[pkg-java] r10122 - in branches/upstream: . swt-gtk swt-gtk/current swt-gtk/current/about_files swt-gtk/current/org swt-gtk/current/org/eclipse swt-gtk/current/org/eclipse/swt swt-gtk/current/org/eclipse/swt/accessibility swt-gtk/current/org/eclipse/swt/awt swt-gtk/current/org/eclipse/swt/browser swt-gtk/current/org/eclipse/swt/custom swt-gtk/current/org/eclipse/swt/dnd swt-gtk/current/org/eclipse/swt/events swt-gtk/current/org/eclipse/swt/graphics swt-gtk/current/org/eclipse/swt/internal swt-gtk/current/org/eclipse/swt/internal/accessibility swt-gtk/current/org/eclipse/swt/internal/accessibility/gtk swt-gtk/current/org/eclipse/swt/internal/cairo swt-gtk/current/org/eclipse/swt/internal/cde swt-gtk/current/org/eclipse/swt/internal/gnome swt-gtk/current/org/eclipse/swt/internal/gtk swt-gtk/current/org/eclipse/swt/internal/image swt-gtk/current/org/eclipse/swt/internal/mozilla swt-gtk/current/org/eclipse/swt/internal/opengl swt-gtk/current/org/eclipse/swt/internal/opengl/glx swt-gtk/current/org/eclipse/swt/internal/theme swt-gtk/current/org/eclipse/swt/layout swt-gtk/current/org/eclipse/swt/opengl swt-gtk/current/org/eclipse/swt/printing swt-gtk/current/org/eclipse/swt/program swt-gtk/current/org/eclipse/swt/widgets

Adrian Perez adrianperez-guest at alioth.debian.org
Tue Aug 18 13:26:39 UTC 2009


Author: adrianperez-guest
Date: 2009-08-18 13:26:39 +0000 (Tue, 18 Aug 2009)
New Revision: 10122

Added:
   branches/upstream/swt-gtk/
   branches/upstream/swt-gtk/current/
   branches/upstream/swt-gtk/current/about.html
   branches/upstream/swt-gtk/current/about_files/
   branches/upstream/swt-gtk/current/about_files/IJG_README
   branches/upstream/swt-gtk/current/about_files/about_cairo.html
   branches/upstream/swt-gtk/current/about_files/lgpl-v21.txt
   branches/upstream/swt-gtk/current/about_files/mpl-v11.txt
   branches/upstream/swt-gtk/current/about_files/pixman-licenses.txt
   branches/upstream/swt-gtk/current/atk.c
   branches/upstream/swt-gtk/current/atk.h
   branches/upstream/swt-gtk/current/atk_custom.c
   branches/upstream/swt-gtk/current/atk_custom.h
   branches/upstream/swt-gtk/current/atk_stats.c
   branches/upstream/swt-gtk/current/atk_stats.h
   branches/upstream/swt-gtk/current/atk_structs.c
   branches/upstream/swt-gtk/current/atk_structs.h
   branches/upstream/swt-gtk/current/build.sh
   branches/upstream/swt-gtk/current/build.xml
   branches/upstream/swt-gtk/current/c.c
   branches/upstream/swt-gtk/current/c.h
   branches/upstream/swt-gtk/current/c_stats.c
   branches/upstream/swt-gtk/current/c_stats.h
   branches/upstream/swt-gtk/current/c_structs.c
   branches/upstream/swt-gtk/current/c_structs.h
   branches/upstream/swt-gtk/current/cairo.c
   branches/upstream/swt-gtk/current/cairo.h
   branches/upstream/swt-gtk/current/cairo_custom.h
   branches/upstream/swt-gtk/current/cairo_stats.c
   branches/upstream/swt-gtk/current/cairo_stats.h
   branches/upstream/swt-gtk/current/cairo_structs.c
   branches/upstream/swt-gtk/current/cairo_structs.h
   branches/upstream/swt-gtk/current/callback.c
   branches/upstream/swt-gtk/current/callback.h
   branches/upstream/swt-gtk/current/cde.c
   branches/upstream/swt-gtk/current/cde.h
   branches/upstream/swt-gtk/current/cde_stats.c
   branches/upstream/swt-gtk/current/cde_stats.h
   branches/upstream/swt-gtk/current/cde_structs.c
   branches/upstream/swt-gtk/current/cde_structs.h
   branches/upstream/swt-gtk/current/glx.c
   branches/upstream/swt-gtk/current/glx.h
   branches/upstream/swt-gtk/current/glx_stats.c
   branches/upstream/swt-gtk/current/glx_stats.h
   branches/upstream/swt-gtk/current/glx_structs.c
   branches/upstream/swt-gtk/current/glx_structs.h
   branches/upstream/swt-gtk/current/gnome.c
   branches/upstream/swt-gtk/current/gnome.h
   branches/upstream/swt-gtk/current/gnome_stats.c
   branches/upstream/swt-gtk/current/gnome_stats.h
   branches/upstream/swt-gtk/current/gnome_structs.c
   branches/upstream/swt-gtk/current/gnome_structs.h
   branches/upstream/swt-gtk/current/make_common.mak
   branches/upstream/swt-gtk/current/make_freebsd.mak
   branches/upstream/swt-gtk/current/make_linux.mak
   branches/upstream/swt-gtk/current/make_solaris.mak
   branches/upstream/swt-gtk/current/mozilla_exports
   branches/upstream/swt-gtk/current/org/
   branches/upstream/swt-gtk/current/org/eclipse/
   branches/upstream/swt-gtk/current/org/eclipse/swt/
   branches/upstream/swt-gtk/current/org/eclipse/swt/SWT.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/SWTError.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/SWTException.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/accessibility/
   branches/upstream/swt-gtk/current/org/eclipse/swt/accessibility/ACC.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/accessibility/Accessible.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/accessibility/AccessibleAdapter.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/accessibility/AccessibleControlAdapter.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/accessibility/AccessibleControlEvent.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/accessibility/AccessibleControlListener.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/accessibility/AccessibleEvent.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/accessibility/AccessibleFactory.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/accessibility/AccessibleListener.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/accessibility/AccessibleObject.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/accessibility/AccessibleTextAdapter.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/accessibility/AccessibleTextEvent.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/accessibility/AccessibleTextListener.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/awt/
   branches/upstream/swt-gtk/current/org/eclipse/swt/awt/SWT_AWT.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/browser/
   branches/upstream/swt-gtk/current/org/eclipse/swt/browser/AppFileLocProvider.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/browser/Browser.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/browser/CloseWindowListener.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/browser/Download.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/browser/DownloadFactory.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/browser/DownloadFactory_1_8.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/browser/Download_1_8.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/browser/FilePicker.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/browser/FilePickerFactory.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/browser/FilePickerFactory_1_8.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/browser/FilePicker_1_8.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/browser/HelperAppLauncherDialog.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/browser/HelperAppLauncherDialogFactory.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/browser/HelperAppLauncherDialog_1_9.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/browser/InputStream.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/browser/LocationAdapter.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/browser/LocationEvent.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/browser/LocationListener.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/browser/Mozilla.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/browser/MozillaDelegate.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/browser/OpenWindowListener.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/browser/ProgressAdapter.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/browser/ProgressEvent.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/browser/ProgressListener.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/browser/PromptDialog.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/browser/PromptService2.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/browser/PromptService2Factory.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/browser/SimpleEnumerator.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/browser/StatusTextEvent.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/browser/StatusTextListener.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/browser/TitleEvent.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/browser/TitleListener.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/browser/VisibilityWindowAdapter.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/browser/VisibilityWindowListener.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/browser/WebBrowser.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/browser/WindowCreator2.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/browser/WindowEvent.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/custom/
   branches/upstream/swt-gtk/current/org/eclipse/swt/custom/AnimatedProgress.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/custom/BidiSegmentEvent.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/custom/BidiSegmentListener.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/custom/Bullet.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/custom/BusyIndicator.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/custom/CBanner.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/custom/CBannerLayout.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/custom/CCombo.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/custom/CLabel.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/custom/CLayoutData.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/custom/CTabFolder.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/custom/CTabFolder2Adapter.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/custom/CTabFolder2Listener.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/custom/CTabFolderAdapter.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/custom/CTabFolderEvent.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/custom/CTabFolderLayout.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/custom/CTabFolderListener.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/custom/CTabItem.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/custom/ControlEditor.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/custom/DefaultContent.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/custom/ExtendedModifyEvent.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/custom/ExtendedModifyListener.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/custom/LineBackgroundEvent.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/custom/LineBackgroundListener.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/custom/LineStyleEvent.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/custom/LineStyleListener.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/custom/MovementEvent.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/custom/MovementListener.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/custom/PaintObjectEvent.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/custom/PaintObjectListener.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/custom/PopupList.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/custom/ST.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/custom/SashForm.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/custom/SashFormData.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/custom/SashFormLayout.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/custom/ScrolledComposite.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/custom/ScrolledCompositeLayout.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/custom/StackLayout.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/custom/StyleRange.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/custom/StyledText.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/custom/StyledTextContent.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/custom/StyledTextDropTargetEffect.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/custom/StyledTextEvent.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/custom/StyledTextListener.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/custom/StyledTextPrintOptions.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/custom/StyledTextRenderer.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/custom/TableCursor.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/custom/TableEditor.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/custom/TableTree.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/custom/TableTreeEditor.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/custom/TableTreeItem.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/custom/TextChangeListener.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/custom/TextChangedEvent.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/custom/TextChangingEvent.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/custom/TreeEditor.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/custom/VerifyKeyListener.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/custom/ViewForm.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/custom/ViewFormLayout.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/
   branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/ByteArrayTransfer.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/Clipboard.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/ClipboardProxy.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/DND.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/DNDEvent.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/DNDListener.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/DragSource.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/DragSourceAdapter.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/DragSourceEffect.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/DragSourceEvent.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/DragSourceListener.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/DropTarget.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/DropTargetAdapter.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/DropTargetEffect.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/DropTargetEvent.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/DropTargetListener.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/FileTransfer.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/HTMLTransfer.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/ImageTransfer.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/RTFTransfer.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/TableDragSourceEffect.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/TableDropTargetEffect.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/TextTransfer.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/Transfer.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/TransferData.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/TreeDragSourceEffect.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/TreeDropTargetEffect.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/URLTransfer.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/events/
   branches/upstream/swt-gtk/current/org/eclipse/swt/events/ArmEvent.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/events/ArmListener.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/events/ControlAdapter.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/events/ControlEvent.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/events/ControlListener.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/events/DisposeEvent.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/events/DisposeListener.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/events/DragDetectEvent.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/events/DragDetectListener.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/events/ExpandAdapter.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/events/ExpandEvent.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/events/ExpandListener.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/events/FocusAdapter.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/events/FocusEvent.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/events/FocusListener.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/events/HelpEvent.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/events/HelpListener.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/events/KeyAdapter.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/events/KeyEvent.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/events/KeyListener.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/events/MenuAdapter.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/events/MenuDetectEvent.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/events/MenuDetectListener.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/events/MenuEvent.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/events/MenuListener.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/events/ModifyEvent.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/events/ModifyListener.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/events/MouseAdapter.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/events/MouseEvent.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/events/MouseListener.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/events/MouseMoveListener.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/events/MouseTrackAdapter.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/events/MouseTrackListener.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/events/MouseWheelListener.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/events/PaintEvent.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/events/PaintListener.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/events/SelectionAdapter.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/events/SelectionEvent.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/events/SelectionListener.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/events/ShellAdapter.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/events/ShellEvent.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/events/ShellListener.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/events/TraverseEvent.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/events/TraverseListener.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/events/TreeAdapter.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/events/TreeEvent.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/events/TreeListener.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/events/TypedEvent.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/events/VerifyEvent.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/events/VerifyListener.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/
   branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/Color.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/Cursor.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/Device.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/DeviceData.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/Drawable.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/Font.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/FontData.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/FontMetrics.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/GC.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/GCData.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/GlyphMetrics.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/Image.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/ImageData.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/ImageDataLoader.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/ImageLoader.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/ImageLoaderEvent.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/ImageLoaderListener.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/LineAttributes.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/PaletteData.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/Path.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/PathData.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/Pattern.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/Point.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/RGB.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/Rectangle.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/Region.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/Resource.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/TextLayout.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/TextStyle.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/Transform.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/BidiUtil.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/C.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/Callback.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/CloneableCompatibility.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/Compatibility.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/Converter.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/LONG.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/Library.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/Lock.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/Platform.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/SWTEventListener.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/SWTEventObject.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/SWTMessages.properties
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/SerializableCompatibility.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/accessibility/
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/accessibility/gtk/
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/accessibility/gtk/ATK.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/accessibility/gtk/AtkActionIface.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/accessibility/gtk/AtkComponentIface.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/accessibility/gtk/AtkHypertextIface.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/accessibility/gtk/AtkObjectClass.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/accessibility/gtk/AtkObjectFactoryClass.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/accessibility/gtk/AtkSelectionIface.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/accessibility/gtk/AtkTextIface.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/accessibility/gtk/GtkAccessible.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/cairo/
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/cairo/Cairo.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/cairo/cairo_font_extents_t.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/cairo/cairo_path_data_t.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/cairo/cairo_path_t.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/cairo/cairo_text_extents_t.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/cde/
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/cde/CDE.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/cde/DtActionArg.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gnome/
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gnome/GNOME.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gnome/GnomeVFSMimeApplication.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GInterfaceInfo.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GObjectClass.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GTypeInfo.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GTypeQuery.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GdkColor.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GdkDragContext.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GdkEvent.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GdkEventAny.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GdkEventButton.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GdkEventCrossing.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GdkEventExpose.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GdkEventFocus.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GdkEventKey.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GdkEventMotion.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GdkEventScroll.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GdkEventVisibility.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GdkEventWindowState.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GdkGCValues.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GdkGeometry.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GdkImage.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GdkRectangle.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GdkVisual.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GdkWindowAttr.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GtkAdjustment.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GtkAllocation.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GtkBorder.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GtkCellRendererClass.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GtkColorSelectionDialog.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GtkCombo.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GtkFileSelection.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GtkFixed.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GtkRequisition.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GtkSelectionData.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GtkTargetEntry.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GtkTargetPair.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GtkWidgetClass.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/OS.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/PangoAttrColor.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/PangoAttrInt.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/PangoAttribute.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/PangoItem.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/PangoLayoutLine.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/PangoLayoutRun.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/PangoLogAttr.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/PangoRectangle.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/XAnyEvent.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/XButtonEvent.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/XClientMessageEvent.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/XCrossingEvent.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/XEvent.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/XExposeEvent.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/XFocusChangeEvent.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/XRenderPictureAttributes.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/XVisibilityEvent.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/XWindowChanges.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/FileFormat.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/GIFFileFormat.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/JPEGAppn.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/JPEGArithmeticConditioningTable.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/JPEGComment.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/JPEGDecoder.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/JPEGEndOfImage.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/JPEGFileFormat.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/JPEGFixedSizeSegment.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/JPEGFrameHeader.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/JPEGHuffmanTable.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/JPEGQuantizationTable.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/JPEGRestartInterval.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/JPEGScanHeader.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/JPEGSegment.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/JPEGStartOfImage.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/JPEGVariableSizeSegment.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/LEDataInputStream.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/LEDataOutputStream.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/LZWCodec.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/LZWNode.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/OS2BMPFileFormat.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/PNGFileFormat.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/PngChunk.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/PngChunkReader.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/PngDecodingDataStream.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/PngDeflater.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/PngEncoder.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/PngFileReadState.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/PngHuffmanTable.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/PngHuffmanTables.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/PngIdatChunk.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/PngIendChunk.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/PngIhdrChunk.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/PngInputStream.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/PngLzBlockReader.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/PngPlteChunk.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/PngTrnsChunk.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/TIFFDirectory.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/TIFFFileFormat.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/TIFFModifiedHuffmanCodec.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/TIFFRandomFileAccess.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/WinBMPFileFormat.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/WinICOFileFormat.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/GREVersionRange.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/XPCOM.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/XPCOMInit.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/XPCOMObject.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsEmbedString.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIAppShell.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIAuthInformation.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIBaseWindow.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsICancelable.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsICategoryManager.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIChannel.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIComponentManager.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIComponentRegistrar.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIContextMenuListener.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsICookie.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsICookieManager.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsID.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIDOMEvent.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIDOMEventTarget.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIDOMKeyEvent.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIDOMMouseEvent.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIDOMSerializer.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIDOMSerializer_1_7.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIDOMUIEvent.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIDOMWindow.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIDOMWindowCollection.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIDirectoryService.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIDirectoryServiceProvider.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIDirectoryServiceProvider2.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIDocShell.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIDocShell_1_8.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIDocShell_1_9.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIDownload.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIDownload_1_8.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIEmbeddingSiteWindow.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIFactory.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIFile.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIFilePicker.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIFilePicker_1_8.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIHelperAppLauncher.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIHelperAppLauncherDialog.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIHelperAppLauncherDialog_1_9.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIHelperAppLauncher_1_8.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIHelperAppLauncher_1_9.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIIOService.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIInputStream.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIInterfaceRequestor.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIJSContextStack.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsILocalFile.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIMemory.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIObserverService.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIPrefBranch.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIPrefLocalizedString.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIPrefService.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIProgressDialog.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIProgressDialog_1_8.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIPromptService.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIPromptService2.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIProperties.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIRequest.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIServiceManager.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsISimpleEnumerator.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsISupports.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsISupportsWeakReference.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsITooltipListener.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsITransfer.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIURI.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIURIContentListener.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIWeakReference.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIWebBrowser.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIWebBrowserChrome.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIWebBrowserChromeFocus.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIWebBrowserFocus.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIWebNavigation.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIWebNavigationInfo.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIWebProgress.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIWebProgressListener.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIWebProgressListener2.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIWindowCreator.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIWindowCreator2.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIWindowWatcher.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/opengl/
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/opengl/glx/
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/opengl/glx/GLX.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/opengl/glx/XVisualInfo.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/theme/
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/theme/ButtonDrawData.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/theme/ComboDrawData.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/theme/DrawData.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/theme/ExpanderDrawData.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/theme/GroupDrawData.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/theme/ProgressBarDrawData.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/theme/RangeDrawData.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/theme/ScaleDrawData.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/theme/ScrollBarDrawData.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/theme/TabFolderDrawData.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/theme/TabItemDrawData.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/theme/Theme.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/theme/ToolBarDrawData.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/internal/theme/ToolItemDrawData.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/layout/
   branches/upstream/swt-gtk/current/org/eclipse/swt/layout/FillData.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/layout/FillLayout.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/layout/FormAttachment.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/layout/FormData.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/layout/FormLayout.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/layout/GridData.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/layout/GridLayout.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/layout/RowData.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/layout/RowLayout.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/opengl/
   branches/upstream/swt-gtk/current/org/eclipse/swt/opengl/GLCanvas.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/opengl/GLData.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/printing/
   branches/upstream/swt-gtk/current/org/eclipse/swt/printing/PrintDialog.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/printing/Printer.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/printing/PrinterData.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/program/
   branches/upstream/swt-gtk/current/org/eclipse/swt/program/Program.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/
   branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Button.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Canvas.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Caret.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/ColorDialog.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Combo.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Composite.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Control.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/CoolBar.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/CoolItem.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/DateTime.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Decorations.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Dialog.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/DirectoryDialog.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Display.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Event.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/EventTable.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/ExpandBar.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/ExpandItem.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/FileDialog.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/FontDialog.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Group.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/IME.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/ImageList.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Item.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Label.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Layout.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Link.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/List.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Listener.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Menu.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/MenuItem.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/MessageBox.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Monitor.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/ProgressBar.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/RunnableLock.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Sash.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Scale.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/ScrollBar.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Scrollable.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Shell.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Slider.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Spinner.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Synchronizer.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/TabFolder.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/TabItem.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Table.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/TableColumn.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/TableItem.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Text.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/ToolBar.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/ToolItem.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/ToolTip.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Tracker.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Tray.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/TrayItem.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Tree.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/TreeColumn.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/TreeItem.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/TypedListener.java
   branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Widget.java
   branches/upstream/swt-gtk/current/os.c
   branches/upstream/swt-gtk/current/os.h
   branches/upstream/swt-gtk/current/os_custom.c
   branches/upstream/swt-gtk/current/os_custom.h
   branches/upstream/swt-gtk/current/os_stats.c
   branches/upstream/swt-gtk/current/os_stats.h
   branches/upstream/swt-gtk/current/os_structs.c
   branches/upstream/swt-gtk/current/os_structs.h
   branches/upstream/swt-gtk/current/swt.c
   branches/upstream/swt-gtk/current/swt.h
   branches/upstream/swt-gtk/current/swt_awt.c
   branches/upstream/swt-gtk/current/swt_xpcom.rc
   branches/upstream/swt-gtk/current/version.txt
   branches/upstream/swt-gtk/current/xpcom.cpp
   branches/upstream/swt-gtk/current/xpcom.h
   branches/upstream/swt-gtk/current/xpcom_custom.cpp
   branches/upstream/swt-gtk/current/xpcom_stats.cpp
   branches/upstream/swt-gtk/current/xpcom_stats.h
   branches/upstream/swt-gtk/current/xpcom_structs.cpp
   branches/upstream/swt-gtk/current/xpcom_structs.h
   branches/upstream/swt-gtk/current/xpcominit.cpp
   branches/upstream/swt-gtk/current/xpcominit.h
   branches/upstream/swt-gtk/current/xpcominit_stats.cpp
   branches/upstream/swt-gtk/current/xpcominit_stats.h
   branches/upstream/swt-gtk/current/xpcominit_structs.cpp
   branches/upstream/swt-gtk/current/xpcominit_structs.h
Log:
[svn-inject] Installing original source of swt-gtk

Added: branches/upstream/swt-gtk/current/about.html
===================================================================
--- branches/upstream/swt-gtk/current/about.html	                        (rev 0)
+++ branches/upstream/swt-gtk/current/about.html	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,250 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
+<title>About</title>
+</head>
+<body lang="EN-US">
+<h2>About This Content</h2>
+ 
+<p>August 17, 2006</p>	
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;).  Unless otherwise 
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 (&quot;EPL&quot;).  A copy of the EPL is available 
+at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
+
+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is 
+being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
+apply to your use of any object code in the Content.  Check the Redistributor's license that was 
+provided with the Content.  If no such license exists, contact the Redistributor.  Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at <a href="http://www.eclipse.org">http://www.eclipse.org</a>.</p>
+
+<h3>Third Party Content</h3>
+
+<p>The Content includes items that have been sourced from third parties as set out below. If you 
+did not receive this Content directly from the Eclipse Foundation, the following is provided 
+for informational purposes only, and you should look to the Redistributor&rsquo;s license for 
+terms and conditions of use.</p>
+
+<h4>Gnome Binding</h4>
+
+<p>The &quot;Gnome Binding&quot; is a binding to the Gnome API.  The Content may include any or all of the following files:</p>
+
+<p>The following files in the plug-in JAR shall be defined as the native code portion of the Gnome Binding:</p>
+<ul>
+	<li>libswt-gnome-gtk-xxxx.so (where &quot;xxxx&quot; is the version number)</li>
+</ul>
+
+<p>The following files in both the plug-in JAR and the src.zip shall be defined respectively as the bytecode and source code portions of the Gnome Binding:</p>
+<ul>
+	<li>The contents of the directory org/eclipse/swt/internal/gnome (but not including any sub-directories)</li>
+</ul>
+
+<p>The Gnome Binding contains portions of Gnome (&quot;Library&quot;).  Gnome is made available by The Free Software Foundation.  Use of the Library is governed by the terms and
+conditions of the GNU Lesser General Public License Version 2.1 (&quot;LGPL&quot;).  Use of the Gnome Binding on a standalone
+basis, is also governed by the terms and conditions of the LGPL.  A copy of the LGPL is provided with the Content (<a href="about_files/lgpl-v21.txt" target="_blank">lgpl-v21.txt</a>) and is also available at
+<a href="http://www.gnu.org/licenses/lgpl.html" target="_blank">http://www.gnu.org/licenses/lgpl.html</a>.</p>
+
+<p>In accordance with Section 6 of the LGPL, you may combine or link a "work that uses the Library" (e.g. the SWT) with the Library to produce a work
+containing portions of the Library (e.g. the Gnome Binding) and distribute that work under the terms of your choice (e.g. the EPL) provided you comply with all
+other terms and conditions of Section 6 as well as other Sections of the LGPL.  Please note, if you modify the Gnome Binding such modifications shall be
+governed by the terms and conditions of the LGPL.  Also note, the terms of the EPL permit you to modify the combined work and the source code of the combined
+work is provided for debugging purposes so there is no need to reverse engineer the combined work.</p>
+
+<h4>GTK+ Binding</h4>
+
+<p>The &quot;GTK+ Binding&quot; is a binding to the GTK+ API.  The Content may include any or all of the following files:</p>
+
+<p>The following files in the plug-in JAR shall be defined as the native code portion of the GTK+ Binding:</p>
+<ul>
+	<li>libswt-atk-gtk-xxxx.so (where &quot;xxxx&quot; is the version number)</li>
+	<li>libswt-pi-gtk-xxxx.so (where &quot;xxxx&quot; is the version number)</li>
+</ul>
+
+<p>The following files in both the plug-in JAR and the src.zip shall be defined respectively as the bytecode and source code portions of the GTK+ Binding:</p>
+<ul>
+	<li>The contents of the directory org/eclipse/swt/internal/accessibility/gtk (but not including any sub-directories)</li>
+	<li>The contents of the directory org/eclipse/swt/internal/cde (but not including any sub-directories)</li>
+	<li>The contents of the directory org/eclipse/swt/internal/gtk (but not including any sub-directories)</li>
+	<li>The contents of the directory org/eclipse/swt/internal/kde (but not including any sub-directories)</li>				
+</ul>
+
+<p>The GTK+ Binding contains portions of GTK+ (&quot;Library&quot;).  GTK+ is made available by The Free Software Foundation.  Use of the Library is governed by the terms and
+conditions of the GNU Lesser General Public License Version 2.1 (&quot;LGPL&quot;).  Use of the GTK+ Binding on a standalone
+basis, is also governed by the terms and conditions of the LGPL.  A copy of the LGPL is provided with the Content (<a href="about_files/lgpl-v21.txt" target="_blank">lgpl-v21.txt</a>) and is also available at
+<a href="http://www.gnu.org/licenses/lgpl.html" target="_blank">http://www.gnu.org/licenses/lgpl.html</a>.</p>
+
+<p>In accordance with Section 6 of the LGPL, you may combine or link a "work that uses the Library" (e.g. the SWT) with the Library to produce a work
+containing portions of the Library (e.g. the GTK+ Binding) and distribute that work under the terms of your choice (e.g. the EPL) provided you comply with all
+other terms and conditions of Section 6 as well as other Sections of the LGPL.  Please note, if you modify the GTK+ Binding such modifications shall be
+governed by the terms and conditions of the LGPL.  Also note, the terms of the EPL permit you to modify the combined work and the source code of the combined
+work is provided for debugging purposes so there is no need to reverse engineer the combined work.</p>
+
+<h4>Mozilla Binding</h4>
+
+<p>The &quot;Mozilla Binding&quot; is a binding to the Mozilla API.  The Content may include any or all of the following files:</p>
+
+<p>The following files in the plug-in JAR shall be defined as the native code portion of the Mozilla Binding:</p>
+<ul>
+	<li>libswt-mozilla-gtk-xxxx.so (where &quot;xxxx&quot; is the version number)</li>
+	<li>libswt-mozilla-gcc3-gtk-xxxx.so (where &quot;xxxx&quot; is the version number)</li>
+	<li>libswt-xulrunner-gtk-xxxx.so (where &quot;xxxx&quot; is the version number)</li>
+	<li>libswt-xpcominit-gtk-xxxx.so (where &quot;xxxx&quot; is the version number)</li>
+</ul>
+
+<p>The following files in both the plug-in JAR and the src.zip shall be defined respectively as the bytecode and source code portions of the Mozilla Binding:</p>
+<ul>
+	<li>The contents of the directory org/eclipse/swt/internal/mozilla (but not including any sub-directories)</li>
+</ul>
+
+<p>The Mozilla Binding contains portions of Mozilla (&quot;Mozilla&quot;).  Mozilla is made available by Mozilla.org.  Use of Mozilla is governed by the terms and
+conditions of the Mozilla Public License Version 1.1 (&quot;MPL&quot;).  A copy of the MPL is provided with the Content (<a href="about_files/mpl-v11.txt" target="_blank">mpl-v11.txt</a>) and is also available at
+<a href="http://www.mozilla.org/MPL/MPL-1.1.html" target="_blank">http://www.mozilla.org/MPL/MPL-1.1.html</a>.</p>
+
+<h4>Cairo Binding</h4>
+
+<p>The &quot;Cairo Binding&quot; is a binding to the Cairo API.  The Content may include any or all of the following files:</p>
+
+<p>The following files in the plug-in JAR shall be defined as the native code portion of the Cairo Binding:</p>
+<ul>
+	<li>libswt-cairo-gtk-xxxx.so (where &quot;xxxx&quot; is the version number)</li>
+</ul>
+
+<p>The following files in both the plug-in JAR and the src.zip shall be defined respectively as the bytecode and source code portions of the Cairo Binding:</p>
+<ul>
+	<li>The contents of the directory org/eclipse/swt/internal/cairo (but not including any sub-directories)</li>
+</ul>
+
+<p>The Cairo Binding contains portions of Cairo (&quot;Cairo&quot;).  Cairo is made available by the Cairo project at
+<a href="http://www.cairographics.org" target="_blank">http://www.cairographics.org</a>.  Use of Cairo by the Cairo Binding is governed by the terms and
+conditions of the Mozilla Public License Version 1.1 (&quot;MPL&quot;).  A copy of the MPL is
+provided with the Content (<a href="about_files/mpl-v11.txt" target="_blank">mpl-v11.txt</a>) and is also available at <a href="http://www.mozilla.org/MPL/MPL-1.1.html">http://www.mozilla.org/MPL/MPL-1.1.html</a>.</p>
+
+<h4>Cairo for Linux</h4>
+
+<p>Refer to the file <a href="about_files/about_cairo.html">about_files/about_cairo.html</a> for licensing details about &quot;Cairo for Linux.&quot;
+
+<h4>Independent JPEG Group's JPEG software release 6b</h4>
+
+<p>This software is based in part on the work of the Independent JPEG Group's JPEG software release 6b (&quot;LIBJPEG&quot;).
+LIBJPEG was used to implement the decoding of JPEG format files in Java (TM).  The Content does NOT include any portion of the LIBJPEG file ansi2knr.c.</p>
+
+<p>Your use of LIBJPEG is subject to the terms and conditions located in the <a href="about_files/IJG_README">about_files/IJG_README</a> file which is included
+with the Content.</p>
+
+<p>The IJG's website is located at <a href="http://ijg.org/" target="_blank">http://ijg.org</a>.</p>
+
+<p>The class org.eclipse.swt.internal.image.JPEGFileFormat is based on following files from LIBJPEG:</p>
+
+<ul>
+    <li>cderror.h</li>
+    <li>cdjpeg.h</li>
+    <li>jchuff.h</li>
+    <li>jdcolor.c</li>
+    <li>jdct.h</li>
+    <li>jdhuff.h</li>
+    <li>jerror.h</li>
+    <li>jidctint.c</li>
+    <li>jinclude.h</li>
+    <li>jmemsys.h</li>
+    <li>jmorecfg.h</li>
+    <li>jpegint.h</li>
+    <li>jpeglib.h</li>
+    <li>jversion.h</li>
+    <li>transupp.h</li>
+</ul>
+
+<p>The class org.eclipse.swt.internal.image.JPEGDecoder is based on the following files from LIBJPEG:</p>
+
+<ul>
+	<li>jcapimin.c</li>
+	<li>jcapistd.c</li>
+	<li>jccoefct.c</li>
+	<li>jccolor.c</li>
+	<li>jcdctmgr.c</li>
+	<li>jchuff.c</li>
+	<li>jcinit.c</li>
+	<li>jcmainct.c</li>
+	<li>jcmarker.c</li>
+	<li>jcmaster.c</li>
+	<li>jcomapi.c</li>
+	<li>jcparam.c</li>
+	<li>jcphuff.c</li>
+	<li>jcprepct.c</li>
+	<li>jcsample.c</li>
+	<li>jctrans.c</li>
+	<li>jdapimin.c</li>
+	<li>jdapistd.c</li>
+	<li>jdatadst.c</li>
+	<li>jdatasrc.c</li>
+	<li>jdcoefct.c</li>
+	<li>jdcolor.c</li>
+	<li>jddctmgr.c</li>
+	<li>jdhuff.c</li>
+	<li>jdinput.c</li>
+	<li>jdmainct.c</li>
+	<li>jdmarker.c</li>
+	<li>jdmaster.c</li>
+	<li>jdmerge.c</li>
+	<li>jdphuff.c</li>
+	<li>jdpostct.c</li>
+	<li>jdsample.c</li>
+	<li>jdtrans.c</li>
+	<li>jerror.c</li>
+	<li>jfdctflt.c</li>
+	<li>jfdctfst.c</li>
+	<li>jfdctint.c</li>
+	<li>jidctflt.c</li>
+	<li>jidctfst.c</li>
+	<li>jidctint.c</li>
+	<li>jidctred.c</li>
+	<li>jpegtran.c</li>
+	<li>jquant1.c</li>
+	<li>jquant2.c</li>
+	<li>jutils.c</li>
+	<li>cderror.h</li>
+	<li>cdjpeg.h</li>
+	<li>jchuff.h</li>
+	<li>jconfig.h</li>
+	<li>jdct.h</li>
+	<li>jdhuff.h</li>
+	<li>jerror.h</li>
+	<li>jinclude.h</li>
+	<li>jmorecfg.h</li>
+	<li>jpegint.h</li>
+	<li>jpeglib.h</li>
+	<li>jversion.h</li>
+	<li>transupp.h</li>
+</ul>
+	
+<p>The following changes were made to the LIBJPEG code in the Content:</p>
+
+<ol>
+	<li>In Java, pointer math is not allowed so indexing was used instead.</li>
+	<li>Function pointers were replaced with switch statements.</li>
+	<li>The virtual memory, tracing and progress monitoring were removed.</li>
+	<li>The error handling was simplified and now uses Java exceptions.</li>
+</ol>
+
+<h4>PuTTY 0.58 (derivative work)</h4>
+
+<p>Portions of the SWT class org/eclipse/swt/internal/image/PngDeflater are based on PuTTY's sshzlib.c. PuTTY is made available by Mozilla.org.  Use of PuTTY is governed by the terms and
+conditions of the the following MIT-style license:  </p>
+<blockquote>
+  <p><em>PuTTY is copyright 1997-2007 Simon Tatham.</em> </p>
+  <p><em>Portions copyright Robert de Bath, Joris van Rantwijk, Delian  Delchev, Andreas Schultz, Jeroen Massar, Wez Furlong, Nicolas Barry,  Justin Bradford, Ben Harris, Malcolm Smith, Ahmad Khalifa, Markus Kuhn,  and CORE SDI S.A.</em> </p>
+  <p><em>Permission is hereby granted, free of charge, to any person  obtaining a copy of this software and associated documentation files  (the &quot;Software&quot;), to deal in the Software without restriction,  including without limitation the rights to use, copy, modify, merge,  publish, distribute, sublicense, and/or sell copies of the Software,  and to permit persons to whom the Software is furnished to do so,  subject to the following conditions:</em> </p>
+  <p><em>The above copyright notice and this permission notice shall be  included in all copies or substantial portions of the Software.</em> </p>
+  <p><em>THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND,  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND  NONINFRINGEMENT.  IN NO EVENT SHALL SIMON TATHAM BE LIABLE FOR ANY  CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,  TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE  SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.</em> </p>
+</blockquote>
+<p>A copy of the license is also available at <a href="http://www.chiark.greenend.org.uk/~sgtatham/putty/licence.html" target="_blank">http://www.chiark.greenend.org.uk/~sgtatham/putty/licence.html</a>.</p>
+
+<p><small>Java and all Java-based trademarks and logos are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and other countries.</small></p>
+
+</body>
+</html>
\ No newline at end of file

Added: branches/upstream/swt-gtk/current/about_files/IJG_README
===================================================================
--- branches/upstream/swt-gtk/current/about_files/IJG_README	                        (rev 0)
+++ branches/upstream/swt-gtk/current/about_files/IJG_README	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,385 @@
+The Independent JPEG Group's JPEG software
+==========================================
+
+README for release 6b of 27-Mar-1998
+====================================
+
+This distribution contains the sixth public release of the Independent JPEG
+Group's free JPEG software.  You are welcome to redistribute this software and
+to use it for any purpose, subject to the conditions under LEGAL ISSUES, below.
+
+Serious users of this software (particularly those incorporating it into
+larger programs) should contact IJG at jpeg-info at uunet.uu.net to be added to
+our electronic mailing list.  Mailing list members are notified of updates
+and have a chance to participate in technical discussions, etc.
+
+This software is the work of Tom Lane, Philip Gladstone, Jim Boucher,
+Lee Crocker, Julian Minguillon, Luis Ortiz, George Phillips, Davide Rossi,
+Guido Vollbeding, Ge' Weijers, and other members of the Independent JPEG
+Group.
+
+IJG is not affiliated with the official ISO JPEG standards committee.
+
+
+DOCUMENTATION ROADMAP
+=====================
+
+This file contains the following sections:
+
+OVERVIEW            General description of JPEG and the IJG software.
+LEGAL ISSUES        Copyright, lack of warranty, terms of distribution.
+REFERENCES          Where to learn more about JPEG.
+ARCHIVE LOCATIONS   Where to find newer versions of this software.
+RELATED SOFTWARE    Other stuff you should get.
+FILE FORMAT WARS    Software *not* to get.
+TO DO               Plans for future IJG releases.
+
+Other documentation files in the distribution are:
+
+User documentation:
+  install.doc       How to configure and install the IJG software.
+  usage.doc         Usage instructions for cjpeg, djpeg, jpegtran,
+                    rdjpgcom, and wrjpgcom.
+  *.1               Unix-style man pages for programs (same info as usage.doc).
+  wizard.doc        Advanced usage instructions for JPEG wizards only.
+  change.log        Version-to-version change highlights.
+Programmer and internal documentation:
+  libjpeg.doc       How to use the JPEG library in your own programs.
+  example.c         Sample code for calling the JPEG library.
+  structure.doc     Overview of the JPEG library's internal structure.
+  filelist.doc      Road map of IJG files.
+  coderules.doc     Coding style rules --- please read if you contribute code.
+
+Please read at least the files install.doc and usage.doc.  Useful information
+can also be found in the JPEG FAQ (Frequently Asked Questions) article.  See
+ARCHIVE LOCATIONS below to find out where to obtain the FAQ article.
+
+If you want to understand how the JPEG code works, we suggest reading one or
+more of the REFERENCES, then looking at the documentation files (in roughly
+the order listed) before diving into the code.
+
+
+OVERVIEW
+========
+
+This package contains C software to implement JPEG image compression and
+decompression.  JPEG (pronounced "jay-peg") is a standardized compression
+method for full-color and gray-scale images.  JPEG is intended for compressing
+"real-world" scenes; line drawings, cartoons and other non-realistic images
+are not its strong suit.  JPEG is lossy, meaning that the output image is not
+exactly identical to the input image.  Hence you must not use JPEG if you
+have to have identical output bits.  However, on typical photographic images,
+very good compression levels can be obtained with no visible change, and
+remarkably high compression levels are possible if you can tolerate a
+low-quality image.  For more details, see the references, or just experiment
+with various compression settings.
+
+This software implements JPEG baseline, extended-sequential, and progressive
+compression processes.  Provision is made for supporting all variants of these
+processes, although some uncommon parameter settings aren't implemented yet.
+For legal reasons, we are not distributing code for the arithmetic-coding
+variants of JPEG; see LEGAL ISSUES.  We have made no provision for supporting
+the hierarchical or lossless processes defined in the standard.
+
+We provide a set of library routines for reading and writing JPEG image files,
+plus two sample applications "cjpeg" and "djpeg", which use the library to
+perform conversion between JPEG and some other popular image file formats.
+The library is intended to be reused in other applications.
+
+In order to support file conversion and viewing software, we have included
+considerable functionality beyond the bare JPEG coding/decoding capability;
+for example, the color quantization modules are not strictly part of JPEG
+decoding, but they are essential for output to colormapped file formats or
+colormapped displays.  These extra functions can be compiled out of the
+library if not required for a particular application.  We have also included
+"jpegtran", a utility for lossless transcoding between different JPEG
+processes, and "rdjpgcom" and "wrjpgcom", two simple applications for
+inserting and extracting textual comments in JFIF files.
+
+The emphasis in designing this software has been on achieving portability and
+flexibility, while also making it fast enough to be useful.  In particular,
+the software is not intended to be read as a tutorial on JPEG.  (See the
+REFERENCES section for introductory material.)  Rather, it is intended to
+be reliable, portable, industrial-strength code.  We do not claim to have
+achieved that goal in every aspect of the software, but we strive for it.
+
+We welcome the use of this software as a component of commercial products.
+No royalty is required, but we do ask for an acknowledgement in product
+documentation, as described under LEGAL ISSUES.
+
+
+LEGAL ISSUES
+============
+
+In plain English:
+
+1. We don't promise that this software works.  (But if you find any bugs,
+   please let us know!)
+2. You can use this software for whatever you want.  You don't have to pay us.
+3. You may not pretend that you wrote this software.  If you use it in a
+   program, you must acknowledge somewhere in your documentation that
+   you've used the IJG code.
+
+In legalese:
+
+The authors make NO WARRANTY or representation, either express or implied,
+with respect to this software, its quality, accuracy, merchantability, or
+fitness for a particular purpose.  This software is provided "AS IS", and you,
+its user, assume the entire risk as to its quality and accuracy.
+
+This software is copyright (C) 1991-1998, Thomas G. Lane.
+All Rights Reserved except as specified below.
+
+Permission is hereby granted to use, copy, modify, and distribute this
+software (or portions thereof) for any purpose, without fee, subject to these
+conditions:
+(1) If any part of the source code for this software is distributed, then this
+README file must be included, with this copyright and no-warranty notice
+unaltered; and any additions, deletions, or changes to the original files
+must be clearly indicated in accompanying documentation.
+(2) If only executable code is distributed, then the accompanying
+documentation must state that "this software is based in part on the work of
+the Independent JPEG Group".
+(3) Permission for use of this software is granted only if the user accepts
+full responsibility for any undesirable consequences; the authors accept
+NO LIABILITY for damages of any kind.
+
+These conditions apply to any software derived from or based on the IJG code,
+not just to the unmodified library.  If you use our work, you ought to
+acknowledge us.
+
+Permission is NOT granted for the use of any IJG author's name or company name
+in advertising or publicity relating to this software or products derived from
+it.  This software may be referred to only as "the Independent JPEG Group's
+software".
+
+We specifically permit and encourage the use of this software as the basis of
+commercial products, provided that all warranty or liability claims are
+assumed by the product vendor.
+
+
+ansi2knr.c is included in this distribution by permission of L. Peter Deutsch,
+sole proprietor of its copyright holder, Aladdin Enterprises of Menlo Park, CA.
+ansi2knr.c is NOT covered by the above copyright and conditions, but instead
+by the usual distribution terms of the Free Software Foundation; principally,
+that you must include source code if you redistribute it.  (See the file
+ansi2knr.c for full details.)  However, since ansi2knr.c is not needed as part
+of any program generated from the IJG code, this does not limit you more than
+the foregoing paragraphs do.
+
+The Unix configuration script "configure" was produced with GNU Autoconf.
+It is copyright by the Free Software Foundation but is freely distributable.
+The same holds for its supporting scripts (config.guess, config.sub,
+ltconfig, ltmain.sh).  Another support script, install-sh, is copyright
+by M.I.T. but is also freely distributable.
+
+It appears that the arithmetic coding option of the JPEG spec is covered by
+patents owned by IBM, AT&T, and Mitsubishi.  Hence arithmetic coding cannot
+legally be used without obtaining one or more licenses.  For this reason,
+support for arithmetic coding has been removed from the free JPEG software.
+(Since arithmetic coding provides only a marginal gain over the unpatented
+Huffman mode, it is unlikely that very many implementations will support it.)
+So far as we are aware, there are no patent restrictions on the remaining
+code.
+
+The IJG distribution formerly included code to read and write GIF files.
+To avoid entanglement with the Unisys LZW patent, GIF reading support has
+been removed altogether, and the GIF writer has been simplified to produce
+"uncompressed GIFs".  This technique does not use the LZW algorithm; the
+resulting GIF files are larger than usual, but are readable by all standard
+GIF decoders.
+
+We are required to state that
+    "The Graphics Interchange Format(c) is the Copyright property of
+    CompuServe Incorporated.  GIF(sm) is a Service Mark property of
+    CompuServe Incorporated."
+
+
+REFERENCES
+==========
+
+We highly recommend reading one or more of these references before trying to
+understand the innards of the JPEG software.
+
+The best short technical introduction to the JPEG compression algorithm is
+	Wallace, Gregory K.  "The JPEG Still Picture Compression Standard",
+	Communications of the ACM, April 1991 (vol. 34 no. 4), pp. 30-44.
+(Adjacent articles in that issue discuss MPEG motion picture compression,
+applications of JPEG, and related topics.)  If you don't have the CACM issue
+handy, a PostScript file containing a revised version of Wallace's article is
+available at ftp://ftp.uu.net/graphics/jpeg/wallace.ps.gz.  The file (actually
+a preprint for an article that appeared in IEEE Trans. Consumer Electronics)
+omits the sample images that appeared in CACM, but it includes corrections
+and some added material.  Note: the Wallace article is copyright ACM and IEEE,
+and it may not be used for commercial purposes.
+
+A somewhat less technical, more leisurely introduction to JPEG can be found in
+"The Data Compression Book" by Mark Nelson and Jean-loup Gailly, published by
+M&T Books (New York), 2nd ed. 1996, ISBN 1-55851-434-1.  This book provides
+good explanations and example C code for a multitude of compression methods
+including JPEG.  It is an excellent source if you are comfortable reading C
+code but don't know much about data compression in general.  The book's JPEG
+sample code is far from industrial-strength, but when you are ready to look
+at a full implementation, you've got one here...
+
+The best full description of JPEG is the textbook "JPEG Still Image Data
+Compression Standard" by William B. Pennebaker and Joan L. Mitchell, published
+by Van Nostrand Reinhold, 1993, ISBN 0-442-01272-1.  Price US$59.95, 638 pp.
+The book includes the complete text of the ISO JPEG standards (DIS 10918-1
+and draft DIS 10918-2).  This is by far the most complete exposition of JPEG
+in existence, and we highly recommend it.
+
+The JPEG standard itself is not available electronically; you must order a
+paper copy through ISO or ITU.  (Unless you feel a need to own a certified
+official copy, we recommend buying the Pennebaker and Mitchell book instead;
+it's much cheaper and includes a great deal of useful explanatory material.)
+In the USA, copies of the standard may be ordered from ANSI Sales at (212)
+642-4900, or from Global Engineering Documents at (800) 854-7179.  (ANSI
+doesn't take credit card orders, but Global does.)  It's not cheap: as of
+1992, ANSI was charging $95 for Part 1 and $47 for Part 2, plus 7%
+shipping/handling.  The standard is divided into two parts, Part 1 being the
+actual specification, while Part 2 covers compliance testing methods.  Part 1
+is titled "Digital Compression and Coding of Continuous-tone Still Images,
+Part 1: Requirements and guidelines" and has document numbers ISO/IEC IS
+10918-1, ITU-T T.81.  Part 2 is titled "Digital Compression and Coding of
+Continuous-tone Still Images, Part 2: Compliance testing" and has document
+numbers ISO/IEC IS 10918-2, ITU-T T.83.
+
+Some extensions to the original JPEG standard are defined in JPEG Part 3,
+a newer ISO standard numbered ISO/IEC IS 10918-3 and ITU-T T.84.  IJG
+currently does not support any Part 3 extensions.
+
+The JPEG standard does not specify all details of an interchangeable file
+format.  For the omitted details we follow the "JFIF" conventions, revision
+1.02.  A copy of the JFIF spec is available from:
+	Literature Department
+	C-Cube Microsystems, Inc.
+	1778 McCarthy Blvd.
+	Milpitas, CA 95035
+	phone (408) 944-6300,  fax (408) 944-6314
+A PostScript version of this document is available by FTP at
+ftp://ftp.uu.net/graphics/jpeg/jfif.ps.gz.  There is also a plain text
+version at ftp://ftp.uu.net/graphics/jpeg/jfif.txt.gz, but it is missing
+the figures.
+
+The TIFF 6.0 file format specification can be obtained by FTP from
+ftp://ftp.sgi.com/graphics/tiff/TIFF6.ps.gz.  The JPEG incorporation scheme
+found in the TIFF 6.0 spec of 3-June-92 has a number of serious problems.
+IJG does not recommend use of the TIFF 6.0 design (TIFF Compression tag 6).
+Instead, we recommend the JPEG design proposed by TIFF Technical Note #2
+(Compression tag 7).  Copies of this Note can be obtained from ftp.sgi.com or
+from ftp://ftp.uu.net/graphics/jpeg/.  It is expected that the next revision
+of the TIFF spec will replace the 6.0 JPEG design with the Note's design.
+Although IJG's own code does not support TIFF/JPEG, the free libtiff library
+uses our library to implement TIFF/JPEG per the Note.  libtiff is available
+from ftp://ftp.sgi.com/graphics/tiff/.
+
+
+ARCHIVE LOCATIONS
+=================
+
+The "official" archive site for this software is ftp.uu.net (Internet
+address 192.48.96.9).  The most recent released version can always be found
+there in directory graphics/jpeg.  This particular version will be archived
+as ftp://ftp.uu.net/graphics/jpeg/jpegsrc.v6b.tar.gz.  If you don't have
+direct Internet access, UUNET's archives are also available via UUCP; contact
+help at uunet.uu.net for information on retrieving files that way.
+
+Numerous Internet sites maintain copies of the UUNET files.  However, only
+ftp.uu.net is guaranteed to have the latest official version.
+
+You can also obtain this software in DOS-compatible "zip" archive format from
+the SimTel archives (ftp://ftp.simtel.net/pub/simtelnet/msdos/graphics/), or
+on CompuServe in the Graphics Support forum (GO CIS:GRAPHSUP), library 12
+"JPEG Tools".  Again, these versions may sometimes lag behind the ftp.uu.net
+release.
+
+The JPEG FAQ (Frequently Asked Questions) article is a useful source of
+general information about JPEG.  It is updated constantly and therefore is
+not included in this distribution.  The FAQ is posted every two weeks to
+Usenet newsgroups comp.graphics.misc, news.answers, and other groups.
+It is available on the World Wide Web at http://www.faqs.org/faqs/jpeg-faq/
+and other news.answers archive sites, including the official news.answers
+archive at rtfm.mit.edu: ftp://rtfm.mit.edu/pub/usenet/news.answers/jpeg-faq/.
+If you don't have Web or FTP access, send e-mail to mail-server at rtfm.mit.edu
+with body
+	send usenet/news.answers/jpeg-faq/part1
+	send usenet/news.answers/jpeg-faq/part2
+
+
+RELATED SOFTWARE
+================
+
+Numerous viewing and image manipulation programs now support JPEG.  (Quite a
+few of them use this library to do so.)  The JPEG FAQ described above lists
+some of the more popular free and shareware viewers, and tells where to
+obtain them on Internet.
+
+If you are on a Unix machine, we highly recommend Jef Poskanzer's free
+PBMPLUS software, which provides many useful operations on PPM-format image
+files.  In particular, it can convert PPM images to and from a wide range of
+other formats, thus making cjpeg/djpeg considerably more useful.  The latest
+version is distributed by the NetPBM group, and is available from numerous
+sites, notably ftp://wuarchive.wustl.edu/graphics/graphics/packages/NetPBM/.
+Unfortunately PBMPLUS/NETPBM is not nearly as portable as the IJG software is;
+you are likely to have difficulty making it work on any non-Unix machine.
+
+A different free JPEG implementation, written by the PVRG group at Stanford,
+is available from ftp://havefun.stanford.edu/pub/jpeg/.  This program
+is designed for research and experimentation rather than production use;
+it is slower, harder to use, and less portable than the IJG code, but it
+is easier to read and modify.  Also, the PVRG code supports lossless JPEG,
+which we do not.  (On the other hand, it doesn't do progressive JPEG.)
+
+
+FILE FORMAT WARS
+================
+
+Some JPEG programs produce files that are not compatible with our library.
+The root of the problem is that the ISO JPEG committee failed to specify a
+concrete file format.  Some vendors "filled in the blanks" on their own,
+creating proprietary formats that no one else could read.  (For example, none
+of the early commercial JPEG implementations for the Macintosh were able to
+exchange compressed files.)
+
+The file format we have adopted is called JFIF (see REFERENCES).  This format
+has been agreed to by a number of major commercial JPEG vendors, and it has
+become the de facto standard.  JFIF is a minimal or "low end" representation.
+We recommend the use of TIFF/JPEG (TIFF revision 6.0 as modified by TIFF
+Technical Note #2) for "high end" applications that need to record a lot of
+additional data about an image.  TIFF/JPEG is fairly new and not yet widely
+supported, unfortunately.
+
+The upcoming JPEG Part 3 standard defines a file format called SPIFF.
+SPIFF is interoperable with JFIF, in the sense that most JFIF decoders should
+be able to read the most common variant of SPIFF.  SPIFF has some technical
+advantages over JFIF, but its major claim to fame is simply that it is an
+official standard rather than an informal one.  At this point it is unclear
+whether SPIFF will supersede JFIF or whether JFIF will remain the de-facto
+standard.  IJG intends to support SPIFF once the standard is frozen, but we
+have not decided whether it should become our default output format or not.
+(In any case, our decoder will remain capable of reading JFIF indefinitely.)
+
+Various proprietary file formats incorporating JPEG compression also exist.
+We have little or no sympathy for the existence of these formats.  Indeed,
+one of the original reasons for developing this free software was to help
+force convergence on common, open format standards for JPEG files.  Don't
+use a proprietary file format!
+
+
+TO DO
+=====
+
+The major thrust for v7 will probably be improvement of visual quality.
+The current method for scaling the quantization tables is known not to be
+very good at low Q values.  We also intend to investigate block boundary
+smoothing, "poor man's variable quantization", and other means of improving
+quality-vs-file-size performance without sacrificing compatibility.
+
+In future versions, we are considering supporting some of the upcoming JPEG
+Part 3 extensions --- principally, variable quantization and the SPIFF file
+format.
+
+As always, speeding things up is of great interest.
+
+Please send bug reports, offers of help, etc. to jpeg-info at uunet.uu.net.


Property changes on: branches/upstream/swt-gtk/current/about_files/IJG_README
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/about_files/about_cairo.html
===================================================================
--- branches/upstream/swt-gtk/current/about_files/about_cairo.html	                        (rev 0)
+++ branches/upstream/swt-gtk/current/about_files/about_cairo.html	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,48 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
+<html>
+<head>
+<title>About</title>
+<meta http-equiv=Content-Type content="text/html; charset=ISO-8859-1">
+</head>
+<body lang="EN-US">
+<h2>About This Content</h2>
+ 
+<p>March 27, 2006</p>	
+<h3>License</h3>
+
+<p>The Eclipse Foundation has included the following package for your convenience:</p> 
+
+<h4>Cairo 1.0.2 for Linux</h4>
+
+<p>Cairo for Linux (&quot;Cairo&quot;) is developed by The Cairo Project (<a href="http://www.cairographics.org" target="_blank">http://www.cairographics.org</a>):</p>
+
+<p>Cairo is delivered in the following file (&quot;Cairo Library&quot;):</p>
+<ul>
+    <li>libcairo-swt.so</li>
+</ul>
+
+<p>which was compiled from Cairo source code available at <a href="http://www.cairographics.org/snapshots" target="_blank">http://www.cairographics.org/snapshots</a>.</p>
+
+<p>Your use of the Cairo code in binary form is subject to
+the terms and conditions of Mozilla Public License Version 1.1 (&quot;MPL&quot;).  A copy of the MPL is provided (<a href="mpl-v11.txt" target="blank">mpl-v11.txt</a>)
+and is also available at <a href="http://www.mozilla.org/MPL/MPL-1.1.html" target="_blank">http://www.mozilla.org/MPL/MPL-1.1.html.</a>
+
+<h4>pixman 0.1.6</h4>
+
+<p>pixman (&quot;pixman&quot;) is packaged within the Cairo Library and was compiled from source code available at
+<a href="http://www.cairographics.org/snapshots" target="_blank">http://www.cairographics.org/snapshots</a>.
+pixman includes the following packages:</p>
+
+<ul>
+	<li>libpixregion</li>
+	<li>libic</li>
+	<li>slim</li>
+</ul>
+
+Your use of pixman is subject to the terms and conditions of the licenses in <a href="pixman-licenses.txt" target="blank">pixman-licenses.txt</a>.</p>
+
+<p>If you did not receive the Cairo Library directly from the Eclipse Foundation, the package is being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
+apply its use.  Check the Redistributor's license that was provided with the content.  If no such license exists, contact the Redistributor.</p>
+
+</body>
+</html>
\ No newline at end of file


Property changes on: branches/upstream/swt-gtk/current/about_files/about_cairo.html
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/about_files/lgpl-v21.txt
===================================================================
--- branches/upstream/swt-gtk/current/about_files/lgpl-v21.txt	                        (rev 0)
+++ branches/upstream/swt-gtk/current/about_files/lgpl-v21.txt	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,506 @@
+		  GNU LESSER GENERAL PUBLIC LICENSE
+		       Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+     59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL.  It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+			    Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+  This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it.  You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations below.
+
+  When we speak of free software, we are referring to freedom of use,
+not price.  Our General Public Licenses are designed to make sure that
+you have the freedom to distribute copies of free software (and charge
+for this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
+
+  To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights.  These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+  For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you.  You must make sure that they, too, receive or can get the source
+code.  If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it.  And you must show them these terms so they know their rights.
+
+  We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+  To protect each distributor, we want to make it very clear that
+there is no warranty for the free library.  Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+
+  Finally, software patents pose a constant threat to the existence of
+any free program.  We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder.  Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+  Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License.  This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License.  We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+  When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library.  The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom.  The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+  We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License.  It also provides other free software developers Less
+of an advantage over competing non-free programs.  These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries.  However, the Lesser license provides advantages in certain
+special circumstances.
+
+  For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it becomes
+a de-facto standard.  To achieve this, non-free programs must be
+allowed to use the library.  A more frequent case is that a free
+library does the same job as widely used non-free libraries.  In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+  In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software.  For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+  Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.  Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library".  The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
+
+		  GNU LESSER GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License Agreement applies to any software library or other
+program which contains a notice placed by the copyright holder or
+other authorized party saying it may be distributed under the terms of
+this Lesser General Public License (also called "this License").
+Each licensee is addressed as "you".
+
+  A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+  The "Library", below, refers to any such software library or work
+which has been distributed under these terms.  A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language.  (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+  "Source code" for a work means the preferred form of the work for
+making modifications to it.  For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+  Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it).  Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+  
+  1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+  You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+
+  2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) The modified work must itself be a software library.
+
+    b) You must cause the files modified to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    c) You must cause the whole of the work to be licensed at no
+    charge to all third parties under the terms of this License.
+
+    d) If a facility in the modified Library refers to a function or a
+    table of data to be supplied by an application program that uses
+    the facility, other than as an argument passed when the facility
+    is invoked, then you must make a good faith effort to ensure that,
+    in the event an application does not supply such function or
+    table, the facility still operates, and performs whatever part of
+    its purpose remains meaningful.
+
+    (For example, a function in a library to compute square roots has
+    a purpose that is entirely well-defined independent of the
+    application.  Therefore, Subsection 2d requires that any
+    application-supplied function or table used by this function must
+    be optional: if the application does not supply it, the square
+    root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library.  To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License.  (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.)  Do not make any other change in
+these notices.
+
+  Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+  This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+  4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+  If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library".  Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+  However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library".  The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+  When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library.  The
+threshold for this to be true is not precisely defined by law.
+
+  If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work.  (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+  Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+
+  6. As an exception to the Sections above, you may also combine or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+  You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License.  You must supply a copy of this License.  If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License.  Also, you must do one
+of these things:
+
+    a) Accompany the work with the complete corresponding
+    machine-readable source code for the Library including whatever
+    changes were used in the work (which must be distributed under
+    Sections 1 and 2 above); and, if the work is an executable linked
+    with the Library, with the complete machine-readable "work that
+    uses the Library", as object code and/or source code, so that the
+    user can modify the Library and then relink to produce a modified
+    executable containing the modified Library.  (It is understood
+    that the user who changes the contents of definitions files in the
+    Library will not necessarily be able to recompile the application
+    to use the modified definitions.)
+
+    b) Use a suitable shared library mechanism for linking with the
+    Library.  A suitable mechanism is one that (1) uses at run time a
+    copy of the library already present on the user's computer system,
+    rather than copying library functions into the executable, and (2)
+    will operate properly with a modified version of the library, if
+    the user installs one, as long as the modified version is
+    interface-compatible with the version that the work was made with.
+
+    c) Accompany the work with a written offer, valid for at
+    least three years, to give the same user the materials
+    specified in Subsection 6a, above, for a charge no more
+    than the cost of performing this distribution.
+
+    d) If distribution of the work is made by offering access to copy
+    from a designated place, offer equivalent access to copy the above
+    specified materials from the same place.
+
+    e) Verify that the user has already received a copy of these
+    materials or that you have already sent this user a copy.
+
+  For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it.  However, as a special exception,
+the materials to be distributed need not include anything that is
+normally distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+  It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system.  Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+
+  7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+    a) Accompany the combined library with a copy of the same work
+    based on the Library, uncombined with any other library
+    facilities.  This must be distributed under the terms of the
+    Sections above.
+
+    b) Give prominent notice with the combined library of the fact
+    that part of it is a work based on the Library, and explaining
+    where to find the accompanying uncombined form of the same work.
+
+  8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License.  Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License.  However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+  9. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Library or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+  10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties with
+this License.
+
+  11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded.  In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+  13. The Free Software Foundation may publish revised and/or new
+versions of the Lesser General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation.  If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+
+  14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission.  For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this.  Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+			    NO WARRANTY
+
+  15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU.  SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+  16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+		     END OF TERMS AND CONDITIONS
+
+           How to Apply These Terms to Your New Libraries
+
+  If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change.  You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms of the
+ordinary General Public License).
+
+  To apply these terms, attach the following notices to the library.  It is
+safest to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least the
+"copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the library's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 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
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser 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
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the library, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the
+  library `Frob' (a library for tweaking knobs) written by James Random Hacker.
+
+  <signature of Ty Coon>, 1 April 1990
+  Ty Coon, President of Vice
+
+That's all there is to it!
+
+
+
+


Property changes on: branches/upstream/swt-gtk/current/about_files/lgpl-v21.txt
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/about_files/mpl-v11.txt
===================================================================
--- branches/upstream/swt-gtk/current/about_files/mpl-v11.txt	                        (rev 0)
+++ branches/upstream/swt-gtk/current/about_files/mpl-v11.txt	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,470 @@
+                          MOZILLA PUBLIC LICENSE
+                                Version 1.1
+
+                              ---------------
+
+1. Definitions.
+
+     1.0.1. "Commercial Use" means distribution or otherwise making the
+     Covered Code available to a third party.
+
+     1.1. "Contributor" means each entity that creates or contributes to
+     the creation of Modifications.
+
+     1.2. "Contributor Version" means the combination of the Original
+     Code, prior Modifications used by a Contributor, and the Modifications
+     made by that particular Contributor.
+
+     1.3. "Covered Code" means the Original Code or Modifications or the
+     combination of the Original Code and Modifications, in each case
+     including portions thereof.
+
+     1.4. "Electronic Distribution Mechanism" means a mechanism generally
+     accepted in the software development community for the electronic
+     transfer of data.
+
+     1.5. "Executable" means Covered Code in any form other than Source
+     Code.
+
+     1.6. "Initial Developer" means the individual or entity identified
+     as the Initial Developer in the Source Code notice required by Exhibit
+     A.
+
+     1.7. "Larger Work" means a work which combines Covered Code or
+     portions thereof with code not governed by the terms of this License.
+
+     1.8. "License" means this document.
+
+     1.8.1. "Licensable" means having the right to grant, to the maximum
+     extent possible, whether at the time of the initial grant or
+     subsequently acquired, any and all of the rights conveyed herein.
+
+     1.9. "Modifications" means any addition to or deletion from the
+     substance or structure of either the Original Code or any previous
+     Modifications. When Covered Code is released as a series of files, a
+     Modification is:
+          A. Any addition to or deletion from the contents of a file
+          containing Original Code or previous Modifications.
+
+          B. Any new file that contains any part of the Original Code or
+          previous Modifications.
+
+     1.10. "Original Code" means Source Code of computer software code
+     which is described in the Source Code notice required by Exhibit A as
+     Original Code, and which, at the time of its release under this
+     License is not already Covered Code governed by this License.
+
+     1.10.1. "Patent Claims" means any patent claim(s), now owned or
+     hereafter acquired, including without limitation,  method, process,
+     and apparatus claims, in any patent Licensable by grantor.
+
+     1.11. "Source Code" means the preferred form of the Covered Code for
+     making modifications to it, including all modules it contains, plus
+     any associated interface definition files, scripts used to control
+     compilation and installation of an Executable, or source code
+     differential comparisons against either the Original Code or another
+     well known, available Covered Code of the Contributor's choice. The
+     Source Code can be in a compressed or archival form, provided the
+     appropriate decompression or de-archiving software is widely available
+     for no charge.
+
+     1.12. "You" (or "Your")  means an individual or a legal entity
+     exercising rights under, and complying with all of the terms of, this
+     License or a future version of this License issued under Section 6.1.
+     For legal entities, "You" includes any entity which controls, is
+     controlled by, or is under common control with You. For purposes of
+     this definition, "control" means (a) the power, direct or indirect,
+     to cause the direction or management of such entity, whether by
+     contract or otherwise, or (b) ownership of more than fifty percent
+     (50%) of the outstanding shares or beneficial ownership of such
+     entity.
+
+2. Source Code License.
+
+     2.1. The Initial Developer Grant.
+     The Initial Developer hereby grants You a world-wide, royalty-free,
+     non-exclusive license, subject to third party intellectual property
+     claims:
+          (a)  under intellectual property rights (other than patent or
+          trademark) Licensable by Initial Developer to use, reproduce,
+          modify, display, perform, sublicense and distribute the Original
+          Code (or portions thereof) with or without Modifications, and/or
+          as part of a Larger Work; and
+
+          (b) under Patents Claims infringed by the making, using or
+          selling of Original Code, to make, have made, use, practice,
+          sell, and offer for sale, and/or otherwise dispose of the
+          Original Code (or portions thereof).
+
+          (c) the licenses granted in this Section 2.1(a) and (b) are
+          effective on the date Initial Developer first distributes
+          Original Code under the terms of this License.
+
+          (d) Notwithstanding Section 2.1(b) above, no patent license is
+          granted: 1) for code that You delete from the Original Code; 2)
+          separate from the Original Code;  or 3) for infringements caused
+          by: i) the modification of the Original Code or ii) the
+          combination of the Original Code with other software or devices.
+
+     2.2. Contributor Grant.
+     Subject to third party intellectual property claims, each Contributor
+     hereby grants You a world-wide, royalty-free, non-exclusive license
+
+          (a)  under intellectual property rights (other than patent or
+          trademark) Licensable by Contributor, to use, reproduce, modify,
+          display, perform, sublicense and distribute the Modifications
+          created by such Contributor (or portions thereof) either on an
+          unmodified basis, with other Modifications, as Covered Code
+          and/or as part of a Larger Work; and
+
+          (b) under Patent Claims infringed by the making, using, or
+          selling of  Modifications made by that Contributor either alone
+          and/or in combination with its Contributor Version (or portions
+          of such combination), to make, use, sell, offer for sale, have
+          made, and/or otherwise dispose of: 1) Modifications made by that
+          Contributor (or portions thereof); and 2) the combination of
+          Modifications made by that Contributor with its Contributor
+          Version (or portions of such combination).
+
+          (c) the licenses granted in Sections 2.2(a) and 2.2(b) are
+          effective on the date Contributor first makes Commercial Use of
+          the Covered Code.
+
+          (d)    Notwithstanding Section 2.2(b) above, no patent license is
+          granted: 1) for any code that Contributor has deleted from the
+          Contributor Version; 2)  separate from the Contributor Version;
+          3)  for infringements caused by: i) third party modifications of
+          Contributor Version or ii)  the combination of Modifications made
+          by that Contributor with other software  (except as part of the
+          Contributor Version) or other devices; or 4) under Patent Claims
+          infringed by Covered Code in the absence of Modifications made by
+          that Contributor.
+
+3. Distribution Obligations.
+
+     3.1. Application of License.
+     The Modifications which You create or to which You contribute are
+     governed by the terms of this License, including without limitation
+     Section 2.2. The Source Code version of Covered Code may be
+     distributed only under the terms of this License or a future version
+     of this License released under Section 6.1, and You must include a
+     copy of this License with every copy of the Source Code You
+     distribute. You may not offer or impose any terms on any Source Code
+     version that alters or restricts the applicable version of this
+     License or the recipients' rights hereunder. However, You may include
+     an additional document offering the additional rights described in
+     Section 3.5.
+
+     3.2. Availability of Source Code.
+     Any Modification which You create or to which You contribute must be
+     made available in Source Code form under the terms of this License
+     either on the same media as an Executable version or via an accepted
+     Electronic Distribution Mechanism to anyone to whom you made an
+     Executable version available; and if made available via Electronic
+     Distribution Mechanism, must remain available for at least twelve (12)
+     months after the date it initially became available, or at least six
+     (6) months after a subsequent version of that particular Modification
+     has been made available to such recipients. You are responsible for
+     ensuring that the Source Code version remains available even if the
+     Electronic Distribution Mechanism is maintained by a third party.
+
+     3.3. Description of Modifications.
+     You must cause all Covered Code to which You contribute to contain a
+     file documenting the changes You made to create that Covered Code and
+     the date of any change. You must include a prominent statement that
+     the Modification is derived, directly or indirectly, from Original
+     Code provided by the Initial Developer and including the name of the
+     Initial Developer in (a) the Source Code, and (b) in any notice in an
+     Executable version or related documentation in which You describe the
+     origin or ownership of the Covered Code.
+
+     3.4. Intellectual Property Matters
+          (a) Third Party Claims.
+          If Contributor has knowledge that a license under a third party's
+          intellectual property rights is required to exercise the rights
+          granted by such Contributor under Sections 2.1 or 2.2,
+          Contributor must include a text file with the Source Code
+          distribution titled "LEGAL" which describes the claim and the
+          party making the claim in sufficient detail that a recipient will
+          know whom to contact. If Contributor obtains such knowledge after
+          the Modification is made available as described in Section 3.2,
+          Contributor shall promptly modify the LEGAL file in all copies
+          Contributor makes available thereafter and shall take other steps
+          (such as notifying appropriate mailing lists or newsgroups)
+          reasonably calculated to inform those who received the Covered
+          Code that new knowledge has been obtained.
+
+          (b) Contributor APIs.
+          If Contributor's Modifications include an application programming
+          interface and Contributor has knowledge of patent licenses which
+          are reasonably necessary to implement that API, Contributor must
+          also include this information in the LEGAL file.
+
+               (c)    Representations.
+          Contributor represents that, except as disclosed pursuant to
+          Section 3.4(a) above, Contributor believes that Contributor's
+          Modifications are Contributor's original creation(s) and/or
+          Contributor has sufficient rights to grant the rights conveyed by
+          this License.
+
+     3.5. Required Notices.
+     You must duplicate the notice in Exhibit A in each file of the Source
+     Code.  If it is not possible to put such notice in a particular Source
+     Code file due to its structure, then You must include such notice in a
+     location (such as a relevant directory) where a user would be likely
+     to look for such a notice.  If You created one or more Modification(s)
+     You may add your name as a Contributor to the notice described in
+     Exhibit A.  You must also duplicate this License in any documentation
+     for the Source Code where You describe recipients' rights or ownership
+     rights relating to Covered Code.  You may choose to offer, and to
+     charge a fee for, warranty, support, indemnity or liability
+     obligations to one or more recipients of Covered Code. However, You
+     may do so only on Your own behalf, and not on behalf of the Initial
+     Developer or any Contributor. You must make it absolutely clear than
+     any such warranty, support, indemnity or liability obligation is
+     offered by You alone, and You hereby agree to indemnify the Initial
+     Developer and every Contributor for any liability incurred by the
+     Initial Developer or such Contributor as a result of warranty,
+     support, indemnity or liability terms You offer.
+
+     3.6. Distribution of Executable Versions.
+     You may distribute Covered Code in Executable form only if the
+     requirements of Section 3.1-3.5 have been met for that Covered Code,
+     and if You include a notice stating that the Source Code version of
+     the Covered Code is available under the terms of this License,
+     including a description of how and where You have fulfilled the
+     obligations of Section 3.2. The notice must be conspicuously included
+     in any notice in an Executable version, related documentation or
+     collateral in which You describe recipients' rights relating to the
+     Covered Code. You may distribute the Executable version of Covered
+     Code or ownership rights under a license of Your choice, which may
+     contain terms different from this License, provided that You are in
+     compliance with the terms of this License and that the license for the
+     Executable version does not attempt to limit or alter the recipient's
+     rights in the Source Code version from the rights set forth in this
+     License. If You distribute the Executable version under a different
+     license You must make it absolutely clear that any terms which differ
+     from this License are offered by You alone, not by the Initial
+     Developer or any Contributor. You hereby agree to indemnify the
+     Initial Developer and every Contributor for any liability incurred by
+     the Initial Developer or such Contributor as a result of any such
+     terms You offer.
+
+     3.7. Larger Works.
+     You may create a Larger Work by combining Covered Code with other code
+     not governed by the terms of this License and distribute the Larger
+     Work as a single product. In such a case, You must make sure the
+     requirements of this License are fulfilled for the Covered Code.
+
+4. Inability to Comply Due to Statute or Regulation.
+
+     If it is impossible for You to comply with any of the terms of this
+     License with respect to some or all of the Covered Code due to
+     statute, judicial order, or regulation then You must: (a) comply with
+     the terms of this License to the maximum extent possible; and (b)
+     describe the limitations and the code they affect. Such description
+     must be included in the LEGAL file described in Section 3.4 and must
+     be included with all distributions of the Source Code. Except to the
+     extent prohibited by statute or regulation, such description must be
+     sufficiently detailed for a recipient of ordinary skill to be able to
+     understand it.
+
+5. Application of this License.
+
+     This License applies to code to which the Initial Developer has
+     attached the notice in Exhibit A and to related Covered Code.
+
+6. Versions of the License.
+
+     6.1. New Versions.
+     Netscape Communications Corporation ("Netscape") may publish revised
+     and/or new versions of the License from time to time. Each version
+     will be given a distinguishing version number.
+
+     6.2. Effect of New Versions.
+     Once Covered Code has been published under a particular version of the
+     License, You may always continue to use it under the terms of that
+     version. You may also choose to use such Covered Code under the terms
+     of any subsequent version of the License published by Netscape. No one
+     other than Netscape has the right to modify the terms applicable to
+     Covered Code created under this License.
+
+     6.3. Derivative Works.
+     If You create or use a modified version of this License (which you may
+     only do in order to apply it to code which is not already Covered Code
+     governed by this License), You must (a) rename Your license so that
+     the phrases "Mozilla", "MOZILLAPL", "MOZPL", "Netscape",
+     "MPL", "NPL" or any confusingly similar phrase do not appear in your
+     license (except to note that your license differs from this License)
+     and (b) otherwise make it clear that Your version of the license
+     contains terms which differ from the Mozilla Public License and
+     Netscape Public License. (Filling in the name of the Initial
+     Developer, Original Code or Contributor in the notice described in
+     Exhibit A shall not of themselves be deemed to be modifications of
+     this License.)
+
+7. DISCLAIMER OF WARRANTY.
+
+     COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS,
+     WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+     WITHOUT LIMITATION, WARRANTIES THAT THE COVERED CODE IS FREE OF
+     DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING.
+     THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED CODE
+     IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT,
+     YOU (NOT THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE
+     COST OF ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER
+     OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF
+     ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER.
+
+8. TERMINATION.
+
+     8.1.  This License and the rights granted hereunder will terminate
+     automatically if You fail to comply with terms herein and fail to cure
+     such breach within 30 days of becoming aware of the breach. All
+     sublicenses to the Covered Code which are properly granted shall
+     survive any termination of this License. Provisions which, by their
+     nature, must remain in effect beyond the termination of this License
+     shall survive.
+
+     8.2.  If You initiate litigation by asserting a patent infringement
+     claim (excluding declatory judgment actions) against Initial Developer
+     or a Contributor (the Initial Developer or Contributor against whom
+     You file such action is referred to as "Participant")  alleging that:
+
+     (a)  such Participant's Contributor Version directly or indirectly
+     infringes any patent, then any and all rights granted by such
+     Participant to You under Sections 2.1 and/or 2.2 of this License
+     shall, upon 60 days notice from Participant terminate prospectively,
+     unless if within 60 days after receipt of notice You either: (i)
+     agree in writing to pay Participant a mutually agreeable reasonable
+     royalty for Your past and future use of Modifications made by such
+     Participant, or (ii) withdraw Your litigation claim with respect to
+     the Contributor Version against such Participant.  If within 60 days
+     of notice, a reasonable royalty and payment arrangement are not
+     mutually agreed upon in writing by the parties or the litigation claim
+     is not withdrawn, the rights granted by Participant to You under
+     Sections 2.1 and/or 2.2 automatically terminate at the expiration of
+     the 60 day notice period specified above.
+
+     (b)  any software, hardware, or device, other than such Participant's
+     Contributor Version, directly or indirectly infringes any patent, then
+     any rights granted to You by such Participant under Sections 2.1(b)
+     and 2.2(b) are revoked effective as of the date You first made, used,
+     sold, distributed, or had made, Modifications made by that
+     Participant.
+
+     8.3.  If You assert a patent infringement claim against Participant
+     alleging that such Participant's Contributor Version directly or
+     indirectly infringes any patent where such claim is resolved (such as
+     by license or settlement) prior to the initiation of patent
+     infringement litigation, then the reasonable value of the licenses
+     granted by such Participant under Sections 2.1 or 2.2 shall be taken
+     into account in determining the amount or value of any payment or
+     license.
+
+     8.4.  In the event of termination under Sections 8.1 or 8.2 above,
+     all end user license agreements (excluding distributors and resellers)
+     which have been validly granted by You or any distributor hereunder
+     prior to termination shall survive termination.
+
+9. LIMITATION OF LIABILITY.
+
+     UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT
+     (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE INITIAL
+     DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED CODE,
+     OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO ANY PERSON FOR
+     ANY INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY
+     CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF GOODWILL,
+     WORK STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER
+     COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN
+     INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF
+     LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL INJURY
+     RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT APPLICABLE LAW
+     PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE
+     EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO
+     THIS EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU.
+
+10. U.S. GOVERNMENT END USERS.
+
+     The Covered Code is a "commercial item," as that term is defined in
+     48 C.F.R. 2.101 (Oct. 1995), consisting of "commercial computer
+     software" and "commercial computer software documentation," as such
+     terms are used in 48 C.F.R. 12.212 (Sept. 1995). Consistent with 48
+     C.F.R. 12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (June 1995),
+     all U.S. Government End Users acquire Covered Code with only those
+     rights set forth herein.
+
+11. MISCELLANEOUS.
+
+     This License represents the complete agreement concerning subject
+     matter hereof. If any provision of this License is held to be
+     unenforceable, such provision shall be reformed only to the extent
+     necessary to make it enforceable. This License shall be governed by
+     California law provisions (except to the extent applicable law, if
+     any, provides otherwise), excluding its conflict-of-law provisions.
+     With respect to disputes in which at least one party is a citizen of,
+     or an entity chartered or registered to do business in the United
+     States of America, any litigation relating to this License shall be
+     subject to the jurisdiction of the Federal Courts of the Northern
+     District of California, with venue lying in Santa Clara County,
+     California, with the losing party responsible for costs, including
+     without limitation, court costs and reasonable attorneys' fees and
+     expenses. The application of the United Nations Convention on
+     Contracts for the International Sale of Goods is expressly excluded.
+     Any law or regulation which provides that the language of a contract
+     shall be construed against the drafter shall not apply to this
+     License.
+
+12. RESPONSIBILITY FOR CLAIMS.
+
+     As between Initial Developer and the Contributors, each party is
+     responsible for claims and damages arising, directly or indirectly,
+     out of its utilization of rights under this License and You agree to
+     work with Initial Developer and Contributors to distribute such
+     responsibility on an equitable basis. Nothing herein is intended or
+     shall be deemed to constitute any admission of liability.
+
+13. MULTIPLE-LICENSED CODE.
+
+     Initial Developer may designate portions of the Covered Code as
+     "Multiple-Licensed".  "Multiple-Licensed" means that the Initial
+     Developer permits you to utilize portions of the Covered Code under
+     Your choice of the NPL or the alternative licenses, if any, specified
+     by the Initial Developer in the file described in Exhibit A.
+
+EXHIBIT A -Mozilla Public License.
+
+     ``The contents of this file are subject to the Mozilla Public License
+     Version 1.1 (the "License"); you may not use this file except in
+     compliance with the License. You may obtain a copy of the License at
+     http://www.mozilla.org/MPL/
+
+     Software distributed under the License is distributed on an "AS IS"
+     basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+     License for the specific language governing rights and limitations
+     under the License.
+
+     The Original Code is ______________________________________.
+
+     The Initial Developer of the Original Code is ________________________.
+     Portions created by ______________________ are Copyright (C) ______
+     _______________________. All Rights Reserved.
+
+     Contributor(s): ______________________________________.
+
+     Alternatively, the contents of this file may be used under the terms
+     of the _____ license (the  "[___] License"), in which case the
+     provisions of [______] License are applicable instead of those
+     above.  If you wish to allow use of your version of this file only
+     under the terms of the [____] License and not to allow others to use
+     your version of this file under the MPL, indicate your decision by
+     deleting  the provisions above and replace  them with the notice and
+     other provisions required by the [___] License.  If you do not delete
+     the provisions above, a recipient may use your version of this file
+     under either the MPL or the [___] License."
+
+     [NOTE: The text of this Exhibit A may differ slightly from the text of
+     the notices in the Source Code files of the Original Code. You should
+     use the text of this Exhibit A rather than the text found in the
+     Original Code Source Code for Your Modifications.]
+


Property changes on: branches/upstream/swt-gtk/current/about_files/mpl-v11.txt
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/about_files/pixman-licenses.txt
===================================================================
--- branches/upstream/swt-gtk/current/about_files/pixman-licenses.txt	                        (rev 0)
+++ branches/upstream/swt-gtk/current/about_files/pixman-licenses.txt	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,92 @@
+libpixregion
+
+Copyright 1987, 1998  The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+                        All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its 
+documentation for any purpose and without fee is hereby granted, 
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in 
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.  
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+----------------------------------------------------------------------
+libic
+
+Copyright © 2001 Keith Packard
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation, and that the name of Keith Packard not be used in
+advertising or publicity pertaining to distribution of the software without
+specific, written prior permission.  Keith Packard makes no
+representations about the suitability of this software for any purpose.  It
+is provided "as is" without express or implied warranty.
+
+KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+PERFORMANCE OF THIS SOFTWARE.
+
+----------------------------------------------------------------------
+slim
+
+slim is Copyright © 2003 Richard Henderson
+
+Permission to use, copy, modify, distribute, and sell this software
+and its documentation for any purpose is hereby granted without fee,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Richard Henderson not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.  Richard Henderson
+makes no representations about the suitability of this software for
+any purpose.  It is provided "as is" without express or implied
+warranty.
+
+RICHARD HENDERSON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+EVENT SHALL RICHARD HENDERSON BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
+USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+PERFORMANCE OF THIS SOFTWARE.
+


Property changes on: branches/upstream/swt-gtk/current/about_files/pixman-licenses.txt
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/atk.c
===================================================================
--- branches/upstream/swt-gtk/current/atk.c	                        (rev 0)
+++ branches/upstream/swt-gtk/current/atk.c	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,487 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 IBM Corporation and others. All rights reserved.
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt).  The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html.  If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+#include "swt.h"
+#include "atk_structs.h"
+#include "atk_stats.h"
+
+#define ATK_NATIVE(func) Java_org_eclipse_swt_internal_accessibility_gtk_ATK_##func
+
+#ifndef NO_AtkObjectFactoryClass_1sizeof
+JNIEXPORT jint JNICALL ATK_NATIVE(AtkObjectFactoryClass_1sizeof)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	ATK_NATIVE_ENTER(env, that, AtkObjectFactoryClass_1sizeof_FUNC);
+	rc = (jint)AtkObjectFactoryClass_sizeof();
+	ATK_NATIVE_EXIT(env, that, AtkObjectFactoryClass_1sizeof_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_AtkObjectFactory_1sizeof
+JNIEXPORT jint JNICALL ATK_NATIVE(AtkObjectFactory_1sizeof)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	ATK_NATIVE_ENTER(env, that, AtkObjectFactory_1sizeof_FUNC);
+	rc = (jint)AtkObjectFactory_sizeof();
+	ATK_NATIVE_EXIT(env, that, AtkObjectFactory_1sizeof_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1ATK_1ACTION_1GET_1IFACE
+JNIEXPORT jint JNICALL ATK_NATIVE(_1ATK_1ACTION_1GET_1IFACE)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	ATK_NATIVE_ENTER(env, that, _1ATK_1ACTION_1GET_1IFACE_FUNC);
+	rc = (jint)ATK_ACTION_GET_IFACE(arg0);
+	ATK_NATIVE_EXIT(env, that, _1ATK_1ACTION_1GET_1IFACE_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1ATK_1COMPONENT_1GET_1IFACE
+JNIEXPORT jint JNICALL ATK_NATIVE(_1ATK_1COMPONENT_1GET_1IFACE)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	ATK_NATIVE_ENTER(env, that, _1ATK_1COMPONENT_1GET_1IFACE_FUNC);
+	rc = (jint)ATK_COMPONENT_GET_IFACE(arg0);
+	ATK_NATIVE_EXIT(env, that, _1ATK_1COMPONENT_1GET_1IFACE_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1ATK_1OBJECT_1FACTORY_1CLASS
+JNIEXPORT jint JNICALL ATK_NATIVE(_1ATK_1OBJECT_1FACTORY_1CLASS)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	ATK_NATIVE_ENTER(env, that, _1ATK_1OBJECT_1FACTORY_1CLASS_FUNC);
+	rc = (jint)ATK_OBJECT_FACTORY_CLASS(arg0);
+	ATK_NATIVE_EXIT(env, that, _1ATK_1OBJECT_1FACTORY_1CLASS_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1ATK_1SELECTION_1GET_1IFACE
+JNIEXPORT jint JNICALL ATK_NATIVE(_1ATK_1SELECTION_1GET_1IFACE)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	ATK_NATIVE_ENTER(env, that, _1ATK_1SELECTION_1GET_1IFACE_FUNC);
+	rc = (jint)ATK_SELECTION_GET_IFACE(arg0);
+	ATK_NATIVE_EXIT(env, that, _1ATK_1SELECTION_1GET_1IFACE_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1ATK_1TEXT_1GET_1IFACE
+JNIEXPORT jint JNICALL ATK_NATIVE(_1ATK_1TEXT_1GET_1IFACE)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	ATK_NATIVE_ENTER(env, that, _1ATK_1TEXT_1GET_1IFACE_FUNC);
+	rc = (jint)ATK_TEXT_GET_IFACE(arg0);
+	ATK_NATIVE_EXIT(env, that, _1ATK_1TEXT_1GET_1IFACE_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1GTK_1ACCESSIBLE
+JNIEXPORT jint JNICALL ATK_NATIVE(_1GTK_1ACCESSIBLE)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	ATK_NATIVE_ENTER(env, that, _1GTK_1ACCESSIBLE_FUNC);
+	rc = (jint)GTK_ACCESSIBLE(arg0);
+	ATK_NATIVE_EXIT(env, that, _1GTK_1ACCESSIBLE_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1atk_1focus_1tracker_1notify
+JNIEXPORT void JNICALL ATK_NATIVE(_1atk_1focus_1tracker_1notify)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	ATK_NATIVE_ENTER(env, that, _1atk_1focus_1tracker_1notify_FUNC);
+	atk_focus_tracker_notify((AtkObject *)arg0);
+	ATK_NATIVE_EXIT(env, that, _1atk_1focus_1tracker_1notify_FUNC);
+}
+#endif
+
+#ifndef NO__1atk_1get_1default_1registry
+JNIEXPORT jint JNICALL ATK_NATIVE(_1atk_1get_1default_1registry)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	ATK_NATIVE_ENTER(env, that, _1atk_1get_1default_1registry_FUNC);
+	rc = (jint)atk_get_default_registry();
+	ATK_NATIVE_EXIT(env, that, _1atk_1get_1default_1registry_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1atk_1object_1factory_1create_1accessible
+JNIEXPORT jint JNICALL ATK_NATIVE(_1atk_1object_1factory_1create_1accessible)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	jint rc = 0;
+	ATK_NATIVE_ENTER(env, that, _1atk_1object_1factory_1create_1accessible_FUNC);
+	rc = (jint)atk_object_factory_create_accessible((AtkObjectFactory *)arg0, (GObject *)arg1);
+	ATK_NATIVE_EXIT(env, that, _1atk_1object_1factory_1create_1accessible_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1atk_1object_1factory_1get_1accessible_1type
+JNIEXPORT jint JNICALL ATK_NATIVE(_1atk_1object_1factory_1get_1accessible_1type)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	ATK_NATIVE_ENTER(env, that, _1atk_1object_1factory_1get_1accessible_1type_FUNC);
+	rc = (jint)atk_object_factory_get_accessible_type((AtkObjectFactory *)arg0);
+	ATK_NATIVE_EXIT(env, that, _1atk_1object_1factory_1get_1accessible_1type_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1atk_1object_1initialize
+JNIEXPORT void JNICALL ATK_NATIVE(_1atk_1object_1initialize)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	ATK_NATIVE_ENTER(env, that, _1atk_1object_1initialize_FUNC);
+	atk_object_initialize((AtkObject *)arg0, (gpointer)arg1);
+	ATK_NATIVE_EXIT(env, that, _1atk_1object_1initialize_FUNC);
+}
+#endif
+
+#ifndef NO__1atk_1object_1ref_1relation_1set
+JNIEXPORT jint JNICALL ATK_NATIVE(_1atk_1object_1ref_1relation_1set)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	ATK_NATIVE_ENTER(env, that, _1atk_1object_1ref_1relation_1set_FUNC);
+	rc = (jint)atk_object_ref_relation_set((AtkObject *)arg0);
+	ATK_NATIVE_EXIT(env, that, _1atk_1object_1ref_1relation_1set_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1atk_1registry_1get_1factory
+JNIEXPORT jint JNICALL ATK_NATIVE(_1atk_1registry_1get_1factory)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	jint rc = 0;
+	ATK_NATIVE_ENTER(env, that, _1atk_1registry_1get_1factory_FUNC);
+	rc = (jint)atk_registry_get_factory((AtkRegistry *)arg0, (GType)arg1);
+	ATK_NATIVE_EXIT(env, that, _1atk_1registry_1get_1factory_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1atk_1registry_1set_1factory_1type
+JNIEXPORT void JNICALL ATK_NATIVE(_1atk_1registry_1set_1factory_1type)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+	ATK_NATIVE_ENTER(env, that, _1atk_1registry_1set_1factory_1type_FUNC);
+	atk_registry_set_factory_type((AtkRegistry *)arg0, (GType)arg1, (GType)arg2);
+	ATK_NATIVE_EXIT(env, that, _1atk_1registry_1set_1factory_1type_FUNC);
+}
+#endif
+
+#ifndef NO__1atk_1relation_1set_1get_1n_1relations
+JNIEXPORT jint JNICALL ATK_NATIVE(_1atk_1relation_1set_1get_1n_1relations)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	ATK_NATIVE_ENTER(env, that, _1atk_1relation_1set_1get_1n_1relations_FUNC);
+	rc = (jint)atk_relation_set_get_n_relations((AtkRelationSet *)arg0);
+	ATK_NATIVE_EXIT(env, that, _1atk_1relation_1set_1get_1n_1relations_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1atk_1relation_1set_1get_1relation
+JNIEXPORT jint JNICALL ATK_NATIVE(_1atk_1relation_1set_1get_1relation)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	jint rc = 0;
+	ATK_NATIVE_ENTER(env, that, _1atk_1relation_1set_1get_1relation_FUNC);
+	rc = (jint)atk_relation_set_get_relation((AtkRelationSet *)arg0, arg1);
+	ATK_NATIVE_EXIT(env, that, _1atk_1relation_1set_1get_1relation_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1atk_1relation_1set_1remove
+JNIEXPORT void JNICALL ATK_NATIVE(_1atk_1relation_1set_1remove)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	ATK_NATIVE_ENTER(env, that, _1atk_1relation_1set_1remove_FUNC);
+	atk_relation_set_remove((AtkRelationSet *)arg0, (AtkRelation *)arg1);
+	ATK_NATIVE_EXIT(env, that, _1atk_1relation_1set_1remove_FUNC);
+}
+#endif
+
+#ifndef NO__1atk_1state_1set_1add_1state
+JNIEXPORT jboolean JNICALL ATK_NATIVE(_1atk_1state_1set_1add_1state)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	jboolean rc = 0;
+	ATK_NATIVE_ENTER(env, that, _1atk_1state_1set_1add_1state_FUNC);
+	rc = (jboolean)atk_state_set_add_state((AtkStateSet *)arg0, (AtkStateType)arg1);
+	ATK_NATIVE_EXIT(env, that, _1atk_1state_1set_1add_1state_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1atk_1state_1set_1new
+JNIEXPORT jint JNICALL ATK_NATIVE(_1atk_1state_1set_1new)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	ATK_NATIVE_ENTER(env, that, _1atk_1state_1set_1new_FUNC);
+	rc = (jint)atk_state_set_new();
+	ATK_NATIVE_EXIT(env, that, _1atk_1state_1set_1new_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1call__II
+JNIEXPORT jint JNICALL ATK_NATIVE(_1call__II)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	jint rc = 0;
+	ATK_NATIVE_ENTER(env, that, _1call__II_FUNC);
+	rc = (jint)((jint (*)())arg0)(arg1);
+	ATK_NATIVE_EXIT(env, that, _1call__II_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1call__III
+JNIEXPORT jint JNICALL ATK_NATIVE(_1call__III)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+	jint rc = 0;
+	ATK_NATIVE_ENTER(env, that, _1call__III_FUNC);
+	rc = (jint)((jint (*)())arg0)(arg1, arg2);
+	ATK_NATIVE_EXIT(env, that, _1call__III_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1call__IIII
+JNIEXPORT jint JNICALL ATK_NATIVE(_1call__IIII)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3)
+{
+	jint rc = 0;
+	ATK_NATIVE_ENTER(env, that, _1call__IIII_FUNC);
+	rc = (jint)((jint (*)())arg0)(arg1, arg2, arg3);
+	ATK_NATIVE_EXIT(env, that, _1call__IIII_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1call__IIIII
+JNIEXPORT jint JNICALL ATK_NATIVE(_1call__IIIII)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4)
+{
+	jint rc = 0;
+	ATK_NATIVE_ENTER(env, that, _1call__IIIII_FUNC);
+	rc = (jint)((jint (*)())arg0)(arg1, arg2, arg3, arg4);
+	ATK_NATIVE_EXIT(env, that, _1call__IIIII_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1call__IIIIII
+JNIEXPORT jint JNICALL ATK_NATIVE(_1call__IIIIII)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4, jint arg5)
+{
+	jint rc = 0;
+	ATK_NATIVE_ENTER(env, that, _1call__IIIIII_FUNC);
+	rc = (jint)((jint (*)())arg0)(arg1, arg2, arg3, arg4, arg5);
+	ATK_NATIVE_EXIT(env, that, _1call__IIIIII_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1call__IIIIIII
+JNIEXPORT jint JNICALL ATK_NATIVE(_1call__IIIIIII)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4, jint arg5, jint arg6)
+{
+	jint rc = 0;
+	ATK_NATIVE_ENTER(env, that, _1call__IIIIIII_FUNC);
+	rc = (jint)((jint (*)())arg0)(arg1, arg2, arg3, arg4, arg5, arg6);
+	ATK_NATIVE_EXIT(env, that, _1call__IIIIIII_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_memmove__ILorg_eclipse_swt_internal_accessibility_gtk_AtkActionIface_2
+JNIEXPORT void JNICALL ATK_NATIVE(memmove__ILorg_eclipse_swt_internal_accessibility_gtk_AtkActionIface_2)
+	(JNIEnv *env, jclass that, jint arg0, jobject arg1)
+{
+	ATK_NATIVE_ENTER(env, that, memmove__ILorg_eclipse_swt_internal_accessibility_gtk_AtkActionIface_2_FUNC);
+	if (arg1) getAtkActionIfaceFields(env, arg1, (AtkActionIface *)arg0);
+	ATK_NATIVE_EXIT(env, that, memmove__ILorg_eclipse_swt_internal_accessibility_gtk_AtkActionIface_2_FUNC);
+}
+#endif
+
+#ifndef NO_memmove__ILorg_eclipse_swt_internal_accessibility_gtk_AtkComponentIface_2
+JNIEXPORT void JNICALL ATK_NATIVE(memmove__ILorg_eclipse_swt_internal_accessibility_gtk_AtkComponentIface_2)
+	(JNIEnv *env, jclass that, jint arg0, jobject arg1)
+{
+	ATK_NATIVE_ENTER(env, that, memmove__ILorg_eclipse_swt_internal_accessibility_gtk_AtkComponentIface_2_FUNC);
+	if (arg1) getAtkComponentIfaceFields(env, arg1, (AtkComponentIface *)arg0);
+	ATK_NATIVE_EXIT(env, that, memmove__ILorg_eclipse_swt_internal_accessibility_gtk_AtkComponentIface_2_FUNC);
+}
+#endif
+
+#ifndef NO_memmove__ILorg_eclipse_swt_internal_accessibility_gtk_AtkHypertextIface_2
+JNIEXPORT void JNICALL ATK_NATIVE(memmove__ILorg_eclipse_swt_internal_accessibility_gtk_AtkHypertextIface_2)
+	(JNIEnv *env, jclass that, jint arg0, jobject arg1)
+{
+	ATK_NATIVE_ENTER(env, that, memmove__ILorg_eclipse_swt_internal_accessibility_gtk_AtkHypertextIface_2_FUNC);
+	if (arg1) getAtkHypertextIfaceFields(env, arg1, (AtkHypertextIface *)arg0);
+	ATK_NATIVE_EXIT(env, that, memmove__ILorg_eclipse_swt_internal_accessibility_gtk_AtkHypertextIface_2_FUNC);
+}
+#endif
+
+#ifndef NO_memmove__ILorg_eclipse_swt_internal_accessibility_gtk_AtkObjectClass_2
+JNIEXPORT void JNICALL ATK_NATIVE(memmove__ILorg_eclipse_swt_internal_accessibility_gtk_AtkObjectClass_2)
+	(JNIEnv *env, jclass that, jint arg0, jobject arg1)
+{
+	ATK_NATIVE_ENTER(env, that, memmove__ILorg_eclipse_swt_internal_accessibility_gtk_AtkObjectClass_2_FUNC);
+	if (arg1) getAtkObjectClassFields(env, arg1, (AtkObjectClass *)arg0);
+	ATK_NATIVE_EXIT(env, that, memmove__ILorg_eclipse_swt_internal_accessibility_gtk_AtkObjectClass_2_FUNC);
+}
+#endif
+
+#ifndef NO_memmove__ILorg_eclipse_swt_internal_accessibility_gtk_AtkObjectFactoryClass_2
+JNIEXPORT void JNICALL ATK_NATIVE(memmove__ILorg_eclipse_swt_internal_accessibility_gtk_AtkObjectFactoryClass_2)
+	(JNIEnv *env, jclass that, jint arg0, jobject arg1)
+{
+	ATK_NATIVE_ENTER(env, that, memmove__ILorg_eclipse_swt_internal_accessibility_gtk_AtkObjectFactoryClass_2_FUNC);
+	if (arg1) getAtkObjectFactoryClassFields(env, arg1, (AtkObjectFactoryClass *)arg0);
+	ATK_NATIVE_EXIT(env, that, memmove__ILorg_eclipse_swt_internal_accessibility_gtk_AtkObjectFactoryClass_2_FUNC);
+}
+#endif
+
+#ifndef NO_memmove__ILorg_eclipse_swt_internal_accessibility_gtk_AtkSelectionIface_2
+JNIEXPORT void JNICALL ATK_NATIVE(memmove__ILorg_eclipse_swt_internal_accessibility_gtk_AtkSelectionIface_2)
+	(JNIEnv *env, jclass that, jint arg0, jobject arg1)
+{
+	ATK_NATIVE_ENTER(env, that, memmove__ILorg_eclipse_swt_internal_accessibility_gtk_AtkSelectionIface_2_FUNC);
+	if (arg1) getAtkSelectionIfaceFields(env, arg1, (AtkSelectionIface *)arg0);
+	ATK_NATIVE_EXIT(env, that, memmove__ILorg_eclipse_swt_internal_accessibility_gtk_AtkSelectionIface_2_FUNC);
+}
+#endif
+
+#ifndef NO_memmove__ILorg_eclipse_swt_internal_accessibility_gtk_AtkTextIface_2
+JNIEXPORT void JNICALL ATK_NATIVE(memmove__ILorg_eclipse_swt_internal_accessibility_gtk_AtkTextIface_2)
+	(JNIEnv *env, jclass that, jint arg0, jobject arg1)
+{
+	ATK_NATIVE_ENTER(env, that, memmove__ILorg_eclipse_swt_internal_accessibility_gtk_AtkTextIface_2_FUNC);
+	if (arg1) getAtkTextIfaceFields(env, arg1, (AtkTextIface *)arg0);
+	ATK_NATIVE_EXIT(env, that, memmove__ILorg_eclipse_swt_internal_accessibility_gtk_AtkTextIface_2_FUNC);
+}
+#endif
+
+#ifndef NO_memmove__Lorg_eclipse_swt_internal_accessibility_gtk_AtkActionIface_2I
+JNIEXPORT void JNICALL ATK_NATIVE(memmove__Lorg_eclipse_swt_internal_accessibility_gtk_AtkActionIface_2I)
+	(JNIEnv *env, jclass that, jobject arg0, jint arg1)
+{
+	ATK_NATIVE_ENTER(env, that, memmove__Lorg_eclipse_swt_internal_accessibility_gtk_AtkActionIface_2I_FUNC);
+	if (arg0) setAtkActionIfaceFields(env, arg0, (AtkActionIface *)arg1);
+	ATK_NATIVE_EXIT(env, that, memmove__Lorg_eclipse_swt_internal_accessibility_gtk_AtkActionIface_2I_FUNC);
+}
+#endif
+
+#ifndef NO_memmove__Lorg_eclipse_swt_internal_accessibility_gtk_AtkComponentIface_2I
+JNIEXPORT void JNICALL ATK_NATIVE(memmove__Lorg_eclipse_swt_internal_accessibility_gtk_AtkComponentIface_2I)
+	(JNIEnv *env, jclass that, jobject arg0, jint arg1)
+{
+	ATK_NATIVE_ENTER(env, that, memmove__Lorg_eclipse_swt_internal_accessibility_gtk_AtkComponentIface_2I_FUNC);
+	if (arg0) setAtkComponentIfaceFields(env, arg0, (AtkComponentIface *)arg1);
+	ATK_NATIVE_EXIT(env, that, memmove__Lorg_eclipse_swt_internal_accessibility_gtk_AtkComponentIface_2I_FUNC);
+}
+#endif
+
+#ifndef NO_memmove__Lorg_eclipse_swt_internal_accessibility_gtk_AtkHypertextIface_2I
+JNIEXPORT void JNICALL ATK_NATIVE(memmove__Lorg_eclipse_swt_internal_accessibility_gtk_AtkHypertextIface_2I)
+	(JNIEnv *env, jclass that, jobject arg0, jint arg1)
+{
+	ATK_NATIVE_ENTER(env, that, memmove__Lorg_eclipse_swt_internal_accessibility_gtk_AtkHypertextIface_2I_FUNC);
+	if (arg0) setAtkHypertextIfaceFields(env, arg0, (AtkHypertextIface *)arg1);
+	ATK_NATIVE_EXIT(env, that, memmove__Lorg_eclipse_swt_internal_accessibility_gtk_AtkHypertextIface_2I_FUNC);
+}
+#endif
+
+#ifndef NO_memmove__Lorg_eclipse_swt_internal_accessibility_gtk_AtkObjectClass_2I
+JNIEXPORT void JNICALL ATK_NATIVE(memmove__Lorg_eclipse_swt_internal_accessibility_gtk_AtkObjectClass_2I)
+	(JNIEnv *env, jclass that, jobject arg0, jint arg1)
+{
+	ATK_NATIVE_ENTER(env, that, memmove__Lorg_eclipse_swt_internal_accessibility_gtk_AtkObjectClass_2I_FUNC);
+	if (arg0) setAtkObjectClassFields(env, arg0, (AtkObjectClass *)arg1);
+	ATK_NATIVE_EXIT(env, that, memmove__Lorg_eclipse_swt_internal_accessibility_gtk_AtkObjectClass_2I_FUNC);
+}
+#endif
+
+#ifndef NO_memmove__Lorg_eclipse_swt_internal_accessibility_gtk_AtkObjectFactoryClass_2I
+JNIEXPORT void JNICALL ATK_NATIVE(memmove__Lorg_eclipse_swt_internal_accessibility_gtk_AtkObjectFactoryClass_2I)
+	(JNIEnv *env, jclass that, jobject arg0, jint arg1)
+{
+	ATK_NATIVE_ENTER(env, that, memmove__Lorg_eclipse_swt_internal_accessibility_gtk_AtkObjectFactoryClass_2I_FUNC);
+	if (arg0) setAtkObjectFactoryClassFields(env, arg0, (AtkObjectFactoryClass *)arg1);
+	ATK_NATIVE_EXIT(env, that, memmove__Lorg_eclipse_swt_internal_accessibility_gtk_AtkObjectFactoryClass_2I_FUNC);
+}
+#endif
+
+#ifndef NO_memmove__Lorg_eclipse_swt_internal_accessibility_gtk_AtkSelectionIface_2I
+JNIEXPORT void JNICALL ATK_NATIVE(memmove__Lorg_eclipse_swt_internal_accessibility_gtk_AtkSelectionIface_2I)
+	(JNIEnv *env, jclass that, jobject arg0, jint arg1)
+{
+	ATK_NATIVE_ENTER(env, that, memmove__Lorg_eclipse_swt_internal_accessibility_gtk_AtkSelectionIface_2I_FUNC);
+	if (arg0) setAtkSelectionIfaceFields(env, arg0, (AtkSelectionIface *)arg1);
+	ATK_NATIVE_EXIT(env, that, memmove__Lorg_eclipse_swt_internal_accessibility_gtk_AtkSelectionIface_2I_FUNC);
+}
+#endif
+
+#ifndef NO_memmove__Lorg_eclipse_swt_internal_accessibility_gtk_AtkTextIface_2I
+JNIEXPORT void JNICALL ATK_NATIVE(memmove__Lorg_eclipse_swt_internal_accessibility_gtk_AtkTextIface_2I)
+	(JNIEnv *env, jclass that, jobject arg0, jint arg1)
+{
+	ATK_NATIVE_ENTER(env, that, memmove__Lorg_eclipse_swt_internal_accessibility_gtk_AtkTextIface_2I_FUNC);
+	if (arg0) setAtkTextIfaceFields(env, arg0, (AtkTextIface *)arg1);
+	ATK_NATIVE_EXIT(env, that, memmove__Lorg_eclipse_swt_internal_accessibility_gtk_AtkTextIface_2I_FUNC);
+}
+#endif
+
+#ifndef NO_memmove__Lorg_eclipse_swt_internal_accessibility_gtk_GtkAccessible_2I
+JNIEXPORT void JNICALL ATK_NATIVE(memmove__Lorg_eclipse_swt_internal_accessibility_gtk_GtkAccessible_2I)
+	(JNIEnv *env, jclass that, jobject arg0, jint arg1)
+{
+	ATK_NATIVE_ENTER(env, that, memmove__Lorg_eclipse_swt_internal_accessibility_gtk_GtkAccessible_2I_FUNC);
+	if (arg0) setGtkAccessibleFields(env, arg0, (GtkAccessible *)arg1);
+	ATK_NATIVE_EXIT(env, that, memmove__Lorg_eclipse_swt_internal_accessibility_gtk_GtkAccessible_2I_FUNC);
+}
+#endif
+

Added: branches/upstream/swt-gtk/current/atk.h
===================================================================
--- branches/upstream/swt-gtk/current/atk.h	                        (rev 0)
+++ branches/upstream/swt-gtk/current/atk.h	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,18 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others. All rights reserved.
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt).  The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html.  If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+  
+#include "os.h"
+#include <atk/atk.h>
+#include "atk_custom.h"

Added: branches/upstream/swt-gtk/current/atk_custom.c
===================================================================
--- branches/upstream/swt-gtk/current/atk_custom.c	                        (rev 0)
+++ branches/upstream/swt-gtk/current/atk_custom.c	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,21 @@
+/*******************************************************************************
+* Copyright (c) 2000, 2004 IBM Corporation and others. All rights reserved.
+* The contents of this file are made available under the terms
+* of the GNU Lesser General Public License (LGPL) Version 2.1 that
+* accompanies this distribution (lgpl-v21.txt).  The LGPL is also
+* available at http://www.gnu.org/licenses/lgpl.html.  If the version
+* of the LGPL at http://www.gnu.org is different to the version of
+* the LGPL accompanying this distribution and there is any conflict
+* between the two license versions, the terms of the LGPL accompanying
+* this distribution shall govern.
+* 
+* Contributors:
+*     IBM Corporation - initial API and implementation
+*******************************************************************************/
+
+#include "swt.h"
+#include "atk_structs.h"
+#include "atk_stats.h"
+
+#define OS_NATIVE(func) Java_org_eclipse_swt_internal_accessibility_gtk_ATK_##func
+

Added: branches/upstream/swt-gtk/current/atk_custom.h
===================================================================
--- branches/upstream/swt-gtk/current/atk_custom.h	                        (rev 0)
+++ branches/upstream/swt-gtk/current/atk_custom.h	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,18 @@
+/*******************************************************************************
+* Copyright (c) 2000, 2004 IBM Corporation and others. All rights reserved.
+* The contents of this file are made available under the terms
+* of the GNU Lesser General Public License (LGPL) Version 2.1 that
+* accompanies this distribution (lgpl-v21.txt).  The LGPL is also
+* available at http://www.gnu.org/licenses/lgpl.html.  If the version
+* of the LGPL at http://www.gnu.org is different to the version of
+* the LGPL accompanying this distribution and there is any conflict
+* between the two license versions, the terms of the LGPL accompanying
+* this distribution shall govern.
+* 
+* Contributors:
+*     IBM Corporation - initial API and implementation
+*******************************************************************************/
+
+/* Special sizeof's */
+#define AtkObjectFactory_sizeof() sizeof(AtkObjectFactory)
+

Added: branches/upstream/swt-gtk/current/atk_stats.c
===================================================================
--- branches/upstream/swt-gtk/current/atk_stats.c	                        (rev 0)
+++ branches/upstream/swt-gtk/current/atk_stats.c	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,88 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 IBM Corporation and others. All rights reserved.
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt).  The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html.  If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+#include "swt.h"
+#include "atk_stats.h"
+
+#ifdef NATIVE_STATS
+
+int ATK_nativeFunctionCount = 42;
+int ATK_nativeFunctionCallCount[42];
+char * ATK_nativeFunctionNames[] = {
+	"AtkObjectFactoryClass_1sizeof",
+	"AtkObjectFactory_1sizeof",
+	"_1ATK_1ACTION_1GET_1IFACE",
+	"_1ATK_1COMPONENT_1GET_1IFACE",
+	"_1ATK_1OBJECT_1FACTORY_1CLASS",
+	"_1ATK_1SELECTION_1GET_1IFACE",
+	"_1ATK_1TEXT_1GET_1IFACE",
+	"_1GTK_1ACCESSIBLE",
+	"_1atk_1focus_1tracker_1notify",
+	"_1atk_1get_1default_1registry",
+	"_1atk_1object_1factory_1create_1accessible",
+	"_1atk_1object_1factory_1get_1accessible_1type",
+	"_1atk_1object_1initialize",
+	"_1atk_1object_1ref_1relation_1set",
+	"_1atk_1registry_1get_1factory",
+	"_1atk_1registry_1set_1factory_1type",
+	"_1atk_1relation_1set_1get_1n_1relations",
+	"_1atk_1relation_1set_1get_1relation",
+	"_1atk_1relation_1set_1remove",
+	"_1atk_1state_1set_1add_1state",
+	"_1atk_1state_1set_1new",
+	"_1call__II",
+	"_1call__III",
+	"_1call__IIII",
+	"_1call__IIIII",
+	"_1call__IIIIII",
+	"_1call__IIIIIII",
+	"memmove__ILorg_eclipse_swt_internal_accessibility_gtk_AtkActionIface_2",
+	"memmove__ILorg_eclipse_swt_internal_accessibility_gtk_AtkComponentIface_2",
+	"memmove__ILorg_eclipse_swt_internal_accessibility_gtk_AtkHypertextIface_2",
+	"memmove__ILorg_eclipse_swt_internal_accessibility_gtk_AtkObjectClass_2",
+	"memmove__ILorg_eclipse_swt_internal_accessibility_gtk_AtkObjectFactoryClass_2",
+	"memmove__ILorg_eclipse_swt_internal_accessibility_gtk_AtkSelectionIface_2",
+	"memmove__ILorg_eclipse_swt_internal_accessibility_gtk_AtkTextIface_2",
+	"memmove__Lorg_eclipse_swt_internal_accessibility_gtk_AtkActionIface_2I",
+	"memmove__Lorg_eclipse_swt_internal_accessibility_gtk_AtkComponentIface_2I",
+	"memmove__Lorg_eclipse_swt_internal_accessibility_gtk_AtkHypertextIface_2I",
+	"memmove__Lorg_eclipse_swt_internal_accessibility_gtk_AtkObjectClass_2I",
+	"memmove__Lorg_eclipse_swt_internal_accessibility_gtk_AtkObjectFactoryClass_2I",
+	"memmove__Lorg_eclipse_swt_internal_accessibility_gtk_AtkSelectionIface_2I",
+	"memmove__Lorg_eclipse_swt_internal_accessibility_gtk_AtkTextIface_2I",
+	"memmove__Lorg_eclipse_swt_internal_accessibility_gtk_GtkAccessible_2I",
+};
+
+#define STATS_NATIVE(func) Java_org_eclipse_swt_tools_internal_NativeStats_##func
+
+JNIEXPORT jint JNICALL STATS_NATIVE(ATK_1GetFunctionCount)
+	(JNIEnv *env, jclass that)
+{
+	return ATK_nativeFunctionCount;
+}
+
+JNIEXPORT jstring JNICALL STATS_NATIVE(ATK_1GetFunctionName)
+	(JNIEnv *env, jclass that, jint index)
+{
+	return (*env)->NewStringUTF(env, ATK_nativeFunctionNames[index]);
+}
+
+JNIEXPORT jint JNICALL STATS_NATIVE(ATK_1GetFunctionCallCount)
+	(JNIEnv *env, jclass that, jint index)
+{
+	return ATK_nativeFunctionCallCount[index];
+}
+
+#endif

Added: branches/upstream/swt-gtk/current/atk_stats.h
===================================================================
--- branches/upstream/swt-gtk/current/atk_stats.h	                        (rev 0)
+++ branches/upstream/swt-gtk/current/atk_stats.h	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,74 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 IBM Corporation and others. All rights reserved.
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt).  The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html.  If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+#ifdef NATIVE_STATS
+extern int ATK_nativeFunctionCount;
+extern int ATK_nativeFunctionCallCount[];
+extern char* ATK_nativeFunctionNames[];
+#define ATK_NATIVE_ENTER(env, that, func) ATK_nativeFunctionCallCount[func]++;
+#define ATK_NATIVE_EXIT(env, that, func) 
+#else
+#ifndef ATK_NATIVE_ENTER
+#define ATK_NATIVE_ENTER(env, that, func) 
+#endif
+#ifndef ATK_NATIVE_EXIT
+#define ATK_NATIVE_EXIT(env, that, func) 
+#endif
+#endif
+
+typedef enum {
+	AtkObjectFactoryClass_1sizeof_FUNC,
+	AtkObjectFactory_1sizeof_FUNC,
+	_1ATK_1ACTION_1GET_1IFACE_FUNC,
+	_1ATK_1COMPONENT_1GET_1IFACE_FUNC,
+	_1ATK_1OBJECT_1FACTORY_1CLASS_FUNC,
+	_1ATK_1SELECTION_1GET_1IFACE_FUNC,
+	_1ATK_1TEXT_1GET_1IFACE_FUNC,
+	_1GTK_1ACCESSIBLE_FUNC,
+	_1atk_1focus_1tracker_1notify_FUNC,
+	_1atk_1get_1default_1registry_FUNC,
+	_1atk_1object_1factory_1create_1accessible_FUNC,
+	_1atk_1object_1factory_1get_1accessible_1type_FUNC,
+	_1atk_1object_1initialize_FUNC,
+	_1atk_1object_1ref_1relation_1set_FUNC,
+	_1atk_1registry_1get_1factory_FUNC,
+	_1atk_1registry_1set_1factory_1type_FUNC,
+	_1atk_1relation_1set_1get_1n_1relations_FUNC,
+	_1atk_1relation_1set_1get_1relation_FUNC,
+	_1atk_1relation_1set_1remove_FUNC,
+	_1atk_1state_1set_1add_1state_FUNC,
+	_1atk_1state_1set_1new_FUNC,
+	_1call__II_FUNC,
+	_1call__III_FUNC,
+	_1call__IIII_FUNC,
+	_1call__IIIII_FUNC,
+	_1call__IIIIII_FUNC,
+	_1call__IIIIIII_FUNC,
+	memmove__ILorg_eclipse_swt_internal_accessibility_gtk_AtkActionIface_2_FUNC,
+	memmove__ILorg_eclipse_swt_internal_accessibility_gtk_AtkComponentIface_2_FUNC,
+	memmove__ILorg_eclipse_swt_internal_accessibility_gtk_AtkHypertextIface_2_FUNC,
+	memmove__ILorg_eclipse_swt_internal_accessibility_gtk_AtkObjectClass_2_FUNC,
+	memmove__ILorg_eclipse_swt_internal_accessibility_gtk_AtkObjectFactoryClass_2_FUNC,
+	memmove__ILorg_eclipse_swt_internal_accessibility_gtk_AtkSelectionIface_2_FUNC,
+	memmove__ILorg_eclipse_swt_internal_accessibility_gtk_AtkTextIface_2_FUNC,
+	memmove__Lorg_eclipse_swt_internal_accessibility_gtk_AtkActionIface_2I_FUNC,
+	memmove__Lorg_eclipse_swt_internal_accessibility_gtk_AtkComponentIface_2I_FUNC,
+	memmove__Lorg_eclipse_swt_internal_accessibility_gtk_AtkHypertextIface_2I_FUNC,
+	memmove__Lorg_eclipse_swt_internal_accessibility_gtk_AtkObjectClass_2I_FUNC,
+	memmove__Lorg_eclipse_swt_internal_accessibility_gtk_AtkObjectFactoryClass_2I_FUNC,
+	memmove__Lorg_eclipse_swt_internal_accessibility_gtk_AtkSelectionIface_2I_FUNC,
+	memmove__Lorg_eclipse_swt_internal_accessibility_gtk_AtkTextIface_2I_FUNC,
+	memmove__Lorg_eclipse_swt_internal_accessibility_gtk_GtkAccessible_2I_FUNC,
+} ATK_FUNCS;

Added: branches/upstream/swt-gtk/current/atk_structs.c
===================================================================
--- branches/upstream/swt-gtk/current/atk_structs.c	                        (rev 0)
+++ branches/upstream/swt-gtk/current/atk_structs.c	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,473 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 IBM Corporation and others. All rights reserved.
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt).  The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html.  If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+#include "swt.h"
+#include "atk_structs.h"
+
+#ifndef NO_AtkActionIface
+typedef struct AtkActionIface_FID_CACHE {
+	int cached;
+	jclass clazz;
+	jfieldID do_action, get_n_actions, get_description, get_name, get_keybinding, set_description;
+} AtkActionIface_FID_CACHE;
+
+AtkActionIface_FID_CACHE AtkActionIfaceFc;
+
+void cacheAtkActionIfaceFields(JNIEnv *env, jobject lpObject)
+{
+	if (AtkActionIfaceFc.cached) return;
+	AtkActionIfaceFc.clazz = (*env)->GetObjectClass(env, lpObject);
+	AtkActionIfaceFc.do_action = (*env)->GetFieldID(env, AtkActionIfaceFc.clazz, "do_action", "I");
+	AtkActionIfaceFc.get_n_actions = (*env)->GetFieldID(env, AtkActionIfaceFc.clazz, "get_n_actions", "I");
+	AtkActionIfaceFc.get_description = (*env)->GetFieldID(env, AtkActionIfaceFc.clazz, "get_description", "I");
+	AtkActionIfaceFc.get_name = (*env)->GetFieldID(env, AtkActionIfaceFc.clazz, "get_name", "I");
+	AtkActionIfaceFc.get_keybinding = (*env)->GetFieldID(env, AtkActionIfaceFc.clazz, "get_keybinding", "I");
+	AtkActionIfaceFc.set_description = (*env)->GetFieldID(env, AtkActionIfaceFc.clazz, "set_description", "I");
+	AtkActionIfaceFc.cached = 1;
+}
+
+AtkActionIface *getAtkActionIfaceFields(JNIEnv *env, jobject lpObject, AtkActionIface *lpStruct)
+{
+	if (!AtkActionIfaceFc.cached) cacheAtkActionIfaceFields(env, lpObject);
+	lpStruct->do_action = (gboolean (*)())(*env)->GetIntField(env, lpObject, AtkActionIfaceFc.do_action);
+	lpStruct->get_n_actions = (gint (*)())(*env)->GetIntField(env, lpObject, AtkActionIfaceFc.get_n_actions);
+	lpStruct->get_description = (G_CONST_RETURN gchar *(*)())(*env)->GetIntField(env, lpObject, AtkActionIfaceFc.get_description);
+	lpStruct->get_name = (G_CONST_RETURN gchar *(*)())(*env)->GetIntField(env, lpObject, AtkActionIfaceFc.get_name);
+	lpStruct->get_keybinding = (G_CONST_RETURN gchar *(*)())(*env)->GetIntField(env, lpObject, AtkActionIfaceFc.get_keybinding);
+	lpStruct->set_description = (gboolean (*)())(*env)->GetIntField(env, lpObject, AtkActionIfaceFc.set_description);
+	return lpStruct;
+}
+
+void setAtkActionIfaceFields(JNIEnv *env, jobject lpObject, AtkActionIface *lpStruct)
+{
+	if (!AtkActionIfaceFc.cached) cacheAtkActionIfaceFields(env, lpObject);
+	(*env)->SetIntField(env, lpObject, AtkActionIfaceFc.do_action, (jint)lpStruct->do_action);
+	(*env)->SetIntField(env, lpObject, AtkActionIfaceFc.get_n_actions, (jint)lpStruct->get_n_actions);
+	(*env)->SetIntField(env, lpObject, AtkActionIfaceFc.get_description, (jint)lpStruct->get_description);
+	(*env)->SetIntField(env, lpObject, AtkActionIfaceFc.get_name, (jint)lpStruct->get_name);
+	(*env)->SetIntField(env, lpObject, AtkActionIfaceFc.get_keybinding, (jint)lpStruct->get_keybinding);
+	(*env)->SetIntField(env, lpObject, AtkActionIfaceFc.set_description, (jint)lpStruct->set_description);
+}
+#endif
+
+#ifndef NO_AtkComponentIface
+typedef struct AtkComponentIface_FID_CACHE {
+	int cached;
+	jclass clazz;
+	jfieldID add_focus_handler, contains, ref_accessible_at_point, get_extents, get_position, get_size, grab_focus, remove_focus_handler, set_extents, set_position, set_size, get_layer, get_mdi_zorder;
+} AtkComponentIface_FID_CACHE;
+
+AtkComponentIface_FID_CACHE AtkComponentIfaceFc;
+
+void cacheAtkComponentIfaceFields(JNIEnv *env, jobject lpObject)
+{
+	if (AtkComponentIfaceFc.cached) return;
+	AtkComponentIfaceFc.clazz = (*env)->GetObjectClass(env, lpObject);
+	AtkComponentIfaceFc.add_focus_handler = (*env)->GetFieldID(env, AtkComponentIfaceFc.clazz, "add_focus_handler", "I");
+	AtkComponentIfaceFc.contains = (*env)->GetFieldID(env, AtkComponentIfaceFc.clazz, "contains", "I");
+	AtkComponentIfaceFc.ref_accessible_at_point = (*env)->GetFieldID(env, AtkComponentIfaceFc.clazz, "ref_accessible_at_point", "I");
+	AtkComponentIfaceFc.get_extents = (*env)->GetFieldID(env, AtkComponentIfaceFc.clazz, "get_extents", "I");
+	AtkComponentIfaceFc.get_position = (*env)->GetFieldID(env, AtkComponentIfaceFc.clazz, "get_position", "I");
+	AtkComponentIfaceFc.get_size = (*env)->GetFieldID(env, AtkComponentIfaceFc.clazz, "get_size", "I");
+	AtkComponentIfaceFc.grab_focus = (*env)->GetFieldID(env, AtkComponentIfaceFc.clazz, "grab_focus", "I");
+	AtkComponentIfaceFc.remove_focus_handler = (*env)->GetFieldID(env, AtkComponentIfaceFc.clazz, "remove_focus_handler", "I");
+	AtkComponentIfaceFc.set_extents = (*env)->GetFieldID(env, AtkComponentIfaceFc.clazz, "set_extents", "I");
+	AtkComponentIfaceFc.set_position = (*env)->GetFieldID(env, AtkComponentIfaceFc.clazz, "set_position", "I");
+	AtkComponentIfaceFc.set_size = (*env)->GetFieldID(env, AtkComponentIfaceFc.clazz, "set_size", "I");
+	AtkComponentIfaceFc.get_layer = (*env)->GetFieldID(env, AtkComponentIfaceFc.clazz, "get_layer", "I");
+	AtkComponentIfaceFc.get_mdi_zorder = (*env)->GetFieldID(env, AtkComponentIfaceFc.clazz, "get_mdi_zorder", "I");
+	AtkComponentIfaceFc.cached = 1;
+}
+
+AtkComponentIface *getAtkComponentIfaceFields(JNIEnv *env, jobject lpObject, AtkComponentIface *lpStruct)
+{
+	if (!AtkComponentIfaceFc.cached) cacheAtkComponentIfaceFields(env, lpObject);
+	lpStruct->add_focus_handler = (guint (*)())(*env)->GetIntField(env, lpObject, AtkComponentIfaceFc.add_focus_handler);
+	lpStruct->contains = (gboolean (*)())(*env)->GetIntField(env, lpObject, AtkComponentIfaceFc.contains);
+	lpStruct->ref_accessible_at_point = (AtkObject *(*)())(*env)->GetIntField(env, lpObject, AtkComponentIfaceFc.ref_accessible_at_point);
+	lpStruct->get_extents = (void (*)())(*env)->GetIntField(env, lpObject, AtkComponentIfaceFc.get_extents);
+	lpStruct->get_position = (void (*)())(*env)->GetIntField(env, lpObject, AtkComponentIfaceFc.get_position);
+	lpStruct->get_size = (void (*)())(*env)->GetIntField(env, lpObject, AtkComponentIfaceFc.get_size);
+	lpStruct->grab_focus = (gboolean (*)())(*env)->GetIntField(env, lpObject, AtkComponentIfaceFc.grab_focus);
+	lpStruct->remove_focus_handler = (void (*)())(*env)->GetIntField(env, lpObject, AtkComponentIfaceFc.remove_focus_handler);
+	lpStruct->set_extents = (gboolean (*)())(*env)->GetIntField(env, lpObject, AtkComponentIfaceFc.set_extents);
+	lpStruct->set_position = (gboolean (*)())(*env)->GetIntField(env, lpObject, AtkComponentIfaceFc.set_position);
+	lpStruct->set_size = (gboolean (*)())(*env)->GetIntField(env, lpObject, AtkComponentIfaceFc.set_size);
+	lpStruct->get_layer = (AtkLayer (*)())(*env)->GetIntField(env, lpObject, AtkComponentIfaceFc.get_layer);
+	lpStruct->get_mdi_zorder = (gint (*)())(*env)->GetIntField(env, lpObject, AtkComponentIfaceFc.get_mdi_zorder);
+	return lpStruct;
+}
+
+void setAtkComponentIfaceFields(JNIEnv *env, jobject lpObject, AtkComponentIface *lpStruct)
+{
+	if (!AtkComponentIfaceFc.cached) cacheAtkComponentIfaceFields(env, lpObject);
+	(*env)->SetIntField(env, lpObject, AtkComponentIfaceFc.add_focus_handler, (jint)lpStruct->add_focus_handler);
+	(*env)->SetIntField(env, lpObject, AtkComponentIfaceFc.contains, (jint)lpStruct->contains);
+	(*env)->SetIntField(env, lpObject, AtkComponentIfaceFc.ref_accessible_at_point, (jint)lpStruct->ref_accessible_at_point);
+	(*env)->SetIntField(env, lpObject, AtkComponentIfaceFc.get_extents, (jint)lpStruct->get_extents);
+	(*env)->SetIntField(env, lpObject, AtkComponentIfaceFc.get_position, (jint)lpStruct->get_position);
+	(*env)->SetIntField(env, lpObject, AtkComponentIfaceFc.get_size, (jint)lpStruct->get_size);
+	(*env)->SetIntField(env, lpObject, AtkComponentIfaceFc.grab_focus, (jint)lpStruct->grab_focus);
+	(*env)->SetIntField(env, lpObject, AtkComponentIfaceFc.remove_focus_handler, (jint)lpStruct->remove_focus_handler);
+	(*env)->SetIntField(env, lpObject, AtkComponentIfaceFc.set_extents, (jint)lpStruct->set_extents);
+	(*env)->SetIntField(env, lpObject, AtkComponentIfaceFc.set_position, (jint)lpStruct->set_position);
+	(*env)->SetIntField(env, lpObject, AtkComponentIfaceFc.set_size, (jint)lpStruct->set_size);
+	(*env)->SetIntField(env, lpObject, AtkComponentIfaceFc.get_layer, (jint)lpStruct->get_layer);
+	(*env)->SetIntField(env, lpObject, AtkComponentIfaceFc.get_mdi_zorder, (jint)lpStruct->get_mdi_zorder);
+}
+#endif
+
+#ifndef NO_AtkHypertextIface
+typedef struct AtkHypertextIface_FID_CACHE {
+	int cached;
+	jclass clazz;
+	jfieldID get_link, get_n_links, get_link_index;
+} AtkHypertextIface_FID_CACHE;
+
+AtkHypertextIface_FID_CACHE AtkHypertextIfaceFc;
+
+void cacheAtkHypertextIfaceFields(JNIEnv *env, jobject lpObject)
+{
+	if (AtkHypertextIfaceFc.cached) return;
+	AtkHypertextIfaceFc.clazz = (*env)->GetObjectClass(env, lpObject);
+	AtkHypertextIfaceFc.get_link = (*env)->GetFieldID(env, AtkHypertextIfaceFc.clazz, "get_link", "I");
+	AtkHypertextIfaceFc.get_n_links = (*env)->GetFieldID(env, AtkHypertextIfaceFc.clazz, "get_n_links", "I");
+	AtkHypertextIfaceFc.get_link_index = (*env)->GetFieldID(env, AtkHypertextIfaceFc.clazz, "get_link_index", "I");
+	AtkHypertextIfaceFc.cached = 1;
+}
+
+AtkHypertextIface *getAtkHypertextIfaceFields(JNIEnv *env, jobject lpObject, AtkHypertextIface *lpStruct)
+{
+	if (!AtkHypertextIfaceFc.cached) cacheAtkHypertextIfaceFields(env, lpObject);
+	lpStruct->get_link = (AtkHyperlink *(*)())(*env)->GetIntField(env, lpObject, AtkHypertextIfaceFc.get_link);
+	lpStruct->get_n_links = (gint (*)())(*env)->GetIntField(env, lpObject, AtkHypertextIfaceFc.get_n_links);
+	lpStruct->get_link_index = (gint (*)())(*env)->GetIntField(env, lpObject, AtkHypertextIfaceFc.get_link_index);
+	return lpStruct;
+}
+
+void setAtkHypertextIfaceFields(JNIEnv *env, jobject lpObject, AtkHypertextIface *lpStruct)
+{
+	if (!AtkHypertextIfaceFc.cached) cacheAtkHypertextIfaceFields(env, lpObject);
+	(*env)->SetIntField(env, lpObject, AtkHypertextIfaceFc.get_link, (jint)lpStruct->get_link);
+	(*env)->SetIntField(env, lpObject, AtkHypertextIfaceFc.get_n_links, (jint)lpStruct->get_n_links);
+	(*env)->SetIntField(env, lpObject, AtkHypertextIfaceFc.get_link_index, (jint)lpStruct->get_link_index);
+}
+#endif
+
+#ifndef NO_AtkObjectClass
+typedef struct AtkObjectClass_FID_CACHE {
+	int cached;
+	jclass clazz;
+	jfieldID get_name, get_description, get_parent, get_n_children, ref_child, get_index_in_parent, ref_relation_set, get_role, get_layer, get_mdi_zorder, ref_state_set, set_name, set_description, set_parent, set_role, connect_property_change_handler, remove_property_change_handler, initialize, children_changed, focus_event, property_change, state_change, visible_data_changed;
+} AtkObjectClass_FID_CACHE;
+
+AtkObjectClass_FID_CACHE AtkObjectClassFc;
+
+void cacheAtkObjectClassFields(JNIEnv *env, jobject lpObject)
+{
+	if (AtkObjectClassFc.cached) return;
+	AtkObjectClassFc.clazz = (*env)->GetObjectClass(env, lpObject);
+	AtkObjectClassFc.get_name = (*env)->GetFieldID(env, AtkObjectClassFc.clazz, "get_name", "I");
+	AtkObjectClassFc.get_description = (*env)->GetFieldID(env, AtkObjectClassFc.clazz, "get_description", "I");
+	AtkObjectClassFc.get_parent = (*env)->GetFieldID(env, AtkObjectClassFc.clazz, "get_parent", "I");
+	AtkObjectClassFc.get_n_children = (*env)->GetFieldID(env, AtkObjectClassFc.clazz, "get_n_children", "I");
+	AtkObjectClassFc.ref_child = (*env)->GetFieldID(env, AtkObjectClassFc.clazz, "ref_child", "I");
+	AtkObjectClassFc.get_index_in_parent = (*env)->GetFieldID(env, AtkObjectClassFc.clazz, "get_index_in_parent", "I");
+	AtkObjectClassFc.ref_relation_set = (*env)->GetFieldID(env, AtkObjectClassFc.clazz, "ref_relation_set", "I");
+	AtkObjectClassFc.get_role = (*env)->GetFieldID(env, AtkObjectClassFc.clazz, "get_role", "I");
+	AtkObjectClassFc.get_layer = (*env)->GetFieldID(env, AtkObjectClassFc.clazz, "get_layer", "I");
+	AtkObjectClassFc.get_mdi_zorder = (*env)->GetFieldID(env, AtkObjectClassFc.clazz, "get_mdi_zorder", "I");
+	AtkObjectClassFc.ref_state_set = (*env)->GetFieldID(env, AtkObjectClassFc.clazz, "ref_state_set", "I");
+	AtkObjectClassFc.set_name = (*env)->GetFieldID(env, AtkObjectClassFc.clazz, "set_name", "I");
+	AtkObjectClassFc.set_description = (*env)->GetFieldID(env, AtkObjectClassFc.clazz, "set_description", "I");
+	AtkObjectClassFc.set_parent = (*env)->GetFieldID(env, AtkObjectClassFc.clazz, "set_parent", "I");
+	AtkObjectClassFc.set_role = (*env)->GetFieldID(env, AtkObjectClassFc.clazz, "set_role", "I");
+	AtkObjectClassFc.connect_property_change_handler = (*env)->GetFieldID(env, AtkObjectClassFc.clazz, "connect_property_change_handler", "I");
+	AtkObjectClassFc.remove_property_change_handler = (*env)->GetFieldID(env, AtkObjectClassFc.clazz, "remove_property_change_handler", "I");
+	AtkObjectClassFc.initialize = (*env)->GetFieldID(env, AtkObjectClassFc.clazz, "initialize", "I");
+	AtkObjectClassFc.children_changed = (*env)->GetFieldID(env, AtkObjectClassFc.clazz, "children_changed", "I");
+	AtkObjectClassFc.focus_event = (*env)->GetFieldID(env, AtkObjectClassFc.clazz, "focus_event", "I");
+	AtkObjectClassFc.property_change = (*env)->GetFieldID(env, AtkObjectClassFc.clazz, "property_change", "I");
+	AtkObjectClassFc.state_change = (*env)->GetFieldID(env, AtkObjectClassFc.clazz, "state_change", "I");
+	AtkObjectClassFc.visible_data_changed = (*env)->GetFieldID(env, AtkObjectClassFc.clazz, "visible_data_changed", "I");
+	AtkObjectClassFc.cached = 1;
+}
+
+AtkObjectClass *getAtkObjectClassFields(JNIEnv *env, jobject lpObject, AtkObjectClass *lpStruct)
+{
+	if (!AtkObjectClassFc.cached) cacheAtkObjectClassFields(env, lpObject);
+	lpStruct->get_name = (G_CONST_RETURN gchar *(*)())(*env)->GetIntField(env, lpObject, AtkObjectClassFc.get_name);
+	lpStruct->get_description = (G_CONST_RETURN gchar *(*)())(*env)->GetIntField(env, lpObject, AtkObjectClassFc.get_description);
+	lpStruct->get_parent = (AtkObject *(*)())(*env)->GetIntField(env, lpObject, AtkObjectClassFc.get_parent);
+	lpStruct->get_n_children = (gint (*)())(*env)->GetIntField(env, lpObject, AtkObjectClassFc.get_n_children);
+	lpStruct->ref_child = (AtkObject *(*)())(*env)->GetIntField(env, lpObject, AtkObjectClassFc.ref_child);
+	lpStruct->get_index_in_parent = (gint (*)())(*env)->GetIntField(env, lpObject, AtkObjectClassFc.get_index_in_parent);
+	lpStruct->ref_relation_set = (AtkRelationSet *(*)())(*env)->GetIntField(env, lpObject, AtkObjectClassFc.ref_relation_set);
+	lpStruct->get_role = (AtkRole (*)())(*env)->GetIntField(env, lpObject, AtkObjectClassFc.get_role);
+	lpStruct->get_layer = (AtkLayer (*)())(*env)->GetIntField(env, lpObject, AtkObjectClassFc.get_layer);
+	lpStruct->get_mdi_zorder = (gint (*)())(*env)->GetIntField(env, lpObject, AtkObjectClassFc.get_mdi_zorder);
+	lpStruct->ref_state_set = (AtkStateSet *(*)())(*env)->GetIntField(env, lpObject, AtkObjectClassFc.ref_state_set);
+	lpStruct->set_name = (void (*)())(*env)->GetIntField(env, lpObject, AtkObjectClassFc.set_name);
+	lpStruct->set_description = (void (*)())(*env)->GetIntField(env, lpObject, AtkObjectClassFc.set_description);
+	lpStruct->set_parent = (void (*)())(*env)->GetIntField(env, lpObject, AtkObjectClassFc.set_parent);
+	lpStruct->set_role = (void (*)())(*env)->GetIntField(env, lpObject, AtkObjectClassFc.set_role);
+	lpStruct->connect_property_change_handler = (guint (*)())(*env)->GetIntField(env, lpObject, AtkObjectClassFc.connect_property_change_handler);
+	lpStruct->remove_property_change_handler = (void (*)())(*env)->GetIntField(env, lpObject, AtkObjectClassFc.remove_property_change_handler);
+	lpStruct->initialize = (void (*)())(*env)->GetIntField(env, lpObject, AtkObjectClassFc.initialize);
+	lpStruct->children_changed = (void (*)())(*env)->GetIntField(env, lpObject, AtkObjectClassFc.children_changed);
+	lpStruct->focus_event = (void (*)())(*env)->GetIntField(env, lpObject, AtkObjectClassFc.focus_event);
+	lpStruct->property_change = (void (*)())(*env)->GetIntField(env, lpObject, AtkObjectClassFc.property_change);
+	lpStruct->state_change = (void (*)())(*env)->GetIntField(env, lpObject, AtkObjectClassFc.state_change);
+	lpStruct->visible_data_changed = (void (*)())(*env)->GetIntField(env, lpObject, AtkObjectClassFc.visible_data_changed);
+	return lpStruct;
+}
+
+void setAtkObjectClassFields(JNIEnv *env, jobject lpObject, AtkObjectClass *lpStruct)
+{
+	if (!AtkObjectClassFc.cached) cacheAtkObjectClassFields(env, lpObject);
+	(*env)->SetIntField(env, lpObject, AtkObjectClassFc.get_name, (jint)lpStruct->get_name);
+	(*env)->SetIntField(env, lpObject, AtkObjectClassFc.get_description, (jint)lpStruct->get_description);
+	(*env)->SetIntField(env, lpObject, AtkObjectClassFc.get_parent, (jint)lpStruct->get_parent);
+	(*env)->SetIntField(env, lpObject, AtkObjectClassFc.get_n_children, (jint)lpStruct->get_n_children);
+	(*env)->SetIntField(env, lpObject, AtkObjectClassFc.ref_child, (jint)lpStruct->ref_child);
+	(*env)->SetIntField(env, lpObject, AtkObjectClassFc.get_index_in_parent, (jint)lpStruct->get_index_in_parent);
+	(*env)->SetIntField(env, lpObject, AtkObjectClassFc.ref_relation_set, (jint)lpStruct->ref_relation_set);
+	(*env)->SetIntField(env, lpObject, AtkObjectClassFc.get_role, (jint)lpStruct->get_role);
+	(*env)->SetIntField(env, lpObject, AtkObjectClassFc.get_layer, (jint)lpStruct->get_layer);
+	(*env)->SetIntField(env, lpObject, AtkObjectClassFc.get_mdi_zorder, (jint)lpStruct->get_mdi_zorder);
+	(*env)->SetIntField(env, lpObject, AtkObjectClassFc.ref_state_set, (jint)lpStruct->ref_state_set);
+	(*env)->SetIntField(env, lpObject, AtkObjectClassFc.set_name, (jint)lpStruct->set_name);
+	(*env)->SetIntField(env, lpObject, AtkObjectClassFc.set_description, (jint)lpStruct->set_description);
+	(*env)->SetIntField(env, lpObject, AtkObjectClassFc.set_parent, (jint)lpStruct->set_parent);
+	(*env)->SetIntField(env, lpObject, AtkObjectClassFc.set_role, (jint)lpStruct->set_role);
+	(*env)->SetIntField(env, lpObject, AtkObjectClassFc.connect_property_change_handler, (jint)lpStruct->connect_property_change_handler);
+	(*env)->SetIntField(env, lpObject, AtkObjectClassFc.remove_property_change_handler, (jint)lpStruct->remove_property_change_handler);
+	(*env)->SetIntField(env, lpObject, AtkObjectClassFc.initialize, (jint)lpStruct->initialize);
+	(*env)->SetIntField(env, lpObject, AtkObjectClassFc.children_changed, (jint)lpStruct->children_changed);
+	(*env)->SetIntField(env, lpObject, AtkObjectClassFc.focus_event, (jint)lpStruct->focus_event);
+	(*env)->SetIntField(env, lpObject, AtkObjectClassFc.property_change, (jint)lpStruct->property_change);
+	(*env)->SetIntField(env, lpObject, AtkObjectClassFc.state_change, (jint)lpStruct->state_change);
+	(*env)->SetIntField(env, lpObject, AtkObjectClassFc.visible_data_changed, (jint)lpStruct->visible_data_changed);
+}
+#endif
+
+#ifndef NO_AtkObjectFactoryClass
+typedef struct AtkObjectFactoryClass_FID_CACHE {
+	int cached;
+	jclass clazz;
+	jfieldID create_accessible, invalidate, get_accessible_type;
+} AtkObjectFactoryClass_FID_CACHE;
+
+AtkObjectFactoryClass_FID_CACHE AtkObjectFactoryClassFc;
+
+void cacheAtkObjectFactoryClassFields(JNIEnv *env, jobject lpObject)
+{
+	if (AtkObjectFactoryClassFc.cached) return;
+	AtkObjectFactoryClassFc.clazz = (*env)->GetObjectClass(env, lpObject);
+	AtkObjectFactoryClassFc.create_accessible = (*env)->GetFieldID(env, AtkObjectFactoryClassFc.clazz, "create_accessible", "I");
+	AtkObjectFactoryClassFc.invalidate = (*env)->GetFieldID(env, AtkObjectFactoryClassFc.clazz, "invalidate", "I");
+	AtkObjectFactoryClassFc.get_accessible_type = (*env)->GetFieldID(env, AtkObjectFactoryClassFc.clazz, "get_accessible_type", "I");
+	AtkObjectFactoryClassFc.cached = 1;
+}
+
+AtkObjectFactoryClass *getAtkObjectFactoryClassFields(JNIEnv *env, jobject lpObject, AtkObjectFactoryClass *lpStruct)
+{
+	if (!AtkObjectFactoryClassFc.cached) cacheAtkObjectFactoryClassFields(env, lpObject);
+	lpStruct->create_accessible = (AtkObject *(*)())(*env)->GetIntField(env, lpObject, AtkObjectFactoryClassFc.create_accessible);
+	lpStruct->invalidate = (void (*)())(*env)->GetIntField(env, lpObject, AtkObjectFactoryClassFc.invalidate);
+	lpStruct->get_accessible_type = (GType (*)())(*env)->GetIntField(env, lpObject, AtkObjectFactoryClassFc.get_accessible_type);
+	return lpStruct;
+}
+
+void setAtkObjectFactoryClassFields(JNIEnv *env, jobject lpObject, AtkObjectFactoryClass *lpStruct)
+{
+	if (!AtkObjectFactoryClassFc.cached) cacheAtkObjectFactoryClassFields(env, lpObject);
+	(*env)->SetIntField(env, lpObject, AtkObjectFactoryClassFc.create_accessible, (jint)lpStruct->create_accessible);
+	(*env)->SetIntField(env, lpObject, AtkObjectFactoryClassFc.invalidate, (jint)lpStruct->invalidate);
+	(*env)->SetIntField(env, lpObject, AtkObjectFactoryClassFc.get_accessible_type, (jint)lpStruct->get_accessible_type);
+}
+#endif
+
+#ifndef NO_AtkSelectionIface
+typedef struct AtkSelectionIface_FID_CACHE {
+	int cached;
+	jclass clazz;
+	jfieldID add_selection, clear_selection, ref_selection, get_selection_count, is_child_selected, remove_selection, select_all_selection, selection_changed;
+} AtkSelectionIface_FID_CACHE;
+
+AtkSelectionIface_FID_CACHE AtkSelectionIfaceFc;
+
+void cacheAtkSelectionIfaceFields(JNIEnv *env, jobject lpObject)
+{
+	if (AtkSelectionIfaceFc.cached) return;
+	AtkSelectionIfaceFc.clazz = (*env)->GetObjectClass(env, lpObject);
+	AtkSelectionIfaceFc.add_selection = (*env)->GetFieldID(env, AtkSelectionIfaceFc.clazz, "add_selection", "I");
+	AtkSelectionIfaceFc.clear_selection = (*env)->GetFieldID(env, AtkSelectionIfaceFc.clazz, "clear_selection", "I");
+	AtkSelectionIfaceFc.ref_selection = (*env)->GetFieldID(env, AtkSelectionIfaceFc.clazz, "ref_selection", "I");
+	AtkSelectionIfaceFc.get_selection_count = (*env)->GetFieldID(env, AtkSelectionIfaceFc.clazz, "get_selection_count", "I");
+	AtkSelectionIfaceFc.is_child_selected = (*env)->GetFieldID(env, AtkSelectionIfaceFc.clazz, "is_child_selected", "I");
+	AtkSelectionIfaceFc.remove_selection = (*env)->GetFieldID(env, AtkSelectionIfaceFc.clazz, "remove_selection", "I");
+	AtkSelectionIfaceFc.select_all_selection = (*env)->GetFieldID(env, AtkSelectionIfaceFc.clazz, "select_all_selection", "I");
+	AtkSelectionIfaceFc.selection_changed = (*env)->GetFieldID(env, AtkSelectionIfaceFc.clazz, "selection_changed", "I");
+	AtkSelectionIfaceFc.cached = 1;
+}
+
+AtkSelectionIface *getAtkSelectionIfaceFields(JNIEnv *env, jobject lpObject, AtkSelectionIface *lpStruct)
+{
+	if (!AtkSelectionIfaceFc.cached) cacheAtkSelectionIfaceFields(env, lpObject);
+	lpStruct->add_selection = (gboolean (*)())(*env)->GetIntField(env, lpObject, AtkSelectionIfaceFc.add_selection);
+	lpStruct->clear_selection = (gboolean (*)())(*env)->GetIntField(env, lpObject, AtkSelectionIfaceFc.clear_selection);
+	lpStruct->ref_selection = (AtkObject *(*)())(*env)->GetIntField(env, lpObject, AtkSelectionIfaceFc.ref_selection);
+	lpStruct->get_selection_count = (gint (*)())(*env)->GetIntField(env, lpObject, AtkSelectionIfaceFc.get_selection_count);
+	lpStruct->is_child_selected = (gboolean (*)())(*env)->GetIntField(env, lpObject, AtkSelectionIfaceFc.is_child_selected);
+	lpStruct->remove_selection = (gboolean (*)())(*env)->GetIntField(env, lpObject, AtkSelectionIfaceFc.remove_selection);
+	lpStruct->select_all_selection = (gboolean (*)())(*env)->GetIntField(env, lpObject, AtkSelectionIfaceFc.select_all_selection);
+	lpStruct->selection_changed = (void (*)())(*env)->GetIntField(env, lpObject, AtkSelectionIfaceFc.selection_changed);
+	return lpStruct;
+}
+
+void setAtkSelectionIfaceFields(JNIEnv *env, jobject lpObject, AtkSelectionIface *lpStruct)
+{
+	if (!AtkSelectionIfaceFc.cached) cacheAtkSelectionIfaceFields(env, lpObject);
+	(*env)->SetIntField(env, lpObject, AtkSelectionIfaceFc.add_selection, (jint)lpStruct->add_selection);
+	(*env)->SetIntField(env, lpObject, AtkSelectionIfaceFc.clear_selection, (jint)lpStruct->clear_selection);
+	(*env)->SetIntField(env, lpObject, AtkSelectionIfaceFc.ref_selection, (jint)lpStruct->ref_selection);
+	(*env)->SetIntField(env, lpObject, AtkSelectionIfaceFc.get_selection_count, (jint)lpStruct->get_selection_count);
+	(*env)->SetIntField(env, lpObject, AtkSelectionIfaceFc.is_child_selected, (jint)lpStruct->is_child_selected);
+	(*env)->SetIntField(env, lpObject, AtkSelectionIfaceFc.remove_selection, (jint)lpStruct->remove_selection);
+	(*env)->SetIntField(env, lpObject, AtkSelectionIfaceFc.select_all_selection, (jint)lpStruct->select_all_selection);
+	(*env)->SetIntField(env, lpObject, AtkSelectionIfaceFc.selection_changed, (jint)lpStruct->selection_changed);
+}
+#endif
+
+#ifndef NO_AtkTextIface
+typedef struct AtkTextIface_FID_CACHE {
+	int cached;
+	jclass clazz;
+	jfieldID get_text, get_text_after_offset, get_text_at_offset, get_character_at_offset, get_text_before_offset, get_caret_offset, get_run_attributes, get_default_attributes, get_character_extents, get_character_count, get_offset_at_point, get_n_selections, get_selection, add_selection, remove_selection, set_selection, set_caret_offset, text_changed, text_caret_moved, text_selection_changed;
+} AtkTextIface_FID_CACHE;
+
+AtkTextIface_FID_CACHE AtkTextIfaceFc;
+
+void cacheAtkTextIfaceFields(JNIEnv *env, jobject lpObject)
+{
+	if (AtkTextIfaceFc.cached) return;
+	AtkTextIfaceFc.clazz = (*env)->GetObjectClass(env, lpObject);
+	AtkTextIfaceFc.get_text = (*env)->GetFieldID(env, AtkTextIfaceFc.clazz, "get_text", "I");
+	AtkTextIfaceFc.get_text_after_offset = (*env)->GetFieldID(env, AtkTextIfaceFc.clazz, "get_text_after_offset", "I");
+	AtkTextIfaceFc.get_text_at_offset = (*env)->GetFieldID(env, AtkTextIfaceFc.clazz, "get_text_at_offset", "I");
+	AtkTextIfaceFc.get_character_at_offset = (*env)->GetFieldID(env, AtkTextIfaceFc.clazz, "get_character_at_offset", "I");
+	AtkTextIfaceFc.get_text_before_offset = (*env)->GetFieldID(env, AtkTextIfaceFc.clazz, "get_text_before_offset", "I");
+	AtkTextIfaceFc.get_caret_offset = (*env)->GetFieldID(env, AtkTextIfaceFc.clazz, "get_caret_offset", "I");
+	AtkTextIfaceFc.get_run_attributes = (*env)->GetFieldID(env, AtkTextIfaceFc.clazz, "get_run_attributes", "I");
+	AtkTextIfaceFc.get_default_attributes = (*env)->GetFieldID(env, AtkTextIfaceFc.clazz, "get_default_attributes", "I");
+	AtkTextIfaceFc.get_character_extents = (*env)->GetFieldID(env, AtkTextIfaceFc.clazz, "get_character_extents", "I");
+	AtkTextIfaceFc.get_character_count = (*env)->GetFieldID(env, AtkTextIfaceFc.clazz, "get_character_count", "I");
+	AtkTextIfaceFc.get_offset_at_point = (*env)->GetFieldID(env, AtkTextIfaceFc.clazz, "get_offset_at_point", "I");
+	AtkTextIfaceFc.get_n_selections = (*env)->GetFieldID(env, AtkTextIfaceFc.clazz, "get_n_selections", "I");
+	AtkTextIfaceFc.get_selection = (*env)->GetFieldID(env, AtkTextIfaceFc.clazz, "get_selection", "I");
+	AtkTextIfaceFc.add_selection = (*env)->GetFieldID(env, AtkTextIfaceFc.clazz, "add_selection", "I");
+	AtkTextIfaceFc.remove_selection = (*env)->GetFieldID(env, AtkTextIfaceFc.clazz, "remove_selection", "I");
+	AtkTextIfaceFc.set_selection = (*env)->GetFieldID(env, AtkTextIfaceFc.clazz, "set_selection", "I");
+	AtkTextIfaceFc.set_caret_offset = (*env)->GetFieldID(env, AtkTextIfaceFc.clazz, "set_caret_offset", "I");
+	AtkTextIfaceFc.text_changed = (*env)->GetFieldID(env, AtkTextIfaceFc.clazz, "text_changed", "I");
+	AtkTextIfaceFc.text_caret_moved = (*env)->GetFieldID(env, AtkTextIfaceFc.clazz, "text_caret_moved", "I");
+	AtkTextIfaceFc.text_selection_changed = (*env)->GetFieldID(env, AtkTextIfaceFc.clazz, "text_selection_changed", "I");
+	AtkTextIfaceFc.cached = 1;
+}
+
+AtkTextIface *getAtkTextIfaceFields(JNIEnv *env, jobject lpObject, AtkTextIface *lpStruct)
+{
+	if (!AtkTextIfaceFc.cached) cacheAtkTextIfaceFields(env, lpObject);
+	lpStruct->get_text = (gchar *(*)())(*env)->GetIntField(env, lpObject, AtkTextIfaceFc.get_text);
+	lpStruct->get_text_after_offset = (gchar *(*)())(*env)->GetIntField(env, lpObject, AtkTextIfaceFc.get_text_after_offset);
+	lpStruct->get_text_at_offset = (gchar *(*)())(*env)->GetIntField(env, lpObject, AtkTextIfaceFc.get_text_at_offset);
+	lpStruct->get_character_at_offset = (gunichar (*)())(*env)->GetIntField(env, lpObject, AtkTextIfaceFc.get_character_at_offset);
+	lpStruct->get_text_before_offset = (gchar *(*)())(*env)->GetIntField(env, lpObject, AtkTextIfaceFc.get_text_before_offset);
+	lpStruct->get_caret_offset = (gint (*)())(*env)->GetIntField(env, lpObject, AtkTextIfaceFc.get_caret_offset);
+	lpStruct->get_run_attributes = (AtkAttributeSet *(*)())(*env)->GetIntField(env, lpObject, AtkTextIfaceFc.get_run_attributes);
+	lpStruct->get_default_attributes = (AtkAttributeSet *(*)())(*env)->GetIntField(env, lpObject, AtkTextIfaceFc.get_default_attributes);
+	lpStruct->get_character_extents = (void (*)())(*env)->GetIntField(env, lpObject, AtkTextIfaceFc.get_character_extents);
+	lpStruct->get_character_count = (gint (*)())(*env)->GetIntField(env, lpObject, AtkTextIfaceFc.get_character_count);
+	lpStruct->get_offset_at_point = (gint (*)())(*env)->GetIntField(env, lpObject, AtkTextIfaceFc.get_offset_at_point);
+	lpStruct->get_n_selections = (gint (*)())(*env)->GetIntField(env, lpObject, AtkTextIfaceFc.get_n_selections);
+	lpStruct->get_selection = (gchar *(*)())(*env)->GetIntField(env, lpObject, AtkTextIfaceFc.get_selection);
+	lpStruct->add_selection = (gboolean (*)())(*env)->GetIntField(env, lpObject, AtkTextIfaceFc.add_selection);
+	lpStruct->remove_selection = (gboolean (*)())(*env)->GetIntField(env, lpObject, AtkTextIfaceFc.remove_selection);
+	lpStruct->set_selection = (gboolean (*)())(*env)->GetIntField(env, lpObject, AtkTextIfaceFc.set_selection);
+	lpStruct->set_caret_offset = (gboolean (*)())(*env)->GetIntField(env, lpObject, AtkTextIfaceFc.set_caret_offset);
+	lpStruct->text_changed = (void (*)())(*env)->GetIntField(env, lpObject, AtkTextIfaceFc.text_changed);
+	lpStruct->text_caret_moved = (void (*)())(*env)->GetIntField(env, lpObject, AtkTextIfaceFc.text_caret_moved);
+	lpStruct->text_selection_changed = (void (*)())(*env)->GetIntField(env, lpObject, AtkTextIfaceFc.text_selection_changed);
+	return lpStruct;
+}
+
+void setAtkTextIfaceFields(JNIEnv *env, jobject lpObject, AtkTextIface *lpStruct)
+{
+	if (!AtkTextIfaceFc.cached) cacheAtkTextIfaceFields(env, lpObject);
+	(*env)->SetIntField(env, lpObject, AtkTextIfaceFc.get_text, (jint)lpStruct->get_text);
+	(*env)->SetIntField(env, lpObject, AtkTextIfaceFc.get_text_after_offset, (jint)lpStruct->get_text_after_offset);
+	(*env)->SetIntField(env, lpObject, AtkTextIfaceFc.get_text_at_offset, (jint)lpStruct->get_text_at_offset);
+	(*env)->SetIntField(env, lpObject, AtkTextIfaceFc.get_character_at_offset, (jint)lpStruct->get_character_at_offset);
+	(*env)->SetIntField(env, lpObject, AtkTextIfaceFc.get_text_before_offset, (jint)lpStruct->get_text_before_offset);
+	(*env)->SetIntField(env, lpObject, AtkTextIfaceFc.get_caret_offset, (jint)lpStruct->get_caret_offset);
+	(*env)->SetIntField(env, lpObject, AtkTextIfaceFc.get_run_attributes, (jint)lpStruct->get_run_attributes);
+	(*env)->SetIntField(env, lpObject, AtkTextIfaceFc.get_default_attributes, (jint)lpStruct->get_default_attributes);
+	(*env)->SetIntField(env, lpObject, AtkTextIfaceFc.get_character_extents, (jint)lpStruct->get_character_extents);
+	(*env)->SetIntField(env, lpObject, AtkTextIfaceFc.get_character_count, (jint)lpStruct->get_character_count);
+	(*env)->SetIntField(env, lpObject, AtkTextIfaceFc.get_offset_at_point, (jint)lpStruct->get_offset_at_point);
+	(*env)->SetIntField(env, lpObject, AtkTextIfaceFc.get_n_selections, (jint)lpStruct->get_n_selections);
+	(*env)->SetIntField(env, lpObject, AtkTextIfaceFc.get_selection, (jint)lpStruct->get_selection);
+	(*env)->SetIntField(env, lpObject, AtkTextIfaceFc.add_selection, (jint)lpStruct->add_selection);
+	(*env)->SetIntField(env, lpObject, AtkTextIfaceFc.remove_selection, (jint)lpStruct->remove_selection);
+	(*env)->SetIntField(env, lpObject, AtkTextIfaceFc.set_selection, (jint)lpStruct->set_selection);
+	(*env)->SetIntField(env, lpObject, AtkTextIfaceFc.set_caret_offset, (jint)lpStruct->set_caret_offset);
+	(*env)->SetIntField(env, lpObject, AtkTextIfaceFc.text_changed, (jint)lpStruct->text_changed);
+	(*env)->SetIntField(env, lpObject, AtkTextIfaceFc.text_caret_moved, (jint)lpStruct->text_caret_moved);
+	(*env)->SetIntField(env, lpObject, AtkTextIfaceFc.text_selection_changed, (jint)lpStruct->text_selection_changed);
+}
+#endif
+
+#ifndef NO_GtkAccessible
+typedef struct GtkAccessible_FID_CACHE {
+	int cached;
+	jclass clazz;
+	jfieldID widget;
+} GtkAccessible_FID_CACHE;
+
+GtkAccessible_FID_CACHE GtkAccessibleFc;
+
+void cacheGtkAccessibleFields(JNIEnv *env, jobject lpObject)
+{
+	if (GtkAccessibleFc.cached) return;
+	GtkAccessibleFc.clazz = (*env)->GetObjectClass(env, lpObject);
+	GtkAccessibleFc.widget = (*env)->GetFieldID(env, GtkAccessibleFc.clazz, "widget", "I");
+	GtkAccessibleFc.cached = 1;
+}
+
+GtkAccessible *getGtkAccessibleFields(JNIEnv *env, jobject lpObject, GtkAccessible *lpStruct)
+{
+	if (!GtkAccessibleFc.cached) cacheGtkAccessibleFields(env, lpObject);
+	lpStruct->widget = (GtkWidget *)(*env)->GetIntField(env, lpObject, GtkAccessibleFc.widget);
+	return lpStruct;
+}
+
+void setGtkAccessibleFields(JNIEnv *env, jobject lpObject, GtkAccessible *lpStruct)
+{
+	if (!GtkAccessibleFc.cached) cacheGtkAccessibleFields(env, lpObject);
+	(*env)->SetIntField(env, lpObject, GtkAccessibleFc.widget, (jint)lpStruct->widget);
+}
+#endif
+

Added: branches/upstream/swt-gtk/current/atk_structs.h
===================================================================
--- branches/upstream/swt-gtk/current/atk_structs.h	                        (rev 0)
+++ branches/upstream/swt-gtk/current/atk_structs.h	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,113 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 IBM Corporation and others. All rights reserved.
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt).  The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html.  If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+#include "atk.h"
+
+#ifndef NO_AtkActionIface
+void cacheAtkActionIfaceFields(JNIEnv *env, jobject lpObject);
+AtkActionIface *getAtkActionIfaceFields(JNIEnv *env, jobject lpObject, AtkActionIface *lpStruct);
+void setAtkActionIfaceFields(JNIEnv *env, jobject lpObject, AtkActionIface *lpStruct);
+#define AtkActionIface_sizeof() sizeof(AtkActionIface)
+#else
+#define cacheAtkActionIfaceFields(a,b)
+#define getAtkActionIfaceFields(a,b,c) NULL
+#define setAtkActionIfaceFields(a,b,c)
+#define AtkActionIface_sizeof() 0
+#endif
+
+#ifndef NO_AtkComponentIface
+void cacheAtkComponentIfaceFields(JNIEnv *env, jobject lpObject);
+AtkComponentIface *getAtkComponentIfaceFields(JNIEnv *env, jobject lpObject, AtkComponentIface *lpStruct);
+void setAtkComponentIfaceFields(JNIEnv *env, jobject lpObject, AtkComponentIface *lpStruct);
+#define AtkComponentIface_sizeof() sizeof(AtkComponentIface)
+#else
+#define cacheAtkComponentIfaceFields(a,b)
+#define getAtkComponentIfaceFields(a,b,c) NULL
+#define setAtkComponentIfaceFields(a,b,c)
+#define AtkComponentIface_sizeof() 0
+#endif
+
+#ifndef NO_AtkHypertextIface
+void cacheAtkHypertextIfaceFields(JNIEnv *env, jobject lpObject);
+AtkHypertextIface *getAtkHypertextIfaceFields(JNIEnv *env, jobject lpObject, AtkHypertextIface *lpStruct);
+void setAtkHypertextIfaceFields(JNIEnv *env, jobject lpObject, AtkHypertextIface *lpStruct);
+#define AtkHypertextIface_sizeof() sizeof(AtkHypertextIface)
+#else
+#define cacheAtkHypertextIfaceFields(a,b)
+#define getAtkHypertextIfaceFields(a,b,c) NULL
+#define setAtkHypertextIfaceFields(a,b,c)
+#define AtkHypertextIface_sizeof() 0
+#endif
+
+#ifndef NO_AtkObjectClass
+void cacheAtkObjectClassFields(JNIEnv *env, jobject lpObject);
+AtkObjectClass *getAtkObjectClassFields(JNIEnv *env, jobject lpObject, AtkObjectClass *lpStruct);
+void setAtkObjectClassFields(JNIEnv *env, jobject lpObject, AtkObjectClass *lpStruct);
+#define AtkObjectClass_sizeof() sizeof(AtkObjectClass)
+#else
+#define cacheAtkObjectClassFields(a,b)
+#define getAtkObjectClassFields(a,b,c) NULL
+#define setAtkObjectClassFields(a,b,c)
+#define AtkObjectClass_sizeof() 0
+#endif
+
+#ifndef NO_AtkObjectFactoryClass
+void cacheAtkObjectFactoryClassFields(JNIEnv *env, jobject lpObject);
+AtkObjectFactoryClass *getAtkObjectFactoryClassFields(JNIEnv *env, jobject lpObject, AtkObjectFactoryClass *lpStruct);
+void setAtkObjectFactoryClassFields(JNIEnv *env, jobject lpObject, AtkObjectFactoryClass *lpStruct);
+#define AtkObjectFactoryClass_sizeof() sizeof(AtkObjectFactoryClass)
+#else
+#define cacheAtkObjectFactoryClassFields(a,b)
+#define getAtkObjectFactoryClassFields(a,b,c) NULL
+#define setAtkObjectFactoryClassFields(a,b,c)
+#define AtkObjectFactoryClass_sizeof() 0
+#endif
+
+#ifndef NO_AtkSelectionIface
+void cacheAtkSelectionIfaceFields(JNIEnv *env, jobject lpObject);
+AtkSelectionIface *getAtkSelectionIfaceFields(JNIEnv *env, jobject lpObject, AtkSelectionIface *lpStruct);
+void setAtkSelectionIfaceFields(JNIEnv *env, jobject lpObject, AtkSelectionIface *lpStruct);
+#define AtkSelectionIface_sizeof() sizeof(AtkSelectionIface)
+#else
+#define cacheAtkSelectionIfaceFields(a,b)
+#define getAtkSelectionIfaceFields(a,b,c) NULL
+#define setAtkSelectionIfaceFields(a,b,c)
+#define AtkSelectionIface_sizeof() 0
+#endif
+
+#ifndef NO_AtkTextIface
+void cacheAtkTextIfaceFields(JNIEnv *env, jobject lpObject);
+AtkTextIface *getAtkTextIfaceFields(JNIEnv *env, jobject lpObject, AtkTextIface *lpStruct);
+void setAtkTextIfaceFields(JNIEnv *env, jobject lpObject, AtkTextIface *lpStruct);
+#define AtkTextIface_sizeof() sizeof(AtkTextIface)
+#else
+#define cacheAtkTextIfaceFields(a,b)
+#define getAtkTextIfaceFields(a,b,c) NULL
+#define setAtkTextIfaceFields(a,b,c)
+#define AtkTextIface_sizeof() 0
+#endif
+
+#ifndef NO_GtkAccessible
+void cacheGtkAccessibleFields(JNIEnv *env, jobject lpObject);
+GtkAccessible *getGtkAccessibleFields(JNIEnv *env, jobject lpObject, GtkAccessible *lpStruct);
+void setGtkAccessibleFields(JNIEnv *env, jobject lpObject, GtkAccessible *lpStruct);
+#define GtkAccessible_sizeof() sizeof(GtkAccessible)
+#else
+#define cacheGtkAccessibleFields(a,b)
+#define getGtkAccessibleFields(a,b,c) NULL
+#define setGtkAccessibleFields(a,b,c)
+#define GtkAccessible_sizeof() 0
+#endif
+

Added: branches/upstream/swt-gtk/current/build.sh
===================================================================
--- branches/upstream/swt-gtk/current/build.sh	                        (rev 0)
+++ branches/upstream/swt-gtk/current/build.sh	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,146 @@
+#!/bin/sh
+#*******************************************************************************
+# Copyright (c) 2000, 2008 IBM Corporation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+#     IBM Corporation - initial API and implementation
+#     Kevin Cornell (Rational Software Corporation)
+#     Tom Tromey (Red Hat, Inc.)
+#*******************************************************************************
+
+cd `dirname $0`
+
+if [ "${JAVA_HOME}" = "" ]; then
+	echo "Please set JAVA_HOME to point at a JRE."
+fi
+if [ "${CC}" = "" ]; then
+	CC=gcc
+	export CC
+fi
+
+# Determine which OS we are on
+if [ "${OS}" = "" ]; then
+	OS=`uname -s`
+fi
+case $OS in
+	"SunOS")
+		SWT_OS=solaris
+		MAKEFILE=make_solaris.mak
+		;;
+	"FreeBSD")
+		SWT_OS=freebsd
+		MAKEFILE=make_freebsd.mak
+		;;
+	*)
+		SWT_OS=`uname -s | tr -s '[:upper:]' '[:lower:]'`
+		MAKEFILE=make_linux.mak
+		;;
+esac
+
+# Determine which CPU type we are building for
+if [ "${MODEL}" = "" ]; then
+	if uname -p > /dev/null 2>&1; then
+		MODEL=`uname -p`
+	else
+		MODEL=`uname -m`
+	fi
+fi
+case $MODEL in
+	"x86_64")
+		SWT_ARCH=x86_64
+		AWT_ARCH=amd64
+		;;
+	i?86)
+		SWT_ARCH=x86
+		AWT_ARCH=i386
+		;;
+	*)
+		SWT_ARCH=$MODEL
+		AWT_ARCH=$MODEL
+		;;
+esac
+
+# For 64-bit CPUs, we have a switch
+if [ ${MODEL} = 'x86_64' -o ${MODEL} = 'ppc64' -o ${MODEL} = 'ia64' -o ${MODEL} = 's390x' ]; then
+	SWT_PTR_CFLAGS=-DSWT_PTR_SIZE_64
+	export SWT_PTR_CFLAGS
+	if [ -d /lib64 ]; then
+		XLIB64=-L/usr/X11R6/lib64
+		export XLIB64
+	fi
+fi
+
+if [ x`pkg-config --exists gnome-vfs-module-2.0 libgnome-2.0 libgnomeui-2.0 && echo YES` = "xYES" ]; then
+	echo "libgnomeui-2.0 found, compiling SWT program support using GNOME"
+	MAKE_GNOME=make_gnome
+else
+	echo "libgnome-2.0 and libgnomeui-2.0 not found:"
+	echo "    *** SWT Program support for GNOME will not be compiled."
+fi
+
+if [ x`pkg-config --exists cairo && echo YES` = "xYES" ]; then
+	echo "Cairo found, compiling SWT support for the cairo graphics library."
+	MAKE_CAIRO=make_cairo
+else
+	echo "Cairo not found:"
+	echo "    *** Advanced graphics support using cairo will not be compiled."
+fi
+
+if [ -z "${MOZILLA_INCLUDES}" -a -z "${MOZILLA_LIBS}" ]; then
+	if [ x`pkg-config --exists mozilla-xpcom && echo YES` = "xYES" ]; then
+		MOZILLA_INCLUDES=`pkg-config --cflags mozilla-xpcom`
+		MOZILLA_LIBS=`pkg-config --libs mozilla-xpcom`
+		export MOZILLA_INCLUDES
+		export MOZILLA_LIBS
+		MAKE_MOZILLA=make_mozilla
+	elif [ x`pkg-config --exists firefox-xpcom && echo YES` = "xYES" ]; then
+		MOZILLA_INCLUDES=`pkg-config --cflags firefox-xpcom`
+		MOZILLA_LIBS=`pkg-config --libs firefox-xpcom`
+		export MOZILLA_INCLUDES
+		export MOZILLA_LIBS
+		MAKE_MOZILLA=make_mozilla
+	elif [ x`pkg-config --exists libxul && echo YES` = "xYES" ]; then
+		MOZILLA_INCLUDES=`pkg-config --cflags libxul`
+		MOZILLA_LIBS=`pkg-config --libs libxul`
+		export MOZILLA_INCLUDES
+		export MOZILLA_LIBS
+		MAKE_MOZILLA=make_mozilla
+	else
+		echo "None of the following libraries were found:  Mozilla/XPCOM, Firefox/XPCOM, or XULRunner/XPCOM"
+		echo "    *** Mozilla embedding support will not be compiled."
+	fi
+fi
+
+# Find AWT if available
+if [ -z "${AWT_LIB_PATH}" ]; then
+	if [ -d ${JAVA_HOME}/jre/lib/${AWT_ARCH} ]; then
+		AWT_LIB_PATH=${JAVA_HOME}/jre/lib/${AWT_ARCH}
+		export AWT_LIB_PATH
+	else
+		AWT_LIB_PATH=${JAVA_HOME}/jre/bin
+		export AWT_LIB_PATH
+	fi
+fi
+
+if [ -f ${AWT_LIB_PATH}/libjawt.so ]; then
+	MAKE_AWT=make_awt
+else
+	echo "libjawt.so not found, the SWT/AWT integration library will not be compiled."
+fi
+
+# Announce our target
+echo "Building SWT/GTK+ for $SWT_OS $SWT_ARCH"
+if [ "x${OUTPUT_DIR}" = "x" ]; then
+	OUTPUT_DIR=../../../org.eclipse.swt.gtk.${SWT_OS}.${SWT_ARCH}
+	export OUTPUT_DIR
+fi
+
+if [ "x${1}" = "xclean" ]; then
+	make -f $MAKEFILE clean
+else
+	make -f $MAKEFILE all $MAKE_GNOME $MAKE_CAIRO $MAKE_AWT $MAKE_MOZILLA ${1} ${2} ${3} ${4} ${5} ${6} ${7} ${8} ${9}
+fi


Property changes on: branches/upstream/swt-gtk/current/build.sh
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/build.xml
===================================================================
--- branches/upstream/swt-gtk/current/build.xml	                        (rev 0)
+++ branches/upstream/swt-gtk/current/build.xml	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<project default="build_gtk_lib" basedir="../../..">
+
+<target name="init">
+	<eclipse.refreshLocal resource="org.eclipse.swt" depth="infinite" />
+	<eclipse.refreshLocal resource="org.eclipse.swt.tools" depth="infinite" />	
+   	<eclipse.incrementalBuild project="org.eclipse.swt" kind="incr" />
+</target>
+	
+<!-- Build swt.so for GTK -->
+<target name="build_gtk_lib" depends="init">
+	<exec dir="./bin/library" executable="sh">
+		<arg line="${basedir}/bin/library/build.sh"/>
+		<arg line="install"/>
+	</exec>
+	<eclipse.refreshLocal resource="org.eclipse.swt.gtk.linux.x86" depth="infinite" />
+</target>
+
+<!-- Build swt.so for PowerPC 32 bit GTK (no Mozilla)-->
+<target name="build_ppc_gtk_lib" depends="init">
+	<exec dir="./bin/library" executable="sh">
+		<env key="MODEL" value="ppc"/>
+		<arg line="${basedir}/bin/library/build.sh"/>
+		<arg line="install"/>
+	</exec>
+	<eclipse.refreshLocal resource="org.eclipse.swt.gtk.linux.ppc" depth="infinite" />
+</target>
+
+<!-- Build swt.so for Solaris GTK (no Mozilla) -->
+<target name="build_solaris_gtk_lib" depends="init">
+	<exec dir="./bin/library" executable="sh">
+		<arg line="${basedir}/bin/library/build.sh"/>
+		<arg line="install"/>
+	</exec>
+	<eclipse.refreshLocal resource="org.eclipse.swt.gtk.solaris.sparc" depth="infinite" />
+</target>
+	
+<!-- Build swt.so for GTK 64 -->
+<target name="build_gtk64_lib" depends="init">
+	<exec dir="./bin/library" executable="sh">
+		<arg line="${basedir}/bin/library/build.sh"/>
+		<arg line="install"/>
+	</exec>
+	<eclipse.refreshLocal resource="org.eclipse.swt.gtk.linux.x86_64" depth="infinite" />	
+</target>
+
+<target name="clean">
+	<exec dir="./bin/library" executable="sh">
+		<arg line="${basedir}/bin/library/build.sh"/>
+		<arg line="clean"/>
+	</exec>
+</target>
+
+</project>
\ No newline at end of file

Added: branches/upstream/swt-gtk/current/c.c
===================================================================
--- branches/upstream/swt-gtk/current/c.c	                        (rev 0)
+++ branches/upstream/swt-gtk/current/c.c	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,557 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+#include "swt.h"
+#include "c_structs.h"
+#include "c_stats.h"
+
+#define C_NATIVE(func) Java_org_eclipse_swt_internal_C_##func
+
+#ifndef NO_PTR_1sizeof
+JNIEXPORT jint JNICALL C_NATIVE(PTR_1sizeof)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	C_NATIVE_ENTER(env, that, PTR_1sizeof_FUNC);
+	rc = (jint)PTR_sizeof();
+	C_NATIVE_EXIT(env, that, PTR_1sizeof_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_free
+JNIEXPORT void JNICALL C_NATIVE(free)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	C_NATIVE_ENTER(env, that, free_FUNC);
+	free((void *)arg0);
+	C_NATIVE_EXIT(env, that, free_FUNC);
+}
+#endif
+
+#ifndef NO_getenv
+JNIEXPORT jint JNICALL C_NATIVE(getenv)
+	(JNIEnv *env, jclass that, jbyteArray arg0)
+{
+	jbyte *lparg0=NULL;
+	jint rc = 0;
+	C_NATIVE_ENTER(env, that, getenv_FUNC);
+	if (arg0) if ((lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL)) == NULL) goto fail;
+	rc = (jint)getenv((const char *)lparg0);
+fail:
+	if (arg0 && lparg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
+	C_NATIVE_EXIT(env, that, getenv_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_malloc
+JNIEXPORT jint JNICALL C_NATIVE(malloc)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	C_NATIVE_ENTER(env, that, malloc_FUNC);
+	rc = (jint)malloc(arg0);
+	C_NATIVE_EXIT(env, that, malloc_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_memmove__III
+JNIEXPORT void JNICALL C_NATIVE(memmove__III)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+	C_NATIVE_ENTER(env, that, memmove__III_FUNC);
+	memmove((void *)arg0, (const void *)arg1, (size_t)arg2);
+	C_NATIVE_EXIT(env, that, memmove__III_FUNC);
+}
+#endif
+
+#ifndef NO_memmove__I_3BI
+JNIEXPORT void JNICALL C_NATIVE(memmove__I_3BI)
+	(JNIEnv *env, jclass that, jint arg0, jbyteArray arg1, jint arg2)
+{
+	jbyte *lparg1=NULL;
+	C_NATIVE_ENTER(env, that, memmove__I_3BI_FUNC);
+#ifdef JNI_VERSION_1_2
+	if (IS_JNI_1_2) {
+		if (arg1) if ((lparg1 = (*env)->GetPrimitiveArrayCritical(env, arg1, NULL)) == NULL) goto fail;
+	} else
+#endif
+	{
+		if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	}
+	memmove((void *)arg0, (const void *)lparg1, (size_t)arg2);
+fail:
+#ifdef JNI_VERSION_1_2
+	if (IS_JNI_1_2) {
+		if (arg1 && lparg1) (*env)->ReleasePrimitiveArrayCritical(env, arg1, lparg1, JNI_ABORT);
+	} else
+#endif
+	{
+		if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, JNI_ABORT);
+	}
+	C_NATIVE_EXIT(env, that, memmove__I_3BI_FUNC);
+}
+#endif
+
+#ifndef NO_memmove__I_3CI
+JNIEXPORT void JNICALL C_NATIVE(memmove__I_3CI)
+	(JNIEnv *env, jclass that, jint arg0, jcharArray arg1, jint arg2)
+{
+	jchar *lparg1=NULL;
+	C_NATIVE_ENTER(env, that, memmove__I_3CI_FUNC);
+#ifdef JNI_VERSION_1_2
+	if (IS_JNI_1_2) {
+		if (arg1) if ((lparg1 = (*env)->GetPrimitiveArrayCritical(env, arg1, NULL)) == NULL) goto fail;
+	} else
+#endif
+	{
+		if (arg1) if ((lparg1 = (*env)->GetCharArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	}
+	memmove((void *)arg0, (const void *)lparg1, (size_t)arg2);
+fail:
+#ifdef JNI_VERSION_1_2
+	if (IS_JNI_1_2) {
+		if (arg1 && lparg1) (*env)->ReleasePrimitiveArrayCritical(env, arg1, lparg1, JNI_ABORT);
+	} else
+#endif
+	{
+		if (arg1 && lparg1) (*env)->ReleaseCharArrayElements(env, arg1, lparg1, JNI_ABORT);
+	}
+	C_NATIVE_EXIT(env, that, memmove__I_3CI_FUNC);
+}
+#endif
+
+#ifndef NO_memmove__I_3DI
+JNIEXPORT void JNICALL C_NATIVE(memmove__I_3DI)
+	(JNIEnv *env, jclass that, jint arg0, jdoubleArray arg1, jint arg2)
+{
+	jdouble *lparg1=NULL;
+	C_NATIVE_ENTER(env, that, memmove__I_3DI_FUNC);
+#ifdef JNI_VERSION_1_2
+	if (IS_JNI_1_2) {
+		if (arg1) if ((lparg1 = (*env)->GetPrimitiveArrayCritical(env, arg1, NULL)) == NULL) goto fail;
+	} else
+#endif
+	{
+		if (arg1) if ((lparg1 = (*env)->GetDoubleArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	}
+	memmove((void *)arg0, (const void *)lparg1, (size_t)arg2);
+fail:
+#ifdef JNI_VERSION_1_2
+	if (IS_JNI_1_2) {
+		if (arg1 && lparg1) (*env)->ReleasePrimitiveArrayCritical(env, arg1, lparg1, JNI_ABORT);
+	} else
+#endif
+	{
+		if (arg1 && lparg1) (*env)->ReleaseDoubleArrayElements(env, arg1, lparg1, JNI_ABORT);
+	}
+	C_NATIVE_EXIT(env, that, memmove__I_3DI_FUNC);
+}
+#endif
+
+#ifndef NO_memmove__I_3FI
+JNIEXPORT void JNICALL C_NATIVE(memmove__I_3FI)
+	(JNIEnv *env, jclass that, jint arg0, jfloatArray arg1, jint arg2)
+{
+	jfloat *lparg1=NULL;
+	C_NATIVE_ENTER(env, that, memmove__I_3FI_FUNC);
+#ifdef JNI_VERSION_1_2
+	if (IS_JNI_1_2) {
+		if (arg1) if ((lparg1 = (*env)->GetPrimitiveArrayCritical(env, arg1, NULL)) == NULL) goto fail;
+	} else
+#endif
+	{
+		if (arg1) if ((lparg1 = (*env)->GetFloatArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	}
+	memmove((void *)arg0, (const void *)lparg1, (size_t)arg2);
+fail:
+#ifdef JNI_VERSION_1_2
+	if (IS_JNI_1_2) {
+		if (arg1 && lparg1) (*env)->ReleasePrimitiveArrayCritical(env, arg1, lparg1, JNI_ABORT);
+	} else
+#endif
+	{
+		if (arg1 && lparg1) (*env)->ReleaseFloatArrayElements(env, arg1, lparg1, JNI_ABORT);
+	}
+	C_NATIVE_EXIT(env, that, memmove__I_3FI_FUNC);
+}
+#endif
+
+#ifndef NO_memmove__I_3II
+JNIEXPORT void JNICALL C_NATIVE(memmove__I_3II)
+	(JNIEnv *env, jclass that, jint arg0, jintArray arg1, jint arg2)
+{
+	jint *lparg1=NULL;
+	C_NATIVE_ENTER(env, that, memmove__I_3II_FUNC);
+#ifdef JNI_VERSION_1_2
+	if (IS_JNI_1_2) {
+		if (arg1) if ((lparg1 = (*env)->GetPrimitiveArrayCritical(env, arg1, NULL)) == NULL) goto fail;
+	} else
+#endif
+	{
+		if (arg1) if ((lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	}
+	memmove((void *)arg0, (const void *)lparg1, (size_t)arg2);
+fail:
+#ifdef JNI_VERSION_1_2
+	if (IS_JNI_1_2) {
+		if (arg1 && lparg1) (*env)->ReleasePrimitiveArrayCritical(env, arg1, lparg1, JNI_ABORT);
+	} else
+#endif
+	{
+		if (arg1 && lparg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, JNI_ABORT);
+	}
+	C_NATIVE_EXIT(env, that, memmove__I_3II_FUNC);
+}
+#endif
+
+#ifndef NO_memmove__I_3JI
+JNIEXPORT void JNICALL C_NATIVE(memmove__I_3JI)
+	(JNIEnv *env, jclass that, jint arg0, jlongArray arg1, jint arg2)
+{
+	jlong *lparg1=NULL;
+	C_NATIVE_ENTER(env, that, memmove__I_3JI_FUNC);
+#ifdef JNI_VERSION_1_2
+	if (IS_JNI_1_2) {
+		if (arg1) if ((lparg1 = (*env)->GetPrimitiveArrayCritical(env, arg1, NULL)) == NULL) goto fail;
+	} else
+#endif
+	{
+		if (arg1) if ((lparg1 = (*env)->GetLongArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	}
+	memmove((void *)arg0, (const void *)lparg1, (size_t)arg2);
+fail:
+#ifdef JNI_VERSION_1_2
+	if (IS_JNI_1_2) {
+		if (arg1 && lparg1) (*env)->ReleasePrimitiveArrayCritical(env, arg1, lparg1, JNI_ABORT);
+	} else
+#endif
+	{
+		if (arg1 && lparg1) (*env)->ReleaseLongArrayElements(env, arg1, lparg1, JNI_ABORT);
+	}
+	C_NATIVE_EXIT(env, that, memmove__I_3JI_FUNC);
+}
+#endif
+
+#ifndef NO_memmove__I_3SI
+JNIEXPORT void JNICALL C_NATIVE(memmove__I_3SI)
+	(JNIEnv *env, jclass that, jint arg0, jshortArray arg1, jint arg2)
+{
+	jshort *lparg1=NULL;
+	C_NATIVE_ENTER(env, that, memmove__I_3SI_FUNC);
+#ifdef JNI_VERSION_1_2
+	if (IS_JNI_1_2) {
+		if (arg1) if ((lparg1 = (*env)->GetPrimitiveArrayCritical(env, arg1, NULL)) == NULL) goto fail;
+	} else
+#endif
+	{
+		if (arg1) if ((lparg1 = (*env)->GetShortArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	}
+	memmove((void *)arg0, (const void *)lparg1, (size_t)arg2);
+fail:
+#ifdef JNI_VERSION_1_2
+	if (IS_JNI_1_2) {
+		if (arg1 && lparg1) (*env)->ReleasePrimitiveArrayCritical(env, arg1, lparg1, JNI_ABORT);
+	} else
+#endif
+	{
+		if (arg1 && lparg1) (*env)->ReleaseShortArrayElements(env, arg1, lparg1, JNI_ABORT);
+	}
+	C_NATIVE_EXIT(env, that, memmove__I_3SI_FUNC);
+}
+#endif
+
+#ifndef NO_memmove___3BII
+JNIEXPORT void JNICALL C_NATIVE(memmove___3BII)
+	(JNIEnv *env, jclass that, jbyteArray arg0, jint arg1, jint arg2)
+{
+	jbyte *lparg0=NULL;
+	C_NATIVE_ENTER(env, that, memmove___3BII_FUNC);
+#ifdef JNI_VERSION_1_2
+	if (IS_JNI_1_2) {
+		if (arg0) if ((lparg0 = (*env)->GetPrimitiveArrayCritical(env, arg0, NULL)) == NULL) goto fail;
+	} else
+#endif
+	{
+		if (arg0) if ((lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL)) == NULL) goto fail;
+	}
+	memmove((void *)lparg0, (const void *)arg1, (size_t)arg2);
+fail:
+#ifdef JNI_VERSION_1_2
+	if (IS_JNI_1_2) {
+		if (arg0 && lparg0) (*env)->ReleasePrimitiveArrayCritical(env, arg0, lparg0, 0);
+	} else
+#endif
+	{
+		if (arg0 && lparg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
+	}
+	C_NATIVE_EXIT(env, that, memmove___3BII_FUNC);
+}
+#endif
+
+#ifndef NO_memmove___3B_3CI
+JNIEXPORT void JNICALL C_NATIVE(memmove___3B_3CI)
+	(JNIEnv *env, jclass that, jbyteArray arg0, jcharArray arg1, jint arg2)
+{
+	jbyte *lparg0=NULL;
+	jchar *lparg1=NULL;
+	C_NATIVE_ENTER(env, that, memmove___3B_3CI_FUNC);
+#ifdef JNI_VERSION_1_2
+	if (IS_JNI_1_2) {
+		if (arg0) if ((lparg0 = (*env)->GetPrimitiveArrayCritical(env, arg0, NULL)) == NULL) goto fail;
+		if (arg1) if ((lparg1 = (*env)->GetPrimitiveArrayCritical(env, arg1, NULL)) == NULL) goto fail;
+	} else
+#endif
+	{
+		if (arg0) if ((lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL)) == NULL) goto fail;
+		if (arg1) if ((lparg1 = (*env)->GetCharArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	}
+	memmove((void *)lparg0, (const void *)lparg1, (size_t)arg2);
+fail:
+#ifdef JNI_VERSION_1_2
+	if (IS_JNI_1_2) {
+		if (arg1 && lparg1) (*env)->ReleasePrimitiveArrayCritical(env, arg1, lparg1, JNI_ABORT);
+		if (arg0 && lparg0) (*env)->ReleasePrimitiveArrayCritical(env, arg0, lparg0, 0);
+	} else
+#endif
+	{
+		if (arg1 && lparg1) (*env)->ReleaseCharArrayElements(env, arg1, lparg1, JNI_ABORT);
+		if (arg0 && lparg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
+	}
+	C_NATIVE_EXIT(env, that, memmove___3B_3CI_FUNC);
+}
+#endif
+
+#ifndef NO_memmove___3CII
+JNIEXPORT void JNICALL C_NATIVE(memmove___3CII)
+	(JNIEnv *env, jclass that, jcharArray arg0, jint arg1, jint arg2)
+{
+	jchar *lparg0=NULL;
+	C_NATIVE_ENTER(env, that, memmove___3CII_FUNC);
+#ifdef JNI_VERSION_1_2
+	if (IS_JNI_1_2) {
+		if (arg0) if ((lparg0 = (*env)->GetPrimitiveArrayCritical(env, arg0, NULL)) == NULL) goto fail;
+	} else
+#endif
+	{
+		if (arg0) if ((lparg0 = (*env)->GetCharArrayElements(env, arg0, NULL)) == NULL) goto fail;
+	}
+	memmove((void *)lparg0, (const void *)arg1, (size_t)arg2);
+fail:
+#ifdef JNI_VERSION_1_2
+	if (IS_JNI_1_2) {
+		if (arg0 && lparg0) (*env)->ReleasePrimitiveArrayCritical(env, arg0, lparg0, 0);
+	} else
+#endif
+	{
+		if (arg0 && lparg0) (*env)->ReleaseCharArrayElements(env, arg0, lparg0, 0);
+	}
+	C_NATIVE_EXIT(env, that, memmove___3CII_FUNC);
+}
+#endif
+
+#ifndef NO_memmove___3DII
+JNIEXPORT void JNICALL C_NATIVE(memmove___3DII)
+	(JNIEnv *env, jclass that, jdoubleArray arg0, jint arg1, jint arg2)
+{
+	jdouble *lparg0=NULL;
+	C_NATIVE_ENTER(env, that, memmove___3DII_FUNC);
+#ifdef JNI_VERSION_1_2
+	if (IS_JNI_1_2) {
+		if (arg0) if ((lparg0 = (*env)->GetPrimitiveArrayCritical(env, arg0, NULL)) == NULL) goto fail;
+	} else
+#endif
+	{
+		if (arg0) if ((lparg0 = (*env)->GetDoubleArrayElements(env, arg0, NULL)) == NULL) goto fail;
+	}
+	memmove((void *)lparg0, (const void *)arg1, (size_t)arg2);
+fail:
+#ifdef JNI_VERSION_1_2
+	if (IS_JNI_1_2) {
+		if (arg0 && lparg0) (*env)->ReleasePrimitiveArrayCritical(env, arg0, lparg0, 0);
+	} else
+#endif
+	{
+		if (arg0 && lparg0) (*env)->ReleaseDoubleArrayElements(env, arg0, lparg0, 0);
+	}
+	C_NATIVE_EXIT(env, that, memmove___3DII_FUNC);
+}
+#endif
+
+#ifndef NO_memmove___3FII
+JNIEXPORT void JNICALL C_NATIVE(memmove___3FII)
+	(JNIEnv *env, jclass that, jfloatArray arg0, jint arg1, jint arg2)
+{
+	jfloat *lparg0=NULL;
+	C_NATIVE_ENTER(env, that, memmove___3FII_FUNC);
+#ifdef JNI_VERSION_1_2
+	if (IS_JNI_1_2) {
+		if (arg0) if ((lparg0 = (*env)->GetPrimitiveArrayCritical(env, arg0, NULL)) == NULL) goto fail;
+	} else
+#endif
+	{
+		if (arg0) if ((lparg0 = (*env)->GetFloatArrayElements(env, arg0, NULL)) == NULL) goto fail;
+	}
+	memmove((void *)lparg0, (const void *)arg1, (size_t)arg2);
+fail:
+#ifdef JNI_VERSION_1_2
+	if (IS_JNI_1_2) {
+		if (arg0 && lparg0) (*env)->ReleasePrimitiveArrayCritical(env, arg0, lparg0, 0);
+	} else
+#endif
+	{
+		if (arg0 && lparg0) (*env)->ReleaseFloatArrayElements(env, arg0, lparg0, 0);
+	}
+	C_NATIVE_EXIT(env, that, memmove___3FII_FUNC);
+}
+#endif
+
+#ifndef NO_memmove___3III
+JNIEXPORT void JNICALL C_NATIVE(memmove___3III)
+	(JNIEnv *env, jclass that, jintArray arg0, jint arg1, jint arg2)
+{
+	jint *lparg0=NULL;
+	C_NATIVE_ENTER(env, that, memmove___3III_FUNC);
+#ifdef JNI_VERSION_1_2
+	if (IS_JNI_1_2) {
+		if (arg0) if ((lparg0 = (*env)->GetPrimitiveArrayCritical(env, arg0, NULL)) == NULL) goto fail;
+	} else
+#endif
+	{
+		if (arg0) if ((lparg0 = (*env)->GetIntArrayElements(env, arg0, NULL)) == NULL) goto fail;
+	}
+	memmove((void *)lparg0, (const void *)arg1, (size_t)arg2);
+fail:
+#ifdef JNI_VERSION_1_2
+	if (IS_JNI_1_2) {
+		if (arg0 && lparg0) (*env)->ReleasePrimitiveArrayCritical(env, arg0, lparg0, 0);
+	} else
+#endif
+	{
+		if (arg0 && lparg0) (*env)->ReleaseIntArrayElements(env, arg0, lparg0, 0);
+	}
+	C_NATIVE_EXIT(env, that, memmove___3III_FUNC);
+}
+#endif
+
+#ifndef NO_memmove___3I_3BI
+JNIEXPORT void JNICALL C_NATIVE(memmove___3I_3BI)
+	(JNIEnv *env, jclass that, jintArray arg0, jbyteArray arg1, jint arg2)
+{
+	jint *lparg0=NULL;
+	jbyte *lparg1=NULL;
+	C_NATIVE_ENTER(env, that, memmove___3I_3BI_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+#ifdef JNI_VERSION_1_2
+	if (IS_JNI_1_2) {
+		if (arg0) if ((lparg0 = (*env)->GetPrimitiveArrayCritical(env, arg0, NULL)) == NULL) goto fail;
+	} else
+#endif
+	{
+		if (arg0) if ((lparg0 = (*env)->GetIntArrayElements(env, arg0, NULL)) == NULL) goto fail;
+	}
+	memmove((void *)lparg0, (const void *)lparg1, (size_t)arg2);
+fail:
+#ifdef JNI_VERSION_1_2
+	if (IS_JNI_1_2) {
+		if (arg0 && lparg0) (*env)->ReleasePrimitiveArrayCritical(env, arg0, lparg0, 0);
+	} else
+#endif
+	{
+		if (arg0 && lparg0) (*env)->ReleaseIntArrayElements(env, arg0, lparg0, 0);
+	}
+	if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+	C_NATIVE_EXIT(env, that, memmove___3I_3BI_FUNC);
+}
+#endif
+
+#ifndef NO_memmove___3JII
+JNIEXPORT void JNICALL C_NATIVE(memmove___3JII)
+	(JNIEnv *env, jclass that, jlongArray arg0, jint arg1, jint arg2)
+{
+	jlong *lparg0=NULL;
+	C_NATIVE_ENTER(env, that, memmove___3JII_FUNC);
+#ifdef JNI_VERSION_1_2
+	if (IS_JNI_1_2) {
+		if (arg0) if ((lparg0 = (*env)->GetPrimitiveArrayCritical(env, arg0, NULL)) == NULL) goto fail;
+	} else
+#endif
+	{
+		if (arg0) if ((lparg0 = (*env)->GetLongArrayElements(env, arg0, NULL)) == NULL) goto fail;
+	}
+	memmove((void *)lparg0, (const void *)arg1, (size_t)arg2);
+fail:
+#ifdef JNI_VERSION_1_2
+	if (IS_JNI_1_2) {
+		if (arg0 && lparg0) (*env)->ReleasePrimitiveArrayCritical(env, arg0, lparg0, 0);
+	} else
+#endif
+	{
+		if (arg0 && lparg0) (*env)->ReleaseLongArrayElements(env, arg0, lparg0, 0);
+	}
+	C_NATIVE_EXIT(env, that, memmove___3JII_FUNC);
+}
+#endif
+
+#ifndef NO_memmove___3SII
+JNIEXPORT void JNICALL C_NATIVE(memmove___3SII)
+	(JNIEnv *env, jclass that, jshortArray arg0, jint arg1, jint arg2)
+{
+	jshort *lparg0=NULL;
+	C_NATIVE_ENTER(env, that, memmove___3SII_FUNC);
+#ifdef JNI_VERSION_1_2
+	if (IS_JNI_1_2) {
+		if (arg0) if ((lparg0 = (*env)->GetPrimitiveArrayCritical(env, arg0, NULL)) == NULL) goto fail;
+	} else
+#endif
+	{
+		if (arg0) if ((lparg0 = (*env)->GetShortArrayElements(env, arg0, NULL)) == NULL) goto fail;
+	}
+	memmove((void *)lparg0, (const void *)arg1, (size_t)arg2);
+fail:
+#ifdef JNI_VERSION_1_2
+	if (IS_JNI_1_2) {
+		if (arg0 && lparg0) (*env)->ReleasePrimitiveArrayCritical(env, arg0, lparg0, 0);
+	} else
+#endif
+	{
+		if (arg0 && lparg0) (*env)->ReleaseShortArrayElements(env, arg0, lparg0, 0);
+	}
+	C_NATIVE_EXIT(env, that, memmove___3SII_FUNC);
+}
+#endif
+
+#ifndef NO_memset
+JNIEXPORT jint JNICALL C_NATIVE(memset)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+	jint rc = 0;
+	C_NATIVE_ENTER(env, that, memset_FUNC);
+	rc = (jint)memset((void *)arg0, arg1, (size_t)arg2);
+	C_NATIVE_EXIT(env, that, memset_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_strlen
+JNIEXPORT jint JNICALL C_NATIVE(strlen)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	C_NATIVE_ENTER(env, that, strlen_FUNC);
+	rc = (jint)strlen((char *)arg0);
+	C_NATIVE_EXIT(env, that, strlen_FUNC);
+	return rc;
+}
+#endif
+

Added: branches/upstream/swt-gtk/current/c.h
===================================================================
--- branches/upstream/swt-gtk/current/c.h	                        (rev 0)
+++ branches/upstream/swt-gtk/current/c.h	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+#ifndef INC_c_H
+#define INC_c_H
+
+#include <stdlib.h>
+#include <string.h>
+
+#define PTR_sizeof() sizeof(void *)
+
+/* Functions excludes */
+#ifdef _WIN32_WCE
+#define NO_getenv
+#endif /* _WIN32_WCE */
+
+#endif /* INC_c_H */

Added: branches/upstream/swt-gtk/current/c_stats.c
===================================================================
--- branches/upstream/swt-gtk/current/c_stats.c	                        (rev 0)
+++ branches/upstream/swt-gtk/current/c_stats.c	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+#include "swt.h"
+#include "c_stats.h"
+
+#ifdef NATIVE_STATS
+
+int C_nativeFunctionCount = 23;
+int C_nativeFunctionCallCount[23];
+char * C_nativeFunctionNames[] = {
+	"PTR_1sizeof",
+	"free",
+	"getenv",
+	"malloc",
+	"memmove__III",
+	"memmove__I_3BI",
+	"memmove__I_3CI",
+	"memmove__I_3DI",
+	"memmove__I_3FI",
+	"memmove__I_3II",
+	"memmove__I_3JI",
+	"memmove__I_3SI",
+	"memmove___3BII",
+	"memmove___3B_3CI",
+	"memmove___3CII",
+	"memmove___3DII",
+	"memmove___3FII",
+	"memmove___3III",
+	"memmove___3I_3BI",
+	"memmove___3JII",
+	"memmove___3SII",
+	"memset",
+	"strlen",
+};
+
+#define STATS_NATIVE(func) Java_org_eclipse_swt_tools_internal_NativeStats_##func
+
+JNIEXPORT jint JNICALL STATS_NATIVE(C_1GetFunctionCount)
+	(JNIEnv *env, jclass that)
+{
+	return C_nativeFunctionCount;
+}
+
+JNIEXPORT jstring JNICALL STATS_NATIVE(C_1GetFunctionName)
+	(JNIEnv *env, jclass that, jint index)
+{
+	return (*env)->NewStringUTF(env, C_nativeFunctionNames[index]);
+}
+
+JNIEXPORT jint JNICALL STATS_NATIVE(C_1GetFunctionCallCount)
+	(JNIEnv *env, jclass that, jint index)
+{
+	return C_nativeFunctionCallCount[index];
+}
+
+#endif

Added: branches/upstream/swt-gtk/current/c_stats.h
===================================================================
--- branches/upstream/swt-gtk/current/c_stats.h	                        (rev 0)
+++ branches/upstream/swt-gtk/current/c_stats.h	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+#ifdef NATIVE_STATS
+extern int C_nativeFunctionCount;
+extern int C_nativeFunctionCallCount[];
+extern char* C_nativeFunctionNames[];
+#define C_NATIVE_ENTER(env, that, func) C_nativeFunctionCallCount[func]++;
+#define C_NATIVE_EXIT(env, that, func) 
+#else
+#ifndef C_NATIVE_ENTER
+#define C_NATIVE_ENTER(env, that, func) 
+#endif
+#ifndef C_NATIVE_EXIT
+#define C_NATIVE_EXIT(env, that, func) 
+#endif
+#endif
+
+typedef enum {
+	PTR_1sizeof_FUNC,
+	free_FUNC,
+	getenv_FUNC,
+	malloc_FUNC,
+	memmove__III_FUNC,
+	memmove__I_3BI_FUNC,
+	memmove__I_3CI_FUNC,
+	memmove__I_3DI_FUNC,
+	memmove__I_3FI_FUNC,
+	memmove__I_3II_FUNC,
+	memmove__I_3JI_FUNC,
+	memmove__I_3SI_FUNC,
+	memmove___3BII_FUNC,
+	memmove___3B_3CI_FUNC,
+	memmove___3CII_FUNC,
+	memmove___3DII_FUNC,
+	memmove___3FII_FUNC,
+	memmove___3III_FUNC,
+	memmove___3I_3BI_FUNC,
+	memmove___3JII_FUNC,
+	memmove___3SII_FUNC,
+	memset_FUNC,
+	strlen_FUNC,
+} C_FUNCS;

Added: branches/upstream/swt-gtk/current/c_structs.c
===================================================================
--- branches/upstream/swt-gtk/current/c_structs.c	                        (rev 0)
+++ branches/upstream/swt-gtk/current/c_structs.c	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,14 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+#include "swt.h"
+#include "c_structs.h"
+

Added: branches/upstream/swt-gtk/current/c_structs.h
===================================================================
--- branches/upstream/swt-gtk/current/c_structs.h	                        (rev 0)
+++ branches/upstream/swt-gtk/current/c_structs.h	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+#include "c.h"
+

Added: branches/upstream/swt-gtk/current/cairo.c
===================================================================
--- branches/upstream/swt-gtk/current/cairo.c	                        (rev 0)
+++ branches/upstream/swt-gtk/current/cairo.c	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,1822 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * -  Binding to permit interfacing between Cairo and SWT
+ * -  Copyright (C) 2005, 2007 IBM Corp.  All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#include "swt.h"
+#include "cairo_structs.h"
+#include "cairo_stats.h"
+
+#define Cairo_NATIVE(func) Java_org_eclipse_swt_internal_cairo_Cairo_##func
+
+#ifndef NO_CAIRO_1VERSION_1ENCODE
+JNIEXPORT jint JNICALL Cairo_NATIVE(CAIRO_1VERSION_1ENCODE)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+	jint rc = 0;
+	Cairo_NATIVE_ENTER(env, that, CAIRO_1VERSION_1ENCODE_FUNC);
+	rc = (jint)CAIRO_VERSION_ENCODE(arg0, arg1, arg2);
+	Cairo_NATIVE_EXIT(env, that, CAIRO_1VERSION_1ENCODE_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1cairo_1append_1path
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1append_1path)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1append_1path_FUNC);
+	cairo_append_path((cairo_t *)arg0, (cairo_path_t *)arg1);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1append_1path_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1arc
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1arc)
+	(JNIEnv *env, jclass that, jint arg0, jdouble arg1, jdouble arg2, jdouble arg3, jdouble arg4, jdouble arg5)
+{
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1arc_FUNC);
+	cairo_arc((cairo_t *)arg0, arg1, arg2, arg3, arg4, arg5);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1arc_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1arc_1negative
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1arc_1negative)
+	(JNIEnv *env, jclass that, jint arg0, jdouble arg1, jdouble arg2, jdouble arg3, jdouble arg4, jdouble arg5)
+{
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1arc_1negative_FUNC);
+	cairo_arc_negative((cairo_t *)arg0, arg1, arg2, arg3, arg4, arg5);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1arc_1negative_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1clip
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1clip)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1clip_FUNC);
+	cairo_clip((cairo_t *)arg0);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1clip_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1clip_1preserve
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1clip_1preserve)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1clip_1preserve_FUNC);
+	cairo_clip_preserve((cairo_t *)arg0);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1clip_1preserve_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1close_1path
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1close_1path)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1close_1path_FUNC);
+	cairo_close_path((cairo_t *)arg0);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1close_1path_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1copy_1page
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1copy_1page)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1copy_1page_FUNC);
+	cairo_copy_page((cairo_t *)arg0);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1copy_1page_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1copy_1path
+JNIEXPORT jint JNICALL Cairo_NATIVE(_1cairo_1copy_1path)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1copy_1path_FUNC);
+	rc = (jint)cairo_copy_path((cairo_t *)arg0);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1copy_1path_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1cairo_1copy_1path_1flat
+JNIEXPORT jint JNICALL Cairo_NATIVE(_1cairo_1copy_1path_1flat)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1copy_1path_1flat_FUNC);
+	rc = (jint)cairo_copy_path_flat((cairo_t *)arg0);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1copy_1path_1flat_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1cairo_1create
+JNIEXPORT jint JNICALL Cairo_NATIVE(_1cairo_1create)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1create_FUNC);
+	rc = (jint)cairo_create((cairo_surface_t *)arg0);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1create_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1cairo_1curve_1to
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1curve_1to)
+	(JNIEnv *env, jclass that, jint arg0, jdouble arg1, jdouble arg2, jdouble arg3, jdouble arg4, jdouble arg5, jdouble arg6)
+{
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1curve_1to_FUNC);
+	cairo_curve_to((cairo_t *)arg0, arg1, arg2, arg3, arg4, arg5, arg6);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1curve_1to_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1destroy
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1destroy)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1destroy_FUNC);
+	cairo_destroy((cairo_t *)arg0);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1destroy_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1device_1to_1user
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1device_1to_1user)
+	(JNIEnv *env, jclass that, jint arg0, jdoubleArray arg1, jdoubleArray arg2)
+{
+	jdouble *lparg1=NULL;
+	jdouble *lparg2=NULL;
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1device_1to_1user_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetDoubleArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	if (arg2) if ((lparg2 = (*env)->GetDoubleArrayElements(env, arg2, NULL)) == NULL) goto fail;
+	cairo_device_to_user((cairo_t *)arg0, lparg1, lparg2);
+fail:
+	if (arg2 && lparg2) (*env)->ReleaseDoubleArrayElements(env, arg2, lparg2, 0);
+	if (arg1 && lparg1) (*env)->ReleaseDoubleArrayElements(env, arg1, lparg1, 0);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1device_1to_1user_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1device_1to_1user_1distance
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1device_1to_1user_1distance)
+	(JNIEnv *env, jclass that, jint arg0, jdoubleArray arg1, jdoubleArray arg2)
+{
+	jdouble *lparg1=NULL;
+	jdouble *lparg2=NULL;
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1device_1to_1user_1distance_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetDoubleArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	if (arg2) if ((lparg2 = (*env)->GetDoubleArrayElements(env, arg2, NULL)) == NULL) goto fail;
+	cairo_device_to_user_distance((cairo_t *)arg0, lparg1, lparg2);
+fail:
+	if (arg2 && lparg2) (*env)->ReleaseDoubleArrayElements(env, arg2, lparg2, 0);
+	if (arg1 && lparg1) (*env)->ReleaseDoubleArrayElements(env, arg1, lparg1, 0);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1device_1to_1user_1distance_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1fill
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1fill)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1fill_FUNC);
+	cairo_fill((cairo_t *)arg0);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1fill_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1fill_1extents
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1fill_1extents)
+	(JNIEnv *env, jclass that, jint arg0, jdoubleArray arg1, jdoubleArray arg2, jdoubleArray arg3, jdoubleArray arg4)
+{
+	jdouble *lparg1=NULL;
+	jdouble *lparg2=NULL;
+	jdouble *lparg3=NULL;
+	jdouble *lparg4=NULL;
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1fill_1extents_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetDoubleArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	if (arg2) if ((lparg2 = (*env)->GetDoubleArrayElements(env, arg2, NULL)) == NULL) goto fail;
+	if (arg3) if ((lparg3 = (*env)->GetDoubleArrayElements(env, arg3, NULL)) == NULL) goto fail;
+	if (arg4) if ((lparg4 = (*env)->GetDoubleArrayElements(env, arg4, NULL)) == NULL) goto fail;
+	cairo_fill_extents((cairo_t *)arg0, lparg1, lparg2, lparg3, lparg4);
+fail:
+	if (arg4 && lparg4) (*env)->ReleaseDoubleArrayElements(env, arg4, lparg4, 0);
+	if (arg3 && lparg3) (*env)->ReleaseDoubleArrayElements(env, arg3, lparg3, 0);
+	if (arg2 && lparg2) (*env)->ReleaseDoubleArrayElements(env, arg2, lparg2, 0);
+	if (arg1 && lparg1) (*env)->ReleaseDoubleArrayElements(env, arg1, lparg1, 0);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1fill_1extents_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1fill_1preserve
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1fill_1preserve)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1fill_1preserve_FUNC);
+	cairo_fill_preserve((cairo_t *)arg0);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1fill_1preserve_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1font_1extents
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1font_1extents)
+	(JNIEnv *env, jclass that, jint arg0, jobject arg1)
+{
+	cairo_font_extents_t _arg1, *lparg1=NULL;
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1font_1extents_FUNC);
+	if (arg1) if ((lparg1 = getcairo_font_extents_tFields(env, arg1, &_arg1)) == NULL) goto fail;
+	cairo_font_extents((cairo_t *)arg0, lparg1);
+fail:
+	if (arg1 && lparg1) setcairo_font_extents_tFields(env, arg1, lparg1);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1font_1extents_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1font_1options_1create
+JNIEXPORT jint JNICALL Cairo_NATIVE(_1cairo_1font_1options_1create)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1font_1options_1create_FUNC);
+	rc = (jint)cairo_font_options_create();
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1font_1options_1create_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1cairo_1font_1options_1destroy
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1font_1options_1destroy)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1font_1options_1destroy_FUNC);
+	cairo_font_options_destroy((cairo_font_options_t *)arg0);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1font_1options_1destroy_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1font_1options_1get_1antialias
+JNIEXPORT jint JNICALL Cairo_NATIVE(_1cairo_1font_1options_1get_1antialias)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1font_1options_1get_1antialias_FUNC);
+	rc = (jint)cairo_font_options_get_antialias((cairo_font_options_t *)arg0);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1font_1options_1get_1antialias_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1cairo_1font_1options_1set_1antialias
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1font_1options_1set_1antialias)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1font_1options_1set_1antialias_FUNC);
+	cairo_font_options_set_antialias((cairo_font_options_t *)arg0, arg1);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1font_1options_1set_1antialias_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1get_1antialias
+JNIEXPORT jint JNICALL Cairo_NATIVE(_1cairo_1get_1antialias)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1get_1antialias_FUNC);
+	rc = (jint)cairo_get_antialias((cairo_t *)arg0);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1get_1antialias_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1cairo_1get_1current_1point
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1get_1current_1point)
+	(JNIEnv *env, jclass that, jint arg0, jdoubleArray arg1, jdoubleArray arg2)
+{
+	jdouble *lparg1=NULL;
+	jdouble *lparg2=NULL;
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1get_1current_1point_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetDoubleArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	if (arg2) if ((lparg2 = (*env)->GetDoubleArrayElements(env, arg2, NULL)) == NULL) goto fail;
+	cairo_get_current_point((cairo_t *)arg0, lparg1, lparg2);
+fail:
+	if (arg2 && lparg2) (*env)->ReleaseDoubleArrayElements(env, arg2, lparg2, 0);
+	if (arg1 && lparg1) (*env)->ReleaseDoubleArrayElements(env, arg1, lparg1, 0);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1get_1current_1point_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1get_1fill_1rule
+JNIEXPORT jint JNICALL Cairo_NATIVE(_1cairo_1get_1fill_1rule)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1get_1fill_1rule_FUNC);
+	rc = (jint)cairo_get_fill_rule((cairo_t *)arg0);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1get_1fill_1rule_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1cairo_1get_1font_1face
+JNIEXPORT jint JNICALL Cairo_NATIVE(_1cairo_1get_1font_1face)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1get_1font_1face_FUNC);
+	rc = (jint)cairo_get_font_face((cairo_t *)arg0);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1get_1font_1face_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1cairo_1get_1font_1matrix
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1get_1font_1matrix)
+	(JNIEnv *env, jclass that, jint arg0, jdoubleArray arg1)
+{
+	jdouble *lparg1=NULL;
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1get_1font_1matrix_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetDoubleArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	cairo_get_font_matrix((cairo_t *)arg0, (cairo_matrix_t *)lparg1);
+fail:
+	if (arg1 && lparg1) (*env)->ReleaseDoubleArrayElements(env, arg1, lparg1, 0);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1get_1font_1matrix_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1get_1font_1options
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1get_1font_1options)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1get_1font_1options_FUNC);
+	cairo_get_font_options((cairo_t *)arg0, (cairo_font_options_t *)arg1);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1get_1font_1options_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1get_1line_1cap
+JNIEXPORT jint JNICALL Cairo_NATIVE(_1cairo_1get_1line_1cap)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1get_1line_1cap_FUNC);
+	rc = (jint)cairo_get_line_cap((cairo_t *)arg0);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1get_1line_1cap_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1cairo_1get_1line_1join
+JNIEXPORT jint JNICALL Cairo_NATIVE(_1cairo_1get_1line_1join)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1get_1line_1join_FUNC);
+	rc = (jint)cairo_get_line_join((cairo_t *)arg0);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1get_1line_1join_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1cairo_1get_1line_1width
+JNIEXPORT jdouble JNICALL Cairo_NATIVE(_1cairo_1get_1line_1width)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jdouble rc = 0;
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1get_1line_1width_FUNC);
+	rc = (jdouble)cairo_get_line_width((cairo_t *)arg0);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1get_1line_1width_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1cairo_1get_1matrix
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1get_1matrix)
+	(JNIEnv *env, jclass that, jint arg0, jdoubleArray arg1)
+{
+	jdouble *lparg1=NULL;
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1get_1matrix_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetDoubleArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	cairo_get_matrix((cairo_t *)arg0, (cairo_matrix_t *)lparg1);
+fail:
+	if (arg1 && lparg1) (*env)->ReleaseDoubleArrayElements(env, arg1, lparg1, 0);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1get_1matrix_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1get_1miter_1limit
+JNIEXPORT jdouble JNICALL Cairo_NATIVE(_1cairo_1get_1miter_1limit)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jdouble rc = 0;
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1get_1miter_1limit_FUNC);
+	rc = (jdouble)cairo_get_miter_limit((cairo_t *)arg0);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1get_1miter_1limit_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1cairo_1get_1operator
+JNIEXPORT jint JNICALL Cairo_NATIVE(_1cairo_1get_1operator)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1get_1operator_FUNC);
+	rc = (jint)cairo_get_operator((cairo_t *)arg0);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1get_1operator_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1cairo_1get_1source
+JNIEXPORT jint JNICALL Cairo_NATIVE(_1cairo_1get_1source)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1get_1source_FUNC);
+	rc = (jint)cairo_get_source((cairo_t *)arg0);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1get_1source_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1cairo_1get_1target
+JNIEXPORT jint JNICALL Cairo_NATIVE(_1cairo_1get_1target)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1get_1target_FUNC);
+	rc = (jint)cairo_get_target((cairo_t *)arg0);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1get_1target_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1cairo_1get_1tolerance
+JNIEXPORT jdouble JNICALL Cairo_NATIVE(_1cairo_1get_1tolerance)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jdouble rc = 0;
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1get_1tolerance_FUNC);
+	rc = (jdouble)cairo_get_tolerance((cairo_t *)arg0);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1get_1tolerance_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1cairo_1glyph_1extents
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1glyph_1extents)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3)
+{
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1glyph_1extents_FUNC);
+	cairo_glyph_extents((cairo_t *)arg0, (cairo_glyph_t *)arg1, arg2, (cairo_text_extents_t *)arg3);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1glyph_1extents_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1glyph_1path
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1glyph_1path)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1glyph_1path_FUNC);
+	cairo_glyph_path((cairo_t *)arg0, (cairo_glyph_t *)arg1, arg2);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1glyph_1path_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1identity_1matrix
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1identity_1matrix)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1identity_1matrix_FUNC);
+	cairo_identity_matrix((cairo_t *)arg0);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1identity_1matrix_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1image_1surface_1create
+JNIEXPORT jint JNICALL Cairo_NATIVE(_1cairo_1image_1surface_1create)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+	jint rc = 0;
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1image_1surface_1create_FUNC);
+	rc = (jint)cairo_image_surface_create(arg0, arg1, arg2);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1image_1surface_1create_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1cairo_1image_1surface_1create_1for_1data
+JNIEXPORT jint JNICALL Cairo_NATIVE(_1cairo_1image_1surface_1create_1for_1data)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4)
+{
+	jint rc = 0;
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1image_1surface_1create_1for_1data_FUNC);
+	rc = (jint)cairo_image_surface_create_for_data((unsigned char *)arg0, arg1, arg2, arg3, arg4);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1image_1surface_1create_1for_1data_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1cairo_1image_1surface_1get_1height
+JNIEXPORT jint JNICALL Cairo_NATIVE(_1cairo_1image_1surface_1get_1height)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1image_1surface_1get_1height_FUNC);
+	rc = (jint)cairo_image_surface_get_height((cairo_surface_t *)arg0);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1image_1surface_1get_1height_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1cairo_1image_1surface_1get_1width
+JNIEXPORT jint JNICALL Cairo_NATIVE(_1cairo_1image_1surface_1get_1width)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1image_1surface_1get_1width_FUNC);
+	rc = (jint)cairo_image_surface_get_width((cairo_surface_t *)arg0);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1image_1surface_1get_1width_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1cairo_1in_1fill
+JNIEXPORT jint JNICALL Cairo_NATIVE(_1cairo_1in_1fill)
+	(JNIEnv *env, jclass that, jint arg0, jdouble arg1, jdouble arg2)
+{
+	jint rc = 0;
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1in_1fill_FUNC);
+	rc = (jint)cairo_in_fill((cairo_t *)arg0, arg1, arg2);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1in_1fill_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1cairo_1in_1stroke
+JNIEXPORT jint JNICALL Cairo_NATIVE(_1cairo_1in_1stroke)
+	(JNIEnv *env, jclass that, jint arg0, jdouble arg1, jdouble arg2)
+{
+	jint rc = 0;
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1in_1stroke_FUNC);
+	rc = (jint)cairo_in_stroke((cairo_t *)arg0, arg1, arg2);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1in_1stroke_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1cairo_1line_1to
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1line_1to)
+	(JNIEnv *env, jclass that, jint arg0, jdouble arg1, jdouble arg2)
+{
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1line_1to_FUNC);
+	cairo_line_to((cairo_t *)arg0, arg1, arg2);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1line_1to_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1mask
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1mask)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1mask_FUNC);
+	cairo_mask((cairo_t *)arg0, (cairo_pattern_t *)arg1);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1mask_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1mask_1surface
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1mask_1surface)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jdouble arg2, jdouble arg3)
+{
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1mask_1surface_FUNC);
+	cairo_mask_surface((cairo_t *)arg0, (cairo_surface_t *)arg1, arg2, arg3);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1mask_1surface_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1matrix_1init
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1matrix_1init)
+	(JNIEnv *env, jclass that, jdoubleArray arg0, jdouble arg1, jdouble arg2, jdouble arg3, jdouble arg4, jdouble arg5, jdouble arg6)
+{
+	jdouble *lparg0=NULL;
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1matrix_1init_FUNC);
+	if (arg0) if ((lparg0 = (*env)->GetDoubleArrayElements(env, arg0, NULL)) == NULL) goto fail;
+	cairo_matrix_init((cairo_matrix_t *)lparg0, arg1, arg2, arg3, arg4, arg5, arg6);
+fail:
+	if (arg0 && lparg0) (*env)->ReleaseDoubleArrayElements(env, arg0, lparg0, 0);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1matrix_1init_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1matrix_1init_1identity
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1matrix_1init_1identity)
+	(JNIEnv *env, jclass that, jdoubleArray arg0)
+{
+	jdouble *lparg0=NULL;
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1matrix_1init_1identity_FUNC);
+	if (arg0) if ((lparg0 = (*env)->GetDoubleArrayElements(env, arg0, NULL)) == NULL) goto fail;
+	cairo_matrix_init_identity((cairo_matrix_t *)lparg0);
+fail:
+	if (arg0 && lparg0) (*env)->ReleaseDoubleArrayElements(env, arg0, lparg0, 0);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1matrix_1init_1identity_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1matrix_1init_1rotate
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1matrix_1init_1rotate)
+	(JNIEnv *env, jclass that, jdoubleArray arg0, jdouble arg1)
+{
+	jdouble *lparg0=NULL;
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1matrix_1init_1rotate_FUNC);
+	if (arg0) if ((lparg0 = (*env)->GetDoubleArrayElements(env, arg0, NULL)) == NULL) goto fail;
+	cairo_matrix_init_rotate((cairo_matrix_t *)lparg0, arg1);
+fail:
+	if (arg0 && lparg0) (*env)->ReleaseDoubleArrayElements(env, arg0, lparg0, 0);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1matrix_1init_1rotate_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1matrix_1init_1scale
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1matrix_1init_1scale)
+	(JNIEnv *env, jclass that, jdoubleArray arg0, jdouble arg1, jdouble arg2)
+{
+	jdouble *lparg0=NULL;
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1matrix_1init_1scale_FUNC);
+	if (arg0) if ((lparg0 = (*env)->GetDoubleArrayElements(env, arg0, NULL)) == NULL) goto fail;
+	cairo_matrix_init_scale((cairo_matrix_t *)lparg0, arg1, arg2);
+fail:
+	if (arg0 && lparg0) (*env)->ReleaseDoubleArrayElements(env, arg0, lparg0, 0);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1matrix_1init_1scale_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1matrix_1init_1translate
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1matrix_1init_1translate)
+	(JNIEnv *env, jclass that, jdoubleArray arg0, jdouble arg1, jdouble arg2)
+{
+	jdouble *lparg0=NULL;
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1matrix_1init_1translate_FUNC);
+	if (arg0) if ((lparg0 = (*env)->GetDoubleArrayElements(env, arg0, NULL)) == NULL) goto fail;
+	cairo_matrix_init_translate((cairo_matrix_t *)lparg0, arg1, arg2);
+fail:
+	if (arg0 && lparg0) (*env)->ReleaseDoubleArrayElements(env, arg0, lparg0, 0);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1matrix_1init_1translate_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1matrix_1invert
+JNIEXPORT jint JNICALL Cairo_NATIVE(_1cairo_1matrix_1invert)
+	(JNIEnv *env, jclass that, jdoubleArray arg0)
+{
+	jdouble *lparg0=NULL;
+	jint rc = 0;
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1matrix_1invert_FUNC);
+	if (arg0) if ((lparg0 = (*env)->GetDoubleArrayElements(env, arg0, NULL)) == NULL) goto fail;
+	rc = (jint)cairo_matrix_invert((cairo_matrix_t *)lparg0);
+fail:
+	if (arg0 && lparg0) (*env)->ReleaseDoubleArrayElements(env, arg0, lparg0, 0);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1matrix_1invert_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1cairo_1matrix_1multiply
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1matrix_1multiply)
+	(JNIEnv *env, jclass that, jdoubleArray arg0, jdoubleArray arg1, jdoubleArray arg2)
+{
+	jdouble *lparg0=NULL;
+	jdouble *lparg1=NULL;
+	jdouble *lparg2=NULL;
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1matrix_1multiply_FUNC);
+	if (arg0) if ((lparg0 = (*env)->GetDoubleArrayElements(env, arg0, NULL)) == NULL) goto fail;
+	if (arg1) if ((lparg1 = (*env)->GetDoubleArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	if (arg2) if ((lparg2 = (*env)->GetDoubleArrayElements(env, arg2, NULL)) == NULL) goto fail;
+	cairo_matrix_multiply((cairo_matrix_t *)lparg0, (cairo_matrix_t *)lparg1, (cairo_matrix_t *)lparg2);
+fail:
+	if (arg2 && lparg2) (*env)->ReleaseDoubleArrayElements(env, arg2, lparg2, 0);
+	if (arg1 && lparg1) (*env)->ReleaseDoubleArrayElements(env, arg1, lparg1, 0);
+	if (arg0 && lparg0) (*env)->ReleaseDoubleArrayElements(env, arg0, lparg0, 0);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1matrix_1multiply_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1matrix_1rotate
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1matrix_1rotate)
+	(JNIEnv *env, jclass that, jdoubleArray arg0, jdouble arg1)
+{
+	jdouble *lparg0=NULL;
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1matrix_1rotate_FUNC);
+	if (arg0) if ((lparg0 = (*env)->GetDoubleArrayElements(env, arg0, NULL)) == NULL) goto fail;
+	cairo_matrix_rotate((cairo_matrix_t *)lparg0, arg1);
+fail:
+	if (arg0 && lparg0) (*env)->ReleaseDoubleArrayElements(env, arg0, lparg0, 0);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1matrix_1rotate_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1matrix_1scale
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1matrix_1scale)
+	(JNIEnv *env, jclass that, jdoubleArray arg0, jdouble arg1, jdouble arg2)
+{
+	jdouble *lparg0=NULL;
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1matrix_1scale_FUNC);
+	if (arg0) if ((lparg0 = (*env)->GetDoubleArrayElements(env, arg0, NULL)) == NULL) goto fail;
+	cairo_matrix_scale((cairo_matrix_t *)lparg0, arg1, arg2);
+fail:
+	if (arg0 && lparg0) (*env)->ReleaseDoubleArrayElements(env, arg0, lparg0, 0);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1matrix_1scale_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1matrix_1transform_1distance
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1matrix_1transform_1distance)
+	(JNIEnv *env, jclass that, jdoubleArray arg0, jdoubleArray arg1, jdoubleArray arg2)
+{
+	jdouble *lparg0=NULL;
+	jdouble *lparg1=NULL;
+	jdouble *lparg2=NULL;
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1matrix_1transform_1distance_FUNC);
+	if (arg0) if ((lparg0 = (*env)->GetDoubleArrayElements(env, arg0, NULL)) == NULL) goto fail;
+	if (arg1) if ((lparg1 = (*env)->GetDoubleArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	if (arg2) if ((lparg2 = (*env)->GetDoubleArrayElements(env, arg2, NULL)) == NULL) goto fail;
+	cairo_matrix_transform_distance((cairo_matrix_t *)lparg0, lparg1, lparg2);
+fail:
+	if (arg2 && lparg2) (*env)->ReleaseDoubleArrayElements(env, arg2, lparg2, 0);
+	if (arg1 && lparg1) (*env)->ReleaseDoubleArrayElements(env, arg1, lparg1, 0);
+	if (arg0 && lparg0) (*env)->ReleaseDoubleArrayElements(env, arg0, lparg0, 0);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1matrix_1transform_1distance_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1matrix_1transform_1point
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1matrix_1transform_1point)
+	(JNIEnv *env, jclass that, jdoubleArray arg0, jdoubleArray arg1, jdoubleArray arg2)
+{
+	jdouble *lparg0=NULL;
+	jdouble *lparg1=NULL;
+	jdouble *lparg2=NULL;
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1matrix_1transform_1point_FUNC);
+	if (arg0) if ((lparg0 = (*env)->GetDoubleArrayElements(env, arg0, NULL)) == NULL) goto fail;
+	if (arg1) if ((lparg1 = (*env)->GetDoubleArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	if (arg2) if ((lparg2 = (*env)->GetDoubleArrayElements(env, arg2, NULL)) == NULL) goto fail;
+	cairo_matrix_transform_point((cairo_matrix_t *)lparg0, lparg1, lparg2);
+fail:
+	if (arg2 && lparg2) (*env)->ReleaseDoubleArrayElements(env, arg2, lparg2, 0);
+	if (arg1 && lparg1) (*env)->ReleaseDoubleArrayElements(env, arg1, lparg1, 0);
+	if (arg0 && lparg0) (*env)->ReleaseDoubleArrayElements(env, arg0, lparg0, 0);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1matrix_1transform_1point_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1matrix_1translate
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1matrix_1translate)
+	(JNIEnv *env, jclass that, jdoubleArray arg0, jdouble arg1, jdouble arg2)
+{
+	jdouble *lparg0=NULL;
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1matrix_1translate_FUNC);
+	if (arg0) if ((lparg0 = (*env)->GetDoubleArrayElements(env, arg0, NULL)) == NULL) goto fail;
+	cairo_matrix_translate((cairo_matrix_t *)lparg0, arg1, arg2);
+fail:
+	if (arg0 && lparg0) (*env)->ReleaseDoubleArrayElements(env, arg0, lparg0, 0);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1matrix_1translate_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1move_1to
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1move_1to)
+	(JNIEnv *env, jclass that, jint arg0, jdouble arg1, jdouble arg2)
+{
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1move_1to_FUNC);
+	cairo_move_to((cairo_t *)arg0, arg1, arg2);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1move_1to_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1new_1path
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1new_1path)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1new_1path_FUNC);
+	cairo_new_path((cairo_t *)arg0);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1new_1path_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1paint
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1paint)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1paint_FUNC);
+	cairo_paint((cairo_t *)arg0);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1paint_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1paint_1with_1alpha
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1paint_1with_1alpha)
+	(JNIEnv *env, jclass that, jint arg0, jdouble arg1)
+{
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1paint_1with_1alpha_FUNC);
+	cairo_paint_with_alpha((cairo_t *)arg0, arg1);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1paint_1with_1alpha_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1path_1destroy
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1path_1destroy)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1path_1destroy_FUNC);
+	cairo_path_destroy((cairo_path_t *)arg0);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1path_1destroy_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1pattern_1add_1color_1stop_1rgb
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1pattern_1add_1color_1stop_1rgb)
+	(JNIEnv *env, jclass that, jint arg0, jdouble arg1, jdouble arg2, jdouble arg3, jdouble arg4)
+{
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1pattern_1add_1color_1stop_1rgb_FUNC);
+	cairo_pattern_add_color_stop_rgb((cairo_pattern_t *)arg0, arg1, arg2, arg3, arg4);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1pattern_1add_1color_1stop_1rgb_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1pattern_1add_1color_1stop_1rgba
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1pattern_1add_1color_1stop_1rgba)
+	(JNIEnv *env, jclass that, jint arg0, jdouble arg1, jdouble arg2, jdouble arg3, jdouble arg4, jdouble arg5)
+{
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1pattern_1add_1color_1stop_1rgba_FUNC);
+	cairo_pattern_add_color_stop_rgba((cairo_pattern_t *)arg0, arg1, arg2, arg3, arg4, arg5);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1pattern_1add_1color_1stop_1rgba_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1pattern_1create_1for_1surface
+JNIEXPORT jint JNICALL Cairo_NATIVE(_1cairo_1pattern_1create_1for_1surface)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1pattern_1create_1for_1surface_FUNC);
+	rc = (jint)cairo_pattern_create_for_surface((cairo_surface_t *)arg0);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1pattern_1create_1for_1surface_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1cairo_1pattern_1create_1linear
+JNIEXPORT jint JNICALL Cairo_NATIVE(_1cairo_1pattern_1create_1linear)
+	(JNIEnv *env, jclass that, jdouble arg0, jdouble arg1, jdouble arg2, jdouble arg3)
+{
+	jint rc = 0;
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1pattern_1create_1linear_FUNC);
+	rc = (jint)cairo_pattern_create_linear(arg0, arg1, arg2, arg3);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1pattern_1create_1linear_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1cairo_1pattern_1create_1radial
+JNIEXPORT jint JNICALL Cairo_NATIVE(_1cairo_1pattern_1create_1radial)
+	(JNIEnv *env, jclass that, jdouble arg0, jdouble arg1, jdouble arg2, jdouble arg3, jdouble arg4, jdouble arg5)
+{
+	jint rc = 0;
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1pattern_1create_1radial_FUNC);
+	rc = (jint)cairo_pattern_create_radial(arg0, arg1, arg2, arg3, arg4, arg5);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1pattern_1create_1radial_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1cairo_1pattern_1destroy
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1pattern_1destroy)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1pattern_1destroy_FUNC);
+	cairo_pattern_destroy((cairo_pattern_t *)arg0);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1pattern_1destroy_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1pattern_1get_1extend
+JNIEXPORT jint JNICALL Cairo_NATIVE(_1cairo_1pattern_1get_1extend)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1pattern_1get_1extend_FUNC);
+	rc = (jint)cairo_pattern_get_extend((cairo_pattern_t *)arg0);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1pattern_1get_1extend_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1cairo_1pattern_1get_1filter
+JNIEXPORT jint JNICALL Cairo_NATIVE(_1cairo_1pattern_1get_1filter)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1pattern_1get_1filter_FUNC);
+	rc = (jint)cairo_pattern_get_filter((cairo_pattern_t *)arg0);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1pattern_1get_1filter_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1cairo_1pattern_1get_1matrix
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1pattern_1get_1matrix)
+	(JNIEnv *env, jclass that, jint arg0, jdoubleArray arg1)
+{
+	jdouble *lparg1=NULL;
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1pattern_1get_1matrix_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetDoubleArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	cairo_pattern_get_matrix((cairo_pattern_t *)arg0, (cairo_matrix_t *)lparg1);
+fail:
+	if (arg1 && lparg1) (*env)->ReleaseDoubleArrayElements(env, arg1, lparg1, 0);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1pattern_1get_1matrix_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1pattern_1reference
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1pattern_1reference)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1pattern_1reference_FUNC);
+	cairo_pattern_reference((cairo_pattern_t *)arg0);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1pattern_1reference_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1pattern_1set_1extend
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1pattern_1set_1extend)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1pattern_1set_1extend_FUNC);
+	cairo_pattern_set_extend((cairo_pattern_t *)arg0, arg1);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1pattern_1set_1extend_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1pattern_1set_1filter
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1pattern_1set_1filter)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1pattern_1set_1filter_FUNC);
+	cairo_pattern_set_filter((cairo_pattern_t *)arg0, arg1);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1pattern_1set_1filter_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1pattern_1set_1matrix
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1pattern_1set_1matrix)
+	(JNIEnv *env, jclass that, jint arg0, jdoubleArray arg1)
+{
+	jdouble *lparg1=NULL;
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1pattern_1set_1matrix_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetDoubleArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	cairo_pattern_set_matrix((cairo_pattern_t *)arg0, (cairo_matrix_t *)lparg1);
+fail:
+	if (arg1 && lparg1) (*env)->ReleaseDoubleArrayElements(env, arg1, lparg1, 0);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1pattern_1set_1matrix_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1pdf_1surface_1set_1size
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1pdf_1surface_1set_1size)
+	(JNIEnv *env, jclass that, jint arg0, jdouble arg1, jdouble arg2)
+{
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1pdf_1surface_1set_1size_FUNC);
+/*
+	cairo_pdf_surface_set_size((cairo_surface_t *)arg0, arg1, arg2);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef void (*FPTR)(cairo_surface_t *, jdouble, jdouble);
+		static FPTR fptr;
+		if (!initialized) {
+			if (!handle) handle = dlopen(cairo_pdf_surface_set_size_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "cairo_pdf_surface_set_size");
+			initialized = 1;
+		}
+		if (fptr) {
+			(*fptr)((cairo_surface_t *)arg0, arg1, arg2);
+		}
+	}
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1pdf_1surface_1set_1size_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1ps_1surface_1set_1size
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1ps_1surface_1set_1size)
+	(JNIEnv *env, jclass that, jint arg0, jdouble arg1, jdouble arg2)
+{
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1ps_1surface_1set_1size_FUNC);
+/*
+	cairo_ps_surface_set_size((cairo_surface_t *)arg0, arg1, arg2);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef void (*FPTR)(cairo_surface_t *, jdouble, jdouble);
+		static FPTR fptr;
+		if (!initialized) {
+			if (!handle) handle = dlopen(cairo_ps_surface_set_size_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "cairo_ps_surface_set_size");
+			initialized = 1;
+		}
+		if (fptr) {
+			(*fptr)((cairo_surface_t *)arg0, arg1, arg2);
+		}
+	}
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1ps_1surface_1set_1size_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1rectangle
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1rectangle)
+	(JNIEnv *env, jclass that, jint arg0, jdouble arg1, jdouble arg2, jdouble arg3, jdouble arg4)
+{
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1rectangle_FUNC);
+	cairo_rectangle((cairo_t *)arg0, arg1, arg2, arg3, arg4);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1rectangle_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1reference
+JNIEXPORT jint JNICALL Cairo_NATIVE(_1cairo_1reference)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1reference_FUNC);
+	rc = (jint)cairo_reference((cairo_t *)arg0);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1reference_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1cairo_1rel_1curve_1to
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1rel_1curve_1to)
+	(JNIEnv *env, jclass that, jint arg0, jdouble arg1, jdouble arg2, jdouble arg3, jdouble arg4, jdouble arg5, jdouble arg6)
+{
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1rel_1curve_1to_FUNC);
+	cairo_rel_curve_to((cairo_t *)arg0, arg1, arg2, arg3, arg4, arg5, arg6);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1rel_1curve_1to_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1rel_1line_1to
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1rel_1line_1to)
+	(JNIEnv *env, jclass that, jint arg0, jdouble arg1, jdouble arg2)
+{
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1rel_1line_1to_FUNC);
+	cairo_rel_line_to((cairo_t *)arg0, arg1, arg2);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1rel_1line_1to_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1rel_1move_1to
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1rel_1move_1to)
+	(JNIEnv *env, jclass that, jint arg0, jdouble arg1, jdouble arg2)
+{
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1rel_1move_1to_FUNC);
+	cairo_rel_move_to((cairo_t *)arg0, arg1, arg2);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1rel_1move_1to_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1reset_1clip
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1reset_1clip)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1reset_1clip_FUNC);
+	cairo_reset_clip((cairo_t *)arg0);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1reset_1clip_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1restore
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1restore)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1restore_FUNC);
+	cairo_restore((cairo_t *)arg0);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1restore_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1rotate
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1rotate)
+	(JNIEnv *env, jclass that, jint arg0, jdouble arg1)
+{
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1rotate_FUNC);
+	cairo_rotate((cairo_t *)arg0, arg1);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1rotate_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1save
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1save)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1save_FUNC);
+	cairo_save((cairo_t *)arg0);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1save_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1scale
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1scale)
+	(JNIEnv *env, jclass that, jint arg0, jdouble arg1, jdouble arg2)
+{
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1scale_FUNC);
+	cairo_scale((cairo_t *)arg0, arg1, arg2);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1scale_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1select_1font_1face
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1select_1font_1face)
+	(JNIEnv *env, jclass that, jint arg0, jbyteArray arg1, jint arg2, jint arg3)
+{
+	jbyte *lparg1=NULL;
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1select_1font_1face_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	cairo_select_font_face((cairo_t *)arg0, (const char *)lparg1, arg2, arg3);
+fail:
+	if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1select_1font_1face_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1set_1antialias
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1set_1antialias)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1set_1antialias_FUNC);
+	cairo_set_antialias((cairo_t *)arg0, arg1);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1set_1antialias_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1set_1dash
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1set_1dash)
+	(JNIEnv *env, jclass that, jint arg0, jdoubleArray arg1, jint arg2, jdouble arg3)
+{
+	jdouble *lparg1=NULL;
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1set_1dash_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetDoubleArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	cairo_set_dash((cairo_t *)arg0, lparg1, arg2, arg3);
+fail:
+	if (arg1 && lparg1) (*env)->ReleaseDoubleArrayElements(env, arg1, lparg1, 0);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1set_1dash_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1set_1fill_1rule
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1set_1fill_1rule)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1set_1fill_1rule_FUNC);
+	cairo_set_fill_rule((cairo_t *)arg0, arg1);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1set_1fill_1rule_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1set_1font_1face
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1set_1font_1face)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1set_1font_1face_FUNC);
+	cairo_set_font_face((cairo_t *)arg0, (cairo_font_face_t *)arg1);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1set_1font_1face_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1set_1font_1matrix
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1set_1font_1matrix)
+	(JNIEnv *env, jclass that, jint arg0, jdoubleArray arg1)
+{
+	jdouble *lparg1=NULL;
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1set_1font_1matrix_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetDoubleArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	cairo_set_font_matrix((cairo_t *)arg0, (cairo_matrix_t *)lparg1);
+fail:
+	if (arg1 && lparg1) (*env)->ReleaseDoubleArrayElements(env, arg1, lparg1, 0);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1set_1font_1matrix_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1set_1font_1options
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1set_1font_1options)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1set_1font_1options_FUNC);
+	cairo_set_font_options((cairo_t *)arg0, (cairo_font_options_t *)arg1);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1set_1font_1options_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1set_1font_1size
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1set_1font_1size)
+	(JNIEnv *env, jclass that, jint arg0, jdouble arg1)
+{
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1set_1font_1size_FUNC);
+	cairo_set_font_size((cairo_t *)arg0, arg1);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1set_1font_1size_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1set_1line_1cap
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1set_1line_1cap)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1set_1line_1cap_FUNC);
+	cairo_set_line_cap((cairo_t *)arg0, arg1);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1set_1line_1cap_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1set_1line_1join
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1set_1line_1join)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1set_1line_1join_FUNC);
+	cairo_set_line_join((cairo_t *)arg0, arg1);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1set_1line_1join_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1set_1line_1width
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1set_1line_1width)
+	(JNIEnv *env, jclass that, jint arg0, jdouble arg1)
+{
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1set_1line_1width_FUNC);
+	cairo_set_line_width((cairo_t *)arg0, arg1);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1set_1line_1width_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1set_1matrix
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1set_1matrix)
+	(JNIEnv *env, jclass that, jint arg0, jdoubleArray arg1)
+{
+	jdouble *lparg1=NULL;
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1set_1matrix_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetDoubleArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	cairo_set_matrix((cairo_t *)arg0, (cairo_matrix_t *)lparg1);
+fail:
+	if (arg1 && lparg1) (*env)->ReleaseDoubleArrayElements(env, arg1, lparg1, 0);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1set_1matrix_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1set_1miter_1limit
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1set_1miter_1limit)
+	(JNIEnv *env, jclass that, jint arg0, jdouble arg1)
+{
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1set_1miter_1limit_FUNC);
+	cairo_set_miter_limit((cairo_t *)arg0, arg1);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1set_1miter_1limit_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1set_1operator
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1set_1operator)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1set_1operator_FUNC);
+	cairo_set_operator((cairo_t *)arg0, arg1);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1set_1operator_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1set_1source
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1set_1source)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1set_1source_FUNC);
+	cairo_set_source((cairo_t *)arg0, (cairo_pattern_t *)arg1);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1set_1source_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1set_1source_1rgb
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1set_1source_1rgb)
+	(JNIEnv *env, jclass that, jint arg0, jdouble arg1, jdouble arg2, jdouble arg3)
+{
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1set_1source_1rgb_FUNC);
+	cairo_set_source_rgb((cairo_t *)arg0, arg1, arg2, arg3);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1set_1source_1rgb_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1set_1source_1rgba
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1set_1source_1rgba)
+	(JNIEnv *env, jclass that, jint arg0, jdouble arg1, jdouble arg2, jdouble arg3, jdouble arg4)
+{
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1set_1source_1rgba_FUNC);
+	cairo_set_source_rgba((cairo_t *)arg0, arg1, arg2, arg3, arg4);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1set_1source_1rgba_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1set_1source_1surface
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1set_1source_1surface)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jdouble arg2, jdouble arg3)
+{
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1set_1source_1surface_FUNC);
+	cairo_set_source_surface((cairo_t *)arg0, (cairo_surface_t *)arg1, arg2, arg3);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1set_1source_1surface_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1set_1tolerance
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1set_1tolerance)
+	(JNIEnv *env, jclass that, jint arg0, jdouble arg1)
+{
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1set_1tolerance_FUNC);
+	cairo_set_tolerance((cairo_t *)arg0, arg1);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1set_1tolerance_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1show_1glyphs
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1show_1glyphs)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1show_1glyphs_FUNC);
+	cairo_show_glyphs((cairo_t *)arg0, (cairo_glyph_t *)arg1, arg2);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1show_1glyphs_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1show_1page
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1show_1page)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1show_1page_FUNC);
+	cairo_show_page((cairo_t *)arg0);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1show_1page_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1show_1text
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1show_1text)
+	(JNIEnv *env, jclass that, jint arg0, jbyteArray arg1)
+{
+	jbyte *lparg1=NULL;
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1show_1text_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	cairo_show_text((cairo_t *)arg0, (const char *)lparg1);
+fail:
+	if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1show_1text_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1status
+JNIEXPORT jint JNICALL Cairo_NATIVE(_1cairo_1status)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1status_FUNC);
+	rc = (jint)cairo_status((cairo_t *)arg0);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1status_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1cairo_1status_1to_1string
+JNIEXPORT jint JNICALL Cairo_NATIVE(_1cairo_1status_1to_1string)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1status_1to_1string_FUNC);
+	rc = (jint)cairo_status_to_string(arg0);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1status_1to_1string_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1cairo_1stroke
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1stroke)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1stroke_FUNC);
+	cairo_stroke((cairo_t *)arg0);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1stroke_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1stroke_1extents
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1stroke_1extents)
+	(JNIEnv *env, jclass that, jint arg0, jdoubleArray arg1, jdoubleArray arg2, jdoubleArray arg3, jdoubleArray arg4)
+{
+	jdouble *lparg1=NULL;
+	jdouble *lparg2=NULL;
+	jdouble *lparg3=NULL;
+	jdouble *lparg4=NULL;
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1stroke_1extents_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetDoubleArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	if (arg2) if ((lparg2 = (*env)->GetDoubleArrayElements(env, arg2, NULL)) == NULL) goto fail;
+	if (arg3) if ((lparg3 = (*env)->GetDoubleArrayElements(env, arg3, NULL)) == NULL) goto fail;
+	if (arg4) if ((lparg4 = (*env)->GetDoubleArrayElements(env, arg4, NULL)) == NULL) goto fail;
+	cairo_stroke_extents((cairo_t *)arg0, lparg1, lparg2, lparg3, lparg4);
+fail:
+	if (arg4 && lparg4) (*env)->ReleaseDoubleArrayElements(env, arg4, lparg4, 0);
+	if (arg3 && lparg3) (*env)->ReleaseDoubleArrayElements(env, arg3, lparg3, 0);
+	if (arg2 && lparg2) (*env)->ReleaseDoubleArrayElements(env, arg2, lparg2, 0);
+	if (arg1 && lparg1) (*env)->ReleaseDoubleArrayElements(env, arg1, lparg1, 0);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1stroke_1extents_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1stroke_1preserve
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1stroke_1preserve)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1stroke_1preserve_FUNC);
+	cairo_stroke_preserve((cairo_t *)arg0);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1stroke_1preserve_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1surface_1create_1similar
+JNIEXPORT jint JNICALL Cairo_NATIVE(_1cairo_1surface_1create_1similar)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3)
+{
+	jint rc = 0;
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1surface_1create_1similar_FUNC);
+	rc = (jint)cairo_surface_create_similar((cairo_surface_t *)arg0, arg1, arg2, arg3);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1surface_1create_1similar_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1cairo_1surface_1destroy
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1surface_1destroy)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1surface_1destroy_FUNC);
+	cairo_surface_destroy((cairo_surface_t *)arg0);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1surface_1destroy_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1surface_1finish
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1surface_1finish)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1surface_1finish_FUNC);
+	cairo_surface_finish((cairo_surface_t *)arg0);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1surface_1finish_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1surface_1get_1type
+JNIEXPORT jint JNICALL Cairo_NATIVE(_1cairo_1surface_1get_1type)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1surface_1get_1type_FUNC);
+/*
+	rc = (jint)cairo_surface_get_type((cairo_surface_t *)arg0);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jint (*FPTR)(cairo_surface_t *);
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(cairo_surface_get_type_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "cairo_surface_get_type");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jint)(*fptr)((cairo_surface_t *)arg0);
+		}
+	}
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1surface_1get_1type_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1cairo_1surface_1get_1user_1data
+JNIEXPORT jint JNICALL Cairo_NATIVE(_1cairo_1surface_1get_1user_1data)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	jint rc = 0;
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1surface_1get_1user_1data_FUNC);
+	rc = (jint)cairo_surface_get_user_data((cairo_surface_t *)arg0, (cairo_user_data_key_t *)arg1);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1surface_1get_1user_1data_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1cairo_1surface_1reference
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1surface_1reference)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1surface_1reference_FUNC);
+	cairo_surface_reference((cairo_surface_t *)arg0);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1surface_1reference_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1surface_1set_1device_1offset
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1surface_1set_1device_1offset)
+	(JNIEnv *env, jclass that, jint arg0, jdouble arg1, jdouble arg2)
+{
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1surface_1set_1device_1offset_FUNC);
+	cairo_surface_set_device_offset((cairo_surface_t *)arg0, arg1, arg2);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1surface_1set_1device_1offset_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1surface_1set_1fallback_1resolution
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1surface_1set_1fallback_1resolution)
+	(JNIEnv *env, jclass that, jint arg0, jdouble arg1, jdouble arg2)
+{
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1surface_1set_1fallback_1resolution_FUNC);
+/*
+	cairo_surface_set_fallback_resolution(arg0, arg1, arg2);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef void (*FPTR)(jint, jdouble, jdouble);
+		static FPTR fptr;
+		if (!initialized) {
+			if (!handle) handle = dlopen(cairo_surface_set_fallback_resolution_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "cairo_surface_set_fallback_resolution");
+			initialized = 1;
+		}
+		if (fptr) {
+			(*fptr)(arg0, arg1, arg2);
+		}
+	}
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1surface_1set_1fallback_1resolution_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1surface_1set_1user_1data
+JNIEXPORT jint JNICALL Cairo_NATIVE(_1cairo_1surface_1set_1user_1data)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3)
+{
+	jint rc = 0;
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1surface_1set_1user_1data_FUNC);
+	rc = (jint)cairo_surface_set_user_data((cairo_surface_t *)arg0, (cairo_user_data_key_t *)arg1, (void *)arg2, (cairo_destroy_func_t)arg3);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1surface_1set_1user_1data_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1cairo_1text_1extents
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1text_1extents)
+	(JNIEnv *env, jclass that, jint arg0, jbyteArray arg1, jobject arg2)
+{
+	jbyte *lparg1=NULL;
+	cairo_text_extents_t _arg2, *lparg2=NULL;
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1text_1extents_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	if (arg2) if ((lparg2 = getcairo_text_extents_tFields(env, arg2, &_arg2)) == NULL) goto fail;
+	cairo_text_extents((cairo_t *)arg0, (const char *)lparg1, (cairo_text_extents_t *)lparg2);
+fail:
+	if (arg2 && lparg2) setcairo_text_extents_tFields(env, arg2, lparg2);
+	if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1text_1extents_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1text_1path
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1text_1path)
+	(JNIEnv *env, jclass that, jint arg0, jbyteArray arg1)
+{
+	jbyte *lparg1=NULL;
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1text_1path_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	cairo_text_path((cairo_t *)arg0, (const char *)lparg1);
+fail:
+	if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1text_1path_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1transform
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1transform)
+	(JNIEnv *env, jclass that, jint arg0, jdoubleArray arg1)
+{
+	jdouble *lparg1=NULL;
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1transform_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetDoubleArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	cairo_transform((cairo_t *)arg0, (cairo_matrix_t *)lparg1);
+fail:
+	if (arg1 && lparg1) (*env)->ReleaseDoubleArrayElements(env, arg1, lparg1, 0);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1transform_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1translate
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1translate)
+	(JNIEnv *env, jclass that, jint arg0, jdouble arg1, jdouble arg2)
+{
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1translate_FUNC);
+	cairo_translate((cairo_t *)arg0, arg1, arg2);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1translate_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1user_1to_1device
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1user_1to_1device)
+	(JNIEnv *env, jclass that, jint arg0, jdoubleArray arg1, jdoubleArray arg2)
+{
+	jdouble *lparg1=NULL;
+	jdouble *lparg2=NULL;
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1user_1to_1device_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetDoubleArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	if (arg2) if ((lparg2 = (*env)->GetDoubleArrayElements(env, arg2, NULL)) == NULL) goto fail;
+	cairo_user_to_device((cairo_t *)arg0, lparg1, lparg2);
+fail:
+	if (arg2 && lparg2) (*env)->ReleaseDoubleArrayElements(env, arg2, lparg2, 0);
+	if (arg1 && lparg1) (*env)->ReleaseDoubleArrayElements(env, arg1, lparg1, 0);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1user_1to_1device_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1user_1to_1device_1distance
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1user_1to_1device_1distance)
+	(JNIEnv *env, jclass that, jint arg0, jdoubleArray arg1, jdoubleArray arg2)
+{
+	jdouble *lparg1=NULL;
+	jdouble *lparg2=NULL;
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1user_1to_1device_1distance_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetDoubleArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	if (arg2) if ((lparg2 = (*env)->GetDoubleArrayElements(env, arg2, NULL)) == NULL) goto fail;
+	cairo_user_to_device_distance((cairo_t *)arg0, lparg1, lparg2);
+fail:
+	if (arg2 && lparg2) (*env)->ReleaseDoubleArrayElements(env, arg2, lparg2, 0);
+	if (arg1 && lparg1) (*env)->ReleaseDoubleArrayElements(env, arg1, lparg1, 0);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1user_1to_1device_1distance_FUNC);
+}
+#endif
+
+#ifndef NO__1cairo_1xlib_1surface_1create
+JNIEXPORT jint JNICALL Cairo_NATIVE(_1cairo_1xlib_1surface_1create)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4)
+{
+	jint rc = 0;
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1xlib_1surface_1create_FUNC);
+	rc = (jint)cairo_xlib_surface_create((Display *)arg0, (Drawable)arg1, (Visual *)arg2, arg3, arg4);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1xlib_1surface_1create_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1cairo_1xlib_1surface_1create_1for_1bitmap
+JNIEXPORT jint JNICALL Cairo_NATIVE(_1cairo_1xlib_1surface_1create_1for_1bitmap)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4)
+{
+	jint rc = 0;
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1xlib_1surface_1create_1for_1bitmap_FUNC);
+	rc = (jint)cairo_xlib_surface_create_for_bitmap((Display *)arg0, (Pixmap)arg1, (Screen *)arg2, arg3, arg4);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1xlib_1surface_1create_1for_1bitmap_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1cairo_1xlib_1surface_1set_1size
+JNIEXPORT void JNICALL Cairo_NATIVE(_1cairo_1xlib_1surface_1set_1size)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+	Cairo_NATIVE_ENTER(env, that, _1cairo_1xlib_1surface_1set_1size_FUNC);
+	cairo_xlib_surface_set_size((cairo_surface_t *)arg0, arg1, arg2);
+	Cairo_NATIVE_EXIT(env, that, _1cairo_1xlib_1surface_1set_1size_FUNC);
+}
+#endif
+
+#ifndef NO_cairo_1font_1extents_1t_1sizeof
+JNIEXPORT jint JNICALL Cairo_NATIVE(cairo_1font_1extents_1t_1sizeof)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	Cairo_NATIVE_ENTER(env, that, cairo_1font_1extents_1t_1sizeof_FUNC);
+	rc = (jint)cairo_font_extents_t_sizeof();
+	Cairo_NATIVE_EXIT(env, that, cairo_1font_1extents_1t_1sizeof_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_cairo_1path_1data_1t_1sizeof
+JNIEXPORT jint JNICALL Cairo_NATIVE(cairo_1path_1data_1t_1sizeof)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	Cairo_NATIVE_ENTER(env, that, cairo_1path_1data_1t_1sizeof_FUNC);
+	rc = (jint)cairo_path_data_t_sizeof();
+	Cairo_NATIVE_EXIT(env, that, cairo_1path_1data_1t_1sizeof_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_cairo_1path_1t_1sizeof
+JNIEXPORT jint JNICALL Cairo_NATIVE(cairo_1path_1t_1sizeof)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	Cairo_NATIVE_ENTER(env, that, cairo_1path_1t_1sizeof_FUNC);
+	rc = (jint)cairo_path_t_sizeof();
+	Cairo_NATIVE_EXIT(env, that, cairo_1path_1t_1sizeof_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_cairo_1text_1extents_1t_1sizeof
+JNIEXPORT jint JNICALL Cairo_NATIVE(cairo_1text_1extents_1t_1sizeof)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	Cairo_NATIVE_ENTER(env, that, cairo_1text_1extents_1t_1sizeof_FUNC);
+	rc = (jint)cairo_text_extents_t_sizeof();
+	Cairo_NATIVE_EXIT(env, that, cairo_1text_1extents_1t_1sizeof_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_cairo_1version
+JNIEXPORT jint JNICALL Cairo_NATIVE(cairo_1version)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	Cairo_NATIVE_ENTER(env, that, cairo_1version_FUNC);
+	rc = (jint)cairo_version();
+	Cairo_NATIVE_EXIT(env, that, cairo_1version_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_memmove__Lorg_eclipse_swt_internal_cairo_cairo_1path_1data_1t_2II
+JNIEXPORT void JNICALL Cairo_NATIVE(memmove__Lorg_eclipse_swt_internal_cairo_cairo_1path_1data_1t_2II)
+	(JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2)
+{
+	cairo_path_data_t _arg0, *lparg0=NULL;
+	Cairo_NATIVE_ENTER(env, that, memmove__Lorg_eclipse_swt_internal_cairo_cairo_1path_1data_1t_2II_FUNC);
+	if (arg0) if ((lparg0 = getcairo_path_data_tFields(env, arg0, &_arg0)) == NULL) goto fail;
+	memmove((void *)lparg0, (const void *)arg1, (size_t)arg2);
+fail:
+	if (arg0 && lparg0) setcairo_path_data_tFields(env, arg0, lparg0);
+	Cairo_NATIVE_EXIT(env, that, memmove__Lorg_eclipse_swt_internal_cairo_cairo_1path_1data_1t_2II_FUNC);
+}
+#endif
+
+#ifndef NO_memmove__Lorg_eclipse_swt_internal_cairo_cairo_1path_1t_2II
+JNIEXPORT void JNICALL Cairo_NATIVE(memmove__Lorg_eclipse_swt_internal_cairo_cairo_1path_1t_2II)
+	(JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2)
+{
+	cairo_path_t _arg0, *lparg0=NULL;
+	Cairo_NATIVE_ENTER(env, that, memmove__Lorg_eclipse_swt_internal_cairo_cairo_1path_1t_2II_FUNC);
+	if (arg0) if ((lparg0 = getcairo_path_tFields(env, arg0, &_arg0)) == NULL) goto fail;
+	memmove((void *)lparg0, (const void *)arg1, (size_t)arg2);
+fail:
+	if (arg0 && lparg0) setcairo_path_tFields(env, arg0, lparg0);
+	Cairo_NATIVE_EXIT(env, that, memmove__Lorg_eclipse_swt_internal_cairo_cairo_1path_1t_2II_FUNC);
+}
+#endif
+
+#ifndef NO_memmove___3DII
+JNIEXPORT void JNICALL Cairo_NATIVE(memmove___3DII)
+	(JNIEnv *env, jclass that, jdoubleArray arg0, jint arg1, jint arg2)
+{
+	jdouble *lparg0=NULL;
+	Cairo_NATIVE_ENTER(env, that, memmove___3DII_FUNC);
+	if (arg0) if ((lparg0 = (*env)->GetDoubleArrayElements(env, arg0, NULL)) == NULL) goto fail;
+	memmove((void *)lparg0, (const void *)arg1, (size_t)arg2);
+fail:
+	if (arg0 && lparg0) (*env)->ReleaseDoubleArrayElements(env, arg0, lparg0, 0);
+	Cairo_NATIVE_EXIT(env, that, memmove___3DII_FUNC);
+}
+#endif
+

Added: branches/upstream/swt-gtk/current/cairo.h
===================================================================
--- branches/upstream/swt-gtk/current/cairo.h	                        (rev 0)
+++ branches/upstream/swt-gtk/current/cairo.h	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,32 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * -  Binding to permit interfacing between Cairo and SWT
+ * -  Copyright (C) 2005 IBM Corp.  All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef INC_cairo_H
+#define INC_cairo_H
+
+#include <cairo.h>
+#include <cairo-xlib.h>
+#include <string.h>
+#include <dlfcn.h>
+
+#include "cairo_custom.h"
+
+#endif /* INC_cairo_H */

Added: branches/upstream/swt-gtk/current/cairo_custom.h
===================================================================
--- branches/upstream/swt-gtk/current/cairo_custom.h	                        (rev 0)
+++ branches/upstream/swt-gtk/current/cairo_custom.h	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,26 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * -  Binding to permit interfacing between Cairo and SWT
+ * -  Copyright (C) 2005 IBM Corp.  All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/* Libraries for dynamic loaded functions */
+#define cairo_pdf_surface_set_size_LIB "libcairo.so.2"
+#define cairo_ps_surface_set_size_LIB "libcairo.so.2"
+#define cairo_surface_set_fallback_resolution_LIB "libcairo.so.2"
+#define cairo_surface_get_type_LIB "libcairo.so.2"

Added: branches/upstream/swt-gtk/current/cairo_stats.c
===================================================================
--- branches/upstream/swt-gtk/current/cairo_stats.c	                        (rev 0)
+++ branches/upstream/swt-gtk/current/cairo_stats.c	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,197 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * -  Binding to permit interfacing between Cairo and SWT
+ * -  Copyright (C) 2005, 2007 IBM Corp.  All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#include "swt.h"
+#include "cairo_stats.h"
+
+#ifdef NATIVE_STATS
+
+int Cairo_nativeFunctionCount = 145;
+int Cairo_nativeFunctionCallCount[145];
+char * Cairo_nativeFunctionNames[] = {
+	"CAIRO_1VERSION_1ENCODE",
+	"_1cairo_1append_1path",
+	"_1cairo_1arc",
+	"_1cairo_1arc_1negative",
+	"_1cairo_1clip",
+	"_1cairo_1clip_1preserve",
+	"_1cairo_1close_1path",
+	"_1cairo_1copy_1page",
+	"_1cairo_1copy_1path",
+	"_1cairo_1copy_1path_1flat",
+	"_1cairo_1create",
+	"_1cairo_1curve_1to",
+	"_1cairo_1destroy",
+	"_1cairo_1device_1to_1user",
+	"_1cairo_1device_1to_1user_1distance",
+	"_1cairo_1fill",
+	"_1cairo_1fill_1extents",
+	"_1cairo_1fill_1preserve",
+	"_1cairo_1font_1extents",
+	"_1cairo_1font_1options_1create",
+	"_1cairo_1font_1options_1destroy",
+	"_1cairo_1font_1options_1get_1antialias",
+	"_1cairo_1font_1options_1set_1antialias",
+	"_1cairo_1get_1antialias",
+	"_1cairo_1get_1current_1point",
+	"_1cairo_1get_1fill_1rule",
+	"_1cairo_1get_1font_1face",
+	"_1cairo_1get_1font_1matrix",
+	"_1cairo_1get_1font_1options",
+	"_1cairo_1get_1line_1cap",
+	"_1cairo_1get_1line_1join",
+	"_1cairo_1get_1line_1width",
+	"_1cairo_1get_1matrix",
+	"_1cairo_1get_1miter_1limit",
+	"_1cairo_1get_1operator",
+	"_1cairo_1get_1source",
+	"_1cairo_1get_1target",
+	"_1cairo_1get_1tolerance",
+	"_1cairo_1glyph_1extents",
+	"_1cairo_1glyph_1path",
+	"_1cairo_1identity_1matrix",
+	"_1cairo_1image_1surface_1create",
+	"_1cairo_1image_1surface_1create_1for_1data",
+	"_1cairo_1image_1surface_1get_1height",
+	"_1cairo_1image_1surface_1get_1width",
+	"_1cairo_1in_1fill",
+	"_1cairo_1in_1stroke",
+	"_1cairo_1line_1to",
+	"_1cairo_1mask",
+	"_1cairo_1mask_1surface",
+	"_1cairo_1matrix_1init",
+	"_1cairo_1matrix_1init_1identity",
+	"_1cairo_1matrix_1init_1rotate",
+	"_1cairo_1matrix_1init_1scale",
+	"_1cairo_1matrix_1init_1translate",
+	"_1cairo_1matrix_1invert",
+	"_1cairo_1matrix_1multiply",
+	"_1cairo_1matrix_1rotate",
+	"_1cairo_1matrix_1scale",
+	"_1cairo_1matrix_1transform_1distance",
+	"_1cairo_1matrix_1transform_1point",
+	"_1cairo_1matrix_1translate",
+	"_1cairo_1move_1to",
+	"_1cairo_1new_1path",
+	"_1cairo_1paint",
+	"_1cairo_1paint_1with_1alpha",
+	"_1cairo_1path_1destroy",
+	"_1cairo_1pattern_1add_1color_1stop_1rgb",
+	"_1cairo_1pattern_1add_1color_1stop_1rgba",
+	"_1cairo_1pattern_1create_1for_1surface",
+	"_1cairo_1pattern_1create_1linear",
+	"_1cairo_1pattern_1create_1radial",
+	"_1cairo_1pattern_1destroy",
+	"_1cairo_1pattern_1get_1extend",
+	"_1cairo_1pattern_1get_1filter",
+	"_1cairo_1pattern_1get_1matrix",
+	"_1cairo_1pattern_1reference",
+	"_1cairo_1pattern_1set_1extend",
+	"_1cairo_1pattern_1set_1filter",
+	"_1cairo_1pattern_1set_1matrix",
+	"_1cairo_1pdf_1surface_1set_1size",
+	"_1cairo_1ps_1surface_1set_1size",
+	"_1cairo_1rectangle",
+	"_1cairo_1reference",
+	"_1cairo_1rel_1curve_1to",
+	"_1cairo_1rel_1line_1to",
+	"_1cairo_1rel_1move_1to",
+	"_1cairo_1reset_1clip",
+	"_1cairo_1restore",
+	"_1cairo_1rotate",
+	"_1cairo_1save",
+	"_1cairo_1scale",
+	"_1cairo_1select_1font_1face",
+	"_1cairo_1set_1antialias",
+	"_1cairo_1set_1dash",
+	"_1cairo_1set_1fill_1rule",
+	"_1cairo_1set_1font_1face",
+	"_1cairo_1set_1font_1matrix",
+	"_1cairo_1set_1font_1options",
+	"_1cairo_1set_1font_1size",
+	"_1cairo_1set_1line_1cap",
+	"_1cairo_1set_1line_1join",
+	"_1cairo_1set_1line_1width",
+	"_1cairo_1set_1matrix",
+	"_1cairo_1set_1miter_1limit",
+	"_1cairo_1set_1operator",
+	"_1cairo_1set_1source",
+	"_1cairo_1set_1source_1rgb",
+	"_1cairo_1set_1source_1rgba",
+	"_1cairo_1set_1source_1surface",
+	"_1cairo_1set_1tolerance",
+	"_1cairo_1show_1glyphs",
+	"_1cairo_1show_1page",
+	"_1cairo_1show_1text",
+	"_1cairo_1status",
+	"_1cairo_1status_1to_1string",
+	"_1cairo_1stroke",
+	"_1cairo_1stroke_1extents",
+	"_1cairo_1stroke_1preserve",
+	"_1cairo_1surface_1create_1similar",
+	"_1cairo_1surface_1destroy",
+	"_1cairo_1surface_1finish",
+	"_1cairo_1surface_1get_1type",
+	"_1cairo_1surface_1get_1user_1data",
+	"_1cairo_1surface_1reference",
+	"_1cairo_1surface_1set_1device_1offset",
+	"_1cairo_1surface_1set_1fallback_1resolution",
+	"_1cairo_1surface_1set_1user_1data",
+	"_1cairo_1text_1extents",
+	"_1cairo_1text_1path",
+	"_1cairo_1transform",
+	"_1cairo_1translate",
+	"_1cairo_1user_1to_1device",
+	"_1cairo_1user_1to_1device_1distance",
+	"_1cairo_1xlib_1surface_1create",
+	"_1cairo_1xlib_1surface_1create_1for_1bitmap",
+	"_1cairo_1xlib_1surface_1set_1size",
+	"cairo_1font_1extents_1t_1sizeof",
+	"cairo_1path_1data_1t_1sizeof",
+	"cairo_1path_1t_1sizeof",
+	"cairo_1text_1extents_1t_1sizeof",
+	"cairo_1version",
+	"memmove__Lorg_eclipse_swt_internal_cairo_cairo_1path_1data_1t_2II",
+	"memmove__Lorg_eclipse_swt_internal_cairo_cairo_1path_1t_2II",
+	"memmove___3DII",
+};
+
+#define STATS_NATIVE(func) Java_org_eclipse_swt_tools_internal_NativeStats_##func
+
+JNIEXPORT jint JNICALL STATS_NATIVE(Cairo_1GetFunctionCount)
+	(JNIEnv *env, jclass that)
+{
+	return Cairo_nativeFunctionCount;
+}
+
+JNIEXPORT jstring JNICALL STATS_NATIVE(Cairo_1GetFunctionName)
+	(JNIEnv *env, jclass that, jint index)
+{
+	return (*env)->NewStringUTF(env, Cairo_nativeFunctionNames[index]);
+}
+
+JNIEXPORT jint JNICALL STATS_NATIVE(Cairo_1GetFunctionCallCount)
+	(JNIEnv *env, jclass that, jint index)
+{
+	return Cairo_nativeFunctionCallCount[index];
+}
+
+#endif

Added: branches/upstream/swt-gtk/current/cairo_stats.h
===================================================================
--- branches/upstream/swt-gtk/current/cairo_stats.h	                        (rev 0)
+++ branches/upstream/swt-gtk/current/cairo_stats.h	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,183 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * -  Binding to permit interfacing between Cairo and SWT
+ * -  Copyright (C) 2005, 2007 IBM Corp.  All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifdef NATIVE_STATS
+extern int Cairo_nativeFunctionCount;
+extern int Cairo_nativeFunctionCallCount[];
+extern char* Cairo_nativeFunctionNames[];
+#define Cairo_NATIVE_ENTER(env, that, func) Cairo_nativeFunctionCallCount[func]++;
+#define Cairo_NATIVE_EXIT(env, that, func) 
+#else
+#ifndef Cairo_NATIVE_ENTER
+#define Cairo_NATIVE_ENTER(env, that, func) 
+#endif
+#ifndef Cairo_NATIVE_EXIT
+#define Cairo_NATIVE_EXIT(env, that, func) 
+#endif
+#endif
+
+typedef enum {
+	CAIRO_1VERSION_1ENCODE_FUNC,
+	_1cairo_1append_1path_FUNC,
+	_1cairo_1arc_FUNC,
+	_1cairo_1arc_1negative_FUNC,
+	_1cairo_1clip_FUNC,
+	_1cairo_1clip_1preserve_FUNC,
+	_1cairo_1close_1path_FUNC,
+	_1cairo_1copy_1page_FUNC,
+	_1cairo_1copy_1path_FUNC,
+	_1cairo_1copy_1path_1flat_FUNC,
+	_1cairo_1create_FUNC,
+	_1cairo_1curve_1to_FUNC,
+	_1cairo_1destroy_FUNC,
+	_1cairo_1device_1to_1user_FUNC,
+	_1cairo_1device_1to_1user_1distance_FUNC,
+	_1cairo_1fill_FUNC,
+	_1cairo_1fill_1extents_FUNC,
+	_1cairo_1fill_1preserve_FUNC,
+	_1cairo_1font_1extents_FUNC,
+	_1cairo_1font_1options_1create_FUNC,
+	_1cairo_1font_1options_1destroy_FUNC,
+	_1cairo_1font_1options_1get_1antialias_FUNC,
+	_1cairo_1font_1options_1set_1antialias_FUNC,
+	_1cairo_1get_1antialias_FUNC,
+	_1cairo_1get_1current_1point_FUNC,
+	_1cairo_1get_1fill_1rule_FUNC,
+	_1cairo_1get_1font_1face_FUNC,
+	_1cairo_1get_1font_1matrix_FUNC,
+	_1cairo_1get_1font_1options_FUNC,
+	_1cairo_1get_1line_1cap_FUNC,
+	_1cairo_1get_1line_1join_FUNC,
+	_1cairo_1get_1line_1width_FUNC,
+	_1cairo_1get_1matrix_FUNC,
+	_1cairo_1get_1miter_1limit_FUNC,
+	_1cairo_1get_1operator_FUNC,
+	_1cairo_1get_1source_FUNC,
+	_1cairo_1get_1target_FUNC,
+	_1cairo_1get_1tolerance_FUNC,
+	_1cairo_1glyph_1extents_FUNC,
+	_1cairo_1glyph_1path_FUNC,
+	_1cairo_1identity_1matrix_FUNC,
+	_1cairo_1image_1surface_1create_FUNC,
+	_1cairo_1image_1surface_1create_1for_1data_FUNC,
+	_1cairo_1image_1surface_1get_1height_FUNC,
+	_1cairo_1image_1surface_1get_1width_FUNC,
+	_1cairo_1in_1fill_FUNC,
+	_1cairo_1in_1stroke_FUNC,
+	_1cairo_1line_1to_FUNC,
+	_1cairo_1mask_FUNC,
+	_1cairo_1mask_1surface_FUNC,
+	_1cairo_1matrix_1init_FUNC,
+	_1cairo_1matrix_1init_1identity_FUNC,
+	_1cairo_1matrix_1init_1rotate_FUNC,
+	_1cairo_1matrix_1init_1scale_FUNC,
+	_1cairo_1matrix_1init_1translate_FUNC,
+	_1cairo_1matrix_1invert_FUNC,
+	_1cairo_1matrix_1multiply_FUNC,
+	_1cairo_1matrix_1rotate_FUNC,
+	_1cairo_1matrix_1scale_FUNC,
+	_1cairo_1matrix_1transform_1distance_FUNC,
+	_1cairo_1matrix_1transform_1point_FUNC,
+	_1cairo_1matrix_1translate_FUNC,
+	_1cairo_1move_1to_FUNC,
+	_1cairo_1new_1path_FUNC,
+	_1cairo_1paint_FUNC,
+	_1cairo_1paint_1with_1alpha_FUNC,
+	_1cairo_1path_1destroy_FUNC,
+	_1cairo_1pattern_1add_1color_1stop_1rgb_FUNC,
+	_1cairo_1pattern_1add_1color_1stop_1rgba_FUNC,
+	_1cairo_1pattern_1create_1for_1surface_FUNC,
+	_1cairo_1pattern_1create_1linear_FUNC,
+	_1cairo_1pattern_1create_1radial_FUNC,
+	_1cairo_1pattern_1destroy_FUNC,
+	_1cairo_1pattern_1get_1extend_FUNC,
+	_1cairo_1pattern_1get_1filter_FUNC,
+	_1cairo_1pattern_1get_1matrix_FUNC,
+	_1cairo_1pattern_1reference_FUNC,
+	_1cairo_1pattern_1set_1extend_FUNC,
+	_1cairo_1pattern_1set_1filter_FUNC,
+	_1cairo_1pattern_1set_1matrix_FUNC,
+	_1cairo_1pdf_1surface_1set_1size_FUNC,
+	_1cairo_1ps_1surface_1set_1size_FUNC,
+	_1cairo_1rectangle_FUNC,
+	_1cairo_1reference_FUNC,
+	_1cairo_1rel_1curve_1to_FUNC,
+	_1cairo_1rel_1line_1to_FUNC,
+	_1cairo_1rel_1move_1to_FUNC,
+	_1cairo_1reset_1clip_FUNC,
+	_1cairo_1restore_FUNC,
+	_1cairo_1rotate_FUNC,
+	_1cairo_1save_FUNC,
+	_1cairo_1scale_FUNC,
+	_1cairo_1select_1font_1face_FUNC,
+	_1cairo_1set_1antialias_FUNC,
+	_1cairo_1set_1dash_FUNC,
+	_1cairo_1set_1fill_1rule_FUNC,
+	_1cairo_1set_1font_1face_FUNC,
+	_1cairo_1set_1font_1matrix_FUNC,
+	_1cairo_1set_1font_1options_FUNC,
+	_1cairo_1set_1font_1size_FUNC,
+	_1cairo_1set_1line_1cap_FUNC,
+	_1cairo_1set_1line_1join_FUNC,
+	_1cairo_1set_1line_1width_FUNC,
+	_1cairo_1set_1matrix_FUNC,
+	_1cairo_1set_1miter_1limit_FUNC,
+	_1cairo_1set_1operator_FUNC,
+	_1cairo_1set_1source_FUNC,
+	_1cairo_1set_1source_1rgb_FUNC,
+	_1cairo_1set_1source_1rgba_FUNC,
+	_1cairo_1set_1source_1surface_FUNC,
+	_1cairo_1set_1tolerance_FUNC,
+	_1cairo_1show_1glyphs_FUNC,
+	_1cairo_1show_1page_FUNC,
+	_1cairo_1show_1text_FUNC,
+	_1cairo_1status_FUNC,
+	_1cairo_1status_1to_1string_FUNC,
+	_1cairo_1stroke_FUNC,
+	_1cairo_1stroke_1extents_FUNC,
+	_1cairo_1stroke_1preserve_FUNC,
+	_1cairo_1surface_1create_1similar_FUNC,
+	_1cairo_1surface_1destroy_FUNC,
+	_1cairo_1surface_1finish_FUNC,
+	_1cairo_1surface_1get_1type_FUNC,
+	_1cairo_1surface_1get_1user_1data_FUNC,
+	_1cairo_1surface_1reference_FUNC,
+	_1cairo_1surface_1set_1device_1offset_FUNC,
+	_1cairo_1surface_1set_1fallback_1resolution_FUNC,
+	_1cairo_1surface_1set_1user_1data_FUNC,
+	_1cairo_1text_1extents_FUNC,
+	_1cairo_1text_1path_FUNC,
+	_1cairo_1transform_FUNC,
+	_1cairo_1translate_FUNC,
+	_1cairo_1user_1to_1device_FUNC,
+	_1cairo_1user_1to_1device_1distance_FUNC,
+	_1cairo_1xlib_1surface_1create_FUNC,
+	_1cairo_1xlib_1surface_1create_1for_1bitmap_FUNC,
+	_1cairo_1xlib_1surface_1set_1size_FUNC,
+	cairo_1font_1extents_1t_1sizeof_FUNC,
+	cairo_1path_1data_1t_1sizeof_FUNC,
+	cairo_1path_1t_1sizeof_FUNC,
+	cairo_1text_1extents_1t_1sizeof_FUNC,
+	cairo_1version_FUNC,
+	memmove__Lorg_eclipse_swt_internal_cairo_cairo_1path_1data_1t_2II_FUNC,
+	memmove__Lorg_eclipse_swt_internal_cairo_cairo_1path_1t_2II_FUNC,
+	memmove___3DII_FUNC,
+} Cairo_FUNCS;

Added: branches/upstream/swt-gtk/current/cairo_structs.c
===================================================================
--- branches/upstream/swt-gtk/current/cairo_structs.c	                        (rev 0)
+++ branches/upstream/swt-gtk/current/cairo_structs.c	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,184 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * -  Binding to permit interfacing between Cairo and SWT
+ * -  Copyright (C) 2005, 2007 IBM Corp.  All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#include "swt.h"
+#include "cairo_structs.h"
+
+#ifndef NO_cairo_font_extents_t
+typedef struct cairo_font_extents_t_FID_CACHE {
+	int cached;
+	jclass clazz;
+	jfieldID ascent, descent, height, max_x_advance, max_y_advance;
+} cairo_font_extents_t_FID_CACHE;
+
+cairo_font_extents_t_FID_CACHE cairo_font_extents_tFc;
+
+void cachecairo_font_extents_tFields(JNIEnv *env, jobject lpObject)
+{
+	if (cairo_font_extents_tFc.cached) return;
+	cairo_font_extents_tFc.clazz = (*env)->GetObjectClass(env, lpObject);
+	cairo_font_extents_tFc.ascent = (*env)->GetFieldID(env, cairo_font_extents_tFc.clazz, "ascent", "D");
+	cairo_font_extents_tFc.descent = (*env)->GetFieldID(env, cairo_font_extents_tFc.clazz, "descent", "D");
+	cairo_font_extents_tFc.height = (*env)->GetFieldID(env, cairo_font_extents_tFc.clazz, "height", "D");
+	cairo_font_extents_tFc.max_x_advance = (*env)->GetFieldID(env, cairo_font_extents_tFc.clazz, "max_x_advance", "D");
+	cairo_font_extents_tFc.max_y_advance = (*env)->GetFieldID(env, cairo_font_extents_tFc.clazz, "max_y_advance", "D");
+	cairo_font_extents_tFc.cached = 1;
+}
+
+cairo_font_extents_t *getcairo_font_extents_tFields(JNIEnv *env, jobject lpObject, cairo_font_extents_t *lpStruct)
+{
+	if (!cairo_font_extents_tFc.cached) cachecairo_font_extents_tFields(env, lpObject);
+	lpStruct->ascent = (*env)->GetDoubleField(env, lpObject, cairo_font_extents_tFc.ascent);
+	lpStruct->descent = (*env)->GetDoubleField(env, lpObject, cairo_font_extents_tFc.descent);
+	lpStruct->height = (*env)->GetDoubleField(env, lpObject, cairo_font_extents_tFc.height);
+	lpStruct->max_x_advance = (*env)->GetDoubleField(env, lpObject, cairo_font_extents_tFc.max_x_advance);
+	lpStruct->max_y_advance = (*env)->GetDoubleField(env, lpObject, cairo_font_extents_tFc.max_y_advance);
+	return lpStruct;
+}
+
+void setcairo_font_extents_tFields(JNIEnv *env, jobject lpObject, cairo_font_extents_t *lpStruct)
+{
+	if (!cairo_font_extents_tFc.cached) cachecairo_font_extents_tFields(env, lpObject);
+	(*env)->SetDoubleField(env, lpObject, cairo_font_extents_tFc.ascent, (jdouble)lpStruct->ascent);
+	(*env)->SetDoubleField(env, lpObject, cairo_font_extents_tFc.descent, (jdouble)lpStruct->descent);
+	(*env)->SetDoubleField(env, lpObject, cairo_font_extents_tFc.height, (jdouble)lpStruct->height);
+	(*env)->SetDoubleField(env, lpObject, cairo_font_extents_tFc.max_x_advance, (jdouble)lpStruct->max_x_advance);
+	(*env)->SetDoubleField(env, lpObject, cairo_font_extents_tFc.max_y_advance, (jdouble)lpStruct->max_y_advance);
+}
+#endif
+
+#ifndef NO_cairo_path_data_t
+typedef struct cairo_path_data_t_FID_CACHE {
+	int cached;
+	jclass clazz;
+	jfieldID type, length;
+} cairo_path_data_t_FID_CACHE;
+
+cairo_path_data_t_FID_CACHE cairo_path_data_tFc;
+
+void cachecairo_path_data_tFields(JNIEnv *env, jobject lpObject)
+{
+	if (cairo_path_data_tFc.cached) return;
+	cairo_path_data_tFc.clazz = (*env)->GetObjectClass(env, lpObject);
+	cairo_path_data_tFc.type = (*env)->GetFieldID(env, cairo_path_data_tFc.clazz, "type", "I");
+	cairo_path_data_tFc.length = (*env)->GetFieldID(env, cairo_path_data_tFc.clazz, "length", "I");
+	cairo_path_data_tFc.cached = 1;
+}
+
+cairo_path_data_t *getcairo_path_data_tFields(JNIEnv *env, jobject lpObject, cairo_path_data_t *lpStruct)
+{
+	if (!cairo_path_data_tFc.cached) cachecairo_path_data_tFields(env, lpObject);
+	lpStruct->header.type = (*env)->GetIntField(env, lpObject, cairo_path_data_tFc.type);
+	lpStruct->header.length = (*env)->GetIntField(env, lpObject, cairo_path_data_tFc.length);
+	return lpStruct;
+}
+
+void setcairo_path_data_tFields(JNIEnv *env, jobject lpObject, cairo_path_data_t *lpStruct)
+{
+	if (!cairo_path_data_tFc.cached) cachecairo_path_data_tFields(env, lpObject);
+	(*env)->SetIntField(env, lpObject, cairo_path_data_tFc.type, (jint)lpStruct->header.type);
+	(*env)->SetIntField(env, lpObject, cairo_path_data_tFc.length, (jint)lpStruct->header.length);
+}
+#endif
+
+#ifndef NO_cairo_path_t
+typedef struct cairo_path_t_FID_CACHE {
+	int cached;
+	jclass clazz;
+	jfieldID status, data, num_data;
+} cairo_path_t_FID_CACHE;
+
+cairo_path_t_FID_CACHE cairo_path_tFc;
+
+void cachecairo_path_tFields(JNIEnv *env, jobject lpObject)
+{
+	if (cairo_path_tFc.cached) return;
+	cairo_path_tFc.clazz = (*env)->GetObjectClass(env, lpObject);
+	cairo_path_tFc.status = (*env)->GetFieldID(env, cairo_path_tFc.clazz, "status", "I");
+	cairo_path_tFc.data = (*env)->GetFieldID(env, cairo_path_tFc.clazz, "data", "I");
+	cairo_path_tFc.num_data = (*env)->GetFieldID(env, cairo_path_tFc.clazz, "num_data", "I");
+	cairo_path_tFc.cached = 1;
+}
+
+cairo_path_t *getcairo_path_tFields(JNIEnv *env, jobject lpObject, cairo_path_t *lpStruct)
+{
+	if (!cairo_path_tFc.cached) cachecairo_path_tFields(env, lpObject);
+	lpStruct->status = (*env)->GetIntField(env, lpObject, cairo_path_tFc.status);
+	lpStruct->data = (cairo_path_data_t *)(*env)->GetIntField(env, lpObject, cairo_path_tFc.data);
+	lpStruct->num_data = (*env)->GetIntField(env, lpObject, cairo_path_tFc.num_data);
+	return lpStruct;
+}
+
+void setcairo_path_tFields(JNIEnv *env, jobject lpObject, cairo_path_t *lpStruct)
+{
+	if (!cairo_path_tFc.cached) cachecairo_path_tFields(env, lpObject);
+	(*env)->SetIntField(env, lpObject, cairo_path_tFc.status, (jint)lpStruct->status);
+	(*env)->SetIntField(env, lpObject, cairo_path_tFc.data, (jint)lpStruct->data);
+	(*env)->SetIntField(env, lpObject, cairo_path_tFc.num_data, (jint)lpStruct->num_data);
+}
+#endif
+
+#ifndef NO_cairo_text_extents_t
+typedef struct cairo_text_extents_t_FID_CACHE {
+	int cached;
+	jclass clazz;
+	jfieldID x_bearing, y_bearing, width, height, x_advance, y_advance;
+} cairo_text_extents_t_FID_CACHE;
+
+cairo_text_extents_t_FID_CACHE cairo_text_extents_tFc;
+
+void cachecairo_text_extents_tFields(JNIEnv *env, jobject lpObject)
+{
+	if (cairo_text_extents_tFc.cached) return;
+	cairo_text_extents_tFc.clazz = (*env)->GetObjectClass(env, lpObject);
+	cairo_text_extents_tFc.x_bearing = (*env)->GetFieldID(env, cairo_text_extents_tFc.clazz, "x_bearing", "D");
+	cairo_text_extents_tFc.y_bearing = (*env)->GetFieldID(env, cairo_text_extents_tFc.clazz, "y_bearing", "D");
+	cairo_text_extents_tFc.width = (*env)->GetFieldID(env, cairo_text_extents_tFc.clazz, "width", "D");
+	cairo_text_extents_tFc.height = (*env)->GetFieldID(env, cairo_text_extents_tFc.clazz, "height", "D");
+	cairo_text_extents_tFc.x_advance = (*env)->GetFieldID(env, cairo_text_extents_tFc.clazz, "x_advance", "D");
+	cairo_text_extents_tFc.y_advance = (*env)->GetFieldID(env, cairo_text_extents_tFc.clazz, "y_advance", "D");
+	cairo_text_extents_tFc.cached = 1;
+}
+
+cairo_text_extents_t *getcairo_text_extents_tFields(JNIEnv *env, jobject lpObject, cairo_text_extents_t *lpStruct)
+{
+	if (!cairo_text_extents_tFc.cached) cachecairo_text_extents_tFields(env, lpObject);
+	lpStruct->x_bearing = (*env)->GetDoubleField(env, lpObject, cairo_text_extents_tFc.x_bearing);
+	lpStruct->y_bearing = (*env)->GetDoubleField(env, lpObject, cairo_text_extents_tFc.y_bearing);
+	lpStruct->width = (*env)->GetDoubleField(env, lpObject, cairo_text_extents_tFc.width);
+	lpStruct->height = (*env)->GetDoubleField(env, lpObject, cairo_text_extents_tFc.height);
+	lpStruct->x_advance = (*env)->GetDoubleField(env, lpObject, cairo_text_extents_tFc.x_advance);
+	lpStruct->y_advance = (*env)->GetDoubleField(env, lpObject, cairo_text_extents_tFc.y_advance);
+	return lpStruct;
+}
+
+void setcairo_text_extents_tFields(JNIEnv *env, jobject lpObject, cairo_text_extents_t *lpStruct)
+{
+	if (!cairo_text_extents_tFc.cached) cachecairo_text_extents_tFields(env, lpObject);
+	(*env)->SetDoubleField(env, lpObject, cairo_text_extents_tFc.x_bearing, (jdouble)lpStruct->x_bearing);
+	(*env)->SetDoubleField(env, lpObject, cairo_text_extents_tFc.y_bearing, (jdouble)lpStruct->y_bearing);
+	(*env)->SetDoubleField(env, lpObject, cairo_text_extents_tFc.width, (jdouble)lpStruct->width);
+	(*env)->SetDoubleField(env, lpObject, cairo_text_extents_tFc.height, (jdouble)lpStruct->height);
+	(*env)->SetDoubleField(env, lpObject, cairo_text_extents_tFc.x_advance, (jdouble)lpStruct->x_advance);
+	(*env)->SetDoubleField(env, lpObject, cairo_text_extents_tFc.y_advance, (jdouble)lpStruct->y_advance);
+}
+#endif
+

Added: branches/upstream/swt-gtk/current/cairo_structs.h
===================================================================
--- branches/upstream/swt-gtk/current/cairo_structs.h	                        (rev 0)
+++ branches/upstream/swt-gtk/current/cairo_structs.h	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,71 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * -  Binding to permit interfacing between Cairo and SWT
+ * -  Copyright (C) 2005, 2007 IBM Corp.  All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#include "cairo.h"
+
+#ifndef NO_cairo_font_extents_t
+void cachecairo_font_extents_tFields(JNIEnv *env, jobject lpObject);
+cairo_font_extents_t *getcairo_font_extents_tFields(JNIEnv *env, jobject lpObject, cairo_font_extents_t *lpStruct);
+void setcairo_font_extents_tFields(JNIEnv *env, jobject lpObject, cairo_font_extents_t *lpStruct);
+#define cairo_font_extents_t_sizeof() sizeof(cairo_font_extents_t)
+#else
+#define cachecairo_font_extents_tFields(a,b)
+#define getcairo_font_extents_tFields(a,b,c) NULL
+#define setcairo_font_extents_tFields(a,b,c)
+#define cairo_font_extents_t_sizeof() 0
+#endif
+
+#ifndef NO_cairo_path_data_t
+void cachecairo_path_data_tFields(JNIEnv *env, jobject lpObject);
+cairo_path_data_t *getcairo_path_data_tFields(JNIEnv *env, jobject lpObject, cairo_path_data_t *lpStruct);
+void setcairo_path_data_tFields(JNIEnv *env, jobject lpObject, cairo_path_data_t *lpStruct);
+#define cairo_path_data_t_sizeof() sizeof(cairo_path_data_t)
+#else
+#define cachecairo_path_data_tFields(a,b)
+#define getcairo_path_data_tFields(a,b,c) NULL
+#define setcairo_path_data_tFields(a,b,c)
+#define cairo_path_data_t_sizeof() 0
+#endif
+
+#ifndef NO_cairo_path_t
+void cachecairo_path_tFields(JNIEnv *env, jobject lpObject);
+cairo_path_t *getcairo_path_tFields(JNIEnv *env, jobject lpObject, cairo_path_t *lpStruct);
+void setcairo_path_tFields(JNIEnv *env, jobject lpObject, cairo_path_t *lpStruct);
+#define cairo_path_t_sizeof() sizeof(cairo_path_t)
+#else
+#define cachecairo_path_tFields(a,b)
+#define getcairo_path_tFields(a,b,c) NULL
+#define setcairo_path_tFields(a,b,c)
+#define cairo_path_t_sizeof() 0
+#endif
+
+#ifndef NO_cairo_text_extents_t
+void cachecairo_text_extents_tFields(JNIEnv *env, jobject lpObject);
+cairo_text_extents_t *getcairo_text_extents_tFields(JNIEnv *env, jobject lpObject, cairo_text_extents_t *lpStruct);
+void setcairo_text_extents_tFields(JNIEnv *env, jobject lpObject, cairo_text_extents_t *lpStruct);
+#define cairo_text_extents_t_sizeof() sizeof(cairo_text_extents_t)
+#else
+#define cachecairo_text_extents_tFields(a,b)
+#define getcairo_text_extents_tFields(a,b,c) NULL
+#define setcairo_text_extents_tFields(a,b,c)
+#define cairo_text_extents_t_sizeof() 0
+#endif
+

Added: branches/upstream/swt-gtk/current/callback.c
===================================================================
--- branches/upstream/swt-gtk/current/callback.c	                        (rev 0)
+++ branches/upstream/swt-gtk/current/callback.c	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,731 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+ 
+/**
+ * Callback implementation.
+ */
+#include "callback.h"
+#include <string.h>
+
+/* define this to print out debug statements */
+/* #define DEBUG_CALL_PRINTS */
+
+/* --------------- callback globals ----------------- */
+
+static JavaVM *jvm = NULL;
+static CALLBACK_DATA callbackData[MAX_CALLBACKS];
+static int callbackEnabled = 1;
+static int callbackEntryCount = 0;
+static int initialized = 0;
+
+#ifdef DEBUG_CALL_PRINTS
+static int counter = 0;
+#endif
+
+SWT_PTR callback(int index, ...);
+
+#ifdef USE_ASSEMBLER
+
+#if !(defined (_WIN32) || defined (_WIN32_WCE))
+#include <sys/mman.h>
+#endif
+
+static unsigned char *callbackCode = NULL;
+#define CALLBACK_THUNK_SIZE 64
+
+#else
+
+/* --------------- callback functions --------------- */
+
+
+/* Function name from index and number of arguments */
+#define FN(index, args) fn##index##_##args
+
+/**
+ * Functions templates
+ *
+ * NOTE: If the maximum number of arguments changes (MAX_ARGS), the number
+ *       of function templates has to change accordingly.
+ */
+
+/* Function template with no arguments */
+#define FN_0(index) RETURN_TYPE FN(index, 0)() { return RETURN_CAST callback(index); }
+
+/* Function template with 1 argument */
+#define FN_1(index) RETURN_TYPE FN(index, 1)(SWT_PTR p1) { return RETURN_CAST callback(index, p1); }
+
+/* Function template with 2 arguments */
+#define FN_2(index) RETURN_TYPE FN(index, 2)(SWT_PTR p1, SWT_PTR p2) { return RETURN_CAST callback(index, p1, p2); }
+
+/* Function template with 3 arguments */
+#define FN_3(index) RETURN_TYPE FN(index, 3)(SWT_PTR p1, SWT_PTR p2, SWT_PTR p3) { return RETURN_CAST callback(index, p1, p2, p3); }
+
+/* Function template with 4 arguments */
+#define FN_4(index) RETURN_TYPE FN(index, 4)(SWT_PTR p1, SWT_PTR p2, SWT_PTR p3, SWT_PTR p4) { return RETURN_CAST callback(index, p1, p2, p3, p4); }
+
+/* Function template with 5 arguments */
+#define FN_5(index) RETURN_TYPE FN(index, 5)(SWT_PTR p1, SWT_PTR p2, SWT_PTR p3, SWT_PTR p4, SWT_PTR p5) { return RETURN_CAST callback(index, p1, p2, p3, p4, p5); }
+
+/* Function template with 6 arguments */
+#define FN_6(index) RETURN_TYPE FN(index, 6)(SWT_PTR p1, SWT_PTR p2, SWT_PTR p3, SWT_PTR p4, SWT_PTR p5, SWT_PTR p6) { return RETURN_CAST callback(index, p1, p2, p3, p4, p5, p6); }
+
+/* Function template with 7 arguments */
+#define FN_7(index) RETURN_TYPE FN(index, 7)(SWT_PTR p1, SWT_PTR p2, SWT_PTR p3, SWT_PTR p4, SWT_PTR p5, SWT_PTR p6, SWT_PTR p7) { return RETURN_CAST callback(index, p1, p2, p3, p4, p5, p6, p7); }
+
+/* Function template with 8 arguments */
+#define FN_8(index) RETURN_TYPE FN(index, 8)(SWT_PTR p1, SWT_PTR p2, SWT_PTR p3, SWT_PTR p4, SWT_PTR p5, SWT_PTR p6, SWT_PTR p7, SWT_PTR p8) { return RETURN_CAST callback(index, p1, p2, p3, p4, p5, p6, p7, p8); }
+
+/* Function template with 9 arguments */
+#define FN_9(index) RETURN_TYPE FN(index, 9)(SWT_PTR p1, SWT_PTR p2, SWT_PTR p3, SWT_PTR p4, SWT_PTR p5, SWT_PTR p6, SWT_PTR p7, SWT_PTR p8, SWT_PTR p9) { return RETURN_CAST callback(index, p1, p2, p3, p4, p5, p6, p7, p8, p9); }
+
+/* Function template with 10 arguments */
+#define FN_10(index) RETURN_TYPE FN(index, 10) (SWT_PTR p1, SWT_PTR p2, SWT_PTR p3, SWT_PTR p4, SWT_PTR p5, SWT_PTR p6, SWT_PTR p7, SWT_PTR p8, SWT_PTR p9, SWT_PTR p10) { return RETURN_CAST callback(index, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10); }
+
+/* Function template with 11 arguments */
+#define FN_11(index) RETURN_TYPE FN(index, 11) (SWT_PTR p1, SWT_PTR p2, SWT_PTR p3, SWT_PTR p4, SWT_PTR p5, SWT_PTR p6, SWT_PTR p7, SWT_PTR p8, SWT_PTR p9, SWT_PTR p10, SWT_PTR p11) { return RETURN_CAST callback(index, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11); }
+
+/* Function template with 12 arguments */
+#define FN_12(index) RETURN_TYPE FN(index, 12) (SWT_PTR p1, SWT_PTR p2, SWT_PTR p3, SWT_PTR p4, SWT_PTR p5, SWT_PTR p6, SWT_PTR p7, SWT_PTR p8, SWT_PTR p9, SWT_PTR p10, SWT_PTR p11, SWT_PTR p12) { return RETURN_CAST callback(index, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12); }
+
+/**
+ * Define all functions with the specified number of arguments.
+ *
+ * NOTE: If the maximum number of callbacks changes (MAX_CALLBACKS),
+ *       this macro has to be updated. 
+ */
+#if MAX_CALLBACKS == 16
+#define FN_BLOCK(args) \
+	FN_##args(0) \
+	FN_##args(1) \
+	FN_##args(2) \
+	FN_##args(3) \
+	FN_##args(4) \
+	FN_##args(5) \
+	FN_##args(6) \
+	FN_##args(7) \
+	FN_##args(8) \
+	FN_##args(9) \
+	FN_##args(10) \
+	FN_##args(11) \
+	FN_##args(12) \
+	FN_##args(13) \
+	FN_##args(14) \
+	FN_##args(15)
+#elif MAX_CALLBACKS == 128
+#define FN_BLOCK(args) \
+	FN_##args(0) \
+	FN_##args(1) \
+	FN_##args(2) \
+	FN_##args(3) \
+	FN_##args(4) \
+	FN_##args(5) \
+	FN_##args(6) \
+	FN_##args(7) \
+	FN_##args(8) \
+	FN_##args(9) \
+	FN_##args(10) \
+	FN_##args(11) \
+	FN_##args(12) \
+	FN_##args(13) \
+	FN_##args(14) \
+	FN_##args(15) \
+	FN_##args(16) \
+	FN_##args(17) \
+	FN_##args(18) \
+	FN_##args(19) \
+	FN_##args(20) \
+	FN_##args(21) \
+	FN_##args(22) \
+	FN_##args(23) \
+	FN_##args(24) \
+	FN_##args(25) \
+	FN_##args(26) \
+	FN_##args(27) \
+	FN_##args(28) \
+	FN_##args(29) \
+	FN_##args(30) \
+	FN_##args(31) \
+	FN_##args(32) \
+	FN_##args(33) \
+	FN_##args(34) \
+	FN_##args(35) \
+	FN_##args(36) \
+	FN_##args(37) \
+	FN_##args(38) \
+	FN_##args(39) \
+	FN_##args(40) \
+	FN_##args(41) \
+	FN_##args(42) \
+	FN_##args(43) \
+	FN_##args(44) \
+	FN_##args(45) \
+	FN_##args(46) \
+	FN_##args(47) \
+	FN_##args(48) \
+	FN_##args(49) \
+	FN_##args(50) \
+	FN_##args(51) \
+	FN_##args(52) \
+	FN_##args(53) \
+	FN_##args(54) \
+	FN_##args(55) \
+	FN_##args(56) \
+	FN_##args(57) \
+	FN_##args(58) \
+	FN_##args(59) \
+	FN_##args(60) \
+	FN_##args(61) \
+	FN_##args(62) \
+	FN_##args(63) \
+	FN_##args(64) \
+	FN_##args(65) \
+	FN_##args(66) \
+	FN_##args(67) \
+	FN_##args(68) \
+	FN_##args(69) \
+	FN_##args(70) \
+	FN_##args(71) \
+	FN_##args(72) \
+	FN_##args(73) \
+	FN_##args(74) \
+	FN_##args(75) \
+	FN_##args(76) \
+	FN_##args(77) \
+	FN_##args(78) \
+	FN_##args(79) \
+	FN_##args(80) \
+	FN_##args(81) \
+	FN_##args(82) \
+	FN_##args(83) \
+	FN_##args(84) \
+	FN_##args(85) \
+	FN_##args(86) \
+	FN_##args(87) \
+	FN_##args(88) \
+	FN_##args(89) \
+	FN_##args(90) \
+	FN_##args(91) \
+	FN_##args(92) \
+	FN_##args(93) \
+	FN_##args(94) \
+	FN_##args(95) \
+	FN_##args(96) \
+	FN_##args(97) \
+	FN_##args(98) \
+	FN_##args(99) \
+	FN_##args(100) \
+	FN_##args(101) \
+	FN_##args(102) \
+	FN_##args(103) \
+	FN_##args(104) \
+	FN_##args(105) \
+	FN_##args(106) \
+	FN_##args(107) \
+	FN_##args(108) \
+	FN_##args(109) \
+	FN_##args(110) \
+	FN_##args(111) \
+	FN_##args(112) \
+	FN_##args(113) \
+	FN_##args(114) \
+	FN_##args(115) \
+	FN_##args(116) \
+	FN_##args(117) \
+	FN_##args(118) \
+	FN_##args(119) \
+	FN_##args(120) \
+	FN_##args(121) \
+	FN_##args(122) \
+	FN_##args(123) \
+	FN_##args(124) \
+	FN_##args(125) \
+	FN_##args(126) \
+	FN_##args(127)
+#else
+#error Invalid MAX_CALLBACKS
+#endif /* MAX_CALLBACKS == 16 */
+
+/**
+ * Define all callback functions.
+ *
+ * NOTE: If the maximum number of arguments changes (MAX_ARGS), the following
+ *       has to change accordinglly.
+ */
+FN_BLOCK(0)
+FN_BLOCK(1)
+FN_BLOCK(2)
+FN_BLOCK(3)
+FN_BLOCK(4)
+FN_BLOCK(5)
+FN_BLOCK(6)
+FN_BLOCK(7)
+FN_BLOCK(8)
+FN_BLOCK(9)
+FN_BLOCK(10)
+FN_BLOCK(11)
+FN_BLOCK(12)
+
+/**
+ * Initialize the function pointers for the callback routines.
+ *
+ * NOTE: If MAX_ARGS or MAX_CALLBACKS changes, the following has to be updated.
+ */
+#if MAX_CALLBACKS == 16
+#define FN_A_BLOCK(args) { \
+	(SWT_PTR)FN(0, args), \
+	(SWT_PTR)FN(1, args), \
+	(SWT_PTR)FN(2, args), \
+	(SWT_PTR)FN(3, args), \
+	(SWT_PTR)FN(4, args), \
+	(SWT_PTR)FN(5, args), \
+	(SWT_PTR)FN(6, args), \
+	(SWT_PTR)FN(7, args), \
+	(SWT_PTR)FN(8, args), \
+	(SWT_PTR)FN(9, args), \
+	(SWT_PTR)FN(10, args), \
+	(SWT_PTR)FN(11, args), \
+	(SWT_PTR)FN(12, args), \
+	(SWT_PTR)FN(13, args), \
+	(SWT_PTR)FN(14, args), \
+	(SWT_PTR)FN(15, args), \
+},
+#elif MAX_CALLBACKS == 128
+#define FN_A_BLOCK(args) { \
+	(SWT_PTR)FN(0, args), \
+	(SWT_PTR)FN(1, args), \
+	(SWT_PTR)FN(2, args), \
+	(SWT_PTR)FN(3, args), \
+	(SWT_PTR)FN(4, args), \
+	(SWT_PTR)FN(5, args), \
+	(SWT_PTR)FN(6, args), \
+	(SWT_PTR)FN(7, args), \
+	(SWT_PTR)FN(8, args), \
+	(SWT_PTR)FN(9, args), \
+	(SWT_PTR)FN(10, args), \
+	(SWT_PTR)FN(11, args), \
+	(SWT_PTR)FN(12, args), \
+	(SWT_PTR)FN(13, args), \
+	(SWT_PTR)FN(14, args), \
+	(SWT_PTR)FN(15, args), \
+	(SWT_PTR)FN(16, args), \
+	(SWT_PTR)FN(17, args), \
+	(SWT_PTR)FN(18, args), \
+	(SWT_PTR)FN(19, args), \
+	(SWT_PTR)FN(20, args), \
+	(SWT_PTR)FN(21, args), \
+	(SWT_PTR)FN(22, args), \
+	(SWT_PTR)FN(23, args), \
+	(SWT_PTR)FN(24, args), \
+	(SWT_PTR)FN(25, args), \
+	(SWT_PTR)FN(26, args), \
+	(SWT_PTR)FN(27, args), \
+	(SWT_PTR)FN(28, args), \
+	(SWT_PTR)FN(29, args), \
+	(SWT_PTR)FN(30, args), \
+	(SWT_PTR)FN(31, args), \
+	(SWT_PTR)FN(32, args), \
+	(SWT_PTR)FN(33, args), \
+	(SWT_PTR)FN(34, args), \
+	(SWT_PTR)FN(35, args), \
+	(SWT_PTR)FN(36, args), \
+	(SWT_PTR)FN(37, args), \
+	(SWT_PTR)FN(38, args), \
+	(SWT_PTR)FN(39, args), \
+	(SWT_PTR)FN(40, args), \
+	(SWT_PTR)FN(41, args), \
+	(SWT_PTR)FN(42, args), \
+	(SWT_PTR)FN(43, args), \
+	(SWT_PTR)FN(44, args), \
+	(SWT_PTR)FN(45, args), \
+	(SWT_PTR)FN(46, args), \
+	(SWT_PTR)FN(47, args), \
+	(SWT_PTR)FN(48, args), \
+	(SWT_PTR)FN(49, args), \
+	(SWT_PTR)FN(50, args), \
+	(SWT_PTR)FN(51, args), \
+	(SWT_PTR)FN(52, args), \
+	(SWT_PTR)FN(53, args), \
+	(SWT_PTR)FN(54, args), \
+	(SWT_PTR)FN(55, args), \
+	(SWT_PTR)FN(56, args), \
+	(SWT_PTR)FN(57, args), \
+	(SWT_PTR)FN(58, args), \
+	(SWT_PTR)FN(59, args), \
+	(SWT_PTR)FN(60, args), \
+	(SWT_PTR)FN(61, args), \
+	(SWT_PTR)FN(62, args), \
+	(SWT_PTR)FN(63, args), \
+	(SWT_PTR)FN(64, args), \
+	(SWT_PTR)FN(65, args), \
+	(SWT_PTR)FN(66, args), \
+	(SWT_PTR)FN(67, args), \
+	(SWT_PTR)FN(68, args), \
+	(SWT_PTR)FN(69, args), \
+	(SWT_PTR)FN(70, args), \
+	(SWT_PTR)FN(71, args), \
+	(SWT_PTR)FN(72, args), \
+	(SWT_PTR)FN(73, args), \
+	(SWT_PTR)FN(74, args), \
+	(SWT_PTR)FN(75, args), \
+	(SWT_PTR)FN(76, args), \
+	(SWT_PTR)FN(77, args), \
+	(SWT_PTR)FN(78, args), \
+	(SWT_PTR)FN(79, args), \
+	(SWT_PTR)FN(80, args), \
+	(SWT_PTR)FN(81, args), \
+	(SWT_PTR)FN(82, args), \
+	(SWT_PTR)FN(83, args), \
+	(SWT_PTR)FN(84, args), \
+	(SWT_PTR)FN(85, args), \
+	(SWT_PTR)FN(86, args), \
+	(SWT_PTR)FN(87, args), \
+	(SWT_PTR)FN(88, args), \
+	(SWT_PTR)FN(89, args), \
+	(SWT_PTR)FN(90, args), \
+	(SWT_PTR)FN(91, args), \
+	(SWT_PTR)FN(92, args), \
+	(SWT_PTR)FN(93, args), \
+	(SWT_PTR)FN(94, args), \
+	(SWT_PTR)FN(95, args), \
+	(SWT_PTR)FN(96, args), \
+	(SWT_PTR)FN(97, args), \
+	(SWT_PTR)FN(98, args), \
+	(SWT_PTR)FN(99, args), \
+	(SWT_PTR)FN(100, args), \
+	(SWT_PTR)FN(101, args), \
+	(SWT_PTR)FN(102, args), \
+	(SWT_PTR)FN(103, args), \
+	(SWT_PTR)FN(104, args), \
+	(SWT_PTR)FN(105, args), \
+	(SWT_PTR)FN(106, args), \
+	(SWT_PTR)FN(107, args), \
+	(SWT_PTR)FN(108, args), \
+	(SWT_PTR)FN(109, args), \
+	(SWT_PTR)FN(110, args), \
+	(SWT_PTR)FN(111, args), \
+	(SWT_PTR)FN(112, args), \
+	(SWT_PTR)FN(113, args), \
+	(SWT_PTR)FN(114, args), \
+	(SWT_PTR)FN(115, args), \
+	(SWT_PTR)FN(116, args), \
+	(SWT_PTR)FN(117, args), \
+	(SWT_PTR)FN(118, args), \
+	(SWT_PTR)FN(119, args), \
+	(SWT_PTR)FN(120, args), \
+	(SWT_PTR)FN(121, args), \
+	(SWT_PTR)FN(122, args), \
+	(SWT_PTR)FN(123, args), \
+	(SWT_PTR)FN(124, args), \
+	(SWT_PTR)FN(125, args), \
+	(SWT_PTR)FN(126, args), \
+	(SWT_PTR)FN(127, args), \
+},
+#else
+#error Invalid MAX_CALLBACKS
+#endif /* MAX_CALLBACKS == 16 */
+
+SWT_PTR fnx_array[MAX_ARGS+1][MAX_CALLBACKS] = { 
+	FN_A_BLOCK(0)    
+	FN_A_BLOCK(1)    
+	FN_A_BLOCK(2)    
+	FN_A_BLOCK(3)    
+	FN_A_BLOCK(4)    
+	FN_A_BLOCK(5)    
+	FN_A_BLOCK(6)    
+	FN_A_BLOCK(7)    
+	FN_A_BLOCK(8)    
+	FN_A_BLOCK(9)    
+	FN_A_BLOCK(10)    
+	FN_A_BLOCK(11)    
+	FN_A_BLOCK(12)    
+};
+
+#endif /* USE_ASSEMBLER */
+
+/* --------------- callback class calls --------------- */
+
+JNIEXPORT SWT_PTR JNICALL Java_org_eclipse_swt_internal_Callback_bind
+  (JNIEnv *env, jclass that, jobject callbackObject, jobject object, jstring method, jstring signature, jint argCount, jboolean isStatic, jboolean isArrayBased, SWT_PTR errorResult)
+{
+	int i;
+	jmethodID mid = NULL;
+	jclass javaClass = that;
+	const char *methodString = NULL, *sigString = NULL;
+	if (jvm == NULL) (*env)->GetJavaVM(env, &jvm);
+	if (!initialized) {
+		memset(&callbackData, 0, sizeof(callbackData));
+		initialized = 1;
+	}
+	if (method) methodString = (const char *) (*env)->GetStringUTFChars(env, method, NULL);
+	if (signature) sigString = (const char *) (*env)->GetStringUTFChars(env, signature, NULL);
+	if (object && methodString && sigString) {
+		if (isStatic) {
+			mid = (*env)->GetStaticMethodID(env, object, methodString, sigString);
+		} else {
+			javaClass = (*env)->GetObjectClass(env, object);    
+			mid = (*env)->GetMethodID(env, javaClass, methodString, sigString);
+		}
+	}
+	if (method && methodString) (*env)->ReleaseStringUTFChars(env, method, methodString);
+	if (signature && sigString) (*env)->ReleaseStringUTFChars(env, signature, sigString);
+	if (mid == 0) goto fail;
+	for (i=0; i<MAX_CALLBACKS; i++) {
+		if (!callbackData[i].callback) {
+			if ((callbackData[i].callback = (*env)->NewGlobalRef(env, callbackObject)) == NULL) goto fail;
+			if ((callbackData[i].object = (*env)->NewGlobalRef(env, object)) == NULL) goto fail;
+			callbackData[i].isStatic = isStatic;
+			callbackData[i].isArrayBased = isArrayBased;
+			callbackData[i].argCount = argCount;
+			callbackData[i].errorResult = errorResult;
+			callbackData[i].methodID = mid;
+#ifndef USE_ASSEMBLER
+			return (SWT_PTR) fnx_array[argCount][i];
+#else
+			{
+			int j = 0, k, pad = 0;
+			unsigned char* code;
+			if (callbackCode == NULL) {
+#if defined (_WIN32) || defined (_WIN32_WCE)
+				callbackCode = VirtualAlloc(NULL, CALLBACK_THUNK_SIZE * MAX_CALLBACKS, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
+				if (callbackCode == NULL) return 0;
+#else 
+				callbackCode = mmap(NULL, CALLBACK_THUNK_SIZE * MAX_CALLBACKS, PROT_EXEC | PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0);
+				if (callbackCode == MAP_FAILED) return 0;
+#endif
+			}
+			code = (unsigned char *)(callbackCode + (i * CALLBACK_THUNK_SIZE));
+
+			//PUSH EBP - 1 byte
+			code[j++] = 0x55;
+
+			//MOV EBP,ESP - 2 bytes
+			code[j++] = 0x8b;
+			code[j++] = 0xec;
+
+#ifdef __APPLE__
+			/* darwin calling conventions require that the stack be aligned on a 16-byte boundary. */
+			k = (argCount+3)*sizeof(SWT_PTR);
+			pad = ((k + 15) & ~15) - k;
+			if (pad > 0) {
+				//SUB ESP,pad - 3 bytes
+				code[j++] = 0x83;
+				code[j++] = 0xec;
+				code[j++] = pad;
+			}
+#endif
+
+			// 3*argCount bytes
+			for (k=(argCount + 1) * sizeof(SWT_PTR); k >= sizeof(SWT_PTR)*2; k -= sizeof(SWT_PTR)) {
+				//PUSH SS:[EBP+k]
+				code[j++] = 0xff;
+				code[j++] = 0x75;
+				code[j++] = k;
+			}
+
+			if (i > 127) {
+				//PUSH i - 5 bytes
+				code[j++] = 0x68;
+				code[j++] = ((i >> 0) & 0xFF);
+				code[j++] = ((i >> 8) & 0xFF);
+				code[j++] = ((i >> 16) & 0xFF);
+				code[j++] = ((i >> 24) & 0xFF);
+			} else {
+				//PUSH i - 2 bytes
+				code[j++] = 0x6a;
+				code[j++] = i;
+			}
+
+			//MOV EAX callback - 1 + sizeof(SWT_PTR) bytes
+			code[j++] = 0xb8;
+			((SWT_PTR *)&code[j])[0] = (SWT_PTR)&callback;
+			j += sizeof(SWT_PTR);
+
+			//CALL EAX - 2 bytes
+			code[j++] = 0xff;
+			code[j++] = 0xd0;
+
+			//ADD ESP,(argCount + 1) * sizeof(SWT_PTR) - 3 bytes
+			code[j++] = 0x83;
+			code[j++] = 0xc4;
+#ifdef __APPLE__
+			code[j++] = (unsigned char)(pad + ((argCount + 1) * sizeof(SWT_PTR)));
+#else
+			code[j++] = (unsigned char)((argCount + 1) * sizeof(SWT_PTR));
+#endif
+
+			//POP EBP - 1 byte
+			code[j++] = 0x5d;
+
+#if defined (_WIN32) || defined (_WIN32_WCE)
+			//RETN argCount * sizeof(SWT_PTR) - 3 bytes
+			code[j++] = 0xc2;
+			code[j++] = (unsigned char)(argCount * sizeof(SWT_PTR));
+			code[j++] = 0x00;
+#else
+			//RETN - 1 byte
+			code[j++] = 0xc3;
+#endif
+
+			if (j > CALLBACK_THUNK_SIZE) {
+				jclass errorClass = (*env)->FindClass(env, "java/lang/Error");
+				(*env)->ThrowNew(env, errorClass, "Callback thunk overflow");
+			}
+
+			return (SWT_PTR)code;
+			}
+#endif /* USE_ASSEMBLER */
+		}
+	}
+fail:
+    return 0;
+}
+
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_Callback_unbind
+  (JNIEnv *env, jclass that, jobject callback)
+{
+	int i;
+    for (i=0; i<MAX_CALLBACKS; i++) {
+        if (callbackData[i].callback != NULL && (*env)->IsSameObject(env, callback, callbackData[i].callback)) {
+            if (callbackData[i].callback != NULL) (*env)->DeleteGlobalRef(env, callbackData[i].callback);
+            if (callbackData[i].object != NULL) (*env)->DeleteGlobalRef(env, callbackData[i].object);
+            memset(&callbackData[i], 0, sizeof(CALLBACK_DATA));
+        }
+    }
+}
+
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_Callback_getEnabled
+  (JNIEnv *env, jclass that)
+{
+	return (jboolean)callbackEnabled;
+}
+
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_Callback_getEntryCount
+  (JNIEnv *env, jclass that)
+{
+	return (jint)callbackEntryCount;
+}
+
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_Callback_setEnabled
+  (JNIEnv *env, jclass that, jboolean enable)
+{
+	callbackEnabled = enable;
+}
+
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_Callback_reset
+  (JNIEnv *env, jclass that)
+{
+    memset((void *)&callbackData, 0, sizeof(callbackData));
+}
+
+SWT_PTR callback(int index, ...)
+{
+	if (!callbackEnabled) return 0;
+
+	{
+	JNIEnv *env = NULL;
+	jmethodID mid = callbackData[index].methodID;
+	jobject object = callbackData[index].object;
+	jboolean isStatic = callbackData[index].isStatic;
+	jboolean isArrayBased = callbackData[index].isArrayBased;
+	jint argCount = callbackData[index].argCount;
+	SWT_PTR result = callbackData[index].errorResult;
+	int detach = 0;
+	va_list vl;
+
+#ifdef DEBUG_CALL_PRINTS
+	fprintf(stderr, "* callback starting %d\n", counter++);
+#endif
+
+#ifdef JNI_VERSION_1_2
+	if (IS_JNI_1_2) {
+		(*jvm)->GetEnv(jvm, (void **)&env, JNI_VERSION_1_2);
+	}
+#endif
+	
+	if (env == NULL) {
+		(*jvm)->AttachCurrentThread(jvm, (void **)&env, NULL);
+		if (IS_JNI_1_2) detach = 1;
+	}
+	
+	/* If the current thread is not attached to the VM, it is not possible to call into the VM */
+	if (env == NULL) {
+#ifdef DEBUG_CALL_PRINTS
+		fprintf(stderr, "* could not get env\n");
+#endif
+		goto noEnv;
+	}
+
+	/* If an exception has occurred in previous callbacks do not call into the VM. */
+	if ((*env)->ExceptionOccurred(env)) {
+		goto done;
+	}
+
+	/* Call into the VM. */
+	callbackEntryCount++;
+	va_start(vl, index);
+	if (isArrayBased) {
+		int i;
+		SWT_PTRArray argsArray = (*env)->NewSWT_PTRArray(env, argCount);
+		if (argsArray != NULL) {
+			SWT_PTR *elements = (*env)->GetSWT_PTRArrayElements(env, argsArray, NULL);
+			if (elements != NULL) {
+				for (i=0; i<argCount; i++) {
+					elements[i] = va_arg(vl, SWT_PTR); 
+				}
+				(*env)->ReleaseSWT_PTRArrayElements(env, argsArray, elements, 0);
+				if (isStatic) {
+					result = (*env)->CallStaticSWT_PTRMethod(env, object, mid, argsArray);
+				} else {
+					result = (*env)->CallSWT_PTRMethod(env, object, mid, argsArray);
+				}
+			}
+			/*
+			* This function may be called many times before returning to Java,
+			* explicitly delete local references to avoid GP's in certain VMs.
+			*/
+			(*env)->DeleteLocalRef(env, argsArray);
+		}
+	} else {
+		if (isStatic) {
+			result = (*env)->CallStaticSWT_PTRMethodV(env, object, mid, vl);
+		} else {
+			result = (*env)->CallSWT_PTRMethodV(env, object, mid, vl);
+		}
+	}
+	va_end(vl);
+	callbackEntryCount--;
+	
+done:
+	/* If an exception has occurred in Java, return the error result. */
+	if ((*env)->ExceptionOccurred(env)) {
+#ifdef DEBUG_CALL_PRINTS
+		fprintf(stderr, "* java exception occurred\n");
+		(*env)->ExceptionDescribe(env);
+#endif
+		result = callbackData[index].errorResult;
+	}
+
+	if (detach) {
+		(*jvm)->DetachCurrentThread(jvm);
+		env = NULL;
+	}
+
+noEnv:
+
+#ifdef DEBUG_CALL_PRINTS
+	fprintf(stderr, "* callback exiting %d\n", --counter);
+#endif
+
+	return result;
+	}
+}
+
+/* ------------- callback class calls end --------------- */

Added: branches/upstream/swt-gtk/current/callback.h
===================================================================
--- branches/upstream/swt-gtk/current/callback.h	                        (rev 0)
+++ branches/upstream/swt-gtk/current/callback.h	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+ 
+/**
+ * Callback implementation.
+ */
+#ifndef INC_callback_H
+#define INC_callback_H
+
+#include "swt.h"
+
+#if defined (_WIN32) || defined (_WIN32_WCE)
+#include "windows.h"
+#define RETURN_TYPE LRESULT CALLBACK
+#define RETURN_CAST (LRESULT)
+#endif
+
+#ifndef RETURN_TYPE
+#define RETURN_TYPE SWT_PTR
+#endif
+
+#ifndef RETURN_CAST
+#define RETURN_CAST
+#endif
+
+/*
+* Note that only x86 assembler is supported
+*/
+#if !(defined(__i386__) || defined(_M_IX86) || defined(_X86_))
+#undef USE_ASSEMBLER
+#endif
+
+#ifdef REDUCED_CALLBACKS
+#define MAX_CALLBACKS 16
+#else
+#ifdef USE_ASSEMBLER
+#define MAX_CALLBACKS 256
+#else
+#define MAX_CALLBACKS 128
+#endif
+#endif /* REDUCED_CALLBACKS */
+
+#define MAX_ARGS 12
+
+typedef struct CALLBACK_DATA {
+    jobject callback;
+    jmethodID methodID;
+  	jobject object;
+	jboolean isStatic;
+	jboolean isArrayBased; 
+	jint argCount;
+	SWT_PTR errorResult;
+} CALLBACK_DATA;
+
+#endif /* ifndef INC_callback_H */
+

Added: branches/upstream/swt-gtk/current/cde.c
===================================================================
--- branches/upstream/swt-gtk/current/cde.c	                        (rev 0)
+++ branches/upstream/swt-gtk/current/cde.c	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,288 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+#include "swt.h"
+#include "cde_structs.h"
+#include "cde_stats.h"
+
+#define CDE_NATIVE(func) Java_org_eclipse_swt_internal_cde_CDE_##func
+
+#ifndef NO_DtActionArg_1sizeof
+JNIEXPORT jint JNICALL CDE_NATIVE(DtActionArg_1sizeof)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	CDE_NATIVE_ENTER(env, that, DtActionArg_1sizeof_FUNC);
+	rc = (jint)DtActionArg_sizeof();
+	CDE_NATIVE_EXIT(env, that, DtActionArg_1sizeof_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1DtActionInvoke
+JNIEXPORT jlong JNICALL CDE_NATIVE(_1DtActionInvoke)
+	(JNIEnv *env, jclass that, jint arg0, jbyteArray arg1, jobject arg2, jint arg3, jbyteArray arg4, jbyteArray arg5, jbyteArray arg6, jint arg7, jint arg8, jint arg9)
+{
+	jbyte *lparg1=NULL;
+	DtActionArg _arg2, *lparg2=NULL;
+	jbyte *lparg4=NULL;
+	jbyte *lparg5=NULL;
+	jbyte *lparg6=NULL;
+	jlong rc = 0;
+	CDE_NATIVE_ENTER(env, that, _1DtActionInvoke_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	if (arg2) if ((lparg2 = getDtActionArgFields(env, arg2, &_arg2)) == NULL) goto fail;
+	if (arg4) if ((lparg4 = (*env)->GetByteArrayElements(env, arg4, NULL)) == NULL) goto fail;
+	if (arg5) if ((lparg5 = (*env)->GetByteArrayElements(env, arg5, NULL)) == NULL) goto fail;
+	if (arg6) if ((lparg6 = (*env)->GetByteArrayElements(env, arg6, NULL)) == NULL) goto fail;
+	rc = (jlong)DtActionInvoke((Widget)arg0, (char *)lparg1, lparg2, arg3, (char *)lparg4, (char *)lparg5, (char *)lparg6, arg7, (DtActionCallbackProc)arg8, (XtPointer)arg9);
+fail:
+	if (arg6 && lparg6) (*env)->ReleaseByteArrayElements(env, arg6, lparg6, 0);
+	if (arg5 && lparg5) (*env)->ReleaseByteArrayElements(env, arg5, lparg5, 0);
+	if (arg4 && lparg4) (*env)->ReleaseByteArrayElements(env, arg4, lparg4, 0);
+	if (arg2 && lparg2) setDtActionArgFields(env, arg2, lparg2);
+	if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+	CDE_NATIVE_EXIT(env, that, _1DtActionInvoke_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1DtAppInitialize
+JNIEXPORT jboolean JNICALL CDE_NATIVE(_1DtAppInitialize)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jbyteArray arg3, jbyteArray arg4)
+{
+	jbyte *lparg3=NULL;
+	jbyte *lparg4=NULL;
+	jboolean rc = 0;
+	CDE_NATIVE_ENTER(env, that, _1DtAppInitialize_FUNC);
+	if (arg3) if ((lparg3 = (*env)->GetByteArrayElements(env, arg3, NULL)) == NULL) goto fail;
+	if (arg4) if ((lparg4 = (*env)->GetByteArrayElements(env, arg4, NULL)) == NULL) goto fail;
+	rc = (jboolean)DtAppInitialize((XtAppContext)arg0, (Display *)arg1, (Widget)arg2, (char *)lparg3, (char *)lparg4);
+fail:
+	if (arg4 && lparg4) (*env)->ReleaseByteArrayElements(env, arg4, lparg4, 0);
+	if (arg3 && lparg3) (*env)->ReleaseByteArrayElements(env, arg3, lparg3, 0);
+	CDE_NATIVE_EXIT(env, that, _1DtAppInitialize_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1DtDbLoad
+JNIEXPORT void JNICALL CDE_NATIVE(_1DtDbLoad)
+	(JNIEnv *env, jclass that)
+{
+	CDE_NATIVE_ENTER(env, that, _1DtDbLoad_FUNC);
+	DtDbLoad();
+	CDE_NATIVE_EXIT(env, that, _1DtDbLoad_FUNC);
+}
+#endif
+
+#ifndef NO__1DtDtsDataTypeIsAction
+JNIEXPORT jboolean JNICALL CDE_NATIVE(_1DtDtsDataTypeIsAction)
+	(JNIEnv *env, jclass that, jbyteArray arg0)
+{
+	jbyte *lparg0=NULL;
+	jboolean rc = 0;
+	CDE_NATIVE_ENTER(env, that, _1DtDtsDataTypeIsAction_FUNC);
+	if (arg0) if ((lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL)) == NULL) goto fail;
+	rc = (jboolean)DtDtsDataTypeIsAction((char *)lparg0);
+fail:
+	if (arg0 && lparg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
+	CDE_NATIVE_EXIT(env, that, _1DtDtsDataTypeIsAction_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1DtDtsDataTypeNames
+JNIEXPORT jint JNICALL CDE_NATIVE(_1DtDtsDataTypeNames)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	CDE_NATIVE_ENTER(env, that, _1DtDtsDataTypeNames_FUNC);
+	rc = (jint)DtDtsDataTypeNames();
+	CDE_NATIVE_EXIT(env, that, _1DtDtsDataTypeNames_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1DtDtsDataTypeToAttributeValue
+JNIEXPORT jint JNICALL CDE_NATIVE(_1DtDtsDataTypeToAttributeValue)
+	(JNIEnv *env, jclass that, jbyteArray arg0, jbyteArray arg1, jbyteArray arg2)
+{
+	jbyte *lparg0=NULL;
+	jbyte *lparg1=NULL;
+	jbyte *lparg2=NULL;
+	jint rc = 0;
+	CDE_NATIVE_ENTER(env, that, _1DtDtsDataTypeToAttributeValue_FUNC);
+	if (arg0) if ((lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL)) == NULL) goto fail;
+	if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	if (arg2) if ((lparg2 = (*env)->GetByteArrayElements(env, arg2, NULL)) == NULL) goto fail;
+	rc = (jint)DtDtsDataTypeToAttributeValue((char *)lparg0, (char *)lparg1, (char *)lparg2);
+fail:
+	if (arg2 && lparg2) (*env)->ReleaseByteArrayElements(env, arg2, lparg2, 0);
+	if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+	if (arg0 && lparg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
+	CDE_NATIVE_EXIT(env, that, _1DtDtsDataTypeToAttributeValue_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1DtDtsFileToDataType
+JNIEXPORT jint JNICALL CDE_NATIVE(_1DtDtsFileToDataType)
+	(JNIEnv *env, jclass that, jbyteArray arg0)
+{
+	jbyte *lparg0=NULL;
+	jint rc = 0;
+	CDE_NATIVE_ENTER(env, that, _1DtDtsFileToDataType_FUNC);
+	if (arg0) if ((lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL)) == NULL) goto fail;
+	rc = (jint)DtDtsFileToDataType((char *)lparg0);
+fail:
+	if (arg0 && lparg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
+	CDE_NATIVE_EXIT(env, that, _1DtDtsFileToDataType_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1DtDtsFreeAttributeValue
+JNIEXPORT void JNICALL CDE_NATIVE(_1DtDtsFreeAttributeValue)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	CDE_NATIVE_ENTER(env, that, _1DtDtsFreeAttributeValue_FUNC);
+	DtDtsFreeAttributeValue((char *)arg0);
+	CDE_NATIVE_EXIT(env, that, _1DtDtsFreeAttributeValue_FUNC);
+}
+#endif
+
+#ifndef NO__1DtDtsFreeDataType
+JNIEXPORT void JNICALL CDE_NATIVE(_1DtDtsFreeDataType)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	CDE_NATIVE_ENTER(env, that, _1DtDtsFreeDataType_FUNC);
+	DtDtsFreeDataType((char *)arg0);
+	CDE_NATIVE_EXIT(env, that, _1DtDtsFreeDataType_FUNC);
+}
+#endif
+
+#ifndef NO__1DtDtsFreeDataTypeNames
+JNIEXPORT void JNICALL CDE_NATIVE(_1DtDtsFreeDataTypeNames)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	CDE_NATIVE_ENTER(env, that, _1DtDtsFreeDataTypeNames_FUNC);
+	DtDtsFreeDataTypeNames((char **)arg0);
+	CDE_NATIVE_EXIT(env, that, _1DtDtsFreeDataTypeNames_FUNC);
+}
+#endif
+
+#ifndef NO__1XtAppCreateShell
+JNIEXPORT jint JNICALL CDE_NATIVE(_1XtAppCreateShell)
+	(JNIEnv *env, jclass that, jbyteArray arg0, jbyteArray arg1, jint arg2, jint arg3, jintArray arg4, jint arg5)
+{
+	jbyte *lparg0=NULL;
+	jbyte *lparg1=NULL;
+	jint *lparg4=NULL;
+	jint rc = 0;
+	CDE_NATIVE_ENTER(env, that, _1XtAppCreateShell_FUNC);
+	if (arg0) if ((lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL)) == NULL) goto fail;
+	if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	if (arg4) if ((lparg4 = (*env)->GetIntArrayElements(env, arg4, NULL)) == NULL) goto fail;
+	rc = (jint)XtAppCreateShell((String)lparg0, (String)lparg1, (WidgetClass)arg2, (Display *)arg3, (ArgList)lparg4, arg5);
+fail:
+	if (arg4 && lparg4) (*env)->ReleaseIntArrayElements(env, arg4, lparg4, 0);
+	if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+	if (arg0 && lparg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
+	CDE_NATIVE_EXIT(env, that, _1XtAppCreateShell_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1XtCreateApplicationContext
+JNIEXPORT jint JNICALL CDE_NATIVE(_1XtCreateApplicationContext)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	CDE_NATIVE_ENTER(env, that, _1XtCreateApplicationContext_FUNC);
+	rc = (jint)XtCreateApplicationContext();
+	CDE_NATIVE_EXIT(env, that, _1XtCreateApplicationContext_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1XtDisplayInitialize
+JNIEXPORT void JNICALL CDE_NATIVE(_1XtDisplayInitialize)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jbyteArray arg2, jbyteArray arg3, jint arg4, jint arg5, jintArray arg6, jint arg7)
+{
+	jbyte *lparg2=NULL;
+	jbyte *lparg3=NULL;
+	jint *lparg6=NULL;
+	CDE_NATIVE_ENTER(env, that, _1XtDisplayInitialize_FUNC);
+	if (arg2) if ((lparg2 = (*env)->GetByteArrayElements(env, arg2, NULL)) == NULL) goto fail;
+	if (arg3) if ((lparg3 = (*env)->GetByteArrayElements(env, arg3, NULL)) == NULL) goto fail;
+	if (arg6) if ((lparg6 = (*env)->GetIntArrayElements(env, arg6, NULL)) == NULL) goto fail;
+	XtDisplayInitialize((XtAppContext)arg0, (Display *)arg1, (String)lparg2, (String)lparg3, (XrmOptionDescRec *)arg4, (Cardinal)arg5, (int *)lparg6, (String *)arg7);
+fail:
+	if (arg6 && lparg6) (*env)->ReleaseIntArrayElements(env, arg6, lparg6, 0);
+	if (arg3 && lparg3) (*env)->ReleaseByteArrayElements(env, arg3, lparg3, 0);
+	if (arg2 && lparg2) (*env)->ReleaseByteArrayElements(env, arg2, lparg2, 0);
+	CDE_NATIVE_EXIT(env, that, _1XtDisplayInitialize_FUNC);
+}
+#endif
+
+#ifndef NO__1XtRealizeWidget
+JNIEXPORT void JNICALL CDE_NATIVE(_1XtRealizeWidget)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	CDE_NATIVE_ENTER(env, that, _1XtRealizeWidget_FUNC);
+	XtRealizeWidget((Widget)arg0);
+	CDE_NATIVE_EXIT(env, that, _1XtRealizeWidget_FUNC);
+}
+#endif
+
+#ifndef NO__1XtResizeWidget
+JNIEXPORT void JNICALL CDE_NATIVE(_1XtResizeWidget)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3)
+{
+	CDE_NATIVE_ENTER(env, that, _1XtResizeWidget_FUNC);
+	XtResizeWidget((Widget)arg0, arg1, arg2, arg3);
+	CDE_NATIVE_EXIT(env, that, _1XtResizeWidget_FUNC);
+}
+#endif
+
+#ifndef NO__1XtSetMappedWhenManaged
+JNIEXPORT void JNICALL CDE_NATIVE(_1XtSetMappedWhenManaged)
+	(JNIEnv *env, jclass that, jint arg0, jboolean arg1)
+{
+	CDE_NATIVE_ENTER(env, that, _1XtSetMappedWhenManaged_FUNC);
+	XtSetMappedWhenManaged((Widget)arg0, arg1);
+	CDE_NATIVE_EXIT(env, that, _1XtSetMappedWhenManaged_FUNC);
+}
+#endif
+
+#ifndef NO__1XtToolkitInitialize
+JNIEXPORT void JNICALL CDE_NATIVE(_1XtToolkitInitialize)
+	(JNIEnv *env, jclass that)
+{
+	CDE_NATIVE_ENTER(env, that, _1XtToolkitInitialize_FUNC);
+	XtToolkitInitialize();
+	CDE_NATIVE_EXIT(env, that, _1XtToolkitInitialize_FUNC);
+}
+#endif
+
+#ifndef NO__1topLevelShellWidgetClass
+JNIEXPORT jint JNICALL CDE_NATIVE(_1topLevelShellWidgetClass)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	CDE_NATIVE_ENTER(env, that, _1topLevelShellWidgetClass_FUNC);
+	rc = (jint)topLevelShellWidgetClass;
+	CDE_NATIVE_EXIT(env, that, _1topLevelShellWidgetClass_FUNC);
+	return rc;
+}
+#endif
+

Added: branches/upstream/swt-gtk/current/cde.h
===================================================================
--- branches/upstream/swt-gtk/current/cde.h	                        (rev 0)
+++ branches/upstream/swt-gtk/current/cde.h	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+#ifndef INC_cde_H
+#define INC_cde_H
+
+#define NDEBUG 
+
+#include <stdio.h>
+#include <assert.h>
+
+#include <Dt/Dt.h>
+#include <Dt/Dts.h>
+#include <Dt/Action.h>
+
+#include <X11/IntrinsicP.h>
+#include <X11/Shell.h>
+
+#endif /* INC_cde_H */

Added: branches/upstream/swt-gtk/current/cde_stats.c
===================================================================
--- branches/upstream/swt-gtk/current/cde_stats.c	                        (rev 0)
+++ branches/upstream/swt-gtk/current/cde_stats.c	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+#include "swt.h"
+#include "cde_stats.h"
+
+#ifdef NATIVE_STATS
+
+int CDE_nativeFunctionCount = 19;
+int CDE_nativeFunctionCallCount[19];
+char * CDE_nativeFunctionNames[] = {
+	"DtActionArg_1sizeof",
+	"_1DtActionInvoke",
+	"_1DtAppInitialize",
+	"_1DtDbLoad",
+	"_1DtDtsDataTypeIsAction",
+	"_1DtDtsDataTypeNames",
+	"_1DtDtsDataTypeToAttributeValue",
+	"_1DtDtsFileToDataType",
+	"_1DtDtsFreeAttributeValue",
+	"_1DtDtsFreeDataType",
+	"_1DtDtsFreeDataTypeNames",
+	"_1XtAppCreateShell",
+	"_1XtCreateApplicationContext",
+	"_1XtDisplayInitialize",
+	"_1XtRealizeWidget",
+	"_1XtResizeWidget",
+	"_1XtSetMappedWhenManaged",
+	"_1XtToolkitInitialize",
+	"_1topLevelShellWidgetClass",
+};
+
+#define STATS_NATIVE(func) Java_org_eclipse_swt_tools_internal_NativeStats_##func
+
+JNIEXPORT jint JNICALL STATS_NATIVE(CDE_1GetFunctionCount)
+	(JNIEnv *env, jclass that)
+{
+	return CDE_nativeFunctionCount;
+}
+
+JNIEXPORT jstring JNICALL STATS_NATIVE(CDE_1GetFunctionName)
+	(JNIEnv *env, jclass that, jint index)
+{
+	return (*env)->NewStringUTF(env, CDE_nativeFunctionNames[index]);
+}
+
+JNIEXPORT jint JNICALL STATS_NATIVE(CDE_1GetFunctionCallCount)
+	(JNIEnv *env, jclass that, jint index)
+{
+	return CDE_nativeFunctionCallCount[index];
+}
+
+#endif

Added: branches/upstream/swt-gtk/current/cde_stats.h
===================================================================
--- branches/upstream/swt-gtk/current/cde_stats.h	                        (rev 0)
+++ branches/upstream/swt-gtk/current/cde_stats.h	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+#ifdef NATIVE_STATS
+extern int CDE_nativeFunctionCount;
+extern int CDE_nativeFunctionCallCount[];
+extern char* CDE_nativeFunctionNames[];
+#define CDE_NATIVE_ENTER(env, that, func) CDE_nativeFunctionCallCount[func]++;
+#define CDE_NATIVE_EXIT(env, that, func) 
+#else
+#ifndef CDE_NATIVE_ENTER
+#define CDE_NATIVE_ENTER(env, that, func) 
+#endif
+#ifndef CDE_NATIVE_EXIT
+#define CDE_NATIVE_EXIT(env, that, func) 
+#endif
+#endif
+
+typedef enum {
+	DtActionArg_1sizeof_FUNC,
+	_1DtActionInvoke_FUNC,
+	_1DtAppInitialize_FUNC,
+	_1DtDbLoad_FUNC,
+	_1DtDtsDataTypeIsAction_FUNC,
+	_1DtDtsDataTypeNames_FUNC,
+	_1DtDtsDataTypeToAttributeValue_FUNC,
+	_1DtDtsFileToDataType_FUNC,
+	_1DtDtsFreeAttributeValue_FUNC,
+	_1DtDtsFreeDataType_FUNC,
+	_1DtDtsFreeDataTypeNames_FUNC,
+	_1XtAppCreateShell_FUNC,
+	_1XtCreateApplicationContext_FUNC,
+	_1XtDisplayInitialize_FUNC,
+	_1XtRealizeWidget_FUNC,
+	_1XtResizeWidget_FUNC,
+	_1XtSetMappedWhenManaged_FUNC,
+	_1XtToolkitInitialize_FUNC,
+	_1topLevelShellWidgetClass_FUNC,
+} CDE_FUNCS;

Added: branches/upstream/swt-gtk/current/cde_structs.c
===================================================================
--- branches/upstream/swt-gtk/current/cde_structs.c	                        (rev 0)
+++ branches/upstream/swt-gtk/current/cde_structs.c	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+#include "swt.h"
+#include "cde_structs.h"
+
+#ifndef NO_DtActionArg
+typedef struct DtActionArg_FID_CACHE {
+	int cached;
+	jclass clazz;
+	jfieldID argClass, name;
+} DtActionArg_FID_CACHE;
+
+DtActionArg_FID_CACHE DtActionArgFc;
+
+void cacheDtActionArgFields(JNIEnv *env, jobject lpObject)
+{
+	if (DtActionArgFc.cached) return;
+	DtActionArgFc.clazz = (*env)->GetObjectClass(env, lpObject);
+	DtActionArgFc.argClass = (*env)->GetFieldID(env, DtActionArgFc.clazz, "argClass", "I");
+	DtActionArgFc.name = (*env)->GetFieldID(env, DtActionArgFc.clazz, "name", "I");
+	DtActionArgFc.cached = 1;
+}
+
+DtActionArg *getDtActionArgFields(JNIEnv *env, jobject lpObject, DtActionArg *lpStruct)
+{
+	if (!DtActionArgFc.cached) cacheDtActionArgFields(env, lpObject);
+	lpStruct->argClass = (*env)->GetIntField(env, lpObject, DtActionArgFc.argClass);
+	lpStruct->u.file.name = (char *)(*env)->GetIntField(env, lpObject, DtActionArgFc.name);
+	return lpStruct;
+}
+
+void setDtActionArgFields(JNIEnv *env, jobject lpObject, DtActionArg *lpStruct)
+{
+	if (!DtActionArgFc.cached) cacheDtActionArgFields(env, lpObject);
+	(*env)->SetIntField(env, lpObject, DtActionArgFc.argClass, (jint)lpStruct->argClass);
+	(*env)->SetIntField(env, lpObject, DtActionArgFc.name, (jint)lpStruct->u.file.name);
+}
+#endif
+

Added: branches/upstream/swt-gtk/current/cde_structs.h
===================================================================
--- branches/upstream/swt-gtk/current/cde_structs.h	                        (rev 0)
+++ branches/upstream/swt-gtk/current/cde_structs.h	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+#include "cde.h"
+
+#ifndef NO_DtActionArg
+void cacheDtActionArgFields(JNIEnv *env, jobject lpObject);
+DtActionArg *getDtActionArgFields(JNIEnv *env, jobject lpObject, DtActionArg *lpStruct);
+void setDtActionArgFields(JNIEnv *env, jobject lpObject, DtActionArg *lpStruct);
+#define DtActionArg_sizeof() sizeof(DtActionArg)
+#else
+#define cacheDtActionArgFields(a,b)
+#define getDtActionArgFields(a,b,c) NULL
+#define setDtActionArgFields(a,b,c)
+#define DtActionArg_sizeof() 0
+#endif
+

Added: branches/upstream/swt-gtk/current/glx.c
===================================================================
--- branches/upstream/swt-gtk/current/glx.c	                        (rev 0)
+++ branches/upstream/swt-gtk/current/glx.c	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,316 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+#include "swt.h"
+#include "glx_structs.h"
+#include "glx_stats.h"
+
+#define GLX_NATIVE(func) Java_org_eclipse_swt_internal_opengl_glx_GLX_##func
+
+#ifndef NO_XVisualInfo_1sizeof
+JNIEXPORT jint JNICALL GLX_NATIVE(XVisualInfo_1sizeof)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	GLX_NATIVE_ENTER(env, that, XVisualInfo_1sizeof_FUNC);
+	rc = (jint)XVisualInfo_sizeof();
+	GLX_NATIVE_EXIT(env, that, XVisualInfo_1sizeof_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1glGetIntegerv
+JNIEXPORT void JNICALL GLX_NATIVE(_1glGetIntegerv)
+	(JNIEnv *env, jclass that, jint arg0, jintArray arg1)
+{
+	jint *lparg1=NULL;
+	GLX_NATIVE_ENTER(env, that, _1glGetIntegerv_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	glGetIntegerv((GLenum)arg0, (GLint *)lparg1);
+fail:
+	if (arg1 && lparg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0);
+	GLX_NATIVE_EXIT(env, that, _1glGetIntegerv_FUNC);
+}
+#endif
+
+#ifndef NO__1glViewport
+JNIEXPORT void JNICALL GLX_NATIVE(_1glViewport)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3)
+{
+	GLX_NATIVE_ENTER(env, that, _1glViewport_FUNC);
+	glViewport((GLint)arg0, (GLint)arg1, (GLsizei)arg2, (GLsizei)arg3);
+	GLX_NATIVE_EXIT(env, that, _1glViewport_FUNC);
+}
+#endif
+
+#ifndef NO__1glXChooseVisual
+JNIEXPORT jint JNICALL GLX_NATIVE(_1glXChooseVisual)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jintArray arg2)
+{
+	jint *lparg2=NULL;
+	jint rc = 0;
+	GLX_NATIVE_ENTER(env, that, _1glXChooseVisual_FUNC);
+	if (arg2) if ((lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL)) == NULL) goto fail;
+	rc = (jint)glXChooseVisual((Display *)arg0, arg1, lparg2);
+fail:
+	if (arg2 && lparg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
+	GLX_NATIVE_EXIT(env, that, _1glXChooseVisual_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1glXCopyContext
+JNIEXPORT void JNICALL GLX_NATIVE(_1glXCopyContext)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3)
+{
+	GLX_NATIVE_ENTER(env, that, _1glXCopyContext_FUNC);
+	glXCopyContext((Display *)arg0, (GLXContext)arg1, (GLXContext)arg2, arg3);
+	GLX_NATIVE_EXIT(env, that, _1glXCopyContext_FUNC);
+}
+#endif
+
+#ifndef NO__1glXCreateContext
+JNIEXPORT jint JNICALL GLX_NATIVE(_1glXCreateContext)
+	(JNIEnv *env, jclass that, jint arg0, jobject arg1, jint arg2, jboolean arg3)
+{
+	XVisualInfo _arg1, *lparg1=NULL;
+	jint rc = 0;
+	GLX_NATIVE_ENTER(env, that, _1glXCreateContext_FUNC);
+	if (arg1) if ((lparg1 = getXVisualInfoFields(env, arg1, &_arg1)) == NULL) goto fail;
+	rc = (jint)glXCreateContext((Display *)arg0, lparg1, (GLXContext)arg2, arg3);
+fail:
+	if (arg1 && lparg1) setXVisualInfoFields(env, arg1, lparg1);
+	GLX_NATIVE_EXIT(env, that, _1glXCreateContext_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1glXCreateGLXPixmap
+JNIEXPORT jint JNICALL GLX_NATIVE(_1glXCreateGLXPixmap)
+	(JNIEnv *env, jclass that, jint arg0, jobject arg1, jint arg2)
+{
+	XVisualInfo _arg1, *lparg1=NULL;
+	jint rc = 0;
+	GLX_NATIVE_ENTER(env, that, _1glXCreateGLXPixmap_FUNC);
+	if (arg1) if ((lparg1 = getXVisualInfoFields(env, arg1, &_arg1)) == NULL) goto fail;
+	rc = (jint)glXCreateGLXPixmap((Display *)arg0, lparg1, (Pixmap)arg2);
+fail:
+	if (arg1 && lparg1) setXVisualInfoFields(env, arg1, lparg1);
+	GLX_NATIVE_EXIT(env, that, _1glXCreateGLXPixmap_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1glXDestroyContext
+JNIEXPORT void JNICALL GLX_NATIVE(_1glXDestroyContext)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	GLX_NATIVE_ENTER(env, that, _1glXDestroyContext_FUNC);
+	glXDestroyContext((Display *)arg0, (GLXContext)arg1);
+	GLX_NATIVE_EXIT(env, that, _1glXDestroyContext_FUNC);
+}
+#endif
+
+#ifndef NO__1glXDestroyGLXPixmap
+JNIEXPORT void JNICALL GLX_NATIVE(_1glXDestroyGLXPixmap)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	GLX_NATIVE_ENTER(env, that, _1glXDestroyGLXPixmap_FUNC);
+	glXDestroyGLXPixmap((Display *)arg0, (GLXPixmap)arg1);
+	GLX_NATIVE_EXIT(env, that, _1glXDestroyGLXPixmap_FUNC);
+}
+#endif
+
+#ifndef NO__1glXGetClientString
+JNIEXPORT jint JNICALL GLX_NATIVE(_1glXGetClientString)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	jint rc = 0;
+	GLX_NATIVE_ENTER(env, that, _1glXGetClientString_FUNC);
+	rc = (jint)glXGetClientString((Display *)arg0, arg1);
+	GLX_NATIVE_EXIT(env, that, _1glXGetClientString_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1glXGetConfig
+JNIEXPORT jint JNICALL GLX_NATIVE(_1glXGetConfig)
+	(JNIEnv *env, jclass that, jint arg0, jobject arg1, jint arg2, jintArray arg3)
+{
+	XVisualInfo _arg1, *lparg1=NULL;
+	jint *lparg3=NULL;
+	jint rc = 0;
+	GLX_NATIVE_ENTER(env, that, _1glXGetConfig_FUNC);
+	if (arg1) if ((lparg1 = getXVisualInfoFields(env, arg1, &_arg1)) == NULL) goto fail;
+	if (arg3) if ((lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL)) == NULL) goto fail;
+	rc = (jint)glXGetConfig((Display *)arg0, lparg1, arg2, lparg3);
+fail:
+	if (arg3 && lparg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0);
+	if (arg1 && lparg1) setXVisualInfoFields(env, arg1, lparg1);
+	GLX_NATIVE_EXIT(env, that, _1glXGetConfig_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1glXGetCurrentContext
+JNIEXPORT jint JNICALL GLX_NATIVE(_1glXGetCurrentContext)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	GLX_NATIVE_ENTER(env, that, _1glXGetCurrentContext_FUNC);
+	rc = (jint)glXGetCurrentContext();
+	GLX_NATIVE_EXIT(env, that, _1glXGetCurrentContext_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1glXGetCurrentDrawable
+JNIEXPORT jint JNICALL GLX_NATIVE(_1glXGetCurrentDrawable)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	GLX_NATIVE_ENTER(env, that, _1glXGetCurrentDrawable_FUNC);
+	rc = (jint)glXGetCurrentDrawable();
+	GLX_NATIVE_EXIT(env, that, _1glXGetCurrentDrawable_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1glXIsDirect
+JNIEXPORT jboolean JNICALL GLX_NATIVE(_1glXIsDirect)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	jboolean rc = 0;
+	GLX_NATIVE_ENTER(env, that, _1glXIsDirect_FUNC);
+	rc = (jboolean)glXIsDirect((Display *)arg0, (GLXContext)arg1);
+	GLX_NATIVE_EXIT(env, that, _1glXIsDirect_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1glXMakeCurrent
+JNIEXPORT jboolean JNICALL GLX_NATIVE(_1glXMakeCurrent)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+	jboolean rc = 0;
+	GLX_NATIVE_ENTER(env, that, _1glXMakeCurrent_FUNC);
+	rc = (jboolean)glXMakeCurrent((Display *)arg0, (GLXDrawable)arg1, (GLXContext)arg2);
+	GLX_NATIVE_EXIT(env, that, _1glXMakeCurrent_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1glXQueryExtension
+JNIEXPORT jboolean JNICALL GLX_NATIVE(_1glXQueryExtension)
+	(JNIEnv *env, jclass that, jint arg0, jintArray arg1, jintArray arg2)
+{
+	jint *lparg1=NULL;
+	jint *lparg2=NULL;
+	jboolean rc = 0;
+	GLX_NATIVE_ENTER(env, that, _1glXQueryExtension_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	if (arg2) if ((lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL)) == NULL) goto fail;
+	rc = (jboolean)glXQueryExtension((Display *)arg0, lparg1, lparg2);
+fail:
+	if (arg2 && lparg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
+	if (arg1 && lparg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0);
+	GLX_NATIVE_EXIT(env, that, _1glXQueryExtension_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1glXQueryExtensionsString
+JNIEXPORT jint JNICALL GLX_NATIVE(_1glXQueryExtensionsString)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	jint rc = 0;
+	GLX_NATIVE_ENTER(env, that, _1glXQueryExtensionsString_FUNC);
+	rc = (jint)glXQueryExtensionsString((Display *)arg0, arg1);
+	GLX_NATIVE_EXIT(env, that, _1glXQueryExtensionsString_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1glXQueryServerString
+JNIEXPORT jint JNICALL GLX_NATIVE(_1glXQueryServerString)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+	jint rc = 0;
+	GLX_NATIVE_ENTER(env, that, _1glXQueryServerString_FUNC);
+	rc = (jint)glXQueryServerString((Display *)arg0, arg1, arg2);
+	GLX_NATIVE_EXIT(env, that, _1glXQueryServerString_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1glXQueryVersion
+JNIEXPORT jboolean JNICALL GLX_NATIVE(_1glXQueryVersion)
+	(JNIEnv *env, jclass that, jint arg0, jintArray arg1, jintArray arg2)
+{
+	jint *lparg1=NULL;
+	jint *lparg2=NULL;
+	jboolean rc = 0;
+	GLX_NATIVE_ENTER(env, that, _1glXQueryVersion_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	if (arg2) if ((lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL)) == NULL) goto fail;
+	rc = (jboolean)glXQueryVersion((Display *)arg0, lparg1, lparg2);
+fail:
+	if (arg2 && lparg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
+	if (arg1 && lparg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0);
+	GLX_NATIVE_EXIT(env, that, _1glXQueryVersion_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1glXSwapBuffers
+JNIEXPORT void JNICALL GLX_NATIVE(_1glXSwapBuffers)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	GLX_NATIVE_ENTER(env, that, _1glXSwapBuffers_FUNC);
+	glXSwapBuffers((Display *)arg0, (GLXDrawable)arg1);
+	GLX_NATIVE_EXIT(env, that, _1glXSwapBuffers_FUNC);
+}
+#endif
+
+#ifndef NO__1glXWaitGL
+JNIEXPORT void JNICALL GLX_NATIVE(_1glXWaitGL)
+	(JNIEnv *env, jclass that)
+{
+	GLX_NATIVE_ENTER(env, that, _1glXWaitGL_FUNC);
+	glXWaitGL();
+	GLX_NATIVE_EXIT(env, that, _1glXWaitGL_FUNC);
+}
+#endif
+
+#ifndef NO__1glXWaitX
+JNIEXPORT void JNICALL GLX_NATIVE(_1glXWaitX)
+	(JNIEnv *env, jclass that)
+{
+	GLX_NATIVE_ENTER(env, that, _1glXWaitX_FUNC);
+	glXWaitX();
+	GLX_NATIVE_EXIT(env, that, _1glXWaitX_FUNC);
+}
+#endif
+
+#ifndef NO_memmove
+JNIEXPORT void JNICALL GLX_NATIVE(memmove)
+	(JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2)
+{
+	XVisualInfo _arg0, *lparg0=NULL;
+	GLX_NATIVE_ENTER(env, that, memmove_FUNC);
+	if (arg0) if ((lparg0 = getXVisualInfoFields(env, arg0, &_arg0)) == NULL) goto fail;
+	memmove(lparg0, (const void *)arg1, (size_t)arg2);
+fail:
+	if (arg0 && lparg0) setXVisualInfoFields(env, arg0, lparg0);
+	GLX_NATIVE_EXIT(env, that, memmove_FUNC);
+}
+#endif
+

Added: branches/upstream/swt-gtk/current/glx.h
===================================================================
--- branches/upstream/swt-gtk/current/glx.h	                        (rev 0)
+++ branches/upstream/swt-gtk/current/glx.h	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,19 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+#ifndef SWT_GLX_H_INCLUDED
+#define SWT_GLX_H_INCLUDED
+
+#include <GL/glx.h>
+#include <X11/Xutil.h>
+#include <string.h>
+
+#endif /* SWT_GLX_H_INCLUDED */

Added: branches/upstream/swt-gtk/current/glx_stats.c
===================================================================
--- branches/upstream/swt-gtk/current/glx_stats.c	                        (rev 0)
+++ branches/upstream/swt-gtk/current/glx_stats.c	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+#include "swt.h"
+#include "glx_stats.h"
+
+#ifdef NATIVE_STATS
+
+int GLX_nativeFunctionCount = 23;
+int GLX_nativeFunctionCallCount[23];
+char * GLX_nativeFunctionNames[] = {
+	"XVisualInfo_1sizeof",
+	"_1glGetIntegerv",
+	"_1glViewport",
+	"_1glXChooseVisual",
+	"_1glXCopyContext",
+	"_1glXCreateContext",
+	"_1glXCreateGLXPixmap",
+	"_1glXDestroyContext",
+	"_1glXDestroyGLXPixmap",
+	"_1glXGetClientString",
+	"_1glXGetConfig",
+	"_1glXGetCurrentContext",
+	"_1glXGetCurrentDrawable",
+	"_1glXIsDirect",
+	"_1glXMakeCurrent",
+	"_1glXQueryExtension",
+	"_1glXQueryExtensionsString",
+	"_1glXQueryServerString",
+	"_1glXQueryVersion",
+	"_1glXSwapBuffers",
+	"_1glXWaitGL",
+	"_1glXWaitX",
+	"memmove",
+};
+
+#define STATS_NATIVE(func) Java_org_eclipse_swt_tools_internal_NativeStats_##func
+
+JNIEXPORT jint JNICALL STATS_NATIVE(GLX_1GetFunctionCount)
+	(JNIEnv *env, jclass that)
+{
+	return GLX_nativeFunctionCount;
+}
+
+JNIEXPORT jstring JNICALL STATS_NATIVE(GLX_1GetFunctionName)
+	(JNIEnv *env, jclass that, jint index)
+{
+	return (*env)->NewStringUTF(env, GLX_nativeFunctionNames[index]);
+}
+
+JNIEXPORT jint JNICALL STATS_NATIVE(GLX_1GetFunctionCallCount)
+	(JNIEnv *env, jclass that, jint index)
+{
+	return GLX_nativeFunctionCallCount[index];
+}
+
+#endif

Added: branches/upstream/swt-gtk/current/glx_stats.h
===================================================================
--- branches/upstream/swt-gtk/current/glx_stats.h	                        (rev 0)
+++ branches/upstream/swt-gtk/current/glx_stats.h	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+#ifdef NATIVE_STATS
+extern int GLX_nativeFunctionCount;
+extern int GLX_nativeFunctionCallCount[];
+extern char* GLX_nativeFunctionNames[];
+#define GLX_NATIVE_ENTER(env, that, func) GLX_nativeFunctionCallCount[func]++;
+#define GLX_NATIVE_EXIT(env, that, func) 
+#else
+#ifndef GLX_NATIVE_ENTER
+#define GLX_NATIVE_ENTER(env, that, func) 
+#endif
+#ifndef GLX_NATIVE_EXIT
+#define GLX_NATIVE_EXIT(env, that, func) 
+#endif
+#endif
+
+typedef enum {
+	XVisualInfo_1sizeof_FUNC,
+	_1glGetIntegerv_FUNC,
+	_1glViewport_FUNC,
+	_1glXChooseVisual_FUNC,
+	_1glXCopyContext_FUNC,
+	_1glXCreateContext_FUNC,
+	_1glXCreateGLXPixmap_FUNC,
+	_1glXDestroyContext_FUNC,
+	_1glXDestroyGLXPixmap_FUNC,
+	_1glXGetClientString_FUNC,
+	_1glXGetConfig_FUNC,
+	_1glXGetCurrentContext_FUNC,
+	_1glXGetCurrentDrawable_FUNC,
+	_1glXIsDirect_FUNC,
+	_1glXMakeCurrent_FUNC,
+	_1glXQueryExtension_FUNC,
+	_1glXQueryExtensionsString_FUNC,
+	_1glXQueryServerString_FUNC,
+	_1glXQueryVersion_FUNC,
+	_1glXSwapBuffers_FUNC,
+	_1glXWaitGL_FUNC,
+	_1glXWaitX_FUNC,
+	memmove_FUNC,
+} GLX_FUNCS;

Added: branches/upstream/swt-gtk/current/glx_structs.c
===================================================================
--- branches/upstream/swt-gtk/current/glx_structs.c	                        (rev 0)
+++ branches/upstream/swt-gtk/current/glx_structs.c	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+#include "swt.h"
+#include "glx_structs.h"
+
+#ifndef NO_XVisualInfo
+typedef struct XVisualInfo_FID_CACHE {
+	int cached;
+	jclass clazz;
+	jfieldID visual, visualid, screen, depth, cclass, red_mask, green_mask, blue_mask, colormap_size, bits_per_rgb;
+} XVisualInfo_FID_CACHE;
+
+XVisualInfo_FID_CACHE XVisualInfoFc;
+
+void cacheXVisualInfoFields(JNIEnv *env, jobject lpObject)
+{
+	if (XVisualInfoFc.cached) return;
+	XVisualInfoFc.clazz = (*env)->GetObjectClass(env, lpObject);
+	XVisualInfoFc.visual = (*env)->GetFieldID(env, XVisualInfoFc.clazz, "visual", "I");
+	XVisualInfoFc.visualid = (*env)->GetFieldID(env, XVisualInfoFc.clazz, "visualid", "I");
+	XVisualInfoFc.screen = (*env)->GetFieldID(env, XVisualInfoFc.clazz, "screen", "I");
+	XVisualInfoFc.depth = (*env)->GetFieldID(env, XVisualInfoFc.clazz, "depth", "I");
+	XVisualInfoFc.cclass = (*env)->GetFieldID(env, XVisualInfoFc.clazz, "cclass", "I");
+	XVisualInfoFc.red_mask = (*env)->GetFieldID(env, XVisualInfoFc.clazz, "red_mask", "I");
+	XVisualInfoFc.green_mask = (*env)->GetFieldID(env, XVisualInfoFc.clazz, "green_mask", "I");
+	XVisualInfoFc.blue_mask = (*env)->GetFieldID(env, XVisualInfoFc.clazz, "blue_mask", "I");
+	XVisualInfoFc.colormap_size = (*env)->GetFieldID(env, XVisualInfoFc.clazz, "colormap_size", "I");
+	XVisualInfoFc.bits_per_rgb = (*env)->GetFieldID(env, XVisualInfoFc.clazz, "bits_per_rgb", "I");
+	XVisualInfoFc.cached = 1;
+}
+
+XVisualInfo *getXVisualInfoFields(JNIEnv *env, jobject lpObject, XVisualInfo *lpStruct)
+{
+	if (!XVisualInfoFc.cached) cacheXVisualInfoFields(env, lpObject);
+	lpStruct->visual = (Visual *)(*env)->GetIntField(env, lpObject, XVisualInfoFc.visual);
+	lpStruct->visualid = (*env)->GetIntField(env, lpObject, XVisualInfoFc.visualid);
+	lpStruct->screen = (*env)->GetIntField(env, lpObject, XVisualInfoFc.screen);
+	lpStruct->depth = (*env)->GetIntField(env, lpObject, XVisualInfoFc.depth);
+	lpStruct->class = (*env)->GetIntField(env, lpObject, XVisualInfoFc.cclass);
+	lpStruct->red_mask = (*env)->GetIntField(env, lpObject, XVisualInfoFc.red_mask);
+	lpStruct->green_mask = (*env)->GetIntField(env, lpObject, XVisualInfoFc.green_mask);
+	lpStruct->blue_mask = (*env)->GetIntField(env, lpObject, XVisualInfoFc.blue_mask);
+	lpStruct->colormap_size = (*env)->GetIntField(env, lpObject, XVisualInfoFc.colormap_size);
+	lpStruct->bits_per_rgb = (*env)->GetIntField(env, lpObject, XVisualInfoFc.bits_per_rgb);
+	return lpStruct;
+}
+
+void setXVisualInfoFields(JNIEnv *env, jobject lpObject, XVisualInfo *lpStruct)
+{
+	if (!XVisualInfoFc.cached) cacheXVisualInfoFields(env, lpObject);
+	(*env)->SetIntField(env, lpObject, XVisualInfoFc.visual, (jint)lpStruct->visual);
+	(*env)->SetIntField(env, lpObject, XVisualInfoFc.visualid, (jint)lpStruct->visualid);
+	(*env)->SetIntField(env, lpObject, XVisualInfoFc.screen, (jint)lpStruct->screen);
+	(*env)->SetIntField(env, lpObject, XVisualInfoFc.depth, (jint)lpStruct->depth);
+	(*env)->SetIntField(env, lpObject, XVisualInfoFc.cclass, (jint)lpStruct->class);
+	(*env)->SetIntField(env, lpObject, XVisualInfoFc.red_mask, (jint)lpStruct->red_mask);
+	(*env)->SetIntField(env, lpObject, XVisualInfoFc.green_mask, (jint)lpStruct->green_mask);
+	(*env)->SetIntField(env, lpObject, XVisualInfoFc.blue_mask, (jint)lpStruct->blue_mask);
+	(*env)->SetIntField(env, lpObject, XVisualInfoFc.colormap_size, (jint)lpStruct->colormap_size);
+	(*env)->SetIntField(env, lpObject, XVisualInfoFc.bits_per_rgb, (jint)lpStruct->bits_per_rgb);
+}
+#endif
+

Added: branches/upstream/swt-gtk/current/glx_structs.h
===================================================================
--- branches/upstream/swt-gtk/current/glx_structs.h	                        (rev 0)
+++ branches/upstream/swt-gtk/current/glx_structs.h	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+#include "glx.h"
+
+#ifndef NO_XVisualInfo
+void cacheXVisualInfoFields(JNIEnv *env, jobject lpObject);
+XVisualInfo *getXVisualInfoFields(JNIEnv *env, jobject lpObject, XVisualInfo *lpStruct);
+void setXVisualInfoFields(JNIEnv *env, jobject lpObject, XVisualInfo *lpStruct);
+#define XVisualInfo_sizeof() sizeof(XVisualInfo)
+#else
+#define cacheXVisualInfoFields(a,b)
+#define getXVisualInfoFields(a,b,c) NULL
+#define setXVisualInfoFields(a,b,c)
+#define XVisualInfo_sizeof() 0
+#endif
+

Added: branches/upstream/swt-gtk/current/gnome.c
===================================================================
--- branches/upstream/swt-gtk/current/gnome.c	                        (rev 0)
+++ branches/upstream/swt-gtk/current/gnome.c	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,362 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 IBM Corporation and others. All rights reserved.
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt).  The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html.  If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+#include "swt.h"
+#include "gnome_structs.h"
+#include "gnome_stats.h"
+
+#define GNOME_NATIVE(func) Java_org_eclipse_swt_internal_gnome_GNOME_##func
+
+#ifndef NO_GnomeVFSMimeApplication_1sizeof
+JNIEXPORT jint JNICALL GNOME_NATIVE(GnomeVFSMimeApplication_1sizeof)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	GNOME_NATIVE_ENTER(env, that, GnomeVFSMimeApplication_1sizeof_FUNC);
+	rc = (jint)GnomeVFSMimeApplication_sizeof();
+	GNOME_NATIVE_EXIT(env, that, GnomeVFSMimeApplication_1sizeof_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1g_1free
+JNIEXPORT void JNICALL GNOME_NATIVE(_1g_1free)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	GNOME_NATIVE_ENTER(env, that, _1g_1free_FUNC);
+	g_free((gpointer)arg0);
+	GNOME_NATIVE_EXIT(env, that, _1g_1free_FUNC);
+}
+#endif
+
+#ifndef NO__1g_1list_1append
+JNIEXPORT jint JNICALL GNOME_NATIVE(_1g_1list_1append)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	jint rc = 0;
+	GNOME_NATIVE_ENTER(env, that, _1g_1list_1append_FUNC);
+	rc = (jint)g_list_append((GList *)arg0, (gpointer)arg1);
+	GNOME_NATIVE_EXIT(env, that, _1g_1list_1append_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1g_1list_1free
+JNIEXPORT void JNICALL GNOME_NATIVE(_1g_1list_1free)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	GNOME_NATIVE_ENTER(env, that, _1g_1list_1free_FUNC);
+	g_list_free((GList *)arg0);
+	GNOME_NATIVE_EXIT(env, that, _1g_1list_1free_FUNC);
+}
+#endif
+
+#ifndef NO__1g_1list_1next
+JNIEXPORT jint JNICALL GNOME_NATIVE(_1g_1list_1next)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	GNOME_NATIVE_ENTER(env, that, _1g_1list_1next_FUNC);
+	rc = (jint)g_list_next(arg0);
+	GNOME_NATIVE_EXIT(env, that, _1g_1list_1next_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1g_1object_1unref
+JNIEXPORT void JNICALL GNOME_NATIVE(_1g_1object_1unref)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	GNOME_NATIVE_ENTER(env, that, _1g_1object_1unref_FUNC);
+	g_object_unref((gpointer)arg0);
+	GNOME_NATIVE_EXIT(env, that, _1g_1object_1unref_FUNC);
+}
+#endif
+
+#ifndef NO__1gnome_1icon_1lookup
+JNIEXPORT jint JNICALL GNOME_NATIVE(_1gnome_1icon_1lookup)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jbyteArray arg2, jbyteArray arg3, jint arg4, jbyteArray arg5, jint arg6, jintArray arg7)
+{
+	jbyte *lparg2=NULL;
+	jbyte *lparg3=NULL;
+	jbyte *lparg5=NULL;
+	jint *lparg7=NULL;
+	jint rc = 0;
+	GNOME_NATIVE_ENTER(env, that, _1gnome_1icon_1lookup_FUNC);
+	if (arg2) if ((lparg2 = (*env)->GetByteArrayElements(env, arg2, NULL)) == NULL) goto fail;
+	if (arg3) if ((lparg3 = (*env)->GetByteArrayElements(env, arg3, NULL)) == NULL) goto fail;
+	if (arg5) if ((lparg5 = (*env)->GetByteArrayElements(env, arg5, NULL)) == NULL) goto fail;
+	if (arg7) if ((lparg7 = (*env)->GetIntArrayElements(env, arg7, NULL)) == NULL) goto fail;
+	rc = (jint)gnome_icon_lookup((GnomeIconTheme *)arg0, (GnomeThumbnailFactory *)arg1, (const char *)lparg2, (const char *)lparg3, (GnomeVFSFileInfo *)arg4, (const char *)lparg5, (GnomeIconLookupFlags)arg6, (GnomeIconLookupResultFlags *)lparg7);
+fail:
+	if (arg7 && lparg7) (*env)->ReleaseIntArrayElements(env, arg7, lparg7, 0);
+	if (arg5 && lparg5) (*env)->ReleaseByteArrayElements(env, arg5, lparg5, 0);
+	if (arg3 && lparg3) (*env)->ReleaseByteArrayElements(env, arg3, lparg3, 0);
+	if (arg2 && lparg2) (*env)->ReleaseByteArrayElements(env, arg2, lparg2, 0);
+	GNOME_NATIVE_EXIT(env, that, _1gnome_1icon_1lookup_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gnome_1icon_1theme_1lookup_1icon
+JNIEXPORT jint JNICALL GNOME_NATIVE(_1gnome_1icon_1theme_1lookup_1icon)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jintArray arg3, jintArray arg4)
+{
+	jint *lparg3=NULL;
+	jint *lparg4=NULL;
+	jint rc = 0;
+	GNOME_NATIVE_ENTER(env, that, _1gnome_1icon_1theme_1lookup_1icon_FUNC);
+	if (arg3) if ((lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL)) == NULL) goto fail;
+	if (arg4) if ((lparg4 = (*env)->GetIntArrayElements(env, arg4, NULL)) == NULL) goto fail;
+	rc = (jint)gnome_icon_theme_lookup_icon((GnomeIconTheme *)arg0, (const char *)arg1, arg2, (const GnomeIconData **)lparg3, lparg4);
+fail:
+	if (arg4 && lparg4) (*env)->ReleaseIntArrayElements(env, arg4, lparg4, 0);
+	if (arg3 && lparg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0);
+	GNOME_NATIVE_EXIT(env, that, _1gnome_1icon_1theme_1lookup_1icon_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gnome_1icon_1theme_1new
+JNIEXPORT jint JNICALL GNOME_NATIVE(_1gnome_1icon_1theme_1new)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	GNOME_NATIVE_ENTER(env, that, _1gnome_1icon_1theme_1new_FUNC);
+	rc = (jint)gnome_icon_theme_new();
+	GNOME_NATIVE_EXIT(env, that, _1gnome_1icon_1theme_1new_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gnome_1vfs_1get_1registered_1mime_1types
+JNIEXPORT jint JNICALL GNOME_NATIVE(_1gnome_1vfs_1get_1registered_1mime_1types)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	GNOME_NATIVE_ENTER(env, that, _1gnome_1vfs_1get_1registered_1mime_1types_FUNC);
+	rc = (jint)gnome_vfs_get_registered_mime_types();
+	GNOME_NATIVE_EXIT(env, that, _1gnome_1vfs_1get_1registered_1mime_1types_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gnome_1vfs_1init
+JNIEXPORT jboolean JNICALL GNOME_NATIVE(_1gnome_1vfs_1init)
+	(JNIEnv *env, jclass that)
+{
+	jboolean rc = 0;
+	GNOME_NATIVE_ENTER(env, that, _1gnome_1vfs_1init_FUNC);
+	rc = (jboolean)gnome_vfs_init();
+	GNOME_NATIVE_EXIT(env, that, _1gnome_1vfs_1init_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gnome_1vfs_1make_1uri_1from_1input
+JNIEXPORT jint JNICALL GNOME_NATIVE(_1gnome_1vfs_1make_1uri_1from_1input)
+	(JNIEnv *env, jclass that, jbyteArray arg0)
+{
+	jbyte *lparg0=NULL;
+	jint rc = 0;
+	GNOME_NATIVE_ENTER(env, that, _1gnome_1vfs_1make_1uri_1from_1input_FUNC);
+	if (arg0) if ((lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL)) == NULL) goto fail;
+	rc = (jint)gnome_vfs_make_uri_from_input((const char *)lparg0);
+fail:
+	if (arg0 && lparg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
+	GNOME_NATIVE_EXIT(env, that, _1gnome_1vfs_1make_1uri_1from_1input_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gnome_1vfs_1make_1uri_1from_1input_1with_1dirs
+JNIEXPORT jint JNICALL GNOME_NATIVE(_1gnome_1vfs_1make_1uri_1from_1input_1with_1dirs)
+	(JNIEnv *env, jclass that, jbyteArray arg0, jint arg1)
+{
+	jbyte *lparg0=NULL;
+	jint rc = 0;
+	GNOME_NATIVE_ENTER(env, that, _1gnome_1vfs_1make_1uri_1from_1input_1with_1dirs_FUNC);
+	if (arg0) if ((lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL)) == NULL) goto fail;
+/*
+	rc = (jint)gnome_vfs_make_uri_from_input_with_dirs((const char *)lparg0, arg1);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jint (*FPTR)(const char *, jint);
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gnome_vfs_make_uri_from_input_with_dirs_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gnome_vfs_make_uri_from_input_with_dirs");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jint)(*fptr)((const char *)lparg0, arg1);
+		}
+	}
+fail:
+	if (arg0 && lparg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
+	GNOME_NATIVE_EXIT(env, that, _1gnome_1vfs_1make_1uri_1from_1input_1with_1dirs_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gnome_1vfs_1mime_1application_1free
+JNIEXPORT void JNICALL GNOME_NATIVE(_1gnome_1vfs_1mime_1application_1free)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	GNOME_NATIVE_ENTER(env, that, _1gnome_1vfs_1mime_1application_1free_FUNC);
+	gnome_vfs_mime_application_free((GnomeVFSMimeApplication *)arg0);
+	GNOME_NATIVE_EXIT(env, that, _1gnome_1vfs_1mime_1application_1free_FUNC);
+}
+#endif
+
+#ifndef NO__1gnome_1vfs_1mime_1application_1launch
+JNIEXPORT jint JNICALL GNOME_NATIVE(_1gnome_1vfs_1mime_1application_1launch)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	jint rc = 0;
+	GNOME_NATIVE_ENTER(env, that, _1gnome_1vfs_1mime_1application_1launch_FUNC);
+/*
+	rc = (jint)gnome_vfs_mime_application_launch((GnomeVFSMimeApplication *)arg0, (GList *)arg1);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jint (*FPTR)(GnomeVFSMimeApplication *, GList *);
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gnome_vfs_mime_application_launch_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gnome_vfs_mime_application_launch");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jint)(*fptr)((GnomeVFSMimeApplication *)arg0, (GList *)arg1);
+		}
+	}
+	GNOME_NATIVE_EXIT(env, that, _1gnome_1vfs_1mime_1application_1launch_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gnome_1vfs_1mime_1extensions_1list_1free
+JNIEXPORT void JNICALL GNOME_NATIVE(_1gnome_1vfs_1mime_1extensions_1list_1free)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	GNOME_NATIVE_ENTER(env, that, _1gnome_1vfs_1mime_1extensions_1list_1free_FUNC);
+	gnome_vfs_mime_extensions_list_free((GList *)arg0);
+	GNOME_NATIVE_EXIT(env, that, _1gnome_1vfs_1mime_1extensions_1list_1free_FUNC);
+}
+#endif
+
+#ifndef NO__1gnome_1vfs_1mime_1get_1default_1application
+JNIEXPORT jint JNICALL GNOME_NATIVE(_1gnome_1vfs_1mime_1get_1default_1application)
+	(JNIEnv *env, jclass that, jbyteArray arg0)
+{
+	jbyte *lparg0=NULL;
+	jint rc = 0;
+	GNOME_NATIVE_ENTER(env, that, _1gnome_1vfs_1mime_1get_1default_1application_FUNC);
+	if (arg0) if ((lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL)) == NULL) goto fail;
+	rc = (jint)gnome_vfs_mime_get_default_application((const char *)lparg0);
+fail:
+	if (arg0 && lparg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
+	GNOME_NATIVE_EXIT(env, that, _1gnome_1vfs_1mime_1get_1default_1application_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gnome_1vfs_1mime_1get_1extensions_1list
+JNIEXPORT jint JNICALL GNOME_NATIVE(_1gnome_1vfs_1mime_1get_1extensions_1list)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	GNOME_NATIVE_ENTER(env, that, _1gnome_1vfs_1mime_1get_1extensions_1list_FUNC);
+	rc = (jint)gnome_vfs_mime_get_extensions_list((const char *)arg0);
+	GNOME_NATIVE_EXIT(env, that, _1gnome_1vfs_1mime_1get_1extensions_1list_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gnome_1vfs_1mime_1registered_1mime_1type_1list_1free
+JNIEXPORT void JNICALL GNOME_NATIVE(_1gnome_1vfs_1mime_1registered_1mime_1type_1list_1free)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	GNOME_NATIVE_ENTER(env, that, _1gnome_1vfs_1mime_1registered_1mime_1type_1list_1free_FUNC);
+	gnome_vfs_mime_registered_mime_type_list_free((GList *)arg0);
+	GNOME_NATIVE_EXIT(env, that, _1gnome_1vfs_1mime_1registered_1mime_1type_1list_1free_FUNC);
+}
+#endif
+
+#ifndef NO__1gnome_1vfs_1mime_1type_1from_1name
+JNIEXPORT jint JNICALL GNOME_NATIVE(_1gnome_1vfs_1mime_1type_1from_1name)
+	(JNIEnv *env, jclass that, jbyteArray arg0)
+{
+	jbyte *lparg0=NULL;
+	jint rc = 0;
+	GNOME_NATIVE_ENTER(env, that, _1gnome_1vfs_1mime_1type_1from_1name_FUNC);
+	if (arg0) if ((lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL)) == NULL) goto fail;
+	rc = (jint)gnome_vfs_mime_type_from_name((const char *)lparg0);
+fail:
+	if (arg0 && lparg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
+	GNOME_NATIVE_EXIT(env, that, _1gnome_1vfs_1mime_1type_1from_1name_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gnome_1vfs_1url_1show
+JNIEXPORT jint JNICALL GNOME_NATIVE(_1gnome_1vfs_1url_1show)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	GNOME_NATIVE_ENTER(env, that, _1gnome_1vfs_1url_1show_FUNC);
+/*
+	rc = (jint)gnome_vfs_url_show((const char *)arg0);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jint (*FPTR)(const char *);
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gnome_vfs_url_show_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gnome_vfs_url_show");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jint)(*fptr)((const char *)arg0);
+		}
+	}
+	GNOME_NATIVE_EXIT(env, that, _1gnome_1vfs_1url_1show_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_memmove
+JNIEXPORT void JNICALL GNOME_NATIVE(memmove)
+	(JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2)
+{
+	GnomeVFSMimeApplication _arg0, *lparg0=NULL;
+	GNOME_NATIVE_ENTER(env, that, memmove_FUNC);
+	if (arg0) if ((lparg0 = &_arg0) == NULL) goto fail;
+	memmove((void *)lparg0, (const void *)arg1, (size_t)arg2);
+fail:
+	if (arg0 && lparg0) setGnomeVFSMimeApplicationFields(env, arg0, lparg0);
+	GNOME_NATIVE_EXIT(env, that, memmove_FUNC);
+}
+#endif
+

Added: branches/upstream/swt-gtk/current/gnome.h
===================================================================
--- branches/upstream/swt-gtk/current/gnome.h	                        (rev 0)
+++ branches/upstream/swt-gtk/current/gnome.h	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,35 @@
+/*******************************************************************************
+* Copyright (c) 2000, 2005 IBM Corporation and others. All rights reserved.
+* The contents of this file are made available under the terms
+* of the GNU Lesser General Public License (LGPL) Version 2.1 that
+* accompanies this distribution (lgpl-v21.txt).  The LGPL is also
+* available at http://www.gnu.org/licenses/lgpl.html.  If the version
+* of the LGPL at http://www.gnu.org is different to the version of
+* the LGPL accompanying this distribution and there is any conflict
+* between the two license versions, the terms of the LGPL accompanying
+* this distribution shall govern.
+* 
+* Contributors:
+*     IBM Corporation - initial API and implementation
+*******************************************************************************/
+
+#ifndef INC_gnome_H
+#define INC_gnome_H
+
+#include <string.h>
+#include <stdio.h>
+#include <assert.h>
+#include <dlfcn.h>
+#include <libgnome/libgnome.h>
+#include <libgnome/gnome-program.h>
+#include <libgnomeui/libgnomeui.h>
+#include <libgnomevfs/gnome-vfs.h>
+#include <libgnomevfs/gnome-vfs-mime.h>
+#include <libgnomevfs/gnome-vfs-mime-handlers.h>
+#include <libgnomevfs/gnome-vfs-mime-info.h>
+
+#define gnome_vfs_url_show_LIB "libgnomevfs-2.so.0"
+#define gnome_vfs_make_uri_from_input_with_dirs_LIB "libgnomevfs-2.so.0"
+#define gnome_vfs_mime_application_launch_LIB "libgnomevfs-2.so.0"
+
+#endif

Added: branches/upstream/swt-gtk/current/gnome_stats.c
===================================================================
--- branches/upstream/swt-gtk/current/gnome_stats.c	                        (rev 0)
+++ branches/upstream/swt-gtk/current/gnome_stats.c	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 IBM Corporation and others. All rights reserved.
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt).  The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html.  If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+#include "swt.h"
+#include "gnome_stats.h"
+
+#ifdef NATIVE_STATS
+
+int GNOME_nativeFunctionCount = 22;
+int GNOME_nativeFunctionCallCount[22];
+char * GNOME_nativeFunctionNames[] = {
+	"GnomeVFSMimeApplication_1sizeof",
+	"_1g_1free",
+	"_1g_1list_1append",
+	"_1g_1list_1free",
+	"_1g_1list_1next",
+	"_1g_1object_1unref",
+	"_1gnome_1icon_1lookup",
+	"_1gnome_1icon_1theme_1lookup_1icon",
+	"_1gnome_1icon_1theme_1new",
+	"_1gnome_1vfs_1get_1registered_1mime_1types",
+	"_1gnome_1vfs_1init",
+	"_1gnome_1vfs_1make_1uri_1from_1input",
+	"_1gnome_1vfs_1make_1uri_1from_1input_1with_1dirs",
+	"_1gnome_1vfs_1mime_1application_1free",
+	"_1gnome_1vfs_1mime_1application_1launch",
+	"_1gnome_1vfs_1mime_1extensions_1list_1free",
+	"_1gnome_1vfs_1mime_1get_1default_1application",
+	"_1gnome_1vfs_1mime_1get_1extensions_1list",
+	"_1gnome_1vfs_1mime_1registered_1mime_1type_1list_1free",
+	"_1gnome_1vfs_1mime_1type_1from_1name",
+	"_1gnome_1vfs_1url_1show",
+	"memmove",
+};
+
+#define STATS_NATIVE(func) Java_org_eclipse_swt_tools_internal_NativeStats_##func
+
+JNIEXPORT jint JNICALL STATS_NATIVE(GNOME_1GetFunctionCount)
+	(JNIEnv *env, jclass that)
+{
+	return GNOME_nativeFunctionCount;
+}
+
+JNIEXPORT jstring JNICALL STATS_NATIVE(GNOME_1GetFunctionName)
+	(JNIEnv *env, jclass that, jint index)
+{
+	return (*env)->NewStringUTF(env, GNOME_nativeFunctionNames[index]);
+}
+
+JNIEXPORT jint JNICALL STATS_NATIVE(GNOME_1GetFunctionCallCount)
+	(JNIEnv *env, jclass that, jint index)
+{
+	return GNOME_nativeFunctionCallCount[index];
+}
+
+#endif

Added: branches/upstream/swt-gtk/current/gnome_stats.h
===================================================================
--- branches/upstream/swt-gtk/current/gnome_stats.h	                        (rev 0)
+++ branches/upstream/swt-gtk/current/gnome_stats.h	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 IBM Corporation and others. All rights reserved.
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt).  The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html.  If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+#ifdef NATIVE_STATS
+extern int GNOME_nativeFunctionCount;
+extern int GNOME_nativeFunctionCallCount[];
+extern char* GNOME_nativeFunctionNames[];
+#define GNOME_NATIVE_ENTER(env, that, func) GNOME_nativeFunctionCallCount[func]++;
+#define GNOME_NATIVE_EXIT(env, that, func) 
+#else
+#ifndef GNOME_NATIVE_ENTER
+#define GNOME_NATIVE_ENTER(env, that, func) 
+#endif
+#ifndef GNOME_NATIVE_EXIT
+#define GNOME_NATIVE_EXIT(env, that, func) 
+#endif
+#endif
+
+typedef enum {
+	GnomeVFSMimeApplication_1sizeof_FUNC,
+	_1g_1free_FUNC,
+	_1g_1list_1append_FUNC,
+	_1g_1list_1free_FUNC,
+	_1g_1list_1next_FUNC,
+	_1g_1object_1unref_FUNC,
+	_1gnome_1icon_1lookup_FUNC,
+	_1gnome_1icon_1theme_1lookup_1icon_FUNC,
+	_1gnome_1icon_1theme_1new_FUNC,
+	_1gnome_1vfs_1get_1registered_1mime_1types_FUNC,
+	_1gnome_1vfs_1init_FUNC,
+	_1gnome_1vfs_1make_1uri_1from_1input_FUNC,
+	_1gnome_1vfs_1make_1uri_1from_1input_1with_1dirs_FUNC,
+	_1gnome_1vfs_1mime_1application_1free_FUNC,
+	_1gnome_1vfs_1mime_1application_1launch_FUNC,
+	_1gnome_1vfs_1mime_1extensions_1list_1free_FUNC,
+	_1gnome_1vfs_1mime_1get_1default_1application_FUNC,
+	_1gnome_1vfs_1mime_1get_1extensions_1list_FUNC,
+	_1gnome_1vfs_1mime_1registered_1mime_1type_1list_1free_FUNC,
+	_1gnome_1vfs_1mime_1type_1from_1name_FUNC,
+	_1gnome_1vfs_1url_1show_FUNC,
+	memmove_FUNC,
+} GNOME_FUNCS;

Added: branches/upstream/swt-gtk/current/gnome_structs.c
===================================================================
--- branches/upstream/swt-gtk/current/gnome_structs.c	                        (rev 0)
+++ branches/upstream/swt-gtk/current/gnome_structs.c	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 IBM Corporation and others. All rights reserved.
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt).  The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html.  If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+#include "swt.h"
+#include "gnome_structs.h"
+
+#ifndef NO_GnomeVFSMimeApplication
+typedef struct GnomeVFSMimeApplication_FID_CACHE {
+	int cached;
+	jclass clazz;
+	jfieldID id, name, command, can_open_multiple_files, expects_uris, supported_uri_schemes, requires_terminal;
+} GnomeVFSMimeApplication_FID_CACHE;
+
+GnomeVFSMimeApplication_FID_CACHE GnomeVFSMimeApplicationFc;
+
+void cacheGnomeVFSMimeApplicationFields(JNIEnv *env, jobject lpObject)
+{
+	if (GnomeVFSMimeApplicationFc.cached) return;
+	GnomeVFSMimeApplicationFc.clazz = (*env)->GetObjectClass(env, lpObject);
+	GnomeVFSMimeApplicationFc.id = (*env)->GetFieldID(env, GnomeVFSMimeApplicationFc.clazz, "id", "I");
+	GnomeVFSMimeApplicationFc.name = (*env)->GetFieldID(env, GnomeVFSMimeApplicationFc.clazz, "name", "I");
+	GnomeVFSMimeApplicationFc.command = (*env)->GetFieldID(env, GnomeVFSMimeApplicationFc.clazz, "command", "I");
+	GnomeVFSMimeApplicationFc.can_open_multiple_files = (*env)->GetFieldID(env, GnomeVFSMimeApplicationFc.clazz, "can_open_multiple_files", "Z");
+	GnomeVFSMimeApplicationFc.expects_uris = (*env)->GetFieldID(env, GnomeVFSMimeApplicationFc.clazz, "expects_uris", "I");
+	GnomeVFSMimeApplicationFc.supported_uri_schemes = (*env)->GetFieldID(env, GnomeVFSMimeApplicationFc.clazz, "supported_uri_schemes", "I");
+	GnomeVFSMimeApplicationFc.requires_terminal = (*env)->GetFieldID(env, GnomeVFSMimeApplicationFc.clazz, "requires_terminal", "Z");
+	GnomeVFSMimeApplicationFc.cached = 1;
+}
+
+GnomeVFSMimeApplication *getGnomeVFSMimeApplicationFields(JNIEnv *env, jobject lpObject, GnomeVFSMimeApplication *lpStruct)
+{
+	if (!GnomeVFSMimeApplicationFc.cached) cacheGnomeVFSMimeApplicationFields(env, lpObject);
+	lpStruct->id = (char *)(*env)->GetIntField(env, lpObject, GnomeVFSMimeApplicationFc.id);
+	lpStruct->name = (char *)(*env)->GetIntField(env, lpObject, GnomeVFSMimeApplicationFc.name);
+	lpStruct->command = (char *)(*env)->GetIntField(env, lpObject, GnomeVFSMimeApplicationFc.command);
+	lpStruct->can_open_multiple_files = (gboolean)(*env)->GetBooleanField(env, lpObject, GnomeVFSMimeApplicationFc.can_open_multiple_files);
+	lpStruct->expects_uris = (GnomeVFSMimeApplicationArgumentType)(*env)->GetIntField(env, lpObject, GnomeVFSMimeApplicationFc.expects_uris);
+	lpStruct->supported_uri_schemes = (GList *)(*env)->GetIntField(env, lpObject, GnomeVFSMimeApplicationFc.supported_uri_schemes);
+	lpStruct->requires_terminal = (gboolean)(*env)->GetBooleanField(env, lpObject, GnomeVFSMimeApplicationFc.requires_terminal);
+	return lpStruct;
+}
+
+void setGnomeVFSMimeApplicationFields(JNIEnv *env, jobject lpObject, GnomeVFSMimeApplication *lpStruct)
+{
+	if (!GnomeVFSMimeApplicationFc.cached) cacheGnomeVFSMimeApplicationFields(env, lpObject);
+	(*env)->SetIntField(env, lpObject, GnomeVFSMimeApplicationFc.id, (jint)lpStruct->id);
+	(*env)->SetIntField(env, lpObject, GnomeVFSMimeApplicationFc.name, (jint)lpStruct->name);
+	(*env)->SetIntField(env, lpObject, GnomeVFSMimeApplicationFc.command, (jint)lpStruct->command);
+	(*env)->SetBooleanField(env, lpObject, GnomeVFSMimeApplicationFc.can_open_multiple_files, (jboolean)lpStruct->can_open_multiple_files);
+	(*env)->SetIntField(env, lpObject, GnomeVFSMimeApplicationFc.expects_uris, (jint)lpStruct->expects_uris);
+	(*env)->SetIntField(env, lpObject, GnomeVFSMimeApplicationFc.supported_uri_schemes, (jint)lpStruct->supported_uri_schemes);
+	(*env)->SetBooleanField(env, lpObject, GnomeVFSMimeApplicationFc.requires_terminal, (jboolean)lpStruct->requires_terminal);
+}
+#endif
+

Added: branches/upstream/swt-gtk/current/gnome_structs.h
===================================================================
--- branches/upstream/swt-gtk/current/gnome_structs.h	                        (rev 0)
+++ branches/upstream/swt-gtk/current/gnome_structs.h	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 IBM Corporation and others. All rights reserved.
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt).  The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html.  If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+#include "gnome.h"
+
+#ifndef NO_GnomeVFSMimeApplication
+void cacheGnomeVFSMimeApplicationFields(JNIEnv *env, jobject lpObject);
+GnomeVFSMimeApplication *getGnomeVFSMimeApplicationFields(JNIEnv *env, jobject lpObject, GnomeVFSMimeApplication *lpStruct);
+void setGnomeVFSMimeApplicationFields(JNIEnv *env, jobject lpObject, GnomeVFSMimeApplication *lpStruct);
+#define GnomeVFSMimeApplication_sizeof() sizeof(GnomeVFSMimeApplication)
+#else
+#define cacheGnomeVFSMimeApplicationFields(a,b)
+#define getGnomeVFSMimeApplicationFields(a,b,c) NULL
+#define setGnomeVFSMimeApplicationFields(a,b,c)
+#define GnomeVFSMimeApplication_sizeof() 0
+#endif
+

Added: branches/upstream/swt-gtk/current/make_common.mak
===================================================================
--- branches/upstream/swt-gtk/current/make_common.mak	                        (rev 0)
+++ branches/upstream/swt-gtk/current/make_common.mak	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,14 @@
+#*******************************************************************************
+# Copyright (c) 2000, 2008 IBM Corporation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+#     IBM Corporation - initial API and implementation
+#*******************************************************************************
+
+maj_ver=3
+min_ver=452
+comma_ver=3,4,5,2

Added: branches/upstream/swt-gtk/current/make_freebsd.mak
===================================================================
--- branches/upstream/swt-gtk/current/make_freebsd.mak	                        (rev 0)
+++ branches/upstream/swt-gtk/current/make_freebsd.mak	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,293 @@
+#*******************************************************************************
+# Copyright (c) 2000, 2007 IBM Corporation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+#     IBM Corporation - initial API and implementation
+#*******************************************************************************
+
+# Makefile for creating SWT libraries for Linux GTK
+
+include make_common.mak
+
+SWT_VERSION=$(maj_ver)$(min_ver)
+
+# Define the various shared libraries to be build.
+WS_PREFIX = gtk
+SWT_PREFIX = swt
+CDE_PREFIX = swt-cde
+AWT_PREFIX = swt-awt
+SWTPI_PREFIX = swt-pi
+CAIRO_PREFIX = swt-cairo
+ATK_PREFIX = swt-atk
+GNOME_PREFIX = swt-gnome
+MOZILLA_PREFIX = swt-mozilla$(GCC_VERSION)
+XULRUNNER_PREFIX = swt-xulrunner
+XPCOMINIT_PREFIX = swt-xpcominit
+GLX_PREFIX = swt-glx
+
+SWT_LIB = lib$(SWT_PREFIX)-$(WS_PREFIX)-$(SWT_VERSION).so
+CDE_LIB = lib$(CDE_PREFIX)-$(WS_PREFIX)-$(SWT_VERSION).so
+AWT_LIB = lib$(AWT_PREFIX)-$(WS_PREFIX)-$(SWT_VERSION).so
+SWTPI_LIB = lib$(SWTPI_PREFIX)-$(WS_PREFIX)-$(SWT_VERSION).so
+CAIRO_LIB = lib$(CAIRO_PREFIX)-$(WS_PREFIX)-$(SWT_VERSION).so
+ATK_LIB = lib$(ATK_PREFIX)-$(WS_PREFIX)-$(SWT_VERSION).so
+GNOME_LIB = lib$(GNOME_PREFIX)-$(WS_PREFIX)-$(SWT_VERSION).so
+MOZILLA_LIB = lib$(MOZILLA_PREFIX)-$(WS_PREFIX)-$(SWT_VERSION).so
+XULRUNNER_LIB = lib$(XULRUNNER_PREFIX)-$(WS_PREFIX)-$(SWT_VERSION).so
+XPCOMINIT_LIB = lib$(XPCOMINIT_PREFIX)-$(WS_PREFIX)-$(SWT_VERSION).so
+GLX_LIB = lib$(GLX_PREFIX)-$(WS_PREFIX)-$(SWT_VERSION).so
+
+CAIROCFLAGS = `pkg-config --cflags cairo`
+CAIROLIBS = `pkg-config --libs-only-L cairo` -lcairo
+
+# Do not use pkg-config to get libs because it includes unnecessary dependencies (i.e. pangoxft-1.0)
+GTKCFLAGS = `pkg-config --cflags gtk+-2.0`
+GTKLIBS = `pkg-config --libs-only-L gtk+-2.0 gthread-2.0` -lgtk-x11-2.0 -lgthread-2.0 -L/usr/X11R6/lib $(XLIB64) -lXtst
+
+CDE_LIBS = -L$(CDE_HOME)/lib -R$(CDE_HOME)/lib -lXt -lX11 -lDtSvc
+
+AWT_LIBS = -L$(AWT_LIB_PATH) -ljawt -shared
+
+ATKCFLAGS = `pkg-config --cflags atk gtk+-2.0`
+ATKLIBS = `pkg-config --libs-only-L atk gtk+-2.0` -latk-1.0 -lgtk-x11-2.0
+
+GNOMECFLAGS = `pkg-config --cflags gnome-vfs-module-2.0 libgnome-2.0 libgnomeui-2.0`
+GNOMELIBS = `pkg-config --libs-only-L gnome-vfs-module-2.0 libgnome-2.0 libgnomeui-2.0` -lgnomevfs-2 -lgnome-2 -lgnomeui-2
+
+GLXCFLAGS = 
+GLXLIBS = -shared -fPIC -L/usr/X11R6/lib -lGL -lGLU -lm
+
+# Uncomment for Native Stats tool
+#NATIVE_STATS = -DNATIVE_STATS
+
+MOZILLACFLAGS = -O \
+	-DSWT_VERSION=$(SWT_VERSION) \
+	$(NATIVE_STATS) \
+	-DMOZILLA_STRICT_API=1 \
+	-fno-rtti \
+	-fno-exceptions \
+	-Wall \
+	-Wno-non-virtual-dtor \
+	-fPIC \
+	-I. \
+	-I$(JAVA_HOME)/include \
+	-I$(JAVA_HOME)/include/freebsd \
+	${SWT_PTR_CFLAGS}
+MOZILLALIBS = -shared -Wl,--version-script=mozilla_exports -Bsymbolic
+	
+SWT_OBJECTS = swt.o c.o c_stats.o callback.o
+CDE_OBJECTS = swt.o cde.o cde_structs.o cde_stats.o
+AWT_OBJECTS = swt_awt.o
+SWTPI_OBJECTS = swt.o os.o os_structs.o os_custom.o os_stats.o
+CAIRO_OBJECTS = swt.o cairo.o cairo_structs.o cairo_stats.o
+ATK_OBJECTS = swt.o atk.o atk_structs.o atk_custom.o atk_stats.o
+GNOME_OBJECTS = swt.o gnome.o gnome_structs.o gnome_stats.o
+MOZILLA_OBJECTS = swt.o xpcom.o xpcom_custom.o xpcom_structs.o xpcom_stats.o
+XULRUNNER_OBJECTS = swt.o xpcomxul.o xpcomxul_custom.o xpcomxul_structs.o xpcomxul_stats.o xpcomxulglue.o xpcomxulglue_stats.o
+XPCOMINIT_OBJECTS = swt.o xpcominit.o xpcominit_structs.o xpcominit_stats.o
+GLX_OBJECTS = swt.o glx.o glx_structs.o glx_stats.o
+
+CFLAGS = -O -Wall \
+		-DSWT_VERSION=$(SWT_VERSION) \
+		$(NATIVE_STATS) \
+		-DFREEBSD -DGTK \
+		-I$(JAVA_HOME)/include \
+		-I$(JAVA_HOME)/include/freebsd \
+		-fPIC \
+		${SWT_PTR_CFLAGS}
+LIBS = -shared -fPIC
+
+ifndef NO_STRIP
+	AWT_LIBS := $(AWT_LIBS) -s
+	MOZILLALIBS := $(MOZILLALIBS) -s
+	LIBS := $(LIBS) -s
+endif
+
+all: make_swt make_atk make_gnome make_glx
+
+#
+# SWT libs
+#
+make_swt: $(SWT_LIB) $(SWTPI_LIB)
+
+$(SWT_LIB): $(SWT_OBJECTS)
+	$(CC) $(LIBS) -o $(SWT_LIB) $(SWT_OBJECTS)
+
+callback.o: callback.c callback.h
+	$(CC) $(CFLAGS) -DUSE_ASSEMBLER -c callback.c
+
+$(SWTPI_LIB): $(SWTPI_OBJECTS)
+	$(CC) $(LIBS) $(GTKLIBS) -o $(SWTPI_LIB) $(SWTPI_OBJECTS)
+
+swt.o: swt.c swt.h
+	$(CC) $(CFLAGS) -c swt.c
+os.o: os.c os.h swt.h os_custom.h
+	$(CC) $(CFLAGS) $(GTKCFLAGS) -c os.c
+os_structs.o: os_structs.c os_structs.h os.h swt.h
+	$(CC) $(CFLAGS) $(GTKCFLAGS) -c os_structs.c 
+os_custom.o: os_custom.c os_structs.h os.h swt.h
+	$(CC) $(CFLAGS) $(GTKCFLAGS) -c os_custom.c
+os_stats.o: os_stats.c os_structs.h os.h os_stats.h swt.h
+	$(CC) $(CFLAGS) $(GTKCFLAGS) -c os_stats.c
+
+#
+# CAIRO libs
+#
+make_cairo: $(CAIRO_LIB)
+
+$(CAIRO_LIB): $(CAIRO_OBJECTS)
+	$(CC) $(LIBS) $(CAIROLIBS) -o $(CAIRO_LIB) $(CAIRO_OBJECTS)
+
+cairo.o: cairo.c cairo.h swt.h
+	$(CC) $(CFLAGS) $(CAIROCFLAGS) -c cairo.c
+cairo_structs.o: cairo_structs.c cairo_structs.h cairo.h swt.h
+	$(CC) $(CFLAGS) $(CAIROCFLAGS) -c cairo_structs.c
+cairo_stats.o: cairo_stats.c cairo_structs.h cairo.h cairo_stats.h swt.h
+	$(CC) $(CFLAGS) $(CAIROCFLAGS) -c cairo_stats.c
+
+#
+# CDE lib
+#
+
+make_cde: $(CDE_LIB)
+
+$(CDE_LIB): $(CDE_OBJECTS)
+	$(CC) $(LIBS) $(CDE_LIBS) -o $(CDE_LIB) $(CDE_OBJECTS)
+
+#
+# AWT lib
+#
+make_awt:$(AWT_LIB)
+
+$(AWT_LIB): $(AWT_OBJECTS)
+	$(CC) $(AWT_LIBS) -o $(AWT_LIB) $(AWT_OBJECTS)
+
+#
+# Atk lib
+#
+make_atk: $(ATK_LIB)
+
+$(ATK_LIB): $(ATK_OBJECTS)
+	$(CC) $(LIBS) $(ATKLIBS) -o $(ATK_LIB) $(ATK_OBJECTS)
+
+atk.o: atk.c atk.h
+	$(CC) $(CFLAGS) $(ATKCFLAGS) -c atk.c
+atk_structs.o: atk_structs.c atk_structs.h atk.h
+	$(CC) $(CFLAGS) $(ATKCFLAGS) -c atk_structs.c
+atk_custom.o: atk_custom.c atk_structs.h atk.h
+	$(CC) $(CFLAGS) $(ATKCFLAGS) -c atk_custom.c
+atk_stats.o: atk_stats.c atk_structs.h atk_stats.h atk.h
+	$(CC) $(CFLAGS) $(ATKCFLAGS) -c atk_stats.c
+
+#
+# Gnome lib
+#
+make_gnome: $(GNOME_LIB)
+
+$(GNOME_LIB): $(GNOME_OBJECTS)
+	$(CC) $(LIBS) $(GNOMELIBS) -o $(GNOME_LIB) $(GNOME_OBJECTS)
+
+gnome.o: gnome.c 
+	$(CC) $(CFLAGS) $(GNOMECFLAGS) -c gnome.c
+
+gnome_structs.o: gnome_structs.c 
+	$(CC) $(CFLAGS) $(GNOMECFLAGS) -c gnome_structs.c
+	
+gnome_stats.o: gnome_stats.c gnome_stats.h
+	$(CC) $(CFLAGS) $(GNOMECFLAGS) -c gnome_stats.c
+
+#
+# Mozilla lib
+#
+make_mozilla:$(MOZILLA_LIB)
+
+$(MOZILLA_LIB): $(MOZILLA_OBJECTS)
+	$(CXX) -o $(MOZILLA_LIB) $(MOZILLA_OBJECTS) $(MOZILLALIBS) ${MOZILLA_LIBS}
+
+xpcom.o: xpcom.cpp
+	$(CXX) $(MOZILLACFLAGS) ${MOZILLA_INCLUDES} -c xpcom.cpp
+
+xpcom_structs.o: xpcom_structs.cpp
+	$(CXX) $(MOZILLACFLAGS) ${MOZILLA_INCLUDES} -c xpcom_structs.cpp
+	
+xpcom_custom.o: xpcom_custom.cpp
+	$(CXX) $(MOZILLACFLAGS) ${MOZILLA_INCLUDES} -c xpcom_custom.cpp
+
+xpcom_stats.o: xpcom_stats.cpp
+	$(CXX) $(MOZILLACFLAGS) ${MOZILLA_INCLUDES} -c xpcom_stats.cpp
+
+#
+# XULRunner lib
+#
+make_xulrunner:$(XULRUNNER_LIB)
+
+$(XULRUNNER_LIB): $(XULRUNNER_OBJECTS)
+	$(CXX) -o $(XULRUNNER_LIB) $(XULRUNNER_OBJECTS) $(MOZILLALIBS) ${XULRUNNER_LIBS}
+
+xpcomxul.o: xpcom.cpp
+	$(CXX) -o xpcomxul.o $(MOZILLACFLAGS) ${XULRUNNER_INCLUDES} -c xpcom.cpp
+
+xpcomxul_structs.o: xpcom_structs.cpp
+	$(CXX) -o xpcomxul_structs.o $(MOZILLACFLAGS) ${XULRUNNER_INCLUDES} -c xpcom_structs.cpp
+	
+xpcomxul_custom.o: xpcom_custom.cpp
+	$(CXX) -o xpcomxul_custom.o $(MOZILLACFLAGS) ${XULRUNNER_INCLUDES} -c xpcom_custom.cpp
+
+xpcomxul_stats.o: xpcom_stats.cpp
+	$(CXX) -o xpcomxul_stats.o $(MOZILLACFLAGS) ${XULRUNNER_INCLUDES} -c xpcom_stats.cpp
+
+xpcomxulglue.o: xpcomglue.cpp
+	$(CXX) -o xpcomxulglue.o $(MOZILLACFLAGS) ${XULRUNNER_INCLUDES} -c xpcomglue.cpp
+
+xpcomxulglue_stats.o: xpcomglue_stats.cpp
+	$(CXX) -o xpcomxulglue_stats.o $(MOZILLACFLAGS) ${XULRUNNER_INCLUDES} -c xpcomglue_stats.cpp
+
+#
+# XPCOMInit lib
+#
+make_xpcominit:$(XPCOMINIT_LIB)
+
+$(XPCOMINIT_LIB): $(XPCOMINIT_OBJECTS)
+	$(CXX) -o $(XPCOMINIT_LIB) $(XPCOMINIT_OBJECTS) $(MOZILLALIBS) ${XULRUNNER_LIBS}
+
+xpcominit.o: xpcominit.cpp
+	$(CXX) $(MOZILLACFLAGS) ${XULRUNNER_INCLUDES} -c xpcominit.cpp
+
+xpcominit_structs.o: xpcominit_structs.cpp
+	$(CXX) $(MOZILLACFLAGS) ${XULRUNNER_INCLUDES} -c xpcominit_structs.cpp
+	
+xpcominit_stats.o: xpcominit_stats.cpp
+	$(CXX) $(MOZILLACFLAGS) ${XULRUNNER_INCLUDES} -c xpcominit_stats.cpp
+
+#
+# GLX lib
+#
+make_glx: $(GLX_LIB)
+
+$(GLX_LIB): $(GLX_OBJECTS)
+	$(CC) $(LIBS) $(GLXLIBS) -o $(GLX_LIB) $(GLX_OBJECTS)
+
+glx.o: glx.c 
+	$(CC) $(CFLAGS) $(GLXCFLAGS) -c glx.c
+
+glx_structs.o: glx_structs.c 
+	$(CC) $(CFLAGS) $(GLXCFLAGS) -c glx_structs.c
+	
+glx_stats.o: glx_stats.c glx_stats.h
+	$(CC) $(CFLAGS) $(GLXCFLAGS) -c glx_stats.c
+
+#
+# Install
+#
+install: all
+	cp *.so $(OUTPUT_DIR)
+
+#
+# Clean
+#
+clean:
+	rm -f *.o *.so

Added: branches/upstream/swt-gtk/current/make_linux.mak
===================================================================
--- branches/upstream/swt-gtk/current/make_linux.mak	                        (rev 0)
+++ branches/upstream/swt-gtk/current/make_linux.mak	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,288 @@
+#*******************************************************************************
+# Copyright (c) 2000, 2007 IBM Corporation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+#     IBM Corporation - initial API and implementation
+#*******************************************************************************
+
+# Makefile for creating SWT libraries for Linux GTK
+
+include make_common.mak
+
+SWT_VERSION=$(maj_ver)$(min_ver)
+
+# Define the various shared libraries to be build.
+WS_PREFIX = gtk
+SWT_PREFIX = swt
+CDE_PREFIX = swt-cde
+AWT_PREFIX = swt-awt
+SWTPI_PREFIX = swt-pi
+CAIRO_PREFIX = swt-cairo
+ATK_PREFIX = swt-atk
+GNOME_PREFIX = swt-gnome
+MOZILLA_PREFIX = swt-mozilla$(GCC_VERSION)
+XULRUNNER_PREFIX = swt-xulrunner
+XPCOMINIT_PREFIX = swt-xpcominit
+GLX_PREFIX = swt-glx
+
+SWT_LIB = lib$(SWT_PREFIX)-$(WS_PREFIX)-$(SWT_VERSION).so
+CDE_LIB = lib$(CDE_PREFIX)-$(WS_PREFIX)-$(SWT_VERSION).so
+AWT_LIB = lib$(AWT_PREFIX)-$(WS_PREFIX)-$(SWT_VERSION).so
+SWTPI_LIB = lib$(SWTPI_PREFIX)-$(WS_PREFIX)-$(SWT_VERSION).so
+CAIRO_LIB = lib$(CAIRO_PREFIX)-$(WS_PREFIX)-$(SWT_VERSION).so
+ATK_LIB = lib$(ATK_PREFIX)-$(WS_PREFIX)-$(SWT_VERSION).so
+GNOME_LIB = lib$(GNOME_PREFIX)-$(WS_PREFIX)-$(SWT_VERSION).so
+MOZILLA_LIB = lib$(MOZILLA_PREFIX)-$(WS_PREFIX)-$(SWT_VERSION).so
+XULRUNNER_LIB = lib$(XULRUNNER_PREFIX)-$(WS_PREFIX)-$(SWT_VERSION).so
+XPCOMINIT_LIB = lib$(XPCOMINIT_PREFIX)-$(WS_PREFIX)-$(SWT_VERSION).so
+GLX_LIB = lib$(GLX_PREFIX)-$(WS_PREFIX)-$(SWT_VERSION).so
+
+CAIROCFLAGS = `pkg-config --cflags cairo`
+CAIROLIBS = `pkg-config --libs-only-L cairo` -lcairo
+
+# Do not use pkg-config to get libs because it includes unnecessary dependencies (i.e. pangoxft-1.0)
+GTKCFLAGS = `pkg-config --cflags gtk+-2.0`
+GTKLIBS = `pkg-config --libs-only-L gtk+-2.0 gthread-2.0` -lgtk-x11-2.0 -lgthread-2.0 -L/usr/X11R6/lib $(XLIB64) -lXtst
+
+CDE_LIBS = -L$(CDE_HOME)/lib -R$(CDE_HOME)/lib -lXt -lX11 -lDtSvc
+
+AWT_LIBS = -L$(AWT_LIB_PATH) -ljawt -shared
+
+ATKCFLAGS = `pkg-config --cflags atk gtk+-2.0`
+ATKLIBS = `pkg-config --libs-only-L atk gtk+-2.0` -latk-1.0 -lgtk-x11-2.0
+
+GNOMECFLAGS = `pkg-config --cflags gnome-vfs-module-2.0 libgnome-2.0 libgnomeui-2.0`
+GNOMELIBS = `pkg-config --libs-only-L gnome-vfs-module-2.0 libgnome-2.0 libgnomeui-2.0` -lgnomevfs-2 -lgnome-2 -lgnomeui-2
+
+GLXCFLAGS = 
+GLXLIBS = -shared -fPIC -L/usr/X11R6/lib -lGL -lGLU -lm
+
+# Uncomment for Native Stats tool
+#NATIVE_STATS = -DNATIVE_STATS
+
+MOZILLACFLAGS = -O \
+	-DSWT_VERSION=$(SWT_VERSION) \
+	$(NATIVE_STATS) \
+	-DMOZILLA_STRICT_API=1 \
+	-fno-rtti \
+	-fno-exceptions \
+	-Wall \
+	-Wno-non-virtual-dtor \
+	-fPIC \
+	-I. \
+	-I$(JAVA_HOME)/include \
+	-I$(JAVA_HOME)/include/linux \
+	${SWT_PTR_CFLAGS}
+MOZILLALIBS = -shared -Wl,--version-script=mozilla_exports -Bsymbolic
+MOZILLAEXCLUDES = -DNO_XPCOMGlueShutdown -DNO_XPCOMGlueStartup
+	
+SWT_OBJECTS = swt.o c.o c_stats.o callback.o
+CDE_OBJECTS = swt.o cde.o cde_structs.o cde_stats.o
+AWT_OBJECTS = swt_awt.o
+SWTPI_OBJECTS = swt.o os.o os_structs.o os_custom.o os_stats.o
+CAIRO_OBJECTS = swt.o cairo.o cairo_structs.o cairo_stats.o
+ATK_OBJECTS = swt.o atk.o atk_structs.o atk_custom.o atk_stats.o
+GNOME_OBJECTS = swt.o gnome.o gnome_structs.o gnome_stats.o
+MOZILLA_OBJECTS = swt.o xpcom.o xpcom_custom.o xpcom_structs.o xpcom_stats.o
+XULRUNNER_OBJECTS = swt.o xpcomxul.o xpcomxul_custom.o xpcomxul_structs.o xpcomxul_stats.o
+XPCOMINIT_OBJECTS = swt.o xpcominit.o xpcominit_structs.o xpcominit_stats.o
+GLX_OBJECTS = swt.o glx.o glx_structs.o glx_stats.o
+
+CFLAGS = -O -Wall \
+		-DSWT_VERSION=$(SWT_VERSION) \
+		$(NATIVE_STATS) \
+		-DLINUX -DGTK \
+		-I$(JAVA_HOME)/include \
+		-I$(JAVA_HOME)/include/linux \
+		-fPIC \
+		${SWT_PTR_CFLAGS}
+LIBS = -shared -fPIC
+
+ifndef NO_STRIP
+	AWT_LIBS := $(AWT_LIBS) -s
+	MOZILLALIBS := $(MOZILLALIBS) -s
+	LIBS := $(LIBS) -s
+endif
+
+all: make_swt make_atk make_gnome make_glx
+
+#
+# SWT libs
+#
+make_swt: $(SWT_LIB) $(SWTPI_LIB)
+
+$(SWT_LIB): $(SWT_OBJECTS)
+	$(CC) $(LIBS) -o $(SWT_LIB) $(SWT_OBJECTS)
+
+callback.o: callback.c callback.h
+	$(CC) $(CFLAGS) -DUSE_ASSEMBLER -c callback.c
+
+$(SWTPI_LIB): $(SWTPI_OBJECTS)
+	$(CC) $(LIBS) $(GTKLIBS) -o $(SWTPI_LIB) $(SWTPI_OBJECTS)
+
+swt.o: swt.c swt.h
+	$(CC) $(CFLAGS) -c swt.c
+os.o: os.c os.h swt.h os_custom.h
+	$(CC) $(CFLAGS) $(GTKCFLAGS) -c os.c
+os_structs.o: os_structs.c os_structs.h os.h swt.h
+	$(CC) $(CFLAGS) $(GTKCFLAGS) -c os_structs.c 
+os_custom.o: os_custom.c os_structs.h os.h swt.h
+	$(CC) $(CFLAGS) $(GTKCFLAGS) -c os_custom.c
+os_stats.o: os_stats.c os_structs.h os.h os_stats.h swt.h
+	$(CC) $(CFLAGS) $(GTKCFLAGS) -c os_stats.c
+
+#
+# CAIRO libs
+#
+make_cairo: $(CAIRO_LIB)
+
+$(CAIRO_LIB): $(CAIRO_OBJECTS)
+	$(CC) $(LIBS) $(CAIROLIBS) -o $(CAIRO_LIB) $(CAIRO_OBJECTS)
+
+cairo.o: cairo.c cairo.h swt.h
+	$(CC) $(CFLAGS) $(CAIROCFLAGS) -c cairo.c
+cairo_structs.o: cairo_structs.c cairo_structs.h cairo.h swt.h
+	$(CC) $(CFLAGS) $(CAIROCFLAGS) -c cairo_structs.c
+cairo_stats.o: cairo_stats.c cairo_structs.h cairo.h cairo_stats.h swt.h
+	$(CC) $(CFLAGS) $(CAIROCFLAGS) -c cairo_stats.c
+
+#
+# CDE lib
+#
+
+make_cde: $(CDE_LIB)
+
+$(CDE_LIB): $(CDE_OBJECTS)
+	$(CC) $(LIBS) $(CDE_LIBS) -o $(CDE_LIB) $(CDE_OBJECTS)
+
+#
+# AWT lib
+#
+make_awt:$(AWT_LIB)
+
+$(AWT_LIB): $(AWT_OBJECTS)
+	$(CC) $(AWT_LIBS) -o $(AWT_LIB) $(AWT_OBJECTS)
+
+#
+# Atk lib
+#
+make_atk: $(ATK_LIB)
+
+$(ATK_LIB): $(ATK_OBJECTS)
+	$(CC) $(LIBS) $(ATKLIBS) -o $(ATK_LIB) $(ATK_OBJECTS)
+
+atk.o: atk.c atk.h
+	$(CC) $(CFLAGS) $(ATKCFLAGS) -c atk.c
+atk_structs.o: atk_structs.c atk_structs.h atk.h
+	$(CC) $(CFLAGS) $(ATKCFLAGS) -c atk_structs.c
+atk_custom.o: atk_custom.c atk_structs.h atk.h
+	$(CC) $(CFLAGS) $(ATKCFLAGS) -c atk_custom.c
+atk_stats.o: atk_stats.c atk_structs.h atk_stats.h atk.h
+	$(CC) $(CFLAGS) $(ATKCFLAGS) -c atk_stats.c
+
+#
+# Gnome lib
+#
+make_gnome: $(GNOME_LIB)
+
+$(GNOME_LIB): $(GNOME_OBJECTS)
+	$(CC) $(LIBS) $(GNOMELIBS) -o $(GNOME_LIB) $(GNOME_OBJECTS)
+
+gnome.o: gnome.c 
+	$(CC) $(CFLAGS) $(GNOMECFLAGS) -c gnome.c
+
+gnome_structs.o: gnome_structs.c 
+	$(CC) $(CFLAGS) $(GNOMECFLAGS) -c gnome_structs.c
+	
+gnome_stats.o: gnome_stats.c gnome_stats.h
+	$(CC) $(CFLAGS) $(GNOMECFLAGS) -c gnome_stats.c
+
+#
+# Mozilla lib
+#
+make_mozilla:$(MOZILLA_LIB)
+
+$(MOZILLA_LIB): $(MOZILLA_OBJECTS)
+	$(CXX) -o $(MOZILLA_LIB) $(MOZILLA_OBJECTS) $(MOZILLALIBS) ${MOZILLA_LIBS}
+
+xpcom.o: xpcom.cpp
+	$(CXX) $(MOZILLACFLAGS) $(MOZILLAEXCLUDES) ${MOZILLA_INCLUDES} -c xpcom.cpp
+
+xpcom_structs.o: xpcom_structs.cpp
+	$(CXX) $(MOZILLACFLAGS) ${MOZILLA_INCLUDES} -c xpcom_structs.cpp
+	
+xpcom_custom.o: xpcom_custom.cpp
+	$(CXX) $(MOZILLACFLAGS) ${MOZILLA_INCLUDES} -c xpcom_custom.cpp
+
+xpcom_stats.o: xpcom_stats.cpp
+	$(CXX) $(MOZILLACFLAGS) ${MOZILLA_INCLUDES} -c xpcom_stats.cpp
+
+#
+# XULRunner lib
+#
+make_xulrunner:$(XULRUNNER_LIB)
+
+$(XULRUNNER_LIB): $(XULRUNNER_OBJECTS)
+	$(CXX) -o $(XULRUNNER_LIB) $(XULRUNNER_OBJECTS) $(MOZILLALIBS) ${XULRUNNER_LIBS}
+
+xpcomxul.o: xpcom.cpp
+	$(CXX) -o xpcomxul.o $(MOZILLACFLAGS) ${XULRUNNER_INCLUDES} -c xpcom.cpp
+
+xpcomxul_structs.o: xpcom_structs.cpp
+	$(CXX) -o xpcomxul_structs.o $(MOZILLACFLAGS) ${XULRUNNER_INCLUDES} -c xpcom_structs.cpp
+	
+xpcomxul_custom.o: xpcom_custom.cpp
+	$(CXX) -o xpcomxul_custom.o $(MOZILLACFLAGS) ${XULRUNNER_INCLUDES} -c xpcom_custom.cpp
+
+xpcomxul_stats.o: xpcom_stats.cpp
+	$(CXX) -o xpcomxul_stats.o $(MOZILLACFLAGS) ${XULRUNNER_INCLUDES} -c xpcom_stats.cpp
+
+#
+# XPCOMInit lib
+#
+make_xpcominit:$(XPCOMINIT_LIB)
+
+$(XPCOMINIT_LIB): $(XPCOMINIT_OBJECTS)
+	$(CXX) -o $(XPCOMINIT_LIB) $(XPCOMINIT_OBJECTS) $(MOZILLALIBS) ${XULRUNNER_LIBS}
+
+xpcominit.o: xpcominit.cpp
+	$(CXX) $(MOZILLACFLAGS) ${XULRUNNER_INCLUDES} -c xpcominit.cpp
+
+xpcominit_structs.o: xpcominit_structs.cpp
+	$(CXX) $(MOZILLACFLAGS) ${XULRUNNER_INCLUDES} -c xpcominit_structs.cpp
+	
+xpcominit_stats.o: xpcominit_stats.cpp
+	$(CXX) $(MOZILLACFLAGS) ${XULRUNNER_INCLUDES} -c xpcominit_stats.cpp
+
+#
+# GLX lib
+#
+make_glx: $(GLX_LIB)
+
+$(GLX_LIB): $(GLX_OBJECTS)
+	$(CC) $(LIBS) $(GLXLIBS) -o $(GLX_LIB) $(GLX_OBJECTS)
+
+glx.o: glx.c 
+	$(CC) $(CFLAGS) $(GLXCFLAGS) -c glx.c
+
+glx_structs.o: glx_structs.c 
+	$(CC) $(CFLAGS) $(GLXCFLAGS) -c glx_structs.c
+	
+glx_stats.o: glx_stats.c glx_stats.h
+	$(CC) $(CFLAGS) $(GLXCFLAGS) -c glx_stats.c
+
+#
+# Install
+#
+install: all
+	cp *.so $(OUTPUT_DIR)
+
+#
+# Clean
+#
+clean:
+	rm -f *.o *.so

Added: branches/upstream/swt-gtk/current/make_solaris.mak
===================================================================
--- branches/upstream/swt-gtk/current/make_solaris.mak	                        (rev 0)
+++ branches/upstream/swt-gtk/current/make_solaris.mak	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,247 @@
+#*******************************************************************************
+# Copyright (c) 2000, 2007 IBM Corporation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+#     IBM Corporation - initial API and implementation
+#*******************************************************************************
+
+# Makefile for creating SWT libraries for Solaris GTK
+
+include make_common.mak
+
+SWT_VERSION=$(maj_ver)$(min_ver)
+
+# Define the various shared libraries to be build.
+WS_PREFIX = gtk
+SWT_PREFIX = swt
+CDE_PREFIX = swt-cde
+AWT_PREFIX = swt-awt
+SWTPI_PREFIX = swt-pi
+CAIRO_PREFIX = swt-cairo
+ATK_PREFIX = swt-atk
+GNOME_PREFIX = swt-gnome
+MOZILLA_PREFIX = swt-mozilla
+GLX_PREFIX = swt-glx
+
+SWT_LIB = lib$(SWT_PREFIX)-$(WS_PREFIX)-$(SWT_VERSION).so
+CDE_LIB = lib$(CDE_PREFIX)-$(WS_PREFIX)-$(SWT_VERSION).so
+AWT_LIB = lib$(AWT_PREFIX)-$(WS_PREFIX)-$(SWT_VERSION).so
+SWTPI_LIB = lib$(SWTPI_PREFIX)-$(WS_PREFIX)-$(SWT_VERSION).so
+CAIRO_LIB = lib$(CAIRO_PREFIX)-$(WS_PREFIX)-$(SWT_VERSION).so
+ATK_LIB = lib$(ATK_PREFIX)-$(WS_PREFIX)-$(SWT_VERSION).so
+GNOME_LIB = lib$(GNOME_PREFIX)-$(WS_PREFIX)-$(SWT_VERSION).so
+MOZILLA_LIB = lib$(MOZILLA_PREFIX)-$(WS_PREFIX)-$(SWT_VERSION).so
+GLX_LIB = lib$(GLX_PREFIX)-$(WS_PREFIX)-$(SWT_VERSION).so
+
+CAIROCFLAGS = `pkg-config --cflags cairo`
+CAIROLIBS = `pkg-config --libs-only-L cairo` -lcairo
+
+# Do not use pkg-config to get libs because it includes unnecessary dependencies (i.e. pangoxft-1.0)
+GTKCFLAGS = `pkg-config --cflags gtk+-2.0`
+GTKLIBS = `pkg-config --libs-only-L gtk+-2.0 gthread-2.0` -lgtk-x11-2.0 -lgthread-2.0 -L/usr/openwin/lib -Wl,-R -Wl,/usr/openwin/lib -lXtst
+
+CDE_LIBS = -L$(CDE_HOME)/lib -R$(CDE_HOME)/lib -lXt -lX11 -lDtSvc
+
+AWT_LIBS = -L$(AWT_LIB_PATH) -ljawt -G -s
+
+ATKCFLAGS = `pkg-config --cflags atk gtk+-2.0`
+ATKLIBS = `pkg-config --libs-only-L atk gtk+-2.0` -latk-1.0 -lgtk-x11-2.0
+
+GNOMECFLAGS = `pkg-config --cflags gnome-vfs-module-2.0 libgnome-2.0 libgnomeui-2.0`
+GNOMELIBS = `pkg-config --libs-only-L gnome-vfs-module-2.0 libgnome-2.0 libgnomeui-2.0` -lgnomevfs-2 -lgnome-2 -lgnomeui-2
+
+GLXCFLAGS = 
+GLXLIBS = -G -K PIC -L/usr/X11R6/lib -lGL -lGLU -lm
+
+# Uncomment for Native Stats tool
+#NATIVE_STATS = -DNATIVE_STATS
+
+MOZILLACFLAGS = -O \
+	-DMOZILLA_STRICT_API=1 \
+	-fno-rtti \
+	-fno-exceptions \
+	-Wall \
+	-DSWT_VERSION=$(SWT_VERSION) $(NATIVE_STATS) \
+	-Wno-non-virtual-dtor \
+	-fPIC \
+	-I. \
+	-I$(MOZILLA_SDK)	\
+	-include $(MOZILLA_SDK)/mozilla-config.h \
+	-I$(MOZILLA_SDK)/nspr/include \
+	-I$(MOZILLA_SDK)/xpcom/include \
+	-I$(MOZILLA_SDK)/string/include \
+	-I$(MOZILLA_SDK)/embed_base/include \
+	-I$(MOZILLA_SDK)/embedstring/include
+MOZILLALIBS = -G -s -Wl,--version-script=mozilla_exports -Bsymbolic \
+	-L$(MOZILLA_SDK)/embedstring/bin -lembedstring \
+	-L$(MOZILLA_SDK)/embed_base/bin -lembed_base_s \
+	-L$(MOZILLA_SDK)/xpcom/bin -lxpcomglue_s -lxpcom \
+	-L$(MOZILLA_SDK)/nspr/bin -lnspr4 -lplds4 -lplc4
+
+SWT_OBJECTS = swt.o c.o c_stats.o callback.o
+CDE_OBJECTS = swt.o cde.o cde_structs.o cde_stats.o
+AWT_OBJECTS = swt_awt.o
+SWTPI_OBJECTS = swt.o os.o os_structs.o os_custom.o os_stats.o
+CAIRO_OBJECTS = swt.o cairo.o cairo_structs.o cairo_stats.o
+ATK_OBJECTS = swt.o atk.o atk_structs.o atk_custom.o atk_stats.o
+GNOME_OBJECTS = swt.o gnome.o gnome_structs.o gnome_stats.o
+MOZILLA_OBJECTS = swt.o xpcom.o xpcom_custom.o xpcom_structs.o xpcom_stats.o
+GLX_OBJECTS = swt.o glx.o glx_structs.o glx_stats.o
+
+CFLAGS = -O \
+		-DSWT_VERSION=$(SWT_VERSION) \
+		$(NATIVE_STATS) \
+		-DSOLARIS -DGTK -DCDE \
+		-I$(JAVA_HOME)/include \
+		-I$(JAVA_HOME)/include/solaris \
+		-K PIC \
+		${SWT_PTR_CFLAGS} \
+		-I$(CDE_HOME)/include
+LIBS = -G -K PIC -s
+
+
+all: make_swt make_atk make_awt make_glx make_cde
+
+#
+# SWT libs
+#
+make_swt: $(SWT_LIB) $(SWTPI_LIB)
+
+$(SWT_LIB): $(SWT_OBJECTS)
+	$(CC) $(LIBS) -o $(SWT_LIB) $(SWT_OBJECTS)
+
+callback.o: callback.c callback.h
+	$(CC) $(CFLAGS) -c callback.c
+
+$(SWTPI_LIB): $(SWTPI_OBJECTS)
+	$(CC) $(LIBS) $(GTKLIBS) -o $(SWTPI_LIB) $(SWTPI_OBJECTS)
+
+swt.o: swt.c swt.h
+	$(CC) $(CFLAGS) -c swt.c
+os.o: os.c os.h swt.h os_custom.h
+	$(CC) $(CFLAGS) $(GTKCFLAGS) -c os.c
+os_structs.o: os_structs.c os_structs.h os.h swt.h
+	$(CC) $(CFLAGS) $(GTKCFLAGS) -c os_structs.c 
+os_custom.o: os_custom.c os_structs.h os.h swt.h
+	$(CC) $(CFLAGS) $(GTKCFLAGS) -c os_custom.c
+os_stats.o: os_stats.c os_structs.h os.h os_stats.h swt.h
+	$(CC) $(CFLAGS) $(GTKCFLAGS) -c os_stats.c
+
+#
+# CAIRO libs
+#
+make_cairo: $(CAIRO_LIB)
+
+$(CAIRO_LIB): $(CAIRO_OBJECTS)
+	$(CC) $(LIBS) $(CAIROLIBS) -o $(CAIRO_LIB) $(CAIRO_OBJECTS)
+
+cairo.o: cairo.c cairo.h swt.h
+	$(CC) $(CFLAGS) $(CAIROCFLAGS) -c cairo.c
+cairo_structs.o: cairo_structs.c cairo_structs.h cairo.h swt.h
+	$(CC) $(CFLAGS) $(CAIROCFLAGS) -c cairo_structs.c
+cairo_stats.o: cairo_stats.c cairo_structs.h cairo.h cairo_stats.h swt.h
+	$(CC) $(CFLAGS) $(CAIROCFLAGS) -c cairo_stats.c
+
+#
+# CDE lib
+#
+
+make_cde: $(CDE_LIB)
+
+$(CDE_LIB): $(CDE_OBJECTS)
+	$(CC) $(LIBS) $(CDE_LIBS) -o $(CDE_LIB) $(CDE_OBJECTS)
+
+#
+# AWT lib
+#
+make_awt:$(AWT_LIB)
+
+$(AWT_LIB): $(AWT_OBJECTS)
+	$(CC) $(AWT_LIBS) -o $(AWT_LIB) $(AWT_OBJECTS)
+
+#
+# Atk lib
+#
+make_atk: $(ATK_LIB)
+
+$(ATK_LIB): $(ATK_OBJECTS)
+	$(CC) $(LIBS) $(ATKLIBS) -o $(ATK_LIB) $(ATK_OBJECTS)
+
+atk.o: atk.c atk.h
+	$(CC) $(CFLAGS) $(ATKCFLAGS) -c atk.c
+atk_structs.o: atk_structs.c atk_structs.h atk.h
+	$(CC) $(CFLAGS) $(ATKCFLAGS) -c atk_structs.c
+atk_custom.o: atk_custom.c atk_structs.h atk.h
+	$(CC) $(CFLAGS) $(ATKCFLAGS) -c atk_custom.c
+atk_stats.o: atk_stats.c atk_structs.h atk_stats.h atk.h
+	$(CC) $(CFLAGS) $(ATKCFLAGS) -c atk_stats.c
+
+#
+# Gnome lib
+#
+make_gnome: $(GNOME_LIB)
+
+$(GNOME_LIB): $(GNOME_OBJECTS)
+	$(CC) $(LIBS) $(GNOMELIBS) -o $(GNOME_LIB) $(GNOME_OBJECTS)
+
+gnome.o: gnome.c 
+	$(CC) $(CFLAGS) $(GNOMECFLAGS) -c gnome.c
+
+gnome_structs.o: gnome_structs.c 
+	$(CC) $(CFLAGS) $(GNOMECFLAGS) -c gnome_structs.c
+	
+gnome_stats.o: gnome_stats.c gnome_stats.h
+	$(CC) $(CFLAGS) $(GNOMECFLAGS) -c gnome_stats.c
+
+#
+# Mozilla lib
+#
+make_mozilla:$(MOZILLA_LIB)
+
+$(MOZILLA_LIB): $(MOZILLA_OBJECTS)
+	$(CXX) -o $(MOZILLA_LIB) $(MOZILLA_OBJECTS) $(MOZILLALIBS)
+
+xpcom.o: xpcom.cpp
+	$(CXX) $(MOZILLACFLAGS) -c xpcom.cpp
+
+xpcom_structs.o: xpcom_structs.cpp
+	$(CXX) $(MOZILLACFLAGS) -c xpcom_structs.cpp
+	
+xpcom_custom.o: xpcom_custom.cpp
+	$(CXX) $(MOZILLACFLAGS) -c xpcom_custom.cpp
+
+xpcom_stats.o: xpcom_stats.cpp
+	$(CXX) $(MOZILLACFLAGS) -c xpcom_stats.cpp	
+
+#
+# GLX lib
+#
+make_glx: $(GLX_LIB)
+
+$(GLX_LIB): $(GLX_OBJECTS)
+	$(CC) $(LIBS) $(GLXLIBS) -o $(GLX_LIB) $(GLX_OBJECTS)
+
+glx.o: glx.c 
+	$(CC) $(CFLAGS) $(GLXCFLAGS) -c glx.c
+
+glx_structs.o: glx_structs.c 
+	$(CC) $(CFLAGS) $(GLXCFLAGS) -c glx_structs.c
+	
+glx_stats.o: glx_stats.c glx_stats.h
+	$(CC) $(CFLAGS) $(GLXCFLAGS) -c glx_stats.c
+
+#
+# Install
+#
+install: all
+	cp *.so $(OUTPUT_DIR)
+
+#
+# Clean
+#
+clean:
+	rm -f *.o *.so

Added: branches/upstream/swt-gtk/current/mozilla_exports
===================================================================
--- branches/upstream/swt-gtk/current/mozilla_exports	                        (rev 0)
+++ branches/upstream/swt-gtk/current/mozilla_exports	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,16 @@
+#*******************************************************************************
+# Copyright (c) 2000, 2005 IBM Corporation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+# 
+# Contributors:
+#     IBM Corporation - initial API and implementation
+#*******************************************************************************
+EXPORTED {
+  global:
+    JNI_OnLoad;
+    Java_org_eclipse_swt*;
+  local: *;
+};

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/SWT.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/SWT.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/SWT.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,3842 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt;
+
+
+import org.eclipse.swt.internal.*;
+
+/**
+ * This class provides access to a small number of SWT system-wide
+ * methods, and in addition defines the public constants provided
+ * by SWT.
+ * <p>
+ * By defining constants like UP and DOWN in a single class, SWT
+ * can share common names and concepts at the same time minimizing
+ * the number of classes, names and constants for the application
+ * programmer.
+ * </p><p>
+ * Note that some of the constants provided by this class represent
+ * optional, appearance related aspects of widgets which are available
+ * either only on some window systems, or for a differing set of
+ * widgets on each window system. These constants are marked
+ * as <em>HINT</em>s. The set of widgets which support a particular
+ * <em>HINT</em> may change from release to release, although we typically
+ * will not withdraw support for a <em>HINT</em> once it is made available.
+ * </p>
+ *
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+ 
+/* NOTE:
+ *   Good javadoc coding style is to put the values of static final 
+ *   constants in the comments. This reinforces the fact that
+ *   consumers are allowed to rely on the value (and they must
+ *   since the values are compiled inline in their code). We
+ *   can <em>not</em> change the values of these constants between
+ *   releases.
+ */
+public class SWT {
+	
+	/* Widget Event Constants */
+	
+	/**
+	 * The null event type (value is 0).
+	 * 
+	 * @since 3.0
+	 */
+	public static final int None = 0;
+	
+	/**
+	 * The key down event type (value is 1).
+	 * 
+	 * @see org.eclipse.swt.widgets.Widget#addListener
+	 * @see org.eclipse.swt.widgets.Display#addFilter
+	 * @see org.eclipse.swt.widgets.Event
+	 * 
+	 * @see org.eclipse.swt.widgets.Control#addKeyListener
+	 * @see org.eclipse.swt.widgets.Tracker#addKeyListener
+	 * @see org.eclipse.swt.events.KeyListener#keyPressed
+	 * @see org.eclipse.swt.events.KeyEvent
+	 */
+	public static final int KeyDown = 1;
+	
+	/**
+	 * The key up event type (value is 2).
+	 * 
+	 * @see org.eclipse.swt.widgets.Widget#addListener
+	 * @see org.eclipse.swt.widgets.Display#addFilter
+	 * @see org.eclipse.swt.widgets.Event
+	 * 
+	 * @see org.eclipse.swt.widgets.Control#addKeyListener
+	 * @see org.eclipse.swt.widgets.Tracker#addKeyListener
+	 * @see org.eclipse.swt.events.KeyListener#keyReleased
+	 * @see org.eclipse.swt.events.KeyEvent
+	 */
+	public static final int KeyUp = 2;
+	
+	/**
+	 * The mouse down event type (value is 3).
+	 * 
+	 * @see org.eclipse.swt.widgets.Widget#addListener
+	 * @see org.eclipse.swt.widgets.Display#addFilter
+	 * @see org.eclipse.swt.widgets.Event
+	 * 
+	 * @see org.eclipse.swt.widgets.Control#addMouseListener
+	 * @see org.eclipse.swt.events.MouseListener#mouseDown
+	 * @see org.eclipse.swt.events.MouseEvent
+	 */
+	public static final int MouseDown = 3;
+	
+	/**
+	 * The mouse up event type (value is 4).
+	 * 
+	 * @see org.eclipse.swt.widgets.Widget#addListener
+	 * @see org.eclipse.swt.widgets.Display#addFilter
+	 * @see org.eclipse.swt.widgets.Event
+	 * 
+	 * @see org.eclipse.swt.widgets.Control#addMouseListener
+	 * @see org.eclipse.swt.events.MouseListener#mouseUp
+	 * @see org.eclipse.swt.events.MouseEvent
+	 */
+	public static final int MouseUp = 4;
+	
+	/**
+	 * The mouse move event type (value is 5).
+	 * 
+	 * @see org.eclipse.swt.widgets.Widget#addListener
+	 * @see org.eclipse.swt.widgets.Display#addFilter
+	 * @see org.eclipse.swt.widgets.Event
+	 * 
+	 * @see org.eclipse.swt.widgets.Control#addMouseMoveListener
+	 * @see org.eclipse.swt.events.MouseMoveListener#mouseMove
+	 * @see org.eclipse.swt.events.MouseEvent
+	 */
+	public static final int MouseMove = 5;
+	
+	/**
+	 * The mouse enter event type (value is 6).
+	 * 
+	 * @see org.eclipse.swt.widgets.Widget#addListener
+	 * @see org.eclipse.swt.widgets.Display#addFilter
+	 * @see org.eclipse.swt.widgets.Event
+	 * 
+	 * @see org.eclipse.swt.widgets.Control#addMouseTrackListener
+	 * @see org.eclipse.swt.events.MouseTrackListener#mouseEnter
+	 * @see org.eclipse.swt.events.MouseEvent
+	 */
+	public static final int MouseEnter = 6;		
+	
+	/**
+	 * The mouse exit event type (value is 7).
+	 * 
+	 * @see org.eclipse.swt.widgets.Widget#addListener
+	 * @see org.eclipse.swt.widgets.Display#addFilter
+	 * @see org.eclipse.swt.widgets.Event
+	 * 
+	 * @see org.eclipse.swt.widgets.Control#addMouseTrackListener
+	 * @see org.eclipse.swt.events.MouseTrackListener#mouseExit
+	 * @see org.eclipse.swt.events.MouseEvent
+	 */
+	public static final int MouseExit = 7;
+	
+	/**
+	 * The mouse double click event type (value is 8).
+	 * 
+	 * @see org.eclipse.swt.widgets.Widget#addListener
+	 * @see org.eclipse.swt.widgets.Display#addFilter
+	 * @see org.eclipse.swt.widgets.Event
+	 * 
+	 * @see org.eclipse.swt.widgets.Control#addMouseListener
+	 * @see org.eclipse.swt.events.MouseListener#mouseDoubleClick
+	 * @see org.eclipse.swt.events.MouseEvent
+	 */
+	public static final int MouseDoubleClick = 8;	
+	
+	/**
+	 * The paint event type (value is 9).
+	 * 
+	 * @see org.eclipse.swt.widgets.Widget#addListener
+	 * @see org.eclipse.swt.widgets.Display#addFilter
+	 * @see org.eclipse.swt.widgets.Event
+	 * 
+	 * @see org.eclipse.swt.widgets.Control#addPaintListener
+	 * @see org.eclipse.swt.events.PaintListener#paintControl
+	 * @see org.eclipse.swt.events.PaintEvent
+	 */
+	public static final int Paint = 9;	
+	
+	/**
+	 * The move event type (value is 10).
+	 * 
+	 * @see org.eclipse.swt.widgets.Widget#addListener
+	 * @see org.eclipse.swt.widgets.Display#addFilter
+	 * @see org.eclipse.swt.widgets.Event
+	 * 
+	 * @see org.eclipse.swt.widgets.Control#addControlListener
+	 * @see org.eclipse.swt.widgets.TableColumn#addControlListener
+	 * @see org.eclipse.swt.widgets.Tracker#addControlListener
+	 * @see org.eclipse.swt.widgets.TreeColumn#addControlListener
+	 * @see org.eclipse.swt.events.ControlListener#controlMoved
+	 * @see org.eclipse.swt.events.ControlEvent
+	 */
+	public static final int Move = 10;
+	
+	/**
+	 * The resize event type (value is 11).
+	 * 
+	 * @see org.eclipse.swt.widgets.Widget#addListener
+	 * @see org.eclipse.swt.widgets.Display#addFilter
+	 * @see org.eclipse.swt.widgets.Event
+	 * 
+	 * @see org.eclipse.swt.widgets.Control#addControlListener
+	 * @see org.eclipse.swt.widgets.TableColumn#addControlListener
+	 * @see org.eclipse.swt.widgets.Tracker#addControlListener
+	 * @see org.eclipse.swt.widgets.TreeColumn#addControlListener
+	 * @see org.eclipse.swt.events.ControlListener#controlResized
+	 * @see org.eclipse.swt.events.ControlEvent
+	 */
+	public static final int Resize = 11;
+	
+	/**
+	 * The dispose event type (value is 12).
+	 * 
+	 * @see org.eclipse.swt.widgets.Widget#addListener
+	 * @see org.eclipse.swt.widgets.Display#addListener
+	 * @see org.eclipse.swt.widgets.Display#addFilter
+	 * @see org.eclipse.swt.widgets.Event
+	 * 
+	 * @see org.eclipse.swt.widgets.Widget#addDisposeListener
+	 * @see org.eclipse.swt.events.DisposeListener#widgetDisposed
+	 * @see org.eclipse.swt.events.DisposeEvent
+	 */
+	public static final int Dispose = 12;
+	
+	/**
+	 * The selection event type (value is 13).
+	 * 
+	 * @see org.eclipse.swt.widgets.Widget#addListener
+	 * @see org.eclipse.swt.widgets.Display#addFilter
+	 * @see org.eclipse.swt.widgets.Event
+	 * 
+	 * @see org.eclipse.swt.widgets.Button#addSelectionListener
+	 * @see org.eclipse.swt.widgets.Combo#addSelectionListener
+	 * @see org.eclipse.swt.widgets.CoolItem#addSelectionListener
+	 * @see org.eclipse.swt.widgets.Link#addSelectionListener
+	 * @see org.eclipse.swt.widgets.List#addSelectionListener
+	 * @see org.eclipse.swt.widgets.MenuItem#addSelectionListener
+	 * @see org.eclipse.swt.widgets.Sash#addSelectionListener
+	 * @see org.eclipse.swt.widgets.Scale#addSelectionListener
+	 * @see org.eclipse.swt.widgets.ScrollBar#addSelectionListener
+	 * @see org.eclipse.swt.widgets.Slider#addSelectionListener
+	 * @see org.eclipse.swt.widgets.TabFolder#addSelectionListener
+	 * @see org.eclipse.swt.widgets.Table#addSelectionListener
+	 * @see org.eclipse.swt.widgets.TableColumn#addSelectionListener
+	 * @see org.eclipse.swt.widgets.ToolItem#addSelectionListener
+	 * @see org.eclipse.swt.widgets.TrayItem#addSelectionListener
+	 * @see org.eclipse.swt.widgets.Tree#addSelectionListener
+	 * @see org.eclipse.swt.widgets.TreeColumn#addSelectionListener
+	 * @see org.eclipse.swt.events.SelectionListener#widgetSelected
+	 * @see org.eclipse.swt.events.SelectionEvent
+	 */
+	public static final int Selection = 13;
+	
+	/**
+	 * The default selection event type (value is 14).
+	 * 
+	 * @see org.eclipse.swt.widgets.Widget#addListener
+	 * @see org.eclipse.swt.widgets.Display#addFilter
+	 * @see org.eclipse.swt.widgets.Event
+	 * 
+	 * @see org.eclipse.swt.widgets.Combo#addSelectionListener
+	 * @see org.eclipse.swt.widgets.List#addSelectionListener
+	 * @see org.eclipse.swt.widgets.Spinner#addSelectionListener
+	 * @see org.eclipse.swt.widgets.Table#addSelectionListener
+	 * @see org.eclipse.swt.widgets.Text#addSelectionListener
+	 * @see org.eclipse.swt.widgets.TrayItem#addSelectionListener
+	 * @see org.eclipse.swt.widgets.Tree#addSelectionListener
+	 * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected
+	 * @see org.eclipse.swt.events.SelectionEvent
+	 */
+	public static final int DefaultSelection = 14;
+	
+	/**
+	 * The focus in event type (value is 15).
+	 * 
+	 * @see org.eclipse.swt.widgets.Widget#addListener
+	 * @see org.eclipse.swt.widgets.Display#addFilter
+	 * @see org.eclipse.swt.widgets.Event
+	 * 
+	 * @see org.eclipse.swt.widgets.Control#addFocusListener
+	 * @see org.eclipse.swt.events.FocusListener#focusGained
+	 * @see org.eclipse.swt.events.FocusEvent
+	 */
+	public static final int FocusIn = 15;
+	
+	/**
+	 * The focus out event type (value is 16).
+	 * 
+	 * @see org.eclipse.swt.widgets.Widget#addListener
+	 * @see org.eclipse.swt.widgets.Display#addFilter
+	 * @see org.eclipse.swt.widgets.Event
+	 * 
+	 * @see org.eclipse.swt.widgets.Control#addFocusListener
+	 * @see org.eclipse.swt.events.FocusListener#focusLost
+	 * @see org.eclipse.swt.events.FocusEvent
+	 */
+	public static final int FocusOut = 16;
+	
+	/**
+	 * The expand event type (value is 17).
+	 * 
+	 * @see org.eclipse.swt.widgets.Widget#addListener
+	 * @see org.eclipse.swt.widgets.Display#addFilter
+	 * @see org.eclipse.swt.widgets.Event
+	 * 
+	 * @see org.eclipse.swt.widgets.Tree#addTreeListener
+	 * @see org.eclipse.swt.events.TreeListener#treeExpanded
+	 * @see org.eclipse.swt.events.TreeEvent
+	 */
+	public static final int Expand = 17;
+	
+	/**
+	 * The collapse event type (value is 18).
+	 * 
+	 * @see org.eclipse.swt.widgets.Widget#addListener
+	 * @see org.eclipse.swt.widgets.Display#addFilter
+	 * @see org.eclipse.swt.widgets.Event
+	 * 
+	 * @see org.eclipse.swt.widgets.Tree#addTreeListener
+	 * @see org.eclipse.swt.events.TreeListener#treeCollapsed
+	 * @see org.eclipse.swt.events.TreeEvent
+	 */
+	public static final int Collapse = 18;
+	
+	/**
+	 * The iconify event type (value is 19).
+	 * 
+	 * @see org.eclipse.swt.widgets.Widget#addListener
+	 * @see org.eclipse.swt.widgets.Display#addFilter
+	 * @see org.eclipse.swt.widgets.Event
+	 * 
+	 * @see org.eclipse.swt.widgets.Shell#addShellListener
+	 * @see org.eclipse.swt.events.ShellListener#shellIconified
+	 * @see org.eclipse.swt.events.ShellEvent
+	 */
+	public static final int Iconify = 19;
+	
+	/**
+	 * The de-iconify event type (value is 20).
+	 * 
+	 * @see org.eclipse.swt.widgets.Widget#addListener
+	 * @see org.eclipse.swt.widgets.Display#addFilter
+	 * @see org.eclipse.swt.widgets.Event
+	 * 
+	 * @see org.eclipse.swt.widgets.Shell#addShellListener
+	 * @see org.eclipse.swt.events.ShellListener#shellDeiconified
+	 * @see org.eclipse.swt.events.ShellEvent
+	 */
+	public static final int Deiconify = 20;
+	
+	/**
+	 * The close event type (value is 21).
+	 * 
+	 * @see org.eclipse.swt.widgets.Widget#addListener
+	 * @see org.eclipse.swt.widgets.Display#addListener
+	 * @see org.eclipse.swt.widgets.Display#addFilter
+	 * @see org.eclipse.swt.widgets.Event
+	 * 
+	 * @see org.eclipse.swt.widgets.Shell#addShellListener
+	 * @see org.eclipse.swt.events.ShellListener#shellClosed
+	 * @see org.eclipse.swt.events.ShellEvent
+	 */
+	public static final int Close = 21;
+	
+	/**
+	 * The show event type (value is 22).
+	 * 
+	 * @see org.eclipse.swt.widgets.Widget#addListener
+	 * @see org.eclipse.swt.widgets.Display#addFilter
+	 * @see org.eclipse.swt.widgets.Event
+	 * 
+	 * @see org.eclipse.swt.widgets.Menu#addMenuListener
+	 * @see org.eclipse.swt.events.MenuListener#menuShown
+	 * @see org.eclipse.swt.events.MenuEvent
+	 */
+	public static final int Show = 22;
+	
+	/**
+	 * The hide event type (value is 23).
+	 * 
+	 * @see org.eclipse.swt.widgets.Widget#addListener
+	 * @see org.eclipse.swt.widgets.Display#addFilter
+	 * @see org.eclipse.swt.widgets.Event
+	 * 
+	 * @see org.eclipse.swt.widgets.Menu#addMenuListener
+	 * @see org.eclipse.swt.events.MenuListener#menuHidden
+	 * @see org.eclipse.swt.events.MenuEvent
+	 */
+	public static final int Hide = 23;
+	
+	/**
+	 * The modify event type (value is 24).
+	 * 
+	 * @see org.eclipse.swt.widgets.Widget#addListener
+	 * @see org.eclipse.swt.widgets.Display#addFilter
+	 * @see org.eclipse.swt.widgets.Event
+	 * 
+	 * @see org.eclipse.swt.widgets.Combo#addModifyListener
+	 * @see org.eclipse.swt.widgets.Spinner#addModifyListener
+	 * @see org.eclipse.swt.widgets.Text#addModifyListener
+	 * @see org.eclipse.swt.events.ModifyListener#modifyText
+	 * @see org.eclipse.swt.events.ModifyEvent
+	 */
+	public static final int Modify = 24;
+	
+	/**
+	 * The verify event type (value is 25).
+	 * 
+	 * @see org.eclipse.swt.widgets.Widget#addListener
+	 * @see org.eclipse.swt.widgets.Display#addFilter
+	 * @see org.eclipse.swt.widgets.Event
+	 * 
+	 * @see org.eclipse.swt.custom.CCombo#addVerifyListener
+	 * @see org.eclipse.swt.widgets.Combo#addVerifyListener
+	 * @see org.eclipse.swt.custom.StyledText#addVerifyListener
+	 * @see org.eclipse.swt.widgets.Text#addVerifyListener
+	 * @see org.eclipse.swt.events.VerifyListener#verifyText
+	 * @see org.eclipse.swt.events.VerifyEvent
+	 */
+	public static final int Verify = 25;
+	
+	/**
+	 * The activate event type (value is 26).
+	 * 
+	 * @see org.eclipse.swt.widgets.Widget#addListener
+	 * @see org.eclipse.swt.widgets.Display#addFilter
+	 * @see org.eclipse.swt.widgets.Event
+	 * 
+	 * @see org.eclipse.swt.widgets.Shell#addShellListener
+	 * @see org.eclipse.swt.events.ShellListener#shellActivated
+	 * @see org.eclipse.swt.events.ShellEvent
+	 */
+	public static final int Activate = 26;
+	
+	/**
+	 * The deactivate event type (value is 27).
+	 * 
+	 * @see org.eclipse.swt.widgets.Widget#addListener
+	 * @see org.eclipse.swt.widgets.Display#addFilter
+	 * @see org.eclipse.swt.widgets.Event
+	 * 
+	 * @see org.eclipse.swt.widgets.Shell#addShellListener
+	 * @see org.eclipse.swt.events.ShellListener#shellDeactivated
+	 * @see org.eclipse.swt.events.ShellEvent
+	 */
+	public static final int Deactivate = 27;	
+	
+	/**
+	 * The help event type (value is 28).
+	 * 
+	 * @see org.eclipse.swt.widgets.Widget#addListener
+	 * @see org.eclipse.swt.widgets.Display#addFilter
+	 * @see org.eclipse.swt.widgets.Event
+	 * 
+	 * @see org.eclipse.swt.widgets.Control#addHelpListener
+	 * @see org.eclipse.swt.widgets.Menu#addHelpListener
+	 * @see org.eclipse.swt.widgets.MenuItem#addHelpListener
+	 * @see org.eclipse.swt.events.HelpListener#helpRequested
+	 * @see org.eclipse.swt.events.HelpEvent
+	 */
+	public static final int Help = 28;
+	
+	/**
+	 * The drag detect event type (value is 29).
+	 * 
+	 * @see org.eclipse.swt.widgets.Widget#addListener
+	 * @see org.eclipse.swt.widgets.Display#addFilter
+	 * @see org.eclipse.swt.widgets.Event
+	 * 
+	 * @see org.eclipse.swt.dnd.DragSource
+	 */
+	public static final int DragDetect = 29;
+	
+	/**
+	 * The arm event type (value is 30).
+	 * 
+	 * @see org.eclipse.swt.widgets.Widget#addListener
+	 * @see org.eclipse.swt.widgets.Display#addFilter
+	 * @see org.eclipse.swt.widgets.Event
+	 * 
+	 * @see org.eclipse.swt.widgets.MenuItem#addArmListener
+	 * @see org.eclipse.swt.events.ArmListener#widgetArmed
+	 * @see org.eclipse.swt.events.ArmEvent
+	 */
+	public static final int Arm = 30;
+	
+	/**
+	 * The traverse event type (value is 31).
+	 * 
+	 * @see org.eclipse.swt.widgets.Widget#addListener
+	 * @see org.eclipse.swt.widgets.Display#addFilter
+	 * @see org.eclipse.swt.widgets.Event
+	 * 
+	 * @see org.eclipse.swt.widgets.Control#addTraverseListener
+	 * @see org.eclipse.swt.events.TraverseListener#keyTraversed
+	 * @see org.eclipse.swt.events.TraverseEvent
+	 */
+	public static final int Traverse = 31;
+	
+	/**
+	 * The mouse hover event type (value is 32).
+	 * 
+	 * @see org.eclipse.swt.widgets.Widget#addListener
+	 * @see org.eclipse.swt.widgets.Display#addFilter
+	 * @see org.eclipse.swt.widgets.Event
+	 * 
+	 * @see org.eclipse.swt.widgets.Control#addMouseTrackListener
+	 * @see org.eclipse.swt.events.MouseTrackListener#mouseHover
+	 * @see org.eclipse.swt.events.MouseEvent
+	 */
+	public static final int MouseHover = 32;
+
+	/**
+	 * The hardware key down event type (value is 33).
+	 * 
+	 * @see org.eclipse.swt.widgets.Widget#addListener
+	 * @see org.eclipse.swt.widgets.Display#addFilter
+	 * @see org.eclipse.swt.widgets.Event
+	 */
+	public static final int HardKeyDown = 33;
+	
+	/**
+	 * The hardware key up event type (value is 34).
+	 * 
+	 * @see org.eclipse.swt.widgets.Widget#addListener
+	 * @see org.eclipse.swt.widgets.Display#addFilter
+	 * @see org.eclipse.swt.widgets.Event
+	 */
+	public static final int HardKeyUp = 34;
+
+	/**
+	 * The menu detect event type (value is 35).
+	 * 
+	 * @see org.eclipse.swt.widgets.Widget#addListener
+	 * @see org.eclipse.swt.widgets.Display#addFilter
+	 * @see org.eclipse.swt.widgets.Event
+	 * 
+	 * @since 3.0
+	 */
+	public static final int MenuDetect = 35;
+	
+	/**
+	 * The set data event type (value is 36).
+	 * 
+	 * @see org.eclipse.swt.widgets.Widget#addListener
+	 * @see org.eclipse.swt.widgets.Display#addFilter
+	 * @see org.eclipse.swt.widgets.Event
+	 * 
+	 * @see org.eclipse.swt.widgets.Table
+	 * @see org.eclipse.swt.widgets.Tree
+	 * 
+	 * @since 3.0
+	 */
+	public static final int SetData = 36;
+
+	/**
+	 * The mouse wheel event type (value is 37).
+	 * 
+	 * @see org.eclipse.swt.widgets.Widget#addListener
+	 * @see org.eclipse.swt.widgets.Display#addFilter
+	 * @see org.eclipse.swt.widgets.Event
+	 * 
+	 * @since 3.1
+	 */
+	public static final int MouseWheel = 37;
+
+	/**
+	 * The settings changed event type (value is 39).
+	 * <p>
+	 * The settings changed event is sent when an operating system
+	 * property, such as a system font or color, has been changed.
+	 * The event occurs after the property has been changed, but
+	 * before any widget is redrawn.  Applications that cache operating
+	 * system properties can use this event to update their caches.
+	 * A specific property change can be detected by querying the
+	 * new value of a property and comparing it with the equivalent
+	 * cached value.  The operating system automatically redraws and
+	 * lays out all widgets after this event is sent.
+	 * </p>
+	 * 
+	 * @see org.eclipse.swt.widgets.Display#addListener
+	 * @see org.eclipse.swt.widgets.Event
+	 * 
+	 * @since 3.2
+	 */
+	public static final int Settings = 39;
+	
+	/**
+	 * The erase item event type (value is 40).
+	 * 
+	 * @see org.eclipse.swt.widgets.Widget#addListener
+	 * @see org.eclipse.swt.widgets.Display#addFilter
+	 * @see org.eclipse.swt.widgets.Event
+	 * 
+	 * @since 3.2
+	 */
+	public static final int EraseItem = 40;
+	
+	/**
+	 * The measure item event type (value is 41).
+	 * 
+	 * @see org.eclipse.swt.widgets.Widget#addListener
+	 * @see org.eclipse.swt.widgets.Display#addFilter
+	 * @see org.eclipse.swt.widgets.Event
+	 * 
+	 * @since 3.2
+	 */
+	public static final int MeasureItem = 41;
+	
+	/**
+	 * The paint item event type (value is 42).
+	 * 
+	 * @see org.eclipse.swt.widgets.Widget#addListener
+	 * @see org.eclipse.swt.widgets.Display#addFilter
+	 * @see org.eclipse.swt.widgets.Event
+	 * 
+	 * @since 3.2
+	 */
+	public static final int PaintItem = 42;	
+	
+	/**
+	 * The IME composition event type (value is 43).  
+	 * <p>
+	 * The IME composition event is sent to allow
+	 * custom text editors to implement in-line
+	 * editing of international text. 
+	 * </p> 
+	 * 
+	 * The detail field indicates the action to be taken:
+	 * <p><ul>
+	 * <li>{@link SWT#COMPOSITION_CHANGED}</li>
+	 * <li>{@link SWT#COMPOSITION_OFFSET}</li>
+	 * <li>{@link SWT#COMPOSITION_SELECTION}</li>
+	 * </ul></p>
+	 * 
+	 * @see org.eclipse.swt.widgets.Widget#addListener
+	 * @see org.eclipse.swt.widgets.Display#addFilter
+	 * @see org.eclipse.swt.widgets.Event
+	 * 
+	 * @since 3.4
+	 */
+	public static final int ImeComposition = 43;
+	
+	/* Event Details */
+	
+	/**
+	 * The IME composition event detail that indicates
+	 * a change in the IME composition. The text field
+	 * of the event is the new composition text. 
+	 * The start and end indicate the offsets where the
+	 * composition text should be inserted.
+	 * The styles and ranges are stored in the IME 
+	 * object (value is 1).
+	 * 
+	 * @see SWT#ImeComposition
+	 * 
+	 * @since 3.4
+	 */
+	public static final int COMPOSITION_CHANGED = 1;
+	
+	/**
+	 * The IME composition event detail that indicates
+	 * that the IME needs the offset for a given location.
+	 * The x and y fields of the event are used by the 
+	 * application to determine the offset.
+	 * 
+	 * The index field of the event should be set to the 
+	 * text offset at that location. The count field should 
+	 * be set to indicate whether the location is closer to
+	 * the leading edge (0) or the trailing edge (1) (value is 2).
+	 * 
+	 * @see SWT#ImeComposition
+	 * @see org.eclipse.swt.graphics.TextLayout#getOffset(int, int, int[])
+	 * 
+	 * @since 3.4
+	 */
+	public static final int COMPOSITION_OFFSET = 2;
+	
+	/**
+	 * The IME composition event detail that indicates
+	 * that IME needs the selected text and its start
+	 * and end offsets (value is 3).
+	 * 
+	 * @see SWT#ImeComposition
+	 * 
+	 * @since 3.4
+	 */
+	public static final int COMPOSITION_SELECTION = 3;
+
+	/**
+	 * Indicates that a user-interface component is being dragged,
+	 * for example dragging the thumb of a scroll bar (value is 1).
+	 */
+	public static final int DRAG = 1;
+	
+	/**
+	 * Event detail field that indicates a user-interface component
+	 * state is selected (value is 1&lt;&lt;1).
+	 *
+	 * @since 3.2
+	 */
+	public static final int SELECTED = 1 << 1;
+	
+	/**
+	 * Event detail field that indicates a user-interface component
+	 * state is focused (value is 1&lt;&lt;2).
+	 *
+	 * @since 3.2
+	 */	
+	public static final int FOCUSED = 1 << 2;
+	
+	/**
+	 * Event detail field that indicates a user-interface component
+	 * draws the background (value is 1&lt;&lt;3).
+	 *
+	 * @since 3.2
+	 */
+	public static final int BACKGROUND = 1 << 3;
+	
+	/**
+	 * Event detail field that indicates a user-interface component
+	 * draws the foreground (value is 1&lt;&lt;4).
+	 *
+	 * @since 3.2
+	 */
+	public static final int FOREGROUND = 1 << 4;
+	
+	/**
+	 * Event detail field that indicates a user-interface component
+	 * state is hot (value is 1&lt;&lt;5).
+	 *
+	 * @since 3.3
+	 */
+	public static final int HOT = 1 << 5;
+	
+	/* This code is intentionally commented */
+	//public static final int PRESSED = 1 << 3;
+	//public static final int ACTIVE = 1 << 4;
+	//public static final int DISABLED = 1 << 5;
+	//public static final int HOT = 1 << 6;
+	//public static final int DEFAULTED = 1 << 7;
+
+	/**
+	 * Traversal event detail field value indicating that no 
+	 * traversal action should be taken
+	 * (value is 0).
+	 */
+	public static final int TRAVERSE_NONE = 0;
+	
+	/**
+	 * Traversal event detail field value indicating that the 
+	 * key which designates that a dialog should be cancelled was
+	 * pressed; typically, this is the ESC key
+	 * (value is 1&lt;&lt;1).
+	 */
+	public static final int TRAVERSE_ESCAPE = 1 << 1;
+
+	/**
+	 * Traversal event detail field value indicating that the
+	 * key which activates the default button in a dialog was
+	 * pressed; typically, this is the ENTER key
+	 * (value is 1&lt;&lt;2).
+	 */
+	public static final int TRAVERSE_RETURN = 1 << 2;
+
+	/**
+	 * Traversal event detail field value indicating that the 
+	 * key which designates that focus should be given to the
+	 * previous tab group was pressed; typically, this is the
+	 * SHIFT-TAB key sequence
+	 * (value is 1&lt;&lt;3).
+	 */
+	public static final int TRAVERSE_TAB_PREVIOUS = 1 << 3;
+
+	/**
+	 * Traversal event detail field value indicating that the 
+	 * key which designates that focus should be given to the
+	 * next tab group was pressed; typically, this is the
+	 * TAB key
+	 * (value is 1&lt;&lt;4).
+	 */
+	public static final int TRAVERSE_TAB_NEXT = 1 << 4;
+
+	/**
+	 * Traversal event detail field value indicating that the 
+	 * key which designates that focus should be given to the
+	 * previous tab item was pressed; typically, this is either
+	 * the LEFT-ARROW or UP-ARROW keys
+	 * (value is 1&lt;&lt;5).
+	 */
+	public static final int TRAVERSE_ARROW_PREVIOUS = 1 << 5;
+
+	/**
+	 * Traversal event detail field value indicating that the 
+	 * key which designates that focus should be given to the
+	 * previous tab item was pressed; typically, this is either
+	 * the RIGHT-ARROW or DOWN-ARROW keys
+	 * (value is 1&lt;&lt;6).
+	 */
+	public static final int TRAVERSE_ARROW_NEXT = 1 << 6;
+
+	/**
+	 * Traversal event detail field value indicating that a 
+	 * mnemonic key sequence was pressed
+	 * (value is 1&lt;&lt;7).
+	 */
+	public static final int TRAVERSE_MNEMONIC = 1 << 7;
+
+	/**
+	 * Traversal event detail field value indicating that the 
+	 * key which designates that the previous page of a multi-page
+	 * window should be shown was pressed; typically, this
+	 * is the CTRL-PAGEUP key sequence
+	 * (value is 1&lt;&lt;8).
+	 */
+	public static final int TRAVERSE_PAGE_PREVIOUS = 1 << 8;
+	
+	/**
+	 * Traversal event detail field value indicating that the 
+	 * key which designates that the next page of a multi-page
+	 * window should be shown was pressed; typically, this
+	 * is the CTRL-PAGEDOWN key sequence
+	 * (value is 1&lt;&lt;9).
+	 */
+	public static final int TRAVERSE_PAGE_NEXT = 1 << 9;
+
+	/**
+	 * A constant known to be zero (0), typically used in operations
+	 * which take bit flags to indicate that "no bits are set".
+	 */
+	public static final int NONE = 0;
+	
+	/**
+	 * A constant known to be zero (0), used in operations which
+	 * take pointers to indicate a null argument.
+	 */
+	public static final int NULL = 0;
+	
+	/**
+	 * Indicates that a default should be used (value is -1).
+	 */
+	public static final int DEFAULT = -1;
+
+	/**
+	 * Indicates that a property is off (value is 0).
+	 * 
+	 * @since 3.1
+	 */
+	public static final int OFF = 0;
+	
+	/**
+	 * Indicates that a property is on (value is 1).
+	 * 
+	 * @since 3.1
+	 */
+	public static final int ON = 1;
+
+	/**
+	 * Indicates low quality (value is 1).
+	 * 
+	 * @since 3.1
+	 */
+	public static final int LOW = 1;
+
+	/**
+	 * Indicates high quality (value is 2).
+	 * 
+	 * @since 3.1
+	 */
+	public static final int HIGH = 2;
+
+	/**
+	 * Style constant for menu bar behavior (value is 1&lt;&lt;1).
+	 * <p><b>Used By:</b><ul>
+	 * <li><code>Menu</code></li>
+	 * </ul></p>
+	 */
+	public static final int BAR = 1 << 1;
+
+	/**
+	 * Style constant for drop down menu/list behavior (value is 1&lt;&lt;2).
+	 * <p><b>Used By:</b><ul>
+	 * <li><code>Menu</code></li>
+	 * <li><code>ToolItem</code></li>
+	 * <li><code>CoolItem</code></li>
+	 * <li><code>Combo</code></li>
+	 * </ul></p>
+	 */
+	public static final int DROP_DOWN = 1 << 2;
+
+	/**
+	 * Style constant for pop up menu behavior (value is 1&lt;&lt;3).
+	 * <p><b>Used By:</b><ul>
+	 * <li><code>Menu</code></li>
+	 * </ul></p>
+	 */
+	public static final int POP_UP = 1 << 3;
+
+	/**
+	 * Style constant for line separator behavior (value is 1&lt;&lt;1).
+	 * <p><b>Used By:</b><ul>
+	 * <li><code>Label</code></li>
+	 * <li><code>MenuItem</code></li>
+	 * <li><code>ToolItem</code></li>
+	 * </ul></p>
+	 */
+	public static final int SEPARATOR = 1 << 1;
+
+	/**
+	 * Style constant for toggle button behavior (value is 1&lt;&lt;1).
+	 * <p><b>Used By:</b><ul>
+	 * <li><code>Button</code></li>
+	 * </ul></p>
+	 */
+	public static final int TOGGLE = 1 << 1;
+
+	/**
+	 * Style constant for arrow button behavior (value is 1&lt;&lt;2).
+	 * <p><b>Used By:</b><ul>
+	 * <li><code>Button</code></li>
+	 * </ul></p>
+	 */
+	public static final int ARROW = 1 << 2;
+
+	/**
+	 * Style constant for push button behavior (value is 1&lt;&lt;3).
+	 * <p><b>Used By:</b><ul>
+	 * <li><code>Button</code></li>
+	 * <li><code>MenuItem</code></li>
+	 * <li><code>ToolItem</code></li>
+	 * </ul></p>
+	 */
+	public static final int PUSH = 1 << 3;
+
+	/**
+	 * Style constant for radio button behavior (value is 1&lt;&lt;4).
+	 * <p><b>Used By:</b><ul>
+	 * <li><code>Button</code></li>
+	 * <li><code>MenuItem</code></li>
+	 * <li><code>ToolItem</code></li>
+	 * </ul></p>
+	 */
+	public static final int RADIO = 1 << 4;
+
+	/**
+	 * Style constant for check box behavior (value is 1&lt;&lt;5).
+	 * <p><b>Used By:</b><ul>
+	 * <li><code>Button</code></li>
+	 * <li><code>MenuItem</code></li>
+	 * <li><code>ToolItem</code></li>
+	 * <li><code>Table</code></li>
+	 * <li><code>Tree</code></li>
+	 * </ul></p>
+	 */
+	public static final int CHECK = 1 << 5;
+
+	/**
+	 * Style constant for cascade behavior (value is 1&lt;&lt;6).
+	 * <p><b>Used By:</b><ul>
+	 * <li><code>MenuItem</code></li>
+	 * </ul></p>
+	 */
+	public static final int CASCADE = 1 << 6;
+
+	/**
+	 * Style constant for multi-selection behavior in lists
+	 * and multiple line support on text fields (value is 1&lt;&lt;1).
+	 * <p><b>Used By:</b><ul>
+	 * <li><code>Text</code></li>
+	 * <li><code>List</code></li>
+	 * <li><code>FileDialog</code></li>
+	 * </ul></p>
+	 */
+	public static final int MULTI = 1 << 1;
+
+	/**
+	 * Style constant for single selection behavior in lists
+	 * and single line support on text fields (value is 1&lt;&lt;2).
+	 * <p><b>Used By:</b><ul>
+	 * <li><code>Text</code></li>
+	 * <li><code>List</code></li>
+	 * <li><code>Table</code></li>
+	 * <li><code>Tree</code></li>
+	 * </ul></p>
+	 */
+	public static final int SINGLE = 1 << 2;
+
+	/**
+	 * Style constant for read-only behavior (value is 1&lt;&lt;3).
+	 * <p><b>Used By:</b><ul>
+	 * <li><code>Combo</code></li>
+	 * <li><code>Text</code></li>
+	 * </ul></p>
+	 */
+	public static final int READ_ONLY = 1 << 3;
+
+	/**
+	 * Style constant for automatic line wrap behavior (value is 1&lt;&lt;6).
+	 * <p><b>Used By:</b><ul>
+	 * <li><code>Label</code></li>
+	 * <li><code>Text</code></li>
+	 * <li><code>ToolBar</code></li>
+	 * <li><code>Spinner</code></li>
+	 * </ul></p>
+	 */
+	public static final int WRAP = 1 << 6;
+
+	/**
+	 * Style constant for search behavior (value is 1&lt;&lt;7).
+	 * <p><b>Used By:</b><ul>
+	 * <li><code>Text</code></li>
+	 * </ul></p>
+	 * 
+	 * @since 3.3
+	 */
+	public static final int SEARCH = 1 << 7;
+
+	/**
+	 * Style constant for simple (not drop down) behavior (value is 1&lt;&lt;6).
+	 * <p><b>Used By:</b><ul>
+	 * <li><code>Combo</code></li>
+	 * </ul></p>
+	 */
+	public static final int SIMPLE = 1 << 6;
+
+	/**
+	 * Style constant for password behavior (value is 1&lt;&lt;22).
+	 * <p><b>Used By:</b><ul>
+	 * <li><code>Text</code></li>
+	 * </ul></p>
+	 * 
+	 * @since 3.0
+	 */
+	public static final int PASSWORD = 1 << 22;
+	
+	/**
+	 * Style constant for shadow in behavior (value is 1&lt;&lt;2).
+	 * <br>Note that this is a <em>HINT</em>.
+	 * <p><b>Used By:</b><ul>
+	 * <li><code>Label</code></li>
+	 * <li><code>Group</code></li>
+	 * </ul></p>
+	 */
+	public static final int SHADOW_IN = 1 << 2;
+
+	/**
+	 * Style constant for shadow out behavior (value is 1&lt;&lt;3).
+	 * <br>Note that this is a <em>HINT</em>.
+	 * <p><b>Used By:</b><ul>
+	 * <li><code>Label</code></li>
+	 * <li><code>Group</code></li>
+	 * <li><code>ToolBar</code></li>
+	 * </ul></p>
+	 */
+	public static final int SHADOW_OUT = 1 << 3;
+
+	/**
+	 * Style constant for shadow etched in behavior (value is 1&lt;&lt;4).
+	 * <br>Note that this is a <em>HINT</em>. It is ignored on all platforms except Motif.
+	 * <p><b>Used By:</b><ul>
+	 * <li><code>Group</code></li>
+	 * </ul></p>
+	 */
+	public static final int SHADOW_ETCHED_IN = 1 << 4;
+
+	/**
+	 * Style constant for shadow etched out behavior (value is 1&lt;&lt;6).
+	 * <br>Note that this is a <em>HINT</em>. It is ignored on all platforms except Motif.
+	 * <p><b>Used By:</b><ul>
+	 * <li><code>Group</code></li>
+	 * </ul></p>
+	 */
+	public static final int SHADOW_ETCHED_OUT = 1 << 6;
+
+	/**
+	 * Style constant for no shadow behavior (value is 1&lt;&lt;5).
+	 * <br>Note that this is a <em>HINT</em>.
+	 * <p><b>Used By:</b><ul>
+	 * <li><code>Label</code></li>
+	 * <li><code>Group</code></li>
+	 * </ul></p>
+	 */
+	public static final int SHADOW_NONE = 1 << 5;
+
+	/**
+	 * Style constant for progress bar behavior (value is 1&lt;&lt;1).
+	 * <p><b>Used By:</b><ul>
+	 * <li><code>ProgressBar</code></li>
+	 * </ul></p>
+	 */
+	public static final int INDETERMINATE = 1 << 1;
+	
+	/**
+	 * Style constant for tool window behavior (value is 1&lt;&lt;2).
+	 * <p>
+	 * A tool window is a window intended to be used as a floating toolbar.
+	 * It typically has a title bar that is shorter than a normal title bar,
+	 * and the window title is typically drawn using a smaller font.
+	 * <br>Note that this is a <em>HINT</em>.
+	 * </p><p><b>Used By:</b><ul>
+	 * <li><code>Decorations</code> and subclasses</li>
+	 * </ul></p>
+	 */
+	public static final int TOOL = 1 << 2; 
+
+	/**
+	 * Style constant to ensure no trimmings are used (value is 1&lt;&lt;3).
+	 * <br>Note that this overrides all other trim styles.
+	 * <p><b>Used By:</b><ul>
+	 * <li><code>Decorations</code> and subclasses</li>
+	 * </ul></p>
+	 */
+	public static final int NO_TRIM = 1 << 3;
+	
+	/**
+	 * Style constant for resize box trim (value is 1&lt;&lt;4).
+	 * <p><b>Used By:</b><ul>
+	 * <li><code>Decorations</code> and subclasses</li>
+	 * <li><code>Tracker</code></li>
+	 * </ul></p>
+	 */
+	public static final int RESIZE = 1 << 4;
+
+	/**
+	 * Style constant for title area trim (value is 1&lt;&lt;5).
+	 * <p><b>Used By:</b><ul>
+	 * <li><code>Decorations</code> and subclasses</li>
+	 * </ul></p>
+	 */
+	public static final int TITLE = 1 << 5;
+
+	/**
+	 * Style constant for close box trim (value is 1&lt;&lt;6,
+	 * since we do not distinguish between CLOSE style and MENU style).
+	 * <p><b>Used By:</b><ul>
+	 * <li><code>Decorations</code> and subclasses</li>
+	 * </ul></p>
+	 */
+	public static final int CLOSE = 1 << 6;
+
+	/**
+	 * Style constant for shell menu trim (value is 1&lt;&lt;6,
+	 * since we do not distinguish between CLOSE style and MENU style).
+	 * <p><b>Used By:</b><ul>
+	 * <li><code>Decorations</code> and subclasses</li>
+	 * </ul></p>
+	 */
+	public static final int MENU = CLOSE;
+
+	/**
+	 * Style constant for minimize box trim (value is 1&lt;&lt;7).
+	 * <p><b>Used By:</b><ul>
+	 * <li><code>Decorations</code> and subclasses</li>
+	 * </ul></p>
+	 */
+	public static final int MIN = 1 << 7;
+
+	/**
+	 * Style constant for maximize box trim (value is 1&lt;&lt;10).
+	 * <p><b>Used By:</b><ul>
+	 * <li><code>Decorations</code> and subclasses</li>
+	 * </ul></p>
+	 */
+	public static final int MAX = 1 << 10;
+
+	/**
+	 * Style constant for horizontal scrollbar behavior (value is 1&lt;&lt;8).
+	 * <p><b>Used By:</b><ul>
+	 * <li><code>Scrollable</code> and subclasses</li>
+	 * </ul></p>
+	 */
+	public static final int H_SCROLL = 1 << 8;
+
+	/**
+	 * Style constant for vertical scrollbar behavior (value is 1&lt;&lt;9).
+	 * <p><b>Used By:</b><ul>
+	 * <li><code>Scrollable</code> and subclasses</li>
+	 * </ul></p>
+	 */
+	public static final int V_SCROLL = 1 << 9;
+
+	/**
+	 * Style constant for no scrollbar behavior (value is 1&lt;&lt;4).
+	 * <p>
+	 * When neither H_SCROLL or V_SCROLL are specified, controls
+	 * are free to create the default scroll bars for the control.
+	 * Using NO_SCROLL overrides the default and forces the control
+	 * to have no scroll bars.
+	 * 
+	 * <b>Used By:</b><ul>
+	 * <li><code>Tree</code></li>
+	 * <li><code>Table</code></li>
+	 * </ul></p>
+	 *
+	 * @since 3.4
+	 */
+	public static final int NO_SCROLL = 1 << 4;
+	
+	/**
+	 * Style constant for bordered behavior (value is 1&lt;&lt;11).
+	 * <br>Note that this is a <em>HINT</em>.
+	 * <p><b>Used By:</b><ul>
+	 * <li><code>Control</code> and subclasses</li>
+	 * </ul></p>
+	 */
+	public static final int BORDER = 1 << 11;
+
+	/**
+	 * Style constant indicating that the window manager should clip
+	 * a widget's children with respect to its viewable area. (value is 1&lt;&lt;12).
+	 * <br>Note that this is a <em>HINT</em>.
+	 * <p><b>Used By:</b><ul>
+	 * <li><code>Control</code> and subclasses</li>
+	 * </ul></p>
+	 */
+	public static final int CLIP_CHILDREN = 1 << 12; 
+
+	/**
+	 * Style constant indicating that the window manager should clip
+	 * a widget's siblings with respect to its viewable area. (value is 1&lt;&lt;13).
+	 * <br>Note that this is a <em>HINT</em>.
+	 * <p><b>Used By:</b><ul>
+	 * <li><code>Control</code> and subclasses</li>
+	 * </ul></p>
+	 */
+	public static final int CLIP_SIBLINGS = 1 << 13;
+
+	/**
+	 * Style constant for always on top behavior (value is 1&lt;&lt;14).
+	 * <br>Note that this is a <em>HINT</em>.
+	 * <p><b>Used By:</b><ul>
+	 * <li><code>Shell</code> and subclasses</li>
+	 * </ul></p>
+	 */
+	public static final int ON_TOP = 1 << 14;
+
+	/**
+	 * Trim style convenience constant for the most common top level shell appearance
+	 * (value is CLOSE|TITLE|MIN|MAX|RESIZE).
+	 * <p><b>Used By:</b><ul>
+	 * <li><code>Shell</code></li>
+	 * </ul></p>
+	 */
+	public static final int SHELL_TRIM = CLOSE | TITLE | MIN | MAX | RESIZE;
+
+	/**
+	 * Trim style convenience constant for the most common dialog shell appearance
+	 * (value is CLOSE|TITLE|BORDER).
+	 * <p><b>Used By:</b><ul>
+	 * <li><code>Shell</code></li>
+	 * </ul></p>
+	 */
+	public static final int DIALOG_TRIM = TITLE | CLOSE | BORDER;
+
+	/**
+	 * Style constant for modeless behavior (value is 0).
+	 * <br>Note that this is a <em>HINT</em>.
+	 * <p><b>Used By:</b><ul>
+	 * <li><code>Dialog</code></li>
+	 * <li><code>Shell</code></li>
+	 * </ul></p>
+	 */
+	public static final int MODELESS = 0;
+
+	/**
+	 * Style constant for primary modal behavior (value is 1&lt;&lt;15).
+	 * <br>Note that this is a <em>HINT</em>.
+	 * <p><b>Used By:</b><ul>
+	 * <li><code>Dialog</code></li>
+	 * <li><code>Shell</code></li>
+	 * </ul></p>
+	 */
+	public static final int PRIMARY_MODAL = 1 << 15;
+
+	/**
+	 * Style constant for application modal behavior (value is 1&lt;&lt;16).
+	 * <br>Note that this is a <em>HINT</em>.
+	 * <p><b>Used By:</b><ul>
+	 * <li><code>Dialog</code></li>
+	 * <li><code>Shell</code></li>
+	 * </ul></p>
+	 */
+	public static final int APPLICATION_MODAL = 1 << 16;
+
+	/**
+	 * Style constant for system modal behavior (value is 1&lt;&lt;17).
+	 * <br>Note that this is a <em>HINT</em>.
+	 * <p><b>Used By:</b><ul>
+	 * <li><code>Dialog</code></li>
+	 * <li><code>Shell</code></li>
+	 * </ul></p>
+	 */
+	public static final int SYSTEM_MODAL = 1 << 17;
+
+	/**
+	 * Style constant for selection hiding behavior when the widget loses focus (value is 1&lt;&lt;15).
+	 * <br>Note that this is a <em>HINT</em>.
+	 * <p><b>Used By:</b><ul>
+	 * <li><code>Table</code></li>
+	 * </ul></p>
+	 */
+	public static final int HIDE_SELECTION = 1 << 15;
+
+	/**
+	 * Style constant for full row selection behavior and 
+	 * selection constant indicating that a full line should be 
+	 * drawn. (value is 1&lt;&lt;16).
+	 * <br>Note that for some widgets this is a <em>HINT</em>.
+	 * <p><b>Used By:</b><ul>
+	 * <li><code>Table</code></li>
+	 * <li><code>Tree</code></li>
+	 * <li><code>StyledText</code></li>
+	 * <li><code>TextLayout</code></li> 
+	 * </ul></p>
+	 */
+	public static final int FULL_SELECTION = 1 << 16;
+
+	/**
+	 * Style constant for flat appearance. (value is 1&lt;&lt;23).
+	 * <br>Note that this is a <em>HINT</em>.
+	 * <p><b>Used By:</b><ul>
+	 * <li><code>Button</code></li>
+	 * <li><code>ToolBar</code></li>
+	 * </ul></p>
+	 */
+	public static final int FLAT = 1 << 23;
+
+	/**
+	 * Style constant for smooth appearance. (value is 1&lt;&lt;16).
+	 * <br>Note that this is a <em>HINT</em>.
+	 * <p><b>Used By:</b><ul>
+	 * <li><code>ProgressBar</code></li>
+	 * <li><code>Sash</code></li>
+	 * </ul></p>
+	 */
+	public static final int SMOOTH = 1 << 16;
+
+	/**
+	 * Style constant for no background behavior (value is 1&lt;&lt;18).
+	 * <p>
+	 * By default, before a widget paints, the client area is filled with the current background.
+	 * When this style is specified, the background is not filled, and the application is responsible
+	 * for filling every pixel of the client area.
+	 * This style might be used as an alternative to "double-buffering" in order to reduce flicker.
+	 * This style does not mean "transparent" - widgets that are obscured will not draw through.
+	 * </p><p><b>Used By:</b><ul>
+	 * <li><code>Composite</code></li>
+	 * </ul></p>
+	 */
+	public static final int NO_BACKGROUND = 1 << 18;
+
+	/**
+	 * Style constant for no focus from the mouse behavior (value is 1&lt;&lt;19).
+	 * <p>
+	 * Normally, when the user clicks on a control, focus is assigned to that
+	 * control, providing the control has no children.  Some controls, such as
+	 * tool bars and sashes, don't normally take focus when the mouse is clicked
+	 * or accept focus when assigned from within the program.  This style allows
+	 * Composites to implement "no focus" mouse behavior.
+	 * 
+	 * <br>Note that this is a <em>HINT</em>.
+	 * </p>
+	 * <p><b>Used By:</b><ul>
+	 * <li><code>Composite</code></li>
+	 * </ul></p>
+	 */
+	public static final int NO_FOCUS = 1 << 19;
+
+	/**
+	 * Style constant for no redraw on resize behavior (value is 1&lt;&lt;20).
+	 * <p>
+	 * This style stops the entire client area from being invalidated when the size
+	 * of the Canvas changes. Specifically, when the size of the Canvas gets smaller,
+	 * the SWT.Paint event is not sent. When it gets bigger, an SWT.Paint event is
+	 * sent with a GC clipped to only the new areas to be painted. Without this
+	 * style, the entire client area will be repainted.
+	 * 
+	 * <br>Note that this is a <em>HINT</em>.
+	 * </p><p><b>Used By:</b><ul>
+	 * <li><code>Composite</code></li>
+	 * </ul></p>
+	 */
+	public static final int NO_REDRAW_RESIZE = 1 << 20;
+
+	/**
+	 * Style constant for no paint event merging behavior (value is 1&lt;&lt;21).
+	 * 
+	 * <br>Note that this is a <em>HINT</em>.
+	 * <p><b>Used By:</b><ul>
+	 * <li><code>Composite</code></li>
+	 * </ul></p>
+	 */
+	public static final int NO_MERGE_PAINTS = 1 << 21;
+
+	/**
+	 * Style constant for preventing child radio group behavior (value is 1&lt;&lt;22).
+	 * <p><b>Used By:</b><ul>
+	 * <li><code>Composite</code></li>
+	 * </ul></p>
+	 */
+	public static final int NO_RADIO_GROUP = 1 << 22;
+	
+	/**
+	 * Style constant for left to right orientation (value is 1&lt;&lt;25).
+	 * <p>
+	 * When orientation is not explicitly specified, orientation is
+	 * inherited.  This means that children will be assigned the
+	 * orientation of their parent.  To override this behavior and
+	 * force an orientation for a child, explicitly set the orientation
+	 * of the child when that child is created.
+	 * <br>Note that this is a <em>HINT</em>.
+	 * </p>
+	 * <p><b>Used By:</b><ul>
+	 * <li><code>Control</code></li>
+	 * <li><code>Menu</code></li>
+	 * <li><code>GC</code></li> 
+	 * </ul></p>
+	 * 
+	 * @since 2.1.2
+	 */
+	public static final int LEFT_TO_RIGHT = 1 << 25;
+	
+	/**
+	 * Style constant for right to left orientation (value is 1&lt;&lt;26).
+	 * <p>
+	 * When orientation is not explicitly specified, orientation is
+	 * inherited.  This means that children will be assigned the
+	 * orientation of their parent.  To override this behavior and
+	 * force an orientation for a child, explicitly set the orientation
+	 * of the child when that child is created.
+	 * <br>Note that this is a <em>HINT</em>.
+	 * </p>
+	 * <p><b>Used By:</b><ul>
+	 * <li><code>Control</code></li>
+	 * <li><code>Menu</code></li>
+	 * <li><code>GC</code></li> 
+	 * </ul></p>
+	 * 
+	 * @since 2.1.2
+	 */
+	public static final int RIGHT_TO_LEFT = 1 << 26;
+	
+	/**
+	 * Style constant to indicate coordinate mirroring (value is 1&lt;&lt;27).
+	 * <p><b>Used By:</b><ul>
+	 * <li><code>Control</code></li>
+	 * <li><code>Menu</code></li>
+	 * </ul></p>
+	 * 
+	 * @since 2.1.2
+	 */
+	public static final int MIRRORED = 1 << 27;
+	
+	/**
+	 * Style constant to allow embedding (value is 1&lt;&lt;24).
+	 * <p><b>Used By:</b><ul>
+	 * <li><code>Composite</code></li>
+	 * </ul></p>
+	 * 
+	 * @since 3.0
+	 */
+	public static final int EMBEDDED = 1 << 24;
+	
+	/**
+	 * Style constant to allow virtual data (value is 1&lt;&lt;28).
+	 * <p><b>Used By:</b><ul>
+	 * <li><code>Table</code></li>
+	 * <li><code>Tree</code></li>
+	 * </ul></p>
+	 * 
+	 * @since 3.0
+	 */
+	public static final int VIRTUAL = 1 << 28;
+
+	/**
+	 * Style constant to indicate double buffering (value is 1&lt;&lt;29).
+	 * <p><b>Used By:</b><ul>
+	 * <li><code>Control</code></li>
+	 * </ul></p>
+	 * 
+	 * @since 3.1
+	 */
+	public static final int DOUBLE_BUFFERED = 1 << 29;
+	
+	/**
+	 * Style constant for transparent behavior (value is 1&lt;&lt;30).
+	 * <p>
+	 * By default, before a widget paints, the client area is filled with the current background.
+	 * When this style is specified, the background is not filled and widgets that are obscured
+	 * will draw through.
+	 * </p><p><b>Used By:</b><ul>
+	 * <li><code>Composite</code></li>
+	 * </ul></p>
+	 *
+	 * @since 3.4
+	 * 
+	 * WARNING: THIS API IS UNDER CONSTRUCTION AND SHOULD NOT BE USED
+	 */
+	public static final int TRANSPARENT = 1 << 30;
+	
+	/**
+	 * Style constant for align up behavior (value is 1&lt;&lt;7,
+	 * since align UP and align TOP are considered the same).
+	 * <p><b>Used By:</b><ul>
+	 * <li><code>Button</code> with <code>ARROW</code> style</li>
+	 * <li><code>Tracker</code></li>
+	 * <li><code>Table</code></li>
+	 * <li><code>Tree</code></li>
+	 * </ul></p>
+	 */
+	public static final int UP = 1 << 7;
+	
+	/**
+	 * Style constant to indicate single underline (value is 0).
+	 * <p><b>Used By:</b><ul>
+	 * <li><code>TextStyle</code></li>
+	 * </ul></p>
+	 * 
+	 * @since 3.4
+	 */
+	public static final int UNDERLINE_SINGLE = 0;
+
+	/**
+	 * Style constant to indicate double underline (value is 1).
+	 * <p><b>Used By:</b><ul>
+	 * <li><code>TextStyle</code></li>
+	 * </ul></p>
+	 * 
+	 * @since 3.4
+	 */
+	public static final int UNDERLINE_DOUBLE = 1;
+	
+	/**
+	 * Style constant to indicate error underline (value is 2).
+	 * <p><b>Used By:</b><ul>
+	 * <li><code>TextStyle</code></li>
+	 * </ul></p>
+	 * 
+	 * @since 3.4
+	 */
+	public static final int UNDERLINE_ERROR = 2;
+	
+	/**
+	 * Style constant to indicate squiggle underline (value is 3).
+	 * <p><b>Used By:</b><ul>
+	 * <li><code>TextStyle</code></li>
+	 * </ul></p>
+	 * 
+	 * @since 3.4
+	 */
+	public static final int UNDERLINE_SQUIGGLE = 3;
+	
+	/**
+	 * Style constant to indicate solid border (value is 1).
+	 * <p><b>Used By:</b><ul>
+	 * <li><code>TextStyle</code></li>
+	 * </ul></p>
+	 * 
+	 * @since 3.4
+	 */
+	public static final int BORDER_SOLID = 1;
+
+	/**
+	 * Style constant to indicate dashed border (value is 2).
+	 * <p><b>Used By:</b><ul>
+	 * <li><code>TextStyle</code></li>
+	 * </ul></p>
+	 * 
+	 * @since 3.4
+	 */
+	public static final int BORDER_DASH = 2;
+	
+	/**
+	 * Style constant to indicate dotted border (value is 4).
+	 * <p><b>Used By:</b><ul>
+	 * <li><code>TextStyle</code></li>
+	 * </ul></p>
+	 * 
+	 * @since 3.4
+	 */
+	public static final int BORDER_DOT = 4;
+	
+	/**
+	 * Style constant for align top behavior (value is 1&lt;&lt;7,
+	 * since align UP and align TOP are considered the same).
+	 * <p><b>Used By:</b><ul>
+	 * <li><code>FormAttachment</code> in a <code>FormLayout</code></li>
+	 * </ul></p>
+	 */
+	public static final int TOP = UP;
+
+	/**
+	 * Style constant for align down behavior (value is 1&lt;&lt;10,
+	 * since align DOWN and align BOTTOM are considered the same).
+	 * <p><b>Used By:</b><ul>
+	 * <li><code>Button</code> with <code>ARROW</code> style</li>
+	 * <li><code>Tracker</code></li>
+	 * <li><code>Table</code></li>
+	 * <li><code>Tree</code></li>
+	 * </ul></p>
+	 */
+	public static final int DOWN               = 1 << 10;
+
+	/**
+	 * Style constant for align bottom behavior (value is 1&lt;&lt;10,
+	 * since align DOWN and align BOTTOM are considered the same).
+	 * <p><b>Used By:</b><ul>
+	 * <li><code>FormAttachment</code> in a <code>FormLayout</code></li>
+	 * </ul></p>
+	 */
+	public static final int BOTTOM             = DOWN;
+
+	/**
+	 * Style constant for leading alignment (value is 1&lt;&lt;14).
+	 * <p><b>Used By:</b><ul>
+	 * <li><code>Button</code></li>
+	 * <li><code>Label</code></li>
+	 * <li><code>TableColumn</code></li>
+	 * <li><code>Tracker</code></li>
+	 * <li><code>FormAttachment</code> in a <code>FormLayout</code></li>
+	 * </ul></p>
+	 * 
+	 * @since 2.1.2
+	 */
+	public static final int LEAD               = 1 << 14;
+	
+	/**
+	 * Style constant for align left behavior (value is 1&lt;&lt;14).
+	 * This is a synonym for LEAD (value is 1&lt;&lt;14).  Newer
+	 * applications should use LEAD instead of LEFT to make code more
+	 * understandable on right-to-left platforms.
+	 */
+	public static final int LEFT               = LEAD;
+
+	/**
+	 * Style constant for trailing alignment (value is 1&lt;&lt;17).
+	 * <p><b>Used By:</b><ul>
+	 * <li><code>Button</code></li>
+	 * <li><code>Label</code></li>
+	 * <li><code>TableColumn</code></li>
+	 * <li><code>Tracker</code></li>
+	 * <li><code>FormAttachment</code> in a <code>FormLayout</code></li>
+	 * </ul></p>
+	 * 
+	 * @since 2.1.2
+	 */
+	public static final int TRAIL              = 1 << 17;
+		
+	/**
+	 * Style constant for align right behavior (value is 1&lt;&lt;17).
+	 * This is a synonym for TRAIL (value is 1&lt;&lt;17).  Newer
+	 * applications should use TRAIL instead of RIGHT to make code more
+	 * understandable on right-to-left platforms.
+	 */
+	public static final int RIGHT              = TRAIL;
+
+	/**
+	 * Style constant for align center behavior (value is 1&lt;&lt;24).
+	 * <p><b>Used By:</b><ul>
+	 * <li><code>Button</code></li>
+	 * <li><code>Label</code></li>
+	 * <li><code>TableColumn</code></li>
+	 * <li><code>FormAttachment</code> in a <code>FormLayout</code></li>
+	 * </ul></p>
+	 */
+	public static final int CENTER = 1 << 24;
+
+	/**
+	 * Style constant for horizontal alignment or orientation behavior (value is 1&lt;&lt;8).
+	 * <p><b>Used By:</b><ul>
+	 * <li><code>Label</code></li>
+	 * <li><code>ProgressBar</code></li>
+	 * <li><code>Sash</code></li>
+	 * <li><code>Scale</code></li>
+	 * <li><code>ScrollBar</code></li>
+	 * <li><code>Slider</code></li>
+	 * <li><code>ToolBar</code></li>
+	 * <li><code>FillLayout</code> type</li>
+	 * <li><code>RowLayout</code> type</li>
+	 * </ul></p>
+	 */
+	public static final int HORIZONTAL = 1 << 8;
+
+	/**
+	 * Style constant for vertical alignment or orientation behavior (value is 1&lt;&lt;9).
+	 * <p><b>Used By:</b><ul>
+	 * <li><code>Label</code></li>
+	 * <li><code>ProgressBar</code></li>
+	 * <li><code>Sash</code></li>
+	 * <li><code>Scale</code></li>
+	 * <li><code>ScrollBar</code></li>
+	 * <li><code>Slider</code></li>
+	 * <li><code>ToolBar</code></li>
+	 * <li><code>CoolBar</code></li>
+	 * <li><code>FillLayout</code> type</li>
+	 * <li><code>RowLayout</code> type</li>
+	 * </ul></p>
+	 */
+	public static final int VERTICAL = 1 << 9;
+
+	/**
+	 * Style constant for date display (value is 1&lt;&lt;5).
+	 * <p><b>Used By:</b><ul>
+	 * <li><code>DateTime</code></li>
+	 * </ul></p>
+	 * 
+	 * @since 3.3
+	 */
+	public static final int DATE = 1 << 5;
+
+	/**
+	 * Style constant for time display (value is 1&lt;&lt;7).
+	 * <p><b>Used By:</b><ul>
+	 * <li><code>DateTime</code></li>
+	 * </ul></p>
+	 * 
+	 * @since 3.3
+	 */
+	public static final int TIME = 1 << 7;
+	
+	/**
+	 * Style constant for calendar display (value is 1&lt;&lt;10).
+	 * <p><b>Used By:</b><ul>
+	 * <li><code>DateTime</code></li>
+	 * </ul></p>
+	 * 
+	 * @since 3.3
+	 */
+	public static final int CALENDAR = 1 << 10;
+
+	/**
+	 * Style constant for short date/time format (value is 1&lt;&lt;15).
+	 * <p>
+	 * A short date displays the month and year.
+	 * A short time displays hours and minutes.
+	 * <br>Note that this is a <em>HINT</em>.
+	 * </p>
+	 * <p><b>Used By:</b><ul>
+	 * <li><code>DateTime</code></li>
+	 * </ul></p>
+	 * 
+	 * @since 3.3
+	 */
+	public static final int SHORT = 1 << 15;
+
+	/**
+	 * Style constant for medium date/time format (value is 1&lt;&lt;16).
+	 * <p>
+	 * A medium date displays the day, month and year.
+	 * A medium time displays hours, minutes, and seconds.
+	 * <br>Note that this is a <em>HINT</em>.
+	 * </p>
+	 * <p><b>Used By:</b><ul>
+	 * <li><code>DateTime</code></li>
+	 * </ul></p>
+	 * 
+	 * @since 3.3
+	 */
+	public static final int MEDIUM = 1 << 16;
+
+	/**
+	 * Style constant for long date/time format (value is 1&lt;&lt;28).
+	 * <p>
+	 * A long date displays the day, month and year.
+	 * A long time displays hours, minutes, and seconds.
+	 * The day and month names may be displayed.
+	 * <br>Note that this is a <em>HINT</em>.
+	 * </p>
+	 * <p><b>Used By:</b><ul>
+	 * <li><code>DateTime</code></li>
+	 * </ul></p>
+	 * 
+	 * @since 3.3
+	 */
+	public static final int LONG = 1 << 28;
+
+	/**
+	 * Style constant specifying that a Browser should use a Mozilla GRE
+	 * for rendering its content (value is 1&lt;&lt;15).
+	 * <p>
+	 * <p><b>Used By:</b><ul>
+	 * <li><code>Browser</code></li>
+	 * </ul></p>
+	 * 
+	 * @since 3.3
+	 */
+	public static final int MOZILLA = 1 << 15;
+
+	/**
+	 * Style constant for balloon behavior (value is 1&lt;&lt;12).
+	 * <p><b>Used By:</b><ul>
+	 * <li><code>ToolTip</code></li>
+	 * </ul></p>
+	 *
+	 * @since 3.2
+	 */	
+	public static final int BALLOON = 1 << 12;
+	
+	/**
+	 * Style constant for vertical alignment or orientation behavior (value is 1).
+	 * <p><b>Used By:</b><ul>
+	 * <li><code>GridLayout</code> type</li>
+	 * </ul></p>
+	 */
+	public static final int BEGINNING = 1;
+	
+	/**
+	 * Style constant for vertical alignment or orientation behavior (value is 4).
+	 * <p><b>Used By:</b><ul>
+	 * <li><code>GridLayout</code> type</li>
+	 * </ul></p>
+	 */
+	public static final int FILL = 4;
+	
+	/**
+	 * Input Method Editor style constant for double byte
+	 * input behavior (value is 1&lt;&lt;1).
+	 */
+	public static final int DBCS = 1 << 1;
+
+	/**
+	 * Input Method Editor style constant for alpha
+	 * input behavior (value is 1&lt;&lt;2).
+	 */
+	public static final int ALPHA = 1 << 2;
+
+	/**
+	 * Input Method Editor style constant for native
+	 * input behavior (value is 1&lt;&lt;3).
+	 */
+	public static final int NATIVE = 1 << 3;
+
+	/**
+	 * Input Method Editor style constant for phonetic
+	 * input behavior (value is 1&lt;&lt;4).
+	 */
+	public static final int PHONETIC = 1 << 4;
+
+	/**
+	 * Input Method Editor style constant for romanicized
+	 * input behavior (value is 1&lt;&lt;5).
+	 */
+	public static final int ROMAN = 1 << 5;
+
+	/**
+	 * ASCII character convenience constant for the backspace character
+	 * (value is the <code>char</code> '\b').
+	 */
+	public static final char BS = '\b';
+
+	/**
+	 * ASCII character convenience constant for the carriage return character
+	 * (value is the <code>char</code> '\r').
+	 */
+	public static final char CR = '\r';
+
+	/**
+	 * ASCII character convenience constant for the delete character
+	 * (value is the <code>char</code> with value 127).
+	 */
+	public static final char DEL = 0x7F;
+ 
+	/**
+	 * ASCII character convenience constant for the escape character
+	 * (value is the <code>char</code> with value 27).
+	 */
+	public static final char ESC = 0x1B;
+
+	/**
+	 * ASCII character convenience constant for the line feed character
+	 * (value is the <code>char</code> '\n').
+	 */
+	public static final char LF = '\n';
+
+	/**
+	 * ASCII character convenience constant for the tab character
+	 * (value is the <code>char</code> '\t').
+	 * 
+	 * @since 2.1
+	 */
+	public static final char TAB = '\t';
+						
+	/**
+	 * keyboard and/or mouse event mask indicating that the ALT key
+	 * was pushed on the keyboard when the event was generated
+	 * (value is 1&lt;&lt;16).
+	 */
+	public static final int ALT = 1 << 16;
+					
+	/**
+	 * Keyboard and/or mouse event mask indicating that the SHIFT key
+	 * was pushed on the keyboard when the event was generated
+	 * (value is 1&lt;&lt;17).
+	 */
+	public static final int SHIFT = 1 << 17;
+					
+	/**
+	 * Keyboard and/or mouse event mask indicating that the CTRL key
+	 * was pushed on the keyboard when the event was generated
+	 * (value is 1&lt;&lt;18).
+	 */
+	public static final int CTRL = 1 << 18;
+
+	/**
+	 * Keyboard and/or mouse event mask indicating that the CTRL key
+	 * was pushed on the keyboard when the event was generated. This
+	 * is a synonym for CTRL (value is 1&lt;&lt;18).
+	 */
+	public static final int CONTROL = CTRL;
+
+	/**
+	 * Keyboard and/or mouse event mask indicating that the COMMAND key
+	 * was pushed on the keyboard when the event was generated
+	 * (value is 1&lt;&lt;22).
+	 * 
+	 * @since 2.1
+	 */
+	public static final int COMMAND = 1 << 22;
+	
+	/**
+	 * Keyboard and/or mouse event mask indicating all possible
+	 * keyboard modifiers.
+	 * 
+	 * To allow for the future, this mask  is intended to be used in 
+	 * place of code that references  each individual keyboard mask. 
+	 *  For example, the following expression will determine whether 
+	 * any modifier is pressed and will continue to work as new modifier 
+	 * masks are added.
+	 * 
+ 	 * <code>(stateMask & SWT.MODIFIER_MASK) != 0</code>.
+	 * 
+	 * @since 2.1
+	 */
+	public static final int MODIFIER_MASK;
+	
+	/**
+	 * Keyboard and/or mouse event mask indicating that mouse button one
+	 * was pushed when the event was generated. (value is 1&lt;&lt;19).
+	 */
+	public static final int BUTTON1 = 1 << 19;
+
+	/**
+	 * Keyboard and/or mouse event mask indicating that mouse button two
+	 * was pushed when the event was generated. (value is 1&lt;&lt;20).
+	 */
+	public static final int BUTTON2 = 1 << 20;
+
+	/**
+	 * Keyboard and/or mouse event mask indicating that mouse button three
+	 * was pushed when the event was generated. (value is 1&lt;&lt;21).
+	 */
+	public static final int BUTTON3 = 1 << 21;
+
+	/**
+	 * Keyboard and/or mouse event mask indicating that mouse button four
+	 * was pushed when the event was generated. (value is 1&lt;&lt;23).
+	 * 
+	 * @since 3.1
+	 */
+	public static final int BUTTON4 = 1 << 23;
+
+	/**
+	 * Keyboard and/or mouse event mask indicating that mouse button five
+	 * was pushed when the event was generated. (value is 1&lt;&lt;25).
+	 * 
+	 * @since 3.1
+	 */
+	public static final int BUTTON5 = 1 << 25;
+
+	/**
+	 * Keyboard and/or mouse event mask indicating all possible
+	 * mouse buttons.
+	 * 
+	 * To allow for the future, this mask  is intended to be used 
+	 * in place of code that references each individual button mask.  
+	 * For example, the following expression will determine whether
+	 * any button is pressed and will continue to work as new button 
+	 * masks are added.
+	 * 
+ 	 * <code>(stateMask & SWT.BUTTON_MASK) != 0</code>.
+	 * 
+	 * @since 2.1
+	 */
+	public static final int BUTTON_MASK;
+	
+	/**
+	 * Keyboard and/or mouse event mask indicating that the MOD1 key
+	 * was pushed on the keyboard when the event was generated.
+	 * 
+	 * This is the primary keyboard modifier for the platform.
+	 * 
+	 * @since 2.1
+	 */
+	public static final int MOD1;
+	
+	/**
+	 * Keyboard and/or mouse event mask indicating that the MOD2 key
+	 * was pushed on the keyboard when the event was generated.
+	 * 
+	 * This is the secondary keyboard modifier for the platform.
+	 * 
+	 * @since 2.1
+	 */
+	public static final int MOD2;
+
+	/**
+	 * Keyboard and/or mouse event mask indicating that the MOD3 key
+	 * was pushed on the keyboard when the event was generated.
+	 * 
+	 * @since 2.1
+	 */
+	public static final int MOD3;
+
+	/**
+	 * Keyboard and/or mouse event mask indicating that the MOD4 key
+	 * was pushed on the keyboard when the event was generated.
+	 * 
+	 * @since 2.1
+	 */
+	public static final int MOD4;
+	
+	/**
+	 * Constants to indicate line scrolling (value is 1).
+	 * <p><b>Used By:</b><ul>
+	 * <li><code>Control</code></li>
+	 * </ul></p>
+	 * 
+	 * @since 3.1
+	 */
+	public static final int SCROLL_LINE = 1;
+
+	/**
+	 * Constants to indicate page scrolling (value is 2).
+	 * <p><b>Used By:</b><ul>
+	 * <li><code>Control</code></li>
+	 * </ul></p>
+	 * 
+	 * @since 3.1
+	 */
+	public static final int SCROLL_PAGE = 2;
+	
+	/**
+	 * Accelerator constant used to differentiate a key code from a
+	 * unicode character.
+	 * 
+	 * If this bit is set, then the key stroke
+	 * portion of an accelerator represents a key code.  If this bit
+	 * is not set, then the key stroke portion of an accelerator is
+	 * a unicode character.
+	 * 
+	 * The following expression is false:
+	 * 
+	 * <code>((SWT.MOD1 | SWT.MOD2 | 'T') & SWT.KEYCODE_BIT) != 0</code>.
+	 * 
+	 * The following expression is true:
+	 * 
+	 * <code>((SWT.MOD3 | SWT.F2) & SWT.KEYCODE_BIT) != 0</code>.
+	 * 
+	 * (value is (1&lt;&lt;24))
+	 * 
+	 * @since 2.1
+	 */	
+	public static final int KEYCODE_BIT = (1 << 24);
+
+	/**
+	 * Accelerator constant used to extract the key stroke portion of
+	 * an accelerator.
+	 * 
+	 * The key stroke may be a key code or a unicode
+	 * value.  If the key stroke is a key code <code>KEYCODE_BIT</code>
+	 * will be set.
+	 * 
+	 * @since 2.1
+	 */	
+	public static final int KEY_MASK = KEYCODE_BIT + 0xFFFF;
+	
+	/**
+	 * Keyboard event constant representing the UP ARROW key
+	 * (value is (1&lt;&lt;24)+1).
+	 */
+	public static final int ARROW_UP = KEYCODE_BIT + 1;
+
+	/**
+	 * Keyboard event constant representing the DOWN ARROW key
+	 * (value is (1&lt;&lt;24)+2).
+	 */
+	public static final int ARROW_DOWN = KEYCODE_BIT + 2;
+
+	/**
+	 * Keyboard event constant representing the LEFT ARROW key
+	 * (value is (1&lt;&lt;24)+3).
+	 */
+	public static final int ARROW_LEFT = KEYCODE_BIT + 3;
+
+	/**
+	 * Keyboard event constant representing the RIGHT ARROW key
+	 * (value is (1&lt;&lt;24)+4).
+	 */
+	public static final int ARROW_RIGHT = KEYCODE_BIT + 4;
+
+	/**
+	 * Keyboard event constant representing the PAGE UP key
+	 * (value is (1&lt;&lt;24)+5).
+	 */
+	public static final int PAGE_UP = KEYCODE_BIT + 5;
+
+	/**
+	 * Keyboard event constant representing the PAGE DOWN key
+	 * (value is (1&lt;&lt;24)+6).
+	 */
+	public static final int PAGE_DOWN = KEYCODE_BIT + 6;
+
+	/**
+	 * Keyboard event constant representing the HOME key
+	 * (value is (1&lt;&lt;24)+7).
+	 */
+	public static final int HOME = KEYCODE_BIT + 7;
+
+	/**
+	 * Keyboard event constant representing the END key
+	 * (value is (1&lt;&lt;24)+8).
+	 */
+	public static final int END = KEYCODE_BIT + 8;
+
+	/**
+	 * Keyboard event constant representing the INSERT key
+	 * (value is (1&lt;&lt;24)+9).
+	 */
+	public static final int INSERT = KEYCODE_BIT + 9;
+
+	/**
+	 * Keyboard event constant representing the F1 key
+	 * (value is (1&lt;&lt;24)+10).
+	 */
+	public static final int F1 = KEYCODE_BIT + 10;
+	
+	/**
+	 * Keyboard event constant representing the F2 key
+	 * (value is (1&lt;&lt;24)+11).
+	 */
+	public static final int F2 = KEYCODE_BIT + 11;
+	
+	/**
+	 * Keyboard event constant representing the F3 key
+	 * (value is (1&lt;&lt;24)+12).
+	 */
+	public static final int F3 = KEYCODE_BIT + 12;
+	
+	/**
+	 * Keyboard event constant representing the F4 key
+	 * (value is (1&lt;&lt;24)+13).
+	 */
+	public static final int F4 = KEYCODE_BIT + 13;
+	
+	/**
+	 * Keyboard event constant representing the F5 key
+	 * (value is (1&lt;&lt;24)+14).
+	 */
+	public static final int F5 = KEYCODE_BIT + 14;
+	
+	/**
+	 * Keyboard event constant representing the F6 key
+	 * (value is (1&lt;&lt;24)+15).
+	 */
+	public static final int F6 = KEYCODE_BIT + 15;
+	
+	/**
+	 * Keyboard event constant representing the F7 key
+	 * (value is (1&lt;&lt;24)+16).
+	 */
+	public static final int F7 = KEYCODE_BIT + 16;
+	
+	/**
+	 * Keyboard event constant representing the F8 key
+	 * (value is (1&lt;&lt;24)+17).
+	 */
+	public static final int F8 = KEYCODE_BIT + 17;
+	
+	/**
+	 * Keyboard event constant representing the F9 key
+	 * (value is (1&lt;&lt;24)+18).
+	 */
+	public static final int F9 = KEYCODE_BIT + 18;
+	
+	/**
+	 * Keyboard event constant representing the F10 key
+	 * (value is (1&lt;&lt;24)+19).
+	 */
+	public static final int F10 = KEYCODE_BIT + 19;
+	
+	/**
+	 * Keyboard event constant representing the F11 key
+	 * (value is (1&lt;&lt;24)+20).
+	 */
+	public static final int F11 = KEYCODE_BIT + 20;
+	
+	/**
+	 * Keyboard event constant representing the F12 key
+	 * (value is (1&lt;&lt;24)+21).
+	 */
+	public static final int F12 = KEYCODE_BIT + 21;
+
+	/**
+	 * Keyboard event constant representing the F13 key
+	 * (value is (1&lt;&lt;24)+22).
+	 * 
+	 * @since 3.0
+	 */
+	public static final int F13 = KEYCODE_BIT + 22;
+	
+	/**
+	 * Keyboard event constant representing the F14 key
+	 * (value is (1&lt;&lt;24)+23).
+	 * 
+	 * @since 3.0
+	 */
+	public static final int F14 = KEYCODE_BIT + 23;
+	
+	/**
+	 * Keyboard event constant representing the F15 key
+	 * (value is (1&lt;&lt;24)+24).
+	 * 
+	 * @since 3.0
+	 */
+	public static final int F15 = KEYCODE_BIT + 24;
+	
+	/**
+	 * Keyboard event constant representing the numeric key
+	 * pad multiply key (value is (1&lt;&lt;24)+42).
+	 * 
+	 * @since 3.0
+	 */
+	public static final int KEYPAD_MULTIPLY = KEYCODE_BIT + 42;
+	
+	/**
+	 * Keyboard event constant representing the numeric key
+	 * pad add key (value is (1&lt;&lt;24)+43).
+	 * 
+	 * @since 3.0
+	 */
+	public static final int KEYPAD_ADD = KEYCODE_BIT + 43;
+	
+	/**
+	 * Keyboard event constant representing the numeric key
+	 * pad subtract key (value is (1&lt;&lt;24)+45).
+	 * 
+	 * @since 3.0
+	 */
+	public static final int KEYPAD_SUBTRACT = KEYCODE_BIT + 45;
+
+	/**
+	 * Keyboard event constant representing the numeric key
+	 * pad decimal key (value is (1&lt;&lt;24)+46).
+	 * 
+	 * @since 3.0
+	 */
+	public static final int KEYPAD_DECIMAL = KEYCODE_BIT + 46;
+
+	/**
+	 * Keyboard event constant representing the numeric key
+	 * pad divide key (value is (1&lt;&lt;24)+47).
+	 * 
+	 * @since 3.0
+	 */
+	public static final int KEYPAD_DIVIDE = KEYCODE_BIT + 47;
+
+	/**
+	 * Keyboard event constant representing the numeric key
+	 * pad zero key (value is (1&lt;&lt;24)+48).
+	 * 
+	 * @since 3.0
+	 */
+	public static final int KEYPAD_0 = KEYCODE_BIT + 48;
+
+	/**
+	 * Keyboard event constant representing the numeric key
+	 * pad one key (value is (1&lt;&lt;24)+49).
+	 * 
+	 * @since 3.0
+	 */
+	public static final int KEYPAD_1 = KEYCODE_BIT + 49;
+
+	/**
+	 * Keyboard event constant representing the numeric key
+	 * pad two key (value is (1&lt;&lt;24)+50).
+	 * 
+	 * @since 3.0
+	 */
+	public static final int KEYPAD_2 = KEYCODE_BIT + 50;
+
+	/**
+	 * Keyboard event constant representing the numeric key
+	 * pad three key (value is (1&lt;&lt;24)+51).
+	 * 
+	 * @since 3.0
+	 */
+	public static final int KEYPAD_3 = KEYCODE_BIT + 51;
+
+	/**
+	 * Keyboard event constant representing the numeric key
+	 * pad four key (value is (1&lt;&lt;24)+52).
+	 * 
+	 * @since 3.0
+	 */
+	public static final int KEYPAD_4 = KEYCODE_BIT + 52;
+	
+	/**
+	 * Keyboard event constant representing the numeric key
+	 * pad five key (value is (1&lt;&lt;24)+53).
+	 * 
+	 * @since 3.0
+	 */
+	public static final int KEYPAD_5 = KEYCODE_BIT + 53;
+	
+	/**
+	 * Keyboard event constant representing the numeric key
+	 * pad six key (value is (1&lt;&lt;24)+54).
+	 * 
+	 * @since 3.0
+	 */
+	public static final int KEYPAD_6 = KEYCODE_BIT + 54;
+
+	/**
+	 * Keyboard event constant representing the numeric key
+	 * pad seven key (value is (1&lt;&lt;24)+55).
+	 * 
+	 * @since 3.0
+	 */
+	public static final int KEYPAD_7 = KEYCODE_BIT + 55;
+
+	/**
+	 * Keyboard event constant representing the numeric key
+	 * pad eight key (value is (1&lt;&lt;24)+56).
+	 * 
+	 * @since 3.0
+	 */
+	public static final int KEYPAD_8 = KEYCODE_BIT + 56;
+	
+	/**
+	 * Keyboard event constant representing the numeric key
+	 * pad nine key (value is (1&lt;&lt;24)+57).
+	 * 
+	 * @since 3.0
+	 */
+	public static final int KEYPAD_9 = KEYCODE_BIT + 57;
+
+	/**
+	 * Keyboard event constant representing the numeric key
+	 * pad equal key (value is (1&lt;&lt;24)+61).
+	 * 
+	 * @since 3.0
+	 */
+	public static final int KEYPAD_EQUAL = KEYCODE_BIT + 61;
+	
+	/**
+	 * Keyboard event constant representing the numeric key
+	 * pad enter key (value is (1&lt;&lt;24)+80).
+	 * 
+	 * @since 3.0
+	 */
+	public static final int KEYPAD_CR = KEYCODE_BIT + 80;
+	
+	/**
+	 * Keyboard event constant representing the help
+	 * key (value is (1&lt;&lt;24)+81).
+	 * 
+	 * NOTE: The HELP key maps to the key labeled "help",
+	 * not "F1". If your keyboard does not have a HELP key,
+	 * you will never see this key press.  To listen for
+	 * help on a control, use SWT.Help.
+	 * 
+	 * @since 3.0
+	 * 
+	 * @see SWT#Help
+	 */
+	public static final int HELP = KEYCODE_BIT + 81;
+	
+	/**
+	 * Keyboard event constant representing the caps
+	 * lock key (value is (1&lt;&lt;24)+82).
+	 * 
+	 * @since 3.0
+	 */
+	public static final int CAPS_LOCK = KEYCODE_BIT + 82;
+	
+	/**
+	 * Keyboard event constant representing the num
+	 * lock key (value is (1&lt;&lt;24)+83).
+	 * 
+	 * @since 3.0
+	 */
+	public static final int NUM_LOCK = KEYCODE_BIT + 83;
+	
+	/**
+	 * Keyboard event constant representing the scroll
+	 * lock key (value is (1&lt;&lt;24)+84).
+	 * 
+	 * @since 3.0
+	 */
+	public static final int SCROLL_LOCK = KEYCODE_BIT + 84;
+	
+	/**
+	 * Keyboard event constant representing the pause
+	 * key (value is (1&lt;&lt;24)+85).
+	 * 
+	 * @since 3.0
+	 */
+	public static final int PAUSE = KEYCODE_BIT + 85;
+	
+	/**
+	 * Keyboard event constant representing the break
+	 * key (value is (1&lt;&lt;24)+86).
+	 * 
+	 * @since 3.0
+	 */
+	public static final int BREAK = KEYCODE_BIT + 86;
+	
+	/**
+	 * Keyboard event constant representing the print screen
+	 * key (value is (1&lt;&lt;24)+87).
+	 * 
+	 * @since 3.0
+	 */
+	public static final int PRINT_SCREEN = KEYCODE_BIT + 87;
+	
+	/**
+	 * The <code>MessageBox</code> style constant for error icon
+	 * behavior (value is 1).
+	 */
+	public static final int ICON_ERROR = 1;
+
+	/**
+	 * The <code>MessageBox</code> style constant for information icon
+	 * behavior (value is 1&lt;&lt;1).
+	 */
+	public static final int ICON_INFORMATION = 1 << 1;
+
+	/**
+	 * The <code>MessageBox</code> style constant for question icon
+	 * behavior (value is 1&lt;&lt;2).
+	 */
+	public static final int ICON_QUESTION = 1 << 2;
+
+	/**
+	 * The <code>MessageBox</code> style constant for warning icon
+	 * behavior (value is 1&lt;&lt;3).
+	 */
+	public static final int ICON_WARNING = 1 << 3;
+
+	/**
+	 * The <code>MessageBox</code> style constant for "working" icon
+	 * behavior (value is 1&lt;&lt;4).
+	 */
+	public static final int ICON_WORKING = 1 << 4;
+
+	/**
+	 * The <code>MessageBox</code> style constant for an OK button;
+	 * valid combinations are OK, OK|CANCEL
+	 * (value is 1&lt;&lt;5).
+	 */
+	public static final int OK = 1 << 5;
+
+	/**
+	 * The <code>MessageBox</code> style constant for YES button;
+	 * valid combinations are YES|NO, YES|NO|CANCEL
+	 * (value is 1&lt;&lt;6).
+	 */
+	public static final int YES = 1 << 6;
+
+	/**
+	 * The <code>MessageBox</code> style constant for NO button;
+	 * valid combinations are YES|NO, YES|NO|CANCEL
+	 * (value is 1&lt;&lt;7).
+	 */
+	public static final int NO = 1 << 7;
+
+	/**
+	 * The <code>MessageBox</code> style constant for a CANCEL button;
+	 * valid combinations are OK|CANCEL, YES|NO|CANCEL, RETRY|CANCEL
+	 * (value is 1&lt;&lt;8).  This style constant is also used with 
+	 * <code>Text</code> in combination with SEARCH.
+	 * 
+	 * <p><b>Used By:</b><ul>
+	 * <li><code>MessageBox</code></li>
+	 * <li><code>Text</code></li>
+	 * </ul></p>
+	 */
+	public static final int CANCEL = 1 << 8;
+
+	/**
+	 * The <code>MessageBox</code> style constant for an ABORT button;
+	 * the only valid combination is ABORT|RETRY|IGNORE
+	 * (value is 1&lt;&lt;9).
+	 */
+	public static final int ABORT = 1 << 9;
+
+	/**
+	 * The <code>MessageBox</code> style constant for a RETRY button;
+	 *  valid combinations are ABORT|RETRY|IGNORE, RETRY|CANCEL
+	 * (value is 1&lt;&lt;10).
+	 */
+	public static final int RETRY = 1 << 10;
+
+	/**
+	 * The <code>MessageBox</code> style constant for an IGNORE button;
+	 * the only valid combination is ABORT|RETRY|IGNORE
+	 * (value is 1&lt;&lt;11).
+	 */
+	public static final int	IGNORE = 1 << 11;
+
+	/**
+	 * The <code>FileDialog</code> style constant for open file dialog behavior
+	 * (value is 1&lt;&lt;12).
+	 */
+	public static final int OPEN = 1 << 12;
+
+	/**
+	 * The <code>FileDialog</code> style constant for save file dialog behavior
+	 * (value is 1&lt;&lt;13).
+	 */
+	public static final int SAVE = 1 << 13;
+
+	/**
+	 * The <code>Composite</code> constant to indicate that
+	 * an attribute (such as background) is not inherited
+	 * by the children (value is 0).
+	 *
+	 * @since 3.2
+	 */
+	public static final int INHERIT_NONE = 0;
+	
+	/**
+	 * The <code>Composite</code> constant to indicate that
+	 * an attribute (such as background) is inherited by
+	 * children who choose this value as their "default"
+	 * (value is 1).  For example, a label child will
+	 * typically choose to inherit the background color
+	 * of a composite while a list or table will not.
+	 *
+	 * @since 3.2
+	 */
+	public static final int INHERIT_DEFAULT = 1;
+	
+	/**
+	 * The <code>Composite</code> constant to indicate that
+	 * an attribute (such as background) is inherited by
+	 * all children.
+	 *
+	 * @since 3.2
+	 */
+	public static final int INHERIT_FORCE = 2;
+	
+	/**
+	 * Default color white (value is 1).
+	 */
+	public static final int COLOR_WHITE = 1;
+
+	/**
+	 * Default color black (value is 2).
+	 */
+	public static final int COLOR_BLACK = 2;
+
+	/**
+	 * Default color red (value is 3).
+	 */
+	public static final int COLOR_RED = 3;
+
+	/**
+	 * Default color dark red (value is 4).
+	 */
+	public static final int COLOR_DARK_RED = 4;
+
+	/**
+	 * Default color green (value is 5).
+	 */
+	public static final int COLOR_GREEN = 5;
+
+	/**
+	 * Default color dark green (value is 6).
+	 */
+	public static final int COLOR_DARK_GREEN = 6;
+
+	/**
+	 * Default color yellow (value is 7).
+	 */
+	public static final int COLOR_YELLOW = 7;
+
+	/**
+	 * Default color dark yellow (value is 8).
+	 */
+	public static final int COLOR_DARK_YELLOW = 8;
+
+	/**
+	 * Default color blue (value is 9).
+	 */
+	public static final int COLOR_BLUE = 9;
+
+	/**
+	 * Default color dark blue (value is 10).
+	 */
+	public static final int COLOR_DARK_BLUE = 10;
+
+	/**
+	 * Default color magenta (value is 11).
+	 */
+	public static final int COLOR_MAGENTA = 11;
+
+	/**
+	 * Default color dark magenta (value is 12).
+	 */
+	public static final int COLOR_DARK_MAGENTA = 12;
+
+	/**
+	 * Default color cyan (value is 13).
+	 */
+	public static final int COLOR_CYAN = 13;
+
+	/**
+	 * Default color dark cyan (value is 14).
+	 */
+	public static final int COLOR_DARK_CYAN = 14;
+
+	/**
+	 * Default color gray (value is 15).
+	 */
+	public static final int COLOR_GRAY = 15;
+
+	/**
+	 * Default color dark gray (value is 16).
+	 */
+	public static final int COLOR_DARK_GRAY = 16;
+	
+	/*
+	 * System Colors
+	 *
+	 * Dealing with system colors is an area where there are
+	 * many platform differences.  On some platforms, system
+	 * colors can change dynamically while the program is
+	 * running.  On other platforms, system colors can be
+	 * changed for all instances of a particular widget.
+	 * Therefore, the only truly portable method to obtain
+	 * a widget color query is to query the color from an
+	 * instance of the widget.
+	 *
+	 *	It is expected that the list of supported colors
+	 * will grow over time.
+	 */
+	
+	/**
+	 * System color used to paint dark shadow areas (value is 17).
+	 */
+	public static final int COLOR_WIDGET_DARK_SHADOW = 17;
+
+	/**
+	 * System color used to paint normal shadow areas (value is 18).
+	 */
+	public static final int COLOR_WIDGET_NORMAL_SHADOW = 18;
+
+	/**
+	 * System color used to paint light shadow areas (value is 19).
+	 */
+	public static final int COLOR_WIDGET_LIGHT_SHADOW = 19;
+
+	/**
+	 * System color used to paint highlight shadow areas (value is 20).
+	 */
+	public static final int COLOR_WIDGET_HIGHLIGHT_SHADOW = 20;
+
+	/**
+	 * System color used to paint foreground areas (value is 21).
+	 */
+	public static final int COLOR_WIDGET_FOREGROUND = 21;
+
+	/**
+	 * System color used to paint background areas (value is 22).
+	 */
+	public static final int COLOR_WIDGET_BACKGROUND = 22;
+
+	/**
+	 * System color used to paint border areas (value is 23).
+	 */
+	public static final int COLOR_WIDGET_BORDER = 23;
+
+	/**
+	 * System color used to paint list foreground areas (value is 24).
+	 */
+	public static final int COLOR_LIST_FOREGROUND = 24;
+
+	/**
+	 * System color used to paint list background areas (value is 25).
+	 */
+	public static final int COLOR_LIST_BACKGROUND = 25;
+
+	/**
+	 * System color used to paint list selection background areas (value is 26).
+	 */
+	public static final int COLOR_LIST_SELECTION = 26;
+
+	/**
+	 * System color used to paint list selected text (value is 27).
+	 */
+	public static final int COLOR_LIST_SELECTION_TEXT = 27;
+
+	/**
+	 * System color used to paint tooltip text (value is 28).
+	 */
+	public static final int COLOR_INFO_FOREGROUND = 28;
+
+	/**
+	 * System color used to paint tooltip background areas (value is 29).
+	 */
+	public static final int COLOR_INFO_BACKGROUND = 29;
+	
+	/**
+	 * System color used to paint title text (value is 30).
+	 */
+	public static final int COLOR_TITLE_FOREGROUND = 30;
+
+	/**
+	 * System color used to paint title background areas (value is 31).
+	 */
+	public static final int COLOR_TITLE_BACKGROUND = 31;
+
+	/**
+	 * System color used to paint title background gradient (value is 32).
+	 */
+	public static final int COLOR_TITLE_BACKGROUND_GRADIENT = 32;
+	
+	/**
+	 * System color used to paint inactive title text (value is 33).
+	 */
+	public static final int COLOR_TITLE_INACTIVE_FOREGROUND = 33;
+
+	/**
+	 * System color used to paint inactive title background areas (value is 34).
+	 */
+	public static final int COLOR_TITLE_INACTIVE_BACKGROUND = 34;
+
+	/**
+	 * System color used to paint inactive title background gradient (value is 35).
+	 */
+	public static final int COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT = 35;
+	
+	/**
+	 * Draw constant indicating whether the drawing operation
+	 * should fill the background (value is 1&lt;&lt;0).
+	 */
+	public static final int DRAW_TRANSPARENT = 1 << 0;
+
+	/**
+	 * Draw constant indicating whether the string drawing operation
+	 * should handle line-delimiters (value is 1&lt;&lt;1).
+	 */
+	public static final int DRAW_DELIMITER = 1 << 1;
+
+	/**
+	 * Draw constant indicating whether the string drawing operation
+	 * should expand TAB characters (value is 1&lt;&lt;2).
+	 */
+	public static final int DRAW_TAB = 1 << 2;
+
+	/**
+	 * Draw constant indicating whether the string drawing operation
+	 * should handle mnemonics (value is 1&lt;&lt;3).
+	 */
+	public static final int DRAW_MNEMONIC = 1 << 3;	
+
+	
+	/**
+	 * Selection constant indicating that a line delimiter should be 
+	 * drawn (value is 1&lt;&lt;17).
+	 * 
+	 * <p><b>Used By:</b><ul>
+	 * <li><code>TextLayout</code></li>
+	 * </ul></p>
+	 *
+	 * @see #FULL_SELECTION
+	 * @see #LAST_LINE_SELECTION
+	 * 
+	 * @since 3.3
+	 */
+	public static final int DELIMITER_SELECTION = 1 << 17;
+	
+	/**
+	 * Selection constant indicating that the last line is selected
+	 * to the end and should be drawn using either a line delimiter 
+	 * or full line selection (value is 1&lt;&lt;20).
+	 * 
+	 * <p><b>Used By:</b><ul>
+	 * <li><code>TextLayout</code></li>
+	 * </ul></p>
+	 * 
+	 * @see #DELIMITER_SELECTION
+	 * @see #FULL_SELECTION
+	 * 
+	 * @since 3.3
+	 */
+	public static final int LAST_LINE_SELECTION = 1 << 20;
+	
+	/** 
+	 * SWT error constant indicating that no error number was specified
+	 * (value is 1).
+	 */
+	public static final int ERROR_UNSPECIFIED = 1;
+	
+	/** 
+	 * SWT error constant indicating that no more handles for an
+	 * operating system resource are available
+	 * (value is 2).
+	 */
+	public static final int ERROR_NO_HANDLES = 2;
+	
+	/** 
+	 * SWT error constant indicating that no more callback resources are available
+	 * (value is 3).
+	 */
+	public static final int ERROR_NO_MORE_CALLBACKS = 3;
+	
+	/** 
+	 * SWT error constant indicating that a null argument was passed in
+	 * (value is 4). 
+	 */
+	public static final int ERROR_NULL_ARGUMENT = 4;
+	
+	/** 
+	 * SWT error constant indicating that an invalid argument was passed in
+	 * (value is 5).
+	 */
+	public static final int ERROR_INVALID_ARGUMENT = 5;
+	
+	/** 
+	 * SWT error constant indicating that a value was found to be
+	 * outside the allowable range
+	 * (value is 6).
+	 */
+	public static final int ERROR_INVALID_RANGE = 6;
+	
+	/** 
+	 * SWT error constant indicating that a value which can not be 
+	 * zero was found to be
+	 * (value is 7).
+	 */
+	public static final int ERROR_CANNOT_BE_ZERO = 7;
+	
+	/** 
+	 * SWT error constant indicating that the underlying operating
+	 * system was unable to provide the value of an item
+	 * (value is 8).
+	 */
+	public static final int ERROR_CANNOT_GET_ITEM = 8;
+	
+	/** 
+	 * SWT error constant indicating that the underlying operating
+	 * system was unable to provide the selection
+	 * (value is 9).
+	 */
+	public static final int ERROR_CANNOT_GET_SELECTION = 9;
+
+	/** 
+	 * SWT error constant indicating that the matrix is not invertible
+	 * (value is 10).
+	 * 
+	 * @since 3.1
+	 */
+	public static final int ERROR_CANNOT_INVERT_MATRIX = 10;
+
+	/** 
+	 * SWT error constant indicating that the underlying operating
+	 * system was unable to provide the height of an item
+	 * (value is 11).
+	 */
+	public static final int ERROR_CANNOT_GET_ITEM_HEIGHT = 11;
+
+	/** 
+	 * SWT error constant indicating that the underlying operating
+	 * system was unable to provide the text of a widget
+	 * (value is 12).
+	 */
+	public static final int ERROR_CANNOT_GET_TEXT = 12;
+
+	/** 
+	 * SWT error constant indicating that the underlying operating
+	 * system was unable to set the text of a widget
+	 * (value is 13).
+	 */
+	public static final int ERROR_CANNOT_SET_TEXT = 13;
+
+	/** 
+	 * SWT error constant indicating that the underlying operating
+	 * system was unable to add an item
+	 * (value is 14).
+	 */
+	public static final int ERROR_ITEM_NOT_ADDED = 14;
+
+	/** 
+	 * SWT error constant indicating that the underlying operating
+	 * system was unable to remove an item
+	 * (value is 15).
+	 */
+	public static final int ERROR_ITEM_NOT_REMOVED = 15;
+
+	/** 
+	 * SWT error constant indicating that the graphics library
+	 * is not available
+	 * (value is 16).
+	 */
+	public static final int ERROR_NO_GRAPHICS_LIBRARY = 16;
+
+	/** 
+	 * SWT error constant indicating that a particular feature has
+	 * not been implemented on this platform
+	 * (value is 20).
+	 */
+	public static final int ERROR_NOT_IMPLEMENTED = 20;
+
+	/** 
+	 * SWT error constant indicating that a menu which needed
+	 * to have the drop down style had some other style instead
+	 * (value is 21).
+	 */
+	public static final int ERROR_MENU_NOT_DROP_DOWN = 21;
+
+	/** 
+	 * SWT error constant indicating that an attempt was made to
+	 * invoke an SWT operation which can only be executed by the
+	 * user-interface thread from some other thread
+	 * (value is 22).
+	 */
+	public static final int ERROR_THREAD_INVALID_ACCESS = 22;
+
+	/** 
+	 * SWT error constant indicating that an attempt was made to
+	 * invoke an SWT operation using a widget which had already
+	 * been disposed
+	 * (value is 24). 
+	 */
+	public static final int ERROR_WIDGET_DISPOSED = 24;
+
+	/** 
+	 * SWT error constant indicating that a menu item which needed
+	 * to have the cascade style had some other style instead
+	 * (value is 27).
+	 */
+	public static final int ERROR_MENUITEM_NOT_CASCADE = 27;
+
+	/** 
+	 * SWT error constant indicating that the underlying operating
+	 * system was unable to set the selection of a widget
+	 * (value is 28).
+	 */
+	public static final int ERROR_CANNOT_SET_SELECTION = 28;
+
+	/** 
+	 * SWT error constant indicating that the underlying operating
+	 * system was unable to set the menu
+	 * (value is 29).
+	 */
+	public static final int ERROR_CANNOT_SET_MENU = 29;
+
+	/** 
+	 * SWT error constant indicating that the underlying operating
+	 * system was unable to set the enabled state
+	 * (value is 30).
+	 */
+	public static final int ERROR_CANNOT_SET_ENABLED = 30;
+
+	/** 
+	 * SWT error constant indicating that the underlying operating
+	 * system was unable to provide enabled/disabled state information
+	 * (value is 31).
+	 */
+	public static final int ERROR_CANNOT_GET_ENABLED = 31;
+
+	/** 
+	 * SWT error constant indicating that a provided widget can
+	 * not be used as a parent in the current operation
+	 * (value is 32).
+	 */
+	public static final int ERROR_INVALID_PARENT = 32;
+	
+	/** 
+	 * SWT error constant indicating that a menu which needed
+	 * to have the menu bar style had some other style instead
+	 * (value is 33).
+	 */
+	public static final int ERROR_MENU_NOT_BAR = 33;
+
+	/** 
+	 * SWT error constant indicating that the underlying operating
+	 * system was unable to provide count information
+	 * (value is 36).
+	 */
+	public static final int ERROR_CANNOT_GET_COUNT = 36;
+
+	/** 
+	 * SWT error constant indicating that a menu which needed
+	 * to have the pop up menu style had some other style instead
+	 * (value is 37).
+	 */
+	public static final int ERROR_MENU_NOT_POP_UP = 37;
+
+	/** 
+	 * SWT error constant indicating that a graphics operation
+	 * was attempted with an image of an unsupported depth
+	 * (value is 38).
+	 */
+	public static final int ERROR_UNSUPPORTED_DEPTH = 38;
+
+	/** 
+	 * SWT error constant indicating that an input/output operation
+	 * failed during the execution of an SWT operation
+	 * (value is 39).
+	 */
+	public static final int ERROR_IO = 39;
+
+	/** 
+	 * SWT error constant indicating that a graphics operation
+	 * was attempted with an image having an invalid format
+	 * (value is 40).
+	 */
+	public static final int ERROR_INVALID_IMAGE = 40;
+
+	/** 
+	 * SWT error constant indicating that a graphics operation
+	 * was attempted with an image having a valid but unsupported
+	 * format
+	 * (value is 42).
+	 */
+	public static final int ERROR_UNSUPPORTED_FORMAT = 42;
+
+	/** 
+	 * SWT error constant indicating that an attempt was made
+	 * to subclass an SWT widget class without implementing the
+	 * <code>checkSubclass()</code> method
+	 * (value is 43).
+	 * 
+	 * For additional information see the comment in 
+	 * <code>Widget.checkSubclass()</code>.
+	 *
+	 * @see org.eclipse.swt.widgets.Widget#checkSubclass
+	 */
+	public static final int ERROR_INVALID_SUBCLASS = 43;
+
+	/** 
+	 * SWT error constant indicating that an attempt was made to
+	 * invoke an SWT operation using a graphics object which had
+	 * already been disposed
+	 * (value is 44).
+	 */
+	public static final int ERROR_GRAPHIC_DISPOSED = 44;
+	
+	/** 
+	 * SWT error constant indicating that an attempt was made to
+	 * invoke an SWT operation using a device which had already
+	 * been disposed
+	 * (value is 45). 
+	 */
+	public static final int ERROR_DEVICE_DISPOSED = 45;
+	
+	/** 
+	 * SWT error constant indicating that an exception happened
+	 * when executing a runnable
+	 * (value is 46).
+	 */
+	public static final int ERROR_FAILED_EXEC = 46;
+	
+	/** 
+	 * SWT error constant indicating that an unsatisfied link
+	 * error occurred while attempting to load a library
+	 * (value is 47).
+	 * 
+	 * @since 3.1
+	 */
+	public static final int ERROR_FAILED_LOAD_LIBRARY = 47;
+
+	/** 
+	 * SWT error constant indicating that a font is not valid
+	 * (value is 48).
+	 * 
+	 * @since 3.1
+	 */
+	public static final int ERROR_INVALID_FONT = 48;
+
+	/**
+	 * Constant indicating that an image or operation is of type bitmap  (value is 0).
+	 */	
+	public static final int BITMAP = 0;
+
+	/**
+	 * Constant indicating that an image or operation is of type icon  (value is 1).
+	 */	
+	public static final int ICON = 1;
+
+	/**
+	 * The <code>Image</code> constructor argument indicating that
+	 * the new image should be a copy of the image provided as
+	 * an argument  (value is 0).
+	 */	
+	public static final int IMAGE_COPY = 0;
+
+	/**
+	 * The <code>Image</code> constructor argument indicating that
+	 * the new image should have the appearance of a "disabled"
+	 * (using the platform's rules for how this should look)
+	 * copy of the image provided as an argument  (value is 1).
+	 */	
+	public static final int IMAGE_DISABLE = 1;
+	
+	/**
+	 * The <code>Image</code> constructor argument indicating that
+	 * the new image should have the appearance of a "gray scaled"
+	 * copy of the image provided as an argument  (value is 2).
+	 */	
+	public static final int IMAGE_GRAY = 2;
+	
+	/**
+	 * Constant to indicate an error state (value is 1).
+	 * <p><b>Used By:</b><ul>
+	 * <li><code>ProgressBar</code></li>
+	 * </ul></p>
+	 * 
+	 * @since 3.4
+	 */
+	public static final int ERROR = 1;
+	
+	/**
+	 * Constant to a indicate a paused state (value is 4).
+	 * <p><b>Used By:</b><ul>
+	 * <li><code>ProgressBar</code></li>
+	 * </ul></p>
+	 * 
+	 * @since 3.4
+	 */
+	public static final int PAUSED = 1 << 2;
+	
+	/**
+	 * The font style constant indicating a normal weight, non-italic font
+	 * (value is 0). This constant is also used with <code>ProgressBar</code>
+	 * to indicate a normal state.
+	 * <p><b>Used By:</b><ul>
+	 * <li><code>ProgressBar</code></li>
+	 * </ul></p>
+	 */
+	public static final int NORMAL = 0;
+	
+	/**
+	 * The font style constant indicating a bold weight font
+	 * (value is 1&lt;&lt;0).
+	 */
+	public static final int BOLD = 1 << 0;
+	
+	/**
+	 * The font style constant indicating an italic font
+	 * (value is 1&lt;&lt;1).
+	 */
+	public static final int ITALIC = 1 << 1;
+		
+	/**
+	 * System arrow cursor  (value is 0).
+	 */
+	public static final int CURSOR_ARROW = 0;
+		
+	/**
+	 * System wait cursor  (value is 1).
+	 */
+	public static final int CURSOR_WAIT = 1;
+		
+	/**
+	 * System cross hair cursor  (value is 2).
+	 */
+	public static final int CURSOR_CROSS = 2;
+		
+	/**
+	 * System app startup cursor  (value is 3).
+	 */
+	public static final int CURSOR_APPSTARTING = 3;
+		
+	/**
+	 * System help cursor  (value is 4).
+	 */
+	public static final int CURSOR_HELP = 4;
+		
+	/**
+	 * System resize all directions cursor (value is 5).
+	 */
+	public static final int CURSOR_SIZEALL = 5;
+		
+	/**
+	 * System resize north-east-south-west cursor  (value is 6).
+	 */
+	public static final int CURSOR_SIZENESW = 6;
+		
+	/**
+	 * System resize north-south cursor  (value is 7).
+	 */
+	public static final int CURSOR_SIZENS = 7;
+		
+	/**
+	 * System resize north-west-south-east cursor  (value is 8).
+	 */
+	public static final int CURSOR_SIZENWSE = 8;
+		
+	/**
+	 * System resize west-east cursor  (value is 9).
+	 */
+	public static final int CURSOR_SIZEWE = 9;
+		
+	/**
+	 * System resize north cursor  (value is 10).
+	 */
+	public static final int CURSOR_SIZEN = 10;
+		
+	/**
+	 * System resize south cursor  (value is 11).
+	 */
+	public static final int CURSOR_SIZES = 11;
+		
+	/**
+	 * System resize east cursor  (value is 12).
+	 */
+	public static final int CURSOR_SIZEE = 12;
+		
+	/**
+	 * System resize west cursor  (value is 13).
+	 */
+	public static final int CURSOR_SIZEW = 13;
+		
+	/**
+	 * System resize north-east cursor (value is 14).
+	 */
+	public static final int CURSOR_SIZENE = 14;
+		
+	/**
+	 * System resize south-east cursor (value is 15).
+	 */
+	public static final int CURSOR_SIZESE = 15;
+		
+	/**
+	 * System resize south-west cursor (value is 16).
+	 */
+	public static final int CURSOR_SIZESW = 16;
+		
+	/**
+	 * System resize north-west cursor (value is 17).
+	 */
+	public static final int CURSOR_SIZENW = 17;
+		
+	/**
+	 * System up arrow cursor  (value is 18).
+	 */
+	public static final int CURSOR_UPARROW = 18;
+		
+	/**
+	 * System i-beam cursor (value is 19).
+	 */
+	public static final int CURSOR_IBEAM = 19;
+		
+	/**
+	 * System "not allowed" cursor (value is 20).
+	 */
+	public static final int CURSOR_NO = 20;
+		
+	/**
+	 * System hand cursor (value is 21).
+	 */
+	public static final int CURSOR_HAND = 21;
+		
+	/**
+	 * Line drawing style for flat end caps (value is 1).
+	 * 
+	 * @see org.eclipse.swt.graphics.GC#setLineCap(int)
+	 * @see org.eclipse.swt.graphics.GC#getLineCap()
+	 * 
+	 * @since 3.1
+	 */
+	public static final int CAP_FLAT = 1;
+
+	/**
+	 * Line drawing style for rounded end caps (value is 2).
+	 * 
+	 * @see org.eclipse.swt.graphics.GC#setLineCap(int)
+	 * @see org.eclipse.swt.graphics.GC#getLineCap()
+	 * 
+	 * @since 3.1
+	 */
+	public static final int CAP_ROUND = 2;
+
+	/**
+	 * Line drawing style for square end caps (value is 3).
+	 * 
+	 * @see org.eclipse.swt.graphics.GC#setLineCap(int)
+	 * @see org.eclipse.swt.graphics.GC#getLineCap()
+	 * 
+	 * @since 3.1
+	 */
+	public static final int CAP_SQUARE = 3;
+
+	/**
+	 * Line drawing style for miter joins (value is 1).
+	 * 
+	 * @see org.eclipse.swt.graphics.GC#setLineJoin(int)
+	 * @see org.eclipse.swt.graphics.GC#getLineJoin()
+	 * 
+	 * @since 3.1
+	 */
+	public static final int JOIN_MITER = 1;
+
+	/**
+	 * Line drawing  style for rounded joins (value is 2).
+	 * 
+	 * @see org.eclipse.swt.graphics.GC#setLineJoin(int)
+	 * @see org.eclipse.swt.graphics.GC#getLineJoin()
+	 * 
+	 * @since 3.1
+	 */
+	public static final int JOIN_ROUND = 2;
+
+	/**
+	 * Line drawing style for bevel joins (value is 3).
+	 * 
+	 * @see org.eclipse.swt.graphics.GC#setLineJoin(int)
+	 * @see org.eclipse.swt.graphics.GC#getLineJoin()
+	 * 
+	 * @since 3.1
+	 */
+	public static final int JOIN_BEVEL = 3;
+
+	/**
+	 * Line drawing style for solid lines  (value is 1).
+	 */
+	public static final int LINE_SOLID = 1;
+		
+	/**
+	 * Line drawing style for dashed lines (value is 2).
+	 */
+	public static final int LINE_DASH = 2;
+		
+	/**
+	 * Line drawing style for dotted lines (value is 3).
+	 */
+	public static final int LINE_DOT = 3;
+		
+	/**
+	 * Line drawing style for alternating dash-dot lines (value is 4).
+	 */
+	public static final int LINE_DASHDOT = 4;
+		
+	/**
+	 * Line drawing style for dash-dot-dot lines (value is 5).
+	 */
+	public static final int LINE_DASHDOTDOT = 5;
+
+	/**
+	 * Line drawing style for custom dashed lines (value is 6).
+	 * 
+	 * @see org.eclipse.swt.graphics.GC#setLineDash(int[])
+	 * @see org.eclipse.swt.graphics.GC#getLineDash()
+	 * 
+	 * @since 3.1
+	 */
+	public static final int LINE_CUSTOM = 6;
+	
+	/**
+	 * Path constant that represents a "move to" operation (value is 1).
+	 * 
+	 * @since 3.1
+	 */
+	public static final int PATH_MOVE_TO = 1;
+
+	/**
+	 * Path constant that represents a "line to" operation (value is 2).
+	 * 
+	 * @since 3.1
+	 */
+	public static final int PATH_LINE_TO = 2;
+
+	/**
+	 * Path constant that represents a "quadratic curve to" operation (value is 3).
+	 * 
+	 * @since 3.1
+	 */
+	public static final int PATH_QUAD_TO = 3;
+
+	/**
+	 * Path constant that represents a "cubic curve to" operation (value is 4).
+	 * 
+	 * @since 3.1
+	 */
+	public static final int PATH_CUBIC_TO = 4;
+
+	/**
+	 * Path constant that represents a "close" operation (value is 5).
+	 * 
+	 * @since 3.1
+	 */
+	public static final int PATH_CLOSE = 5;
+
+	/**
+	 * Even odd rule for filling operations (value is 1).
+	 * 
+	 * @since 3.1
+	 */
+	public static final int FILL_EVEN_ODD = 1;
+
+	/**
+	 * Winding rule for filling operations (value is 2).
+	 * 
+	 * @since 3.1
+	 */
+	public static final int FILL_WINDING = 2;
+
+	/**
+	 * Image format constant indicating an unknown image type (value is -1).
+	 */
+	public static final int IMAGE_UNDEFINED = -1;
+
+	/**
+	 * Image format constant indicating a Windows BMP format image (value is 0).
+	 */
+	public static final int IMAGE_BMP = 0;
+
+	/**
+	 * Image format constant indicating a run-length encoded 
+	 * Windows BMP format image (value is 1).
+	 */
+	public static final int IMAGE_BMP_RLE = 1;
+
+	/**
+	 * Image format constant indicating a GIF format image (value is 2).
+	 */
+	public static final int IMAGE_GIF = 2;
+
+	/**
+	 * Image format constant indicating a ICO format image (value is 3).
+	 */
+	public static final int IMAGE_ICO = 3;
+
+	/**
+	 * Image format constant indicating a JPEG format image (value is 4).
+	 */
+	public static final int IMAGE_JPEG = 4;
+
+	/**
+	 * Image format constant indicating a PNG format image (value is 5).
+	 */
+	public static final int IMAGE_PNG = 5;
+
+	/**
+	 * Image format constant indicating a TIFF format image (value is 6).
+	 */
+	public static final int IMAGE_TIFF = 6;
+
+	/**
+	 * Image format constant indicating an OS/2 BMP format image (value is 7).
+	 */
+	public static final int IMAGE_OS2_BMP = 7;
+
+	/**
+	 * GIF image disposal method constants indicating that the
+	 * disposal method is unspecified (value is 0).
+	 */
+	public static final int DM_UNSPECIFIED = 0x0;
+
+	/**
+	 * GIF image disposal method constants indicating that the
+	 * disposal method is to do nothing; that is, to leave the 
+	 * previous image in place (value is 1).
+	 */
+	public static final int DM_FILL_NONE = 0x1;
+
+	/**
+	 * GIF image disposal method constants indicating that the
+	 * the previous images should be covered with the background
+	 * color before displaying the next image (value is 2).
+	 */
+	public static final int DM_FILL_BACKGROUND = 0x2;
+
+	/**
+	 * GIF image disposal method constants indicating that the
+	 * disposal method is to restore the previous picture
+	 * (value is 3).
+	 */
+	public static final int DM_FILL_PREVIOUS = 0x3;
+	
+	/**
+	 * Image transparency constant indicating that the image
+	 * contains no transparency information (value is 0).
+	 */
+	public static final int TRANSPARENCY_NONE = 0x0;
+	
+	/**
+	 * Image transparency constant indicating that the image
+	 * contains alpha transparency information (value is 1&lt;&lt;0).
+	 */
+	public static final int TRANSPARENCY_ALPHA = 1 << 0;
+	
+	/**
+	 * Image transparency constant indicating that the image
+	 * contains a transparency mask (value is 1&lt;&lt;1).
+	 */
+	public static final int TRANSPARENCY_MASK = 1 << 1;
+	
+	/**
+	 * Image transparency constant indicating that the image
+	 * contains a transparent pixel (value is 1&lt;&lt;2).
+	 */
+	public static final int TRANSPARENCY_PIXEL = 1 << 2;
+
+	/**
+	 * The character movement type (value is 1&lt;&lt;0).
+	 * This constant is used to move a text offset over a character.
+	 * 
+	 * @see org.eclipse.swt.graphics.TextLayout#getNextOffset(int, int)
+	 * @see org.eclipse.swt.graphics.TextLayout#getPreviousOffset(int, int)
+	 * 
+	 * @since 3.0
+	 */	
+	public static final int MOVEMENT_CHAR = 1 << 0;
+
+	/**
+	 * The cluster movement type (value is 1&lt;&lt;1).
+	 * This constant is used to move a text offset over a cluster.
+	 * A cluster groups one or more characters. A cluster is 
+	 * undivisible, this means that a caret offset can not be placed in the
+	 * middle of a cluster.  
+	 * 
+	 * @see org.eclipse.swt.graphics.TextLayout#getNextOffset(int, int)
+	 * @see org.eclipse.swt.graphics.TextLayout#getPreviousOffset(int, int)
+	 * 
+	 * @since 3.0
+	 */
+	public static final int MOVEMENT_CLUSTER = 1 << 1;
+
+	/**
+	 * The word movement type (value is 1&lt;&lt;2).
+	 * This constant is used to move a text offset over a word.
+	 * The behavior of this constant depends on the platform and on the 
+	 * direction of the movement. For example, on Windows the stop is 
+	 * always at the start of the word. On GTK and Mac the stop is at the end 
+	 * of the word if the direction is next and at the start of the word if the 
+	 * direction is previous.
+	 * 
+	 * @see org.eclipse.swt.graphics.TextLayout#getNextOffset(int, int)
+	 * @see org.eclipse.swt.graphics.TextLayout#getPreviousOffset(int, int)
+	 * 
+	 * @since 3.0
+	 */	
+	public static final int MOVEMENT_WORD = 1 << 2;
+
+	/**
+	 * The word end movement type (value is 1&lt;&lt;3).
+	 * This constant is used to move a text offset to the next or previous
+	 * word end. The behavior of this constant does not depend on the platform.  
+	 * 
+	 * 
+	 * @see org.eclipse.swt.graphics.TextLayout#getNextOffset(int, int)
+	 * @see org.eclipse.swt.graphics.TextLayout#getPreviousOffset(int, int)
+	 * 
+	 * @since 3.3
+	 */	
+	public static final int MOVEMENT_WORD_END = 1 << 3;
+
+	/**
+	 * The word start movement type (value is 1&lt;&lt;4).
+	 * This constant is used to move a text offset to the next or previous
+	 * word start. The behavior of this constant does not depend on the platform.  
+	 * 
+	 * @see org.eclipse.swt.graphics.TextLayout#getNextOffset(int, int)
+	 * @see org.eclipse.swt.graphics.TextLayout#getPreviousOffset(int, int)
+	 * 
+	 * @since 3.3
+	 */	
+	public static final int MOVEMENT_WORD_START = 1 << 4;
+
+	
+/**
+ * Answers a concise, human readable description of the error code.
+ *
+ * @param code the SWT error code.
+ * @return a description of the error code.
+ *
+ * @see SWT
+ */
+static String findErrorText (int code) {
+	switch (code) {
+		case ERROR_UNSPECIFIED:            return "Unspecified error"; //$NON-NLS-1$
+		case ERROR_NO_HANDLES:			   return "No more handles"; //$NON-NLS-1$
+		case ERROR_NO_MORE_CALLBACKS:      return "No more callbacks"; //$NON-NLS-1$
+		case ERROR_NULL_ARGUMENT:          return "Argument cannot be null"; //$NON-NLS-1$
+		case ERROR_INVALID_ARGUMENT:       return "Argument not valid"; //$NON-NLS-1$
+		case ERROR_INVALID_RANGE:          return "Index out of bounds"; //$NON-NLS-1$
+		case ERROR_CANNOT_BE_ZERO:         return "Argument cannot be zero"; //$NON-NLS-1$
+		case ERROR_CANNOT_GET_ITEM:        return "Cannot get item"; //$NON-NLS-1$
+		case ERROR_CANNOT_GET_SELECTION:   return "Cannot get selection"; //$NON-NLS-1$
+		case ERROR_CANNOT_GET_ITEM_HEIGHT: return "Cannot get item height"; //$NON-NLS-1$
+		case ERROR_CANNOT_GET_TEXT:        return "Cannot get text"; //$NON-NLS-1$
+		case ERROR_CANNOT_SET_TEXT:        return "Cannot set text"; //$NON-NLS-1$
+		case ERROR_ITEM_NOT_ADDED:         return "Item not added"; //$NON-NLS-1$
+		case ERROR_ITEM_NOT_REMOVED:       return "Item not removed"; //$NON-NLS-1$
+		case ERROR_NOT_IMPLEMENTED:        return "Not implemented"; //$NON-NLS-1$
+		case ERROR_MENU_NOT_DROP_DOWN:     return "Menu must be a drop down"; //$NON-NLS-1$
+		case ERROR_THREAD_INVALID_ACCESS:  return "Invalid thread access"; //$NON-NLS-1$
+		case ERROR_WIDGET_DISPOSED:        return "Widget is disposed"; //$NON-NLS-1$
+		case ERROR_MENUITEM_NOT_CASCADE:   return "Menu item is not a CASCADE"; //$NON-NLS-1$
+		case ERROR_CANNOT_SET_SELECTION:   return "Cannot set selection";  //$NON-NLS-1$
+		case ERROR_CANNOT_SET_MENU:        return "Cannot set menu";  //$NON-NLS-1$
+		case ERROR_CANNOT_SET_ENABLED:     return "Cannot set the enabled state";  //$NON-NLS-1$
+		case ERROR_CANNOT_GET_ENABLED:     return "Cannot get the enabled state";  //$NON-NLS-1$
+		case ERROR_INVALID_PARENT:         return "Widget has the wrong parent";  //$NON-NLS-1$
+		case ERROR_MENU_NOT_BAR:           return "Menu is not a BAR";  //$NON-NLS-1$
+		case ERROR_CANNOT_GET_COUNT:       return "Cannot get count"; //$NON-NLS-1$
+		case ERROR_MENU_NOT_POP_UP:        return "Menu is not a POP_UP"; //$NON-NLS-1$
+		case ERROR_UNSUPPORTED_DEPTH:      return "Unsupported color depth"; //$NON-NLS-1$
+		case ERROR_IO:                     return "i/o error"; //$NON-NLS-1$
+		case ERROR_INVALID_IMAGE:          return "Invalid image"; //$NON-NLS-1$
+		case ERROR_UNSUPPORTED_FORMAT:     return "Unsupported or unrecognized format"; //$NON-NLS-1$
+		case ERROR_INVALID_SUBCLASS:       return "Subclassing not allowed"; //$NON-NLS-1$
+		case ERROR_GRAPHIC_DISPOSED:       return "Graphic is disposed"; //$NON-NLS-1$
+		case ERROR_DEVICE_DISPOSED:        return "Device is disposed"; //$NON-NLS-1$
+		case ERROR_FAILED_EXEC:            return "Failed to execute runnable"; //$NON-NLS-1$
+		case ERROR_FAILED_LOAD_LIBRARY:    return "Unable to load library"; //$NON-NLS-1$
+		case ERROR_CANNOT_INVERT_MATRIX:    return "Cannot invert matrix"; //$NON-NLS-1$
+		case ERROR_NO_GRAPHICS_LIBRARY:    return "Unable to load graphics library"; //$NON-NLS-1$
+		case ERROR_INVALID_FONT:    		return "Font not valid"; //$NON-NLS-1$
+	}
+	return "Unknown error"; //$NON-NLS-1$
+}
+
+/**
+ * Returns the NLS'ed message for the given argument.
+ * 
+ * @param key the key to look up
+ * @return the message for the given key
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the key is null</li>
+ * </ul>
+ */
+public static String getMessage(String key) {
+	return Compatibility.getMessage(key);
+}
+	
+/**
+ * Returns the SWT platform name.
+ * Examples: "win32", "motif", "gtk", "photon", "carbon"
+ *
+ * @return the SWT platform name
+ */
+public static String getPlatform () {
+	return Platform.PLATFORM;
+}
+
+/**
+ * Returns the SWT version number as an integer.
+ * Example: "SWT051" == 51
+ *
+ * @return the SWT version number
+ */
+public static int getVersion () {
+	return Library.SWT_VERSION;
+}
+
+/**
+ * Throws an appropriate exception based on the passed in error code.
+ *
+ * @param code the SWT error code
+ */
+public static void error (int code) {
+	error (code, null);
+}
+
+/**
+ * Throws an appropriate exception based on the passed in error code.
+ * The <code>throwable</code> argument should be either null, or the
+ * throwable which caused SWT to throw an exception.
+ * <p>
+ * In SWT, errors are reported by throwing one of three exceptions:
+ * <dl>
+ * <dd>java.lang.IllegalArgumentException</dd>
+ * <dt>thrown whenever one of the API methods is invoked with an illegal argument</dt>
+ * <dd>org.eclipse.swt.SWTException (extends java.lang.RuntimeException)</dd>
+ * <dt>thrown whenever a recoverable error happens internally in SWT</dt>
+ * <dd>org.eclipse.swt.SWTError (extends java.lang.Error)</dd>
+ * <dt>thrown whenever a <b>non-recoverable</b> error happens internally in SWT</dt>
+ * </dl>
+ * This method provides the logic which maps between error codes
+ * and one of the above exceptions.
+ * </p>
+ *
+ * @param code the SWT error code.
+ * @param throwable the exception which caused the error to occur.
+ *
+ * @see SWTError
+ * @see SWTException
+ * @see IllegalArgumentException
+ */
+public static void error (int code, Throwable throwable) {
+	error (code, throwable, null);
+}
+
+/**
+ * Throws an appropriate exception based on the passed in error code.
+ * The <code>throwable</code> argument should be either null, or the
+ * throwable which caused SWT to throw an exception.
+ * <p>
+ * In SWT, errors are reported by throwing one of three exceptions:
+ * <dl>
+ * <dd>java.lang.IllegalArgumentException</dd>
+ * <dt>thrown whenever one of the API methods is invoked with an illegal argument</dt>
+ * <dd>org.eclipse.swt.SWTException (extends java.lang.RuntimeException)</dd>
+ * <dt>thrown whenever a recoverable error happens internally in SWT</dt>
+ * <dd>org.eclipse.swt.SWTError (extends java.lang.Error)</dd>
+ * <dt>thrown whenever a <b>non-recoverable</b> error happens internally in SWT</dt>
+ * </dl>
+ * This method provides the logic which maps between error codes
+ * and one of the above exceptions.
+ * </p>
+ *
+ * @param code the SWT error code.
+ * @param throwable the exception which caused the error to occur.
+ * @param detail more information about error.
+ *
+ * @see SWTError
+ * @see SWTException
+ * @see IllegalArgumentException
+ * 
+ * @since 3.0
+ */
+public static void error (int code, Throwable throwable, String detail) {
+
+	/*
+	* This code prevents the creation of "chains" of SWTErrors and
+	* SWTExceptions which in turn contain other SWTErrors and 
+	* SWTExceptions as their throwable. This can occur when low level
+	* code throws an exception past a point where a higher layer is
+	* being "safe" and catching all exceptions. (Note that, this is
+	* _a_bad_thing_ which we always try to avoid.)
+	*
+	* On the theory that the low level code is closest to the
+	* original problem, we simply re-throw the original exception here.
+	* 
+	* NOTE: Exceptions thrown in syncExec and asyncExec must be
+	* wrapped.
+	*/
+	if (code != SWT.ERROR_FAILED_EXEC) {
+		if (throwable instanceof SWTError) throw (SWTError) throwable;
+		if (throwable instanceof SWTException) throw (SWTException) throwable;
+	}
+
+	String message = findErrorText (code);
+	if (detail != null) message += detail;
+	switch (code) {
+		
+		/* Illegal Arguments (non-fatal) */
+		case ERROR_NULL_ARGUMENT: 
+		case ERROR_CANNOT_BE_ZERO:
+		case ERROR_INVALID_ARGUMENT:
+		case ERROR_MENU_NOT_BAR:
+		case ERROR_MENU_NOT_DROP_DOWN:
+		case ERROR_MENU_NOT_POP_UP:
+		case ERROR_MENUITEM_NOT_CASCADE:
+		case ERROR_INVALID_PARENT: 		
+		case ERROR_INVALID_RANGE: {
+			throw new IllegalArgumentException (message);
+		}
+		
+		/* SWT Exceptions (non-fatal) */
+		case ERROR_INVALID_SUBCLASS:
+		case ERROR_THREAD_INVALID_ACCESS:
+		case ERROR_WIDGET_DISPOSED:
+		case ERROR_GRAPHIC_DISPOSED:
+		case ERROR_DEVICE_DISPOSED:
+		case ERROR_INVALID_IMAGE:
+		case ERROR_UNSUPPORTED_DEPTH:
+		case ERROR_UNSUPPORTED_FORMAT:
+		case ERROR_FAILED_EXEC:
+		case ERROR_CANNOT_INVERT_MATRIX:
+		case ERROR_NO_GRAPHICS_LIBRARY:
+		case ERROR_IO: {
+			SWTException exception = new SWTException (code, message);
+			exception.throwable = throwable;
+			throw exception;
+		}
+		
+		/* Operation System Errors (fatal, may occur only on some platforms) */
+		case ERROR_CANNOT_GET_COUNT:
+		case ERROR_CANNOT_GET_ENABLED:
+		case ERROR_CANNOT_GET_ITEM:
+		case ERROR_CANNOT_GET_ITEM_HEIGHT:
+		case ERROR_CANNOT_GET_SELECTION:
+		case ERROR_CANNOT_GET_TEXT:
+		case ERROR_CANNOT_SET_ENABLED:
+		case ERROR_CANNOT_SET_MENU:
+		case ERROR_CANNOT_SET_SELECTION:
+		case ERROR_CANNOT_SET_TEXT:
+		case ERROR_ITEM_NOT_ADDED:
+		case ERROR_ITEM_NOT_REMOVED:
+		case ERROR_NO_HANDLES:
+		//FALL THROUGH
+		
+		/* SWT Errors (fatal, may occur only on some platforms) */
+		case ERROR_FAILED_LOAD_LIBRARY:
+		case ERROR_NO_MORE_CALLBACKS:
+		case ERROR_NOT_IMPLEMENTED:
+		case ERROR_UNSPECIFIED: {
+			SWTError error = new SWTError (code, message);
+			error.throwable = throwable;
+			throw error;
+		}
+	}
+	
+	/* Unknown/Undefined Error */
+	SWTError error = new SWTError (code, message);
+	error.throwable = throwable;
+	throw error;
+}
+
+static {
+	/*
+	* These values represent bit masks that may need to
+	* expand in the future.  Therefore they are not initialized
+	* in the declaration to stop the compiler from inlining.
+	*/
+	BUTTON_MASK = BUTTON1 | BUTTON2 | BUTTON3 | BUTTON4 | BUTTON5;
+	MODIFIER_MASK = ALT | SHIFT | CTRL | COMMAND;
+	
+	/*
+	* These values can be different on different platforms.
+	* Therefore they are not initialized in the declaration
+	* to stop the compiler from inlining.
+	*/
+	String platform = getPlatform ();
+	if ("carbon".equals (platform)) { //$NON-NLS-1$
+		MOD1 = COMMAND;
+		MOD2 = SHIFT;
+		MOD3 = ALT;
+		MOD4 = CONTROL;
+	} else {
+		MOD1 = CONTROL;
+		MOD2 = SHIFT;
+		MOD3 = ALT;
+		MOD4 = 0;
+	}
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/SWTError.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/SWTError.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/SWTError.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,146 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt;
+
+import org.eclipse.swt.internal.*;
+
+/**
+ * This error is thrown whenever an unrecoverable error
+ * occurs internally in SWT. The message text and error code 
+ * provide a further description of the problem. The exception
+ * has a <code>throwable</code> field which holds the underlying
+ * throwable that caused the problem (if this information is
+ * available (i.e. it may be null)).
+ * <p>
+ * SWTErrors are thrown when something fails internally which
+ * either leaves SWT in an unknown state (eg. the o/s call to
+ * remove an item from a list returns an error code) or when SWT
+ * is left in a known-to-be-unrecoverable state (eg. it runs out
+ * of callback resources). SWTErrors should not occur in typical
+ * programs, although "high reliability" applications should
+ * still catch them.
+ * </p><p>
+ * This class also provides support methods used by SWT to match
+ * error codes to the appropriate exception class (SWTError, 
+ * SWTException, or IllegalArgumentException) and to provide
+ * human readable strings for SWT error codes.
+ * </p>
+ *
+ * @see SWTException
+ * @see SWT#error(int)
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+
+public class SWTError extends Error {
+    /**
+     * The SWT error code, one of SWT.ERROR_*.
+     */
+	public int code;
+
+	/**
+	 * The underlying throwable that caused the problem,
+	 * or null if this information is not available.
+	 */
+	public Throwable throwable;
+
+    static final long serialVersionUID = 3833467327105808433L;
+    
+/**
+ * Constructs a new instance of this class with its 
+ * stack trace filled in. The error code is set to an
+ * unspecified value.
+ */
+public SWTError () {
+	this (SWT.ERROR_UNSPECIFIED);
+}
+
+/**
+ * Constructs a new instance of this class with its 
+ * stack trace and message filled in. The error code is
+ * set to an unspecified value.  Specifying <code>null</code>
+ * as the message is equivalent to specifying an empty string.
+ *
+ * @param message the detail message for the exception
+ */
+public SWTError (String message) {
+	this (SWT.ERROR_UNSPECIFIED, message);
+}
+
+/**
+ * Constructs a new instance of this class with its 
+ * stack trace and error code filled in.
+ *
+ * @param code the SWT error code
+ */
+public SWTError (int code) {
+	this (code, SWT.findErrorText (code));
+}
+
+/**
+ * Constructs a new instance of this class with its 
+ * stack trace, error code and message filled in.
+ * Specifying <code>null</code> as the message is
+ * equivalent to specifying an empty string.
+ * 
+ * @param code the SWT error code
+ * @param message the detail message for the exception
+ */
+public SWTError (int code, String message) {
+	super (message);
+	this.code = code;
+}
+
+/**
+ * Returns the underlying throwable that caused the problem,
+ * or null if this information is not available.
+ * <p>
+ * NOTE: This method overrides Throwable.getCause() that was
+ * added to JDK1.4. It is necessary to override this method
+ * in order for inherited printStackTrace() methods to work.
+ * </p>
+ * @return the underlying throwable
+ * 
+ * @since 3.1
+ */
+public Throwable getCause() {
+	return throwable;
+}
+
+/**
+ *  Returns the string describing this SWTError object.
+ *  <p>
+ *  It is combined with the message string of the Throwable
+ *  which caused this SWTError (if this information is available).
+ *  </p>
+ *  @return the error message string of this SWTError object
+ */
+public String getMessage () {
+	if (throwable == null) return super.getMessage ();
+	return super.getMessage () + " (" + throwable.toString () + ")"; //$NON-NLS-1$ //$NON-NLS-2$
+}
+
+/**
+ * Outputs a printable representation of this error's
+ * stack trace on the standard error stream.
+ * <p>
+ * Note: printStackTrace(PrintStream) and printStackTrace(PrintWriter)
+ * are not provided in order to maintain compatibility with CLDC.
+ * </p>
+ */
+public void printStackTrace () {
+	super.printStackTrace ();
+	if (Library.JAVA_VERSION < Library.JAVA_VERSION(1, 4, 0) && throwable != null) {
+		System.err.println ("*** Stack trace of contained error ***"); //$NON-NLS-1$
+		throwable.printStackTrace ();
+	}
+}
+
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/SWTException.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/SWTException.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/SWTException.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,139 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt;
+
+import org.eclipse.swt.internal.*;
+
+/**
+ * This runtime exception is thrown whenever a recoverable error
+ * occurs internally in SWT. The message text and error code 
+ * provide a further description of the problem. The exception
+ * has a <code>throwable</code> field which holds the underlying
+ * exception that caused the problem (if this information is
+ * available (i.e. it may be null)).
+ * <p>
+ * SWTExceptions are thrown when something fails internally,
+ * but SWT is left in a known stable state (eg. a widget call
+ * was made from a non-u/i thread, or there is failure while
+ * reading an Image because the source file was corrupt).
+ * </p>
+ *
+ * @see SWTError
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+
+public class SWTException extends RuntimeException {
+	/**
+	 * The SWT error code, one of SWT.ERROR_*.
+	 */
+	public int code;
+
+	/**
+	 * The underlying throwable that caused the problem,
+	 * or null if this information is not available.
+	 */
+	public Throwable throwable;
+	
+	static final long serialVersionUID = 3257282552304842547L;
+	
+/**
+ * Constructs a new instance of this class with its 
+ * stack trace filled in. The error code is set to an
+ * unspecified value.
+ */
+public SWTException () {
+	this (SWT.ERROR_UNSPECIFIED);
+}
+
+/**
+ * Constructs a new instance of this class with its 
+ * stack trace and message filled in. The error code is
+ * set to an unspecified value.  Specifying <code>null</code>
+ * as the message is equivalent to specifying an empty string.
+ *
+ * @param message the detail message for the exception
+ */
+public SWTException (String message) {
+	this (SWT.ERROR_UNSPECIFIED, message);
+}
+
+/**
+ * Constructs a new instance of this class with its 
+ * stack trace and error code filled in.
+ *
+ * @param code the SWT error code
+ */
+public SWTException (int code) {
+	this (code, SWT.findErrorText (code));
+}
+
+/**
+ * Constructs a new instance of this class with its 
+ * stack trace, error code and message filled in.
+ * Specifying <code>null</code> as the message is
+ * equivalent to specifying an empty string.
+ *
+ * @param code the SWT error code
+ * @param message the detail message for the exception
+ */
+public SWTException (int code, String message) {
+	super (message);
+	this.code = code;
+}
+
+/**
+ * Returns the underlying throwable that caused the problem,
+ * or null if this information is not available.
+ * <p>
+ * NOTE: This method overrides Throwable.getCause() that was
+ * added to JDK1.4. It is necessary to override this method
+ * in order for inherited printStackTrace() methods to work.
+ * </p>
+ * @return the underlying throwable
+ * 
+ * @since 3.1
+ */
+public Throwable getCause() {
+	return throwable;
+}
+
+/**
+ *  Returns the string describing this SWTException object.
+ *  <p>
+ *  It is combined with the message string of the Throwable
+ *  which caused this SWTException (if this information is available).
+ *  </p>
+ *  @return the error message string of this SWTException object
+ */
+public String getMessage () {
+	if (throwable == null) return super.getMessage ();
+	return super.getMessage () + " (" + throwable.toString () + ")"; //$NON-NLS-1$ //$NON-NLS-2$
+}
+
+/**
+ * Outputs a printable representation of this exception's
+ * stack trace on the standard error stream.
+ * <p>
+ * Note: printStackTrace(PrintStream) and printStackTrace(PrintWriter)
+ * are not provided in order to maintain compatibility with CLDC.
+ * </p>
+ */
+public void printStackTrace () {
+	super.printStackTrace ();
+	if (Library.JAVA_VERSION < Library.JAVA_VERSION(1, 4, 0) && throwable != null) {
+		System.err.println ("*** Stack trace of contained exception ***"); //$NON-NLS-1$
+		throwable.printStackTrace ();
+	}
+}
+
+}
+
+

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/accessibility/ACC.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/accessibility/ACC.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/accessibility/ACC.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,79 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.accessibility;
+
+
+/**
+ * Class ACC contains all the constants used in defining an
+ * Accessible object.
+ *
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ * 
+ * @since 2.0
+ */
+public class ACC {
+	public static final int STATE_NORMAL = 0x00000000;
+	public static final int STATE_SELECTED = 0x00000002;
+	public static final int STATE_SELECTABLE = 0x00200000;
+	public static final int STATE_MULTISELECTABLE = 0x1000000;
+	public static final int STATE_FOCUSED = 0x00000004;
+	public static final int STATE_FOCUSABLE = 0x00100000;
+	public static final int STATE_PRESSED = 0x8;
+	public static final int STATE_CHECKED = 0x10;
+	public static final int STATE_EXPANDED = 0x200;
+	public static final int STATE_COLLAPSED = 0x400;
+	public static final int STATE_HOTTRACKED = 0x80;
+	public static final int STATE_BUSY = 0x800;
+	public static final int STATE_READONLY = 0x40;
+	public static final int STATE_INVISIBLE = 0x8000;
+	public static final int STATE_OFFSCREEN = 0x10000;
+	public static final int STATE_SIZEABLE = 0x20000;
+	public static final int STATE_LINKED = 0x400000;
+
+	public static final int ROLE_CLIENT_AREA = 0xa;
+	public static final int ROLE_WINDOW = 0x9;
+	public static final int ROLE_MENUBAR = 0x2;
+	public static final int ROLE_MENU = 0xb;
+	public static final int ROLE_MENUITEM = 0xc;
+	public static final int ROLE_SEPARATOR = 0x15;
+	public static final int ROLE_TOOLTIP = 0xd;
+	public static final int ROLE_SCROLLBAR = 0x3;
+	public static final int ROLE_DIALOG = 0x12;
+	public static final int ROLE_LABEL = 0x29;
+	public static final int ROLE_PUSHBUTTON = 0x2b;
+	public static final int ROLE_CHECKBUTTON = 0x2c;
+	public static final int ROLE_RADIOBUTTON = 0x2d;
+	public static final int ROLE_COMBOBOX = 0x2e;
+	public static final int ROLE_TEXT = 0x2a;
+	public static final int ROLE_TOOLBAR = 0x16;
+	public static final int ROLE_LIST = 0x21;
+	public static final int ROLE_LISTITEM = 0x22;
+	public static final int ROLE_TABLE = 0x18;
+	public static final int ROLE_TABLECELL = 0x1d;
+	public static final int ROLE_TABLECOLUMNHEADER = 0x19;
+	/** @deprecated use ROLE_TABLECOLUMNHEADER */
+	public static final int ROLE_TABLECOLUMN = ROLE_TABLECOLUMNHEADER;
+	public static final int ROLE_TABLEROWHEADER = 0x1a;
+	public static final int ROLE_TREE = 0x23;
+	public static final int ROLE_TREEITEM = 0x24;
+	public static final int ROLE_TABFOLDER = 0x3c;
+	public static final int ROLE_TABITEM = 0x25;
+	public static final int ROLE_PROGRESSBAR = 0x30;
+	public static final int ROLE_SLIDER = 0x33;
+	public static final int ROLE_LINK = 0x1e;
+
+	public static final int CHILDID_SELF = -1;
+	public static final int CHILDID_NONE = -2;
+	public static final int CHILDID_MULTIPLE = -3;
+	
+	public static final int TEXT_INSERT = 0;
+	public static final int TEXT_DELETE = 1;
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/accessibility/Accessible.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/accessibility/Accessible.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/accessibility/Accessible.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,392 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.accessibility;
+
+
+import java.util.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.widgets.*;
+
+/**
+ * Instances of this class provide a bridge between application
+ * code and assistive technology clients. Many platforms provide
+ * default accessible behavior for most widgets, and this class
+ * allows that default behavior to be overridden. Applications
+ * can get the default Accessible object for a control by sending
+ * it <code>getAccessible</code>, and then add an accessible listener
+ * to override simple items like the name and help string, or they
+ * can add an accessible control listener to override complex items.
+ * As a rule of thumb, an application would only want to use the
+ * accessible control listener to implement accessibility for a
+ * custom control.
+ * 
+ * @see Control#getAccessible
+ * @see AccessibleListener
+ * @see AccessibleEvent
+ * @see AccessibleControlListener
+ * @see AccessibleControlEvent
+ * @see <a href="http://www.eclipse.org/swt/snippets/#accessibility">Accessibility snippets</a>
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ * 
+ * @since 2.0
+ */
+public class Accessible {
+	Vector accessibleListeners = new Vector ();
+	Vector controlListeners = new Vector ();
+	Vector textListeners = new Vector ();
+	AccessibleObject accessibleObject;
+	Control control;
+	
+	Accessible (Control control) {
+		super ();
+		this.control = control;
+		AccessibleFactory.registerAccessible (this);
+		control.addDisposeListener (new DisposeListener () {
+			public void widgetDisposed (DisposeEvent e) {
+				release ();
+			}
+		});
+	}	
+	
+	/**
+	 * Adds the listener to the collection of listeners who will
+	 * be notified when an accessible client asks for certain strings,
+	 * such as name, description, help, or keyboard shortcut. The
+	 * listener is notified by sending it one of the messages defined
+	 * in the <code>AccessibleListener</code> interface.
+	 *
+	 * @param listener the listener that should be notified when the receiver
+	 * is asked for a name, description, help, or keyboard shortcut string
+	 *
+	 * @exception IllegalArgumentException <ul>
+	 *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+	 * </ul>
+	 * @exception SWTException <ul>
+	 *    <li>ERROR_WIDGET_DISPOSED - if the receiver's control has been disposed</li>
+	 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver's control</li>
+	 * </ul>
+	 *
+	 * @see AccessibleListener
+	 * @see #removeAccessibleListener
+	 */
+	public void addAccessibleListener (AccessibleListener listener) {
+		checkWidget ();
+		if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+		accessibleListeners.addElement (listener);	
+	}
+
+	/**
+	 * Adds the listener to the collection of listeners who will
+	 * be notified when an accessible client asks for custom control
+	 * specific information. The listener is notified by sending it
+	 * one of the messages defined in the <code>AccessibleControlListener</code>
+	 * interface.
+	 *
+	 * @param listener the listener that should be notified when the receiver
+	 * is asked for custom control specific information
+	 *
+	 * @exception IllegalArgumentException <ul>
+	 *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+	 * </ul>
+	 * @exception SWTException <ul>
+	 *    <li>ERROR_WIDGET_DISPOSED - if the receiver's control has been disposed</li>
+	 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver's control</li>
+	 * </ul>
+	 *
+	 * @see AccessibleControlListener
+	 * @see #removeAccessibleControlListener
+	 */
+	public void addAccessibleControlListener (AccessibleControlListener listener) {
+		checkWidget ();
+		if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+		controlListeners.addElement (listener);		
+	}
+
+	/**
+	 * Adds the listener to the collection of listeners who will
+	 * be notified when an accessible client asks for custom text control
+	 * specific information. The listener is notified by sending it
+	 * one of the messages defined in the <code>AccessibleTextListener</code>
+	 * interface.
+	 *
+	 * @param listener the listener that should be notified when the receiver
+	 * is asked for custom text control specific information
+	 *
+	 * @exception IllegalArgumentException <ul>
+	 *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+	 * </ul>
+	 * @exception SWTException <ul>
+	 *    <li>ERROR_WIDGET_DISPOSED - if the receiver's control has been disposed</li>
+	 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver's control</li>
+	 * </ul>
+	 *
+	 * @see AccessibleTextListener
+	 * @see #removeAccessibleTextListener
+	 * 
+	 * @since 3.0
+	 */
+	public void addAccessibleTextListener (AccessibleTextListener listener) {
+		checkWidget ();
+		if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+		textListeners.addElement (listener);		
+	}
+	
+	/**
+	 * Returns the control for this Accessible object. 
+	 *
+	 * @return the receiver's control
+	 * @since 3.0
+	 */
+	public Control getControl() {
+		return control;
+	}
+
+	/* checkWidget was copied from Widget, and rewritten to work in this package */
+	void checkWidget () {
+		if (!isValidThread ()) SWT.error (SWT.ERROR_THREAD_INVALID_ACCESS);
+		if (control.isDisposed ()) SWT.error (SWT.ERROR_WIDGET_DISPOSED);
+	}
+
+	AccessibleListener[] getAccessibleListeners () {
+		if (accessibleListeners == null) return null;
+		AccessibleListener[] result = new AccessibleListener [accessibleListeners.size ()];
+		accessibleListeners.copyInto (result);
+		return result;
+	}
+
+	int /*long*/ getControlHandle () {
+		return control.handle;
+	}
+
+	AccessibleControlListener[] getControlListeners () {
+		if (controlListeners == null) return null;
+		AccessibleControlListener[] result = new AccessibleControlListener [controlListeners.size ()];
+		controlListeners.copyInto (result);
+		return result;
+	}
+
+	AccessibleTextListener[] getTextListeners () {
+		if (textListeners == null) return null;
+		AccessibleTextListener[] result = new AccessibleTextListener [textListeners.size ()];
+		textListeners.copyInto (result);
+		return result;
+	}
+
+	/**
+	 * Invokes platform specific functionality to allocate a new accessible object.
+	 * <p>
+	 * <b>IMPORTANT:</b> This method is <em>not</em> part of the public
+	 * API for <code>Accessible</code>. It is marked public only so that it
+	 * can be shared within the packages provided by SWT. It is not
+	 * available on all platforms, and should never be called from
+	 * application code.
+	 * </p>
+	 *
+	 * @param control the control to get the accessible object for
+	 * @return the platform specific accessible object
+	 */
+	public static Accessible internal_new_Accessible (Control control) {
+		return new Accessible (control);
+	}
+
+	/* isValidThread was copied from Widget, and rewritten to work in this package */
+	boolean isValidThread () {
+		return control.getDisplay ().getThread () == Thread.currentThread ();
+	}
+	
+	void release () {
+		AccessibleFactory.unregisterAccessible (Accessible.this);
+		if (accessibleObject != null) {
+			accessibleObject.release ();
+			accessibleObject = null;
+		}
+		accessibleListeners = null;
+		controlListeners = null;
+		textListeners = null;
+	}
+	/**
+	 * Removes the listener from the collection of listeners who will
+	 * be notified when an accessible client asks for custom control
+	 * specific information.
+	 *
+	 * @param listener the listener that should no longer be notified when the receiver
+	 * is asked for custom control specific information
+	 *
+	 * @exception IllegalArgumentException <ul>
+	 *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+	 * </ul>
+	 * @exception SWTException <ul>
+	 *    <li>ERROR_WIDGET_DISPOSED - if the receiver's control has been disposed</li>
+	 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver's control</li>
+	 * </ul>
+	 *
+	 * @see AccessibleControlListener
+	 * @see #addAccessibleControlListener
+	 */
+	public void removeAccessibleControlListener (AccessibleControlListener listener) {
+		checkWidget ();
+		if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+		controlListeners.removeElement (listener);
+	}
+
+	/**
+	 * Removes the listener from the collection of listeners who will
+	 * be notified when an accessible client asks for certain strings,
+	 * such as name, description, help, or keyboard shortcut.
+	 *
+	 * @param listener the listener that should no longer be notified when the receiver
+	 * is asked for a name, description, help, or keyboard shortcut string
+	 *
+	 * @exception IllegalArgumentException <ul>
+	 *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+	 * </ul>
+	 * @exception SWTException <ul>
+	 *    <li>ERROR_WIDGET_DISPOSED - if the receiver's control has been disposed</li>
+	 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver's control</li>
+	 * </ul>
+	 *
+	 * @see AccessibleListener
+	 * @see #addAccessibleListener
+	 */
+	public void removeAccessibleListener (AccessibleListener listener) {
+		checkWidget ();
+		if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+		accessibleListeners.removeElement (listener);
+	}
+
+	/**
+	 * Removes the listener from the collection of listeners who will
+	 * be notified when an accessible client asks for custom text control
+	 * specific information.
+	 *
+	 * @param listener the listener that should no longer be notified when the receiver
+	 * is asked for custom text control specific information
+	 *
+	 * @exception IllegalArgumentException <ul>
+	 *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+	 * </ul>
+	 * @exception SWTException <ul>
+	 *    <li>ERROR_WIDGET_DISPOSED - if the receiver's control has been disposed</li>
+	 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver's control</li>
+	 * </ul>
+	 *
+	 * @see AccessibleTextListener
+	 * @see #addAccessibleTextListener
+	 * 
+	 * @since 3.0
+	 */
+	public void removeAccessibleTextListener (AccessibleTextListener listener) {
+		checkWidget ();
+		if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+		textListeners.removeElement (listener);
+	}
+	
+	/**
+	 * Sends a message to accessible clients that the child selection
+	 * within a custom container control has changed.
+	 *
+	 * @exception SWTException <ul>
+	 *    <li>ERROR_WIDGET_DISPOSED - if the receiver's control has been disposed</li>
+	 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver's control</li>
+	 * </ul>
+	 * 
+	 * @since 3.0
+	 */
+	public void selectionChanged () {
+		checkWidget ();
+		if (accessibleObject != null) {
+			accessibleObject.selectionChanged ();
+		}
+	}
+
+	/**
+	 * Sends a message to accessible clients indicating that the focus
+	 * has changed within a custom control.
+	 *
+	 * @param childID an identifier specifying a child of the control
+	 * 
+	 * @exception SWTException <ul>
+	 *    <li>ERROR_WIDGET_DISPOSED - if the receiver's control has been disposed</li>
+	 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver's control</li>
+	 * </ul>
+	 */
+	public void setFocus (int childID) {
+		checkWidget ();
+		if (accessibleObject != null) {
+			accessibleObject.setFocus (childID);
+		}
+	}
+	
+	/**
+	 * Sends a message to accessible clients that the text
+	 * caret has moved within a custom control.
+	 *
+	 * @param index the new caret index within the control
+	 * 
+	 * @exception SWTException <ul>
+	 *    <li>ERROR_WIDGET_DISPOSED - if the receiver's control has been disposed</li>
+	 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver's control</li>
+	 * </ul>
+	 *
+	 * @since 3.0
+	 */
+	public void textCaretMoved (int index) {
+		checkWidget ();
+		if (accessibleObject != null) {
+			accessibleObject.textCaretMoved (index);
+		}
+	}
+
+	/**
+	 * Sends a message to accessible clients that the text
+	 * within a custom control has changed.
+	 *
+	 * @param type the type of change, one of <code>ACC.NOTIFY_TEXT_INSERT</code>
+	 * or <code>ACC.NOTIFY_TEXT_DELETE</code>
+	 * @param startIndex the text index within the control where the insertion or deletion begins
+	 * @param length the non-negative length in characters of the insertion or deletion
+	 *
+	 * @exception SWTException <ul>
+	 *    <li>ERROR_WIDGET_DISPOSED - if the receiver's control has been disposed</li>
+	 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver's control</li>
+	 * </ul>
+	 * 
+	 * @see ACC#TEXT_INSERT
+	 * @see ACC#TEXT_DELETE
+	 * 
+	 * @since 3.0
+	 */
+	public void textChanged (int type, int startIndex, int length) {
+		checkWidget ();
+		if (accessibleObject != null) {
+			accessibleObject.textChanged (type, startIndex, length);
+		}
+	}
+
+	/**
+	 * Sends a message to accessible clients that the text
+	 * selection has changed within a custom control.
+	 *
+	 * @exception SWTException <ul>
+	 *    <li>ERROR_WIDGET_DISPOSED - if the receiver's control has been disposed</li>
+	 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver's control</li>
+	 * </ul>
+	 *
+	 * @since 3.0
+	 */
+	public void textSelectionChanged () {
+		checkWidget ();
+		if (accessibleObject != null) {
+			accessibleObject.textSelectionChanged ();
+		}
+	}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/accessibility/AccessibleAdapter.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/accessibility/AccessibleAdapter.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/accessibility/AccessibleAdapter.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,129 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.accessibility;
+
+
+/**
+ * This adapter class provides default implementations for the
+ * methods described by the <code>AccessibleListener</code> interface.
+ * <p>
+ * Classes that wish to deal with <code>AccessibleEvent</code>s can
+ * extend this class and override only the methods that they are
+ * interested in.
+ * </p><p>
+ * Note: Accessibility clients use child identifiers to specify
+ * whether they want information about a control or one of its children.
+ * Child identifiers are increasing integers beginning with 0.
+ * The identifier CHILDID_SELF represents the control itself.
+ * </p>
+ *
+ * @see AccessibleListener
+ * @see AccessibleEvent
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ * 
+ * @since 2.0
+ */
+public abstract class AccessibleAdapter implements AccessibleListener {
+
+	/**
+	 * Sent when an accessibility client requests the name
+	 * of the control, or the name of a child of the control.
+	 * The default behavior is to do nothing.
+	 * <p>
+	 * Return the name of the control or specified child in the
+	 * <code>result</code> field of the event object. Returning
+	 * an empty string tells the client that the control or child
+	 * does not have a name, and returning null tells the client
+	 * to use the platform name.
+	 * </p>
+	 *
+	 * @param e an event object containing the following fields:<ul>
+	 *    <li>childID [IN] - an identifier specifying the control or one of its children</li>
+	 *    <li>result [OUT] - the requested name string, or null</li>
+	 * </ul>
+	 */
+	public void getName(AccessibleEvent e) {
+	}
+		
+	/**
+	 * Sent when an accessibility client requests the help string
+	 * of the control, or the help string of a child of the control.
+	 * The default behavior is to do nothing.
+	 * <p>
+	 * The information in this property should be similar to the help
+	 * provided by toolTipText. It describes what the control or child
+	 * does or how to use it, as opposed to getDescription, which
+	 * describes appearance.
+	 * </p><p>
+	 * Return the help string of the control or specified child in
+	 * the <code>result</code> field of the event object. Returning
+	 * an empty string tells the client that the control or child
+	 * does not have a help string, and returning null tells the
+	 * client to use the platform help string.
+	 * </p>
+	 *
+	 * @param e an event object containing the following fields:<ul>
+	 *    <li>childID [IN] - an identifier specifying the control or one of its children</li>
+	 *    <li>result [OUT] - the requested help string, or null</li>
+	 * </ul>
+	 */
+	public void getHelp(AccessibleEvent e) {
+	}
+		
+	/**
+	 * Sent when an accessibility client requests the keyboard shortcut
+	 * of the control, or the keyboard shortcut of a child of the control.
+	 * The default behavior is to do nothing.
+	 * <p>
+	 * A keyboard shortcut can either be a mnemonic, or an accelerator.
+	 * As a general rule, if the control or child can receive keyboard focus,
+	 * then you should expose its mnemonic, and if it cannot receive keyboard
+	 * focus, then you should expose its accelerator.
+	 * </p><p>
+	 * Return the keyboard shortcut string of the control or specified child
+	 * in the <code>result</code> field of the event object. Returning an
+	 * empty string tells the client that the control or child does not
+	 * have a keyboard shortcut string, and returning null tells the client
+	 * to use the platform keyboard shortcut string.
+	 * </p>
+	 *
+	 * @param e an event object containing the following fields:<ul>
+	 *    <li>childID [IN] - an identifier specifying the control or one of its children</li>
+	 *    <li>result [OUT] - the requested keyboard shortcut string (example: "ALT+N"), or null</li>
+	 * </ul>
+	 */
+	public void getKeyboardShortcut(AccessibleEvent e) {
+	}
+		
+	/**
+	 * Sent when an accessibility client requests a description
+	 * of the control, or a description of a child of the control.
+	 * The default behavior is to do nothing.
+	 * <p>
+	 * This is a textual description of the control or child's visual
+	 * appearance, which is typically only necessary if it cannot be
+	 * determined from other properties such as role.
+	 * </p><p>
+	 * Return the description of the control or specified child in
+	 * the <code>result</code> field of the event object. Returning
+	 * an empty string tells the client that the control or child
+	 * does not have a description, and returning null tells the
+	 * client to use the platform description.
+	 * </p>
+	 *
+	 * @param e an event object containing the following fields:<ul>
+	 *    <li>childID [IN] - an identifier specifying the control or one of its children</li>
+	 *    <li>result [OUT] - the requested description string, or null</li>
+	 * </ul>
+	 */
+	public void getDescription(AccessibleEvent e) {
+	}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/accessibility/AccessibleControlAdapter.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/accessibility/AccessibleControlAdapter.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/accessibility/AccessibleControlAdapter.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,252 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.accessibility;
+
+
+/**
+ * This adapter class provides default implementations for the
+ * methods described by the <code>AccessibleControlListener</code> interface.
+ * <p>
+ * Classes that wish to deal with <code>AccessibleControlEvent</code>s can
+ * extend this class and override only the methods that they are
+ * interested in.
+ * </p><p>
+ * Note: Accessibility clients use child identifiers to specify
+ * whether they want information about a control or one of its children.
+ * Child identifiers are increasing integers beginning with 0.
+ * The identifier CHILDID_SELF represents the control itself.
+ * When returning a child identifier to a client, you may use CHILDID_NONE
+ * to indicate that no child or control has the required information.
+ * </p><p>
+ * Note: This adapter is typically used by implementors of
+ * a custom control to provide very detailed information about
+ * the control instance to accessibility clients.
+ * </p>
+ *
+ * @see AccessibleControlListener
+ * @see AccessibleControlEvent
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ * 
+ * @since 2.0
+ */
+public abstract class AccessibleControlAdapter implements AccessibleControlListener {
+
+	/**
+	 * Sent when an accessibility client requests the identifier
+	 * of the control child at the specified display coordinates.
+	 * The default behavior is to do nothing.
+	 * <p>
+	 * Return the identifier of the child at display point (x, y)
+	 * in the <code>childID</code> field of the event object.
+	 * Return CHILDID_SELF if point (x, y) is in the control itself
+	 * and not in any child. Return CHILDID_NONE if point (x, y)
+	 * is not contained in either the control or any of its children.
+	 * </p>
+	 *
+	 * @param e an event object containing the following fields:<ul>
+	 *    <li>x, y [IN] - the specified point in display coordinates</li>
+	 *    <li>childID [Typical OUT] - the ID of the child at point, or CHILDID_SELF, or CHILDID_NONE</li>
+	 *    <li>accessible [Optional OUT] - the accessible object for the control or child may be returned instead of the childID</li>
+	 * </ul>
+	 */
+	public void getChildAtPoint(AccessibleControlEvent e) {
+	}
+	
+	/**
+	 * Sent when an accessibility client requests the location
+	 * of the control, or the location of a child of the control.
+	 * The default behavior is to do nothing.
+	 * <p>
+	 * Return a rectangle describing the location of the specified
+	 * control or child in the <code>x, y, width, and height</code>
+	 * fields of the event object.
+	 * </p>
+	 *
+	 * @param e an event object containing the following fields:<ul>
+	 *    <li>childID [IN] - an identifier specifying the control or one of its children</li>
+	 *    <li>x, y, width, height [OUT] - the control or child location in display coordinates</li>
+	 * </ul>
+	 */
+	public void getLocation(AccessibleControlEvent e) {
+	}
+	
+	/**
+	 * Sent when an accessibility client requests the accessible object
+	 * for a child of the control.
+	 * The default behavior is to do nothing.
+	 * <p>
+	 * Return an <code>Accessible</code> for the specified control or
+	 * child in the <code>accessible</code> field of the event object.
+	 * Return null if the specified child does not have its own
+	 * <code>Accessible</code>.
+	 * </p>
+	 *
+	 * @param e an event object containing the following fields:<ul>
+	 *    <li>childID [IN] - an identifier specifying a child of the control</li>
+	 *    <li>accessible [OUT] - an Accessible for the specified childID, or null if one does not exist</li>
+	 * </ul>
+	 */
+	public void getChild(AccessibleControlEvent e) {
+	}
+	
+	/**
+	 * Sent when an accessibility client requests the number of
+	 * children in the control.
+	 * The default behavior is to do nothing.
+	 * <p>
+	 * Return the number of child items in the <code>detail</code>
+	 * field of the event object.
+	 * </p>
+	 *
+	 * @param e an event object containing the following fields:<ul>
+	 *    <li>detail [OUT] - the number of child items in this control</li>
+	 * </ul>
+	 */
+	public void getChildCount(AccessibleControlEvent e) {
+	}
+	
+	/**
+	 * Sent when an accessibility client requests the default action
+	 * of the control, or the default action of a child of the control.
+	 * The default behavior is to do nothing.
+	 * <p>
+	 * This string is typically a verb describing what the user does to it.
+	 * For example, a Push Button's default action is "Press", a Check Button's
+	 * is "Check" or "UnCheck", and List items have the default action "Double Click".
+	 * </p><p>
+	 * Return a string describing the default action of the specified
+	 * control or child in the <code>result</code> field of the event object.
+	 * Returning null tells the client to use the platform default action string.
+	 * </p>
+	 *
+	 * @param e an event object containing the following fields:<ul>
+	 *    <li>childID [IN] - an identifier specifying the control or one of its children</li>
+	 *    <li>result [OUT] - the requested default action string, or null</li>
+	 * </ul>
+	 */
+	public void getDefaultAction(AccessibleControlEvent e) {
+	}
+	
+	/**
+	 * Sent when an accessibility client requests the identity of
+	 * the child or control that has keyboard focus.
+	 * The default behavior is to do nothing.
+	 * <p>
+	 * Return the identifier of the child that has focus in the
+	 * <code>childID</code> field of the event object.
+	 * Return CHILDID_SELF if the control itself has keyboard focus.
+	 * Return CHILDID_NONE if neither the control nor any of its children has focus.
+	 * </p>
+	 *
+	 * @param e an event object containing the following fields:<ul>
+	 *    <li>childID [Typical OUT] - the ID of the child with focus, or CHILDID_SELF, or CHILDID_NONE</li>
+	 *    <li>accessible [Optional OUT] - the accessible object for a child may be returned instead of its childID</li>
+	 * </ul>
+	 */
+	public void getFocus(AccessibleControlEvent e) {
+	}
+	
+	/**
+	 * Sent when an accessibility client requests the role
+	 * of the control, or the role of a child of the control.
+	 * The default behavior is to do nothing.
+	 * <p>
+	 * Return a role constant (constant defined in ACC beginning with ROLE_)
+	 * that describes the role of the specified control or child in the
+	 * <code>detail</code> field of the event object.
+	 * </p>
+	 *
+	 * @param e an event object containing the following fields:<ul>
+	 *    <li>childID [IN] - an identifier specifying the control or one of its children</li>
+	 *    <li>detail [OUT] - a role constant describing the role of the control or child</li>
+	 * </ul>
+	 */
+	public void getRole(AccessibleControlEvent e) {
+	}
+	
+	/**
+	 * Sent when an accessibility client requests the identity of
+	 * the child or control that is currently selected.
+	 * The default behavior is to do nothing.
+	 * <p>
+	 * Return the identifier of the selected child in the
+	 * <code>childID</code> field of the event object.
+	 * Return CHILDID_SELF if the control itself is selected.
+	 * Return CHILDID_MULTIPLE if multiple children are selected, and return an array of childIDs in the <code>children</code> field.
+	 * Return CHILDID_NONE if neither the control nor any of its children are selected.
+	 * </p>
+	 *
+	 * @param e an event object containing the following fields:<ul>
+	 *    <li>childID [Typical OUT] - the ID of the selected child, or CHILDID_SELF, or CHILDID_MULTIPLE, or CHILDID_NONE</li>
+	 *    <li>accessible [Optional OUT] - the accessible object for the control or child may be returned instead of the childID</li>
+	 * </ul>
+	 */
+	public void getSelection(AccessibleControlEvent e) {
+	}
+	
+	/**
+	 * Sent when an accessibility client requests the state
+	 * of the control, or the state of a child of the control.
+	 * The default behavior is to do nothing.
+	 * <p>
+	 * Return a state mask (mask bit constants defined in ACC beginning with STATE_)
+	 * that describes the current state of the specified control or child in the
+	 * <code>detail</code> field of the event object.
+	 * </p>
+	 *
+	 * @param e an event object containing the following fields:<ul>
+	 *    <li>childID [IN] - an identifier specifying the control or one of its children</li>
+	 *    <li>detail [OUT] - a state mask describing the current state of the control or child</li>
+	 * </ul>
+	 */
+	public void getState(AccessibleControlEvent e) {
+	}
+	
+	/**
+	 * Sent when an accessibility client requests the value
+	 * of the control, or the value of a child of the control.
+	 * The default behavior is to do nothing.
+	 * <p>
+	 * Many controls do not return a value. Examples of controls
+	 * that do are: Combo returns the text string, Text returns
+	 * its contents, ProgressBar returns a string representing a
+	 * percentage, and Tree items return a string representing
+	 * their level in the tree.
+	 * </p><p>
+	 * Return a string describing the value of the specified control
+	 * or child in the <code>result</code> field of the event object.
+	 * Returning null tells the client to use the platform value string.
+	 * </p>
+	 *
+	 * @param e an event object containing the following fields:<ul>
+	 *    <li>childID [IN] - an identifier specifying the control or one of its children</li>
+	 *    <li>result [OUT] - the requested value string, or null</li>
+	 * </ul>
+	 */
+	public void getValue(AccessibleControlEvent e) {
+	}
+	
+	/**
+	 * Sent when an accessibility client requests the children of the control.
+	 * The default behavior is to do nothing.
+	 * <p>
+	 * Return the children as an array of childIDs in the <code>children</code>
+	 * field of the event object.
+	 * </p>
+	 *
+	 * @param e an event object containing the following fields:<ul>
+	 *    <li>children [Typical OUT] - an array of childIDs</li>
+	 *    <li>accessible [Optional OUT] - an array of accessible objects for the children may be returned instead of the childIDs</li>
+	 * </ul>
+	 */
+	public void getChildren(AccessibleControlEvent e) {
+	}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/accessibility/AccessibleControlEvent.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/accessibility/AccessibleControlEvent.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/accessibility/AccessibleControlEvent.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.accessibility;
+
+
+import org.eclipse.swt.internal.SWTEventObject;
+
+/**
+ * Instances of this class are sent as a result of
+ * accessibility clients sending messages to controls
+ * asking for detailed information about the implementation
+ * of the control instance. Typically, only implementors
+ * of custom controls need to listen for this event.
+ * <p>
+ * Note: The meaning of each field depends on the
+ * message that was sent.
+ * </p>
+ *
+ * @see AccessibleControlListener
+ * @see AccessibleControlAdapter
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ * 
+ * @since 2.0
+ */
+public class AccessibleControlEvent extends SWTEventObject {
+	public int childID;			// IN/OUT
+	public Accessible accessible;	// OUT
+	public int x, y;				// IN/OUT
+	public int width, height;		// OUT
+	public int detail;			// IN/OUT
+	public String result;			// OUT
+	public Object children[];		// [OUT]
+	
+	static final long serialVersionUID = 3257281444169529141L;
+	
+/**
+ * Constructs a new instance of this class.
+ *
+ * @param source the object that fired the event
+ */
+public AccessibleControlEvent(Object source) {
+	super(source);
+}
+
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the event
+ */
+public String toString () {
+	return "AccessibleControlEvent {childID=" + childID +  //$NON-NLS-1$
+		" accessible=" + accessible +  //$NON-NLS-1$
+		" x=" + x +  //$NON-NLS-1$
+		" y=" + y +  //$NON-NLS-1$
+		" width=" + width +  //$NON-NLS-1$
+		" height=" + height +  //$NON-NLS-1$
+		" detail=" + detail +  //$NON-NLS-1$
+		" result=" + result +  //$NON-NLS-1$
+		"}"; //$NON-NLS-1$
+}	
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/accessibility/AccessibleControlListener.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/accessibility/AccessibleControlListener.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/accessibility/AccessibleControlListener.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,233 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.accessibility;
+
+
+import org.eclipse.swt.internal.SWTEventListener;
+
+/**
+ * Classes that implement this interface provide methods
+ * that deal with the events that are generated when an
+ * accessibility client sends a message to a control.
+ * <p>
+ * After creating an instance of a class that implements
+ * this interface it can be added to a control using the
+ * <code>addAccessibleControlListener</code> method and removed
+ * using the <code>removeAccessibleControlListener</code> method.
+ * When a client requests information the appropriate method
+ * will be invoked.
+ * </p><p>
+ * Note: Accessibility clients use child identifiers to specify
+ * whether they want information about a control or one of its children.
+ * Child identifiers are increasing integers beginning with 0.
+ * The identifier CHILDID_SELF represents the control itself.
+ * </p><p>
+ * Note: This interface is typically used by implementors of
+ * a custom control to provide very detailed information about
+ * the control instance to accessibility clients.
+ * </p>
+ *
+ * @see AccessibleControlAdapter
+ * @see AccessibleControlEvent
+ * 
+ * @since 2.0
+ */
+public interface AccessibleControlListener extends SWTEventListener {
+
+	/**
+	 * Sent when an accessibility client requests the identifier
+	 * of the control child at the specified display coordinates.
+	 * <p>
+	 * Return the identifier of the child at display point (x, y)
+	 * in the <code>childID</code> field of the event object.
+	 * Return CHILDID_SELF if point (x, y) is in the control itself
+	 * and not in any child. Return CHILDID_NONE if point (x, y)
+	 * is not contained in either the control or any of its children.
+	 * </p>
+	 *
+	 * @param e an event object containing the following fields:<ul>
+	 *    <li>x, y [IN] - the specified point in display coordinates</li>
+	 *    <li>childID [Typical OUT] - the ID of the child at point, or CHILDID_SELF, or CHILDID_NONE</li>
+	 *    <li>accessible [Optional OUT] - the accessible object for the control or child may be returned instead of the childID</li>
+	 * </ul>
+	 */
+	public void getChildAtPoint(AccessibleControlEvent e);
+
+	/**
+	 * Sent when an accessibility client requests the location
+	 * of the control, or the location of a child of the control.
+	 * <p>
+	 * Return a rectangle describing the location of the specified
+	 * control or child in the <code>x, y, width, and height</code>
+	 * fields of the event object.
+	 * </p>
+	 *
+	 * @param e an event object containing the following fields:<ul>
+	 *    <li>childID [IN] - an identifier specifying the control or one of its children</li>
+	 *    <li>x, y, width, height [OUT] - the control or child location in display coordinates</li>
+	 * </ul>
+	 */
+	public void getLocation(AccessibleControlEvent e);
+	
+	/**
+	 * Sent when an accessibility client requests the accessible object
+	 * for a child of the control.
+	 * <p>
+	 * Return an <code>Accessible</code> for the specified control or
+	 * child in the <code>accessible</code> field of the event object.
+	 * Return null if the specified child does not have its own
+	 * <code>Accessible</code>.
+	 * </p>
+	 *
+	 * @param e an event object containing the following fields:<ul>
+	 *    <li>childID [IN] - an identifier specifying a child of the control</li>
+	 *    <li>accessible [OUT] - an Accessible for the specified childID, or null if one does not exist</li>
+	 * </ul>
+	 */
+	public void getChild(AccessibleControlEvent e);
+	
+	/**
+	 * Sent when an accessibility client requests the number of
+	 * children in the control.
+	 * <p>
+	 * Return the number of child items in the <code>detail</code>
+	 * field of the event object.
+	 * </p>
+	 *
+	 * @param e an event object containing the following fields:<ul>
+	 *    <li>detail [OUT] - the number of child items in this control</li>
+	 * </ul>
+	 */
+	public void getChildCount(AccessibleControlEvent e);
+	
+	/**
+	 * Sent when an accessibility client requests the default action
+	 * of the control, or the default action of a child of the control.
+	 * <p>
+	 * This string is typically a verb describing what the user does to it.
+	 * For example, a Push Button's default action is "Press", a Check Button's
+	 * is "Check" or "UnCheck", and List items have the default action "Double Click".
+	 * </p><p>
+	 * Return a string describing the default action of the specified
+	 * control or child in the <code>result</code> field of the event object.
+	 * Returning null tells the client to use the platform default action string.
+	 * </p>
+	 *
+	 * @param e an event object containing the following fields:<ul>
+	 *    <li>childID [IN] - an identifier specifying the control or one of its children</li>
+	 *    <li>result [OUT] - the requested default action string, or null</li>
+	 * </ul>
+	 */
+	public void getDefaultAction(AccessibleControlEvent e);
+	
+	/**
+	 * Sent when an accessibility client requests the identity of
+	 * the child or control that has keyboard focus.
+	 * <p>
+	 * Return the identifier of the child that has focus in the
+	 * <code>childID</code> field of the event object.
+	 * Return CHILDID_SELF if the control itself has keyboard focus.
+	 * Return CHILDID_NONE if neither the control nor any of its children has focus.
+	 * </p>
+	 *
+	 * @param e an event object containing the following fields:<ul>
+	 *    <li>childID [Typical OUT] - the ID of the child with focus, or CHILDID_SELF, or CHILDID_NONE</li>
+	 *    <li>accessible [Optional OUT] - the accessible object for a child may be returned instead of its childID</li>
+	 * </ul>
+	 */
+	public void getFocus(AccessibleControlEvent e);
+	
+	/**
+	 * Sent when an accessibility client requests the role
+	 * of the control, or the role of a child of the control.
+	 * <p>
+	 * Return a role constant (constant defined in ACC beginning with ROLE_)
+	 * that describes the role of the specified control or child in the
+	 * <code>detail</code> field of the event object.
+	 * </p>
+	 *
+	 * @param e an event object containing the following fields:<ul>
+	 *    <li>childID [IN] - an identifier specifying the control or one of its children</li>
+	 *    <li>detail [OUT] - a role constant describing the role of the control or child</li>
+	 * </ul>
+	 */
+	public void getRole(AccessibleControlEvent e);
+	
+	/**
+	 * Sent when an accessibility client requests the identity of
+	 * the child or control that is currently selected.
+	 * <p>
+	 * Return the identifier of the selected child in the
+	 * <code>childID</code> field of the event object.
+	 * Return CHILDID_SELF if the control itself is selected.
+	 * Return CHILDID_MULTIPLE if multiple children are selected, and return an array of childIDs in the <code>children</code> field.
+	 * Return CHILDID_NONE if neither the control nor any of its children are selected.
+	 * </p>
+	 *
+	 * @param e an event object containing the following fields:<ul>
+	 *    <li>childID [Typical OUT] - the ID of the selected child, or CHILDID_SELF, or CHILDID_MULTIPLE, or CHILDID_NONE</li>
+	 *    <li>accessible [Optional OUT] - the accessible object for the control or child may be returned instead of the childID</li>
+	 * </ul>
+	 */
+	public void getSelection(AccessibleControlEvent e);
+	
+	/**
+	 * Sent when an accessibility client requests the state
+	 * of the control, or the state of a child of the control.
+	 * <p>
+	 * Return a state mask (mask bit constants defined in ACC beginning with STATE_)
+	 * that describes the current state of the specified control or child in the
+	 * <code>detail</code> field of the event object.
+	 * </p>
+	 *
+	 * @param e an event object containing the following fields:<ul>
+	 *    <li>childID [IN] - an identifier specifying the control or one of its children</li>
+	 *    <li>detail [OUT] - a state mask describing the current state of the control or child</li>
+	 * </ul>
+	 */
+	public void getState(AccessibleControlEvent e);
+	
+	/**
+	 * Sent when an accessibility client requests the value
+	 * of the control, or the value of a child of the control.
+	 * <p>
+	 * Many controls do not return a value. Examples of controls
+	 * that do are: Combo returns the text string, Text returns
+	 * its contents, ProgressBar returns a string representing a
+	 * percentage, and Tree items return a string representing
+	 * their level in the tree.
+	 * </p><p>
+	 * Return a string describing the value of the specified control
+	 * or child in the <code>result</code> field of the event object.
+	 * Returning null tells the client to use the platform value string.
+	 * </p>
+	 *
+	 * @param e an event object containing the following fields:<ul>
+	 *    <li>childID [IN] - an identifier specifying the control or one of its children</li>
+	 *    <li>result [OUT] - the requested value string, or null</li>
+	 * </ul>
+	 */
+	public void getValue(AccessibleControlEvent e);
+	
+	/**
+	 * Sent when an accessibility client requests the children of the control.
+	 * <p>
+	 * Return the children as an array of childIDs in the <code>children</code>
+	 * field of the event object.
+	 * </p>
+	 *
+	 * @param e an event object containing the following fields:<ul>
+	 *    <li>children [Typical OUT] - an array of childIDs</li>
+	 *    <li>children [Optional OUT] - an array of accessible objects for the children may be returned instead of the childIDs</li>
+	 * </ul>
+	 */
+	public void getChildren(AccessibleControlEvent e);
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/accessibility/AccessibleEvent.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/accessibility/AccessibleEvent.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/accessibility/AccessibleEvent.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.accessibility;
+
+
+import org.eclipse.swt.internal.SWTEventObject;
+
+/**
+ * Instances of this class are sent as a result of
+ * accessibility clients sending messages to controls
+ * asking for information about the control instance.
+ * <p>
+ * Note: The meaning of the result field depends
+ * on the message that was sent.
+ * </p>
+ *
+ * @see AccessibleListener
+ * @see AccessibleAdapter
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ * 
+ * @since 2.0
+ */
+public class AccessibleEvent extends SWTEventObject {
+	/**
+	 * The value of this field is set by an accessibility client
+	 * before the accessible listener method is called.
+	 * ChildID can be CHILDID_SELF, representing the control itself,
+	 * or a 0-based integer representing a specific child of the control.
+	 */
+	public int childID;
+	
+	/**
+	 * The value of this field must be set in the accessible listener
+	 * method before returning.
+	 * What to set it to depends on the listener method called, and
+	 * the childID specified by the client.
+	 */
+	public String result;
+	
+	static final long serialVersionUID = 3257567304224026934L;
+	
+/**
+ * Constructs a new instance of this class.
+ *
+ * @param source the object that fired the event
+ */
+public AccessibleEvent(Object source) {
+	super(source);
+}
+
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the event
+ */
+public String toString () {
+	return "AccessibleEvent {childID=" + childID + " result=" + result + "}"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+}	
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/accessibility/AccessibleFactory.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/accessibility/AccessibleFactory.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/accessibility/AccessibleFactory.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,413 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.accessibility;
+
+
+import java.util.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.accessibility.gtk.*;
+import org.eclipse.swt.internal.gtk.*;
+import org.eclipse.swt.*;
+
+class AccessibleFactory {
+	int /*long*/ handle;
+	int /*long*/ objectParentType;
+	int /*long*/ widgetTypeName;
+	Callback atkObjectFactoryCB_create_accessible;
+	Callback gTypeInfo_base_init_factory;
+	Hashtable accessibles = new Hashtable (9);
+	
+	static final Hashtable Types = new Hashtable (9);
+	static final Hashtable Factories = new Hashtable (9);	
+	static final int /*long*/ DefaultParentType = OS.g_type_from_name (Converter.wcsToMbcs (null, "GtkAccessible", true)); //$NON-NLS-1$
+	static final byte[] FACTORY_PARENTTYPENAME = Converter.wcsToMbcs (null, "AtkObjectFactory", true); //$NON-NLS-1$
+	static final byte[] SWT_TYPE_PREFIX = Converter.wcsToMbcs (null, "SWT", false); //$NON-NLS-1$
+	static final byte[] CHILD_TYPENAME = Converter.wcsToMbcs (null, "Child", false); //$NON-NLS-1$
+	static final byte[] FACTORY_TYPENAME = Converter.wcsToMbcs (null, "SWTFactory", true); //$NON-NLS-1$
+	static final int[] actionRoles = {
+		ACC.ROLE_CHECKBUTTON, ACC.ROLE_COMBOBOX, ACC.ROLE_LINK,
+		ACC.ROLE_MENUITEM, ACC.ROLE_PUSHBUTTON, ACC.ROLE_RADIOBUTTON,
+	};
+	static final int[] hypertextRoles = {ACC.ROLE_LINK};
+	static final int[] selectionRoles = {
+		ACC.ROLE_LIST, ACC.ROLE_TABFOLDER, ACC.ROLE_TABLE, ACC.ROLE_TREE,
+	};
+	static final int[] textRoles = {
+		ACC.ROLE_COMBOBOX, ACC.ROLE_LINK, ACC.ROLE_LABEL, ACC.ROLE_TEXT,
+	};
+
+	/* AT callbacks*/
+	static final Callback AtkActionCB_get_keybinding;
+	static final Callback AtkActionCB_get_name;	
+	static final Callback AtkComponentCB_get_extents;
+	static final Callback AtkComponentCB_get_position;
+	static final Callback AtkComponentCB_get_size;
+	static final Callback AtkComponentCB_ref_accessible_at_point;
+	static final Callback AtkHypertextCB_get_link;
+	static final Callback AtkHypertextCB_get_n_links;
+	static final Callback AtkHypertextCB_get_link_index;
+	static final Callback AtkObjectCB_get_description;
+	static final Callback AtkObjectCB_get_index_in_parent;
+	static final Callback AtkObjectCB_get_n_children;
+	static final Callback AtkObjectCB_get_name;
+	static final Callback AtkObjectCB_get_parent;	
+	static final Callback AtkObjectCB_get_role;
+	static final Callback AtkObjectCB_ref_child;
+	static final Callback AtkObjectCB_ref_state_set;
+	static final Callback AtkSelectionCB_is_child_selected;
+	static final Callback AtkSelectionCB_ref_selection;
+	static final Callback AtkTextCB_get_caret_offset;
+	static final Callback AtkTextCB_get_n_selections;
+	static final Callback AtkTextCB_get_selection;
+	static final Callback AtkTextCB_get_text;
+	static final Callback AtkTextCB_get_text_after_offset;
+	static final Callback AtkTextCB_get_text_at_offset;
+	static final Callback AtkTextCB_get_text_before_offset;
+	static final Callback AtkTextCB_get_character_at_offset;
+	static final Callback AtkTextCB_get_character_count;
+	static final Callback GObjectClass_finalize;
+	/* interface initialization callbacks */
+	static final Callback InitActionIfaceCB;		
+	static final Callback InitComponentIfaceCB;
+	static final Callback InitHypertextIfaceCB;
+	static final Callback GTypeInfo_base_init_type;
+	static final Callback InitSelectionIfaceCB;
+	static final Callback InitTextIfaceCB;
+	/* interface definitions */
+	static int /*long*/ ObjectIfaceDefinition;
+	static final int /*long*/ ActionIfaceDefinition;
+	static final int /*long*/ ComponentIfaceDefinition;
+	static final int /*long*/ HypertextIfaceDefinition;
+	static final int /*long*/ SelectionIfaceDefinition;
+	static final int /*long*/ TextIfaceDefinition;
+	static {
+		AtkActionCB_get_keybinding = newCallback (AccessibleObject.class, "atkAction_get_keybinding", 2); //$NON-NLS-1$
+		AtkActionCB_get_name = newCallback (AccessibleObject.class, "atkAction_get_name", 2); //$NON-NLS-1$
+		AtkComponentCB_get_extents = newCallback (AccessibleObject.class, "atkComponent_get_extents", 6); //$NON-NLS-1$
+		AtkComponentCB_get_position = newCallback (AccessibleObject.class, "atkComponent_get_position", 4); //$NON-NLS-1$
+		AtkComponentCB_get_size = newCallback (AccessibleObject.class, "atkComponent_get_size", 4); //$NON-NLS-1$
+		AtkComponentCB_ref_accessible_at_point = newCallback (AccessibleObject.class, "atkComponent_ref_accessible_at_point", 4); //$NON-NLS-1$
+		AtkHypertextCB_get_link = newCallback (AccessibleObject.class, "atkHypertext_get_link", 2); //$NON-NLS-1$
+		AtkHypertextCB_get_n_links = newCallback (AccessibleObject.class, "atkHypertext_get_n_links", 1); //$NON-NLS-1$
+		AtkHypertextCB_get_link_index = newCallback (AccessibleObject.class, "atkHypertext_get_link_index", 2); //$NON-NLS-1$
+		AtkObjectCB_get_name = newCallback (AccessibleObject.class, "atkObject_get_name", 1); //$NON-NLS-1$
+		AtkObjectCB_get_description = newCallback (AccessibleObject.class, "atkObject_get_description", 1); //$NON-NLS-1$
+		AtkObjectCB_get_n_children = newCallback (AccessibleObject.class, "atkObject_get_n_children", 1); //$NON-NLS-1$
+		AtkObjectCB_get_role = newCallback (AccessibleObject.class, "atkObject_get_role", 1); //$NON-NLS-1$
+		AtkObjectCB_get_parent = newCallback (AccessibleObject.class, "atkObject_get_parent", 1); //$NON-NLS-1$
+		AtkObjectCB_ref_state_set = newCallback (AccessibleObject.class, "atkObject_ref_state_set", 1); //$NON-NLS-1$
+		AtkObjectCB_get_index_in_parent = newCallback (AccessibleObject.class, "atkObject_get_index_in_parent", 1); //$NON-NLS-1$
+		AtkObjectCB_ref_child = newCallback (AccessibleObject.class, "atkObject_ref_child", 2); //$NON-NLS-1$
+		AtkSelectionCB_is_child_selected = newCallback (AccessibleObject.class, "atkSelection_is_child_selected", 2); //$NON-NLS-1$
+		AtkSelectionCB_ref_selection = newCallback (AccessibleObject.class, "atkSelection_ref_selection", 2); //$NON-NLS-1$
+		AtkTextCB_get_caret_offset = newCallback (AccessibleObject.class, "atkText_get_caret_offset", 1); //$NON-NLS-1$
+		AtkTextCB_get_n_selections = newCallback (AccessibleObject.class, "atkText_get_n_selections", 1); //$NON-NLS-1$
+		AtkTextCB_get_selection = newCallback (AccessibleObject.class, "atkText_get_selection", 4); //$NON-NLS-1$
+		AtkTextCB_get_text = newCallback (AccessibleObject.class, "atkText_get_text", 3); //$NON-NLS-1$
+		AtkTextCB_get_text_after_offset = newCallback (AccessibleObject.class, "atkText_get_text_after_offset", 5); //$NON-NLS-1$
+		AtkTextCB_get_text_at_offset = newCallback ( AccessibleObject.class, "atkText_get_text_at_offset", 5); //$NON-NLS-1$
+		AtkTextCB_get_text_before_offset = newCallback (AccessibleObject.class, "atkText_get_text_before_offset", 5); //$NON-NLS-1$
+		AtkTextCB_get_character_at_offset = newCallback (AccessibleObject.class, "atkText_get_character_at_offset", 2); //$NON-NLS-1$
+		AtkTextCB_get_character_count = newCallback (AccessibleObject.class, "atkText_get_character_count", 1); //$NON-NLS-1$
+		GObjectClass_finalize = newCallback (AccessibleObject.class, "gObjectClass_finalize", 1); //$NON-NLS-1$
+		GTypeInfo_base_init_type = newCallback (AccessibleFactory.class, "gTypeInfo_base_init_type", 1); //$NON-NLS-1$
+		/* Action interface */
+		InitActionIfaceCB = newCallback (AccessibleFactory.class, "initActionIfaceCB", 1); //$NON-NLS-1$
+		GInterfaceInfo interfaceInfo = new GInterfaceInfo ();
+		interfaceInfo.interface_init = InitActionIfaceCB.getAddress ();
+		ActionIfaceDefinition = OS.g_malloc (GInterfaceInfo.sizeof);  
+		OS.memmove (ActionIfaceDefinition, interfaceInfo, GInterfaceInfo.sizeof);
+		/* Component interface */
+		InitComponentIfaceCB = newCallback (AccessibleFactory.class, "initComponentIfaceCB", 1); //$NON-NLS-1$
+		interfaceInfo = new GInterfaceInfo ();
+		interfaceInfo.interface_init = InitComponentIfaceCB.getAddress ();
+		ComponentIfaceDefinition = OS.g_malloc (GInterfaceInfo.sizeof);
+		OS.memmove (ComponentIfaceDefinition, interfaceInfo, GInterfaceInfo.sizeof);
+		/* Hypertext interface */
+		InitHypertextIfaceCB = newCallback (AccessibleFactory.class, "initHypertextIfaceCB", 1); //$NON-NLS-1$
+		interfaceInfo = new GInterfaceInfo ();
+		interfaceInfo.interface_init = InitHypertextIfaceCB.getAddress ();
+		HypertextIfaceDefinition = OS.g_malloc (GInterfaceInfo.sizeof);  
+		OS.memmove (HypertextIfaceDefinition, interfaceInfo, GInterfaceInfo.sizeof);
+		/* Selection interface */
+		InitSelectionIfaceCB = newCallback (AccessibleFactory.class, "initSelectionIfaceCB", 1); //$NON-NLS-1$
+		interfaceInfo = new GInterfaceInfo ();
+		interfaceInfo.interface_init = InitSelectionIfaceCB.getAddress ();
+		SelectionIfaceDefinition = OS.g_malloc (GInterfaceInfo.sizeof);  
+		OS.memmove (SelectionIfaceDefinition, interfaceInfo, GInterfaceInfo.sizeof);
+		/* Text interface */
+		InitTextIfaceCB = newCallback (AccessibleFactory.class, "initTextIfaceCB", 1); //$NON-NLS-1$
+		interfaceInfo = new GInterfaceInfo ();
+		interfaceInfo.interface_init = InitTextIfaceCB.getAddress ();
+		TextIfaceDefinition = OS.g_malloc (GInterfaceInfo.sizeof);  
+		OS.memmove (TextIfaceDefinition, interfaceInfo, GInterfaceInfo.sizeof);
+	}
+
+	static private Callback newCallback (Object object, String method, int argCount) {
+		Callback callback = new Callback (object, method, argCount);
+		if (callback.getAddress () == 0) SWT.error (SWT.ERROR_NO_MORE_CALLBACKS);
+		return callback;
+	}
+
+	private AccessibleFactory (int /*long*/ widgetType) {
+		super ();
+		widgetTypeName = OS.g_type_name (widgetType);
+		int widgetTypeNameLength = OS.strlen (widgetTypeName) + 1;
+		byte[] buffer = new byte [widgetTypeNameLength];
+		OS.memmove (buffer, widgetTypeName, widgetTypeNameLength);
+		byte[] factoryName = new byte [FACTORY_TYPENAME.length + widgetTypeNameLength - 1];
+		System.arraycopy (FACTORY_TYPENAME, 0, factoryName, 0, FACTORY_TYPENAME.length);
+		System.arraycopy (buffer, 0, factoryName, FACTORY_TYPENAME.length - 1, widgetTypeNameLength);
+		if (OS.g_type_from_name (factoryName) == 0) {
+			/* register the factory */
+			int /*long*/ registry = ATK.atk_get_default_registry ();
+			int /*long*/ previousFactory = ATK.atk_registry_get_factory (registry, widgetType);
+			objectParentType = ATK.atk_object_factory_get_accessible_type (previousFactory);
+			if (objectParentType == 0) objectParentType = DefaultParentType;
+			int /*long*/ factoryParentType = OS.g_type_from_name (FACTORY_PARENTTYPENAME);
+			gTypeInfo_base_init_factory  = new Callback (this, "gTypeInfo_base_init_factory", 1); //$NON-NLS-1$
+			int /*long*/ address = gTypeInfo_base_init_factory.getAddress ();
+			if (address == 0) SWT.error (SWT.ERROR_NO_MORE_CALLBACKS);
+			GTypeInfo typeInfo = new GTypeInfo ();
+			typeInfo.base_init = address;
+			typeInfo.class_size = (short)ATK.AtkObjectFactoryClass_sizeof ();
+			typeInfo.instance_size = (short)ATK.AtkObjectFactory_sizeof ();
+			int /*long*/ info = OS.g_malloc (GTypeInfo.sizeof); 
+			OS.memmove (info, typeInfo, GTypeInfo.sizeof); 
+			int /*long*/ swtFactoryType = OS.g_type_register_static (factoryParentType, factoryName, info, 0);
+			ATK.atk_registry_set_factory_type (registry, widgetType, swtFactoryType);
+			handle = ATK.atk_registry_get_factory (registry, widgetType);
+		}
+	}
+
+	void addAccessible (Accessible accessible) {
+		int /*long*/ controlHandle = accessible.getControlHandle ();
+		accessibles.put (new LONG (controlHandle), accessible);
+		ATK.atk_object_factory_create_accessible (handle, controlHandle);
+	}
+
+	int /*long*/ atkObjectFactory_create_accessible (int /*long*/ widget) {
+		Accessible accessible = (Accessible) accessibles.get (new LONG (widget));
+		if (accessible == null) {
+			/*
+			* we don't care about this control, so create it with the parent's
+			* type so that its accessibility callbacks will not pass though here 
+			*/  
+			int /*long*/ result = OS.g_object_new (objectParentType, 0);
+			ATK.atk_object_initialize (result, widget);
+			return result;
+		}
+		/* if an atk object has already been created for this widget then just return it */
+		if (accessible.accessibleObject != null) {
+			return accessible.accessibleObject.handle;
+		}
+		int typeNameLength = OS.strlen (widgetTypeName);
+		byte[] buffer = new byte [typeNameLength];
+		OS.memmove (buffer, widgetTypeName, typeNameLength);
+		int /*long*/ type = getType (buffer, accessible, objectParentType, ACC.CHILDID_SELF);
+		AccessibleObject object = new AccessibleObject (type, widget, accessible, objectParentType, false);
+		accessible.accessibleObject = object;
+		return object.handle;
+	}
+	
+	static int /*long*/ getChildType (Accessible accessible, int childIndex) {
+		return getType (CHILD_TYPENAME, accessible, DefaultParentType, childIndex);
+	}
+
+	static int /*long*/ getDefaultParentType () {
+		return DefaultParentType;
+	}
+
+	static int /*long*/ getType (byte[] widgetTypeName, Accessible accessible, int /*long*/ parentType, int childId) {
+		AccessibleControlEvent event = new AccessibleControlEvent (accessible);
+		event.childID = childId;
+		AccessibleControlListener[] listeners = accessible.getControlListeners ();
+		for (int i = 0; i < listeners.length; i++) {
+			listeners [i].getRole (event);
+		}
+		boolean action = false, hypertext = false, selection = false, text = false;
+		if (event.detail != 0) {	/* a role was specified */
+			for (int i = 0; i < actionRoles.length; i++) {
+				if (event.detail == actionRoles [i]) {
+					action = true;
+					break;
+				}
+			}
+			for (int i = 0; i < hypertextRoles.length; i++) {
+				if (event.detail == hypertextRoles [i]) {
+					hypertext = true;
+					break;
+				}
+			}
+			for (int i = 0; i < selectionRoles.length; i++) {
+				if (event.detail == selectionRoles [i]) {
+					selection = true;
+					break;
+				}
+			}
+			for (int i = 0; i < textRoles.length; i++) {
+				if (event.detail == textRoles [i]) {
+					text = true;
+					break;
+				}
+			}
+		} else {
+			action = hypertext = selection = text = true;
+		}
+		String swtTypeName = new String (SWT_TYPE_PREFIX);
+		swtTypeName += new String (widgetTypeName);
+		if (action) swtTypeName += "Action"; //$NON-NLS-1$
+		if (hypertext) swtTypeName += "Hypertext"; //$NON-NLS-1$
+		if (selection) swtTypeName += "Selection"; //$NON-NLS-1$
+		if (text) swtTypeName += "Text"; //$NON-NLS-1$
+
+		int /*long*/ type = 0;
+		LONG typeInt = (LONG)Types.get (swtTypeName);
+		if (typeInt != null) {
+			type = typeInt.value;
+		} else {
+			/* define the type */
+			int /*long*/ queryPtr = OS.g_malloc (GTypeQuery.sizeof);
+			OS.g_type_query (parentType, queryPtr);
+			GTypeQuery query = new GTypeQuery ();
+			OS.memmove (query, queryPtr, GTypeQuery.sizeof);
+			OS.g_free (queryPtr);
+			GTypeInfo typeInfo = new GTypeInfo ();
+			typeInfo.base_init = GTypeInfo_base_init_type.getAddress ();
+			typeInfo.class_size = (short) query.class_size;
+			typeInfo.instance_size = (short) query.instance_size;
+			ObjectIfaceDefinition = OS.g_malloc (GTypeInfo.sizeof); 
+			OS.memmove (ObjectIfaceDefinition, typeInfo, GTypeInfo.sizeof);
+			byte[] nameBytes = Converter.wcsToMbcs(null, swtTypeName, true);
+			type = OS.g_type_register_static (parentType, nameBytes, ObjectIfaceDefinition, 0);
+			OS.g_type_add_interface_static (type, AccessibleObject.ATK_COMPONENT_TYPE, ComponentIfaceDefinition);
+			if (action) OS.g_type_add_interface_static (type, AccessibleObject.ATK_ACTION_TYPE, ActionIfaceDefinition);
+			if (hypertext) OS.g_type_add_interface_static (type, AccessibleObject.ATK_HYPERTEXT_TYPE, HypertextIfaceDefinition);
+			if (selection) OS.g_type_add_interface_static (type, AccessibleObject.ATK_SELECTION_TYPE, SelectionIfaceDefinition);
+			if (text) OS.g_type_add_interface_static (type, AccessibleObject.ATK_TEXT_TYPE, TextIfaceDefinition);
+			Types.put (swtTypeName, new LONG (type));
+		}
+		return type;
+	}
+
+	int /*long*/ gTypeInfo_base_init_factory (int /*long*/ klass) {
+		int /*long*/ atkObjectFactoryClass = ATK.ATK_OBJECT_FACTORY_CLASS (klass);
+		AtkObjectFactoryClass objectFactoryClassStruct = new AtkObjectFactoryClass ();
+		ATK.memmove (objectFactoryClassStruct, atkObjectFactoryClass);
+		atkObjectFactoryCB_create_accessible = new Callback (this, "atkObjectFactory_create_accessible", 1); //$NON-NLS-1$
+		int /*long*/ address = atkObjectFactoryCB_create_accessible.getAddress ();
+		if (address == 0) SWT.error (SWT.ERROR_NO_MORE_CALLBACKS);
+		objectFactoryClassStruct.create_accessible = address;
+		ATK.memmove (atkObjectFactoryClass, objectFactoryClassStruct); 
+		return 0;
+	}
+	
+	static int /*long*/ gTypeInfo_base_init_type (int /*long*/ klass) {
+		AtkObjectClass objectClass = new AtkObjectClass ();
+		ATK.memmove (objectClass, klass);
+		objectClass.get_name = AtkObjectCB_get_name.getAddress ();
+		objectClass.get_description = AtkObjectCB_get_description.getAddress ();
+		objectClass.get_n_children = AtkObjectCB_get_n_children.getAddress ();
+		objectClass.get_role = AtkObjectCB_get_role.getAddress ();
+		objectClass.get_parent = AtkObjectCB_get_parent.getAddress ();
+		objectClass.ref_state_set = AtkObjectCB_ref_state_set.getAddress ();
+		objectClass.get_index_in_parent = AtkObjectCB_get_index_in_parent.getAddress ();
+		objectClass.ref_child = AtkObjectCB_ref_child.getAddress ();
+		int /*long*/ gObjectClass = OS.G_OBJECT_CLASS (klass);
+		GObjectClass objectClassStruct = new GObjectClass ();
+		OS.memmove (objectClassStruct, gObjectClass);
+		objectClassStruct.finalize = GObjectClass_finalize.getAddress ();
+		OS.memmove (gObjectClass, objectClassStruct); 
+		ATK.memmove (klass, objectClass);
+		return 0;
+	}
+	
+	static int /*long*/ initActionIfaceCB (int /*long*/ iface) {
+		AtkActionIface actionIface = new AtkActionIface ();
+		ATK.memmove (actionIface, iface);
+		actionIface.get_keybinding = AtkActionCB_get_keybinding.getAddress (); 
+		actionIface.get_name = AtkActionCB_get_name.getAddress ();
+		ATK.memmove (iface, actionIface);
+		return 0;
+	}
+	
+	static int /*long*/ initComponentIfaceCB (int /*long*/ iface) {
+		AtkComponentIface componentIface = new AtkComponentIface ();
+		ATK.memmove (componentIface, iface);
+		componentIface.get_extents = AtkComponentCB_get_extents.getAddress ();
+		componentIface.get_position = AtkComponentCB_get_position.getAddress ();
+		componentIface.get_size = AtkComponentCB_get_size.getAddress ();
+		componentIface.ref_accessible_at_point = AtkComponentCB_ref_accessible_at_point.getAddress ();
+		ATK.memmove (iface, componentIface);
+		return 0;
+	}
+
+	static int /*long*/ initHypertextIfaceCB (int /*long*/ iface) {
+		AtkHypertextIface hypertextIface = new AtkHypertextIface ();
+		ATK.memmove (hypertextIface, iface);
+		hypertextIface.get_link = AtkHypertextCB_get_link.getAddress (); 
+		hypertextIface.get_link_index = AtkHypertextCB_get_link_index.getAddress ();
+		hypertextIface.get_n_links = AtkHypertextCB_get_n_links.getAddress ();
+		ATK.memmove (iface, hypertextIface);
+		return 0;
+	}
+
+	static int /*long*/ initSelectionIfaceCB (int /*long*/ iface) {
+		AtkSelectionIface selectionIface = new AtkSelectionIface ();
+		ATK.memmove (selectionIface, iface);
+		selectionIface.is_child_selected = AtkSelectionCB_is_child_selected.getAddress ();
+		selectionIface.ref_selection = AtkSelectionCB_ref_selection.getAddress ();
+		ATK.memmove (iface, selectionIface);
+		return 0;
+	}
+
+	static int /*long*/ initTextIfaceCB (int /*long*/ iface) {
+		AtkTextIface textInterface = new AtkTextIface ();
+		ATK.memmove (textInterface, iface);
+		textInterface.get_caret_offset = AtkTextCB_get_caret_offset.getAddress ();
+		textInterface.get_character_at_offset = AtkTextCB_get_character_at_offset.getAddress ();
+		textInterface.get_character_count = AtkTextCB_get_character_count.getAddress ();
+		textInterface.get_n_selections = AtkTextCB_get_n_selections.getAddress ();
+		textInterface.get_selection = AtkTextCB_get_selection.getAddress ();
+		textInterface.get_text = AtkTextCB_get_text.getAddress ();
+		textInterface.get_text_after_offset = AtkTextCB_get_text_after_offset.getAddress ();
+		textInterface.get_text_at_offset = AtkTextCB_get_text_at_offset.getAddress ();
+		textInterface.get_text_before_offset = AtkTextCB_get_text_before_offset.getAddress ();
+		ATK.memmove (iface, textInterface);
+		return 0;
+	}
+
+	static void registerAccessible (Accessible accessible) {
+		/* If DefaultParentType is 0 then OS accessibility is not active */
+		if (DefaultParentType == 0) return;
+		int /*long*/ controlHandle = accessible.getControlHandle ();
+		int /*long*/ widgetType = OS.G_OBJECT_TYPE (controlHandle);
+		AccessibleFactory factory = (AccessibleFactory) Factories.get (new LONG (widgetType));
+		if (factory == null) {
+			factory = new AccessibleFactory (widgetType);
+			Factories.put (new LONG (widgetType), factory);
+		}
+		factory.addAccessible (accessible);
+	}
+	
+	void removeAccessible (Accessible accessible) {
+		accessibles.remove (new LONG (accessible.getControlHandle ()));
+	}
+	
+	static void unregisterAccessible (Accessible accessible) {
+		int /*long*/ controlHandle = accessible.getControlHandle ();
+		int /*long*/ widgetType = OS.G_OBJECT_TYPE (controlHandle);
+		AccessibleFactory factory = (AccessibleFactory) Factories.get (new LONG (widgetType));
+		if (factory != null) {
+			factory.removeAccessible (accessible);
+		}
+	}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/accessibility/AccessibleListener.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/accessibility/AccessibleListener.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/accessibility/AccessibleListener.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,126 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.accessibility;
+
+
+import org.eclipse.swt.internal.SWTEventListener;
+
+/**
+ * Classes that implement this interface provide methods
+ * that deal with the events that are generated when an
+ * accessibility client sends a message to a control.
+ * <p>
+ * After creating an instance of a class that implements
+ * this interface it can be added to a control using the
+ * <code>addAccessibleListener</code> method and removed
+ * using the <code>removeAccessibleListener</code> method.
+ * When a client requests information, the appropriate method
+ * will be invoked.
+ * </p><p>
+ * Note: Accessibility clients use child identifiers to specify
+ * whether they want information about a control or one of its children.
+ * Child identifiers are increasing integers beginning with 0.
+ * The identifier CHILDID_SELF represents the control itself.
+ * </p>
+ *
+ * @see AccessibleAdapter
+ * @see AccessibleEvent
+ * 
+ * @since 2.0
+ */
+public interface AccessibleListener extends SWTEventListener {
+
+	/**
+	 * Sent when an accessibility client requests the name
+	 * of the control, or the name of a child of the control.
+	 * <p>
+	 * Return the name of the control or specified child in the
+	 * <code>result</code> field of the event object. Returning
+	 * an empty string tells the client that the control or child
+	 * does not have a name, and returning null tells the client
+	 * to use the platform name.
+	 * </p>
+	 *
+	 * @param e an event object containing the following fields:<ul>
+	 *    <li>childID [IN] - an identifier specifying the control or one of its children</li>
+	 *    <li>result [OUT] - the requested name string, or null</li>
+	 * </ul>
+	 */
+	public void getName(AccessibleEvent e);
+
+	/**
+	 * Sent when an accessibility client requests the help string
+	 * of the control, or the help string of a child of the control.
+	 * <p>
+	 * The information in this property should be similar to the help
+	 * provided by toolTipText. It describes what the control or child
+	 * does or how to use it, as opposed to getDescription, which
+	 * describes appearance.
+	 * </p><p>
+	 * Return the help string of the control or specified child in
+	 * the <code>result</code> field of the event object. Returning
+	 * an empty string tells the client that the control or child
+	 * does not have a help string, and returning null tells the
+	 * client to use the platform help string.
+	 * </p>
+	 *
+	 * @param e an event object containing the following fields:<ul>
+	 *    <li>childID [IN] - an identifier specifying the control or one of its children</li>
+	 *    <li>result [OUT] - the requested help string, or null</li>
+	 * </ul>
+	 */
+	public void getHelp(AccessibleEvent e);
+
+	/**
+	 * Sent when an accessibility client requests the keyboard shortcut
+	 * of the control, or the keyboard shortcut of a child of the control.
+	 * <p>
+	 * A keyboard shortcut can either be a mnemonic, or an accelerator.
+	 * As a general rule, if the control or child can receive keyboard focus,
+	 * then you should expose its mnemonic, and if it cannot receive keyboard
+	 * focus, then you should expose its accelerator.
+	 * </p><p>
+	 * Return the keyboard shortcut string of the control or specified child
+	 * in the <code>result</code> field of the event object. Returning an
+	 * empty string tells the client that the control or child does not
+	 * have a keyboard shortcut string, and returning null tells the client
+	 * to use the platform keyboard shortcut string.
+	 * </p>
+	 *
+	 * @param e an event object containing the following fields:<ul>
+	 *    <li>childID [IN] - an identifier specifying the control or one of its children</li>
+	 *    <li>result [OUT] - the requested keyboard shortcut string (example: "ALT+N"), or null</li>
+	 * </ul>
+	 */
+	public void getKeyboardShortcut(AccessibleEvent e);
+
+	/**
+	 * Sent when an accessibility client requests a description
+	 * of the control, or a description of a child of the control.
+	 * <p>
+	 * This is a textual description of the control or child's visual
+	 * appearance, which is typically only necessary if it cannot be
+	 * determined from other properties such as role.
+	 * </p><p>
+	 * Return the description of the control or specified child in
+	 * the <code>result</code> field of the event object. Returning
+	 * an empty string tells the client that the control or child
+	 * does not have a description, and returning null tells the
+	 * client to use the platform description.
+	 * </p>
+	 *
+	 * @param e an event object containing the following fields:<ul>
+	 *    <li>childID [IN] - an identifier specifying the control or one of its children</li>
+	 *    <li>result [OUT] - the requested description string, or null</li>
+	 * </ul>
+	 */
+	public void getDescription(AccessibleEvent e);
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/accessibility/AccessibleObject.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/accessibility/AccessibleObject.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/accessibility/AccessibleObject.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,1411 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.accessibility;
+
+
+import java.util.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.accessibility.gtk.*;
+import org.eclipse.swt.internal.gtk.*;
+import org.eclipse.swt.widgets.*;
+
+class AccessibleObject {
+	int /*long*/ handle;
+	int /*long*/ parentType;
+	int index = -1, id = ACC.CHILDID_SELF;
+	Accessible accessible;
+	AccessibleObject parent;
+	Hashtable children = new Hashtable (9);
+	/*
+	* a lightweight object does not correspond to a concrete gtk widget, but
+	* to a logical child of a widget (eg.- a CTabItem, which is simply drawn)
+	*/ 
+	boolean isLightweight = false;
+
+	static int /*long*/ actionNamePtr = -1;
+	static int /*long*/ descriptionPtr = -1;
+	static int /*long*/ keybindingPtr = -1;
+	static int /*long*/ namePtr = -1;
+	static final Hashtable AccessibleObjects = new Hashtable (9);
+	static final int /*long*/ ATK_ACTION_TYPE = ATK.g_type_from_name (Converter.wcsToMbcs (null, "AtkAction", true));
+	static final int /*long*/ ATK_COMPONENT_TYPE = ATK.g_type_from_name (Converter.wcsToMbcs (null, "AtkComponent", true));
+	static final int /*long*/ ATK_HYPERTEXT_TYPE = ATK.g_type_from_name (Converter.wcsToMbcs (null, "AtkHypertext", true));
+	static final int /*long*/ ATK_SELECTION_TYPE = ATK.g_type_from_name (Converter.wcsToMbcs (null, "AtkSelection", true));		
+	static final int /*long*/ ATK_TEXT_TYPE = ATK.g_type_from_name (Converter.wcsToMbcs (null, "AtkText", true));
+	static final boolean DEBUG = Display.DEBUG;
+
+	AccessibleObject (int /*long*/ type, int /*long*/ widget, Accessible accessible, int /*long*/ parentType, boolean isLightweight) {
+		super ();
+		handle = ATK.g_object_new (type, 0);
+		this.parentType = parentType;
+		ATK.atk_object_initialize (handle, widget);
+		this.accessible = accessible;
+		this.isLightweight = isLightweight;
+		AccessibleObjects.put (new LONG (handle), this);
+		if (DEBUG) System.out.println("new AccessibleObject: " + handle);
+	}
+
+	void addChild (AccessibleObject child) {
+		children.put (new LONG (child.handle), child);		
+		child.setParent (this);
+	}
+	
+	static int /*long*/ atkAction_get_keybinding (int /*long*/ atkObject, int /*long*/ index) {
+		if (DEBUG) System.out.println ("-->atkAction_get_keybinding");
+		AccessibleObject object = getAccessibleObject (atkObject);
+		if (object == null) return 0;
+		int /*long*/ parentResult = 0;
+		if (ATK.g_type_is_a (object.parentType, ATK_ACTION_TYPE)) {
+			int /*long*/ superType = ATK.g_type_interface_peek_parent (ATK.ATK_ACTION_GET_IFACE (object.handle));
+			AtkActionIface actionIface = new AtkActionIface ();
+			ATK.memmove (actionIface, superType);
+			if (actionIface.get_keybinding != 0) {
+				parentResult = ATK.call (actionIface.get_keybinding, object.handle, index);
+			}
+		}
+		AccessibleListener[] listeners = object.getAccessibleListeners ();
+		if (listeners.length == 0) return parentResult;
+
+		AccessibleEvent event = new AccessibleEvent (object);
+		event.childID = object.id;
+		if (parentResult != 0) {
+			int length = OS.strlen (parentResult);
+			byte [] buffer = new byte [length];
+			OS.memmove (buffer, parentResult, length);
+			event.result = new String (Converter.mbcsToWcs (null, buffer));
+		}
+		for (int i = 0; i < listeners.length; i++) {
+			listeners [i].getKeyboardShortcut (event);	
+		} 
+		if (event.result == null) return parentResult;
+		if (keybindingPtr != -1) OS.g_free (keybindingPtr);
+		byte[] name = Converter.wcsToMbcs (null, event.result, true);
+		keybindingPtr = OS.g_malloc (name.length);
+		OS.memmove (keybindingPtr, name, name.length);
+		return keybindingPtr; 	
+	}
+
+	static int /*long*/ atkAction_get_name (int /*long*/ atkObject, int /*long*/ index) {
+		if (DEBUG) System.out.println ("-->atkAction_get_name");
+		AccessibleObject object = getAccessibleObject (atkObject);
+		if (object == null) return 0;
+		int /*long*/ parentResult = 0;
+		if (ATK.g_type_is_a (object.parentType, ATK_ACTION_TYPE)) {
+			int /*long*/ superType = ATK.g_type_interface_peek_parent (ATK.ATK_ACTION_GET_IFACE (object.handle));
+			AtkActionIface actionIface = new AtkActionIface ();
+			ATK.memmove (actionIface, superType);
+			if (actionIface.get_name != 0) {
+				parentResult = ATK.call (actionIface.get_name, object.handle, index);
+			}
+		}
+		AccessibleControlListener[] listeners = object.getControlListeners ();
+		if (listeners.length == 0) return parentResult;
+
+		AccessibleControlEvent event = new AccessibleControlEvent (object);
+		event.childID = object.id;
+		if (parentResult != 0) {
+			int length = OS.strlen (parentResult);
+			byte [] buffer = new byte [length];
+			OS.memmove (buffer, parentResult, length);
+			event.result = new String (Converter.mbcsToWcs (null, buffer));
+		}
+		for (int i = 0; i < listeners.length; i++) {
+			listeners [i].getDefaultAction (event);				
+		} 
+		if (event.result == null) return parentResult;
+		if (actionNamePtr != -1) OS.g_free (actionNamePtr);
+		byte[] name = Converter.wcsToMbcs (null, event.result, true);
+		actionNamePtr = OS.g_malloc (name.length);
+		OS.memmove (actionNamePtr, name, name.length);
+		return actionNamePtr;
+	}	
+
+	static int /*long*/ atkComponent_get_extents (int /*long*/ atkObject, int /*long*/ x, int /*long*/ y, int /*long*/ width, int /*long*/ height, int /*long*/ coord_type) {
+		if (DEBUG) System.out.println ("-->atkComponent_get_extents");
+		AccessibleObject object = getAccessibleObject (atkObject);
+		if (object == null) return 0;
+		OS.memmove (x, new int[] {0}, 4);
+		OS.memmove (y, new int[] {0}, 4);
+		OS.memmove (width, new int[] {0}, 4);
+		OS.memmove (height, new int[] {0}, 4);
+		if (ATK.g_type_is_a (object.parentType, ATK_COMPONENT_TYPE)) {
+			int /*long*/ superType = ATK.g_type_interface_peek_parent (ATK.ATK_COMPONENT_GET_IFACE (object.handle));
+			AtkComponentIface componentIface = new AtkComponentIface ();
+			ATK.memmove (componentIface, superType);
+			if (componentIface.get_extents != 0) {
+				ATK.call (componentIface.get_extents, object.handle, x, y, width, height, coord_type);
+			}
+		}
+		AccessibleControlListener[] listeners = object.getControlListeners ();
+		if (listeners.length == 0) return 0;
+		
+		int[] parentX = new int [1], parentY = new int [1];
+		int[] parentWidth = new int [1], parentHeight = new int [1];
+		OS.memmove (parentX, x, 4);
+		OS.memmove (parentY, y, 4);
+		OS.memmove (parentWidth, width, 4);
+		OS.memmove (parentHeight, height, 4);
+		AccessibleControlEvent event = new AccessibleControlEvent (object);
+		event.childID = object.id;
+		event.x = parentX [0]; event.y = parentY [0];
+		event.width = parentWidth [0]; event.height = parentHeight [0];
+		if (coord_type == ATK.ATK_XY_WINDOW) {
+			/* translate control -> display, for filling in event to be dispatched */
+			int /*long*/ gtkAccessibleHandle = ATK.GTK_ACCESSIBLE (object.handle);
+			GtkAccessible gtkAccessible = new GtkAccessible ();
+			ATK.memmove (gtkAccessible, gtkAccessibleHandle);
+			int /*long*/ topLevel = ATK.gtk_widget_get_toplevel (gtkAccessible.widget);
+			int /*long*/ window = OS.GTK_WIDGET_WINDOW (topLevel);				
+			int[] topWindowX = new int [1], topWindowY = new int [1];
+			OS.gdk_window_get_origin (window, topWindowX, topWindowY);
+			event.x += topWindowX [0];
+			event.y += topWindowY [0]; 
+		}
+		for (int i = 0; i < listeners.length; i++) {
+			listeners [i].getLocation (event);
+		}
+		if (coord_type == ATK.ATK_XY_WINDOW) {
+			/* translate display -> control, for answering to the OS */ 
+			int /*long*/ gtkAccessibleHandle = ATK.GTK_ACCESSIBLE (object.handle);
+			GtkAccessible gtkAccessible = new GtkAccessible ();
+			ATK.memmove (gtkAccessible, gtkAccessibleHandle);
+			int /*long*/ topLevel = ATK.gtk_widget_get_toplevel (gtkAccessible.widget);
+			int /*long*/ window = OS.GTK_WIDGET_WINDOW (topLevel);
+			int[] topWindowX = new int [1], topWindowY = new int [1];
+			OS.gdk_window_get_origin (window, topWindowX, topWindowY);
+			event.x -= topWindowX [0];
+			event.y -= topWindowY [0];
+		}
+		OS.memmove (x, new int[] {event.x}, 4);
+		OS.memmove (y, new int[] {event.y}, 4);
+		OS.memmove (width, new int[] {event.width}, 4);
+		OS.memmove (height, new int[] {event.height}, 4);
+		return 0;
+	}
+
+	static int /*long*/ atkComponent_get_position (int /*long*/ atkObject, int /*long*/ x, int /*long*/ y, int /*long*/ coord_type) {
+		if (DEBUG) System.out.println ("-->atkComponent_get_position, object: " + atkObject + " x: " + x + " y: " + y + " coord: " + coord_type);
+		AccessibleObject object = getAccessibleObject (atkObject);
+		if (object == null) return 0;
+		OS.memmove (x, new int[] {0}, 4);
+		OS.memmove (y, new int[] {0}, 4);
+		if (ATK.g_type_is_a (object.parentType, ATK_COMPONENT_TYPE)) {
+			int /*long*/ superType = ATK.g_type_interface_peek_parent (ATK.ATK_COMPONENT_GET_IFACE (object.handle));
+			AtkComponentIface componentIface = new AtkComponentIface ();
+			ATK.memmove (componentIface, superType);
+			if (componentIface.get_extents != 0) {
+				ATK.call (componentIface.get_position, object.handle, x, y, coord_type);
+			}
+		}
+		AccessibleControlListener[] listeners = object.getControlListeners ();
+		if (listeners.length == 0) return 0;
+		
+		int[] parentX = new int [1], parentY = new int [1];
+		OS.memmove (parentX, x, 4);
+		OS.memmove (parentY, y, 4);
+		AccessibleControlEvent event = new AccessibleControlEvent (object);
+		event.childID = object.id;
+		event.x = parentX [0]; event.y = parentY [0];
+		if (coord_type == ATK.ATK_XY_WINDOW) {
+			/* translate control -> display, for filling in event to be dispatched */
+			int /*long*/ gtkAccessibleHandle = ATK.GTK_ACCESSIBLE (object.handle);
+			GtkAccessible gtkAccessible = new GtkAccessible ();
+			ATK.memmove (gtkAccessible, gtkAccessibleHandle);
+			int /*long*/ topLevel = ATK.gtk_widget_get_toplevel (gtkAccessible.widget);
+			int /*long*/ window = OS.GTK_WIDGET_WINDOW (topLevel);				
+			int[] topWindowX = new int [1], topWindowY = new int [1];
+			OS.gdk_window_get_origin (window, topWindowX, topWindowY);
+			event.x += topWindowX [0];
+			event.y += topWindowY [0]; 
+		}
+		for (int i = 0; i < listeners.length; i++) {
+			listeners [i].getLocation (event);
+		}
+		if (coord_type == ATK.ATK_XY_WINDOW) {
+			/* translate display -> control, for answering to the OS */ 
+			int /*long*/ gtkAccessibleHandle = ATK.GTK_ACCESSIBLE (object.handle);
+			GtkAccessible gtkAccessible = new GtkAccessible ();
+			ATK.memmove (gtkAccessible, gtkAccessibleHandle);
+			int /*long*/ topLevel = ATK.gtk_widget_get_toplevel (gtkAccessible.widget);
+			int /*long*/ window = OS.GTK_WIDGET_WINDOW (topLevel);
+			int[] topWindowX = new int [1], topWindowY = new int [1];
+			OS.gdk_window_get_origin (window, topWindowX, topWindowY);
+			event.x -= topWindowX [0];
+			event.y -= topWindowY [0];
+		}
+		OS.memmove (x, new int[] {event.x}, 4);
+		OS.memmove (y, new int[] {event.y}, 4);
+		return 0;
+	}
+
+	static int /*long*/ atkComponent_get_size (int /*long*/ atkObject, int /*long*/ width, int /*long*/ height, int /*long*/ coord_type) {
+		if (DEBUG) System.out.println ("-->atkComponent_get_size");
+		AccessibleObject object = getAccessibleObject (atkObject);
+		if (object == null) return 0;
+		OS.memmove (width, new int[] {0}, 4);
+		OS.memmove (height, new int[] {0}, 4);
+		if (ATK.g_type_is_a (object.parentType, ATK_COMPONENT_TYPE)) {
+			int /*long*/ superType = ATK.g_type_interface_peek_parent (ATK.ATK_COMPONENT_GET_IFACE (object.handle));
+			AtkComponentIface componentIface = new AtkComponentIface ();
+			ATK.memmove (componentIface, superType);
+			if (componentIface.get_extents != 0) {
+				ATK.call (componentIface.get_size, object.handle, width, height, coord_type);
+			}
+		}
+		AccessibleControlListener[] listeners = object.getControlListeners ();
+		if (listeners.length == 0) return 0;
+		
+		int[] parentWidth = new int [1], parentHeight = new int [1];
+		OS.memmove (parentWidth, width, 4);
+		OS.memmove (parentHeight, height, 4);
+		AccessibleControlEvent event = new AccessibleControlEvent (object);
+		event.childID = object.id;
+		event.width = parentWidth [0]; event.height = parentHeight [0];
+		for (int i = 0; i < listeners.length; i++) {
+			listeners [i].getLocation (event);
+		}
+		OS.memmove (width, new int[] {event.width}, 4);
+		OS.memmove (height, new int[] {event.height}, 4);
+		return 0;
+	}
+
+	static int /*long*/ atkComponent_ref_accessible_at_point (int /*long*/ atkObject, int /*long*/ x, int /*long*/ y, int /*long*/ coord_type) {
+		if (DEBUG) System.out.println ("-->atkComponent_ref_accessible_at_point");
+		AccessibleObject object = getAccessibleObject (atkObject);
+		if (object == null) return 0;
+		int /*long*/ parentResult = 0;
+		if (ATK.g_type_is_a (object.parentType, ATK_COMPONENT_TYPE)) {
+			int /*long*/ superType = ATK.g_type_interface_peek_parent (ATK.ATK_COMPONENT_GET_IFACE (object.handle));
+			AtkComponentIface componentIface = new AtkComponentIface ();
+			ATK.memmove (componentIface, superType);
+			if (componentIface.ref_accessible_at_point != 0) {
+				parentResult = ATK.call (componentIface.ref_accessible_at_point, object.handle, x, y, coord_type);
+			}
+		}
+		AccessibleControlListener[] listeners = object.getControlListeners ();
+		if (listeners.length == 0) return parentResult;
+		
+		AccessibleControlEvent event = new AccessibleControlEvent (object);
+		event.childID = object.id;
+		event.x = (int)/*64*/x; event.y = (int)/*64*/y;
+		if (coord_type == ATK.ATK_XY_WINDOW) {
+			/* translate control -> display, for filling in the event to be dispatched */
+			int /*long*/ gtkAccessibleHandle = ATK.GTK_ACCESSIBLE (object.handle);
+			GtkAccessible gtkAccessible = new GtkAccessible ();
+			ATK.memmove (gtkAccessible, gtkAccessibleHandle);
+			int /*long*/ topLevel = ATK.gtk_widget_get_toplevel (gtkAccessible.widget);
+			int /*long*/ window = OS.GTK_WIDGET_WINDOW (topLevel);				
+			int[] topWindowX = new int [1], topWindowY = new int [1];
+			OS.gdk_window_get_origin (window, topWindowX, topWindowY);
+			event.x += topWindowX [0];
+			event.y += topWindowY [0]; 
+		}
+		for (int i = 0; i < listeners.length; i++) {
+			listeners [i].getChildAtPoint (event);				
+		}
+		if (event.childID == object.id) event.childID = ACC.CHILDID_SELF;
+		AccessibleObject accObj = object.getChildByID (event.childID);
+		if (accObj != null) {
+			if (parentResult > 0) OS.g_object_unref (parentResult);
+			OS.g_object_ref (accObj.handle);	
+			return accObj.handle;
+		}
+		return parentResult;
+	}	
+
+	static int /*long*/ atkHypertext_get_link (int /*long*/ atkObject, int /*long*/ link_index) {
+		if (DEBUG) System.out.println ("-->atkHypertext_get_link");
+		return 0;
+	}
+
+	static int /*long*/ atkHypertext_get_n_links (int /*long*/ atkObject) {
+		if (DEBUG) System.out.println ("-->atkHypertext_get_n_links");
+		return 0;	/* read hyperlink's name */
+	}
+
+	static int /*long*/ atkHypertext_get_link_index (int /*long*/ atkObject, int /*long*/ char_index) {
+		if (DEBUG) System.out.println ("-->atkHypertext_get_link_index");
+		return 0;
+	}
+
+	static int /*long*/ atkObject_get_description (int /*long*/ atkObject) {
+		if (DEBUG) System.out.println ("-->atkObject_get_description");
+		AccessibleObject object = getAccessibleObject (atkObject);
+		if (object == null) return 0;
+		int /*long*/ parentResult = 0;
+		int /*long*/ superType = ATK.g_type_class_peek (object.parentType);
+		AtkObjectClass objectClass = new AtkObjectClass ();
+		ATK.memmove (objectClass, superType);
+		if (objectClass.get_description != 0) {
+			parentResult = ATK.call (objectClass.get_description, object.handle);
+		}
+		AccessibleListener[] listeners = object.getAccessibleListeners ();
+		if (listeners.length == 0) return parentResult;
+			
+		AccessibleEvent event = new AccessibleEvent (object);
+		event.childID = object.id;
+		if (parentResult != 0) {
+			int length = OS.strlen (parentResult);
+			byte [] buffer = new byte [length];
+			OS.memmove (buffer, parentResult, length);
+			event.result = new String (Converter.mbcsToWcs (null, buffer));
+		}
+		for (int i = 0; i < listeners.length; i++) {
+			listeners [i].getDescription (event);
+		} 
+		if (event.result == null) return parentResult;
+		if (descriptionPtr != -1) OS.g_free (descriptionPtr);
+		byte[] name = Converter.wcsToMbcs (null, event.result, true);
+		descriptionPtr = OS.g_malloc (name.length);
+		OS.memmove (descriptionPtr, name, name.length);
+		return descriptionPtr; 
+	}
+
+	static int /*long*/ atkObject_get_name (int /*long*/ atkObject) {
+		if (DEBUG) System.out.println ("-->atkObject_get_name: " + atkObject);
+		AccessibleObject object = getAccessibleObject (atkObject);
+		if (object == null) return 0;
+		int /*long*/ parentResult = 0;
+		int /*long*/ superType = ATK.g_type_class_peek (object.parentType);
+		AtkObjectClass objectClass = new AtkObjectClass ();
+		ATK.memmove (objectClass, superType);
+		if (objectClass.get_name != 0) {
+			parentResult = ATK.call (objectClass.get_name, object.handle);
+		}
+		AccessibleListener[] listeners = object.getAccessibleListeners ();
+		if (listeners.length == 0) return parentResult;
+		
+		AccessibleEvent event = new AccessibleEvent (object);
+		event.childID = object.id;
+		if (parentResult != 0) {
+			int length = OS.strlen (parentResult);
+			byte [] buffer = new byte [length];
+			OS.memmove (buffer, parentResult, length);
+			event.result = new String (Converter.mbcsToWcs (null, buffer));
+		}
+		for (int i = 0; i < listeners.length; i++) {
+			listeners [i].getName (event);				
+		} 
+		if (event.result == null) return parentResult;
+		if (namePtr != -1) OS.g_free (namePtr);
+		byte[] name = Converter.wcsToMbcs (null, event.result, true);
+		namePtr = OS.g_malloc (name.length);
+		OS.memmove (namePtr, name, name.length);
+		return namePtr; 
+	}	
+
+	static int /*long*/ atkObject_get_n_children (int /*long*/ atkObject) {
+		if (DEBUG) System.out.println ("-->atkObject_get_n_children: " + atkObject);
+		AccessibleObject object = getAccessibleObject (atkObject);
+		if (object == null) return 0;
+		int /*long*/ parentResult = 0;
+		int /*long*/ superType = ATK.g_type_class_peek (object.parentType);
+		AtkObjectClass objectClass = new AtkObjectClass ();
+		ATK.memmove (objectClass, superType);
+		if (objectClass.get_n_children != 0) { 
+			parentResult = ATK.call (objectClass.get_n_children, object.handle);
+		}
+		AccessibleControlListener[] listeners = object.getControlListeners ();
+		if (listeners.length == 0) return parentResult;
+			
+		AccessibleControlEvent event = new AccessibleControlEvent (object);
+		event.childID = object.id;
+		event.detail = (int)/*64*/parentResult;
+		for (int i = 0; i < listeners.length; i++) {
+			listeners [i].getChildCount (event);
+		} 
+		return event.detail;
+	}
+
+	static int /*long*/ atkObject_get_index_in_parent (int /*long*/ atkObject) {
+		if (DEBUG) System.out.println ("-->atkObjectCB_get_index_in_parent.  ");
+		AccessibleObject object = getAccessibleObject (atkObject);
+		if (object == null) return 0;
+		if (object.index != -1) return object.index;
+		int /*long*/ superType = ATK.g_type_class_peek (object.parentType);
+		AtkObjectClass objectClass = new AtkObjectClass ();
+		ATK.memmove (objectClass, superType);
+		if (objectClass.get_index_in_parent == 0) return 0;
+		return ATK.call (objectClass.get_index_in_parent,object. handle);
+	}
+
+	static int /*long*/ atkObject_get_parent (int /*long*/ atkObject) {
+		if (DEBUG) System.out.println ("-->atkObject_get_parent: " + atkObject);
+		AccessibleObject object = getAccessibleObject (atkObject);
+		if (object == null) return 0;
+		if (object.parent != null) return object.parent.handle;
+		int /*long*/ superType = ATK.g_type_class_peek (object.parentType);
+		AtkObjectClass objectClass = new AtkObjectClass ();
+		ATK.memmove (objectClass, superType);
+		if (objectClass.get_parent == 0) return 0;
+		return ATK.call (objectClass.get_parent, object.handle);
+	}
+
+	static int /*long*/ atkObject_get_role (int /*long*/ atkObject) {
+		if (DEBUG) System.out.println ("-->atkObject_get_role: " + atkObject);
+		AccessibleObject object = getAccessibleObject (atkObject);
+		if (object == null) return 0;
+		if (object.getAccessibleListeners ().length != 0) {
+			AccessibleControlListener[] listeners = object.getControlListeners ();
+			AccessibleControlEvent event = new AccessibleControlEvent (object);
+			event.childID = object.id;
+			event.detail = -1;
+			for (int i = 0; i < listeners.length; i++) {
+				listeners [i].getRole (event);				
+			} 
+			if (event.detail != -1) {
+				switch (event.detail) {
+					/* Convert from win32 role values to atk role values */
+					case ACC.ROLE_CHECKBUTTON: return ATK.ATK_ROLE_CHECK_BOX;
+					case ACC.ROLE_CLIENT_AREA: return ATK.ATK_ROLE_DRAWING_AREA;
+					case ACC.ROLE_COMBOBOX: return ATK.ATK_ROLE_COMBO_BOX;
+					case ACC.ROLE_DIALOG: return ATK.ATK_ROLE_DIALOG;
+					case ACC.ROLE_LABEL: return ATK.ATK_ROLE_LABEL;
+					case ACC.ROLE_LINK: return ATK.ATK_ROLE_TEXT;
+					case ACC.ROLE_LIST: return ATK.ATK_ROLE_LIST;
+					case ACC.ROLE_LISTITEM: return ATK.ATK_ROLE_LIST_ITEM;
+					case ACC.ROLE_MENU: return ATK.ATK_ROLE_MENU;
+					case ACC.ROLE_MENUBAR: return ATK.ATK_ROLE_MENU_BAR;
+					case ACC.ROLE_MENUITEM: return ATK.ATK_ROLE_MENU_ITEM;
+					case ACC.ROLE_PROGRESSBAR: return ATK.ATK_ROLE_PROGRESS_BAR;
+					case ACC.ROLE_PUSHBUTTON: return ATK.ATK_ROLE_PUSH_BUTTON;
+					case ACC.ROLE_SCROLLBAR: return ATK.ATK_ROLE_SCROLL_BAR;
+					case ACC.ROLE_SEPARATOR: return ATK.ATK_ROLE_SEPARATOR;
+					case ACC.ROLE_SLIDER: return ATK.ATK_ROLE_SLIDER;
+					case ACC.ROLE_TABLE: return ATK.ATK_ROLE_LIST;
+					case ACC.ROLE_TABLECELL: return ATK.ATK_ROLE_LIST_ITEM;
+					case ACC.ROLE_TABLECOLUMNHEADER: return ATK.ATK_ROLE_TABLE_COLUMN_HEADER;
+					case ACC.ROLE_TABLEROWHEADER: return ATK.ATK_ROLE_TABLE_ROW_HEADER;
+					case ACC.ROLE_TABFOLDER: return ATK.ATK_ROLE_PAGE_TAB_LIST;
+					case ACC.ROLE_TABITEM: return ATK.ATK_ROLE_PAGE_TAB;
+					case ACC.ROLE_TEXT: return ATK.ATK_ROLE_TEXT;
+					case ACC.ROLE_TOOLBAR: return ATK.ATK_ROLE_TOOL_BAR;
+					case ACC.ROLE_TOOLTIP: return ATK.ATK_ROLE_TOOL_TIP;
+					case ACC.ROLE_TREE: return ATK.ATK_ROLE_TREE;
+					case ACC.ROLE_TREEITEM: return ATK.ATK_ROLE_LIST_ITEM;
+					case ACC.ROLE_RADIOBUTTON: return ATK.ATK_ROLE_RADIO_BUTTON;
+					case ACC.ROLE_WINDOW: return ATK.ATK_ROLE_WINDOW;
+				}
+			}
+		} 
+		int /*long*/ superType = ATK.g_type_class_peek (object.parentType);
+		AtkObjectClass objectClass = new AtkObjectClass ();
+		ATK.memmove (objectClass, superType);
+		if (objectClass.get_role == 0) return 0;
+		return ATK.call (objectClass.get_role, object.handle);
+	}
+
+	static int /*long*/ atkObject_ref_child (int /*long*/ atkObject, int /*long*/ index) {
+		if (DEBUG) System.out.println ("-->atkObject_ref_child: " + index + " of: " + atkObject);
+		AccessibleObject object = getAccessibleObject (atkObject);
+		if (object == null) return 0;
+		object.updateChildren ();
+		AccessibleObject accObject = object.getChildByIndex ((int)/*64*/index);	
+		if (accObject != null) {
+			OS.g_object_ref (accObject.handle);	
+			return accObject.handle;
+		}
+		int /*long*/ superType = ATK.g_type_class_peek (object.parentType);
+		AtkObjectClass objectClass = new AtkObjectClass ();
+		ATK.memmove (objectClass, superType);
+		if (objectClass.ref_child == 0) return 0;
+		return ATK.call (objectClass.ref_child, object.handle, index);
+	}
+
+	static int /*long*/ atkObject_ref_state_set (int /*long*/ atkObject) {
+		if (DEBUG) System.out.println ("-->atkObject_ref_state_set");
+		AccessibleObject object = getAccessibleObject (atkObject);
+		if (object == null) return 0;
+		int /*long*/ parentResult = 0;
+		int /*long*/ superType = ATK.g_type_class_peek (object.parentType);
+		AtkObjectClass objectClass = new AtkObjectClass ();
+		ATK.memmove (objectClass, superType);
+		if (objectClass.ref_state_set != 0) { 
+			parentResult = ATK.call (objectClass.ref_state_set, object.handle);
+		}
+		AccessibleControlListener[] listeners = object.getControlListeners ();
+		if (listeners.length == 0) return parentResult;
+
+		int /*long*/ set = parentResult;
+		AccessibleControlEvent event = new AccessibleControlEvent (object);
+		event.childID = object.id;
+		event.detail = -1;
+		for (int i = 0; i < listeners.length; i++) {
+			listeners [i].getState (event);
+		} 
+		if (event.detail != -1) {
+			/*	Convert from win32 state values to atk state values */
+			int state = event.detail;
+			if ((state & ACC.STATE_BUSY) != 0) ATK.atk_state_set_add_state (set, ATK.ATK_STATE_BUSY);
+			if ((state & ACC.STATE_CHECKED) != 0) ATK.atk_state_set_add_state (set, ATK.ATK_STATE_CHECKED);
+			if ((state & ACC.STATE_EXPANDED) != 0) ATK.atk_state_set_add_state (set, ATK.ATK_STATE_EXPANDED);
+			if ((state & ACC.STATE_FOCUSABLE) != 0) ATK.atk_state_set_add_state (set, ATK.ATK_STATE_FOCUSABLE);
+			if ((state & ACC.STATE_FOCUSED) != 0) ATK.atk_state_set_add_state (set, ATK.ATK_STATE_FOCUSED);
+			if ((state & ACC.STATE_HOTTRACKED) != 0) ATK.atk_state_set_add_state (set, ATK.ATK_STATE_ARMED);
+			if ((state & ACC.STATE_INVISIBLE) == 0) ATK.atk_state_set_add_state (set, ATK.ATK_STATE_VISIBLE);
+			if ((state & ACC.STATE_MULTISELECTABLE) != 0) ATK.atk_state_set_add_state (set, ATK.ATK_STATE_MULTISELECTABLE);
+			if ((state & ACC.STATE_OFFSCREEN) == 0) ATK.atk_state_set_add_state (set, ATK.ATK_STATE_SHOWING);												
+			if ((state & ACC.STATE_PRESSED) != 0) ATK.atk_state_set_add_state (set, ATK.ATK_STATE_PRESSED);
+			if ((state & ACC.STATE_READONLY) == 0) ATK.atk_state_set_add_state (set, ATK.ATK_STATE_EDITABLE);
+			if ((state & ACC.STATE_SELECTABLE) != 0) ATK.atk_state_set_add_state (set, ATK.ATK_STATE_SELECTABLE);
+			if ((state & ACC.STATE_SELECTED) != 0) ATK.atk_state_set_add_state (set, ATK.ATK_STATE_SELECTED);
+			if ((state & ACC.STATE_SIZEABLE) != 0) ATK.atk_state_set_add_state (set, ATK.ATK_STATE_RESIZABLE);
+			/* Note: STATE_COLLAPSED, STATE_LINKED and STATE_NORMAL have no ATK equivalents */
+		}
+		return set;
+	}
+
+	static int /*long*/ atkSelection_is_child_selected (int /*long*/ atkObject, int /*long*/ index) {
+		if (DEBUG) System.out.println ("-->atkSelection_is_child_selected");
+		AccessibleObject object = getAccessibleObject (atkObject);
+		if (object == null) return 0;
+		int /*long*/ parentResult = 0;
+		if (ATK.g_type_is_a (object.parentType, ATK_SELECTION_TYPE)) {
+			int /*long*/ superType = ATK.g_type_interface_peek_parent (ATK.ATK_SELECTION_GET_IFACE (object.handle));
+			AtkSelectionIface selectionIface = new AtkSelectionIface ();
+			ATK.memmove (selectionIface, superType);
+			if (selectionIface.is_child_selected != 0) {
+				parentResult = ATK.call (selectionIface.is_child_selected, object.handle, index);
+			}
+		}
+		AccessibleControlListener[] listeners = object.getControlListeners ();
+		if (listeners.length == 0) return parentResult;
+			
+		AccessibleControlEvent event = new AccessibleControlEvent (object);
+		event.childID = object.id;
+		for (int i = 0; i < listeners.length; i++) {
+			listeners [i].getSelection (event);
+		}
+		AccessibleObject accessibleObject = object.getChildByID (event.childID);
+		if (accessibleObject != null) { 
+			return accessibleObject.index == index ? 1 : 0;
+		}
+		return parentResult;
+	}
+
+	static int /*long*/ atkSelection_ref_selection (int /*long*/ atkObject, int /*long*/ index) {
+		if (DEBUG) System.out.println ("-->atkSelection_ref_selection");
+		AccessibleObject object = getAccessibleObject (atkObject);
+		if (object == null) return 0;
+		int /*long*/ parentResult = 0;
+		if (ATK.g_type_is_a (object.parentType, ATK_SELECTION_TYPE)) {
+			int /*long*/ superType = ATK.g_type_interface_peek_parent (ATK.ATK_SELECTION_GET_IFACE (object.handle));
+			AtkSelectionIface selectionIface = new AtkSelectionIface ();
+			ATK.memmove (selectionIface, superType);
+			if (selectionIface.ref_selection != 0) {
+				parentResult = ATK.call (selectionIface.ref_selection, object.handle, index);
+			}
+		}
+		AccessibleControlListener[] listeners = object.getControlListeners ();
+		if (listeners.length == 0) return parentResult;
+			
+		AccessibleControlEvent event = new AccessibleControlEvent (object);
+		event.childID = object.id;
+		for (int i = 0; i < listeners.length; i++) {
+			listeners [i].getSelection (event);
+		} 
+		AccessibleObject accObj = object.getChildByID (event.childID);
+		if (accObj != null) {
+			if (parentResult > 0) OS.g_object_unref (parentResult);
+			OS.g_object_ref (accObj.handle);	
+			return accObj.handle;
+		}
+		return parentResult;
+	}
+
+	static int /*long*/ atkText_get_caret_offset (int /*long*/ atkObject) {
+		if (DEBUG) System.out.println ("-->atkText_get_caret_offset");
+		AccessibleObject object = getAccessibleObject (atkObject);
+		if (object == null) return 0;
+		int /*long*/ parentResult = 0;
+		if (ATK.g_type_is_a (object.parentType, ATK_TEXT_TYPE)) {
+			int /*long*/ superType = ATK.g_type_interface_peek_parent (ATK.ATK_TEXT_GET_IFACE (object.handle));
+			AtkTextIface textIface = new AtkTextIface ();
+			ATK.memmove (textIface, superType);
+			if (textIface.get_caret_offset != 0) {
+				parentResult = ATK.call (textIface.get_caret_offset, object.handle);
+			}
+		}
+		AccessibleTextListener[] listeners = object.getTextListeners ();
+		if (listeners.length == 0) return parentResult;
+		
+		AccessibleTextEvent event = new AccessibleTextEvent (object);
+		event.childID = object.id;
+		event.offset = (int)/*64*/parentResult;
+		for (int i = 0; i < listeners.length; i++) {
+			listeners [i].getCaretOffset (event);	
+		} 
+		return event.offset; 	
+	}
+	
+	static int /*long*/ atkText_get_character_at_offset (int /*long*/ atkObject, int /*long*/ offset) {
+		if (DEBUG) System.out.println ("-->atkText_get_character_at_offset");
+		AccessibleObject object = getAccessibleObject (atkObject);
+		if (object == null) return 0;
+		String text = object.getText ();
+		if (text != null) return text.charAt ((int)/*64*/offset); // TODO
+		if (ATK.g_type_is_a (object.parentType, ATK_TEXT_TYPE)) {
+			int /*long*/ superType = ATK.g_type_class_peek (object.parentType);
+			AtkTextIface textIface = new AtkTextIface ();
+			ATK.memmove (textIface, superType);
+			if (textIface.get_character_at_offset != 0) {
+				return ATK.call (textIface.get_character_at_offset, object.handle, offset);
+			}
+		}
+		return 0;
+	}
+
+	static int /*long*/ atkText_get_character_count (int /*long*/ atkObject) {
+		if (DEBUG) System.out.println ("-->atkText_get_character_count");
+		AccessibleObject object = getAccessibleObject (atkObject);
+		if (object == null) return 0;
+		String text = object.getText ();
+		if (text != null) return text.length ();
+		if (ATK.g_type_is_a (object.parentType, ATK_TEXT_TYPE)) {
+			int /*long*/ superType = ATK.g_type_class_peek (object.parentType);
+			AtkTextIface textIface = new AtkTextIface ();
+			ATK.memmove (textIface, superType);
+			if (textIface.get_character_count != 0) {
+				return ATK.call (textIface.get_character_count, object.handle);
+			}
+		}
+		return 0;
+	}
+
+	static int /*long*/ atkText_get_n_selections (int /*long*/ atkObject) {
+		if (DEBUG) System.out.println ("-->atkText_get_n_selections");
+		AccessibleObject object = getAccessibleObject (atkObject);
+		if (object == null) return 0;
+		int /*long*/ parentResult = 0;
+		if (ATK.g_type_is_a (object.parentType, ATK_TEXT_TYPE)) {
+			int /*long*/ superType = ATK.g_type_interface_peek_parent (ATK.ATK_TEXT_GET_IFACE (object.handle));
+			AtkTextIface textIface = new AtkTextIface ();
+			ATK.memmove (textIface, superType);
+			if (textIface.get_n_selections != 0) {
+				parentResult = ATK.call (textIface.get_n_selections, object.handle);
+			}
+		}
+		AccessibleTextListener[] listeners = object.getTextListeners ();
+		if (listeners.length == 0) return parentResult;
+
+		AccessibleTextEvent event = new AccessibleTextEvent (object);
+		event.childID = object.id;
+		for (int i = 0; i < listeners.length; i++) {
+			listeners [i].getSelectionRange (event);
+		}
+		return event.length == 0 ? parentResult : 1;
+	}
+
+	static int /*long*/ atkText_get_selection (int /*long*/ atkObject, int /*long*/ selection_num, int /*long*/ start_offset, int /*long*/ end_offset) {
+		if (DEBUG) System.out.println ("-->atkText_get_selection");
+		AccessibleObject object = getAccessibleObject (atkObject);
+		if (object == null) return 0;
+		OS.memmove (start_offset, new int[] {0}, 4);
+		OS.memmove (end_offset, new int[] {0}, 4);
+		if (ATK.g_type_is_a (object.parentType, ATK_TEXT_TYPE)) {
+			int /*long*/ superType = ATK.g_type_interface_peek_parent (ATK.ATK_TEXT_GET_IFACE (object.handle));
+			AtkTextIface textIface = new AtkTextIface ();
+			ATK.memmove (textIface, superType);
+			if (textIface.get_selection != 0) {
+				ATK.call (textIface.get_selection, object.handle, selection_num, start_offset, end_offset);
+			}
+		}
+		AccessibleTextListener[] listeners = object.getTextListeners ();
+		if (listeners.length == 0) return 0;
+
+		AccessibleTextEvent event = new AccessibleTextEvent (object);
+		event.childID = object.id;
+		int[] parentStart = new int [1];
+		int[] parentEnd = new int [1];
+		OS.memmove (parentStart, start_offset, 4);
+		OS.memmove (parentEnd, end_offset, 4);
+		event.offset = parentStart [0];
+		event.length = parentEnd [0] - parentStart [0];
+		for (int i = 0; i < listeners.length; i++) {
+			listeners [i].getSelectionRange (event);
+		}
+		OS.memmove (start_offset, new int[] {event.offset}, 4);
+		OS.memmove (end_offset, new int[] {event.offset + event.length}, 4);
+		return 0;
+	}
+
+	static int /*long*/ atkText_get_text (int /*long*/ atkObject, int /*long*/ start_offset, int /*long*/ end_offset) {
+		if (DEBUG) System.out.println ("-->atkText_get_text: " + start_offset + "," + end_offset);
+		AccessibleObject object = getAccessibleObject (atkObject);
+		if (object == null) return 0;
+		String text = object.getText ();
+		if (text.length () > 0) {
+			if (end_offset == -1) {
+				end_offset = text.length ();
+			} else {
+				end_offset = Math.min (end_offset, text.length ());	
+			}
+			start_offset = Math.min (start_offset, end_offset);
+			text = text.substring ((int)/*64*/start_offset, (int)/*64*/end_offset);
+			byte[] bytes = Converter.wcsToMbcs (null, text, true);
+			int /*long*/ result = OS.g_malloc (bytes.length);
+			OS.memmove (result, bytes, bytes.length);
+			return result;
+		}
+		return 0;
+	}
+
+	static int /*long*/ atkText_get_text_after_offset (int /*long*/ atkObject, int /*long*/ offset_value, int /*long*/ boundary_type, int /*long*/ start_offset, int /*long*/ end_offset) {
+		if (DEBUG) System.out.println ("-->atkText_get_text_after_offset");
+		AccessibleObject object = getAccessibleObject (atkObject);
+		if (object == null) return 0;
+		int offset = (int)/*64*/offset_value;
+		String text = object.getText ();
+		if (text.length () > 0) {
+			int length = text.length ();
+			offset = Math.min (offset, length - 1);
+			int startBounds = offset;
+			int endBounds = offset;
+			switch ((int)/*64*/boundary_type) {
+				case ATK.ATK_TEXT_BOUNDARY_CHAR: {
+					if (length > offset) endBounds++;
+					break;
+				}
+				case ATK.ATK_TEXT_BOUNDARY_WORD_START: {
+					int wordStart1 = nextIndexOfChar (text, " !?.\n", offset - 1);
+					if (wordStart1 == -1) {
+						startBounds = endBounds = length;
+						break;
+					}
+					wordStart1 = nextIndexOfNotChar (text, " !?.\n", wordStart1);
+					if (wordStart1 == length) {
+						startBounds = endBounds = length;
+						break;
+					}
+					startBounds = wordStart1;
+					int wordStart2 = nextIndexOfChar (text, " !?.\n", wordStart1);
+					if (wordStart2 == -1) {
+						endBounds = length;
+						break;
+					}
+					endBounds = nextIndexOfNotChar (text, " !?.\n", wordStart2);
+					break;
+				}
+				case ATK.ATK_TEXT_BOUNDARY_WORD_END: {
+					int previousWordEnd = previousIndexOfNotChar (text, " \n", offset); 
+					if (previousWordEnd == -1 || previousWordEnd != offset - 1) {
+						offset = nextIndexOfNotChar (text, " \n", offset);
+					}
+					if (offset == -1) {
+						startBounds = endBounds = length;
+						break;
+					}
+					int wordEnd1 = nextIndexOfChar (text, " !?.\n", (int)/*64*/offset);
+					if (wordEnd1 == -1) {
+						startBounds = endBounds = length;
+						break;
+					}
+					wordEnd1 = nextIndexOfNotChar (text, "!?.", wordEnd1);
+					if (wordEnd1 == length) {
+						startBounds = endBounds = length;
+						break;
+					}
+					startBounds = wordEnd1;
+					int wordEnd2 = nextIndexOfNotChar (text, " \n", wordEnd1);
+					if (wordEnd2 == length) {
+						startBounds = endBounds = length;
+						break;
+					}
+					wordEnd2 = nextIndexOfChar (text, " !?.\n", wordEnd2);
+					if (wordEnd2 == -1) {
+						endBounds = length;
+						break;
+					}
+					endBounds = nextIndexOfNotChar (text, "!?.", wordEnd2);
+					break;
+				}
+				case ATK.ATK_TEXT_BOUNDARY_SENTENCE_START: {
+					int previousSentenceEnd = previousIndexOfChar (text, "!?.", offset);
+					int previousText = previousIndexOfNotChar (text, " !?.\n", offset);
+					int sentenceStart1 = 0;
+					if (previousSentenceEnd >= previousText) {
+						sentenceStart1 = nextIndexOfNotChar (text, " !?.\n", offset);
+					} else {
+						sentenceStart1 = nextIndexOfChar (text, "!?.", offset);
+						if (sentenceStart1 == -1) {
+							startBounds = endBounds = length;
+							break;
+						}
+						sentenceStart1 = nextIndexOfNotChar (text, " !?.\n", sentenceStart1);
+					}
+					if (sentenceStart1 == length) {
+						startBounds = endBounds = length;
+						break;
+					}
+					startBounds = sentenceStart1;
+					int sentenceStart2 = nextIndexOfChar (text, "!?.", sentenceStart1);
+					if (sentenceStart2 == -1) {
+						endBounds = length;
+						break;
+					}
+					endBounds = nextIndexOfNotChar (text, " !?.\n", sentenceStart2);
+					break;
+				}
+				case ATK.ATK_TEXT_BOUNDARY_SENTENCE_END: {
+					int sentenceEnd1 = nextIndexOfChar (text, "!?.", offset);
+					if (sentenceEnd1 == -1) {
+						startBounds = endBounds = length;
+						break;
+					}
+					sentenceEnd1 = nextIndexOfNotChar (text, "!?.", sentenceEnd1);
+					if (sentenceEnd1 == length) {
+						startBounds = endBounds = length;
+						break;
+					}
+					startBounds = sentenceEnd1;
+					int sentenceEnd2 = nextIndexOfNotChar (text, " \n", sentenceEnd1);
+					if (sentenceEnd2 == length) {
+						startBounds = endBounds = length;
+						break;
+					}
+					sentenceEnd2 = nextIndexOfChar (text, "!?.", sentenceEnd2);
+					if (sentenceEnd2 == -1) {
+						endBounds = length;
+						break;
+					}
+					endBounds = nextIndexOfNotChar (text, "!?.", sentenceEnd2);
+					break;
+				}
+				case ATK.ATK_TEXT_BOUNDARY_LINE_START: {
+					int lineStart1 = text.indexOf ('\n', offset - 1);
+					if (lineStart1 == -1) {
+						startBounds = endBounds = length;
+						break;
+					}
+					lineStart1 = nextIndexOfNotChar (text, "\n", lineStart1);
+					if (lineStart1 == length) {
+						startBounds = endBounds = length;
+						break;
+					}
+					startBounds = lineStart1;
+					int lineStart2 = text.indexOf ('\n', lineStart1);
+					if (lineStart2 == -1) {
+						endBounds = length;
+						break;
+					}
+					lineStart2 = nextIndexOfNotChar (text, "\n", lineStart2);
+					endBounds = lineStart2;
+					break;
+				}
+				case ATK.ATK_TEXT_BOUNDARY_LINE_END: {
+					int lineEnd1 = nextIndexOfChar (text, "\n", offset);
+					if (lineEnd1 == -1) {
+						startBounds = endBounds = length;
+						break;
+					}
+					startBounds = lineEnd1;
+					if (startBounds == length) {
+						endBounds = length;
+						break;
+					}
+					int lineEnd2 = nextIndexOfChar (text, "\n", lineEnd1 + 1);
+					if (lineEnd2 == -1) {
+						endBounds = length;
+						break;
+					}
+					endBounds = lineEnd2;
+					break;
+				}
+			}
+			OS.memmove (start_offset, new int[] {startBounds}, 4);
+			OS.memmove (end_offset, new int[] {endBounds}, 4);
+			text = text.substring (startBounds, endBounds);
+			byte[] bytes = Converter.wcsToMbcs (null, text, true);
+			int /*long*/ result = OS.g_malloc (bytes.length);
+			OS.memmove (result, bytes, bytes.length);
+			return result;
+		} 
+		return 0;
+	}
+
+	static int /*long*/ atkText_get_text_at_offset (int /*long*/ atkObject, int /*long*/ offset_value, int /*long*/ boundary_type, int /*long*/ start_offset, int /*long*/ end_offset) {
+		if (DEBUG) System.out.println ("-->atkText_get_text_at_offset: " + offset_value + " start: " + start_offset + " end: " + end_offset);
+		AccessibleObject object = getAccessibleObject (atkObject);
+		if (object == null) return 0;
+		int offset = (int)/*64*/offset_value;
+		String text = object.getText ();
+		if (text.length () > 0) {
+			int length = text.length ();
+			offset = Math.min (offset, length - 1);
+			int startBounds = offset;
+			int endBounds = offset;
+			switch ((int)/*64*/boundary_type) {
+				case ATK.ATK_TEXT_BOUNDARY_CHAR: {
+					if (length > offset) endBounds++;
+					break;
+				}
+				case ATK.ATK_TEXT_BOUNDARY_WORD_START: {
+					int wordStart1 = previousIndexOfNotChar (text, " !?.\n", offset);
+					if (wordStart1 == -1) {
+						startBounds = endBounds = 0;
+						break;
+					}
+					wordStart1 = previousIndexOfChar (text, " !?.\n", wordStart1) + 1;
+					if (wordStart1 == -1) {
+						startBounds = 0;
+						break;
+					}
+					startBounds = wordStart1;
+					int wordStart2 = nextIndexOfChar (text, " !?.\n", wordStart1);
+					endBounds = nextIndexOfNotChar (text, " !?.\n", wordStart2);
+					break;
+				}
+				case ATK.ATK_TEXT_BOUNDARY_WORD_END: {
+					int wordEnd1 = previousIndexOfNotChar (text, "!?.", offset + 1);
+					wordEnd1 = previousIndexOfChar (text, " !?.\n", wordEnd1);
+					wordEnd1 = previousIndexOfNotChar (text, " \n", wordEnd1 + 1);
+					if (wordEnd1 == -1) {
+						startBounds = endBounds = 0;
+						break;
+					}
+					startBounds = wordEnd1 + 1;
+					int wordEnd2 = nextIndexOfNotChar (text, " \n", startBounds);
+					if (wordEnd2 == length) {
+						endBounds = startBounds;
+						break;
+					}
+					wordEnd2 = nextIndexOfChar (text, " !?.\n", wordEnd2);
+					if (wordEnd2 == -1) {
+						endBounds = startBounds;
+						break;
+					}
+					endBounds = nextIndexOfNotChar (text, "!?.", wordEnd2);
+					break;
+				}
+				case ATK.ATK_TEXT_BOUNDARY_SENTENCE_START: {
+					int sentenceStart1 = previousIndexOfNotChar (text, " !?.\n", offset + 1);
+					if (sentenceStart1 == -1) {
+						startBounds = endBounds = 0;
+						break;
+					}
+					sentenceStart1 = previousIndexOfChar (text, "!?.", sentenceStart1) + 1;
+					startBounds = nextIndexOfNotChar (text, " \n", sentenceStart1);
+					int sentenceStart2 = nextIndexOfChar (text, "!?.", startBounds);
+					endBounds = nextIndexOfNotChar (text, " !?.\n", sentenceStart2);
+					break;
+				}
+				case ATK.ATK_TEXT_BOUNDARY_SENTENCE_END: {
+					int sentenceEnd1 = previousIndexOfNotChar (text, "!?.", offset + 1);
+					sentenceEnd1 = previousIndexOfChar (text, "!?.", sentenceEnd1);
+					sentenceEnd1 = previousIndexOfNotChar (text, " \n", sentenceEnd1 + 1);
+					if (sentenceEnd1 == -1) {
+						startBounds = endBounds = 0;
+						break;
+					}
+					startBounds = sentenceEnd1 + 1;
+					int sentenceEnd2 = nextIndexOfNotChar (text, " \n", startBounds);
+					if (sentenceEnd2 == length) {
+						endBounds = startBounds;
+						break;
+					}
+					sentenceEnd2 = nextIndexOfChar (text, "!?.", sentenceEnd2);
+					if (sentenceEnd2 == -1) {
+						endBounds = startBounds;
+						break;
+					}
+					endBounds = nextIndexOfNotChar (text, "!?.", sentenceEnd2);
+					break;
+				}
+				case ATK.ATK_TEXT_BOUNDARY_LINE_START: {
+					startBounds = previousIndexOfChar (text, "\n", offset) + 1;
+					int lineEnd2 = nextIndexOfChar (text, "\n", startBounds);
+					if (lineEnd2 < length) lineEnd2++;
+					endBounds = lineEnd2;
+					break;
+				}
+				case ATK.ATK_TEXT_BOUNDARY_LINE_END: {
+					int lineEnd1 = previousIndexOfChar (text, "\n", offset);
+					if (lineEnd1 == -1) {
+						startBounds = endBounds = 0;
+						break;
+					}
+					startBounds = lineEnd1;
+					endBounds = nextIndexOfChar (text, "\n", lineEnd1 + 1);
+				}
+			}
+			OS.memmove (start_offset, new int[] {startBounds}, 4);
+			OS.memmove (end_offset, new int[] {endBounds}, 4);
+			text = text.substring (startBounds, endBounds);
+			byte[] bytes = Converter.wcsToMbcs (null, text, true);
+			int /*long*/ result = OS.g_malloc (bytes.length);
+			OS.memmove (result, bytes, bytes.length);
+			return result;
+		} 
+		return 0;
+	}
+
+	static int /*long*/ atkText_get_text_before_offset (int /*long*/ atkObject, int /*long*/ offset_value, int /*long*/ boundary_type, int /*long*/ start_offset, int /*long*/ end_offset) {
+		if (DEBUG) System.out.println ("-->atkText_get_text_before_offset");
+		AccessibleObject object = getAccessibleObject (atkObject);
+		if (object == null) return 0;
+		int offset = (int)/*64*/offset_value;
+		String text = object.getText ();
+		if (text.length () > 0) {
+			int length = text.length ();
+			offset = Math.min (offset, length - 1);
+			int startBounds = offset;
+			int endBounds = offset;
+			switch ((int)/*64*/boundary_type) {
+				case ATK.ATK_TEXT_BOUNDARY_CHAR: {
+					if (length >= offset && offset > 0) startBounds--;
+					break;
+				}
+				case ATK.ATK_TEXT_BOUNDARY_WORD_START: {
+					int wordStart1 = previousIndexOfChar (text, " !?.\n", offset - 1);
+					if (wordStart1 == -1) {
+						startBounds = endBounds = 0;
+						break;
+					}
+					int wordStart2 = previousIndexOfNotChar (text, " !?.\n", wordStart1);
+					if (wordStart2 == -1) {
+						startBounds = endBounds = 0;
+						break;
+					}
+					endBounds = wordStart1 + 1;
+					startBounds = previousIndexOfChar (text, " !?.\n", wordStart2) + 1;
+					break;
+				}
+				case ATK.ATK_TEXT_BOUNDARY_WORD_END: {
+					int wordEnd1 =previousIndexOfChar (text, " !?.\n", offset);
+					if (wordEnd1 == -1) {
+						startBounds = endBounds = 0;
+						break;
+					}
+					wordEnd1 = previousIndexOfNotChar (text, " \n", wordEnd1 + 1);
+					if (wordEnd1 == -1) {
+						startBounds = endBounds = 0;
+						break;
+					}
+					endBounds = wordEnd1 + 1;
+					int wordEnd2 = previousIndexOfNotChar (text, " !?.\n", endBounds);
+					wordEnd2 = previousIndexOfChar (text, " !?.\n", wordEnd2);
+					if (wordEnd2 == -1) {
+						startBounds = 0;
+						break;
+					}
+					startBounds = previousIndexOfNotChar (text, " \n", wordEnd2 + 1) + 1;
+					break;
+				}
+				case ATK.ATK_TEXT_BOUNDARY_SENTENCE_START: {
+					int sentenceStart1 = previousIndexOfChar (text, "!?.", offset);
+					if (sentenceStart1 == -1) {
+						startBounds = endBounds = 0;
+						break;
+					}
+					int sentenceStart2 = previousIndexOfNotChar (text, "!?.", sentenceStart1);
+					if (sentenceStart2 == -1) {
+						startBounds = endBounds = 0;
+						break;
+					}
+					endBounds = sentenceStart1 + 1;
+					startBounds = previousIndexOfChar (text, "!?.", sentenceStart2) + 1;
+					break;
+				}
+				case ATK.ATK_TEXT_BOUNDARY_SENTENCE_END: {
+					int sentenceEnd1 = previousIndexOfChar (text, "!?.", offset);
+					if (sentenceEnd1 == -1) {
+						startBounds = endBounds = 0;
+						break;
+					}
+					sentenceEnd1 = previousIndexOfNotChar (text, " \n", sentenceEnd1 + 1);
+					if (sentenceEnd1 == -1) {
+						startBounds = endBounds = 0;
+						break;
+					}
+					endBounds = sentenceEnd1 + 1;
+					int sentenceEnd2 = previousIndexOfNotChar (text, "!?.", endBounds);
+					sentenceEnd2 = previousIndexOfChar (text, "!?.", sentenceEnd2);
+					if (sentenceEnd2 == -1) {
+						startBounds = 0;
+						break;
+					}
+					startBounds = previousIndexOfNotChar (text, " \n", sentenceEnd2 + 1) + 1;
+					break;
+				}
+				case ATK.ATK_TEXT_BOUNDARY_LINE_START: {
+					int lineStart1 = previousIndexOfChar (text, "\n", offset);
+					if (lineStart1 == -1) {
+						startBounds = endBounds = 0;
+						break;
+					}
+					endBounds = lineStart1 + 1;
+					startBounds = previousIndexOfChar (text, "\n", lineStart1) + 1;
+					break;
+				}
+				case ATK.ATK_TEXT_BOUNDARY_LINE_END: {
+					int lineEnd1 = previousIndexOfChar (text, "\n", offset);
+					if (lineEnd1 == -1) {
+						startBounds = endBounds = 0;
+						break;
+					}
+					endBounds = lineEnd1;
+					startBounds = previousIndexOfChar (text, "\n", lineEnd1);
+					if (startBounds == -1) startBounds = 0;
+					break;
+				}
+			}
+			OS.memmove (start_offset, new int[] {startBounds}, 4);
+			OS.memmove (end_offset, new int[] {endBounds}, 4);
+			text = text.substring (startBounds, endBounds);
+			byte[] bytes = Converter.wcsToMbcs (null, text, true);
+			int /*long*/ result = OS.g_malloc (bytes.length);
+			OS.memmove (result, bytes, bytes.length);
+			return result;
+		} 
+		return 0;
+	}
+
+	AccessibleListener[] getAccessibleListeners () {
+		if (accessible == null) return new AccessibleListener [0];
+		AccessibleListener[] result = accessible.getAccessibleListeners ();
+		return result != null ? result : new AccessibleListener [0];
+	}
+
+	static AccessibleObject getAccessibleObject (int /*long*/ atkObject) {
+		return (AccessibleObject)AccessibleObjects.get (new LONG (atkObject));
+	}
+	
+	AccessibleObject getChildByHandle (int /*long*/ handle) {
+		return (AccessibleObject) children.get (new LONG (handle));	
+	}	
+
+	AccessibleObject getChildByID (int childId) {
+		if (childId == ACC.CHILDID_SELF) return this;
+		Enumeration elements = children.elements ();
+		while (elements.hasMoreElements ()) {
+			AccessibleObject object = (AccessibleObject) elements.nextElement ();
+			if (object.id == childId) return object;
+		}
+		return null;
+	}
+	
+	AccessibleObject getChildByIndex (int childIndex) {
+		Enumeration elements = children.elements ();
+		while (elements.hasMoreElements ()) {
+			AccessibleObject object = (AccessibleObject) elements.nextElement ();
+			if (object.index == childIndex) return object;
+		}
+		return null;
+	}
+	
+	AccessibleControlListener[] getControlListeners () {
+		if (accessible == null) return new AccessibleControlListener [0];
+		AccessibleControlListener[] result = accessible.getControlListeners (); 
+		return result != null ? result : new AccessibleControlListener [0];
+	}
+
+	String getText () {
+		int /*long*/ parentResult = 0;
+		String parentText = "";	//$NON-NLS-1$
+		if (ATK.g_type_is_a (parentType, ATK_TEXT_TYPE)) {
+			int /*long*/ superType = ATK.g_type_interface_peek_parent (ATK.ATK_TEXT_GET_IFACE (handle));
+			AtkTextIface textIface = new AtkTextIface ();
+			ATK.memmove (textIface, superType);
+			int /*long*/ characterCount = 0;
+			if (textIface.get_character_count != 0) {
+				characterCount = ATK.call (textIface.get_character_count, handle);
+			}
+			if (characterCount > 0 && textIface.get_text != 0) {
+				parentResult = ATK.call (textIface.get_text, handle, 0, characterCount);
+				if (parentResult != 0) {
+					int length = OS.strlen (parentResult);
+					byte [] buffer = new byte [length];
+					OS.memmove (buffer, parentResult, length);
+					parentText = new String (Converter.mbcsToWcs (null, buffer));
+				}
+			}
+		}
+		AccessibleControlListener[] controlListeners = getControlListeners ();
+		if (controlListeners.length == 0) return parentText;
+		AccessibleControlEvent event = new AccessibleControlEvent (this);
+		event.childID = id;
+		event.result = parentText;
+		for (int i = 0; i < controlListeners.length; i++) {
+			controlListeners [i].getValue (event);				
+		}
+		return event.result;
+	}
+	
+	AccessibleTextListener[] getTextListeners () {
+		if (accessible == null) return new AccessibleTextListener [0];
+		AccessibleTextListener[] result = accessible.getTextListeners (); 
+		return result != null ? result : new AccessibleTextListener [0];
+	}
+
+	static int /*long*/ gObjectClass_finalize (int /*long*/ atkObject) {
+		int /*long*/ superType = ATK.g_type_class_peek_parent (ATK.G_OBJECT_GET_CLASS (atkObject));
+		int /*long*/ gObjectClass = ATK.G_OBJECT_CLASS (superType);
+		GObjectClass objectClassStruct = new GObjectClass ();
+		ATK.memmove (objectClassStruct, gObjectClass);
+		ATK.call (objectClassStruct.finalize, atkObject);
+		AccessibleObject object = getAccessibleObject (atkObject);
+		if (object != null) {
+			AccessibleObjects.remove (new LONG (atkObject));
+			object.release ();
+		}
+		return 0;
+	}
+	
+	static int nextIndexOfChar (String string, String searchChars, int startIndex) {
+		int result = string.length ();
+		for (int i = 0; i < searchChars.length (); i++) {
+			char current = searchChars.charAt (i);
+			int index = string.indexOf (current, startIndex);
+			if (index != -1) result = Math.min (result, index);
+		}
+		return result;
+	}
+
+	static int nextIndexOfNotChar (String string, String searchChars, int startIndex) {
+		int length = string.length ();
+		int index = startIndex; 
+		while (index < length) {
+			char current = string.charAt (index);
+			if (searchChars.indexOf (current) == -1) break; 
+			index++;
+		}
+		return index;
+	}
+
+	static int previousIndexOfChar (String string, String searchChars, int startIndex) {
+		int result = -1;
+		if (startIndex < 0) return result;
+		string = string.substring (0, startIndex);
+		for (int i = 0; i < searchChars.length (); i++) {
+			char current = searchChars.charAt (i);
+			int index = string.lastIndexOf (current);
+			if (index != -1) result = Math.max (result, index);
+		}
+		return result;
+	}
+
+	static int previousIndexOfNotChar (String string, String searchChars, int startIndex) {
+		if (startIndex < 0) return -1;
+		int index = startIndex - 1; 
+		while (index >= 0) {
+			char current = string.charAt (index);
+			if (searchChars.indexOf (current) == -1) break; 
+			index--;
+		}
+		return index;
+	}
+
+	void release () {
+		if (DEBUG) System.out.println("AccessibleObject.release: " + handle);
+		accessible = null;
+		Enumeration elements = children.elements ();
+		while (elements.hasMoreElements ()) {
+			AccessibleObject child = (AccessibleObject) elements.nextElement ();
+			if (child.isLightweight) OS.g_object_unref (child.handle);
+		}
+		if (parent != null) parent.removeChild (this, false);
+	}
+	
+	void removeChild (AccessibleObject child, boolean unref) {
+		children.remove (new LONG (child.handle));
+		if (unref && child.isLightweight) OS.g_object_unref (child.handle);
+	}
+	
+	void selectionChanged () {
+		OS.g_signal_emit_by_name (handle, ATK.selection_changed);
+	}
+	
+	void setFocus (int childID) {
+		updateChildren ();
+		AccessibleObject accObject = getChildByID (childID);
+		if (accObject != null) {
+			ATK.atk_focus_tracker_notify (accObject.handle);
+		}
+	}
+
+	void setParent (AccessibleObject parent) {
+		this.parent = parent;
+	}
+	
+	void textCaretMoved(int index) {
+		OS.g_signal_emit_by_name (handle, ATK.text_caret_moved, index);
+	}
+
+	void textChanged(int type, int startIndex, int length) {
+		if (type == ACC.TEXT_DELETE) {
+			OS.g_signal_emit_by_name (handle, ATK.text_changed_delete, startIndex, length);
+		} else {
+			OS.g_signal_emit_by_name (handle, ATK.text_changed_insert, startIndex, length);
+		}
+	}
+
+	void textSelectionChanged() {
+		OS.g_signal_emit_by_name (handle, ATK.text_selection_changed);
+	}
+
+	void updateChildren () {
+		if (isLightweight) return;
+		AccessibleControlListener[] listeners = getControlListeners ();
+		if (listeners.length == 0) return;
+
+		AccessibleControlEvent event = new AccessibleControlEvent (this);
+		for (int i = 0; i < listeners.length; i++) {
+			listeners [i].getChildren (event);
+		}
+		if (event.children != null && event.children.length > 0) {
+			Vector idsToKeep = new Vector (children.size ());
+			if (event.children [0] instanceof Integer) {
+				/*	an array of child id's (Integers) was answered */
+				int /*long*/ parentType = AccessibleFactory.getDefaultParentType ();
+				for (int i = 0; i < event.children.length; i++) {
+					AccessibleObject object = getChildByIndex (i);
+					if (object == null) {
+						int /*long*/ childType = AccessibleFactory.getChildType (accessible, i);
+						object = new AccessibleObject (childType, 0, accessible, parentType, true);
+						AccessibleObjects.put (new LONG (object.handle), object);
+						addChild (object);
+						object.index = i;
+					}
+					try {
+						object.id = ((Integer)event.children[i]).intValue ();
+					} catch (ClassCastException e) {
+						/* a non-ID value was given so don't set the ID */
+					}
+					idsToKeep.addElement (new LONG (object.handle));
+				}
+			} else {
+				/* an array of Accessible children was answered */
+				int childIndex = 0;
+				for (int i = 0; i < event.children.length; i++) {
+					AccessibleObject object = null;
+					try {
+						object = ((Accessible)event.children [i]).accessibleObject;
+					} catch (ClassCastException e) {
+						/* a non-Accessible value was given so nothing to do here */ 
+					}
+					if (object != null) {
+						object.index = childIndex++;
+						idsToKeep.addElement (new LONG (object.handle));
+					}
+				}
+			}
+			/* remove old children that were not provided as children anymore */
+			Enumeration ids = children.keys ();
+			while (ids.hasMoreElements ()) {
+				LONG id = (LONG)ids.nextElement ();
+				if (!idsToKeep.contains (id)) {
+					AccessibleObject object = (AccessibleObject) children.get (id);
+					removeChild (object, true);
+				}
+			}
+		}
+	}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/accessibility/AccessibleTextAdapter.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/accessibility/AccessibleTextAdapter.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/accessibility/AccessibleTextAdapter.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.accessibility;
+
+
+/**
+ * This adapter class provides default implementations for the
+ * methods described by the <code>AccessibleTextListener</code> interface.
+ * <p>
+ * Classes that wish to deal with <code>AccessibleTextEvent</code>s can
+ * extend this class and override only the methods that they are
+ * interested in.
+ * </p><p>
+ * Note: Accessibility clients use child identifiers to specify
+ * whether they want information about a control or one of its children.
+ * Child identifiers are increasing integers beginning with 0.
+ * The identifier CHILDID_SELF represents the control itself.
+ * When returning a child identifier to a client, you may use CHILDID_NONE
+ * to indicate that no child or control has the required information.
+ * </p><p>
+ * Note: This adapter is typically used by implementors of
+ * a custom control to provide very detailed information about
+ * the control instance to accessibility clients.
+ * </p>
+ *
+ * @see AccessibleTextListener
+ * @see AccessibleTextEvent
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ * 
+ * @since 3.0
+ */
+public abstract class AccessibleTextAdapter implements AccessibleTextListener {
+	
+	/**
+	 * Sent when an accessibility client requests the current character offset
+	 * of the text caret.
+	 * The default behavior is to do nothing.
+	 * <p>
+	 * Return the caret offset in the <code>offset</code>
+	 * field of the event object.
+	 * </p>
+	 *
+	 * @param e an event object containing the following fields:<ul>
+	 *    <li>childID [IN] - an identifier specifying a child of the control</li>
+	 *    <li>offset [OUT] - the current offset of the text caret</li>
+	 * </ul>
+	 */
+	public void getCaretOffset (AccessibleTextEvent e) {
+	}
+
+	/**
+	 * Sent when an accessibility client requests the range of the current
+	 * text selection.
+	 * The default behavior is to do nothing.
+	 * <p>
+	 * Return the selection start offset and non-negative length in the
+	 * <code>offset</code> and <code>length</code> fields of the event object.
+	 * </p>
+	 *
+	 * @param e an event object containing the following fields:<ul>
+	 *    <li>childID [IN] - an identifier specifying a child of the control</li>
+	 *    <li>offset [OUT] - the offset of the current text selection</li>
+	 *    <li>length [OUT] - the length of the current text selection</li>
+	 * </ul>
+	 */
+	public void getSelectionRange (AccessibleTextEvent e) {
+	}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/accessibility/AccessibleTextEvent.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/accessibility/AccessibleTextEvent.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/accessibility/AccessibleTextEvent.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.accessibility;
+
+
+import org.eclipse.swt.internal.*;
+
+/**
+ * Instances of this class are sent as a result of
+ * accessibility clients sending messages to controls
+ * asking for detailed information about the implementation
+ * of the control instance. Typically, only implementors
+ * of custom controls need to listen for this event.
+ * <p>
+ * Note: The meaning of each field depends on the
+ * message that was sent.
+ * </p>
+ *
+ * @see AccessibleTextListener
+ * @see AccessibleTextAdapter
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ * 
+ * @since 3.0
+ */
+public class AccessibleTextEvent extends SWTEventObject {
+	public int childID;				// IN
+	public int offset, length;		// OUT
+	
+	static final long serialVersionUID = 3977019530868308275L;
+	
+/**
+ * Constructs a new instance of this class.
+ *
+ * @param source the object that fired the event
+ */
+public AccessibleTextEvent (Object source) {
+	super (source);
+}
+
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the event
+ */
+public String toString () {
+	return "AccessibleTextEvent {childID=" + childID +  //$NON-NLS-1$
+		" offset=" + offset +  //$NON-NLS-1$
+		" length=" + length +  //$NON-NLS-1$
+		"}"; //$NON-NLS-1$
+}	
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/accessibility/AccessibleTextListener.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/accessibility/AccessibleTextListener.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/accessibility/AccessibleTextListener.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,75 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.accessibility;
+
+
+import org.eclipse.swt.internal.*;
+
+/**
+ * Classes that implement this interface provide methods
+ * that deal with the events that are generated when an
+ * accessibility client sends a message to a control.
+ * <p>
+ * After creating an instance of a class that implements
+ * this interface it can be added to a control using the
+ * <code>addAccessibleTextListener</code> method and removed
+ * using the <code>removeAccessibleTextListener</code> method.
+ * When a client requests information the appropriate method
+ * will be invoked.
+ * </p><p>
+ * Note: Accessibility clients use child identifiers to specify
+ * whether they want information about a control or one of its children.
+ * Child identifiers are increasing integers beginning with 0.
+ * The identifier CHILDID_SELF represents the control itself.
+ * </p><p>
+ * Note: This interface is typically used by implementors of
+ * a custom control to provide very detailed information about
+ * the control instance to accessibility clients.
+ * </p>
+ *
+ * @see AccessibleTextAdapter
+ * @see AccessibleTextEvent
+ * 
+ * @since 3.0
+ */
+public interface AccessibleTextListener extends SWTEventListener {
+	
+	/**
+	 * Sent when an accessibility client requests the current character offset
+	 * of the text caret.
+	 * <p>
+	 * Return the caret offset in the <code>offset</code>
+	 * field of the event object.
+	 * </p>
+	 *
+	 * @param e an event object containing the following fields:<ul>
+	 *    <li>childID [IN] - an identifier specifying a child of the control</li>
+	 *    <li>offset [OUT] - the current offset of the text caret</li>
+	 * </ul>
+	 */
+	public void getCaretOffset (AccessibleTextEvent e);
+
+	/**
+	 * Sent when an accessibility client requests the range of the current
+	 * text selection.
+	 * <p>
+	 * Return the selection start offset and non-negative length in the
+	 * <code>offset</code> and <code>length</code> fields of the event object.
+	 * </p>
+	 *
+	 * @param e an event object containing the following fields:<ul>
+	 *    <li>childID [IN] - an identifier specifying a child of the control</li>
+	 *    <li>offset [OUT] - the offset of the current text selection</li>
+	 *    <li>length [OUT] - the length of the current text selection</li>
+	 * </ul>
+	 */
+	public void getSelectionRange (AccessibleTextEvent e);
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/awt/SWT_AWT.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/awt/SWT_AWT.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/awt/SWT_AWT.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,325 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.awt;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
+
+/* SWT Imports */
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.gtk.*;
+import org.eclipse.swt.graphics.Device;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Event;
+
+/* AWT Imports */
+import java.awt.AWTEvent;
+import java.awt.Dimension;
+import java.awt.EventQueue;
+import java.awt.Canvas;
+import java.awt.Frame;
+import java.awt.Window;
+import java.awt.event.AWTEventListener;
+import java.awt.event.ComponentAdapter;
+import java.awt.event.ComponentEvent;
+import java.awt.event.WindowEvent;
+
+
+/**
+ * This class provides a bridge between SWT and AWT, so that it
+ * is possible to embed AWT components in SWT and vice versa.
+ *
+ * @see <a href="http://www.eclipse.org/swt/snippets/#awt">Swing/AWT snippets</a>
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ * 
+ * @since 3.0
+ */
+public class SWT_AWT {
+
+	/**
+	 * The name of the embedded Frame class. The default class name
+	 * for the platform will be used if <code>null</code>. 
+	 */
+	public static String embeddedFrameClass;
+
+	/**
+	 * Key for looking up the embedded frame for a Composite using
+	 * getData(). 
+	 */
+	static String EMBEDDED_FRAME_KEY = "org.eclipse.swt.awt.SWT_AWT.embeddedFrame";
+
+static boolean loaded, swingInitialized;
+
+static native final int /*long*/ getAWTHandle (Object canvas);
+static native final void setDebug (Frame canvas, boolean debug);
+
+static synchronized void loadLibrary () {
+	if (loaded) return;
+	loaded = true;
+	/*
+	* Note that the jawt library is loaded explicitly
+	* because it cannot be found by the library loader.
+	* All exceptions are caught because the library may
+	* have been loaded already.
+	*/
+	try {
+		System.loadLibrary("jawt");
+	} catch (Throwable e) {}
+	Library.loadLibrary("swt-awt");
+}
+
+static synchronized void initializeSwing() {
+	if (swingInitialized) return;
+	swingInitialized = true;
+	/*
+	* Feature in GTK.  The default X error handler
+	* for GTK calls exit() after printing the X error.
+	* Normally, this isn't that big a problem for SWT
+	* applications because they don't cause X errors.
+	* However, sometimes X errors are generated by AWT
+	* that make SWT exit.  The fix is to hide all X
+	* errors when AWT is running.
+	*/
+	OS.gdk_error_trap_push();
+	try {
+		/* Initialize the default focus traversal policy */
+		Class[] emptyClass = new Class[0];
+		Object[] emptyObject = new Object[0];
+		Class clazz = Class.forName("javax.swing.UIManager");
+		Method method = clazz.getMethod("getDefaults", emptyClass);
+		if (method != null) method.invoke(clazz, emptyObject);
+	} catch (Throwable e) {}
+}
+
+/**
+ * Returns a <code>java.awt.Frame</code> which is the embedded frame
+ * associated with the specified composite.
+ * 
+ * @param parent the parent <code>Composite</code> of the <code>java.awt.Frame</code>
+ * @return a <code>java.awt.Frame</code> the embedded frame or <code>null</code>.
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * 
+ * @since 3.2
+ */
+public static Frame getFrame (Composite parent) {
+	if (parent == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+	if ((parent.getStyle () & SWT.EMBEDDED) == 0) return null;
+	return (Frame)parent.getData(EMBEDDED_FRAME_KEY);
+}
+
+/**
+ * Creates a new <code>java.awt.Frame</code>. This frame is the root for
+ * the AWT components that will be embedded within the composite. In order
+ * for the embedding to succeed, the composite must have been created
+ * with the SWT.EMBEDDED style.
+ * <p>
+ * IMPORTANT: As of JDK1.5, the embedded frame does not receive mouse events.
+ * When a lightweight component is added as a child of the embedded frame,
+ * the cursor does not change. In order to work around both these problems, it is
+ * strongly recommended that a heavyweight component such as <code>java.awt.Panel</code>
+ * be added to the frame as the root of all components.
+ * </p>
+ * 
+ * @param parent the parent <code>Composite</code> of the new <code>java.awt.Frame</code>
+ * @return a <code>java.awt.Frame</code> to be the parent of the embedded AWT components
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the parent Composite does not have the SWT.EMBEDDED style</li> 
+ * </ul>
+ * 
+ * @since 3.0
+ */
+public static Frame new_Frame (final Composite parent) {
+	if (parent == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+	if ((parent.getStyle () & SWT.EMBEDDED) == 0) {
+		SWT.error (SWT.ERROR_INVALID_ARGUMENT);
+	}
+	int /*long*/ handle = parent.embeddedHandle;
+	/*
+	 * Some JREs have implemented the embedded frame constructor to take an integer
+	 * and other JREs take a long.  To handle this binary incompatibility, use
+	 * reflection to create the embedded frame.
+	 */
+	Class clazz = null;
+	try {
+		String className = embeddedFrameClass != null ? embeddedFrameClass : "sun.awt.X11.XEmbeddedFrame";
+		clazz = Class.forName(className);
+	} catch (Throwable e) {
+		SWT.error (SWT.ERROR_NOT_IMPLEMENTED, e, " [need JDK 1.5 or greater]");		
+	}
+	initializeSwing ();
+	Object value = null;
+	Constructor constructor = null;
+	try {
+		constructor = clazz.getConstructor (new Class [] {int.class, boolean.class});
+		value = constructor.newInstance (new Object [] {new Integer ((int)/*64*/handle), Boolean.TRUE});
+	} catch (Throwable e1) {
+		try {
+			constructor = clazz.getConstructor (new Class [] {long.class, boolean.class});
+			value = constructor.newInstance (new Object [] {new Long (handle), Boolean.TRUE});
+		} catch (Throwable e2) {
+			SWT.error (SWT.ERROR_NOT_IMPLEMENTED, e2);
+		}
+	}
+	final Frame frame = (Frame) value;
+	parent.setData(EMBEDDED_FRAME_KEY, frame);
+	if (Device.DEBUG) {
+		loadLibrary();
+		setDebug(frame, true);
+	}
+	try {
+		/* Call registerListeners() to make XEmbed focus traversal work */
+		Method method = clazz.getMethod("registerListeners", null);
+		if (method != null) method.invoke(value, null);
+	} catch (Throwable e) {}
+	final AWTEventListener awtListener = new AWTEventListener() {
+		public void eventDispatched(AWTEvent event) {
+			if (event.getID() == WindowEvent.WINDOW_OPENED) {
+				final Window window = (Window) event.getSource();
+				if (window.getParent() == frame) {
+					parent.getDisplay().asyncExec(new Runnable() {
+						public void run() {
+							if (parent.isDisposed()) return;
+							Shell shell = parent.getShell();
+							loadLibrary();
+							int /*long*/ awtHandle = getAWTHandle(window);
+							if (awtHandle == 0) return;
+							int /*long*/ xWindow = OS.gdk_x11_drawable_get_xid(OS.GTK_WIDGET_WINDOW(OS.gtk_widget_get_toplevel(shell.handle)));
+							OS.XSetTransientForHint(OS.GDK_DISPLAY(), awtHandle, xWindow);
+						}
+					});
+				}
+			}
+		}
+	};
+	frame.getToolkit().addAWTEventListener(awtListener, AWTEvent.WINDOW_EVENT_MASK);
+	final Listener shellListener = new Listener () {
+		public void handleEvent (Event e) {
+			switch (e.type) {
+				case SWT.Deiconify:
+					EventQueue.invokeLater(new Runnable () {
+						public void run () {
+							frame.dispatchEvent (new WindowEvent (frame, WindowEvent.WINDOW_DEICONIFIED));
+						}
+					});
+					break;
+				case SWT.Iconify:
+					EventQueue.invokeLater(new Runnable () {
+						public void run () {
+							frame.dispatchEvent (new WindowEvent (frame, WindowEvent.WINDOW_ICONIFIED));
+						}
+					});
+					break;
+			}
+		}
+	};
+	Shell shell = parent.getShell ();
+	shell.addListener (SWT.Deiconify, shellListener);
+	shell.addListener (SWT.Iconify, shellListener);
+	
+	Listener listener = new Listener () {
+		public void handleEvent (Event e) {
+			switch (e.type) {
+				case SWT.Dispose:
+					Shell shell = parent.getShell ();
+					shell.removeListener (SWT.Deiconify, shellListener);
+					shell.removeListener (SWT.Iconify, shellListener);
+					parent.setVisible(false);
+					EventQueue.invokeLater(new Runnable () {
+						public void run () {
+							frame.getToolkit().removeAWTEventListener(awtListener);
+							frame.dispose ();
+						}
+					});
+					break;
+				case SWT.Resize:
+					if (Library.JAVA_VERSION >= Library.JAVA_VERSION(1, 6, 0)) {
+						final Rectangle clientArea = parent.getClientArea();
+						EventQueue.invokeLater(new Runnable () {
+							public void run () {
+								frame.setSize (clientArea.width, clientArea.height);
+							}
+						});
+					}
+					break;
+			}
+		}
+	};
+	parent.addListener (SWT.Dispose, listener);
+	parent.addListener (SWT.Resize, listener);
+	
+	parent.getDisplay().asyncExec(new Runnable() {
+		public void run () {
+			if (parent.isDisposed()) return;
+			final Rectangle clientArea = parent.getClientArea();
+			EventQueue.invokeLater(new Runnable () {
+				public void run () {
+					frame.setSize (clientArea.width, clientArea.height);
+					frame.validate ();
+				}
+			});
+		}
+	});
+	return frame;
+}
+
+/**
+ * Creates a new <code>Shell</code>. This Shell is the root for
+ * the SWT widgets that will be embedded within the AWT canvas. 
+ * 
+ * @param display the display for the new Shell
+ * @param parent the parent <code>java.awt.Canvas</code> of the new Shell
+ * @return a <code>Shell</code> to be the parent of the embedded SWT widgets
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the display is null</li>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the parent's peer is not created</li>
+ * </ul>
+ * 
+ * @since 3.0
+ */
+public static Shell new_Shell (final Display display, final Canvas parent) {
+	if (display == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+	if (parent == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+	int /*long*/ handle = 0;
+	try {
+		loadLibrary ();
+		handle = getAWTHandle (parent);
+	} catch (Throwable e) {
+		SWT.error (SWT.ERROR_NOT_IMPLEMENTED, e);
+	}
+	if (handle == 0) SWT.error (SWT.ERROR_INVALID_ARGUMENT, null, " [peer not created]");
+
+	final Shell shell = Shell.gtk_new (display, handle);
+	parent.addComponentListener(new ComponentAdapter () {
+		public void componentResized (ComponentEvent e) {
+			display.syncExec (new Runnable () {
+				public void run () {
+					Dimension dim = parent.getSize ();
+					shell.setSize (dim.width, dim.height);
+				}
+			});
+		}
+	});
+	shell.setVisible (true);
+	return shell;
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/browser/AppFileLocProvider.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/browser/AppFileLocProvider.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/browser/AppFileLocProvider.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,313 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.browser;
+
+import java.util.Vector;
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.mozilla.*;
+
+class AppFileLocProvider {
+	XPCOMObject supports;
+	XPCOMObject directoryServiceProvider;
+	XPCOMObject directoryServiceProvider2;	
+	int refCount = 0;
+	String mozillaPath, profilePath;
+	String[] pluginDirs;
+	boolean isXULRunner;
+	
+	static final String SEPARATOR_OS = System.getProperty ("file.separator"); //$NON-NLS-1$
+	static final String CHROME_DIR = "chrome"; //$NON-NLS-1$
+	static final String COMPONENTS_DIR = "components"; //$NON-NLS-1$
+	static final String HISTORY_FILE = "history.dat"; //$NON-NLS-1$
+	static final String LOCALSTORE_FILE = "localstore.rdf"; //$NON-NLS-1$
+	static final String MIMETYPES_FILE = "mimeTypes.rdf"; //$NON-NLS-1$
+	static final String PLUGINS_DIR = "plugins"; //$NON-NLS-1$
+	static final String USER_PLUGINS_DIR = ".mozilla" + SEPARATOR_OS + "plugins"; //$NON-NLS-1$ //$NON-NLS-2$
+	static final String PREFERENCES_FILE = "prefs.js"; //$NON-NLS-1$
+	
+AppFileLocProvider (String path) {
+	mozillaPath = path + SEPARATOR_OS;
+	createCOMInterfaces ();
+}
+
+int AddRef () {
+	refCount++;
+	return refCount;
+}
+
+void createCOMInterfaces () {
+	/* Create each of the interfaces that this object implements */
+	supports = new XPCOMObject (new int[] {2, 0, 0}) {
+		public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+		public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+		public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+	};
+	
+	directoryServiceProvider = new XPCOMObject (new int[] {2, 0, 0, 3}) {
+		public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+		public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+		public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+		public int /*long*/ method3 (int /*long*/[] args) {return getFile (args[0], args[1], args[2]);}
+	};
+		
+	directoryServiceProvider2 = new XPCOMObject (new int[] {2, 0, 0, 3, 2}) {
+		public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+		public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+		public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+		public int /*long*/ method3 (int /*long*/[] args) {return getFile (args[0], args[1], args[2]);}
+		public int /*long*/ method4 (int /*long*/[] args) {return getFiles (args[0], args[1]);}
+	};
+}
+
+void disposeCOMInterfaces () {
+	if (supports != null) {
+		supports.dispose ();
+		supports = null;
+	}	
+	if (directoryServiceProvider != null) {
+		directoryServiceProvider.dispose ();
+		directoryServiceProvider = null;	
+	}
+	if (directoryServiceProvider2 != null) {
+		directoryServiceProvider2.dispose ();
+		directoryServiceProvider2 = null;	
+	}	
+}
+
+int /*long*/ getAddress () {
+	return directoryServiceProvider.getAddress ();
+}
+
+int QueryInterface (int /*long*/ riid, int /*long*/ ppvObject) {
+	if (riid == 0 || ppvObject == 0) return XPCOM.NS_ERROR_NO_INTERFACE;
+	nsID guid = new nsID ();
+	XPCOM.memmove (guid, riid, nsID.sizeof);
+	
+	if (guid.Equals (nsISupports.NS_ISUPPORTS_IID)) {
+		XPCOM.memmove (ppvObject, new int /*long*/[] {supports.getAddress ()}, C.PTR_SIZEOF);
+		AddRef ();
+		return XPCOM.NS_OK;
+	}
+	if (guid.Equals (nsIDirectoryServiceProvider.NS_IDIRECTORYSERVICEPROVIDER_IID)) {
+		XPCOM.memmove (ppvObject, new int /*long*/[] {directoryServiceProvider.getAddress ()}, C.PTR_SIZEOF);
+		AddRef ();
+		return XPCOM.NS_OK;
+	}
+	if (guid.Equals (nsIDirectoryServiceProvider2.NS_IDIRECTORYSERVICEPROVIDER2_IID)) {
+		XPCOM.memmove (ppvObject, new int /*long*/[] {directoryServiceProvider2.getAddress ()}, C.PTR_SIZEOF);
+		AddRef ();
+		return XPCOM.NS_OK;
+	}
+	
+	XPCOM.memmove (ppvObject, new int /*long*/[] {0}, C.PTR_SIZEOF);
+	return XPCOM.NS_ERROR_NO_INTERFACE;
+}
+
+int Release () {
+	refCount--;
+	if (refCount == 0) disposeCOMInterfaces ();
+	return refCount;
+}
+
+void setProfilePath (String path) {
+	profilePath = path;
+	if (!Compatibility.fileExists (path, "")) { //$NON-NLS-1$
+		int /*long*/[] result = new int /*long*/[1];
+		nsEmbedString pathString = new nsEmbedString (path);
+		int rc = XPCOM.NS_NewLocalFile (pathString.getAddress (), 1, result);
+		if (rc != XPCOM.NS_OK) Mozilla.error (rc);
+		if (result[0] == 0) Mozilla.error (XPCOM.NS_ERROR_NULL_POINTER);
+		pathString.dispose ();
+
+		nsILocalFile file = new nsILocalFile (result [0]);
+		rc = file.Create (nsILocalFile.DIRECTORY_TYPE, 0700);
+		if (rc != XPCOM.NS_OK) Mozilla.error (rc);
+		file.Release ();
+	}
+}
+
+/* nsIDirectoryServiceProvider2 */
+
+int getFiles (int /*long*/ prop, int /*long*/ _retval) {
+	int size = XPCOM.strlen (prop);
+	byte[] bytes = new byte[size];
+	XPCOM.memmove (bytes, prop, size);
+	String propertyName = new String (MozillaDelegate.mbcsToWcs (null, bytes));
+	String[] propertyValues = null;
+
+	if (propertyName.equals (XPCOM.NS_APP_PLUGINS_DIR_LIST)) {
+		if (pluginDirs == null) {
+			int index = 0;
+			/* set the first value(s) to the MOZ_PLUGIN_PATH environment variable value if it's defined */
+			int /*long*/ ptr = C.getenv (MozillaDelegate.wcsToMbcs (null, XPCOM.MOZILLA_PLUGIN_PATH, true));
+			if (ptr != 0) {
+				int length = C.strlen (ptr);
+				byte[] buffer = new byte[length];
+				C.memmove (buffer, ptr, length);
+				String value = new String (MozillaDelegate.mbcsToWcs (null, buffer));
+				if (value.length () > 0) {
+					String separator = System.getProperty ("path.separator"); // $NON-NLS-1$
+					Vector segments = new Vector ();
+					int start, end = -1;
+					do {
+						start = end + 1;
+						end = value.indexOf (separator, start);
+						String segment;
+						if (end == -1) {
+							segment = value.substring (start);
+						} else {
+							segment = value.substring (start, end);
+						}
+						if (segment.length () > 0) segments.addElement (segment);
+					} while (end != -1);
+					int segmentsSize = segments.size ();
+					pluginDirs = new String [segmentsSize + 2];
+					for (index = 0; index < segmentsSize; index++) {
+						pluginDirs[index] = (String)segments.elementAt (index);
+					}
+				}
+			}
+			if (pluginDirs == null) {
+				pluginDirs = new String[2];
+			}
+
+			/* set the next value to the GRE path + "plugins" */
+			pluginDirs[index++] = mozillaPath + PLUGINS_DIR;
+
+			/* set the next value to the home directory + "/.mozilla/plugins" */
+			pluginDirs[index++] = System.getProperty("user.home") + SEPARATOR_OS + USER_PLUGINS_DIR;
+		}
+		propertyValues = pluginDirs;
+	}
+
+	XPCOM.memmove(_retval, new int /*long*/[] {0}, C.PTR_SIZEOF);
+	if (propertyValues != null) {
+		int /*long*/[] result = new int /*long*/[1];
+		nsISupports[] files = new nsISupports [propertyValues.length];
+		int index = 0;
+		for (int i = 0; i < propertyValues.length; i++) {
+			nsEmbedString pathString = new nsEmbedString (propertyValues[i]);
+			int rc = XPCOM.NS_NewLocalFile (pathString.getAddress (), 1, result);
+			if (rc != XPCOM.NS_ERROR_FILE_UNRECOGNIZED_PATH) {
+				/* value appears to be a valid pathname */
+				if (rc != XPCOM.NS_OK) Mozilla.error (rc);
+				if (result[0] == 0) Mozilla.error (XPCOM.NS_ERROR_NULL_POINTER);
+
+				nsILocalFile localFile = new nsILocalFile (result[0]);
+				result[0] = 0;
+				rc = localFile.QueryInterface (nsIFile.NS_IFILE_IID, result); 
+				if (rc != XPCOM.NS_OK) Mozilla.error (rc);
+				if (result[0] == 0) Mozilla.error (XPCOM.NS_ERROR_NO_INTERFACE);
+				localFile.Release ();
+
+				nsIFile file = new nsIFile (result[0]);
+				files[index++] = file;
+			}
+			pathString.dispose ();
+			result[0] = 0;
+		}
+
+		if (index < propertyValues.length) {
+			/* there were some invalid values so remove the trailing empty array slots */
+			nsISupports[] temp = new nsISupports [index];
+			System.arraycopy (files, 0, temp, 0, index);
+			files = temp;
+		}
+
+		SimpleEnumerator enumerator = new SimpleEnumerator (files);
+		enumerator.AddRef ();
+		XPCOM.memmove (_retval, new int /*long*/[] {enumerator.getAddress ()}, C.PTR_SIZEOF);
+		return XPCOM.NS_OK;
+	}
+
+	return XPCOM.NS_ERROR_FAILURE;
+}	
+	
+/* nsIDirectoryServiceProvider implementation */
+
+int getFile(int /*long*/ prop, int /*long*/ persistent, int /*long*/ _retval) {
+	int size = XPCOM.strlen (prop);
+	byte[] bytes = new byte[size];
+	XPCOM.memmove (bytes, prop, size);
+	String propertyName = new String (MozillaDelegate.mbcsToWcs (null, bytes));
+	String propertyValue = null;
+
+	if (propertyName.equals (XPCOM.NS_APP_HISTORY_50_FILE)) {
+		propertyValue = profilePath + HISTORY_FILE;
+	} else if (propertyName.equals (XPCOM.NS_APP_USER_MIMETYPES_50_FILE)) {
+		propertyValue = profilePath + MIMETYPES_FILE;
+	} else if (propertyName.equals (XPCOM.NS_APP_PREFS_50_FILE)) {
+		propertyValue = profilePath + PREFERENCES_FILE;
+	} else if (propertyName.equals (XPCOM.NS_APP_PREFS_50_DIR)) {
+		propertyValue = profilePath;
+	} else if (propertyName.equals (XPCOM.NS_APP_USER_CHROME_DIR)) {
+		propertyValue = profilePath + CHROME_DIR;
+	} else if (propertyName.equals (XPCOM.NS_APP_USER_PROFILE_50_DIR)) {
+		propertyValue = profilePath;
+	} else if (propertyName.equals (XPCOM.NS_APP_LOCALSTORE_50_FILE)) {
+		propertyValue = profilePath + LOCALSTORE_FILE;
+	} else if (propertyName.equals (XPCOM.NS_APP_CACHE_PARENT_DIR)) {
+		propertyValue = profilePath;
+	} else if (propertyName.equals (XPCOM.NS_OS_HOME_DIR)) {
+		propertyValue = System.getProperty("user.home");	//$NON-NLS-1$
+	} else if (propertyName.equals (XPCOM.NS_OS_TEMP_DIR)) {
+		propertyValue = System.getProperty("java.io.tmpdir");	//$NON-NLS-1$
+	} else if (propertyName.equals (XPCOM.NS_GRE_DIR)) {
+		propertyValue = mozillaPath;
+	} else if (propertyName.equals (XPCOM.NS_GRE_COMPONENT_DIR)) {
+		propertyValue = mozillaPath + COMPONENTS_DIR;
+	} else if (propertyName.equals (XPCOM.NS_XPCOM_INIT_CURRENT_PROCESS_DIR)) {
+		propertyValue = mozillaPath;
+	} else if (propertyName.equals (XPCOM.NS_OS_CURRENT_PROCESS_DIR)) {
+		propertyValue = mozillaPath;
+	} else if (propertyName.equals (XPCOM.NS_XPCOM_COMPONENT_DIR)) {
+		propertyValue = mozillaPath + COMPONENTS_DIR;
+	} else if (propertyName.equals (XPCOM.NS_XPCOM_CURRENT_PROCESS_DIR)) {
+		propertyValue = mozillaPath;
+	} else if (propertyName.equals (XPCOM.NS_APP_PREF_DEFAULTS_50_DIR)) {
+		/*
+		* Answering a value for this property causes problems in Mozilla versions
+		* < 1.7.  Unfortunately this property is queried early enough in the
+		* Browser creation process that the Mozilla version being used is not
+		* yet determined.  However it is known if XULRunner is being used or not.
+		* 
+		* For now answer a value for this property iff XULRunner is the GRE.
+		* If the range of Mozilla versions supported by the Browser is changed
+		* in the future to be >= 1.7 then this value can always be answered.  
+		*/
+		if (isXULRunner) propertyValue = profilePath;
+	}
+
+	XPCOM.memmove (persistent, new int[] {1}, 4); /* PRBool */
+	XPCOM.memmove (_retval, new int /*long*/[] {0}, C.PTR_SIZEOF);
+	if (propertyValue != null && propertyValue.length () > 0) {
+		int /*long*/[] result = new int /*long*/[1];
+		nsEmbedString pathString = new nsEmbedString (propertyValue);
+		int rc = XPCOM.NS_NewLocalFile (pathString.getAddress (), 1, result);
+		if (rc != XPCOM.NS_OK) Mozilla.error (rc);
+		if (result[0] == 0) Mozilla.error (XPCOM.NS_ERROR_NULL_POINTER);
+		pathString.dispose ();
+		
+		nsILocalFile localFile = new nsILocalFile (result [0]);
+		result[0] = 0;
+	    rc = localFile.QueryInterface (nsIFile.NS_IFILE_IID, result); 
+		if (rc != XPCOM.NS_OK) Mozilla.error (rc);
+		if (result[0] == 0) Mozilla.error (XPCOM.NS_ERROR_NO_INTERFACE);
+
+		XPCOM.memmove (_retval, new int /*long*/[] {result[0]}, C.PTR_SIZEOF);
+		localFile.Release ();
+		return XPCOM.NS_OK;
+	}
+
+	return XPCOM.NS_ERROR_FAILURE;
+}		
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/browser/Browser.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/browser/Browser.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/browser/Browser.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,780 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.browser;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.widgets.*;
+
+/**
+ * Instances of this class implement the browser user interface
+ * metaphor.  It allows the user to visualize and navigate through
+ * HTML documents.
+ * <p>
+ * Note that although this class is a subclass of <code>Composite</code>,
+ * it does not make sense to set a layout on it.
+ * </p>
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>MOZILLA</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>CloseWindowListener, LocationListener, OpenWindowListener, ProgressListener, StatusTextListener, TitleListener, VisibilityWindowListener</dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ * 
+ * @see <a href="http://www.eclipse.org/swt/snippets/#browser">Browser snippets</a>
+ * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Examples: ControlExample, BrowserExample</a>
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ *
+ * @since 3.0
+ */
+
+public class Browser extends Composite {
+	WebBrowser webBrowser;
+	int userStyle;
+
+	static final String PACKAGE_PREFIX = "org.eclipse.swt.browser."; //$NON-NLS-1$
+	static final String NO_INPUT_METHOD = "org.eclipse.swt.internal.gtk.noInputMethod"; //$NON-NLS-1$
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a widget which will be the parent of the new instance (cannot be null)
+ * @param style the style of widget to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * </ul>
+ * @exception SWTError <ul>
+ *    <li>ERROR_NO_HANDLES if a handle could not be obtained for browser creation</li>
+ * </ul>
+ * 
+ * @see Widget#getStyle
+ * 
+ * @since 3.0
+ */
+public Browser (Composite parent, int style) {
+	super (checkParent (parent), checkStyle (style));
+	userStyle = style;
+
+	String platform = SWT.getPlatform ();
+	Display display = parent.getDisplay ();
+	if ("gtk".equals (platform)) display.setData (NO_INPUT_METHOD, null); //$NON-NLS-1$
+	String className = null;
+	if ((style & SWT.MOZILLA) != 0) {
+		className = "org.eclipse.swt.browser.Mozilla"; //$NON-NLS-1$
+	} else {
+		if ("win32".equals (platform) || "wpf".equals (platform)) { //$NON-NLS-1$ $NON-NLS-2$
+			className = "org.eclipse.swt.browser.IE"; //$NON-NLS-1$
+		} else if ("motif".equals (platform)) { //$NON-NLS-1$
+			className = "org.eclipse.swt.browser.Mozilla"; //$NON-NLS-1$
+		} else if ("gtk".equals (platform)) { //$NON-NLS-1$
+			className = "org.eclipse.swt.browser.Mozilla"; //$NON-NLS-1$
+		} else if ("carbon".equals (platform) || "cocoa".equals (platform)) { //$NON-NLS-1$
+			className = "org.eclipse.swt.browser.Safari"; //$NON-NLS-1$
+		} else if ("photon".equals (platform)) { //$NON-NLS-1$
+			className = "org.eclipse.swt.browser.Voyager"; //$NON-NLS-1$
+		} else {
+			dispose ();
+			SWT.error (SWT.ERROR_NO_HANDLES);
+		}
+	}
+
+	try {
+		Class clazz = Class.forName (className);
+		webBrowser = (WebBrowser)clazz.newInstance ();
+	} catch (ClassNotFoundException e) {
+	} catch (IllegalAccessException e) {
+	} catch (InstantiationException e) {
+	}
+	if (webBrowser == null) {
+		dispose ();
+		SWT.error (SWT.ERROR_NO_HANDLES);
+	}
+
+	webBrowser.setBrowser (this);
+	webBrowser.create (parent, style);
+}
+
+static Composite checkParent (Composite parent) {
+	String platform = SWT.getPlatform ();
+	if (!"gtk".equals (platform)) return parent; //$NON-NLS-1$
+
+	/*
+	* Note.  Mozilla provides all IM support needed for text input in web pages.
+	* If SWT creates another input method context for the widget it will cause
+	* indeterminate results to happen (hangs and crashes). The fix is to prevent 
+	* SWT from creating an input method context for the  Browser widget.
+	*/
+	if (parent != null && !parent.isDisposed ()) {
+		Display display = parent.getDisplay ();
+		if (display != null) {
+			if (display.getThread () == Thread.currentThread ()) {
+				display.setData (NO_INPUT_METHOD, "true"); //$NON-NLS-1$
+			}
+		}
+	}
+	return parent;
+}
+
+static int checkStyle(int style) {
+	String platform = SWT.getPlatform ();
+	if ((style & SWT.MOZILLA) != 0) {
+		if ("carbon".equals (platform)) return style | SWT.EMBEDDED; //$NON-NLS-1$
+		if ("motif".equals (platform)) return style | SWT.EMBEDDED; //$NON-NLS-1$
+		return style;
+	}
+
+	if ("win32".equals (platform)) { //$NON-NLS-1$
+		/*
+		* For IE on win32 the border is supplied by the embedded browser, so remove
+		* the style so that the parent Composite will not draw a second border.
+		*/
+		return style & ~SWT.BORDER;
+	} else if ("motif".equals (platform)) { //$NON-NLS-1$
+		return style | SWT.EMBEDDED;
+	}
+	return style;
+}
+
+/**
+ * Clears all session cookies from all current Browser instances.
+ * 
+ * @since 3.2
+ */
+public static void clearSessions () {
+	WebBrowser.clearSessions ();
+}
+
+/**	 
+ * Adds the listener to the collection of listeners who will be
+ * notified when the window hosting the receiver should be closed.
+ * <p>
+ * This notification occurs when a javascript command such as
+ * <code>window.close</code> gets executed by a <code>Browser</code>.
+ * </p>
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+ *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+ * </ul>
+ *
+ * @since 3.0
+ */
+public void addCloseWindowListener (CloseWindowListener listener) {
+	checkWidget();
+	if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+	webBrowser.addCloseWindowListener (listener);
+}
+
+/**	 
+ * Adds the listener to the collection of listeners who will be
+ * notified when the current location has changed or is about to change.
+ * <p>
+ * This notification typically occurs when the application navigates
+ * to a new location with {@link #setUrl(String)} or when the user
+ * activates a hyperlink.
+ * </p>
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+ *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+ * </ul>
+ *
+ * @since 3.0
+ */
+public void addLocationListener (LocationListener listener) {
+	checkWidget();
+	if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+	webBrowser.addLocationListener (listener);
+}
+
+/**	 
+ * Adds the listener to the collection of listeners who will be
+ * notified when a new window needs to be created.
+ * <p>
+ * This notification occurs when a javascript command such as
+ * <code>window.open</code> gets executed by a <code>Browser</code>.
+ * </p>
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+ *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+ * </ul>
+ *
+ * @since 3.0
+ */
+public void addOpenWindowListener (OpenWindowListener listener) {
+	checkWidget();
+	if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+	webBrowser.addOpenWindowListener (listener);
+}
+
+/**	 
+ * Adds the listener to the collection of listeners who will be
+ * notified when a progress is made during the loading of the current 
+ * URL or when the loading of the current URL has been completed.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+ *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+ * </ul>
+ *
+ * @since 3.0
+ */
+public void addProgressListener (ProgressListener listener) {
+	checkWidget();
+	if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+	webBrowser.addProgressListener (listener);
+}
+
+/**	 
+ * Adds the listener to the collection of listeners who will be
+ * notified when the status text is changed.
+ * <p>
+ * The status text is typically displayed in the status bar of
+ * a browser application.
+ * </p>
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+ *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+ * </ul>
+ *
+ * @since 3.0
+ */
+public void addStatusTextListener (StatusTextListener listener) {
+	checkWidget();
+	if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+	webBrowser.addStatusTextListener (listener);
+}
+
+/**	 
+ * Adds the listener to the collection of listeners who will be
+ * notified when the title of the current document is available
+ * or has changed.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+ *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+ * </ul>
+ *
+ * @since 3.0
+ */
+public void addTitleListener (TitleListener listener) {
+	checkWidget();
+	if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+	webBrowser.addTitleListener (listener);
+}
+
+/**	 
+ * Adds the listener to the collection of listeners who will be
+ * notified when a window hosting the receiver needs to be displayed
+ * or hidden.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+ *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+ * </ul>
+ *
+ * @since 3.0
+ */
+public void addVisibilityWindowListener (VisibilityWindowListener listener) {
+	checkWidget();
+	if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+	webBrowser.addVisibilityWindowListener (listener);
+}
+
+/**
+ * Navigate to the previous session history item.
+ *
+ * @return <code>true</code> if the operation was successful and <code>false</code> otherwise
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+ *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+ * </ul>
+ *
+ * @see #forward
+ * 
+ * @since 3.0
+ */
+public boolean back () {
+	checkWidget();
+	return webBrowser.back ();
+}
+
+protected void checkSubclass () {
+	String name = getClass ().getName ();
+	int index = name.lastIndexOf ('.');
+	if (!name.substring (0, index + 1).equals (PACKAGE_PREFIX)) {
+		SWT.error (SWT.ERROR_INVALID_SUBCLASS);
+	}
+}
+
+/**
+ * Execute the specified script.
+ *
+ * <p>
+ * Execute a script containing javascript commands in the context of the current document. 
+ * 
+ * @param script the script with javascript commands
+ *  
+ * @return <code>true</code> if the operation was successful and <code>false</code> otherwise
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the script is null</li>
+ * </ul>
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+ *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+ * </ul>
+ *
+ * @since 3.1
+ */
+public boolean execute (String script) {
+	checkWidget();
+	if (script == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+	return webBrowser.execute (script);
+}
+
+/**
+ * Navigate to the next session history item.
+ *
+ * @return <code>true</code> if the operation was successful and <code>false</code> otherwise
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+ *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+ * </ul>
+ * 
+ * @see #back
+ * 
+ * @since 3.0
+ */
+public boolean forward () {
+	checkWidget();
+	return webBrowser.forward ();
+}
+
+public int getStyle () {
+	/*
+	* If SWT.BORDER was specified at creation time then getStyle() should answer
+	* it even though it is removed for IE on win32 in checkStyle().
+	*/
+	return super.getStyle () | (userStyle & SWT.BORDER);
+}
+
+/**
+ * Returns a string with HTML that represents the content of the current page.
+ *
+ * @return HTML representing the current page or an empty <code>String</code>
+ * if this is empty
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+ *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+ * </ul>
+ *
+ * @since 3.4
+ */
+public String getText () {
+	checkWidget();
+	return webBrowser.getText ();
+}
+
+/**
+ * Returns the current URL.
+ *
+ * @return the current URL or an empty <code>String</code> if there is no current URL
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+ *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+ * </ul>
+ *
+ * @see #setUrl
+ * 
+ * @since 3.0
+ */
+public String getUrl () {
+	checkWidget();
+	return webBrowser.getUrl ();
+}
+
+/**
+ * Returns the JavaXPCOM <code>nsIWebBrowser</code> for the receiver, or <code>null</code>
+ * if it is not available.  In order for an <code>nsIWebBrowser</code> to be returned all
+ * of the following must be true: <ul>
+ *    <li>the receiver's style must be <code>SWT.MOZILLA</code></li>
+ *    <li>the classes from JavaXPCOM &gt;= 1.8.1.2 must be resolvable at runtime</li>
+ *    <li>the version of the underlying XULRunner must be &gt;= 1.8.1.2</li>
+ * </ul> 
+ *
+ * @return the receiver's JavaXPCOM <code>nsIWebBrowser</code> or <code>null</code>
+ * 
+ * @since 3.3
+ */
+public Object getWebBrowser () {
+	checkWidget();
+	return webBrowser.getWebBrowser ();
+}
+
+/**
+ * Returns <code>true</code> if the receiver can navigate to the 
+ * previous session history item, and <code>false</code> otherwise.
+ *
+ * @return the receiver's back command enabled state
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see #back
+ */
+public boolean isBackEnabled () {
+	checkWidget();
+	return webBrowser.isBackEnabled ();
+}
+
+public boolean isFocusControl () {
+	checkWidget();
+	if (webBrowser.isFocusControl ()) return true;
+	return super.isFocusControl ();
+}
+
+/**
+ * Returns <code>true</code> if the receiver can navigate to the 
+ * next session history item, and <code>false</code> otherwise.
+ *
+ * @return the receiver's forward command enabled state
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see #forward
+ */
+public boolean isForwardEnabled () {
+	checkWidget();
+	return webBrowser.isForwardEnabled ();
+}
+
+/**
+ * Refresh the current page.
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+ *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+ * </ul>
+ *
+ * @since 3.0
+ */
+public void refresh () {
+	checkWidget();
+	webBrowser.refresh ();
+}
+
+/**	 
+ * Removes the listener from the collection of listeners who will
+ * be notified when the window hosting the receiver should be closed.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+ *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+ * </ul>
+ * 
+ * @since 3.0
+ */
+public void removeCloseWindowListener (CloseWindowListener listener) {
+	checkWidget();
+	if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+	webBrowser.removeCloseWindowListener (listener);
+}
+
+/**	 
+ * Removes the listener from the collection of listeners who will
+ * be notified when the current location is changed or about to be changed.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+ *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+ * </ul>
+ * 
+ * @since 3.0
+ */
+public void removeLocationListener (LocationListener listener) {
+	checkWidget();
+	if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+	webBrowser.removeLocationListener (listener);
+}
+
+/**	 
+ * Removes the listener from the collection of listeners who will
+ * be notified when a new window needs to be created.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+ *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+ * </ul>
+ * 
+ * @since 3.0
+ */
+public void removeOpenWindowListener (OpenWindowListener listener) {
+	checkWidget();
+	if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+	webBrowser.removeOpenWindowListener (listener);
+}
+
+/**	 
+ * Removes the listener from the collection of listeners who will
+ * be notified when a progress is made during the loading of the current 
+ * URL or when the loading of the current URL has been completed.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+ *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+ * </ul>
+ * 
+ * @since 3.0
+ */
+public void removeProgressListener (ProgressListener listener) {
+	checkWidget();
+	if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+	webBrowser.removeProgressListener (listener);
+}
+
+/**	 
+ * Removes the listener from the collection of listeners who will
+ * be notified when the status text is changed.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+ *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+ * </ul>
+ * 
+ * @since 3.0
+ */
+public void removeStatusTextListener (StatusTextListener listener) {
+	checkWidget();
+	if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+	webBrowser.removeStatusTextListener (listener);
+}
+
+/**	 
+ * Removes the listener from the collection of listeners who will
+ * be notified when the title of the current document is available
+ * or has changed.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+ *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+ * </ul>
+ * 
+ * @since 3.0
+ */
+public void removeTitleListener (TitleListener listener) {
+	checkWidget();
+	if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+	webBrowser.removeTitleListener (listener);
+}
+
+/**	 
+ * Removes the listener from the collection of listeners who will
+ * be notified when a window hosting the receiver needs to be displayed
+ * or hidden.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+ *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+ * </ul>
+ * 
+ * @since 3.0
+ */
+public void removeVisibilityWindowListener (VisibilityWindowListener listener) {
+	checkWidget();
+	if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+	webBrowser.removeVisibilityWindowListener (listener);
+}
+
+/**
+ * Renders HTML.
+ * 
+ * <p>
+ * The html parameter is Unicode encoded since it is a java <code>String</code>.
+ * As a result, the HTML meta tag charset should not be set. The charset is implied
+ * by the <code>String</code> itself.
+ * 
+ * @param html the HTML content to be rendered
+ *
+ * @return true if the operation was successful and false otherwise.
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the html is null</li>
+ * </ul>
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+ *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+ * </ul>
+ *  
+ * @see #setUrl
+ * 
+ * @since 3.0
+ */
+public boolean setText (String html) {
+	checkWidget();
+	if (html == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+	return webBrowser.setText (html);
+}
+
+/**
+ * Loads a URL.
+ * 
+ * @param url the URL to be loaded
+ *
+ * @return true if the operation was successful and false otherwise.
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the url is null</li>
+ * </ul>
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+ *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+ * </ul>
+ *  
+ * @see #getUrl
+ * 
+ * @since 3.0
+ */
+public boolean setUrl (String url) {
+	checkWidget();
+	if (url == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+	return webBrowser.setUrl (url);
+}
+
+/**
+ * Stop any loading and rendering activity.
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+ *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+ * </ul>
+ *
+ * @since 3.0
+ */
+public void stop () {
+	checkWidget();
+	webBrowser.stop ();
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/browser/CloseWindowListener.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/browser/CloseWindowListener.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/browser/CloseWindowListener.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.browser;
+
+import org.eclipse.swt.internal.SWTEventListener;
+
+/**
+ * This listener interface may be implemented in order to receive
+ * a {@link WindowEvent} notification when a {@link Browser} is 
+ * about to be closed and when its host window should be closed
+ * by the application.
+ * 
+ * @see Browser#addCloseWindowListener(CloseWindowListener)
+ * @see Browser#removeCloseWindowListener(CloseWindowListener)
+ * @see OpenWindowListener
+ * @see VisibilityWindowListener
+ * 
+ * @since 3.0
+ */
+public interface CloseWindowListener extends SWTEventListener {
+
+/**
+ * This method is called when the window hosting a {@link Browser} should be closed.
+ * Application would typically close the {@link org.eclipse.swt.widgets.Shell} that
+ * hosts the <code>Browser</code>. The <code>Browser</code> is disposed after this
+ * notification.
+ *
+ * <p>The following fields in the <code>WindowEvent</code> apply:
+ * <ul>
+ * <li>(in) widget the <code>Browser</code> that is going to be disposed
+ * </ul></p>
+ *
+ * @param event the <code>WindowEvent</code> that specifies the <code>Browser</code>
+ * that is going to be disposed
+ * 
+ * @see org.eclipse.swt.widgets.Shell#close()
+ * 
+ * @since 3.0
+ */ 
+public void close(WindowEvent event);
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/browser/Download.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/browser/Download.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/browser/Download.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,369 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.browser;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.mozilla.*;
+import org.eclipse.swt.layout.*;
+import org.eclipse.swt.widgets.*;
+
+class Download {
+	XPCOMObject supports;
+	XPCOMObject download;
+	XPCOMObject progressDialog;
+	XPCOMObject webProgressListener;
+	nsIHelperAppLauncher helperAppLauncher;
+	int refCount = 0;
+
+	Shell shell;
+	Label status;
+	Button cancel;
+	
+Download () {
+	createCOMInterfaces ();
+}
+
+int AddRef () {
+	refCount++;
+	return refCount;
+}
+
+void createCOMInterfaces () {
+	/* Create each of the interfaces that this object implements */
+	supports = new XPCOMObject (new int[] {2, 0, 0}) {
+		public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+		public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+		public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+	};
+	
+	download = new XPCOMObject (new int[] {2, 0, 0, 7, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1}) {
+		public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+		public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+		public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+		public int /*long*/ method3 (int /*long*/[] args) {return Init (args[0], args[1], args[2], args[3], args[4], args[5], args[6]);}
+		public int /*long*/ method4 (int /*long*/[] args) {return GetSource (args[0]);}
+		public int /*long*/ method5 (int /*long*/[] args) {return GetTarget (args[0]);}
+		public int /*long*/ method6 (int /*long*/[] args) {return GetPersist (args[0]);}
+		public int /*long*/ method7 (int /*long*/[] args) {return GetPercentComplete (args[0]);}
+		public int /*long*/ method8 (int /*long*/[] args) {return GetDisplayName (args[0]);}
+		public int /*long*/ method9 (int /*long*/[] args) {return SetDisplayName (args[0]);}
+		public int /*long*/ method10 (int /*long*/[] args) {return GetStartTime (args[0]);}
+		public int /*long*/ method11 (int /*long*/[] args) {return GetMIMEInfo (args[0]);}
+		public int /*long*/ method12 (int /*long*/[] args) {return GetListener (args[0]);}
+		public int /*long*/ method13 (int /*long*/[] args) {return SetListener (args[0]);}
+		public int /*long*/ method14 (int /*long*/[] args) {return GetObserver (args[0]);}
+		public int /*long*/ method15 (int /*long*/[] args) {return SetObserver (args[0]);}
+	};
+	
+	progressDialog = new XPCOMObject (new int[] {2, 0, 0, 7, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}) {
+		public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+		public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+		public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+		public int /*long*/ method3 (int /*long*/[] args) {return Init (args[0], args[1], args[2], args[3], args[4], args[5], args[6]);}
+		public int /*long*/ method4 (int /*long*/[] args) {return GetSource (args[0]);}
+		public int /*long*/ method5 (int /*long*/[] args) {return GetTarget (args[0]);}
+		public int /*long*/ method6 (int /*long*/[] args) {return GetPersist (args[0]);}
+		public int /*long*/ method7 (int /*long*/[] args) {return GetPercentComplete (args[0]);}
+		public int /*long*/ method8 (int /*long*/[] args) {return GetDisplayName (args[0]);}
+		public int /*long*/ method9 (int /*long*/[] args) {return SetDisplayName (args[0]);}
+		public int /*long*/ method10 (int /*long*/[] args) {return GetStartTime (args[0]);}
+		public int /*long*/ method11 (int /*long*/[] args) {return GetMIMEInfo (args[0]);}
+		public int /*long*/ method12 (int /*long*/[] args) {return GetListener (args[0]);}
+		public int /*long*/ method13 (int /*long*/[] args) {return SetListener (args[0]);}
+		public int /*long*/ method14 (int /*long*/[] args) {return GetObserver (args[0]);}
+		public int /*long*/ method15 (int /*long*/[] args) {return SetObserver (args[0]);}
+		public int /*long*/ method16 (int /*long*/[] args) {return Open (args[0]);}
+		public int /*long*/ method17 (int /*long*/[] args) {return GetCancelDownloadOnClose (args[0]);}
+		public int /*long*/ method18 (int /*long*/[] args) {return SetCancelDownloadOnClose ((int)/*64*/args[0]);}
+		public int /*long*/ method19 (int /*long*/[] args) {return GetDialog (args[0]);}
+		public int /*long*/ method20 (int /*long*/[] args) {return SetDialog (args[0]);}
+	};
+	
+	webProgressListener = new XPCOMObject (new int[] {2, 0, 0, 4, 6, 3, 4, 3}) {
+		public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+		public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+		public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+		public int /*long*/ method3 (int /*long*/[] args) {return OnStateChange (args[0], args[1], (int)/*64*/args[2], (int)/*64*/args[3]);}
+		public int /*long*/ method4 (int /*long*/[] args) {return OnProgressChange (args[0], args[1], (int)/*64*/args[2], (int)/*64*/args[3], (int)/*64*/args[4], (int)/*64*/args[5]);}
+		public int /*long*/ method5 (int /*long*/[] args) {return OnLocationChange (args[0], args[1], args[2]);}
+		public int /*long*/ method6 (int /*long*/[] args) {return OnStatusChange (args[0], args[1], (int)/*64*/args[2], args[3]);}
+		public int /*long*/ method7 (int /*long*/[] args) {return OnSecurityChange (args[0], args[1], (int)/*64*/args[2]);}
+	};
+}
+
+void disposeCOMInterfaces () {
+	if (supports != null) {
+		supports.dispose ();
+		supports = null;
+	}	
+	if (download != null) {
+		download.dispose ();
+		download = null;	
+	}
+	if (progressDialog != null) {
+		progressDialog.dispose ();
+		progressDialog = null;
+	}
+	if (webProgressListener != null) {
+		webProgressListener.dispose ();
+		webProgressListener = null;
+	}
+}
+
+int /*long*/ getAddress () {
+	return progressDialog.getAddress ();
+}
+
+int QueryInterface (int /*long*/ riid, int /*long*/ ppvObject) {
+	if (riid == 0 || ppvObject == 0) return XPCOM.NS_ERROR_NO_INTERFACE;
+	nsID guid = new nsID ();
+	XPCOM.memmove (guid, riid, nsID.sizeof);
+
+	if (guid.Equals (nsISupports.NS_ISUPPORTS_IID)) {
+		XPCOM.memmove (ppvObject, new int /*long*/[] {supports.getAddress ()}, C.PTR_SIZEOF);
+		AddRef();
+		return XPCOM.NS_OK;
+	}
+	if (guid.Equals (nsIDownload.NS_IDOWNLOAD_IID)) {
+		XPCOM.memmove (ppvObject, new int /*long*/[] {download.getAddress ()}, C.PTR_SIZEOF);
+		AddRef();
+		return XPCOM.NS_OK;
+	}
+	if (guid.Equals (nsIProgressDialog.NS_IPROGRESSDIALOG_IID)) {
+		XPCOM.memmove (ppvObject, new int /*long*/[] {progressDialog.getAddress ()}, C.PTR_SIZEOF);
+		AddRef();
+		return XPCOM.NS_OK;
+	}
+	if (guid.Equals (nsIWebProgressListener.NS_IWEBPROGRESSLISTENER_IID)) {
+		XPCOM.memmove (ppvObject, new int /*long*/[] {webProgressListener.getAddress ()}, C.PTR_SIZEOF);
+		AddRef();
+		return XPCOM.NS_OK;
+	}
+	XPCOM.memmove (ppvObject, new int /*long*/[] {0}, C.PTR_SIZEOF);
+	return XPCOM.NS_ERROR_NO_INTERFACE;
+}
+        	
+int Release () {
+	refCount--;
+	if (refCount == 0) disposeCOMInterfaces ();
+	return refCount;
+}
+
+/* nsIDownload */
+
+/* Note. The argument startTime is defined as a PRInt64. This translates into two java ints. */
+int Init (int /*long*/ aSource, int /*long*/ aTarget, int /*long*/ aDisplayName, int /*long*/ aMIMEInfo, int /*long*/ startTime1, int /*long*/ startTime2, int /*long*/ aPersist) {
+	nsIURI source = new nsIURI (aSource);
+	int /*long*/ aSpec = XPCOM.nsEmbedCString_new ();
+	int rc = source.GetHost (aSpec);
+	if (rc != XPCOM.NS_OK) Mozilla.error (rc);
+	int length = XPCOM.nsEmbedCString_Length (aSpec);
+	int /*long*/ buffer = XPCOM.nsEmbedCString_get (aSpec);
+	byte[] dest = new byte[length];
+	XPCOM.memmove (dest, buffer, length);
+	XPCOM.nsEmbedCString_delete (aSpec);
+	String url = new String (dest);
+
+	/*
+	* As of mozilla 1.7 the second argument of the nsIDownload interface's 
+	* Init function changed from nsILocalFile to nsIURI.  Detect which of
+	* these interfaces the second argument implements and act accordingly.  
+	*/
+	String filename = null;
+	nsISupports supports = new nsISupports (aTarget);
+	int /*long*/[] result = new int /*long*/[1];
+	rc = supports.QueryInterface (nsIURI.NS_IURI_IID, result);
+	if (rc == 0) {	/* >= 1.7 */
+		nsIURI target = new nsIURI (result[0]);
+		result[0] = 0;
+		int /*long*/ aPath = XPCOM.nsEmbedCString_new ();
+		rc = target.GetPath (aPath);
+		if (rc != XPCOM.NS_OK) Mozilla.error (rc);
+		length = XPCOM.nsEmbedCString_Length (aPath);
+		buffer = XPCOM.nsEmbedCString_get (aPath);
+		dest = new byte[length];
+		XPCOM.memmove (dest, buffer, length);
+		XPCOM.nsEmbedCString_delete (aPath);
+		filename = new String (dest);
+		int separator = filename.lastIndexOf (System.getProperty ("file.separator"));	//$NON-NLS-1$
+		filename = filename.substring (separator + 1);
+		target.Release ();
+	} else {	/* < 1.7 */
+		nsILocalFile target = new nsILocalFile (aTarget);
+		int /*long*/ aNativeTarget = XPCOM.nsEmbedCString_new ();
+		rc = target.GetNativeLeafName (aNativeTarget);
+		if (rc != XPCOM.NS_OK) Mozilla.error (rc);
+		length = XPCOM.nsEmbedCString_Length (aNativeTarget);
+		buffer = XPCOM.nsEmbedCString_get (aNativeTarget);
+		dest = new byte[length];
+		XPCOM.memmove (dest, buffer, length);
+		XPCOM.nsEmbedCString_delete (aNativeTarget);
+		filename = new String (dest);
+	}
+
+	Listener listener = new Listener () {
+		public void handleEvent (Event event) {
+			if (event.widget == cancel) {
+				shell.close ();
+			}
+			if (helperAppLauncher != null) {
+				helperAppLauncher.Cancel ();
+				helperAppLauncher.Release ();
+			}
+			shell = null;
+			helperAppLauncher = null;
+		}
+	};
+	shell = new Shell (SWT.DIALOG_TRIM);
+	String msg = Compatibility.getMessage ("SWT_Download_File", new Object[] {filename}); //$NON-NLS-1$
+	shell.setText (msg);
+	GridLayout gridLayout = new GridLayout ();
+	gridLayout.marginHeight = 15;
+	gridLayout.marginWidth = 15;
+	gridLayout.verticalSpacing = 20;
+	shell.setLayout(gridLayout);
+	msg = Compatibility.getMessage ("SWT_Download_Location", new Object[] {filename, url}); //$NON-NLS-1$
+	new Label (shell, SWT.SIMPLE).setText (msg);
+	status = new Label (shell, SWT.SIMPLE);
+	msg = Compatibility.getMessage ("SWT_Download_Started"); //$NON-NLS-1$
+	status.setText (msg);
+	GridData data = new GridData ();
+	data.grabExcessHorizontalSpace = true;
+	data.grabExcessVerticalSpace = true;
+	status.setLayoutData (data);
+
+	cancel = new Button (shell, SWT.PUSH);
+	cancel.setText (SWT.getMessage ("SWT_Cancel")); //$NON-NLS-1$
+	data = new GridData ();
+	data.horizontalAlignment = GridData.CENTER;
+	cancel.setLayoutData (data);
+	cancel.addListener (SWT.Selection, listener);
+	shell.addListener (SWT.Close, listener);
+	shell.pack ();
+	shell.open ();
+	return XPCOM.NS_OK;
+}
+
+int GetSource (int /*long*/ aSource) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+int GetTarget (int /*long*/ aTarget) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+int GetPersist (int /*long*/ aPersist) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+int GetPercentComplete (int /*long*/ aPercentComplete) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+int GetDisplayName (int /*long*/ aDisplayName) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+int SetDisplayName (int /*long*/ aDisplayName) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+int GetStartTime (int /*long*/ aStartTime) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+int GetMIMEInfo (int /*long*/ aMIMEInfo) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+int GetListener (int /*long*/ aListener) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+int SetListener (int /*long*/ aListener) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+int GetObserver (int /*long*/ aObserver) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+int SetObserver (int /*long*/ aObserver) {
+	if (aObserver != 0) {
+		nsISupports supports = new nsISupports (aObserver);
+		int /*long*/[] result = new int /*long*/[1];
+		int rc = supports.QueryInterface (nsIHelperAppLauncher.NS_IHELPERAPPLAUNCHER_IID, result);
+		if (rc != XPCOM.NS_OK) Mozilla.error (rc);
+		if (result[0] == 0) Mozilla.error (XPCOM.NS_ERROR_NO_INTERFACE);
+		helperAppLauncher = new nsIHelperAppLauncher (result[0]);
+	}
+	return XPCOM.NS_OK;
+}
+
+/* nsIProgressDialog */
+int Open (int /*long*/ aParent) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+int GetCancelDownloadOnClose (int /*long*/ aCancelDownloadOnClose) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+int SetCancelDownloadOnClose (int aCancelDownloadOnClose) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+int GetDialog (int /*long*/ aDialog) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+int SetDialog (int /*long*/ aDialog) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* nsIWebProgressListener */
+
+int OnStateChange (int /*long*/ aWebProgress, int /*long*/ aRequest, int aStateFlags, int aStatus) {
+	if ((aStateFlags & nsIWebProgressListener.STATE_STOP) != 0) {
+		if (helperAppLauncher != null) helperAppLauncher.Release ();
+		helperAppLauncher = null;
+		if (shell != null && !shell.isDisposed ()) shell.dispose ();
+		shell = null;
+	}
+	return XPCOM.NS_OK;
+}
+
+int OnProgressChange (int /*long*/ aWebProgress, int /*long*/ aRequest, int aCurSelfProgress, int aMaxSelfProgress, int aCurTotalProgress, int aMaxTotalProgress) {
+	int currentKBytes = aCurTotalProgress / 1024;
+	int totalKBytes = aMaxTotalProgress / 1024;
+	if (shell != null && !shell.isDisposed ()) {
+		Object[] arguments = {new Integer (currentKBytes), new Integer (totalKBytes)};
+		String statusMsg = Compatibility.getMessage ("SWT_Download_Status", arguments); //$NON-NLS-1$
+		status.setText (statusMsg);
+		shell.layout (true);
+		shell.getDisplay ().update ();
+	}
+	return XPCOM.NS_OK;
+}
+
+int OnLocationChange (int /*long*/ aWebProgress, int /*long*/ aRequest, int /*long*/ aLocation) {
+	return XPCOM.NS_OK;
+}
+
+int OnStatusChange (int /*long*/ aWebProgress, int /*long*/ aRequest, int aStatus, int /*long*/ aMessage) {
+	return XPCOM.NS_OK;
+}
+
+int OnSecurityChange (int /*long*/ aWebProgress, int /*long*/ aRequest, int state) {
+	return XPCOM.NS_OK;
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/browser/DownloadFactory.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/browser/DownloadFactory.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/browser/DownloadFactory.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,100 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.browser;
+
+import org.eclipse.swt.internal.C;
+import org.eclipse.swt.internal.mozilla.*;
+
+class DownloadFactory {
+	XPCOMObject supports;
+	XPCOMObject factory;
+	int refCount = 0;
+
+DownloadFactory () {
+	createCOMInterfaces ();
+}
+
+int AddRef () {
+	refCount++;
+	return refCount;
+}
+
+void createCOMInterfaces () {
+	/* Create each of the interfaces that this object implements */
+	supports = new XPCOMObject (new int[] {2, 0, 0}) {
+		public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+		public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+		public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+	};
+	
+	factory = new XPCOMObject (new int[] {2, 0, 0, 3, 1}) {
+		public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+		public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+		public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+		public int /*long*/ method3 (int /*long*/[] args) {return CreateInstance (args[0], args[1], args[2]);}
+		public int /*long*/ method4 (int /*long*/[] args) {return LockFactory ((int)/*64*/args[0]);}
+	};
+}
+
+void disposeCOMInterfaces () {
+	if (supports != null) {
+		supports.dispose ();
+		supports = null;
+	}	
+	if (factory != null) {
+		factory.dispose ();
+		factory = null;	
+	}
+}
+
+int /*long*/ getAddress () {
+	return factory.getAddress ();
+}
+
+int QueryInterface (int /*long*/ riid, int /*long*/ ppvObject) {
+	if (riid == 0 || ppvObject == 0) return XPCOM.NS_ERROR_NO_INTERFACE;
+	nsID guid = new nsID ();
+	XPCOM.memmove (guid, riid, nsID.sizeof);
+	
+	if (guid.Equals (nsISupports.NS_ISUPPORTS_IID)) {
+		XPCOM.memmove (ppvObject, new int /*long*/[] {supports.getAddress ()}, C.PTR_SIZEOF);
+		AddRef ();
+		return XPCOM.NS_OK;
+	}
+	if (guid.Equals (nsIFactory.NS_IFACTORY_IID)) {
+		XPCOM.memmove (ppvObject, new int /*long*/[] {factory.getAddress ()}, C.PTR_SIZEOF);
+		AddRef ();
+		return XPCOM.NS_OK;
+	}
+	
+	XPCOM.memmove (ppvObject, new int /*long*/[] {0}, C.PTR_SIZEOF);
+	return XPCOM.NS_ERROR_NO_INTERFACE;
+}
+        	
+int Release () {
+	refCount--;
+	if (refCount == 0) disposeCOMInterfaces ();
+	return refCount;
+}
+	
+/* nsIFactory */
+
+int CreateInstance (int /*long*/ aOuter, int /*long*/ iid, int /*long*/ result) {
+	Download download = new Download ();
+	download.AddRef ();
+	XPCOM.memmove (result, new int /*long*/[] {download.getAddress ()}, C.PTR_SIZEOF);
+	return XPCOM.NS_OK;
+}
+
+int LockFactory (int lock) {
+	return XPCOM.NS_OK;
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/browser/DownloadFactory_1_8.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/browser/DownloadFactory_1_8.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/browser/DownloadFactory_1_8.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,100 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.browser;
+
+import org.eclipse.swt.internal.C;
+import org.eclipse.swt.internal.mozilla.*;
+
+class DownloadFactory_1_8 {
+	XPCOMObject supports;
+	XPCOMObject factory;
+	int refCount = 0;
+
+DownloadFactory_1_8 () {
+	createCOMInterfaces ();
+}
+
+int AddRef () {
+	refCount++;
+	return refCount;
+}
+
+void createCOMInterfaces () {
+	/* Create each of the interfaces that this object implements */
+	supports = new XPCOMObject (new int[] {2, 0, 0}) {
+		public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+		public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+		public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+	};
+	
+	factory = new XPCOMObject (new int[] {2, 0, 0, 3, 1}) {
+		public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+		public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+		public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+		public int /*long*/ method3 (int /*long*/[] args) {return CreateInstance (args[0], args[1], args[2]);}
+		public int /*long*/ method4 (int /*long*/[] args) {return LockFactory ((int)/*64*/args[0]);}
+	};
+}
+
+void disposeCOMInterfaces () {
+	if (supports != null) {
+		supports.dispose ();
+		supports = null;
+	}	
+	if (factory != null) {
+		factory.dispose ();
+		factory = null;	
+	}
+}
+
+int /*long*/ getAddress () {
+	return factory.getAddress ();
+}
+
+int QueryInterface (int /*long*/ riid, int /*long*/ ppvObject) {
+	if (riid == 0 || ppvObject == 0) return XPCOM.NS_ERROR_NO_INTERFACE;
+	nsID guid = new nsID ();
+	XPCOM.memmove (guid, riid, nsID.sizeof);
+	
+	if (guid.Equals (nsISupports.NS_ISUPPORTS_IID)) {
+		XPCOM.memmove (ppvObject, new int /*long*/[] {supports.getAddress ()}, C.PTR_SIZEOF);
+		AddRef ();
+		return XPCOM.NS_OK;
+	}
+	if (guid.Equals (nsIFactory.NS_IFACTORY_IID)) {
+		XPCOM.memmove (ppvObject, new int /*long*/[] {factory.getAddress ()}, C.PTR_SIZEOF);
+		AddRef ();
+		return XPCOM.NS_OK;
+	}
+	
+	XPCOM.memmove (ppvObject, new int /*long*/[] {0}, C.PTR_SIZEOF);
+	return XPCOM.NS_ERROR_NO_INTERFACE;
+}
+        	
+int Release () {
+	refCount--;
+	if (refCount == 0) disposeCOMInterfaces ();
+	return refCount;
+}
+
+/* nsIFactory */
+
+int CreateInstance (int /*long*/ aOuter, int /*long*/ iid, int /*long*/ result) {
+	Download_1_8 download = new Download_1_8 ();
+	download.AddRef ();
+	XPCOM.memmove (result, new int /*long*/[] {download.getAddress ()}, C.PTR_SIZEOF);
+	return XPCOM.NS_OK;
+}
+
+int LockFactory (int lock) {
+	return XPCOM.NS_OK;
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/browser/Download_1_8.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/browser/Download_1_8.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/browser/Download_1_8.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,391 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.browser;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.mozilla.*;
+import org.eclipse.swt.layout.*;
+import org.eclipse.swt.widgets.*;
+
+class Download_1_8 {
+	XPCOMObject supports;
+	XPCOMObject download;
+	XPCOMObject progressDialog;
+	XPCOMObject webProgressListener;
+	nsICancelable cancelable;
+	int refCount = 0;
+
+	Shell shell;
+	Label status;
+	Button cancel;
+
+	static final boolean is32 = C.PTR_SIZEOF == 4;
+
+Download_1_8 () {
+	createCOMInterfaces ();
+}
+
+int AddRef () {
+	refCount++;
+	return refCount;
+}
+
+void createCOMInterfaces () {
+	/* Create each of the interfaces that this object implements */
+	supports = new XPCOMObject (new int[] {2, 0, 0}) {
+		public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+		public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+		public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+	};
+
+	download = new XPCOMObject (new int[] {2, 0, 0, 4, 6, 3, 4, 3, is32 ? 10 : 6, is32 ? 8 : 7, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}) {
+		public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+		public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+		public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+		public int /*long*/ method3 (int /*long*/[] args) {return OnStateChange (args[0], args[1], (int)/*64*/args[2], (int)/*64*/args[3]);}
+		public int /*long*/ method4 (int /*long*/[] args) {return OnProgressChange (args[0], args[1], (int)/*64*/args[2], (int)/*64*/args[3], (int)/*64*/args[4], (int)/*64*/args[5]);}
+		public int /*long*/ method5 (int /*long*/[] args) {return OnLocationChange (args[0], args[1], args[2]);}
+		public int /*long*/ method6 (int /*long*/[] args) {return OnStatusChange (args[0], args[1], (int)/*64*/args[2], args[3]);}
+		public int /*long*/ method7 (int /*long*/[] args) {return OnSecurityChange (args[0], args[1], (int)/*64*/args[2]);}
+		public int /*long*/ method8 (int /*long*/[] args) {
+			if (args.length == 10) {
+				return OnProgressChange64_32 (args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8], args[9]);
+			} else {
+				return OnProgressChange64 (args[0], args[1], args[2], args[3], args[4], args[5]);
+			}
+		}
+		public int /*long*/ method9 (int /*long*/[] args) {
+			if (args.length == 8) {
+				return Init_32 (args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7]);
+			} else {
+				return Init (args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
+			}
+		}
+		public int /*long*/ method10 (int /*long*/[] args) {return GetTargetFile (args[0]);}
+		public int /*long*/ method11 (int /*long*/[] args) {return GetPercentComplete (args[0]);}
+		public int /*long*/ method12 (int /*long*/[] args) {return GetAmountTransferred (args[0]);}
+		public int /*long*/ method13 (int /*long*/[] args) {return GetSize (args[0]);}
+		public int /*long*/ method14 (int /*long*/[] args) {return GetSource (args[0]);}
+		public int /*long*/ method15 (int /*long*/[] args) {return GetTarget (args[0]);}
+		public int /*long*/ method16 (int /*long*/[] args) {return GetCancelable (args[0]);}
+		public int /*long*/ method17 (int /*long*/[] args) {return GetDisplayName (args[0]);}
+		public int /*long*/ method18 (int /*long*/[] args) {return GetStartTime (args[0]);}
+		public int /*long*/ method19 (int /*long*/[] args) {return GetMIMEInfo (args[0]);}
+	};
+
+	progressDialog = new XPCOMObject (new int[] {2, 0, 0, 4, 6, 3, 4, 3, is32 ? 10 : 6, is32 ? 8 : 7, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}) {
+		public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+		public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+		public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+		public int /*long*/ method3 (int /*long*/[] args) {return OnStateChange (args[0], args[1], (int)/*64*/args[2], (int)/*64*/args[3]);}
+		public int /*long*/ method4 (int /*long*/[] args) {return OnProgressChange (args[0], args[1], (int)/*64*/args[2], (int)/*64*/args[3], (int)/*64*/args[4], (int)/*64*/args[5]);}
+		public int /*long*/ method5 (int /*long*/[] args) {return OnLocationChange (args[0], args[1], args[2]);}
+		public int /*long*/ method6 (int /*long*/[] args) {return OnStatusChange (args[0], args[1], (int)/*64*/args[2], args[3]);}
+		public int /*long*/ method7 (int /*long*/[] args) {return OnSecurityChange (args[0], args[1], (int)/*64*/args[2]);}
+		public int /*long*/ method8 (int /*long*/[] args) {
+			if (args.length == 10) {
+				return OnProgressChange64_32 (args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8], args[9]);
+			} else {
+				return OnProgressChange64 (args[0], args[1], args[2], args[3], args[4], args[5]);
+			}
+		}
+		public int /*long*/ method9 (int /*long*/[] args) {
+			if (args.length == 8) {
+				return Init_32 (args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7]);
+			} else {
+				return Init (args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
+			}
+		}
+		public int /*long*/ method10 (int /*long*/[] args) {return GetTargetFile (args[0]);}
+		public int /*long*/ method11 (int /*long*/[] args) {return GetPercentComplete (args[0]);}
+		public int /*long*/ method12 (int /*long*/[] args) {return GetAmountTransferred (args[0]);}
+		public int /*long*/ method13 (int /*long*/[] args) {return GetSize (args[0]);}
+		public int /*long*/ method14 (int /*long*/[] args) {return GetSource (args[0]);}
+		public int /*long*/ method15 (int /*long*/[] args) {return GetTarget (args[0]);}
+		public int /*long*/ method16 (int /*long*/[] args) {return GetCancelable (args[0]);}
+		public int /*long*/ method17 (int /*long*/[] args) {return GetDisplayName (args[0]);}
+		public int /*long*/ method18 (int /*long*/[] args) {return GetStartTime (args[0]);}
+		public int /*long*/ method19 (int /*long*/[] args) {return GetMIMEInfo (args[0]);}
+		public int /*long*/ method20 (int /*long*/[] args) {return Open (args[0]);}
+		public int /*long*/ method21 (int /*long*/[] args) {return GetCancelDownloadOnClose (args[0]);}
+		public int /*long*/ method22 (int /*long*/[] args) {return SetCancelDownloadOnClose ((int)/*64*/args[0]);}
+		public int /*long*/ method23 (int /*long*/[] args) {return GetObserver (args[0]);}
+		public int /*long*/ method24 (int /*long*/[] args) {return SetObserver (args[0]);}
+		public int /*long*/ method25 (int /*long*/[] args) {return GetDialog (args[0]);}
+		public int /*long*/ method26 (int /*long*/[] args) {return SetDialog (args[0]);}
+	};
+
+	webProgressListener = new XPCOMObject (new int[] {2, 0, 0, 4, 6, 3, 4, 3}) {
+		public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+		public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+		public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+		public int /*long*/ method3 (int /*long*/[] args) {return OnStateChange (args[0], args[1], (int)/*64*/args[2], (int)/*64*/args[3]);}
+		public int /*long*/ method4 (int /*long*/[] args) {return OnProgressChange (args[0], args[1], (int)/*64*/args[2], (int)/*64*/args[3], (int)/*64*/args[4], (int)/*64*/args[5]);}
+		public int /*long*/ method5 (int /*long*/[] args) {return OnLocationChange (args[0], args[1], args[2]);}
+		public int /*long*/ method6 (int /*long*/[] args) {return OnStatusChange (args[0], args[1], (int)/*64*/args[2], args[3]);}
+		public int /*long*/ method7 (int /*long*/[] args) {return OnSecurityChange (args[0], args[1], (int)/*64*/args[2]);}
+	};
+}
+
+void disposeCOMInterfaces() {
+	if (supports != null) {
+		supports.dispose ();
+		supports = null;
+	}	
+	if (download != null) {
+		download.dispose ();
+		download = null;	
+	}
+	if (progressDialog != null) {
+		progressDialog.dispose ();
+		progressDialog = null;	
+	}
+	if (webProgressListener != null) {
+		webProgressListener.dispose ();
+		webProgressListener = null;	
+	}
+}
+
+int /*long*/ getAddress () {
+	return progressDialog.getAddress ();
+}
+
+int QueryInterface (int /*long*/ riid, int /*long*/ ppvObject) {
+	if (riid == 0 || ppvObject == 0) return XPCOM.NS_ERROR_NO_INTERFACE;
+	nsID guid = new nsID ();
+	XPCOM.memmove (guid, riid, nsID.sizeof);
+
+	if (guid.Equals (nsISupports.NS_ISUPPORTS_IID)) {
+		XPCOM.memmove (ppvObject, new int /*long*/[] {supports.getAddress ()}, C.PTR_SIZEOF);
+		AddRef();
+		return XPCOM.NS_OK;
+	}
+	if (guid.Equals (nsIDownload_1_8.NS_IDOWNLOAD_IID)) {
+		XPCOM.memmove (ppvObject, new int /*long*/[] {download.getAddress ()}, C.PTR_SIZEOF);
+		AddRef();
+		return XPCOM.NS_OK;
+	}
+	if (guid.Equals (nsIProgressDialog_1_8.NS_IPROGRESSDIALOG_IID)) {
+		XPCOM.memmove (ppvObject, new int /*long*/[] {progressDialog.getAddress ()}, C.PTR_SIZEOF);
+		AddRef();
+		return XPCOM.NS_OK;
+	}
+	if (guid.Equals (nsIWebProgressListener.NS_IWEBPROGRESSLISTENER_IID)) {
+		XPCOM.memmove (ppvObject, new int /*long*/[] {webProgressListener.getAddress ()}, C.PTR_SIZEOF);
+		AddRef();
+		return XPCOM.NS_OK;
+	}
+	XPCOM.memmove (ppvObject, new int /*long*/[] {0}, C.PTR_SIZEOF);
+	return XPCOM.NS_ERROR_NO_INTERFACE;
+}
+
+int Release () {
+	refCount--;
+	if (refCount == 0) disposeCOMInterfaces ();
+	return refCount;
+}
+
+/* nsIDownload */
+
+/* Note. The argument startTime is defined as a PRInt64. This translates into two java ints. */
+int Init_32 (int /*long*/ aSource, int /*long*/ aTarget, int /*long*/ aDisplayName, int /*long*/ aMIMEInfo, int /*long*/ startTime1, int /*long*/ startTime2, int /*long*/ aTempFile, int /*long*/ aCancelable) {
+	long startTime = (startTime2 << 32) + startTime1;
+	return Init (aSource, aTarget, aDisplayName, aMIMEInfo, startTime, aTempFile, aCancelable);
+}
+
+int Init (int /*long*/ aSource, int /*long*/ aTarget, int /*long*/ aDisplayName, int /*long*/ aMIMEInfo, long startTime, int /*long*/ aTempFile, int /*long*/ aCancelable) {
+	cancelable = new nsICancelable (aCancelable);
+	nsIURI source = new nsIURI (aSource);
+	int /*long*/ aSpec = XPCOM.nsEmbedCString_new ();
+	int rc = source.GetHost (aSpec);
+	if (rc != XPCOM.NS_OK) Mozilla.error(rc);
+	int length = XPCOM.nsEmbedCString_Length (aSpec);
+	int /*long*/ buffer = XPCOM.nsEmbedCString_get (aSpec);
+	byte[] dest = new byte[length];
+	XPCOM.memmove (dest, buffer, length);
+	XPCOM.nsEmbedCString_delete (aSpec);
+	String url = new String (dest);
+
+	nsIURI target = new nsIURI (aTarget);
+	int /*long*/ aPath = XPCOM.nsEmbedCString_new ();
+	rc = target.GetPath (aPath);
+	if (rc != XPCOM.NS_OK) Mozilla.error (rc);
+	length = XPCOM.nsEmbedCString_Length (aPath);
+	buffer = XPCOM.nsEmbedCString_get (aPath);
+	dest = new byte[length];
+	XPCOM.memmove (dest, buffer, length);
+	XPCOM.nsEmbedCString_delete (aPath);
+	String filename = new String (dest);
+	int separator = filename.lastIndexOf (System.getProperty ("file.separator"));	//$NON-NLS-1$
+	filename = filename.substring (separator + 1);
+
+	Listener listener = new Listener() {
+		public void handleEvent (Event event) {
+			if (event.widget == cancel) {
+				shell.close ();
+			}
+			if (cancelable != null) {
+				int rc = cancelable.Cancel (XPCOM.NS_BINDING_ABORTED);
+				if (rc != XPCOM.NS_OK) Mozilla.error (rc);
+			}
+			shell = null;
+			cancelable = null;
+		}
+	};
+	shell = new Shell (SWT.DIALOG_TRIM);
+	String msg = Compatibility.getMessage ("SWT_Download_File", new Object[] {filename}); //$NON-NLS-1$
+	shell.setText (msg);
+	GridLayout gridLayout = new GridLayout ();
+	gridLayout.marginHeight = 15;
+	gridLayout.marginWidth = 15;
+	gridLayout.verticalSpacing = 20;
+	shell.setLayout (gridLayout);
+	msg = Compatibility.getMessage ("SWT_Download_Location", new Object[] {filename, url}); //$NON-NLS-1$
+	new Label (shell, SWT.SIMPLE).setText (msg);
+	status = new Label (shell, SWT.SIMPLE);
+	msg = Compatibility.getMessage ("SWT_Download_Started"); //$NON-NLS-1$
+	status.setText (msg);
+	GridData data = new GridData ();
+	data.grabExcessHorizontalSpace = true;
+	data.grabExcessVerticalSpace = true;
+	status.setLayoutData (data);
+	
+	cancel = new Button (shell, SWT.PUSH);
+	cancel.setText (SWT.getMessage ("SWT_Cancel")); //$NON-NLS-1$
+	data = new GridData ();
+	data.horizontalAlignment = GridData.CENTER;
+	cancel.setLayoutData (data);
+	cancel.addListener (SWT.Selection, listener);
+	shell.addListener (SWT.Close, listener);
+	shell.pack ();
+	shell.open ();
+	return XPCOM.NS_OK;
+}
+
+int GetAmountTransferred (int /*long*/ arg0) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+int GetCancelable (int /*long*/ arg0) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+int GetDisplayName (int /*long*/ aDisplayName) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+int GetMIMEInfo (int /*long*/ aMIMEInfo) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+int GetPercentComplete (int /*long*/ aPercentComplete) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+int GetSize (int /*long*/ arg0) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+int GetSource (int /*long*/ aSource) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+int GetStartTime (int /*long*/ aStartTime) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+int GetTarget (int /*long*/ aTarget) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+int GetTargetFile (int /*long*/ arg0) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* nsIProgressDialog */
+int GetCancelDownloadOnClose (int /*long*/ aCancelDownloadOnClose) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+int GetDialog (int /*long*/ aDialog) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+int GetObserver (int /*long*/ aObserver) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+int Open (int /*long*/ aParent) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+int SetCancelDownloadOnClose (int aCancelDownloadOnClose) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+int SetDialog (int /*long*/ aDialog) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+int SetObserver (int /*long*/ aObserver) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* nsIWebProgressListener */
+
+int OnLocationChange (int /*long*/ aWebProgress, int /*long*/ aRequest, int /*long*/ aLocation) {
+	return XPCOM.NS_OK;
+}
+
+int OnProgressChange (int /*long*/ aWebProgress, int /*long*/ aRequest, int aCurSelfProgress, int aMaxSelfProgress, int aCurTotalProgress, int aMaxTotalProgress) {
+	return OnProgressChange64 (aWebProgress, aRequest, aCurSelfProgress, aMaxSelfProgress, aCurTotalProgress, aMaxTotalProgress);
+}
+
+/* Note. The last 4 args in the original interface are defined as PRInt64. These each translate into two java ints. */
+int OnProgressChange64_32 (int /*long*/ aWebProgress, int /*long*/ aRequest, int /*long*/ aCurSelfProgress1, int /*long*/ aCurSelfProgress2, int /*long*/ aMaxSelfProgress1, int /*long*/ aMaxSelfProgress2, int /*long*/ aCurTotalProgress1, int /*long*/ aCurTotalProgress2, int /*long*/ aMaxTotalProgress1, int /*long*/ aMaxTotalProgress2) {
+	long aCurSelfProgress = (aCurSelfProgress2 << 32) + aCurSelfProgress1;
+	long aMaxSelfProgress = (aMaxSelfProgress2 << 32) + aMaxSelfProgress1;
+	long aCurTotalProgress = (aCurTotalProgress2 << 32) + aCurTotalProgress1;
+	long aMaxTotalProgress = (aMaxTotalProgress2 << 32) + aMaxTotalProgress1;
+	return OnProgressChange64 (aWebProgress, aRequest, aCurSelfProgress, aMaxSelfProgress, aCurTotalProgress, aMaxTotalProgress);
+}
+
+int OnProgressChange64 (int /*long*/ aWebProgress, int /*long*/ aRequest, long aCurSelfProgress, long aMaxSelfProgress, long aCurTotalProgress, long aMaxTotalProgress) {
+	long currentKBytes = aCurTotalProgress / 1024;
+	long totalKBytes = aMaxTotalProgress / 1024;
+	if (shell != null && !shell.isDisposed ()) {
+		Object[] arguments = {new Long (currentKBytes), new Long (totalKBytes)};
+		String statusMsg = Compatibility.getMessage ("SWT_Download_Status", arguments); //$NON-NLS-1$
+		status.setText (statusMsg);
+		shell.layout (true);
+		shell.getDisplay ().update ();
+	}
+	return XPCOM.NS_OK;
+}
+
+int OnSecurityChange (int /*long*/ aWebProgress, int /*long*/ aRequest, int state) {
+	return XPCOM.NS_OK;
+}
+
+int OnStateChange (int /*long*/ aWebProgress, int /*long*/ aRequest, int aStateFlags, int aStatus) {
+	if ((aStateFlags & nsIWebProgressListener.STATE_STOP) != 0) {
+		cancelable = null;
+		if (shell != null && !shell.isDisposed ()) shell.dispose ();
+		shell = null;
+	}
+	return XPCOM.NS_OK;
+}	
+
+int OnStatusChange (int /*long*/ aWebProgress, int /*long*/ aRequest, int aStatus, int /*long*/ aMessage) {
+	return XPCOM.NS_OK;
+}		
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/browser/FilePicker.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/browser/FilePicker.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/browser/FilePicker.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,296 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.browser;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.mozilla.*;
+import org.eclipse.swt.widgets.*;
+
+class FilePicker {
+	XPCOMObject supports;
+	XPCOMObject filePicker;
+
+	int refCount = 0;
+	short mode;
+	int /*long*/ parentHandle;
+	String[] files, masks;
+	String defaultFilename, directory, title;
+
+	static final String SEPARATOR = System.getProperty ("file.separator"); //$NON-NLS-1$
+
+FilePicker () {
+	createCOMInterfaces ();
+}
+
+int AddRef () {
+	refCount++;
+	return refCount;
+}
+
+void createCOMInterfaces () {
+	/* Create each of the interfaces that this object implements */
+	supports = new XPCOMObject (new int[] {2, 0, 0}) {
+		public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+		public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+		public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+	};
+
+	filePicker = new XPCOMObject (new int[] {2, 0, 0, 3, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}) {
+		public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+		public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+		public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+		public int /*long*/ method3 (int /*long*/[] args) {return Init (args[0], args[1], (short)args[2]);}
+		public int /*long*/ method4 (int /*long*/[] args) {return AppendFilters ((int)/*64*/args[0]);}
+		public int /*long*/ method5 (int /*long*/[] args) {return AppendFilter (args[0], args[1]);}
+		public int /*long*/ method6 (int /*long*/[] args) {return GetDefaultString (args[0]);}
+		public int /*long*/ method7 (int /*long*/[] args) {return SetDefaultString (args[0]);}
+		public int /*long*/ method8 (int /*long*/[] args) {return GetDefaultExtension (args[0]);}
+		public int /*long*/ method9 (int /*long*/[] args) {return SetDefaultExtension (args[0]);}
+		public int /*long*/ method10 (int /*long*/[] args) {return GetFilterIndex (args[0]);}
+		public int /*long*/ method11 (int /*long*/[] args) {return SetFilterIndex ((int)/*64*/args[0]);}
+		public int /*long*/ method12 (int /*long*/[] args) {return GetDisplayDirectory (args[0]);}
+		public int /*long*/ method13 (int /*long*/[] args) {return SetDisplayDirectory (args[0]);}
+		public int /*long*/ method14 (int /*long*/[] args) {return GetFile (args[0]);}
+		public int /*long*/ method15 (int /*long*/[] args) {return GetFileURL (args[0]);}
+		public int /*long*/ method16 (int /*long*/[] args) {return GetFiles (args[0]);}
+		public int /*long*/ method17 (int /*long*/[] args) {return Show (args[0]);}
+	};
+}
+
+void disposeCOMInterfaces () {
+	if (supports != null) {
+		supports.dispose ();
+		supports = null;
+	}	
+	if (filePicker != null) {
+		filePicker.dispose ();
+		filePicker = null;	
+	}
+}
+
+int /*long*/ getAddress () {
+	return filePicker.getAddress ();
+}
+
+int QueryInterface (int /*long*/ riid, int /*long*/ ppvObject) {
+	if (riid == 0 || ppvObject == 0) return XPCOM.NS_ERROR_NO_INTERFACE;
+	nsID guid = new nsID ();
+	XPCOM.memmove (guid, riid, nsID.sizeof);
+	
+	if (guid.Equals (nsISupports.NS_ISUPPORTS_IID)) {
+		XPCOM.memmove (ppvObject, new int /*long*/[] {supports.getAddress ()}, C.PTR_SIZEOF);
+		AddRef ();
+		return XPCOM.NS_OK;
+	}
+	if (guid.Equals (nsIFilePicker.NS_IFILEPICKER_IID)) {
+		XPCOM.memmove(ppvObject, new int /*long*/[] {filePicker.getAddress ()}, C.PTR_SIZEOF);
+		AddRef ();
+		return XPCOM.NS_OK;
+	}
+	if (guid.Equals (nsIFilePicker_1_8.NS_IFILEPICKER_IID)) {
+		XPCOM.memmove(ppvObject, new int /*long*/[] {filePicker.getAddress ()}, C.PTR_SIZEOF);
+		AddRef ();
+		return XPCOM.NS_OK;
+	}
+
+	XPCOM.memmove (ppvObject, new int /*long*/[] {0}, C.PTR_SIZEOF);
+	return XPCOM.NS_ERROR_NO_INTERFACE;
+}
+
+int Release () {
+	refCount--;
+	if (refCount == 0) disposeCOMInterfaces ();
+	return refCount;
+}
+
+/*
+ * As of Mozilla 1.8 some of nsIFilePicker's string arguments changed type.  This method
+ * answers a java string based on the type of string that is appropriate for the Mozilla
+ * version being used.
+ */
+String parseAString (int /*long*/ string) {
+	return null;
+}
+
+/* nsIFilePicker */
+
+int Init (int /*long*/ parent, int /*long*/ title, short mode) {
+	parentHandle = parent;
+	this.mode = mode;
+	this.title = parseAString (title);
+	return XPCOM.NS_OK;
+}
+
+int Show (int /*long*/ _retval) {
+	if (mode == nsIFilePicker.modeGetFolder) {
+		/* picking a directory */
+		int result = showDirectoryPicker ();
+		XPCOM.memmove (_retval, new short[] {(short)result}, 2); /* PRInt16 */
+		return XPCOM.NS_OK;
+	}
+
+	/* picking a file */
+	int style = mode == nsIFilePicker.modeSave ? SWT.SAVE : SWT.OPEN;
+	if (mode == nsIFilePicker.modeOpenMultiple) style |= SWT.MULTI;
+	Display display = Display.getCurrent ();
+	Shell parent = null; // TODO compute parent
+	if (parent == null) {
+		parent = new Shell (display);
+	}
+	FileDialog dialog = new FileDialog (parent, style);
+	if (title != null) dialog.setText (title);
+	if (directory != null) dialog.setFilterPath (directory);
+	if (masks != null) dialog.setFilterExtensions (masks);
+	if (defaultFilename != null) dialog.setFileName (defaultFilename);
+	String filename = dialog.open ();
+	files = dialog.getFileNames ();
+	directory = dialog.getFilterPath ();
+	title = defaultFilename = null;
+	masks = null;
+	int result = filename == null ? nsIFilePicker.returnCancel : nsIFilePicker.returnOK; 
+	XPCOM.memmove (_retval, new short[] {(short)result}, 2); /* PRInt16 */
+	return XPCOM.NS_OK;
+}
+
+int showDirectoryPicker () {
+	Display display = Display.getCurrent ();
+	Shell parent = null; // TODO compute parent
+	if (parent == null) {
+		parent = new Shell (display);
+	}
+	DirectoryDialog dialog = new DirectoryDialog (parent, SWT.NONE);
+	if (title != null) dialog.setText (title);
+	if (directory != null) dialog.setFilterPath (directory);
+	directory = dialog.open ();
+	title = defaultFilename = null;
+	files = masks = null;
+	return directory == null ? nsIFilePicker.returnCancel : nsIFilePicker.returnOK;
+}
+
+int GetFiles (int /*long*/ aFiles) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+int GetFileURL (int /*long*/ aFileURL) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+int GetFile (int /*long*/ aFile) {
+	String filename = "";	//$NON-NLS-1$
+	if (directory != null) filename += directory + SEPARATOR;
+	if (files != null && files.length > 0) filename += files[0];
+	nsEmbedString path = new nsEmbedString (filename);
+	int /*long*/[] file = new int /*long*/[1];
+	int rc = XPCOM.NS_NewLocalFile (path.getAddress (), 1, file);
+	path.dispose ();
+	if (rc != XPCOM.NS_OK) Mozilla.error (rc);
+	if (file[0] == 0) Mozilla.error (XPCOM.NS_ERROR_NULL_POINTER);
+	XPCOM.memmove (aFile, file, C.PTR_SIZEOF);
+	return XPCOM.NS_OK;
+}
+
+int SetDisplayDirectory (int /*long*/ aDisplayDirectory) {
+	if (aDisplayDirectory == 0) return XPCOM.NS_OK;
+	nsILocalFile file = new nsILocalFile (aDisplayDirectory);
+	int /*long*/ pathname = XPCOM.nsEmbedCString_new ();
+	file.GetNativePath (pathname);
+	int length = XPCOM.nsEmbedCString_Length (pathname);
+	int /*long*/ buffer = XPCOM.nsEmbedCString_get (pathname);
+	byte[] bytes = new byte[length];
+	XPCOM.memmove (bytes, buffer, length);
+	XPCOM.nsEmbedCString_delete (pathname);
+	char[] chars = MozillaDelegate.mbcsToWcs (null, bytes);
+	directory = new String (chars);
+	return XPCOM.NS_OK;
+}
+
+int GetDisplayDirectory (int /*long*/ aDisplayDirectory) {
+	String directoryName = directory != null ? directory : "";	//$NON-NLS-1$
+	nsEmbedString path = new nsEmbedString (directoryName);
+	int /*long*/[] file = new int /*long*/[1];
+	int rc = XPCOM.NS_NewLocalFile (path.getAddress (), 1, file);
+	path.dispose ();
+	if (rc != XPCOM.NS_OK) Mozilla.error (rc);
+	if (file[0] == 0) Mozilla.error (XPCOM.NS_ERROR_NULL_POINTER);
+	XPCOM.memmove (aDisplayDirectory, file, C.PTR_SIZEOF);
+	return XPCOM.NS_OK;
+}
+
+int SetFilterIndex (int aFilterIndex) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+int GetFilterIndex (int /*long*/ aFilterIndex) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+int SetDefaultExtension (int /*long*/ aDefaultExtension) {
+	/* note that the type of argument 1 changed as of Mozilla 1.8 */
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+int GetDefaultExtension (int /*long*/ aDefaultExtension) {
+	/* note that the type of argument 1 changed as of Mozilla 1.8 */
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+int SetDefaultString (int /*long*/ aDefaultString) {
+	defaultFilename = parseAString (aDefaultString);
+	return XPCOM.NS_OK;
+}
+
+int GetDefaultString (int /*long*/ aDefaultString) {
+	/* note that the type of argument 1 changed as of Mozilla 1.8 */
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+int AppendFilter (int /*long*/ title, int /*long*/ filter) {
+	/* note that the type of arguments 1 and 2 changed as of Mozilla 1.8 */
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+int AppendFilters (int filterMask) {
+	String[] addFilters = null;
+	switch (filterMask) {
+		case nsIFilePicker.filterAll:
+		case nsIFilePicker.filterApps:
+			masks = null;			/* this is equivalent to no filter */
+			break;
+		case nsIFilePicker.filterHTML:
+			addFilters = new String[] {"*.htm;*.html"}; //$NON-NLS-1$
+			break;
+		case nsIFilePicker.filterImages:
+			addFilters = new String[] {"*.gif;*.jpeg;*.jpg;*.png"};	//$NON-NLS-1$
+			break;
+		case nsIFilePicker.filterText:
+			addFilters = new String[] {"*.txt"};	//$NON-NLS-1$
+			break;
+		case nsIFilePicker.filterXML:
+			addFilters = new String[] {"*.xml"};	//$NON-NLS-1$
+			break;
+		case nsIFilePicker.filterXUL:
+			addFilters = new String[] {"*.xul"};	//$NON-NLS-1$
+			break;
+	}
+	if (masks == null) {
+		masks = addFilters;
+	} else {
+		if (addFilters != null) {
+			String[] newFilters = new String[masks.length + addFilters.length];
+			System.arraycopy (masks, 0, newFilters, 0, masks.length);
+			System.arraycopy (addFilters, 0, newFilters, masks.length, addFilters.length);
+			masks = newFilters;
+		}
+	}
+	return XPCOM.NS_OK;
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/browser/FilePickerFactory.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/browser/FilePickerFactory.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/browser/FilePickerFactory.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,100 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.browser;
+
+import org.eclipse.swt.internal.C;
+import org.eclipse.swt.internal.mozilla.*;
+
+class FilePickerFactory {
+	XPCOMObject supports;
+	XPCOMObject factory;
+	int refCount = 0;
+
+FilePickerFactory () {
+	createCOMInterfaces ();
+}
+
+int AddRef () {
+	refCount++;
+	return refCount;
+}
+
+void createCOMInterfaces () {
+	/* Create each of the interfaces that this object implements */
+	supports = new XPCOMObject (new int[] {2, 0, 0}) {
+		public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+		public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+		public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+	};
+	
+	factory = new XPCOMObject (new int[] {2, 0, 0, 3, 1}) {
+		public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+		public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+		public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+		public int /*long*/ method3 (int /*long*/[] args) {return CreateInstance (args[0], args[1], args[2]);}
+		public int /*long*/ method4 (int /*long*/[] args) {return LockFactory ((int)/*64*/args[0]);}
+	};
+}
+
+void disposeCOMInterfaces () {
+	if (supports != null) {
+		supports.dispose ();
+		supports = null;
+	}	
+	if (factory != null) {
+		factory.dispose ();
+		factory = null;	
+	}
+}
+
+int /*long*/ getAddress () {
+	return factory.getAddress ();
+}
+
+int QueryInterface (int /*long*/ riid, int /*long*/ ppvObject) {
+	if (riid == 0 || ppvObject == 0) return XPCOM.NS_ERROR_NO_INTERFACE;
+	nsID guid = new nsID ();
+	XPCOM.memmove (guid, riid, nsID.sizeof);
+	
+	if (guid.Equals (nsISupports.NS_ISUPPORTS_IID)) {
+		XPCOM.memmove (ppvObject, new int /*long*/[] {supports.getAddress ()}, C.PTR_SIZEOF);
+		AddRef ();
+		return XPCOM.NS_OK;
+	}
+	if (guid.Equals (nsIFactory.NS_IFACTORY_IID)) {
+		XPCOM.memmove (ppvObject, new int /*long*/[] {factory.getAddress ()}, C.PTR_SIZEOF);
+		AddRef ();
+		return XPCOM.NS_OK;
+	}
+	
+	XPCOM.memmove (ppvObject, new int /*long*/[] {0}, C.PTR_SIZEOF);
+	return XPCOM.NS_ERROR_NO_INTERFACE;
+}
+
+int Release () {
+	refCount--;
+	if (refCount == 0) disposeCOMInterfaces ();
+	return refCount;
+}
+	
+/* nsIFactory */
+
+int CreateInstance (int /*long*/ aOuter, int /*long*/ iid, int /*long*/ result) {
+	FilePicker picker = new FilePicker ();
+	picker.AddRef ();
+	XPCOM.memmove (result, new int /*long*/[] {picker.getAddress ()}, C.PTR_SIZEOF);
+	return XPCOM.NS_OK;
+}
+
+int LockFactory (int lock) {
+	return XPCOM.NS_OK;
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/browser/FilePickerFactory_1_8.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/browser/FilePickerFactory_1_8.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/browser/FilePickerFactory_1_8.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.browser;
+
+import org.eclipse.swt.internal.C;
+import org.eclipse.swt.internal.mozilla.*;
+
+class FilePickerFactory_1_8 extends FilePickerFactory {
+
+void createCOMInterfaces () {
+	/* Create each of the interfaces that this object implements */
+	supports = new XPCOMObject (new int[] {2, 0, 0}) {
+		public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+		public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+		public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+	};
+	
+	factory = new XPCOMObject (new int[] {2, 0, 0, 3, 1}) {
+		public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+		public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+		public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+		public int /*long*/ method3 (int /*long*/[] args) {return CreateInstance (args[0], args[1], args[2]);}
+		public int /*long*/ method4 (int /*long*/[] args) {return LockFactory ((int)/*64*/args[0]);}
+	};
+}
+
+/* nsIFactory */
+
+int CreateInstance (int /*long*/ aOuter, int /*long*/ iid, int /*long*/ result) {
+	FilePicker_1_8 picker = new FilePicker_1_8 ();
+	picker.AddRef ();
+	XPCOM.memmove (result, new int /*long*/[] {picker.getAddress ()}, C.PTR_SIZEOF);
+	return XPCOM.NS_OK;
+}
+
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/browser/FilePicker_1_8.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/browser/FilePicker_1_8.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/browser/FilePicker_1_8.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.browser;
+
+import org.eclipse.swt.internal.mozilla.*;
+
+class FilePicker_1_8 extends FilePicker {
+
+void createCOMInterfaces () {
+	/* Create each of the interfaces that this object implements */
+	supports = new XPCOMObject (new int[] {2, 0, 0}) {
+		public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+		public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+		public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+	};
+
+	filePicker = new XPCOMObject (new int[] {2, 0, 0, 3, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}) {
+		public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+		public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+		public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+		public int /*long*/ method3 (int /*long*/[] args) {return Init (args[0], args[1], (short)args[2]);}
+		public int /*long*/ method4 (int /*long*/[] args) {return AppendFilters ((int)/*64*/args[0]);}
+		public int /*long*/ method5 (int /*long*/[] args) {return AppendFilter (args[0], args[1]);}
+		public int /*long*/ method6 (int /*long*/[] args) {return GetDefaultString (args[0]);}
+		public int /*long*/ method7 (int /*long*/[] args) {return SetDefaultString (args[0]);}
+		public int /*long*/ method8 (int /*long*/[] args) {return GetDefaultExtension (args[0]);}
+		public int /*long*/ method9 (int /*long*/[] args) {return SetDefaultExtension (args[0]);}
+		public int /*long*/ method10 (int /*long*/[] args) {return GetFilterIndex (args[0]);}
+		public int /*long*/ method11 (int /*long*/[] args) {return SetFilterIndex ((int)/*64*/args[0]);}
+		public int /*long*/ method12 (int /*long*/[] args) {return GetDisplayDirectory (args[0]);}
+		public int /*long*/ method13 (int /*long*/[] args) {return SetDisplayDirectory (args[0]);}
+		public int /*long*/ method14 (int /*long*/[] args) {return GetFile (args[0]);}
+		public int /*long*/ method15 (int /*long*/[] args) {return GetFileURL (args[0]);}
+		public int /*long*/ method16 (int /*long*/[] args) {return GetFiles (args[0]);}
+		public int /*long*/ method17 (int /*long*/[] args) {return Show (args[0]);}
+	};
+}
+
+/*
+ * As of Mozilla 1.8 some of nsIFilePicker's string arguments changed type.  This method
+ * answers a java string based on the type of string that is appropriate for the Mozilla
+ * version being used.
+ */
+String parseAString (int /*long*/ string) {
+	if (string == 0) return null;
+	int length = XPCOM.nsEmbedString_Length (string);
+	int /*long*/ buffer = XPCOM.nsEmbedString_get (string);
+	char[] chars = new char[length];
+	XPCOM.memmove (chars, buffer, length * 2);
+	return new String (chars);
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/browser/HelperAppLauncherDialog.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/browser/HelperAppLauncherDialog.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/browser/HelperAppLauncherDialog.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,208 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.browser;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.C;
+import org.eclipse.swt.internal.mozilla.*;
+import org.eclipse.swt.widgets.*;
+
+/**
+ * This class implements the HelperAppLauncherDialog interface for mozilla
+ * versions 1.4 - 1.8.x.  For mozilla versions >= 1.9 this interface is
+ * implemented by class HelperAppLauncherDialog_1_9.  HelperAppLauncherDialogFactory
+ * determines at runtime which of these classes to instantiate. 
+ */
+class HelperAppLauncherDialog {
+	XPCOMObject supports;
+	XPCOMObject helperAppLauncherDialog;
+	int refCount = 0;
+
+HelperAppLauncherDialog () {
+	createCOMInterfaces ();
+}
+
+int AddRef () {
+	refCount++;
+	return refCount;
+}
+
+void createCOMInterfaces () {
+	/* Create each of the interfaces that this object implements */
+	supports = new XPCOMObject (new int[] {2, 0, 0}) {
+		public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+		public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+		public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+	};
+	
+	helperAppLauncherDialog = new XPCOMObject (new int[] {2, 0, 0, 3, 5}) {
+		public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+		public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+		public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+		public int /*long*/ method3 (int /*long*/[] args) {return Show (args[0], args[1], (int)/*64*/args[2]);}
+		public int /*long*/ method4 (int /*long*/[] args) {return PromptForSaveToFile (args[0], args[1], args[2], args[3], args[4]);}
+	};		
+}
+
+void disposeCOMInterfaces () {
+	if (supports != null) {
+		supports.dispose ();
+		supports = null;
+	}	
+	if (helperAppLauncherDialog != null) {
+		helperAppLauncherDialog.dispose ();
+		helperAppLauncherDialog = null;	
+	}
+}
+
+int /*long*/ getAddress () {
+	return helperAppLauncherDialog.getAddress ();
+}
+
+int QueryInterface (int /*long*/ riid, int /*long*/ ppvObject) {
+	if (riid == 0 || ppvObject == 0) return XPCOM.NS_ERROR_NO_INTERFACE;
+	nsID guid = new nsID ();
+	XPCOM.memmove (guid, riid, nsID.sizeof);
+	
+	if (guid.Equals (nsISupports.NS_ISUPPORTS_IID)) {
+		XPCOM.memmove (ppvObject, new int /*long*/[] {supports.getAddress ()}, C.PTR_SIZEOF);
+		AddRef ();
+		return XPCOM.NS_OK;
+	}
+	if (guid.Equals (nsIHelperAppLauncherDialog.NS_IHELPERAPPLAUNCHERDIALOG_IID)) {
+		XPCOM.memmove (ppvObject, new int /*long*/[] {helperAppLauncherDialog.getAddress ()}, C.PTR_SIZEOF);
+		AddRef ();
+		return XPCOM.NS_OK;
+	}
+	
+	XPCOM.memmove (ppvObject, new int /*long*/[] {0}, C.PTR_SIZEOF);
+	return XPCOM.NS_ERROR_NO_INTERFACE;
+}
+        	
+int Release () {
+	refCount--;
+	/*
+	* Note.  This instance lives as long as the download it is binded to.
+	* Its reference count is expected to go down to 0 when the download
+	* has completed or when it has been cancelled. E.g. when the user
+	* cancels the File Dialog, cancels or closes the Download Dialog
+	* and when the Download Dialog goes away after the download is completed.
+	*/
+	if (refCount == 0) disposeCOMInterfaces ();
+	return refCount;
+}
+
+/* nsIHelperAppLauncherDialog */
+
+int Show (int /*long*/ aLauncher, int /*long*/ aContext, int aReason) {
+	/*
+	 * The interface for nsIHelperAppLauncher changed as of mozilla 1.8.  Query the received
+	 * nsIHelperAppLauncher for the new interface, and if it is not found then fall back to
+	 * the old interface. 
+	 */
+	nsISupports supports = new nsISupports (aLauncher);
+	int /*long*/[] result = new int /*long*/[1];
+	int rc = supports.QueryInterface (nsIHelperAppLauncher_1_8.NS_IHELPERAPPLAUNCHER_IID, result);
+	if (rc == XPCOM.NS_OK) {	/* >= 1.8 */
+		nsIHelperAppLauncher_1_8 helperAppLauncher = new nsIHelperAppLauncher_1_8 (aLauncher);
+		rc = helperAppLauncher.SaveToDisk (0, 0);
+		helperAppLauncher.Release ();
+		return rc;
+	}
+	nsIHelperAppLauncher helperAppLauncher = new nsIHelperAppLauncher (aLauncher);	/* < 1.8 */
+	return helperAppLauncher.SaveToDisk (0, 0);
+}
+
+int PromptForSaveToFile (int /*long*/ arg0, int /*long*/ arg1, int /*long*/ arg2, int /*long*/ arg3, int /*long*/ arg4) {
+	int /*long*/ aDefaultFile, aSuggestedFileExtension, _retval;
+	boolean hasLauncher = false;
+
+	/*
+	* The interface for nsIHelperAppLauncherDialog changed as of mozilla 1.5 when an
+	* extra argument was added to the PromptForSaveToFile method (this resulted in all
+	* subsequent arguments shifting right).  The workaround is to provide an XPCOMObject 
+	* that fits the newer API, and to use the first argument's type to infer whether
+	* the old or new nsIHelperAppLauncherDialog interface is being used (and by extension
+	* the ordering of the arguments).  In mozilla >= 1.5 the first argument is an
+	* nsIHelperAppLauncher. 
+	*/
+	/*
+	 * The interface for nsIHelperAppLauncher changed as of mozilla 1.8, so the first
+	 * argument must be queried for both the old and new nsIHelperAppLauncher interfaces. 
+	 */
+ 	boolean using_1_8 = false;
+	nsISupports support = new nsISupports (arg0);
+	int /*long*/[] result = new int /*long*/[1];
+	int rc = support.QueryInterface (nsIHelperAppLauncher_1_8.NS_IHELPERAPPLAUNCHER_IID, result);
+	if (rc == XPCOM.NS_OK) {
+		using_1_8 = true;
+		hasLauncher = true;
+		new nsISupports (result[0]).Release ();
+	} else {
+		result[0] = 0;
+		rc = support.QueryInterface (nsIHelperAppLauncher.NS_IHELPERAPPLAUNCHER_IID, result);
+		if (rc == XPCOM.NS_OK) {
+			hasLauncher = true;
+			new nsISupports (result[0]).Release ();
+		}
+	}
+	result[0] = 0;
+
+	if (hasLauncher) {	/* >= 1.5 */
+		aDefaultFile = arg2;
+		aSuggestedFileExtension = arg3;
+		_retval = arg4;
+	} else {			/* 1.4 */
+		aDefaultFile = arg1;
+		aSuggestedFileExtension = arg2;
+		_retval = arg3;
+	}
+
+	int length = XPCOM.strlen_PRUnichar (aDefaultFile);
+	char[] dest = new char[length];
+	XPCOM.memmove (dest, aDefaultFile, length * 2);
+	String defaultFile = new String (dest);
+
+	length = XPCOM.strlen_PRUnichar (aSuggestedFileExtension);
+	dest = new char[length];
+	XPCOM.memmove (dest, aSuggestedFileExtension, length * 2);
+	String suggestedFileExtension = new String (dest);
+
+	Shell shell = new Shell ();
+	FileDialog fileDialog = new FileDialog (shell, SWT.SAVE);
+	fileDialog.setFileName (defaultFile);
+	fileDialog.setFilterExtensions (new String[] {suggestedFileExtension});
+	String name = fileDialog.open ();
+	shell.close ();
+	if (name == null) {
+		if (hasLauncher) {
+			if (using_1_8) {
+				nsIHelperAppLauncher_1_8 launcher = new nsIHelperAppLauncher_1_8 (arg0);
+				rc = launcher.Cancel (XPCOM.NS_BINDING_ABORTED);
+			} else {
+				nsIHelperAppLauncher launcher = new nsIHelperAppLauncher (arg0);
+				rc = launcher.Cancel ();
+			}
+			if (rc != XPCOM.NS_OK) Mozilla.error (rc);
+			return XPCOM.NS_OK;
+		}
+		return XPCOM.NS_ERROR_FAILURE;
+	}
+	nsEmbedString path = new nsEmbedString (name);
+	rc = XPCOM.NS_NewLocalFile (path.getAddress (), 1, result);
+	path.dispose ();
+	if (rc != XPCOM.NS_OK) Mozilla.error (rc);
+	if (result[0] == 0) Mozilla.error (XPCOM.NS_ERROR_NULL_POINTER);
+	/* Our own nsIDownload has been registered during the Browser initialization. It will be invoked by Mozilla. */
+	XPCOM.memmove (_retval, result, C.PTR_SIZEOF);	
+	return XPCOM.NS_OK;
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/browser/HelperAppLauncherDialogFactory.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/browser/HelperAppLauncherDialogFactory.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/browser/HelperAppLauncherDialogFactory.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,107 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.browser;
+
+import org.eclipse.swt.internal.C;
+import org.eclipse.swt.internal.mozilla.*;
+
+class HelperAppLauncherDialogFactory {
+	XPCOMObject supports;
+	XPCOMObject factory;
+	int refCount = 0;
+	boolean isPre_1_9 = true;
+
+HelperAppLauncherDialogFactory () {
+	createCOMInterfaces ();
+}
+
+int AddRef () {
+	refCount++;
+	return refCount;
+}
+
+void createCOMInterfaces () {
+	/* Create each of the interfaces that this object implements */
+	supports = new XPCOMObject (new int[] {2, 0, 0}) {
+		public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+		public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+		public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+	};
+	
+	factory = new XPCOMObject (new int[] {2, 0, 0, 3, 1}) {
+		public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+		public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+		public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+		public int /*long*/ method3 (int /*long*/[] args) {return CreateInstance (args[0], args[1], args[2]);}
+		public int /*long*/ method4 (int /*long*/[] args) {return LockFactory ((int)/*64*/args[0]);}
+	};
+}
+
+void disposeCOMInterfaces () {
+	if (supports != null) {
+		supports.dispose ();
+		supports = null;
+	}	
+	if (factory != null) {
+		factory.dispose ();
+		factory = null;	
+	}
+}
+
+int /*long*/ getAddress () {
+	return factory.getAddress ();
+}
+
+int QueryInterface (int /*long*/ riid, int /*long*/ ppvObject) {
+	if (riid == 0 || ppvObject == 0) return XPCOM.NS_ERROR_NO_INTERFACE;
+	nsID guid = new nsID ();
+	XPCOM.memmove (guid, riid, nsID.sizeof);
+	
+	if (guid.Equals (nsISupports.NS_ISUPPORTS_IID)) {
+		XPCOM.memmove (ppvObject, new int /*long*/[] {supports.getAddress ()}, C.PTR_SIZEOF);
+		AddRef ();
+		return XPCOM.NS_OK;
+	}
+	if (guid.Equals (nsIFactory.NS_IFACTORY_IID)) {
+		XPCOM.memmove (ppvObject, new int /*long*/[] {factory.getAddress ()}, C.PTR_SIZEOF);
+		AddRef ();
+		return XPCOM.NS_OK;
+	}
+	
+	XPCOM.memmove (ppvObject, new int /*long*/[] {0}, C.PTR_SIZEOF);
+	return XPCOM.NS_ERROR_NO_INTERFACE;
+}
+        	
+int Release () {
+	refCount--;
+	if (refCount == 0) disposeCOMInterfaces ();
+	return refCount;
+}
+	
+/* nsIFactory */
+
+int CreateInstance (int /*long*/ aOuter, int /*long*/ iid, int /*long*/ result) {
+	if (isPre_1_9) {
+		HelperAppLauncherDialog helperAppLauncherDialog = new HelperAppLauncherDialog ();
+		helperAppLauncherDialog.AddRef ();
+		XPCOM.memmove (result, new int /*long*/[] {helperAppLauncherDialog.getAddress ()}, C.PTR_SIZEOF);
+	} else {
+		HelperAppLauncherDialog_1_9 helperAppLauncherDialog = new HelperAppLauncherDialog_1_9 ();
+		helperAppLauncherDialog.AddRef ();
+		XPCOM.memmove (result, new int /*long*/[] {helperAppLauncherDialog.getAddress ()}, C.PTR_SIZEOF);
+	}
+	return XPCOM.NS_OK;
+}
+
+int LockFactory (int lock) {
+	return XPCOM.NS_OK;
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/browser/HelperAppLauncherDialog_1_9.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/browser/HelperAppLauncherDialog_1_9.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/browser/HelperAppLauncherDialog_1_9.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,137 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.browser;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.C;
+import org.eclipse.swt.internal.mozilla.*;
+import org.eclipse.swt.widgets.*;
+
+class HelperAppLauncherDialog_1_9 {
+	XPCOMObject supports;
+	XPCOMObject helperAppLauncherDialog;
+	int refCount = 0;
+
+HelperAppLauncherDialog_1_9 () {
+	createCOMInterfaces ();
+}
+
+int AddRef () {
+	refCount++;
+	return refCount;
+}
+
+void createCOMInterfaces () {
+	/* Create each of the interfaces that this object implements */
+	supports = new XPCOMObject (new int[] {2, 0, 0}) {
+		public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+		public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+		public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+	};
+	
+	helperAppLauncherDialog = new XPCOMObject (new int[] {2, 0, 0, 3, 6}) {
+		public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+		public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+		public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+		public int /*long*/ method3 (int /*long*/[] args) {return Show (args[0], args[1], (int)/*64*/args[2]);}
+		public int /*long*/ method4 (int /*long*/[] args) {return PromptForSaveToFile (args[0], args[1], args[2], args[3], (int)/*64*/args[4], args[5]);}
+	};		
+}
+
+void disposeCOMInterfaces () {
+	if (supports != null) {
+		supports.dispose ();
+		supports = null;
+	}	
+	if (helperAppLauncherDialog != null) {
+		helperAppLauncherDialog.dispose ();
+		helperAppLauncherDialog = null;	
+	}
+}
+
+int /*long*/ getAddress () {
+	return helperAppLauncherDialog.getAddress ();
+}
+
+int QueryInterface (int /*long*/ riid, int /*long*/ ppvObject) {
+	if (riid == 0 || ppvObject == 0) return XPCOM.NS_ERROR_NO_INTERFACE;
+	nsID guid = new nsID ();
+	XPCOM.memmove (guid, riid, nsID.sizeof);
+
+	if (guid.Equals (nsISupports.NS_ISUPPORTS_IID)) {
+		XPCOM.memmove (ppvObject, new int /*long*/[] {supports.getAddress ()}, C.PTR_SIZEOF);
+		AddRef ();
+		return XPCOM.NS_OK;
+	}
+	if (guid.Equals (nsIHelperAppLauncherDialog_1_9.NS_IHELPERAPPLAUNCHERDIALOG_IID)) {
+		XPCOM.memmove (ppvObject, new int /*long*/[] {helperAppLauncherDialog.getAddress ()}, C.PTR_SIZEOF);
+		AddRef ();
+		return XPCOM.NS_OK;
+	}
+
+	XPCOM.memmove (ppvObject, new int /*long*/[] {0}, C.PTR_SIZEOF);
+	return XPCOM.NS_ERROR_NO_INTERFACE;
+}
+        	
+int Release () {
+	refCount--;
+	/*
+	* Note.  This instance lives as long as the download it is bound to.
+	* Its reference count is expected to go down to 0 when the download
+	* has completed or when it has been cancelled. E.g. when the user
+	* cancels the File Dialog, cancels or closes the Download Dialog
+	* and when the Download Dialog goes away after the download is completed.
+	*/
+	if (refCount == 0) disposeCOMInterfaces ();
+	return refCount;
+}
+
+/* nsIHelperAppLauncherDialog */
+
+int Show (int /*long*/ aLauncher, int /*long*/ aContext, int aReason) {
+	nsIHelperAppLauncher_1_9 helperAppLauncher = new nsIHelperAppLauncher_1_9 (aLauncher);
+	return helperAppLauncher.SaveToDisk (0, 0);
+}
+
+int PromptForSaveToFile (int /*long*/ aLauncher, int /*long*/ aWindowContext, int /*long*/ aDefaultFileName, int /*long*/ aSuggestedFileExtension, int aForcePrompt, int /*long*/ _retval) {
+	int length = XPCOM.strlen_PRUnichar (aDefaultFileName);
+	char[] dest = new char[length];
+	XPCOM.memmove (dest, aDefaultFileName, length * 2);
+	String defaultFile = new String (dest);
+
+	length = XPCOM.strlen_PRUnichar (aSuggestedFileExtension);
+	dest = new char[length];
+	XPCOM.memmove (dest, aSuggestedFileExtension, length * 2);
+	String suggestedFileExtension = new String (dest);
+
+	Shell shell = new Shell ();
+	FileDialog fileDialog = new FileDialog (shell, SWT.SAVE);
+	fileDialog.setFileName (defaultFile);
+	fileDialog.setFilterExtensions (new String[] {suggestedFileExtension});
+	String name = fileDialog.open ();
+	shell.close ();
+	if (name == null) {
+		nsIHelperAppLauncher_1_9 launcher = new nsIHelperAppLauncher_1_9 (aLauncher);
+		int rc = launcher.Cancel (XPCOM.NS_BINDING_ABORTED);
+		if (rc != XPCOM.NS_OK) Mozilla.error (rc);
+		return XPCOM.NS_ERROR_FAILURE;
+	}
+	nsEmbedString path = new nsEmbedString (name);
+	int /*long*/[] result = new int /*long*/[1];
+	int rc = XPCOM.NS_NewLocalFile (path.getAddress (), 1, result);
+	path.dispose ();
+	if (rc != XPCOM.NS_OK) Mozilla.error (rc);
+	if (result[0] == 0) Mozilla.error (XPCOM.NS_ERROR_NULL_POINTER);
+	/* Our own nsIDownload has been registered during the Browser initialization. It will be invoked by Mozilla. */
+	XPCOM.memmove (_retval, result, C.PTR_SIZEOF);	
+	return XPCOM.NS_OK;
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/browser/InputStream.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/browser/InputStream.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/browser/InputStream.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,129 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.browser;
+
+import org.eclipse.swt.internal.C;
+import org.eclipse.swt.internal.mozilla.*;
+
+class InputStream {
+	XPCOMObject inputStream;
+	int refCount = 0;
+
+	byte[] buffer;
+	int index = 0;
+	
+InputStream (byte[] buffer) {
+	this.buffer = buffer;
+	index = 0;
+	createCOMInterfaces ();
+}
+
+int AddRef () {
+	refCount++;
+	return refCount;
+}
+
+void createCOMInterfaces () {
+	/* Create each of the interfaces that this object implements */
+	inputStream = new XPCOMObject (new int[] {2, 0, 0, 0, 1, 3, 4, 1}) {
+		public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+		public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+		public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+		public int /*long*/ method3 (int /*long*/[] args) {return Close ();}
+		public int /*long*/ method4 (int /*long*/[] args) {return Available (args[0]);}
+		public int /*long*/ method5 (int /*long*/[] args) {return Read (args[0], (int)/*64*/args[1], args[2]);}
+		public int /*long*/ method6 (int /*long*/[] args) {return ReadSegments (args[0], args[1], (int)/*64*/args[2], args[3]);}
+		public int /*long*/ method7 (int /*long*/[] args) {return IsNonBlocking (args[0]);}
+	};
+}
+
+void disposeCOMInterfaces () {
+	if (inputStream != null) {
+		inputStream.dispose ();
+		inputStream = null;	
+	}
+}
+
+int /*long*/ getAddress () {
+	return inputStream.getAddress ();
+}
+
+int QueryInterface (int /*long*/ riid, int /*long*/ ppvObject) {
+	if (riid == 0 || ppvObject == 0) return XPCOM.NS_ERROR_NO_INTERFACE;
+	nsID guid = new nsID ();
+	XPCOM.memmove (guid, riid, nsID.sizeof);
+	
+	if (guid.Equals (nsISupports.NS_ISUPPORTS_IID)) {
+		XPCOM.memmove (ppvObject, new int /*long*/[] {inputStream.getAddress ()}, C.PTR_SIZEOF);
+		AddRef ();
+		return XPCOM.NS_OK;
+	}
+	if (guid.Equals (nsIInputStream.NS_IINPUTSTREAM_IID)) {
+		XPCOM.memmove (ppvObject, new int /*long*/[] {inputStream.getAddress ()}, C.PTR_SIZEOF);
+		AddRef ();
+		return XPCOM.NS_OK;
+	}	
+	XPCOM.memmove (ppvObject, new int /*long*/[] {0}, C.PTR_SIZEOF);
+	return XPCOM.NS_ERROR_NO_INTERFACE;
+}
+        	
+int Release () {
+	refCount--;
+	if (refCount == 0) disposeCOMInterfaces ();
+	return refCount;
+}
+	
+/* nsIInputStream implementation */
+
+int Close () {
+	buffer = null;
+	index = 0;
+	return XPCOM.NS_OK;
+}
+
+int Available (int /*long*/ _retval) {
+	int available = buffer == null ? 0 : buffer.length - index;
+	XPCOM.memmove (_retval, new int[] {available}, 4);
+	return XPCOM.NS_OK;
+}
+
+int Read(int /*long*/ aBuf, int aCount, int /*long*/ _retval) {
+	int max = Math.min (aCount, buffer == null ? 0 : buffer.length - index);
+	if (max > 0) {
+		byte[] src = new byte[max];
+		System.arraycopy (buffer, index, src, 0, max);
+		XPCOM.memmove (aBuf, src, max);
+		index += max;
+	}
+	XPCOM.memmove(_retval, new int[] {max}, 4);
+	return XPCOM.NS_OK;
+}
+
+int ReadSegments (int /*long*/ aWriter, int /*long*/ aClosure, int aCount, int /*long*/ _retval) {
+	int max = Math.min (aCount, buffer == null ? 0 : buffer.length - index);
+	int cnt = max;
+	while (cnt > 0) {
+		int[] aWriteCount = new int[1];
+		int /*long*/ rc = XPCOM.Call (aWriter, getAddress (), aClosure, buffer, index, cnt, aWriteCount);
+		if (rc != XPCOM.NS_OK) break;
+		index += aWriteCount[0];
+		cnt -= aWriteCount[0];
+	}
+	XPCOM.memmove (_retval, new int[] {max - cnt}, 4);
+	return XPCOM.NS_OK;
+}
+
+int IsNonBlocking (int /*long*/ _retval) {
+	/* blocking */
+	XPCOM.memmove (_retval, new int[] {0}, 4);
+	return XPCOM.NS_OK;
+}		
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/browser/LocationAdapter.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/browser/LocationAdapter.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/browser/LocationAdapter.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.browser;
+
+/**
+ * This adapter class provides default implementations for the
+ * methods described by the {@link LocationListener} interface.
+ * <p>
+ * Classes that wish to deal with {@link LocationEvent}'s can
+ * extend this class and override only the methods which they are
+ * interested in.
+ * </p>
+ * 
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ *
+ * @since 3.0
+ */
+public abstract class LocationAdapter implements LocationListener {
+
+public void changing(LocationEvent event) {
+}
+
+public void changed(LocationEvent event) {
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/browser/LocationEvent.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/browser/LocationEvent.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/browser/LocationEvent.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.browser;
+
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.events.*;
+
+/**
+ * A <code>LocationEvent</code> is sent by a {@link Browser} to
+ * {@link LocationListener}'s when the <code>Browser</code>
+ * navigates to a different URL. This notification typically 
+ * occurs when the application navigates to a new location with 
+ * {@link Browser#setUrl(String)} or when the user activates a
+ * hyperlink.
+ * 
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ *
+ * @since 3.0
+ */
+public class LocationEvent extends TypedEvent {
+	/** current location */
+	public String location;
+	
+	/**
+	 * A flag indicating whether the location opens in the top frame
+	 * or not.
+	 */
+	public boolean top;
+	
+	/**
+	 * A flag indicating whether the location loading should be allowed.
+	 * Setting this field to <code>false</code> will cancel the operation.
+	 */
+	public boolean doit;
+
+	static final long serialVersionUID = 3906644198244299574L;
+	
+LocationEvent(Widget w) {
+	super(w);
+}
+
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the event
+ */
+public String toString() {
+	String string = super.toString ();
+	return string.substring (0, string.length() - 1) // remove trailing '}'
+		+ " location=" + location
+		+ " top=" + top
+		+ " doit=" + doit
+		+ "}";
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/browser/LocationListener.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/browser/LocationListener.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/browser/LocationListener.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.browser;
+
+import org.eclipse.swt.internal.SWTEventListener;
+
+/**
+ * This listener interface may be implemented in order to receive
+ * a {@link LocationEvent} notification when a {@link Browser}
+ * navigates to a different URL.
+ * 
+ * @see Browser#addLocationListener(LocationListener)
+ * @see Browser#removeLocationListener(LocationListener)
+ * 
+ * @since 3.0
+ */
+public interface LocationListener extends SWTEventListener {
+
+/**
+ * This method is called when the current location is about to be changed.
+ * <p>
+ *
+ * <p>The following fields in the <code>LocationEvent</code> apply:
+ * <ul>
+ * <li>(in) location the location to be loaded
+ * <li>(in) widget the <code>Browser</code> whose location is changing
+ * <li>(in/out) doit can be set to <code>false</code> to prevent the location
+ * from being loaded 
+ * </ul>
+ * 
+ * @param event the <code>LocationEvent</code> that specifies the location
+ * to be loaded by a <code>Browser</code>
+ * 
+ * @since 3.0
+ */ 
+public void changing(LocationEvent event);
+
+/**
+ * This method is called when the current location is changed.
+ * <p>
+ *
+ * <p>The following fields in the <code>LocationEvent</code> apply:
+ * <ul>
+ * <li>(in) location the current location
+ * <li>(in) top <code>true</code> if the location opens in the top frame or
+ * <code>false</code> otherwise
+ * <li>(in) widget the <code>Browser</code> whose location has changed
+ * </ul>
+ * 
+ * @param event the <code>LocationEvent</code> that specifies  the new
+ * location of a <code>Browser</code>
+ * 
+ * @since 3.0
+ */ 
+public void changed(LocationEvent event);
+
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/browser/Mozilla.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/browser/Mozilla.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/browser/Mozilla.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,3223 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.browser;
+
+import java.io.*;
+import java.lang.reflect.*;
+import java.util.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.mozilla.*;
+import org.eclipse.swt.layout.*;
+
+class Mozilla extends WebBrowser {
+	int /*long*/ embedHandle;
+	nsIWebBrowser webBrowser;
+	Object webBrowserObject;
+	MozillaDelegate delegate;
+
+	/* Interfaces for this Mozilla embedding notification */
+	XPCOMObject supports;
+	XPCOMObject weakReference;
+	XPCOMObject webProgressListener;
+	XPCOMObject	webBrowserChrome;
+	XPCOMObject webBrowserChromeFocus;
+	XPCOMObject embeddingSiteWindow;
+	XPCOMObject interfaceRequestor;
+	XPCOMObject supportsWeakReference;
+	XPCOMObject contextMenuListener;	
+	XPCOMObject uriContentListener;
+	XPCOMObject tooltipListener;
+	XPCOMObject domEventListener;
+	int chromeFlags = nsIWebBrowserChrome.CHROME_DEFAULT;
+	int refCount, lastKeyCode, lastCharCode;
+	int /*long*/ request;
+	Point location, size;
+	boolean visible, isChild, ignoreDispose, awaitingNavigate;
+	Shell tip = null;
+	Listener listener;
+	Vector unhookedDOMWindows = new Vector ();
+
+	static nsIAppShell AppShell;
+	static AppFileLocProvider LocationProvider;
+	static WindowCreator2 WindowCreator;
+	static int BrowserCount;
+	static boolean Initialized, IsPre_1_8, PerformedVersionCheck, XPCOMWasGlued, XPCOMInitWasGlued;
+
+	/* XULRunner detect constants */
+	static final String GRERANGE_LOWER = "1.8.1.2"; //$NON-NLS-1$
+	static final String GRERANGE_LOWER_FALLBACK = "1.8"; //$NON-NLS-1$
+	static final boolean LowerRangeInclusive = true;
+	static final String GRERANGE_UPPER = "1.9.*"; //$NON-NLS-1$
+	static final boolean UpperRangeInclusive = true;
+
+	static final int MAX_PORT = 65535;
+	static final String SEPARATOR_OS = System.getProperty ("file.separator"); //$NON-NLS-1$
+	static final String ABOUT_BLANK = "about:blank"; //$NON-NLS-1$
+	static final String DISPOSE_LISTENER_HOOKED = "org.eclipse.swt.browser.Mozilla.disposeListenerHooked"; //$NON-NLS-1$
+	static final String PREFIX_JAVASCRIPT = "javascript:"; //$NON-NLS-1$
+	static final String PREFERENCE_CHARSET = "intl.charset.default"; //$NON-NLS-1$
+	static final String PREFERENCE_DISABLEOPENDURINGLOAD = "dom.disable_open_during_load"; //$NON-NLS-1$
+	static final String PREFERENCE_DISABLEWINDOWSTATUSCHANGE = "dom.disable_window_status_change"; //$NON-NLS-1$
+	static final String PREFERENCE_LANGUAGES = "intl.accept_languages"; //$NON-NLS-1$
+	static final String PREFERENCE_PROXYHOST_FTP = "network.proxy.ftp"; //$NON-NLS-1$
+	static final String PREFERENCE_PROXYPORT_FTP = "network.proxy.ftp_port"; //$NON-NLS-1$
+	static final String PREFERENCE_PROXYHOST_HTTP = "network.proxy.http"; //$NON-NLS-1$
+	static final String PREFERENCE_PROXYPORT_HTTP = "network.proxy.http_port"; //$NON-NLS-1$
+	static final String PREFERENCE_PROXYHOST_SSL = "network.proxy.ssl"; //$NON-NLS-1$
+	static final String PREFERENCE_PROXYPORT_SSL = "network.proxy.ssl_port"; //$NON-NLS-1$
+	static final String PREFERENCE_PROXYTYPE = "network.proxy.type"; //$NON-NLS-1$
+	static final String PROFILE_AFTER_CHANGE = "profile-after-change"; //$NON-NLS-1$
+	static final String PROFILE_BEFORE_CHANGE = "profile-before-change"; //$NON-NLS-1$
+	static final String PROFILE_DIR = SEPARATOR_OS + "eclipse" + SEPARATOR_OS; //$NON-NLS-1$
+	static final String PROFILE_DO_CHANGE = "profile-do-change"; //$NON-NLS-1$
+	static final String PROPERTY_PROXYPORT = "network.proxy_port"; //$NON-NLS-1$
+	static final String PROPERTY_PROXYHOST = "network.proxy_host"; //$NON-NLS-1$
+	static final String SEPARATOR_LOCALE = "-"; //$NON-NLS-1$
+	static final String SHUTDOWN_PERSIST = "shutdown-persist"; //$NON-NLS-1$
+	static final String STARTUP = "startup"; //$NON-NLS-1$
+	static final String TOKENIZER_LOCALE = ","; //$NON-NLS-1$
+	static final String URI_FROMMEMORY = "file:///"; //$NON-NLS-1$
+	static final String XULRUNNER_PATH = "org.eclipse.swt.browser.XULRunnerPath"; //$NON-NLS-1$
+
+	// TEMPORARY CODE
+	static final String GRE_INITIALIZED = "org.eclipse.swt.browser.XULRunnerInitialized"; //$NON-NLS-1$
+
+	static {
+		MozillaClearSessions = new Runnable () {
+			public void run () {
+				if (!Initialized) return;
+				int /*long*/[] result = new int /*long*/[1];
+				int rc = XPCOM.NS_GetServiceManager (result);
+				if (rc != XPCOM.NS_OK) error (rc);
+				if (result[0] == 0) error (XPCOM.NS_NOINTERFACE);
+				nsIServiceManager serviceManager = new nsIServiceManager (result[0]);
+				result[0] = 0;
+				byte[] aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_COOKIEMANAGER_CONTRACTID, true);
+				rc = serviceManager.GetServiceByContractID (aContractID, nsICookieManager.NS_ICOOKIEMANAGER_IID, result);
+				if (rc != XPCOM.NS_OK) error (rc);
+				if (result[0] == 0) error (XPCOM.NS_NOINTERFACE);
+				serviceManager.Release ();
+
+				nsICookieManager manager = new nsICookieManager (result[0]);
+				result[0] = 0;
+				rc = manager.GetEnumerator (result);
+				if (rc != XPCOM.NS_OK) error (rc);
+				manager.Release ();
+
+				nsISimpleEnumerator enumerator = new nsISimpleEnumerator (result[0]);
+				int[] moreElements = new int[1]; /* PRBool */
+				rc = enumerator.HasMoreElements (moreElements);
+				if (rc != XPCOM.NS_OK) error (rc);
+				while (moreElements[0] != 0) {
+					result[0] = 0;
+					rc = enumerator.GetNext (result);
+					if (rc != XPCOM.NS_OK) error (rc);
+					nsICookie cookie = new nsICookie (result[0]);
+					long[] expires = new long[1];
+					rc = cookie.GetExpires (expires);
+					if (expires[0] == 0) {
+						/* indicates a session cookie */
+						int /*long*/ domain = XPCOM.nsEmbedCString_new ();
+						int /*long*/ name = XPCOM.nsEmbedCString_new ();
+						int /*long*/ path = XPCOM.nsEmbedCString_new ();
+						cookie.GetHost (domain);
+						cookie.GetName (name);
+						cookie.GetPath (path);
+						rc = manager.Remove (domain, name, path, 0);
+						XPCOM.nsEmbedCString_delete (domain);
+						XPCOM.nsEmbedCString_delete (name);
+						XPCOM.nsEmbedCString_delete (path);
+						if (rc != XPCOM.NS_OK) error (rc);
+					}
+					cookie.Release ();
+					rc = enumerator.HasMoreElements (moreElements);
+					if (rc != XPCOM.NS_OK) error (rc);
+				}
+				enumerator.Release ();
+			}
+		};
+	}
+
+public void create (Composite parent, int style) {
+	delegate = new MozillaDelegate (browser);
+	final Display display = parent.getDisplay ();
+
+	int /*long*/[] result = new int /*long*/[1];
+	if (!Initialized) {
+		boolean initLoaded = false;
+		boolean IsXULRunner = false;
+
+		String greInitialized = System.getProperty (GRE_INITIALIZED); 
+		if ("true".equals (greInitialized)) { //$NON-NLS-1$
+			/* 
+			 * Another browser has already initialized xulrunner in this process,
+			 * so just bind to it instead of trying to initialize a new one.
+			 */
+			Initialized = true;
+		}
+
+		String mozillaPath = System.getProperty (XULRUNNER_PATH);
+		/*
+		* Browser clients that ship XULRunner in a plug-in must have an opportunity 
+		* to set the org.eclipse.swt.browser.XULRunnerPath system property to point
+		* at their XULRunner before the first Mozilla-based Browser is created.  To
+		* facilitate this, reflection is used to reference non-existent class
+		* org.eclipse.swt.browser.XULRunnerInitializer the first time a Mozilla-
+		* based Browser is created.   A client wishing to use this hook can do so
+		* by creating a fragment of org.eclipse.swt that implements this class and
+		* sets the system property in its static initializer.
+		*/
+		if (mozillaPath == null) {
+			try {
+				Class.forName ("org.eclipse.swt.browser.XULRunnerInitializer"); //$NON-NLS-1$
+				mozillaPath = System.getProperty (XULRUNNER_PATH);
+			} catch (ClassNotFoundException e) {
+				/* no fragment is providing this class, which is the typical case */
+			}
+		}
+
+		if (mozillaPath == null) {
+			try {
+				String libName = delegate.getSWTInitLibraryName ();
+				Library.loadLibrary (libName);
+				initLoaded = true;
+			} catch (UnsatisfiedLinkError e) {
+				/* 
+				* If this library failed to load then do not attempt to detect a
+				* xulrunner to use.  The Browser may still be usable if MOZILLA_FIVE_HOME
+				* points at a GRE. 
+				*/
+			}
+		} else {
+			mozillaPath += SEPARATOR_OS + delegate.getLibraryName ();
+			IsXULRunner = true;
+		}
+
+		if (initLoaded) {
+			/* attempt to discover a XULRunner to use as the GRE */
+			GREVersionRange range = new GREVersionRange ();
+			byte[] bytes = MozillaDelegate.wcsToMbcs (null, GRERANGE_LOWER, true);
+			int /*long*/ lower = C.malloc (bytes.length);
+			C.memmove (lower, bytes, bytes.length);
+			range.lower = lower;
+			range.lowerInclusive = LowerRangeInclusive;
+
+			bytes = MozillaDelegate.wcsToMbcs (null, GRERANGE_UPPER, true);
+			int /*long*/ upper = C.malloc (bytes.length);
+			C.memmove (upper, bytes, bytes.length);
+			range.upper = upper;
+			range.upperInclusive = UpperRangeInclusive;
+
+			int length = XPCOMInit.PATH_MAX;
+			int /*long*/ greBuffer = C.malloc (length);
+			int /*long*/ propertiesPtr = C.malloc (2 * C.PTR_SIZEOF);
+			int rc = XPCOMInit.GRE_GetGREPathWithProperties (range, 1, propertiesPtr, 0, greBuffer, length);
+
+			/*
+			 * A XULRunner was not found that supports wrapping of XPCOM handles as JavaXPCOM objects.
+			 * Drop the lower version bound and try to detect an earlier XULRunner installation.
+			 */
+			if (rc != XPCOM.NS_OK) {
+				C.free (lower);
+				bytes = MozillaDelegate.wcsToMbcs (null, GRERANGE_LOWER_FALLBACK, true);
+				lower = C.malloc (bytes.length);
+				C.memmove (lower, bytes, bytes.length);
+				range.lower = lower;
+				rc = XPCOMInit.GRE_GetGREPathWithProperties (range, 1, propertiesPtr, 0, greBuffer, length);
+			}
+
+			C.free (lower);
+			C.free (upper);
+			C.free (propertiesPtr);
+			if (rc == XPCOM.NS_OK) {
+				/* indicates that a XULRunner was found */
+				length = C.strlen (greBuffer);
+				bytes = new byte[length];
+				C.memmove (bytes, greBuffer, length);
+				mozillaPath = new String (MozillaDelegate.mbcsToWcs (null, bytes));
+				IsXULRunner = mozillaPath.length () > 0;
+
+				/*
+				 * Test whether the detected XULRunner can be used as the GRE before loading swt's
+				 * XULRunner library.  If it cannot be used then fall back to attempting to use
+				 * the GRE pointed to by MOZILLA_FIVE_HOME.
+				 * 
+				 * One case where this will fail is attempting to use a 64-bit xulrunner while swt
+				 * is running in 32-bit mode, or vice versa.
+				 */
+				if (IsXULRunner) {
+					byte[] path = MozillaDelegate.wcsToMbcs (null, mozillaPath, true);
+					rc = XPCOMInit.XPCOMGlueStartup (path);
+					if (rc != XPCOM.NS_OK) {
+						mozillaPath = mozillaPath.substring (0, mozillaPath.lastIndexOf (SEPARATOR_OS));
+						if (Device.DEBUG) System.out.println ("cannot use detected XULRunner: " + mozillaPath); //$NON-NLS-1$
+
+						/* attempt to XPCOMGlueStartup the GRE pointed at by MOZILLA_FIVE_HOME */
+						int /*long*/ ptr = C.getenv (MozillaDelegate.wcsToMbcs (null, XPCOM.MOZILLA_FIVE_HOME, true));
+						if (ptr == 0) {
+							IsXULRunner = false;
+						} else {
+							length = C.strlen (ptr);
+							byte[] buffer = new byte[length];
+							C.memmove (buffer, ptr, length);
+							mozillaPath = new String (MozillaDelegate.mbcsToWcs (null, buffer));
+							/*
+							 * Attempting to XPCOMGlueStartup a mozilla-based GRE != xulrunner can
+							 * crash, so don't attempt unless the GRE appears to be xulrunner.
+							 */
+							if (mozillaPath.indexOf("xulrunner") == -1) { //$NON-NLS-1$
+								IsXULRunner = false;	
+							} else {
+								mozillaPath += SEPARATOR_OS + delegate.getLibraryName ();
+								path = MozillaDelegate.wcsToMbcs (null, mozillaPath, true);
+								rc = XPCOMInit.XPCOMGlueStartup (path);
+								if (rc != XPCOM.NS_OK) {
+									IsXULRunner = false;
+									mozillaPath = mozillaPath.substring (0, mozillaPath.lastIndexOf (SEPARATOR_OS));
+									if (Device.DEBUG) System.out.println ("failed to start as XULRunner: " + mozillaPath); //$NON-NLS-1$
+								}
+							}
+						} 
+					}
+					if (IsXULRunner) {
+						XPCOMInitWasGlued = true;
+					}
+				}
+			}
+			C.free (greBuffer);
+		}
+
+		if (IsXULRunner) {
+			if (Device.DEBUG) System.out.println ("XULRunner path: " + mozillaPath); //$NON-NLS-1$
+			try {
+				Library.loadLibrary ("swt-xulrunner"); //$NON-NLS-1$
+			} catch (UnsatisfiedLinkError e) {
+				SWT.error (SWT.ERROR_NO_HANDLES, e);
+			}
+			byte[] path = MozillaDelegate.wcsToMbcs (null, mozillaPath, true);
+			int rc = XPCOM.XPCOMGlueStartup (path);
+			if (rc != XPCOM.NS_OK) {
+				browser.dispose ();
+				error (rc);
+			}
+			XPCOMWasGlued = true;
+
+			/*
+			 * Remove the trailing xpcom lib name from mozillaPath because the
+			 * Mozilla.initialize and NS_InitXPCOM2 invocations require a directory name only.
+			 */ 
+			mozillaPath = mozillaPath.substring (0, mozillaPath.lastIndexOf (SEPARATOR_OS));
+		} else {
+			if ((style & SWT.MOZILLA) != 0) {
+				browser.dispose ();
+				String errorString = (mozillaPath != null && mozillaPath.length () > 0) ?
+					" [Failed to use detected XULRunner: " + mozillaPath + "]" :
+					" [Could not detect registered XULRunner to use]";	//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+				SWT.error (SWT.ERROR_NO_HANDLES, null, errorString);
+			}
+
+			/* attempt to use the GRE pointed at by MOZILLA_FIVE_HOME */
+			int /*long*/ ptr = C.getenv (MozillaDelegate.wcsToMbcs (null, XPCOM.MOZILLA_FIVE_HOME, true));
+			if (ptr != 0) {
+				int length = C.strlen (ptr);
+				byte[] buffer = new byte[length];
+				C.memmove (buffer, ptr, length);
+				mozillaPath = new String (MozillaDelegate.mbcsToWcs (null, buffer));
+			} else {
+				browser.dispose ();
+				SWT.error (SWT.ERROR_NO_HANDLES, null, " [Unknown Mozilla path (MOZILLA_FIVE_HOME not set)]"); //$NON-NLS-1$
+			}
+			if (Device.DEBUG) System.out.println ("Mozilla path: " + mozillaPath); //$NON-NLS-1$
+
+			/*
+			* Note.  Embedding a Mozilla GTK1.2 causes a crash.  The workaround
+			* is to check the version of GTK used by Mozilla by looking for
+			* the libwidget_gtk.so library used by Mozilla GTK1.2. Mozilla GTK2
+			* uses the libwidget_gtk2.so library.   
+			*/
+			if (Compatibility.fileExists (mozillaPath, "components/libwidget_gtk.so")) { //$NON-NLS-1$
+				browser.dispose ();
+				SWT.error (SWT.ERROR_NO_HANDLES, null, " [Mozilla GTK2 required (GTK1.2 detected)]"); //$NON-NLS-1$							
+			}
+
+			try {
+				Library.loadLibrary ("swt-mozilla"); //$NON-NLS-1$
+			} catch (UnsatisfiedLinkError e) {
+				try {
+					/* 
+					 * The initial loadLibrary attempt may have failed as a result of the user's
+					 * system not having libstdc++.so.6 installed, so try to load the alternate
+					 * swt mozilla library that depends on libswtc++.so.5 instead.
+					 */
+					Library.loadLibrary ("swt-mozilla-gcc3"); //$NON-NLS-1$
+				} catch (UnsatisfiedLinkError ex) {
+					browser.dispose ();
+					/*
+					 * Print the error from the first failed attempt since at this point it's
+					 * known that the failure was not due to the libstdc++.so.6 dependency.
+					 */
+					SWT.error (SWT.ERROR_NO_HANDLES, e, " [MOZILLA_FIVE_HOME='" + mozillaPath + "']"); //$NON-NLS-1$ //$NON-NLS-2$
+				}
+			}
+		}
+
+		if (!Initialized) {
+			int /*long*/[] retVal = new int /*long*/[1];
+			nsEmbedString pathString = new nsEmbedString (mozillaPath);
+			int rc = XPCOM.NS_NewLocalFile (pathString.getAddress (), 1, retVal);
+			pathString.dispose ();
+			if (rc != XPCOM.NS_OK) {
+				browser.dispose ();
+				error (rc);
+			}
+			if (retVal[0] == 0) {
+				browser.dispose ();
+				error (XPCOM.NS_ERROR_NULL_POINTER);
+			}
+
+			LocationProvider = new AppFileLocProvider (mozillaPath);
+			LocationProvider.AddRef ();
+
+			nsIFile localFile = new nsILocalFile (retVal[0]);
+			rc = XPCOM.NS_InitXPCOM2 (0, localFile.getAddress(), LocationProvider.getAddress ());
+			localFile.Release ();
+			if (rc != XPCOM.NS_OK) {
+				browser.dispose ();
+				SWT.error (SWT.ERROR_NO_HANDLES, null, " [MOZILLA_FIVE_HOME may not point at an embeddable GRE] [NS_InitEmbedding " + mozillaPath + " error " + rc + "]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+			}
+			System.setProperty (GRE_INITIALIZED, "true"); //$NON-NLS-1$
+			if (IsXULRunner) {
+				System.setProperty (XULRUNNER_PATH, mozillaPath);
+			}
+		}
+
+		/* If JavaXPCOM is detected then attempt to initialize it with the XULRunner being used */
+		if (IsXULRunner) {
+			try {
+				Class clazz = Class.forName ("org.mozilla.xpcom.Mozilla"); //$NON-NLS-1$
+				Method method = clazz.getMethod ("getInstance", new Class[0]); //$NON-NLS-1$
+				Object mozilla = method.invoke (null, new Object[0]);
+				method = clazz.getMethod ("getComponentManager", new Class[0]); //$NON-NLS-1$
+				try {
+					method.invoke (mozilla, new Object[0]);
+				} catch (InvocationTargetException e) {
+					/* indicates that JavaXPCOM has not been initialized yet */
+					Class fileClass = Class.forName ("java.io.File"); //$NON-NLS-1$
+					method = clazz.getMethod ("initialize", new Class[] {fileClass}); //$NON-NLS-1$
+					Constructor constructor = fileClass.getDeclaredConstructor (new Class[] {String.class});
+					Object argument = constructor.newInstance (new Object[] {mozillaPath});
+					method.invoke (mozilla, new Object[] {argument});
+				}
+			} catch (ClassNotFoundException e) {
+				/* JavaXPCOM is not on the classpath */
+			} catch (NoSuchMethodException e) {
+				/* the JavaXPCOM on the classpath does not implement initialize() */
+			} catch (IllegalArgumentException e) {
+			} catch (IllegalAccessException e) {
+			} catch (InvocationTargetException e) {
+			} catch (InstantiationException e) {
+			}
+		}
+
+		int rc = XPCOM.NS_GetComponentManager (result);
+		if (rc != XPCOM.NS_OK) {
+			browser.dispose ();
+			error (rc);
+		}
+		if (result[0] == 0) {
+			browser.dispose ();
+			error (XPCOM.NS_NOINTERFACE);
+		}
+		
+		nsIComponentManager componentManager = new nsIComponentManager (result[0]);
+		result[0] = 0;
+		if (delegate.needsSpinup ()) {
+			/* nsIAppShell is discontinued as of xulrunner 1.9, so do not fail if it is not found */
+			rc = componentManager.CreateInstance (XPCOM.NS_APPSHELL_CID, 0, nsIAppShell.NS_IAPPSHELL_IID, result);
+			if (rc != XPCOM.NS_ERROR_NO_INTERFACE) {
+				if (rc != XPCOM.NS_OK) {
+					browser.dispose ();
+					error (rc);
+				}
+				if (result[0] == 0) {
+					browser.dispose ();
+					error (XPCOM.NS_NOINTERFACE);
+				}
+	
+				AppShell = new nsIAppShell (result[0]);
+				rc = AppShell.Create (0, null);
+				if (rc != XPCOM.NS_OK) {
+					browser.dispose ();
+					error (rc);
+				}
+				rc = AppShell.Spinup ();
+				if (rc != XPCOM.NS_OK) {
+					browser.dispose ();
+					error (rc);
+				}
+			}
+			result[0] = 0;
+		}
+
+		WindowCreator = new WindowCreator2 ();
+		WindowCreator.AddRef ();
+		
+		rc = XPCOM.NS_GetServiceManager (result);
+		if (rc != XPCOM.NS_OK) {
+			browser.dispose ();
+			error (rc);
+		}
+		if (result[0] == 0) {
+			browser.dispose ();
+			error (XPCOM.NS_NOINTERFACE);
+		}
+		
+		nsIServiceManager serviceManager = new nsIServiceManager (result[0]);
+		result[0] = 0;		
+		byte[] aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_WINDOWWATCHER_CONTRACTID, true);
+		rc = serviceManager.GetServiceByContractID (aContractID, nsIWindowWatcher.NS_IWINDOWWATCHER_IID, result);
+		if (rc != XPCOM.NS_OK) {
+			browser.dispose ();
+			error (rc);
+		}
+		if (result[0] == 0) {
+			browser.dispose ();
+			error (XPCOM.NS_NOINTERFACE);		
+		}
+
+		nsIWindowWatcher windowWatcher = new nsIWindowWatcher (result[0]);
+		result[0] = 0;
+		rc = windowWatcher.SetWindowCreator (WindowCreator.getAddress());
+		if (rc != XPCOM.NS_OK) {
+			browser.dispose ();
+			error (rc);
+		}
+		windowWatcher.Release ();
+
+		/* compute the profile directory and set it on the AppFileLocProvider */
+		if (LocationProvider != null) {
+			byte[] buffer = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_DIRECTORYSERVICE_CONTRACTID, true);
+			rc = serviceManager.GetServiceByContractID (buffer, nsIDirectoryService.NS_IDIRECTORYSERVICE_IID, result);
+			if (rc != XPCOM.NS_OK) {
+				browser.dispose ();
+				error (rc);
+			}
+			if (result[0] == 0) {
+				browser.dispose ();
+				error (XPCOM.NS_NOINTERFACE);
+			}
+
+			nsIDirectoryService directoryService = new nsIDirectoryService (result[0]);
+			result[0] = 0;
+			rc = directoryService.QueryInterface (nsIProperties.NS_IPROPERTIES_IID, result);
+			if (rc != XPCOM.NS_OK) {
+				browser.dispose ();
+				error (rc);
+			}
+			if (result[0] == 0) {
+				browser.dispose ();
+				error (XPCOM.NS_NOINTERFACE);
+			}
+			directoryService.Release ();
+
+			nsIProperties properties = new nsIProperties (result[0]);
+			result[0] = 0;
+			buffer = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_APP_APPLICATION_REGISTRY_DIR, true);
+			rc = properties.Get (buffer, nsIFile.NS_IFILE_IID, result);
+			if (rc != XPCOM.NS_OK) {
+				browser.dispose ();
+				error (rc);
+			}
+			if (result[0] == 0) {
+				browser.dispose ();
+				error (XPCOM.NS_NOINTERFACE);
+			}
+			properties.Release ();
+
+			nsIFile profileDir = new nsIFile (result[0]);
+			result[0] = 0;
+			int /*long*/ path = XPCOM.nsEmbedCString_new ();
+			rc = profileDir.GetNativePath (path);
+			if (rc != XPCOM.NS_OK) {
+				browser.dispose ();
+				error (rc);
+			}
+			int length = XPCOM.nsEmbedCString_Length (path);
+			int /*long*/ ptr = XPCOM.nsEmbedCString_get (path);
+			buffer = new byte [length];
+			XPCOM.memmove (buffer, ptr, length);
+			String profilePath = new String (MozillaDelegate.mbcsToWcs (null, buffer)) + PROFILE_DIR;
+			LocationProvider.setProfilePath (profilePath);
+			LocationProvider.isXULRunner = IsXULRunner;
+			XPCOM.nsEmbedCString_delete (path);
+			profileDir.Release ();
+
+			/* notify observers of a new profile directory being used */
+			buffer = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_OBSERVER_CONTRACTID, true);
+			rc = serviceManager.GetServiceByContractID (buffer, nsIObserverService.NS_IOBSERVERSERVICE_IID, result);
+			if (rc != XPCOM.NS_OK) {
+				browser.dispose ();
+				error (rc);
+			}
+			if (result[0] == 0) {
+				browser.dispose ();
+				error (XPCOM.NS_NOINTERFACE);
+			}
+
+			nsIObserverService observerService = new nsIObserverService (result[0]);
+			result[0] = 0;
+			buffer = MozillaDelegate.wcsToMbcs (null, PROFILE_DO_CHANGE, true);
+			length = STARTUP.length ();
+			char[] chars = new char [length + 1];
+			STARTUP.getChars (0, length, chars, 0);
+			rc = observerService.NotifyObservers (0, buffer, chars);
+			if (rc != XPCOM.NS_OK) {
+				browser.dispose ();
+				error (rc);
+			}
+			buffer = MozillaDelegate.wcsToMbcs (null, PROFILE_AFTER_CHANGE, true);
+			rc = observerService.NotifyObservers (0, buffer, chars);
+			if (rc != XPCOM.NS_OK) {
+				browser.dispose ();
+				error (rc);
+			}
+			observerService.Release ();
+		}
+
+		/*
+		 * As a result of using a common profile the user cannot change their locale
+		 * and charset.  The fix for this is to set mozilla's locale and charset
+		 * preference values according to the user's current locale and charset.
+		 */
+		aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_PREFSERVICE_CONTRACTID, true);
+		rc = serviceManager.GetServiceByContractID (aContractID, nsIPrefService.NS_IPREFSERVICE_IID, result);
+		serviceManager.Release ();
+		if (rc != XPCOM.NS_OK) {
+			browser.dispose ();
+			error (rc);
+		}
+		if (result[0] == 0) {
+			browser.dispose ();
+			error (XPCOM.NS_NOINTERFACE);
+		}
+
+		nsIPrefService prefService = new nsIPrefService (result[0]);
+		result[0] = 0;
+		byte[] buffer = new byte[1];
+		rc = prefService.GetBranch (buffer, result);	/* empty buffer denotes root preference level */
+		prefService.Release ();
+		if (rc != XPCOM.NS_OK) {
+			browser.dispose ();
+			error (rc);
+		}
+		if (result[0] == 0) {
+			browser.dispose ();
+			error (XPCOM.NS_NOINTERFACE);
+		}
+
+		nsIPrefBranch prefBranch = new nsIPrefBranch (result[0]);
+		result[0] = 0;
+
+		/* get Mozilla's current locale preference value */
+		String prefLocales = null;
+		nsIPrefLocalizedString localizedString = null;
+		buffer = MozillaDelegate.wcsToMbcs (null, PREFERENCE_LANGUAGES, true);
+		rc = prefBranch.GetComplexValue (buffer, nsIPrefLocalizedString.NS_IPREFLOCALIZEDSTRING_IID, result);
+		/* 
+		 * Feature of Debian.  For some reason attempting to query for the current locale
+		 * preference fails on Debian.  The workaround for this is to assume a value of
+		 * "en-us,en" since this is typically the default value when mozilla is used without
+		 * a profile.
+		 */
+		if (rc != XPCOM.NS_OK) {
+			prefLocales = "en-us,en" + TOKENIZER_LOCALE;	//$NON-NLS-1$
+		} else {
+			if (result[0] == 0) {
+				browser.dispose ();
+				error (XPCOM.NS_NOINTERFACE);
+			}
+			localizedString = new nsIPrefLocalizedString (result[0]);
+			result[0] = 0;
+			rc = localizedString.ToString (result);
+			if (rc != XPCOM.NS_OK) {
+				browser.dispose ();
+				error (rc);
+			}
+			if (result[0] == 0) {
+				browser.dispose ();
+				error (XPCOM.NS_NOINTERFACE);
+			}
+			int length = XPCOM.strlen_PRUnichar (result[0]);
+			char[] dest = new char[length];
+			XPCOM.memmove (dest, result[0], length * 2);
+			prefLocales = new String (dest) + TOKENIZER_LOCALE;
+		}
+		result[0] = 0;
+
+		/*
+		 * construct the new locale preference value by prepending the
+		 * user's current locale and language to the original value 
+		 */
+		Locale locale = Locale.getDefault ();
+		String language = locale.getLanguage ();
+		String country = locale.getCountry ();
+		StringBuffer stringBuffer = new StringBuffer (language);
+		stringBuffer.append (SEPARATOR_LOCALE);
+		stringBuffer.append (country.toLowerCase ());
+		stringBuffer.append (TOKENIZER_LOCALE);
+		stringBuffer.append (language);
+		stringBuffer.append (TOKENIZER_LOCALE);
+		String newLocales = stringBuffer.toString ();
+
+		int start, end = -1;
+		do {
+			start = end + 1;
+			end = prefLocales.indexOf (TOKENIZER_LOCALE, start);
+			String token;
+			if (end == -1) {
+				token = prefLocales.substring (start);
+			} else {
+				token = prefLocales.substring (start, end);
+			}
+			if (token.length () > 0) {
+				token = (token + TOKENIZER_LOCALE).trim ();
+				/* ensure that duplicate locale values are not added */
+				if (newLocales.indexOf (token) == -1) {
+					stringBuffer.append (token);
+				}
+			}
+		} while (end != -1);
+		newLocales = stringBuffer.toString ();
+		if (!newLocales.equals (prefLocales)) {
+			/* write the new locale value */
+			newLocales = newLocales.substring (0, newLocales.length () - TOKENIZER_LOCALE.length ()); /* remove trailing tokenizer */
+			int length = newLocales.length ();
+			char[] charBuffer = new char[length + 1];
+			newLocales.getChars (0, length, charBuffer, 0);
+			if (localizedString == null) {
+				byte[] contractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_PREFLOCALIZEDSTRING_CONTRACTID, true);
+				rc = componentManager.CreateInstanceByContractID (contractID, 0, nsIPrefLocalizedString.NS_IPREFLOCALIZEDSTRING_IID, result);
+				if (rc != XPCOM.NS_OK) {
+					browser.dispose ();
+					error (rc);
+				}
+				if (result[0] == 0) {
+					browser.dispose ();
+					error (XPCOM.NS_NOINTERFACE);
+				}
+				localizedString = new nsIPrefLocalizedString (result[0]);
+				result[0] = 0;
+			}
+			localizedString.SetDataWithLength (length, charBuffer);
+			rc = prefBranch.SetComplexValue (buffer, nsIPrefLocalizedString.NS_IPREFLOCALIZEDSTRING_IID, localizedString.getAddress());
+		}
+		if (localizedString != null) {
+			localizedString.Release ();
+			localizedString = null;
+		}
+
+		/* get Mozilla's current charset preference value */
+		String prefCharset = null;
+		buffer = MozillaDelegate.wcsToMbcs (null, PREFERENCE_CHARSET, true);
+		rc = prefBranch.GetComplexValue (buffer, nsIPrefLocalizedString.NS_IPREFLOCALIZEDSTRING_IID, result);
+		/* 
+		 * Feature of Debian.  For some reason attempting to query for the current charset
+		 * preference fails on Debian.  The workaround for this is to assume a value of
+		 * "ISO-8859-1" since this is typically the default value when mozilla is used
+		 * without a profile.
+		 */
+		if (rc != XPCOM.NS_OK) {
+			prefCharset = "ISO-8859-1";	//$NON_NLS-1$
+		} else {
+			if (result[0] == 0) {
+				browser.dispose ();
+				error (XPCOM.NS_NOINTERFACE);
+			}
+			localizedString = new nsIPrefLocalizedString (result[0]);
+			result[0] = 0;
+			rc = localizedString.ToString (result);
+			if (rc != XPCOM.NS_OK) {
+				browser.dispose ();
+				error (rc);
+			}
+			if (result[0] == 0) {
+				browser.dispose ();
+				error (XPCOM.NS_NOINTERFACE);
+			}
+			int length = XPCOM.strlen_PRUnichar (result[0]);
+			char[] dest = new char[length];
+			XPCOM.memmove (dest, result[0], length * 2);
+			prefCharset = new String (dest);
+		}
+		result[0] = 0;
+
+		String newCharset = System.getProperty ("file.encoding");	// $NON-NLS-1$
+		if (!newCharset.equals (prefCharset)) {
+			/* write the new charset value */
+			int length = newCharset.length ();
+			char[] charBuffer = new char[length + 1];
+			newCharset.getChars (0, length, charBuffer, 0);
+			if (localizedString == null) {
+				byte[] contractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_PREFLOCALIZEDSTRING_CONTRACTID, true);
+				rc = componentManager.CreateInstanceByContractID (contractID, 0, nsIPrefLocalizedString.NS_IPREFLOCALIZEDSTRING_IID, result);
+				if (rc != XPCOM.NS_OK) {
+					browser.dispose ();
+					error (rc);
+				}
+				if (result[0] == 0) {
+					browser.dispose ();
+					error (XPCOM.NS_NOINTERFACE);
+				}
+				localizedString = new nsIPrefLocalizedString (result[0]);
+				result[0] = 0;
+			}
+			localizedString.SetDataWithLength (length, charBuffer);
+			rc = prefBranch.SetComplexValue (buffer, nsIPrefLocalizedString.NS_IPREFLOCALIZEDSTRING_IID, localizedString.getAddress ());
+		}
+		if (localizedString != null) localizedString.Release ();
+
+		/*
+		* Check for proxy values set as documented java properties and update mozilla's
+		* preferences with these values if needed.
+		*/
+		String proxyHost = System.getProperty (PROPERTY_PROXYHOST);
+		String proxyPortString = System.getProperty (PROPERTY_PROXYPORT);
+
+		int port = -1;
+		if (proxyPortString != null) {
+			try {
+				int value = Integer.valueOf (proxyPortString).intValue ();
+				if (0 <= value && value <= MAX_PORT) port = value;
+			} catch (NumberFormatException e) {
+				/* do nothing, java property has non-integer value */
+			}
+		}
+
+		if (proxyHost != null) {
+			byte[] contractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_PREFLOCALIZEDSTRING_CONTRACTID, true);
+			rc = componentManager.CreateInstanceByContractID (contractID, 0, nsIPrefLocalizedString.NS_IPREFLOCALIZEDSTRING_IID, result);
+			if (rc != XPCOM.NS_OK) error (rc);
+			if (result[0] == 0) error (XPCOM.NS_NOINTERFACE);
+
+			localizedString = new nsIPrefLocalizedString (result[0]);
+			result[0] = 0;
+			int length = proxyHost.length ();
+			char[] charBuffer = new char[length + 1];
+			proxyHost.getChars (0, length, charBuffer, 0);
+			rc = localizedString.SetDataWithLength (length, charBuffer);
+			if (rc != XPCOM.NS_OK) error (rc);
+			buffer = MozillaDelegate.wcsToMbcs (null, PREFERENCE_PROXYHOST_FTP, true);
+			rc = prefBranch.SetComplexValue (buffer, nsIPrefLocalizedString.NS_IPREFLOCALIZEDSTRING_IID, localizedString.getAddress ());
+			if (rc != XPCOM.NS_OK) error (rc);
+			buffer = MozillaDelegate.wcsToMbcs (null, PREFERENCE_PROXYHOST_HTTP, true);
+			rc = prefBranch.SetComplexValue (buffer, nsIPrefLocalizedString.NS_IPREFLOCALIZEDSTRING_IID, localizedString.getAddress ());
+			if (rc != XPCOM.NS_OK) error (rc);
+			buffer = MozillaDelegate.wcsToMbcs (null, PREFERENCE_PROXYHOST_SSL, true);
+			rc = prefBranch.SetComplexValue (buffer, nsIPrefLocalizedString.NS_IPREFLOCALIZEDSTRING_IID, localizedString.getAddress ());
+			if (rc != XPCOM.NS_OK) error (rc);
+			localizedString.Release ();
+		}
+
+		if (port != -1) {
+			buffer = MozillaDelegate.wcsToMbcs (null, PREFERENCE_PROXYPORT_FTP, true);
+			rc = prefBranch.SetIntPref (buffer, port);
+			if (rc != XPCOM.NS_OK) error (rc);
+			buffer = MozillaDelegate.wcsToMbcs (null, PREFERENCE_PROXYPORT_HTTP, true);
+			rc = prefBranch.SetIntPref (buffer, port);
+			if (rc != XPCOM.NS_OK) error (rc);
+			buffer = MozillaDelegate.wcsToMbcs (null, PREFERENCE_PROXYPORT_SSL, true);
+			rc = prefBranch.SetIntPref (buffer, port);
+			if (rc != XPCOM.NS_OK) error (rc);
+		}
+
+		if (proxyHost != null || port != -1) {
+			buffer = MozillaDelegate.wcsToMbcs (null, PREFERENCE_PROXYTYPE, true);
+			rc = prefBranch.SetIntPref (buffer, 1);
+			if (rc != XPCOM.NS_OK) error (rc);
+		}
+
+		/*
+		* Ensure that windows that are shown during page loads are not blocked.  Firefox may
+		* try to block these by default since such windows are often unwelcome, but this
+		* assumption should not be made in the Browser's context.  Since the Browser client
+		* is responsible for creating the new Browser and Shell in an OpenWindowListener,
+		* they should decide whether the new window is unwelcome or not and act accordingly. 
+		*/
+		buffer = MozillaDelegate.wcsToMbcs (null, PREFERENCE_DISABLEOPENDURINGLOAD, true);
+		rc = prefBranch.SetBoolPref (buffer, 0);
+		if (rc != XPCOM.NS_OK) {
+			browser.dispose ();
+			error (rc);
+		}
+
+		/* Ensure that the status text can be set through means like javascript */ 
+		buffer = MozillaDelegate.wcsToMbcs (null, PREFERENCE_DISABLEWINDOWSTATUSCHANGE, true);
+		rc = prefBranch.SetBoolPref (buffer, 0);
+		if (rc != XPCOM.NS_OK) {
+			browser.dispose ();
+			error (rc);
+		}
+
+		prefBranch.Release ();
+
+		PromptService2Factory factory = new PromptService2Factory ();
+		factory.AddRef ();
+
+		rc = componentManager.QueryInterface (nsIComponentRegistrar.NS_ICOMPONENTREGISTRAR_IID, result);
+		if (rc != XPCOM.NS_OK) {
+			browser.dispose ();
+			error (rc);
+		}
+		if (result[0] == 0) {
+			browser.dispose ();
+			error (XPCOM.NS_NOINTERFACE);
+		}
+		
+		nsIComponentRegistrar componentRegistrar = new nsIComponentRegistrar (result[0]);
+		result[0] = 0;
+		aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_PROMPTSERVICE_CONTRACTID, true); 
+		byte[] aClassName = MozillaDelegate.wcsToMbcs (null, "Prompt Service", true); //$NON-NLS-1$
+		rc = componentRegistrar.RegisterFactory (XPCOM.NS_PROMPTSERVICE_CID, aClassName, aContractID, factory.getAddress ());
+		if (rc != XPCOM.NS_OK) {
+			browser.dispose ();
+			error (rc);
+		}
+		factory.Release ();
+		
+		/*
+		* This Download factory will be used if the GRE version is < 1.8.
+		* If the GRE version is 1.8.x then the Download factory that is registered later for
+		*   contract "Transfer" will be used.
+		* If the GRE version is >= 1.9 then no Download factory is registered because this
+		*   functionality is provided by the GRE.
+		*/
+		DownloadFactory downloadFactory = new DownloadFactory ();
+		downloadFactory.AddRef ();
+		aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_DOWNLOAD_CONTRACTID, true);
+		aClassName = MozillaDelegate.wcsToMbcs (null, "Download", true); //$NON-NLS-1$
+		rc = componentRegistrar.RegisterFactory (XPCOM.NS_DOWNLOAD_CID, aClassName, aContractID, downloadFactory.getAddress ());
+		if (rc != XPCOM.NS_OK) {
+			browser.dispose ();
+			error (rc);
+		}
+		downloadFactory.Release ();
+
+		FilePickerFactory pickerFactory = IsXULRunner ? new FilePickerFactory_1_8 () : new FilePickerFactory ();
+		pickerFactory.AddRef ();
+		aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_FILEPICKER_CONTRACTID, true);
+		aClassName = MozillaDelegate.wcsToMbcs (null, "FilePicker", true); //$NON-NLS-1$
+		rc = componentRegistrar.RegisterFactory (XPCOM.NS_FILEPICKER_CID, aClassName, aContractID, pickerFactory.getAddress ());
+		if (rc != XPCOM.NS_OK) {
+			browser.dispose ();
+			error (rc);
+		}
+		pickerFactory.Release ();
+
+		componentRegistrar.Release ();
+		componentManager.Release ();
+
+		Initialized = true;
+	}
+
+	if (display.getData (DISPOSE_LISTENER_HOOKED) == null) {
+		display.setData (DISPOSE_LISTENER_HOOKED, DISPOSE_LISTENER_HOOKED);
+		display.addListener (SWT.Dispose, new Listener () {
+			public void handleEvent (Event event) {
+				if (BrowserCount > 0) return; /* another display is still active */
+
+				int /*long*/[] result = new int /*long*/[1];
+				int rc = XPCOM.NS_GetServiceManager (result);
+				if (rc != XPCOM.NS_OK) error (rc);
+				if (result[0] == 0) error (XPCOM.NS_NOINTERFACE);
+
+				nsIServiceManager serviceManager = new nsIServiceManager (result[0]);
+				result[0] = 0;		
+				byte[] buffer = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_OBSERVER_CONTRACTID, true);
+				rc = serviceManager.GetServiceByContractID (buffer, nsIObserverService.NS_IOBSERVERSERVICE_IID, result);
+				if (rc != XPCOM.NS_OK) error (rc);
+				if (result[0] == 0) error (XPCOM.NS_NOINTERFACE);
+
+				nsIObserverService observerService = new nsIObserverService (result[0]);
+				result[0] = 0;
+				buffer = MozillaDelegate.wcsToMbcs (null, PROFILE_BEFORE_CHANGE, true);
+				int length = SHUTDOWN_PERSIST.length ();
+				char[] chars = new char [length + 1];
+				SHUTDOWN_PERSIST.getChars (0, length, chars, 0);
+				rc = observerService.NotifyObservers (0, buffer, chars);
+				if (rc != XPCOM.NS_OK) error (rc);
+				observerService.Release ();
+
+				if (LocationProvider != null) {
+					String prefsLocation = LocationProvider.profilePath + AppFileLocProvider.PREFERENCES_FILE;
+					nsEmbedString pathString = new nsEmbedString (prefsLocation);
+					rc = XPCOM.NS_NewLocalFile (pathString.getAddress (), 1, result);
+					if (rc != XPCOM.NS_OK) Mozilla.error (rc);
+					if (result[0] == 0) Mozilla.error (XPCOM.NS_ERROR_NULL_POINTER);
+					pathString.dispose ();
+
+					nsILocalFile localFile = new nsILocalFile (result [0]);
+					result[0] = 0;
+				    rc = localFile.QueryInterface (nsIFile.NS_IFILE_IID, result); 
+					if (rc != XPCOM.NS_OK) Mozilla.error (rc);
+					if (result[0] == 0) Mozilla.error (XPCOM.NS_ERROR_NO_INTERFACE);
+					localFile.Release ();
+
+					nsIFile prefFile = new nsIFile (result[0]);
+					result[0] = 0;
+
+					buffer = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_PREFSERVICE_CONTRACTID, true);
+					rc = serviceManager.GetServiceByContractID (buffer, nsIPrefService.NS_IPREFSERVICE_IID, result);
+					if (rc != XPCOM.NS_OK) error (rc);
+					if (result[0] == 0) error (XPCOM.NS_NOINTERFACE);
+
+					nsIPrefService prefService = new nsIPrefService (result[0]);
+					result[0] = 0;
+					rc = prefService.SavePrefFile(prefFile.getAddress ());
+					prefService.Release ();
+					prefFile.Release ();
+				}
+				serviceManager.Release ();
+
+				if (XPCOMWasGlued) {
+					/*
+					* XULRunner 1.9 can crash on Windows if XPCOMGlueShutdown is invoked here,
+					* presumably because one or more of its unloaded symbols are referenced when
+					* this callback returns.  The workaround is to delay invoking XPCOMGlueShutdown
+					* so that its symbols are still available once this callback returns.
+					*/
+					display.asyncExec (new Runnable () {
+						public void run () {
+							XPCOM.XPCOMGlueShutdown ();
+						}
+					});
+					XPCOMWasGlued = false;
+				}
+				if (XPCOMInitWasGlued) {
+					XPCOMInit.XPCOMGlueShutdown ();
+					XPCOMInitWasGlued = false;
+				}
+				Initialized = false;
+			}
+		});
+	}
+
+	BrowserCount++;
+	int rc = XPCOM.NS_GetComponentManager (result);
+	if (rc != XPCOM.NS_OK) {
+		browser.dispose ();
+		error (rc);
+	}
+	if (result[0] == 0) {
+		browser.dispose ();
+		error (XPCOM.NS_NOINTERFACE);
+	}
+	
+	nsIComponentManager componentManager = new nsIComponentManager (result[0]);
+	result[0] = 0;
+	nsID NS_IWEBBROWSER_CID = new nsID ("F1EAC761-87E9-11d3-AF80-00A024FFC08C"); //$NON-NLS-1$
+	rc = componentManager.CreateInstance (NS_IWEBBROWSER_CID, 0, nsIWebBrowser.NS_IWEBBROWSER_IID, result);
+	if (rc != XPCOM.NS_OK) {
+		browser.dispose ();
+		error (rc);
+	}
+	if (result[0] == 0) {
+		browser.dispose ();
+		error (XPCOM.NS_NOINTERFACE);	
+	}
+	
+	webBrowser = new nsIWebBrowser (result[0]);
+	result[0] = 0;
+
+	createCOMInterfaces ();
+	AddRef ();
+
+	rc = webBrowser.SetContainerWindow (webBrowserChrome.getAddress());
+	if (rc != XPCOM.NS_OK) {
+		browser.dispose ();
+		error (rc);
+	}
+			
+	rc = webBrowser.QueryInterface (nsIBaseWindow.NS_IBASEWINDOW_IID, result);
+	if (rc != XPCOM.NS_OK) {
+		browser.dispose ();
+		error (rc);
+	}
+	if (result[0] == 0) {
+		browser.dispose ();
+		error (XPCOM.NS_ERROR_NO_INTERFACE);
+	}
+	
+	nsIBaseWindow baseWindow = new nsIBaseWindow (result[0]);
+	result[0] = 0;
+	Rectangle rect = browser.getClientArea ();
+	if (rect.isEmpty ()) {
+		rect.width = 1;
+		rect.height = 1;
+	}
+
+	embedHandle = delegate.getHandle ();
+
+	rc = baseWindow.InitWindow (embedHandle, 0, 0, 0, rect.width, rect.height);
+	if (rc != XPCOM.NS_OK) {
+		browser.dispose ();
+		error (XPCOM.NS_ERROR_FAILURE);
+	}
+	rc = baseWindow.Create ();
+	if (rc != XPCOM.NS_OK) {
+		browser.dispose ();
+		error (XPCOM.NS_ERROR_FAILURE);
+	}
+	rc = baseWindow.SetVisibility (1);
+	if (rc != XPCOM.NS_OK) {
+		browser.dispose ();
+		error (XPCOM.NS_ERROR_FAILURE);
+	}
+	baseWindow.Release ();
+
+	if (!PerformedVersionCheck) {
+		PerformedVersionCheck = true;
+
+		rc = componentManager.QueryInterface (nsIComponentRegistrar.NS_ICOMPONENTREGISTRAR_IID, result);
+		if (rc != XPCOM.NS_OK) {
+			browser.dispose ();
+			error (rc);
+		}
+		if (result[0] == 0) {
+			browser.dispose ();
+			error (XPCOM.NS_NOINTERFACE);
+		}
+		nsIComponentRegistrar componentRegistrar = new nsIComponentRegistrar (result[0]);
+		result[0] = 0;
+
+		HelperAppLauncherDialogFactory dialogFactory = new HelperAppLauncherDialogFactory ();
+		dialogFactory.AddRef ();
+		byte[] aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_HELPERAPPLAUNCHERDIALOG_CONTRACTID, true);
+		byte[] aClassName = MozillaDelegate.wcsToMbcs (null, "Helper App Launcher Dialog", true); //$NON-NLS-1$
+		rc = componentRegistrar.RegisterFactory (XPCOM.NS_HELPERAPPLAUNCHERDIALOG_CID, aClassName, aContractID, dialogFactory.getAddress ());
+		if (rc != XPCOM.NS_OK) {
+			browser.dispose ();
+			error (rc);
+		}
+		dialogFactory.Release ();
+
+		/*
+		* Check for the availability of the pre-1.8 implementation of nsIDocShell
+		* to determine if the GRE's version is < 1.8.
+		*/
+		rc = webBrowser.QueryInterface (nsIInterfaceRequestor.NS_IINTERFACEREQUESTOR_IID, result);
+		if (rc != XPCOM.NS_OK) {
+			browser.dispose ();
+			error (XPCOM.NS_ERROR_FAILURE);
+		}
+		if (result[0] == 0) {
+			browser.dispose ();
+			error (XPCOM.NS_ERROR_NO_INTERFACE);
+		}
+		nsIInterfaceRequestor interfaceRequestor = new nsIInterfaceRequestor (result[0]);
+		result[0] = 0;
+
+		rc = interfaceRequestor.GetInterface (nsIDocShell.NS_IDOCSHELL_IID, result);
+		if (rc == XPCOM.NS_OK && result[0] != 0) {
+			IsPre_1_8 = true;
+			new nsISupports (result[0]).Release ();
+		}
+		result[0] = 0;
+
+		/*
+		* A Download factory for contract "Transfer" must be registered iff the GRE's version is 1.8.x.
+		*   Check for the availability of the 1.8 implementation of nsIDocShell to determine if the
+		*   GRE's version is 1.8.x.
+		* If the GRE version is < 1.8 then the previously-registered Download factory for contract
+		*   "Download" will be used.
+		* If the GRE version is >= 1.9 then no Download factory is registered because this
+		*   functionality is provided by the GRE.
+		*/
+		if (!IsPre_1_8) {
+			rc = interfaceRequestor.GetInterface (nsIDocShell_1_8.NS_IDOCSHELL_IID, result);
+			if (rc == XPCOM.NS_OK && result[0] != 0) { /* 1.8 */
+				new nsISupports (result[0]).Release ();
+				result[0] = 0;
+
+				DownloadFactory_1_8 downloadFactory_1_8 = new DownloadFactory_1_8 ();
+				downloadFactory_1_8.AddRef ();
+				aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_TRANSFER_CONTRACTID, true);
+				aClassName = MozillaDelegate.wcsToMbcs (null, "Transfer", true); //$NON-NLS-1$
+				rc = componentRegistrar.RegisterFactory (XPCOM.NS_DOWNLOAD_CID, aClassName, aContractID, downloadFactory_1_8.getAddress ());
+				if (rc != XPCOM.NS_OK) {
+					browser.dispose ();
+					error (rc);
+				}
+				downloadFactory_1_8.Release ();
+			} else { /* >= 1.9 */
+				/*
+				 * Bug in XULRunner 1.9.  Mozilla no longer clears its background before initial content has
+				 * been set.  As a result embedders appear broken if they do not immediately navigate to a url.
+				 * The workaround for this is to navigate to about:blank immediately so that the background is
+				 * cleared, but do not fire any corresponding events or allow Browser API calls to reveal this.
+				 * Once the client does a proper navigate with either setUrl() or setText() then resume as
+				 * normal.  The Mozilla bug for this is https://bugzilla.mozilla.org/show_bug.cgi?id=415789.
+				 */
+				awaitingNavigate = true;
+				rc = webBrowser.QueryInterface (nsIWebNavigation.NS_IWEBNAVIGATION_IID, result);
+				if (rc != XPCOM.NS_OK) {
+					browser.dispose ();
+					error (rc);
+				}
+				if (result[0] == 0) {
+					browser.dispose ();
+					error (XPCOM.NS_ERROR_NO_INTERFACE);
+				}
+				nsIWebNavigation webNavigation = new nsIWebNavigation (result[0]);
+			    char[] uri = new char[ABOUT_BLANK.length () + 1];
+			    ABOUT_BLANK.getChars (0, ABOUT_BLANK.length (), uri, 0);
+				rc = webNavigation.LoadURI (uri, nsIWebNavigation.LOAD_FLAGS_NONE, 0, 0, 0);
+				webNavigation.Release ();
+
+				dialogFactory.isPre_1_9 = false;
+			}
+		}
+		result[0] = 0;
+		interfaceRequestor.Release ();
+		componentRegistrar.Release ();
+	}
+	componentManager.Release ();
+
+	rc = webBrowser.AddWebBrowserListener (weakReference.getAddress (), nsIWebProgressListener.NS_IWEBPROGRESSLISTENER_IID);
+	if (rc != XPCOM.NS_OK) {
+		browser.dispose ();
+		error (rc);
+	}
+
+	rc = webBrowser.SetParentURIContentListener (uriContentListener.getAddress ());
+	if (rc != XPCOM.NS_OK) {
+		browser.dispose ();
+		error (rc);
+	}
+
+	delegate.init ();
+
+	listener = new Listener () {
+		public void handleEvent (Event event) {
+			switch (event.type) {
+				case SWT.Dispose: {
+					/* make this handler run after other dispose listeners */
+					if (ignoreDispose) {
+						ignoreDispose = false;
+						break;
+					}
+					ignoreDispose = true;
+					browser.notifyListeners (event.type, event);
+					event.type = SWT.NONE;
+					onDispose (event.display);
+					break;
+				}
+				case SWT.Resize: onResize (); break;
+				case SWT.FocusIn: Activate (); break;
+				case SWT.Activate: Activate (); break;
+				case SWT.Deactivate: {
+					Display display = event.display;
+					if (Mozilla.this.browser == display.getFocusControl ()) Deactivate ();
+					break;
+				}
+				case SWT.Show: {
+					/*
+					* Feature in GTK Mozilla.  Mozilla does not show up when
+					* its container (a GTK fixed handle) is made visible
+					* after having been hidden.  The workaround is to reset
+					* its size after the container has been made visible. 
+					*/
+					Display display = event.display;
+					display.asyncExec(new Runnable () {
+						public void run() {
+							if (browser.isDisposed ()) return;
+							onResize ();
+						}
+					});
+					break;
+				}
+			}
+		}
+	};	
+	int[] folderEvents = new int[] {
+		SWT.Dispose,
+		SWT.Resize,  
+		SWT.FocusIn,
+		SWT.Activate,
+		SWT.Deactivate,
+		SWT.Show,
+		SWT.KeyDown		// needed to make browser traversable
+	};
+	for (int i = 0; i < folderEvents.length; i++) {
+		browser.addListener (folderEvents[i], listener);
+	}
+}
+
+public boolean back () {
+	if (awaitingNavigate) return false;
+
+	int /*long*/[] result = new int /*long*/[1];
+	int rc = webBrowser.QueryInterface (nsIWebNavigation.NS_IWEBNAVIGATION_IID, result);
+	if (rc != XPCOM.NS_OK) error (rc);
+	if (result[0] == 0) error (XPCOM.NS_ERROR_NO_INTERFACE);
+	
+	nsIWebNavigation webNavigation = new nsIWebNavigation (result[0]);		 	
+	rc = webNavigation.GoBack ();	
+	webNavigation.Release ();
+	return rc == XPCOM.NS_OK;
+}
+
+void createCOMInterfaces () {
+	// Create each of the interfaces that this object implements
+	supports = new XPCOMObject (new int[] {2, 0, 0}) {
+		public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+		public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+		public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+	};
+	
+	weakReference = new XPCOMObject (new int[] {2, 0, 0, 2}) {
+		public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+		public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+		public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+		public int /*long*/ method3 (int /*long*/[] args) {return QueryReferent (args[0], args[1]);}
+	};
+
+	webProgressListener = new XPCOMObject (new int[] {2, 0, 0, 4, 6, 3, 4, 3}) {
+		public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+		public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+		public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+		public int /*long*/ method3 (int /*long*/[] args) {return OnStateChange (args[0], args[1], (int)/*64*/args[2], (int)/*64*/args[3]);}
+		public int /*long*/ method4 (int /*long*/[] args) {return OnProgressChange (args[0], args[1], (int)/*64*/args[2], (int)/*64*/args[3], (int)/*64*/args[4], (int)/*64*/args[5]);}
+		public int /*long*/ method5 (int /*long*/[] args) {return OnLocationChange (args[0], args[1], args[2]);}
+		public int /*long*/ method6 (int /*long*/[] args) {return OnStatusChange (args[0], args[1], (int)/*64*/args[2], args[3]);}
+		public int /*long*/ method7 (int /*long*/[] args) {return OnSecurityChange (args[0], args[1], (int)/*64*/args[2]);}
+	};
+	
+	webBrowserChrome = new XPCOMObject (new int[] {2, 0, 0, 2, 1, 1, 1, 1, 0, 2, 0, 1, 1}) {
+		public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+		public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+		public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+		public int /*long*/ method3 (int /*long*/[] args) {return SetStatus ((int)/*64*/args[0], args[1]);}
+		public int /*long*/ method4 (int /*long*/[] args) {return GetWebBrowser (args[0]);}
+		public int /*long*/ method5 (int /*long*/[] args) {return SetWebBrowser (args[0]);}
+		public int /*long*/ method6 (int /*long*/[] args) {return GetChromeFlags (args[0]);}
+		public int /*long*/ method7 (int /*long*/[] args) {return SetChromeFlags ((int)/*64*/args[0]);}
+		public int /*long*/ method8 (int /*long*/[] args) {return DestroyBrowserWindow ();}
+		public int /*long*/ method9 (int /*long*/[] args) {return SizeBrowserTo ((int)/*64*/args[0], (int)/*64*/args[1]);}
+		public int /*long*/ method10 (int /*long*/[] args) {return ShowAsModal ();}
+		public int /*long*/ method11 (int /*long*/[] args) {return IsWindowModal (args[0]);}
+		public int /*long*/ method12 (int /*long*/[] args) {return ExitModalEventLoop ((int)/*64*/args[0]);}
+	};
+	
+	webBrowserChromeFocus = new XPCOMObject (new int[] {2, 0, 0, 0, 0}) {
+		public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+		public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+		public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+		public int /*long*/ method3 (int /*long*/[] args) {return FocusNextElement ();}
+		public int /*long*/ method4 (int /*long*/[] args) {return FocusPrevElement ();}
+	};
+		
+	embeddingSiteWindow = new XPCOMObject (new int[] {2, 0, 0, 5, 5, 0, 1, 1, 1, 1, 1}) {
+		public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+		public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+		public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+		public int /*long*/ method3 (int /*long*/[] args) {return SetDimensions ((int)/*64*/args[0], (int)/*64*/args[1], (int)/*64*/args[2], (int)/*64*/args[3], (int)/*64*/args[4]);}
+		public int /*long*/ method4 (int /*long*/[] args) {return GetDimensions ((int)/*64*/args[0], args[1], args[2], args[3], args[4]);}
+		public int /*long*/ method5 (int /*long*/[] args) {return SetFocus ();}
+		public int /*long*/ method6 (int /*long*/[] args) {return GetVisibility (args[0]);}
+		public int /*long*/ method7 (int /*long*/[] args) {return SetVisibility ((int)/*64*/args[0]);}
+		public int /*long*/ method8 (int /*long*/[] args) {return GetTitle (args[0]);}
+		public int /*long*/ method9 (int /*long*/[] args) {return SetTitle (args[0]);}
+		public int /*long*/ method10 (int /*long*/[] args) {return GetSiteWindow (args[0]);}
+	};
+	
+	interfaceRequestor = new XPCOMObject (new int[] {2, 0, 0, 2} ){
+		public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+		public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+		public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+		public int /*long*/ method3 (int /*long*/[] args) {return GetInterface (args[0], args[1]);}
+	};
+		
+	supportsWeakReference = new XPCOMObject (new int[] {2, 0, 0, 1}) {
+		public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+		public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+		public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+		public int /*long*/ method3 (int /*long*/[] args) {return GetWeakReference (args[0]);}
+	};
+	
+	contextMenuListener = new XPCOMObject (new int[] {2, 0, 0, 3}) {
+		public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+		public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+		public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+		public int /*long*/ method3 (int /*long*/[] args) {return OnShowContextMenu ((int)/*64*/args[0], args[1], args[2]);}
+	};
+	
+	uriContentListener = new XPCOMObject (new int[] {2, 0, 0, 2, 5, 3, 4, 1, 1, 1, 1}) {
+		public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+		public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+		public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+		public int /*long*/ method3 (int /*long*/[] args) {return OnStartURIOpen (args[0], args[1]);}
+		public int /*long*/ method4 (int /*long*/[] args) {return DoContent (args[0], (int)/*64*/args[1], args[2], args[3], args[4]);}
+		public int /*long*/ method5 (int /*long*/[] args) {return IsPreferred (args[0], args[1], args[2]);}
+		public int /*long*/ method6 (int /*long*/[] args) {return CanHandleContent (args[0], (int)/*64*/args[1], args[2], args[3]);}
+		public int /*long*/ method7 (int /*long*/[] args) {return GetLoadCookie (args[0]);}
+		public int /*long*/ method8 (int /*long*/[] args) {return SetLoadCookie (args[0]);}
+		public int /*long*/ method9 (int /*long*/[] args) {return GetParentContentListener (args[0]);}
+		public int /*long*/ method10 (int /*long*/[] args) {return SetParentContentListener (args[0]);}		
+	};
+	
+	tooltipListener = new XPCOMObject (new int[] {2, 0, 0, 3, 0}) {
+		public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+		public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+		public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+		public int /*long*/ method3 (int /*long*/[] args) {return OnShowTooltip ((int)/*64*/args[0], (int)/*64*/args[1], args[2]);}
+		public int /*long*/ method4 (int /*long*/[] args) {return OnHideTooltip ();}		
+	};
+
+	domEventListener = new XPCOMObject (new int[] {2, 0, 0, 1}) {
+		public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+		public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+		public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+		public int /*long*/ method3 (int /*long*/[] args) {return HandleEvent (args[0]);}
+	};
+}
+
+void disposeCOMInterfaces () {
+	if (supports != null) {
+		supports.dispose ();
+		supports = null;
+	}	
+	if (weakReference != null) {
+		weakReference.dispose ();
+		weakReference = null;	
+	}
+	if (webProgressListener != null) {
+		webProgressListener.dispose ();
+		webProgressListener = null;
+	}
+	if (webBrowserChrome != null) {
+		webBrowserChrome.dispose ();
+		webBrowserChrome = null;
+	}
+	if (webBrowserChromeFocus != null) {
+		webBrowserChromeFocus.dispose ();
+		webBrowserChromeFocus = null;
+	}
+	if (embeddingSiteWindow != null) {
+		embeddingSiteWindow.dispose ();
+		embeddingSiteWindow = null;
+	}
+	if (interfaceRequestor != null) {
+		interfaceRequestor.dispose ();
+		interfaceRequestor = null;
+	}		
+	if (supportsWeakReference != null) {
+		supportsWeakReference.dispose ();
+		supportsWeakReference = null;
+	}	
+	if (contextMenuListener != null) {
+		contextMenuListener.dispose ();
+		contextMenuListener = null;
+	}
+	if (uriContentListener != null) {
+		uriContentListener.dispose ();
+		uriContentListener = null;
+	}
+	if (tooltipListener != null) {
+		tooltipListener.dispose ();
+		tooltipListener = null;
+	}
+	if (domEventListener != null) {
+		domEventListener.dispose ();
+		domEventListener = null;
+	}
+}
+
+public boolean execute (String script) {
+	if (awaitingNavigate) return false;
+
+	String url = PREFIX_JAVASCRIPT + script + ";void(0);";	//$NON-NLS-1$
+	int /*long*/[] result = new int /*long*/[1];
+	int rc = webBrowser.QueryInterface (nsIWebNavigation.NS_IWEBNAVIGATION_IID, result);
+	if (rc != XPCOM.NS_OK) error (rc);
+	if (result[0] == 0) error (XPCOM.NS_ERROR_NO_INTERFACE);
+
+	nsIWebNavigation webNavigation = new nsIWebNavigation (result[0]);
+    char[] arg = url.toCharArray (); 
+    char[] c = new char[arg.length+1];
+    System.arraycopy (arg, 0, c, 0, arg.length);
+	rc = webNavigation.LoadURI (c, nsIWebNavigation.LOAD_FLAGS_NONE, 0, 0, 0);
+	webNavigation.Release ();
+	return rc == XPCOM.NS_OK;
+}
+
+static Browser findBrowser (int /*long*/ handle) {
+	return MozillaDelegate.findBrowser (handle);
+}
+
+public boolean forward () {
+	if (awaitingNavigate) return false;
+
+	int /*long*/[] result = new int /*long*/[1];
+	int rc = webBrowser.QueryInterface (nsIWebNavigation.NS_IWEBNAVIGATION_IID, result);
+	if (rc != XPCOM.NS_OK) error (rc);
+	if (result[0] == 0) error (XPCOM.NS_ERROR_NO_INTERFACE);
+	
+	nsIWebNavigation webNavigation = new nsIWebNavigation (result[0]);
+	rc = webNavigation.GoForward ();
+	webNavigation.Release ();
+
+	return rc == XPCOM.NS_OK;
+}
+
+public String getText () {
+	if (awaitingNavigate) return ""; //$NON-NLS-1$
+
+	int /*long*/[] result = new int /*long*/[1];
+	int rc = webBrowser.GetContentDOMWindow (result);
+	if (rc != XPCOM.NS_OK) error (rc);
+	if (result[0] == 0) error (XPCOM.NS_NOINTERFACE);
+
+	nsIDOMWindow window = new nsIDOMWindow (result[0]);
+	result[0] = 0;
+	rc = window.GetDocument (result);
+	if (rc != XPCOM.NS_OK) error (rc);
+	if (result[0] == 0) error (XPCOM.NS_NOINTERFACE);
+	window.Release ();
+
+	int /*long*/ document = result[0];
+	result[0] = 0;
+	rc = XPCOM.NS_GetComponentManager (result);
+	if (rc != XPCOM.NS_OK) error (rc);
+	if (result[0] == 0) error (XPCOM.NS_NOINTERFACE);
+
+	nsIComponentManager componentManager = new nsIComponentManager (result[0]);
+	result[0] = 0;
+	byte[] contractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_DOMSERIALIZER_CONTRACTID, true);
+	char[] chars = null;
+
+	rc = componentManager.CreateInstanceByContractID (contractID, 0, nsIDOMSerializer_1_7.NS_IDOMSERIALIZER_IID, result);
+	if (rc == XPCOM.NS_OK) {	/* mozilla >= 1.7 */
+		if (result[0] == 0) error (XPCOM.NS_NOINTERFACE);
+
+		nsIDOMSerializer_1_7 serializer = new nsIDOMSerializer_1_7 (result[0]);
+		result[0] = 0;
+		int /*long*/ string = XPCOM.nsEmbedString_new ();
+		rc = serializer.SerializeToString (document, string);
+		serializer.Release ();
+
+		int length = XPCOM.nsEmbedString_Length (string);
+		int /*long*/ buffer = XPCOM.nsEmbedString_get (string);
+		chars = new char[length];
+		XPCOM.memmove (chars, buffer, length * 2);
+		XPCOM.nsEmbedString_delete (string);
+	} else {	/* mozilla < 1.7 */
+		rc = componentManager.CreateInstanceByContractID (contractID, 0, nsIDOMSerializer.NS_IDOMSERIALIZER_IID, result);
+		if (rc != XPCOM.NS_OK) error (rc);
+		if (result[0] == 0) error (XPCOM.NS_NOINTERFACE);
+
+		nsIDOMSerializer serializer = new nsIDOMSerializer (result[0]);
+		result[0] = 0;
+		rc = serializer.SerializeToString (document, result);
+		serializer.Release ();
+
+		int length = XPCOM.strlen_PRUnichar (result[0]);
+		chars = new char[length];
+		XPCOM.memmove (chars, result[0], length * 2);
+	}
+
+	componentManager.Release ();
+	new nsISupports (document).Release ();
+	return new String (chars);
+}
+
+public String getUrl () {
+	if (awaitingNavigate) return ""; //$NON-NLS-1$
+
+	int /*long*/[] result = new int /*long*/[1];
+	int rc = webBrowser.QueryInterface (nsIWebNavigation.NS_IWEBNAVIGATION_IID, result);
+	if (rc != XPCOM.NS_OK) error (rc);
+	if (result[0] == 0) error (XPCOM.NS_ERROR_NO_INTERFACE);
+
+	nsIWebNavigation webNavigation = new nsIWebNavigation (result[0]);
+	int /*long*/[] aCurrentURI = new int /*long*/[1];
+	rc = webNavigation.GetCurrentURI (aCurrentURI);
+	if (rc != XPCOM.NS_OK) error (rc);
+	webNavigation.Release ();
+
+	byte[] dest = null;
+	if (aCurrentURI[0] != 0) {
+		nsIURI uri = new nsIURI (aCurrentURI[0]);
+		int /*long*/ aSpec = XPCOM.nsEmbedCString_new ();
+		rc = uri.GetSpec (aSpec);
+		if (rc != XPCOM.NS_OK) error (rc);
+		int length = XPCOM.nsEmbedCString_Length (aSpec);
+		int /*long*/ buffer = XPCOM.nsEmbedCString_get (aSpec);
+		dest = new byte[length];
+		XPCOM.memmove (dest, buffer, length);
+		XPCOM.nsEmbedCString_delete (aSpec);
+		uri.Release ();
+	}
+	if (dest == null) return ""; //$NON-NLS-1$
+
+	String location = new String (dest);
+	/*
+	 * If the URI indicates that the page is being rendered from memory
+	 * (via setText()) then set it to about:blank to be consistent with IE.
+	 */
+	if (location.equals (URI_FROMMEMORY)) location = ABOUT_BLANK;
+	return location;
+}
+
+public Object getWebBrowser () {
+	if ((browser.getStyle () & SWT.MOZILLA) == 0) return null;
+	if (webBrowserObject != null) return webBrowserObject;
+
+	try {
+		Class clazz = Class.forName ("org.mozilla.xpcom.Mozilla"); //$NON-NLS-1$
+		Method method = clazz.getMethod ("getInstance", new Class[0]); //$NON-NLS-1$
+		Object mozilla = method.invoke (null, new Object[0]);
+		method = clazz.getMethod ("wrapXPCOMObject", new Class[] {Long.TYPE, String.class}); //$NON-NLS-1$
+		webBrowserObject = method.invoke (mozilla, new Object[] {new Long (webBrowser.getAddress ()), nsIWebBrowser.NS_IWEBBROWSER_IID_STR});
+		/*
+		 * The following AddRef() is needed to offset the automatic Release() that
+		 * will be performed by JavaXPCOM when webBrowserObject is finalized.
+		 */
+		webBrowser.AddRef ();
+		return webBrowserObject;
+	} catch (ClassNotFoundException e) {
+	} catch (NoSuchMethodException e) {
+	} catch (IllegalArgumentException e) {
+	} catch (IllegalAccessException e) {
+	} catch (InvocationTargetException e) {
+	}
+	return null;
+}
+
+public boolean isBackEnabled () {
+	if (awaitingNavigate) return false;
+
+	int /*long*/[] result = new int /*long*/[1];
+	int rc = webBrowser.QueryInterface (nsIWebNavigation.NS_IWEBNAVIGATION_IID, result);
+	if (rc != XPCOM.NS_OK) error (rc);
+	if (result[0] == 0) error (XPCOM.NS_ERROR_NO_INTERFACE);
+	
+	nsIWebNavigation webNavigation = new nsIWebNavigation (result[0]);
+	int[] aCanGoBack = new int[1]; /* PRBool */
+	rc = webNavigation.GetCanGoBack (aCanGoBack);	
+	webNavigation.Release ();
+	return aCanGoBack[0] != 0;
+}
+
+public boolean isForwardEnabled () {
+	if (awaitingNavigate) return false;
+
+	int /*long*/[] result = new int /*long*/[1];
+	int rc = webBrowser.QueryInterface (nsIWebNavigation.NS_IWEBNAVIGATION_IID, result);
+	if (rc != XPCOM.NS_OK) error (rc);
+	if (result[0] == 0) error (XPCOM.NS_ERROR_NO_INTERFACE);
+	
+	nsIWebNavigation webNavigation = new nsIWebNavigation (result[0]);
+	int[] aCanGoForward = new int[1]; /* PRBool */
+	rc = webNavigation.GetCanGoForward (aCanGoForward);
+	webNavigation.Release ();
+	return aCanGoForward[0] != 0;
+}
+
+static String error (int code) {
+	throw new SWTError ("XPCOM error " + code); //$NON-NLS-1$
+}
+
+void onDispose (Display display) {
+	int rc = webBrowser.RemoveWebBrowserListener (weakReference.getAddress (), nsIWebProgressListener.NS_IWEBPROGRESSLISTENER_IID);
+	if (rc != XPCOM.NS_OK) error (rc);
+
+	rc = webBrowser.SetParentURIContentListener (0);
+	if (rc != XPCOM.NS_OK) error (rc);
+	
+	unhookDOMListeners ();
+	if (listener != null) {
+		int[] folderEvents = new int[] {
+			SWT.Dispose,
+			SWT.Resize,  
+			SWT.FocusIn,
+			SWT.Activate,
+			SWT.Deactivate,
+			SWT.Show,
+			SWT.KeyDown,
+		};
+		for (int i = 0; i < folderEvents.length; i++) {
+			browser.removeListener (folderEvents[i], listener);
+		}
+		listener = null;
+	}
+
+	int /*long*/[] result = new int /*long*/[1];
+	rc = webBrowser.QueryInterface (nsIBaseWindow.NS_IBASEWINDOW_IID, result);
+	if (rc != XPCOM.NS_OK) error (rc);
+	if (result[0] == 0) error (XPCOM.NS_ERROR_NO_INTERFACE);
+
+	nsIBaseWindow baseWindow = new nsIBaseWindow (result[0]);
+	rc = baseWindow.Destroy ();
+	if (rc != XPCOM.NS_OK) error (rc);
+	baseWindow.Release ();
+
+	Release ();
+	webBrowser.Release ();
+	webBrowser = null;
+	webBrowserObject = null;
+
+	if (tip != null && !tip.isDisposed ()) tip.dispose ();
+	tip = null;
+	location = size = null;
+
+	Enumeration elements = unhookedDOMWindows.elements ();
+	while (elements.hasMoreElements ()) {
+		LONG ptrObject = (LONG)elements.nextElement ();
+		new nsISupports (ptrObject.value).Release ();
+	}
+	unhookedDOMWindows = null;
+
+	delegate.onDispose (embedHandle);
+	delegate = null;
+
+	embedHandle = 0;
+	BrowserCount--;
+}
+
+void Activate () {
+	int /*long*/[] result = new int /*long*/[1];
+	int rc = webBrowser.QueryInterface (nsIWebBrowserFocus.NS_IWEBBROWSERFOCUS_IID, result);
+	if (rc != XPCOM.NS_OK) error (rc);
+	if (result[0] == 0) error (XPCOM.NS_ERROR_NO_INTERFACE);
+	
+	nsIWebBrowserFocus webBrowserFocus = new nsIWebBrowserFocus (result[0]);
+	rc = webBrowserFocus.Activate ();
+	if (rc != XPCOM.NS_OK) error (rc);
+	webBrowserFocus.Release ();
+}
+	
+void Deactivate () {
+	int /*long*/[] result = new int /*long*/[1];
+	int rc = webBrowser.QueryInterface (nsIWebBrowserFocus.NS_IWEBBROWSERFOCUS_IID, result);
+	if (rc != XPCOM.NS_OK) error (rc);
+	if (result[0] == 0) error (XPCOM.NS_ERROR_NO_INTERFACE);
+	
+	nsIWebBrowserFocus webBrowserFocus = new nsIWebBrowserFocus (result[0]);
+	rc = webBrowserFocus.Deactivate ();
+	if (rc != XPCOM.NS_OK) error (rc);
+	webBrowserFocus.Release ();
+}
+
+void onResize () {
+	Rectangle rect = browser.getClientArea ();
+	int width = Math.max (1, rect.width);
+	int height = Math.max (1, rect.height);
+
+	int /*long*/[] result = new int /*long*/[1];
+	int rc = webBrowser.QueryInterface (nsIBaseWindow.NS_IBASEWINDOW_IID, result);
+	if (rc != XPCOM.NS_OK) error (rc);
+	if (result[0] == 0) error (XPCOM.NS_ERROR_NO_INTERFACE);
+
+	delegate.setSize (embedHandle, width, height);
+	nsIBaseWindow baseWindow = new nsIBaseWindow (result[0]);
+	rc = baseWindow.SetPositionAndSize (0, 0, width, height, 1);
+	if (rc != XPCOM.NS_OK) error (rc);
+	baseWindow.Release ();
+}
+
+public void refresh () {
+	if (awaitingNavigate) return;
+
+	int /*long*/[] result = new int /*long*/[1];
+	int rc = webBrowser.QueryInterface (nsIWebNavigation.NS_IWEBNAVIGATION_IID, result);
+	if (rc != XPCOM.NS_OK) error(rc);
+	if (result[0] == 0) error (XPCOM.NS_ERROR_NO_INTERFACE);
+	
+	nsIWebNavigation webNavigation = new nsIWebNavigation (result[0]);		 	
+	rc = webNavigation.Reload (nsIWebNavigation.LOAD_FLAGS_NONE);
+	webNavigation.Release ();
+	if (rc == XPCOM.NS_OK) return;
+	/*
+	* Feature in Mozilla.  Reload returns an error code NS_ERROR_INVALID_POINTER
+	* when it is called immediately after a request to load a new document using
+	* LoadURI.  The workaround is to ignore this error code.
+	*
+	* Feature in Mozilla.  Attempting to reload a file that no longer exists
+	* returns an error code of NS_ERROR_FILE_NOT_FOUND.  This is equivalent to
+	* attempting to load a non-existent local url, which is not a Browser error,
+	* so this error code should be ignored. 
+	*/
+	if (rc != XPCOM.NS_ERROR_INVALID_POINTER && rc != XPCOM.NS_ERROR_FILE_NOT_FOUND) error (rc);
+}
+
+public boolean setText (String html) {
+	/*
+	*  Feature in Mozilla.  The focus memory of Mozilla must be 
+	*  properly managed through the nsIWebBrowserFocus interface.
+	*  In particular, nsIWebBrowserFocus.deactivate must be called
+	*  when the focus moves from the browser (or one of its children
+	*  managed by Mozilla to another widget.  We currently do not
+	*  get notified when a widget takes focus away from the Browser.
+	*  As a result, deactivate is not properly called. This causes
+	*  Mozilla to retake focus the next time a document is loaded.
+	*  This breaks the case where the HTML loaded in the Browser 
+	*  varies while the user enters characters in a text widget. The text
+	*  widget loses focus every time new content is loaded.
+	*  The current workaround is to call deactivate everytime if 
+	*  the browser currently does not have focus. A better workaround
+	*  would be to have a way to call deactivate when the Browser
+	*  or one of its children loses focus.
+	*/
+	if (browser != browser.getDisplay ().getFocusControl ()) Deactivate ();
+	
+	/* convert the String containing HTML to an array of bytes with UTF-8 data */
+	byte[] data = null;
+	try {
+		data = html.getBytes ("UTF-8"); //$NON-NLS-1$
+	} catch (UnsupportedEncodingException e) {
+		return false;
+	}
+
+	awaitingNavigate = false;
+
+	byte[] contentTypeBuffer = MozillaDelegate.wcsToMbcs (null, "text/html", true); // $NON-NLS-1$
+	int /*long*/ aContentType = XPCOM.nsEmbedCString_new (contentTypeBuffer, contentTypeBuffer.length);
+	byte[] contentCharsetBuffer = MozillaDelegate.wcsToMbcs (null, "UTF-8", true);	//$NON-NLS-1$
+	int /*long*/ aContentCharset = XPCOM.nsEmbedCString_new (contentCharsetBuffer, contentCharsetBuffer.length);
+
+	int /*long*/[] result = new int /*long*/[1];
+	int rc = XPCOM.NS_GetServiceManager (result);
+	if (rc != XPCOM.NS_OK) error (rc);
+	if (result[0] == 0) error (XPCOM.NS_NOINTERFACE);
+
+	nsIServiceManager serviceManager = new nsIServiceManager (result[0]);
+	result[0] = 0;
+	rc = serviceManager.GetService (XPCOM.NS_IOSERVICE_CID, nsIIOService.NS_IIOSERVICE_IID, result);
+	if (rc != XPCOM.NS_OK) error (rc);
+	if (result[0] == 0) error (XPCOM.NS_NOINTERFACE);
+	serviceManager.Release ();
+
+	nsIIOService ioService = new nsIIOService (result[0]);
+	result[0] = 0;
+	/*
+	* Note.  Mozilla ignores LINK tags used to load CSS stylesheets
+	* when the URI protocol for the nsInputStreamChannel
+	* is about:blank.  The fix is to specify the file protocol.
+	*/
+	byte[] aString = MozillaDelegate.wcsToMbcs (null, URI_FROMMEMORY, false);
+	int /*long*/ aSpec = XPCOM.nsEmbedCString_new (aString, aString.length);
+	rc = ioService.NewURI (aSpec, null, 0, result);
+	if (rc != XPCOM.NS_OK) error (rc);
+	if (result[0] == 0) error (XPCOM.NS_NOINTERFACE);
+	XPCOM.nsEmbedCString_delete (aSpec);
+	ioService.Release ();
+
+	nsIURI uri = new nsIURI (result[0]);
+	result[0] = 0;
+
+	rc = webBrowser.QueryInterface (nsIInterfaceRequestor.NS_IINTERFACEREQUESTOR_IID, result);
+	if (rc != XPCOM.NS_OK) error (rc);
+	if (result[0] == 0) error (XPCOM.NS_ERROR_NO_INTERFACE);
+	nsIInterfaceRequestor interfaceRequestor = new nsIInterfaceRequestor (result[0]);
+	result[0] = 0;
+
+	/*
+	* Feature in Mozilla. LoadStream invokes the nsIInputStream argument
+	* through a different thread.  The callback mechanism must attach 
+	* a non java thread to the JVM otherwise the nsIInputStream Read and
+	* Close methods never get called.
+	*/
+	InputStream inputStream = new InputStream (data);
+	inputStream.AddRef ();
+
+	rc = interfaceRequestor.GetInterface (nsIDocShell_1_9.NS_IDOCSHELL_IID, result);
+	if (rc == XPCOM.NS_OK) {
+		if (result[0] == 0) error (XPCOM.NS_ERROR_NO_INTERFACE);
+		nsIDocShell_1_9 docShell = new nsIDocShell_1_9 (result[0]);
+		rc = docShell.LoadStream (inputStream.getAddress (), uri.getAddress (), aContentType,  aContentCharset, 0);
+		docShell.Release ();
+	} else {
+		result[0] = 0;
+		rc = interfaceRequestor.GetInterface (nsIDocShell_1_8.NS_IDOCSHELL_IID, result);
+		if (rc == XPCOM.NS_OK) {	
+			if (result[0] == 0) error (XPCOM.NS_ERROR_NO_INTERFACE);
+			nsIDocShell_1_8 docShell = new nsIDocShell_1_8 (result[0]);
+			rc = docShell.LoadStream (inputStream.getAddress (), uri.getAddress (), aContentType,  aContentCharset, 0);
+			docShell.Release ();
+		} else {
+			result[0] = 0;
+			rc = interfaceRequestor.GetInterface (nsIDocShell.NS_IDOCSHELL_IID, result);
+			if (rc != XPCOM.NS_OK) error (rc);
+			if (result[0] == 0) error (XPCOM.NS_ERROR_NO_INTERFACE);
+			nsIDocShell docShell = new nsIDocShell (result[0]);
+			rc = docShell.LoadStream (inputStream.getAddress (), uri.getAddress (), aContentType,  aContentCharset, 0);
+			docShell.Release ();
+		}
+	}
+	if (rc != XPCOM.NS_OK) error (rc);
+	result[0] = 0;
+
+	inputStream.Release ();
+	interfaceRequestor.Release ();
+	uri.Release ();
+	XPCOM.nsEmbedCString_delete (aContentCharset);
+	XPCOM.nsEmbedCString_delete (aContentType);
+	return true;
+}
+
+public boolean setUrl (String url) {
+	awaitingNavigate = false;
+
+	int /*long*/[] result = new int /*long*/[1];
+	int rc = webBrowser.QueryInterface (nsIWebNavigation.NS_IWEBNAVIGATION_IID, result);
+	if (rc != XPCOM.NS_OK) error (rc);
+	if (result[0] == 0) error (XPCOM.NS_ERROR_NO_INTERFACE);
+
+	nsIWebNavigation webNavigation = new nsIWebNavigation (result[0]);
+    char[] uri = new char[url.length () + 1];
+    url.getChars (0, url.length (), uri, 0);
+	rc = webNavigation.LoadURI (uri, nsIWebNavigation.LOAD_FLAGS_NONE, 0, 0, 0);
+	webNavigation.Release ();
+	return rc == XPCOM.NS_OK;
+}
+
+public void stop () {
+	if (awaitingNavigate) return;
+
+	int /*long*/[] result = new int /*long*/[1];
+	int rc = webBrowser.QueryInterface (nsIWebNavigation.NS_IWEBNAVIGATION_IID, result);
+	if (rc != XPCOM.NS_OK) error (rc);
+	if (result[0] == 0) error (XPCOM.NS_ERROR_NO_INTERFACE);
+	
+	nsIWebNavigation webNavigation = new nsIWebNavigation (result[0]);	 	
+	rc = webNavigation.Stop (nsIWebNavigation.STOP_ALL);
+	if (rc != XPCOM.NS_OK) error (rc);
+	webNavigation.Release ();
+}
+
+void hookDOMListeners (nsIDOMEventTarget target, boolean isTop) {
+	nsEmbedString string = new nsEmbedString (XPCOM.DOMEVENT_FOCUS);
+	target.AddEventListener (string.getAddress (), domEventListener.getAddress (), 0);
+	string.dispose ();
+	string = new nsEmbedString (XPCOM.DOMEVENT_UNLOAD);
+	target.AddEventListener (string.getAddress (), domEventListener.getAddress (), 0);
+	string.dispose ();
+	string = new nsEmbedString (XPCOM.DOMEVENT_MOUSEDOWN);
+	target.AddEventListener (string.getAddress (), domEventListener.getAddress (), 0);
+	string.dispose ();
+	string = new nsEmbedString (XPCOM.DOMEVENT_MOUSEUP);
+	target.AddEventListener (string.getAddress (), domEventListener.getAddress (), 0);
+	string.dispose ();
+	string = new nsEmbedString (XPCOM.DOMEVENT_MOUSEMOVE);
+	target.AddEventListener (string.getAddress (), domEventListener.getAddress (), 0);
+	string.dispose ();
+	string = new nsEmbedString (XPCOM.DOMEVENT_MOUSEWHEEL);
+	target.AddEventListener (string.getAddress (), domEventListener.getAddress (), 0);
+	string.dispose ();
+	string = new nsEmbedString (XPCOM.DOMEVENT_MOUSEDRAG);
+	target.AddEventListener (string.getAddress (), domEventListener.getAddress (), 0);
+	string.dispose ();
+
+	/*
+	* Only hook mouseover and mouseout if the target is a top-level frame, so that mouse moves
+	* between frames will not generate events.
+	*/
+	if (isTop && delegate.hookEnterExit ()) {
+		string = new nsEmbedString (XPCOM.DOMEVENT_MOUSEOVER);
+		target.AddEventListener (string.getAddress (), domEventListener.getAddress (), 0);
+		string.dispose ();
+		string = new nsEmbedString (XPCOM.DOMEVENT_MOUSEOUT);
+		target.AddEventListener (string.getAddress (), domEventListener.getAddress (), 0);
+		string.dispose ();
+	}
+
+	string = new nsEmbedString (XPCOM.DOMEVENT_KEYDOWN);
+	target.AddEventListener (string.getAddress (), domEventListener.getAddress (), 0);
+	string.dispose ();
+	string = new nsEmbedString (XPCOM.DOMEVENT_KEYPRESS);
+	target.AddEventListener (string.getAddress (), domEventListener.getAddress (), 0);
+	string.dispose ();
+	string = new nsEmbedString (XPCOM.DOMEVENT_KEYUP);
+	target.AddEventListener (string.getAddress (), domEventListener.getAddress (), 0);
+	string.dispose ();
+}
+
+void unhookDOMListeners () {
+	int /*long*/[] result = new int /*long*/[1];
+	int rc = webBrowser.GetContentDOMWindow (result);
+	if (rc != XPCOM.NS_OK) error (rc);
+	if (result[0] == 0) error (XPCOM.NS_ERROR_NO_INTERFACE);
+
+	nsIDOMWindow window = new nsIDOMWindow (result[0]);
+	result[0] = 0;
+	rc = window.QueryInterface (nsIDOMEventTarget.NS_IDOMEVENTTARGET_IID, result);
+	if (rc != XPCOM.NS_OK) error (rc);
+	if (result[0] == 0) error (XPCOM.NS_ERROR_NO_INTERFACE);
+
+	nsIDOMEventTarget target = new nsIDOMEventTarget (result[0]);
+	result[0] = 0;
+	unhookDOMListeners (target);
+	target.Release ();
+
+	/* Listeners must be unhooked in pages contained in frames */
+	rc = window.GetFrames (result);
+	if (rc != XPCOM.NS_OK) error (rc);
+	if (result[0] == 0) error (XPCOM.NS_ERROR_NO_INTERFACE);
+	nsIDOMWindowCollection frames = new nsIDOMWindowCollection (result[0]);
+	result[0] = 0;
+	int[] frameCount = new int[1];
+	rc = frames.GetLength (frameCount); /* PRUint32 */
+	if (rc != XPCOM.NS_OK) error (rc);
+	int count = frameCount[0];
+
+	if (count > 0) {
+		for (int i = 0; i < count; i++) {
+			rc = frames.Item (i, result);
+			if (rc != XPCOM.NS_OK) error (rc);
+			if (result[0] == 0) error (XPCOM.NS_ERROR_NO_INTERFACE);
+
+			nsIDOMWindow frame = new nsIDOMWindow (result[0]);
+			result[0] = 0;
+			rc = frame.QueryInterface (nsIDOMEventTarget.NS_IDOMEVENTTARGET_IID, result);
+			if (rc != XPCOM.NS_OK) error (rc);
+			if (result[0] == 0) error (XPCOM.NS_ERROR_NO_INTERFACE);
+
+			target = new nsIDOMEventTarget (result[0]);
+			result[0] = 0;
+			unhookDOMListeners (target);
+			target.Release ();
+			frame.Release ();
+		}
+	}
+	frames.Release ();
+	window.Release ();
+}
+
+void unhookDOMListeners (nsIDOMEventTarget target) {
+	nsEmbedString string = new nsEmbedString (XPCOM.DOMEVENT_FOCUS);
+	target.RemoveEventListener (string.getAddress (), domEventListener.getAddress (), 0);
+	string.dispose ();
+	string = new nsEmbedString (XPCOM.DOMEVENT_UNLOAD);
+	target.RemoveEventListener (string.getAddress (), domEventListener.getAddress (), 0);
+	string.dispose ();
+	string = new nsEmbedString (XPCOM.DOMEVENT_MOUSEDOWN);
+	target.RemoveEventListener (string.getAddress (), domEventListener.getAddress (), 0);
+	string.dispose ();
+	string = new nsEmbedString (XPCOM.DOMEVENT_MOUSEUP);
+	target.RemoveEventListener (string.getAddress (), domEventListener.getAddress (), 0);
+	string.dispose ();
+	string = new nsEmbedString (XPCOM.DOMEVENT_MOUSEMOVE);
+	target.RemoveEventListener (string.getAddress (), domEventListener.getAddress (), 0);
+	string.dispose ();
+	string = new nsEmbedString (XPCOM.DOMEVENT_MOUSEWHEEL);
+	target.RemoveEventListener (string.getAddress (), domEventListener.getAddress (), 0);
+	string.dispose ();
+	string = new nsEmbedString (XPCOM.DOMEVENT_MOUSEDRAG);
+	target.RemoveEventListener (string.getAddress (), domEventListener.getAddress (), 0);
+	string.dispose ();
+	string = new nsEmbedString (XPCOM.DOMEVENT_MOUSEOVER);
+	target.RemoveEventListener (string.getAddress (), domEventListener.getAddress (), 0);
+	string.dispose ();
+	string = new nsEmbedString (XPCOM.DOMEVENT_MOUSEOUT);
+	target.RemoveEventListener (string.getAddress (), domEventListener.getAddress (), 0);
+	string.dispose ();
+	string = new nsEmbedString (XPCOM.DOMEVENT_KEYDOWN);
+	target.RemoveEventListener (string.getAddress (), domEventListener.getAddress (), 0);
+	string.dispose ();
+	string = new nsEmbedString (XPCOM.DOMEVENT_KEYPRESS);
+	target.RemoveEventListener (string.getAddress (), domEventListener.getAddress (), 0);
+	string.dispose ();
+	string = new nsEmbedString (XPCOM.DOMEVENT_KEYUP);
+	target.RemoveEventListener (string.getAddress (), domEventListener.getAddress (), 0);
+	string.dispose ();
+}
+
+/* nsISupports */
+
+int QueryInterface (int /*long*/ riid, int /*long*/ ppvObject) {
+	if (riid == 0 || ppvObject == 0) return XPCOM.NS_ERROR_NO_INTERFACE;
+
+	nsID guid = new nsID ();
+	XPCOM.memmove (guid, riid, nsID.sizeof);
+
+	if (guid.Equals (nsISupports.NS_ISUPPORTS_IID)) {
+		XPCOM.memmove (ppvObject, new int /*long*/[] {supports.getAddress ()}, C.PTR_SIZEOF);
+		AddRef ();
+		return XPCOM.NS_OK;
+	}
+	if (guid.Equals (nsIWeakReference.NS_IWEAKREFERENCE_IID)) {
+		XPCOM.memmove (ppvObject, new int /*long*/[] {weakReference.getAddress ()}, C.PTR_SIZEOF);
+		AddRef ();
+		return XPCOM.NS_OK;
+	}
+	if (guid.Equals (nsIWebProgressListener.NS_IWEBPROGRESSLISTENER_IID)) {
+		XPCOM.memmove (ppvObject, new int /*long*/[] {webProgressListener.getAddress ()}, C.PTR_SIZEOF);
+		AddRef ();
+		return XPCOM.NS_OK;
+	}
+	if (guid.Equals (nsIWebBrowserChrome.NS_IWEBBROWSERCHROME_IID)) {
+		XPCOM.memmove (ppvObject, new int /*long*/[] {webBrowserChrome.getAddress ()}, C.PTR_SIZEOF);
+		AddRef ();
+		return XPCOM.NS_OK;
+	}
+	if (guid.Equals (nsIWebBrowserChromeFocus.NS_IWEBBROWSERCHROMEFOCUS_IID)) {
+		XPCOM.memmove (ppvObject, new int /*long*/[] {webBrowserChromeFocus.getAddress ()}, C.PTR_SIZEOF);
+		AddRef ();
+		return XPCOM.NS_OK;
+	}
+	if (guid.Equals (nsIEmbeddingSiteWindow.NS_IEMBEDDINGSITEWINDOW_IID)) {
+		XPCOM.memmove (ppvObject, new int /*long*/[] {embeddingSiteWindow.getAddress ()}, C.PTR_SIZEOF);
+		AddRef ();
+		return XPCOM.NS_OK;
+	}
+	if (guid.Equals (nsIInterfaceRequestor.NS_IINTERFACEREQUESTOR_IID)) {
+		XPCOM.memmove (ppvObject, new int /*long*/[] {interfaceRequestor.getAddress ()}, C.PTR_SIZEOF);
+		AddRef ();
+		return XPCOM.NS_OK;
+	}
+	if (guid.Equals (nsISupportsWeakReference.NS_ISUPPORTSWEAKREFERENCE_IID)) {
+		XPCOM.memmove (ppvObject, new int /*long*/[] {supportsWeakReference.getAddress ()}, C.PTR_SIZEOF);
+		AddRef ();
+		return XPCOM.NS_OK;
+	}
+	if (guid.Equals (nsIContextMenuListener.NS_ICONTEXTMENULISTENER_IID)) {
+		XPCOM.memmove (ppvObject, new int /*long*/[] {contextMenuListener.getAddress ()}, C.PTR_SIZEOF);
+		AddRef ();
+		return XPCOM.NS_OK;
+	}
+	if (guid.Equals (nsIURIContentListener.NS_IURICONTENTLISTENER_IID)) {
+		XPCOM.memmove (ppvObject, new int /*long*/[] {uriContentListener.getAddress ()}, C.PTR_SIZEOF);
+		AddRef ();
+		return XPCOM.NS_OK;
+	}
+	if (guid.Equals (nsITooltipListener.NS_ITOOLTIPLISTENER_IID)) {
+		XPCOM.memmove (ppvObject, new int /*long*/[] {tooltipListener.getAddress ()}, C.PTR_SIZEOF);
+		AddRef ();
+		return XPCOM.NS_OK;
+	}
+	XPCOM.memmove (ppvObject, new int /*long*/[] {0}, C.PTR_SIZEOF);
+	return XPCOM.NS_ERROR_NO_INTERFACE;
+}
+
+int AddRef () {
+	refCount++;
+	return refCount;
+}
+
+int Release () {
+	refCount--;
+	if (refCount == 0) disposeCOMInterfaces ();
+	return refCount;
+}
+
+/* nsIWeakReference */	
+	
+int QueryReferent (int /*long*/ riid, int /*long*/ ppvObject) {
+	return QueryInterface (riid, ppvObject);
+}
+
+/* nsIInterfaceRequestor */
+
+int GetInterface (int /*long*/ riid, int /*long*/ ppvObject) {
+	if (riid == 0 || ppvObject == 0) return XPCOM.NS_ERROR_NO_INTERFACE;
+	nsID guid = new nsID ();
+	XPCOM.memmove (guid, riid, nsID.sizeof);
+	if (guid.Equals (nsIDOMWindow.NS_IDOMWINDOW_IID)) {
+		int /*long*/[] aContentDOMWindow = new int /*long*/[1];
+		int rc = webBrowser.GetContentDOMWindow (aContentDOMWindow);
+		if (rc != XPCOM.NS_OK) error (rc);
+		if (aContentDOMWindow[0] == 0) error (XPCOM.NS_ERROR_NO_INTERFACE);
+		XPCOM.memmove (ppvObject, aContentDOMWindow, C.PTR_SIZEOF);
+		return rc;
+	}
+	return QueryInterface (riid, ppvObject);
+}
+
+int GetWeakReference (int /*long*/ ppvObject) {
+	XPCOM.memmove (ppvObject, new int /*long*/[] {weakReference.getAddress ()}, C.PTR_SIZEOF);
+	AddRef ();
+	return XPCOM.NS_OK;
+}
+
+/* nsIWebProgressListener */
+
+int OnStateChange (int /*long*/ aWebProgress, int /*long*/ aRequest, int aStateFlags, int aStatus) {
+	if ((aStateFlags & nsIWebProgressListener.STATE_IS_DOCUMENT) == 0) return XPCOM.NS_OK;
+	if ((aStateFlags & nsIWebProgressListener.STATE_START) != 0) {
+		if (request == 0) request = aRequest;
+
+		if (!awaitingNavigate) {
+			/*
+			 * Add the page's nsIDOMWindow to the collection of windows that will
+			 * have DOM listeners added to them later on in the page loading
+			 * process.  These listeners cannot be added yet because the
+			 * nsIDOMWindow is not ready to take them at this stage.
+			 */
+			int /*long*/[] result = new int /*long*/[1];
+			nsIWebProgress progress = new nsIWebProgress (aWebProgress);
+			int rc = progress.GetDOMWindow (result);
+			if (rc != XPCOM.NS_OK) error (rc);
+			if (result[0] == 0) error (XPCOM.NS_NOINTERFACE);
+			unhookedDOMWindows.addElement (new LONG (result[0]));
+		}
+	} else if ((aStateFlags & nsIWebProgressListener.STATE_REDIRECTING) != 0) {
+		if (request == aRequest) request = 0;
+	} else if ((aStateFlags & nsIWebProgressListener.STATE_STOP) != 0) {
+		/*
+		* If this page's nsIDOMWindow handle is still in unhookedDOMWindows then
+		* add its DOM listeners now.  It's possible for this to happen since
+		* there is no guarantee that a STATE_TRANSFERRING state change will be
+		* received for every window in a page, which is when these listeners
+		* are typically added.
+		*/
+		int /*long*/[] result = new int /*long*/[1];
+		nsIWebProgress progress = new nsIWebProgress (aWebProgress);
+		int rc = progress.GetDOMWindow (result);
+		if (rc != XPCOM.NS_OK) error (rc);
+		if (result[0] == 0) error (XPCOM.NS_NOINTERFACE);
+		nsIDOMWindow domWindow = new nsIDOMWindow (result[0]);
+
+		LONG ptrObject = new LONG (result[0]);
+		result[0] = 0;
+		int index = unhookedDOMWindows.indexOf (ptrObject);
+		if (index != -1) {
+			rc = webBrowser.GetContentDOMWindow (result);
+			if (rc != XPCOM.NS_OK) error (rc);
+			if (result[0] == 0) error (XPCOM.NS_ERROR_NO_INTERFACE);
+			boolean isTop = result[0] == domWindow.getAddress ();
+			new nsISupports (result[0]).Release ();
+			result[0] = 0;
+
+			rc = domWindow.QueryInterface (nsIDOMEventTarget.NS_IDOMEVENTTARGET_IID, result);
+			if (rc != XPCOM.NS_OK) error (rc);
+			if (result[0] == 0) error (XPCOM.NS_ERROR_NO_INTERFACE);
+
+			nsIDOMEventTarget target = new nsIDOMEventTarget (result[0]);
+			result[0] = 0;
+			hookDOMListeners (target, isTop);
+			target.Release ();
+
+			/*
+			* Remove and unreference the nsIDOMWindow from the collection of windows
+			* that are waiting to have DOM listeners hooked on them. 
+			*/
+			unhookedDOMWindows.remove (ptrObject);
+			new nsISupports (ptrObject.value).Release ();
+		}
+		domWindow.Release ();
+
+		/*
+		* Feature in Mozilla.  When a request is redirected (STATE_REDIRECTING),
+		* it never reaches the state STATE_STOP and it is replaced with a new request.
+		* The new request is received when it is in the state STATE_STOP.
+		* To handle this case,  the variable request is set to 0 when the corresponding
+		* request is redirected. The following request received with the state STATE_STOP
+		* - the new request resulting from the redirection - is used to send
+		* the ProgressListener.completed event.
+		*/
+		if (request == aRequest || request == 0) {
+			request = 0;
+			if (!awaitingNavigate) {
+				StatusTextEvent event = new StatusTextEvent (browser);
+				event.display = browser.getDisplay ();
+				event.widget = browser;
+				event.text = ""; //$NON-NLS-1$
+				for (int i = 0; i < statusTextListeners.length; i++) {
+					statusTextListeners[i].changed (event);
+				}
+				ProgressEvent event2 = new ProgressEvent (browser);
+				event2.display = browser.getDisplay ();
+				event2.widget = browser;
+				for (int i = 0; i < progressListeners.length; i++) {
+					progressListeners[i].completed (event2);
+				}
+			}
+		}
+	} else if ((aStateFlags & nsIWebProgressListener.STATE_TRANSFERRING) != 0) {
+		/*
+		* Hook DOM listeners to the page's nsIDOMWindow here because this is
+		* the earliest opportunity to do so.    
+		*/
+		int /*long*/[] result = new int /*long*/[1];
+		nsIWebProgress progress = new nsIWebProgress (aWebProgress);
+		int rc = progress.GetDOMWindow (result);
+		if (rc != XPCOM.NS_OK) error (rc);
+		if (result[0] == 0) error (XPCOM.NS_NOINTERFACE);
+		nsIDOMWindow domWindow = new nsIDOMWindow (result[0]);
+
+		LONG ptrObject = new LONG (result[0]);
+		result[0] = 0;
+		int index = unhookedDOMWindows.indexOf (ptrObject);
+		if (index != -1) {
+			rc = webBrowser.GetContentDOMWindow (result);
+			if (rc != XPCOM.NS_OK) error (rc);
+			if (result[0] == 0) error (XPCOM.NS_ERROR_NO_INTERFACE);
+			boolean isTop = result[0] == domWindow.getAddress ();
+			new nsISupports (result[0]).Release ();
+			result[0] = 0;
+
+			rc = domWindow.QueryInterface (nsIDOMEventTarget.NS_IDOMEVENTTARGET_IID, result);
+			if (rc != XPCOM.NS_OK) error (rc);
+			if (result[0] == 0) error (XPCOM.NS_ERROR_NO_INTERFACE);
+
+			nsIDOMEventTarget target = new nsIDOMEventTarget (result[0]);
+			result[0] = 0;
+			hookDOMListeners (target, isTop);
+			target.Release ();
+
+			/*
+			* Remove and unreference the nsIDOMWindow from the collection of windows
+			* that are waiting to have DOM listeners hooked on them. 
+			*/
+			unhookedDOMWindows.remove (ptrObject);
+			new nsISupports (ptrObject.value).Release ();
+		}
+		domWindow.Release ();
+	}
+	return XPCOM.NS_OK;
+}
+
+int OnProgressChange (int /*long*/ aWebProgress, int /*long*/ aRequest, int aCurSelfProgress, int aMaxSelfProgress, int aCurTotalProgress, int aMaxTotalProgress) {
+	if (awaitingNavigate || progressListeners.length == 0) return XPCOM.NS_OK;
+	ProgressEvent event = new ProgressEvent (browser);
+	event.display = browser.getDisplay ();
+	event.widget = browser;
+	event.current = aCurTotalProgress;
+	event.total = aMaxTotalProgress;
+	for (int i = 0; i < progressListeners.length; i++) {
+		progressListeners[i].changed (event);
+	}
+	return XPCOM.NS_OK;
+}
+
+int OnLocationChange (int /*long*/ aWebProgress, int /*long*/ aRequest, int /*long*/ aLocation) {
+	/*
+	* Feature in Mozilla.  When a page is loaded via setText before a previous
+	* setText page load has completed, the expected OnStateChange STATE_STOP for the
+	* original setText never arrives because it gets replaced by the OnStateChange
+	* STATE_STOP for the new request.  This results in the request field never being
+	* cleared because the original request's OnStateChange STATE_STOP is still expected
+	* (but never arrives).  To handle this case, the request field is updated to the new
+	* overriding request since its OnStateChange STATE_STOP will be received next.
+	*/
+	if (request != 0 && request != aRequest) request = aRequest;
+
+	if (awaitingNavigate || locationListeners.length == 0) return XPCOM.NS_OK;
+
+	nsIWebProgress webProgress = new nsIWebProgress (aWebProgress);
+	int /*long*/[] aDOMWindow = new int /*long*/[1];
+	int rc = webProgress.GetDOMWindow (aDOMWindow);
+	if (rc != XPCOM.NS_OK) error (rc);
+	if (aDOMWindow[0] == 0) error (XPCOM.NS_ERROR_NO_INTERFACE);
+	
+	nsIDOMWindow domWindow = new nsIDOMWindow (aDOMWindow[0]);
+	int /*long*/[] aTop = new int /*long*/[1];
+	rc = domWindow.GetTop (aTop);
+	if (rc != XPCOM.NS_OK) error (rc);
+	if (aTop[0] == 0) error (XPCOM.NS_ERROR_NO_INTERFACE);
+	domWindow.Release ();
+	
+	nsIDOMWindow topWindow = new nsIDOMWindow (aTop[0]);
+	topWindow.Release ();
+	
+	nsIURI location = new nsIURI (aLocation);
+	int /*long*/ aSpec = XPCOM.nsEmbedCString_new ();
+	location.GetSpec (aSpec);
+	int length = XPCOM.nsEmbedCString_Length (aSpec);
+	int /*long*/ buffer = XPCOM.nsEmbedCString_get (aSpec);
+	byte[] dest = new byte[length];
+	XPCOM.memmove (dest, buffer, length);
+	XPCOM.nsEmbedCString_delete (aSpec);
+	String url = new String (dest);
+
+	/*
+	 * As of Mozilla 1.8, the first time that a page is displayed, regardless of
+	 * whether it's via Browser.setURL() or Browser.setText(), the GRE navigates
+	 * to about:blank and fires the corresponding navigation events.  Do not send
+	 * this event on to the user since it is not expected.
+	 */
+	if (!IsPre_1_8 && aRequest == 0 && url.startsWith (ABOUT_BLANK)) return XPCOM.NS_OK;
+
+	LocationEvent event = new LocationEvent (browser);
+	event.display = browser.getDisplay ();
+	event.widget = browser;
+	event.location = url;
+	/*
+	 * If the URI indicates that the page is being rendered from memory
+	 * (via setText()) then set it to about:blank to be consistent with IE.
+	 */
+	if (event.location.equals (URI_FROMMEMORY)) event.location = ABOUT_BLANK;
+	event.top = aTop[0] == aDOMWindow[0];
+	for (int i = 0; i < locationListeners.length; i++) {
+		locationListeners[i].changed (event);
+	}
+	return XPCOM.NS_OK;
+}
+
+int OnStatusChange (int /*long*/ aWebProgress, int /*long*/ aRequest, int aStatus, int /*long*/ aMessage) {
+	if (awaitingNavigate || statusTextListeners.length == 0) return XPCOM.NS_OK;
+	StatusTextEvent event = new StatusTextEvent (browser);
+	event.display = browser.getDisplay ();
+	event.widget = browser;
+	int length = XPCOM.strlen_PRUnichar (aMessage);
+	char[] dest = new char[length];
+	XPCOM.memmove (dest, aMessage, length * 2);
+	event.text = new String (dest);
+	for (int i = 0; i < statusTextListeners.length; i++) {
+		statusTextListeners[i].changed (event);
+	}
+	return XPCOM.NS_OK;
+}		
+
+int OnSecurityChange (int /*long*/ aWebProgress, int /*long*/ aRequest, int state) {
+	return XPCOM.NS_OK;
+}
+
+/* nsIWebBrowserChrome */
+
+int SetStatus (int statusType, int /*long*/ status) {
+	if (awaitingNavigate || statusTextListeners.length == 0) return XPCOM.NS_OK;
+	StatusTextEvent event = new StatusTextEvent (browser);
+	event.display = browser.getDisplay ();
+	event.widget = browser;
+	int length = XPCOM.strlen_PRUnichar (status);
+	char[] dest = new char[length];
+	XPCOM.memmove (dest, status, length * 2);
+	String string = new String (dest);
+	event.text = string;
+	for (int i = 0; i < statusTextListeners.length; i++) {
+		statusTextListeners[i].changed (event);
+	}
+	return XPCOM.NS_OK;
+}
+
+int GetWebBrowser (int /*long*/ aWebBrowser) {
+	int /*long*/[] ret = new int /*long*/[1];	
+	if (webBrowser != null) {
+		webBrowser.AddRef ();
+		ret[0] = webBrowser.getAddress ();	
+	}
+	XPCOM.memmove (aWebBrowser, ret, C.PTR_SIZEOF);
+	return XPCOM.NS_OK;
+}
+
+int SetWebBrowser (int /*long*/ aWebBrowser) {
+	if (webBrowser != null) webBrowser.Release ();
+	webBrowser = aWebBrowser != 0 ? new nsIWebBrowser (aWebBrowser) : null;  				
+	return XPCOM.NS_OK;
+}
+   
+int GetChromeFlags (int /*long*/ aChromeFlags) {
+	int[] ret = new int[1];
+	ret[0] = chromeFlags;
+	XPCOM.memmove (aChromeFlags, ret, 4); /* PRUint32 */
+	return XPCOM.NS_OK;
+}
+
+int SetChromeFlags (int aChromeFlags) {
+	chromeFlags = aChromeFlags;
+	return XPCOM.NS_OK;
+}
+
+int DestroyBrowserWindow () {
+	WindowEvent newEvent = new WindowEvent (browser);
+	newEvent.display = browser.getDisplay ();
+	newEvent.widget = browser;
+	for (int i = 0; i < closeWindowListeners.length; i++) {
+		closeWindowListeners[i].close (newEvent);
+	}
+	/*
+	* Note on Mozilla.  The DestroyBrowserWindow notification cannot be cancelled.
+	* The browser widget cannot be used after this notification has been received.
+	* The application is advised to close the window hosting the browser widget.
+	* The browser widget must be disposed in all cases.
+	*/
+	browser.dispose ();
+	return XPCOM.NS_OK;
+}
+   	
+int SizeBrowserTo (int aCX, int aCY) {
+	size = new Point (aCX, aCY);
+	boolean isChrome = (chromeFlags & nsIWebBrowserChrome.CHROME_OPENAS_CHROME) != 0;
+	if (isChrome) {
+		Shell shell = browser.getShell ();
+		shell.setSize (shell.computeSize (size.x, size.y));
+	}
+	return XPCOM.NS_OK;
+}
+
+int ShowAsModal () {
+	int /*long*/[] result = new int /*long*/[1];
+	int rc = XPCOM.NS_GetServiceManager (result);
+	if (rc != XPCOM.NS_OK) error (rc);
+	if (result[0] == 0) error (XPCOM.NS_NOINTERFACE);
+
+	nsIServiceManager serviceManager = new nsIServiceManager (result[0]);
+	result[0] = 0;
+	byte[] aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_CONTEXTSTACK_CONTRACTID, true);
+	rc = serviceManager.GetServiceByContractID (aContractID, nsIJSContextStack.NS_IJSCONTEXTSTACK_IID, result);
+	if (rc != XPCOM.NS_OK) error (rc);
+	if (result[0] == 0) error (XPCOM.NS_NOINTERFACE);
+	serviceManager.Release ();
+
+	nsIJSContextStack stack = new nsIJSContextStack (result[0]);
+	result[0] = 0;
+	rc = stack.Push (0);
+	if (rc != XPCOM.NS_OK) error (rc);
+
+	Shell shell = browser.getShell ();
+	Display display = browser.getDisplay ();
+	while (!shell.isDisposed ()) {
+		if (!display.readAndDispatch ()) display.sleep ();
+	}
+
+	rc = stack.Pop (result);
+	if (rc != XPCOM.NS_OK) error (rc);
+	stack.Release ();
+	return XPCOM.NS_OK;
+}
+
+int IsWindowModal (int /*long*/ retval) {
+	int result = (chromeFlags & nsIWebBrowserChrome.CHROME_MODAL) != 0 ? 1 : 0;
+	XPCOM.memmove (retval, new int[] {result}, 4); /* PRBool */
+	return XPCOM.NS_OK;
+}
+   
+int ExitModalEventLoop (int aStatus) {
+	return XPCOM.NS_OK;
+}
+
+/* nsIEmbeddingSiteWindow */ 
+
+int SetDimensions (int flags, int x, int y, int cx, int cy) {
+	if ((flags & nsIEmbeddingSiteWindow.DIM_FLAGS_POSITION) != 0) {
+		location = new Point (x, y);
+		browser.getShell ().setLocation (x, y);
+	}
+	if ((flags & nsIEmbeddingSiteWindow.DIM_FLAGS_SIZE_INNER) != 0) {
+		browser.setSize (cx, cy);
+	}
+	if ((flags & nsIEmbeddingSiteWindow.DIM_FLAGS_SIZE_OUTER) != 0) {
+		browser.getShell ().setSize (cx, cy);
+	}
+	return XPCOM.NS_OK;
+}
+
+int GetDimensions (int flags, int /*long*/ x, int /*long*/ y, int /*long*/ cx, int /*long*/ cy) {
+	if ((flags & nsIEmbeddingSiteWindow.DIM_FLAGS_POSITION) != 0) {
+		Point location = browser.getShell ().getLocation ();
+		if (x != 0) C.memmove (x, new int[] {location.x}, 4); /* PRInt32 */
+		if (y != 0) C.memmove (y, new int[] {location.y}, 4); /* PRInt32 */
+	}
+	if ((flags & nsIEmbeddingSiteWindow.DIM_FLAGS_SIZE_INNER) != 0) {
+		Point size = browser.getSize ();
+		if (cx != 0) C.memmove (cx, new int[] {size.x}, 4); /* PRInt32 */
+		if (cy != 0) C.memmove (cy, new int[] {size.y}, 4); /* PRInt32 */
+	}
+	if ((flags & nsIEmbeddingSiteWindow.DIM_FLAGS_SIZE_OUTER) != 0) {
+		Point size = browser.getShell().getSize ();
+		if (cx != 0) C.memmove (cx, new int[] {size.x}, 4); /* PRInt32 */
+		if (cy != 0) C.memmove (cy, new int[] {size.y}, 4); /* PRInt32 */
+	}
+	return XPCOM.NS_OK;
+}
+
+int SetFocus () {
+	int /*long*/[] result = new int /*long*/[1];
+	int rc = webBrowser.QueryInterface (nsIBaseWindow.NS_IBASEWINDOW_IID, result);
+	if (rc != XPCOM.NS_OK) error (rc);
+	if (result[0] == 0) error (XPCOM.NS_ERROR_NO_INTERFACE);
+	
+	nsIBaseWindow baseWindow = new nsIBaseWindow (result[0]);
+	rc = baseWindow.SetFocus ();
+	if (rc != XPCOM.NS_OK) error (rc);
+	baseWindow.Release ();
+
+	/*
+	* Note. Mozilla notifies here that one of the children took
+	* focus. This could or should be used to fire an SWT.FOCUS_IN
+	* event on Browser focus listeners.
+	*/
+	return XPCOM.NS_OK;     	
+}	
+
+int GetVisibility (int /*long*/ aVisibility) {
+	boolean visible = browser.isVisible () && !browser.getShell ().getMinimized ();
+	XPCOM.memmove (aVisibility, new int[] {visible ? 1 : 0}, 4); /* PRBool */
+	return XPCOM.NS_OK;
+}
+
+int SetVisibility (int aVisibility) {
+	if (isChild) {
+		WindowEvent event = new WindowEvent (browser);
+		event.display = browser.getDisplay ();
+		event.widget = browser;
+		if (aVisibility != 0) {
+			/*
+			* Bug in Mozilla.  When the JavaScript window.open is executed, Mozilla
+			* fires multiple SetVisibility 1 notifications.  The workaround is
+			* to ignore subsequent notifications. 
+			*/
+			if (!visible) {
+				visible = true;
+				event.location = location;
+				event.size = size;
+				event.addressBar = (chromeFlags & nsIWebBrowserChrome.CHROME_LOCATIONBAR) != 0;
+				event.menuBar = (chromeFlags & nsIWebBrowserChrome.CHROME_MENUBAR) != 0;
+				event.statusBar = (chromeFlags & nsIWebBrowserChrome.CHROME_STATUSBAR) != 0;
+				event.toolBar = (chromeFlags & nsIWebBrowserChrome.CHROME_TOOLBAR) != 0;
+				for (int i = 0; i < visibilityWindowListeners.length; i++) {
+					visibilityWindowListeners[i].show (event);
+				}
+				location = null;
+				size = null;
+			}
+		} else {
+			visible = false;
+			for (int i = 0; i < visibilityWindowListeners.length; i++) {
+				visibilityWindowListeners[i].hide (event);
+			}
+		}
+	} else {
+		visible = aVisibility != 0;
+	}
+	return XPCOM.NS_OK;     	
+}
+
+int GetTitle (int /*long*/ aTitle) {
+	return XPCOM.NS_OK;     	
+}
+ 
+int SetTitle (int /*long*/ aTitle) {
+	if (awaitingNavigate || titleListeners.length == 0) return XPCOM.NS_OK;
+	TitleEvent event = new TitleEvent (browser);
+	event.display = browser.getDisplay ();
+	event.widget = browser;
+	/*
+	* To be consistent with other platforms the title event should
+	* contain the page's url if the page does not contain a <title>
+	* tag. 
+	*/
+	int length = XPCOM.strlen_PRUnichar (aTitle);
+	if (length > 0) {
+		char[] dest = new char[length];
+		XPCOM.memmove (dest, aTitle, length * 2);
+		event.title = new String (dest);
+	} else {
+		event.title = getUrl ();
+	}
+	for (int i = 0; i < titleListeners.length; i++) {
+		titleListeners[i].changed (event);
+	}
+	return XPCOM.NS_OK;     	
+}
+
+int GetSiteWindow (int /*long*/ aSiteWindow) {
+	/*
+	* Note.  The handle is expected to be an HWND on Windows and
+	* a GtkWidget* on GTK.  This callback is invoked on Windows
+	* when the javascript window.print is invoked and the print
+	* dialog comes up. If no handle is returned, the print dialog
+	* does not come up on this platform.  
+	*/
+	XPCOM.memmove (aSiteWindow, new int /*long*/[] {embedHandle}, C.PTR_SIZEOF);
+	return XPCOM.NS_OK;     	
+}  
+ 
+/* nsIWebBrowserChromeFocus */
+
+int FocusNextElement () {
+	/*
+	* Bug in Mozilla embedding API.  Mozilla takes back the focus after sending
+	* this event.  This prevents tabbing out of Mozilla. This behaviour can be reproduced
+	* with the Mozilla application TestGtkEmbed.  The workaround is to
+	* send the traversal notification after this callback returns.
+	*/
+	browser.getDisplay ().asyncExec (new Runnable () {
+		public void run () {
+			if (browser.isDisposed ()) return;
+			browser.traverse (SWT.TRAVERSE_TAB_NEXT);
+		}
+	});
+	return XPCOM.NS_OK;  
+}
+
+int FocusPrevElement () {
+	/*
+	* Bug in Mozilla embedding API.  Mozilla takes back the focus after sending
+	* this event.  This prevents tabbing out of Mozilla. This behaviour can be reproduced
+	* with the Mozilla application TestGtkEmbed.  The workaround is to
+	* send the traversal notification after this callback returns.
+	*/
+	browser.getDisplay ().asyncExec (new Runnable () {
+		public void run () {
+			if (browser.isDisposed ()) return;
+			browser.traverse (SWT.TRAVERSE_TAB_PREVIOUS);
+		}
+	});
+	return XPCOM.NS_OK;     	
+}
+
+/* nsIContextMenuListener */
+
+int OnShowContextMenu (int aContextFlags, int /*long*/ aEvent, int /*long*/ aNode) {
+	if (awaitingNavigate) return XPCOM.NS_OK;
+
+	nsIDOMEvent domEvent = new nsIDOMEvent (aEvent);
+	int /*long*/[] result = new int /*long*/[1];
+	int rc = domEvent.QueryInterface (nsIDOMMouseEvent.NS_IDOMMOUSEEVENT_IID, result);
+	if (rc != XPCOM.NS_OK) error (rc);
+	if (result[0] == 0) error (XPCOM.NS_NOINTERFACE);
+
+	nsIDOMMouseEvent domMouseEvent = new nsIDOMMouseEvent (result[0]);
+	int[] aScreenX = new int[1], aScreenY = new int[1];
+	rc = domMouseEvent.GetScreenX (aScreenX);
+	if (rc != XPCOM.NS_OK) error (rc);
+	rc = domMouseEvent.GetScreenY (aScreenY);
+	if (rc != XPCOM.NS_OK) error (rc);
+	domMouseEvent.Release ();
+	
+	Event event = new Event ();
+	event.x = aScreenX[0];
+	event.y = aScreenY[0];
+	browser.notifyListeners (SWT.MenuDetect, event);
+	if (!event.doit || browser.isDisposed ()) return XPCOM.NS_OK;
+	Menu menu = browser.getMenu ();
+	if (menu != null && !menu.isDisposed ()) {
+		if (aScreenX[0] != event.x || aScreenY[0] != event.y) {
+			menu.setLocation (event.x, event.y);
+		}
+		menu.setVisible (true);
+	}
+	return XPCOM.NS_OK;     	
+}
+
+/* nsIURIContentListener */
+
+int OnStartURIOpen (int /*long*/ aURI, int /*long*/ retval) {
+	if (awaitingNavigate || locationListeners.length == 0) {
+		XPCOM.memmove (retval, new int[] {0}, 4); /* PRBool */
+		return XPCOM.NS_OK;
+	}
+	nsIURI location = new nsIURI (aURI);
+	int /*long*/ aSpec = XPCOM.nsEmbedCString_new ();
+	location.GetSpec (aSpec);
+	int length = XPCOM.nsEmbedCString_Length (aSpec);
+	int /*long*/ buffer = XPCOM.nsEmbedCString_get (aSpec);
+	buffer = XPCOM.nsEmbedCString_get (aSpec);
+	byte[] dest = new byte[length];
+	XPCOM.memmove (dest, buffer, length);
+	XPCOM.nsEmbedCString_delete (aSpec);
+	String value = new String (dest);
+	boolean doit = true;
+	if (request == 0) {
+		/* 
+		 * listeners should not be notified of internal transitions like "javascipt:..."
+		 * because this is an implementation side-effect, not a true navigate
+		 */
+		if (!value.startsWith (PREFIX_JAVASCRIPT)) {
+			LocationEvent event = new LocationEvent (browser);
+			event.display = browser.getDisplay();
+			event.widget = browser;
+			event.location = value;
+			/*
+			 * If the URI indicates that the page is being rendered from memory
+			 * (via setText()) then set it to about:blank to be consistent with IE.
+			 */
+			if (event.location.equals (URI_FROMMEMORY)) event.location = ABOUT_BLANK;
+			event.doit = doit;
+			for (int i = 0; i < locationListeners.length; i++) {
+				locationListeners[i].changing (event);
+			}
+			doit = event.doit && !browser.isDisposed();
+		}
+	}
+	XPCOM.memmove (retval, new int[] {doit ? 0 : 1}, 4); /* PRBool */
+	return XPCOM.NS_OK;
+}
+
+int DoContent (int /*long*/ aContentType, int aIsContentPreferred, int /*long*/ aRequest, int /*long*/ aContentHandler, int /*long*/ retval) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+int IsPreferred (int /*long*/ aContentType, int /*long*/ aDesiredContentType, int /*long*/ retval) {
+	boolean preferred = false;
+	int size = XPCOM.strlen (aContentType);
+	if (size > 0) {
+		byte[] typeBytes = new byte[size + 1];
+		XPCOM.memmove (typeBytes, aContentType, size);
+		String contentType = new String (typeBytes, 0, size);
+
+		/* do not attempt to handle known problematic content types */
+		if (!contentType.equals (XPCOM.CONTENT_MAYBETEXT) && !contentType.equals (XPCOM.CONTENT_MULTIPART)) {
+			/* determine whether browser can handle the content type */
+			int /*long*/[] result = new int /*long*/[1];
+			int rc = XPCOM.NS_GetServiceManager (result);
+			if (rc != XPCOM.NS_OK) error (rc);
+			if (result[0] == 0) error (XPCOM.NS_NOINTERFACE);
+			nsIServiceManager serviceManager = new nsIServiceManager (result[0]);
+			result[0] = 0;
+
+			/* First try to use the nsIWebNavigationInfo if it's available (>= mozilla 1.8) */
+			byte[] aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_WEBNAVIGATIONINFO_CONTRACTID, true);
+			rc = serviceManager.GetServiceByContractID (aContractID, nsIWebNavigationInfo.NS_IWEBNAVIGATIONINFO_IID, result);
+			if (rc == XPCOM.NS_OK) {
+				byte[] bytes = MozillaDelegate.wcsToMbcs (null, contentType, true);
+				int /*long*/ typePtr = XPCOM.nsEmbedCString_new (bytes, bytes.length);
+				nsIWebNavigationInfo info = new nsIWebNavigationInfo (result[0]);
+				result[0] = 0;
+				int[] isSupportedResult = new int[1]; /* PRUint32 */
+				rc = info.IsTypeSupported (typePtr, 0, isSupportedResult);
+				if (rc != XPCOM.NS_OK) error (rc);
+				info.Release ();
+				XPCOM.nsEmbedCString_delete (typePtr);
+				preferred = isSupportedResult[0] != 0;
+			} else {
+				/* nsIWebNavigationInfo is not available, so do the type lookup */
+				result[0] = 0;
+				rc = serviceManager.GetService (XPCOM.NS_CATEGORYMANAGER_CID, nsICategoryManager.NS_ICATEGORYMANAGER_IID, result);
+				if (rc != XPCOM.NS_OK) error (rc);
+				if (result[0] == 0) error (XPCOM.NS_NOINTERFACE);
+
+				nsICategoryManager categoryManager = new nsICategoryManager (result[0]);
+				result[0] = 0;
+				byte[] categoryBytes = MozillaDelegate.wcsToMbcs (null, "Gecko-Content-Viewers", true);	//$NON-NLS-1$
+				rc = categoryManager.GetCategoryEntry (categoryBytes, typeBytes, result);
+				categoryManager.Release ();
+				/* if no viewer for the content type is registered then rc == XPCOM.NS_ERROR_NOT_AVAILABLE */
+				preferred = rc == XPCOM.NS_OK;
+			}
+			serviceManager.Release ();
+		}
+	}
+
+	XPCOM.memmove(retval, new int[] {preferred ? 1 : 0}, 4); /* PRBool */
+	if (preferred) {
+		XPCOM.memmove (aDesiredContentType, new int /*long*/[] {0}, C.PTR_SIZEOF);
+	}
+	return XPCOM.NS_OK;
+}
+
+int CanHandleContent (int /*long*/ aContentType, int aIsContentPreferred, int /*long*/ aDesiredContentType, int /*long*/ retval) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+int GetLoadCookie (int /*long*/ aLoadCookie) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+int SetLoadCookie (int /*long*/ aLoadCookie) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+int GetParentContentListener (int /*long*/ aParentContentListener) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+	
+int SetParentContentListener (int /*long*/ aParentContentListener) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* nsITooltipListener */
+
+int OnShowTooltip (int aXCoords, int aYCoords, int /*long*/ aTipText) {
+	if (awaitingNavigate) return XPCOM.NS_OK;
+
+	int length = XPCOM.strlen_PRUnichar (aTipText);
+	char[] dest = new char[length];
+	XPCOM.memmove (dest, aTipText, length * 2);
+	String text = new String (dest);
+	if (tip != null && !tip.isDisposed ()) tip.dispose ();
+	Display display = browser.getDisplay ();
+	Shell parent = browser.getShell ();
+	tip = new Shell (parent, SWT.ON_TOP);
+	tip.setLayout (new FillLayout());
+	Label label = new Label (tip, SWT.CENTER);
+	label.setForeground (display.getSystemColor (SWT.COLOR_INFO_FOREGROUND));
+	label.setBackground (display.getSystemColor (SWT.COLOR_INFO_BACKGROUND));
+	label.setText (text);
+	/*
+	* Bug in Mozilla embedded API.  Tooltip coordinates are wrong for 
+	* elements inside an inline frame (IFrame tag).  The workaround is 
+	* to position the tooltip based on the mouse cursor location.
+	*/
+	Point point = display.getCursorLocation ();
+	/* Assuming cursor is 21x21 because this is the size of
+	 * the arrow cursor on Windows
+	 */ 
+	point.y += 21;
+	tip.setLocation (point);
+	tip.pack ();
+	tip.setVisible (true);
+	return XPCOM.NS_OK;
+}
+
+int OnHideTooltip () {
+	if (tip != null && !tip.isDisposed ()) tip.dispose ();
+	tip = null;
+	return XPCOM.NS_OK;
+}
+
+/* nsIDOMEventListener */
+
+int HandleEvent (int /*long*/ event) {
+	nsIDOMEvent domEvent = new nsIDOMEvent (event);
+
+	int /*long*/ type = XPCOM.nsEmbedString_new ();
+	int rc = domEvent.GetType (type);
+	if (rc != XPCOM.NS_OK) error (rc);
+	int length = XPCOM.nsEmbedString_Length (type);
+	int /*long*/ buffer = XPCOM.nsEmbedString_get (type);
+	char[] chars = new char[length];
+	XPCOM.memmove (chars, buffer, length * 2);
+	String typeString = new String (chars);
+	XPCOM.nsEmbedString_delete (type);
+
+	if (XPCOM.DOMEVENT_UNLOAD.equals (typeString)) {
+		int /*long*/[] result = new int /*long*/[1];
+		rc = domEvent.GetCurrentTarget (result);
+		if (rc != XPCOM.NS_OK) error (rc);
+		if (result[0] == 0) error (XPCOM.NS_NOINTERFACE);
+
+		nsIDOMEventTarget target = new nsIDOMEventTarget (result[0]);
+		unhookDOMListeners (target);
+		target.Release ();
+		return XPCOM.NS_OK;
+	}
+
+	if (XPCOM.DOMEVENT_FOCUS.equals (typeString)) {
+		delegate.handleFocus ();
+		return XPCOM.NS_OK;
+	}
+
+	if (XPCOM.DOMEVENT_KEYDOWN.equals (typeString)) {
+		int /*long*/[] result = new int /*long*/[1];
+		rc = domEvent.QueryInterface (nsIDOMKeyEvent.NS_IDOMKEYEVENT_IID, result);
+		if (rc != XPCOM.NS_OK) error (rc);
+		if (result[0] == 0) error (XPCOM.NS_NOINTERFACE);
+		nsIDOMKeyEvent domKeyEvent = new nsIDOMKeyEvent (result[0]);
+		result[0] = 0;
+
+		int[] aKeyCode = new int[1]; /* PRUint32 */
+		rc = domKeyEvent.GetKeyCode (aKeyCode);
+		if (rc != XPCOM.NS_OK) error (rc);
+		int keyCode = translateKey (aKeyCode[0]);
+
+		/*
+		* if keyCode == lastKeyCode then either a repeating key like Shift
+		* is being held or a key for which key events are not sent has been
+		* pressed.  In both of these cases a KeyDown should not be sent.
+		*/
+		if (keyCode != lastKeyCode) {
+			lastKeyCode = keyCode;
+			switch (keyCode) {
+				case SWT.SHIFT:
+				case SWT.CONTROL:
+				case SWT.ALT:
+				case SWT.CAPS_LOCK:
+				case SWT.NUM_LOCK:
+				case SWT.SCROLL_LOCK:
+				case SWT.COMMAND: {
+					/* keypress events will not be received for these keys, so send KeyDowns for them now */
+					int[] aAltKey = new int[1], aCtrlKey = new int[1], aShiftKey = new int[1], aMetaKey = new int[1]; /* PRBool */
+					rc = domKeyEvent.GetAltKey (aAltKey);
+					if (rc != XPCOM.NS_OK) error (rc);
+					rc = domKeyEvent.GetCtrlKey (aCtrlKey);
+					if (rc != XPCOM.NS_OK) error (rc);
+					rc = domKeyEvent.GetShiftKey (aShiftKey);
+					if (rc != XPCOM.NS_OK) error (rc);
+					rc = domKeyEvent.GetMetaKey (aMetaKey);
+					if (rc != XPCOM.NS_OK) error (rc);
+
+					Event keyEvent = new Event ();
+					keyEvent.widget = browser;
+					keyEvent.type = SWT.KeyDown;
+					keyEvent.keyCode = keyCode;
+					keyEvent.stateMask = (aAltKey[0] != 0 ? SWT.ALT : 0) | (aCtrlKey[0] != 0 ? SWT.CTRL : 0) | (aShiftKey[0] != 0 ? SWT.SHIFT : 0) | (aMetaKey[0] != 0 ? SWT.COMMAND : 0);
+					keyEvent.stateMask &= ~keyCode;		/* remove current keydown if it's a state key */
+					browser.notifyListeners (keyEvent.type, keyEvent);
+					if (!keyEvent.doit || browser.isDisposed ()) {
+						domEvent.PreventDefault ();
+					}
+					break;
+				}
+				default: {
+					/* 
+					* If the keydown has Meta (but not Meta+Ctrl) as a modifier then send a KeyDown event for it here
+					* because a corresponding keypress event will not be received for it from the DOM.  If the keydown
+					* does not have Meta as a modifier, or has Meta+Ctrl as a modifier, then then do nothing here
+					* because its KeyDown event will be sent from the keypress listener.
+					*/
+					int[] aMetaKey = new int[1]; /* PRBool */
+					rc = domKeyEvent.GetMetaKey (aMetaKey);
+					if (rc != XPCOM.NS_OK) error (rc);
+					if (aMetaKey[0] != 0) {
+						int[] aCtrlKey = new int[1]; /* PRBool */
+						rc = domKeyEvent.GetCtrlKey (aCtrlKey);
+						if (rc != XPCOM.NS_OK) error (rc);
+						if (aCtrlKey[0] == 0) {
+							int[] aAltKey = new int[1], aShiftKey = new int[1]; /* PRBool */
+							rc = domKeyEvent.GetAltKey (aAltKey);
+							if (rc != XPCOM.NS_OK) error (rc);
+							rc = domKeyEvent.GetShiftKey (aShiftKey);
+							if (rc != XPCOM.NS_OK) error (rc);
+
+							Event keyEvent = new Event ();
+							keyEvent.widget = browser;
+							keyEvent.type = SWT.KeyDown;
+							keyEvent.keyCode = lastKeyCode;
+							keyEvent.stateMask = (aAltKey[0] != 0 ? SWT.ALT : 0) | (aCtrlKey[0] != 0? SWT.CTRL : 0) | (aShiftKey[0] != 0? SWT.SHIFT : 0) | (aMetaKey[0] != 0? SWT.COMMAND : 0);
+							browser.notifyListeners (keyEvent.type, keyEvent);
+							if (!keyEvent.doit || browser.isDisposed ()) {
+								domEvent.PreventDefault ();
+							}
+						}
+					}
+				}
+			}
+		}
+
+		domKeyEvent.Release ();
+		return XPCOM.NS_OK;
+	}
+
+	if (XPCOM.DOMEVENT_KEYPRESS.equals (typeString)) {
+		/*
+		* if keydown could not determine a keycode for this key then it's a
+		* key for which key events are not sent (eg.- the Windows key)
+		*/
+		if (lastKeyCode == 0) return XPCOM.NS_OK;
+
+		/*
+		* On linux only, unexpected keypress events are received for some
+		* modifier keys.  The workaround is to ignore these events since
+		* KeyDown events are sent for these keys in the keydown listener.  
+		*/
+		switch (lastKeyCode) {
+			case SWT.CAPS_LOCK:
+			case SWT.NUM_LOCK:
+			case SWT.SCROLL_LOCK: return XPCOM.NS_OK;
+		}
+
+		int /*long*/[] result = new int /*long*/[1];
+		rc = domEvent.QueryInterface (nsIDOMKeyEvent.NS_IDOMKEYEVENT_IID, result);
+		if (rc != XPCOM.NS_OK) error (rc);
+		if (result[0] == 0) error (XPCOM.NS_NOINTERFACE);
+		nsIDOMKeyEvent domKeyEvent = new nsIDOMKeyEvent (result[0]);
+		result[0] = 0;
+
+		int[] aAltKey = new int[1], aCtrlKey = new int[1], aShiftKey = new int[1], aMetaKey = new int[1]; /* PRBool */
+		rc = domKeyEvent.GetAltKey (aAltKey);
+		if (rc != XPCOM.NS_OK) error (rc);
+		rc = domKeyEvent.GetCtrlKey (aCtrlKey);
+		if (rc != XPCOM.NS_OK) error (rc);
+		rc = domKeyEvent.GetShiftKey (aShiftKey);
+		if (rc != XPCOM.NS_OK) error (rc);
+		rc = domKeyEvent.GetMetaKey (aMetaKey);
+		if (rc != XPCOM.NS_OK) error (rc);
+		domKeyEvent.Release ();
+
+		int[] aCharCode = new int[1]; /* PRUint32 */
+		rc = domKeyEvent.GetCharCode (aCharCode);
+		if (rc != XPCOM.NS_OK) error (rc);
+		lastCharCode = aCharCode[0];
+		if (lastCharCode == 0) {
+			switch (lastKeyCode) {
+				case SWT.TAB: lastCharCode = SWT.TAB; break;
+				case SWT.CR: lastCharCode = SWT.CR; break;
+				case SWT.BS: lastCharCode = SWT.BS; break;
+				case SWT.ESC: lastCharCode = SWT.ESC; break;
+				case SWT.DEL: lastCharCode = SWT.DEL; break;
+			}
+		}
+		if (aCtrlKey[0] != 0 && (0 <= lastCharCode && lastCharCode <= 0x7F)) {
+			if ('a'  <= lastCharCode && lastCharCode <= 'z') lastCharCode -= 'a' - 'A';
+			if (64 <= lastCharCode && lastCharCode <= 95) lastCharCode -= 64;
+		}
+
+		Event keyEvent = new Event ();
+		keyEvent.widget = browser;
+		keyEvent.type = SWT.KeyDown;
+		keyEvent.keyCode = lastKeyCode;
+		keyEvent.character = (char)lastCharCode;
+		keyEvent.stateMask = (aAltKey[0] != 0 ? SWT.ALT : 0) | (aCtrlKey[0] != 0 ? SWT.CTRL : 0) | (aShiftKey[0] != 0 ? SWT.SHIFT : 0) | (aMetaKey[0] != 0 ? SWT.COMMAND : 0);
+		browser.notifyListeners (keyEvent.type, keyEvent);
+		if (!keyEvent.doit || browser.isDisposed ()) {
+			domEvent.PreventDefault ();
+		}
+		return XPCOM.NS_OK;
+	}
+
+	if (XPCOM.DOMEVENT_KEYUP.equals (typeString)) {
+		int /*long*/[] result = new int /*long*/[1];
+		rc = domEvent.QueryInterface (nsIDOMKeyEvent.NS_IDOMKEYEVENT_IID, result);
+		if (rc != XPCOM.NS_OK) error (rc);
+		if (result[0] == 0) error (XPCOM.NS_NOINTERFACE);
+		nsIDOMKeyEvent domKeyEvent = new nsIDOMKeyEvent (result[0]);
+		result[0] = 0;
+
+		int[] aKeyCode = new int[1]; /* PRUint32 */
+		rc = domKeyEvent.GetKeyCode (aKeyCode);
+		if (rc != XPCOM.NS_OK) error (rc);
+		int keyCode = translateKey (aKeyCode[0]);
+		if (keyCode == 0) {
+			/* indicates a key for which key events are not sent */
+			domKeyEvent.Release ();
+			return XPCOM.NS_OK;
+		}
+		if (keyCode != lastKeyCode) {
+			/* keyup does not correspond to the last keydown */
+			lastKeyCode = keyCode;
+			lastCharCode = 0;
+		}
+
+		int[] aAltKey = new int[1], aCtrlKey = new int[1], aShiftKey = new int[1], aMetaKey = new int[1]; /* PRBool */
+		rc = domKeyEvent.GetAltKey (aAltKey);
+		if (rc != XPCOM.NS_OK) error (rc);
+		rc = domKeyEvent.GetCtrlKey (aCtrlKey);
+		if (rc != XPCOM.NS_OK) error (rc);
+		rc = domKeyEvent.GetShiftKey (aShiftKey);
+		if (rc != XPCOM.NS_OK) error (rc);
+		rc = domKeyEvent.GetMetaKey (aMetaKey);
+		if (rc != XPCOM.NS_OK) error (rc);
+		domKeyEvent.Release ();
+
+		Event keyEvent = new Event ();
+		keyEvent.widget = browser;
+		keyEvent.type = SWT.KeyUp;
+		keyEvent.keyCode = lastKeyCode;
+		keyEvent.character = (char)lastCharCode;
+		keyEvent.stateMask = (aAltKey[0] != 0 ? SWT.ALT : 0) | (aCtrlKey[0] != 0 ? SWT.CTRL : 0) | (aShiftKey[0] != 0 ? SWT.SHIFT : 0) | (aMetaKey[0] != 0 ? SWT.COMMAND : 0);
+		switch (lastKeyCode) {
+			case SWT.SHIFT:
+			case SWT.CONTROL:
+			case SWT.ALT:
+			case SWT.COMMAND: {
+				keyEvent.stateMask |= lastKeyCode;
+			}
+		}
+		browser.notifyListeners (keyEvent.type, keyEvent);
+		if (!keyEvent.doit || browser.isDisposed ()) {
+			domEvent.PreventDefault ();
+		}
+		lastKeyCode = lastCharCode = 0;
+		return XPCOM.NS_OK;
+	}
+
+	/* mouse event */
+
+	int /*long*/[] result = new int /*long*/[1];
+	rc = domEvent.QueryInterface (nsIDOMMouseEvent.NS_IDOMMOUSEEVENT_IID, result);
+	if (rc != XPCOM.NS_OK) error (rc);
+	if (result[0] == 0) error (XPCOM.NS_NOINTERFACE);
+	nsIDOMMouseEvent domMouseEvent = new nsIDOMMouseEvent (result[0]);
+	result[0] = 0;
+
+	/*
+	 * MouseOver and MouseOut events are fired any time the mouse enters or exits
+	 * any element within the Browser.  To ensure that SWT events are only
+	 * fired for mouse movements into or out of the Browser, do not fire an
+	 * event if the element being exited (on MouseOver) or entered (on MouseExit)
+	 * is within the Browser.
+	 */
+	if (XPCOM.DOMEVENT_MOUSEOVER.equals (typeString) || XPCOM.DOMEVENT_MOUSEOUT.equals (typeString)) {
+		rc = domMouseEvent.GetRelatedTarget (result);
+		if (rc != XPCOM.NS_OK) error (rc);
+		if (result[0] != 0) {
+			domMouseEvent.Release ();
+			return XPCOM.NS_OK;
+		}
+	}
+
+	int[] aClientX = new int[1], aClientY = new int[1], aDetail = new int[1]; /* PRInt32 */
+	rc = domMouseEvent.GetClientX (aClientX);
+	if (rc != XPCOM.NS_OK) error (rc);
+	rc = domMouseEvent.GetClientY (aClientY);
+	if (rc != XPCOM.NS_OK) error (rc);
+	rc = domMouseEvent.GetDetail (aDetail);
+	if (rc != XPCOM.NS_OK) error (rc);
+	short[] aButton = new short[1]; /* PRUint16 */
+	rc = domMouseEvent.GetButton (aButton);
+	if (rc != XPCOM.NS_OK) error (rc);
+	int[] aAltKey = new int[1], aCtrlKey = new int[1], aShiftKey = new int[1], aMetaKey = new int[1]; /* PRBool */
+	rc = domMouseEvent.GetAltKey (aAltKey);
+	if (rc != XPCOM.NS_OK) error (rc);
+	rc = domMouseEvent.GetCtrlKey (aCtrlKey);
+	if (rc != XPCOM.NS_OK) error (rc);
+	rc = domMouseEvent.GetShiftKey (aShiftKey);
+	if (rc != XPCOM.NS_OK) error (rc);
+	rc = domMouseEvent.GetMetaKey (aMetaKey);
+	if (rc != XPCOM.NS_OK) error (rc);
+	domMouseEvent.Release ();
+
+	Event mouseEvent = new Event ();
+	mouseEvent.widget = browser;
+	mouseEvent.x = aClientX[0]; mouseEvent.y = aClientY[0];
+	mouseEvent.stateMask = (aAltKey[0] != 0 ? SWT.ALT : 0) | (aCtrlKey[0] != 0 ? SWT.CTRL : 0) | (aShiftKey[0] != 0 ? SWT.SHIFT : 0) | (aMetaKey[0] != 0 ? SWT.COMMAND : 0);
+
+	if (XPCOM.DOMEVENT_MOUSEDOWN.equals (typeString)) {
+		delegate.handleMouseDown ();
+		mouseEvent.type = SWT.MouseDown;
+		mouseEvent.button = aButton[0] + 1;
+		mouseEvent.count = aDetail[0];
+	} else if (XPCOM.DOMEVENT_MOUSEUP.equals (typeString)) {
+		/*
+		 * Bug on OSX.  For some reason multiple mouseup events come from the DOM
+		 * when button 3 is released on OSX.  The first of these events has a count
+		 * detail and the others do not.  The workaround is to not fire received
+		 * button 3 mouseup events that do not have a count since mouse events
+		 * without a click count are not valid.
+		 */
+		int button = aButton[0] + 1;
+		int count = aDetail[0];
+		if (count == 0 && button == 3) return XPCOM.NS_OK;
+		mouseEvent.type = SWT.MouseUp;
+		mouseEvent.button = button;
+		mouseEvent.count = count;
+	} else if (XPCOM.DOMEVENT_MOUSEMOVE.equals (typeString)) {
+		mouseEvent.type = SWT.MouseMove;
+	} else if (XPCOM.DOMEVENT_MOUSEWHEEL.equals (typeString)) {
+		mouseEvent.type = SWT.MouseWheel;
+		mouseEvent.count = -aDetail[0];
+	} else if (XPCOM.DOMEVENT_MOUSEOVER.equals (typeString)) {
+		mouseEvent.type = SWT.MouseEnter;
+	} else if (XPCOM.DOMEVENT_MOUSEOUT.equals (typeString)) {
+		mouseEvent.type = SWT.MouseExit;
+	} else if (XPCOM.DOMEVENT_MOUSEDRAG.equals (typeString)) {
+		mouseEvent.type = SWT.DragDetect;
+		mouseEvent.button = aButton[0] + 1;
+		switch (mouseEvent.button) {
+			case 1: mouseEvent.stateMask |= SWT.BUTTON1; break;
+			case 2: mouseEvent.stateMask |= SWT.BUTTON2; break;
+			case 3: mouseEvent.stateMask |= SWT.BUTTON3; break;
+			case 4: mouseEvent.stateMask |= SWT.BUTTON4; break;
+			case 5: mouseEvent.stateMask |= SWT.BUTTON5; break;
+		}
+	}
+
+	browser.notifyListeners (mouseEvent.type, mouseEvent);
+	if (browser.isDisposed ()) return XPCOM.NS_OK;
+	if (aDetail[0] == 2 && XPCOM.DOMEVENT_MOUSEDOWN.equals (typeString)) {
+		mouseEvent = new Event ();
+		mouseEvent.widget = browser;
+		mouseEvent.x = aClientX[0]; mouseEvent.y = aClientY[0];
+		mouseEvent.stateMask = (aAltKey[0] != 0 ? SWT.ALT : 0) | (aCtrlKey[0] != 0 ? SWT.CTRL : 0) | (aShiftKey[0] != 0 ? SWT.SHIFT : 0) | (aMetaKey[0] != 0 ? SWT.COMMAND : 0);
+		mouseEvent.type = SWT.MouseDoubleClick;
+		mouseEvent.button = aButton[0] + 1;
+		mouseEvent.count = aDetail[0];
+		browser.notifyListeners (mouseEvent.type, mouseEvent);	
+	}
+	return XPCOM.NS_OK;
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/browser/MozillaDelegate.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/browser/MozillaDelegate.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/browser/MozillaDelegate.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,202 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.browser;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.browser.Browser;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.gtk.*;
+import org.eclipse.swt.widgets.*;
+
+class MozillaDelegate {
+	Browser browser;
+	int /*long*/ mozillaHandle, embedHandle;
+	boolean hasFocus;
+	Listener listener;
+	static Callback eventCallback;
+	static int /*long*/ eventProc;
+	static final int STOP_PROPOGATE = 1;
+
+	static boolean IsLinux;
+	static {
+		String osName = System.getProperty ("os.name").toLowerCase (); //$NON-NLS-1$
+		IsLinux = osName.startsWith ("linux"); //$NON-NLS-1$
+	}
+
+MozillaDelegate (Browser browser) {
+	super ();
+	if (!IsLinux) {
+		browser.dispose ();
+		SWT.error (SWT.ERROR_NO_HANDLES, null, " [Unsupported platform]"); //$NON-NLS-1$
+	}
+	this.browser = browser;
+}
+
+static int /*long*/ eventProc (int /*long*/ handle, int /*long*/ gdkEvent, int /*long*/ pointer) {
+	int /*long*/ parent = OS.gtk_widget_get_parent (handle);
+	parent = OS.gtk_widget_get_parent (parent);
+	if (parent == 0) return 0;
+	Widget widget = Display.getCurrent ().findWidget (parent);
+	if (widget != null && widget instanceof Browser) {
+		return ((Mozilla)((Browser)widget).webBrowser).delegate.gtk_event (handle, gdkEvent, pointer);
+	}
+	return 0;
+}
+
+static Browser findBrowser (int /*long*/ handle) {
+	/*
+	* Note.  On GTK, Mozilla is embedded into a GtkHBox handle
+	* and not directly into the parent Composite handle.
+	*/
+	int /*long*/ parent = OS.gtk_widget_get_parent (handle);
+	Display display = Display.getCurrent ();
+	return (Browser)display.findWidget (parent); 
+}
+
+static char[] mbcsToWcs (String codePage, byte [] buffer) {
+	return Converter.mbcsToWcs (codePage, buffer);
+}
+
+static byte[] wcsToMbcs (String codePage, String string, boolean terminate) {
+	return Converter.wcsToMbcs (codePage, string, terminate);
+}
+
+int /*long*/ getHandle () {
+	/*
+	* Bug in Mozilla Linux GTK.  Embedding Mozilla into a GtkFixed
+	* handle causes problems with some Mozilla plug-ins.  For some
+	* reason, the Flash plug-in causes the child of the GtkFixed
+	* handle to be resized to 1 when the Flash document is loaded.
+	* That could be due to gtk_container_resize_children being called
+	* by Mozilla - or one of its plug-ins - on the GtkFixed handle,
+	* causing the child of the GtkFixed handle to be resized to 1.
+	* The workaround is to embed Mozilla into a GtkHBox handle.
+	*/
+	embedHandle = OS.gtk_hbox_new (false, 0);
+	OS.gtk_container_add (browser.handle, embedHandle);
+	OS.gtk_widget_show (embedHandle);
+	return embedHandle;
+}
+
+String getLibraryName () {
+	return "libxpcom.so"; //$NON-NLS-1$
+}
+
+String getSWTInitLibraryName () {
+	return "swt-xpcominit"; //$NON-NLS-1$
+}
+
+int /*long*/ gtk_event (int /*long*/ handle, int /*long*/ gdkEvent, int /*long*/ pointer) {
+	GdkEvent event = new GdkEvent ();
+	OS.memmove (event, gdkEvent, GdkEvent.sizeof);
+	if (event.type == OS.GDK_BUTTON_PRESS) {
+		if (!hasFocus) browser.setFocus ();
+	}
+
+	/* 
+	* Stop the propagation of events that are not consumed by Mozilla, before
+	* they reach the parent embedder.  These event have already been received.
+	*/
+	if (pointer == STOP_PROPOGATE) return 1;
+	return 0;
+}
+
+void handleFocus () {
+	if (hasFocus) return;
+	hasFocus = true;
+	listener = new Listener () {
+		public void handleEvent (Event event) {
+			if (event.widget == browser) return;
+			((Mozilla)browser.webBrowser).Deactivate ();
+			hasFocus = false;
+			browser.getDisplay ().removeFilter (SWT.FocusIn, this);
+			browser.getShell ().removeListener (SWT.Deactivate, this);
+			listener = null;
+		}
+	};
+	browser.getDisplay ().addFilter (SWT.FocusIn, listener);
+	browser.getShell ().addListener (SWT.Deactivate, listener);
+}
+
+void handleMouseDown () {
+	int shellStyle = browser.getShell ().getStyle (); 
+	if ((shellStyle & SWT.ON_TOP) != 0 && (((shellStyle & SWT.NO_FOCUS) == 0) || ((browser.getStyle () & SWT.NO_FOCUS) == 0))) {
+		browser.getDisplay ().asyncExec (new Runnable () {
+			public void run () {
+				if (browser == null || browser.isDisposed ()) return;
+				((Mozilla)browser.webBrowser).Activate ();
+			}
+		});
+	}
+}
+
+boolean hookEnterExit () {
+	return false;
+}
+
+void init () {
+	if (eventCallback == null) {
+		eventCallback = new Callback (getClass (), "eventProc", 3); //$NON-NLS-1$
+		eventProc = eventCallback.getAddress ();
+		if (eventProc == 0) {
+			browser.dispose ();
+			Mozilla.error (SWT.ERROR_NO_MORE_CALLBACKS);
+		}
+	}
+
+	/*
+	* Feature in Mozilla.  GtkEvents such as key down, key pressed may be consumed
+	* by Mozilla and never be received by the parent embedder.  The workaround
+	* is to find the top Mozilla gtk widget that receives all the Mozilla GtkEvents,
+	* i.e. the first child of the parent embedder. Then hook event callbacks and
+	* forward the event to the parent embedder before Mozilla received and consumed
+	* them.
+	*/
+	int /*long*/ list = OS.gtk_container_get_children (embedHandle);
+	if (list != 0) {
+		mozillaHandle = OS.g_list_data (list);
+		OS.g_list_free (list);
+		
+		if (mozillaHandle != 0) {			
+			/* Note. Callback to get events before Mozilla receives and consumes them. */
+			OS.g_signal_connect (mozillaHandle, OS.event, eventProc, 0);
+			
+			/* 
+			* Note.  Callback to get the events not consumed by Mozilla - and to block 
+			* them so that they don't get propagated to the parent handle twice.  
+			* This hook is set after Mozilla and is therefore called after Mozilla's 
+			* handler because GTK dispatches events in their order of registration.
+			*/
+			OS.g_signal_connect (mozillaHandle, OS.key_press_event, eventProc, STOP_PROPOGATE);
+			OS.g_signal_connect (mozillaHandle, OS.key_release_event, eventProc, STOP_PROPOGATE);
+			OS.g_signal_connect (mozillaHandle, OS.button_press_event, eventProc, STOP_PROPOGATE);
+		}
+	}
+}
+
+boolean needsSpinup () {
+	return true;
+}
+
+void onDispose (int /*long*/ embedHandle) {
+	if (listener != null) {
+		browser.getDisplay ().removeFilter (SWT.FocusIn, listener);
+		browser.getShell ().removeListener (SWT.Deactivate, listener);
+		listener = null;
+	}
+	browser = null;
+}
+
+void setSize (int /*long*/ embedHandle, int width, int height) {
+	OS.gtk_widget_set_size_request (embedHandle, width, height);
+}
+
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/browser/OpenWindowListener.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/browser/OpenWindowListener.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/browser/OpenWindowListener.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.browser;
+
+import org.eclipse.swt.internal.SWTEventListener;
+
+/** 
+ * This listener interface may be implemented in order to receive
+ * a {@link WindowEvent} notification when a new {@link Browser}
+ * needs to be provided by the application.
+ * 
+ * @see Browser#addOpenWindowListener(OpenWindowListener)
+ * @see Browser#removeOpenWindowListener(OpenWindowListener)
+ * @see CloseWindowListener
+ * @see VisibilityWindowListener
+ * 
+ * @since 3.0
+ */
+public interface OpenWindowListener extends SWTEventListener {
+
+/**
+ * This method is called when a new window needs to be created.
+ * <p>
+ * A particular <code>Browser</code> can be passed to the event.browser
+ * field to host the content of a new window.
+ * <p>
+ * A standalone system browser is used to host the new window
+ * if the event.required field value is false and if the event.browser 
+ * field is left <code>null</code>. The event.required field
+ * is true on platforms that don't support a standalone system browser for
+ * new window requests. 
+ * <p>
+ * The navigation is cancelled if the event.required field is set to
+ * true and the event.browser field is left <code>null</code>.
+ * <p>
+ * <p>The following fields in the <code>WindowEvent</code> apply:
+ * <ul>
+ * <li>(in/out) required true if the platform requires the user to provide a
+ * <code>Browser</code> to handle the new window or false otherwise.
+ * <li>(out) browser the new <code>Browser</code> that will host the 
+ * content of the new window.
+ * <li>(in) widget the <code>Browser</code> that is requesting to open a 
+ * new window
+ * </ul>
+ * 
+ * @param event the <code>WindowEvent</code> that needs to be passed a new
+ * <code>Browser</code> to handle the new window request
+ * 
+ * @since 3.0
+ */ 
+public void open(WindowEvent event);
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/browser/ProgressAdapter.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/browser/ProgressAdapter.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/browser/ProgressAdapter.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.browser;
+
+/**
+ * This adapter class provides default implementations for the
+ * methods described by the {@link ProgressListener} interface.
+ * <p>
+ * Classes that wish to deal with {@link ProgressEvent}'s can
+ * extend this class and override only the methods which they are
+ * interested in.
+ * </p>
+ * 
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ *
+ * @since 3.0
+ */
+public abstract class ProgressAdapter implements ProgressListener {
+ 
+public void changed(ProgressEvent event) {
+}
+
+public void completed(ProgressEvent event) {
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/browser/ProgressEvent.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/browser/ProgressEvent.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/browser/ProgressEvent.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.browser;
+
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.events.*;
+
+/**
+ * A <code>ProgressEvent</code> is sent by a {@link Browser} to
+ * {@link ProgressListener}'s when a progress is made during the
+ * loading of the current URL or when the loading of the current
+ * URL has been completed.
+ * 
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ *
+ * @since 3.0
+ */
+public class ProgressEvent extends TypedEvent {
+	/** current value */
+	public int current;
+	/** total value */
+	public int total;
+	
+	static final long serialVersionUID = 3977018427045393972L;
+
+ProgressEvent(Widget w) {
+	super(w);
+}
+
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the event
+ */
+public String toString() {
+	String string = super.toString ();
+	return string.substring (0, string.length() - 1) // remove trailing '}'
+		+ " current=" + current
+		+ " total=" + total
+		+ "}";
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/browser/ProgressListener.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/browser/ProgressListener.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/browser/ProgressListener.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.browser;
+
+import org.eclipse.swt.internal.SWTEventListener;
+
+/**
+ * This listener interface may be implemented in order to receive
+ * a {@link ProgressEvent} notification when a {@link Browser}
+ * makes a progress in loading the current URL or when the
+ * current URL has been loaded.
+ * 
+ * @see Browser#addProgressListener(ProgressListener)
+ * @see Browser#removeProgressListener(ProgressListener)
+ * @see Browser#getUrl()
+ * 
+ * @since 3.0
+ */
+public interface ProgressListener extends SWTEventListener {
+	
+/**
+ * This method is called when a progress is made during the loading of the 
+ * current location.
+ * <p>
+ *
+ * <p>The following fields in the <code>ProgressEvent</code> apply:
+ * <ul>
+ * <li>(in) current the progress for the location currently being loaded
+ * <li>(in) total the maximum progress for the location currently being loaded
+ * <li>(in) widget the <code>Browser</code> whose current URL is being loaded
+ * </ul>
+ * 
+ * @param event the <code>ProgressEvent</code> related to the loading of the
+ * current location of a <code>Browser</code>
+ * 
+ * @since 3.0
+ */   
+public void changed(ProgressEvent event);
+	
+/**
+ * This method is called when the current location has been completely loaded.
+ * <p>
+ *
+ * <p>The following fields in the <code>ProgressEvent</code> apply:
+ * <ul>
+ * <li>(in) widget the <code>Browser</code> whose current URL has been loaded
+ * </ul>
+ * 
+ * @param event the <code>ProgressEvent</code> related to the <code>Browser</code>
+ * that has loaded its current URL.
+ * 
+ * @since 3.0
+ */
+public void completed(ProgressEvent event);
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/browser/PromptDialog.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/browser/PromptDialog.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/browser/PromptDialog.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,294 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.browser;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.layout.*;
+import org.eclipse.swt.widgets.*;
+
+class PromptDialog extends Dialog {
+	
+	PromptDialog(Shell parent, int style) {
+		super(parent, style);
+	}
+	
+	PromptDialog(Shell parent) {
+		this(parent, 0);
+	}
+	
+	void alertCheck(String title, String text, String check, final int[] checkValue) {
+		Shell parent = getParent();
+		final Shell shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
+		if (title != null) shell.setText(title);
+		GridLayout gridLayout = new GridLayout();
+		shell.setLayout(gridLayout);
+		Label label = new Label(shell, SWT.WRAP);
+		label.setText(text);
+		GridData data = new GridData();
+		Monitor monitor = parent.getMonitor();
+		int maxWidth = monitor.getBounds().width * 2 / 3;
+		int width = label.computeSize(SWT.DEFAULT, SWT.DEFAULT).x;
+		data.widthHint = Math.min(width, maxWidth);
+		data.horizontalAlignment = GridData.FILL;
+		data.grabExcessHorizontalSpace = true;
+		label.setLayoutData (data);
+
+		final Button checkButton = check != null ? new Button(shell, SWT.CHECK) : null;
+		if (checkButton != null) {
+			checkButton.setText(check);
+			checkButton.setSelection(checkValue[0] != 0);
+			data = new GridData ();
+			data.horizontalAlignment = GridData.BEGINNING;
+			checkButton.setLayoutData (data);
+		}
+		Button okButton = new Button(shell, SWT.PUSH);
+		okButton.setText(SWT.getMessage("SWT_OK")); //$NON-NLS-1$
+		data = new GridData ();
+		data.horizontalAlignment = GridData.CENTER;
+		okButton.setLayoutData (data);
+		okButton.addListener(SWT.Selection, new Listener() {
+			public void handleEvent(Event event) {
+				if (checkButton != null) checkValue[0] = checkButton.getSelection() ? 1 : 0;
+				shell.close();
+			}
+		});
+
+		shell.pack();
+		shell.open();
+		Display display = parent.getDisplay();
+		while (!shell.isDisposed()) {
+			if (!display.readAndDispatch()) display.sleep();
+		}
+	}
+
+	void confirmEx(String title, String text, String check, String button0, String button1, String button2, int defaultIndex, final int[] checkValue, final int[] result) {
+		Shell parent = getParent();
+		final Shell shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
+		shell.setText(title);
+		GridLayout gridLayout = new GridLayout();
+		shell.setLayout(gridLayout);
+		Label label = new Label(shell, SWT.WRAP);
+		label.setText(text);
+		GridData data = new GridData();
+		Monitor monitor = parent.getMonitor();
+		int maxWidth = monitor.getBounds().width * 2 / 3;
+		int width = label.computeSize(SWT.DEFAULT, SWT.DEFAULT).x;
+		data.widthHint = Math.min(width, maxWidth);
+		data.horizontalAlignment = GridData.FILL;
+		data.grabExcessHorizontalSpace = true;
+		label.setLayoutData (data);
+
+		final Button[] buttons = new Button[4];
+		Listener listener = new Listener() {
+			public void handleEvent(Event event) {
+				if (buttons[0] != null) checkValue[0] = buttons[0].getSelection() ? 1 : 0;
+				Widget widget = event.widget;
+				for (int i = 1; i < buttons.length; i++) {
+					if (widget == buttons[i]) {
+						result[0] = i - 1;
+						break;
+					}
+				}
+				shell.close();
+			}	
+		};
+		if (check != null) {
+			buttons[0] = new Button(shell, SWT.CHECK);
+			buttons[0].setText(check);
+			buttons[0].setSelection(checkValue[0] != 0);
+			data = new GridData ();
+			data.horizontalAlignment = GridData.BEGINNING;
+			buttons[0].setLayoutData (data);
+		}
+		Composite composite = new Composite(shell, SWT.NONE);
+		data = new GridData();
+		data.horizontalAlignment = GridData.CENTER;
+		composite.setLayoutData (data);
+		GridLayout layout = new GridLayout();
+		layout.makeColumnsEqualWidth = true;
+		composite.setLayout(layout);
+		int buttonCount = 0;
+		if (button0 != null) {
+			buttons[1] = new Button(composite, SWT.PUSH);
+			buttons[1].setText(button0);
+			buttons[1].addListener(SWT.Selection, listener);
+			buttons[1].setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+			buttonCount++;
+		}
+		if (button1 != null) {
+			buttons[2] = new Button(composite, SWT.PUSH);
+			buttons[2].setText(button1);
+			buttons[2].addListener(SWT.Selection, listener);
+			buttons[2].setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+			buttonCount++;
+		}
+		if (button2 != null) {
+			buttons[3] = new Button(composite, SWT.PUSH);
+			buttons[3].setText(button2);
+			buttons[3].addListener(SWT.Selection, listener);
+			buttons[3].setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+			buttonCount++;
+		}
+		layout.numColumns = buttonCount;
+		Button defaultButton = buttons [defaultIndex + 1];
+		if (defaultButton != null) shell.setDefaultButton (defaultButton);
+
+		shell.pack();
+		shell.open();
+		Display display = parent.getDisplay();
+		while (!shell.isDisposed()) {
+			if (!display.readAndDispatch()) display.sleep();
+		}
+	}
+	
+	void prompt(String title, String text, String check, final String[] value, final int[] checkValue, final int[] result) {
+		Shell parent = getParent();
+		final Shell shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
+		if (title != null) shell.setText(title);
+		GridLayout gridLayout = new GridLayout();
+		shell.setLayout(gridLayout);
+		Label label = new Label(shell, SWT.WRAP);
+		label.setText(text);
+		GridData data = new GridData();
+		Monitor monitor = parent.getMonitor();
+		int maxWidth = monitor.getBounds().width * 2 / 3;
+		int width = label.computeSize(SWT.DEFAULT, SWT.DEFAULT).x;
+		data.widthHint = Math.min(width, maxWidth);
+		data.horizontalAlignment = GridData.FILL;
+		data.grabExcessHorizontalSpace = true;
+		label.setLayoutData (data);
+				
+		final Text valueText = new Text(shell, SWT.BORDER);
+		if (value[0] != null) valueText.setText(value[0]);
+		data = new GridData();
+		width = valueText.computeSize(SWT.DEFAULT, SWT.DEFAULT).x;
+		if (width > maxWidth) data.widthHint = maxWidth;
+		data.horizontalAlignment = GridData.FILL;
+		data.grabExcessHorizontalSpace = true;
+		valueText.setLayoutData(data);
+
+		final Button[] buttons = new Button[3];
+		Listener listener = new Listener() {
+			public void handleEvent(Event event) {
+				if (buttons[0] != null) checkValue[0] = buttons[0].getSelection() ? 1 : 0;
+				value[0] = valueText.getText();
+				result[0] = event.widget == buttons[1] ? 1 : 0;
+				shell.close();
+			}	
+		};
+		if (check != null) {
+			buttons[0] = new Button(shell, SWT.CHECK);
+			buttons[0].setText(check);
+			buttons[0].setSelection(checkValue[0] != 0);
+			data = new GridData ();
+			data.horizontalAlignment = GridData.BEGINNING;
+			buttons[0].setLayoutData (data);
+		}
+		Composite composite = new Composite(shell, SWT.NONE);
+		data = new GridData();
+		data.horizontalAlignment = GridData.CENTER;
+		composite.setLayoutData (data);
+		composite.setLayout(new GridLayout(2, true));
+		buttons[1] = new Button(composite, SWT.PUSH);
+		buttons[1].setText(SWT.getMessage("SWT_OK")); //$NON-NLS-1$
+		buttons[1].setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+		buttons[1].addListener(SWT.Selection, listener);
+		buttons[2] = new Button(composite, SWT.PUSH);
+		buttons[2].setText(SWT.getMessage("SWT_Cancel")); //$NON-NLS-1$
+		buttons[2].setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+		buttons[2].addListener(SWT.Selection, listener);
+
+		shell.pack();
+		shell.open();
+		Display display = parent.getDisplay();
+		while (!shell.isDisposed()) {
+			if (!display.readAndDispatch()) display.sleep();
+		}	
+	}
+
+	void promptUsernameAndPassword(String title, String text, String check, final String[] user, final String[] pass, final int[] checkValue, final int[] result) {
+		Shell parent = getParent();
+		final Shell shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
+		shell.setText(title);
+		GridLayout gridLayout = new GridLayout();
+		shell.setLayout(gridLayout);
+		Label label = new Label(shell, SWT.WRAP);
+		label.setText(text);
+		GridData data = new GridData();
+		Monitor monitor = parent.getMonitor();
+		int maxWidth = monitor.getBounds().width * 2 / 3;
+		int width = label.computeSize(SWT.DEFAULT, SWT.DEFAULT).x;
+		data.widthHint = Math.min(width, maxWidth);
+		data.horizontalAlignment = GridData.FILL;
+		data.grabExcessHorizontalSpace = true;
+		label.setLayoutData (data);
+		
+		Label userLabel = new Label(shell, SWT.NONE);
+		userLabel.setText(SWT.getMessage("SWT_Username")); //$NON-NLS-1$
+		
+		final Text userText = new Text(shell, SWT.BORDER);
+		if (user[0] != null) userText.setText(user[0]);
+		data = new GridData();
+		data.horizontalAlignment = GridData.FILL;
+		data.grabExcessHorizontalSpace = true;
+		userText.setLayoutData(data);
+		
+		Label passwordLabel = new Label(shell, SWT.NONE);
+		passwordLabel.setText(SWT.getMessage("SWT_Password")); //$NON-NLS-1$
+		
+		final Text passwordText = new Text(shell, SWT.PASSWORD | SWT.BORDER);
+		if (pass[0] != null) passwordText.setText(pass[0]);
+		data = new GridData();
+		data.horizontalAlignment = GridData.FILL;
+		data.grabExcessHorizontalSpace = true;
+		passwordText.setLayoutData(data);
+
+		final Button[] buttons = new Button[3];
+		Listener listener = new Listener() {
+			public void handleEvent(Event event) {
+				if (buttons[0] != null) checkValue[0] = buttons[0].getSelection() ? 1 : 0;
+				user[0] = userText.getText();
+				pass[0] = passwordText.getText();
+				result[0] = event.widget == buttons[1] ? 1 : 0;
+				shell.close();
+			}	
+		};
+		if (check != null) {
+			buttons[0] = new Button(shell, SWT.CHECK);
+			buttons[0].setText(check);
+			buttons[0].setSelection(checkValue[0] != 0);
+			data = new GridData ();
+			data.horizontalAlignment = GridData.BEGINNING;
+			buttons[0].setLayoutData (data);
+		}
+		Composite composite = new Composite(shell, SWT.NONE);
+		data = new GridData();
+		data.horizontalAlignment = GridData.CENTER;
+		composite.setLayoutData (data);
+		composite.setLayout(new GridLayout(2, true));
+		buttons[1] = new Button(composite, SWT.PUSH);
+		buttons[1].setText(SWT.getMessage("SWT_OK")); //$NON-NLS-1$
+		buttons[1].setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+		buttons[1].addListener(SWT.Selection, listener);
+		buttons[2] = new Button(composite, SWT.PUSH);
+		buttons[2].setText(SWT.getMessage("SWT_Cancel")); //$NON-NLS-1$
+		buttons[2].setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+		buttons[2].addListener(SWT.Selection, listener);
+
+		shell.setDefaultButton(buttons[1]);
+		shell.pack();
+		shell.open();
+		Display display = parent.getDisplay();
+		while (!shell.isDisposed()) {
+			if (!display.readAndDispatch()) display.sleep();
+		}
+	}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/browser/PromptService2.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/browser/PromptService2.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/browser/PromptService2.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,630 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.browser;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.mozilla.*;
+import org.eclipse.swt.widgets.*;
+
+class PromptService2 {
+	XPCOMObject supports;
+	XPCOMObject promptService;
+	XPCOMObject promptService2;
+	int refCount = 0;
+
+PromptService2 () {
+	createCOMInterfaces ();
+}
+
+int AddRef () {
+	refCount++;
+	return refCount;
+}
+
+void createCOMInterfaces () {
+	/* Create each of the interfaces that this object implements */
+	supports = new XPCOMObject (new int[] {2, 0, 0}) {
+		public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+		public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+		public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+	};
+	
+	promptService = new XPCOMObject (new int[] {2, 0, 0, 3, 5, 4, 6, 10, 7, 8, 7, 7}) {
+		public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+		public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+		public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+		public int /*long*/ method3 (int /*long*/[] args) {return Alert (args[0], args[1], args[2]);}
+		public int /*long*/ method4 (int /*long*/[] args) {return AlertCheck (args[0], args[1], args[2], args[3], args[4]);}
+		public int /*long*/ method5 (int /*long*/[] args) {return Confirm (args[0], args[1], args[2], args[3]);}
+		public int /*long*/ method6 (int /*long*/[] args) {return ConfirmCheck (args[0], args[1], args[2], args[3], args[4], args[5]);}
+		public int /*long*/ method7 (int /*long*/[] args) {return ConfirmEx (args[0], args[1], args[2], (int)/*64*/args[3], args[4], args[5], args[6], args[7], args[8], args[9]);}
+		public int /*long*/ method8 (int /*long*/[] args) {return Prompt (args[0], args[1], args[2], args[3], args[4], args[5], args[6]);}
+		public int /*long*/ method9 (int /*long*/[] args) {return PromptUsernameAndPassword (args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7]);}
+		public int /*long*/ method10 (int /*long*/[] args) {return PromptPassword (args[0], args[1], args[2], args[3], args[4], args[5], args[6]);}
+		public int /*long*/ method11 (int /*long*/[] args) {return Select (args[0], args[1], args[2], (int)/*64*/args[3], args[4], args[5], args[6]);}
+	};
+	
+	promptService2 = new XPCOMObject (new int[] {2, 0, 0, 3, 5, 4, 6, 10, 7, 8, 7, 7, 7, 9}) {
+		public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+		public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+		public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+		public int /*long*/ method3 (int /*long*/[] args) {return Alert (args[0], args[1], args[2]);}
+		public int /*long*/ method4 (int /*long*/[] args) {return AlertCheck (args[0], args[1], args[2], args[3], args[4]);}
+		public int /*long*/ method5 (int /*long*/[] args) {return Confirm (args[0], args[1], args[2], args[3]);}
+		public int /*long*/ method6 (int /*long*/[] args) {return ConfirmCheck (args[0], args[1], args[2], args[3], args[4], args[5]);}
+		public int /*long*/ method7 (int /*long*/[] args) {return ConfirmEx (args[0], args[1], args[2], (int)/*64*/args[3], args[4], args[5], args[6], args[7], args[8], args[9]);}
+		public int /*long*/ method8 (int /*long*/[] args) {return Prompt (args[0], args[1], args[2], args[3], args[4], args[5], args[6]);}
+		public int /*long*/ method9 (int /*long*/[] args) {return PromptUsernameAndPassword (args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7]);}
+		public int /*long*/ method10 (int /*long*/[] args) {return PromptPassword (args[0], args[1], args[2], args[3], args[4], args[5], args[6]);}
+		public int /*long*/ method11 (int /*long*/[] args) {return Select (args[0], args[1], args[2], (int)/*64*/args[3], args[4], args[5], args[6]);}
+		public int /*long*/ method12 (int /*long*/[] args) {return PromptAuth (args[0], args[1], (int)/*64*/args[2], args[3], args[4], args[5], args[6]);}
+		public int /*long*/ method13 (int /*long*/[] args) {return AsyncPromptAuth (args[0], args[1], args[2], args[3], (int)/*64*/args[4], args[5], args[6], args[7], args[8]);}
+	};
+}
+
+void disposeCOMInterfaces () {
+	if (supports != null) {
+		supports.dispose ();
+		supports = null;
+	}	
+	if (promptService != null) {
+		promptService.dispose ();
+		promptService = null;	
+	}
+	if (promptService2 != null) {
+		promptService2.dispose ();
+		promptService2 = null;	
+	}
+}
+
+int /*long*/ getAddress () {
+	return promptService2.getAddress ();
+}
+
+int QueryInterface (int /*long*/ riid, int /*long*/ ppvObject) {
+	if (riid == 0 || ppvObject == 0) return XPCOM.NS_ERROR_NO_INTERFACE;
+	nsID guid = new nsID ();
+	XPCOM.memmove (guid, riid, nsID.sizeof);
+	
+	if (guid.Equals (nsISupports.NS_ISUPPORTS_IID)) {
+		XPCOM.memmove (ppvObject, new int /*long*/[] {supports.getAddress ()}, C.PTR_SIZEOF);
+		AddRef ();
+		return XPCOM.NS_OK;
+	}
+	if (guid.Equals (nsIPromptService.NS_IPROMPTSERVICE_IID)) {
+		XPCOM.memmove (ppvObject, new int /*long*/[] {promptService.getAddress ()}, C.PTR_SIZEOF);
+		AddRef ();
+		return XPCOM.NS_OK;
+	}
+	if (guid.Equals (nsIPromptService2.NS_IPROMPTSERVICE2_IID)) {
+		XPCOM.memmove (ppvObject, new int /*long*/[] {promptService2.getAddress ()}, C.PTR_SIZEOF);
+		AddRef ();
+		return XPCOM.NS_OK;
+	}
+
+	XPCOM.memmove (ppvObject, new int /*long*/[] {0}, C.PTR_SIZEOF);
+	return XPCOM.NS_ERROR_NO_INTERFACE;
+}
+        	
+int Release () {
+	refCount--;
+	if (refCount == 0) disposeCOMInterfaces ();
+	return refCount;
+}
+
+Browser getBrowser (int /*long*/ aDOMWindow) {
+	if (aDOMWindow == 0) return null;
+
+	int /*long*/[] result = new int /*long*/[1];
+	int rc = XPCOM.NS_GetServiceManager (result);
+	if (rc != XPCOM.NS_OK) Mozilla.error (rc);
+	if (result[0] == 0) Mozilla.error (XPCOM.NS_NOINTERFACE);
+	
+	nsIServiceManager serviceManager = new nsIServiceManager (result[0]);
+	result[0] = 0;
+	byte[] aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_WINDOWWATCHER_CONTRACTID, true);
+	rc = serviceManager.GetServiceByContractID (aContractID, nsIWindowWatcher.NS_IWINDOWWATCHER_IID, result);
+	if (rc != XPCOM.NS_OK) Mozilla.error(rc);
+	if (result[0] == 0) Mozilla.error (XPCOM.NS_NOINTERFACE);		
+	serviceManager.Release ();
+	
+	nsIWindowWatcher windowWatcher = new nsIWindowWatcher (result[0]);
+	result[0] = 0;
+	/* the chrome will only be answered for the top-level nsIDOMWindow */
+	nsIDOMWindow window = new nsIDOMWindow (aDOMWindow);
+	rc = window.GetTop (result);
+	if (rc != XPCOM.NS_OK) Mozilla.error (rc);
+	if (result[0] == 0) Mozilla.error (XPCOM.NS_NOINTERFACE);
+	aDOMWindow = result[0];
+	result[0] = 0;
+	rc = windowWatcher.GetChromeForWindow (aDOMWindow, result);
+	if (rc != XPCOM.NS_OK) Mozilla.error (rc);
+	if (result[0] == 0) Mozilla.error (XPCOM.NS_NOINTERFACE);		
+	windowWatcher.Release ();	
+	
+	nsIWebBrowserChrome webBrowserChrome = new nsIWebBrowserChrome (result[0]);
+	result[0] = 0;
+	rc = webBrowserChrome.QueryInterface (nsIEmbeddingSiteWindow.NS_IEMBEDDINGSITEWINDOW_IID, result);
+	if (rc != XPCOM.NS_OK) Mozilla.error (rc);
+	if (result[0] == 0) Mozilla.error (XPCOM.NS_NOINTERFACE);		
+	webBrowserChrome.Release ();
+	
+	nsIEmbeddingSiteWindow embeddingSiteWindow = new nsIEmbeddingSiteWindow (result[0]);
+	result[0] = 0;
+	rc = embeddingSiteWindow.GetSiteWindow (result);
+	if (rc != XPCOM.NS_OK) Mozilla.error (rc);
+	if (result[0] == 0) Mozilla.error (XPCOM.NS_NOINTERFACE);		
+	embeddingSiteWindow.Release ();
+	
+	return Mozilla.findBrowser (result[0]); 
+}
+
+String getLabel (int buttonFlag, int index, int /*long*/ buttonTitle) {
+	String label = null;
+	int flag = (buttonFlag & (0xff * index)) / index;
+	switch (flag) {
+		case nsIPromptService.BUTTON_TITLE_CANCEL : label = SWT.getMessage ("SWT_Cancel"); break; //$NON-NLS-1$
+		case nsIPromptService.BUTTON_TITLE_NO : label = SWT.getMessage ("SWT_No"); break; //$NON-NLS-1$
+		case nsIPromptService.BUTTON_TITLE_OK : label = SWT.getMessage ("SWT_OK"); break; //$NON-NLS-1$
+		case nsIPromptService.BUTTON_TITLE_SAVE : label = SWT.getMessage ("SWT_Save"); break; //$NON-NLS-1$
+		case nsIPromptService.BUTTON_TITLE_YES : label = SWT.getMessage ("SWT_Yes"); break; //$NON-NLS-1$
+		case nsIPromptService.BUTTON_TITLE_IS_STRING : {
+			int length = XPCOM.strlen_PRUnichar (buttonTitle);
+			char[] dest = new char[length];
+			XPCOM.memmove (dest, buttonTitle, length * 2);
+			label = new String (dest);
+		}
+	}
+	return label;
+}
+
+/* nsIPromptService */
+
+int Alert (int /*long*/ aParent, int /*long*/ aDialogTitle, int /*long*/ aText) {
+	Browser browser = getBrowser (aParent);
+	
+	int length = XPCOM.strlen_PRUnichar (aDialogTitle);
+	char[] dest = new char[length];
+	XPCOM.memmove (dest, aDialogTitle, length * 2);
+	String titleLabel = new String (dest);
+
+	length = XPCOM.strlen_PRUnichar (aText);
+	dest = new char[length];
+	XPCOM.memmove (dest, aText, length * 2);
+	String textLabel = new String (dest);
+
+	Shell shell = browser == null ? new Shell () : browser.getShell (); 
+	MessageBox messageBox = new MessageBox (shell, SWT.OK | SWT.ICON_WARNING);
+	messageBox.setText (titleLabel);
+	messageBox.setMessage (textLabel);
+	messageBox.open ();
+	return XPCOM.NS_OK;
+}
+
+int AlertCheck (int /*long*/ aParent, int /*long*/ aDialogTitle, int /*long*/ aText, int /*long*/ aCheckMsg, int /*long*/ aCheckState) {
+	Browser browser = getBrowser (aParent);
+	
+	int length = XPCOM.strlen_PRUnichar (aDialogTitle);
+	char[] dest = new char[length];
+	XPCOM.memmove (dest, aDialogTitle, length * 2);
+	String titleLabel = new String (dest);
+
+	length = XPCOM.strlen_PRUnichar (aText);
+	dest = new char[length];
+	XPCOM.memmove (dest, aText, length * 2);
+	String textLabel = new String (dest);
+
+	length = XPCOM.strlen_PRUnichar (aCheckMsg);
+	dest = new char[length];
+	XPCOM.memmove (dest, aCheckMsg, length * 2);
+	String checkLabel = new String (dest);
+
+	Shell shell = browser == null ? new Shell () : browser.getShell ();
+	PromptDialog dialog = new PromptDialog (shell);
+	int[] check = new int[1];
+	if (aCheckState != 0) XPCOM.memmove (check, aCheckState, 4); /* PRBool */
+	dialog.alertCheck (titleLabel, textLabel, checkLabel, check);
+	if (aCheckState != 0) XPCOM.memmove (aCheckState, check, 4); /* PRBool */
+	return XPCOM.NS_OK;
+}
+
+int AsyncPromptAuth(int /*long*/ aParent, int /*long*/ aChannel, int /*long*/ aCallback, int /*long*/ aContext, int level, int /*long*/ authInfo, int /*long*/ checkboxLabel, int /*long*/ checkValue, int /*long*/ _retval) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+int Confirm (int /*long*/ aParent, int /*long*/ aDialogTitle, int /*long*/ aText, int /*long*/ _retval) {
+	Browser browser = getBrowser (aParent);
+	
+	int length = XPCOM.strlen_PRUnichar (aDialogTitle);
+	char[] dest = new char[length];
+	XPCOM.memmove (dest, aDialogTitle, length * 2);
+	String titleLabel = new String (dest);
+
+	length = XPCOM.strlen_PRUnichar (aText);
+	dest = new char[length];
+	XPCOM.memmove (dest, aText, length * 2);
+	String textLabel = new String (dest);
+
+	Shell shell = browser == null ? new Shell () : browser.getShell ();
+	MessageBox messageBox = new MessageBox (shell, SWT.OK | SWT.CANCEL | SWT.ICON_QUESTION);
+	messageBox.setText (titleLabel);
+	messageBox.setMessage (textLabel);
+	int id = messageBox.open ();
+	int[] result = {id == SWT.OK ? 1 : 0};
+	XPCOM.memmove (_retval, result, 4);
+	return XPCOM.NS_OK;
+}
+
+int ConfirmCheck (int /*long*/ aParent, int /*long*/ aDialogTitle, int /*long*/ aText, int /*long*/ aCheckMsg, int /*long*/ aCheckState, int /*long*/ _retval) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+int ConfirmEx (int /*long*/ aParent, int /*long*/ aDialogTitle, int /*long*/ aText, int aButtonFlags, int /*long*/ aButton0Title, int /*long*/ aButton1Title, int /*long*/ aButton2Title, int /*long*/ aCheckMsg, int /*long*/ aCheckState, int /*long*/ _retval) {
+	Browser browser = getBrowser (aParent);
+	
+	int length = XPCOM.strlen_PRUnichar (aDialogTitle);
+	char[] dest = new char[length];
+	XPCOM.memmove (dest, aDialogTitle, length * 2);
+	String titleLabel = new String (dest);
+
+	length = XPCOM.strlen_PRUnichar (aText);
+	dest = new char[length];
+	XPCOM.memmove (dest, aText, length * 2);
+	String textLabel = new String (dest);
+	
+	String checkLabel = null;
+	if (aCheckMsg != 0) {
+		length = XPCOM.strlen_PRUnichar (aCheckMsg);
+		dest = new char[length];
+		XPCOM.memmove (dest, aCheckMsg, length * 2);
+		checkLabel = new String (dest);
+	}
+	
+	String button0Label = getLabel (aButtonFlags, nsIPromptService.BUTTON_POS_0, aButton0Title);
+	String button1Label = getLabel (aButtonFlags, nsIPromptService.BUTTON_POS_1, aButton1Title);
+	String button2Label = getLabel (aButtonFlags, nsIPromptService.BUTTON_POS_2, aButton2Title);
+	
+	int defaultIndex = 0;
+	if ((aButtonFlags & nsIPromptService.BUTTON_POS_1_DEFAULT) != 0) {
+		defaultIndex = 1;
+	} else if ((aButtonFlags & nsIPromptService.BUTTON_POS_2_DEFAULT) != 0) {
+		defaultIndex = 2;
+	}
+	
+	Shell shell = browser == null ? new Shell () : browser.getShell ();
+	PromptDialog dialog = new PromptDialog (shell);
+	int[] check = new int[1], result = new int[1];
+	if (aCheckState != 0) XPCOM.memmove (check, aCheckState, 4);
+	dialog.confirmEx (titleLabel, textLabel, checkLabel, button0Label, button1Label, button2Label, defaultIndex, check, result);
+	if (aCheckState != 0) XPCOM.memmove (aCheckState, check, 4);
+	XPCOM.memmove (_retval, result, 4);
+	return XPCOM.NS_OK;
+}
+
+int Prompt (int /*long*/ aParent, int /*long*/ aDialogTitle, int /*long*/ aText, int /*long*/ aValue, int /*long*/ aCheckMsg, int /*long*/ aCheckState, int /*long*/ _retval) {
+	Browser browser = getBrowser (aParent);
+	String titleLabel = null, textLabel, checkLabel = null;
+	String[] valueLabel = new String[1];
+	char[] dest;
+	int length;
+	if (aDialogTitle != 0) {
+		length = XPCOM.strlen_PRUnichar (aDialogTitle);
+		dest = new char[length];
+		XPCOM.memmove (dest, aDialogTitle, length * 2);
+		titleLabel = new String (dest);
+	}
+	
+	length = XPCOM.strlen_PRUnichar (aText);
+	dest = new char[length];
+	XPCOM.memmove (dest, aText, length * 2);
+	textLabel = new String (dest);
+	
+	int /*long*/[] valueAddr = new int /*long*/[1];
+	XPCOM.memmove (valueAddr, aValue, C.PTR_SIZEOF);
+	if (valueAddr[0] != 0) {
+		length = XPCOM.strlen_PRUnichar (valueAddr[0]);
+		dest = new char[length];
+		XPCOM.memmove (dest, valueAddr[0], length * 2);
+		valueLabel[0] = new String (dest);		
+	}
+	
+	if (aCheckMsg != 0) {
+		length = XPCOM.strlen_PRUnichar (aCheckMsg);
+		if (length > 0) {
+			dest = new char[length];
+			XPCOM.memmove (dest, aCheckMsg, length * 2);
+			checkLabel = new String (dest);
+		}
+	}
+
+	Shell shell = browser == null ? new Shell () : browser.getShell ();
+	PromptDialog dialog = new PromptDialog (shell);
+	int[] check = new int[1], result = new int[1];
+	if (aCheckState != 0) XPCOM.memmove (check, aCheckState, 4);
+	dialog.prompt (titleLabel, textLabel, checkLabel, valueLabel, check, result);
+
+	XPCOM.memmove (_retval, result, 4);
+	if (result[0] == 1) {
+		/* 
+		* User selected OK. User name and password are returned as PRUnichar values. Any default
+		* value that we override must be freed using the nsIMemory service.
+		*/
+		int cnt, size;
+		int /*long*/ ptr;
+		char[] buffer;
+		int /*long*/[] result2 = new int /*long*/[1];
+		if (valueLabel[0] != null) {
+			cnt = valueLabel[0].length ();
+			buffer = new char[cnt + 1];
+			valueLabel[0].getChars (0, cnt, buffer, 0);
+			size = buffer.length * 2;
+			ptr = C.malloc (size);
+			XPCOM.memmove (ptr, buffer, size);
+			XPCOM.memmove (aValue, new int /*long*/[] {ptr}, C.PTR_SIZEOF);
+
+			if (valueAddr[0] != 0) {
+				int rc = XPCOM.NS_GetServiceManager (result2);
+				if (rc != XPCOM.NS_OK) SWT.error (rc);
+				if (result2[0] == 0) SWT.error (XPCOM.NS_NOINTERFACE);
+			
+				nsIServiceManager serviceManager = new nsIServiceManager (result2[0]);
+				result2[0] = 0;
+				byte[] aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_MEMORY_CONTRACTID, true);
+				rc = serviceManager.GetServiceByContractID (aContractID, nsIMemory.NS_IMEMORY_IID, result2);
+				if (rc != XPCOM.NS_OK) SWT.error (rc);
+				if (result2[0] == 0) SWT.error (XPCOM.NS_NOINTERFACE);		
+				serviceManager.Release ();
+				
+				nsIMemory memory = new nsIMemory (result2[0]);
+				result2[0] = 0;
+				memory.Free (valueAddr[0]);
+				memory.Release ();
+			}
+		}
+	}
+	if (aCheckState != 0) XPCOM.memmove (aCheckState, check, 4);
+	return XPCOM.NS_OK;
+}
+
+int PromptAuth(int /*long*/ aParent, int /*long*/ aChannel, int level, int /*long*/ authInfo, int /*long*/ checkboxLabel, int /*long*/ checkboxValue, int /*long*/ _retval) {
+	Browser browser = getBrowser (aParent);
+	String checkLabel = null;
+	int[] checkValue = new int[1];
+	String[] userLabel = new String[1], passLabel = new String[1];
+
+	String title = SWT.getMessage ("SWT_Authentication_Required"); //$NON-NLS-1$
+
+	if (checkboxLabel != 0 && checkboxValue != 0) {
+		int length = XPCOM.strlen_PRUnichar (checkboxLabel);
+		char[] dest = new char[length];
+		XPCOM.memmove (dest, checkboxLabel, length * 2);
+		checkLabel = new String (dest);
+		XPCOM.memmove (checkValue, checkboxValue, 4); /* PRBool */
+	}
+
+	/* get initial username and password values */
+
+	nsIAuthInformation auth = new nsIAuthInformation (authInfo);
+
+	int /*long*/ ptr = XPCOM.nsEmbedString_new ();
+	int rc = auth.GetUsername (ptr);
+	if (rc != XPCOM.NS_OK) SWT.error (rc);
+	int length = XPCOM.nsEmbedString_Length (ptr);
+	int /*long*/ buffer = XPCOM.nsEmbedString_get (ptr);
+	char[] chars = new char[length];
+	XPCOM.memmove (chars, buffer, length * 2);
+	userLabel[0] = new String (chars);
+	XPCOM.nsEmbedString_delete (ptr);
+
+	ptr = XPCOM.nsEmbedString_new ();
+	rc = auth.GetPassword (ptr);
+	if (rc != XPCOM.NS_OK) SWT.error (rc);
+	length = XPCOM.nsEmbedString_Length (ptr);
+	buffer = XPCOM.nsEmbedString_get (ptr);
+	chars = new char[length];
+	XPCOM.memmove (chars, buffer, length * 2);
+	passLabel[0] = new String (chars);
+	XPCOM.nsEmbedString_delete (ptr);
+
+	/* compute the message text */
+
+	ptr = XPCOM.nsEmbedString_new ();
+	rc = auth.GetRealm (ptr);
+	if (rc != XPCOM.NS_OK) SWT.error (rc);
+	length = XPCOM.nsEmbedString_Length (ptr);
+	buffer = XPCOM.nsEmbedString_get (ptr);
+	chars = new char[length];
+	XPCOM.memmove (chars, buffer, length * 2);
+	String realm = new String (chars);
+	XPCOM.nsEmbedString_delete (ptr);
+
+	nsIChannel channel = new nsIChannel (aChannel);
+	int /*long*/[] uri = new int /*long*/[1];
+	rc = channel.GetURI (uri);
+	if (rc != XPCOM.NS_OK) SWT.error (rc);
+	if (uri[0] == 0) Mozilla.error (XPCOM.NS_NOINTERFACE);
+
+	nsIURI nsURI = new nsIURI (uri[0]);
+	int /*long*/ aSpec = XPCOM.nsEmbedCString_new ();
+	rc = nsURI.GetHost (aSpec);
+	if (rc != XPCOM.NS_OK) SWT.error (rc);
+	length = XPCOM.nsEmbedCString_Length (aSpec);
+	buffer = XPCOM.nsEmbedCString_get (aSpec);
+	byte[] bytes = new byte[length];
+	XPCOM.memmove (bytes, buffer, length);
+	XPCOM.nsEmbedCString_delete (aSpec);
+	String host = new String (bytes);
+	nsURI.Release ();
+
+	String message;
+	if (realm.length () > 0 && host.length () > 0) {
+		message = Compatibility.getMessage ("SWT_Enter_Username_and_Password", new String[] {realm, host}); //$NON-NLS-1$
+	} else {
+		message = ""; //$NON-NLS-1$
+	}
+
+	/* open the prompter */
+	Shell shell = browser == null ? new Shell () : browser.getShell ();
+	PromptDialog dialog = new PromptDialog (shell);
+	int[] result = new int[1];
+	dialog.promptUsernameAndPassword (title, message, checkLabel, userLabel, passLabel, checkValue, result);
+
+	XPCOM.memmove (_retval, result, 4);	/* PRBool */
+	if (result[0] == 1) {	/* User selected OK */
+		nsEmbedString string = new nsEmbedString (userLabel[0]);
+		rc = auth.SetUsername(string.getAddress ());
+		if (rc != XPCOM.NS_OK) SWT.error (rc);
+		string.dispose ();
+		
+		string = new nsEmbedString (passLabel[0]);
+		rc = auth.SetPassword(string.getAddress ());
+		if (rc != XPCOM.NS_OK) SWT.error (rc);
+		string.dispose ();
+	}
+
+	if (checkboxValue != 0) XPCOM.memmove (checkboxValue, checkValue, 4); /* PRBool */
+	return XPCOM.NS_OK;
+}
+
+int PromptUsernameAndPassword (int /*long*/ aParent, int /*long*/ aDialogTitle, int /*long*/ aText, int /*long*/ aUsername, int /*long*/ aPassword, int /*long*/ aCheckMsg, int /*long*/ aCheckState, int /*long*/ _retval) {
+	Browser browser = getBrowser (aParent);
+	String titleLabel, textLabel, checkLabel = null;
+	String[] userLabel = new String[1], passLabel = new String[1];
+	char[] dest;
+	int length;
+	if (aDialogTitle != 0) {
+		length = XPCOM.strlen_PRUnichar (aDialogTitle);
+		dest = new char[length];
+		XPCOM.memmove (dest, aDialogTitle, length * 2);
+		titleLabel = new String (dest);
+	} else {
+		titleLabel = SWT.getMessage ("SWT_Authentication_Required");	//$NON-NLS-1$
+	}
+	
+	length = XPCOM.strlen_PRUnichar (aText);
+	dest = new char[length];
+	XPCOM.memmove (dest, aText, length * 2);
+	textLabel = new String (dest);
+	
+	int /*long*/[] userAddr = new int /*long*/[1];
+	XPCOM.memmove (userAddr, aUsername, C.PTR_SIZEOF);
+	if (userAddr[0] != 0) {
+		length = XPCOM.strlen_PRUnichar (userAddr[0]);
+		dest = new char[length];
+		XPCOM.memmove (dest, userAddr[0], length * 2);
+		userLabel[0] = new String (dest);		
+	}
+	
+	int /*long*/[] passAddr = new int /*long*/[1];
+	XPCOM.memmove (passAddr, aPassword, C.PTR_SIZEOF);
+	if (passAddr[0] != 0) {
+		length = XPCOM.strlen_PRUnichar (passAddr[0]);
+		dest = new char[length];
+		XPCOM.memmove (dest, passAddr[0], length * 2);
+		passLabel[0] = new String (dest);		
+	}
+	
+	if (aCheckMsg != 0) {
+		length = XPCOM.strlen_PRUnichar (aCheckMsg);
+		if (length > 0) {
+			dest = new char[length];
+			XPCOM.memmove (dest, aCheckMsg, length * 2);
+			checkLabel = new String (dest);
+		}
+	}
+
+	Shell shell = browser == null ? new Shell () : browser.getShell ();
+	PromptDialog dialog = new PromptDialog (shell);
+	int[] check = new int[1], result = new int[1];
+	if (aCheckState != 0) XPCOM.memmove (check, aCheckState, 4);	/* PRBool */
+	dialog.promptUsernameAndPassword (titleLabel, textLabel, checkLabel, userLabel, passLabel, check, result);
+
+	XPCOM.memmove (_retval, result, 4);	/* PRBool */
+	if (result[0] == 1) {
+		/* 
+		* User selected OK. User name and password are returned as PRUnichar values. Any default
+		* value that we override must be freed using the nsIMemory service.
+		*/
+		int cnt, size;
+		int /*long*/ ptr;
+		char[] buffer;
+		int /*long*/[] result2 = new int /*long*/[1];
+		if (userLabel[0] != null) {
+			cnt = userLabel[0].length ();
+			buffer = new char[cnt + 1];
+			userLabel[0].getChars (0, cnt, buffer, 0);
+			size = buffer.length * 2;
+			ptr = C.malloc (size);
+			XPCOM.memmove (ptr, buffer, size);
+			XPCOM.memmove (aUsername, new int /*long*/[] {ptr}, C.PTR_SIZEOF);
+
+			if (userAddr[0] != 0) {
+				int rc = XPCOM.NS_GetServiceManager (result2);
+				if (rc != XPCOM.NS_OK) SWT.error (rc);
+				if (result2[0] == 0) SWT.error (XPCOM.NS_NOINTERFACE);
+			
+				nsIServiceManager serviceManager = new nsIServiceManager (result2[0]);
+				result2[0] = 0;
+				byte[] aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_MEMORY_CONTRACTID, true);
+				rc = serviceManager.GetServiceByContractID (aContractID, nsIMemory.NS_IMEMORY_IID, result2);
+				if (rc != XPCOM.NS_OK) SWT.error (rc);
+				if (result[0] == 0) SWT.error (XPCOM.NS_NOINTERFACE);		
+				serviceManager.Release ();
+				
+				nsIMemory memory = new nsIMemory (result2[0]);
+				result2[0] = 0;
+				memory.Free (userAddr[0]);
+				memory.Release ();
+			}
+		}
+		if (passLabel[0] != null) {
+			cnt = passLabel[0].length ();
+			buffer = new char[cnt + 1];
+			passLabel[0].getChars (0, cnt, buffer, 0);
+			size = buffer.length * 2;
+			ptr = C.malloc (size);
+			XPCOM.memmove (ptr, buffer, size);
+			XPCOM.memmove (aPassword, new int /*long*/[] {ptr}, C.PTR_SIZEOF);
+			
+			if (passAddr[0] != 0) {
+				int rc = XPCOM.NS_GetServiceManager (result2);
+				if (rc != XPCOM.NS_OK) SWT.error (rc);
+				if (result2[0] == 0) SWT.error (XPCOM.NS_NOINTERFACE);
+
+				nsIServiceManager serviceManager = new nsIServiceManager (result2[0]);
+				result2[0] = 0;
+				byte[] aContractID = MozillaDelegate.wcsToMbcs (null, XPCOM.NS_MEMORY_CONTRACTID, true);
+				rc = serviceManager.GetServiceByContractID (aContractID, nsIMemory.NS_IMEMORY_IID, result2);
+				if (rc != XPCOM.NS_OK) SWT.error (rc);
+				if (result2[0] == 0) SWT.error (XPCOM.NS_NOINTERFACE);		
+				serviceManager.Release ();
+
+				nsIMemory memory = new nsIMemory (result2[0]);
+				result2[0] = 0;
+				memory.Free (passAddr[0]);
+				memory.Release ();
+			}
+		}
+	}
+	if (aCheckState != 0) XPCOM.memmove (aCheckState, check, 4); /* PRBool */
+	return XPCOM.NS_OK;
+}
+
+int PromptPassword (int /*long*/ aParent, int /*long*/ aDialogTitle, int /*long*/ aText, int /*long*/ aPassword, int /*long*/ aCheckMsg, int /*long*/ aCheckState, int /*long*/ _retval) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+int Select (int /*long*/ aParent, int /*long*/ aDialogTitle, int /*long*/ aText, int aCount, int /*long*/ aSelectList, int /*long*/ aOutSelection, int /*long*/ _retval) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/browser/PromptService2Factory.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/browser/PromptService2Factory.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/browser/PromptService2Factory.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,100 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.browser;
+
+import org.eclipse.swt.internal.C;
+import org.eclipse.swt.internal.mozilla.*;
+
+class PromptService2Factory {
+	XPCOMObject supports;
+	XPCOMObject factory;
+	int refCount = 0;
+
+PromptService2Factory () {
+	createCOMInterfaces ();
+}
+
+int AddRef () {
+	refCount++;
+	return refCount;
+}
+
+void createCOMInterfaces () {
+	/* Create each of the interfaces that this object implements */
+	supports = new XPCOMObject (new int[] {2, 0, 0}) {
+		public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+		public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+		public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+	};
+	
+	factory = new XPCOMObject (new int[] {2, 0, 0, 3, 1}) {
+		public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+		public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+		public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+		public int /*long*/ method3 (int /*long*/[] args) {return CreateInstance (args[0], args[1], args[2]);}
+		public int /*long*/ method4 (int /*long*/[] args) {return LockFactory ((int)/*64*/args[0]);}
+	};
+}
+
+void disposeCOMInterfaces () {
+	if (supports != null) {
+		supports.dispose ();
+		supports = null;
+	}	
+	if (factory != null) {
+		factory.dispose ();
+		factory = null;	
+	}
+}
+
+int /*long*/ getAddress () {
+	return factory.getAddress ();
+}
+
+int QueryInterface (int /*long*/ riid, int /*long*/ ppvObject) {
+	if (riid == 0 || ppvObject == 0) return XPCOM.NS_ERROR_NO_INTERFACE;
+	nsID guid = new nsID ();
+	XPCOM.memmove (guid, riid, nsID.sizeof);
+	
+	if (guid.Equals (nsISupports.NS_ISUPPORTS_IID)) {
+		XPCOM.memmove (ppvObject, new int /*long*/[] {supports.getAddress ()}, C.PTR_SIZEOF);
+		AddRef ();
+		return XPCOM.NS_OK;
+	}
+	if (guid.Equals (nsIFactory.NS_IFACTORY_IID)) {
+		XPCOM.memmove (ppvObject, new int /*long*/[] {factory.getAddress ()}, C.PTR_SIZEOF);
+		AddRef ();
+		return XPCOM.NS_OK;
+	}
+	
+	XPCOM.memmove (ppvObject, new int /*long*/[] {0}, C.PTR_SIZEOF);
+	return XPCOM.NS_ERROR_NO_INTERFACE;
+}
+        	
+int Release () {
+	refCount--;
+	if (refCount == 0) disposeCOMInterfaces ();
+	return refCount;
+}
+	
+/* nsIFactory */
+
+int CreateInstance (int /*long*/ aOuter, int /*long*/ iid, int /*long*/ result) {
+	PromptService2 promptService = new PromptService2 ();
+	promptService.AddRef ();
+	XPCOM.memmove (result, new int /*long*/[] {promptService.getAddress ()}, C.PTR_SIZEOF);
+	return XPCOM.NS_OK;
+}
+
+int LockFactory (int lock) {
+	return XPCOM.NS_OK;
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/browser/SimpleEnumerator.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/browser/SimpleEnumerator.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/browser/SimpleEnumerator.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,114 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.browser;
+
+import org.eclipse.swt.internal.C;
+import org.eclipse.swt.internal.mozilla.*;
+
+class SimpleEnumerator {
+	XPCOMObject supports;
+	XPCOMObject simpleEnumerator;
+	int refCount = 0;
+	nsISupports[] values;
+	int index = 0;
+
+SimpleEnumerator (nsISupports[] values) {
+	this.values = values;
+	for (int i = 0; i < values.length; i++) {
+		values[i].AddRef ();
+	}
+	createCOMInterfaces ();
+}
+
+int AddRef () {
+	refCount++;
+	return refCount;
+}
+
+void createCOMInterfaces () {
+	/* Create each of the interfaces that this object implements */
+	supports = new XPCOMObject (new int[] {2, 0, 0}) {
+		public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+		public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+		public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+	};
+
+	simpleEnumerator = new XPCOMObject (new int[] {2, 0, 0, 1, 1}) {
+		public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+		public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+		public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+		public int /*long*/ method3 (int /*long*/[] args) {return HasMoreElements (args[0]);}
+		public int /*long*/ method4 (int /*long*/[] args) {return GetNext (args[0]);}
+	};
+}
+
+void disposeCOMInterfaces () {
+	if (supports != null) {
+		supports.dispose ();
+		supports = null;
+	}	
+	if (simpleEnumerator != null) {
+		simpleEnumerator.dispose ();
+		simpleEnumerator = null;	
+	}
+	if (values != null) {
+		for (int i = 0; i < values.length; i++) {
+			values[i].Release ();
+		}
+		values = null;
+	}
+}
+
+int /*long*/ getAddress () {
+	return simpleEnumerator.getAddress ();
+}
+
+int QueryInterface (int /*long*/ riid, int /*long*/ ppvObject) {
+	if (riid == 0 || ppvObject == 0) return XPCOM.NS_ERROR_NO_INTERFACE;
+	nsID guid = new nsID ();
+	XPCOM.memmove (guid, riid, nsID.sizeof);
+
+	if (guid.Equals (nsISupports.NS_ISUPPORTS_IID)) {
+		XPCOM.memmove (ppvObject, new int /*long*/[] {supports.getAddress ()}, C.PTR_SIZEOF);
+		AddRef ();
+		return XPCOM.NS_OK;
+	}
+	if (guid.Equals (nsISimpleEnumerator.NS_ISIMPLEENUMERATOR_IID)) {
+		XPCOM.memmove (ppvObject, new int /*long*/[] {simpleEnumerator.getAddress ()}, C.PTR_SIZEOF);
+		AddRef ();
+		return XPCOM.NS_OK;
+	}
+
+	XPCOM.memmove (ppvObject, new int /*long*/[] {0}, C.PTR_SIZEOF);
+	return XPCOM.NS_ERROR_NO_INTERFACE;
+}
+
+int Release () {
+	refCount--;
+	if (refCount == 0) disposeCOMInterfaces ();
+	return refCount;
+}
+
+int HasMoreElements (int /*long*/ _retval) {
+	boolean more = values != null && index < values.length;
+	XPCOM.memmove (_retval, new int[] {more ? 1 : 0}, 4); /*PRBool */
+	return XPCOM.NS_OK;
+}	
+	
+int GetNext (int /*long*/ _retval) {
+	if (values == null || index == values.length) return XPCOM.NS_ERROR_UNEXPECTED;
+	nsISupports value = values[index++];
+    value.AddRef ();
+    XPCOM.memmove (_retval, new int /*long*/[] {value.getAddress ()}, C.PTR_SIZEOF);
+    return XPCOM.NS_OK;
+}		
+}
+

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/browser/StatusTextEvent.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/browser/StatusTextEvent.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/browser/StatusTextEvent.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.browser;
+
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.events.*;
+
+/**
+ * A <code>StatusTextEvent</code> is sent by a {@link Browser} to
+ * {@link StatusTextListener}'s when the status text is changed.
+ * The status text is typically displayed in the status bar of
+ * a browser application.
+ * 
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ *
+ * @since 3.0
+ */
+public class StatusTextEvent extends TypedEvent {
+	/** status text */
+	public String text;
+	
+	static final long serialVersionUID = 3258407348371600439L;
+
+StatusTextEvent(Widget w) {
+	super(w);
+}
+
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the event
+ */
+public String toString() {
+	String string = super.toString ();
+	return string.substring (0, string.length() - 1) // remove trailing '}'
+		+ " text=" + text
+		+ "}";
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/browser/StatusTextListener.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/browser/StatusTextListener.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/browser/StatusTextListener.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.browser;
+
+import org.eclipse.swt.internal.SWTEventListener;
+
+/**
+ * This listener interface may be implemented in order to receive
+ * a {@link StatusTextEvent} notification when the status text for
+ * a {@link Browser} is changed.
+ * 
+ * @see Browser#addStatusTextListener(StatusTextListener)
+ * @see Browser#removeStatusTextListener(StatusTextListener)
+ * 
+ * @since 3.0
+ */
+public interface StatusTextListener extends SWTEventListener {
+
+/**
+ * This method is called when the status text is changed. The
+ * status text is typically displayed in the status bar of a browser 
+ * application. 
+ * <p>
+ *
+ * <p>The following fields in the <code>StatusTextEvent</code> apply:
+ * <ul>
+ * <li>(in) text the modified status text
+ * <li>(in) widget the <code>Browser</code> whose status text is changed
+ * </ul>
+ * 
+ * @param event the <code>StatusTextEvent</code> that contains the updated
+ * status description of a <code>Browser</code>
+ * 
+ * @since 3.0
+ */
+public void changed(StatusTextEvent event);
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/browser/TitleEvent.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/browser/TitleEvent.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/browser/TitleEvent.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.browser;
+
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.events.*;
+
+/**
+ * A <code>TitleEvent</code> is sent by a {@link Browser} to
+ * {@link TitleListener}'s when the title of the current document
+ * is available or when it is modified.
+ * 
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ *
+ * @since 3.0
+ */
+public class TitleEvent extends TypedEvent {
+	/** the title of the current document */
+	public String title;
+	
+	static final long serialVersionUID = 4121132532906340919L;
+
+TitleEvent(Widget w) {
+	super(w);
+}
+
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the event
+ */
+public String toString() {
+	String string = super.toString ();
+	return string.substring (0, string.length() - 1) // remove trailing '}'
+		+ " title=" + title
+		+ "}";
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/browser/TitleListener.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/browser/TitleListener.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/browser/TitleListener.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.browser;
+
+import org.eclipse.swt.internal.SWTEventListener;
+
+/**
+ * This listener interface may be implemented in order to receive
+ * a {@link TitleEvent} notification when the title of the document
+ * displayed in a {@link Browser} is known or has been changed.
+ * 
+ * @see Browser#addTitleListener(TitleListener)
+ * @see Browser#removeTitleListener(TitleListener)
+ * 
+ * @since 3.0
+ */
+public interface TitleListener extends SWTEventListener {
+
+/**
+ * This method is called when the title of the current document
+ * is available or has changed.
+ * <p>
+ *
+ * <p>The following fields in the <code>TitleEvent</code> apply:
+ * <ul>
+ * <li>(in) title the title of the current document
+ * <li>(in) widget the <code>Browser</code> whose current document's
+ * title is known or modified
+ * </ul>
+ * 
+ * @param event the <code>TitleEvent</code> that contains the title
+ * of the document currently displayed in a <code>Browser</code>
+ * 
+ * @since 3.0
+ */
+public void changed(TitleEvent event);
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/browser/VisibilityWindowAdapter.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/browser/VisibilityWindowAdapter.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/browser/VisibilityWindowAdapter.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.browser;
+
+/**
+ * This adapter class provides default implementations for the
+ * methods described by the {@link VisibilityWindowListener} interface.
+ * <p>
+ * Classes that wish to deal with {@link WindowEvent}'s can
+ * extend this class and override only the methods which they are
+ * interested in.
+ * </p>
+ * 
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ *
+ * @since 3.0
+ */
+public abstract class VisibilityWindowAdapter implements VisibilityWindowListener {
+
+public void hide(WindowEvent event) {
+}
+ 
+public void show(WindowEvent event) {
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/browser/VisibilityWindowListener.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/browser/VisibilityWindowListener.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/browser/VisibilityWindowListener.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,91 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.browser;
+
+import org.eclipse.swt.internal.SWTEventListener;
+
+/** 
+ * This listener interface may be implemented in order to receive
+ * a {@link WindowEvent} notification when a window hosting a
+ * {@link Browser} needs to be displayed or hidden.
+ * 
+ * @see Browser#addVisibilityWindowListener(VisibilityWindowListener)
+ * @see Browser#removeVisibilityWindowListener(VisibilityWindowListener)
+ * @see OpenWindowListener
+ * @see CloseWindowListener
+ * 
+ * @since 3.0
+ */
+public interface VisibilityWindowListener extends SWTEventListener {
+	
+/**
+ * This method is called when the window hosting a <code>Browser</code> 
+ * is requested to be hidden. Application would typically hide the
+ * {@link org.eclipse.swt.widgets.Shell} that hosts the <code>Browser</code>.
+ * <p>
+ *
+ * <p>The following fields in the <code>WindowEvent</code> apply:
+ * <ul>
+ * <li>(in) widget the <code>Browser</code> that needs to be hidden
+ * </ul>
+ *
+ * @param event the <code>WindowEvent</code> that specifies the
+ * <code>Browser</code> that needs to be hidden
+ * 
+ * @see org.eclipse.swt.widgets.Shell#setVisible(boolean)
+ * 
+ * @since 3.0
+ */ 
+public void hide(WindowEvent event);
+
+/**
+ * This method is called when the window hosting a <code>Browser</code>
+ * is requested to be displayed. Application would typically set the 
+ * location and the size of the {@link org.eclipse.swt.widgets.Shell} 
+ * that hosts the <code>Browser</code>, if a particular location and size
+ * are specified. The application would then open that <code>Shell</code>.
+ * <p>
+ *
+ * <p>The following fields in the <code>WindowEvent</code> apply:
+ * <ul>
+ * <li>(in) widget the <code>Browser</code> to display
+ * <li>(in) location the requested location for the <code>Shell</code> 
+ * hosting the browser. It is <code>null</code> if no location is set. 
+ * <li>(in) size the requested size for the <code>Browser</code>.
+ * The client area of the <code>Shell</code> hosting the
+ * <code>Browser</code> should be large enough to accommodate that size.
+ * It is <code>null</code> if no size is set.
+ * <li>(in) addressBar <code>true</code> if the <code>Shell</code> 
+ * hosting the <code>Browser</code> should display an address bar or
+ * <code>false</code> otherwise
+ * <li>(in) menuBar <code>true</code> if the <code>Shell</code> 
+ * hosting the <code>Browser</code> should display a menu bar or
+ * <code>false</code> otherwise
+ * <li>(in) statusBar <code>true</code> if the <code>Shell</code> 
+ * hosting the <code>Browser</code> should display a status bar or
+ * <code>false</code> otherwise
+ * <li>(in) toolBar <code>true</code> if the <code>Shell</code> 
+ * hosting the <code>Browser</code> should display a tool bar or
+ * <code>false</code> otherwise
+ * </ul>
+ *
+ * @param event the <code>WindowEvent</code> that specifies the
+ * <code>Browser</code> that needs to be displayed
+ * 
+ * @see org.eclipse.swt.widgets.Control#setLocation(org.eclipse.swt.graphics.Point)
+ * @see org.eclipse.swt.widgets.Control#setSize(org.eclipse.swt.graphics.Point)
+ * @see org.eclipse.swt.widgets.Shell#open()
+ * 
+ * @since 3.0
+ */ 
+public void show(WindowEvent event);
+
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/browser/WebBrowser.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/browser/WebBrowser.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/browser/WebBrowser.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,401 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.browser;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.*;
+
+abstract class WebBrowser {
+	Browser browser;
+	CloseWindowListener[] closeWindowListeners = new CloseWindowListener[0];
+	LocationListener[] locationListeners = new LocationListener[0];
+	OpenWindowListener[] openWindowListeners = new OpenWindowListener[0];
+	ProgressListener[] progressListeners = new ProgressListener[0];
+	StatusTextListener[] statusTextListeners = new StatusTextListener[0];
+	TitleListener[] titleListeners = new TitleListener[0];
+	VisibilityWindowListener[] visibilityWindowListeners = new VisibilityWindowListener[0];
+
+	static Runnable MozillaClearSessions;
+	static Runnable NativeClearSessions;
+
+	/* Key Mappings */
+	static final int [][] KeyTable = {
+		/* Keyboard and Mouse Masks */
+		{18,	SWT.ALT},
+		{16,	SWT.SHIFT},
+		{17,	SWT.CONTROL},
+		{224,	SWT.COMMAND},
+
+		/* Literal Keys */
+		{65,	'a'},
+		{66,	'b'},
+		{67,	'c'},
+		{68,	'd'},
+		{69,	'e'},
+		{70,	'f'},
+		{71,	'g'},
+		{72,	'h'},
+		{73,	'i'},
+		{74,	'j'},
+		{75,	'k'},
+		{76,	'l'},
+		{77,	'm'},
+		{78,	'n'},
+		{79,	'o'},
+		{80,	'p'},
+		{81,	'q'},
+		{82,	'r'},
+		{83,	's'},
+		{84,	't'},
+		{85,	'u'},
+		{86,	'v'},
+		{87,	'w'},
+		{88,	'x'},
+		{89,	'y'},
+		{90,	'z'},
+		{48,	'0'},
+		{49,	'1'},
+		{50,	'2'},
+		{51,	'3'},
+		{52,	'4'},
+		{53,	'5'},
+		{54,	'6'},
+		{55,	'7'},
+		{56,	'8'},
+		{57,	'9'},
+		{32,	' '},
+		{59,	';'},
+		{61,	'='},
+		{188,	','},
+		{190,	'.'},
+		{191,	'/'},
+		{219,	'['},
+		{221,	']'},
+		{222,	'\''},
+		{192,	'`'},
+		{220,	'\\'},
+		{108,	'|'},
+
+		/* Non-Numeric Keypad Keys */
+		{37,	SWT.ARROW_LEFT},
+		{39,	SWT.ARROW_RIGHT},
+		{38,	SWT.ARROW_UP},
+		{40,	SWT.ARROW_DOWN},
+		{45,	SWT.INSERT},
+		{36,	SWT.HOME},
+		{35,	SWT.END},
+		{46,	SWT.DEL},
+		{33,	SWT.PAGE_UP},
+		{34,	SWT.PAGE_DOWN},
+
+		/* Virtual and Ascii Keys */
+		{8,		SWT.BS},
+		{13,	SWT.CR},
+		{9,		SWT.TAB},
+		{27,	SWT.ESC},
+		{12,	SWT.DEL},
+
+		/* Functions Keys */
+		{112,	SWT.F1},
+		{113,	SWT.F2},
+		{114,	SWT.F3},
+		{115,	SWT.F4},
+		{116,	SWT.F5},
+		{117,	SWT.F6},
+		{118,	SWT.F7},
+		{119,	SWT.F8},
+		{120,	SWT.F9},
+		{121,	SWT.F10},
+		{122,	SWT.F11},
+		{123,	SWT.F12},
+		{124,	SWT.F13},
+		{125,	SWT.F14},
+		{126,	SWT.F15},
+		{127,	0},
+		{128,	0},
+		{129,	0},
+		{130,	0},
+		{131,	0},
+		{132,	0},
+		{133,	0},
+		{134,	0},
+		{135,	0},
+
+		/* Numeric Keypad Keys */
+		{96,	SWT.KEYPAD_0},
+		{97,	SWT.KEYPAD_1},
+		{98,	SWT.KEYPAD_2},
+		{99,	SWT.KEYPAD_3},
+		{100,	SWT.KEYPAD_4},
+		{101,	SWT.KEYPAD_5},
+		{102,	SWT.KEYPAD_6},
+		{103,	SWT.KEYPAD_7},
+		{104,	SWT.KEYPAD_8},
+		{105,	SWT.KEYPAD_9},
+		{14,	SWT.KEYPAD_CR},
+		{107,	SWT.KEYPAD_ADD},
+		{109,	SWT.KEYPAD_SUBTRACT},
+		{106,	SWT.KEYPAD_MULTIPLY},
+		{111,	SWT.KEYPAD_DIVIDE},
+		{110,	SWT.KEYPAD_DECIMAL},
+
+		/* Other keys */
+		{20,	SWT.CAPS_LOCK},
+		{144,	SWT.NUM_LOCK},
+		{145,	SWT.SCROLL_LOCK},
+		{44,	SWT.PRINT_SCREEN},
+		{6,		SWT.HELP},
+		{19,	SWT.PAUSE},
+		{3,		SWT.BREAK},
+
+		/* Safari-specific */
+		{186,	';'},
+		{187,	'='},
+		{189,	'-'},
+	};
+
+public void addCloseWindowListener (CloseWindowListener listener) {
+	CloseWindowListener[] newCloseWindowListeners = new CloseWindowListener[closeWindowListeners.length + 1];
+	System.arraycopy(closeWindowListeners, 0, newCloseWindowListeners, 0, closeWindowListeners.length);
+	closeWindowListeners = newCloseWindowListeners;
+	closeWindowListeners[closeWindowListeners.length - 1] = listener;
+}
+
+public void addLocationListener (LocationListener listener) {
+	LocationListener[] newLocationListeners = new LocationListener[locationListeners.length + 1];
+	System.arraycopy(locationListeners, 0, newLocationListeners, 0, locationListeners.length);
+	locationListeners = newLocationListeners;
+	locationListeners[locationListeners.length - 1] = listener;
+}
+
+public void addOpenWindowListener (OpenWindowListener listener) {
+	OpenWindowListener[] newOpenWindowListeners = new OpenWindowListener[openWindowListeners.length + 1];
+	System.arraycopy(openWindowListeners, 0, newOpenWindowListeners, 0, openWindowListeners.length);
+	openWindowListeners = newOpenWindowListeners;
+	openWindowListeners[openWindowListeners.length - 1] = listener;
+}
+
+public void addProgressListener (ProgressListener listener) {
+	ProgressListener[] newProgressListeners = new ProgressListener[progressListeners.length + 1];
+	System.arraycopy(progressListeners, 0, newProgressListeners, 0, progressListeners.length);
+	progressListeners = newProgressListeners;
+	progressListeners[progressListeners.length - 1] = listener;
+}
+
+public void addStatusTextListener (StatusTextListener listener) {
+	StatusTextListener[] newStatusTextListeners = new StatusTextListener[statusTextListeners.length + 1];
+	System.arraycopy(statusTextListeners, 0, newStatusTextListeners, 0, statusTextListeners.length);
+	statusTextListeners = newStatusTextListeners;
+	statusTextListeners[statusTextListeners.length - 1] = listener;
+}
+
+public void addTitleListener (TitleListener listener) {
+	TitleListener[] newTitleListeners = new TitleListener[titleListeners.length + 1];
+	System.arraycopy(titleListeners, 0, newTitleListeners, 0, titleListeners.length);
+	titleListeners = newTitleListeners;
+	titleListeners[titleListeners.length - 1] = listener;
+}
+
+public void addVisibilityWindowListener (VisibilityWindowListener listener) {
+	VisibilityWindowListener[] newVisibilityWindowListeners = new VisibilityWindowListener[visibilityWindowListeners.length + 1];
+	System.arraycopy(visibilityWindowListeners, 0, newVisibilityWindowListeners, 0, visibilityWindowListeners.length);
+	visibilityWindowListeners = newVisibilityWindowListeners;
+	visibilityWindowListeners[visibilityWindowListeners.length - 1] = listener;
+}
+
+public abstract boolean back ();
+
+public static void clearSessions () {
+	if (NativeClearSessions != null) NativeClearSessions.run ();
+	if (MozillaClearSessions != null) MozillaClearSessions.run ();
+}
+
+public abstract void create (Composite parent, int style);
+
+public abstract boolean execute (String script);
+
+public abstract boolean forward ();
+
+public abstract String getText ();
+
+public abstract String getUrl ();
+
+public Object getWebBrowser () {
+	return null;
+}
+
+public abstract boolean isBackEnabled ();
+
+public boolean isFocusControl () {
+	return false;
+}
+
+public abstract boolean isForwardEnabled ();
+
+public abstract void refresh ();
+
+public void removeCloseWindowListener (CloseWindowListener listener) {
+	if (closeWindowListeners.length == 0) return;
+	int index = -1;
+	for (int i = 0; i < closeWindowListeners.length; i++) {
+		if (listener == closeWindowListeners[i]){
+			index = i;
+			break;
+		}
+	}
+	if (index == -1) return;
+	if (closeWindowListeners.length == 1) {
+		closeWindowListeners = new CloseWindowListener[0];
+		return;
+	}
+	CloseWindowListener[] newCloseWindowListeners = new CloseWindowListener[closeWindowListeners.length - 1];
+	System.arraycopy (closeWindowListeners, 0, newCloseWindowListeners, 0, index);
+	System.arraycopy (closeWindowListeners, index + 1, newCloseWindowListeners, index, closeWindowListeners.length - index - 1);
+	closeWindowListeners = newCloseWindowListeners;
+}
+
+public void removeLocationListener (LocationListener listener) {
+	if (locationListeners.length == 0) return;
+	int index = -1;
+	for (int i = 0; i < locationListeners.length; i++) {
+		if (listener == locationListeners[i]){
+			index = i;
+			break;
+		}
+	}
+	if (index == -1) return;
+	if (locationListeners.length == 1) {
+		locationListeners = new LocationListener[0];
+		return;
+	}
+	LocationListener[] newLocationListeners = new LocationListener[locationListeners.length - 1];
+	System.arraycopy (locationListeners, 0, newLocationListeners, 0, index);
+	System.arraycopy (locationListeners, index + 1, newLocationListeners, index, locationListeners.length - index - 1);
+	locationListeners = newLocationListeners;
+}
+
+public void removeOpenWindowListener (OpenWindowListener listener) {
+	if (openWindowListeners.length == 0) return;
+	int index = -1;
+	for (int i = 0; i < openWindowListeners.length; i++) {
+		if (listener == openWindowListeners[i]){
+			index = i;
+			break;
+		}
+	}
+	if (index == -1) return;
+	if (openWindowListeners.length == 1) {
+		openWindowListeners = new OpenWindowListener[0];
+		return;
+	}
+	OpenWindowListener[] newOpenWindowListeners = new OpenWindowListener[openWindowListeners.length - 1];
+	System.arraycopy (openWindowListeners, 0, newOpenWindowListeners, 0, index);
+	System.arraycopy (openWindowListeners, index + 1, newOpenWindowListeners, index, openWindowListeners.length - index - 1);
+	openWindowListeners = newOpenWindowListeners;
+}
+
+public void removeProgressListener (ProgressListener listener) {
+	if (progressListeners.length == 0) return;
+	int index = -1;
+	for (int i = 0; i < progressListeners.length; i++) {
+		if (listener == progressListeners[i]){
+			index = i;
+			break;
+		}
+	}
+	if (index == -1) return;
+	if (progressListeners.length == 1) {
+		progressListeners = new ProgressListener[0];
+		return;
+	}
+	ProgressListener[] newProgressListeners = new ProgressListener[progressListeners.length - 1];
+	System.arraycopy (progressListeners, 0, newProgressListeners, 0, index);
+	System.arraycopy (progressListeners, index + 1, newProgressListeners, index, progressListeners.length - index - 1);
+	progressListeners = newProgressListeners;
+}
+
+public void removeStatusTextListener (StatusTextListener listener) {
+	if (statusTextListeners.length == 0) return;
+	int index = -1;
+	for (int i = 0; i < statusTextListeners.length; i++) {
+		if (listener == statusTextListeners[i]){
+			index = i;
+			break;
+		}
+	}
+	if (index == -1) return;
+	if (statusTextListeners.length == 1) {
+		statusTextListeners = new StatusTextListener[0];
+		return;
+	}
+	StatusTextListener[] newStatusTextListeners = new StatusTextListener[statusTextListeners.length - 1];
+	System.arraycopy (statusTextListeners, 0, newStatusTextListeners, 0, index);
+	System.arraycopy (statusTextListeners, index + 1, newStatusTextListeners, index, statusTextListeners.length - index - 1);
+	statusTextListeners = newStatusTextListeners;
+}
+
+public void removeTitleListener (TitleListener listener) {
+	if (titleListeners.length == 0) return;
+	int index = -1;
+	for (int i = 0; i < titleListeners.length; i++) {
+		if (listener == titleListeners[i]){
+			index = i;
+			break;
+		}
+	}
+	if (index == -1) return;
+	if (titleListeners.length == 1) {
+		titleListeners = new TitleListener[0];
+		return;
+	}
+	TitleListener[] newTitleListeners = new TitleListener[titleListeners.length - 1];
+	System.arraycopy (titleListeners, 0, newTitleListeners, 0, index);
+	System.arraycopy (titleListeners, index + 1, newTitleListeners, index, titleListeners.length - index - 1);
+	titleListeners = newTitleListeners;
+}
+
+public void removeVisibilityWindowListener (VisibilityWindowListener listener) {
+	if (visibilityWindowListeners.length == 0) return;
+	int index = -1;
+	for (int i = 0; i < visibilityWindowListeners.length; i++) {
+		if (listener == visibilityWindowListeners[i]){
+			index = i;
+			break;
+		}
+	}
+	if (index == -1) return;
+	if (visibilityWindowListeners.length == 1) {
+		visibilityWindowListeners = new VisibilityWindowListener[0];
+		return;
+	}
+	VisibilityWindowListener[] newVisibilityWindowListeners = new VisibilityWindowListener[visibilityWindowListeners.length - 1];
+	System.arraycopy (visibilityWindowListeners, 0, newVisibilityWindowListeners, 0, index);
+	System.arraycopy (visibilityWindowListeners, index + 1, newVisibilityWindowListeners, index, visibilityWindowListeners.length - index - 1);
+	visibilityWindowListeners = newVisibilityWindowListeners;
+}
+
+public void setBrowser (Browser browser) {
+	this.browser = browser;
+}
+
+public abstract boolean setText (String html);
+
+public abstract boolean setUrl (String url);
+
+public abstract void stop ();
+
+int translateKey (int key) {
+	for (int i = 0; i < KeyTable.length; i++) {
+		if (KeyTable[i][0] == key) return KeyTable[i][1];
+	}
+	return 0;
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/browser/WindowCreator2.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/browser/WindowCreator2.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/browser/WindowCreator2.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,226 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.browser;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.mozilla.*;
+import org.eclipse.swt.layout.*;
+import org.eclipse.swt.widgets.*;
+
+class WindowCreator2 {
+	XPCOMObject supports;
+	XPCOMObject windowCreator;
+	XPCOMObject windowCreator2;
+	int refCount = 0;
+
+WindowCreator2 () {
+	createCOMInterfaces ();
+}
+
+int AddRef () {
+	refCount++;
+	return refCount;
+}
+
+void createCOMInterfaces () {
+	/* Create each of the interfaces that this object implements */
+	supports = new XPCOMObject (new int[] {2, 0, 0}) {
+		public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+		public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+		public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+	};
+
+	windowCreator = new XPCOMObject (new int[] {2, 0, 0, 3}) {
+		public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+		public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+		public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+		public int /*long*/ method3 (int /*long*/[] args) {return CreateChromeWindow (args[0], (int)/*64*/args[1], args[2]);}
+	};
+
+	windowCreator2 = new XPCOMObject (new int[] {2, 0, 0, 3, 6}) {
+		public int /*long*/ method0 (int /*long*/[] args) {return QueryInterface (args[0], args[1]);}
+		public int /*long*/ method1 (int /*long*/[] args) {return AddRef ();}
+		public int /*long*/ method2 (int /*long*/[] args) {return Release ();}
+		public int /*long*/ method3 (int /*long*/[] args) {return CreateChromeWindow (args[0], (int)/*64*/args[1], args[2]);}
+		public int /*long*/ method4 (int /*long*/[] args) {return CreateChromeWindow2 (args[0], (int)/*64*/args[1], (int)/*64*/args[2], args[3], args[4], args[5]);}
+	};
+}
+
+void disposeCOMInterfaces () {
+	if (supports != null) {
+		supports.dispose ();
+		supports = null;
+	}	
+	if (windowCreator != null) {
+		windowCreator.dispose ();
+		windowCreator = null;	
+	}
+
+	if (windowCreator2 != null) {
+		windowCreator2.dispose ();
+		windowCreator2 = null;	
+	}
+}
+
+int /*long*/ getAddress () {
+	return windowCreator.getAddress ();
+}
+
+int QueryInterface (int /*long*/ riid, int /*long*/ ppvObject) {
+	if (riid == 0 || ppvObject == 0) return XPCOM.NS_ERROR_NO_INTERFACE;
+	nsID guid = new nsID ();
+	XPCOM.memmove (guid, riid, nsID.sizeof);
+	
+	if (guid.Equals (nsISupports.NS_ISUPPORTS_IID)) {
+		XPCOM.memmove (ppvObject, new int /*long*/[] {supports.getAddress ()}, C.PTR_SIZEOF);
+		AddRef ();
+		return XPCOM.NS_OK;
+	}
+	if (guid.Equals (nsIWindowCreator.NS_IWINDOWCREATOR_IID)) {
+		XPCOM.memmove (ppvObject, new int /*long*/[] {windowCreator.getAddress ()}, C.PTR_SIZEOF);
+		AddRef ();
+		return XPCOM.NS_OK;
+	}
+	if (guid.Equals (nsIWindowCreator2.NS_IWINDOWCREATOR2_IID)) {
+		XPCOM.memmove (ppvObject, new int /*long*/[] {windowCreator2.getAddress ()}, C.PTR_SIZEOF);
+		AddRef ();
+		return XPCOM.NS_OK;
+	}
+
+	XPCOM.memmove (ppvObject, new int /*long*/[] {0}, C.PTR_SIZEOF);
+	return XPCOM.NS_ERROR_NO_INTERFACE;
+}
+        	
+int Release () {
+	refCount--;
+	if (refCount == 0) disposeCOMInterfaces ();
+	return refCount;
+}
+	
+/* nsIWindowCreator */
+
+int CreateChromeWindow (int /*long*/ parent, int chromeFlags, int /*long*/ _retval) {
+	return CreateChromeWindow2 (parent, chromeFlags, 0, 0, 0, _retval);
+}
+
+/* nsIWindowCreator2 */
+
+int CreateChromeWindow2 (int /*long*/ parent, int chromeFlags, int contextFlags, int /*long*/ uri, int /*long*/ cancel, int /*long*/ _retval) {
+	if (parent == 0 && (chromeFlags & nsIWebBrowserChrome.CHROME_OPENAS_CHROME) == 0) {
+		return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+	}
+	Browser src = null; 
+	if (parent != 0) {
+		nsIWebBrowserChrome browserChromeParent = new nsIWebBrowserChrome (parent);
+		int /*long*/[] aWebBrowser = new int /*long*/[1];
+		int rc = browserChromeParent.GetWebBrowser (aWebBrowser);
+		if (rc != XPCOM.NS_OK) Mozilla.error (rc);
+		if (aWebBrowser[0] == 0) Mozilla.error (XPCOM.NS_ERROR_NO_INTERFACE);
+
+		nsIWebBrowser webBrowser = new nsIWebBrowser (aWebBrowser[0]);
+		int /*long*/[] result = new int /*long*/[1];
+		rc = webBrowser.QueryInterface (nsIBaseWindow.NS_IBASEWINDOW_IID, result);
+		if (rc != XPCOM.NS_OK) Mozilla.error (rc);
+		if (result[0] == 0) Mozilla.error (XPCOM.NS_ERROR_NO_INTERFACE);
+		webBrowser.Release ();
+
+		nsIBaseWindow baseWindow = new nsIBaseWindow (result[0]);
+		result[0] = 0;
+		int /*long*/[] aParentNativeWindow = new int /*long*/[1];
+		rc = baseWindow.GetParentNativeWindow (aParentNativeWindow);
+		if (rc != XPCOM.NS_OK) Mozilla.error (rc);
+		if (aParentNativeWindow[0] == 0) Mozilla.error (XPCOM.NS_ERROR_NO_INTERFACE);
+		baseWindow.Release ();
+
+		src = Mozilla.findBrowser (aParentNativeWindow[0]);
+	}
+	final Browser browser;
+	boolean doit = true;
+	if ((chromeFlags & nsIWebBrowserChrome.CHROME_OPENAS_CHROME) != 0) {
+		/*
+		* Mozilla will request a new Browser in a modal window in order to emulate a native
+		* dialog that is not available to it (eg.- a print dialog on Linux).  For this
+		* reason modal requests are handled here so that the user is not exposed to them.
+		*/
+		int style = SWT.DIALOG_TRIM;
+		if ((chromeFlags & nsIWebBrowserChrome.CHROME_MODAL) != 0) style |= SWT.APPLICATION_MODAL; 
+		final Shell shell = src == null ?
+			new Shell (style) :
+			new Shell (src.getShell(), style);
+		shell.setLayout (new FillLayout ());
+		browser = new Browser (shell, src == null ? SWT.MOZILLA : src.getStyle () & SWT.MOZILLA);
+		browser.addVisibilityWindowListener (new VisibilityWindowListener () {
+			public void hide (WindowEvent event) {
+			}
+			public void show (WindowEvent event) {
+				if (event.location != null) shell.setLocation (event.location);
+				if (event.size != null) {
+					Point size = event.size;
+					shell.setSize (shell.computeSize (size.x, size.y));
+				}
+				shell.open ();
+			}
+		});
+		browser.addCloseWindowListener (new CloseWindowListener () {
+			public void close (WindowEvent event) {
+				shell.close ();
+			}
+		});
+		if (uri != 0) {
+			nsIURI location = new nsIURI (uri);
+			int /*long*/ aSpec = XPCOM.nsEmbedCString_new ();
+			if (location.GetSpec (aSpec) == XPCOM.NS_OK) {
+				int length = XPCOM.nsEmbedCString_Length (aSpec);
+				if (length > 0) {
+					int /*long*/ buffer = XPCOM.nsEmbedCString_get (aSpec);
+					byte[] dest = new byte[length];
+					XPCOM.memmove (dest, buffer, length);
+					browser.setUrl (new String (dest));
+				}
+			}
+			XPCOM.nsEmbedCString_delete (aSpec);
+		}
+	} else {
+		WindowEvent event = new WindowEvent (src);
+		event.display = src.getDisplay ();
+		event.widget = src;
+		event.required = true;
+		for (int i = 0; i < src.webBrowser.openWindowListeners.length; i++) {
+			src.webBrowser.openWindowListeners[i].open (event);
+		}
+		browser = event.browser;
+
+		/* Ensure that the Browser provided by the client is valid for use */ 
+		doit = browser != null && !browser.isDisposed ();
+		if (doit) {
+			String platform = Platform.PLATFORM;
+			boolean isMozillaNativePlatform = platform.equals ("gtk") || platform.equals ("motif"); //$NON-NLS-1$ //$NON-NLS-2$
+			doit = isMozillaNativePlatform || (browser.getStyle () & SWT.MOZILLA) != 0;
+		}
+	}
+	if (doit) {
+		Mozilla mozilla = (Mozilla)browser.webBrowser;
+		mozilla.isChild = true;
+		int /*long*/ chromePtr = mozilla.webBrowserChrome.getAddress ();
+		nsIWebBrowserChrome webBrowserChrome = new nsIWebBrowserChrome (chromePtr);
+		webBrowserChrome.SetChromeFlags (chromeFlags);
+		webBrowserChrome.AddRef ();
+		XPCOM.memmove (_retval, new int /*long*/[] {chromePtr}, C.PTR_SIZEOF);
+	} else {
+		if (cancel != 0) {
+			C.memmove (cancel, new int[] {1}, 4);	/* PRBool */
+		}
+	}
+	return doit ? XPCOM.NS_OK : XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/browser/WindowEvent.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/browser/WindowEvent.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/browser/WindowEvent.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,211 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.browser;
+
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
+
+/**
+ * A <code>WindowEvent</code> is sent by a {@link Browser} when
+ * a new window needs to be created or when an existing window needs to be
+ * closed. This notification occurs when a javascript command such as
+ * <code>window.open</code> or <code>window.close</code> gets executed by
+ * a <code>Browser</code>.
+ *
+ * <p>
+ * The following example shows how <code>WindowEvent</code>'s are typically
+ * handled.
+ * 
+ * <code><pre>
+ *	public static void main(String[] args) {
+ *		Display display = new Display();
+ *		Shell shell = new Shell(display);
+ *		shell.setText("Main Window");
+ *		shell.setLayout(new FillLayout());
+ *		Browser browser = new Browser(shell, SWT.NONE);
+ *		initialize(display, browser);
+ *		shell.open();
+ *		browser.setUrl("http://www.eclipse.org");
+ *		while (!shell.isDisposed()) {
+ *			if (!display.readAndDispatch())
+ *				display.sleep();
+ *		}
+ *		display.dispose();
+ *	}
+ *
+ *	static void initialize(final Display display, Browser browser) {
+ *		browser.addOpenWindowListener(new OpenWindowListener() {
+ *			public void open(WindowEvent event) {
+ *				// Certain platforms can provide a default full browser.
+ *				// simply return in that case if the application prefers
+ *				// the default full browser to the embedded one set below.
+ *				if (!event.required) return;
+ *
+ *				// Embed the new window
+ *				Shell shell = new Shell(display);
+ *				shell.setText("New Window");
+ *				shell.setLayout(new FillLayout());
+ *				Browser browser = new Browser(shell, SWT.NONE);
+ *				initialize(display, browser);
+ *				event.browser = browser;
+ *			}
+ *		});
+ *		browser.addVisibilityWindowListener(new VisibilityWindowListener() {
+ *			public void hide(WindowEvent event) {
+ *				Browser browser = (Browser)event.widget;
+ *				Shell shell = browser.getShell();
+ *				shell.setVisible(false);
+ *			}
+ *			public void show(WindowEvent event) {
+ *				Browser browser = (Browser)event.widget;
+ *				Shell shell = browser.getShell();
+ *				if (event.location != null) shell.setLocation(event.location);
+ *				if (event.size != null) {
+ *					Point size = event.size;
+ *					shell.setSize(shell.computeSize(size.x, size.y));
+ *				}
+ *				if (event.addressBar || event.menuBar || event.statusBar || event.toolBar) {
+ *					// Create widgets for the address bar, menu bar, status bar and/or tool bar
+ *					// leave enough space in the Shell to accommodate a Browser of the size
+ *					// given by event.size
+ *				}
+ *				shell.open();
+ *			}
+ *		});
+ *		browser.addCloseWindowListener(new CloseWindowListener() {
+ *			public void close(WindowEvent event) {
+ *				Browser browser = (Browser)event.widget;
+ *				Shell shell = browser.getShell();
+ *				shell.close();
+ *			}
+ *		});
+ *	}
+ * </pre></code>
+ * 
+ * The following notifications are emitted when the user selects a hyperlink that targets a new window
+ * or as the result of a javascript that executes window.open. 
+ * 
+ * <p>Main Browser
+ * <ul>
+ *    <li>User selects a link that opens in a new window or javascript requests a new window</li>
+ *    <li>OpenWindowListener.open() notified</li>
+ *    <ul>
+ *    		<li>Application creates a new Shell and a second Browser inside that Shell</li>
+ *    		<li>Application registers WindowListener's on that second Browser, such as VisibilityWindowListener</li>
+ *	    	<li>Application returns the second Browser as the host for the new window content</li>
+ *    </ul>
+ * </ul>
+ * 
+ * <p>Second Browser
+ * <ul>
+ *    <li>VisibilityWindowListener.show() notified</li>
+ *    <ul>
+ *    		<li>Application sets navigation tool bar, status bar, menu bar and Shell size
+ *    		<li>Application makes the Shell hosting the second Browser visible
+ *    		<li>User now sees the new window
+ *    </ul> 
+ * </ul>
+ * 
+ * @see CloseWindowListener
+ * @see OpenWindowListener
+ * @see VisibilityWindowListener
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ * 
+ * @since 3.0
+ */
+public class WindowEvent extends TypedEvent {
+
+	/** 
+	 * Specifies whether the platform requires the user to provide a
+	 * <code>Browser</code> to handle the new window.
+	 * 
+	 * @since 3.1
+	 */
+	public boolean required;
+	
+	
+	/** 
+	 * <code>Browser</code> provided by the application.
+	 */
+	public Browser browser;
+
+	/** 
+	 * Requested location for the <code>Shell</code> hosting the <code>Browser</code>.
+	 * It is <code>null</code> if no location has been requested.
+	 */
+	public Point location;
+
+	/** 
+	 * Requested <code>Browser</code> size. The client area of the <code>Shell</code> 
+	 * hosting the <code>Browser</code> should be large enough to accommodate that size. 
+	 * It is <code>null</code> if no size has been requested.
+	 */
+	public Point size;
+	
+	/**
+	 * Specifies whether the <code>Shell</code> hosting the <code>Browser</code> should
+	 * display an address bar.
+	 * 
+	 * @since 3.1
+	 */
+	public boolean addressBar;
+
+	/**
+	 * Specifies whether the <code>Shell</code> hosting the <code>Browser</code> should
+	 * display a menu bar.
+	 * 
+	 * @since 3.1
+	 */
+	public boolean menuBar;
+	
+	/**
+	 * Specifies whether the <code>Shell</code> hosting the <code>Browser</code> should
+	 * display a status bar.
+	 * 
+	 * @since 3.1
+	 */
+	public boolean statusBar;
+	
+	/**
+	 * Specifies whether the <code>Shell</code> hosting the <code>Browser</code> should
+	 * display a tool bar.
+	 * 
+	 * @since 3.1
+	 */
+	public boolean toolBar;
+	
+	static final long serialVersionUID = 3617851997387174969L;
+	
+WindowEvent(Widget w) {
+	super(w);
+}
+
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the event
+ */
+public String toString() {
+	String string = super.toString ();
+	return string.substring (0, string.length() - 1) // remove trailing '}'
+		+ " required=" + required
+		+ " browser=" + browser
+		+ " location=" + location
+		+ " size=" + size
+		+ " addressBar=" + addressBar
+		+ " menuBar=" + menuBar
+		+ " statusBar=" + statusBar
+		+ " toolBar=" + toolBar
+		+ "}";
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/custom/AnimatedProgress.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/custom/AnimatedProgress.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/custom/AnimatedProgress.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,221 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.custom;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*; 
+import org.eclipse.swt.events.*;
+
+/**
+ * A control for showing progress feedback for a long running operation.
+ *
+ * @deprecated As of Eclipse 2.1, use ProgressBar with the style SWT.INDETERMINATE
+ * 
+ * <dl>
+ * <dt><b>Styles:</b><dd>VERTICAL, HORIZONTAL, BORDER
+ * </dl>
+ *
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public class AnimatedProgress extends Canvas {
+
+	static final int SLEEP = 70;
+	static final int DEFAULT_WIDTH = 160;
+	static final int DEFAULT_HEIGHT = 18;
+	boolean active = false;
+	boolean showStripes = false;
+	int value;
+	int orientation = SWT.HORIZONTAL;
+	boolean showBorder = false;
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a widget which will be the parent of the new instance (cannot be null)
+ * @param style the style of widget to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * </ul>
+ *
+ * @see SWT#VERTICAL
+ * @see SWT#HORIZONTAL
+ * @see SWT#BORDER
+ * @see #getStyle()
+ */
+public AnimatedProgress(Composite parent, int style) {
+	super(parent, checkStyle(style));
+	
+	if ((style & SWT.VERTICAL) != 0) {
+		orientation = SWT.VERTICAL;
+	}
+	showBorder = (style & SWT.BORDER) != 0;
+	
+	addControlListener(new ControlAdapter() {
+		public void controlResized(ControlEvent e) {
+			redraw();
+		}
+	});	
+	addPaintListener(new PaintListener() {
+		public void paintControl(PaintEvent e) {
+			paint(e);
+		}
+	});
+	addDisposeListener(new DisposeListener() {
+		public void widgetDisposed(DisposeEvent e){
+			stop();
+		}
+	});
+}
+private static int checkStyle (int style) {
+	int mask = SWT.NONE;
+	return style & mask;
+}
+/**
+ * Stop the animation if it is not already stopped and 
+ * reset the presentation to a blank appearance.
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public synchronized void clear(){
+	checkWidget();
+	if (active) stop();
+	showStripes = false;
+	redraw();
+}
+public Point computeSize(int wHint, int hHint, boolean changed) {
+	checkWidget();
+	Point size = null;
+	if (orientation == SWT.HORIZONTAL) {
+		size = new Point(DEFAULT_WIDTH, DEFAULT_HEIGHT);
+	} else {
+		size = new Point(DEFAULT_HEIGHT, DEFAULT_WIDTH);
+	}
+	if (wHint != SWT.DEFAULT) size.x = wHint;
+	if (hHint != SWT.DEFAULT) size.y = hHint;
+	
+	return size;
+}
+private void drawBevelRect(GC gc, int x, int y, int w, int h, Color topleft, Color bottomright) {
+	gc.setForeground(topleft);
+	gc.drawLine(x, y, x+w-1, y);
+	gc.drawLine(x, y, x, y+h-1);
+		
+	gc.setForeground(bottomright);
+	gc.drawLine(x+w, y, x+w, y+h);
+	gc.drawLine(x, y+h, x+w, y+h);
+}
+void paint(PaintEvent event) {
+	GC gc = event.gc;
+	Display disp= getDisplay();
+			
+	Rectangle rect= getClientArea();
+	gc.fillRectangle(rect);
+	if (showBorder) {
+		drawBevelRect(gc, rect.x, rect.y, rect.width-1, rect.height-1,
+			disp.getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW),
+			disp.getSystemColor(SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW));
+	}
+	
+	paintStripes(gc);
+}	
+void paintStripes(GC gc) {
+	
+	if (!showStripes) return;
+	
+	Rectangle rect= getClientArea();
+	// Subtracted border painted by paint.
+	rect = new Rectangle(rect.x+2, rect.y+2, rect.width-4, rect.height-4);
+
+	gc.setLineWidth(2);
+	gc.setClipping(rect);
+	Color color = getDisplay().getSystemColor(SWT.COLOR_LIST_SELECTION);
+	gc.setBackground(color);
+	gc.fillRectangle(rect);
+	gc.setForeground(this.getBackground());
+	int step = 12;
+	int foregroundValue = value == 0 ? step - 2 : value - 2;
+	if (orientation == SWT.HORIZONTAL) {
+		int y = rect.y - 1;
+		int w = rect.width;
+		int h = rect.height + 2;
+		for (int i= 0; i < w; i+= step) {
+			int x = i + foregroundValue;
+			gc.drawLine(x, y, x, h);
+		}
+	} else {
+		int x = rect.x - 1;
+		int w = rect.width + 2;
+		int h = rect.height;
+
+		for (int i= 0; i < h; i+= step) {
+			int y = i + foregroundValue;
+			gc.drawLine(x, y, w, y);
+		}
+	}
+	
+	if (active) {
+		value = (value + 2) % step;
+	}
+}
+/**
+* Start the animation.
+* 
+* @exception SWTException <ul>
+*    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+*    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+* </ul>
+*/
+public synchronized void start() {
+	checkWidget();
+	if (active) return;
+
+	active = true;
+	showStripes = true;
+	
+	final Display display = getDisplay();
+	final Runnable [] timer = new Runnable [1];
+	timer [0] = new Runnable () {
+		public void run () {
+			if (!active) return;
+			GC gc = new GC(AnimatedProgress.this);			
+			paintStripes(gc);
+			gc.dispose();
+			display.timerExec (SLEEP, timer [0]);
+		}
+	};
+	display.timerExec (SLEEP, timer [0]);
+}
+/**
+* Stop the animation.   Freeze the presentation at its current appearance.
+*/
+public synchronized void stop() {
+	//checkWidget();
+	active = false;
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/custom/BidiSegmentEvent.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/custom/BidiSegmentEvent.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/custom/BidiSegmentEvent.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,86 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.custom;
+
+
+import org.eclipse.swt.events.*;
+
+/**
+ * This event is sent to BidiSegmentListeners when a line is to
+ * be measured or rendered in a bidi locale.  The segments field is 
+ * used to specify text ranges in the line that should be treated as 
+ * separate segments for bidi reordering.  Each segment will be reordered 
+ * and rendered separately.
+ * <p>
+ * The elements in the segments field specify the start offset of 
+ * a segment relative to the start of the line. They must follow
+ * the following rules:
+ * <ul>
+ * <li>first element must be 0
+ * <li>elements must be in ascending order and must not have duplicates
+ * <li>elements must not exceed the line length
+ * </ul>
+ * In addition, the last element may be set to the end of the line 
+ * but this is not required.
+ *
+ * The segments field may be left null if the entire line should 
+ * be reordered as is.
+ * </p>
+ * A BidiSegmentListener may be used when adjacent segments of 
+ * right-to-left text should not be reordered relative to each other. 
+ * For example, within a Java editor, you may wish multiple 
+ * right-to-left string literals to be reordered differently than the
+ * bidi algorithm specifies.  
+ *
+ * Example:
+ * <pre>
+ * 	stored line = "R1R2R3" + "R4R5R6"
+ *		R1 to R6 are right-to-left characters. The quotation marks
+ * 		are part of the line text. The line is 13 characters long.
+ * 
+ * 	segments = null: 
+ * 		entire line will be reordered and thus the two R2L segments 
+ * 		swapped (as per the bidi algorithm). 
+ *		visual line (rendered on screen) = "R6R5R4" + "R3R2R1"
+ * 
+ * 	segments = [0, 5, 8]	
+ * 		"R1R2R3" will be reordered, followed by [blank]+[blank] and 
+ * 		"R4R5R6". 
+ *		visual line = "R3R2R1" + "R6R5R4"
+ * </pre>
+ *
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public class BidiSegmentEvent extends TypedEvent {
+	
+	/** 
+	 * line start offset 
+	 */
+	public int lineOffset;
+	
+	/** 
+	 * line text 
+	 */			
+	public String lineText;
+	
+	/** 
+	 * bidi segments, see above 
+	 */
+	public int[] segments;
+		
+	static final long serialVersionUID = 3257846571587547957L;
+
+BidiSegmentEvent(StyledTextEvent e) {
+	super(e);
+	lineOffset = e.detail;
+	lineText = e.text;
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/custom/BidiSegmentListener.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/custom/BidiSegmentListener.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/custom/BidiSegmentListener.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.custom;
+
+import org.eclipse.swt.internal.SWTEventListener;
+
+/**
+ * This listener interface may be implemented in order to receive
+ * BidiSegmentEvents.
+ * @see BidiSegmentEvent
+ */ 
+public interface BidiSegmentListener extends SWTEventListener {
+
+/**
+ * This method is called when a line needs to be reordered for 
+ * measuring or rendering in a bidi locale. 
+ * <p>
+ * The following event fields are used:<ul>
+ * <li>event.lineOffset line start offset (input)</li>
+ * <li>event.lineText line text (input)</li>
+ * <li>event.segments text segments that should be reordered 
+ *	separately. (output)</li> 
+ * </ul>
+ *
+ * @param event the given event
+ *	separately. (output)
+ * @see BidiSegmentEvent
+ */
+public void lineGetSegments(BidiSegmentEvent event);
+
+}
+

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/custom/Bullet.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/custom/Bullet.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/custom/Bullet.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,156 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.custom;
+
+import org.eclipse.swt.*;
+
+/**
+ * Instances of this class represent bullets in the <code>StyledText</code>.
+ * <p>
+ * The hashCode() method in this class uses the values of the public
+ * fields to compute the hash value. When storing instances of the
+ * class in hashed collections, do not modify these fields after the
+ * object has been inserted.  
+ * </p>
+ * <p>
+ * Application code does <em>not</em> need to explicitly release the
+ * resources managed by each instance when those instances are no longer
+ * required, and thus no <code>dispose()</code> method is provided.
+ * </p>
+ * 
+ * @see StyledText#setLineBullet(int, int, Bullet)
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ * 
+ * @since 3.2
+ */
+public class Bullet {
+	/**
+	* The bullet type.  Possible values are:
+	* <ul>
+	* <li><code>ST.BULLET_DOT</code></li>
+	* <li><code>ST.BULLET_NUMBER</code></li>
+	* <li><code>ST.BULLET_LETTER_LOWER</code></li>
+	* <li><code>ST.BULLET_LETTER_UPPER</code></li>
+	* <li><code>ST.BULLET_TEXT</code></li>
+	* <li><code>ST.BULLET_CUSTOM</code></li>
+	* </ul>
+	*/
+	public int type;
+
+	/**
+	* The bullet style.
+	*/
+	public StyleRange style;
+
+	/**
+	* The bullet text.
+	*/
+	public String text;
+
+	int[] linesIndices;
+	int count;
+
+/** 
+ * Create a new bullet with the specified style, and type <code>ST.BULLET_DOT</code>. 
+ * The style must have a glyph metrics set.
+ *
+ * @param style the style 
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT when the style or the glyph metrics are null</li>
+ * </ul> 
+ */
+public Bullet(StyleRange style) {
+	this(ST.BULLET_DOT, style);
+}
+/** 
+ * Create a new bullet the specified style and type. 
+ * The style must have a glyph metrics set.
+ *
+ * @param type the bullet type
+ * @param style the style 
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT when the style or the glyph metrics are null</li>
+ * </ul> 
+ */
+public Bullet(int type, StyleRange style) {
+	if (style == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	if (style.metrics == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	this.type = type;
+	this.style = style;
+}	
+void addIndices (int startLine, int lineCount) {
+	if (linesIndices == null) {
+		linesIndices = new int[lineCount];
+		count = lineCount;
+		for (int i = 0; i < lineCount; i++) linesIndices[i] = startLine + i;
+	} else {
+		int modifyStart = 0;
+		while (modifyStart < count) {
+			if (startLine <= linesIndices[modifyStart]) break;
+			modifyStart++;
+		}
+		int modifyEnd = modifyStart;
+		while (modifyEnd < count) {
+			if (startLine + lineCount <= linesIndices[modifyEnd]) break;
+			modifyEnd++;
+		}
+		int newSize = modifyStart + lineCount + count - modifyEnd;
+		if (newSize > linesIndices.length) {
+			int[] newLinesIndices = new int[newSize];
+			System.arraycopy(linesIndices, 0, newLinesIndices, 0, count);
+			linesIndices = newLinesIndices;
+		}
+		System.arraycopy(linesIndices, modifyEnd, linesIndices, modifyStart + lineCount, count - modifyEnd);
+		for (int i = 0; i < lineCount; i++) linesIndices[modifyStart + i] = startLine + i;
+		count = newSize;
+	}
+}
+int indexOf (int lineIndex) {
+	for (int i = 0; i < count; i++) {
+		if (linesIndices[i] == lineIndex) return i;
+	}
+	return -1;
+}
+public int hashCode() {
+	return style.hashCode() ^ type;
+}
+int[] removeIndices (int startLine, int replaceLineCount, int newLineCount, boolean update) {
+	if (count == 0) return null;
+	if (startLine > linesIndices[count - 1]) return null;
+	int endLine = startLine + replaceLineCount;
+	int delta = newLineCount - replaceLineCount;
+	for (int i = 0; i < count; i++) {
+		int index = linesIndices[i];
+		if (startLine <= index) {
+			int j = i;
+			while (j < count) {
+				if (linesIndices[j] >= endLine) break;
+				j++;
+			}
+			if (update) {
+				for (int k = j; k < count; k++) linesIndices[k] += delta;
+			}
+			int[] redrawLines = new int[count - j];
+			System.arraycopy(linesIndices, j, redrawLines, 0, count - j);
+			System.arraycopy(linesIndices, j, linesIndices, i, count - j);
+			count -= (j - i);
+			return redrawLines;
+		}
+	}
+	for (int i = 0; i < count; i++) linesIndices[i] += delta;
+	return null;
+}
+int size() {
+	return count;
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/custom/BusyIndicator.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/custom/BusyIndicator.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/custom/BusyIndicator.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,82 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.custom;
+
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+
+/**
+ * Support for showing a Busy Cursor during a long running process.
+ *
+ * @see <a href="http://www.eclipse.org/swt/snippets/#busyindicator">BusyIndicator snippets</a>
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public class BusyIndicator {
+
+	static int nextBusyId = 1;
+	static final String BUSYID_NAME = "SWT BusyIndicator"; //$NON-NLS-1$
+	static final String BUSY_CURSOR = "SWT BusyIndicator Cursor"; //$NON-NLS-1$
+
+/**
+ * Runs the given <code>Runnable</code> while providing
+ * busy feedback using this busy indicator.
+ * 
+ * @param display the display on which the busy feedback should be
+ *        displayed.  If the display is null, the Display for the current
+ *        thread will be used.  If there is no Display for the current thread,
+ *        the runnable code will be executed and no busy feedback will be displayed.
+ * @param runnable the runnable for which busy feedback is to be shown.
+ *        Must not be null.
+ * 
+* @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the runnable is null</li>
+ * </ul>
+ */
+
+public static void showWhile(Display display, Runnable runnable) {
+	if (runnable == null)
+		SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	if (display == null) {
+		display = Display.getCurrent();
+		if (display == null) {
+			runnable.run();
+			return;
+		}
+	}
+	
+	Integer busyId = new Integer(nextBusyId);
+	nextBusyId++;
+	Cursor cursor = display.getSystemCursor(SWT.CURSOR_WAIT);
+	Shell[] shells = display.getShells();
+	for (int i = 0; i < shells.length; i++) {
+		Integer id = (Integer)shells[i].getData(BUSYID_NAME);
+		if (id == null) {
+			shells[i].setCursor(cursor);
+			shells[i].setData(BUSYID_NAME, busyId);
+		}
+	}
+		
+	try {
+		runnable.run();
+	} finally {
+		shells = display.getShells();
+		for (int i = 0; i < shells.length; i++) {
+			Integer id = (Integer)shells[i].getData(BUSYID_NAME);
+			if (id == busyId) {
+				shells[i].setCursor(null);
+				shells[i].setData(BUSYID_NAME, null);
+			}
+		}
+	}
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/custom/CBanner.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/custom/CBanner.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/custom/CBanner.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,541 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.custom;
+
+
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.*;
+
+/**
+ * Instances of this class implement a Composite that lays out its
+ * children and allows programmatic control of the layout. It draws
+ * a separator between the left and right children which can be dragged
+ * to resize the right control.
+ * CBanner is used in the workbench to layout the toolbar area and
+ * perspective switching toolbar.
+ * <p>
+ * Note that although this class is a subclass of <code>Composite</code>,
+ * it does not make sense to set a layout on it.
+ * </p><p>
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>NONE</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>(None)</dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ * 
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ *
+ * @since 3.0
+ */
+
+public class CBanner extends Composite {	
+
+	Control left;
+	Control right;
+	Control bottom;
+	
+	boolean simple = true;
+	
+	int[] curve = new int[0];
+	int curveStart = 0;
+	Rectangle curveRect = new Rectangle(0, 0, 0, 0);
+	int curve_width = 5;
+	int curve_indent = -2;
+	
+	int rightWidth = SWT.DEFAULT;
+	int rightMinWidth = 0;
+	int rightMinHeight = 0;
+	Cursor resizeCursor;
+	boolean dragging = false;
+	int rightDragDisplacement = 0;
+	
+	static final int OFFSCREEN = -200;
+	static final int BORDER_BOTTOM = 2;
+	static final int BORDER_TOP = 3;
+	static final int BORDER_STRIPE = 1;
+	static final int CURVE_TAIL = 200;
+	static final int BEZIER_RIGHT = 30;
+	static final int BEZIER_LEFT = 30;
+	static final int MIN_LEFT = 10;
+	static int BORDER1 = SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW;
+	
+		
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a widget which will be the parent of the new instance (cannot be null)
+ * @param style the style of widget to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * </ul>
+ *
+ */
+public CBanner(Composite parent, int style) {
+	super(parent, checkStyle(style));
+	super.setLayout(new CBannerLayout());
+	resizeCursor = new Cursor(getDisplay(), SWT.CURSOR_SIZEWE);
+	
+	Listener listener = new Listener() {
+		public void handleEvent(Event e) {
+			switch (e.type) {
+				case SWT.Dispose:
+					onDispose(); break;
+				case SWT.MouseDown:
+					onMouseDown (e.x, e.y); break;
+				case SWT.MouseExit:
+					onMouseExit(); break;
+				case SWT.MouseMove:
+					onMouseMove(e.x, e.y); break;
+				case SWT.MouseUp:
+					onMouseUp(); break;
+				case SWT.Paint:
+					onPaint(e.gc); break;
+				case SWT.Resize:
+					onResize(); break;
+			}
+		}
+	};
+	int[] events = new int[] {SWT.Dispose, SWT.MouseDown, SWT.MouseExit, SWT.MouseMove, SWT.MouseUp, SWT.Paint, SWT.Resize};
+	for (int i = 0; i < events.length; i++) {
+		addListener(events[i], listener);
+	}
+}
+static int[] bezier(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3, int count) {
+	// The parametric equations for a Bezier curve for x[t] and y[t] where  0 <= t <=1 are:
+	// x[t] = x0+3(x1-x0)t+3(x0+x2-2x1)t^2+(x3-x0+3x1-3x2)t^3
+	// y[t] = y0+3(y1-y0)t+3(y0+y2-2y1)t^2+(y3-y0+3y1-3y2)t^3
+	double a0 = x0;
+	double a1 = 3*(x1 - x0);
+	double a2 = 3*(x0 + x2 - 2*x1);
+	double a3 = x3 - x0 + 3*x1 - 3*x2;
+	double b0 = y0;
+	double b1 = 3*(y1 - y0);
+	double b2 = 3*(y0 + y2 - 2*y1);
+	double b3 = y3 - y0 + 3*y1 - 3*y2;
+
+	int[] polygon = new int[2*count + 2];
+	for (int i = 0; i <= count; i++) {
+		double t = (double)i / (double)count;
+		polygon[2*i] = (int)(a0 + a1*t + a2*t*t + a3*t*t*t);
+		polygon[2*i + 1] = (int)(b0 + b1*t + b2*t*t + b3*t*t*t);
+	}
+	return polygon;
+}
+static int checkStyle (int style) {
+	return SWT.NONE;
+}
+/**
+* Returns the Control that appears on the bottom side of the banner.
+* 
+* @return the control that appears on the bottom side of the banner or null
+* 
+* @exception SWTException <ul>
+*    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+*    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+* </ul>
+* 
+* @since 3.0
+*/
+public Control getBottom() {
+	checkWidget();
+	return bottom;
+}
+public Rectangle getClientArea() {
+	return new Rectangle(0, 0, 0, 0);
+}
+
+/**
+* Returns the Control that appears on the left side of the banner.
+* 
+* @return the control that appears on the left side of the banner or null
+* 
+* @exception SWTException <ul>
+*    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+*    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+* </ul>
+* 
+* @since 3.0
+*/
+public Control getLeft() {
+	checkWidget();
+	return left;
+}
+
+/**
+* Returns the Control that appears on the right side of the banner.
+* 
+* @return the control that appears on the right side of the banner or null
+* 
+* @exception SWTException <ul>
+*    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+*    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+* </ul>
+* 
+* @since 3.0
+*/
+public Control getRight() {
+	checkWidget();
+	return right;
+}
+/**
+ * Returns the minimum size of the control that appears on the right of the banner.
+ * 
+ * @return the minimum size of the control that appears on the right of the banner
+ * 
+ * @since 3.1
+ */
+public Point getRightMinimumSize() {
+	checkWidget();
+	return new Point(rightMinWidth, rightMinHeight);
+}
+/**
+ * Returns the width of the control that appears on the right of the banner.
+ * 
+ * @return the width of the control that appears on the right of the banner
+ * 
+ * @since 3.0
+ */
+public int getRightWidth() {
+	checkWidget();
+	if (right == null) return 0;
+	if (rightWidth == SWT.DEFAULT) {
+		Point size = right.computeSize(SWT.DEFAULT, SWT.DEFAULT, false);
+		return size.x;
+	}
+	return rightWidth;
+}
+/**
+ * Returns <code>true</code> if the CBanner is rendered
+ * with a simple, traditional shape.
+ * 
+ * @return <code>true</code> if the CBanner is rendered with a simple shape
+ * 
+ * @since 3.0
+ */
+public boolean getSimple() {
+	checkWidget();
+	return simple;
+}
+void onDispose() {
+	if (resizeCursor != null) resizeCursor.dispose();
+	resizeCursor = null;
+	left = null;
+	right = null;
+	bottom = null;
+}
+void onMouseDown (int x, int y) {
+	if (curveRect.contains(x, y)) {
+		dragging = true;
+		rightDragDisplacement = curveStart - x + curve_width - curve_indent;
+	}
+}
+void onMouseExit() {
+	if (!dragging) setCursor(null);
+}
+void onMouseMove(int x, int y) {
+	if (dragging) {
+		Point size = getSize();
+		if (!(0 < x && x < size.x)) return;
+		rightWidth = Math.max(0, size.x - x - rightDragDisplacement);
+		if (rightMinWidth == SWT.DEFAULT) {
+			Point minSize = right.computeSize(rightMinWidth, rightMinHeight);
+			rightWidth = Math.max(minSize.x, rightWidth);
+		} else {
+			rightWidth = Math.max(rightMinWidth, rightWidth);
+		}
+		layout(false);
+		return;
+	}
+	if (curveRect.contains(x, y)) {
+		setCursor(resizeCursor); 
+	} else {
+		setCursor(null);
+	}
+}
+void onMouseUp () {
+	dragging = false;
+}
+void onPaint(GC gc) {
+//	 Useful for debugging paint problems
+//	{
+//	Point size = getSize();	
+//	gc.setBackground(getDisplay().getSystemColor(SWT.COLOR_GREEN));
+//	gc.fillRectangle(-10, -10, size.x+20, size.y+20);
+//	}
+	if (left == null && right == null) return;
+	Point size = getSize();
+	Color border1 = getDisplay().getSystemColor(BORDER1);
+	if (bottom != null) {
+		int y = bottom.getBounds().y - BORDER_STRIPE - 1;
+		gc.setForeground(border1);
+		gc.drawLine(0, y, size.x, y);
+	}
+	if (left == null || right == null) return;
+	int[] line1 = new int[curve.length+6];
+	int index = 0;
+	int x = curveStart;
+	line1[index++] = x + 1;
+	line1[index++] = size.y - BORDER_STRIPE;
+	for (int i = 0; i < curve.length/2; i++) {
+		line1[index++]=x+curve[2*i];
+		line1[index++]=curve[2*i+1];
+	}
+	line1[index++] = x + curve_width;
+	line1[index++] = 0;
+	line1[index++] = size.x;
+	line1[index++] = 0;
+	
+	Color background = getBackground();
+		
+	if (getDisplay().getDepth() >= 15) {
+		// Anti- aliasing
+		int[] line2 = new int[line1.length];
+		index = 0;
+		for (int i = 0; i < line1.length/2; i++) { 
+			line2[index] = line1[index++]  - 1;
+			line2[index] = line1[index++];
+		}
+		int[] line3 = new int[line1.length];
+		index = 0;
+		for (int i = 0; i < line1.length/2; i++) {
+			line3[index] = line1[index++] + 1;
+			line3[index] = line1[index++];
+		}
+		RGB from = border1.getRGB();
+		RGB to = background.getRGB();
+		int red = from.red + 3*(to.red - from.red)/4;
+		int green = from.green + 3*(to.green - from.green)/4;
+		int blue = from.blue + 3*(to.blue - from.blue)/4;
+		Color color = new Color(getDisplay(), red, green, blue);
+		gc.setForeground(color);
+		gc.drawPolyline(line2);
+		gc.drawPolyline(line3);
+		color.dispose();
+		
+		// draw tail fading to background
+		int x1 = Math.max(0, curveStart - CURVE_TAIL);
+		gc.setForeground(background);
+		gc.setBackground(border1);
+		gc.fillGradientRectangle(x1, size.y - BORDER_STRIPE, curveStart-x1+1, 1, false);
+	} else {
+		// draw solid tail
+		int x1 = Math.max(0, curveStart - CURVE_TAIL);
+		gc.setForeground(border1);
+		gc.drawLine(x1, size.y - BORDER_STRIPE, curveStart+1, size.y - BORDER_STRIPE);
+	}
+	
+	// draw border
+	gc.setForeground(border1);
+	gc.drawPolyline(line1);
+}
+
+void onResize() {
+	updateCurve(getSize().y);
+}
+/**
+* Set the control that appears on the bottom side of the banner.
+* The bottom control is optional.  Setting the bottom control to null will remove it from 
+* the banner - however, the creator of the control must dispose of the control.
+* 
+* @param control the control to be displayed on the bottom or null
+* 
+* @exception SWTException <ul>
+*    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+*    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+*    <li>ERROR_INVALID_ARGUMENT - if the bottom control was not created as a child of the receiver</li>
+* </ul>
+* 
+* @since 3.0
+*/
+public void setBottom(Control control) {
+	checkWidget();
+	if (control != null && control.getParent() != this) {
+		SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	}
+	if (bottom != null && !bottom.isDisposed()) {
+		Point size = bottom.getSize();
+		bottom.setLocation(OFFSCREEN - size.x, OFFSCREEN - size.y);
+	}
+	bottom = control;
+	layout(false);
+}
+/**
+ * Sets the layout which is associated with the receiver to be
+ * the argument which may be null.
+ * <p>
+ * Note: No Layout can be set on this Control because it already
+ * manages the size and position of its children.
+ * </p>
+ *
+ * @param layout the receiver's new layout or null
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setLayout (Layout layout) {
+	checkWidget();
+	return;
+}
+
+/**
+* Set the control that appears on the left side of the banner.
+* The left control is optional.  Setting the left control to null will remove it from 
+* the banner - however, the creator of the control must dispose of the control.
+* 
+* @param control the control to be displayed on the left or null
+* 
+* @exception SWTException <ul>
+*    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+*    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+*    <li>ERROR_INVALID_ARGUMENT - if the left control was not created as a child of the receiver</li>
+* </ul>
+* 
+* @since 3.0
+*/
+public void setLeft(Control control) {
+	checkWidget();
+	if (control != null && control.getParent() != this) {
+		SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	}
+	if (left != null && !left.isDisposed()) {
+		Point size = left.getSize();
+		left.setLocation(OFFSCREEN - size.x, OFFSCREEN - size.y);
+	}
+	left = control;
+	layout(false);
+}
+/**
+* Set the control that appears on the right side of the banner.
+* The right control is optional.  Setting the right control to null will remove it from 
+* the banner - however, the creator of the control must dispose of the control.
+* 
+* @param control the control to be displayed on the right or null
+* 
+* @exception SWTException <ul>
+*    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+*    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+*    <li>ERROR_INVALID_ARGUMENT - if the right control was not created as a child of the receiver</li>
+* </ul>
+* 
+* @since 3.0
+*/
+public void setRight(Control control) {
+	checkWidget();
+	if (control != null && control.getParent() != this) {
+		SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	}
+	if (right != null && !right.isDisposed()) {
+		Point size = right.getSize();
+		right.setLocation(OFFSCREEN - size.x, OFFSCREEN - size.y);
+	}
+	right = control;
+	layout(false);
+}
+/**
+ * Set the minimum height of the control that appears on the right side of the banner.
+ * 
+ * @param size the minimum size of the control on the right
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the size is null or the values of size are less than SWT.DEFAULT</li>
+ * </ul>
+ * 
+ * @since 3.1
+ */
+public void setRightMinimumSize(Point size) {
+	checkWidget();
+	if (size == null || size.x < SWT.DEFAULT || size.y < SWT.DEFAULT) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	rightMinWidth = size.x;
+	rightMinHeight = size.y;
+	layout(false);
+}
+/**
+ * Set the width of the control that appears on the right side of the banner.
+ * 
+ * @param width the width of the control on the right
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if width is less than SWT.DEFAULT</li>
+ * </ul>
+ * 
+ * @since 3.0
+ */
+public void setRightWidth(int width) {
+	checkWidget();
+	if (width < SWT.DEFAULT) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	rightWidth = width;
+	layout(false);
+}
+/**
+ * Sets the shape that the CBanner will use to render itself.  
+ * 
+ * @param simple <code>true</code> if the CBanner should render itself in a simple, traditional style
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 3.0
+ */
+public void setSimple(boolean simple) {
+	checkWidget();
+	if (this.simple != simple) {
+		this.simple = simple;
+		if (simple) {
+			curve_width = 5;
+			curve_indent = -2;
+		} else {
+			curve_width = 50;
+			curve_indent = 5;
+		}
+		updateCurve(getSize().y);
+		layout(false);
+		redraw();
+	}
+}
+void updateCurve(int height) {
+	int h = height - BORDER_STRIPE;
+	if (simple) {
+		curve = new int[] {0,h, 1,h, 2,h-1, 3,h-2,
+			                       3,2, 4,1, 5,0,};
+	} else {
+		curve = bezier(0, h+1, BEZIER_LEFT, h+1,
+				             curve_width-BEZIER_RIGHT, 0, curve_width, 0,
+		                     curve_width);
+	}
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/custom/CBannerLayout.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/custom/CBannerLayout.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/custom/CBannerLayout.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,188 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.custom;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+
+/**
+ * This class provides the layout for CBanner
+ * 
+ * @see CBanner
+ */
+class CBannerLayout extends Layout {
+
+protected Point computeSize(Composite composite, int wHint, int hHint, boolean flushCache) {
+	CBanner banner = (CBanner)composite;
+	Control left = banner.left;
+	Control right = banner.right;
+	Control bottom = banner.bottom;
+	boolean showCurve = left != null && right != null;
+	int height = hHint;
+	int width = wHint;
+	
+	// Calculate component sizes
+	Point bottomSize = new Point(0, 0);
+	if (bottom != null) {
+		int trim = computeTrim(bottom);
+		int w = wHint == SWT.DEFAULT ? SWT.DEFAULT : Math.max(0, width - trim);
+		bottomSize = computeChildSize(bottom, w, SWT.DEFAULT, flushCache);
+	}
+	Point rightSize = new Point(0, 0);
+	if (right != null) {
+		int trim = computeTrim(right);
+		int w = SWT.DEFAULT;
+		if (banner.rightWidth != SWT.DEFAULT) {
+			w = banner.rightWidth - trim;
+			if (left != null) {
+				w = Math.min(w, width - banner.curve_width + 2* banner.curve_indent - CBanner.MIN_LEFT - trim);
+			}
+			w = Math.max(0, w);
+		}
+		rightSize = computeChildSize(right, w, SWT.DEFAULT, flushCache);
+		if (wHint != SWT.DEFAULT) {
+			width -= rightSize.x + banner.curve_width - 2* banner.curve_indent;
+		}
+	}
+	Point leftSize = new Point(0, 0);
+	if (left != null) {
+		int trim = computeTrim(left);
+		int w = wHint == SWT.DEFAULT ? SWT.DEFAULT : Math.max(0, width - trim);
+		leftSize = computeChildSize(left, w, SWT.DEFAULT, flushCache);
+	}
+	
+	// Add up sizes
+	width = leftSize.x + rightSize.x;
+	height = bottomSize.y;
+	if (bottom != null && (left != null || right != null)) {
+		height += CBanner.BORDER_STRIPE + 2;
+	}
+	if (left != null) {
+		if (right == null) {
+			height += leftSize.y;
+		} else {
+			height += Math.max(leftSize.y, banner.rightMinHeight == SWT.DEFAULT ? rightSize.y : banner.rightMinHeight);
+		}
+	} else {
+		height += rightSize.y;
+	}
+	if (showCurve) {
+		width += banner.curve_width - 2*banner.curve_indent;
+		height +=  CBanner.BORDER_TOP + CBanner.BORDER_BOTTOM + 2*CBanner.BORDER_STRIPE;
+	}
+	
+	if (wHint != SWT.DEFAULT) width = wHint;
+	if (hHint != SWT.DEFAULT) height = hHint;
+	
+	return new Point(width, height);
+}
+Point computeChildSize(Control control, int wHint, int hHint, boolean flushCache) {
+	Object data = control.getLayoutData();
+	if (data == null || !(data instanceof CLayoutData)) {
+		data = new CLayoutData();
+		control.setLayoutData(data);
+	}
+	return ((CLayoutData)data).computeSize(control, wHint, hHint, flushCache);
+}
+int computeTrim(Control c) {
+	if (c instanceof Scrollable) {
+		Rectangle rect = ((Scrollable) c).computeTrim (0, 0, 0, 0);
+		return rect.width;
+	}
+	return c.getBorderWidth () * 2;
+}
+protected boolean flushCache(Control control) {
+	Object data = control.getLayoutData();
+	if (data != null && data instanceof CLayoutData) ((CLayoutData)data).flushCache();
+	return true;
+}
+protected void layout(Composite composite, boolean flushCache) {
+	CBanner banner = (CBanner)composite;
+	Control left = banner.left;
+	Control right = banner.right;
+	Control bottom = banner.bottom;
+	
+	Point size = banner.getSize();
+	boolean showCurve = left != null && right != null;
+	int width = size.x - 2*banner.getBorderWidth();
+	int height = size.y - 2*banner.getBorderWidth();
+	
+	Point bottomSize = new Point(0, 0);
+	if (bottom != null) {
+		int trim = computeTrim(bottom);
+		int w = Math.max(0, width - trim);
+		bottomSize = computeChildSize(bottom, w, SWT.DEFAULT, flushCache);
+		height -= bottomSize.y + CBanner.BORDER_STRIPE + 2;
+	}
+	if (showCurve) height -=  CBanner.BORDER_TOP + CBanner.BORDER_BOTTOM + 2*CBanner.BORDER_STRIPE;
+	height = Math.max(0, height);
+	Point rightSize = new Point(0,0);
+	if (right != null) {
+		int trim = computeTrim(right);
+		int w = SWT.DEFAULT;
+		if (banner.rightWidth != SWT.DEFAULT) {
+			w = banner.rightWidth - trim;
+			if (left != null) {
+				w = Math.min(w, width - banner.curve_width + 2* banner.curve_indent - CBanner.MIN_LEFT - trim);
+			}
+			w = Math.max(0, w);
+		}
+		rightSize = computeChildSize(right, w, SWT.DEFAULT, flushCache);
+		width = width - (rightSize.x - banner.curve_indent + banner.curve_width - banner.curve_indent); 
+	}
+	Point leftSize = new Point(0, 0);
+	if (left != null) {
+		int trim = computeTrim(left);
+		int w = Math.max(0, width - trim);
+		leftSize = computeChildSize(left, w, SWT.DEFAULT, flushCache);
+	}
+
+	int x = 0;
+	int y = 0;
+	int oldStart = banner.curveStart;
+	Rectangle leftRect = null;
+	Rectangle rightRect = null;
+	Rectangle bottomRect = null;
+	if (bottom != null) {
+		bottomRect = new Rectangle(x, y+size.y-bottomSize.y, bottomSize.x, bottomSize.y);
+	}
+	if (showCurve) y += CBanner.BORDER_TOP + CBanner.BORDER_STRIPE;
+	if(left != null) {
+		leftRect = new Rectangle(x, y, leftSize.x, leftSize.y);
+		banner.curveStart = x + leftSize.x - banner.curve_indent;
+		x += leftSize.x - banner.curve_indent + banner.curve_width - banner.curve_indent;
+	}
+	if (right != null) {
+		if (left != null) {
+			rightSize.y = Math.max(leftSize.y, banner.rightMinHeight == SWT.DEFAULT ? rightSize.y : banner.rightMinHeight);
+		}
+		rightRect = new Rectangle(x, y, rightSize.x, rightSize.y);
+	}
+	if (banner.curveStart < oldStart) {
+		banner.redraw(banner.curveStart - CBanner.CURVE_TAIL, 0, oldStart + banner.curve_width - banner.curveStart + CBanner.CURVE_TAIL + 5, size.y, false);
+	}
+	if (banner.curveStart > oldStart) {
+		banner.redraw(oldStart - CBanner.CURVE_TAIL, 0, banner.curveStart + banner.curve_width - oldStart + CBanner.CURVE_TAIL + 5, size.y, false);
+	}
+	/*
+	 * The paint events must be flushed in order to make the curve draw smoothly
+	 * while the user drags the divider.
+	 * On Windows, it is necessary to flush the paints before the children are 
+	 * resized because otherwise the children (particularly toolbars) will flash.
+	 */
+	banner.update();
+	banner.curveRect = new Rectangle(banner.curveStart, 0, banner.curve_width, size.y);
+	if (bottomRect != null) bottom.setBounds(bottomRect);
+	if (rightRect != null) right.setBounds(rightRect);
+	if (leftRect != null) left.setBounds(leftRect);
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/custom/CCombo.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/custom/CCombo.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/custom/CCombo.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,1765 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.custom;
+
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.accessibility.*;
+
+/**
+ * The CCombo class represents a selectable user interface object
+ * that combines a text field and a list and issues notification
+ * when an item is selected from the list.
+ * <p>
+ * CCombo was written to work around certain limitations in the native
+ * combo box. Specifically, on win32, the height of a CCombo can be set;
+ * attempts to set the height of a Combo are ignored. CCombo can be used
+ * anywhere that having the increased flexibility is more important than
+ * getting native L&F, but the decision should not be taken lightly. 
+ * There is no is no strict requirement that CCombo look or behave
+ * the same as the native combo box.
+ * </p>
+ * <p>
+ * Note that although this class is a subclass of <code>Composite</code>,
+ * it does not make sense to add children to it, or set a layout on it.
+ * </p>
+ * <dl>
+ * <dt><b>Styles:</b>
+ * <dd>BORDER, READ_ONLY, FLAT</dd>
+ * <dt><b>Events:</b>
+ * <dd>DefaultSelection, Modify, Selection, Verify</dd>
+ * </dl>
+ *
+ * @see <a href="http://www.eclipse.org/swt/snippets/#ccombo">CCombo snippets</a>
+ * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: CustomControlExample</a>
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public final class CCombo extends Composite {
+
+	Text text;
+	List list;
+	int visibleItemCount = 5;
+	Shell popup;
+	Button arrow;
+	boolean hasFocus;
+	Listener listener, filter;
+	Color foreground, background;
+	Font font;
+	
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a widget which will be the parent of the new instance (cannot be null)
+ * @param style the style of widget to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * </ul>
+ *
+ * @see SWT#BORDER
+ * @see SWT#READ_ONLY
+ * @see SWT#FLAT
+ * @see Widget#getStyle()
+ */
+public CCombo (Composite parent, int style) {
+	super (parent, style = checkStyle (style));
+	
+	int textStyle = SWT.SINGLE;
+	if ((style & SWT.READ_ONLY) != 0) textStyle |= SWT.READ_ONLY;
+	if ((style & SWT.FLAT) != 0) textStyle |= SWT.FLAT;
+	text = new Text (this, textStyle);
+	int arrowStyle = SWT.ARROW | SWT.DOWN;
+	if ((style & SWT.FLAT) != 0) arrowStyle |= SWT.FLAT;
+	arrow = new Button (this, arrowStyle);
+
+	listener = new Listener () {
+		public void handleEvent (Event event) {
+			if (popup == event.widget) {
+				popupEvent (event);
+				return;
+			}
+			if (text == event.widget) {
+				textEvent (event);
+				return;
+			}
+			if (list == event.widget) {
+				listEvent (event);
+				return;
+			}
+			if (arrow == event.widget) {
+				arrowEvent (event);
+				return;
+			}
+			if (CCombo.this == event.widget) {
+				comboEvent (event);
+				return;
+			}
+			if (getShell () == event.widget) {
+				getDisplay().asyncExec(new Runnable() {
+					public void run() {
+						if (isDisposed()) return;
+						handleFocus (SWT.FocusOut);
+					}
+				});
+			}
+		}
+	};
+	filter = new Listener() {
+		public void handleEvent(Event event) {
+			Shell shell = ((Control)event.widget).getShell ();
+			if (shell == CCombo.this.getShell ()) {
+				handleFocus (SWT.FocusOut);
+			}
+		}
+	};
+	
+	int [] comboEvents = {SWT.Dispose, SWT.FocusIn, SWT.Move, SWT.Resize};
+	for (int i=0; i<comboEvents.length; i++) this.addListener (comboEvents [i], listener);
+	
+	int [] textEvents = {SWT.DefaultSelection, SWT.KeyDown, SWT.KeyUp, SWT.MenuDetect, SWT.Modify, SWT.MouseDown, SWT.MouseUp, SWT.MouseDoubleClick, SWT.MouseWheel, SWT.Traverse, SWT.FocusIn, SWT.Verify};
+	for (int i=0; i<textEvents.length; i++) text.addListener (textEvents [i], listener);
+	
+	int [] arrowEvents = {SWT.MouseDown, SWT.MouseUp, SWT.Selection, SWT.FocusIn};
+	for (int i=0; i<arrowEvents.length; i++) arrow.addListener (arrowEvents [i], listener);
+	
+	createPopup(null, -1);
+	initAccessible();
+}
+static int checkStyle (int style) {
+	int mask = SWT.BORDER | SWT.READ_ONLY | SWT.FLAT | SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT;
+	return SWT.NO_FOCUS | (style & mask);
+}
+/**
+ * Adds the argument to the end of the receiver's list.
+ *
+ * @param string the new item
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #add(String,int)
+ */
+public void add (String string) {
+	checkWidget();
+	if (string == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+	list.add (string);
+}
+/**
+ * Adds the argument to the receiver's list at the given
+ * zero-relative index.
+ * <p>
+ * Note: To add an item at the end of the list, use the
+ * result of calling <code>getItemCount()</code> as the
+ * index or use <code>add(String)</code>.
+ * </p>
+ *
+ * @param string the new item
+ * @param index the index for the item
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list (inclusive)</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #add(String)
+ */
+public void add (String string, int index) {
+	checkWidget();
+	if (string == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+	list.add (string, index);
+}
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the receiver's text is modified, by sending
+ * it one of the messages defined in the <code>ModifyListener</code>
+ * interface.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see ModifyListener
+ * @see #removeModifyListener
+ */
+public void addModifyListener (ModifyListener listener) {
+	checkWidget();
+	if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+	TypedListener typedListener = new TypedListener (listener);
+	addListener (SWT.Modify, typedListener);
+}
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the user changes the receiver's selection, by sending
+ * it one of the messages defined in the <code>SelectionListener</code>
+ * interface.
+ * <p>
+ * <code>widgetSelected</code> is called when the combo's list selection changes.
+ * <code>widgetDefaultSelected</code> is typically called when ENTER is pressed the combo's text area.
+ * </p>
+ *
+ * @param listener the listener which should be notified when the user changes the receiver's selection
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent
+ */
+public void addSelectionListener(SelectionListener listener) {
+	checkWidget();
+	if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+	TypedListener typedListener = new TypedListener (listener);
+	addListener (SWT.Selection,typedListener);
+	addListener (SWT.DefaultSelection,typedListener);
+}
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the receiver's text is verified, by sending
+ * it one of the messages defined in the <code>VerifyListener</code>
+ * interface.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see VerifyListener
+ * @see #removeVerifyListener
+ * 
+ * @since 3.3
+ */
+public void addVerifyListener (VerifyListener listener) {
+	checkWidget();
+	if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+	TypedListener typedListener = new TypedListener (listener);
+	addListener (SWT.Verify,typedListener);
+}
+void arrowEvent (Event event) {
+	switch (event.type) {
+		case SWT.FocusIn: {
+			handleFocus (SWT.FocusIn);
+			break;
+		}
+		case SWT.MouseDown: {
+			Event mouseEvent = new Event ();
+			mouseEvent.button = event.button;
+			mouseEvent.count = event.count;
+			mouseEvent.stateMask = event.stateMask;
+			mouseEvent.time = event.time;
+			mouseEvent.x = event.x; mouseEvent.y = event.y;
+			notifyListeners (SWT.MouseDown, mouseEvent);
+			event.doit = mouseEvent.doit;
+			break;
+		}
+		case SWT.MouseUp: {
+			Event mouseEvent = new Event ();
+			mouseEvent.button = event.button;
+			mouseEvent.count = event.count;
+			mouseEvent.stateMask = event.stateMask;
+			mouseEvent.time = event.time;
+			mouseEvent.x = event.x; mouseEvent.y = event.y;
+			notifyListeners (SWT.MouseUp, mouseEvent);
+			event.doit = mouseEvent.doit;
+			break;
+		}
+		case SWT.Selection: {
+			text.setFocus();
+			dropDown (!isDropped ());
+			break;
+		}
+	}
+}
+/**
+ * Sets the selection in the receiver's text field to an empty
+ * selection starting just before the first character. If the
+ * text field is editable, this has the effect of placing the
+ * i-beam at the start of the text.
+ * <p>
+ * Note: To clear the selected items in the receiver's list, 
+ * use <code>deselectAll()</code>.
+ * </p>
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #deselectAll
+ */
+public void clearSelection () {
+	checkWidget ();
+	text.clearSelection ();
+	list.deselectAll ();
+}
+void comboEvent (Event event) {
+	switch (event.type) {
+		case SWT.Dispose:
+			if (popup != null && !popup.isDisposed ()) {
+				list.removeListener (SWT.Dispose, listener);
+				popup.dispose ();
+			}
+			Shell shell = getShell ();
+			shell.removeListener (SWT.Deactivate, listener);
+			Display display = getDisplay ();
+			display.removeFilter (SWT.FocusIn, filter);
+			popup = null;  
+			text = null;  
+			list = null;  
+			arrow = null;
+			break;
+		case SWT.FocusIn:
+			Control focusControl = getDisplay ().getFocusControl ();
+			if (focusControl == arrow || focusControl == list) return;
+			if (isDropped()) {
+				list.setFocus();
+			} else {
+				text.setFocus();
+			}
+			break;
+		case SWT.Move:
+			dropDown (false);
+			break;
+		case SWT.Resize:
+			internalLayout (false);
+			break;
+	}
+}
+
+public Point computeSize (int wHint, int hHint, boolean changed) {
+	checkWidget ();
+	int width = 0, height = 0;
+	String[] items = list.getItems ();
+	GC gc = new GC (text);
+	int spacer = gc.stringExtent (" ").x; //$NON-NLS-1$
+	int textWidth = gc.stringExtent (text.getText ()).x;
+	for (int i = 0; i < items.length; i++) {
+		textWidth = Math.max (gc.stringExtent (items[i]).x, textWidth);
+	}
+	gc.dispose ();
+	Point textSize = text.computeSize (SWT.DEFAULT, SWT.DEFAULT, changed);
+	Point arrowSize = arrow.computeSize (SWT.DEFAULT, SWT.DEFAULT, changed);
+	Point listSize = list.computeSize (SWT.DEFAULT, SWT.DEFAULT, changed);
+	int borderWidth = getBorderWidth ();
+	
+	height = Math.max (textSize.y, arrowSize.y);
+	width = Math.max (textWidth + 2*spacer + arrowSize.x + 2*borderWidth, listSize.x);
+	if (wHint != SWT.DEFAULT) width = wHint;
+	if (hHint != SWT.DEFAULT) height = hHint;
+	return new Point (width + 2*borderWidth, height + 2*borderWidth);
+}
+/**
+ * Copies the selected text.
+ * <p>
+ * The current selection is copied to the clipboard.
+ * </p>
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.3
+ */
+public void copy () {
+	checkWidget ();
+	text.copy ();
+}
+void createPopup(String[] items, int selectionIndex) {		
+	// create shell and list
+	popup = new Shell (getShell (), SWT.NO_TRIM | SWT.ON_TOP);
+	int style = getStyle ();
+	int listStyle = SWT.SINGLE | SWT.V_SCROLL;
+	if ((style & SWT.FLAT) != 0) listStyle |= SWT.FLAT;
+	if ((style & SWT.RIGHT_TO_LEFT) != 0) listStyle |= SWT.RIGHT_TO_LEFT;
+	if ((style & SWT.LEFT_TO_RIGHT) != 0) listStyle |= SWT.LEFT_TO_RIGHT;
+	list = new List (popup, listStyle);
+	if (font != null) list.setFont (font);
+	if (foreground != null) list.setForeground (foreground);
+	if (background != null) list.setBackground (background);
+
+	int [] popupEvents = {SWT.Close, SWT.Paint, SWT.Deactivate};
+	for (int i=0; i<popupEvents.length; i++) popup.addListener (popupEvents [i], listener);
+	int [] listEvents = {SWT.MouseUp, SWT.Selection, SWT.Traverse, SWT.KeyDown, SWT.KeyUp, SWT.FocusIn, SWT.Dispose};
+	for (int i=0; i<listEvents.length; i++) list.addListener (listEvents [i], listener);
+
+	if (items != null) list.setItems (items);
+	if (selectionIndex != -1) list.setSelection (selectionIndex);
+}
+/**
+ * Cuts the selected text.
+ * <p>
+ * The current selection is first copied to the
+ * clipboard and then deleted from the widget.
+ * </p>
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.3
+ */
+public void cut () {
+	checkWidget ();
+	text.cut ();
+}
+/**
+ * Deselects the item at the given zero-relative index in the receiver's 
+ * list.  If the item at the index was already deselected, it remains
+ * deselected. Indices that are out of range are ignored.
+ *
+ * @param index the index of the item to deselect
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void deselect (int index) {
+	checkWidget ();
+	if (0 <= index && index < list.getItemCount () &&
+			index == list.getSelectionIndex() && 
+			text.getText().equals(list.getItem(index))) {
+		text.setText("");  //$NON-NLS-1$
+		list.deselect (index);
+	}
+}
+/**
+ * Deselects all selected items in the receiver's list.
+ * <p>
+ * Note: To clear the selection in the receiver's text field,
+ * use <code>clearSelection()</code>.
+ * </p>
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #clearSelection
+ */
+public void deselectAll () {
+	checkWidget ();
+	text.setText("");  //$NON-NLS-1$
+	list.deselectAll ();
+}
+void dropDown (boolean drop) {
+	if (drop == isDropped ()) return;
+	if (!drop) {
+		popup.setVisible (false);
+		if (!isDisposed () && isFocusControl()) {
+			text.setFocus();
+		}
+		return;
+	}
+	if (!isVisible()) return;
+	if (getShell() != popup.getParent ()) {
+		String[] items = list.getItems ();
+		int selectionIndex = list.getSelectionIndex ();
+		list.removeListener (SWT.Dispose, listener);
+		popup.dispose();
+		popup = null;
+		list = null;
+		createPopup (items, selectionIndex);
+	}
+	
+	Point size = getSize ();
+	int itemCount = list.getItemCount ();
+	itemCount = (itemCount == 0) ? visibleItemCount : Math.min(visibleItemCount, itemCount);
+	int itemHeight = list.getItemHeight () * itemCount;
+	Point listSize = list.computeSize (SWT.DEFAULT, itemHeight, false);
+	list.setBounds (1, 1, Math.max (size.x - 2, listSize.x), listSize.y);
+	
+	int index = list.getSelectionIndex ();
+	if (index != -1) list.setTopIndex (index);
+	Display display = getDisplay ();
+	Rectangle listRect = list.getBounds ();
+	Rectangle parentRect = display.map (getParent (), null, getBounds ());
+	Point comboSize = getSize ();
+	Rectangle displayRect = getMonitor ().getClientArea ();
+	int width = Math.max (comboSize.x, listRect.width + 2);
+	int height = listRect.height + 2;
+	int x = parentRect.x;
+	int y = parentRect.y + comboSize.y;
+	if (y + height > displayRect.y + displayRect.height) y = parentRect.y - height;
+	if (x + width > displayRect.x + displayRect.width) x = displayRect.x + displayRect.width - listRect.width;
+	popup.setBounds (x, y, width, height);
+	popup.setVisible (true);
+	if (isFocusControl()) list.setFocus ();
+}
+/*
+ * Return the lowercase of the first non-'&' character following
+ * an '&' character in the given string. If there are no '&'
+ * characters in the given string, return '\0'.
+ */
+char _findMnemonic (String string) {
+	if (string == null) return '\0';
+	int index = 0;
+	int length = string.length ();
+	do {
+		while (index < length && string.charAt (index) != '&') index++;
+		if (++index >= length) return '\0';
+		if (string.charAt (index) != '&') return Character.toLowerCase (string.charAt (index));
+		index++;
+	} while (index < length);
+ 	return '\0';
+}
+/* 
+ * Return the Label immediately preceding the receiver in the z-order, 
+ * or null if none. 
+ */
+Label getAssociatedLabel () {
+	Control[] siblings = getParent ().getChildren ();
+	for (int i = 0; i < siblings.length; i++) {
+		if (siblings [i] == this) {
+			if (i > 0 && siblings [i-1] instanceof Label) {
+				return (Label) siblings [i-1];
+			}
+		}
+	}
+	return null;
+}
+public Control [] getChildren () {
+	checkWidget();
+	return new Control [0];
+}
+/**
+ * Gets the editable state.
+ *
+ * @return whether or not the receiver is editable
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.0
+ */
+public boolean getEditable () {
+	checkWidget ();
+	return text.getEditable();
+}
+/**
+ * Returns the item at the given, zero-relative index in the
+ * receiver's list. Throws an exception if the index is out
+ * of range.
+ *
+ * @param index the index of the item to return
+ * @return the item at the given index
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public String getItem (int index) {
+	checkWidget();
+	return list.getItem (index);
+}
+/**
+ * Returns the number of items contained in the receiver's list.
+ *
+ * @return the number of items
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getItemCount () {
+	checkWidget ();
+	return list.getItemCount ();
+}
+/**
+ * Returns the height of the area which would be used to
+ * display <em>one</em> of the items in the receiver's list.
+ *
+ * @return the height of one item
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getItemHeight () {
+	checkWidget ();
+	return list.getItemHeight ();
+}
+/**
+ * Returns an array of <code>String</code>s which are the items
+ * in the receiver's list. 
+ * <p>
+ * Note: This is not the actual structure used by the receiver
+ * to maintain its list of items, so modifying the array will
+ * not affect the receiver. 
+ * </p>
+ *
+ * @return the items in the receiver's list
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public String [] getItems () {
+	checkWidget ();
+	return list.getItems ();
+}
+/**
+ * Returns <code>true</code> if the receiver's list is visible,
+ * and <code>false</code> otherwise.
+ * <p>
+ * If one of the receiver's ancestors is not visible or some
+ * other condition makes the receiver not visible, this method
+ * may still indicate that it is considered visible even though
+ * it may not actually be showing.
+ * </p>
+ *
+ * @return the receiver's list's visibility state
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.4
+ */
+public boolean getListVisible () {
+	checkWidget ();
+	return isDropped();
+}
+public Menu getMenu() {
+	return text.getMenu();
+}
+/**
+ * Returns a <code>Point</code> whose x coordinate is the start
+ * of the selection in the receiver's text field, and whose y
+ * coordinate is the end of the selection. The returned values
+ * are zero-relative. An "empty" selection as indicated by
+ * the the x and y coordinates having the same value.
+ *
+ * @return a point representing the selection start and end
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Point getSelection () {
+	checkWidget ();
+	return text.getSelection ();
+}
+/**
+ * Returns the zero-relative index of the item which is currently
+ * selected in the receiver's list, or -1 if no item is selected.
+ *
+ * @return the index of the selected item
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getSelectionIndex () {
+	checkWidget ();
+	return list.getSelectionIndex ();
+}
+public int getStyle () {
+	int style = super.getStyle ();
+	style &= ~SWT.READ_ONLY;
+	if (!text.getEditable()) style |= SWT.READ_ONLY; 
+	return style;
+}
+/**
+ * Returns a string containing a copy of the contents of the
+ * receiver's text field.
+ *
+ * @return the receiver's text
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public String getText () {
+	checkWidget ();
+	return text.getText ();
+}
+/**
+ * Returns the height of the receivers's text field.
+ *
+ * @return the text height
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getTextHeight () {
+	checkWidget ();
+	return text.getLineHeight ();
+}
+/**
+ * Returns the maximum number of characters that the receiver's
+ * text field is capable of holding. If this has not been changed
+ * by <code>setTextLimit()</code>, it will be the constant
+ * <code>Combo.LIMIT</code>.
+ * 
+ * @return the text limit
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getTextLimit () {
+	checkWidget ();
+	return text.getTextLimit ();
+}
+/**
+ * Gets the number of items that are visible in the drop
+ * down portion of the receiver's list.
+ *
+ * @return the number of items that are visible
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.0
+ */
+public int getVisibleItemCount () {
+	checkWidget ();
+	return visibleItemCount;
+}
+void handleFocus (int type) {
+	if (isDisposed ()) return;
+	switch (type) {
+		case SWT.FocusIn: {
+			if (hasFocus) return;
+			if (getEditable ()) text.selectAll ();
+			hasFocus = true;
+			Shell shell = getShell ();
+			shell.removeListener (SWT.Deactivate, listener);
+			shell.addListener (SWT.Deactivate, listener);
+			Display display = getDisplay ();
+			display.removeFilter (SWT.FocusIn, filter);
+			display.addFilter (SWT.FocusIn, filter);
+			Event e = new Event ();
+			notifyListeners (SWT.FocusIn, e);
+			break;
+		}
+		case SWT.FocusOut: {
+			if (!hasFocus) return;
+			Control focusControl = getDisplay ().getFocusControl ();
+			if (focusControl == arrow || focusControl == list || focusControl == text) return;
+			hasFocus = false;
+			Shell shell = getShell ();
+			shell.removeListener(SWT.Deactivate, listener);
+			Display display = getDisplay ();
+			display.removeFilter (SWT.FocusIn, filter);
+			Event e = new Event ();
+			notifyListeners (SWT.FocusOut, e);
+			break;
+		}
+	}
+}
+/**
+ * Searches the receiver's list starting at the first item
+ * (index 0) until an item is found that is equal to the 
+ * argument, and returns the index of that item. If no item
+ * is found, returns -1.
+ *
+ * @param string the search item
+ * @return the index of the item
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int indexOf (String string) {
+	checkWidget ();
+	if (string == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+	return list.indexOf (string);
+}
+/**
+ * Searches the receiver's list starting at the given, 
+ * zero-relative index until an item is found that is equal
+ * to the argument, and returns the index of that item. If
+ * no item is found or the starting index is out of range,
+ * returns -1.
+ *
+ * @param string the search item
+ * @param start the zero-relative index at which to begin the search
+ * @return the index of the item
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int indexOf (String string, int start) {
+	checkWidget ();
+	if (string == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+	return list.indexOf (string, start);
+}
+
+void initAccessible() {
+	AccessibleAdapter accessibleAdapter = new AccessibleAdapter () {
+		public void getName (AccessibleEvent e) {
+			String name = null;
+			Label label = getAssociatedLabel ();
+			if (label != null) {
+				name = stripMnemonic (label.getText());
+			}
+			e.result = name;
+		}
+		public void getKeyboardShortcut(AccessibleEvent e) {
+			String shortcut = null;
+			Label label = getAssociatedLabel ();
+			if (label != null) {
+				String text = label.getText ();
+				if (text != null) {
+					char mnemonic = _findMnemonic (text);
+					if (mnemonic != '\0') {
+						shortcut = "Alt+"+mnemonic; //$NON-NLS-1$
+					}
+				}
+			}
+			e.result = shortcut;
+		}
+		public void getHelp (AccessibleEvent e) {
+			e.result = getToolTipText ();
+		}
+	};
+	getAccessible ().addAccessibleListener (accessibleAdapter);
+	text.getAccessible ().addAccessibleListener (accessibleAdapter);
+	list.getAccessible ().addAccessibleListener (accessibleAdapter);
+	
+	arrow.getAccessible ().addAccessibleListener (new AccessibleAdapter() {
+		public void getName (AccessibleEvent e) {
+			e.result = isDropped () ? SWT.getMessage ("SWT_Close") : SWT.getMessage ("SWT_Open"); //$NON-NLS-1$ //$NON-NLS-2$
+		}
+		public void getKeyboardShortcut (AccessibleEvent e) {
+			e.result = "Alt+Down Arrow"; //$NON-NLS-1$
+		}
+		public void getHelp (AccessibleEvent e) {
+			e.result = getToolTipText ();
+		}
+	});
+
+	getAccessible().addAccessibleTextListener (new AccessibleTextAdapter() {
+		public void getCaretOffset (AccessibleTextEvent e) {
+			e.offset = text.getCaretPosition ();
+		}
+		public void getSelectionRange(AccessibleTextEvent e) {
+			Point sel = text.getSelection();
+			e.offset = sel.x;
+			e.length = sel.y - sel.x;
+		}
+	});
+	
+	getAccessible().addAccessibleControlListener (new AccessibleControlAdapter() {
+		public void getChildAtPoint (AccessibleControlEvent e) {
+			Point testPoint = toControl (e.x, e.y);
+			if (getBounds ().contains (testPoint)) {
+				e.childID = ACC.CHILDID_SELF;
+			}
+		}
+		
+		public void getLocation (AccessibleControlEvent e) {
+			Rectangle location = getBounds ();
+			Point pt = getParent().toDisplay (location.x, location.y);
+			e.x = pt.x;
+			e.y = pt.y;
+			e.width = location.width;
+			e.height = location.height;
+		}
+		
+		public void getChildCount (AccessibleControlEvent e) {
+			e.detail = 0;
+		}
+		
+		public void getRole (AccessibleControlEvent e) {
+			e.detail = ACC.ROLE_COMBOBOX;
+		}
+		
+		public void getState (AccessibleControlEvent e) {
+			e.detail = ACC.STATE_NORMAL;
+		}
+
+		public void getValue (AccessibleControlEvent e) {
+			e.result = getText ();
+		}
+	});
+
+	text.getAccessible ().addAccessibleControlListener (new AccessibleControlAdapter () {
+		public void getRole (AccessibleControlEvent e) {
+			e.detail = text.getEditable () ? ACC.ROLE_TEXT : ACC.ROLE_LABEL;
+		}
+	});
+
+	arrow.getAccessible ().addAccessibleControlListener (new AccessibleControlAdapter() {
+		public void getDefaultAction (AccessibleControlEvent e) {
+			e.result = isDropped () ? SWT.getMessage ("SWT_Close") : SWT.getMessage ("SWT_Open"); //$NON-NLS-1$ //$NON-NLS-2$
+		}
+	});
+}
+boolean isDropped () {
+	return popup.getVisible ();
+}
+public boolean isFocusControl () {
+	checkWidget();
+	if (text.isFocusControl () || arrow.isFocusControl () || list.isFocusControl () || popup.isFocusControl ()) {
+		return true;
+	} 
+	return super.isFocusControl ();
+}
+void internalLayout (boolean changed) {
+	if (isDropped ()) dropDown (false);
+	Rectangle rect = getClientArea ();
+	int width = rect.width;
+	int height = rect.height;
+	Point arrowSize = arrow.computeSize (SWT.DEFAULT, height, changed);
+	text.setBounds (0, 0, width - arrowSize.x, height);
+	arrow.setBounds (width - arrowSize.x, 0, arrowSize.x, arrowSize.y);
+}
+void listEvent (Event event) {
+	switch (event.type) {
+		case SWT.Dispose:
+			if (getShell () != popup.getParent ()) {
+				String[] items = list.getItems ();
+				int selectionIndex = list.getSelectionIndex ();
+				popup = null;
+				list = null;
+				createPopup (items, selectionIndex);
+			}
+			break;
+		case SWT.FocusIn: {
+			handleFocus (SWT.FocusIn);
+			break;
+		}
+		case SWT.MouseUp: {
+			if (event.button != 1) return;
+			dropDown (false);
+			break;
+		}
+		case SWT.Selection: {
+			int index = list.getSelectionIndex ();
+			if (index == -1) return;
+			text.setText (list.getItem (index));
+			text.selectAll ();
+			list.setSelection (index);
+			Event e = new Event ();
+			e.time = event.time;
+			e.stateMask = event.stateMask;
+			e.doit = event.doit;
+			notifyListeners (SWT.Selection, e);
+			event.doit = e.doit;
+			break;
+		}
+		case SWT.Traverse: {
+			switch (event.detail) {
+				case SWT.TRAVERSE_RETURN:
+				case SWT.TRAVERSE_ESCAPE:
+				case SWT.TRAVERSE_ARROW_PREVIOUS:
+				case SWT.TRAVERSE_ARROW_NEXT:
+					event.doit = false;
+					break;
+				case SWT.TRAVERSE_TAB_NEXT:
+				case SWT.TRAVERSE_TAB_PREVIOUS:
+					event.doit = text.traverse(event.detail);
+					event.detail = SWT.TRAVERSE_NONE;
+					if (event.doit) dropDown(false);
+					return;
+			}
+			Event e = new Event ();
+			e.time = event.time;
+			e.detail = event.detail;
+			e.doit = event.doit;
+			e.character = event.character;
+			e.keyCode = event.keyCode;
+			notifyListeners (SWT.Traverse, e);
+			event.doit = e.doit;
+			event.detail = e.detail;
+			break;
+		}
+		case SWT.KeyUp: {		
+			Event e = new Event ();
+			e.time = event.time;
+			e.character = event.character;
+			e.keyCode = event.keyCode;
+			e.stateMask = event.stateMask;
+			notifyListeners (SWT.KeyUp, e);
+			break;
+		}
+		case SWT.KeyDown: {
+			if (event.character == SWT.ESC) { 
+				// Escape key cancels popup list
+				dropDown (false);
+			}
+			if ((event.stateMask & SWT.ALT) != 0 && (event.keyCode == SWT.ARROW_UP || event.keyCode == SWT.ARROW_DOWN)) {
+				dropDown (false);
+			}
+			if (event.character == SWT.CR) {
+				// Enter causes default selection
+				dropDown (false);
+				Event e = new Event ();
+				e.time = event.time;
+				e.stateMask = event.stateMask;
+				notifyListeners (SWT.DefaultSelection, e);
+			}
+			// At this point the widget may have been disposed.
+			// If so, do not continue.
+			if (isDisposed ()) break;
+			Event e = new Event();
+			e.time = event.time;
+			e.character = event.character;
+			e.keyCode = event.keyCode;
+			e.stateMask = event.stateMask;
+			notifyListeners(SWT.KeyDown, e);
+			break;
+			
+		}
+	}
+}
+/**
+ * Pastes text from clipboard.
+ * <p>
+ * The selected text is deleted from the widget
+ * and new text inserted from the clipboard.
+ * </p>
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.3
+ */
+public void paste () {
+	checkWidget ();
+	text.paste ();
+}
+void popupEvent(Event event) {
+	switch (event.type) {
+		case SWT.Paint:
+			// draw black rectangle around list
+			Rectangle listRect = list.getBounds();
+			Color black = getDisplay().getSystemColor(SWT.COLOR_BLACK);
+			event.gc.setForeground(black);
+			event.gc.drawRectangle(0, 0, listRect.width + 1, listRect.height + 1);
+			break;
+		case SWT.Close:
+			event.doit = false;
+			dropDown (false);
+			break;
+		case SWT.Deactivate:
+			/*
+			 * Bug in GTK. When the arrow button is pressed the popup control receives a
+			 * deactivate event and then the arrow button receives a selection event. If 
+			 * we hide the popup in the deactivate event, the selection event will show 
+			 * it again. To prevent the popup from showing again, we will let the selection 
+			 * event of the arrow button hide the popup.
+			 * In Windows, hiding the popup during the deactivate causes the deactivate 
+			 * to be called twice and the selection event to be disappear.
+			 */
+			if (!"carbon".equals(SWT.getPlatform())) {
+				Point point = arrow.toControl(getDisplay().getCursorLocation());
+				Point size = arrow.getSize();
+				Rectangle rect = new Rectangle(0, 0, size.x, size.y);
+				if (!rect.contains(point)) dropDown (false);
+			} else {
+				dropDown(false);
+			}
+			break;
+	}
+}
+public void redraw () {
+	super.redraw();
+	text.redraw();
+	arrow.redraw();
+	if (popup.isVisible()) list.redraw();
+}
+public void redraw (int x, int y, int width, int height, boolean all) {
+	super.redraw(x, y, width, height, true);
+}
+
+/**
+ * Removes the item from the receiver's list at the given
+ * zero-relative index.
+ *
+ * @param index the index for the item
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void remove (int index) {
+	checkWidget();
+	list.remove (index);
+}
+/**
+ * Removes the items from the receiver's list which are
+ * between the given zero-relative start and end 
+ * indices (inclusive).
+ *
+ * @param start the start of the range
+ * @param end the end of the range
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_RANGE - if either the start or end are not between 0 and the number of elements in the list minus 1 (inclusive)</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void remove (int start, int end) {
+	checkWidget();
+	list.remove (start, end);
+}
+/**
+ * Searches the receiver's list starting at the first item
+ * until an item is found that is equal to the argument, 
+ * and removes that item from the list.
+ *
+ * @param string the item to remove
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the string is not found in the list</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void remove (String string) {
+	checkWidget();
+	if (string == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+	list.remove (string);
+}
+/**
+ * Removes all of the items from the receiver's list and clear the
+ * contents of receiver's text field.
+ * <p>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void removeAll () {
+	checkWidget();
+	text.setText (""); //$NON-NLS-1$
+	list.removeAll ();
+}
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the receiver's text is modified.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see ModifyListener
+ * @see #addModifyListener
+ */
+public void removeModifyListener (ModifyListener listener) {
+	checkWidget();
+	if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+	removeListener(SWT.Modify, listener);	
+}
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the user changes the receiver's selection.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #addSelectionListener
+ */
+public void removeSelectionListener (SelectionListener listener) {
+	checkWidget();
+	if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+	removeListener(SWT.Selection, listener);
+	removeListener(SWT.DefaultSelection,listener);	
+}
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the control is verified.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see VerifyListener
+ * @see #addVerifyListener
+ * 
+ * @since 3.3
+ */
+public void removeVerifyListener (VerifyListener listener) {
+	checkWidget();
+	if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+	removeListener(SWT.Verify, listener);
+}
+/**
+ * Selects the item at the given zero-relative index in the receiver's 
+ * list.  If the item at the index was already selected, it remains
+ * selected. Indices that are out of range are ignored.
+ *
+ * @param index the index of the item to select
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void select (int index) {
+	checkWidget();
+	if (index == -1) {
+		list.deselectAll ();
+		text.setText (""); //$NON-NLS-1$
+		return;
+	}
+	if (0 <= index && index < list.getItemCount()) {
+		if (index != getSelectionIndex()) {
+			text.setText (list.getItem (index));
+			text.selectAll ();
+			list.select (index);
+			list.showSelection ();
+		}
+	}
+}
+public void setBackground (Color color) {
+	super.setBackground(color);
+	background = color;
+	if (text != null) text.setBackground(color);
+	if (list != null) list.setBackground(color);
+	if (arrow != null) arrow.setBackground(color);
+}
+/**
+ * Sets the editable state.
+ *
+ * @param editable the new editable state
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.0
+ */
+public void setEditable (boolean editable) {
+	checkWidget ();
+	text.setEditable(editable);
+}
+public void setEnabled (boolean enabled) {
+	super.setEnabled(enabled);
+	if (popup != null) popup.setVisible (false);
+	if (text != null) text.setEnabled(enabled);
+	if (arrow != null) arrow.setEnabled(enabled);
+}
+public boolean setFocus () {
+	checkWidget();
+	if (!isEnabled () || !isVisible ()) return false;
+	if (isFocusControl ()) return true;
+	return text.setFocus ();
+}
+public void setFont (Font font) {
+	super.setFont (font);
+	this.font = font;
+	text.setFont (font);
+	list.setFont (font);
+	internalLayout (true);
+}
+public void setForeground (Color color) {
+	super.setForeground(color);
+	foreground = color;
+	if (text != null) text.setForeground(color);
+	if (list != null) list.setForeground(color);
+	if (arrow != null) arrow.setForeground(color);
+}
+/**
+ * Sets the text of the item in the receiver's list at the given
+ * zero-relative index to the string argument. This is equivalent
+ * to <code>remove</code>'ing the old item at the index, and then
+ * <code>add</code>'ing the new item at that index.
+ *
+ * @param index the index for the item
+ * @param string the new text for the item
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
+ *    <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setItem (int index, String string) {
+	checkWidget();
+	list.setItem (index, string);
+}
+/**
+ * Sets the receiver's list to be the given array of items.
+ *
+ * @param items the array of items
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the items array is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if an item in the items array is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setItems (String [] items) {
+	checkWidget ();
+	list.setItems (items);
+	if (!text.getEditable ()) text.setText (""); //$NON-NLS-1$
+}
+/**
+ * Sets the layout which is associated with the receiver to be
+ * the argument which may be null.
+ * <p>
+ * Note: No Layout can be set on this Control because it already
+ * manages the size and position of its children.
+ * </p>
+ *
+ * @param layout the receiver's new layout or null
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setLayout (Layout layout) {
+	checkWidget ();
+	return;
+}
+/**
+ * Marks the receiver's list as visible if the argument is <code>true</code>,
+ * and marks it invisible otherwise.
+ * <p>
+ * If one of the receiver's ancestors is not visible or some
+ * other condition makes the receiver not visible, marking
+ * it visible may not actually cause it to be displayed.
+ * </p>
+ *
+ * @param visible the new visibility state
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.4
+ */
+public void setListVisible (boolean visible) {
+	checkWidget ();
+	dropDown(visible);
+}
+public void setMenu(Menu menu) {
+	text.setMenu(menu);
+}
+/**
+ * Sets the selection in the receiver's text field to the
+ * range specified by the argument whose x coordinate is the
+ * start of the selection and whose y coordinate is the end
+ * of the selection. 
+ *
+ * @param selection a point representing the new selection start and end
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the point is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setSelection (Point selection) {
+	checkWidget();
+	if (selection == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+	text.setSelection (selection.x, selection.y);
+}
+
+/**
+ * Sets the contents of the receiver's text field to the
+ * given string.
+ * <p>
+ * Note: The text field in a <code>Combo</code> is typically
+ * only capable of displaying a single line of text. Thus,
+ * setting the text to a string containing line breaks or
+ * other special characters will probably cause it to 
+ * display incorrectly.
+ * </p>
+ *
+ * @param string the new text
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setText (String string) {
+	checkWidget();
+	if (string == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+	int index = list.indexOf (string);
+	if (index == -1) {
+		list.deselectAll ();
+		text.setText (string);
+		return;
+	}
+	text.setText (string);
+	text.selectAll ();
+	list.setSelection (index);
+	list.showSelection ();
+}
+/**
+ * Sets the maximum number of characters that the receiver's
+ * text field is capable of holding to be the argument.
+ *
+ * @param limit new text limit
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_CANNOT_BE_ZERO - if the limit is zero</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setTextLimit (int limit) {
+	checkWidget();
+	text.setTextLimit (limit);
+}
+
+public void setToolTipText (String string) {
+	checkWidget();
+	super.setToolTipText(string);
+	arrow.setToolTipText (string);
+	text.setToolTipText (string);		
+}
+
+public void setVisible (boolean visible) {
+	super.setVisible(visible);
+	/* 
+	 * At this point the widget may have been disposed in a FocusOut event.
+	 * If so then do not continue.
+	 */
+	if (isDisposed ()) return;
+	// TEMPORARY CODE
+	if (popup == null || popup.isDisposed ()) return;
+	if (!visible) popup.setVisible (false);
+}
+/**
+ * Sets the number of items that are visible in the drop
+ * down portion of the receiver's list.
+ *
+ * @param count the new number of items to be visible
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.0
+ */
+public void setVisibleItemCount (int count) {
+	checkWidget ();
+	if (count < 0) return;
+	visibleItemCount = count;
+}
+String stripMnemonic (String string) {
+	int index = 0;
+	int length = string.length ();
+	do {
+		while ((index < length) && (string.charAt (index) != '&')) index++;
+		if (++index >= length) return string;
+		if (string.charAt (index) != '&') {
+			return string.substring(0, index-1) + string.substring(index, length);
+		}
+		index++;
+	} while (index < length);
+ 	return string;
+}
+void textEvent (Event event) {
+	switch (event.type) {
+		case SWT.FocusIn: {
+			handleFocus (SWT.FocusIn);
+			break;
+		}
+		case SWT.DefaultSelection: {
+			dropDown (false);
+			Event e = new Event ();
+			e.time = event.time;
+			e.stateMask = event.stateMask;
+			notifyListeners (SWT.DefaultSelection, e);
+			break;
+		}
+		case SWT.KeyDown: {
+			Event keyEvent = new Event ();
+			keyEvent.time = event.time;
+			keyEvent.character = event.character;
+			keyEvent.keyCode = event.keyCode;
+			keyEvent.stateMask = event.stateMask;
+			notifyListeners (SWT.KeyDown, keyEvent);
+			if (isDisposed ()) break;
+			event.doit = keyEvent.doit;
+			if (!event.doit) break;
+			if (event.keyCode == SWT.ARROW_UP || event.keyCode == SWT.ARROW_DOWN) {
+				event.doit = false;
+				if ((event.stateMask & SWT.ALT) != 0) {
+					boolean dropped = isDropped ();
+					text.selectAll ();
+					if (!dropped) setFocus ();
+					dropDown (!dropped);
+					break;
+				}
+
+				int oldIndex = getSelectionIndex ();
+				if (event.keyCode == SWT.ARROW_UP) {
+					select (Math.max (oldIndex - 1, 0));
+				} else {
+					select (Math.min (oldIndex + 1, getItemCount () - 1));
+				}
+				if (oldIndex != getSelectionIndex ()) {
+					Event e = new Event();
+					e.time = event.time;
+					e.stateMask = event.stateMask;
+					notifyListeners (SWT.Selection, e);
+				}
+				if (isDisposed ()) break;
+			}
+			
+			// Further work : Need to add support for incremental search in 
+			// pop up list as characters typed in text widget
+			break;
+		}
+		case SWT.KeyUp: {
+			Event e = new Event ();
+			e.time = event.time;
+			e.character = event.character;
+			e.keyCode = event.keyCode;
+			e.stateMask = event.stateMask;
+			notifyListeners (SWT.KeyUp, e);
+			event.doit = e.doit;
+			break;
+		}
+		case SWT.MenuDetect: {
+			Event e = new Event ();
+			e.time = event.time;
+			notifyListeners (SWT.MenuDetect, e);
+			break;
+		}
+		case SWT.Modify: {
+			list.deselectAll ();
+			Event e = new Event ();
+			e.time = event.time;
+			notifyListeners (SWT.Modify, e);
+			break;
+		}
+		case SWT.MouseDown: {
+			Event mouseEvent = new Event ();
+			mouseEvent.button = event.button;
+			mouseEvent.count = event.count;
+			mouseEvent.stateMask = event.stateMask;
+			mouseEvent.time = event.time;
+			mouseEvent.x = event.x; mouseEvent.y = event.y;
+			notifyListeners (SWT.MouseDown, mouseEvent);
+			if (isDisposed ()) break;
+			event.doit = mouseEvent.doit;
+			if (!event.doit) break;
+			if (event.button != 1) return;
+			if (text.getEditable ()) return;
+			boolean dropped = isDropped ();
+			text.selectAll ();
+			if (!dropped) setFocus ();
+			dropDown (!dropped);
+			break;
+		}
+		case SWT.MouseUp: {
+			Event mouseEvent = new Event ();
+			mouseEvent.button = event.button;
+			mouseEvent.count = event.count;
+			mouseEvent.stateMask = event.stateMask;
+			mouseEvent.time = event.time;
+			mouseEvent.x = event.x; mouseEvent.y = event.y;
+			notifyListeners (SWT.MouseUp, mouseEvent);
+			if (isDisposed ()) break;
+			event.doit = mouseEvent.doit;
+			if (!event.doit) break;
+			if (event.button != 1) return;
+			if (text.getEditable ()) return;
+			text.selectAll ();
+			break;
+		}
+		case SWT.MouseDoubleClick: {
+			Event mouseEvent = new Event ();
+			mouseEvent.button = event.button;
+			mouseEvent.count = event.count;
+			mouseEvent.stateMask = event.stateMask;
+			mouseEvent.time = event.time;
+			mouseEvent.x = event.x; mouseEvent.y = event.y;
+			notifyListeners (SWT.MouseDoubleClick, mouseEvent);
+			break;
+		}
+		case SWT.MouseWheel: {
+			Event keyEvent = new Event ();
+			keyEvent.time = event.time;
+			keyEvent.keyCode = event.count > 0 ? SWT.ARROW_UP : SWT.ARROW_DOWN;
+			keyEvent.stateMask = event.stateMask;
+			notifyListeners (SWT.KeyDown, keyEvent);
+			if (isDisposed ()) break;
+			event.doit = keyEvent.doit;
+			if (!event.doit) break;
+			if (event.count != 0) {
+				event.doit = false;
+				int oldIndex = getSelectionIndex ();
+				if (event.count > 0) {
+					select (Math.max (oldIndex - 1, 0));
+				} else {
+					select (Math.min (oldIndex + 1, getItemCount () - 1));
+				}
+				if (oldIndex != getSelectionIndex ()) {
+					Event e = new Event();
+					e.time = event.time;
+					e.stateMask = event.stateMask;
+					notifyListeners (SWT.Selection, e);
+				}
+				if (isDisposed ()) break;
+			}
+			break;
+		}
+		case SWT.Traverse: {		
+			switch (event.detail) {
+				case SWT.TRAVERSE_ARROW_PREVIOUS:
+				case SWT.TRAVERSE_ARROW_NEXT:
+					// The enter causes default selection and
+					// the arrow keys are used to manipulate the list contents so
+					// do not use them for traversal.
+					event.doit = false;
+					break;
+				case SWT.TRAVERSE_TAB_PREVIOUS:
+					event.doit = traverse(SWT.TRAVERSE_TAB_PREVIOUS);
+					event.detail = SWT.TRAVERSE_NONE;
+					return;
+			}		
+			Event e = new Event ();
+			e.time = event.time;
+			e.detail = event.detail;
+			e.doit = event.doit;
+			e.character = event.character;
+			e.keyCode = event.keyCode;
+			notifyListeners (SWT.Traverse, e);
+			event.doit = e.doit;
+			event.detail = e.detail;
+			break;
+		}
+		case SWT.Verify: {
+			Event e = new Event ();
+			e.text = event.text;
+			e.start = event.start;
+			e.end = event.end;
+			e.character = event.character;
+			e.keyCode = event.keyCode;
+			e.stateMask = event.stateMask;
+			notifyListeners (SWT.Verify, e);
+			event.doit = e.doit;
+			break;
+		}
+	}
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/custom/CLabel.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/custom/CLabel.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/custom/CLabel.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,810 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.custom;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.accessibility.*;
+
+/**
+ * A Label which supports aligned text and/or an image and different border styles.
+ * <p>
+ * If there is not enough space a CLabel uses the following strategy to fit the 
+ * information into the available space:
+ * <pre>
+ * 		ignores the indent in left align mode
+ * 		ignores the image and the gap
+ * 		shortens the text by replacing the center portion of the label with an ellipsis
+ * 		shortens the text by removing the center portion of the label
+ * </pre>
+ * <p>
+ * <dl>
+ * <dt><b>Styles:</b>
+ * <dd>LEFT, RIGHT, CENTER, SHADOW_IN, SHADOW_OUT, SHADOW_NONE</dd>
+ * <dt><b>Events:</b>
+ * <dd></dd>
+ * </dl>
+ * 
+ * </p><p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ *
+ * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: CustomControlExample</a>
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public class CLabel extends Canvas {
+
+	/** Gap between icon and text */
+	private static final int GAP = 5;
+	/** Left and right margins */
+	private static final int INDENT = 3;
+	/** a string inserted in the middle of text that has been shortened */
+	private static final String ELLIPSIS = "..."; //$NON-NLS-1$ // could use the ellipsis glyph on some platforms "\u2026"
+	/** the alignment. Either CENTER, RIGHT, LEFT. Default is LEFT*/
+	private int align = SWT.LEFT;
+	private int hIndent = INDENT;
+	private int vIndent = INDENT;
+	/** the current text */
+	private String text;
+	/** the current icon */
+	private Image image;
+	// The tooltip is used for two purposes - the application can set
+	// a tooltip or the tooltip can be used to display the full text when the
+	// the text has been truncated due to the label being too short.
+	// The appToolTip stores the tooltip set by the application.  Control.tooltiptext 
+	// contains whatever tooltip is currently being displayed.
+	private String appToolTipText;
+	
+	private Image backgroundImage;
+	private Color[] gradientColors;
+	private int[] gradientPercents;
+	private boolean gradientVertical;
+	private Color background;
+	
+	private static int DRAW_FLAGS = SWT.DRAW_MNEMONIC | SWT.DRAW_TAB | SWT.DRAW_TRANSPARENT | SWT.DRAW_DELIMITER;
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a widget which will be the parent of the new instance (cannot be null)
+ * @param style the style of widget to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * </ul>
+ *
+ * @see SWT#LEFT
+ * @see SWT#RIGHT
+ * @see SWT#CENTER
+ * @see SWT#SHADOW_IN
+ * @see SWT#SHADOW_OUT
+ * @see SWT#SHADOW_NONE
+ * @see #getStyle()
+ */
+public CLabel(Composite parent, int style) {
+	super(parent, checkStyle(style));
+	if ((style & (SWT.CENTER | SWT.RIGHT)) == 0) style |= SWT.LEFT;
+	if ((style & SWT.CENTER) != 0) align = SWT.CENTER;
+	if ((style & SWT.RIGHT) != 0)  align = SWT.RIGHT;
+	if ((style & SWT.LEFT) != 0)   align = SWT.LEFT;
+	
+	addPaintListener(new PaintListener(){
+		public void paintControl(PaintEvent event) {
+			onPaint(event);
+		}
+	});
+	
+	addDisposeListener(new DisposeListener(){
+		public void widgetDisposed(DisposeEvent event) {
+			onDispose(event);
+		}
+	});
+
+	addTraverseListener(new TraverseListener() {
+		public void keyTraversed(TraverseEvent event) {
+			if (event.detail == SWT.TRAVERSE_MNEMONIC) {
+				onMnemonic(event);
+			}
+		}
+	});
+	
+	initAccessible();
+
+}
+/**
+ * Check the style bits to ensure that no invalid styles are applied.
+ */
+private static int checkStyle (int style) {
+	if ((style & SWT.BORDER) != 0) style |= SWT.SHADOW_IN;
+	int mask = SWT.SHADOW_IN | SWT.SHADOW_OUT | SWT.SHADOW_NONE | SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT;
+	style = style & mask;
+	return style |= SWT.NO_FOCUS | SWT.DOUBLE_BUFFERED;
+}
+
+//protected void checkSubclass () {
+//	String name = getClass().getName ();
+//	String validName = CLabel.class.getName();
+//	if (!validName.equals(name)) {
+//		SWT.error (SWT.ERROR_INVALID_SUBCLASS);
+//	}
+//}
+
+public Point computeSize(int wHint, int hHint, boolean changed) {
+	checkWidget();
+	Point e = getTotalSize(image, text);
+	if (wHint == SWT.DEFAULT){
+		e.x += 2*hIndent;
+	} else {
+		e.x = wHint;
+	}
+	if (hHint == SWT.DEFAULT) {
+		e.y += 2*vIndent;
+	} else {
+		e.y = hHint;
+	}
+	return e;
+}
+/**
+ * Draw a rectangle in the given colors.
+ */
+private void drawBevelRect(GC gc, int x, int y, int w, int h, Color topleft, Color bottomright) {
+	gc.setForeground(bottomright);
+	gc.drawLine(x+w, y,   x+w, y+h);
+	gc.drawLine(x,   y+h, x+w, y+h);
+	
+	gc.setForeground(topleft);
+	gc.drawLine(x, y, x+w-1, y);
+	gc.drawLine(x, y, x,     y+h-1);
+}
+/*
+ * Return the lowercase of the first non-'&' character following
+ * an '&' character in the given string. If there are no '&'
+ * characters in the given string, return '\0'.
+ */
+char _findMnemonic (String string) {
+	if (string == null) return '\0';
+	int index = 0;
+	int length = string.length ();
+	do {
+		while (index < length && string.charAt (index) != '&') index++;
+		if (++index >= length) return '\0';
+		if (string.charAt (index) != '&') return Character.toLowerCase (string.charAt (index));
+		index++;
+	} while (index < length);
+ 	return '\0';
+}
+/**
+ * Returns the alignment.
+ * The alignment style (LEFT, CENTER or RIGHT) is returned.
+ * 
+ * @return SWT.LEFT, SWT.RIGHT or SWT.CENTER
+ */
+public int getAlignment() {
+	//checkWidget();
+	return align;
+}
+/**
+ * Return the CLabel's image or <code>null</code>.
+ * 
+ * @return the image of the label or null
+ */
+public Image getImage() {
+	//checkWidget();
+	return image;
+}
+/**
+ * Compute the minimum size.
+ */
+private Point getTotalSize(Image image, String text) {
+	Point size = new Point(0, 0);
+
+	if (image != null) {
+		Rectangle r = image.getBounds();
+		size.x += r.width;
+		size.y += r.height;
+	}
+		
+	GC gc = new GC(this);
+	if (text != null && text.length() > 0) {
+		Point e = gc.textExtent(text, DRAW_FLAGS);
+		size.x += e.x;
+		size.y = Math.max(size.y, e.y);
+		if (image != null) size.x += GAP;
+	} else {
+		size.y = Math.max(size.y, gc.getFontMetrics().getHeight());
+	}
+	gc.dispose();
+	
+	return size;
+}
+public int getStyle () {
+	int style = super.getStyle();
+	switch (align) {
+		case SWT.RIGHT: style |= SWT.RIGHT; break;
+		case SWT.CENTER: style |= SWT.CENTER; break;
+		case SWT.LEFT: style |= SWT.LEFT; break;
+	}
+	return style;
+}
+
+/**
+ * Return the Label's text.
+ * 
+ * @return the text of the label or null
+ */
+public String getText() {
+	//checkWidget();
+	return text;
+}
+public String getToolTipText () {
+	checkWidget();
+	return appToolTipText;
+}
+private void initAccessible() {
+	Accessible accessible = getAccessible();
+	accessible.addAccessibleListener(new AccessibleAdapter() {
+		public void getName(AccessibleEvent e) {
+			e.result = getText();
+		}
+		
+		public void getHelp(AccessibleEvent e) {
+			e.result = getToolTipText();
+		}
+		
+		public void getKeyboardShortcut(AccessibleEvent e) {
+			char mnemonic = _findMnemonic(CLabel.this.text);	
+			if (mnemonic != '\0') {
+				e.result = "Alt+"+mnemonic; //$NON-NLS-1$
+			}
+		}
+	});
+		
+	accessible.addAccessibleControlListener(new AccessibleControlAdapter() {
+		public void getChildAtPoint(AccessibleControlEvent e) {
+			e.childID = ACC.CHILDID_SELF;
+		}
+		
+		public void getLocation(AccessibleControlEvent e) {
+			Rectangle rect = getDisplay().map(getParent(), null, getBounds());
+			e.x = rect.x;
+			e.y = rect.y;
+			e.width = rect.width;
+			e.height = rect.height;
+		}
+		
+		public void getChildCount(AccessibleControlEvent e) {
+			e.detail = 0;
+		}
+		
+		public void getRole(AccessibleControlEvent e) {
+			e.detail = ACC.ROLE_LABEL;
+		}
+		
+		public void getState(AccessibleControlEvent e) {
+			e.detail = ACC.STATE_READONLY;
+		}
+	});
+}
+void onDispose(DisposeEvent event) {
+	gradientColors = null;
+	gradientPercents = null;
+	backgroundImage = null;
+	text = null;
+	image = null;
+	appToolTipText = null;
+}
+void onMnemonic(TraverseEvent event) {
+	char mnemonic = _findMnemonic(text);
+	if (mnemonic == '\0') return;
+	if (Character.toLowerCase(event.character) != mnemonic) return;
+	Composite control = this.getParent();
+	while (control != null) {
+		Control [] children = control.getChildren();
+		int index = 0;
+		while (index < children.length) {
+			if (children [index] == this) break;
+			index++;
+		}
+		index++;
+		if (index < children.length) {
+			if (children [index].setFocus ()) {
+				event.doit = true;
+				event.detail = SWT.TRAVERSE_NONE;
+			}
+		}
+		control = control.getParent();
+	}
+}
+
+void onPaint(PaintEvent event) {
+	Rectangle rect = getClientArea();
+	if (rect.width == 0 || rect.height == 0) return;
+	
+	boolean shortenText = false;
+	String t = text;
+	Image img = image;
+	int availableWidth = Math.max(0, rect.width - 2*hIndent);
+	Point extent = getTotalSize(img, t);
+	if (extent.x > availableWidth) {
+		img = null;
+		extent = getTotalSize(img, t);
+		if (extent.x > availableWidth) {
+			shortenText = true;
+		}
+	}
+	
+	GC gc = event.gc;
+	String[] lines = text == null ? null : splitString(text); 
+	
+	// shorten the text
+	if (shortenText) {
+		extent.x = 0;
+	    for(int i = 0; i < lines.length; i++) {
+	    	Point e = gc.textExtent(lines[i], DRAW_FLAGS);
+	    	if (e.x > availableWidth) {
+	    		lines[i] = shortenText(gc, lines[i], availableWidth);
+	    		extent.x = Math.max(extent.x, getTotalSize(null, lines[i]).x);
+	    	} else {
+	    		extent.x = Math.max(extent.x, e.x);
+	    	}
+	    }
+		if (appToolTipText == null) {
+			super.setToolTipText(text);
+		}
+	} else {
+		super.setToolTipText(appToolTipText);
+	}
+		
+	// determine horizontal position
+	int x = rect.x + hIndent;
+	if (align == SWT.CENTER) {
+		x = (rect.width - extent.x)/2;
+	}
+	if (align == SWT.RIGHT) {
+		x = rect.width - hIndent - extent.x;
+	}
+	
+	// draw a background image behind the text
+	try {
+		if (backgroundImage != null) {
+			// draw a background image behind the text
+			Rectangle imageRect = backgroundImage.getBounds();
+			// tile image to fill space
+			gc.setBackground(getBackground());
+			gc.fillRectangle(rect);
+			int xPos = 0;
+			while (xPos < rect.width) {
+				int yPos = 0;
+				while (yPos < rect.height) {
+					gc.drawImage(backgroundImage, xPos, yPos);
+					yPos += imageRect.height;
+				}
+				xPos += imageRect.width;
+			}
+		} else if (gradientColors != null) {
+			// draw a gradient behind the text
+			final Color oldBackground = gc.getBackground();
+			if (gradientColors.length == 1) {
+				if (gradientColors[0] != null) gc.setBackground(gradientColors[0]);
+				gc.fillRectangle(0, 0, rect.width, rect.height);
+			} else {
+				final Color oldForeground = gc.getForeground();
+				Color lastColor = gradientColors[0];
+				if (lastColor == null) lastColor = oldBackground;
+				int pos = 0;
+				for (int i = 0; i < gradientPercents.length; ++i) {
+					gc.setForeground(lastColor);
+					lastColor = gradientColors[i + 1];
+					if (lastColor == null) lastColor = oldBackground;
+					gc.setBackground(lastColor);
+					if (gradientVertical) {
+						final int gradientHeight = (gradientPercents[i] * rect.height / 100) - pos;
+						gc.fillGradientRectangle(0, pos, rect.width, gradientHeight, true);
+						pos += gradientHeight;
+					} else {
+						final int gradientWidth = (gradientPercents[i] * rect.width / 100) - pos;
+						gc.fillGradientRectangle(pos, 0, gradientWidth, rect.height, false);
+						pos += gradientWidth;
+					}
+				}
+				if (gradientVertical && pos < rect.height) {
+					gc.setBackground(getBackground());
+					gc.fillRectangle(0, pos, rect.width, rect.height - pos);
+				}
+				if (!gradientVertical && pos < rect.width) {
+					gc.setBackground(getBackground());
+					gc.fillRectangle(pos, 0, rect.width - pos, rect.height);
+				}
+				gc.setForeground(oldForeground);
+			}
+			gc.setBackground(oldBackground);
+		} else {
+			if (background != null || (getStyle() & SWT.DOUBLE_BUFFERED) == 0) {
+				gc.setBackground(getBackground());
+				gc.fillRectangle(rect);
+			}
+		}
+	} catch (SWTException e) {
+		if ((getStyle() & SWT.DOUBLE_BUFFERED) == 0) {
+			gc.setBackground(getBackground());
+			gc.fillRectangle(rect);
+		}
+	}
+
+	// draw border
+	int style = getStyle();
+	if ((style & SWT.SHADOW_IN) != 0 || (style & SWT.SHADOW_OUT) != 0) {
+		paintBorder(gc, rect);
+	}
+
+	// draw the image
+	if (img != null) {
+		Rectangle imageRect = img.getBounds();
+		gc.drawImage(img, 0, 0, imageRect.width, imageRect.height, 
+		                x, (rect.height-imageRect.height)/2, imageRect.width, imageRect.height);
+		x +=  imageRect.width + GAP;
+		extent.x -= imageRect.width + GAP;
+	}
+	// draw the text
+	if (lines != null) {
+		int lineHeight = gc.getFontMetrics().getHeight();
+		int textHeight = lines.length * lineHeight;
+		int lineY = Math.max(vIndent, rect.y + (rect.height - textHeight) / 2);
+		gc.setForeground(getForeground());
+		for (int i = 0; i < lines.length; i++) {
+			int lineX = x;
+			if (lines.length > 1) {
+				if (align == SWT.CENTER) {
+					int lineWidth = gc.textExtent(lines[i], DRAW_FLAGS).x;
+					lineX = x + Math.max(0, (extent.x - lineWidth) / 2);
+				}
+				if (align == SWT.RIGHT) {
+					int lineWidth = gc.textExtent(lines[i], DRAW_FLAGS).x;
+					lineX = Math.max(x, rect.x + rect.width - hIndent - lineWidth);
+				}
+			}
+			gc.drawText(lines[i], lineX, lineY, DRAW_FLAGS);
+			lineY += lineHeight;
+		}
+	}
+}
+/**
+ * Paint the Label's border.
+ */
+private void paintBorder(GC gc, Rectangle r) {
+	Display disp= getDisplay();
+
+	Color c1 = null;
+	Color c2 = null;
+	
+	int style = getStyle();
+	if ((style & SWT.SHADOW_IN) != 0) {
+		c1 = disp.getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW);
+		c2 = disp.getSystemColor(SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW);
+	}
+	if ((style & SWT.SHADOW_OUT) != 0) {		
+		c1 = disp.getSystemColor(SWT.COLOR_WIDGET_LIGHT_SHADOW);
+		c2 = disp.getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW);
+	}
+		
+	if (c1 != null && c2 != null) {
+		gc.setLineWidth(1);
+		drawBevelRect(gc, r.x, r.y, r.width-1, r.height-1, c1, c2);
+	}
+}
+/**
+ * Set the alignment of the CLabel.
+ * Use the values LEFT, CENTER and RIGHT to align image and text within the available space.
+ * 
+ * @param align the alignment style of LEFT, RIGHT or CENTER
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the value of align is not one of SWT.LEFT, SWT.RIGHT or SWT.CENTER</li>
+ * </ul>
+ */
+public void setAlignment(int align) {
+	checkWidget();
+	if (align != SWT.LEFT && align != SWT.RIGHT && align != SWT.CENTER) {
+		SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	}
+	if (this.align != align) {
+		this.align = align;
+		redraw();
+	}
+}
+
+public void setBackground (Color color) {
+	super.setBackground (color);
+	// Are these settings the same as before?
+	if (backgroundImage == null && 
+		gradientColors == null && 
+		gradientPercents == null) {
+		if (color == null) {
+			if (background == null) return;
+		} else {
+			if (color.equals(background)) return;
+		}		
+	}
+	background = color;
+	backgroundImage = null;
+	gradientColors = null;
+	gradientPercents = null;
+	redraw ();
+}
+
+/**
+ * Specify a gradient of colours to be drawn in the background of the CLabel.
+ * <p>For example, to draw a gradient that varies from dark blue to blue and then to
+ * white and stays white for the right half of the label, use the following call 
+ * to setBackground:</p>
+ * <pre>
+ *	clabel.setBackground(new Color[]{display.getSystemColor(SWT.COLOR_DARK_BLUE), 
+ *		                           display.getSystemColor(SWT.COLOR_BLUE),
+ *		                           display.getSystemColor(SWT.COLOR_WHITE), 
+ *		                           display.getSystemColor(SWT.COLOR_WHITE)},
+ *		               new int[] {25, 50, 100});
+ * </pre>
+ *
+ * @param colors an array of Color that specifies the colors to appear in the gradient 
+ *               in order of appearance from left to right;  The value <code>null</code> 
+ *               clears the background gradient; the value <code>null</code> can be used 
+ *               inside the array of Color to specify the background color.
+ * @param percents an array of integers between 0 and 100 specifying the percent of the width 
+ *                 of the widget at which the color should change; the size of the percents 
+ *                 array must be one less than the size of the colors array.
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the values of colors and percents are not consistent</li>
+ * </ul>
+ */
+public void setBackground(Color[] colors, int[] percents) {
+	setBackground(colors, percents, false);
+}
+/**
+ * Specify a gradient of colours to be drawn in the background of the CLabel.
+ * <p>For example, to draw a gradient that varies from dark blue to white in the vertical,
+ * direction use the following call 
+ * to setBackground:</p>
+ * <pre>
+ *	clabel.setBackground(new Color[]{display.getSystemColor(SWT.COLOR_DARK_BLUE), 
+ *		                           display.getSystemColor(SWT.COLOR_WHITE)},
+ *		                 new int[] {100}, true);
+ * </pre>
+ *
+ * @param colors an array of Color that specifies the colors to appear in the gradient 
+ *               in order of appearance from left/top to right/bottom;  The value <code>null</code> 
+ *               clears the background gradient; the value <code>null</code> can be used 
+ *               inside the array of Color to specify the background color.
+ * @param percents an array of integers between 0 and 100 specifying the percent of the width/height 
+ *                 of the widget at which the color should change; the size of the percents 
+ *                 array must be one less than the size of the colors array.
+ * @param vertical indicate the direction of the gradient.  True is vertical and false is horizontal.
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the values of colors and percents are not consistent</li>
+ * </ul>
+ * 
+ * @since 3.0
+ */
+public void setBackground(Color[] colors, int[] percents, boolean vertical) {	
+	checkWidget();
+	if (colors != null) {
+		if (percents == null || percents.length != colors.length - 1) {
+			SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+		}
+		if (getDisplay().getDepth() < 15) {
+			// Don't use gradients on low color displays
+			colors = new Color[] {colors[colors.length - 1]};
+			percents = new int[] { };
+		}
+		for (int i = 0; i < percents.length; i++) {
+			if (percents[i] < 0 || percents[i] > 100) {
+				SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+			}
+			if (i > 0 && percents[i] < percents[i-1]) {
+				SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+			}
+		}
+	}
+	
+	// Are these settings the same as before?
+	final Color background = getBackground();
+	if (backgroundImage == null) {
+		if ((gradientColors != null) && (colors != null) && 
+			(gradientColors.length == colors.length)) {
+			boolean same = false;
+			for (int i = 0; i < gradientColors.length; i++) {
+				same = (gradientColors[i] == colors[i]) ||
+					((gradientColors[i] == null) && (colors[i] == background)) ||
+					((gradientColors[i] == background) && (colors[i] == null));
+				if (!same) break;
+			}
+			if (same) {
+				for (int i = 0; i < gradientPercents.length; i++) {
+					same = gradientPercents[i] == percents[i];
+					if (!same) break;
+				}
+			}
+			if (same && this.gradientVertical == vertical) return;
+		}
+	} else {
+		backgroundImage = null;
+	}
+	// Store the new settings
+	if (colors == null) {
+		gradientColors = null;
+		gradientPercents = null;
+		gradientVertical = false;
+	} else {
+		gradientColors = new Color[colors.length];
+		for (int i = 0; i < colors.length; ++i)
+			gradientColors[i] = (colors[i] != null) ? colors[i] : background;
+		gradientPercents = new int[percents.length];
+		for (int i = 0; i < percents.length; ++i)
+			gradientPercents[i] = percents[i];
+		gradientVertical = vertical;
+	}
+	// Refresh with the new settings
+	redraw();
+}
+/**
+ * Set the image to be drawn in the background of the label.
+ * 
+ * @param image the image to be drawn in the background
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setBackground(Image image) {
+	checkWidget();
+	if (image == backgroundImage) return;
+	if (image != null) {
+		gradientColors = null;
+		gradientPercents = null;
+	}
+	backgroundImage = image;
+	redraw();
+	
+}
+public void setFont(Font font) {
+	super.setFont(font);
+	redraw();
+}
+/**
+ * Set the label's Image.
+ * The value <code>null</code> clears it.
+ * 
+ * @param image the image to be displayed in the label or null
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setImage(Image image) {
+	checkWidget();
+	if (image != this.image) {
+		this.image = image;
+		redraw();
+	}
+}
+/**
+ * Set the label's text.
+ * The value <code>null</code> clears it.
+ * 
+ * @param text the text to be displayed in the label or null
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setText(String text) {
+	checkWidget();
+	if (text == null) text = ""; //$NON-NLS-1$
+	if (! text.equals(this.text)) {
+		this.text = text;
+		redraw();
+	}
+}
+public void setToolTipText (String string) {
+	super.setToolTipText (string);
+	appToolTipText = super.getToolTipText();
+}
+/**
+ * Shorten the given text <code>t</code> so that its length doesn't exceed
+ * the given width. The default implementation replaces characters in the
+ * center of the original string with an ellipsis ("...").
+ * Override if you need a different strategy.
+ * 
+ * @param gc the gc to use for text measurement
+ * @param t the text to shorten
+ * @param width the width to shorten the text to, in pixels
+ * @return the shortened text
+ */
+protected String shortenText(GC gc, String t, int width) {
+	if (t == null) return null;
+	int w = gc.textExtent(ELLIPSIS, DRAW_FLAGS).x;
+	if (width<=w) return t;
+	int l = t.length();
+	int max = l/2;
+	int min = 0;
+	int mid = (max+min)/2 - 1;
+	if (mid <= 0) return t;
+	TextLayout layout = new TextLayout (getDisplay());
+	layout.setText(t);
+	mid = validateOffset(layout, mid);
+	while (min < mid && mid < max) {
+		String s1 = t.substring(0, mid);
+		String s2 = t.substring(validateOffset(layout, l-mid), l);
+		int l1 = gc.textExtent(s1, DRAW_FLAGS).x;
+		int l2 = gc.textExtent(s2, DRAW_FLAGS).x;
+		if (l1+w+l2 > width) {
+			max = mid;			
+			mid = validateOffset(layout, (max+min)/2);
+		} else if (l1+w+l2 < width) {
+			min = mid;
+			mid = validateOffset(layout, (max+min)/2);
+		} else {
+			min = max;
+		}
+	}
+	String result = mid == 0 ? t : t.substring(0, mid) + ELLIPSIS + t.substring(validateOffset(layout, l-mid), l);
+	layout.dispose();
+ 	return result;
+}
+int validateOffset(TextLayout layout, int offset) {
+	int nextOffset = layout.getNextOffset(offset, SWT.MOVEMENT_CLUSTER);
+	if (nextOffset != offset) return layout.getPreviousOffset(nextOffset, SWT.MOVEMENT_CLUSTER);
+	return offset;
+}
+private String[] splitString(String text) {
+    String[] lines = new String[1];
+    int start = 0, pos;
+    do {
+        pos = text.indexOf('\n', start);
+        if (pos == -1) {
+        	lines[lines.length - 1] = text.substring(start);
+        } else {
+            boolean crlf = (pos > 0) && (text.charAt(pos - 1) == '\r');
+            lines[lines.length - 1] = text.substring(start, pos - (crlf ? 1 : 0));
+            start = pos + 1;
+            String[] newLines = new String[lines.length+1];
+            System.arraycopy(lines, 0, newLines, 0, lines.length);
+       		lines = newLines;
+        }
+    } while (pos != -1);
+    return lines;
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/custom/CLayoutData.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/custom/CLayoutData.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/custom/CLayoutData.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.custom;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+
+class CLayoutData {
+
+	int defaultWidth = -1, defaultHeight = -1;
+	int currentWhint, currentHhint, currentWidth = -1, currentHeight = -1;
+	
+Point computeSize (Control control, int wHint, int hHint, boolean flushCache) {
+	if (flushCache) flushCache();
+	if (wHint == SWT.DEFAULT && hHint == SWT.DEFAULT) {
+		if (defaultWidth == -1 || defaultHeight == -1) {
+			Point size = control.computeSize (wHint, hHint, flushCache);
+			defaultWidth = size.x;
+			defaultHeight = size.y;
+		}
+		return new Point(defaultWidth, defaultHeight);
+	}
+	if (currentWidth == -1 || currentHeight == -1 || wHint != currentWhint || hHint != currentHhint) {
+		Point size = control.computeSize (wHint, hHint, flushCache);
+		currentWhint = wHint;
+		currentHhint = hHint;
+		currentWidth = size.x;
+		currentHeight = size.y;
+	}
+	return new Point(currentWidth, currentHeight);
+}
+void flushCache () {
+	defaultWidth = defaultHeight = -1;
+	currentWidth = currentHeight = -1;
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/custom/CTabFolder.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/custom/CTabFolder.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/custom/CTabFolder.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,4017 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.custom;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.accessibility.*;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+
+/**
+ * 
+ * Instances of this class implement the notebook user interface
+ * metaphor.  It allows the user to select a notebook page from
+ * set of pages.
+ * <p>
+ * The item children that may be added to instances of this class
+ * must be of type <code>CTabItem</code>.
+ * <code>Control</code> children are created and then set into a
+ * tab item using <code>CTabItem#setControl</code>.
+ * </p><p>
+ * Note that although this class is a subclass of <code>Composite</code>,
+ * it does not make sense to set a layout on it.
+ * </p><p>
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>CLOSE, TOP, BOTTOM, FLAT, BORDER, SINGLE, MULTI</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Selection</dd>
+ * <dd>"CTabFolder2"</dd>
+ * </dl>
+ * <p>
+ * Note: Only one of the styles TOP and BOTTOM 
+ * may be specified.
+ * </p><p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ *
+ * @see <a href="http://www.eclipse.org/swt/snippets/#ctabfolder">CTabFolder, CTabItem snippets</a>
+ * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: CustomControlExample</a>
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+ 
+public class CTabFolder extends Composite {
+	
+	/**
+	 * marginWidth specifies the number of pixels of horizontal margin
+	 * that will be placed along the left and right edges of the form.
+	 *
+	 * The default value is 0.
+	 */
+ 	public int marginWidth = 0;
+	/**
+	 * marginHeight specifies the number of pixels of vertical margin
+	 * that will be placed along the top and bottom edges of the form.
+	 *
+	 * The default value is 0.
+	 */
+ 	public int marginHeight = 0;
+	
+ 	/**
+	 * A multiple of the tab height that specifies the minimum width to which a tab 
+	 * will be compressed before scrolling arrows are used to navigate the tabs.
+	 * 
+	 * NOTE This field is badly named and can not be fixed for backwards compatibility.
+	 * It should not be capitalized.
+	 * 
+	 * @deprecated This field is no longer used.  See setMinimumCharacters(int)
+	 */
+	public int MIN_TAB_WIDTH = 4;
+	
+	/**
+	 * Color of innermost line of drop shadow border.
+	 * 
+	 * NOTE This field is badly named and can not be fixed for backwards compatibility.
+	 * It should be capitalized.
+	 * 
+	 * @deprecated drop shadow border is no longer drawn in 3.0
+	 */
+	public static RGB borderInsideRGB  = new RGB (132, 130, 132);
+	/**
+	 * Color of middle line of drop shadow border.
+	 * 
+	 * NOTE This field is badly named and can not be fixed for backwards compatibility.
+	 * It should be capitalized.
+	 * 
+	 * @deprecated drop shadow border is no longer drawn in 3.0
+	 */
+	public static RGB borderMiddleRGB  = new RGB (143, 141, 138);
+	/**
+	 * Color of outermost line of drop shadow border.
+	 * 
+	 * NOTE This field is badly named and can not be fixed for backwards compatibility.
+	 * It should be capitalized.
+	 * 
+	 * @deprecated drop shadow border is no longer drawn in 3.0
+	 */
+	public static RGB borderOutsideRGB = new RGB (171, 168, 165); 
+
+	/* sizing, positioning */
+	int xClient, yClient;
+	boolean onBottom = false;
+	boolean single = false;
+	boolean simple = true;
+	int fixedTabHeight = SWT.DEFAULT;
+	int tabHeight;
+	int minChars = 20;
+	
+	/* item management */
+	CTabItem items[] = new CTabItem[0];
+	int firstIndex = -1; // index of the left most visible tab.
+	int selectedIndex = -1;
+	int[] priority = new int[0];
+	boolean mru = false;
+	Listener listener;
+	
+	/* External Listener management */
+	CTabFolder2Listener[] folderListeners = new CTabFolder2Listener[0];
+	// support for deprecated listener mechanism
+	CTabFolderListener[] tabListeners = new CTabFolderListener[0]; 
+	
+	/* Selected item appearance */
+	Image selectionBgImage;
+	Color[] selectionGradientColors;
+	int[] selectionGradientPercents;
+	boolean selectionGradientVertical;
+	Color selectionForeground;
+	Color selectionBackground;  //selection fade end
+	Color selectionFadeStart;
+	
+	Color selectionHighlightGradientBegin = null;  //null == no highlight
+	//Although we are given new colours all the time to show different states (active, etc),
+	//some of which may have a highlight and some not, we'd like to retain the highlight colours
+	//as a cache so that we can reuse them if we're again told to show the highlight.
+	//We are relying on the fact that only one tab state usually gets a highlight, so only
+	//a single cache is required. If that happens to not be true, cache simply becomes less effective,
+	//but we don't leak colours.
+	Color[] selectionHighlightGradientColorsCache = null;  //null is a legal value, check on access
+	
+	/* Unselected item appearance */
+	Image bgImage;
+	Color[] gradientColors;
+	int[] gradientPercents;
+	boolean gradientVertical;
+	boolean showUnselectedImage = true;
+	
+	static Color borderColor;
+	
+	// close, min/max and chevron buttons
+	boolean showClose = false;
+	boolean showUnselectedClose = true;
+	
+	Rectangle chevronRect = new Rectangle(0, 0, 0, 0);
+	int chevronImageState = NORMAL;
+	boolean showChevron = false;
+	Menu showMenu;
+	
+	boolean showMin = false;
+	Rectangle minRect = new Rectangle(0, 0, 0, 0);
+	boolean minimized = false;
+	int minImageState = NORMAL;
+	
+	boolean showMax = false;
+	Rectangle maxRect = new Rectangle(0, 0, 0, 0);
+	boolean maximized = false;
+	int maxImageState = NORMAL;
+	
+	Control topRight;
+	Rectangle topRightRect = new Rectangle(0, 0, 0, 0);
+	int topRightAlignment = SWT.RIGHT;
+	
+	// borders and shapes
+	int borderLeft = 0;
+	int borderRight = 0;
+	int borderTop = 0;
+	int borderBottom = 0;
+	
+	int highlight_margin = 0;
+	int highlight_header = 0;
+	
+	int[] curve;
+	int[] topCurveHighlightStart;
+	int[] topCurveHighlightEnd;
+	int curveWidth = 0;
+	int curveIndent = 0;
+	
+	// when disposing CTabFolder, don't try to layout the items or 
+	// change the selection as each child is destroyed.
+	boolean inDispose = false;
+
+	// keep track of size changes in order to redraw only affected area
+	// on Resize
+	Point oldSize;
+	Font oldFont;
+	
+	// internal constants
+	static final int DEFAULT_WIDTH = 64;
+	static final int DEFAULT_HEIGHT = 64;
+	static final int BUTTON_SIZE = 18;
+
+	static final int[] TOP_LEFT_CORNER = new int[] {0,6, 1,5, 1,4, 4,1, 5,1, 6,0};
+
+	//TOP_LEFT_CORNER_HILITE is laid out in reverse (ie. top to bottom)
+	//so can fade in same direction as right swoop curve
+	static final int[] TOP_LEFT_CORNER_HILITE = new int[] {5,2, 4,2, 3,3, 2,4, 2,5, 1,6};
+
+	static final int[] TOP_RIGHT_CORNER = new int[] {-6,0, -5,1, -4,1, -1,4, -1,5, 0,6};
+	static final int[] BOTTOM_LEFT_CORNER = new int[] {0,-6, 1,-5, 1,-4, 4,-1, 5,-1, 6,0};
+	static final int[] BOTTOM_RIGHT_CORNER = new int[] {-6,0, -5,-1, -4,-1, -1,-4, -1,-5, 0,-6};
+
+	static final int[] SIMPLE_TOP_LEFT_CORNER = new int[] {0,2, 1,1, 2,0};
+	static final int[] SIMPLE_TOP_RIGHT_CORNER = new int[] {-2,0, -1,1, 0,2};
+	static final int[] SIMPLE_BOTTOM_LEFT_CORNER = new int[] {0,-2, 1,-1, 2,0};
+	static final int[] SIMPLE_BOTTOM_RIGHT_CORNER = new int[] {-2,0, -1,-1, 0,-2};
+	static final int[] SIMPLE_UNSELECTED_INNER_CORNER = new int[] {0,0};
+
+	static final int[] TOP_LEFT_CORNER_BORDERLESS = new int[] {0,6, 1,5, 1,4, 4,1, 5,1, 6,0};
+	static final int[] TOP_RIGHT_CORNER_BORDERLESS = new int[] {-7,0, -6,1, -5,1, -2,4, -2,5, -1,6};
+	static final int[] BOTTOM_LEFT_CORNER_BORDERLESS = new int[] {0,-6, 1,-6, 1,-5, 2,-4, 4,-2, 5,-1, 6,-1, 6,0};
+	static final int[] BOTTOM_RIGHT_CORNER_BORDERLESS = new int[] {-7,0, -7,-1, -6,-1, -5,-2, -3,-4, -2,-5, -2,-6, -1,-6};
+
+	static final int[] SIMPLE_TOP_LEFT_CORNER_BORDERLESS = new int[] {0,2, 1,1, 2,0};
+	static final int[] SIMPLE_TOP_RIGHT_CORNER_BORDERLESS= new int[] {-3,0, -2,1, -1,2};
+	static final int[] SIMPLE_BOTTOM_LEFT_CORNER_BORDERLESS = new int[] {0,-3, 1,-2, 2,-1, 3,0};
+	static final int[] SIMPLE_BOTTOM_RIGHT_CORNER_BORDERLESS = new int[] {-4,0, -3,-1, -2,-2, -1,-3};
+
+	static final int SELECTION_FOREGROUND = SWT.COLOR_LIST_FOREGROUND;
+	static final int SELECTION_BACKGROUND = SWT.COLOR_LIST_BACKGROUND;
+	static final int BORDER1_COLOR = SWT.COLOR_WIDGET_NORMAL_SHADOW;
+	static final int FOREGROUND = SWT.COLOR_WIDGET_FOREGROUND;
+	static final int BACKGROUND = SWT.COLOR_WIDGET_BACKGROUND;
+	static final int BUTTON_BORDER = SWT.COLOR_WIDGET_DARK_SHADOW;
+	static final int BUTTON_FILL = SWT.COLOR_LIST_BACKGROUND;
+	
+	static final int NONE = 0;
+	static final int NORMAL = 1;
+	static final int HOT = 2;
+	static final int SELECTED = 3;
+	static final RGB CLOSE_FILL = new RGB(252, 160, 160);
+	
+	static final int CHEVRON_CHILD_ID = 0;
+	static final int MINIMIZE_CHILD_ID = 1;
+	static final int MAXIMIZE_CHILD_ID = 2;
+	static final int EXTRA_CHILD_ID_COUNT = 3;
+	
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a widget which will be the parent of the new instance (cannot be null)
+ * @param style the style of widget to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * </ul>
+ *
+ * @see SWT#TOP
+ * @see SWT#BOTTOM
+ * @see SWT#FLAT
+ * @see SWT#BORDER
+ * @see SWT#SINGLE
+ * @see SWT#MULTI
+ * @see #getStyle()
+ */
+public CTabFolder(Composite parent, int style) {
+	super(parent, checkStyle (parent, style));
+	super.setLayout(new CTabFolderLayout());
+	int style2 = super.getStyle();
+	oldFont = getFont();
+	onBottom = (style2 & SWT.BOTTOM) != 0;
+	showClose = (style2 & SWT.CLOSE) != 0;
+//	showMin = (style2 & SWT.MIN) != 0; - conflicts with SWT.TOP
+//	showMax = (style2 & SWT.MAX) != 0; - conflicts with SWT.BOTTOM
+	single = (style2 & SWT.SINGLE) != 0;
+	borderLeft = borderRight = (style & SWT.BORDER) != 0 ? 1 : 0;
+	borderTop = onBottom ? borderLeft : 0;
+	borderBottom = onBottom ? 0 : borderLeft;
+	highlight_header = (style & SWT.FLAT) != 0 ? 1 : 3;
+	highlight_margin = (style & SWT.FLAT) != 0 ? 0 : 2;
+	//set up default colors
+	Display display = getDisplay();
+	selectionForeground = display.getSystemColor(SELECTION_FOREGROUND);
+	selectionBackground = display.getSystemColor(SELECTION_BACKGROUND);
+	borderColor = display.getSystemColor(BORDER1_COLOR);
+	updateTabHeight(false);
+	
+	initAccessible();
+	
+	// Add all listeners
+	listener = new Listener() {
+		public void handleEvent(Event event) {
+			switch (event.type) {
+				case SWT.Dispose:          onDispose(event); break;
+				case SWT.DragDetect:       onDragDetect(event); break;
+				case SWT.FocusIn:          onFocus(event);	break;
+				case SWT.FocusOut:         onFocus(event);	break;
+				case SWT.KeyDown:          onKeyDown(event); break;
+				case SWT.MouseDoubleClick: onMouseDoubleClick(event); break;
+				case SWT.MouseDown:        onMouse(event);	break;
+				case SWT.MouseEnter:       onMouse(event);	break;
+				case SWT.MouseExit:        onMouse(event);	break;
+				case SWT.MouseMove:        onMouse(event); break;
+				case SWT.MouseUp:          onMouse(event); break;
+				case SWT.Paint:            onPaint(event);	break;
+				case SWT.Resize:           onResize();	break;
+				case SWT.Traverse:         onTraverse(event); break;
+			}
+		}
+	};
+
+	int[] folderEvents = new int[]{
+		SWT.Dispose,
+		SWT.DragDetect,
+		SWT.FocusIn, 
+		SWT.FocusOut, 
+		SWT.KeyDown,
+		SWT.MouseDoubleClick, 
+		SWT.MouseDown,
+		SWT.MouseEnter, 
+		SWT.MouseExit, 
+		SWT.MouseMove,
+		SWT.MouseUp,
+		SWT.Paint,
+		SWT.Resize,  
+		SWT.Traverse,
+	};
+	for (int i = 0; i < folderEvents.length; i++) {
+		addListener(folderEvents[i], listener);
+	}
+}
+static int checkStyle (Composite parent, int style) {
+	int mask = SWT.CLOSE | SWT.TOP | SWT.BOTTOM | SWT.FLAT | SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT | SWT.SINGLE | SWT.MULTI;
+	style = style & mask;
+	// TOP and BOTTOM are mutually exclusive.
+	// TOP is the default
+	if ((style & SWT.TOP) != 0) style = style & ~SWT.BOTTOM;
+	// SINGLE and MULTI are mutually exclusive.
+	// MULTI is the default
+	if ((style & SWT.MULTI) != 0) style = style & ~SWT.SINGLE;
+	// reduce the flash by not redrawing the entire area on a Resize event
+	style |= SWT.NO_REDRAW_RESIZE;
+	//TEMPORARY CODE
+	/*
+	 * The default background on carbon and some GTK themes is not a solid color 
+	 * but a texture.  To show the correct default background, we must allow
+	 * the operating system to draw it and therefore, we can not use the 
+	 * NO_BACKGROUND style.  The NO_BACKGROUND style is not required on platforms
+	 * that use double buffering which is true in both of these cases.
+	 */
+	String platform = SWT.getPlatform();
+	if ("carbon".equals(platform) || "gtk".equals(platform)) return style; //$NON-NLS-1$ //$NON-NLS-2$
+	
+	//TEMPORARY CODE
+	/*
+	 * In Right To Left orientation on Windows, all GC calls that use a brush are drawing 
+	 * offset by one pixel.  This results in some parts of the CTabFolder not drawing correctly.
+	 * To alleviate some of the appearance problems, allow the OS to draw the background.
+	 * This does not draw correctly but the result is less obviously wrong.
+	 */
+	if ((style & SWT.RIGHT_TO_LEFT) != 0) return style;
+	if ((parent.getStyle() & SWT.MIRRORED) != 0 && (style & SWT.LEFT_TO_RIGHT) == 0) return style;
+	
+	return style | SWT.NO_BACKGROUND;
+}
+static void fillRegion(GC gc, Region region) {
+	// NOTE: region passed in to this function will be modified
+	Region clipping = new Region();
+	gc.getClipping(clipping);
+	region.intersect(clipping);
+	gc.setClipping(region);
+	gc.fillRectangle(region.getBounds());
+	gc.setClipping(clipping);
+	clipping.dispose();
+}
+/**
+ * 
+ * Adds the listener to the collection of listeners who will
+ * be notified when a tab item is closed, minimized, maximized,
+ * restored, or to show the list of items that are not 
+ * currently visible.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+ *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+ * </ul>
+ *
+ * @see CTabFolder2Listener
+ * @see #removeCTabFolder2Listener(CTabFolder2Listener)
+ * 
+ * @since 3.0
+ */
+public void addCTabFolder2Listener(CTabFolder2Listener listener) {
+	checkWidget();
+	if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+	// add to array
+	CTabFolder2Listener[] newListeners = new CTabFolder2Listener[folderListeners.length + 1];
+	System.arraycopy(folderListeners, 0, newListeners, 0, folderListeners.length);
+	folderListeners = newListeners;
+	folderListeners[folderListeners.length - 1] = listener;
+}
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when a tab item is closed.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+ *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+ * </ul>
+ *
+ * @see CTabFolderListener
+ * @see #removeCTabFolderListener(CTabFolderListener)
+ * 
+ * @deprecated use addCTabFolder2Listener(CTabFolder2Listener)
+ */
+public void addCTabFolderListener(CTabFolderListener listener) {
+	checkWidget();
+	if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+	// add to array
+	CTabFolderListener[] newTabListeners = new CTabFolderListener[tabListeners.length + 1];
+	System.arraycopy(tabListeners, 0, newTabListeners, 0, tabListeners.length);
+	tabListeners = newTabListeners;
+	tabListeners[tabListeners.length - 1] = listener;
+	// display close button to be backwards compatible
+	if (!showClose) {
+		showClose = true;
+		updateItems();
+		redraw();
+	}
+}
+/**	 
+ * Adds the listener to the collection of listeners who will
+ * be notified when the user changes the receiver's selection, by sending
+ * it one of the messages defined in the <code>SelectionListener</code>
+ * interface.
+ * <p>
+ * <code>widgetSelected</code> is called when the user changes the selected tab.
+ * <code>widgetDefaultSelected</code> is not called.
+ * </p>
+ *
+ * @param listener the listener which should be notified when the user changes the receiver's selection
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent
+ */
+public void addSelectionListener(SelectionListener listener) {
+	checkWidget();
+	if (listener == null) {
+		SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	}
+	TypedListener typedListener = new TypedListener(listener);
+	addListener(SWT.Selection, typedListener);
+	addListener(SWT.DefaultSelection, typedListener);
+}
+void antialias (int[] shape, RGB lineRGB, RGB innerRGB, RGB outerRGB, GC gc){
+	// Don't perform anti-aliasing on Mac and WPF because the platform
+	// already does it.  The simple style also does not require anti-aliasing.
+	if (simple || "carbon".equals(SWT.getPlatform()) || "wpf".equals(SWT.getPlatform())) return; //$NON-NLS-1$
+	// Don't perform anti-aliasing on low resolution displays
+	if (getDisplay().getDepth() < 15) return;
+	if (outerRGB != null) {
+		int index = 0;
+		boolean left = true;
+		int oldY = onBottom ? 0 : getSize().y;
+		int[] outer = new int[shape.length];
+		for (int i = 0; i < shape.length/2; i++) {
+			if (left && (index + 3 < shape.length)) {
+				left = onBottom ? oldY <= shape[index+3] : oldY >= shape[index+3];
+				oldY = shape[index+1];
+			}
+			outer[index] = shape[index++] + (left ? -1 : +1);
+			outer[index] = shape[index++];
+		}
+		RGB from = lineRGB;
+		RGB to = outerRGB;
+		int red = from.red + 2*(to.red - from.red)/3;
+		int green = from.green + 2*(to.green - from.green)/3;
+		int blue = from.blue + 2*(to.blue - from.blue)/3;
+		Color color = new Color(getDisplay(), red, green, blue);
+		gc.setForeground(color);
+		gc.drawPolyline(outer);
+		color.dispose();
+	}
+	if (innerRGB != null) {
+		int[] inner = new int[shape.length];
+		int index = 0;
+		boolean left = true;
+		int oldY = onBottom ? 0 : getSize().y;
+		for (int i = 0; i < shape.length/2; i++) {
+			if (left && (index + 3 < shape.length)) {
+				left = onBottom ? oldY <= shape[index+3] : oldY >= shape[index+3];
+				oldY = shape[index+1];
+			}
+			inner[index] = shape[index++] + (left ? +1 : -1);
+			inner[index] = shape[index++];
+		}
+		RGB from = lineRGB;
+		RGB to = innerRGB;
+		int red = from.red + 2*(to.red - from.red)/3;
+		int green = from.green + 2*(to.green - from.green)/3;
+		int blue = from.blue + 2*(to.blue - from.blue)/3;
+		Color color = new Color(getDisplay(), red, green, blue);
+		gc.setForeground(color);
+		gc.drawPolyline(inner);
+		color.dispose();
+	}
+}
+public Rectangle computeTrim (int x, int y, int width, int height) {
+	checkWidget();
+	int trimX = x - marginWidth - highlight_margin - borderLeft;
+	int trimWidth = width + borderLeft + borderRight + 2*marginWidth + 2*highlight_margin;
+	if (minimized) {
+		int trimY = onBottom ? y - borderTop : y - highlight_header - tabHeight - borderTop;
+		int trimHeight = borderTop + borderBottom + tabHeight + highlight_header;
+		return new Rectangle (trimX, trimY, trimWidth, trimHeight);
+	} else {
+		int trimY = onBottom ? y - marginHeight - highlight_margin - borderTop: y - marginHeight - highlight_header - tabHeight - borderTop;
+		int trimHeight = height + borderTop + borderBottom + 2*marginHeight + tabHeight + highlight_header + highlight_margin;
+		return new Rectangle (trimX, trimY, trimWidth, trimHeight);
+	}
+}
+void createItem (CTabItem item, int index) {
+	if (0 > index || index > getItemCount ())SWT.error (SWT.ERROR_INVALID_RANGE);
+	item.parent = this;
+	CTabItem[] newItems = new CTabItem [items.length + 1];
+	System.arraycopy(items, 0, newItems, 0, index);
+	newItems[index] = item;
+	System.arraycopy(items, index, newItems, index + 1, items.length - index);
+	items = newItems;
+	if (selectedIndex >= index) selectedIndex ++;	
+	int[] newPriority = new int[priority.length + 1];
+	int next = 0,  priorityIndex = priority.length;
+	for (int i = 0; i < priority.length; i++) {
+		if (!mru && priority[i] == index) {
+			priorityIndex = next++;
+		}
+		newPriority[next++] = priority[i] >= index ? priority[i] + 1 : priority[i];
+	}
+	newPriority[priorityIndex] = index;
+	priority = newPriority;
+	
+	if (items.length == 1) {
+		if (!updateTabHeight(false)) updateItems();
+		redraw();
+	} else {
+		updateItems();
+		redrawTabs();
+	}
+}
+void destroyItem (CTabItem item) {
+	if (inDispose) return;
+	int index = indexOf(item);
+	if (index == -1) return;
+	
+	if (items.length == 1) {
+		items = new CTabItem[0];
+		priority = new int[0];
+		firstIndex = -1;
+		selectedIndex = -1;
+		
+		Control control = item.getControl();
+		if (control != null && !control.isDisposed()) {
+			control.setVisible(false);
+		}
+		setToolTipText(null);
+		setButtonBounds();
+		redraw();
+		return;
+	} 
+		
+	CTabItem[] newItems = new CTabItem [items.length - 1];
+	System.arraycopy(items, 0, newItems, 0, index);
+	System.arraycopy(items, index + 1, newItems, index, items.length - index - 1);
+	items = newItems;
+	
+	int[] newPriority = new int[priority.length - 1];
+	int next = 0;
+	for (int i = 0; i < priority.length; i++) {
+		if (priority [i] == index) continue; 
+		newPriority[next++] = priority[i] > index ? priority[i] - 1 : priority [i];
+	}
+	priority = newPriority;
+	
+	// move the selection if this item is selected
+	if (selectedIndex == index) {
+		Control control = item.getControl();
+		selectedIndex = -1;
+		int nextSelection = mru ? priority[0] : Math.max(0, index - 1);
+		setSelection(nextSelection, true);
+		if (control != null && !control.isDisposed()) {
+			control.setVisible(false);
+		}
+	} else if (selectedIndex > index) {
+		selectedIndex --;
+	}
+	
+	updateItems();
+	redrawTabs();
+}
+void drawBackground(GC gc, int[] shape, boolean selected) {
+	Color defaultBackground = selected ? selectionBackground : getBackground();
+	Image image = selected ? selectionBgImage : bgImage;
+	Color[] colors = selected ? selectionGradientColors : gradientColors;
+	int[] percents = selected ? selectionGradientPercents : gradientPercents;
+	boolean vertical = selected ? selectionGradientVertical : gradientVertical; 
+	Point size = getSize();
+	int width = size.x;
+	int height = tabHeight + highlight_header;
+	int x = 0;
+	if (borderLeft > 0) {
+		x += 1; width -= 2;
+	}
+	int y = onBottom ? size.y - borderBottom - height : borderTop;
+	drawBackground(gc, shape, x, y, width, height, defaultBackground, image, colors, percents, vertical);
+}
+void drawBackground(GC gc, int[] shape, int x, int y, int width, int height, Color defaultBackground, Image image, Color[] colors, int[] percents, boolean vertical) {
+	Region clipping = new Region();
+	gc.getClipping(clipping);
+	Region region = new Region();
+	region.add(shape);
+	region.intersect(clipping);
+	gc.setClipping(region);
+	
+	if (image != null) {
+		// draw the background image in shape
+		gc.setBackground(defaultBackground);
+		gc.fillRectangle(x, y, width, height);
+		Rectangle imageRect = image.getBounds();
+		gc.drawImage(image, imageRect.x, imageRect.y, imageRect.width, imageRect.height, x, y, width, height);
+	} else if (colors != null) {
+		// draw gradient
+		if (colors.length == 1) {
+			Color background = colors[0] != null ? colors[0] : defaultBackground;
+			gc.setBackground(background);
+			gc.fillRectangle(x, y, width, height);
+		} else {
+			if (vertical) {
+				if (onBottom) {
+					int pos = 0;
+					if (percents[percents.length - 1] < 100) {
+						pos = percents[percents.length - 1] * height / 100;
+						gc.setBackground(defaultBackground);
+						gc.fillRectangle(x, y, width, pos);
+					}
+					Color lastColor = colors[colors.length-1];
+					if (lastColor == null) lastColor = defaultBackground;
+					for (int i = percents.length-1; i >= 0; i--) {
+						gc.setForeground(lastColor);
+						lastColor = colors[i];
+						if (lastColor == null) lastColor = defaultBackground;
+						gc.setBackground(lastColor);
+						int gradientHeight = percents[i] * height / 100;
+						gc.fillGradientRectangle(x, y+pos, width, gradientHeight, true);
+						pos += gradientHeight;
+					}
+				} else {
+					Color lastColor = colors[0];
+					if (lastColor == null) lastColor = defaultBackground;
+					int pos = 0;
+					for (int i = 0; i < percents.length; i++) {
+						gc.setForeground(lastColor);
+						lastColor = colors[i + 1];
+						if (lastColor == null) lastColor = defaultBackground;
+						gc.setBackground(lastColor);
+						int gradientHeight = percents[i] * height / 100;
+						gc.fillGradientRectangle(x, y+pos, width, gradientHeight, true);
+						pos += gradientHeight;
+					}
+					if (pos < height) {
+						gc.setBackground(defaultBackground);
+						gc.fillRectangle(x, pos, width, height-pos+1);
+					}
+				}
+			} else { //horizontal gradient
+				y = 0;
+				height = getSize().y;
+				Color lastColor = colors[0];
+				if (lastColor == null) lastColor = defaultBackground;
+				int pos = 0;
+				for (int i = 0; i < percents.length; ++i) {
+					gc.setForeground(lastColor);
+					lastColor = colors[i + 1];
+					if (lastColor == null) lastColor = defaultBackground;
+					gc.setBackground(lastColor);
+					int gradientWidth = (percents[i] * width / 100) - pos;
+					gc.fillGradientRectangle(x+pos, y, gradientWidth, height, false);
+					pos += gradientWidth;
+				}
+				if (pos < width) {
+					gc.setBackground(defaultBackground);
+					gc.fillRectangle(x+pos, y, width-pos, height);
+				}
+			}
+		}
+	} else {
+		// draw a solid background using default background in shape
+		if ((getStyle() & SWT.NO_BACKGROUND) != 0 || !defaultBackground.equals(getBackground())) {
+			gc.setBackground(defaultBackground);
+			gc.fillRectangle(x, y, width, height);
+		}
+	}
+	gc.setClipping(clipping);
+	clipping.dispose();
+	region.dispose();
+}
+void drawBody(Event event) {
+	GC gc = event.gc;
+	Point size = getSize();
+	
+	// fill in body
+	if (!minimized){
+		int width = size.x  - borderLeft - borderRight - 2*highlight_margin;
+		int height = size.y - borderTop - borderBottom - tabHeight - highlight_header - highlight_margin;
+		// Draw highlight margin
+		if (highlight_margin > 0) {
+			int[] shape = null;
+			if (onBottom) {
+				int x1 = borderLeft;
+				int y1 = borderTop;
+				int x2 = size.x - borderRight;
+				int y2 = size.y - borderBottom - tabHeight - highlight_header;
+				shape = new int[] {x1,y1, x2,y1, x2,y2, x2-highlight_margin,y2,
+						           x2-highlight_margin, y1+highlight_margin, x1+highlight_margin,y1+highlight_margin,
+								   x1+highlight_margin,y2, x1,y2};
+			} else {	
+				int x1 = borderLeft;
+				int y1 = borderTop + tabHeight + highlight_header;
+				int x2 = size.x - borderRight;
+				int y2 = size.y - borderBottom;
+				shape = new int[] {x1,y1, x1+highlight_margin,y1, x1+highlight_margin,y2-highlight_margin, 
+						           x2-highlight_margin,y2-highlight_margin, x2-highlight_margin,y1,
+								   x2,y1, x2,y2, x1,y2};
+			}
+			// If horizontal gradient, show gradient across the whole area
+			if (selectedIndex != -1 && selectionGradientColors != null && selectionGradientColors.length > 1 && !selectionGradientVertical) {
+				drawBackground(gc, shape, true);
+			} else if (selectedIndex == -1 && gradientColors != null && gradientColors.length > 1 && !gradientVertical) {
+				drawBackground(gc, shape, false);
+			} else {
+				gc.setBackground(selectedIndex == -1 ? getBackground() : selectionBackground);
+				gc.fillPolygon(shape);
+			}
+		}
+		//Draw client area
+		if ((getStyle() & SWT.NO_BACKGROUND) != 0) {
+			gc.setBackground(getBackground());
+			gc.fillRectangle(xClient - marginWidth, yClient - marginHeight, width, height);
+		}
+	} else {
+		if ((getStyle() & SWT.NO_BACKGROUND) != 0) {
+			int height = borderTop + tabHeight + highlight_header + borderBottom;
+			if (size.y > height) {
+				gc.setBackground(getParent().getBackground());
+				gc.fillRectangle(0, height, size.x, size.y - height);
+			}
+		}
+	}
+	
+	//draw 1 pixel border around outside
+	if (borderLeft > 0) {
+		gc.setForeground(borderColor);
+		int x1 = borderLeft - 1;
+		int x2 = size.x - borderRight;
+		int y1 = onBottom ? borderTop - 1 : borderTop + tabHeight;
+		int y2 = onBottom ? size.y - tabHeight - borderBottom - 1 : size.y - borderBottom;
+		gc.drawLine(x1, y1, x1, y2); // left
+		gc.drawLine(x2, y1, x2, y2); // right
+		if (onBottom) {
+			gc.drawLine(x1, y1, x2, y1); // top
+		} else {
+			gc.drawLine(x1, y2, x2, y2); // bottom
+		}
+	}
+}
+
+void drawChevron(GC gc) {
+	if (chevronRect.width == 0 || chevronRect.height == 0) return;
+	// draw chevron (10x7)
+	Display display = getDisplay();
+	Point dpi = display.getDPI();
+	int fontHeight = 72 * 10 / dpi.y;
+	FontData fd = getFont().getFontData()[0];
+	fd.setHeight(fontHeight);
+	Font f = new Font(display, fd);
+	int fHeight = f.getFontData()[0].getHeight() * dpi.y / 72;
+	int indent = Math.max(2, (chevronRect.height - fHeight - 4) /2);
+	int x = chevronRect.x + 2;
+	int y = chevronRect.y + indent;
+	int count;
+	if (single) {
+		count = selectedIndex == -1 ? items.length : items.length - 1;
+	} else {
+		int showCount = 0;
+		while (showCount < priority.length && items[priority[showCount]].showing) {
+			showCount++;
+		}
+		count = items.length - showCount;
+	}
+	String chevronString = count > 99 ? "99+" : String.valueOf(count); //$NON-NLS-1$
+	switch (chevronImageState) {
+		case NORMAL: {
+			Color chevronBorder = single ? getSelectionForeground() : getForeground();
+			gc.setForeground(chevronBorder);
+			gc.setFont(f);
+			gc.drawLine(x,y,     x+2,y+2);
+			gc.drawLine(x+2,y+2, x,y+4);
+			gc.drawLine(x+1,y,   x+3,y+2);
+			gc.drawLine(x+3,y+2, x+1,y+4);
+			gc.drawLine(x+4,y,   x+6,y+2);
+			gc.drawLine(x+6,y+2, x+5,y+4);
+			gc.drawLine(x+5,y,   x+7,y+2);
+			gc.drawLine(x+7,y+2, x+4,y+4);
+			gc.drawString(chevronString, x+7, y+3, true);
+			break;
+		}
+		case HOT: {
+			gc.setForeground(display.getSystemColor(BUTTON_BORDER));
+			gc.setBackground(display.getSystemColor(BUTTON_FILL));
+			gc.setFont(f);
+			gc.fillRoundRectangle(chevronRect.x, chevronRect.y, chevronRect.width, chevronRect.height, 6, 6);
+			gc.drawRoundRectangle(chevronRect.x, chevronRect.y, chevronRect.width - 1, chevronRect.height - 1, 6, 6);
+			gc.drawLine(x,y,     x+2,y+2);
+			gc.drawLine(x+2,y+2, x,y+4);
+			gc.drawLine(x+1,y,   x+3,y+2);
+			gc.drawLine(x+3,y+2, x+1,y+4);
+			gc.drawLine(x+4,y,   x+6,y+2);
+			gc.drawLine(x+6,y+2, x+5,y+4);
+			gc.drawLine(x+5,y,   x+7,y+2);
+			gc.drawLine(x+7,y+2, x+4,y+4);
+			gc.drawString(chevronString, x+7, y+3, true);
+			break;
+		}
+		case SELECTED: {
+			gc.setForeground(display.getSystemColor(BUTTON_BORDER));
+			gc.setBackground(display.getSystemColor(BUTTON_FILL));
+			gc.setFont(f);
+			gc.fillRoundRectangle(chevronRect.x, chevronRect.y, chevronRect.width, chevronRect.height, 6, 6);
+			gc.drawRoundRectangle(chevronRect.x, chevronRect.y, chevronRect.width - 1, chevronRect.height - 1, 6, 6);
+			gc.drawLine(x+1,y+1, x+3,y+3);
+			gc.drawLine(x+3,y+3, x+1,y+5);
+			gc.drawLine(x+2,y+1, x+4,y+3);
+			gc.drawLine(x+4,y+3, x+2,y+5);
+			gc.drawLine(x+5,y+1, x+7,y+3);
+			gc.drawLine(x+7,y+3, x+6,y+5);
+			gc.drawLine(x+6,y+1, x+8,y+3);
+			gc.drawLine(x+8,y+3, x+5,y+5);
+			gc.drawString(chevronString, x+8, y+4, true);
+			break;
+		}
+	}
+	f.dispose();
+}
+void drawMaximize(GC gc) {
+	if (maxRect.width == 0 || maxRect.height == 0) return;
+	Display display = getDisplay();
+	// 5x4 or 7x9
+	int x = maxRect.x + (CTabFolder.BUTTON_SIZE - 10)/2;
+	int y = maxRect.y + 3;
+	
+	gc.setForeground(display.getSystemColor(BUTTON_BORDER));
+	gc.setBackground(display.getSystemColor(BUTTON_FILL));
+	
+	switch (maxImageState) {
+		case NORMAL: {
+			if (!maximized) {
+				gc.fillRectangle(x, y, 9, 9);
+				gc.drawRectangle(x, y, 9, 9);
+				gc.drawLine(x+1, y+2, x+8, y+2);				
+			} else {
+				gc.fillRectangle(x, y+3, 5, 4);
+				gc.fillRectangle(x+2, y, 5, 4);
+				gc.drawRectangle(x, y+3, 5, 4);
+				gc.drawRectangle(x+2, y, 5, 4);
+				gc.drawLine(x+3, y+1, x+6, y+1);
+				gc.drawLine(x+1, y+4, x+4, y+4);
+			}
+			break;
+		}
+		case HOT: {
+			gc.fillRoundRectangle(maxRect.x, maxRect.y, maxRect.width, maxRect.height, 6, 6);
+			gc.drawRoundRectangle(maxRect.x, maxRect.y, maxRect.width - 1, maxRect.height - 1, 6, 6);
+			if (!maximized) {
+				gc.fillRectangle(x, y, 9, 9);
+				gc.drawRectangle(x, y, 9, 9);
+				gc.drawLine(x+1, y+2, x+8, y+2);
+			} else {
+				gc.fillRectangle(x, y+3, 5, 4);
+				gc.fillRectangle(x+2, y, 5, 4);
+				gc.drawRectangle(x, y+3, 5, 4);
+				gc.drawRectangle(x+2, y, 5, 4);
+				gc.drawLine(x+3, y+1, x+6, y+1);
+				gc.drawLine(x+1, y+4, x+4, y+4);
+			}
+			break;
+		}
+		case SELECTED: {
+			gc.fillRoundRectangle(maxRect.x, maxRect.y, maxRect.width, maxRect.height, 6, 6);
+			gc.drawRoundRectangle(maxRect.x, maxRect.y, maxRect.width - 1, maxRect.height - 1, 6, 6);
+			if (!maximized) {
+				gc.fillRectangle(x+1, y+1, 9, 9);
+				gc.drawRectangle(x+1, y+1, 9, 9);
+				gc.drawLine(x+2, y+3, x+9, y+3);
+			} else {
+				gc.fillRectangle(x+1, y+4, 5, 4);
+				gc.fillRectangle(x+3, y+1, 5, 4);
+				gc.drawRectangle(x+1, y+4, 5, 4);
+				gc.drawRectangle(x+3, y+1, 5, 4);
+				gc.drawLine(x+4, y+2, x+7, y+2);
+				gc.drawLine(x+2, y+5, x+5, y+5);
+			}
+			break;
+		}
+	}
+}
+void drawMinimize(GC gc) {
+	if (minRect.width == 0 || minRect.height == 0) return;
+	Display display = getDisplay();
+	// 5x4 or 9x3
+	int x = minRect.x + (BUTTON_SIZE - 10)/2;
+	int y = minRect.y + 3;
+	
+	gc.setForeground(display.getSystemColor(BUTTON_BORDER));
+	gc.setBackground(display.getSystemColor(BUTTON_FILL));
+	
+	switch (minImageState) {
+		case NORMAL: {
+			if (!minimized) {
+				gc.fillRectangle(x, y, 9, 3);
+				gc.drawRectangle(x, y, 9, 3);
+			} else {
+				gc.fillRectangle(x, y+3, 5, 4);
+				gc.fillRectangle(x+2, y, 5, 4);
+				gc.drawRectangle(x, y+3, 5, 4);
+				gc.drawRectangle(x+2, y, 5, 4);
+				gc.drawLine(x+3, y+1, x+6, y+1);
+				gc.drawLine(x+1, y+4, x+4, y+4);
+			}
+			break;
+		}
+		case HOT: {
+			gc.fillRoundRectangle(minRect.x, minRect.y, minRect.width, minRect.height, 6, 6);
+			gc.drawRoundRectangle(minRect.x, minRect.y, minRect.width - 1, minRect.height - 1, 6, 6);
+			if (!minimized) {
+				gc.fillRectangle(x, y, 9, 3);
+				gc.drawRectangle(x, y, 9, 3);
+			} else {
+				gc.fillRectangle(x, y+3, 5, 4);
+				gc.fillRectangle(x+2, y, 5, 4);
+				gc.drawRectangle(x, y+3, 5, 4);
+				gc.drawRectangle(x+2, y, 5, 4);
+				gc.drawLine(x+3, y+1, x+6, y+1);
+				gc.drawLine(x+1, y+4, x+4, y+4);
+			}
+			break;
+		}
+		case SELECTED: {
+			gc.fillRoundRectangle(minRect.x, minRect.y, minRect.width, minRect.height, 6, 6);
+			gc.drawRoundRectangle(minRect.x, minRect.y, minRect.width - 1, minRect.height - 1, 6, 6);
+			if (!minimized) {
+				gc.fillRectangle(x+1, y+1, 9, 3);
+				gc.drawRectangle(x+1, y+1, 9, 3);
+			} else {
+				gc.fillRectangle(x+1, y+4, 5, 4);
+				gc.fillRectangle(x+3, y+1, 5, 4);
+				gc.drawRectangle(x+1, y+4, 5, 4);
+				gc.drawRectangle(x+3, y+1, 5, 4);
+				gc.drawLine(x+4, y+2, x+7, y+2);
+				gc.drawLine(x+2, y+5, x+5, y+5);
+			}
+			break;
+		}
+	}
+}
+void drawTabArea(Event event) {
+	GC gc = event.gc;
+	Point size = getSize();
+	int[] shape = null;
+	
+	if (tabHeight == 0) {
+		int style = getStyle();
+		if ((style & SWT.FLAT) != 0 && (style & SWT.BORDER) == 0) return;
+		int x1 = borderLeft - 1;
+		int x2 = size.x - borderRight;
+		int y1 = onBottom ? size.y - borderBottom - highlight_header - 1 : borderTop + highlight_header;
+		int y2 = onBottom ? size.y - borderBottom : borderTop;
+		if (borderLeft > 0 && onBottom) y2 -= 1;
+		
+		shape = new int[] {x1, y1, x1,y2, x2,y2, x2,y1};
+
+		// If horizontal gradient, show gradient across the whole area
+		if (selectedIndex != -1 && selectionGradientColors != null && selectionGradientColors.length > 1 && !selectionGradientVertical) {
+			drawBackground(gc, shape, true);
+		} else if (selectedIndex == -1 && gradientColors != null && gradientColors.length > 1 && !gradientVertical) {
+			drawBackground(gc, shape, false);
+		} else {
+			gc.setBackground(selectedIndex == -1 ? getBackground() : selectionBackground);
+			gc.fillPolygon(shape);
+		}
+		
+		//draw 1 pixel border
+		if (borderLeft > 0) {
+			gc.setForeground(borderColor);
+			gc.drawPolyline(shape); 
+		}
+		return;
+	}
+	
+	int x = Math.max(0, borderLeft - 1);
+	int y = onBottom ? size.y - borderBottom - tabHeight : borderTop;
+	int width = size.x - borderLeft - borderRight + 1;
+	int height = tabHeight - 1;
+	
+	// Draw Tab Header
+	if (onBottom) {
+		int[] left, right;
+		if ((getStyle() & SWT.BORDER) != 0) {
+			left = simple ? SIMPLE_BOTTOM_LEFT_CORNER : BOTTOM_LEFT_CORNER;
+			right = simple ? SIMPLE_BOTTOM_RIGHT_CORNER : BOTTOM_RIGHT_CORNER;
+		} else {
+			left = simple ? SIMPLE_BOTTOM_LEFT_CORNER_BORDERLESS : BOTTOM_LEFT_CORNER_BORDERLESS;
+			right = simple ? SIMPLE_BOTTOM_RIGHT_CORNER_BORDERLESS : BOTTOM_RIGHT_CORNER_BORDERLESS;
+		}
+		shape = new int[left.length + right.length + 4];
+		int index = 0;
+		shape[index++] = x;
+		shape[index++] = y-highlight_header;
+		for (int i = 0; i < left.length/2; i++) {
+			shape[index++] = x+left[2*i];
+			shape[index++] = y+height+left[2*i+1];
+			if (borderLeft == 0) shape[index-1] += 1;
+		}
+		for (int i = 0; i < right.length/2; i++) {
+			shape[index++] = x+width+right[2*i];
+			shape[index++] = y+height+right[2*i+1];
+			if (borderLeft == 0) shape[index-1] += 1;
+		}
+		shape[index++] = x+width;
+		shape[index++] = y-highlight_header;
+	} else {
+		int[] left, right;
+		if ((getStyle() & SWT.BORDER) != 0) {
+			left = simple ? SIMPLE_TOP_LEFT_CORNER : TOP_LEFT_CORNER;
+			right = simple ? SIMPLE_TOP_RIGHT_CORNER : TOP_RIGHT_CORNER;
+		} else {
+			left = simple ? SIMPLE_TOP_LEFT_CORNER_BORDERLESS : TOP_LEFT_CORNER_BORDERLESS;
+			right = simple ? SIMPLE_TOP_RIGHT_CORNER_BORDERLESS : TOP_RIGHT_CORNER_BORDERLESS;
+		}
+		shape = new int[left.length + right.length + 4];
+		int index = 0;
+		shape[index++] = x;
+		shape[index++] = y+height+highlight_header + 1;
+		for (int i = 0; i < left.length/2; i++) {
+			shape[index++] = x+left[2*i];
+			shape[index++] = y+left[2*i+1];
+		}
+		for (int i = 0; i < right.length/2; i++) {
+			shape[index++] = x+width+right[2*i];
+			shape[index++] = y+right[2*i+1];
+		}
+		shape[index++] = x+width;
+		shape[index++] = y+height+highlight_header + 1;
+	}
+	// Fill in background
+	boolean bkSelected = single && selectedIndex != -1;
+	drawBackground(gc, shape, bkSelected);
+	// Fill in parent background for non-rectangular shape
+	Region r = new Region();
+	r.add(new Rectangle(x, y, width + 1, height + 1));
+	r.subtract(shape);
+	gc.setBackground(getParent().getBackground());
+	fillRegion(gc, r);
+	r.dispose();
+	
+	// Draw the unselected tabs.
+	if (!single) {
+		for (int i=0; i < items.length; i++) {
+			if (i != selectedIndex && event.getBounds().intersects(items[i].getBounds())) {
+				items[i].onPaint(gc, false);
+			}
+		}
+	}
+	
+	// Draw selected tab
+	if (selectedIndex != -1) {
+		CTabItem item = items[selectedIndex];
+		item.onPaint(gc, true);
+	} else {
+		// if no selected tab - draw line across bottom of all tabs
+		int x1 = borderLeft;
+		int y1 = (onBottom) ? size.y - borderBottom - tabHeight - 1 : borderTop + tabHeight;
+		int x2 = size.x - borderRight;
+		gc.setForeground(borderColor);
+		gc.drawLine(x1, y1, x2, y1);
+	}
+	
+	// Draw Buttons
+	drawChevron(gc);
+	drawMinimize(gc);
+	drawMaximize(gc);
+	
+	// Draw border line
+	if (borderLeft > 0) {
+		RGB outside = getParent().getBackground().getRGB();
+		antialias(shape, borderColor.getRGB(), null, outside, gc);
+		gc.setForeground(borderColor);
+		gc.drawPolyline(shape);
+	}	
+}
+/**
+ * Returns <code>true</code> if the receiver's border is visible.
+ *
+ * @return the receiver's border visibility state
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.0
+ */
+public boolean getBorderVisible() {
+	checkWidget();
+	return borderLeft == 1;
+}
+public Rectangle getClientArea() {
+	checkWidget();
+	if (minimized) return new Rectangle(xClient, yClient, 0, 0);
+	Point size = getSize();
+	int width = size.x  - borderLeft - borderRight - 2*marginWidth - 2*highlight_margin;
+	int height = size.y - borderTop - borderBottom - 2*marginHeight - highlight_margin - highlight_header;
+	height -= tabHeight;
+	return new Rectangle(xClient, yClient, width, height);
+}
+/**
+ * Return the tab that is located at the specified index.
+ * 
+ * @param index the index of the tab item
+ * @return the item at the specified index
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_RANGE - if the index is out of range</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+ *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+ * </ul>
+ */
+public CTabItem getItem (int index) {
+	//checkWidget();
+	if (index  < 0 || index >= items.length) 
+		SWT.error(SWT.ERROR_INVALID_RANGE);
+	return items [index];
+}
+/**
+ * Gets the item at a point in the widget.
+ *
+ * @param pt the point in coordinates relative to the CTabFolder
+ * @return the item at a point or null
+ * 
+ * @exception SWTException <ul>
+ *		<li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+ *		<li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+ *	</ul>
+ */
+public CTabItem getItem (Point pt) {
+	//checkWidget();
+	if (items.length == 0) return null;
+	Point size = getSize();
+	if (size.x <= borderLeft + borderRight) return null;
+	if (showChevron && chevronRect.contains(pt)) return null;
+	for (int i = 0; i < priority.length; i++) {
+		CTabItem item = items[priority[i]];
+		Rectangle rect = item.getBounds();
+		if (rect.contains(pt)) return item;
+	}
+	return null;
+}
+/**
+ * Return the number of tabs in the folder.
+ * 
+ * @return the number of tabs in the folder
+ * 
+ * @exception SWTException <ul>
+ *		<li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+ *		<li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+ *	</ul>
+ */
+public int getItemCount(){
+	//checkWidget();
+	return items.length;
+}
+/**
+ * Return the tab items.
+ * 
+ * @return the tab items
+ * 
+ * @exception SWTException <ul>
+ *		<li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+ *		<li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+ *	</ul>
+ */
+public CTabItem [] getItems() {
+	//checkWidget();
+	CTabItem[] tabItems = new CTabItem [items.length];
+	System.arraycopy(items, 0, tabItems, 0, items.length);
+	return tabItems;
+}
+/*
+ * Return the lowercase of the first non-'&' character following
+ * an '&' character in the given string. If there are no '&'
+ * characters in the given string, return '\0'.
+ */
+char _findMnemonic (String string) {
+	if (string == null) return '\0';
+	int index = 0;
+	int length = string.length ();
+	do {
+		while (index < length && string.charAt (index) != '&') index++;
+		if (++index >= length) return '\0';
+		if (string.charAt (index) != '&') return Character.toLowerCase (string.charAt (index));
+		index++;
+	} while (index < length);
+ 	return '\0';
+}
+String stripMnemonic (String string) {
+	int index = 0;
+	int length = string.length ();
+	do {
+		while ((index < length) && (string.charAt (index) != '&')) index++;
+		if (++index >= length) return string;
+		if (string.charAt (index) != '&') {
+			return string.substring(0, index-1) + string.substring(index, length);
+		}
+		index++;
+	} while (index < length);
+ 	return string;
+}
+/**
+ * Returns <code>true</code> if the receiver is minimized.
+ *
+ * @return the receiver's minimized state
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.0
+ */
+public boolean getMinimized() {
+	checkWidget();
+	return minimized;
+}
+/**
+ * Returns <code>true</code> if the minimize button
+ * is visible.
+ *
+ * @return the visibility of the minimized button
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.0
+ */
+public boolean getMinimizeVisible() {
+	checkWidget();
+	return showMin;
+}
+/** 
+ * Returns the number of characters that will
+ * appear in a fully compressed tab.
+ * 
+ * @return number of characters that will appear in a fully compressed tab
+ * 
+ * @since 3.0
+ */
+public int getMinimumCharacters() {
+	checkWidget();
+	return minChars;
+}
+/**
+ * Returns <code>true</code> if the receiver is maximized.
+ * <p>
+ *
+ * @return the receiver's maximized state
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.0
+ */
+public boolean getMaximized() {
+	checkWidget();
+	return maximized;
+}
+/**
+ * Returns <code>true</code> if the maximize button
+ * is visible.
+ *
+ * @return the visibility of the maximized button
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.0
+ */
+public boolean getMaximizeVisible() {
+	checkWidget();
+	return showMax;
+}
+/**
+ * Returns <code>true</code> if the receiver displays most
+ * recently used tabs and <code>false</code> otherwise.
+ * <p>
+ * When there is not enough horizontal space to show all the tabs,
+ * by default, tabs are shown sequentially from left to right in 
+ * order of their index.  When the MRU visibility is turned on,
+ * the tabs that are visible will be the tabs most recently selected.
+ * Tabs will still maintain their left to right order based on index 
+ * but only the most recently selected tabs are visible.
+ * <p>
+ * For example, consider a CTabFolder that contains "Tab 1", "Tab 2",
+ * "Tab 3" and "Tab 4" (in order by index).  The user selects
+ * "Tab 1" and then "Tab 3".  If the CTabFolder is now
+ * compressed so that only two tabs are visible, by default, 
+ * "Tab 2" and "Tab 3" will be shown ("Tab 3" since it is currently 
+ * selected and "Tab 2" because it is the previous item in index order).
+ * If MRU visibility is enabled, the two visible tabs will be "Tab 1"
+ * and "Tab 3" (in that order from left to right).</p>
+ *
+ * @return the receiver's header's visibility state
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.1
+ */
+public boolean getMRUVisible() {
+	checkWidget();
+	return mru;
+}
+int getRightItemEdge (){
+	int x = getSize().x - borderRight - 3;
+	if (showMin) x -= BUTTON_SIZE;
+	if (showMax) x -= BUTTON_SIZE;
+	if (showChevron) x -= 3*BUTTON_SIZE/2;
+	if (topRight != null && topRightAlignment != SWT.FILL) {
+		Point rightSize = topRight.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+		x -= rightSize.x + 3;
+	}
+	return Math.max(0, x);
+}
+/**
+ * Return the selected tab item, or null if there is no selection.
+ * 
+ * @return the selected tab item, or null if none has been selected
+ * 
+ * @exception SWTException <ul>
+ *		<li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+ *		<li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+ *	</ul>
+ */
+public CTabItem getSelection() {
+	//checkWidget();
+	if (selectedIndex == -1) return null;
+	return items[selectedIndex];
+}
+/**
+ * Returns the receiver's selection background color.
+ *
+ * @return the selection background color of the receiver
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.0
+ */
+public Color getSelectionBackground() {
+	checkWidget();
+	return selectionBackground;
+}
+/**
+ * Returns the receiver's selection foreground color.
+ *
+ * @return the selection foreground color of the receiver
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.0
+ */
+public Color getSelectionForeground() {
+	checkWidget();
+	return selectionForeground;
+}
+/**
+ * Return the index of the selected tab item, or -1 if there
+ * is no selection.
+ * 
+ * @return the index of the selected tab item or -1
+ * 
+ * @exception SWTException <ul>
+ *		<li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+ *		<li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+ *	</ul>
+ */
+public int getSelectionIndex() {
+	//checkWidget();
+	return selectedIndex;
+}
+/**
+ * Returns <code>true</code> if the CTabFolder is rendered
+ * with a simple, traditional shape.
+ * 
+ * @return <code>true</code> if the CTabFolder is rendered with a simple shape
+ * 
+ * @since 3.0
+ */
+public boolean getSimple() {
+	checkWidget();
+	return simple;
+}
+/**
+ * Returns <code>true</code> if the CTabFolder only displays the selected tab
+ * and <code>false</code> if the CTabFolder displays multiple tabs.
+ * 
+ * @return <code>true</code> if the CTabFolder only displays the selected tab and <code>false</code> if the CTabFolder displays multiple tabs
+ * 
+ * @since 3.0
+ */
+public boolean getSingle() {
+	checkWidget();
+	return single;
+}
+
+public int getStyle() {
+	int style = super.getStyle();
+	style &= ~(SWT.TOP | SWT.BOTTOM);
+	style |= onBottom ? SWT.BOTTOM : SWT.TOP;
+	style &= ~(SWT.SINGLE | SWT.MULTI);
+	style |= single ? SWT.SINGLE : SWT.MULTI;
+	if (borderLeft != 0) style |= SWT.BORDER;
+	style &= ~SWT.CLOSE;
+	if (showClose) style |= SWT.CLOSE;
+	return style;
+}
+/**
+ * Returns the height of the tab
+ * 
+ * @return the height of the tab
+ * 
+ * @exception SWTException <ul>
+ *		<li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+ *		<li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+ *	</ul>
+ */
+public int getTabHeight(){
+	checkWidget();
+	if (fixedTabHeight != SWT.DEFAULT) return fixedTabHeight;
+	return tabHeight - 1; // -1 for line drawn across top of tab
+}
+/**
+ * Returns the position of the tab.  Possible values are SWT.TOP or SWT.BOTTOM.
+ * 
+ * @return the position of the tab
+ * 
+ * @exception SWTException <ul>
+ *		<li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+ *		<li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+ *	</ul>
+ */
+public int getTabPosition(){
+	checkWidget();
+	return onBottom ? SWT.BOTTOM : SWT.TOP;
+}
+/**
+ * Returns the control in the top right corner of the tab folder. 
+ * Typically this is a close button or a composite with a menu and close button.
+ *
+ * @return the control in the top right corner of the tab folder or null
+ * 
+ * @exception  SWTException <ul>
+ *		<li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+ *		<li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+ *	</ul>
+ *
+ * @since 2.1
+ */
+public Control getTopRight() {
+	checkWidget();
+	return topRight;
+}
+/**
+ * Returns <code>true</code> if the close button appears 
+ * when the user hovers over an unselected tabs.
+ * 
+ * @return <code>true</code> if the close button appears on unselected tabs
+ * 
+ * @since 3.0
+ */
+public boolean getUnselectedCloseVisible() {
+	checkWidget();
+	return showUnselectedClose;
+}
+/**
+ * Returns <code>true</code> if an image appears 
+ * in unselected tabs.
+ * 
+ * @return <code>true</code> if an image appears in unselected tabs
+ * 
+ * @since 3.0
+ */
+public boolean getUnselectedImageVisible() {
+	checkWidget();
+	return showUnselectedImage;
+}
+/**
+ * Return the index of the specified tab or -1 if the tab is not 
+ * in the receiver.
+ * 
+ * @param item the tab item for which the index is required
+ * 
+ * @return the index of the specified tab item or -1
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+ *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+ * </ul>
+ */
+public int indexOf(CTabItem item) {
+	checkWidget();
+	if (item == null) {
+		SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	}
+	for (int i = 0; i < items.length; i++) {
+		if (items[i] == item) return i;
+	}
+	return -1;
+}
+void initAccessible() {
+	final Accessible accessible = getAccessible();
+	accessible.addAccessibleListener(new AccessibleAdapter() {
+		public void getName(AccessibleEvent e) {
+			String name = null;
+			int childID = e.childID;
+			if (childID >= 0 && childID < items.length) {
+				name = stripMnemonic(items[childID].getText());
+			} else if (childID == items.length + CHEVRON_CHILD_ID) {
+				name = SWT.getMessage("SWT_ShowList"); //$NON-NLS-1$
+			} else if (childID == items.length + MINIMIZE_CHILD_ID) {
+				name = minimized ? SWT.getMessage("SWT_Restore") : SWT.getMessage("SWT_Minimize"); //$NON-NLS-1$ //$NON-NLS-2$
+			} else if (childID == items.length + MAXIMIZE_CHILD_ID) {
+				name = maximized ? SWT.getMessage("SWT_Restore") : SWT.getMessage("SWT_Maximize"); //$NON-NLS-1$ //$NON-NLS-2$
+			}
+			e.result = name;
+		}
+
+		public void getHelp(AccessibleEvent e) {
+			String help = null;
+			int childID = e.childID;
+			if (childID == ACC.CHILDID_SELF) {
+				help = getToolTipText();
+			} else if (childID >= 0 && childID < items.length) {
+				help = items[childID].getToolTipText();
+			}
+			e.result = help;
+		}
+		
+		public void getKeyboardShortcut(AccessibleEvent e) {
+			String shortcut = null;
+			int childID = e.childID;
+			if (childID >= 0 && childID < items.length) {
+				String text = items[childID].getText();
+				if (text != null) {
+					char mnemonic = _findMnemonic(text);	
+					if (mnemonic != '\0') {
+						shortcut = "Alt+"+mnemonic; //$NON-NLS-1$
+					}
+				}
+			}
+			e.result = shortcut;
+		}
+	});
+	
+	accessible.addAccessibleControlListener(new AccessibleControlAdapter() {
+		public void getChildAtPoint(AccessibleControlEvent e) {
+			Point testPoint = toControl(e.x, e.y);
+			int childID = ACC.CHILDID_NONE;
+			for (int i = 0; i < items.length; i++) {
+				if (items[i].getBounds().contains(testPoint)) {
+					childID = i;
+					break;
+				}
+			}
+			if (childID == ACC.CHILDID_NONE) {
+				if (showChevron && chevronRect.contains(testPoint)) {
+					childID = items.length + CHEVRON_CHILD_ID;
+				} else if (showMin && minRect.contains(testPoint)) {
+					childID = items.length + MINIMIZE_CHILD_ID;
+				} else if (showMax && maxRect.contains(testPoint)) {
+					childID = items.length + MAXIMIZE_CHILD_ID;
+				} else {
+					Rectangle location = getBounds();
+					location.height = location.height - getClientArea().height;
+					if (location.contains(testPoint)) {
+						childID = ACC.CHILDID_SELF;
+					}
+				}
+			}
+			e.childID = childID;
+		}
+
+		public void getLocation(AccessibleControlEvent e) {
+			Rectangle location = null;
+			Point pt = null;
+			int childID = e.childID;
+			if (childID == ACC.CHILDID_SELF) {
+				location = getBounds();
+				pt = getParent().toDisplay(location.x, location.y);
+			} else {
+				if (childID >= 0 && childID < items.length && items[childID].isShowing()) {
+					location = items[childID].getBounds();
+				} else if (showChevron && childID == items.length + CHEVRON_CHILD_ID) {
+					location = chevronRect;
+				} else if (showMin && childID == items.length + MINIMIZE_CHILD_ID) {
+					location = minRect;
+				} else if (showMax && childID == items.length + MAXIMIZE_CHILD_ID) {
+					location = maxRect;
+				}
+				if (location != null) {
+					pt = toDisplay(location.x, location.y);
+				}
+			}
+			if (location != null && pt != null) {
+				e.x = pt.x;
+				e.y = pt.y;
+				e.width = location.width;
+				e.height = location.height;
+			}
+		}
+		
+		public void getChildCount(AccessibleControlEvent e) {
+			e.detail = items.length + EXTRA_CHILD_ID_COUNT;
+		}
+		
+		public void getDefaultAction(AccessibleControlEvent e) {
+			String action = null;
+			int childID = e.childID;
+			if (childID >= 0 && childID < items.length) {
+				action = SWT.getMessage ("SWT_Switch"); //$NON-NLS-1$
+			}
+			if (childID >= items.length && childID < items.length + EXTRA_CHILD_ID_COUNT) {
+				action = SWT.getMessage ("SWT_Press"); //$NON-NLS-1$
+			}
+			e.result = action;
+		}
+
+		public void getFocus(AccessibleControlEvent e) {
+			int childID = ACC.CHILDID_NONE;
+			if (isFocusControl()) {
+				if (selectedIndex == -1) {
+					childID = ACC.CHILDID_SELF;
+				} else {
+					childID = selectedIndex;
+				}
+			}
+			e.childID = childID;
+		}
+
+		public void getRole(AccessibleControlEvent e) {
+			int role = 0;
+			int childID = e.childID;
+			if (childID == ACC.CHILDID_SELF) {
+				role = ACC.ROLE_TABFOLDER;
+			} else if (childID >= 0 && childID < items.length) {
+				role = ACC.ROLE_TABITEM;
+			} else if (childID >= items.length && childID < items.length + EXTRA_CHILD_ID_COUNT) {
+				role = ACC.ROLE_PUSHBUTTON;
+			}
+			e.detail = role;
+		}
+		
+		public void getSelection(AccessibleControlEvent e) {
+			e.childID = (selectedIndex == -1) ? ACC.CHILDID_NONE : selectedIndex;
+		}
+		
+		public void getState(AccessibleControlEvent e) {
+			int state = 0;
+			int childID = e.childID;
+			if (childID == ACC.CHILDID_SELF) {
+				state = ACC.STATE_NORMAL;
+			} else if (childID >= 0 && childID < items.length) {
+				state = ACC.STATE_SELECTABLE;
+				if (isFocusControl()) {
+					state |= ACC.STATE_FOCUSABLE;
+				}
+				if (selectedIndex == childID) {
+					state |= ACC.STATE_SELECTED;
+					if (isFocusControl()) {
+						state |= ACC.STATE_FOCUSED;
+					}
+				}
+			} else if (childID == items.length + CHEVRON_CHILD_ID) {
+				state = showChevron ? ACC.STATE_NORMAL : ACC.STATE_INVISIBLE;
+			} else if (childID == items.length + MINIMIZE_CHILD_ID) {
+				state = showMin ? ACC.STATE_NORMAL : ACC.STATE_INVISIBLE;
+			} else if (childID == items.length + MAXIMIZE_CHILD_ID) {
+				state = showMax ? ACC.STATE_NORMAL : ACC.STATE_INVISIBLE;
+			}
+			e.detail = state;
+		}
+		
+		public void getChildren(AccessibleControlEvent e) {
+			int childIdCount = items.length + EXTRA_CHILD_ID_COUNT;
+			Object[] children = new Object[childIdCount];
+			for (int i = 0; i < childIdCount; i++) {
+				children[i] = new Integer(i);
+			}
+			e.children = children;
+		}
+	});
+	
+	addListener(SWT.Selection, new Listener() {
+		public void handleEvent(Event event) {
+			if (isFocusControl()) {
+				if (selectedIndex == -1) {
+					accessible.setFocus(ACC.CHILDID_SELF);
+				} else {
+					accessible.setFocus(selectedIndex);
+				}
+			}
+		}
+	});
+
+	addListener(SWT.FocusIn, new Listener() {
+		public void handleEvent(Event event) {
+			if (selectedIndex == -1) {
+				accessible.setFocus(ACC.CHILDID_SELF);
+			} else {
+				accessible.setFocus(selectedIndex);
+			}
+		}
+	});
+}
+void onKeyDown (Event event) {
+	switch (event.keyCode) {
+		case SWT.ARROW_LEFT:
+		case SWT.ARROW_RIGHT:
+			int count = items.length;
+			if (count == 0) return;
+			if (selectedIndex  == -1) return;
+			int leadKey = (getStyle() & SWT.RIGHT_TO_LEFT) != 0 ? SWT.ARROW_RIGHT : SWT.ARROW_LEFT;
+			int offset =  event.keyCode == leadKey ? -1 : 1;
+			int index;
+			if (!mru) {
+				index = selectedIndex + offset;
+			} else {
+				int[] visible = new int[items.length];
+				int idx = 0;
+				int current = -1;
+				for (int i = 0; i < items.length; i++) {
+					if (items[i].showing) {
+						if (i == selectedIndex) current = idx;
+						visible [idx++] = i;
+					}
+				}
+				if (current + offset >= 0 && current + offset < idx){
+					index = visible [current + offset];
+				} else {
+					if (showChevron) {
+						CTabFolderEvent e = new CTabFolderEvent(this);
+						e.widget = this;
+						e.time = event.time;
+						e.x = chevronRect.x;
+						e.y = chevronRect.y;
+						e.width = chevronRect.width;
+						e.height = chevronRect.height;
+						e.doit = true;
+						for (int i = 0; i < folderListeners.length; i++) {
+							folderListeners[i].showList(e);
+						}
+						if (e.doit && !isDisposed()) {
+							showList(chevronRect);
+						}
+					}
+					return;
+				}
+			}
+			if (index < 0 || index >= count) return;
+			setSelection (index, true);
+			forceFocus();
+	}
+}
+void onDispose(Event event) {
+	removeListener(SWT.Dispose, listener);
+	notifyListeners(SWT.Dispose, event);
+	event.type = SWT.None;
+	/*
+	 * Usually when an item is disposed, destroyItem will change the size of the items array, 
+	 * reset the bounds of all the tabs and manage the widget associated with the tab.
+	 * Since the whole folder is being disposed, this is not necessary.  For speed
+	 * the inDispose flag is used to skip over this part of the item dispose.
+	 */
+	inDispose = true;
+
+	if (showMenu != null && !showMenu.isDisposed()) {
+		showMenu.dispose();
+		showMenu = null;
+	}
+	int length = items.length;
+	for (int i = 0; i < length; i++) {				
+		if (items[i] != null) {
+			items[i].dispose();
+		}
+	}
+	
+	selectionGradientColors = null;
+	selectionGradientPercents = null;
+	selectionBgImage = null;
+
+	selectionBackground = null;
+	selectionForeground = null;
+	disposeSelectionHighlightGradientColors();	
+}
+void onDragDetect(Event event) {
+	boolean consume = false;
+	if (chevronRect.contains(event.x, event.y) ||
+	    minRect.contains(event.x, event.y) ||
+		maxRect.contains(event.x, event.y)){
+		consume = true;
+	} else {
+		for (int i = 0; i < items.length; i++) {
+			if (items[i].closeRect.contains(event.x, event.y)) {
+					consume = true;
+					break;
+			}
+		}
+	}
+	if (consume) {
+		event.type = SWT.None;
+	}
+}
+void onFocus(Event event) {
+	checkWidget();
+	if (selectedIndex >= 0) {
+		redraw();
+	} else {
+		setSelection(0, true);
+	}
+}
+boolean onMnemonic (Event event) {
+	char key = event.character;
+	for (int i = 0; i < items.length; i++) {
+		if (items[i] != null) {
+			char mnemonic = _findMnemonic (items[i].getText ());
+			if (mnemonic != '\0') {
+				if (Character.toLowerCase (key) == mnemonic) {
+					setSelection(i, true);
+					return true;
+				}
+			}
+		}
+	}
+	return false;
+}
+void onMouseDoubleClick(Event event) {	
+	if (event.button != 1 || 
+		(event.stateMask & SWT.BUTTON2) != 0 || 
+		(event.stateMask & SWT.BUTTON3) != 0) return;
+	Event e = new Event();
+	e.item = getItem(new Point(event.x, event.y));
+	if (e.item != null) {
+		notifyListeners(SWT.DefaultSelection, e);
+	}
+}
+void onMouse(Event event) {
+	int x = event.x, y = event.y;
+	switch (event.type) {
+		case SWT.MouseEnter: {
+			setToolTipText(null);
+			break;
+		}
+		case SWT.MouseExit: {
+			if (minImageState != NORMAL) {
+				minImageState = NORMAL;
+				redraw(minRect.x, minRect.y, minRect.width, minRect.height, false);
+			}
+			if (maxImageState != NORMAL) {
+				maxImageState = NORMAL;
+				redraw(maxRect.x, maxRect.y, maxRect.width, maxRect.height, false);
+			}
+			if (chevronImageState != NORMAL) {
+				chevronImageState = NORMAL;
+				redraw(chevronRect.x, chevronRect.y, chevronRect.width, chevronRect.height, false);
+			}
+			for (int i=0; i<items.length; i++) {
+				CTabItem item = items[i];
+				if (i != selectedIndex && item.closeImageState != NONE) {
+					item.closeImageState = NONE;
+					redraw(item.closeRect.x, item.closeRect.y, item.closeRect.width, item.closeRect.height, false);
+				}
+				if (i == selectedIndex && item.closeImageState != NORMAL) {
+					item.closeImageState = NORMAL;
+					redraw(item.closeRect.x, item.closeRect.y, item.closeRect.width, item.closeRect.height, false);
+				}
+			}
+			break;
+		}
+		case SWT.MouseDown: {
+			if (minRect.contains(x, y)) {
+				if (event.button != 1) return;
+				minImageState = SELECTED;
+				redraw(minRect.x, minRect.y, minRect.width, minRect.height, false);
+				update();
+				return;
+			}
+			if (maxRect.contains(x, y)) {
+				if (event.button != 1) return;
+				maxImageState = SELECTED;
+				redraw(maxRect.x, maxRect.y, maxRect.width, maxRect.height, false);
+				update();
+				return;
+			}
+			if (chevronRect.contains(x, y)) {
+				if (event.button != 1) return;
+				if (chevronImageState != HOT) {
+					chevronImageState = HOT;
+				} else {
+					chevronImageState = SELECTED;
+				}
+				redraw(chevronRect.x, chevronRect.y, chevronRect.width, chevronRect.height, false);
+				update();
+				return;
+			}
+			CTabItem item = null;
+			if (single) {
+				if (selectedIndex != -1) {
+					Rectangle bounds = items[selectedIndex].getBounds();
+					if (bounds.contains(x, y)){
+						item = items[selectedIndex];
+					}
+				}
+			} else {
+				for (int i=0; i<items.length; i++) {
+					Rectangle bounds = items[i].getBounds();
+					if (bounds.contains(x, y)){
+						item = items[i];
+					}
+				}
+			}
+			if (item != null) {
+				if (item.closeRect.contains(x,y)){
+					if (event.button != 1) return;
+					item.closeImageState = SELECTED;
+					redraw(item.closeRect.x, item.closeRect.y, item.closeRect.width, item.closeRect.height, false);
+					update();
+					return;
+				}
+				int index = indexOf(item);
+				if (item.showing){
+					setSelection(index, true);
+				}
+				return;
+			}
+			break;
+		}
+		case SWT.MouseMove: {
+			_setToolTipText(event.x, event.y);
+			boolean close = false, minimize = false, maximize = false, chevron = false;
+			if (minRect.contains(x, y)) {
+				minimize = true;
+				if (minImageState != SELECTED && minImageState != HOT) {
+					minImageState = HOT;
+					redraw(minRect.x, minRect.y, minRect.width, minRect.height, false);
+				}
+			}
+			if (maxRect.contains(x, y)) {
+				maximize = true;
+				if (maxImageState != SELECTED && maxImageState != HOT) {
+					maxImageState = HOT;
+					redraw(maxRect.x, maxRect.y, maxRect.width, maxRect.height, false);
+				}
+			}
+			if (chevronRect.contains(x, y)) {
+				chevron = true;
+				if (chevronImageState != SELECTED && chevronImageState != HOT) {
+					chevronImageState = HOT;
+					redraw(chevronRect.x, chevronRect.y, chevronRect.width, chevronRect.height, false);
+				}
+			}
+			if (minImageState != NORMAL && !minimize) {
+				minImageState = NORMAL;
+				redraw(minRect.x, minRect.y, minRect.width, minRect.height, false);
+			}
+			if (maxImageState != NORMAL && !maximize) {
+				maxImageState = NORMAL;
+				redraw(maxRect.x, maxRect.y, maxRect.width, maxRect.height, false);
+			}
+			if (chevronImageState != NORMAL && !chevron) {
+				chevronImageState = NORMAL;
+				redraw(chevronRect.x, chevronRect.y, chevronRect.width, chevronRect.height, false);
+			}
+			for (int i=0; i<items.length; i++) {
+				CTabItem item = items[i];
+				close = false;
+				if (item.getBounds().contains(x, y)) {
+					close = true;
+					if (item.closeRect.contains(x, y)) {
+						if (item.closeImageState != SELECTED && item.closeImageState != HOT) {
+							item.closeImageState = HOT;
+							redraw(item.closeRect.x, item.closeRect.y, item.closeRect.width, item.closeRect.height, false);
+						}
+					} else {
+						if (item.closeImageState != NORMAL) {
+							item.closeImageState = NORMAL;
+							redraw(item.closeRect.x, item.closeRect.y, item.closeRect.width, item.closeRect.height, false);
+						}
+					}
+				} 
+				if (i != selectedIndex && item.closeImageState != NONE && !close) {
+					item.closeImageState = NONE;
+					redraw(item.closeRect.x, item.closeRect.y, item.closeRect.width, item.closeRect.height, false);
+				}
+				if (i == selectedIndex && item.closeImageState != NORMAL && !close) {
+					item.closeImageState = NORMAL;
+					redraw(item.closeRect.x, item.closeRect.y, item.closeRect.width, item.closeRect.height, false);
+				}
+			}
+			break;
+		}
+		case SWT.MouseUp: {
+			if (event.button != 1) return;
+			if (chevronRect.contains(x, y)) {
+				boolean selected = chevronImageState == SELECTED;
+				if (!selected) return;
+				CTabFolderEvent e = new CTabFolderEvent(this);
+				e.widget = this;
+				e.time = event.time;
+				e.x = chevronRect.x;
+				e.y = chevronRect.y;
+				e.width = chevronRect.width;
+				e.height = chevronRect.height;
+				e.doit = true;
+				for (int i = 0; i < folderListeners.length; i++) {
+					folderListeners[i].showList(e);
+				}
+				if (e.doit && !isDisposed()) {
+					showList(chevronRect);
+				}
+				return;
+			}
+			if (minRect.contains(x, y)) {
+				boolean selected = minImageState == SELECTED;
+				minImageState = HOT;
+				redraw(minRect.x, minRect.y, minRect.width, minRect.height, false);
+				if (!selected) return;
+				CTabFolderEvent e = new CTabFolderEvent(this);
+				e.widget = this;
+				e.time = event.time;
+				for (int i = 0; i < folderListeners.length; i++) {
+					if (minimized) {
+						folderListeners[i].restore(e);
+					} else {
+						folderListeners[i].minimize(e);
+					}
+				}
+				return;
+			}
+			if (maxRect.contains(x, y)) {
+				boolean selected = maxImageState == SELECTED;
+				maxImageState = HOT;
+				redraw(maxRect.x, maxRect.y, maxRect.width, maxRect.height, false);
+				if (!selected) return;
+				CTabFolderEvent e = new CTabFolderEvent(this);
+				e.widget = this;
+				e.time = event.time;
+				for (int i = 0; i < folderListeners.length; i++) {
+					if (maximized) {
+						folderListeners[i].restore(e);
+					} else {
+						folderListeners[i].maximize(e);
+					}
+				}
+				return;
+			}
+			CTabItem item = null;
+			if (single) {
+				if (selectedIndex != -1) {
+					Rectangle bounds = items[selectedIndex].getBounds();
+					if (bounds.contains(x, y)){
+						item = items[selectedIndex];
+					}
+				}
+			} else {
+				for (int i=0; i<items.length; i++) {
+					Rectangle bounds = items[i].getBounds();
+					if (bounds.contains(x, y)){
+						item = items[i];
+					}
+				}
+			}
+			if (item != null) {
+				if (item.closeRect.contains(x,y)) {
+					boolean selected = item.closeImageState == SELECTED;
+					item.closeImageState = HOT;
+					redraw(item.closeRect.x, item.closeRect.y, item.closeRect.width, item.closeRect.height, false);
+					if (!selected) return;
+					CTabFolderEvent e = new CTabFolderEvent(this);
+					e.widget = this;
+					e.time = event.time;
+					e.item = item;
+					e.doit = true;
+					for (int j = 0; j < folderListeners.length; j++) {
+						CTabFolder2Listener listener = folderListeners[j];
+						listener.close(e);
+					}
+					for (int j = 0; j < tabListeners.length; j++) {
+						CTabFolderListener listener = tabListeners[j];
+						listener.itemClosed(e);
+					}
+					if (e.doit) item.dispose();
+					if (!isDisposed() && item.isDisposed()) {
+						Display display = getDisplay();
+						Point pt = display.getCursorLocation();
+						pt = display.map(null, this, pt.x, pt.y);
+						CTabItem nextItem = getItem(pt);
+						if (nextItem != null) {
+							if (nextItem.closeRect.contains(pt)) {
+								if (nextItem.closeImageState != SELECTED && nextItem.closeImageState != HOT) {
+									nextItem.closeImageState = HOT;
+									redraw(nextItem.closeRect.x, nextItem.closeRect.y, nextItem.closeRect.width, nextItem.closeRect.height, false);
+								}
+							} else {
+								if (nextItem.closeImageState != NORMAL) {
+									nextItem.closeImageState = NORMAL;
+									redraw(nextItem.closeRect.x, nextItem.closeRect.y, nextItem.closeRect.width, nextItem.closeRect.height, false);
+								}
+							} 
+						}
+					}
+					return;
+				}
+			}
+		}
+	}
+}
+boolean onPageTraversal(Event event) {
+	int count = items.length;
+	if (count == 0) return false;
+	int index = selectedIndex; 
+	if (index  == -1) {
+		index = 0;
+	} else {
+		int offset = (event.detail == SWT.TRAVERSE_PAGE_NEXT) ? 1 : -1;
+		if (!mru) {
+			index = (selectedIndex + offset + count) % count;
+		} else {
+			int[] visible = new int[items.length];
+			int idx = 0;
+			int current = -1;
+			for (int i = 0; i < items.length; i++) {
+				if (items[i].showing) {
+					if (i == selectedIndex) current = idx;
+					visible [idx++] = i;
+				}
+			}
+			if (current + offset >= 0 && current + offset < idx){
+				index = visible [current + offset];
+			} else {
+				if (showChevron) {
+					CTabFolderEvent e = new CTabFolderEvent(this);
+					e.widget = this;
+					e.time = event.time;
+					e.x = chevronRect.x;
+					e.y = chevronRect.y;
+					e.width = chevronRect.width;
+					e.height = chevronRect.height;
+					e.doit = true;
+					for (int i = 0; i < folderListeners.length; i++) {
+						folderListeners[i].showList(e);
+					}
+					if (e.doit && !isDisposed()) {
+						showList(chevronRect);
+					}
+				}
+				return true;
+			}
+		}
+	}
+	setSelection (index, true);
+	return true;
+}
+void onPaint(Event event) {
+	if (inDispose) return;
+	Font font = getFont();
+	if (oldFont == null || !oldFont.equals(font)) {
+		// handle case where  default font changes
+		oldFont = font;
+		if (!updateTabHeight(false)) {
+			updateItems();
+			redraw();
+			return;
+		}
+	}
+
+	GC gc = event.gc;
+	Font gcFont = gc.getFont();
+	Color gcBackground = gc.getBackground();
+	Color gcForeground = gc.getForeground();
+	
+// Useful for debugging paint problems
+//{
+//Point size = getSize();	
+//gc.setBackground(getDisplay().getSystemColor(SWT.COLOR_GREEN));
+//gc.fillRectangle(-10, -10, size.x + 20, size.y+20);
+//}
+
+	drawBody(event);
+	
+	gc.setFont(gcFont);
+	gc.setForeground(gcForeground);
+	gc.setBackground(gcBackground);
+	
+	drawTabArea(event);
+	
+	gc.setFont(gcFont);
+	gc.setForeground(gcForeground);
+	gc.setBackground(gcBackground);	
+}
+
+void onResize() {
+	if (updateItems()) redrawTabs();
+	
+	Point size = getSize();
+	if (oldSize == null) {
+		redraw();
+	} else {
+		if (onBottom && size.y != oldSize.y) {
+			redraw();
+		} else {
+			int x1 = Math.min(size.x, oldSize.x);
+			if (size.x != oldSize.x) x1 -= borderRight + highlight_margin + 2;
+			if (!simple) x1 -= 5; // rounded top right corner
+			int y1 = Math.min(size.y, oldSize.y);
+			if (size.y != oldSize.y) y1 -= borderBottom + highlight_margin;
+			int x2 = Math.max(size.x, oldSize.x);
+			int y2 = Math.max(size.y, oldSize.y);		
+			redraw(0, y1, x2, y2 - y1, false);
+			redraw(x1, 0, x2 - x1, y2, false);
+		}
+	}
+	oldSize = size;
+}
+void onTraverse (Event event) {
+	switch (event.detail) {
+		case SWT.TRAVERSE_ESCAPE:
+		case SWT.TRAVERSE_RETURN:
+		case SWT.TRAVERSE_TAB_NEXT:
+		case SWT.TRAVERSE_TAB_PREVIOUS:
+			Control focusControl = getDisplay().getFocusControl();
+			if (focusControl == this) event.doit = true;
+			break;
+		case SWT.TRAVERSE_MNEMONIC:
+			event.doit = onMnemonic(event);
+			if (event.doit) event.detail = SWT.TRAVERSE_NONE;
+			break;
+		case SWT.TRAVERSE_PAGE_NEXT:
+		case SWT.TRAVERSE_PAGE_PREVIOUS:
+			event.doit = onPageTraversal(event);
+			event.detail = SWT.TRAVERSE_NONE;
+			break;
+	}
+}
+void redrawTabs() {
+	Point size = getSize();
+	if (onBottom) {
+		redraw(0, size.y - borderBottom - tabHeight - highlight_header - 1, size.x, borderBottom + tabHeight + highlight_header + 1, false);
+	} else {
+		redraw(0, 0, size.x, borderTop + tabHeight + highlight_header + 1, false);
+	}
+}
+/**	 
+ * Removes the listener.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+ *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+ * </ul>
+ * 
+ * @see #addCTabFolder2Listener(CTabFolder2Listener)
+ * 
+ * @since 3.0
+ */
+public void removeCTabFolder2Listener(CTabFolder2Listener listener) {
+	checkWidget();
+	if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+	if (folderListeners.length == 0) return;
+	int index = -1;
+	for (int i = 0; i < folderListeners.length; i++) {
+		if (listener == folderListeners[i]){
+			index = i;
+			break;
+		}
+	}
+	if (index == -1) return;
+	if (folderListeners.length == 1) {
+		folderListeners = new CTabFolder2Listener[0];
+		return;
+	}
+	CTabFolder2Listener[] newTabListeners = new CTabFolder2Listener[folderListeners.length - 1];
+	System.arraycopy(folderListeners, 0, newTabListeners, 0, index);
+	System.arraycopy(folderListeners, index + 1, newTabListeners, index, folderListeners.length - index - 1);
+	folderListeners = newTabListeners;
+}
+/**	 
+ * Removes the listener.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+ *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+ * </ul>
+ * 
+ * @deprecated see removeCTabFolderCloseListener(CTabFolderListener)
+ */
+public void removeCTabFolderListener(CTabFolderListener listener) {
+	checkWidget();
+	if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+	if (tabListeners.length == 0) return;
+	int index = -1;
+	for (int i = 0; i < tabListeners.length; i++) {
+		if (listener == tabListeners[i]){
+			index = i;
+			break;
+		}
+	}
+	if (index == -1) return;
+	if (tabListeners.length == 1) {
+		tabListeners = new CTabFolderListener[0];
+		return;
+	}
+	CTabFolderListener[] newTabListeners = new CTabFolderListener[tabListeners.length - 1];
+	System.arraycopy(tabListeners, 0, newTabListeners, 0, index);
+	System.arraycopy(tabListeners, index + 1, newTabListeners, index, tabListeners.length - index - 1);
+	tabListeners = newTabListeners;
+}
+/**	 
+ * Removes the listener from the collection of listeners who will
+ * be notified when the user changes the receiver's selection.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #addSelectionListener
+ */
+public void removeSelectionListener(SelectionListener listener) {
+	checkWidget();
+	if (listener == null) {
+		SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	}
+	removeListener(SWT.Selection, listener);
+	removeListener(SWT.DefaultSelection, listener);	
+}
+public void setBackground (Color color) {
+	super.setBackground(color);
+	redraw();
+}
+/**
+ * Specify a gradient of colours to be drawn in the background of the unselected tabs.
+ * For example to draw a gradient that varies from dark blue to blue and then to
+ * white, use the following call to setBackground:
+ * <pre>
+ *	cfolder.setBackground(new Color[]{display.getSystemColor(SWT.COLOR_DARK_BLUE), 
+ *		                           display.getSystemColor(SWT.COLOR_BLUE),
+ *		                           display.getSystemColor(SWT.COLOR_WHITE), 
+ *		                           display.getSystemColor(SWT.COLOR_WHITE)},
+ *		               new int[] {25, 50, 100});
+ * </pre>
+ *
+ * @param colors an array of Color that specifies the colors to appear in the gradient 
+ *               in order of appearance left to right.  The value <code>null</code> clears the
+ *               background gradient. The value <code>null</code> can be used inside the array of 
+ *               Color to specify the background color.
+ * @param percents an array of integers between 0 and 100 specifying the percent of the width 
+ *                 of the widget at which the color should change.  The size of the percents array must be one 
+ *                 less than the size of the colors array.
+ * 
+ * @exception SWTException <ul>
+ *		<li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+ *		<li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+ *	</ul>
+ *
+ * @since 3.0
+ */
+void setBackground(Color[] colors, int[] percents) {
+	setBackground(colors, percents, false);
+}
+/**
+ * Specify a gradient of colours to be drawn in the background of the unselected tab.
+ * For example to draw a vertical gradient that varies from dark blue to blue and then to
+ * white, use the following call to setBackground:
+ * <pre>
+ *	cfolder.setBackground(new Color[]{display.getSystemColor(SWT.COLOR_DARK_BLUE), 
+ *		                           display.getSystemColor(SWT.COLOR_BLUE),
+ *		                           display.getSystemColor(SWT.COLOR_WHITE), 
+ *		                           display.getSystemColor(SWT.COLOR_WHITE)},
+ *		                  new int[] {25, 50, 100}, true);
+ * </pre>
+ *
+ * @param colors an array of Color that specifies the colors to appear in the gradient 
+ *               in order of appearance left to right.  The value <code>null</code> clears the
+ *               background gradient. The value <code>null</code> can be used inside the array of 
+ *               Color to specify the background color.
+ * @param percents an array of integers between 0 and 100 specifying the percent of the width 
+ *                 of the widget at which the color should change.  The size of the percents array must be one 
+ *                 less than the size of the colors array.
+ * 
+ * @param vertical indicate the direction of the gradient.  True is vertical and false is horizontal. 
+ * 
+ * @exception SWTException <ul>
+ *		<li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+ *		<li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+ *	</ul>
+ *
+ * @since 3.0
+ */
+void setBackground(Color[] colors, int[] percents, boolean vertical) {
+	checkWidget();
+	if (colors != null) {
+		if (percents == null || percents.length != colors.length - 1) {
+			SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+		}
+		for (int i = 0; i < percents.length; i++) {
+			if (percents[i] < 0 || percents[i] > 100) {
+				SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+			}
+			if (i > 0 && percents[i] < percents[i-1]) {
+				SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+			}
+		}
+		if (getDisplay().getDepth() < 15) {
+			// Don't use gradients on low color displays
+			colors = new Color[] {colors[colors.length - 1]};
+			percents = new int[] {};
+		}
+	}
+	
+	// Are these settings the same as before?
+	if (bgImage == null) {
+		if ((gradientColors != null) && (colors != null) && 
+			(gradientColors.length == colors.length)) {
+			boolean same = false;
+			for (int i = 0; i < gradientColors.length; i++) {
+				if (gradientColors[i] == null) {
+					same = colors[i] == null;
+				} else {
+					same = gradientColors[i].equals(colors[i]);
+				}
+				if (!same) break;
+			}
+			if (same) {
+				for (int i = 0; i < gradientPercents.length; i++) {
+					same = gradientPercents[i] == percents[i];
+					if (!same) break;
+				}
+			}
+			if (same && this.gradientVertical == vertical) return;
+		}
+	} else {
+		bgImage = null;
+	}
+	// Store the new settings
+	if (colors == null) {
+		gradientColors = null;
+		gradientPercents = null;
+		gradientVertical = false;
+		setBackground((Color)null);
+	} else {
+		gradientColors = new Color[colors.length];
+		for (int i = 0; i < colors.length; ++i) {
+			gradientColors[i] = colors[i];
+		}
+		gradientPercents = new int[percents.length];
+		for (int i = 0; i < percents.length; ++i) {
+			gradientPercents[i] = percents[i];
+		}
+		gradientVertical = vertical;
+		setBackground(gradientColors[gradientColors.length-1]);
+	}
+
+	// Refresh with the new settings
+	redraw();
+}
+
+/**
+ * Set the image to be drawn in the background of the unselected tab.  Image
+ * is stretched or compressed to cover entire unselected tab area.
+ * 
+ * @param image the image to be drawn in the background
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 3.0
+ */
+void setBackground(Image image) {
+	checkWidget();
+	if (image == bgImage) return;
+	if (image != null) {
+		gradientColors = null;
+		gradientPercents = null;
+	}
+	bgImage = image;
+	redraw();
+}
+/**
+ * Toggle the visibility of the border
+ * 
+ * @param show true if the border should be displayed
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setBorderVisible(boolean show) {
+	checkWidget();
+	if ((borderLeft == 1) == show) return;
+	borderLeft = borderRight = show ? 1 : 0;
+	borderTop = onBottom ? borderLeft : 0;
+	borderBottom = onBottom ? 0 : borderLeft;
+	Rectangle rectBefore = getClientArea();
+	updateItems();
+	Rectangle rectAfter = getClientArea();
+	if (!rectBefore.equals(rectAfter)) {
+		notifyListeners(SWT.Resize, new Event());
+	}
+	redraw();
+}
+void setButtonBounds() {
+	Point size = getSize();
+	int oldX, oldY, oldWidth, oldHeight;
+	// max button
+	oldX = maxRect.x;
+	oldY = maxRect.y;
+	oldWidth = maxRect.width;
+	oldHeight = maxRect.height;
+	maxRect.x = maxRect.y = maxRect.width = maxRect.height = 0;
+	if (showMax) {
+		maxRect.x = size.x - borderRight - BUTTON_SIZE - 3;
+		if (borderRight > 0) maxRect.x += 1;
+		maxRect.y = onBottom ? size.y - borderBottom - tabHeight + (tabHeight - BUTTON_SIZE)/2: borderTop + (tabHeight - BUTTON_SIZE)/2;
+		maxRect.width = BUTTON_SIZE;
+		maxRect.height = BUTTON_SIZE;
+	}
+	if (oldX != maxRect.x || oldWidth != maxRect.width ||
+	    oldY != maxRect.y || oldHeight != maxRect.height) {
+		int left = Math.min(oldX, maxRect.x);
+		int right = Math.max(oldX + oldWidth, maxRect.x + maxRect.width);
+		int top = onBottom ? size.y - borderBottom - tabHeight: borderTop + 1;
+		redraw(left, top, right - left, tabHeight, false); 
+	}
+	
+	// min button
+	oldX = minRect.x;
+	oldY = minRect.y;
+	oldWidth = minRect.width;
+	oldHeight = minRect.height;
+	minRect.x = minRect.y = minRect.width = minRect.height = 0;
+	if (showMin) {
+		minRect.x = size.x - borderRight - maxRect.width - BUTTON_SIZE - 3;
+		if (borderRight > 0) minRect.x += 1;
+		minRect.y = onBottom ? size.y - borderBottom - tabHeight + (tabHeight - BUTTON_SIZE)/2: borderTop + (tabHeight - BUTTON_SIZE)/2;
+		minRect.width = BUTTON_SIZE;
+		minRect.height = BUTTON_SIZE;
+	}
+	if (oldX != minRect.x || oldWidth != minRect.width ||
+	    oldY != minRect.y || oldHeight != minRect.height) {
+		int left = Math.min(oldX, minRect.x);
+		int right = Math.max(oldX + oldWidth, minRect.x + minRect.width);
+		int top = onBottom ? size.y - borderBottom - tabHeight: borderTop + 1;
+		redraw(left, top, right - left, tabHeight, false);
+	}
+	
+	// top right control
+	oldX = topRightRect.x;
+	oldY = topRightRect.y;
+	oldWidth = topRightRect.width;
+	oldHeight = topRightRect.height;
+	topRightRect.x = topRightRect.y = topRightRect.width = topRightRect.height = 0;
+	if (topRight != null) {
+		switch (topRightAlignment) {
+			case SWT.FILL: {
+				int rightEdge = size.x - borderRight - 3 - maxRect.width - minRect.width;
+				if (!simple && borderRight > 0 && !showMax && !showMin) rightEdge -= 2;
+				if (single) {
+					if (items.length == 0 || selectedIndex == -1) {
+						topRightRect.x = borderLeft + 3;
+						topRightRect.width = rightEdge - topRightRect.x;
+					} else {
+						// fill size is 0 if item compressed
+						CTabItem item = items[selectedIndex];
+						if (item.x + item.width + 7 + 3*BUTTON_SIZE/2 >= rightEdge) break;
+						topRightRect.x = item.x + item.width + 7 + 3*BUTTON_SIZE/2;
+						topRightRect.width = rightEdge - topRightRect.x;
+					}
+				} else {
+					// fill size is 0 if chevron showing
+					if (showChevron) break;
+					if (items.length == 0) {
+						topRightRect.x = borderLeft + 3;
+					} else {
+						CTabItem item = items[items.length - 1];
+						topRightRect.x = item.x + item.width;
+						if (!simple && items.length - 1 == selectedIndex) topRightRect.x += curveWidth - curveIndent;
+					}
+					topRightRect.width = Math.max(0, rightEdge - topRightRect.x);
+				}
+				topRightRect.y = onBottom ? size.y - borderBottom - tabHeight: borderTop + 1;
+				topRightRect.height = tabHeight - 1;
+				break;
+			}
+			case SWT.RIGHT: {
+				Point topRightSize = topRight.computeSize(SWT.DEFAULT, tabHeight, false);
+				int rightEdge = size.x - borderRight - 3 - maxRect.width - minRect.width;
+				if (!simple && borderRight > 0 && !showMax && !showMin) rightEdge -= 2;
+				topRightRect.x = rightEdge - topRightSize.x;
+				topRightRect.width = topRightSize.x;
+				topRightRect.y = onBottom ? size.y - borderBottom - tabHeight: borderTop + 1;
+				topRightRect.height = tabHeight - 1;
+			}
+		}
+		topRight.setBounds(topRightRect);
+	}
+	if (oldX != topRightRect.x || oldWidth != topRightRect.width ||
+		oldY != topRightRect.y || oldHeight != topRightRect.height) {	
+		int left = Math.min(oldX, topRightRect.x);
+		int right = Math.max(oldX + oldWidth, topRightRect.x + topRightRect.width);
+		int top = onBottom ? size.y - borderBottom - tabHeight : borderTop + 1;
+		redraw(left, top, right - left, tabHeight, false);
+	}
+	
+	// chevron button
+	oldX = chevronRect.x;
+	oldY = chevronRect.y;
+	oldWidth = chevronRect.width;
+	oldHeight = chevronRect.height;
+	chevronRect.x = chevronRect.y = chevronRect.height = chevronRect.width = 0;
+	if (single) {
+		if (selectedIndex == -1 || items.length > 1) {
+			chevronRect.width = 3*BUTTON_SIZE/2;
+			chevronRect.height = BUTTON_SIZE;
+			chevronRect.y = onBottom ? size.y - borderBottom - tabHeight + (tabHeight - chevronRect.height)/2 : borderTop + (tabHeight - chevronRect.height)/2;
+			if (selectedIndex == -1) {
+				chevronRect.x = size.x - borderRight - 3 - minRect.width - maxRect.width - topRightRect.width - chevronRect.width;
+			} else {
+				CTabItem item = items[selectedIndex];
+				int w = size.x - borderRight - 3 - minRect.width - maxRect.width - chevronRect.width;
+				if (topRightRect.width > 0) w -= topRightRect.width + 3;
+				chevronRect.x = Math.min(item.x + item.width + 3, w);
+			}
+			if (borderRight > 0) chevronRect.x += 1;
+		}
+	} else {
+		if (showChevron) {
+			chevronRect.width = 3*BUTTON_SIZE/2;
+			chevronRect.height = BUTTON_SIZE;
+			int i = 0, lastIndex = -1;
+			while (i < priority.length && items[priority[i]].showing) {
+				lastIndex = Math.max(lastIndex, priority[i++]);
+			}
+			if (lastIndex == -1) lastIndex = firstIndex;
+			CTabItem lastItem = items[lastIndex];
+			int w = lastItem.x + lastItem.width + 3;
+			if (!simple && lastIndex == selectedIndex) w += curveWidth - 2*curveIndent;
+			chevronRect.x = Math.min(w, getRightItemEdge());
+			chevronRect.y = onBottom ? size.y - borderBottom - tabHeight + (tabHeight - chevronRect.height)/2 : borderTop + (tabHeight - chevronRect.height)/2;
+		}
+	}
+	if (oldX != chevronRect.x || oldWidth != chevronRect.width ||
+	    oldY != chevronRect.y || oldHeight != chevronRect.height) {
+		int left = Math.min(oldX, chevronRect.x);
+		int right = Math.max(oldX + oldWidth, chevronRect.x + chevronRect.width);
+		int top = onBottom ? size.y - borderBottom - tabHeight: borderTop + 1;
+		redraw(left, top, right - left, tabHeight, false);
+	}
+}
+public void setFont(Font font) {
+	checkWidget();
+	if (font != null && font.equals(getFont())) return;
+	super.setFont(font);
+	oldFont = getFont();
+	if (!updateTabHeight(false)) {
+		updateItems();
+		redraw();
+	}
+}
+public void setForeground (Color color) {
+	super.setForeground(color);
+	redraw();
+}
+/**
+ * Display an insert marker before or after the specified tab item. 
+ * 
+ * A value of null will clear the mark.
+ * 
+ * @param item the item with which the mark is associated or null
+ * 
+ * @param after true if the mark should be displayed after the specified item
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setInsertMark(CTabItem item, boolean after) {
+	checkWidget();
+}
+/**
+ * Display an insert marker before or after the specified tab item.
+ * 
+ * A value of -1 will clear the mark.
+ * 
+ * @param index the index of the item with which the mark is associated or null
+ * 
+ * @param after true if the mark should be displayed after the specified item
+ * 
+ * @exception IllegalArgumentException<ul>
+ * </ul>
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setInsertMark(int index, boolean after) {
+	checkWidget();
+	if (index < -1 || index >= getItemCount()) {
+		SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	}
+}
+boolean setItemLocation() {
+	boolean changed = false;
+	if (items.length == 0) return false;
+	Point size = getSize();
+	int y = onBottom ? Math.max(borderBottom, size.y - borderBottom - tabHeight) : borderTop;
+	if (single) {
+		int defaultX = getDisplay().getBounds().width + 10; // off screen
+		for (int i = 0; i < items.length; i++) {
+			CTabItem item = items[i];
+			if (i == selectedIndex) {
+				firstIndex = selectedIndex;
+				int oldX = item.x, oldY = item.y;
+				item.x = borderLeft;
+				item.y = y;
+				item.showing = true;
+				if (showClose || item.showClose) {
+					item.closeRect.x = borderLeft + CTabItem.LEFT_MARGIN;
+					item.closeRect.y = onBottom ? size.y - borderBottom - tabHeight + (tabHeight - BUTTON_SIZE)/2: borderTop + (tabHeight - BUTTON_SIZE)/2;
+				}
+				if (item.x != oldX || item.y != oldY) changed = true;
+			} else {
+				item.x = defaultX;
+				item.showing = false;
+			}
+		}
+	} else {
+		int rightItemEdge = getRightItemEdge();
+		int maxWidth = rightItemEdge - borderLeft;
+		int width = 0;
+		for (int i = 0; i < priority.length; i++) {
+			CTabItem item = items[priority[i]];
+			width += item.width;
+			item.showing = i == 0 ? true : item.width > 0 && width <= maxWidth;
+			if (!simple && priority[i] == selectedIndex) width += curveWidth - 2*curveIndent;
+		}
+		int x = 0;
+		int defaultX = getDisplay().getBounds().width + 10; // off screen
+		firstIndex = items.length - 1;
+		for (int i = 0; i < items.length; i++) {
+			CTabItem item = items[i];
+			if (!item.showing) {
+				if (item.x != defaultX) changed = true;
+				item.x = defaultX;
+			} else {
+				firstIndex = Math.min(firstIndex, i);
+				if (item.x != x || item.y != y) changed = true;
+				item.x = x;
+				item.y = y;
+				if (i == selectedIndex) {
+					int edge = Math.min(item.x + item.width, rightItemEdge);
+					item.closeRect.x = edge - CTabItem.RIGHT_MARGIN - BUTTON_SIZE;
+				} else {
+					item.closeRect.x = item.x + item.width - CTabItem.RIGHT_MARGIN - BUTTON_SIZE;
+				}
+				item.closeRect.y = onBottom ? size.y - borderBottom - tabHeight + (tabHeight - BUTTON_SIZE)/2: borderTop + (tabHeight - BUTTON_SIZE)/2;
+				x = x + item.width;
+				if (!simple && i == selectedIndex) x += curveWidth - 2*curveIndent;
+			}
+		}
+	}
+	return changed;
+}
+boolean setItemSize() {
+	boolean changed = false;
+	if (isDisposed()) return changed;
+	Point size = getSize();
+	if (size.x <= 0 || size.y <= 0) return changed;
+	xClient = borderLeft + marginWidth + highlight_margin;
+	if (onBottom) {
+		yClient = borderTop + highlight_margin + marginHeight;
+	} else {
+		yClient = borderTop + tabHeight + highlight_header + marginHeight; 
+	}
+	showChevron = false;
+	if (single) {
+		showChevron = true;
+		if (selectedIndex != -1) {
+			CTabItem tab = items[selectedIndex];
+			GC gc = new GC(this);
+			int width = tab.preferredWidth(gc, true, false);
+			gc.dispose();
+			width = Math.min(width, getRightItemEdge() - borderLeft);
+			if (tab.height != tabHeight || tab.width != width) {
+				changed = true;
+				tab.shortenedText = null;
+				tab.shortenedTextWidth = 0;
+				tab.height = tabHeight;
+				tab.width = width;
+				tab.closeRect.width = tab.closeRect.height = 0;
+				if (showClose || tab.showClose) {
+					tab.closeRect.width = BUTTON_SIZE;
+					tab.closeRect.height = BUTTON_SIZE;
+				}
+			}
+		}
+		return changed;
+	}
+	
+	if (items.length == 0) return changed;
+
+	int[] widths;
+	GC gc = new GC(this);
+	int tabAreaWidth = size.x - borderLeft - borderRight - 3;
+	if (showMin) tabAreaWidth -= BUTTON_SIZE;
+	if (showMax) tabAreaWidth -= BUTTON_SIZE;
+	if (topRightAlignment == SWT.RIGHT && topRight != null) {
+		Point rightSize = topRight.computeSize(SWT.DEFAULT, SWT.DEFAULT, false);
+		tabAreaWidth -= rightSize.x + 3;
+	}
+	if (!simple) tabAreaWidth -= curveWidth - 2*curveIndent;
+	tabAreaWidth = Math.max(0, tabAreaWidth);
+	
+	// First, try the minimum tab size at full compression.
+	int minWidth = 0;
+	int[] minWidths = new int[items.length];	
+	for (int i = 0; i < priority.length; i++) {
+		int index = priority[i];
+		minWidths[index] = items[index].preferredWidth(gc, index == selectedIndex, true);
+		minWidth += minWidths[index];
+		if (minWidth > tabAreaWidth) break;
+	}
+	if (minWidth > tabAreaWidth) {
+		// full compression required and a chevron
+		showChevron = items.length > 1;
+		if (showChevron) tabAreaWidth -= 3*BUTTON_SIZE/2;
+		widths = minWidths;
+		int index = selectedIndex != -1 ? selectedIndex : 0;
+		if (tabAreaWidth < widths[index]) {
+			widths[index] = Math.max(0, tabAreaWidth);
+		}
+	} else {
+		int maxWidth = 0;
+		int[] maxWidths = new int[items.length];
+		for (int i = 0; i < items.length; i++) {
+			maxWidths[i] = items[i].preferredWidth(gc, i == selectedIndex, false);
+			maxWidth += maxWidths[i];
+		}
+		if (maxWidth <= tabAreaWidth) {
+			// no compression required
+			widths = maxWidths;
+		} else {
+			// determine compression for each item
+			int extra = (tabAreaWidth - minWidth) / items.length;
+			while (true) {
+				int large = 0, totalWidth = 0;
+				for (int i = 0 ; i < items.length; i++) {
+					if (maxWidths[i] > minWidths[i] + extra) {
+						totalWidth += minWidths[i] + extra;
+						large++;
+					} else {
+						totalWidth += maxWidths[i];
+					}
+				}
+				if (totalWidth >= tabAreaWidth) {
+					extra--;
+					break;
+				}
+				if (large == 0 || tabAreaWidth - totalWidth < large) break;
+				extra++;
+			}
+			widths = new int[items.length];
+			for (int i = 0; i < items.length; i++) {
+				widths[i] = Math.min(maxWidths[i], minWidths[i] + extra);
+			}
+		}
+	}
+	gc.dispose();
+
+	for (int i = 0; i < items.length; i++) {
+		CTabItem tab = items[i];
+		int width = widths[i];
+		if (tab.height != tabHeight || tab.width != width) {
+			changed = true;
+			tab.shortenedText = null;
+			tab.shortenedTextWidth = 0;
+			tab.height = tabHeight;
+			tab.width = width;
+			tab.closeRect.width = tab.closeRect.height = 0;
+			if (showClose || tab.showClose) {
+				if (i == selectedIndex || showUnselectedClose) {
+					tab.closeRect.width = BUTTON_SIZE;
+					tab.closeRect.height = BUTTON_SIZE;
+				}
+			}
+		}
+	}
+	return changed;
+}
+/**
+ * Marks the receiver's maximize button as visible if the argument is <code>true</code>,
+ * and marks it invisible otherwise. 
+ *
+ * @param visible the new visibility state
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.0
+ */
+public void setMaximizeVisible(boolean visible) {
+	checkWidget();
+	if (showMax == visible) return;
+	// display maximize button
+	showMax = visible;
+	updateItems();
+	redraw();
+}
+/**
+ * Sets the layout which is associated with the receiver to be
+ * the argument which may be null.
+ * <p>
+ * Note: No Layout can be set on this Control because it already
+ * manages the size and position of its children.
+ * </p>
+ *
+ * @param layout the receiver's new layout or null
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setLayout (Layout layout) {
+	checkWidget();
+	return;
+}
+/**
+ * Sets the maximized state of the receiver.
+ *
+ * @param maximize the new maximized state
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 3.0
+ */
+public void setMaximized(boolean maximize) {
+	checkWidget ();
+	if (this.maximized == maximize) return;
+	if (maximize && this.minimized) setMinimized(false);
+	this.maximized = maximize;
+	redraw(maxRect.x, maxRect.y, maxRect.width, maxRect.height, false);
+}
+/**
+ * Marks the receiver's minimize button as visible if the argument is <code>true</code>,
+ * and marks it invisible otherwise. 
+ *
+ * @param visible the new visibility state
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.0
+ */
+public void setMinimizeVisible(boolean visible) {
+	checkWidget();
+	if (showMin == visible) return;
+	// display minimize button
+	showMin = visible;
+	updateItems();
+	redraw();
+}
+/**
+ * Sets the minimized state of the receiver.
+ *
+ * @param minimize the new minimized state
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 3.0
+ */
+public void setMinimized(boolean minimize) {
+	checkWidget ();
+	if (this.minimized == minimize) return;
+	if (minimize && this.maximized) setMaximized(false);
+	this.minimized = minimize;
+	redraw(minRect.x, minRect.y, minRect.width, minRect.height, false);
+}
+
+/**
+ * Sets the minimum number of characters that will 
+ * be displayed in a fully compressed tab.
+ * 
+ * @param count the minimum number of characters that will be displayed in a fully compressed tab
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_INVALID_RANGE - if the count is less than zero</li>
+ * </ul>
+ * 
+ * @since 3.0
+ */
+public void setMinimumCharacters(int count) {
+	checkWidget ();
+	if (count < 0) SWT.error(SWT.ERROR_INVALID_RANGE);
+	if (minChars == count) return;
+	minChars = count;
+	if (updateItems()) redrawTabs();
+}
+
+/**
+ * When there is not enough horizontal space to show all the tabs,
+ * by default, tabs are shown sequentially from left to right in 
+ * order of their index.  When the MRU visibility is turned on,
+ * the tabs that are visible will be the tabs most recently selected.
+ * Tabs will still maintain their left to right order based on index 
+ * but only the most recently selected tabs are visible.
+ * <p>
+ * For example, consider a CTabFolder that contains "Tab 1", "Tab 2",
+ * "Tab 3" and "Tab 4" (in order by index).  The user selects
+ * "Tab 1" and then "Tab 3".  If the CTabFolder is now
+ * compressed so that only two tabs are visible, by default, 
+ * "Tab 2" and "Tab 3" will be shown ("Tab 3" since it is currently 
+ * selected and "Tab 2" because it is the previous item in index order).
+ * If MRU visibility is enabled, the two visible tabs will be "Tab 1"
+ * and "Tab 3" (in that order from left to right).</p>
+ *
+ * @param show the new visibility state
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.1
+ */
+public void setMRUVisible(boolean show) {
+	checkWidget();
+	if (mru == show) return;
+	mru = show;
+	if (!mru) {
+		int idx = firstIndex;
+		int next = 0;
+		for (int i = firstIndex; i < items.length; i++) {
+			priority[next++] = i;
+		}
+		for (int i = 0; i < idx; i++) {
+			priority[next++] = i;
+		}
+		if (updateItems()) redrawTabs();
+	}
+}
+/**
+ * Set the selection to the tab at the specified item.
+ * 
+ * @param item the tab item to be selected
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the item is null</li>
+ * </ul>
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+ *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+ * </ul>
+ */
+public void setSelection(CTabItem item) {
+	checkWidget();
+	if (item == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	int index = indexOf(item);
+	setSelection(index);
+}
+/**
+ * Set the selection to the tab at the specified index.
+ * 
+ * @param index the index of the tab item to be selected
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setSelection(int index) {
+	checkWidget();
+	if (index < 0 || index >= items.length) return;
+	CTabItem selection = items[index];
+	if (selectedIndex == index) {
+		showItem(selection);
+		return;
+	}
+	
+	int oldIndex = selectedIndex;
+	selectedIndex = index;
+	if (oldIndex != -1) {
+		items[oldIndex].closeImageState = NONE;
+	}
+	selection.closeImageState = NORMAL;
+	selection.showing = false;
+
+	Control newControl = selection.control;
+	Control oldControl = null;
+	if (oldIndex != -1) {
+		oldControl = items[oldIndex].control;
+	}
+	
+	if (newControl != oldControl) {
+		if (newControl != null && !newControl.isDisposed()) {
+			newControl.setBounds(getClientArea());
+			newControl.setVisible(true);
+		}
+		if (oldControl != null && !oldControl.isDisposed()) {
+			oldControl.setVisible(false);
+		}
+	}
+	showItem(selection);
+	redraw();
+}
+void setSelection(int index, boolean notify) {	
+	int oldSelectedIndex = selectedIndex;
+	setSelection(index);
+	if (notify && selectedIndex != oldSelectedIndex && selectedIndex != -1) {
+		Event event = new Event();
+		event.item = getItem(selectedIndex);
+		notifyListeners(SWT.Selection, event);
+	}
+}
+/**
+ * Sets the receiver's selection background color to the color specified
+ * by the argument, or to the default system color for the control
+ * if the argument is null.
+ *
+ * @param color the new color (or null)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li> 
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 3.0
+ */
+public void setSelectionBackground (Color color) {
+	checkWidget();
+	setSelectionHighlightGradientColor(null);
+	if (selectionBackground == color) return;
+	if (color == null) color = getDisplay().getSystemColor(SELECTION_BACKGROUND);
+	selectionBackground = color;
+	if (selectedIndex > -1) redraw();
+}
+/**
+ * Specify a gradient of colours to be draw in the background of the selected tab.
+ * For example to draw a gradient that varies from dark blue to blue and then to
+ * white, use the following call to setBackground:
+ * <pre>
+ *	cfolder.setBackground(new Color[]{display.getSystemColor(SWT.COLOR_DARK_BLUE), 
+ *		                           display.getSystemColor(SWT.COLOR_BLUE),
+ *		                           display.getSystemColor(SWT.COLOR_WHITE), 
+ *		                           display.getSystemColor(SWT.COLOR_WHITE)},
+ *		               new int[] {25, 50, 100});
+ * </pre>
+ *
+ * @param colors an array of Color that specifies the colors to appear in the gradient 
+ *               in order of appearance left to right.  The value <code>null</code> clears the
+ *               background gradient. The value <code>null</code> can be used inside the array of 
+ *               Color to specify the background color.
+ * @param percents an array of integers between 0 and 100 specifying the percent of the width 
+ *                 of the widget at which the color should change.  The size of the percents array must be one 
+ *                 less than the size of the colors array.
+ * 
+ * @exception SWTException <ul>
+ *		<li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+ *		<li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+ *	</ul>
+ */
+public void setSelectionBackground(Color[] colors, int[] percents) {
+	setSelectionBackground(colors, percents, false);
+}
+/**
+ * Specify a gradient of colours to be draw in the background of the selected tab.
+ * For example to draw a vertical gradient that varies from dark blue to blue and then to
+ * white, use the following call to setBackground:
+ * <pre>
+ *	cfolder.setBackground(new Color[]{display.getSystemColor(SWT.COLOR_DARK_BLUE), 
+ *		                           display.getSystemColor(SWT.COLOR_BLUE),
+ *		                           display.getSystemColor(SWT.COLOR_WHITE), 
+ *		                           display.getSystemColor(SWT.COLOR_WHITE)},
+ *		                  new int[] {25, 50, 100}, true);
+ * </pre>
+ *
+ * @param colors an array of Color that specifies the colors to appear in the gradient 
+ *               in order of appearance left to right.  The value <code>null</code> clears the
+ *               background gradient. The value <code>null</code> can be used inside the array of 
+ *               Color to specify the background color.
+ * @param percents an array of integers between 0 and 100 specifying the percent of the width 
+ *                 of the widget at which the color should change.  The size of the percents array must be one 
+ *                 less than the size of the colors array.
+ * 
+ * @param vertical indicate the direction of the gradient.  True is vertical and false is horizontal. 
+ * 
+ * @exception SWTException <ul>
+ *		<li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+ *		<li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+ *	</ul>
+ *
+ * @since 3.0
+ */
+public void setSelectionBackground(Color[] colors, int[] percents, boolean vertical) {
+	checkWidget();
+	int colorsLength;
+	Color highlightBeginColor = null;  //null == no highlight
+
+	if (colors != null) {
+		//The colors array can optionally have an extra entry which describes the highlight top color
+		//Thus its either one or two larger than the percents array
+		if (percents == null || 
+				! ((percents.length == colors.length - 1) || (percents.length == colors.length - 2))){
+			SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+		}
+		for (int i = 0; i < percents.length; i++) {
+			if (percents[i] < 0 || percents[i] > 100) {
+				SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+			}
+			if (i > 0 && percents[i] < percents[i-1]) {
+				SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+			}
+		}
+		//If the colors is exactly two more than percents then last is highlight
+		//Keep track of *real* colorsLength (minus the highlight)
+		if(percents.length == colors.length - 2) {
+			highlightBeginColor = colors[colors.length - 1];
+			colorsLength = colors.length - 1;
+		} else {
+			colorsLength = colors.length;
+		}
+		if (getDisplay().getDepth() < 15) {
+			// Don't use gradients on low color displays
+			colors = new Color[] {colors[colorsLength - 1]};
+			colorsLength = colors.length;
+			percents = new int[] {};
+		}
+	} else {
+		colorsLength = 0;
+	}
+	
+	// Are these settings the same as before?
+	if (selectionBgImage == null) {
+		if ((selectionGradientColors != null) && (colors != null) && 
+			(selectionGradientColors.length == colorsLength)) {
+			boolean same = false;
+			for (int i = 0; i < selectionGradientColors.length; i++) {
+				if (selectionGradientColors[i] == null) {
+					same = colors[i] == null;
+				} else {
+					same = selectionGradientColors[i].equals(colors[i]);
+				}
+				if (!same) break;
+			}
+			if (same) {
+				for (int i = 0; i < selectionGradientPercents.length; i++) {
+					same = selectionGradientPercents[i] == percents[i];
+					if (!same) break;
+				}
+			}
+			if (same && this.selectionGradientVertical == vertical) return;
+		}
+	} else {
+		selectionBgImage = null;
+	}
+	// Store the new settings
+	if (colors == null) {
+		selectionGradientColors = null;
+		selectionGradientPercents = null;
+		selectionGradientVertical = false;
+		setSelectionBackground((Color)null);
+		setSelectionHighlightGradientColor(null);
+	} else {
+		selectionGradientColors = new Color[colorsLength];
+		for (int i = 0; i < colorsLength; ++i) {
+			selectionGradientColors[i] = colors[i];
+		}
+		selectionGradientPercents = new int[percents.length];
+		for (int i = 0; i < percents.length; ++i) {
+			selectionGradientPercents[i] = percents[i];
+		}
+		selectionGradientVertical = vertical;
+		setSelectionBackground(selectionGradientColors[selectionGradientColors.length-1]);
+		setSelectionHighlightGradientColor(highlightBeginColor);
+	}
+
+	// Refresh with the new settings
+	if (selectedIndex > -1) redraw();
+}
+
+/*
+ * Set the color for the highlight start for selected tabs.
+ * Update the cache of highlight gradient colors if required.
+ */
+
+void setSelectionHighlightGradientColor(Color start) {
+	//Set to null to match all the early return cases.
+	//For early returns, don't realloc the cache, we may get a cache hit next time we're given the highlight
+	selectionHighlightGradientBegin = null;
+
+	if(start == null)
+		return;
+
+	//don't bother on low colour
+	if (getDisplay().getDepth() < 15)
+		return;
+	
+	//don't bother if we don't have a background gradient
+	if(selectionGradientColors.length < 2) 
+		return;
+
+	//OK we know its a valid gradient now
+	selectionHighlightGradientBegin = start;
+
+	if(! isSelectionHighlightColorsCacheHit(start))
+		createSelectionHighlightGradientColors(start);  //if no cache hit then compute new ones
+}
+
+/*
+ * Return true if given start color, the cache of highlight colors we have
+ * would match the highlight colors we'd compute.
+ */
+boolean isSelectionHighlightColorsCacheHit(Color start) {
+
+	if(selectionHighlightGradientColorsCache == null)
+		return false;
+	
+	//this case should never happen but check to be safe before accessing array indexes
+	if(selectionHighlightGradientColorsCache.length < 2)
+		return false;
+
+	Color highlightBegin = selectionHighlightGradientColorsCache[0];
+	Color highlightEnd = selectionHighlightGradientColorsCache[selectionHighlightGradientColorsCache.length - 1];
+
+	if(! highlightBegin.equals(start))
+		return false;	
+	
+	//Compare number of colours we have vs. we'd compute
+	if(selectionHighlightGradientColorsCache.length != tabHeight)
+		return false;
+	
+	//Compare existing highlight end to what it would be (selectionBackground)
+	if(! highlightEnd.equals(selectionBackground))
+		return false;
+	
+	return true;
+}
+
+/**
+ * Set the image to be drawn in the background of the selected tab.  Image
+ * is stretched or compressed to cover entire selection tab area.
+ * 
+ * @param image the image to be drawn in the background
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setSelectionBackground(Image image) {
+	checkWidget();
+	setSelectionHighlightGradientColor(null);
+	if (image == selectionBgImage) return;
+	if (image != null) {
+		selectionGradientColors = null;
+		selectionGradientPercents = null;
+		disposeSelectionHighlightGradientColors();
+	}
+	selectionBgImage = image;
+	if (selectedIndex > -1) redraw();
+}
+/**
+ * Set the foreground color of the selected tab.
+ * 
+ * @param color the color of the text displayed in the selected tab
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setSelectionForeground (Color color) {
+	checkWidget();
+	if (selectionForeground == color) return;
+	if (color == null) color = getDisplay().getSystemColor(SELECTION_FOREGROUND);
+	selectionForeground = color;
+	if (selectedIndex > -1) redraw();
+}
+
+/*
+ * Allocate colors for the highlight line.
+ * Colours will be a gradual blend ranging from to.
+ * Blend length will be tab height.
+ * Recompute this if tab height changes.
+ * Could remain null if there'd be no gradient (start=end or low colour display)
+ */
+void createSelectionHighlightGradientColors(Color start) {
+	disposeSelectionHighlightGradientColors(); //dispose if existing
+
+	if(start == null)  //shouldn't happen but just to be safe
+		return;
+
+	//alloc colours for entire height to ensure it matches wherever we stop drawing
+	int fadeGradientSize = tabHeight;
+
+	RGB from = start.getRGB();
+	RGB to = selectionBackground.getRGB();
+
+	selectionHighlightGradientColorsCache = new Color[fadeGradientSize];
+	int denom = fadeGradientSize - 1;
+
+	for (int i = 0; i < fadeGradientSize; i++) {
+		int propFrom = denom - i;
+		int propTo = i;
+		int red = (to.red * propTo + from.red * propFrom) / denom;
+		int green = (to.green * propTo  + from.green * propFrom) / denom;
+		int blue = (to.blue * propTo  + from.blue * propFrom) / denom;
+		selectionHighlightGradientColorsCache[i] = new Color(getDisplay(), red, green, blue);
+	}
+}
+
+void disposeSelectionHighlightGradientColors() {
+	if(selectionHighlightGradientColorsCache == null)
+		return;
+	for (int i = 0; i < selectionHighlightGradientColorsCache.length; i++) {
+		selectionHighlightGradientColorsCache[i].dispose();
+	}
+	selectionHighlightGradientColorsCache = null;
+}
+
+/*
+ * Return the gradient start color for selected tabs, which is the start of the tab fade
+ * (end is selectionBackground).
+ */
+Color getSelectionBackgroundGradientBegin() {
+	if (selectionGradientColors == null)
+		return getSelectionBackground();
+	if (selectionGradientColors.length == 0)
+		return getSelectionBackground();
+	return selectionGradientColors[0];
+}
+
+/**
+ * Sets the shape that the CTabFolder will use to render itself.  
+ * 
+ * @param simple <code>true</code> if the CTabFolder should render itself in a simple, traditional style
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 3.0
+ */
+public void setSimple(boolean simple) {
+	checkWidget();
+	if (this.simple != simple) {
+		this.simple = simple;
+		Rectangle rectBefore = getClientArea();
+		updateItems();
+		Rectangle rectAfter = getClientArea();
+		if (!rectBefore.equals(rectAfter)) {
+			notifyListeners(SWT.Resize, new Event());
+		}
+		redraw();
+	}
+}
+/**
+ * Sets the number of tabs that the CTabFolder should display
+ * 
+ * @param single <code>true</code> if only the selected tab should be displayed otherwise, multiple tabs will be shown.
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.0
+ */
+public void setSingle(boolean single) {
+	checkWidget();
+	if (this.single != single) {
+		this.single = single;
+		if (!single) {
+			for (int i = 0; i < items.length; i++) {
+				if (i != selectedIndex && items[i].closeImageState == NORMAL) {
+					items[i].closeImageState = NONE;
+				}
+			}
+		}
+		Rectangle rectBefore = getClientArea();
+		updateItems();
+		Rectangle rectAfter = getClientArea();
+		if (!rectBefore.equals(rectAfter)) {
+			notifyListeners(SWT.Resize, new Event());
+		}
+		redraw();
+	}
+}
+/**
+ * Specify a fixed height for the tab items.  If no height is specified,
+ * the default height is the height of the text or the image, whichever 
+ * is greater. Specifying a height of -1 will revert to the default height.
+ * 
+ * @param height the pixel value of the height or -1
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if called with a height of less than 0</li>
+ * </ul>
+ */
+public void setTabHeight(int height) {
+	checkWidget();
+	if (height < -1) {
+		SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	}
+	fixedTabHeight = height;
+	updateTabHeight(false);
+}
+/**
+ * Specify whether the tabs should appear along the top of the folder 
+ * or along the bottom of the folder.
+ * 
+ * @param position <code>SWT.TOP</code> for tabs along the top or <code>SWT.BOTTOM</code> for tabs along the bottom
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the position value is not either SWT.TOP or SWT.BOTTOM</li>
+ * </ul>
+ * 
+ * @since 3.0
+ */
+public void setTabPosition(int position) {
+	checkWidget();
+	if (position != SWT.TOP && position != SWT.BOTTOM) {
+		SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	}
+	if (onBottom != (position == SWT.BOTTOM)) {
+		onBottom = position == SWT.BOTTOM;
+		borderTop = onBottom ? borderLeft : 0;
+		borderBottom = onBottom ? 0 : borderRight;
+		updateTabHeight(true);
+		Rectangle rectBefore = getClientArea();
+		updateItems();
+		Rectangle rectAfter = getClientArea();
+		if (!rectBefore.equals(rectAfter)) {
+			notifyListeners(SWT.Resize, new Event());
+		}
+		redraw();
+	}
+}
+/**
+ * Set the control that appears in the top right corner of the tab folder.
+ * Typically this is a close button or a composite with a Menu and close button. 
+ * The topRight control is optional.  Setting the top right control to null will 
+ * remove it from the tab folder.
+ * 
+ * @param control the control to be displayed in the top right corner or null
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the control is not a child of this CTabFolder</li>
+ * </ul>
+ * 
+ * @since 2.1
+ */
+public void setTopRight(Control control) {
+	setTopRight(control, SWT.RIGHT);
+}
+/**
+ * Set the control that appears in the top right corner of the tab folder.
+ * Typically this is a close button or a composite with a Menu and close button. 
+ * The topRight control is optional.  Setting the top right control to null 
+ * will remove it from the tab folder.
+ * <p>
+ * The alignment parameter sets the layout of the control in the tab area.
+ * <code>SWT.RIGHT</code> will cause the control to be positioned on the far 
+ * right of the folder and it will have its default size.  <code>SWT.FILL</code> 
+ * will size the control to fill all the available space to the right of the
+ * last tab.  If there is no available space, the control will not be visible.
+ * </p>
+ *
+ * @param control the control to be displayed in the top right corner or null
+ * @param alignment <code>SWT.RIGHT</code> or <code>SWT.FILL</code> 
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the control is not a child of this CTabFolder</li>
+ * </ul>
+ * 
+ * @since 3.0
+ */
+public void setTopRight(Control control, int alignment) {
+	checkWidget();
+	if (alignment != SWT.RIGHT && alignment != SWT.FILL) {
+		SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	}
+	if (control != null && control.getParent() != this) {
+		SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	}
+	topRight = control;
+	topRightAlignment = alignment;
+	if (updateItems()) redraw();
+}
+/**
+ * Specify whether the close button appears 
+ * when the user hovers over an unselected tabs.
+ * 
+ * @param visible <code>true</code> makes the close button appear
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.0
+ */
+public void setUnselectedCloseVisible(boolean visible) {
+	checkWidget();
+	if (showUnselectedClose == visible) return;
+	// display close button when mouse hovers
+	showUnselectedClose = visible;
+	updateItems();
+	redraw();
+}
+/**
+ * Specify whether the image appears on unselected tabs.
+ * 
+ * @param visible <code>true</code> makes the image appear
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.0
+ */
+public void setUnselectedImageVisible(boolean visible) {
+	checkWidget();
+	if (showUnselectedImage == visible) return;
+	// display image on unselected items
+	showUnselectedImage = visible;
+	updateItems();
+	redraw();
+}
+/**
+ * Shows the item.  If the item is already showing in the receiver,
+ * this method simply returns.  Otherwise, the items are scrolled until
+ * the item is visible.
+ * 
+ * @param item the item to be shown
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the item is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the item has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see CTabFolder#showSelection()
+ *
+ * @since 2.0
+ */
+public void showItem (CTabItem item) {
+	checkWidget();
+	if (item == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+	if (item.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	int index = indexOf(item);
+	if (index == -1) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	int idx = -1;
+	for (int i = 0; i < priority.length; i++) {
+		if (priority[i] == index) {
+			idx = i;
+			break;
+		}
+	}
+	if (mru) {
+		// move to front of mru order
+		int[] newPriority = new int[priority.length];
+		System.arraycopy(priority, 0, newPriority, 1, idx);
+		System.arraycopy(priority, idx+1, newPriority, idx+1, priority.length - idx - 1);
+		newPriority[0] = index;
+		priority = newPriority;
+	}
+	if (item.isShowing()) return;
+	updateItems(index);
+	redrawTabs();
+}
+void showList (Rectangle rect) {
+	if (items.length == 0 || !showChevron) return;
+	if (showMenu == null || showMenu.isDisposed()) {
+		showMenu = new Menu(this);
+	} else {
+		MenuItem[] items = showMenu.getItems();
+		for (int i = 0; i < items.length; i++) {
+			items[i].dispose();
+		}
+	}
+	final String id = "CTabFolder_showList_Index"; //$NON-NLS-1$
+	for (int i = 0; i < items.length; i++) {
+		CTabItem tab = items[i];
+		if (tab.showing) continue;
+		MenuItem item = new MenuItem(showMenu, SWT.NONE);
+		item.setText(tab.getText());
+		item.setImage(tab.getImage());
+		item.setData(id, tab);
+		item.addSelectionListener(new SelectionAdapter() {
+			public void widgetSelected(SelectionEvent e) {
+				MenuItem menuItem = (MenuItem)e.widget;
+				int index = indexOf((CTabItem)menuItem.getData(id));
+				CTabFolder.this.setSelection(index, true);
+			}
+		});
+	}
+	int x = rect.x;
+	int y = rect.y + rect.height;
+	Point location = getDisplay().map(this, null, x, y);
+	showMenu.setLocation(location.x, location.y);
+	showMenu.setVisible(true);
+}
+/**
+ * Shows the selection.  If the selection is already showing in the receiver,
+ * this method simply returns.  Otherwise, the items are scrolled until
+ * the selection is visible.
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see CTabFolder#showItem(CTabItem)
+ * 
+ * @since 2.0
+ */
+public void showSelection () {
+	checkWidget (); 
+	if (selectedIndex != -1) {
+		showItem(getSelection());
+	}
+}
+
+void _setToolTipText (int x, int y) {
+	String oldTip = getToolTipText();
+	String newTip = _getToolTip(x, y);
+	if (newTip == null || !newTip.equals(oldTip)) {
+		setToolTipText(newTip);
+	}
+}
+
+boolean updateItems() {
+	return updateItems(selectedIndex);
+}
+
+boolean updateItems(int showIndex) {
+	if (!single && !mru && showIndex != -1) {
+		// make sure selected item will be showing
+		int firstIndex = showIndex;
+		if (priority[0] < showIndex) {
+			int maxWidth = getRightItemEdge() - borderLeft;
+			if (!simple) maxWidth -= curveWidth - 2*curveIndent;
+			int width = 0;
+			int[] widths = new int[items.length];
+			GC gc = new GC(this);
+			for (int i = priority[0]; i <= showIndex; i++) {
+				widths[i] = items[i].preferredWidth(gc, i == selectedIndex, true);
+				width += widths[i];
+				if (width > maxWidth) break;
+			}
+			if (width > maxWidth) {
+				width = 0;
+				for (int i = showIndex; i >= 0; i--) {
+					if (widths[i] == 0) widths[i] = items[i].preferredWidth(gc, i == selectedIndex, true);
+					width += widths[i];
+					if (width > maxWidth) break;
+					firstIndex = i;
+				}
+			} else {
+				firstIndex = priority[0];
+				for (int i = showIndex + 1; i < items.length; i++) {
+					widths[i] = items[i].preferredWidth(gc, i == selectedIndex, true);
+					width += widths[i];
+					if (width >= maxWidth) break;
+				}
+				if (width < maxWidth) {
+					for (int i = priority[0] - 1; i >= 0; i--) {
+						if (widths[i] == 0) widths[i] = items[i].preferredWidth(gc, i == selectedIndex, true);
+						width += widths[i];
+						if (width > maxWidth) break;
+						firstIndex = i;
+					}
+				}
+			}
+			gc.dispose();
+		}
+		if (firstIndex != priority[0]) {
+			int index = 0;
+			for (int i = firstIndex; i < items.length; i++) {
+				priority[index++] = i;
+			}
+			for (int i = 0; i < firstIndex; i++) {
+				priority[index++] = i;
+			}
+		}
+	}
+	
+	boolean oldShowChevron = showChevron;
+	boolean changed = setItemSize();
+	changed |= setItemLocation();
+	setButtonBounds();
+	changed |= showChevron != oldShowChevron;
+	if (changed && getToolTipText() != null) {
+		Point pt = getDisplay().getCursorLocation();
+		pt = toControl(pt);
+		_setToolTipText(pt.x, pt.y);
+	}
+	return changed;
+}
+boolean updateTabHeight(boolean force){
+	int style = getStyle();
+	if (fixedTabHeight == 0 && (style & SWT.FLAT) != 0 && (style & SWT.BORDER) == 0) highlight_header = 0;		
+	int oldHeight = tabHeight;
+	if (fixedTabHeight != SWT.DEFAULT) {
+		tabHeight = fixedTabHeight == 0 ? 0 : fixedTabHeight + 1; // +1 for line drawn across top of tab
+	} else {
+		int tempHeight = 0;
+		GC gc = new GC(this);
+		if (items.length == 0) {
+			tempHeight = gc.textExtent("Default", CTabItem.FLAGS).y + CTabItem.TOP_MARGIN + CTabItem.BOTTOM_MARGIN; //$NON-NLS-1$
+		} else {
+			for (int i=0; i < items.length; i++) {
+				tempHeight = Math.max(tempHeight, items[i].preferredHeight(gc));
+			}
+		}
+		gc.dispose();
+		tabHeight =  tempHeight;
+	}
+	if (!force && tabHeight == oldHeight) return false;
+	
+	oldSize = null;
+	if (onBottom) {
+		int d = tabHeight - 12;
+		curve = new int[]{0,13+d, 0,12+d, 2,12+d, 3,11+d, 5,11+d, 6,10+d, 7,10+d, 9,8+d, 10,8+d,
+				          11,7+d, 11+d,7,
+						  12+d,6, 13+d,6, 15+d,4, 16+d,4, 17+d,3, 19+d,3, 20+d,2, 22+d,2, 23+d,1}; 
+		curveWidth = 26+d;
+		curveIndent = curveWidth/3;	
+	} else {
+		int d = tabHeight - 12;
+		curve = new int[]{0,0, 0,1, 2,1, 3,2, 5,2, 6,3, 7,3, 9,5, 10,5,
+				          11,6, 11+d,6+d,
+				          12+d,7+d, 13+d,7+d, 15+d,9+d, 16+d,9+d, 17+d,10+d, 19+d,10+d, 20+d,11+d, 22+d,11+d, 23+d,12+d};
+		curveWidth = 26+d;
+		curveIndent = curveWidth/3;
+		
+		//this could be static but since values depend on curve, better to keep in one place
+		topCurveHighlightStart = new int[] { 
+				0, 2,  1, 2,  2, 2,    
+				3, 3,  4, 3,  5, 3, 
+				6, 4,  7, 4,
+				8, 5, 
+				9, 6, 10, 6};
+		
+		//also, by adding in 'd' here we save some math cost when drawing the curve
+		topCurveHighlightEnd = new int[] { 
+				10+d, 6+d,
+				11+d, 7+d,
+				12+d, 8+d,  13+d, 8+d,
+				14+d, 9+d,
+				15+d, 10+d,  16+d, 10+d,
+				17+d, 11+d,  18+d, 11+d,  19+d, 11+d,
+				20+d, 12+d,  21+d, 12+d,  22+d,  12+d }; 
+	}
+	notifyListeners(SWT.Resize, new Event());
+	return true;
+}
+String _getToolTip(int x, int y) {
+	if (showMin && minRect.contains(x, y)) return minimized ? SWT.getMessage("SWT_Restore") : SWT.getMessage("SWT_Minimize"); //$NON-NLS-1$ //$NON-NLS-2$
+	if (showMax && maxRect.contains(x, y)) return maximized ? SWT.getMessage("SWT_Restore") : SWT.getMessage("SWT_Maximize"); //$NON-NLS-1$ //$NON-NLS-2$
+	if (showChevron && chevronRect.contains(x, y)) return SWT.getMessage("SWT_ShowList"); //$NON-NLS-1$
+	CTabItem item = getItem(new Point (x, y));
+	if (item == null) return null;
+	if (!item.showing) return null;
+	if ((showClose || item.showClose) && item.closeRect.contains(x, y)) {
+		return SWT.getMessage("SWT_Close"); //$NON-NLS-1$
+	}
+	return item.getToolTipText();
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/custom/CTabFolder2Adapter.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/custom/CTabFolder2Adapter.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/custom/CTabFolder2Adapter.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,83 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.custom;
+
+/**
+ * This adapter class provides default implementations for the
+ * methods described by the <code>CTabFolder2Listener</code> interface.
+ * <p>
+ * Classes that wish to deal with <code>CTabFolderEvent</code>s can
+ * extend this class and override only the methods which they are
+ * interested in.
+ * </p>
+ *
+ * @see CTabFolder2Listener
+ * @see CTabFolderEvent
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ * 
+ * @since 3.0
+ */
+public class CTabFolder2Adapter implements CTabFolder2Listener {
+	
+/**
+ * Sent when the user clicks on the close button of an item in the CTabFolder.  The item being closed is specified
+ * in the event.item field. Setting the event.doit field to false will stop  the CTabItem from closing. 
+ * When the CTabItem is closed, it is disposed.  The contents of the CTabItem (see CTabItem#setControl) will be 
+ * made not visible when the CTabItem is closed.
+ * <p>
+ * The default behaviour is to close the CTabItem.
+ * </p>
+ * 
+ * @param event an event indicating the item being closed
+ */
+public void close(CTabFolderEvent event){}
+
+/**
+ * Sent when the user clicks on the minimize button of a CTabFolder.
+ * <p>
+ * The default behaviour is to do nothing.
+ * </p>
+ * 
+ * @param event an event containing information about the minimize
+ */
+public void minimize(CTabFolderEvent event){}
+
+/**
+ * Sent when the user clicks on the maximize button of a CTabFolder.
+ * <p>
+ * The default behaviour is to do nothing.
+ * </p>
+ * 
+ * @param event an event containing information about the maximize
+ */
+public void maximize(CTabFolderEvent event){}
+
+/**
+ * Sent when the user clicks on the restore button of a CTabFolder.
+ * <p>
+ * The default behaviour is to do nothing.
+ * </p>
+ * 
+ * @param event an event containing information about the restore
+ */
+public void restore(CTabFolderEvent event){}
+
+/**
+ * Sent when the user clicks on the chevron button of a CTabFolder.
+ * <p>
+ * The default behaviour is to show a list of items that are not currently 
+ * visible and to change the selection based on the item selected from the list.
+ * </p>
+ * 
+ * @param event an event containing information about the show list
+ */
+public void showList(CTabFolderEvent event){}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/custom/CTabFolder2Listener.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/custom/CTabFolder2Listener.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/custom/CTabFolder2Listener.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,112 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.custom;
+
+import org.eclipse.swt.internal.*;
+
+/**
+ * Classes which implement this interface provide methods
+ * that deal with the events that are generated by the CTabFolder 
+ * control.
+ * <p>
+ * After creating an instance of a class that implements
+ * this interface it can be added to a CTabFolder using the
+ * <code>addCTabFolder2Listener</code> method and removed using
+ * the <code>removeCTabFolder2Listener</code> method. When
+ * events occurs in a CTabFolder the appropriate method
+ * will be invoked.
+ * </p>
+ *
+ * @see CTabFolder2Adapter
+ * @see CTabFolderEvent
+ * 
+ * @since 3.0
+ */
+public interface CTabFolder2Listener extends SWTEventListener {
+	
+/**
+ * Sent when the user clicks on the close button of an item in the CTabFolder.
+ * The item being closed is specified in the event.item field. 
+ * Setting the event.doit field to false will stop the CTabItem from closing. 
+ * When the CTabItem is closed, it is disposed.  The contents of the 
+ * CTabItem (see CTabItem.setControl) will be made not visible when
+ * the CTabItem is closed.
+ * 
+ * @param event an event indicating the item being closed
+ */
+public void close(CTabFolderEvent event);
+
+/**
+ * Sent when the user clicks on the minimize button of a CTabFolder.
+ * The state of the CTabFolder does not change automatically - it 
+ * is up to the application to change the state of the CTabFolder
+ * in response to this event using CTabFolder.setMinimized(true).
+ * 
+ * @param event an event containing information about the minimize
+ * 
+ * @see CTabFolder#getMinimized()
+ * @see CTabFolder#setMinimized(boolean)
+ * @see CTabFolder#setMinimizeVisible(boolean)
+ */
+public void minimize(CTabFolderEvent event);
+
+/**
+ * Sent when the user clicks on the maximize button of a CTabFolder.
+ * The state of the CTabFolder does not change automatically - it 
+ * is up to the application to change the state of the CTabFolder
+ * in response to this event using CTabFolder.setMaximized(true).
+ * 
+ * @param event an event containing information about the maximize
+ * 
+ * @see CTabFolder#getMaximized()
+ * @see CTabFolder#setMaximized(boolean)
+ * @see CTabFolder#setMaximizeVisible(boolean)
+ */
+public void maximize(CTabFolderEvent event);
+
+/**
+ * Sent when the user clicks on the restore button of a CTabFolder.
+ * This event is sent either to restore the CTabFolder from the 
+ * minimized state or from the maximized state.  To determine
+ * which restore is requested, use CTabFolder.getMinimized() or
+ * CTabFolder.getMaximized() to determine the current state.
+ * The state of the CTabFolder does not change automatically - it 
+ * is up to the application to change the state of the CTabFolder
+ * in response to this event using CTabFolder.setMaximized(false)
+ * or CTabFolder.setMinimized(false).
+ * 
+ * @param event an event containing information about the restore
+ * 
+ * @see CTabFolder#getMinimized()
+ * @see CTabFolder#getMaximized()
+ * @see CTabFolder#setMinimized(boolean)
+ * @see CTabFolder#setMinimizeVisible(boolean)
+ * @see CTabFolder#setMaximized(boolean)
+ * @see CTabFolder#setMaximizeVisible(boolean)
+ */
+public void restore(CTabFolderEvent event);
+
+/**
+ * Sent when the user clicks on the chevron button of the CTabFolder.
+ * A chevron appears in the CTabFolder when there are more tabs 
+ * than can be displayed at the current widget size.  To select a 
+ * tab that is not currently visible, the user clicks on the
+ * chevron and selects a tab item from a list.  By default, the
+ * CTabFolder provides a list of all the items that are not currently
+ * visible, however, the application can provide its own list by setting 
+ * the event.doit field to <code>false</code> and displaying a selection list.
+ * 
+ * @param event an event containing information about the show list  
+ * 
+ * @see CTabFolder#setSelection(CTabItem)
+ */
+public void showList(CTabFolderEvent event);
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/custom/CTabFolderAdapter.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/custom/CTabFolderAdapter.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/custom/CTabFolderAdapter.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.custom;
+
+
+/**
+ * This adapter class provides a default implementation for the
+ * method described by the <code>CTabFolderListener</code> interface.
+ * 
+ * @see CTabFolderListener
+ * @see CTabFolderEvent
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public class CTabFolderAdapter implements CTabFolderListener {
+	public void itemClosed(CTabFolderEvent event){}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/custom/CTabFolderEvent.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/custom/CTabFolderEvent.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/custom/CTabFolderEvent.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,92 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.custom;
+
+
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.widgets.*;
+
+/**
+ * This event is sent when an event is generated in the CTabFolder.
+ *
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a> 
+ */
+public class CTabFolderEvent extends TypedEvent {
+	/**
+	 * The tab item for the operation.
+	 */
+ 	public Widget item;
+
+ 	/**
+	 * A flag indicating whether the operation should be allowed.
+	 * Setting this field to <code>false</code> will cancel the operation.
+	 * Applies to the close and showList events.
+	 */
+ 	public boolean doit;
+
+	/**
+	 * The widget-relative, x coordinate of the chevron button
+	 * at the time of the event.  Applies to the showList event.
+	 * 
+ 	 * @since 3.0
+	 */
+ 	public int x;
+ 	/**
+ 	 * The widget-relative, y coordinate of the chevron button
+	 * at the time of the event.  Applies to the showList event.
+	 * 
+	 * @since 3.0
+	 */
+	public int y;
+	/**
+	 * The width of the chevron button at the time of the event.
+	 * Applies to the showList event.
+	 * 
+	 * @since 3.0
+	 */
+	public int width;
+	/**
+	 * The height of the chevron button at the time of the event.
+	 * Applies to the showList event.
+	 * 
+	 * @since 3.0
+	 */
+	public int height;
+
+	static final long serialVersionUID = 3760566386225066807L;
+	
+/**
+ * Constructs a new instance of this class.
+ *
+ * @param w the widget that fired the event
+ */
+CTabFolderEvent(Widget w) {
+	super(w);
+}
+
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the event
+ */
+public String toString() {
+	String string = super.toString ();
+	return string.substring (0, string.length() - 1) // remove trailing '}'
+		+ " item=" + item
+		+ " doit=" + doit
+		+ " x=" + x
+		+ " y=" + y
+		+ " width=" + width
+		+ " height=" + height
+		+ "}";
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/custom/CTabFolderLayout.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/custom/CTabFolderLayout.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/custom/CTabFolderLayout.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,82 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.custom;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+
+/**
+ * This class provides the layout for CTabFolder
+ * 
+ * @see CTabFolder
+ */
+class CTabFolderLayout extends Layout {
+protected Point computeSize(Composite composite, int wHint, int hHint, boolean flushCache) {
+	CTabFolder folder = (CTabFolder)composite;
+	CTabItem[] items = folder.items;
+	// preferred width of tab area to show all tabs
+	int tabW = 0;
+	GC gc = new GC(folder);
+	for (int i = 0; i < items.length; i++) {
+		if (folder.single) {
+			tabW = Math.max(tabW, items[i].preferredWidth(gc, true, false));
+		} else {
+			tabW += items[i].preferredWidth(gc, i == folder.selectedIndex, false);
+		}
+	}
+	gc.dispose();
+	tabW += 3;
+	if (folder.showMax) tabW += CTabFolder.BUTTON_SIZE;
+	if (folder.showMin) tabW += CTabFolder.BUTTON_SIZE;
+	if (folder.single) tabW += 3*CTabFolder.BUTTON_SIZE/2; //chevron
+	if (folder.topRight != null) {
+		Point pt = folder.topRight.computeSize(SWT.DEFAULT, folder.tabHeight, flushCache);
+		tabW += 3 + pt.x;
+	}
+	if (!folder.single && !folder.simple) tabW += folder.curveWidth - 2*folder.curveIndent;
+	
+	int controlW = 0;
+	int controlH = 0;
+	// preferred size of controls in tab items
+	for (int i = 0; i < items.length; i++) {
+		Control control = items[i].getControl();
+		if (control != null && !control.isDisposed()){
+			Point size = control.computeSize (wHint, hHint, flushCache);
+			controlW = Math.max (controlW, size.x);
+			controlH = Math.max (controlH, size.y);
+		}
+	}
+
+	int minWidth = Math.max(tabW, controlW);
+	int minHeight = (folder.minimized) ? 0 : controlH;
+	if (minWidth == 0) minWidth = CTabFolder.DEFAULT_WIDTH;
+	if (minHeight == 0) minHeight = CTabFolder.DEFAULT_HEIGHT;
+	
+	if (wHint != SWT.DEFAULT) minWidth  = wHint;
+	if (hHint != SWT.DEFAULT) minHeight = hHint;
+	
+	return new Point (minWidth, minHeight);
+}
+protected boolean flushCache(Control control) {
+	return true;
+}
+protected void layout(Composite composite, boolean flushCache) {
+	CTabFolder folder = (CTabFolder)composite;
+	// resize content
+	if (folder.selectedIndex != -1) {
+		Control control = folder.items[folder.selectedIndex].getControl();
+		if (control != null && !control.isDisposed()) {
+			control.setBounds(folder.getClientArea());
+		}
+	}
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/custom/CTabFolderListener.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/custom/CTabFolderListener.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/custom/CTabFolderListener.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.custom;
+
+import org.eclipse.swt.internal.*;
+
+/**
+ * Classes which implement this interface provide a method
+ * that deals with events generated in the CTabFolder.
+ * <p>
+ * After creating an instance of a class that implements
+ * this interface it can be added to a CTabFolder using the
+ * <code>addCTabFolderListener</code> method and removed using
+ * the <code>removeCTabFolderListener</code> method. When a
+ * tab item is closed, the itemClosed method will be invoked.
+ * </p>
+ *
+ * @see CTabFolderEvent
+ */
+public interface CTabFolderListener extends SWTEventListener {
+	
+/**
+ * Sent when the user clicks on the close button of an item in the CTabFolder.  The item being closed is specified
+ * in the event.item field. Setting the event.doit field to false will stop the CTabItem from closing. 
+ * When the CTabItem is closed, it is disposed.  The contents of the CTabItem (see CTabItem.setControl) will be 
+ * made not visible when the CTabItem is closed.
+ * 
+ * @param event an event indicating the item being closed
+ * 
+ * @see CTabItem#setControl
+ */
+public void itemClosed(CTabFolderEvent event);
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/custom/CTabItem.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/custom/CTabItem.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/custom/CTabItem.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,1053 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.custom;
+
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+
+/**
+ * Instances of this class represent a selectable user interface object
+ * that represent a page in a notebook widget.
+ * 
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>SWT.CLOSE</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>(none)</dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ *
+ * @see <a href="http://www.eclipse.org/swt/snippets/#ctabfolder">CTabFolder, CTabItem snippets</a>
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public class CTabItem extends Item {
+	CTabFolder parent;
+	int x,y,width,height = 0;
+	Control control; // the tab page
+	
+	String toolTipText;
+	String shortenedText;
+	int shortenedTextWidth;
+	
+	// Appearance
+	Font font;
+	Image disabledImage; 
+	
+	Rectangle closeRect = new Rectangle(0, 0, 0, 0);
+	int closeImageState = CTabFolder.NONE;
+	boolean showClose = false;
+	boolean showing = false;
+
+	// internal constants
+	static final int TOP_MARGIN = 2;
+	static final int BOTTOM_MARGIN = 2;
+	static final int LEFT_MARGIN = 4;
+	static final int RIGHT_MARGIN = 4;
+	static final int INTERNAL_SPACING = 4;
+	static final int FLAGS = SWT.DRAW_TRANSPARENT | SWT.DRAW_MNEMONIC;
+	static final String ELLIPSIS = "..."; //$NON-NLS-1$ // could use the ellipsis glyph on some platforms "\u2026"
+	
+/**
+ * Constructs a new instance of this class given its parent
+ * (which must be a <code>CTabFolder</code>) and a style value
+ * describing its behavior and appearance. The item is added
+ * to the end of the items maintained by its parent.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a CTabFolder which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * </ul>
+ *
+ * @see SWT
+ * @see Widget#getStyle()
+ */
+public CTabItem (CTabFolder parent, int style) {
+	this(parent, style, parent.getItemCount());
+}
+/**
+ * Constructs a new instance of this class given its parent
+ * (which must be a <code>CTabFolder</code>), a style value
+ * describing its behavior and appearance, and the index
+ * at which to place it in the items maintained by its parent.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a CTabFolder which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ * @param index the zero-relative index to store the receiver in its parent
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the parent (inclusive)</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * </ul>
+ *
+ * @see SWT
+ * @see Widget#getStyle()
+ */
+public CTabItem (CTabFolder parent, int style, int index) {
+	super (parent, style);
+	showClose = (style & SWT.CLOSE) != 0;
+	parent.createItem (this, index);
+}
+
+/*
+ * Return whether to use ellipses or just truncate labels
+ */
+boolean useEllipses() {
+	return parent.simple;
+}
+
+String shortenText(GC gc, String text, int width) {
+	return useEllipses()
+		? shortenText(gc, text, width, ELLIPSIS)
+		: shortenText(gc, text, width, ""); //$NON-NLS-1$
+}
+
+String shortenText(GC gc, String text, int width, String ellipses) {
+	if (gc.textExtent(text, FLAGS).x <= width) return text;
+	int ellipseWidth = gc.textExtent(ellipses, FLAGS).x;
+	int length = text.length();
+	TextLayout layout = new TextLayout(getDisplay());
+	layout.setText(text);
+	int end = layout.getPreviousOffset(length, SWT.MOVEMENT_CLUSTER);
+	while (end > 0) {
+		text = text.substring(0, end);
+		int l = gc.textExtent(text, FLAGS).x;
+		if (l + ellipseWidth <= width) {
+			break;
+		}
+		end = layout.getPreviousOffset(end, SWT.MOVEMENT_CLUSTER);
+	}
+	layout.dispose();
+	return end == 0 ? text.substring(0, 1) : text + ellipses;
+}
+
+public void dispose() {
+	if (isDisposed ()) return;
+	//if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+	parent.destroyItem(this);
+	super.dispose();
+	parent = null;
+	control = null;
+	toolTipText = null;
+	shortenedText = null;
+	font = null;
+}
+void drawClose(GC gc) {
+	if (closeRect.width == 0 || closeRect.height == 0) return;
+	Display display = getDisplay();
+
+	// draw X 9x9
+	int indent = Math.max(1, (CTabFolder.BUTTON_SIZE-9)/2);
+	int x = closeRect.x + indent;
+	int y = closeRect.y + indent;
+	y += parent.onBottom ? -1 : 1;
+	
+	Color closeBorder = display.getSystemColor(CTabFolder.BUTTON_BORDER);
+	switch (closeImageState) {
+		case CTabFolder.NORMAL: {
+			int[] shape = new int[] {x,y, x+2,y, x+4,y+2, x+5,y+2, x+7,y, x+9,y, 
+					                 x+9,y+2, x+7,y+4, x+7,y+5, x+9,y+7, x+9,y+9,
+			                         x+7,y+9, x+5,y+7, x+4,y+7, x+2,y+9, x,y+9,
+			                         x,y+7, x+2,y+5, x+2,y+4, x,y+2};
+			gc.setBackground(display.getSystemColor(CTabFolder.BUTTON_FILL));
+			gc.fillPolygon(shape);
+			gc.setForeground(closeBorder);
+			gc.drawPolygon(shape);
+			break;
+		}
+		case CTabFolder.HOT: {
+			int[] shape = new int[] {x,y, x+2,y, x+4,y+2, x+5,y+2, x+7,y, x+9,y, 
+					                 x+9,y+2, x+7,y+4, x+7,y+5, x+9,y+7, x+9,y+9,
+			                         x+7,y+9, x+5,y+7, x+4,y+7, x+2,y+9, x,y+9,
+			                         x,y+7, x+2,y+5, x+2,y+4, x,y+2};
+			Color fill = new Color(display, CTabFolder.CLOSE_FILL);
+			gc.setBackground(fill);
+			gc.fillPolygon(shape);
+			fill.dispose();
+			gc.setForeground(closeBorder);
+			gc.drawPolygon(shape);
+			break;
+		}
+		case CTabFolder.SELECTED: {
+			int[] shape = new int[] {x+1,y+1, x+3,y+1, x+5,y+3, x+6,y+3, x+8,y+1, x+10,y+1, 
+					                 x+10,y+3, x+8,y+5, x+8,y+6, x+10,y+8, x+10,y+10,
+			                         x+8,y+10, x+6,y+8, x+5,y+8, x+3,y+10, x+1,y+10,
+			                         x+1,y+8, x+3,y+6, x+3,y+5, x+1,y+3};
+			Color fill = new Color(display, CTabFolder.CLOSE_FILL);
+			gc.setBackground(fill);
+			gc.fillPolygon(shape);
+			fill.dispose();
+			gc.setForeground(closeBorder);
+			gc.drawPolygon(shape);
+			break;
+		}
+		case CTabFolder.NONE: {
+			int[] shape = new int[] {x,y, x+10,y, x+10,y+10, x,y+10};
+			if (parent.gradientColors != null && !parent.gradientVertical) {
+				parent.drawBackground(gc, shape, false);
+			} else {
+				Color defaultBackground = parent.getBackground();
+				Image image = parent.bgImage;
+				Color[] colors = parent.gradientColors;
+				int[] percents = parent.gradientPercents;
+				boolean vertical = parent.gradientVertical; 
+				parent.drawBackground(gc, shape, x, y, 10, 10, defaultBackground, image, colors, percents, vertical);
+			}
+			break;
+		}
+	}
+}
+void drawSelected(GC gc ) {
+	Point size = parent.getSize();
+	int rightEdge = Math.min (x + width, parent.getRightItemEdge());
+	
+	//	 Draw selection border across all tabs
+	int xx = parent.borderLeft;
+	int yy = parent.onBottom ? size.y - parent.borderBottom - parent.tabHeight - parent.highlight_header : parent.borderTop + parent.tabHeight + 1;
+	int ww = size.x - parent.borderLeft - parent.borderRight;
+	int hh = parent.highlight_header - 1;
+	int[] shape = new int[] {xx,yy, xx+ww,yy, xx+ww,yy+hh, xx,yy+hh};
+	if (parent.selectionGradientColors != null && !parent.selectionGradientVertical) {
+		parent.drawBackground(gc, shape, true);
+	} else {
+		gc.setBackground(parent.selectionBackground);
+		gc.fillRectangle(xx, yy, ww, hh);
+	}
+	
+	if (parent.single) {
+		if (!showing) return;
+	} else {
+		// if selected tab scrolled out of view or partially out of view
+		// just draw bottom line
+		if (!showing){
+			int x1 = Math.max(0, parent.borderLeft - 1);
+			int y1 = (parent.onBottom) ? y - 1 : y + height;
+			int x2 = size.x - parent.borderRight;
+			gc.setForeground(CTabFolder.borderColor);
+			gc.drawLine(x1, y1, x2, y1);
+			return;
+		}
+			
+		// draw selected tab background and outline
+		shape = null;
+		if (this.parent.onBottom) {
+			int[] left = parent.simple ? CTabFolder.SIMPLE_BOTTOM_LEFT_CORNER : CTabFolder.BOTTOM_LEFT_CORNER;
+			int[] right = parent.simple ? CTabFolder.SIMPLE_BOTTOM_RIGHT_CORNER : parent.curve;
+			if (parent.borderLeft == 0 && parent.indexOf(this) == parent.firstIndex) {
+				left = new int[]{x, y+height};
+			}
+			shape = new int[left.length+right.length+8];
+			int index = 0;
+			shape[index++] = x; // first point repeated here because below we reuse shape to draw outline
+			shape[index++] = y - 1;
+			shape[index++] = x;
+			shape[index++] = y - 1;
+			for (int i = 0; i < left.length/2; i++) {
+				shape[index++] = x + left[2*i];
+				shape[index++] = y + height + left[2*i+1] - 1;
+			}
+			for (int i = 0; i < right.length/2; i++) {
+				shape[index++] = parent.simple ? rightEdge - 1 + right[2*i] : rightEdge - parent.curveIndent + right[2*i];
+				shape[index++] = parent.simple ? y + height + right[2*i+1] - 1 : y + right[2*i+1] - 2;
+			}
+			shape[index++] = parent.simple ? rightEdge - 1 : rightEdge + parent.curveWidth - parent.curveIndent;
+			shape[index++] = y - 1;
+			shape[index++] = parent.simple ? rightEdge - 1 : rightEdge + parent.curveWidth - parent.curveIndent;
+			shape[index++] = y - 1;
+		} else {
+			int[] left = parent.simple ? CTabFolder.SIMPLE_TOP_LEFT_CORNER : CTabFolder.TOP_LEFT_CORNER;
+			int[] right = parent.simple ? CTabFolder.SIMPLE_TOP_RIGHT_CORNER : parent.curve;
+			if (parent.borderLeft == 0 && parent.indexOf(this) == parent.firstIndex) {
+				left = new int[]{x, y};
+			}
+			shape = new int[left.length+right.length+8];
+			int index = 0;
+			shape[index++] = x; // first point repeated here because below we reuse shape to draw outline
+			shape[index++] = y + height + 1;
+			shape[index++] = x;
+			shape[index++] = y + height + 1;
+			for (int i = 0; i < left.length/2; i++) {
+				shape[index++] = x + left[2*i];
+				shape[index++] = y + left[2*i+1];
+			}
+			for (int i = 0; i < right.length/2; i++) {
+				shape[index++] = parent.simple ? rightEdge - 1 + right[2*i] : rightEdge - parent.curveIndent + right[2*i];
+				shape[index++] = y + right[2*i+1];
+			}
+			shape[index++] = parent.simple ? rightEdge - 1 : rightEdge + parent.curveWidth - parent.curveIndent;
+			shape[index++] = y + height + 1;
+			shape[index++] = parent.simple ? rightEdge - 1 : rightEdge + parent.curveWidth - parent.curveIndent;
+			shape[index++] = y + height + 1;
+		}
+		
+		Rectangle clipping = gc.getClipping();
+		Rectangle bounds = getBounds();
+		bounds.height += 1;
+		if (parent.onBottom) bounds.y -= 1;
+		boolean tabInPaint = clipping.intersects(bounds);
+		
+		if (tabInPaint) {
+			// fill in tab background
+			if (parent.selectionGradientColors != null && !parent.selectionGradientVertical) {
+				parent.drawBackground(gc, shape, true);
+			} else {
+				Color defaultBackground = parent.selectionBackground;
+				Image image = parent.selectionBgImage;
+				Color[] colors = parent.selectionGradientColors;
+				int[] percents = parent.selectionGradientPercents;
+				boolean vertical = parent.selectionGradientVertical;
+				xx = x;
+				yy = parent.onBottom ? y -1 : y + 1;
+				ww = width;
+				hh = height;
+				if (!parent.single && !parent.simple) ww += parent.curveWidth - parent.curveIndent;
+				parent.drawBackground(gc, shape, xx, yy, ww, hh, defaultBackground, image, colors, percents, vertical);
+			}
+		}
+		
+		//Highlight MUST be drawn before the outline so that outline can cover it in the right spots (start of swoop)
+		//otherwise the curve looks jagged
+		drawHighlight(gc, rightEdge);
+
+		// draw outline
+		shape[0] = Math.max(0, parent.borderLeft - 1);
+		if (parent.borderLeft == 0 && parent.indexOf(this) == parent.firstIndex) {
+			shape[1] = parent.onBottom ? y + height - 1 : y; 
+			shape[5] = shape[3] = shape[1];
+		}
+		shape[shape.length - 2] = size.x - parent.borderRight + 1;
+		for (int i = 0; i < shape.length/2; i++) {
+			if (shape[2*i + 1] == y + height + 1) shape[2*i + 1] -= 1;
+		}
+		RGB inside = parent.selectionBackground.getRGB();
+		if (parent.selectionBgImage != null || 
+		    (parent.selectionGradientColors != null && parent.selectionGradientColors.length > 1)) {
+		    inside = null;
+		}
+		RGB outside = parent.getBackground().getRGB();		
+		if (parent.bgImage != null || 
+		    (parent.gradientColors != null && parent.gradientColors.length > 1)) {
+		    outside = null;
+		}
+		parent.antialias(shape, CTabFolder.borderColor.getRGB(), inside, outside, gc);
+		gc.setForeground(CTabFolder.borderColor);
+		gc.drawPolyline(shape);
+		
+		if (!tabInPaint) return;
+	}
+	
+	// draw Image
+	int xDraw = x + LEFT_MARGIN;
+	if (parent.single && (parent.showClose || showClose)) xDraw += CTabFolder.BUTTON_SIZE; 
+	Image image = getImage();
+	if (image != null) {
+		Rectangle imageBounds = image.getBounds();
+		// only draw image if it won't overlap with close button
+		int maxImageWidth = rightEdge - xDraw - RIGHT_MARGIN;
+		if (!parent.single && closeRect.width > 0) maxImageWidth -= closeRect.width + INTERNAL_SPACING;
+		if (imageBounds.width < maxImageWidth) {
+			int imageX = xDraw;
+			int imageY = y + (height - imageBounds.height) / 2;
+			imageY += parent.onBottom ? -1 : 1;
+			gc.drawImage(image, imageX, imageY);
+			xDraw += imageBounds.width + INTERNAL_SPACING;
+		}
+	}
+	
+	// draw Text
+	int textWidth = rightEdge - xDraw - RIGHT_MARGIN;
+	if (!parent.single && closeRect.width > 0) textWidth -= closeRect.width + INTERNAL_SPACING;
+	if (textWidth > 0) {
+		Font gcFont = gc.getFont();
+		gc.setFont(font == null ? parent.getFont() : font);
+		
+		if (shortenedText == null || shortenedTextWidth != textWidth) {
+			shortenedText = shortenText(gc, getText(), textWidth);
+			shortenedTextWidth = textWidth;
+		}
+		Point extent = gc.textExtent(shortenedText, FLAGS);	
+		int textY = y + (height - extent.y) / 2;
+		textY += parent.onBottom ? -1 : 1;
+		
+		gc.setForeground(parent.selectionForeground);
+		gc.drawText(shortenedText, xDraw, textY, FLAGS);
+		gc.setFont(gcFont);
+		
+		// draw a Focus rectangle
+		if (parent.isFocusControl()) {
+			Display display = getDisplay();
+			if (parent.simple || parent.single) {
+				gc.setBackground(display.getSystemColor(SWT.COLOR_BLACK));
+				gc.setForeground(display.getSystemColor(SWT.COLOR_WHITE));
+				gc.drawFocus(xDraw-1, textY-1, extent.x+2, extent.y+2);
+			} else {
+				gc.setForeground(display.getSystemColor(CTabFolder.BUTTON_BORDER));
+				gc.drawLine(xDraw, textY+extent.y+1, xDraw+extent.x+1, textY+extent.y+1);
+			}
+		}
+	}
+	if (parent.showClose || showClose) drawClose(gc);
+}
+
+/*
+ * Draw a highlight effect along the left, top, and right edges of the tab.
+ * Only for curved tabs, on top.
+ * Do not draw if insufficient colors.
+ */
+void drawHighlight(GC gc, int rightEdge) {
+	//only draw for curvy tabs and only draw for top tabs
+	if(parent.simple || this.parent.onBottom)
+		return;
+	
+	if(parent.selectionHighlightGradientBegin == null)
+		return;
+	
+	Color[] gradients = parent.selectionHighlightGradientColorsCache;
+	if(gradients == null)
+		return;
+	int gradientsSize = gradients.length;
+	if(gradientsSize == 0)
+		return;		//shouldn't happen but just to be tidy
+
+	gc.setForeground(gradients[0]);
+	
+	//draw top horizontal line
+	gc.drawLine(
+			CTabFolder.TOP_LEFT_CORNER_HILITE[0] + x + 1, //rely on fact that first pair is top/right of curve
+			1 + y,
+			rightEdge - parent.curveIndent,
+			1 + y);
+	
+	int[] leftHighlightCurve = CTabFolder.TOP_LEFT_CORNER_HILITE;
+
+	int d = parent.tabHeight - parent.topCurveHighlightEnd.length /2;
+
+	int lastX = 0;
+	int lastY = 0;
+	int lastColorIndex = 0;
+	
+	//draw upper left curve highlight
+	for (int i = 0; i < leftHighlightCurve.length /2; i++) {
+		int rawX = leftHighlightCurve[i * 2];
+		int rawY = leftHighlightCurve[i * 2 + 1];
+		lastX = rawX + x;
+		lastY = rawY + y;
+		lastColorIndex = rawY - 1;
+		gc.setForeground(gradients[lastColorIndex]);
+		gc.drawPoint(lastX, lastY);
+	}
+	//draw left vertical line highlight
+	for(int i = lastColorIndex; i < gradientsSize; i++) {
+		gc.setForeground(gradients[i]);
+		gc.drawPoint(lastX, 1 + lastY++);
+	}
+	
+	int rightEdgeOffset = rightEdge - parent.curveIndent;
+	
+	//draw right swoop highlight up to diagonal portion
+	for (int i = 0; i < parent.topCurveHighlightStart.length /2; i++) {
+		int rawX = parent.topCurveHighlightStart[i * 2];
+		int rawY = parent.topCurveHighlightStart[i * 2 + 1];
+		lastX = rawX + rightEdgeOffset;
+		lastY = rawY + y;
+		lastColorIndex = rawY - 1;
+		if(lastColorIndex >= gradientsSize)
+			break;	//can happen if tabs are unusually short and cut off the curve
+		gc.setForeground(gradients[lastColorIndex]);
+		gc.drawPoint(lastX, lastY);
+	}
+	//draw right diagonal line highlight
+	for(int i = lastColorIndex; i < lastColorIndex + d; i++) {
+		if(i >= gradientsSize)
+			break;	//can happen if tabs are unusually short and cut off the curve
+		gc.setForeground(gradients[i]);
+		gc.drawPoint(1 + lastX++, 1 + lastY++);
+	}
+
+	//draw right swoop highlight from diagonal portion to end
+	for (int i = 0; i < parent.topCurveHighlightEnd.length /2; i++) {
+		int rawX = parent.topCurveHighlightEnd[i * 2]; //d is already encoded in this value
+		int rawY = parent.topCurveHighlightEnd[i * 2 + 1]; //d already encoded
+		lastX = rawX + rightEdgeOffset;
+		lastY = rawY + y;
+		lastColorIndex = rawY - 1;
+		if(lastColorIndex >= gradientsSize)
+			break;	//can happen if tabs are unusually short and cut off the curve
+		gc.setForeground(gradients[lastColorIndex]);
+		gc.drawPoint(lastX, lastY);
+	}	
+}
+
+/*
+ * Draw the unselected border for the receiver on the right.
+ * 
+ * @param gc
+ */
+void drawRightUnselectedBorder(GC gc) {
+
+	int[] shape = null;
+	int startX = x + width - 1;
+
+	if (this.parent.onBottom) {
+		int[] right = parent.simple
+			? CTabFolder.SIMPLE_UNSELECTED_INNER_CORNER
+			: CTabFolder.BOTTOM_RIGHT_CORNER;
+		
+		shape = new int[right.length + 2];
+		int index = 0;
+		
+		for (int i = 0; i < right.length / 2; i++) {
+			shape[index++] = startX + right[2 * i];
+			shape[index++] = y + height + right[2 * i + 1] - 1;
+		}
+		shape[index++] = startX;
+		shape[index++] = y - 1;
+	} else {
+		int[] right = parent.simple
+			? CTabFolder.SIMPLE_UNSELECTED_INNER_CORNER
+			: CTabFolder.TOP_RIGHT_CORNER;
+		
+		shape = new int[right.length + 2];
+		int index = 0;
+
+		for (int i = 0; i < right.length / 2; i++) {
+			shape[index++] = startX + right[2 * i];
+			shape[index++] = y + right[2 * i + 1];
+		}
+
+		shape[index++] = startX;
+		shape[index++] = y + height;
+
+	}
+
+	drawBorder(gc, shape);
+
+}
+
+/*
+ * Draw the border of the tab
+ * 
+ * @param gc
+ * @param shape
+ */
+void drawBorder(GC gc, int[] shape) {
+
+	gc.setForeground(CTabFolder.borderColor);
+	gc.drawPolyline(shape);
+}
+
+/*
+ * Draw the unselected border for the receiver on the left.
+ * 
+ * @param gc
+ */
+void drawLeftUnselectedBorder(GC gc) {
+
+	int[] shape = null;
+	if (this.parent.onBottom) {
+		int[] left = parent.simple
+			? CTabFolder.SIMPLE_UNSELECTED_INNER_CORNER
+			: CTabFolder.BOTTOM_LEFT_CORNER;
+		
+		shape = new int[left.length + 2];
+		int index = 0;
+		shape[index++] = x;
+		shape[index++] = y - 1;
+		for (int i = 0; i < left.length / 2; i++) {
+			shape[index++] = x + left[2 * i];
+			shape[index++] = y + height + left[2 * i + 1] - 1;
+		}
+	} else {
+		int[] left = parent.simple
+			? CTabFolder.SIMPLE_UNSELECTED_INNER_CORNER
+			: CTabFolder.TOP_LEFT_CORNER;
+
+		shape = new int[left.length + 2];
+		int index = 0;
+		shape[index++] = x;
+		shape[index++] = y + height;
+		for (int i = 0; i < left.length / 2; i++) {
+			shape[index++] = x + left[2 * i];
+			shape[index++] = y + left[2 * i + 1];
+		}
+
+	}
+
+	drawBorder(gc, shape);
+}
+
+void drawUnselected(GC gc) {
+	// Do not draw partial items
+	if (!showing) return;
+	
+	Rectangle clipping = gc.getClipping();
+	Rectangle bounds = getBounds();
+	if (!clipping.intersects(bounds)) return;
+	
+	// draw border
+	int index = parent.indexOf(this);
+
+	if (index > 0 && index < parent.selectedIndex)
+		drawLeftUnselectedBorder(gc);
+	// If it is the last one then draw a line
+	if (index > parent.selectedIndex)
+		drawRightUnselectedBorder(gc);
+
+	// draw Image
+	int xDraw = x + LEFT_MARGIN;
+	Image image = getImage();
+	if (image != null && parent.showUnselectedImage) {
+		Rectangle imageBounds = image.getBounds();
+		// only draw image if it won't overlap with close button
+		int maxImageWidth = x + width - xDraw - RIGHT_MARGIN;
+		if (parent.showUnselectedClose && (parent.showClose || showClose)) {
+			maxImageWidth -= closeRect.width + INTERNAL_SPACING;
+		}
+		if (imageBounds.width < maxImageWidth) {		
+			int imageX = xDraw;
+			int imageHeight = imageBounds.height;
+			int imageY = y + (height - imageHeight) / 2;
+			imageY += parent.onBottom ? -1 : 1;
+			int imageWidth = imageBounds.width * imageHeight / imageBounds.height;
+			gc.drawImage(image, 
+				         imageBounds.x, imageBounds.y, imageBounds.width, imageBounds.height,
+				         imageX, imageY, imageWidth, imageHeight);
+			xDraw += imageWidth + INTERNAL_SPACING;
+		}
+	}
+	// draw Text
+	int textWidth = x + width - xDraw - RIGHT_MARGIN;
+	if (parent.showUnselectedClose && (parent.showClose || showClose)) {
+		textWidth -= closeRect.width + INTERNAL_SPACING;
+	}
+	if (textWidth > 0) {
+		Font gcFont = gc.getFont();
+		gc.setFont(font == null ? parent.getFont() : font);
+		if (shortenedText == null || shortenedTextWidth != textWidth) {
+			shortenedText = shortenText(gc, getText(), textWidth);
+			shortenedTextWidth = textWidth;
+		}	
+		Point extent = gc.textExtent(shortenedText, FLAGS);
+		int textY = y + (height - extent.y) / 2;
+		textY += parent.onBottom ? -1 : 1;
+		gc.setForeground(parent.getForeground());
+		gc.drawText(shortenedText, xDraw, textY, FLAGS);
+		gc.setFont(gcFont);
+	}
+	// draw close
+	if (parent.showUnselectedClose && (parent.showClose || showClose)) drawClose(gc);
+}
+/**
+ * Returns a rectangle describing the receiver's size and location
+ * relative to its parent.
+ *
+ * @return the receiver's bounding column rectangle
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Rectangle getBounds () {
+	//checkWidget();
+	int w = width;
+	if (!parent.simple && !parent.single && parent.indexOf(this) == parent.selectedIndex) w += parent.curveWidth - parent.curveIndent;
+	return new Rectangle(x, y, w, height);
+}
+/**
+* Gets the control that is displayed in the content area of the tab item.
+*
+* @return the control
+*
+* @exception SWTException <ul>
+*    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+*    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+* </ul>
+*/
+public Control getControl () {
+	checkWidget();
+	return control;
+}
+/**
+ * Get the image displayed in the tab if the tab is disabled.
+ * 
+ * @return the disabled image or null
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @deprecated the disabled image is not used
+ */
+public Image getDisabledImage(){
+	checkWidget();
+	return disabledImage;
+}
+/**
+ * Returns the font that the receiver will use to paint textual information.
+ *
+ * @return the receiver's font
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ *  @since 3.0
+ */
+public Font getFont() {
+	checkWidget();
+	if (font != null) return font;
+	return parent.getFont();
+}
+/**
+ * Returns the receiver's parent, which must be a <code>CTabFolder</code>.
+ *
+ * @return the receiver's parent
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public CTabFolder getParent () {
+	//checkWidget();
+	return parent;
+}
+/**
+ * Returns <code>true</code> to indicate that the receiver's close button should be shown.
+ * Otherwise return <code>false</code>. The initial value is defined by the style (SWT.CLOSE)
+ * that was used to create the receiver.
+ * 
+ * @return <code>true</code> if the close button should be shown
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.4
+ */
+public boolean getShowClose() {
+	checkWidget();
+	return showClose;
+}
+/**
+ * Returns the receiver's tool tip text, or null if it has
+ * not been set.
+ *
+ * @return the receiver's tool tip text
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public String getToolTipText () {
+	checkWidget();
+	if (toolTipText == null && shortenedText != null) {
+		String text = getText();
+		if (!shortenedText.equals(text)) return text;
+	}
+	return toolTipText;
+}
+/**
+* Returns <code>true</code> if the item will be rendered in the visible area of the CTabFolder. Returns false otherwise.
+* 
+*  @return <code>true</code> if the item will be rendered in the visible area of the CTabFolder. Returns false otherwise.
+* 
+*  @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+* @since 3.0
+*/
+public boolean isShowing () {
+	checkWidget();
+	return showing;
+}
+void onPaint(GC gc, boolean isSelected) {
+	if (width == 0 || height == 0) return;
+	if (isSelected) {
+		drawSelected(gc);
+	} else {
+		drawUnselected(gc);
+	}
+}
+int preferredHeight(GC gc) {
+	Image image = getImage();
+	int h = (image == null) ? 0 : image.getBounds().height;
+	String text = getText();
+	if (font == null) {
+		h = Math.max(h, gc.textExtent(text, FLAGS).y);
+	} else {
+		Font gcFont = gc.getFont();
+		gc.setFont(font);
+		h = Math.max(h, gc.textExtent(text, FLAGS).y);
+		gc.setFont(gcFont);
+	}
+	return h + TOP_MARGIN + BOTTOM_MARGIN;
+}
+int preferredWidth(GC gc, boolean isSelected, boolean minimum) {
+	// NOTE: preferred width does not include the "dead space" caused
+	// by the curve.
+	if (isDisposed()) return 0;
+	int w = 0;
+	Image image = getImage();
+	if (image != null && (isSelected || parent.showUnselectedImage)) {
+		w += image.getBounds().width;
+	}
+	String text = null;
+	if (minimum) {
+		int minChars = parent.minChars;
+		text = minChars == 0 ? null : getText();
+		if (text != null && text.length() > minChars) {
+			if (useEllipses()) {
+				int end = minChars < ELLIPSIS.length() + 1 ? minChars : minChars - ELLIPSIS.length();
+				text = text.substring(0, end);
+				if (minChars > ELLIPSIS.length() + 1) text += ELLIPSIS;
+			} else {
+				int end = minChars;
+				text = text.substring(0, end);
+			}
+		}
+	} else {
+		text = getText();
+	}
+	if (text != null) {
+		if (w > 0) w += INTERNAL_SPACING;
+		if (font == null) {
+			w += gc.textExtent(text, FLAGS).x;
+		} else {
+			Font gcFont = gc.getFont();
+			gc.setFont(font);
+			w += gc.textExtent(text, FLAGS).x;
+			gc.setFont(gcFont);
+		}
+	}
+	if (parent.showClose || showClose) {
+		if (isSelected || parent.showUnselectedClose) {
+			if (w > 0) w += INTERNAL_SPACING;
+			w += CTabFolder.BUTTON_SIZE;
+		}
+	}
+	return w + LEFT_MARGIN + RIGHT_MARGIN;
+}
+/**
+ * Sets the control that is used to fill the client area of
+ * the tab folder when the user selects the tab item.
+ *
+ * @param control the new control (or null)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the control has been disposed</li> 
+ *    <li>ERROR_INVALID_PARENT - if the control is not in the same widget tree</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setControl (Control control) {
+	checkWidget();
+	if (control != null) {
+		if (control.isDisposed()) SWT.error (SWT.ERROR_INVALID_ARGUMENT);
+		if (control.getParent() != parent) SWT.error (SWT.ERROR_INVALID_PARENT);
+	}
+	if (this.control != null && !this.control.isDisposed()) {
+		this.control.setVisible(false);
+	}
+	this.control = control;
+	if (this.control != null) {
+		int index = parent.indexOf (this);
+		if (index == parent.getSelectionIndex ()){
+			this.control.setBounds(parent.getClientArea ());
+			this.control.setVisible(true);
+		} else {
+			this.control.setVisible(false);
+		}
+	}
+}
+/**
+ * Sets the image that is displayed if the tab item is disabled.
+ * Null will clear the image.
+ * 
+ * @param image the image to be displayed when the item is disabled or null
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @deprecated This image is not used
+ */
+public void setDisabledImage (Image image) {
+	checkWidget();
+	if (image != null && image.isDisposed ()) {
+		SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	}
+	this.disabledImage = image;
+}
+/**
+ * Sets the font that the receiver will use to paint textual information
+ * for this item to the font specified by the argument, or to the default font
+ * for that kind of control if the argument is null.
+ *
+ * @param font the new font (or null)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li> 
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.0
+ */
+public void setFont (Font font){
+	checkWidget();
+	if (font != null && font.isDisposed ()) {
+		SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	}
+	if (font == null && this.font == null) return;
+	if (font != null && font.equals(this.font)) return;
+	this.font = font;
+	if (!parent.updateTabHeight(false)) {
+		parent.updateItems();
+		parent.redrawTabs();
+	}
+}
+public void setImage (Image image) {
+	checkWidget();
+	if (image != null && image.isDisposed ()) {
+		SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	}
+	Image oldImage = getImage();
+	if (image == null && oldImage == null) return;
+	if (image != null && image.equals(oldImage)) return;
+	super.setImage(image);
+	if (!parent.updateTabHeight(false)) {
+		// If image is the same size as before, 
+		// redraw only the image
+		if (oldImage != null && image != null) {
+			Rectangle oldBounds = oldImage.getBounds();
+			Rectangle bounds = image.getBounds();
+			if (bounds.width == oldBounds.width && bounds.height == oldBounds.height) {
+				if (showing) {
+					boolean selected = parent.indexOf(this) == parent.selectedIndex;
+					if (selected || parent.showUnselectedImage) {
+						int imageX = x + LEFT_MARGIN, maxImageWidth;
+						if (selected) {
+							if (parent.single && (parent.showClose || showClose)) imageX += CTabFolder.BUTTON_SIZE; 
+							int rightEdge = Math.min (x + width, parent.getRightItemEdge());
+							maxImageWidth = rightEdge - imageX - RIGHT_MARGIN;
+							if (!parent.single && closeRect.width > 0) maxImageWidth -= closeRect.width + INTERNAL_SPACING;
+						} else {
+							maxImageWidth = x + width - imageX - RIGHT_MARGIN;
+							if (parent.showUnselectedClose && (parent.showClose || showClose)) {
+								maxImageWidth -= closeRect.width + INTERNAL_SPACING;
+							}
+						}
+						if (bounds.width < maxImageWidth) {
+							int imageY = y + (height - bounds.height) / 2 + (parent.onBottom ? -1 : 1);
+							parent.redraw(imageX, imageY, bounds.width, bounds.height, false);
+						}
+					}
+				}
+				return;
+			}
+		} 
+		parent.updateItems();
+		parent.redrawTabs();
+	}
+}
+/**
+ * Sets to <code>true</code> to indicate that the receiver's close button should be shown.
+ * If the parent (CTabFolder) was created with SWT.CLOSE style, changing this value has
+ * no effect.
+ * 
+ * @param close the new state of the close button
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.4
+ */
+public void setShowClose(boolean close) {
+	checkWidget();
+	if (showClose == close) return;
+	showClose = close;
+	parent.updateItems();
+	parent.redrawTabs();
+}
+public void setText (String string) {
+	checkWidget();
+	if (string == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+	if (string.equals(getText())) return;
+	super.setText(string);
+	shortenedText = null;
+	shortenedTextWidth = 0;
+	if (!parent.updateTabHeight(false)) {
+		parent.updateItems();
+		parent.redrawTabs();
+	}
+}
+/**
+ * Sets the receiver's tool tip text to the argument, which
+ * may be null indicating that no tool tip text should be shown.
+ *
+ * @param string the new tool tip text (or null)
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setToolTipText (String string) {
+	checkWidget();
+	toolTipText = string;
+}
+
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/custom/ControlEditor.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/custom/ControlEditor.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/custom/ControlEditor.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,255 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.custom;
+
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+
+/**
+*
+* A ControlEditor is a manager for a Control that appears above a composite and tracks with the
+* moving and resizing of that composite.  It can be used to display one control above 
+* another control.  This could be used when editing a control that does not have editing 
+* capabilities by using a text editor or for launching a dialog by placing a button 
+* above a control.
+*
+* <p> Here is an example of using a ControlEditor:
+*
+* <code><pre>
+* Canvas canvas = new Canvas(shell, SWT.BORDER);
+* canvas.setBounds(10, 10, 300, 300);	
+* Color color = new Color(null, 255, 0, 0);
+* canvas.setBackground(color);
+* ControlEditor editor = new ControlEditor (canvas);
+* // The editor will be a button in the bottom right corner of the canvas.
+* // When selected, it will launch a Color dialog that will change the background 
+* // of the canvas.
+* Button button = new Button(canvas, SWT.PUSH);
+* button.setText("Select Color...");
+* button.addSelectionListener (new SelectionAdapter() {
+* 	public void widgetSelected(SelectionEvent e) {
+* 		ColorDialog dialog = new ColorDialog(shell);
+* 		dialog.open();
+* 		RGB rgb = dialog.getRGB();
+* 		if (rgb != null) {
+* 			if (color != null) color.dispose();
+* 			color = new Color(null, rgb);
+* 			canvas.setBackground(color);
+* 		}
+* 		
+* 	}
+* });
+*
+* editor.horizontalAlignment = SWT.RIGHT;
+* editor.verticalAlignment = SWT.BOTTOM;
+* editor.grabHorizontal = false;
+* editor.grabVertical = false;
+* Point size = button.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+* editor.minimumWidth = size.x;
+* editor.minimumHeight = size.y;
+* editor.setEditor (button);
+* </pre></code>
+*
+* @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+*/
+public class ControlEditor {
+
+	/**
+	* Specifies how the editor should be aligned relative to the control.  Allowed values
+	* are SWT.LEFT, SWT.RIGHT and SWT.CENTER.  The default value is SWT.CENTER.
+	*/
+	public int horizontalAlignment = SWT.CENTER;
+	
+	/**
+	* Specifies whether the editor should be sized to use the entire width of the control.
+	* True means resize the editor to the same width as the cell.  False means do not adjust 
+	* the width of the editor.	The default value is false.
+	*/
+	public boolean grabHorizontal = false;
+	
+	/**
+	* Specifies the minimum width the editor can have.  This is used in association with
+	* a true value of grabHorizontal.  If the cell becomes smaller than the minimumWidth, the 
+	* editor will not made smaller than the minimum width value.  The default value is 0.
+	*/
+	public int minimumWidth = 0;
+	
+	/**
+	* Specifies how the editor should be aligned relative to the control.  Allowed values
+	* are SWT.TOP, SWT.BOTTOM and SWT.CENTER.  The default value is SWT.CENTER.
+	*/
+	public int verticalAlignment = SWT.CENTER;
+	
+	/**
+	* Specifies whether the editor should be sized to use the entire height of the control.
+	* True means resize the editor to the same height as the underlying control.  False means do not adjust 
+	* the height of the editor.	The default value is false.
+	*/
+	public boolean grabVertical = false;
+	
+	/**
+	* Specifies the minimum height the editor can have.  This is used in association with
+	* a true value of grabVertical.  If the control becomes smaller than the minimumHeight, the 
+	* editor will not made smaller than the minimum height value.  The default value is 0.
+	*/
+	public int minimumHeight = 0;
+
+	Composite parent;
+	Control editor;
+	private boolean hadFocus;
+	private Listener controlListener;
+	private Listener scrollbarListener;
+	
+	private final static int [] EVENTS = {SWT.KeyDown, SWT.KeyUp, SWT.MouseDown, SWT.MouseUp, SWT.Resize};
+/**
+* Creates a ControlEditor for the specified Composite.
+*
+* @param parent the Composite above which this editor will be displayed
+*
+*/
+public ControlEditor (Composite parent) {
+	this.parent = parent;
+
+	controlListener = new Listener() {
+		public void handleEvent(Event e) {
+			layout ();
+		}
+	};
+	for (int i=0; i<EVENTS.length; i++) {
+		parent.addListener (EVENTS [i], controlListener);
+	}
+	
+	scrollbarListener = new Listener() {
+		public void handleEvent(Event e) {
+			scroll (e);
+		}
+	};			
+	ScrollBar hBar = parent.getHorizontalBar ();
+	if (hBar != null) hBar.addListener (SWT.Selection, scrollbarListener);
+	ScrollBar vBar = parent.getVerticalBar ();
+	if (vBar != null) vBar.addListener (SWT.Selection, scrollbarListener);
+}
+Rectangle computeBounds () {
+	Rectangle clientArea = parent.getClientArea();
+	Rectangle editorRect = new Rectangle(clientArea.x, clientArea.y, minimumWidth, minimumHeight);
+	
+	if (grabHorizontal)
+		editorRect.width = Math.max(clientArea.width, minimumWidth);
+	
+	if (grabVertical)
+		editorRect.height = Math.max(clientArea.height, minimumHeight);
+
+	switch (horizontalAlignment) {
+		case SWT.RIGHT:
+			editorRect.x += clientArea.width - editorRect.width;
+			break;
+		case SWT.LEFT:
+			// do nothing - clientArea.x is the right answer
+			break;
+		default:
+			// default is CENTER
+			editorRect.x += (clientArea.width - editorRect.width)/2;
+	}
+	
+	switch (verticalAlignment) {
+		case SWT.BOTTOM:
+			editorRect.y += clientArea.height - editorRect.height;
+			break;
+		case SWT.TOP:
+			// do nothing - clientArea.y is the right answer
+			break;
+		default :
+			// default is CENTER
+			editorRect.y += (clientArea.height - editorRect.height)/2;
+	}
+
+	
+	return editorRect;
+
+}
+/**
+ * Removes all associations between the Editor and the underlying composite.  The
+ * composite and the editor Control are <b>not</b> disposed.
+ */
+public void dispose () {
+	if (parent != null && !parent.isDisposed()) {
+		for (int i=0; i<EVENTS.length; i++) {
+			parent.removeListener (EVENTS [i], controlListener);
+		}
+		ScrollBar hBar = parent.getHorizontalBar ();
+		if (hBar != null) hBar.removeListener (SWT.Selection, scrollbarListener);
+		ScrollBar vBar = parent.getVerticalBar ();
+		if (vBar != null) vBar.removeListener (SWT.Selection, scrollbarListener);
+	}
+	
+	parent = null;
+	editor = null;
+	hadFocus = false;
+	controlListener = null;
+	scrollbarListener = null;
+}
+/**
+* Returns the Control that is displayed above the composite being edited.
+*
+* @return the Control that is displayed above the composite being edited
+*/
+public Control getEditor () {
+	return editor;
+}
+/**
+ * Lays out the control within the underlying composite.  This
+ * method should be called after changing one or more fields to
+ * force the Editor to resize.
+ * 
+ * @since 2.1
+ */
+public void layout () {
+	if (editor == null || editor.isDisposed()) return;
+	if (editor.getVisible ()) {
+		hadFocus = editor.isFocusControl();
+	} // this doesn't work because
+	  // resizing the column takes the focus away
+	  // before we get here
+	editor.setBounds (computeBounds ());
+	if (hadFocus) {
+		if (editor == null || editor.isDisposed()) return;
+		editor.setFocus ();
+	}
+}
+void scroll (Event e) {
+	if (editor == null || editor.isDisposed()) return;
+	layout();
+}
+/**
+* Specify the Control that is to be displayed.
+*
+* <p>Note: The Control provided as the editor <b>must</b> be created with its parent 
+* being the Composite specified in the ControlEditor constructor.
+* 
+* @param editor the Control that is displayed above the composite being edited
+*/
+public void setEditor (Control editor) {
+	
+	if (editor == null) {
+		// this is the case where the caller is setting the editor to be blank
+		// set all the values accordingly
+		this.editor = null;
+		return;
+	}
+	
+	this.editor = editor;
+	layout();
+	if (this.editor == null || this.editor.isDisposed()) return;
+	editor.setVisible(true);
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/custom/DefaultContent.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/custom/DefaultContent.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/custom/DefaultContent.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,881 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.custom;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.Compatibility;
+import org.eclipse.swt.widgets.*;
+import java.util.Vector;
+
+class DefaultContent implements StyledTextContent {
+	private final static String LineDelimiter = System.getProperty("line.separator");
+
+	Vector textListeners = new Vector(); // stores text listeners for event sending
+	char[] textStore = new char[0];	// stores the actual text
+	int gapStart = -1;	// the character position start of the gap
+	int gapEnd = -1;	// the character position after the end of the gap
+	int gapLine = -1;	// the line on which the gap exists, the gap will always be associated with one line
+	int highWatermark = 300;	
+	int lowWatermark = 50;		
+	
+	int[][] lines = new int[50][2];	// array of character positions and lengths representing the lines of text
+	int lineCount = 0;	// the number of lines of text	
+	int expandExp = 1; 	// the expansion exponent, used to increase the lines array exponentially
+	int replaceExpandExp = 1; 	// the expansion exponent, used to increase the lines array exponentially
+
+/** 
+ * Creates a new DefaultContent and initializes it.  A <code>StyledTextContent</> will always have
+ * at least one empty line.
+ */
+DefaultContent() {
+	super();
+	setText("");
+}
+/** 
+ * Adds a line to the end of the line indexes array.  Increases the size of the array if necessary.
+ * <code>lineCount</code> is updated to reflect the new entry.
+ * <p>
+ *
+ * @param start the start of the line
+ * @param length the length of the line
+ */
+void addLineIndex(int start, int length) {
+	int size = lines.length;
+	if (lineCount == size) {
+		// expand the lines by powers of 2
+		int[][] newLines = new int[size+Compatibility.pow2(expandExp)][2];
+		System.arraycopy(lines, 0, newLines, 0, size);
+		lines = newLines;
+		expandExp++;
+	}
+	int[] range = new int[] {start, length};
+	lines[lineCount] = range;
+	lineCount++;
+}
+/** 
+ * Adds a line index to the end of <code>linesArray</code>.  Increases the 
+ * size of the array if necessary and returns a new array.
+ * <p>
+ *
+ * @param start the start of the line
+ * @param length the length of the line
+ * @param linesArray the array to which to add the line index
+ * @param count the position at which to add the line
+ * @return a new array of line indexes
+ */
+int[][] addLineIndex(int start, int length, int[][] linesArray, int count) {
+	int size = linesArray.length;
+	int[][] newLines = linesArray;
+	if (count == size) {
+		newLines = new int[size+Compatibility.pow2(replaceExpandExp)][2];
+		replaceExpandExp++;
+		System.arraycopy(linesArray, 0, newLines, 0, size);
+	}
+	int[] range = new int[] {start, length};
+	newLines[count] = range;
+	return newLines;
+}
+/**
+ * Adds a <code>TextChangeListener</code> listening for 
+ * <code>TextChangingEvent</code> and <code>TextChangedEvent</code>. A 
+ * <code>TextChangingEvent</code> is sent before changes to the text occur.
+ * A <code>TextChangedEvent</code> is sent after changes to the text 
+ * occurred.
+ * <p>
+ *
+ * @param listener the listener
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT when listener is null</li>
+ * </ul>
+ */
+public void addTextChangeListener(TextChangeListener listener) {
+	if (listener == null) error(SWT.ERROR_NULL_ARGUMENT);
+	StyledTextListener typedListener = new StyledTextListener(listener);
+	textListeners.addElement(typedListener);	
+}	
+/**
+ * Adjusts the gap to accommodate a text change that is occurring.
+ * <p>
+ *
+ * @param position the position at which a change is occurring
+ * @param sizeHint the size of the change
+ * @param line the line where the gap will go
+ */
+void adjustGap(int position, int sizeHint, int line) {
+	if (position == gapStart) {
+		// text is being inserted at the gap position
+		int size = (gapEnd - gapStart) - sizeHint;
+		if (lowWatermark <= size && size <= highWatermark)
+			return;
+	} else if ((position + sizeHint == gapStart) && (sizeHint < 0)) {
+		// text is being deleted at the gap position
+		int size = (gapEnd - gapStart) - sizeHint;
+		if (lowWatermark <= size && size <= highWatermark)
+			return;
+	}
+	moveAndResizeGap(position, sizeHint, line);
+}
+/**
+ * Calculates the indexes of each line in the text store.  Assumes no gap exists.  
+ * Optimized to do less checking.
+ */
+void indexLines(){
+	int start = 0;
+	lineCount = 0;
+	int textLength = textStore.length;
+	int i;
+	for (i = start; i < textLength; i++) {
+		char ch = textStore[i];					
+		if (ch == SWT.CR) {
+			// see if the next character is a LF
+			if (i + 1 < textLength) {
+				ch = textStore[i+1];
+				if (ch == SWT.LF) {
+					i++;
+				}
+			}
+			addLineIndex(start, i - start + 1);
+			start = i + 1;
+		} else if (ch == SWT.LF) {
+			addLineIndex(start, i - start + 1);
+			start = i + 1;
+		}
+	}
+	addLineIndex(start, i - start);
+}
+/** 
+ * Returns whether or not the given character is a line delimiter.  Both CR and LF 
+ * are valid line delimiters.
+ * <p>
+ *
+ * @param ch the character to test
+ * @return true if ch is a delimiter, false otherwise
+ */
+boolean isDelimiter(char ch) {
+	if (ch == SWT.CR) return true;
+	if (ch == SWT.LF) return true;
+	return false;
+}	
+/**
+ * Determine whether or not the replace operation is valid.  DefaultContent will not allow
+ * the /r/n line delimiter to be split or partially deleted.
+ * <p>
+ *
+ * @param start	start offset of text to replace
+ * @param replaceLength start offset of text to replace
+ * @param newText start offset of text to replace
+ * @return a boolean specifying whether or not the replace operation is valid
+ */
+protected boolean isValidReplace(int start, int replaceLength, String newText){
+	if (replaceLength == 0) {
+		// inserting text, see if the \r\n line delimiter is being split
+		if (start == 0) return true;
+		if (start == getCharCount()) return true;
+		char before = getTextRange(start - 1, 1).charAt(0);
+		if (before == '\r') {
+			char after = getTextRange(start, 1).charAt(0);
+			if (after == '\n') return false;
+		}
+	} else {
+		// deleting text, see if part of a \r\n line delimiter is being deleted
+		char startChar = getTextRange(start, 1).charAt(0);
+		if (startChar == '\n') {
+			// see if char before delete position is \r
+			if (start != 0) {
+				char before = getTextRange(start - 1, 1).charAt(0);
+				if (before == '\r') return false;
+			}
+		}
+		char endChar = getTextRange(start + replaceLength - 1, 1).charAt(0);
+		if (endChar == '\r') {
+			// see if char after delete position is \n
+			if (start + replaceLength != getCharCount()) {
+				char after = getTextRange(start + replaceLength, 1).charAt(0);
+				if (after == '\n') return false;
+			}
+		}
+	} 
+	return true;
+}
+/**
+ * Calculates the indexes of each line of text in the given range.
+ * <p>
+ *
+ * @param offset the logical start offset of the text lineate
+ * @param length the length of the text to lineate, includes gap
+ * @param numLines the number of lines to initially allocate for the line index array,
+ *	passed in for efficiency (the exact number of lines may be known)
+ * @return a line indexes array where each line is identified by a start offset and 
+ * 	a length
+ */
+int[][] indexLines(int offset, int length, int numLines){
+	int[][] indexedLines = new int[numLines][2];
+	int start = 0;
+	int lineCount = 0;
+	int i;
+	replaceExpandExp = 1;
+	for (i = start; i < length; i++) {
+		int location = i + offset; 
+		if ((location >= gapStart) && (location < gapEnd)) {
+			// ignore the gap
+		} else {
+			char ch = textStore[location];				
+			if (ch == SWT.CR) {
+				// see if the next character is a LF
+				if (location+1 < textStore.length) {
+					ch = textStore[location+1];
+					if (ch == SWT.LF) {
+						i++;
+					} 
+				}
+				indexedLines = addLineIndex(start, i - start + 1, indexedLines, lineCount);
+				lineCount++;
+				start = i + 1;
+			} else if (ch == SWT.LF) {
+				indexedLines = addLineIndex(start, i - start + 1, indexedLines, lineCount);
+				lineCount++;
+				start = i + 1;
+			}
+		}
+	}
+	int[][] newLines = new int[lineCount+1][2];
+	System.arraycopy(indexedLines, 0, newLines, 0, lineCount);
+	int[] range = new int[] {start, i - start};
+	newLines[lineCount] = range;
+	return newLines; 
+}
+/**
+ * Inserts text.
+ * <p>
+ *
+ * @param position the position at which to insert the text
+ * @param text the text to insert
+ */
+void insert(int position, String text) {	
+	if (text.length() == 0) return;
+				
+	int startLine = getLineAtOffset(position);
+	int change = text.length();
+	boolean endInsert = position == getCharCount();
+	adjustGap(position, change, startLine);
+
+	// during an insert the gap will be adjusted to start at
+	// position and it will be associated with startline, the
+	// inserted text will be placed in the gap		
+	int startLineOffset = getOffsetAtLine(startLine);
+	// at this point, startLineLength will include the start line
+	// and all of the newly inserted text
+	int	startLineLength = getPhysicalLine(startLine).length();
+	
+	if (change > 0) {
+		// shrink gap 
+		gapStart += (change);
+		for (int i = 0; i < text.length(); i++) {
+			textStore[position + i]= text.charAt(i);
+		}
+	}
+		
+	// figure out the number of new lines that have been inserted
+	int [][] newLines = indexLines(startLineOffset, startLineLength, 10);
+	// only insert an empty line if it is the last line in the text
+	int numNewLines = newLines.length - 1;
+	if (newLines[numNewLines][1] == 0) {
+		// last inserted line is a new line
+		if (endInsert) {
+			// insert happening at end of the text, leave numNewLines as
+			// is since the last new line will not be concatenated with another
+			// line 
+			numNewLines += 1;
+		} else {
+			numNewLines -= 1;
+		}
+	}
+	
+	// make room for the new lines
+	expandLinesBy(numNewLines);
+	// shift down the lines after the replace line
+	for (int i = lineCount - 1; i > startLine; i--) {
+		lines[i + numNewLines]=lines[i];
+	}
+	// insert the new lines
+	for (int i = 0; i < numNewLines; i++) {
+		newLines[i][0] += startLineOffset;
+		lines[startLine + i]=newLines[i];
+	}
+	// update the last inserted line
+	if (numNewLines < newLines.length) {
+		newLines[numNewLines][0] += startLineOffset;
+		lines[startLine + numNewLines] = newLines[numNewLines];
+	}
+	
+	lineCount += numNewLines;
+	gapLine = getLineAtPhysicalOffset(gapStart);
+}
+/**
+ * Moves the gap and adjusts its size in anticipation of a text change.  
+ * The gap is resized to actual size + the specified size and moved to the given 
+ * position.
+ * <p>
+ *
+ * @param position the position at which a change is occurring
+ * @param size the size of the change
+ * @param newGapLine the line where the gap should be put
+ */
+void moveAndResizeGap(int position, int size, int newGapLine) {
+	char[] content = null;
+	int oldSize = gapEnd - gapStart;
+	int newSize;
+	if (size > 0) {
+		newSize = highWatermark + size;
+	} else {
+		newSize = lowWatermark - size;
+	}
+	// remove the old gap from the lines information
+	if (gapExists()) {
+		// adjust the line length
+		lines[gapLine][1] = lines[gapLine][1] - oldSize;
+		// adjust the offsets of the lines after the gapLine
+		for (int i = gapLine + 1; i < lineCount; i++) {
+			lines[i][0] = lines[i][0] - oldSize;
+		}
+	}
+	
+	if (newSize < 0) {
+		if (oldSize > 0) {
+			// removing the gap
+			content = new char[textStore.length - oldSize];
+			System.arraycopy(textStore, 0, content, 0, gapStart);
+			System.arraycopy(textStore, gapEnd, content, gapStart, content.length - gapStart);
+			textStore = content;
+		}
+		gapStart = gapEnd = position;
+		return;
+	}
+	content = new char[textStore.length + (newSize - oldSize)];
+	int newGapStart = position;
+	int newGapEnd = newGapStart + newSize;
+	if (oldSize == 0) {
+		System.arraycopy(textStore, 0, content, 0, newGapStart);
+		System.arraycopy(textStore, newGapStart, content, newGapEnd, content.length - newGapEnd);	
+	} else if (newGapStart < gapStart) {
+		int delta = gapStart - newGapStart;
+		System.arraycopy(textStore, 0, content, 0, newGapStart);
+		System.arraycopy(textStore, newGapStart, content, newGapEnd, delta);
+		System.arraycopy(textStore, gapEnd, content, newGapEnd + delta, textStore.length - gapEnd);
+	} else {
+		int delta = newGapStart - gapStart;
+		System.arraycopy(textStore, 0, content, 0, gapStart);
+		System.arraycopy(textStore, gapEnd, content, gapStart, delta);
+		System.arraycopy(textStore, gapEnd + delta, content, newGapEnd, content.length - newGapEnd);
+	}
+	textStore = content;
+	gapStart = newGapStart;
+	gapEnd = newGapEnd;
+	
+	// add the new gap to the lines information
+	if (gapExists()) {
+		gapLine = newGapLine;
+		// adjust the line length
+		int gapLength = gapEnd - gapStart;
+		lines[gapLine][1] = lines[gapLine][1] + (gapLength);
+		// adjust the offsets of the lines after the gapLine
+		for (int i = gapLine + 1; i < lineCount; i++) {
+			lines[i][0] = lines[i][0] + gapLength;
+		}
+	}
+}
+/** 
+ * Returns the number of lines that are in the specified text.
+ * <p>
+ *
+ * @param startOffset the start of the text to lineate
+ * @param length the length of the text to lineate
+ * @return number of lines
+ */
+int lineCount(int startOffset, int length){
+	if (length == 0) {
+		return 0;
+	}
+	int lineCount = 0;
+	int count = 0;
+	int i = startOffset;
+	if (i >= gapStart) {
+		i += gapEnd - gapStart;
+	}
+	while (count < length) {
+		if ((i >= gapStart) && (i < gapEnd)) {
+			// ignore the gap
+		} else {
+			char ch = textStore[i];			
+			if (ch == SWT.CR) {
+				// see if the next character is a LF
+				if (i + 1 < textStore.length) {
+					ch = textStore[i+1];
+					if (ch == SWT.LF) {
+						i++;
+						count++;
+					} 
+				} 
+				lineCount++;
+			} else if (ch == SWT.LF) {
+				lineCount++;
+			}
+			count++;
+		}
+		i++;
+	}
+	return lineCount;
+}
+/** 
+ * Returns the number of lines that are in the specified text.
+ * <p>
+ *
+ * @param text the text to lineate
+ * @return number of lines in the text
+ */
+int lineCount(String text){
+	int lineCount = 0;
+	int length = text.length();
+	for (int i = 0; i < length; i++) {
+		char ch = text.charAt(i);
+		if (ch == SWT.CR) {
+			if (i + 1 < length && text.charAt(i + 1) == SWT.LF) {
+				i++;
+			}
+			lineCount++;
+		} else if (ch == SWT.LF) {
+			lineCount++;
+		}
+	}
+	return lineCount;	
+}
+/**
+ * @return the logical length of the text store
+ */
+public int getCharCount() {
+	int length = gapEnd - gapStart;
+	return (textStore.length - length);
+}
+/**
+ * Returns the line at <code>index</code> without delimiters.
+ * <p>
+ *
+ * @param index	the index of the line to return
+ * @return the logical line text (i.e., without the gap)
+ * @exception IllegalArgumentException <ul>
+ *   <li>ERROR_INVALID_ARGUMENT when index is out of range</li>
+ * </ul>
+ */
+public String getLine(int index) {
+	if ((index >= lineCount) || (index < 0)) error(SWT.ERROR_INVALID_ARGUMENT);
+	int start = lines[index][0];
+	int length = lines[index][1];
+	int end = start + length - 1;
+	if (!gapExists() || (end < gapStart) || (start >= gapEnd)) {
+		// line is before or after the gap
+		while ((length - 1 >= 0) && isDelimiter(textStore[start+length-1])) {
+			length--;
+		}
+		return new String(textStore, start, length);
+	} else {
+		// gap is in the specified range, strip out the gap
+		StringBuffer buf = new StringBuffer();
+		int gapLength = gapEnd - gapStart;
+		buf.append(textStore, start, gapStart - start);
+		buf.append(textStore, gapEnd, length - gapLength - (gapStart - start));
+		length = buf.length();
+		while ((length - 1 >=0) && isDelimiter(buf.charAt(length - 1))) {
+			length--;
+		}
+		return buf.toString().substring(0, length);
+	}
+}
+/**
+ * Returns the line delimiter that should be used by the StyledText 
+ * widget when inserting new lines.  This delimiter may be different than the
+ * delimiter that is used by the <code>StyledTextContent</code> interface.
+ * <p>
+ *
+ * @return the platform line delimiter as specified in the line.separator
+ * 	system property.
+ */
+public String getLineDelimiter() {
+	return LineDelimiter;
+}
+/**
+ * Returns the line at the given index with delimiters.
+ * <p>
+ * @param index	the index of the line to return
+ * @return the logical line text (i.e., without the gap) with delimiters
+ */
+String getFullLine(int index) {
+	int start = lines[index][0];
+	int length = lines[index][1];
+	int end = start + length - 1;
+	if (!gapExists() || (end < gapStart) || (start >= gapEnd)) {
+		// line is before or after the gap
+		return new String(textStore, start, length);
+	} else {
+		// gap is in the specified range, strip out the gap
+		StringBuffer buffer = new StringBuffer();
+		int gapLength = gapEnd - gapStart;
+		buffer.append(textStore, start, gapStart - start);
+		buffer.append(textStore, gapEnd, length - gapLength - (gapStart - start));
+		return buffer.toString();
+	}
+}
+/**
+ * Returns the physical line at the given index (i.e., with delimiters and the gap).
+ * <p>
+ *
+ * @param index the line index
+ * @return the physical line 
+ */
+String getPhysicalLine(int index) {
+	int start = lines[index][0];
+	int length = lines[index][1];
+	return getPhysicalText(start, length);
+}
+/**
+ * @return the number of lines in the text store
+ */
+public int getLineCount(){
+	return lineCount;
+}
+/**
+ * Returns the line at the given offset.
+ * <p>
+ *
+ * @param charPosition logical character offset (i.e., does not include gap)
+ * @return the line index
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT when charPosition is out of range</li>
+ * </ul>
+ */
+public int getLineAtOffset(int charPosition){
+	if ((charPosition > getCharCount()) || (charPosition < 0)) error(SWT.ERROR_INVALID_ARGUMENT);
+	int position;
+	if (charPosition < gapStart) {
+		// position is before the gap
+		position = charPosition;
+	} else {
+		// position includes the gap
+		position = charPosition + (gapEnd - gapStart);
+	}
+
+	// if last line and the line is not empty you can ask for 
+	// a position that doesn't exist (the one to the right of the 
+	// last character) - for inserting
+	if (lineCount > 0) {
+		int lastLine = lineCount - 1;
+		if (position == lines[lastLine][0] + lines[lastLine][1]) 
+			return lastLine;
+	}
+
+	int high = lineCount;
+	int low = -1;
+	int index = lineCount;
+	while (high - low > 1) {
+		index = (high + low) / 2;
+		int lineStart = lines[index][0];
+		int lineEnd = lineStart + lines[index][1] - 1;
+		if (position <= lineStart) {
+			high = index;
+		} else if (position <= lineEnd) {
+			high = index;
+			break;
+		} else {
+			low = index;
+		}
+	}
+	return high;
+}
+/**
+ * Returns the line index at the given physical offset.
+ * <p>
+ *
+ * @param position physical character offset (i.e., includes gap)
+ * @return the line index
+ */
+int getLineAtPhysicalOffset(int position){
+	int high = lineCount;
+	int low = -1;
+	int index = lineCount;
+	while (high - low > 1) {
+		index = (high + low) / 2;
+		int lineStart = lines[index][0];
+		int lineEnd = lineStart + lines[index][1] - 1;
+		if (position <= lineStart) {
+			high = index;
+		} else if (position <= lineEnd) {
+			high = index;
+			break;
+		} else {
+			low = index;
+		}
+	}
+	return high;
+}
+/**
+ * Returns the logical offset of the given line.
+ * <p>
+ *
+ * @param lineIndex index of line 
+ * @return the logical starting offset of the line.  When there are not any lines,
+ * 	getOffsetAtLine(0) is a valid call that should answer 0.
+ * @exception IllegalArgumentException <ul>
+ *   <li>ERROR_INVALID_ARGUMENT when lineIndex is out of range</li>
+ * </ul>
+ */
+public int getOffsetAtLine(int lineIndex) {
+	if (lineIndex == 0) return 0;
+	if ((lineIndex >= lineCount) || (lineIndex < 0)) error(SWT.ERROR_INVALID_ARGUMENT);
+	int start = lines[lineIndex][0];
+	if (start > gapEnd) {
+		return start - (gapEnd - gapStart);
+	} else {
+		return start;
+	}
+}	
+/**
+ * Increases the line indexes array to accommodate more lines.
+ * <p>
+ *
+ * @param numLines the number to increase the array by
+ */
+void expandLinesBy(int numLines) {
+	int size = lines.length;
+	if (size - lineCount >= numLines) {
+		return;
+	}
+	int[][] newLines = new int[size+Math.max(10, numLines)][2];
+	System.arraycopy(lines, 0, newLines, 0, size);
+	lines = newLines;
+}
+/**	 
+ * Reports an SWT error.
+ * <p>
+ *
+ * @param code the error code
+ */
+void error (int code) {
+	SWT.error(code);
+}
+/** 
+ * Returns whether or not a gap exists in the text store.
+ * <p>
+ *
+ * @return true if gap exists, false otherwise
+ */
+boolean gapExists() {
+	return gapStart != gapEnd;
+}
+/**
+ * Returns a string representing the continuous content of
+ * the text store.
+ * <p>
+ *
+ * @param start	the physical start offset of the text to return
+ * @param length the physical length of the text to return
+ * @return the text
+ */
+String getPhysicalText(int start, int length) {
+	return new String(textStore, start, length);
+}
+/**
+ * Returns a string representing the logical content of
+ * the text store (i.e., gap stripped out).
+ * <p>
+ *
+ * @param start the logical start offset of the text to return
+ * @param length the logical length of the text to return
+ * @return the text
+ */
+public String getTextRange(int start, int length) {
+	if (textStore == null)
+		return "";
+	if (length == 0)
+		return "";
+	int end= start + length;
+	if (!gapExists() || (end < gapStart))
+		return new String(textStore, start, length);
+	if (gapStart < start) {
+		int gapLength= gapEnd - gapStart;
+		return new String(textStore, start + gapLength , length);
+	}
+	StringBuffer buf = new StringBuffer();
+	buf.append(textStore, start, gapStart - start);
+	buf.append(textStore, gapEnd, end - gapStart);
+	return buf.toString();
+}
+/**
+ * Removes the specified <code>TextChangeListener</code>.
+ * <p>
+ *
+ * @param listener the listener which should no longer be notified
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT when listener is null</li>
+ * </ul>
+ */
+public void removeTextChangeListener(TextChangeListener listener){
+	if (listener == null) error(SWT.ERROR_NULL_ARGUMENT);
+	for (int i = 0; i < textListeners.size(); i++) {
+		TypedListener typedListener = (TypedListener) textListeners.elementAt(i);
+		if (typedListener.getEventListener () == listener) {
+			textListeners.removeElementAt(i);
+			break;
+		}
+	}
+}
+/**
+ * Replaces the text with <code>newText</code> starting at position <code>start</code> 
+ * for a length of <code>replaceLength</code>.  Notifies the appropriate listeners.
+ * <p>
+ *
+ * When sending the TextChangingEvent, <code>newLineCount</code> is the number of 
+ * lines that are going to be inserted and <code>replaceLineCount</code> is 
+ * the number of lines that are going to be deleted, based on the change 
+ * that occurs visually.  For example:
+ * <ul>
+ * <li>(replaceText,newText) ==> (replaceLineCount,newLineCount)
+ * <li>("","\n") ==> (0,1)
+ * <li>("\n\n","a") ==> (2,0)
+ * </ul>
+ * </p>
+ *
+ * @param start	start offset of text to replace
+ * @param replaceLength start offset of text to replace
+ * @param newText start offset of text to replace
+ * 
+ * @exception SWTException <ul>
+ *   <li>ERROR_INVALID_ARGUMENT when the text change results in a multi byte
+ *      line delimiter being split or partially deleted.  Splitting a line 
+ *      delimiter by inserting text between the CR and LF characters of the 
+ *      \r\n delimiter or deleting part of this line delimiter is not supported</li>
+ * </ul>
+ */
+public void replaceTextRange(int start, int replaceLength, String newText){
+	// check for invalid replace operations
+	if (!isValidReplace(start, replaceLength, newText)) SWT.error(SWT.ERROR_INVALID_ARGUMENT);		
+
+	// inform listeners
+	StyledTextEvent event = new StyledTextEvent(this);
+	event.type = StyledText.TextChanging;
+	event.start = start;
+	event.replaceLineCount = lineCount(start, replaceLength);
+	event.text = newText;
+	event.newLineCount = lineCount(newText);
+	event.replaceCharCount = replaceLength;
+	event.newCharCount = newText.length();
+	sendTextEvent(event);
+
+	// first delete the text to be replaced
+	delete(start, replaceLength, event.replaceLineCount + 1);
+	// then insert the new text
+	insert(start, newText);
+	// inform listeners
+	event = new StyledTextEvent(this);
+	event.type = StyledText.TextChanged;
+	sendTextEvent(event);
+}
+/**
+ * Sends the text listeners the TextChanged event.
+ */
+void sendTextEvent(StyledTextEvent event) {
+	for (int i = 0; i < textListeners.size(); i++) {
+		((StyledTextListener)textListeners.elementAt(i)).handleEvent(event);
+	}
+}		
+/**
+ * Sets the content to text and removes the gap since there are no sensible predictions 
+ * about where the next change will occur.
+ * <p>
+ *
+ * @param text the text
+ */
+public void setText (String text){
+	textStore = text.toCharArray();
+	gapStart = -1;
+	gapEnd = -1;
+	expandExp = 1;
+	indexLines();
+	StyledTextEvent event = new StyledTextEvent(this);
+	event.type = StyledText.TextSet;
+	event.text = "";
+	sendTextEvent(event);
+}
+/**
+ * Deletes text.
+ * <p>
+ * @param position the position at which the text to delete starts
+ * @param length the length of the text to delete
+ * @param numLines the number of lines that are being deleted
+ */
+void delete(int position, int length, int numLines) {
+	if (length == 0) return;
+		
+	int startLine = getLineAtOffset(position);
+	int startLineOffset = getOffsetAtLine(startLine);
+	int endLine = getLineAtOffset(position + length);
+
+	String endText = "";
+	boolean splittingDelimiter = false;
+	if (position + length < getCharCount()) {
+		endText = getTextRange(position + length - 1, 2);
+		if ((endText.charAt(0) == SWT.CR) && (endText.charAt(1) == SWT.LF)) {
+			splittingDelimiter = true;
+		}
+	}
+
+	adjustGap(position + length, -length, startLine);
+	int [][] oldLines = indexLines(position, length + (gapEnd - gapStart), numLines);
+	
+	// enlarge the gap - the gap can be enlarged either to the
+	// right or left
+	if (position + length == gapStart) {
+		gapStart -= length;
+	} else {
+		gapEnd += length;
+	}		
+
+	// figure out the length of the new concatenated line, do so by
+	// finding the first line delimiter after position
+	int j = position;
+	boolean eol = false;
+	while (j < textStore.length && !eol) {
+		if (j < gapStart || j >= gapEnd) {
+			char ch = textStore[j];
+			if (isDelimiter(ch)) {
+				if (j + 1 < textStore.length) {
+					if (ch == SWT.CR && (textStore[j+1] == SWT.LF)) {
+						j++;
+					}
+				}
+				eol = true;
+			} 
+		}
+		j++;
+	}
+	// update the line where the deletion started
+	lines[startLine][1] = (position - startLineOffset) + (j - position);
+	// figure out the number of lines that have been deleted
+	int numOldLines = oldLines.length - 1;
+	if (splittingDelimiter) numOldLines -= 1;
+	// shift up the lines after the last deleted line, no need to update
+	// the offset or length of the lines
+	for (int i = endLine + 1; i < lineCount; i++) {
+		lines[i - numOldLines] = lines[i];
+	}
+	lineCount -= numOldLines;
+	gapLine = getLineAtPhysicalOffset(gapStart);		
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/custom/ExtendedModifyEvent.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/custom/ExtendedModifyEvent.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/custom/ExtendedModifyEvent.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.custom;
+
+import org.eclipse.swt.events.*;
+
+/**
+ * This event is sent after a text change occurs.
+ *
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public final class ExtendedModifyEvent extends TypedEvent {
+	/** start offset of the new text */
+	public int start;			
+	/** length of the new text */
+	public int length;
+	/** replaced text or empty string if no text was replaced */
+	public String replacedText;
+	
+	static final long serialVersionUID = 3258696507027830832L;
+
+/**
+ * Constructs a new instance of this class based on the
+ * information in the given event.
+ *
+ * @param e the event containing the information
+ */
+public ExtendedModifyEvent(StyledTextEvent e) {
+	super(e);
+	start = e.start;
+	length = e.end - e.start;
+	replacedText = e.text;
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/custom/ExtendedModifyListener.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/custom/ExtendedModifyListener.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/custom/ExtendedModifyListener.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.custom;
+
+import org.eclipse.swt.internal.SWTEventListener;
+
+/**
+ * Classes which implement this interface provide a method
+ * that deals with the event that is generated when text
+ * is modified.
+ *
+ * @see ExtendedModifyEvent
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public interface ExtendedModifyListener extends SWTEventListener {
+
+/**
+ * This method is called after a text change occurs.
+ * <p>
+ * The following event fields are used:<ul>
+ * <li>event.start the start offset of the new text (input)</li>
+ * <li>event.length the length of the new text (input)</li>
+ * <li>event.replacedText the replaced text (input)</li>
+ * </ul>
+ *
+ * @param event the given event
+ * @see ExtendedModifyEvent
+ */
+public void modifyText(ExtendedModifyEvent event);
+}
+
+

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/custom/LineBackgroundEvent.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/custom/LineBackgroundEvent.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/custom/LineBackgroundEvent.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.custom;
+
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
+
+/**
+ * This event is sent when a line is about to be drawn.
+ *
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public class LineBackgroundEvent extends TypedEvent {
+	
+	/**
+	 * line start offset
+	 */
+	public int lineOffset;
+	
+	/**
+	 * line text
+	 */
+	public String lineText;
+	
+	/**
+	 * line background color
+	 */
+	public Color lineBackground; 
+	
+	static final long serialVersionUID = 3978711687853324342L;
+
+/**
+ * Constructs a new instance of this class based on the
+ * information in the given event.
+ *
+ * @param e the event containing the information
+ */
+public LineBackgroundEvent(StyledTextEvent e) {
+	super(e);
+	lineOffset = e.detail;
+	lineText = e.text;
+	lineBackground = e.lineBackground;
+}
+}
+
+

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/custom/LineBackgroundListener.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/custom/LineBackgroundListener.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/custom/LineBackgroundListener.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.custom;
+
+import org.eclipse.swt.internal.SWTEventListener;
+
+/**
+ * Classes which implement this interface provide a method
+ * that can provide the background color for a line that
+ * is to be drawn.
+ *
+ * @see LineBackgroundEvent
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public interface LineBackgroundListener extends SWTEventListener {
+	
+/**
+ * This method is called when a line is about to be drawn in order to get its
+ * background color.
+ * <p>
+ * The following event fields are used:<ul>
+ * <li>event.lineOffset line start offset (input)</li>
+ * <li>event.lineText line text (input)</li>
+ * <li>event.lineBackground line background color (output)</li>
+ * </ul>
+ *
+ * @param event the given event
+ * @see LineBackgroundEvent
+ */
+public void lineGetBackground(LineBackgroundEvent event);
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/custom/LineStyleEvent.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/custom/LineStyleEvent.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/custom/LineStyleEvent.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,103 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.custom;
+
+import org.eclipse.swt.events.*;
+
+/**
+ * This event is sent when a line is about to be drawn.
+ *
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public class LineStyleEvent extends TypedEvent {
+	
+	/**
+	 * line start offset (input)
+	 */
+	public int lineOffset;
+	
+	/**
+	 * line text (input)
+	 */
+	public String lineText;
+	
+	/**
+	 * line ranges (output)
+	 * 
+	 * @since 3.2
+	 */
+	public int[] ranges;
+	
+	/**
+	 * line styles (output)
+	 * 
+	 * Note: Because a StyleRange includes the start and length, the
+	 * same instance cannot occur multiple times in the array of styles.
+	 * If the same style attributes, such as font and color, occur in
+	 * multiple StyleRanges, <code>ranges</code> can be used to share
+	 * styles and reduce memory usage.
+	 */
+	public StyleRange[] styles;
+
+	/** 
+	 * line alignment (input, output)
+	 * 
+	 * @since 3.2
+	 */
+	public int alignment;
+
+	/**
+	 * line indent (input, output)
+	 * 
+	 * @since 3.2
+	 */
+	public int indent;
+
+	/** 
+	 * line justification (input, output)
+	 * 
+	 * @since 3.2
+	 */
+	public boolean justify;
+
+	/**
+	 * line bullet (output)
+	 * @since 3.2
+	 */
+	public Bullet bullet;
+
+	/**
+	 * line bullet index (output)
+	 * @since 3.2
+	 */
+	public int bulletIndex;
+	
+	static final long serialVersionUID = 3906081274027192884L;
+
+/**
+ * Constructs a new instance of this class based on the
+ * information in the given event.
+ *
+ * @param e the event containing the information
+ */
+public LineStyleEvent(StyledTextEvent e) {
+	super(e);
+	styles = e.styles;
+	ranges = e.ranges;
+	lineOffset = e.detail;
+	lineText = e.text;
+	alignment = e.alignment;
+	justify = e.justify;
+	indent = e.indent;
+	bullet = e.bullet;
+	bulletIndex = e.bulletIndex;
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/custom/LineStyleListener.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/custom/LineStyleListener.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/custom/LineStyleListener.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.custom;
+
+import org.eclipse.swt.internal.SWTEventListener;
+
+/**
+ * Classes which implement this interface provide a method
+ * that can provide the style information for a line that
+ * is to be drawn.
+ *
+ * @see LineStyleEvent
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public interface LineStyleListener extends SWTEventListener {
+
+/**
+ * This method is called when a line is about to be drawn in order to get the
+ * line's style information.
+ * <p>
+ * The following event fields are used:<ul>
+ * <li>event.lineOffset line start offset (input)</li>
+ * <li>event.lineText line text (input)</li>
+ * <li>event.styles array of StyleRanges, need to be in order (output)</li>
+ * </ul>
+ *
+ * @param event the given event
+ * @see LineStyleEvent
+ */
+public void lineGetStyle(LineStyleEvent event);
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/custom/MovementEvent.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/custom/MovementEvent.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/custom/MovementEvent.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,74 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.custom;
+
+import org.eclipse.swt.events.*;
+
+/**
+ * This event is sent when a new offset is required based on the current
+ * offset and a movement type.
+ * 
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ *
+ * @since 3.3
+ */
+public class MovementEvent extends TypedEvent {
+	
+	/**
+	 * line start offset (input)
+	 */
+	public int lineOffset;
+	
+	/**
+	 * line text (input)
+	 */
+	public String lineText;
+	
+	/**
+	 * the current offset (input)
+	 */
+	public int offset;
+	
+	/**
+	 * the new offset  (input, output)
+	 */
+	public int newOffset;
+	
+	/**
+	 * the movement type (input)
+	 * 
+	 * @see org.eclipse.swt.SWT#MOVEMENT_WORD
+	 * @see org.eclipse.swt.SWT#MOVEMENT_WORD_END 
+	 * @see org.eclipse.swt.SWT#MOVEMENT_WORD_START
+	 * @see org.eclipse.swt.SWT#MOVEMENT_CHAR
+	 * @see org.eclipse.swt.SWT#MOVEMENT_CLUSTER
+	 */
+	public int movement;
+	
+	static final long serialVersionUID = 3978765487853324342L;
+
+/**
+ * Constructs a new instance of this class based on the
+ * information in the given event.
+ *
+ * @param e the event containing the information
+ */
+public MovementEvent(StyledTextEvent e) {
+	super(e);
+	lineOffset = e.detail;
+	lineText = e.text;
+	movement = e.count;
+	offset = e.start;
+	newOffset = e.end;
+}
+}
+
+

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/custom/MovementListener.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/custom/MovementListener.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/custom/MovementListener.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.custom;
+
+import org.eclipse.swt.internal.SWTEventListener;
+
+/**
+ * This listener is invoked when a new offset is required based on the current
+ * offset and a movement type.
+ *
+ * @see org.eclipse.swt.SWT#MOVEMENT_WORD
+ * @see org.eclipse.swt.SWT#MOVEMENT_WORD_END 
+ * @see org.eclipse.swt.SWT#MOVEMENT_WORD_START
+ * @see org.eclipse.swt.SWT#MOVEMENT_CHAR
+ * @see org.eclipse.swt.SWT#MOVEMENT_CLUSTER
+ * 
+ * @since 3.3
+ */
+public interface MovementListener extends SWTEventListener {
+/**
+ * This method is called when a new offset is required based on the current
+ * offset and a movement type.
+ * 
+ * <p>
+ * The following event fields are used:<ul>
+ * <li>event.lineOffset line start offset (input)</li>
+ * <li>event.lineText line text (input)</li>
+ * <li>event.movement the movement type (input)</li>
+ * <li>event.offset the current offset (input)</li>
+ * <li>event.newOffset the new offset (input, output)</li>
+ * </ul>
+ *
+ * @param event the event
+ * 
+ * @see MovementEvent
+ * @see StyledText#addWordMovementListener(MovementListener)
+ */
+public void getNextOffset (MovementEvent event);
+/**
+ * This method is called when a new offset is required based on the current
+ * offset and a movement type.
+ * 
+ * <p>
+ * The following event fields are used:<ul>
+ * <li>event.lineOffset line start offset (input)</li>
+ * <li>event.lineText line text (input)</li>
+ * <li>event.movement the movement type (input)</li>
+ * <li>event.offset the current offset (input)</li>
+ * <li>event.newOffset the new offset (input, output)</li>
+ * </ul>
+ *
+ * @param event the event
+ * 
+ * @see MovementEvent
+ * @see StyledText#addWordMovementListener(MovementListener)
+ */
+public void getPreviousOffset (MovementEvent event);
+
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/custom/PaintObjectEvent.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/custom/PaintObjectEvent.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/custom/PaintObjectEvent.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,84 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.custom;
+
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
+
+/**
+ * This event is sent when an object needs to be drawn.
+ * 
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ *
+ * @since 3.2
+ */
+public class PaintObjectEvent extends TypedEvent {
+	
+	/**
+	 * the GC
+	 */
+	public GC gc;
+	
+	/**
+	 * the x location
+	 */
+	public int x;
+	
+	/**
+	 * the y location
+	 */
+	public int y;
+	
+	/**
+	 * the line ascent
+	 */
+	public int ascent;
+	
+	/**
+	 * the line descent
+	 */
+	public int descent;
+	
+	/**
+	 * the StyleRange
+	 */
+	public StyleRange style;
+	
+	/**
+	 * the Bullet
+	 */
+	public Bullet bullet;
+	
+	/**
+	 * the bullet index
+	 */
+	public int bulletIndex;
+	
+	static final long serialVersionUID = 3906081274027192855L;
+
+/**
+ * Constructs a new instance of this class based on the
+ * information in the given event.
+ *
+ * @param e the event containing the information
+ */
+public PaintObjectEvent(StyledTextEvent e) {
+	super(e);
+	gc = e.gc;
+	x = e.x;
+	y = e.y;
+	ascent = e.ascent;
+	descent = e.descent;
+	style = e.style;
+	bullet = e.bullet;
+	bulletIndex = e.bulletIndex;
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/custom/PaintObjectListener.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/custom/PaintObjectListener.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/custom/PaintObjectListener.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.custom;
+
+
+import org.eclipse.swt.internal.SWTEventListener;
+/**
+ * This listener is invoked when an object needs to be drawn.
+ *
+ * @since 3.2
+ */
+public interface PaintObjectListener extends SWTEventListener {
+/**
+ * This method is called when an object needs to be drawn.
+ * 
+ * <p>
+ * The following event fields are used:<ul>
+ * <li>event.x the x location (input)</li>
+ * <li>event.y the y location (input)</li>
+ * <li>event.ascent the line ascent (input)</li>
+ * <li>event.descent the line descent (input)</li>
+ * <li>event.gc the gc (input)</li>
+ * <li>event.style the style (input)</li>
+ * </ul>
+ *
+ * @param event the event
+ * 
+ * @see PaintObjectEvent
+ * @see StyledText#addPaintObjectListener(PaintObjectListener)
+ */
+public void paintObject(PaintObjectEvent event);
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/custom/PopupList.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/custom/PopupList.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/custom/PopupList.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,274 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.custom;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+
+/**
+* A PopupList is a list of selectable items that appears in its own shell positioned above
+* its parent shell.  It is used for selecting items when editing a Table cell (similar to the
+* list that appears when you open a Combo box).
+*
+* The list will be positioned so that it does not run off the screen and the largest number of items
+* are visible.  It may appear above the current cursor location or below it depending how close you 
+* are to the edge of the screen.
+*
+* @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+*/
+public class PopupList {
+	Shell  shell;
+	List   list;
+	int    minimumWidth;
+/** 
+* Creates a PopupList above the specified shell.
+* 
+* @param parent a Shell control which will be the parent of the new instance (cannot be null)
+*/
+public PopupList(Shell parent) {
+	this (parent, 0);
+}
+/** 
+* Creates a PopupList above the specified shell.
+* 
+* @param parent a widget which will be the parent of the new instance (cannot be null)
+* @param style the style of widget to construct
+* 
+* @since 3.0 
+*/
+public PopupList(Shell parent, int style) {
+	shell = new Shell(parent, checkStyle(style));
+	
+	list = new List(shell, SWT.SINGLE | SWT.V_SCROLL);	
+
+	// close dialog if user selects outside of the shell
+	shell.addListener(SWT.Deactivate, new Listener() {
+		public void handleEvent(Event e){	
+			shell.setVisible (false);
+		}
+	});
+	
+	// resize shell when list resizes
+	shell.addControlListener(new ControlListener() {
+		public void controlMoved(ControlEvent e){}
+		public void controlResized(ControlEvent e){
+			Rectangle shellSize = shell.getClientArea();
+			list.setSize(shellSize.width, shellSize.height);
+		}
+	});
+	
+	// return list selection on Mouse Up or Carriage Return
+	list.addMouseListener(new MouseListener() {
+		public void mouseDoubleClick(MouseEvent e){}
+		public void mouseDown(MouseEvent e){}
+		public void mouseUp(MouseEvent e){
+			shell.setVisible (false);
+		}
+	});
+	list.addKeyListener(new KeyListener() {
+		public void keyReleased(KeyEvent e){}
+		public void keyPressed(KeyEvent e){
+			if (e.character == '\r'){
+				shell.setVisible (false);
+			}
+		}
+	});
+	
+}
+private static int checkStyle (int style) {
+	int mask = SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT;
+	return style & mask;
+}
+/**
+* Gets the widget font.
+* <p>
+* @return the widget font
+*
+* @exception SWTException <ul>
+*    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+*    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+*	</ul>
+*/
+public Font getFont () {
+	return list.getFont();
+}
+/**
+* Gets the items.
+* <p>
+* This operation will fail if the items cannot
+* be queried from the OS.
+*
+* @return the items in the widget
+*
+* @exception SWTException <ul>
+*    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+*    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+*	</ul>
+*/
+public String[] getItems () {
+	return list.getItems();
+}
+/**
+* Gets the minimum width of the list.
+*
+* @return the minimum width of the list
+*/
+public int getMinimumWidth () {
+	return minimumWidth;
+}
+/**
+* Launches the Popup List, waits for an item to be selected and then closes the PopupList.
+*
+* @param rect the initial size and location of the PopupList; the dialog will be
+*        positioned so that it does not run off the screen and the largest number of items are visible
+*
+* @return the text of the selected item or null if no item is selected
+*/
+public String open (Rectangle rect) {
+
+	Point listSize = list.computeSize (rect.width, SWT.DEFAULT, false);
+	Rectangle screenSize = shell.getDisplay().getBounds();
+
+	// Position the dialog so that it does not run off the screen and the largest number of items are visible
+	int spaceBelow = screenSize.height - (rect.y + rect.height) - 30;
+	int spaceAbove = rect.y - 30;
+
+	int y = 0;
+	if (spaceAbove > spaceBelow && listSize.y > spaceBelow) {
+		// place popup list above table cell
+		if (listSize.y > spaceAbove){
+			listSize.y = spaceAbove;
+		} else {
+			listSize.y += 2;
+		}
+		y = rect.y - listSize.y;
+		
+	} else {
+		// place popup list below table cell
+		if (listSize.y > spaceBelow){
+			listSize.y = spaceBelow;
+		} else {
+			listSize.y += 2;
+		}
+		y = rect.y + rect.height;
+	}
+	
+	// Make dialog as wide as the cell
+	listSize.x = rect.width;
+	// dialog width should not be less than minimumWidth
+	if (listSize.x < minimumWidth)
+		listSize.x = minimumWidth;
+	
+	// Align right side of dialog with right side of cell
+	int x = rect.x + rect.width - listSize.x;
+	
+	shell.setBounds(x, y, listSize.x, listSize.y);
+	
+	shell.open();
+	list.setFocus();
+
+	Display display = shell.getDisplay();
+	while (!shell.isDisposed () && shell.isVisible ()) {
+		if (!display.readAndDispatch()) display.sleep();
+	}
+	
+	String result = null;
+	if (!shell.isDisposed ()) {
+		String [] strings = list.getSelection ();
+		shell.dispose();
+		if (strings.length != 0) result = strings [0];
+	}
+	return result;
+}
+/**
+* Selects an item with text that starts with specified String.
+* <p>
+* If the item is not currently selected, it is selected.  
+* If the item at an index is selected, it remains selected.  
+* If the string is not matched, it is ignored.
+*
+* @param string the text of the item
+*
+* @exception SWTException <ul>
+*    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+*    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+*	</ul>
+*/
+public void select(String string) {
+	String[] items = list.getItems();
+
+	// find the first entry in the list that starts with the
+	// specified string
+	if (string != null){
+		for (int i = 0; i < items.length; i++) {
+			if (items[i].startsWith(string)){
+				int index = list.indexOf(items[i]);
+				list.select(index);
+				break;
+			}
+		}
+	}
+}
+/**
+* Sets the widget font.
+* <p>
+* When new font is null, the font reverts
+* to the default system font for the widget.
+*
+* @param font the new font (or null)
+* 
+* @exception SWTException <ul>
+*    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+*    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+*	</ul>
+*/
+public void setFont (Font font) {
+	list.setFont(font);
+}
+/**
+* Sets all items.
+* <p>
+* The previous selection is cleared.
+* The previous items are deleted.
+* The new items are added.
+* The top index is set to 0.
+*
+* @param strings the array of items
+*
+* This operation will fail when an item is null
+* or could not be added in the OS.
+* 
+* @exception IllegalArgumentException <ul>
+*    <li>ERROR_NULL_ARGUMENT - if the items array is null</li>
+*    <li>ERROR_INVALID_ARGUMENT - if an item in the items array is null</li>
+* </ul>
+* @exception SWTException <ul>
+*    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+*    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+*	</ul>
+*/
+public void setItems (String[] strings) {
+	list.setItems(strings);
+}
+/**
+* Sets the minimum width of the list.
+*
+* @param width the minimum width of the list
+*/
+public void setMinimumWidth (int width) {
+	if (width < 0)
+		SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+		
+	minimumWidth = width;
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/custom/ST.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/custom/ST.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/custom/ST.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,131 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.custom;
+
+
+/**
+ * This class provides access to the public constants provided by <code>StyledText</code>.
+ *
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public class ST {
+	 
+	/*
+	 *  Navigation Key Actions. Key bindings for the actions are set
+	 *  by the StyledText widget.
+	 */	
+	public static final int LINE_UP = 16777217; 			// binding = SWT.ARROW_UP
+	public static final int LINE_DOWN = 16777218; 		// binding = SWT.ARROW_DOWN
+	public static final int LINE_START = 16777223; 		// binding = SWT.HOME
+	public static final int LINE_END = 16777224; 		// binding = SWT.END
+	public static final int COLUMN_PREVIOUS = 16777219; 	// binding = SWT.ARROW_LEFT
+	public static final int COLUMN_NEXT = 16777220; 		// binding = SWT.ARROW_RIGHT
+	public static final int PAGE_UP = 16777221; 			// binding = SWT.PAGE_UP
+	public static final int PAGE_DOWN = 16777222; 		// binding = SWT.PAGE_DOWN
+	public static final int WORD_PREVIOUS = 17039363;	// binding = SWT.MOD1 + SWT.ARROW_LEFT
+	public static final int WORD_NEXT = 17039364; 		// binding = SWT.MOD1 + SWT.ARROW_RIGHT
+	public static final int TEXT_START = 17039367; 		// binding = SWT.MOD1 + SWT.HOME
+	public static final int TEXT_END = 17039368; 		// binding = SWT.MOD1 + SWT.END
+	public static final int WINDOW_START = 17039365; 	// binding = SWT.MOD1 + SWT.PAGE_UP
+	public static final int WINDOW_END = 17039366; 		// binding = SWT.MOD1 + SWT.PAGE_DOWN
+
+	/* 
+	 * Selection Key Actions 
+	 */
+	public static final int SELECT_ALL = 262209; 				// binding = SWT.MOD1 + 'A'
+	public static final int SELECT_LINE_UP = 16908289; 			// binding = SWT.MOD2 + SWT.ARROW_UP
+	public static final int SELECT_LINE_DOWN = 16908290; 		// binding = SWT.MOD2 + SWT.ARROW_DOWN
+	public static final int SELECT_LINE_START = 16908295; 		// binding = SWT.MOD2 + SWT.HOME
+	public static final int SELECT_LINE_END = 16908296; 			// binding = SWT.MOD2 + SWT.END
+	public static final int SELECT_COLUMN_PREVIOUS = 16908291;	// binding = SWT.MOD2 + SWT.ARROW_LEFT
+	public static final int SELECT_COLUMN_NEXT = 16908292; 		// binding = SWT.MOD2 + SWT.ARROW_RIGHT
+	public static final int SELECT_PAGE_UP = 16908293; 			// binding = SWT.MOD2 + SWT.PAGE_UP
+	public static final int SELECT_PAGE_DOWN = 16908294; 		// binding = SWT.MOD2 + SWT.PAGE_DOWN
+	public static final int SELECT_WORD_PREVIOUS = 17170435;		// binding = SWT.MOD1 + SWT.MOD2 + SWT.ARROW_LEFT
+	public static final int SELECT_WORD_NEXT = 17170436; 		// binding = SWT.MOD1 + SWT.MOD2 + SWT.ARROW_RIGHT
+	public static final int SELECT_TEXT_START = 17170439; 		// binding = SWT.MOD1 + SWT.MOD2 + SWT.HOME
+	public static final int SELECT_TEXT_END = 17170440; 			// binding = SWT.MOD1 + SWT.MOD2 + SWT.END
+	public static final int SELECT_WINDOW_START = 17170437; 		// binding = SWT.MOD1 + SWT.MOD2 + SWT.PAGE_UP
+	public static final int SELECT_WINDOW_END = 17170438; 		// binding = SWT.MOD1 + SWT.MOD2 + SWT.PAGE_DOWN
+
+	/*
+	 *  Modification Key Actions 
+	 */
+	public static final int CUT = 131199; 			// binding = SWT.MOD2 + SWT.DEL
+	public static final int COPY = 17039369; 		// binding = SWT.MOD1 + SWT.INSERT;
+	public static final int PASTE = 16908297;		// binding = SWT.MOD2 + SWT.INSERT ;
+	public static final int DELETE_PREVIOUS = '\b'; 	// binding = SWT.BS;
+	public static final int DELETE_NEXT = 0x7F; 		// binding = SWT.DEL;
+	public static final int DELETE_WORD_PREVIOUS = 262152;	// binding = SWT.BS | SWT.MOD1;
+	public static final int DELETE_WORD_NEXT = 262271;	// binding = SWT.DEL | SWT.MOD1;
+
+	/* 
+	 * Miscellaneous Key Actions 
+	 */
+	public static final int TOGGLE_OVERWRITE = 16777225; // binding = SWT.INSERT;
+	
+	/**
+	 *  Bullet style dot.
+	 * 
+	 *  @see Bullet
+	 *  
+	 *  @since 3.2
+	 */
+	public static final int BULLET_DOT = 1 << 0;
+
+	/**
+	 *  Bullet style number.
+	 * 
+	 *  @see Bullet
+	 *  
+	 *  @since 3.2
+	 */
+	public static final int BULLET_NUMBER = 1 << 1;
+
+	/**
+	 *  Bullet style lower case letter.
+	 * 
+	 *  @see Bullet
+	 *  
+	 *  @since 3.2
+	 */
+	public static final int BULLET_LETTER_LOWER = 1 << 2;
+
+	/**
+	 *  Bullet style upper case letter.
+	 * 
+	 *  @see Bullet
+	 *  
+	 *  @since 3.2
+	 */
+	public static final int BULLET_LETTER_UPPER = 1 << 3;
+
+	/**
+	 *  Bullet style text.
+	 * 
+	 *  @see Bullet
+	 *  
+	 *  @since 3.2
+	 */
+	public static final int BULLET_TEXT = 1 << 4;
+
+	/**
+	 *  Bullet style custom draw.
+	 *  
+	 *  @see StyledText#addPaintObjectListener(PaintObjectListener)
+	 *  @see StyledText#removePaintObjectListener(PaintObjectListener)
+	 *  @see Bullet 
+	 *  
+	 *  @since 3.2
+	 */
+	public static final int BULLET_CUSTOM = 1 << 5;
+
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/custom/SashForm.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/custom/SashForm.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/custom/SashForm.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,435 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.custom;
+
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.graphics.*;
+
+/**
+ * The SashForm is a composite control that lays out its children in a
+ * row or column arrangement (as specified by the orientation) and places
+ * a Sash between each child. One child may be maximized to occupy the
+ * entire size of the SashForm.  The relative sizes of the children may
+ * be specified using weights.
+ * <p>
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>HORIZONTAL, VERTICAL, SMOOTH</dd>
+ * </dl>
+ * </p>
+ *
+ * @see <a href="http://www.eclipse.org/swt/snippets/#sashform">SashForm snippets</a>
+ * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: CustomControlExample</a>
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public class SashForm extends Composite {
+
+	/**
+	* The width of all sashes in the form.
+	*/
+	public int SASH_WIDTH = 3;
+
+	int sashStyle;
+	Sash[] sashes = new Sash[0];
+	// Remember background and foreground
+	// colors to determine whether to set
+	// sashes to the default color (null) or
+	// a specific color
+	Color background = null;
+	Color foreground = null;
+	Control[] controls = new Control[0];
+	Control maxControl = null;
+	Listener sashListener;
+	static final int DRAG_MINIMUM = 20;
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a widget which will be the parent of the new instance (cannot be null)
+ * @param style the style of widget to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * </ul>
+ *
+ * @see SWT#HORIZONTAL
+ * @see SWT#VERTICAL
+ * @see #getStyle()
+ */
+public SashForm(Composite parent, int style) {
+	super(parent, checkStyle(style));
+	super.setLayout(new SashFormLayout());
+	sashStyle = ((style & SWT.VERTICAL) != 0) ? SWT.HORIZONTAL : SWT.VERTICAL;
+	if ((style & SWT.BORDER) != 0) sashStyle |= SWT.BORDER;
+	if ((style & SWT.SMOOTH) != 0) sashStyle |= SWT.SMOOTH;
+	sashListener = new Listener() {
+		public void handleEvent(Event e) {
+			onDragSash(e);
+		}
+	};
+}
+static int checkStyle (int style) {
+	int mask = SWT.BORDER | SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT;
+	return style & mask;
+}
+/**
+ * Returns SWT.HORIZONTAL if the controls in the SashForm are laid out side by side
+ * or SWT.VERTICAL   if the controls in the SashForm are laid out top to bottom.
+ * 
+ * @return SWT.HORIZONTAL or SWT.VERTICAL
+ */
+public int getOrientation() {
+	//checkWidget();
+	return (sashStyle & SWT.VERTICAL) != 0 ? SWT.HORIZONTAL : SWT.VERTICAL;
+}
+/**
+ * Returns the width of the sashes when the controls in the SashForm are 
+ * laid out.
+ * 
+ * @return the width of the sashes
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.4
+ */
+public int getSashWidth() {
+	checkWidget();
+	return SASH_WIDTH;
+}
+public int getStyle() {
+	int style = super.getStyle();
+	style |= getOrientation() == SWT.VERTICAL ? SWT.VERTICAL : SWT.HORIZONTAL;
+	if ((sashStyle & SWT.SMOOTH) != 0) style |= SWT.SMOOTH;
+	return style;
+}
+/**
+ * Answer the control that currently is maximized in the SashForm.  
+ * This value may be null.
+ * 
+ * @return the control that currently is maximized or null
+ */
+public Control getMaximizedControl(){
+	//checkWidget();
+	return this.maxControl;
+}
+/**
+ * Answer the relative weight of each child in the SashForm.  The weight represents the
+ * percent of the total width (if SashForm has Horizontal orientation) or 
+ * total height (if SashForm has Vertical orientation) each control occupies.
+ * The weights are returned in order of the creation of the widgets (weight[0]
+ * corresponds to the weight of the first child created).
+ * 
+ * @return the relative weight of each child
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+
+public int[] getWeights() {
+	checkWidget();
+	Control[] cArray = getControls(false);
+	int[] ratios = new int[cArray.length];
+	for (int i = 0; i < cArray.length; i++) {
+		Object data = cArray[i].getLayoutData();
+		if (data != null && data instanceof SashFormData) {
+			ratios[i] = (int)(((SashFormData)data).weight * 1000 >> 16);
+		} else {
+			ratios[i] = 200;
+		}
+	}
+	return ratios;
+}
+Control[] getControls(boolean onlyVisible) {
+	Control[] children = getChildren();
+	Control[] result = new Control[0];
+	for (int i = 0; i < children.length; i++) {
+		if (children[i] instanceof Sash) continue;
+		if (onlyVisible && !children[i].getVisible()) continue;
+
+		Control[] newResult = new Control[result.length + 1];
+		System.arraycopy(result, 0, newResult, 0, result.length);
+		newResult[result.length] = children[i];
+		result = newResult;
+	}
+	return result;
+}
+void onDragSash(Event event) {
+	Sash sash = (Sash)event.widget;
+	int sashIndex = -1;
+	for (int i= 0; i < sashes.length; i++) {
+		if (sashes[i] == sash) {
+			sashIndex = i;
+			break;
+		}
+	}
+	if (sashIndex == -1) return;
+
+	Control c1 = controls[sashIndex];
+	Control c2 = controls[sashIndex + 1];
+	Rectangle b1 = c1.getBounds();
+	Rectangle b2 = c2.getBounds();
+	
+	Rectangle sashBounds = sash.getBounds();
+	Rectangle area = getClientArea();
+	boolean correction = false;
+	if (getOrientation() == SWT.HORIZONTAL) {
+		correction = b1.width < DRAG_MINIMUM || b2.width < DRAG_MINIMUM;
+		int totalWidth = b2.x + b2.width - b1.x; 
+		int shift = event.x - sashBounds.x;
+		b1.width += shift;
+		b2.x += shift;
+		b2.width -= shift;
+		if (b1.width < DRAG_MINIMUM) {
+			b1.width = DRAG_MINIMUM;
+			b2.x = b1.x + b1.width + sashBounds.width;
+			b2.width = totalWidth - b2.x;
+			event.x = b1.x + b1.width;
+			event.doit = false;
+		}
+		if (b2.width < DRAG_MINIMUM) {
+			b1.width = totalWidth - DRAG_MINIMUM - sashBounds.width;
+			b2.x = b1.x + b1.width + sashBounds.width;
+			b2.width = DRAG_MINIMUM;
+			event.x = b1.x + b1.width;
+			event.doit = false;
+		}
+		Object data1 = c1.getLayoutData();
+		if (data1 == null || !(data1 instanceof SashFormData)) {
+			data1 = new SashFormData();
+			c1.setLayoutData(data1);
+		}
+		Object data2 = c2.getLayoutData();
+		if (data2 == null || !(data2 instanceof SashFormData)) {
+			data2 = new SashFormData();
+			c2.setLayoutData(data2);
+		}
+		((SashFormData)data1).weight = (((long)b1.width << 16) + area.width - 1) / area.width;
+		((SashFormData)data2).weight = (((long)b2.width << 16) + area.width - 1) / area.width;
+	} else {
+		correction = b1.height < DRAG_MINIMUM || b2.height < DRAG_MINIMUM;
+		int totalHeight = b2.y + b2.height - b1.y;
+		int shift = event.y - sashBounds.y;
+		b1.height += shift;
+		b2.y += shift;
+		b2.height -= shift;
+		if (b1.height < DRAG_MINIMUM) {
+			b1.height = DRAG_MINIMUM;
+			b2.y = b1.y + b1.height + sashBounds.height;
+			b2.height = totalHeight - b2.y;
+			event.y = b1.y + b1.height;
+			event.doit = false;
+		}
+		if (b2.height < DRAG_MINIMUM) {
+			b1.height = totalHeight - DRAG_MINIMUM - sashBounds.height;
+			b2.y = b1.y + b1.height + sashBounds.height;
+			b2.height = DRAG_MINIMUM;
+			event.y = b1.y + b1.height;
+			event.doit = false;
+		}
+		Object data1 = c1.getLayoutData();
+		if (data1 == null || !(data1 instanceof SashFormData)) {
+			data1 = new SashFormData();
+			c1.setLayoutData(data1);
+		}
+		Object data2 = c2.getLayoutData();
+		if (data2 == null || !(data2 instanceof SashFormData)) {
+			data2 = new SashFormData();
+			c2.setLayoutData(data2);
+		}
+		((SashFormData)data1).weight = (((long)b1.height << 16) + area.height - 1) / area.height;
+		((SashFormData)data2).weight = (((long)b2.height << 16) + area.height - 1) / area.height;
+	}
+	if (correction || (event.doit && event.detail != SWT.DRAG)) {
+		c1.setBounds(b1);
+		sash.setBounds(event.x, event.y, event.width, event.height);
+		c2.setBounds(b2);
+	}
+}
+/**
+ * If orientation is SWT.HORIZONTAL, lay the controls in the SashForm 
+ * out side by side.  If orientation is SWT.VERTICAL, lay the 
+ * controls in the SashForm out top to bottom.
+ * 
+ * @param orientation SWT.HORIZONTAL or SWT.VERTICAL
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the value of orientation is not SWT.HORIZONTAL or SWT.VERTICAL
+ * </ul>
+ */
+public void setOrientation(int orientation) {
+	checkWidget();
+	if (getOrientation() == orientation) return;
+	if (orientation != SWT.HORIZONTAL && orientation != SWT.VERTICAL) {
+		SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	}
+	sashStyle &= ~(SWT.HORIZONTAL | SWT.VERTICAL);
+	sashStyle |= orientation == SWT.VERTICAL ? SWT.HORIZONTAL : SWT.VERTICAL;
+	for (int i = 0; i < sashes.length; i++) {
+		sashes[i].dispose();
+		sashes[i] = new Sash(this, sashStyle);
+		sashes[i].setBackground(background);
+		sashes[i].setForeground(foreground);
+		sashes[i].addListener(SWT.Selection, sashListener);
+	}
+	layout(false);
+}
+public void setBackground (Color color) {
+	super.setBackground(color);
+	background = color;
+	for (int i = 0; i < sashes.length; i++) {
+		sashes[i].setBackground(background);
+	}
+}
+public void setForeground (Color color) {
+	super.setForeground(color);
+	foreground = color;
+	for (int i = 0; i < sashes.length; i++) {
+		sashes[i].setForeground(foreground);
+	}
+}
+/**
+ * Sets the layout which is associated with the receiver to be
+ * the argument which may be null.
+ * <p>
+ * Note: No Layout can be set on this Control because it already
+ * manages the size and position of its children.
+ * </p>
+ *
+ * @param layout the receiver's new layout or null
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setLayout (Layout layout) {
+	checkWidget();
+	return;
+}
+/**
+ * Specify the control that should take up the entire client area of the SashForm.  
+ * If one control has been maximized, and this method is called with a different control, 
+ * the previous control will be minimized and the new control will be maximized.
+ * If the value of control is null, the SashForm will minimize all controls and return to
+ * the default layout where all controls are laid out separated by sashes.
+ * 
+ * @param control the control to be maximized or null
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setMaximizedControl(Control control){
+	checkWidget();
+	if (control == null) {
+		if (maxControl != null) {
+			this.maxControl = null;
+			layout(false);
+			for (int i= 0; i < sashes.length; i++){
+				sashes[i].setVisible(true);
+			}
+		}
+		return;
+	}
+	
+	for (int i= 0; i < sashes.length; i++){
+		sashes[i].setVisible(false);
+	}
+	maxControl = control;
+	layout(false);
+}
+
+/**
+ * Specify the width of the sashes when the controls in the SashForm are 
+ * laid out.
+ * 
+ * @param width the width of the sashes
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.4
+ */
+public void setSashWidth(int width) {
+	checkWidget();
+	if (SASH_WIDTH == width) return;
+	SASH_WIDTH = width;
+	layout(false);
+}
+/**
+ * Specify the relative weight of each child in the SashForm.  This will determine
+ * what percent of the total width (if SashForm has Horizontal orientation) or 
+ * total height (if SashForm has Vertical orientation) each control will occupy.
+ * The weights must be positive values and there must be an entry for each
+ * non-sash child of the SashForm.
+ * 
+ * @param weights the relative weight of each child
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the weights value is null or of incorrect length (must match the number of children)</li>
+ * </ul>
+ */
+public void setWeights(int[] weights) {
+	checkWidget();
+	Control[] cArray = getControls(false);
+	if (weights == null || weights.length != cArray.length) {
+		SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	}
+	
+	int total = 0;
+	for (int i = 0; i < weights.length; i++) {
+		if (weights[i] < 0) {
+			SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+		}
+		total += weights[i];
+	}
+	if (total == 0) {
+		SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	}
+	for (int i = 0; i < cArray.length; i++) {
+		Object data = cArray[i].getLayoutData();
+		if (data == null || !(data instanceof SashFormData)) {
+			data = new SashFormData();
+			cArray[i].setLayoutData(data);
+		}
+		((SashFormData)data).weight = (((long)weights[i] << 16) + total - 1) / total;
+	}
+
+	layout(false);
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/custom/SashFormData.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/custom/SashFormData.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/custom/SashFormData.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.custom;
+
+class SashFormData {
+
+	long weight;
+
+String getName () {
+	String string = getClass ().getName ();
+	int index = string.lastIndexOf ('.');
+	if (index == -1) return string;
+	return string.substring (index + 1, string.length ());
+}
+
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the event
+ */
+public String toString () {
+	return getName()+" {weight="+weight+"}"; //$NON-NLS-2$
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/custom/SashFormLayout.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/custom/SashFormLayout.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/custom/SashFormLayout.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,195 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.custom;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+
+/**
+ * This class provides the layout for SashForm
+ * 
+ * @see SashForm
+ */
+class SashFormLayout extends Layout {
+protected Point computeSize(Composite composite, int wHint, int hHint, boolean flushCache) {
+	SashForm sashForm = (SashForm)composite;
+	Control[] cArray = sashForm.getControls(true);
+	int width = 0;
+	int height = 0;
+	if (cArray.length == 0) {		
+		if (wHint != SWT.DEFAULT) width = wHint;
+		if (hHint != SWT.DEFAULT) height = hHint;
+		return new Point(width, height);
+	}
+	// determine control sizes
+	boolean vertical = sashForm.getOrientation() == SWT.VERTICAL;
+	int maxIndex = 0;
+	int maxValue = 0;
+	for (int i = 0; i < cArray.length; i++) {
+		if (vertical) {
+			Point size = cArray[i].computeSize(wHint, SWT.DEFAULT, flushCache);
+			if (size.y > maxValue) {
+				maxIndex = i;
+				maxValue = size.y;
+			}
+			width = Math.max(width, size.x);
+		} else {
+			Point size = cArray[i].computeSize(SWT.DEFAULT, hHint, flushCache);
+			if (size.x > maxValue) {
+				maxIndex = i;
+				maxValue = size.x;
+			}
+			height = Math.max(height, size.y);
+		}
+	}
+	// get the ratios
+	long[] ratios = new long[cArray.length];
+	long total = 0;
+	for (int i = 0; i < cArray.length; i++) {
+		Object data = cArray[i].getLayoutData();
+		if (data != null && data instanceof SashFormData) {
+			ratios[i] = ((SashFormData)data).weight;
+		} else {
+			data = new SashFormData();
+			cArray[i].setLayoutData(data);
+			((SashFormData)data).weight = ratios[i] = ((200 << 16) + 999) / 1000;
+			
+		}
+		total += ratios[i];
+	}
+	if (ratios[maxIndex] > 0) {
+		int sashwidth = sashForm.sashes.length > 0 ? sashForm.SASH_WIDTH + sashForm.sashes [0].getBorderWidth() * 2 : sashForm.SASH_WIDTH;
+		if (vertical) {
+			height += (int)(total * maxValue / ratios[maxIndex]) + (cArray.length - 1) * sashwidth;
+		} else {
+			width += (int)(total * maxValue / ratios[maxIndex]) + (cArray.length - 1) * sashwidth;
+		}
+	}
+	width += sashForm.getBorderWidth()*2;
+	height += sashForm.getBorderWidth()*2;
+	if (wHint != SWT.DEFAULT) width = wHint;
+	if (hHint != SWT.DEFAULT) height = hHint;
+	return new Point(width, height);
+}
+
+protected boolean flushCache(Control control) {
+	return true;
+}
+
+protected void layout(Composite composite, boolean flushCache) {
+	SashForm sashForm = (SashForm)composite;
+	Rectangle area = sashForm.getClientArea();
+	if (area.width <= 1 || area.height <= 1) return;
+	
+	Control[] newControls = sashForm.getControls(true);
+	if (sashForm.controls.length == 0 && newControls.length == 0) return;
+	sashForm.controls = newControls;
+	
+	Control[] controls = sashForm.controls;
+	
+	if (sashForm.maxControl != null && !sashForm.maxControl.isDisposed()) {
+		for (int i= 0; i < controls.length; i++){
+			if (controls[i] != sashForm.maxControl) {
+				controls[i].setBounds(-200, -200, 0, 0);
+			} else {
+				controls[i].setBounds(area);
+			}
+		}
+		return;
+	}
+	
+	// keep just the right number of sashes
+	if (sashForm.sashes.length < controls.length - 1) {
+		Sash[] newSashes = new Sash[controls.length - 1];
+		System.arraycopy(sashForm.sashes, 0, newSashes, 0, sashForm.sashes.length);
+		for (int i = sashForm.sashes.length; i < newSashes.length; i++) {
+			newSashes[i] = new Sash(sashForm, sashForm.sashStyle);
+			newSashes[i].setBackground(sashForm.background);
+			newSashes[i].setForeground(sashForm.foreground);
+			newSashes[i].addListener(SWT.Selection, sashForm.sashListener);
+		}
+		sashForm.sashes = newSashes;
+	}
+	if (sashForm.sashes.length > controls.length - 1) {
+		if (controls.length == 0) {
+			for (int i = 0; i < sashForm.sashes.length; i++) {
+				sashForm.sashes[i].dispose();
+			}
+			sashForm.sashes = new Sash[0];
+		} else {
+			Sash[] newSashes = new Sash[controls.length - 1];
+			System.arraycopy(sashForm.sashes, 0, newSashes, 0, newSashes.length);
+			for (int i = controls.length - 1; i < sashForm.sashes.length; i++) {
+				sashForm.sashes[i].dispose();
+			}
+			sashForm.sashes = newSashes;
+		}
+	}
+	if (controls.length == 0) return;
+	Sash[] sashes = sashForm.sashes;
+	// get the ratios
+	long[] ratios = new long[controls.length];
+	long total = 0;
+	for (int i = 0; i < controls.length; i++) {
+		Object data = controls[i].getLayoutData();
+		if (data != null && data instanceof SashFormData) {
+			ratios[i] = ((SashFormData)data).weight;
+		} else {
+			data = new SashFormData();
+			controls[i].setLayoutData(data);
+			((SashFormData)data).weight = ratios[i] = ((200 << 16) + 999) / 1000;
+			
+		}
+		total += ratios[i];
+	}
+	
+	int sashwidth = sashes.length > 0 ? sashForm.SASH_WIDTH + sashes [0].getBorderWidth() * 2 : sashForm.SASH_WIDTH;
+	if (sashForm.getOrientation() == SWT.HORIZONTAL) {
+		int width = (int)(ratios[0] * (area.width - sashes.length * sashwidth) / total);
+		int x = area.x;
+		controls[0].setBounds(x, area.y, width, area.height);
+		x += width;
+		for (int i = 1; i < controls.length - 1; i++) {
+			sashes[i - 1].setBounds(x, area.y, sashwidth, area.height);
+			x += sashwidth;
+			width = (int)(ratios[i] * (area.width - sashes.length * sashwidth) / total);
+			controls[i].setBounds(x, area.y, width, area.height);
+			x += width;
+		}
+		if (controls.length > 1) {
+			sashes[sashes.length - 1].setBounds(x, area.y, sashwidth, area.height);
+			x += sashwidth;
+			width = area.width - x;
+			controls[controls.length - 1].setBounds(x, area.y, width, area.height);
+		}
+	} else {
+		int height = (int)(ratios[0] * (area.height - sashes.length * sashwidth) / total);
+		int y = area.y;
+		controls[0].setBounds(area.x, y, area.width, height);
+		y += height;
+		for (int i = 1; i < controls.length - 1; i++) {
+			sashes[i - 1].setBounds(area.x, y, area.width, sashwidth);
+			y += sashwidth;
+			height = (int)(ratios[i] * (area.height - sashes.length * sashwidth) / total);
+			controls[i].setBounds(area.x, y, area.width, height);
+			y += height;
+		}
+		if (controls.length > 1) {
+			sashes[sashes.length - 1].setBounds(area.x, y, area.width, sashwidth);
+			y += sashwidth;
+			height = area.height - y;
+			controls[controls.length - 1].setBounds(area.x, y, area.width, height);
+		}
+
+	}
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/custom/ScrolledComposite.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/custom/ScrolledComposite.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/custom/ScrolledComposite.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,694 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.custom;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+
+/**
+ * A ScrolledComposite provides scrollbars and will scroll its content when the user
+ * uses the scrollbars.
+ *
+ *
+ * <p>There are two ways to use the ScrolledComposite:
+ * 
+ * <p>
+ * 1) Set the size of the control that is being scrolled and the ScrolledComposite 
+ * will show scrollbars when the contained control can not be fully seen.
+ * 
+ * 2) The second way imitates the way a browser would work.  Set the minimum size of
+ * the control and the ScrolledComposite will show scroll bars if the visible area is 
+ * less than the minimum size of the control and it will expand the size of the control 
+ * if the visible area is greater than the minimum size.  This requires invoking 
+ * both setMinWidth(), setMinHeight() and setExpandHorizontal(), setExpandVertical().
+ * 
+ * <code><pre>
+ * public static void main (String [] args) {
+ *      Display display = new Display ();
+ *      Color red = display.getSystemColor(SWT.COLOR_RED);
+ *      Color blue = display.getSystemColor(SWT.COLOR_BLUE);
+ *      Shell shell = new Shell (display);
+ *      shell.setLayout(new FillLayout());
+ * 	
+ *      // set the size of the scrolled content - method 1
+ *      final ScrolledComposite sc1 = new ScrolledComposite(shell, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
+ *      final Composite c1 = new Composite(sc1, SWT.NONE);
+ *      sc1.setContent(c1);
+ *      c1.setBackground(red);
+ *      GridLayout layout = new GridLayout();
+ *      layout.numColumns = 4;
+ *      c1.setLayout(layout);
+ *      Button b1 = new Button (c1, SWT.PUSH);
+ *      b1.setText("first button");
+ *      c1.setSize(c1.computeSize(SWT.DEFAULT, SWT.DEFAULT));
+ *      
+ *      // set the minimum width and height of the scrolled content - method 2
+ *      final ScrolledComposite sc2 = new ScrolledComposite(shell, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
+ *      sc2.setExpandHorizontal(true);
+ *      sc2.setExpandVertical(true);
+ *      final Composite c2 = new Composite(sc2, SWT.NONE);
+ *      sc2.setContent(c2);
+ *      c2.setBackground(blue);
+ *      layout = new GridLayout();
+ *      layout.numColumns = 4;
+ *      c2.setLayout(layout);
+ *      Button b2 = new Button (c2, SWT.PUSH);
+ *      b2.setText("first button");
+ *      sc2.setMinSize(c2.computeSize(SWT.DEFAULT, SWT.DEFAULT));
+ *      
+ *      Button add = new Button (shell, SWT.PUSH);
+ *      add.setText("add children");
+ *      final int[] index = new int[]{0};
+ *      add.addListener(SWT.Selection, new Listener() {
+ *          public void handleEvent(Event e) {
+ *              index[0]++;
+ *              Button button = new Button(c1, SWT.PUSH);
+ *              button.setText("button "+index[0]);
+ *              // reset size of content so children can be seen - method 1
+ *              c1.setSize(c1.computeSize(SWT.DEFAULT, SWT.DEFAULT));
+ *              c1.layout();
+ *              
+ *              button = new Button(c2, SWT.PUSH);
+ *              button.setText("button "+index[0]);
+ *              // reset the minimum width and height so children can be seen - method 2
+ *              sc2.setMinSize(c2.computeSize(SWT.DEFAULT, SWT.DEFAULT));
+ *              c2.layout();
+ *          }
+ *      });
+ * 
+ *      shell.open ();
+ *      while (!shell.isDisposed ()) {
+ *          if (!display.readAndDispatch ()) display.sleep ();
+ *      }
+ *      display.dispose ();
+ * }
+ * </pre></code>
+ *
+ * <dl>
+ * <dt><b>Styles:</b><dd>H_SCROLL, V_SCROLL
+ * </dl>
+ *
+ * @see <a href="http://www.eclipse.org/swt/snippets/#scrolledcomposite">ScrolledComposite snippets</a>
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public class ScrolledComposite extends Composite {
+
+	Control content;
+	Listener contentListener;
+	Listener filter;
+	
+	int minHeight = 0;
+	int minWidth = 0;
+	boolean expandHorizontal = false;
+	boolean expandVertical = false;
+	boolean alwaysShowScroll = false;
+	boolean showFocusedControl = false;
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a widget which will be the parent of the new instance (cannot be null)
+ * @param style the style of widget to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * </ul>
+ *
+ * @see SWT#H_SCROLL
+ * @see SWT#V_SCROLL
+ * @see #getStyle()
+ */	
+public ScrolledComposite(Composite parent, int style) {
+	super(parent, checkStyle(style));
+	super.setLayout(new ScrolledCompositeLayout());
+	ScrollBar hBar = getHorizontalBar ();
+	if (hBar != null) {
+		hBar.setVisible(false);
+		hBar.addListener (SWT.Selection, new Listener () {
+			public void handleEvent (Event e) {
+				hScroll();
+			}
+		});
+	}
+	
+	ScrollBar vBar = getVerticalBar ();
+	if (vBar != null) {
+		vBar.setVisible(false);
+		vBar.addListener (SWT.Selection, new Listener () {
+			public void handleEvent (Event e) {
+				vScroll();
+			}
+		});
+	}
+	
+	contentListener = new Listener() {
+		public void handleEvent(Event e) {
+			if (e.type != SWT.Resize) return;
+			layout(false);
+		}
+	};
+	
+	filter = new Listener() {
+		public void handleEvent(Event event) {
+			if (event.widget instanceof Control) {
+				Control control = (Control) event.widget;
+				if (contains(control)) showControl(control);
+			}
+		}
+	};
+	
+	addDisposeListener(new DisposeListener() {
+		public void widgetDisposed(DisposeEvent e) {
+			getDisplay().removeFilter(SWT.FocusIn, filter);
+		}
+	});
+}
+
+static int checkStyle (int style) {
+	int mask = SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT;
+	return style & mask;
+}
+
+boolean contains(Control control) {
+	if (control == null || control.isDisposed()) return false;
+
+	Composite parent = control.getParent();
+	while (parent != null && !(parent instanceof Shell)) {
+		if (this == parent) return true;
+		parent = parent.getParent();
+	}
+	return false;
+}
+
+/**
+ * Returns the Always Show Scrollbars flag.  True if the scrollbars are 
+ * always shown even if they are not required.  False if the scrollbars are only 
+ * visible when some part of the composite needs to be scrolled to be seen.
+ * The H_SCROLL and V_SCROLL style bits are also required to enable scrollbars in the 
+ * horizontal and vertical directions.
+ * 
+ * @return the Always Show Scrollbars flag value
+ */
+public boolean getAlwaysShowScrollBars() {
+	//checkWidget();
+	return alwaysShowScroll;
+}
+
+/**
+ * Returns <code>true</code> if the content control 
+ * will be expanded to fill available horizontal space.
+ *
+ * @return the receiver's horizontal expansion state
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.2
+ */
+public boolean getExpandHorizontal() {
+	checkWidget();
+	return expandHorizontal;
+}
+
+/**
+ * Returns <code>true</code> if the content control 
+ * will be expanded to fill available vertical space.
+ *
+ * @return the receiver's vertical expansion state
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.2
+ */
+public boolean getExpandVertical() {
+	checkWidget();
+	return expandVertical;
+}
+
+/**
+ * Returns the minimum width of the content control.
+ *
+ * @return the minimum width
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.2
+ */
+public int getMinWidth() {
+	checkWidget();
+	return minWidth;
+}
+
+/**
+ * Returns the minimum height of the content control.
+ *
+ * @return the minimum height
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.2
+ */
+public int getMinHeight() {
+	checkWidget();
+	return minHeight;
+}
+
+/**
+ * Get the content that is being scrolled.
+ * 
+ * @return the control displayed in the content area
+ */
+public Control getContent() {
+	//checkWidget();
+	return content;
+}
+
+/**
+ * Returns <code>true</code> if the receiver automatically scrolls to a focused child control 
+ * to make it visible. Otherwise, returns <code>false</code>.
+ * 
+ * @return a boolean indicating whether focused child controls are automatically scrolled into the viewport
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.4
+ */
+public boolean getShowFocusedControl() {
+	checkWidget();
+	return showFocusedControl;
+}
+
+void hScroll() {
+	if (content == null) return;
+	Point location = content.getLocation ();
+	ScrollBar hBar = getHorizontalBar ();
+	int hSelection = hBar.getSelection ();
+	content.setLocation (-hSelection, location.y);
+}
+boolean needHScroll(Rectangle contentRect, boolean vVisible) {
+	ScrollBar hBar = getHorizontalBar();
+	if (hBar == null) return false;
+	
+	Rectangle hostRect = getBounds();
+	int border = getBorderWidth();
+	hostRect.width -= 2*border;
+	ScrollBar vBar = getVerticalBar();
+	if (vVisible && vBar != null) hostRect.width -= vBar.getSize().x;
+	
+	if (!expandHorizontal && contentRect.width > hostRect.width) return true;
+	if (expandHorizontal && minWidth > hostRect.width) return true;
+	return false;
+}
+
+boolean needVScroll(Rectangle contentRect, boolean hVisible) {
+	ScrollBar vBar = getVerticalBar();
+	if (vBar == null) return false;
+	
+	Rectangle hostRect = getBounds();
+	int border = getBorderWidth();
+	hostRect.height -= 2*border;
+	ScrollBar hBar = getHorizontalBar();
+	if (hVisible && hBar != null) hostRect.height -= hBar.getSize().y;
+	
+	if (!expandVertical && contentRect.height > hostRect.height) return true;
+	if (expandVertical && minHeight > hostRect.height) return true;
+	return false;
+}
+
+/**
+ * Return the point in the content that currently appears in the top left 
+ * corner of the scrolled composite.
+ * 
+ * @return the point in the content that currently appears in the top left 
+ * corner of the scrolled composite.  If no content has been set, this returns
+ * (0, 0).
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 2.0
+ */
+public Point getOrigin() {
+	checkWidget();
+	if (content == null) return new Point(0, 0);
+	Point location = content.getLocation();
+	return new Point(-location.x, -location.y);
+}
+/**
+ * Scrolls the content so that the specified point in the content is in the top 
+ * left corner.  If no content has been set, nothing will occur.  
+ * 
+ * Negative values will be ignored.  Values greater than the maximum scroll 
+ * distance will result in scrolling to the end of the scrollbar.
+ *
+ * @param origin the point on the content to appear in the top left corner 
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_INVALID_ARGUMENT - value of origin is outside of content
+ * </ul>
+ * @since 2.0
+ */
+public void setOrigin(Point origin) {
+	setOrigin(origin.x, origin.y);
+}
+/**
+ * Scrolls the content so that the specified point in the content is in the top 
+ * left corner.  If no content has been set, nothing will occur.  
+ * 
+ * Negative values will be ignored.  Values greater than the maximum scroll 
+ * distance will result in scrolling to the end of the scrollbar.
+ *
+ * @param x the x coordinate of the content to appear in the top left corner 
+ * 
+ * @param y the y coordinate of the content to appear in the top left corner 
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 2.0
+ */
+public void setOrigin(int x, int y) {
+	checkWidget();
+	if (content == null) return;
+	ScrollBar hBar = getHorizontalBar ();
+	if (hBar != null) {
+		hBar.setSelection(x);
+		x = -hBar.getSelection ();
+	} else {
+		x = 0;
+	}
+	ScrollBar vBar = getVerticalBar ();
+	if (vBar != null) {
+		vBar.setSelection(y);
+		y = -vBar.getSelection ();
+	} else {
+		y = 0;
+	}
+	content.setLocation(x, y);
+}
+/**
+ * Set the Always Show Scrollbars flag.  True if the scrollbars are 
+ * always shown even if they are not required.  False if the scrollbars are only 
+ * visible when some part of the composite needs to be scrolled to be seen.
+ * The H_SCROLL and V_SCROLL style bits are also required to enable scrollbars in the 
+ * horizontal and vertical directions.
+ * 
+ * @param show true to show the scrollbars even when not required, false to show scrollbars only when required
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setAlwaysShowScrollBars(boolean show) {
+	checkWidget();
+	if (show == alwaysShowScroll) return;
+	alwaysShowScroll = show;
+	ScrollBar hBar = getHorizontalBar ();
+	if (hBar != null && alwaysShowScroll) hBar.setVisible(true);
+	ScrollBar vBar = getVerticalBar ();
+	if (vBar != null && alwaysShowScroll) vBar.setVisible(true);
+	layout(false);
+}
+
+/**
+ * Set the content that will be scrolled.
+ * 
+ * @param content the control to be displayed in the content area
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setContent(Control content) {
+	checkWidget();
+	if (this.content != null && !this.content.isDisposed()) {
+		this.content.removeListener(SWT.Resize, contentListener);
+		this.content.setBounds(new Rectangle(-200, -200, 0, 0));	
+	}
+	
+	this.content = content;
+	ScrollBar vBar = getVerticalBar ();
+	ScrollBar hBar = getHorizontalBar ();
+	if (this.content != null) {
+		if (vBar != null) {
+			vBar.setMaximum (0);
+			vBar.setThumb (0);
+			vBar.setSelection(0);
+		}
+		if (hBar != null) {
+			hBar.setMaximum (0);
+			hBar.setThumb (0);
+			hBar.setSelection(0);
+		}
+		content.setLocation(0, 0);
+		layout(false);
+		this.content.addListener(SWT.Resize, contentListener);
+	} else {
+		if (hBar != null) hBar.setVisible(alwaysShowScroll);
+		if (vBar != null) vBar.setVisible(alwaysShowScroll);
+	}
+}
+/**
+ * Configure the ScrolledComposite to resize the content object to be as wide as the 
+ * ScrolledComposite when the width of the ScrolledComposite is greater than the
+ * minimum width specified in setMinWidth.  If the ScrolledComposite is less than the
+ * minimum width, the content will not be resized and instead the horizontal scroll bar will be
+ * used to view the entire width.
+ * If expand is false, this behaviour is turned off.  By default, this behaviour is turned off.
+ * 
+ * @param expand true to expand the content control to fill available horizontal space
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setExpandHorizontal(boolean expand) {
+	checkWidget();
+	if (expand == expandHorizontal) return;
+	expandHorizontal = expand;
+	layout(false);
+}
+/**
+ * Configure the ScrolledComposite to resize the content object to be as tall as the 
+ * ScrolledComposite when the height of the ScrolledComposite is greater than the
+ * minimum height specified in setMinHeight.  If the ScrolledComposite is less than the
+ * minimum height, the content will not be resized and instead the vertical scroll bar will be
+ * used to view the entire height.
+ * If expand is false, this behaviour is turned off.  By default, this behaviour is turned off.
+ * 
+ * @param expand true to expand the content control to fill available vertical space
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setExpandVertical(boolean expand) {
+	checkWidget();
+	if (expand == expandVertical) return;
+	expandVertical = expand;
+	layout(false);
+}
+/**
+ * Sets the layout which is associated with the receiver to be
+ * the argument which may be null.
+ * <p>
+ * Note: No Layout can be set on this Control because it already
+ * manages the size and position of its children.
+ * </p>
+ *
+ * @param layout the receiver's new layout or null
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setLayout (Layout layout) {
+	checkWidget();
+	return;
+}
+/**
+ * Specify the minimum height at which the ScrolledComposite will begin scrolling the
+ * content with the vertical scroll bar.  This value is only relevant if  
+ * setExpandVertical(true) has been set.
+ * 
+ * @param height the minimum height or 0 for default height
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setMinHeight(int height) {
+	setMinSize(minWidth, height);
+}
+/**
+ * Specify the minimum width and height at which the ScrolledComposite will begin scrolling the
+ * content with the horizontal scroll bar.  This value is only relevant if  
+ * setExpandHorizontal(true) and setExpandVertical(true) have been set.
+ * 
+ * @param size the minimum size or null for the default size
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setMinSize(Point size) {
+	if (size == null) {
+		setMinSize(0, 0);
+	} else {
+		setMinSize(size.x, size.y);
+	}
+}
+/**
+ * Specify the minimum width and height at which the ScrolledComposite will begin scrolling the
+ * content with the horizontal scroll bar.  This value is only relevant if  
+ * setExpandHorizontal(true) and setExpandVertical(true) have been set.
+ * 
+ * @param width the minimum width or 0 for default width
+ * @param height the minimum height or 0 for default height
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setMinSize(int width, int height) {
+	checkWidget();
+	if (width == minWidth && height == minHeight) return;
+	minWidth = Math.max(0, width);
+	minHeight = Math.max(0, height);
+	layout(false);
+}
+/**
+ * Specify the minimum width at which the ScrolledComposite will begin scrolling the
+ * content with the horizontal scroll bar.  This value is only relevant if  
+ * setExpandHorizontal(true) has been set.
+ * 
+ * @param width the minimum width or 0 for default width
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setMinWidth(int width) {
+	setMinSize(width, minHeight);
+}
+
+/**
+ * Configure the receiver to automatically scroll to a focused child control
+ * to make it visible.
+ * 
+ * If show is <code>false</code>, show a focused control is off.  
+ * By default, show a focused control is off.
+ * 
+ * @param show <code>true</code> to show a focused control.
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.4
+ */
+public void setShowFocusedControl(boolean show) {
+	checkWidget();
+	if (showFocusedControl == show) return;
+	Display display = getDisplay();
+	display.removeFilter(SWT.FocusIn, filter);
+	showFocusedControl = show;
+	if (!showFocusedControl) return;
+	display.addFilter(SWT.FocusIn, filter);
+	Control control = display.getFocusControl();
+	if (contains(control)) showControl(control);
+}
+
+/**
+ * Scrolls the content of the receiver so that the control is visible.
+ *
+ * @param control the control to be shown
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the control is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the control has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 3.4
+ */
+public void showControl(Control control) {
+	checkWidget ();
+	if (control == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	if (control.isDisposed ()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	if (!contains(control)) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	
+	Rectangle itemRect = getDisplay().map(control.getParent(), this, control.getBounds());
+	Rectangle area = getClientArea();
+	Point origin = getOrigin();
+	if (itemRect.x < 0) origin.x = Math.max(0, origin.x + itemRect.x);
+	if (itemRect.y < 0) origin.y = Math.max(0, origin.y + itemRect.y);
+	if (area.width < itemRect.x + itemRect.width) origin.x = Math.max(0, origin.x + itemRect.x + itemRect.width - area.width);
+	if (area.height < itemRect.y + itemRect.height) origin.y = Math.max(0, origin.y + itemRect.y + itemRect.height - area.height);
+	setOrigin(origin);
+}
+
+void vScroll() {
+	if (content == null) return;
+	Point location = content.getLocation ();
+	ScrollBar vBar = getVerticalBar ();
+	int vSelection = vBar.getSelection ();
+	content.setLocation (location.x, -vSelection);
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/custom/ScrolledCompositeLayout.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/custom/ScrolledCompositeLayout.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/custom/ScrolledCompositeLayout.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,112 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.custom;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+
+/**
+ * This class provides the layout for ScrolledComposite
+ * 
+ * @see ScrolledComposite
+ */
+class ScrolledCompositeLayout extends Layout {
+	
+	boolean inLayout = false;
+	static final int DEFAULT_WIDTH	= 64;
+	static final int DEFAULT_HEIGHT	= 64;
+	
+protected Point computeSize(Composite composite, int wHint, int hHint, boolean flushCache) {
+	ScrolledComposite sc = (ScrolledComposite)composite;
+	Point size = new Point(DEFAULT_WIDTH, DEFAULT_HEIGHT);
+	if (sc.content != null) {
+		Point preferredSize = sc.content.computeSize(wHint, hHint, flushCache);
+		Point currentSize = sc.content.getSize();
+		size.x = sc.getExpandHorizontal() ? preferredSize.x : currentSize.x;
+		size.y = sc.getExpandVertical() ? preferredSize.y : currentSize.y;
+	}
+	size.x = Math.max(size.x, sc.minWidth);
+	size.y = Math.max(size.y, sc.minHeight);
+	if (wHint != SWT.DEFAULT) size.x = wHint;
+	if (hHint != SWT.DEFAULT) size.y = hHint;
+	return size;
+}
+
+protected boolean flushCache(Control control) {
+	return true;
+}
+
+protected void layout(Composite composite, boolean flushCache) {
+	if (inLayout) return;
+	ScrolledComposite sc = (ScrolledComposite)composite;
+	if (sc.content == null) return;
+	ScrollBar hBar = sc.getHorizontalBar();
+	ScrollBar vBar = sc.getVerticalBar();
+	if (hBar != null) {
+		if (hBar.getSize().y >= sc.getSize().y) {
+			return;
+		}
+	}
+	if (vBar != null) {
+		if (vBar.getSize().x >= sc.getSize().x) {
+			return;
+		}
+	}
+	inLayout = true;
+	Rectangle contentRect = sc.content.getBounds();
+	if (!sc.alwaysShowScroll) {
+		boolean hVisible = sc.needHScroll(contentRect, false);
+		boolean vVisible = sc.needVScroll(contentRect, hVisible);
+		if (!hVisible && vVisible) hVisible = sc.needHScroll(contentRect, vVisible);
+		if (hBar != null) hBar.setVisible(hVisible);
+		if (vBar != null) vBar.setVisible(vVisible);
+	}
+	Rectangle hostRect = sc.getClientArea();
+	if (sc.expandHorizontal) {
+		contentRect.width = Math.max(sc.minWidth, hostRect.width);	
+	}
+	if (sc.expandVertical) {
+		contentRect.height = Math.max(sc.minHeight, hostRect.height);
+	}
+
+	if (hBar != null) {
+		hBar.setMaximum (contentRect.width);
+		hBar.setThumb (Math.min (contentRect.width, hostRect.width));
+		int hPage = contentRect.width - hostRect.width;
+		int hSelection = hBar.getSelection ();
+		if (hSelection >= hPage) {
+			if (hPage <= 0) {
+				hSelection = 0;
+				hBar.setSelection(0);
+			}
+			contentRect.x = -hSelection;
+		}
+	}
+
+	if (vBar != null) {
+		vBar.setMaximum (contentRect.height);
+		vBar.setThumb (Math.min (contentRect.height, hostRect.height));
+		int vPage = contentRect.height - hostRect.height;
+		int vSelection = vBar.getSelection ();
+		if (vSelection >= vPage) {
+			if (vPage <= 0) {
+				vSelection = 0;
+				vBar.setSelection(0);
+			}
+			contentRect.y = -vSelection;
+		}
+	}
+	
+	sc.content.setBounds (contentRect);
+	inLayout = false;
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/custom/StackLayout.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/custom/StackLayout.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/custom/StackLayout.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,148 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.custom;
+
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+
+/**
+ * This Layout stacks all the controls one on top of the other and resizes all controls
+ * to have the same size and location.
+ * The control specified in topControl is visible and all other controls are not visible.
+ * Users must set the topControl value to flip between the visible items and then call 
+ * layout() on the composite which has the StackLayout.
+ * 
+ * <p> Here is an example which places ten buttons in a stack layout and 
+ * flips between them:
+ * 
+ * <pre><code>
+ * 	public static void main(String[] args) {
+ * 		Display display = new Display();
+ * 		Shell shell = new Shell(display);
+ * 		shell.setLayout(new GridLayout());
+ * 	
+ * 		final Composite parent = new Composite(shell, SWT.NONE);
+ * 		parent.setLayoutData(new GridData(GridData.FILL_BOTH));
+ * 		final StackLayout layout = new StackLayout();
+ * 		parent.setLayout(layout);
+ * 		final Button[] bArray = new Button[10];
+ * 		for (int i = 0; i &lt; 10; i++) {
+ * 			bArray[i] = new Button(parent, SWT.PUSH);
+ * 			bArray[i].setText("Button "+i);
+ * 		}
+ * 		layout.topControl = bArray[0];
+ * 	
+ * 		Button b = new Button(shell, SWT.PUSH);
+ * 		b.setText("Show Next Button");
+ * 		final int[] index = new int[1];
+ * 		b.addListener(SWT.Selection, new Listener(){
+ * 			public void handleEvent(Event e) {
+ * 				index[0] = (index[0] + 1) % 10;
+ * 				layout.topControl = bArray[index[0]];
+ * 				parent.layout();
+ * 			}
+ * 		});
+ * 	
+ * 		shell.open();
+ * 		while (shell != null && !shell.isDisposed()) {
+ * 			if (!display.readAndDispatch())
+ * 				display.sleep(); 
+ * 		} 	
+ * 	}
+ * </code></pre>
+ *
+ * @see <a href="http://www.eclipse.org/swt/snippets/#stacklayout">StackLayout snippets</a>
+ * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: LayoutExample</a>
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+
+public class StackLayout extends Layout {
+	
+ 	/**
+	 * marginWidth specifies the number of pixels of horizontal margin
+	 * that will be placed along the left and right edges of the layout.
+	 *
+	 * The default value is 0.
+	 */
+ 	public int marginWidth = 0;
+	/**
+	 * marginHeight specifies the number of pixels of vertical margin
+	 * that will be placed along the top and bottom edges of the layout.
+	 *
+	 * The default value is 0.
+	 */
+	public int marginHeight = 0;
+
+ 	/**
+ 	 * topControl the Control that is displayed at the top of the stack.
+ 	 * All other controls that are children of the parent composite will not be visible.
+ 	 */
+ 	public Control topControl;
+
+protected Point computeSize(Composite composite, int wHint, int hHint, boolean flushCache) {
+	Control children[] = composite.getChildren();
+	int maxWidth = 0;
+	int maxHeight = 0;
+	for (int i = 0; i < children.length; i++) {
+		Point size = children[i].computeSize(wHint, hHint, flushCache);
+		maxWidth = Math.max(size.x, maxWidth);
+		maxHeight = Math.max(size.y, maxHeight);
+	}
+	int width = maxWidth + 2 * marginWidth;
+	int height = maxHeight + 2 * marginHeight;
+	if (wHint != SWT.DEFAULT) width = wHint;
+	if (hHint != SWT.DEFAULT) height = hHint;
+	return new Point(width, height);
+}
+
+protected boolean flushCache(Control control) {
+	return true;
+}
+
+protected void layout(Composite composite, boolean flushCache) {
+	Control children[] = composite.getChildren();
+	Rectangle rect = composite.getClientArea();
+	rect.x += marginWidth;
+	rect.y += marginHeight;
+	rect.width -= 2 * marginWidth;
+	rect.height -= 2 * marginHeight;
+	for (int i = 0; i < children.length; i++) {
+		children[i].setBounds(rect);
+		children[i].setVisible(children[i] == topControl);
+			
+	}
+}
+
+String getName () {
+	String string = getClass ().getName ();
+	int index = string.lastIndexOf ('.');
+	if (index == -1) return string;
+	return string.substring (index + 1, string.length ());
+}
+
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the layout
+ */
+public String toString () {
+ 	String string = getName ()+" {";
+ 	if (marginWidth != 0) string += "marginWidth="+marginWidth+" ";
+ 	if (marginHeight != 0) string += "marginHeight="+marginHeight+" ";
+ 	if (topControl != null) string += "topControl="+topControl+" ";
+ 	string = string.trim();
+ 	string += "}";
+ 	return string;
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/custom/StyleRange.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/custom/StyleRange.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/custom/StyleRange.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,213 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.custom;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.CloneableCompatibility;
+
+/**
+ * <code>StyleRange</code> defines a set of styles for a specified
+ * range of text.
+ * <p>
+ * The hashCode() method in this class uses the values of the public
+ * fields to compute the hash value. When storing instances of the
+ * class in hashed collections, do not modify these fields after the
+ * object has been inserted.
+ * </p>
+ *
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public class StyleRange extends TextStyle implements CloneableCompatibility {
+	
+	/**
+	 * the start offset of the range, zero-based from the document start
+	 */
+	public int start;
+	
+	/**
+	 * the length of the range
+	 */
+	public int length;
+
+	/**
+	 * the font style of the range. It may be a combination of
+	 * SWT.NORMAL, SWT.ITALIC or SWT.BOLD
+	 * 
+	 * Note: the font style is not used if the <code>font</code> attribute
+	 * is set
+	 */
+	public int fontStyle = SWT.NORMAL;
+	
+/**
+ * Create a new style range with no styles
+ * 
+ * @since 3.2
+ */
+public StyleRange() {
+}
+
+/** 
+ * Create a new style range from an existing text style.
+ *
+ * @param style the text style to copy
+ *
+ * @since 3.4
+ */
+public StyleRange(TextStyle style) {
+	super(style);
+}
+
+/** 
+ * Create a new style range.
+ *
+ * @param start start offset of the style
+ * @param length length of the style 
+ * @param foreground foreground color of the style, null if none 
+ * @param background background color of the style, null if none
+ */
+public StyleRange(int start, int length, Color foreground, Color background) {
+	super(null, foreground, background);
+	this.start = start;
+	this.length = length;
+}
+
+/** 
+ * Create a new style range.
+ *
+ * @param start start offset of the style
+ * @param length length of the style 
+ * @param foreground foreground color of the style, null if none 
+ * @param background background color of the style, null if none
+ * @param fontStyle font style of the style, may be SWT.NORMAL, SWT.ITALIC or SWT.BOLD
+ */
+public StyleRange(int start, int length, Color foreground, Color background, int fontStyle) {
+	this(start, length, foreground, background);
+	this.fontStyle = fontStyle;
+}
+
+/**
+ * Compares the argument to the receiver, and returns true
+ * if they represent the <em>same</em> object using a class
+ * specific comparison.
+ *
+ * @param object the object to compare with this object
+ * @return <code>true</code> if the object is the same as this object and <code>false</code> otherwise
+ *
+ * @see #hashCode()
+ */
+public boolean equals(Object object) {
+	if (object == this) return true;
+	if (object instanceof StyleRange) {
+		StyleRange style = (StyleRange)object;
+		if (start != style.start) return false;
+		if (length != style.length) return false;
+		return similarTo(style);
+	}
+	return false;
+}
+
+/**
+ * Returns an integer hash code for the receiver. Any two 
+ * objects that return <code>true</code> when passed to 
+ * <code>equals</code> must return the same value for this
+ * method.
+ *
+ * @return the receiver's hash
+ *
+ * @see #equals(Object)
+ */
+public int hashCode() {
+	return super.hashCode() ^ fontStyle;
+}
+boolean isVariableHeight() {
+	return font != null || metrics != null || rise != 0;
+}
+/**
+ * Returns whether or not the receiver is unstyled (i.e., does not have any 
+ * style attributes specified).
+ *
+ * @return true if the receiver is unstyled, false otherwise.
+ */
+public boolean isUnstyled() {
+	if (font != null) return false;
+	if (rise != 0) return false;
+	if (metrics != null) return false;
+	if (foreground != null) return false;
+	if (background != null) return false;
+	if (fontStyle != SWT.NORMAL) return false;
+	if (underline) return false;
+	if (strikeout) return false;
+	if (borderStyle != SWT.NONE) return false;
+	return true;
+}
+
+/**
+ * Compares the specified object to this StyleRange and answer if the two 
+ * are similar. The object must be an instance of StyleRange and have the
+ * same field values for except for start and length.
+ *
+ * @param style the object to compare with this object
+ * @return true if the objects are similar, false otherwise
+ */
+public boolean similarTo(StyleRange style) {
+	if (!super.equals(style)) return false;
+	if (fontStyle != style.fontStyle) return false;
+	return true;
+}
+
+/**
+ * Returns a new StyleRange with the same values as this StyleRange.
+ *
+ * @return a shallow copy of this StyleRange
+ */	
+public Object clone() {
+	try {
+		return super.clone();
+	} catch (CloneNotSupportedException e) {
+		return null;
+	}
+}
+
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the StyleRange
+ */
+public String toString() {
+	StringBuffer buffer = new StringBuffer();
+	buffer.append("StyleRange {");
+	buffer.append(start);
+	buffer.append(", ");
+	buffer.append(length);
+	buffer.append(", fontStyle=");
+	switch (fontStyle) {
+		case SWT.BOLD:
+			buffer.append("bold");
+			break;
+		case SWT.ITALIC:
+			buffer.append("italic");
+			break;
+		case SWT.BOLD | SWT.ITALIC:
+			buffer.append("bold-italic");
+			break;
+		default:
+			buffer.append("normal");
+	}
+	String str = super.toString();
+	int index = str.indexOf('{');
+	str = str.substring(index + 1);
+	if (str.length() > 1) buffer.append(", ");
+	buffer.append(str);
+	return buffer.toString();
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/custom/StyledText.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/custom/StyledText.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/custom/StyledText.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,8330 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.custom;
+
+
+import java.util.*;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.accessibility.*;
+import org.eclipse.swt.dnd.*;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.printing.*;
+import org.eclipse.swt.widgets.*;
+
+/**
+ * A StyledText is an editable user interface object that displays lines 
+ * of text.  The following style attributes can be defined for the text: 
+ * <ul>
+ * <li>foreground color 
+ * <li>background color
+ * <li>font style (bold, italic, bold-italic, regular)
+ * <li>underline
+ * <li>strikeout
+ * </ul>
+ * <p>
+ * In addition to text style attributes, the background color of a line may 
+ * be specified.
+ * </p><p>
+ * There are two ways to use this widget when specifying text style information.  
+ * You may use the API that is defined for StyledText or you may define your own 
+ * LineStyleListener.  If you define your own listener, you will be responsible 
+ * for maintaining the text style information for the widget.  IMPORTANT: You may 
+ * not define your own listener and use the StyledText API.  The following
+ * StyledText API is not supported if you have defined a LineStyleListener:
+ * <ul>
+ * <li>getStyleRangeAtOffset(int)
+ * <li>getStyleRanges()
+ * <li>replaceStyleRanges(int,int,StyleRange[])
+ * <li>setStyleRange(StyleRange)
+ * <li>setStyleRanges(StyleRange[])
+ * </ul>
+ * </p><p>
+ * There are two ways to use this widget when specifying line background colors.
+ * You may use the API that is defined for StyledText or you may define your own 
+ * LineBackgroundListener.  If you define your own listener, you will be responsible 
+ * for maintaining the line background color information for the widget.  
+ * IMPORTANT: You may not define your own listener and use the StyledText API.  
+ * The following StyledText API is not supported if you have defined a 
+ * LineBackgroundListener:
+ * <ul>
+ * <li>getLineBackground(int)
+ * <li>setLineBackground(int,int,Color)
+ * </ul>
+ * </p><p>
+ * The content implementation for this widget may also be user-defined.  To do so,
+ * you must implement the StyledTextContent interface and use the StyledText API
+ * setContent(StyledTextContent) to initialize the widget. 
+ * </p><p>
+ * <dl>
+ * <dt><b>Styles:</b><dd>FULL_SELECTION, MULTI, READ_ONLY, SINGLE, WRAP
+ * <dt><b>Events:</b><dd>ExtendedModify, LineGetBackground, LineGetSegments, LineGetStyle, Modify, Selection, Verify, VerifyKey
+ * </dl>
+ * </p><p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ *
+ * @see <a href="http://www.eclipse.org/swt/snippets/#styledtext">StyledText snippets</a>
+ * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Examples: CustomControlExample, TextEditor</a>
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public class StyledText extends Canvas {
+	static final char TAB = '\t';
+	static final String PlatformLineDelimiter = System.getProperty("line.separator");
+	static final int BIDI_CARET_WIDTH = 3;
+	static final int DEFAULT_WIDTH	= 64;
+	static final int DEFAULT_HEIGHT = 64;
+	static final int V_SCROLL_RATE = 50;
+	static final int H_SCROLL_RATE = 10;
+	
+	static final int ExtendedModify = 3000;
+	static final int LineGetBackground = 3001;
+	static final int LineGetStyle = 3002;
+	static final int TextChanging = 3003;
+	static final int TextSet = 3004;
+	static final int VerifyKey = 3005;
+	static final int TextChanged = 3006;
+	static final int LineGetSegments = 3007;
+	static final int PaintObject = 3008;
+	static final int WordNext = 3009;
+	static final int WordPrevious = 3010;
+	
+	static final int PREVIOUS_OFFSET_TRAILING = 0;
+	static final int OFFSET_LEADING = 1;
+	
+	Color selectionBackground;	// selection background color
+	Color selectionForeground;	// selection foreground color
+	StyledTextContent content;			// native content (default or user specified)
+	StyledTextRenderer renderer;
+	Listener listener;
+	TextChangeListener textChangeListener;	// listener for TextChanging, TextChanged and TextSet events from StyledTextContent
+	int verticalScrollOffset = 0;		// pixel based
+	int horizontalScrollOffset = 0;		// pixel based
+	int topIndex = 0;					// top visible line
+	int topIndexY;
+	int clientAreaHeight = 0;			// the client area height. Needed to calculate content width for new visible lines during Resize callback
+	int clientAreaWidth = 0;			// the client area width. Needed during Resize callback to determine if line wrap needs to be recalculated
+	int tabLength = 4;					// number of characters in a tab
+	int leftMargin;
+	int topMargin;
+	int rightMargin;
+	int bottomMargin;
+	int columnX;						// keep track of the horizontal caret position when changing lines/pages. Fixes bug 5935
+	int caretOffset = 0;
+	int caretAlignment;
+	Point selection = new Point(0, 0);	// x and y are start and end caret offsets of selection
+	Point clipboardSelection;           // x and y are start and end caret offsets of previous selection
+	int selectionAnchor;				// position of selection anchor. 0 based offset from beginning of text
+	Point doubleClickSelection;			// selection after last mouse double click
+	boolean editable = true;
+	boolean wordWrap = false;
+	boolean doubleClickEnabled = true;	// see getDoubleClickEnabled 
+	boolean overwrite = false;			// insert/overwrite edit mode
+	int textLimit = -1;					// limits the number of characters the user can type in the widget. Unlimited by default.
+	Hashtable keyActionMap = new Hashtable();
+	Color background = null;			// workaround for bug 4791
+	Color foreground = null;			//
+	Clipboard clipboard;
+	int clickCount;
+	int autoScrollDirection = SWT.NULL;	// the direction of autoscrolling (up, down, right, left)
+	int autoScrollDistance = 0;
+	int lastTextChangeStart;			// cache data of the 
+	int lastTextChangeNewLineCount;		// last text changing 
+	int lastTextChangeNewCharCount;		// event for use in the 
+	int lastTextChangeReplaceLineCount;	// text changed handler
+	int lastTextChangeReplaceCharCount;
+	int lastLineBottom;					// the bottom pixel of the last line been replaced
+	boolean isMirrored;
+	boolean bidiColoring = false;		// apply the BIDI algorithm on text segments of the same color
+	Image leftCaretBitmap = null;
+	Image rightCaretBitmap = null;
+	int caretDirection = SWT.NULL;
+	int caretWidth = 0;
+	Caret defaultCaret = null;
+	boolean updateCaretDirection = true;
+	boolean fixedLineHeight;
+	boolean dragDetect = true;
+	IME ime;
+	
+	int alignment;
+	boolean justify;
+	int indent;
+	int lineSpacing;
+
+	final static boolean IS_CARBON, IS_GTK, IS_MOTIF;
+	static {
+		String platform = SWT.getPlatform();
+		IS_CARBON = "carbon".equals(platform);
+		IS_GTK = "gtk".equals(platform);
+		IS_MOTIF = "motif".equals(platform);
+	}
+
+	/**
+	 * The Printing class implements printing of a range of text.
+	 * An instance of <code>Printing</code> is returned in the 
+	 * StyledText#print(Printer) API. The run() method may be 
+	 * invoked from any thread.
+	 */
+	static class Printing implements Runnable {
+		final static int LEFT = 0;						// left aligned header/footer segment
+		final static int CENTER = 1;					// centered header/footer segment
+		final static int RIGHT = 2;						// right aligned header/footer segment
+
+		Printer printer;
+		StyledTextRenderer printerRenderer;
+		StyledTextPrintOptions printOptions;
+		Rectangle clientArea;
+		FontData fontData;
+		Font printerFont;
+		Hashtable resources;
+		int tabLength;
+		GC gc;											// printer GC
+		int pageWidth;									// width of a printer page in pixels
+		int startPage;									// first page to print
+		int endPage;									// last page to print
+		int startLine;									// first (wrapped) line to print
+		int endLine;									// last (wrapped) line to print
+		boolean singleLine;								// widget single line mode
+		Point selection = null;					// selected text
+		boolean mirrored;						// indicates the printing gc should be mirrored
+		int lineSpacing;
+		int printMargin;
+
+	/**
+	 * Creates an instance of <code>Printing</code>.
+	 * Copies the widget content and rendering data that needs 
+	 * to be requested from listeners.
+	 * </p>
+	 * @param parent StyledText widget to print.
+	 * @param printer printer device to print on.
+	 * @param printOptions print options
+	 */		
+	Printing(StyledText styledText, Printer printer, StyledTextPrintOptions printOptions) {
+		this.printer = printer;
+		this.printOptions = printOptions;
+		this.mirrored = (styledText.getStyle() & SWT.MIRRORED) != 0;
+		singleLine = styledText.isSingleLine();
+		startPage = 1;
+		endPage = Integer.MAX_VALUE;
+		PrinterData data = printer.getPrinterData();
+		if (data.scope == PrinterData.PAGE_RANGE) {
+			startPage = data.startPage;
+			endPage = data.endPage;
+			if (endPage < startPage) {
+				int temp = endPage;
+				endPage = startPage;
+				startPage = temp;
+			}
+		} else if (data.scope == PrinterData.SELECTION) {
+			selection = styledText.getSelectionRange();
+		}
+		printerRenderer = new StyledTextRenderer(printer, null);
+		printerRenderer.setContent(copyContent(styledText.getContent()));
+		cacheLineData(styledText);
+	}
+	/**
+	 * Caches all line data that needs to be requested from a listener.
+	 * </p>
+	 * @param printerContent <code>StyledTextContent</code> to request 
+	 * 	line data for.
+	 */
+	void cacheLineData(StyledText styledText) {
+		StyledTextRenderer renderer = styledText.renderer;
+		renderer.copyInto(printerRenderer);
+		fontData = styledText.getFont().getFontData()[0];
+		tabLength = styledText.tabLength;
+		int lineCount = printerRenderer.lineCount;
+		if (styledText.isListening(LineGetBackground) || (styledText.isBidi() && styledText.isListening(LineGetSegments)) || styledText.isListening(LineGetStyle)) {
+			StyledTextContent content = printerRenderer.content;
+			for (int i = 0; i < lineCount; i++) {
+				String line = content.getLine(i);
+				int lineOffset = content.getOffsetAtLine(i);
+				StyledTextEvent event = styledText.getLineBackgroundData(lineOffset, line);
+				if (event != null && event.lineBackground != null) {
+					printerRenderer.setLineBackground(i, 1, event.lineBackground);
+				}
+				if (styledText.isBidi()) {
+					int[] segments = styledText.getBidiSegments(lineOffset, line);
+					printerRenderer.setLineSegments(i, 1, segments);
+				}			
+				event = styledText.getLineStyleData(lineOffset, line);
+				if (event != null) {
+					printerRenderer.setLineIndent(i, 1, event.indent);
+					printerRenderer.setLineAlignment(i, 1, event.alignment);
+					printerRenderer.setLineJustify(i, 1, event.justify);
+					printerRenderer.setLineBullet(i, 1, event.bullet);
+					StyleRange[] styles = event.styles;
+					if (styles != null && styles.length > 0) {
+						printerRenderer.setStyleRanges(event.ranges, styles);
+					}
+				}
+			}
+		}
+		Point screenDPI = styledText.getDisplay().getDPI();
+		Point printerDPI = printer.getDPI();
+		resources = new Hashtable ();
+		for (int i = 0; i < lineCount; i++) {
+			Color color = printerRenderer.getLineBackground(i, null);
+			if (color != null) {
+				if (printOptions.printLineBackground) {
+					Color printerColor = (Color)resources.get(color);
+					if (printerColor == null) {
+						printerColor = new Color (printer, color.getRGB());
+						resources.put(color, printerColor); 
+					}
+					printerRenderer.setLineBackground(i, 1, printerColor);
+				} else {
+					printerRenderer.setLineBackground(i, 1, null);
+				}
+			}
+			int indent = printerRenderer.getLineIndent(i, 0);
+			if (indent != 0) {
+				printerRenderer.setLineIndent(i, 1, indent * printerDPI.x / screenDPI.x);
+			}
+		}
+		StyleRange[] styles = printerRenderer.styles;
+		for (int i = 0; i < printerRenderer.styleCount; i++) {
+			StyleRange style = styles[i];
+			Font font = style.font;
+			if (style.font != null) {
+				Font printerFont = (Font)resources.get(font);
+				if (printerFont == null) {
+					printerFont = new Font (printer, font.getFontData());
+					resources.put(font, printerFont);					
+				}
+				style.font = printerFont;
+			}
+			Color color = style.foreground;
+			if (color != null) {
+				Color printerColor = (Color)resources.get(color);
+				if (printOptions.printTextForeground) {
+					if (printerColor == null) {
+						printerColor = new Color (printer, color.getRGB());
+						resources.put(color, printerColor); 
+					}
+					style.foreground = printerColor;
+				} else {
+					style.foreground = null;
+				}
+			}
+			color = style.background;
+			if (color != null) {
+				Color printerColor = (Color)resources.get(color);
+				if (printOptions.printTextBackground) {
+					if (printerColor == null) {
+						printerColor = new Color (printer, color.getRGB());
+						resources.put(color, printerColor); 
+					}
+					style.background = printerColor;
+				} else {
+					style.background = null;
+				}
+			}
+			if (!printOptions.printTextFontStyle) {
+				style.fontStyle = SWT.NORMAL;
+			}
+			style.rise = style.rise * printerDPI.y / screenDPI.y;
+			GlyphMetrics metrics = style.metrics;
+			if (metrics != null) {
+				metrics.ascent = metrics.ascent * printerDPI.y / screenDPI.y;
+				metrics.descent = metrics.descent * printerDPI.y / screenDPI.y;
+				metrics.width = metrics.width * printerDPI.x / screenDPI.x;
+			}
+		}
+		lineSpacing = styledText.lineSpacing * printerDPI.y / screenDPI.y;
+		if (printOptions.printLineNumbers) {
+			printMargin = 3 * printerDPI.x / screenDPI.x;
+		}
+	}
+	/**
+	 * Copies the text of the specified <code>StyledTextContent</code>.
+	 * </p>
+	 * @param original the <code>StyledTextContent</code> to copy.
+	 */
+	StyledTextContent copyContent(StyledTextContent original) {
+		StyledTextContent printerContent = new DefaultContent();
+		int insertOffset = 0;
+		for (int i = 0; i < original.getLineCount(); i++) {
+			int insertEndOffset;
+			if (i < original.getLineCount() - 1) {
+				insertEndOffset = original.getOffsetAtLine(i + 1);
+			} else {
+				insertEndOffset = original.getCharCount();
+			}
+			printerContent.replaceTextRange(insertOffset, 0, original.getTextRange(insertOffset, insertEndOffset - insertOffset));
+			insertOffset = insertEndOffset;
+		}
+		return printerContent;
+	}
+	/**
+	 * Disposes of the resources and the <code>PrintRenderer</code>.
+	 */
+	void dispose() {
+		if (gc != null) {
+			gc.dispose();
+			gc = null;
+		}
+		if (resources != null) {
+			Enumeration enumeration = resources.elements();			
+			while (enumeration.hasMoreElements()) {
+				Resource resource = (Resource) enumeration.nextElement();
+				resource.dispose();
+			}
+			resources = null;
+		}
+		if (printerFont != null) {
+			printerFont.dispose();
+			printerFont = null;
+		}
+		if (printerRenderer != null) {
+			printerRenderer.dispose();
+			printerRenderer = null;
+		}
+	}
+	void init() {
+		Rectangle trim = printer.computeTrim(0, 0, 0, 0);
+		Point dpi = printer.getDPI();
+		
+		printerFont = new Font(printer, fontData.getName(), fontData.getHeight(), SWT.NORMAL);
+		clientArea = printer.getClientArea();
+		pageWidth = clientArea.width;
+		// one inch margin around text
+		clientArea.x = dpi.x + trim.x; 				
+		clientArea.y = dpi.y + trim.y;
+		clientArea.width -= (clientArea.x + trim.width);
+		clientArea.height -= (clientArea.y + trim.height); 
+
+		int style = mirrored ? SWT.RIGHT_TO_LEFT : SWT.LEFT_TO_RIGHT;
+		gc = new GC(printer, style);
+		gc.setFont(printerFont);
+		printerRenderer.setFont(printerFont, tabLength);
+		int lineHeight = printerRenderer.getLineHeight();
+		if (printOptions.header != null) {
+			clientArea.y += lineHeight * 2;
+			clientArea.height -= lineHeight * 2;
+		}
+		if (printOptions.footer != null) {
+			clientArea.height -= lineHeight * 2;
+		}
+		
+		// TODO not wrapped
+		StyledTextContent content = printerRenderer.content;
+		startLine = 0;
+		endLine = singleLine ? 0 : content.getLineCount() - 1;
+		PrinterData data = printer.getPrinterData();
+		if (data.scope == PrinterData.PAGE_RANGE) {
+			int pageSize = clientArea.height / lineHeight;//WRONG
+			startLine = (startPage - 1) * pageSize;
+		} else if (data.scope == PrinterData.SELECTION) {
+			startLine = content.getLineAtOffset(selection.x);
+			if (selection.y > 0) {
+				endLine = content.getLineAtOffset(selection.x + selection.y - 1);
+			} else {
+				endLine = startLine - 1;
+			}
+		}
+	}
+	/**
+	 * Prints the lines in the specified page range.
+	 */
+	void print() {
+		Color background = gc.getBackground();
+		Color foreground = gc.getForeground();
+		int paintY = clientArea.y;
+		int paintX = clientArea.x;
+		int width = clientArea.width;
+		int page = startPage;
+		int pageBottom = clientArea.y + clientArea.height;
+		int orientation =  gc.getStyle() & (SWT.RIGHT_TO_LEFT | SWT.LEFT_TO_RIGHT);
+		TextLayout printLayout = null;
+		if (printOptions.printLineNumbers || printOptions.header != null || printOptions.footer != null) {
+			printLayout = new TextLayout(printer);
+			printLayout.setFont(printerFont);
+		}
+		if (printOptions.printLineNumbers) {
+			int numberingWidth = 0;
+			int count = endLine - startLine + 1;
+			String[] lineLabels = printOptions.lineLabels;
+			if (lineLabels != null) {
+				for (int i = startLine; i < Math.min(count, lineLabels.length); i++) {
+					if (lineLabels[i] != null) {
+						printLayout.setText(lineLabels[i]);
+						int lineWidth = printLayout.getBounds().width;
+						numberingWidth = Math.max(numberingWidth, lineWidth);
+					}
+				}
+			} else {
+				StringBuffer buffer = new StringBuffer("0");
+				while ((count /= 10) > 0) buffer.append("0");
+				printLayout.setText(buffer.toString());
+				numberingWidth = printLayout.getBounds().width;
+			}
+			numberingWidth += printMargin;
+			if (numberingWidth > width) numberingWidth = width;
+			paintX += numberingWidth;
+			width -= numberingWidth;
+		}
+		for (int i = startLine; i <= endLine && page <= endPage; i++) {
+			if (paintY == clientArea.y) {
+				printer.startPage();
+				printDecoration(page, true, printLayout);
+			}
+			TextLayout layout = printerRenderer.getTextLayout(i, orientation, width, lineSpacing);
+			Color lineBackground = printerRenderer.getLineBackground(i, background);
+			int paragraphBottom = paintY + layout.getBounds().height; 
+			if (paragraphBottom <= pageBottom) {
+				//normal case, the whole paragraph fits in the current page
+				printLine(paintX, paintY, gc, foreground, lineBackground, layout, printLayout, i);
+				paintY = paragraphBottom;
+			} else {
+				int lineCount = layout.getLineCount();
+				while (paragraphBottom > pageBottom && lineCount > 0) {
+					lineCount--;
+					paragraphBottom -= layout.getLineBounds(lineCount).height + layout.getSpacing();
+				}
+				if (lineCount == 0) {
+					//the whole paragraph goes to the next page
+					printDecoration(page, false, printLayout);
+					printer.endPage();
+					page++;
+					if (page <= endPage) {
+						printer.startPage();
+						printDecoration(page, true, printLayout);
+						paintY = clientArea.y;
+						printLine(paintX, paintY, gc, foreground, lineBackground, layout, printLayout, i);
+						paintY += layout.getBounds().height;
+					}
+				} else {
+					//draw paragraph top in the current page and paragraph bottom in the next
+					int height = paragraphBottom - paintY;
+					gc.setClipping(clientArea.x, paintY, clientArea.width, height);
+					printLine(paintX, paintY, gc, foreground, lineBackground, layout, printLayout, i);
+					gc.setClipping((Rectangle)null);
+					printDecoration(page, false, printLayout);
+					printer.endPage();					
+					page++;
+					if (page <= endPage) {
+						printer.startPage();
+						printDecoration(page, true, printLayout);
+						paintY = clientArea.y - height;
+						int layoutHeight = layout.getBounds().height;
+						gc.setClipping(clientArea.x, clientArea.y, clientArea.width, layoutHeight - height);
+						printLine(paintX, paintY, gc, foreground, lineBackground, layout, printLayout, i);
+						gc.setClipping((Rectangle)null);
+						paintY += layoutHeight;
+					}
+				}
+			}
+			printerRenderer.disposeTextLayout(layout);
+		}
+		if (page <= endPage && paintY > clientArea.y) {
+			// close partial page
+			printDecoration(page, false, printLayout);
+			printer.endPage();
+		}
+		if (printLayout != null) printLayout.dispose();
+	}
+	/**
+	 * Print header or footer decorations.
+	 * 
+	 * @param page page number to print, if specified in the StyledTextPrintOptions header or footer.
+	 * @param header true = print the header, false = print the footer
+	 */
+	void printDecoration(int page, boolean header, TextLayout layout) {
+		String text = header ? printOptions.header : printOptions.footer;
+		if (text == null) return;
+		int lastSegmentIndex = 0;
+		for (int i = 0; i < 3; i++) {
+			int segmentIndex = text.indexOf(StyledTextPrintOptions.SEPARATOR, lastSegmentIndex);
+			String segment;
+			if (segmentIndex == -1) {
+				segment = text.substring(lastSegmentIndex);
+				printDecorationSegment(segment, i, page, header, layout);
+				break;
+			} else {
+				segment = text.substring(lastSegmentIndex, segmentIndex);
+				printDecorationSegment(segment, i, page, header, layout);
+				lastSegmentIndex = segmentIndex + StyledTextPrintOptions.SEPARATOR.length();
+			}
+		}
+	}
+	/**
+	 * Print one segment of a header or footer decoration.
+	 * Headers and footers have three different segments.
+	 * One each for left aligned, centered, and right aligned text.
+	 * 
+	 * @param segment decoration segment to print
+	 * @param alignment alignment of the segment. 0=left, 1=center, 2=right 
+	 * @param page page number to print, if specified in the decoration segment.
+	 * @param header true = print the header, false = print the footer
+	 */
+	void printDecorationSegment(String segment, int alignment, int page, boolean header, TextLayout layout) {		
+		int pageIndex = segment.indexOf(StyledTextPrintOptions.PAGE_TAG);
+		if (pageIndex != -1) {
+			int pageTagLength = StyledTextPrintOptions.PAGE_TAG.length();
+			StringBuffer buffer = new StringBuffer(segment.substring (0, pageIndex));
+			buffer.append (page);
+			buffer.append (segment.substring(pageIndex + pageTagLength));
+			segment = buffer.toString();
+		}
+		if (segment.length() > 0) {
+			layout.setText(segment);
+			int segmentWidth = layout.getBounds().width;
+			int segmentHeight = printerRenderer.getLineHeight();
+			int drawX = 0, drawY;
+			if (alignment == LEFT) {
+				drawX = clientArea.x;
+			} else if (alignment == CENTER) {
+				drawX = (pageWidth - segmentWidth) / 2;
+			} else if (alignment == RIGHT) {
+				drawX = clientArea.x + clientArea.width - segmentWidth;
+			}
+			if (header) {
+				drawY = clientArea.y - segmentHeight * 2;
+			} else {
+				drawY = clientArea.y + clientArea.height + segmentHeight;
+			}
+			layout.draw(gc, drawX, drawY);
+		}
+	}
+	void printLine(int x, int y, GC gc, Color foreground, Color background, TextLayout layout, TextLayout printLayout, int index) {
+		if (background != null) {
+			Rectangle rect = layout.getBounds();
+			gc.setBackground(background);
+			gc.fillRectangle(x, y, rect.width, rect.height);
+			
+//			int lineCount = layout.getLineCount();
+//			for (int i = 0; i < lineCount; i++) {
+//				Rectangle rect = layout.getLineBounds(i);
+//				rect.x += paintX;
+//				rect.y += paintY + layout.getSpacing();
+//				rect.width = width;//layout bounds
+//				gc.fillRectangle(rect);
+//			}
+		}
+		if (printOptions.printLineNumbers) {
+			FontMetrics metrics = layout.getLineMetrics(0);
+			printLayout.setAscent(metrics.getAscent() + metrics.getLeading());
+			printLayout.setDescent(metrics.getDescent());
+			String[] lineLabels = printOptions.lineLabels;
+			if (lineLabels != null) {
+				if (0 <= index && index < lineLabels.length && lineLabels[index] != null) {
+					printLayout.setText(lineLabels[index]);
+				} else {
+					printLayout.setText("");
+				}
+			} else {
+				printLayout.setText(String.valueOf(index));
+			}
+			int paintX = x - printMargin - printLayout.getBounds().width;
+			printLayout.draw(gc, paintX, y);
+			printLayout.setAscent(-1);
+			printLayout.setDescent(-1);
+		}
+		gc.setForeground(foreground);
+		layout.draw(gc, x, y);
+	}
+	/**
+	 * Starts a print job and prints the pages specified in the constructor.
+	 */
+	public void run() {
+		String jobName = printOptions.jobName;
+		if (jobName == null) {
+			jobName = "Printing";
+		}
+		if (printer.startJob(jobName)) {
+			init();
+			print();
+			dispose();
+			printer.endJob();
+		}
+	}	
+	}
+	/**
+	 * The <code>RTFWriter</code> class is used to write widget content as
+	 * rich text. The implementation complies with the RTF specification 
+	 * version 1.5.
+	 * <p>
+	 * toString() is guaranteed to return a valid RTF string only after 
+	 * close() has been called. 
+	 * </p><p>
+	 * Whole and partial lines and line breaks can be written. Lines will be
+	 * formatted using the styles queried from the LineStyleListener, if 
+	 * set, or those set directly in the widget. All styles are applied to
+	 * the RTF stream like they are rendered by the widget. In addition, the 
+	 * widget font name and size is used for the whole text.
+	 * </p>
+	 */
+	class RTFWriter extends TextWriter {
+		static final int DEFAULT_FOREGROUND = 0;
+		static final int DEFAULT_BACKGROUND = 1;
+		Vector colorTable, fontTable;
+		boolean WriteUnicode;
+		
+	/**
+	 * Creates a RTF writer that writes content starting at offset "start"
+	 * in the document.  <code>start</code> and <code>length</code>can be set to specify partial 
+	 * lines.
+	 *
+	 * @param start start offset of content to write, 0 based from 
+	 * 	beginning of document
+	 * @param length length of content to write
+	 */
+	public RTFWriter(int start, int length) {
+		super(start, length);
+		colorTable = new Vector();
+		fontTable = new Vector();
+		colorTable.addElement(getForeground());
+		colorTable.addElement(getBackground());
+		fontTable.addElement(getFont());
+		setUnicode();
+	}
+	/**
+	 * Closes the RTF writer. Once closed no more content can be written.
+	 * <b>NOTE:</b>  <code>toString()</code> does not return a valid RTF string until 
+	 * <code>close()</code> has been called.
+	 */
+	public void close() {
+		if (!isClosed()) {
+			writeHeader();
+			write("\n}}\0");
+			super.close();
+		}
+	}	
+	/**
+	 * Returns the index of the specified color in the RTF color table.
+	 *
+	 * @param color the color
+	 * @param defaultIndex return value if color is null
+	 * @return the index of the specified color in the RTF color table
+	 * 	or "defaultIndex" if "color" is null.
+	 */
+	int getColorIndex(Color color, int defaultIndex) {
+		if (color == null) return defaultIndex;
+		int index = colorTable.indexOf(color);
+		if (index == -1) {
+			index = colorTable.size();
+			colorTable.addElement(color);
+		}
+		return index;
+	}
+	/**
+	 * Returns the index of the specified color in the RTF color table.
+	 *
+	 * @param color the color
+	 * @param defaultIndex return value if color is null
+	 * @return the index of the specified color in the RTF color table
+	 * 	or "defaultIndex" if "color" is null.
+	 */
+	int getFontIndex(Font font) {
+		int index = fontTable.indexOf(font);
+		if (index == -1) {
+			index = fontTable.size();
+			fontTable.addElement(font);
+		}
+		return index;
+	}
+	/**
+	 * Determines if Unicode RTF should be written.
+	 * Don't write Unicode RTF on Windows 95/98/ME or NT.
+	 */
+	void setUnicode() {
+		final String Win95 = "windows 95";
+		final String Win98 = "windows 98";
+		final String WinME = "windows me";		
+		final String WinNT = "windows nt";
+		String osName = System.getProperty("os.name").toLowerCase();
+		String osVersion = System.getProperty("os.version");
+		int majorVersion = 0;
+		
+		if (osName.startsWith(WinNT) && osVersion != null) {
+			int majorIndex = osVersion.indexOf('.');
+			if (majorIndex != -1) {
+				osVersion = osVersion.substring(0, majorIndex);
+				try {
+					majorVersion = Integer.parseInt(osVersion);
+				} catch (NumberFormatException exception) {
+					// ignore exception. version number remains unknown.
+					// will write without Unicode
+				}
+			}
+		}
+		WriteUnicode =	!osName.startsWith(Win95) &&
+						!osName.startsWith(Win98) &&
+						!osName.startsWith(WinME) &&
+						(!osName.startsWith(WinNT) || majorVersion > 4);
+	}
+	/**
+	 * Appends the specified segment of "string" to the RTF data.
+	 * Copy from <code>start</code> up to, but excluding, <code>end</code>.
+	 *
+	 * @param string string to copy a segment from. Must not contain
+	 * 	line breaks. Line breaks should be written using writeLineDelimiter()
+	 * @param start start offset of segment. 0 based.
+	 * @param end end offset of segment
+	 */
+	void write(String string, int start, int end) {
+		for (int index = start; index < end; index++) {
+			char ch = string.charAt(index);
+			if (ch > 0xFF && WriteUnicode) {
+				// write the sub string from the last escaped character 
+				// to the current one. Fixes bug 21698.
+				if (index > start) {
+					write(string.substring(start, index));
+				}
+				write("\\u");
+				write(Integer.toString((short) ch));
+				write(' ');						// control word delimiter
+				start = index + 1;
+			} else if (ch == '}' || ch == '{' || ch == '\\') {
+				// write the sub string from the last escaped character 
+				// to the current one. Fixes bug 21698.
+				if (index > start) {
+					write(string.substring(start, index));
+				}
+				write('\\');
+				write(ch);
+				start = index + 1;
+			}
+		}
+		// write from the last escaped character to the end.
+		// Fixes bug 21698.
+		if (start < end) {
+			write(string.substring(start, end));
+		}
+	}
+	/**
+	 * Writes the RTF header including font table and color table.
+	 */
+	void writeHeader() {
+		StringBuffer header = new StringBuffer();
+		FontData fontData = getFont().getFontData()[0];
+		header.append("{\\rtf1\\ansi");
+		// specify code page, necessary for copy to work in bidi 
+		// systems that don't support Unicode RTF.
+		String cpg = System.getProperty("file.encoding").toLowerCase();
+		if (cpg.startsWith("cp") || cpg.startsWith("ms")) {
+			cpg = cpg.substring(2, cpg.length());
+			header.append("\\ansicpg");
+			header.append(cpg);
+		}
+		header.append("\\uc0\\deff0{\\fonttbl{\\f0\\fnil ");
+		header.append(fontData.getName());
+		header.append(";");
+		for (int i = 1; i < fontTable.size(); i++) {
+			header.append("\\f");
+			header.append(i);
+			header.append(" ");
+			FontData fd = ((Font)fontTable.elementAt(i)).getFontData()[0];
+			header.append(fd.getName());
+			header.append(";");			
+		}
+		header.append("}}\n{\\colortbl");
+		for (int i = 0; i < colorTable.size(); i++) {
+			Color color = (Color) colorTable.elementAt(i);
+			header.append("\\red");
+			header.append(color.getRed());
+			header.append("\\green");
+			header.append(color.getGreen());
+			header.append("\\blue");
+			header.append(color.getBlue());
+			header.append(";");
+		}
+		// some RTF readers ignore the deff0 font tag. Explicitly 
+		// set the font for the whole document to work around this.
+		header.append("}\n{\\f0\\fs");
+		// font size is specified in half points
+		header.append(fontData.getHeight() * 2);
+		header.append(" ");
+		write(header.toString(), 0);
+	}
+	/**
+	 * Appends the specified line text to the RTF data.  Lines will be formatted 
+	 * using the styles queried from the LineStyleListener, if set, or those set 
+	 * directly in the widget.
+	 *
+	 * @param line line text to write as RTF. Must not contain line breaks
+	 * 	Line breaks should be written using writeLineDelimiter()
+	 * @param lineOffset offset of the line. 0 based from the start of the 
+	 * 	widget document. Any text occurring before the start offset or after the 
+	 * 	end offset specified during object creation is ignored.
+	 * @exception SWTException <ul>
+	 *   <li>ERROR_IO when the writer is closed.</li>
+	 * </ul>
+	 */
+	public void writeLine(String line, int lineOffset) {
+		if (isClosed()) {
+			SWT.error(SWT.ERROR_IO);
+		}
+		int lineIndex = content.getLineAtOffset(lineOffset);
+		int lineAlignment, lineIndent;
+		boolean lineJustify;
+		int[] ranges;
+		StyleRange[] styles;
+		StyledTextEvent event = getLineStyleData(lineOffset, line);
+		if (event != null) {
+			lineAlignment = event.alignment;
+			lineIndent = event.indent;
+			lineJustify = event.justify;
+			ranges = event.ranges;
+			styles = event.styles;
+		} else {
+			lineAlignment = renderer.getLineAlignment(lineIndex, alignment);
+			lineIndent =  renderer.getLineIndent(lineIndex, indent);			
+			lineJustify = renderer.getLineJustify(lineIndex, justify);
+			ranges = renderer.getRanges(lineOffset, line.length());
+			styles = renderer.getStyleRanges(lineOffset, line.length(), false);
+		}
+		if (styles == null) styles = new StyleRange[0];		
+		Color lineBackground = renderer.getLineBackground(lineIndex, null);
+		event = getLineBackgroundData(lineOffset, line);
+		if (event != null && event.lineBackground != null) lineBackground = event.lineBackground;
+		writeStyledLine(line, lineOffset, ranges, styles, lineBackground, lineIndent, lineAlignment, lineJustify);
+	}
+	/**
+	 * Appends the specified line delimiter to the RTF data.
+	 *
+	 * @param lineDelimiter line delimiter to write as RTF.
+	 * @exception SWTException <ul>
+	 *   <li>ERROR_IO when the writer is closed.</li>
+	 * </ul>
+	 */
+	public void writeLineDelimiter(String lineDelimiter) {
+		if (isClosed()) {
+			SWT.error(SWT.ERROR_IO);
+		}
+		write(lineDelimiter, 0, lineDelimiter.length());
+		write("\\par ");
+	}
+	/**
+	 * Appends the specified line text to the RTF data.
+	 * <p>
+	 * Use the colors and font styles specified in "styles" and "lineBackground".
+	 * Formatting is written to reflect the text rendering by the text widget.
+	 * Style background colors take precedence over the line background color.
+	 * Background colors are written using the \highlight tag (vs. the \cb tag).
+	 * </p>
+	 *
+	 * @param line line text to write as RTF. Must not contain line breaks
+	 * 	Line breaks should be written using writeLineDelimiter()
+	 * @param lineOffset offset of the line. 0 based from the start of the 
+	 * 	widget document. Any text occurring before the start offset or after the 
+	 * 	end offset specified during object creation is ignored.
+	 * @param styles styles to use for formatting. Must not be null.
+	 * @param lineBackground line background color to use for formatting. 
+	 * 	May be null.
+	 */
+	void writeStyledLine(String line, int lineOffset, int ranges[], StyleRange[] styles, Color lineBackground, int indent, int alignment, boolean justify) {
+		int lineLength = line.length();
+		int startOffset = getStart();
+		int writeOffset = startOffset - lineOffset;
+		if (writeOffset >= lineLength) return;
+		int lineIndex = Math.max(0, writeOffset);
+			
+		write("\\fi");
+		write(indent);
+		switch (alignment) {
+			case SWT.LEFT: write("\\ql"); break;
+			case SWT.CENTER: write("\\qc"); break;
+			case SWT.RIGHT: write("\\qr"); break;
+		}
+		if (justify) write("\\qj");
+		write(" ");
+		
+		if (lineBackground != null) {
+			write("{\\highlight");
+			write(getColorIndex(lineBackground, DEFAULT_BACKGROUND));
+			write(" "); 
+		}
+		int endOffset = startOffset + super.getCharCount();
+		int lineEndOffset = Math.min(lineLength, endOffset - lineOffset);
+		for (int i = 0; i < styles.length; i++) {
+			StyleRange style = styles[i];
+			int start, end;
+			if (ranges != null) {
+				start = ranges[i << 1] - lineOffset;
+				end = start + ranges[(i << 1) + 1];
+			} else {
+				start = style.start - lineOffset;
+				end = start + style.length;
+			}
+			// skip over partial first line
+			if (end < writeOffset) {
+				continue;
+			}
+			// style starts beyond line end or RTF write end
+			if (start >= lineEndOffset) {
+				break;
+			}
+			// write any unstyled text
+			if (lineIndex < start) {
+				// copy to start of style
+				// style starting beyond end of write range or end of line 
+				// is guarded against above.
+				write(line, lineIndex, start);
+				lineIndex = start;
+			}
+			// write styled text
+			write("{\\cf");
+			write(getColorIndex(style.foreground, DEFAULT_FOREGROUND));
+			int colorIndex = getColorIndex(style.background, DEFAULT_BACKGROUND);
+			if (colorIndex != DEFAULT_BACKGROUND) {
+				write("\\highlight");
+				write(colorIndex);
+			}
+			Font font = style.font;
+			if (font != null) {
+				int fontIndex = getFontIndex(font);
+				write("\\f");
+				write(fontIndex);
+				FontData fontData = font.getFontData()[0];
+				write("\\fs");
+				write(fontData.getHeight() * 2);
+			} else {
+				if ((style.fontStyle & SWT.BOLD) != 0) {
+					write("\\b"); 
+				}
+				if ((style.fontStyle & SWT.ITALIC) != 0) {
+					write("\\i"); 
+				}
+			}
+			if (style.underline) {
+				write("\\ul");
+			}
+			if (style.strikeout) {
+				write("\\strike");
+			}
+			write(" "); 
+			// copy to end of style or end of write range or end of line
+			int copyEnd = Math.min(end, lineEndOffset);
+			// guard against invalid styles and let style processing continue
+			copyEnd = Math.max(copyEnd, lineIndex);
+			write(line, lineIndex, copyEnd);
+			if (font == null) {
+				if ((style.fontStyle & SWT.BOLD) != 0) {
+					write("\\b0"); 
+				}
+				if ((style.fontStyle & SWT.ITALIC) != 0) {
+					write("\\i0"); 
+				}
+			}
+			if (style.underline) {
+				write("\\ul0");
+			}
+			if (style.strikeout) {
+				write("\\strike0");
+			}
+			write("}");
+			lineIndex = copyEnd;
+		}
+		// write unstyled text at the end of the line
+		if (lineIndex < lineEndOffset) {
+			write(line, lineIndex, lineEndOffset);
+		}
+		if (lineBackground != null) write("}");
+	}
+	}
+	/**
+	 * The <code>TextWriter</code> class is used to write widget content to
+	 * a string.  Whole and partial lines and line breaks can be written. To write 
+	 * partial lines, specify the start and length of the desired segment 
+	 * during object creation.
+	 * <p>
+	 * </b>NOTE:</b> <code>toString()</code> is guaranteed to return a valid string only after close() 
+	 * has been called.
+	 * </p>
+	 */
+	class TextWriter {
+		private StringBuffer buffer;
+		private int startOffset;	// offset of first character that will be written
+		private int endOffset;		// offset of last character that will be written. 
+									// 0 based from the beginning of the widget text. 
+		private boolean isClosed = false;
+	
+	/**
+	 * Creates a writer that writes content starting at offset "start"
+	 * in the document.  <code>start</code> and <code>length</code> can be set to specify partial lines.
+	 *
+	 * @param start start offset of content to write, 0 based from beginning of document
+	 * @param length length of content to write
+	 */
+	public TextWriter(int start, int length) {
+		buffer = new StringBuffer(length);
+		startOffset = start;
+		endOffset = start + length;
+	}
+	/**
+	 * Closes the writer. Once closed no more content can be written.
+	 * <b>NOTE:</b>  <code>toString()</code> is not guaranteed to return a valid string unless
+	 * the writer is closed.
+	 */
+	public void close() {
+		if (!isClosed) {
+			isClosed = true;
+		}
+	}
+	/** 
+	 * Returns the number of characters to write.
+	 * @return the integer number of characters to write
+	 */
+	public int getCharCount() {
+		return endOffset - startOffset;
+	}	
+	/** 
+	 * Returns the offset where writing starts. 0 based from the start of 
+	 * the widget text. Used to write partial lines.
+	 * @return the integer offset where writing starts
+	 */
+	public int getStart() {
+		return startOffset;
+	}
+	/**
+	 * Returns whether the writer is closed.
+	 * @return a boolean specifying whether or not the writer is closed
+	 */
+	public boolean isClosed() {
+		return isClosed;
+	}
+	/**
+	 * Returns the string.  <code>close()</code> must be called before <code>toString()</code> 
+	 * is guaranteed to return a valid string.
+	 *
+	 * @return the string
+	 */
+	public String toString() {
+		return buffer.toString();
+	}
+	/**
+	 * Appends the given string to the data.
+	 */
+	void write(String string) {
+		buffer.append(string);
+	}
+	/**
+	 * Inserts the given string to the data at the specified offset.
+	 * <p>
+	 * Do nothing if "offset" is < 0 or > getCharCount()
+	 * </p>
+	 *
+	 * @param string text to insert
+	 * @param offset offset in the existing data to insert "string" at.
+	 */
+	void write(String string, int offset) {
+		if (offset < 0 || offset > buffer.length()) {
+			return;
+		}
+		buffer.insert(offset, string);
+	}
+	/**
+	 * Appends the given int to the data.
+	 */
+	void write(int i) {
+		buffer.append(i);
+	}
+	/**
+	 * Appends the given character to the data.
+	 */
+	void write(char i) {
+		buffer.append(i);
+	}
+	/**
+	 * Appends the specified line text to the data.
+	 *
+	 * @param line line text to write. Must not contain line breaks
+	 * 	Line breaks should be written using writeLineDelimiter()
+	 * @param lineOffset offset of the line. 0 based from the start of the 
+	 * 	widget document. Any text occurring before the start offset or after the 
+	 *	end offset specified during object creation is ignored.
+	 * @exception SWTException <ul>
+	 *   <li>ERROR_IO when the writer is closed.</li>
+	 * </ul>
+	 */
+	public void writeLine(String line, int lineOffset) {	
+		if (isClosed) {
+			SWT.error(SWT.ERROR_IO);
+		}		
+		int writeOffset = startOffset - lineOffset;
+		int lineLength = line.length();
+		int lineIndex;
+		if (writeOffset >= lineLength) {
+			return;							// whole line is outside write range
+		} else if (writeOffset > 0) {
+			lineIndex = writeOffset;		// line starts before write start
+		} else {
+			lineIndex = 0;
+		}
+		int copyEnd = Math.min(lineLength, endOffset - lineOffset);
+		if (lineIndex < copyEnd) {
+			write(line.substring(lineIndex, copyEnd));
+		}
+	}
+	/**
+	 * Appends the specified line delimiter to the data.
+	 *
+	 * @param lineDelimiter line delimiter to write
+	 * @exception SWTException <ul>
+	 *   <li>ERROR_IO when the writer is closed.</li>
+	 * </ul>
+	 */
+	public void writeLineDelimiter(String lineDelimiter) {
+		if (isClosed) {
+			SWT.error(SWT.ERROR_IO);
+		}
+		write(lineDelimiter);
+	}
+	}
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a widget which will be the parent of the new instance (cannot be null)
+ * @param style the style of widget to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * </ul>
+ *
+ * @see SWT#FULL_SELECTION
+ * @see SWT#MULTI
+ * @see SWT#READ_ONLY
+ * @see SWT#SINGLE
+ * @see SWT#WRAP
+ * @see #getStyle
+ */
+public StyledText(Composite parent, int style) {
+	super(parent, checkStyle(style));
+	// set the fg in the OS to ensure that these are the same as StyledText, necessary
+	// for ensuring that the bg/fg the IME box uses is the same as what StyledText uses
+	super.setForeground(getForeground());
+	super.setDragDetect(false);
+	Display display = getDisplay();
+	isMirrored = (super.getStyle() & SWT.MIRRORED) != 0;
+	fixedLineHeight = true;
+	if ((style & SWT.READ_ONLY) != 0) {
+		setEditable(false);
+	}
+	leftMargin = rightMargin = isBidiCaret() ? BIDI_CARET_WIDTH - 1: 0;
+	if ((style & SWT.SINGLE) != 0 && (style & SWT.BORDER) != 0) {
+		leftMargin = topMargin = rightMargin = bottomMargin = 2;
+	}
+	alignment = style & (SWT.LEFT | SWT.RIGHT | SWT.CENTER);
+	if (alignment == 0) alignment = SWT.LEFT;
+	clipboard = new Clipboard(display);
+	installDefaultContent();
+	renderer = new StyledTextRenderer(getDisplay(), this);
+	renderer.setContent(content);
+	renderer.setFont(getFont(), tabLength);
+	ime = new IME(this, SWT.NONE);
+	defaultCaret = new Caret(this, SWT.NONE);
+	if ((style & SWT.WRAP) != 0) {
+		setWordWrap(true);
+	}
+	if (isBidiCaret()) {
+		createCaretBitmaps();
+		Runnable runnable = new Runnable() {
+			public void run() {
+				int direction = BidiUtil.getKeyboardLanguage() == BidiUtil.KEYBOARD_BIDI ? SWT.RIGHT : SWT.LEFT;
+				if (direction == caretDirection) return;
+				if (getCaret() != defaultCaret) return;
+				Point newCaretPos = getPointAtOffset(caretOffset);
+				setCaretLocation(newCaretPos, direction);
+			}
+		};
+		BidiUtil.addLanguageListener(this, runnable);
+	}
+	setCaret(defaultCaret);	
+	calculateScrollBars();
+	createKeyBindings();
+	setCursor(display.getSystemCursor(SWT.CURSOR_IBEAM));
+	installListeners();
+	initializeAccessible();
+	setData("DEFAULT_DROP_TARGET_EFFECT", new StyledTextDropTargetEffect(this));
+}
+/**	 
+ * Adds an extended modify listener. An ExtendedModify event is sent by the 
+ * widget when the widget text has changed.
+ *
+ * @param extendedModifyListener the listener
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT when listener is null</li>
+ * </ul>
+ */
+public void addExtendedModifyListener(ExtendedModifyListener extendedModifyListener) {
+	checkWidget();
+	if (extendedModifyListener == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	StyledTextListener typedListener = new StyledTextListener(extendedModifyListener);
+	addListener(ExtendedModify, typedListener);
+}
+/**
+ * Adds a bidirectional segment listener.
+ * <p>
+ * A BidiSegmentEvent is sent 
+ * whenever a line of text is measured or rendered. The user can 
+ * specify text ranges in the line that should be treated as if they 
+ * had a different direction than the surrounding text.
+ * This may be used when adjacent segments of right-to-left text should
+ * not be reordered relative to each other. 
+ * E.g., Multiple Java string literals in a right-to-left language
+ * should generally remain in logical order to each other, that is, the
+ * way they are stored. 
+ * </p>
+ *
+ * @param listener the listener
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT when listener is null</li>
+ * </ul>
+ * @see BidiSegmentEvent
+ * @since 2.0
+ */
+public void addBidiSegmentListener(BidiSegmentListener listener) {
+	checkWidget();
+	if (listener == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	addListener(LineGetSegments, new StyledTextListener(listener));
+}
+/**
+ * Adds a line background listener. A LineGetBackground event is sent by the 
+ * widget to determine the background color for a line.
+ *
+ * @param listener the listener
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT when listener is null</li>
+ * </ul>
+ */
+public void addLineBackgroundListener(LineBackgroundListener listener) {
+	checkWidget();
+	if (listener == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	if (!isListening(LineGetBackground)) {
+		renderer.clearLineBackground(0, content.getLineCount());
+	}
+	addListener(LineGetBackground, new StyledTextListener(listener));
+}
+/**
+ * Adds a line style listener. A LineGetStyle event is sent by the widget to 
+ * determine the styles for a line.
+ *
+ * @param listener the listener
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT when listener is null</li>
+ * </ul>
+ */
+public void addLineStyleListener(LineStyleListener listener) {
+	checkWidget();
+	if (listener == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	if (!isListening(LineGetStyle)) {
+		setStyleRanges(0, 0, null, null, true);
+		renderer.clearLineStyle(0, content.getLineCount());
+	}
+	addListener(LineGetStyle, new StyledTextListener(listener));
+}
+/**	 
+ * Adds a modify listener. A Modify event is sent by the widget when the widget text 
+ * has changed.
+ *
+ * @param modifyListener the listener
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT when listener is null</li>
+ * </ul>
+ */
+public void addModifyListener(ModifyListener modifyListener) {
+	checkWidget();
+	if (modifyListener == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	addListener(SWT.Modify, new TypedListener(modifyListener));
+}
+/**	 
+ * Adds a paint object listener. A paint object event is sent by the widget when an object
+ * needs to be drawn.
+ *
+ * @param listener the listener
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT when listener is null</li>
+ * </ul>
+ * 
+ * @since 3.2
+ * 
+ * @see PaintObjectListener
+ * @see PaintObjectEvent
+ */
+public void addPaintObjectListener(PaintObjectListener listener) {
+	checkWidget();
+	if (listener == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	addListener(PaintObject, new StyledTextListener(listener));
+}
+/**	 
+ * Adds a selection listener. A Selection event is sent by the widget when the 
+ * user changes the selection.
+ * <p>
+ * When <code>widgetSelected</code> is called, the event x and y fields contain
+ * the start and end caret indices of the selection.
+ * <code>widgetDefaultSelected</code> is not called for StyledTexts.
+ * </p>
+ * 
+ * @param listener the listener which should be notified when the user changes the receiver's selection
+
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent
+ */
+public void addSelectionListener(SelectionListener listener) {
+	checkWidget();
+	if (listener == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	addListener(SWT.Selection, new TypedListener(listener));
+}
+/**	 
+ * Adds a verify key listener. A VerifyKey event is sent by the widget when a key 
+ * is pressed. The widget ignores the key press if the listener sets the doit field 
+ * of the event to false. 
+ *
+ * @param listener the listener
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT when listener is null</li>
+ * </ul>
+ */
+public void addVerifyKeyListener(VerifyKeyListener listener) {
+	checkWidget();
+	if (listener == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	addListener(VerifyKey, new StyledTextListener(listener));
+}
+/**	 
+ * Adds a verify listener. A Verify event is sent by the widget when the widget text 
+ * is about to change. The listener can set the event text and the doit field to 
+ * change the text that is set in the widget or to force the widget to ignore the 
+ * text change.
+ *
+ * @param verifyListener the listener
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT when listener is null</li>
+ * </ul>
+ */
+public void addVerifyListener(VerifyListener verifyListener) {
+	checkWidget();
+	if (verifyListener == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	addListener(SWT.Verify, new TypedListener(verifyListener));
+}
+/**	 
+ * Adds a word movement listener. A movement event is sent when the boundary 
+ * of a word is needed. For example, this occurs during word next and word 
+ * previous actions.
+ *
+ * @param movementListener the listener
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT when listener is null</li>
+ * </ul>
+ * 
+ * @see MovementEvent
+ * @see MovementListener
+ * @see #removeWordMovementListener
+ * 
+ * @since 3.3 
+ */
+public void addWordMovementListener(MovementListener movementListener) {
+	checkWidget();
+	if (listener == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	addListener(WordNext, new StyledTextListener(movementListener));
+	addListener(WordPrevious, new StyledTextListener(movementListener));
+}
+/** 
+ * Appends a string to the text at the end of the widget.
+ *
+ * @param string the string to be appended
+ * @see #replaceTextRange(int,int,String)
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT when listener is null</li>
+ * </ul>
+ */
+public void append(String string) {
+	checkWidget();
+	if (string == null) {
+		SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	}
+	int lastChar = Math.max(getCharCount(), 0);
+	replaceTextRange(lastChar, 0, string);
+}
+/**
+ * Calculates the scroll bars
+ */
+void calculateScrollBars() {
+	ScrollBar horizontalBar = getHorizontalBar();
+	ScrollBar verticalBar = getVerticalBar();
+	setScrollBars(true);
+	if (verticalBar != null) {
+		verticalBar.setIncrement(getVerticalIncrement());
+	}	
+	if (horizontalBar != null) {
+		horizontalBar.setIncrement(getHorizontalIncrement());
+	}
+}
+/**
+ * Calculates the top index based on the current vertical scroll offset.
+ * The top index is the index of the topmost fully visible line or the
+ * topmost partially visible line if no line is fully visible.
+ * The top index starts at 0.
+ */
+void calculateTopIndex(int delta) {
+	int oldTopIndex = topIndex;
+	int oldTopIndexY = topIndexY;
+	if (isFixedLineHeight()) {
+		int verticalIncrement = getVerticalIncrement();
+		if (verticalIncrement == 0) {
+			return;
+		}
+		topIndex = Compatibility.ceil(getVerticalScrollOffset(), verticalIncrement);
+		// Set top index to partially visible top line if no line is fully 
+		// visible but at least some of the widget client area is visible.
+		// Fixes bug 15088.
+		if (topIndex > 0) {
+			if (clientAreaHeight > 0) {
+				int bottomPixel = getVerticalScrollOffset() + clientAreaHeight;
+				int fullLineTopPixel = topIndex * verticalIncrement;
+				int fullLineVisibleHeight = bottomPixel - fullLineTopPixel;
+				// set top index to partially visible line if no line fully fits in 
+				// client area or if space is available but not used (the latter should
+				// never happen because we use claimBottomFreeSpace)
+				if (fullLineVisibleHeight < verticalIncrement) {
+					topIndex--;
+				}
+			} else if (topIndex >= content.getLineCount()) {
+				topIndex = content.getLineCount() - 1;
+			}
+		}
+	} else {
+		if (delta >= 0) {
+			delta -= topIndexY;
+			int lineIndex = topIndex;
+			int lineCount = content.getLineCount();
+			while (lineIndex < lineCount) {
+				if (delta <= 0) break;
+				delta -= renderer.getLineHeight(lineIndex++);
+			}
+			if (lineIndex < lineCount && -delta + renderer.getLineHeight(lineIndex) <= clientAreaHeight - topMargin - bottomMargin) {
+				topIndex = lineIndex;
+				topIndexY = -delta;
+			} else {
+				topIndex = lineIndex - 1;
+				topIndexY = -renderer.getLineHeight(topIndex) - delta;
+			}
+		} else {
+			delta -= topIndexY;
+			int lineIndex = topIndex;
+			while (lineIndex > 0) {
+				int lineHeight = renderer.getLineHeight(lineIndex - 1);
+				if (delta + lineHeight > 0) break;
+				delta += lineHeight;
+				lineIndex--;
+			}
+			if (lineIndex == 0 || -delta + renderer.getLineHeight(lineIndex) <= clientAreaHeight - topMargin - bottomMargin) {
+				topIndex = lineIndex;
+				topIndexY = - delta;
+			} else {
+				topIndex = lineIndex - 1;
+				topIndexY = - renderer.getLineHeight(topIndex) - delta;
+			}
+		}
+	}
+	if (topIndex != oldTopIndex || oldTopIndexY != topIndexY) {
+		renderer.calculateClientArea();
+		setScrollBars(false);
+	}
+}
+/**
+ * Hides the scroll bars if widget is created in single line mode.
+ */
+static int checkStyle(int style) {
+	if ((style & SWT.SINGLE) != 0) {
+		style &= ~(SWT.H_SCROLL | SWT.V_SCROLL | SWT.WRAP | SWT.MULTI);
+	} else {
+		style |= SWT.MULTI;
+		if ((style & SWT.WRAP) != 0) {
+			style &= ~SWT.H_SCROLL;
+		}
+	}
+	style |= SWT.NO_REDRAW_RESIZE | SWT.DOUBLE_BUFFERED | SWT.NO_BACKGROUND;
+	return style;
+}
+/**
+ * Scrolls down the text to use new space made available by a resize or by 
+ * deleted lines.
+ */
+void claimBottomFreeSpace() {
+	int clientAreaHeight = this.clientAreaHeight - topMargin - bottomMargin;
+	if (isFixedLineHeight()) {
+		int lineHeight = renderer.getLineHeight();
+		int newVerticalOffset = Math.max(0, content.getLineCount() * lineHeight - clientAreaHeight);
+		if (newVerticalOffset < getVerticalScrollOffset()) {
+			scrollVertical(newVerticalOffset - getVerticalScrollOffset(), true);
+		}
+	} else {
+		int bottomIndex = getPartialBottomIndex();
+		int height = getLinePixel(bottomIndex + 1);
+		if (clientAreaHeight > height) {
+			scrollVertical(-getAvailableHeightAbove(clientAreaHeight - height), true);
+		}
+	}
+}
+/**
+ * Scrolls text to the right to use new space made available by a resize.
+ */
+void claimRightFreeSpace() {
+	int newHorizontalOffset = Math.max(0, renderer.getWidth() - (clientAreaWidth - leftMargin - rightMargin));
+	if (newHorizontalOffset < horizontalScrollOffset) {			
+		// item is no longer drawn past the right border of the client area
+		// align the right end of the item with the right border of the 
+		// client area (window is scrolled right).
+		scrollHorizontal(newHorizontalOffset - horizontalScrollOffset, true);					
+	}
+}
+/**
+ * Removes the widget selection.
+ *
+ * @param sendEvent a Selection event is sent when set to true and when the selection is actually reset.
+ */
+void clearSelection(boolean sendEvent) {
+	int selectionStart = selection.x;
+	int selectionEnd = selection.y;	
+	resetSelection();
+	// redraw old selection, if any
+	if (selectionEnd - selectionStart > 0) {
+		int length = content.getCharCount();
+		// called internally to remove selection after text is removed
+		// therefore make sure redraw range is valid.
+		int redrawStart = Math.min(selectionStart, length);
+		int redrawEnd = Math.min(selectionEnd, length);
+		if (redrawEnd - redrawStart > 0) {
+			internalRedrawRange(redrawStart, redrawEnd - redrawStart);
+		}
+		if (sendEvent) {
+			sendSelectionEvent();
+		}
+	}
+}
+public Point computeSize (int wHint, int hHint, boolean changed) {
+	checkWidget();
+	int lineCount = (getStyle() & SWT.SINGLE) != 0 ? 1 : content.getLineCount();
+	int width = 0;
+	int height = 0;
+	if (wHint == SWT.DEFAULT || hHint == SWT.DEFAULT) {
+		Display display = getDisplay();
+		int maxHeight = display.getClientArea().height;
+		for (int lineIndex = 0; lineIndex < lineCount; lineIndex++) {
+			TextLayout layout = renderer.getTextLayout(lineIndex);
+			int wrapWidth = layout.getWidth();
+			if (wordWrap) layout.setWidth(wHint == 0 ? 1 : wHint);
+			Rectangle rect = layout.getBounds();
+			height += rect.height;
+			width = Math.max(width, rect.width);
+			layout.setWidth(wrapWidth);
+			renderer.disposeTextLayout(layout);
+			if (isFixedLineHeight() && height > maxHeight) break;
+		}
+		if (isFixedLineHeight()) {
+			height = lineCount * renderer.getLineHeight();
+		}
+	}
+	// Use default values if no text is defined.
+	if (width == 0) width = DEFAULT_WIDTH;
+	if (height == 0) height = DEFAULT_HEIGHT;
+	if (wHint != SWT.DEFAULT) width = wHint;
+	if (hHint != SWT.DEFAULT) height = hHint;
+	int wTrim = leftMargin + rightMargin + getCaretWidth();
+	int hTrim = topMargin + bottomMargin;
+	Rectangle rect = computeTrim(0, 0, width + wTrim, height + hTrim);
+	return new Point (rect.width, rect.height);
+}
+/**
+ * Copies the selected text to the <code>DND.CLIPBOARD</code> clipboard.
+ * <p>
+ * The text will be put on the clipboard in plain text format and RTF format.
+ * The <code>DND.CLIPBOARD</code> clipboard is used for data that is
+ * transferred by keyboard accelerator (such as Ctrl+C/Ctrl+V) or 
+ * by menu action.
+ * </p>
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void copy() {
+	checkWidget();
+	copy(DND.CLIPBOARD);
+}
+/**
+ * Copies the selected text to the specified clipboard.  The text will be put in the 
+ * clipboard in plain text format and RTF format.
+ * <p>
+ * The clipboardType is  one of the clipboard constants defined in class 
+ * <code>DND</code>.  The <code>DND.CLIPBOARD</code>  clipboard is 
+ * used for data that is transferred by keyboard accelerator (such as Ctrl+C/Ctrl+V) 
+ * or by menu action.  The <code>DND.SELECTION_CLIPBOARD</code> 
+ * clipboard is used for data that is transferred by selecting text and pasting 
+ * with the middle mouse button.
+ * </p>
+ * 
+ * @param clipboardType indicates the type of clipboard
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.1
+ */
+public void copy(int clipboardType) {
+	checkWidget();
+	if (clipboardType != DND.CLIPBOARD && clipboardType != DND.SELECTION_CLIPBOARD) return;
+	int length = selection.y - selection.x;
+	if (length > 0) {
+		try {
+			setClipboardContent(selection.x, length, clipboardType);
+		} catch (SWTError error) {
+			// Copy to clipboard failed. This happens when another application 
+			// is accessing the clipboard while we copy. Ignore the error.
+			// Fixes 1GDQAVN
+			// Rethrow all other errors. Fixes bug 17578.
+			if (error.code != DND.ERROR_CANNOT_SET_CLIPBOARD) {
+				throw error;
+			}
+		}
+	}
+}
+/**
+ * Returns the alignment of the widget.
+ * 
+ * @return the alignment
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *  
+ * @see #getLineAlignment(int)
+ * 
+ * @since 3.2
+ */
+public int getAlignment() {
+	checkWidget();
+	return alignment;
+}
+int getAvailableHeightAbove(int height) {
+	int maxHeight = verticalScrollOffset;
+	if (maxHeight == -1) {
+		int lineIndex = topIndex - 1;
+		maxHeight = -topIndexY;
+		if (topIndexY > 0) {
+			maxHeight += renderer.getLineHeight(lineIndex--);
+		}
+		while (height > maxHeight && lineIndex >= 0) {
+			maxHeight += renderer.getLineHeight(lineIndex--);
+		}
+	}
+	return Math.min(height, maxHeight);
+}
+int getAvailableHeightBellow(int height) {
+	int partialBottomIndex = getPartialBottomIndex();
+	int topY = getLinePixel(partialBottomIndex);
+	int lineHeight = renderer.getLineHeight(partialBottomIndex);
+	int availableHeight = 0;
+	int clientAreaHeight = this.clientAreaHeight - topMargin - bottomMargin;
+	if (topY + lineHeight > clientAreaHeight) {
+		availableHeight = lineHeight - (clientAreaHeight - topY);
+	}
+	int lineIndex = partialBottomIndex + 1;
+	int lineCount = content.getLineCount();
+	while (height > availableHeight && lineIndex < lineCount) {
+		availableHeight += renderer.getLineHeight(lineIndex++);
+	}
+	return Math.min(height, availableHeight);
+}
+/**
+ * Returns a string that uses only the line delimiter specified by the 
+ * StyledTextContent implementation.
+ * <p>
+ * Returns only the first line if the widget has the SWT.SINGLE style.
+ * </p>
+ *
+ * @param text the text that may have line delimiters that don't 
+ * 	match the model line delimiter. Possible line delimiters 
+ * 	are CR ('\r'), LF ('\n'), CR/LF ("\r\n")
+ * @return the converted text that only uses the line delimiter 
+ * 	specified by the model. Returns only the first line if the widget 
+ * 	has the SWT.SINGLE style.
+ */
+String getModelDelimitedText(String text) {	
+	int length = text.length();
+	if (length == 0) {
+		return text;
+	}	
+	int crIndex = 0;
+	int lfIndex = 0;
+	int i = 0;
+	StringBuffer convertedText = new StringBuffer(length);
+	String delimiter = getLineDelimiter();
+	while (i < length) {
+		if (crIndex != -1) {
+			crIndex = text.indexOf(SWT.CR, i);
+		}
+		if (lfIndex != -1) {
+			lfIndex = text.indexOf(SWT.LF, i);
+		}
+		if (lfIndex == -1 && crIndex == -1) {	// no more line breaks?
+			break;
+		} else if ((crIndex < lfIndex && crIndex != -1) || lfIndex == -1) {
+			convertedText.append(text.substring(i, crIndex));
+			if (lfIndex == crIndex + 1) {		// CR/LF combination?
+				i = lfIndex + 1;
+			} else {
+				i = crIndex + 1;
+			}
+		} else {									// LF occurs before CR!
+			convertedText.append(text.substring(i, lfIndex));
+			i = lfIndex + 1;
+		}
+		if (isSingleLine()) {
+			break;
+		}
+		convertedText.append(delimiter);
+	}
+	// copy remaining text if any and if not in single line mode or no 
+	// text copied thus far (because there only is one line)
+	if (i < length && (!isSingleLine() || convertedText.length() == 0)) {
+		convertedText.append(text.substring(i));
+	}
+	return convertedText.toString();
+}
+boolean checkDragDetect(Event event) {
+	if (!isListening(SWT.DragDetect)) return false;
+	if (IS_MOTIF) {
+		if (event.button != 2) return false;
+	} else {
+		if (event.button != 1) return false;
+	}
+	if (selection.x == selection.y) return false;
+	int offset = getOffsetAtPoint(event.x, event.y, null, true);
+	if (selection.x <= offset && offset < selection.y) {
+		return dragDetect(event);
+	}
+	return false;
+}
+/**
+ * Creates default key bindings.
+ */
+void createKeyBindings() {
+	int nextKey = isMirrored() ? SWT.ARROW_LEFT : SWT.ARROW_RIGHT;
+	int previousKey = isMirrored() ? SWT.ARROW_RIGHT : SWT.ARROW_LEFT;
+	
+	// Navigation
+	setKeyBinding(SWT.ARROW_UP, ST.LINE_UP);	
+	setKeyBinding(SWT.ARROW_DOWN, ST.LINE_DOWN);
+	if (IS_CARBON) {
+		setKeyBinding(previousKey | SWT.MOD1, ST.LINE_START);
+		setKeyBinding(nextKey | SWT.MOD1, ST.LINE_END);
+		setKeyBinding(SWT.HOME, ST.TEXT_START);
+		setKeyBinding(SWT.END, ST.TEXT_END);
+		setKeyBinding(SWT.ARROW_UP | SWT.MOD1, ST.TEXT_START);
+		setKeyBinding(SWT.ARROW_DOWN | SWT.MOD1, ST.TEXT_END);
+		setKeyBinding(nextKey | SWT.MOD3, ST.WORD_NEXT);
+		setKeyBinding(previousKey | SWT.MOD3, ST.WORD_PREVIOUS);
+	} else {
+		setKeyBinding(SWT.HOME, ST.LINE_START);
+		setKeyBinding(SWT.END, ST.LINE_END);
+		setKeyBinding(SWT.HOME | SWT.MOD1, ST.TEXT_START);
+		setKeyBinding(SWT.END | SWT.MOD1, ST.TEXT_END);
+		setKeyBinding(nextKey | SWT.MOD1, ST.WORD_NEXT);
+		setKeyBinding(previousKey | SWT.MOD1, ST.WORD_PREVIOUS);
+	}
+	setKeyBinding(SWT.PAGE_UP, ST.PAGE_UP);
+	setKeyBinding(SWT.PAGE_DOWN, ST.PAGE_DOWN);
+	setKeyBinding(SWT.PAGE_UP | SWT.MOD1, ST.WINDOW_START);
+	setKeyBinding(SWT.PAGE_DOWN | SWT.MOD1, ST.WINDOW_END);
+	setKeyBinding(nextKey, ST.COLUMN_NEXT);
+	setKeyBinding(previousKey, ST.COLUMN_PREVIOUS);
+	
+	// Selection
+	setKeyBinding(SWT.ARROW_UP | SWT.MOD2, ST.SELECT_LINE_UP);	
+	setKeyBinding(SWT.ARROW_DOWN | SWT.MOD2, ST.SELECT_LINE_DOWN);
+	if (IS_CARBON) {
+		setKeyBinding(previousKey | SWT.MOD1 | SWT.MOD2, ST.SELECT_LINE_START);
+		setKeyBinding(nextKey | SWT.MOD1 | SWT.MOD2, ST.SELECT_LINE_END);
+		setKeyBinding(SWT.HOME | SWT.MOD2, ST.SELECT_TEXT_START);	
+		setKeyBinding(SWT.END | SWT.MOD2, ST.SELECT_TEXT_END);
+		setKeyBinding(SWT.ARROW_UP | SWT.MOD1 | SWT.MOD2, ST.SELECT_TEXT_START);	
+		setKeyBinding(SWT.ARROW_DOWN | SWT.MOD1 | SWT.MOD2, ST.SELECT_TEXT_END);
+		setKeyBinding(nextKey | SWT.MOD2 | SWT.MOD3, ST.SELECT_WORD_NEXT);
+		setKeyBinding(previousKey | SWT.MOD2 | SWT.MOD3, ST.SELECT_WORD_PREVIOUS);
+	} else  {
+		setKeyBinding(SWT.HOME | SWT.MOD2, ST.SELECT_LINE_START);
+		setKeyBinding(SWT.END | SWT.MOD2, ST.SELECT_LINE_END);
+		setKeyBinding(SWT.HOME | SWT.MOD1 | SWT.MOD2, ST.SELECT_TEXT_START);	
+		setKeyBinding(SWT.END | SWT.MOD1 | SWT.MOD2, ST.SELECT_TEXT_END);
+		setKeyBinding(nextKey | SWT.MOD1 | SWT.MOD2, ST.SELECT_WORD_NEXT);
+		setKeyBinding(previousKey | SWT.MOD1 | SWT.MOD2, ST.SELECT_WORD_PREVIOUS);
+	}
+	setKeyBinding(SWT.PAGE_UP | SWT.MOD2, ST.SELECT_PAGE_UP);
+	setKeyBinding(SWT.PAGE_DOWN | SWT.MOD2, ST.SELECT_PAGE_DOWN);
+	setKeyBinding(SWT.PAGE_UP | SWT.MOD1 | SWT.MOD2, ST.SELECT_WINDOW_START);
+	setKeyBinding(SWT.PAGE_DOWN | SWT.MOD1 | SWT.MOD2, ST.SELECT_WINDOW_END);
+	setKeyBinding(nextKey | SWT.MOD2, ST.SELECT_COLUMN_NEXT);
+	setKeyBinding(previousKey | SWT.MOD2, ST.SELECT_COLUMN_PREVIOUS);	
+           	  	
+	// Modification
+	// Cut, Copy, Paste
+	setKeyBinding('X' | SWT.MOD1, ST.CUT);
+	setKeyBinding('C' | SWT.MOD1, ST.COPY);
+	setKeyBinding('V' | SWT.MOD1, ST.PASTE);
+	if (IS_CARBON) {
+		setKeyBinding(SWT.DEL | SWT.MOD2, ST.DELETE_NEXT);
+		setKeyBinding(SWT.BS | SWT.MOD3, ST.DELETE_WORD_PREVIOUS);
+		setKeyBinding(SWT.DEL | SWT.MOD3, ST.DELETE_WORD_NEXT);
+	} else {
+		// Cut, Copy, Paste Wordstar style
+		setKeyBinding(SWT.DEL | SWT.MOD2, ST.CUT);
+		setKeyBinding(SWT.INSERT | SWT.MOD1, ST.COPY);
+		setKeyBinding(SWT.INSERT | SWT.MOD2, ST.PASTE);
+	}
+	setKeyBinding(SWT.BS | SWT.MOD2, ST.DELETE_PREVIOUS);
+	setKeyBinding(SWT.BS, ST.DELETE_PREVIOUS);
+	setKeyBinding(SWT.DEL, ST.DELETE_NEXT);
+	setKeyBinding(SWT.BS | SWT.MOD1, ST.DELETE_WORD_PREVIOUS);
+	setKeyBinding(SWT.DEL | SWT.MOD1, ST.DELETE_WORD_NEXT);
+	
+	// Miscellaneous
+	setKeyBinding(SWT.INSERT, ST.TOGGLE_OVERWRITE);
+}
+/**
+ * Create the bitmaps to use for the caret in bidi mode.  This
+ * method only needs to be called upon widget creation and when the
+ * font changes (the caret bitmap height needs to match font height).
+ */
+void createCaretBitmaps() {
+	int caretWidth = BIDI_CARET_WIDTH;
+	Display display = getDisplay();
+	if (leftCaretBitmap != null) {
+		if (defaultCaret != null && leftCaretBitmap.equals(defaultCaret.getImage())) {
+			defaultCaret.setImage(null);
+		}
+		leftCaretBitmap.dispose();
+	}
+	int lineHeight = renderer.getLineHeight();
+	leftCaretBitmap = new Image(display, caretWidth, lineHeight);
+	GC gc = new GC (leftCaretBitmap); 
+	gc.setBackground(display.getSystemColor(SWT.COLOR_BLACK));
+	gc.fillRectangle(0, 0, caretWidth, lineHeight);
+	gc.setForeground(display.getSystemColor(SWT.COLOR_WHITE));
+	gc.drawLine(0,0,0,lineHeight);
+	gc.drawLine(0,0,caretWidth-1,0);
+	gc.drawLine(0,1,1,1);
+	gc.dispose();	
+	
+	if (rightCaretBitmap != null) {
+		if (defaultCaret != null && rightCaretBitmap.equals(defaultCaret.getImage())) {
+			defaultCaret.setImage(null);
+		}
+		rightCaretBitmap.dispose();
+	}
+	rightCaretBitmap = new Image(display, caretWidth, lineHeight);
+	gc = new GC (rightCaretBitmap); 
+	gc.setBackground(display.getSystemColor(SWT.COLOR_BLACK));
+	gc.fillRectangle(0, 0, caretWidth, lineHeight);
+	gc.setForeground(display.getSystemColor(SWT.COLOR_WHITE));
+	gc.drawLine(caretWidth-1,0,caretWidth-1,lineHeight);
+	gc.drawLine(0,0,caretWidth-1,0);
+	gc.drawLine(caretWidth-1,1,1,1);
+	gc.dispose();
+}
+/**
+ * Moves the selected text to the clipboard.  The text will be put in the 
+ * clipboard in plain text format and RTF format.
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void cut(){
+	checkWidget();
+	int length = selection.y - selection.x;
+	if (length > 0) {
+		try {
+			setClipboardContent(selection.x, length, DND.CLIPBOARD);
+		} catch (SWTError error) {
+			// Copy to clipboard failed. This happens when another application 
+			// is accessing the clipboard while we copy. Ignore the error.
+			// Fixes 1GDQAVN
+			// Rethrow all other errors. Fixes bug 17578.
+			if (error.code != DND.ERROR_CANNOT_SET_CLIPBOARD) {
+				throw error;
+			}
+			// Abort cut operation if copy to clipboard fails.
+			// Fixes bug 21030.
+			return;
+		}
+		doDelete();
+	}
+}
+/** 
+ * A mouse move event has occurred.  See if we should start autoscrolling.  If
+ * the move position is outside of the client area, initiate autoscrolling.  
+ * Otherwise, we've moved back into the widget so end autoscrolling.
+ */
+void doAutoScroll(Event event) {
+	if (event.y > clientAreaHeight) {
+		doAutoScroll(SWT.DOWN, event.y - clientAreaHeight);
+	} else if (event.y < 0) {
+		doAutoScroll(SWT.UP, -event.y);
+	} else if (event.x < leftMargin && !wordWrap) {
+		doAutoScroll(ST.COLUMN_PREVIOUS, leftMargin - event.x);
+	} else if (event.x > clientAreaWidth - leftMargin - rightMargin && !wordWrap) {
+		doAutoScroll(ST.COLUMN_NEXT, event.x - (clientAreaWidth - leftMargin - rightMargin));
+	} else {
+		endAutoScroll();
+	}
+}
+/** 
+ * Initiates autoscrolling.
+ *
+ * @param direction SWT.UP, SWT.DOWN, SWT.COLUMN_NEXT, SWT.COLUMN_PREVIOUS
+ */
+void doAutoScroll(int direction, int distance) {
+	autoScrollDistance = distance;
+	// If we're already autoscrolling in the given direction do nothing
+	if (autoScrollDirection == direction) {
+		return;
+	}
+	
+	Runnable timer = null;
+	final Display display = getDisplay();
+	// Set a timer that will simulate the user pressing and holding
+	// down a cursor key (i.e., arrowUp, arrowDown).
+	if (direction == SWT.UP) {
+		timer = new Runnable() {
+			public void run() {
+				if (autoScrollDirection == SWT.UP) {
+					doSelectionPageUp(autoScrollDistance);
+					display.timerExec(V_SCROLL_RATE, this);
+				}
+			}
+		};
+		autoScrollDirection = direction;
+		display.timerExec(V_SCROLL_RATE, timer);
+	} else if (direction == SWT.DOWN) {
+		timer = new Runnable() {
+			public void run() {
+				if (autoScrollDirection == SWT.DOWN) {
+					doSelectionPageDown(autoScrollDistance);
+					display.timerExec(V_SCROLL_RATE, this);
+				}
+			}
+		};
+		autoScrollDirection = direction;
+		display.timerExec(V_SCROLL_RATE, timer);
+	} else if (direction == ST.COLUMN_NEXT) {
+		timer = new Runnable() {
+			public void run() {
+				if (autoScrollDirection == ST.COLUMN_NEXT) {
+					doVisualNext();
+					setMouseWordSelectionAnchor();
+					doMouseSelection();
+					display.timerExec(H_SCROLL_RATE, this);
+				}
+			}
+		};
+		autoScrollDirection = direction;
+		display.timerExec(H_SCROLL_RATE, timer);
+	} else if (direction == ST.COLUMN_PREVIOUS) {
+		timer = new Runnable() {
+			public void run() {
+				if (autoScrollDirection == ST.COLUMN_PREVIOUS) {
+					doVisualPrevious();
+					setMouseWordSelectionAnchor();
+					doMouseSelection();
+					display.timerExec(H_SCROLL_RATE, this);
+				}
+			}
+		};
+		autoScrollDirection = direction;
+		display.timerExec(H_SCROLL_RATE, timer);
+	}
+}
+/**
+ * Deletes the previous character. Delete the selected text if any.
+ * Move the caret in front of the deleted text.
+ */
+void doBackspace() {
+	Event event = new Event();
+	event.text = "";
+	if (selection.x != selection.y) {
+		event.start = selection.x;
+		event.end = selection.y;
+		sendKeyEvent(event);
+	} else if (caretOffset > 0) {
+		int lineIndex = content.getLineAtOffset(caretOffset);
+		int lineOffset = content.getOffsetAtLine(lineIndex);
+		if (caretOffset == lineOffset) {
+			lineOffset = content.getOffsetAtLine(lineIndex - 1);
+			event.start = lineOffset + content.getLine(lineIndex - 1).length();
+			event.end = caretOffset;
+		} else {
+			TextLayout layout = renderer.getTextLayout(lineIndex);
+			int start = layout.getPreviousOffset(caretOffset - lineOffset, SWT.MOVEMENT_CHAR);
+			renderer.disposeTextLayout(layout); 
+			event.start = start + lineOffset;
+			event.end = caretOffset;
+		}
+		sendKeyEvent(event);
+	}
+}
+/**
+ * Replaces the selection with the character or insert the character at the 
+ * current caret position if no selection exists.
+ * <p>
+ * If a carriage return was typed replace it with the line break character 
+ * used by the widget on this platform.
+ * </p>
+ *
+ * @param key the character typed by the user
+ */
+void doContent(char key) {
+	Event event = new Event();
+	event.start = selection.x;
+	event.end = selection.y;
+	// replace a CR line break with the widget line break
+	// CR does not make sense on Windows since most (all?) applications
+	// don't recognize CR as a line break.
+	if (key == SWT.CR || key == SWT.LF) {
+		if (!isSingleLine()) {
+			event.text = getLineDelimiter();
+		}
+	} else if (selection.x == selection.y && overwrite && key != TAB) {
+		// no selection and overwrite mode is on and the typed key is not a
+		// tab character (tabs are always inserted without overwriting)?	
+		int lineIndex = content.getLineAtOffset(event.end);
+		int lineOffset = content.getOffsetAtLine(lineIndex);
+		String line = content.getLine(lineIndex);
+		// replace character at caret offset if the caret is not at the 
+		// end of the line
+		if (event.end < lineOffset + line.length()) {
+			event.end++;
+		}
+		event.text = new String(new char[] {key});
+	} else {
+		event.text = new String(new char[] {key});
+	}
+	if (event.text != null) {
+		if (textLimit > 0 && content.getCharCount() - (event.end - event.start) >= textLimit) {
+			return;
+		}
+		sendKeyEvent(event);
+	}
+}
+/**
+ * Moves the caret after the last character of the widget content.
+ */
+void doContentEnd() {
+	// place caret at end of first line if receiver is in single 
+	// line mode. fixes 4820.
+	if (isSingleLine()) {
+		doLineEnd();
+	} else {
+		int length = content.getCharCount();		
+		if (caretOffset < length) {
+			caretOffset = length;
+			showCaret();
+		}
+	}
+}
+/**
+ * Moves the caret in front of the first character of the widget content.
+ */
+void doContentStart() {
+	if (caretOffset > 0) {
+		caretOffset = 0;
+		showCaret();
+	}
+}
+/**
+ * Moves the caret to the start of the selection if a selection exists.
+ * Otherwise, if no selection exists move the cursor according to the 
+ * cursor selection rules.
+ *
+ * @see #doSelectionCursorPrevious
+ */
+void doCursorPrevious() {
+	if (selection.y - selection.x > 0) {
+		caretOffset = selection.x;
+		caretAlignment = OFFSET_LEADING;
+		showCaret();
+	} else {
+		doSelectionCursorPrevious();
+	}
+}
+/**
+ * Moves the caret to the end of the selection if a selection exists.
+ * Otherwise, if no selection exists move the cursor according to the 
+ * cursor selection rules.
+ *
+ * @see #doSelectionCursorNext
+ */
+void doCursorNext() {
+	if (selection.y - selection.x > 0) {
+		caretOffset = selection.y;
+		caretAlignment = PREVIOUS_OFFSET_TRAILING;
+		showCaret();
+	} else {
+		doSelectionCursorNext();
+	}
+}
+/**
+ * Deletes the next character. Delete the selected text if any.
+ */
+void doDelete() {
+	Event event = new Event();
+	event.text = "";
+	if (selection.x != selection.y) {
+		event.start = selection.x;
+		event.end = selection.y;
+		sendKeyEvent(event);
+	} else if (caretOffset < content.getCharCount()) {
+		int line = content.getLineAtOffset(caretOffset);
+		int lineOffset = content.getOffsetAtLine(line);
+		int lineLength = content.getLine(line).length();
+		if (caretOffset == lineOffset + lineLength) {
+			event.start = caretOffset;
+			event.end = content.getOffsetAtLine(line + 1);
+		} else {
+			event.start = caretOffset;
+			event.end = getClusterNext(caretOffset, line);
+		}
+		sendKeyEvent(event);
+	}
+}
+/**
+ * Deletes the next word.
+ */
+void doDeleteWordNext() {
+	if (selection.x != selection.y) {
+		// if a selection exists, treat the as if 
+		// only the delete key was pressed
+		doDelete();
+	} else {
+		Event event = new Event();
+		event.text = "";
+		event.start = caretOffset;
+		event.end = getWordNext(caretOffset, SWT.MOVEMENT_WORD);
+		sendKeyEvent(event);
+	}
+}
+/**
+ * Deletes the previous word.
+ */
+void doDeleteWordPrevious() {
+	if (selection.x != selection.y) {
+		// if a selection exists, treat as if 
+		// only the backspace key was pressed
+		doBackspace();
+	} else {
+		Event event = new Event();
+		event.text = "";
+		event.start = getWordPrevious(caretOffset, SWT.MOVEMENT_WORD);
+		event.end = caretOffset;
+		sendKeyEvent(event);
+	}
+}
+/**
+ * Moves the caret one line down and to the same character offset relative 
+ * to the beginning of the line. Move the caret to the end of the new line 
+ * if the new line is shorter than the character offset.
+ */
+void doLineDown(boolean select) {
+	int caretLine = getCaretLine();
+	int lineCount = content.getLineCount();
+	int y = 0;
+	boolean lastLine = false;
+	if (wordWrap) {
+		int lineOffset = content.getOffsetAtLine(caretLine);
+		int offsetInLine = caretOffset - lineOffset;
+		TextLayout layout = renderer.getTextLayout(caretLine);
+		int lineIndex = getVisualLineIndex(layout, offsetInLine);
+		int layoutLineCount = layout.getLineCount();
+		if (lineIndex == layoutLineCount - 1) {
+			lastLine = caretLine == lineCount - 1;
+			caretLine++;
+		} else {
+			y = layout.getLineBounds(lineIndex + 1).y;
+		}
+		renderer.disposeTextLayout(layout);
+	} else {
+		lastLine = caretLine == lineCount - 1;
+		caretLine++;
+	}
+	if (lastLine) {
+		if (select) caretOffset = content.getCharCount();
+	} else {
+		caretOffset = getOffsetAtPoint(columnX, y, caretLine);
+	}
+	int oldColumnX = columnX;
+	int oldHScrollOffset = horizontalScrollOffset;
+	if (select) {
+		setMouseWordSelectionAnchor();	
+		// select first and then scroll to reduce flash when key 
+		// repeat scrolls lots of lines
+		doSelection(ST.COLUMN_NEXT);
+	}
+	showCaret();
+	int hScrollChange = oldHScrollOffset - horizontalScrollOffset;
+	columnX = oldColumnX + hScrollChange;
+}
+/**
+ * Moves the caret to the end of the line.
+ */
+void doLineEnd() {
+	int caretLine = getCaretLine();
+	int lineOffset = content.getOffsetAtLine(caretLine);	
+	int lineEndOffset;
+	if (wordWrap) {
+		TextLayout layout = renderer.getTextLayout(caretLine);
+		int offsetInLine = caretOffset - lineOffset;
+		int lineIndex = getVisualLineIndex(layout, offsetInLine);
+		int[] offsets = layout.getLineOffsets();
+		lineEndOffset = lineOffset + offsets[lineIndex + 1];
+		renderer.disposeTextLayout(layout);
+	} else {
+		int lineLength = content.getLine(caretLine).length();
+		lineEndOffset = lineOffset + lineLength;
+	}
+	if (caretOffset < lineEndOffset) {
+		caretOffset = lineEndOffset;
+		caretAlignment = PREVIOUS_OFFSET_TRAILING;
+		showCaret();
+	}
+}
+/**
+ * Moves the caret to the beginning of the line.
+ */
+void doLineStart() {
+	int caretLine = getCaretLine();
+	int lineOffset = content.getOffsetAtLine(caretLine);
+	if (wordWrap) {
+		TextLayout layout = renderer.getTextLayout(caretLine);
+		int offsetInLine = caretOffset - lineOffset;
+		int lineIndex = getVisualLineIndex(layout, offsetInLine);
+		int[] offsets = layout.getLineOffsets();
+		lineOffset += offsets[lineIndex];
+		renderer.disposeTextLayout(layout);
+	}
+	if (caretOffset > lineOffset) {
+		caretOffset = lineOffset;
+		caretAlignment = OFFSET_LEADING;
+		showCaret();
+	}
+}
+/**
+ * Moves the caret one line up and to the same character offset relative 
+ * to the beginning of the line. Move the caret to the end of the new line 
+ * if the new line is shorter than the character offset.
+ */
+void doLineUp(boolean select) {
+	int caretLine = getCaretLine(), y = 0;
+	boolean firstLine = false;
+	if (wordWrap) {
+		int lineOffset = content.getOffsetAtLine(caretLine);
+		int offsetInLine = caretOffset - lineOffset;
+		TextLayout layout = renderer.getTextLayout(caretLine);
+		int lineIndex = getVisualLineIndex(layout, offsetInLine);
+		if (lineIndex == 0) {
+			firstLine = caretLine == 0;
+			if (!firstLine) {
+				caretLine--;
+				y = renderer.getLineHeight(caretLine) - 1;
+			}
+		} else {
+			y = layout.getLineBounds(lineIndex - 1).y;
+		}
+		renderer.disposeTextLayout(layout);
+	} else {
+		firstLine = caretLine == 0;
+		caretLine--;
+	}
+	if (firstLine) {
+		if (select) caretOffset = 0;
+	} else {
+		caretOffset = getOffsetAtPoint(columnX, y, caretLine);
+	}
+	int oldColumnX = columnX;
+	int oldHScrollOffset = horizontalScrollOffset;
+	if (select) setMouseWordSelectionAnchor();
+	showCaret();
+	if (select) doSelection(ST.COLUMN_PREVIOUS);
+	int hScrollChange = oldHScrollOffset - horizontalScrollOffset;
+	columnX = oldColumnX + hScrollChange;
+}
+/**
+ * Moves the caret to the specified location.
+ *
+ * @param x x location of the new caret position
+ * @param y y location of the new caret position
+ * @param select the location change is a selection operation.
+ * 	include the line delimiter in the selection
+ */
+void doMouseLocationChange(int x, int y, boolean select) {
+	int line = getLineIndex(y);
+
+	updateCaretDirection = true;
+	// allow caret to be placed below first line only if receiver is 
+	// not in single line mode. fixes 4820.
+	if (line < 0 || (isSingleLine() && line > 0)) {
+		return;
+	}
+	int oldCaretAlignment = caretAlignment;
+	int newCaretOffset = getOffsetAtPoint(x, y);
+	
+	if (doubleClickEnabled && clickCount > 1) {
+		newCaretOffset = doMouseWordSelect(x, newCaretOffset, line);
+	}
+	
+	int newCaretLine = content.getLineAtOffset(newCaretOffset);
+	
+	// Is the mouse within the left client area border or on 
+	// a different line? If not the autoscroll selection 
+	// could be incorrectly reset. Fixes 1GKM3XS
+	if (0 <= y && y < clientAreaHeight && 
+		(0 <= x && x < clientAreaWidth || wordWrap ||	
+		newCaretLine != content.getLineAtOffset(caretOffset))) {
+		if (newCaretOffset != caretOffset || caretAlignment != oldCaretAlignment) {
+			caretOffset = newCaretOffset;
+			if (select) doMouseSelection();
+			showCaret();
+		}
+	}
+	if (!select) {
+		caretOffset = newCaretOffset;
+		clearSelection(true);
+	}
+}
+/**
+ * Updates the selection based on the caret position
+ */
+void doMouseSelection() {
+	if (caretOffset <= selection.x || 
+		(caretOffset > selection.x && 
+		 caretOffset < selection.y && selectionAnchor == selection.x)) {
+		doSelection(ST.COLUMN_PREVIOUS);
+	} else {
+		doSelection(ST.COLUMN_NEXT);
+	}
+}
+/**
+ * Returns the offset of the word at the specified offset. 
+ * If the current selection extends from high index to low index 
+ * (i.e., right to left, or caret is at left border of selection on 
+ * non-bidi platforms) the start offset of the word preceding the
+ * selection is returned. If the current selection extends from 
+ * low index to high index the end offset of the word following 
+ * the selection is returned.
+ * 
+ * @param x mouse x location
+ * @param newCaretOffset caret offset of the mouse cursor location
+ * @param line line index of the mouse cursor location
+ */
+int doMouseWordSelect(int x, int newCaretOffset, int line) {
+	// flip selection anchor based on word selection direction from 
+	// base double click. Always do this here (and don't rely on doAutoScroll)
+	// because auto scroll only does not cover all possible mouse selections
+	// (e.g., mouse x < 0 && mouse y > caret line y)
+ 	if (newCaretOffset < selectionAnchor && selectionAnchor == selection.x) {
+		selectionAnchor = doubleClickSelection.y;
+	} else if (newCaretOffset > selectionAnchor && selectionAnchor == selection.y) {
+		selectionAnchor = doubleClickSelection.x;
+	}
+	if (0 <= x && x < clientAreaWidth) {
+		boolean wordSelect = (clickCount & 1) == 0;
+		if (caretOffset == selection.x) {
+			if (wordSelect) {
+				newCaretOffset = getWordPrevious(newCaretOffset, SWT.MOVEMENT_WORD_START);
+			} else {
+				newCaretOffset = content.getOffsetAtLine(line);
+			}
+		} else {
+			if (wordSelect) {
+				newCaretOffset = getWordNext(newCaretOffset, SWT.MOVEMENT_WORD_END);
+			} else {
+				int lineEnd = content.getCharCount();
+				if (line + 1 < content.getLineCount()) {
+					lineEnd = content.getOffsetAtLine(line + 1);
+				}
+				newCaretOffset = lineEnd; 
+			}
+		}
+	}
+	return newCaretOffset;
+}
+/**
+ * Scrolls one page down so that the last line (truncated or whole)
+ * of the current page becomes the fully visible top line.
+ * <p>
+ * The caret is scrolled the same number of lines so that its location 
+ * relative to the top line remains the same. The exception is the end 
+ * of the text where a full page scroll is not possible. In this case 
+ * the caret is moved after the last character.
+ * </p>
+ *
+ * @param select whether or not to select the page
+ */
+void doPageDown(boolean select, int height) {
+	if (isSingleLine()) return;
+	int oldColumnX = columnX;
+	int oldHScrollOffset = horizontalScrollOffset;
+	if (isFixedLineHeight()) {
+		int lineCount = content.getLineCount();
+		int caretLine = getCaretLine();
+		if (caretLine < lineCount - 1) {
+			int lineHeight = renderer.getLineHeight();
+			int lines = (height == -1 ? clientAreaHeight : height) / lineHeight;
+			int scrollLines = Math.min(lineCount - caretLine - 1, lines);
+			// ensure that scrollLines never gets negative and at least one 
+			// line is scrolled. fixes bug 5602.
+			scrollLines = Math.max(1, scrollLines);
+			caretOffset = getOffsetAtPoint(columnX, getLinePixel(caretLine + scrollLines));
+			if (select) {
+				doSelection(ST.COLUMN_NEXT);
+			}
+			// scroll one page down or to the bottom
+			int verticalMaximum = lineCount * getVerticalIncrement();
+			int pageSize = clientAreaHeight;
+			int verticalScrollOffset = getVerticalScrollOffset();
+			int scrollOffset = verticalScrollOffset + scrollLines * getVerticalIncrement();
+			if (scrollOffset + pageSize > verticalMaximum) {
+				scrollOffset = verticalMaximum - pageSize;
+			}
+			if (scrollOffset > verticalScrollOffset) {
+				scrollVertical(scrollOffset - verticalScrollOffset, true);
+			}
+		}
+	} else {
+		int lineCount = content.getLineCount();
+		int caretLine = getCaretLine();
+		int lineIndex, lineHeight;
+		if (height == -1) {
+			lineIndex = getPartialBottomIndex();
+			int topY = getLinePixel(lineIndex);
+			lineHeight = renderer.getLineHeight(lineIndex);
+			height = topY;
+			if (topY + lineHeight <= clientAreaHeight) {
+				height += lineHeight;
+			} else {
+				if (wordWrap) {
+					TextLayout layout = renderer.getTextLayout(lineIndex);
+					int y = clientAreaHeight - topY;
+					for (int i = 0; i < layout.getLineCount(); i++) {
+						Rectangle bounds = layout.getLineBounds(i);
+						if (bounds.contains(bounds.x, y)) {
+							height += bounds.y;
+							break;
+						}
+					}
+					renderer.disposeTextLayout(layout);
+				}
+			}
+		} else {
+			lineIndex = getLineIndex(height);
+			int topLineY = getLinePixel(lineIndex);
+			if (wordWrap) {
+				TextLayout layout = renderer.getTextLayout(lineIndex);
+				int y = height - topLineY;
+				for (int i = 0; i < layout.getLineCount(); i++) {
+					Rectangle bounds = layout.getLineBounds(i);
+					if (bounds.contains(bounds.x, y)) {
+						height = topLineY + bounds.y + bounds.height;
+						break;
+					}
+				}
+				renderer.disposeTextLayout(layout);
+			} else {
+				height = topLineY + renderer.getLineHeight(lineIndex);
+			}
+		}
+		int caretHeight = height;
+		if (wordWrap) {
+			TextLayout layout = renderer.getTextLayout(caretLine);
+			int offsetInLine = caretOffset - content.getOffsetAtLine(caretLine);
+			lineIndex = getVisualLineIndex(layout, offsetInLine);
+			caretHeight += layout.getLineBounds(lineIndex).y;
+			renderer.disposeTextLayout(layout);
+		}
+		lineIndex = caretLine;
+		lineHeight = renderer.getLineHeight(lineIndex);
+		while (caretHeight - lineHeight >= 0 && lineIndex < lineCount - 1) {
+			caretHeight -= lineHeight;
+			lineHeight = renderer.getLineHeight(++lineIndex);
+		}
+		caretOffset = getOffsetAtPoint(columnX, caretHeight, lineIndex);
+		if (select) doSelection(ST.COLUMN_NEXT);
+		height = getAvailableHeightBellow(height);
+		scrollVertical(height, true);
+		if (height == 0) setCaretLocation();
+	}	
+	showCaret();
+	int hScrollChange = oldHScrollOffset - horizontalScrollOffset;
+	columnX = oldColumnX + hScrollChange;	
+}
+/**
+ * Moves the cursor to the end of the last fully visible line.
+ */
+void doPageEnd() {
+	// go to end of line if in single line mode. fixes 5673
+	if (isSingleLine()) {
+		doLineEnd();
+	} else {
+		int bottomOffset;
+		if (wordWrap) {
+			int lineIndex = getPartialBottomIndex();
+			TextLayout layout = renderer.getTextLayout(lineIndex);
+			int y = (clientAreaHeight - bottomMargin) - getLinePixel(lineIndex);
+			int index = layout.getLineCount() - 1;
+			while (index >= 0) {
+				Rectangle bounds = layout.getLineBounds(index);
+				if (y >= bounds.y + bounds.height) break;
+				index--;
+			}
+			if (index == -1 && lineIndex > 0) {
+				bottomOffset = content.getOffsetAtLine(lineIndex - 1) + content.getLine(lineIndex - 1).length();
+			} else {
+				bottomOffset = content.getOffsetAtLine(lineIndex) + Math.max(0, layout.getLineOffsets()[index + 1] - 1);
+			}
+			renderer.disposeTextLayout(layout);
+		} else {
+			int lineIndex = getBottomIndex();
+			bottomOffset = content.getOffsetAtLine(lineIndex) + content.getLine(lineIndex).length();
+		}
+		if (caretOffset < bottomOffset) {
+			caretOffset = bottomOffset;
+			caretAlignment = OFFSET_LEADING;
+			showCaret();
+		}
+	}
+}
+/**
+ * Moves the cursor to the beginning of the first fully visible line.
+ */
+void doPageStart() {
+	int topOffset;
+	if (wordWrap) {
+		int y, lineIndex;
+		if (topIndexY > 0) {
+			lineIndex = topIndex - 1;
+			y = renderer.getLineHeight(lineIndex) - topIndexY;
+		} else {
+			lineIndex = topIndex;
+			y = -topIndexY;
+		}
+		TextLayout layout = renderer.getTextLayout(lineIndex);
+		int index = 0;
+		int lineCount = layout.getLineCount();
+		while (index < lineCount) {
+			Rectangle bounds = layout.getLineBounds(index);
+			if (y <= bounds.y) break;
+			index++;
+		}
+		if (index == lineCount) {
+			topOffset = content.getOffsetAtLine(lineIndex + 1);
+		} else {
+			topOffset = content.getOffsetAtLine(lineIndex) + layout.getLineOffsets()[index];
+		}
+		renderer.disposeTextLayout(layout);		
+	} else {
+		topOffset = content.getOffsetAtLine(topIndex);
+	}
+	if (caretOffset > topOffset) {
+		caretOffset = topOffset;
+		caretAlignment = OFFSET_LEADING;
+		showCaret();
+	}
+}
+/**
+ * Scrolls one page up so that the first line (truncated or whole)
+ * of the current page becomes the fully visible last line.
+ * The caret is scrolled the same number of lines so that its location 
+ * relative to the top line remains the same. The exception is the beginning 
+ * of the text where a full page scroll is not possible. In this case the
+ * caret is moved in front of the first character.
+ */
+void doPageUp(boolean select, int height) {
+	if (isSingleLine()) return;
+	int oldHScrollOffset = horizontalScrollOffset;
+	int oldColumnX = columnX;	
+	if (isFixedLineHeight()) {
+		int caretLine = getCaretLine();	
+		if (caretLine > 0) {
+			int lineHeight = renderer.getLineHeight();
+			int lines = (height == -1 ? clientAreaHeight : height) / lineHeight;
+			int scrollLines = Math.max(1, Math.min(caretLine, lines));
+			caretLine -= scrollLines;
+			caretOffset = getOffsetAtPoint(columnX, getLinePixel(caretLine));
+			if (select) {
+				doSelection(ST.COLUMN_PREVIOUS);
+			}
+			int verticalScrollOffset = getVerticalScrollOffset();
+			int scrollOffset = Math.max(0, verticalScrollOffset - scrollLines * getVerticalIncrement());
+			if (scrollOffset < verticalScrollOffset) {
+				scrollVertical(scrollOffset - verticalScrollOffset, true);
+			}
+		}
+	} else {
+		int caretLine = getCaretLine();
+		int lineHeight, lineIndex;
+		if (height == -1) {
+			if (topIndexY == 0) {
+				height = clientAreaHeight;
+			} else {
+				int y;
+				if (topIndex > 0) {
+					lineIndex = topIndex - 1;
+					lineHeight = renderer.getLineHeight(lineIndex);
+					height = clientAreaHeight - topIndexY;
+					y = lineHeight - topIndexY;
+				} else {
+					lineIndex = topIndex;
+					lineHeight = renderer.getLineHeight(lineIndex);
+					height = clientAreaHeight - (lineHeight + topIndexY);
+					y = -topIndexY;
+				}
+				if (wordWrap) {
+					TextLayout layout = renderer.getTextLayout(lineIndex);
+					for (int i = 0; i < layout.getLineCount(); i++) {
+						Rectangle bounds = layout.getLineBounds(i);
+						if (bounds.contains(bounds.x, y)) {
+							height += lineHeight - (bounds.y + bounds.height);
+							break;
+						}
+					}
+					renderer.disposeTextLayout(layout);
+				}
+			}
+		} else {
+			lineIndex = getLineIndex(clientAreaHeight - height);
+			int topLineY = getLinePixel(lineIndex);
+			if (wordWrap) {
+				TextLayout layout = renderer.getTextLayout(lineIndex);
+				int y = topLineY;
+				for (int i = 0; i < layout.getLineCount(); i++) {
+					Rectangle bounds = layout.getLineBounds(i);
+					if (bounds.contains(bounds.x, y)) {
+						height = clientAreaHeight - (topLineY + bounds.y);
+						break;
+					}
+				}
+				renderer.disposeTextLayout(layout);
+			} else {
+				height = clientAreaHeight - topLineY;
+			}
+		}
+		int caretHeight = height;
+		if (wordWrap) {
+			TextLayout layout = renderer.getTextLayout(caretLine);
+			int offsetInLine = caretOffset - content.getOffsetAtLine(caretLine);
+			lineIndex = getVisualLineIndex(layout, offsetInLine);
+			caretHeight += layout.getBounds().height - layout.getLineBounds(lineIndex).y;
+			renderer.disposeTextLayout(layout);
+		}
+		lineIndex = caretLine;
+		lineHeight = renderer.getLineHeight(lineIndex);
+		while (caretHeight - lineHeight >= 0 && lineIndex > 0) {
+			caretHeight -= lineHeight;
+			lineHeight = renderer.getLineHeight(--lineIndex);
+		}
+		lineHeight = renderer.getLineHeight(lineIndex);
+		caretOffset = getOffsetAtPoint(columnX, lineHeight - caretHeight, lineIndex);	
+		if (select) doSelection(ST.COLUMN_PREVIOUS);
+		height = getAvailableHeightAbove(height);
+		scrollVertical(-height, true);
+		if (height == 0) setCaretLocation();	
+	}
+	showCaret();
+	int hScrollChange = oldHScrollOffset - horizontalScrollOffset;
+	columnX = oldColumnX + hScrollChange;
+}
+/**
+ * Updates the selection to extend to the current caret position.
+ */
+void doSelection(int direction) {
+	int redrawStart = -1;
+	int redrawEnd = -1;	
+	if (selectionAnchor == -1) {
+		selectionAnchor = selection.x;
+	}	
+	if (direction == ST.COLUMN_PREVIOUS) {
+		if (caretOffset < selection.x) {
+			// grow selection
+			redrawEnd = selection.x; 
+			redrawStart = selection.x = caretOffset;		
+			// check if selection has reversed direction
+			if (selection.y != selectionAnchor) {
+				redrawEnd = selection.y;
+				selection.y = selectionAnchor;
+			}
+		// test whether selection actually changed. Fixes 1G71EO1
+		} else if (selectionAnchor == selection.x && caretOffset < selection.y) {
+			// caret moved towards selection anchor (left side of selection). 
+			// shrink selection			
+			redrawEnd = selection.y;
+			redrawStart = selection.y = caretOffset;		
+		}
+	} else {
+		if (caretOffset > selection.y) {
+			// grow selection
+			redrawStart = selection.y;
+			redrawEnd = selection.y = caretOffset;
+			// check if selection has reversed direction
+			if (selection.x != selectionAnchor) {
+				redrawStart = selection.x;				
+				selection.x = selectionAnchor;
+			}
+		// test whether selection actually changed. Fixes 1G71EO1	
+		} else if (selectionAnchor == selection.y && caretOffset > selection.x) {
+			// caret moved towards selection anchor (right side of selection). 
+			// shrink selection			
+			redrawStart = selection.x;
+			redrawEnd = selection.x = caretOffset;		
+		}
+	}
+	if (redrawStart != -1 && redrawEnd != -1) {
+		internalRedrawRange(redrawStart, redrawEnd - redrawStart);
+		sendSelectionEvent();
+	}
+}
+/**
+ * Moves the caret to the next character or to the beginning of the 
+ * next line if the cursor is at the end of a line.
+ */
+void doSelectionCursorNext() {
+	int caretLine = getCaretLine();
+	int lineOffset = content.getOffsetAtLine(caretLine);
+	int offsetInLine = caretOffset - lineOffset;
+	if (offsetInLine < content.getLine(caretLine).length()) {
+		TextLayout layout = renderer.getTextLayout(caretLine);
+		offsetInLine = layout.getNextOffset(offsetInLine, SWT.MOVEMENT_CLUSTER);
+		int lineStart = layout.getLineOffsets()[layout.getLineIndex(offsetInLine)];
+		renderer.disposeTextLayout(layout);
+		caretOffset = offsetInLine + lineOffset;
+		caretAlignment = offsetInLine == lineStart ? OFFSET_LEADING : PREVIOUS_OFFSET_TRAILING;
+		showCaret();
+	} else if (caretLine < content.getLineCount() - 1 && !isSingleLine()) {
+		caretLine++;		
+		caretOffset = content.getOffsetAtLine(caretLine);
+		caretAlignment = PREVIOUS_OFFSET_TRAILING;
+		showCaret();
+	}
+}
+/**
+ * Moves the caret to the previous character or to the end of the previous 
+ * line if the cursor is at the beginning of a line.
+ */
+void doSelectionCursorPrevious() {
+	int caretLine = getCaretLine();
+	int lineOffset = content.getOffsetAtLine(caretLine);
+	int offsetInLine = caretOffset - lineOffset;
+	caretAlignment = OFFSET_LEADING;
+	if (offsetInLine > 0) {
+		caretOffset = getClusterPrevious(caretOffset, caretLine);
+		showCaret();
+	} else if (caretLine > 0) {
+		caretLine--;
+		lineOffset = content.getOffsetAtLine(caretLine);
+		caretOffset = lineOffset + content.getLine(caretLine).length();
+		showCaret();
+	}
+}
+/**
+ * Moves the caret one line down and to the same character offset relative 
+ * to the beginning of the line. Moves the caret to the end of the new line 
+ * if the new line is shorter than the character offset.
+ * Moves the caret to the end of the text if the caret already is on the 
+ * last line.
+ * Adjusts the selection according to the caret change. This can either add
+ * to or subtract from the old selection, depending on the previous selection
+ * direction.
+ */
+void doSelectionLineDown() {
+	int oldColumnX = columnX = getPointAtOffset(caretOffset).x;
+	doLineDown(true);
+	columnX = oldColumnX;
+}
+/**
+ * Moves the caret one line up and to the same character offset relative 
+ * to the beginning of the line. Moves the caret to the end of the new line 
+ * if the new line is shorter than the character offset.
+ * Moves the caret to the beginning of the document if it is already on the
+ * first line.
+ * Adjusts the selection according to the caret change. This can either add
+ * to or subtract from the old selection, depending on the previous selection
+ * direction.
+ */
+void doSelectionLineUp() {
+	int oldColumnX = columnX = getPointAtOffset(caretOffset).x;	
+	doLineUp(true);	
+	columnX = oldColumnX;
+}
+/**
+ * Scrolls one page down so that the last line (truncated or whole)
+ * of the current page becomes the fully visible top line.
+ * <p>
+ * The caret is scrolled the same number of lines so that its location 
+ * relative to the top line remains the same. The exception is the end 
+ * of the text where a full page scroll is not possible. In this case 
+ * the caret is moved after the last character.
+ * <p></p>
+ * Adjusts the selection according to the caret change. This can either add
+ * to or subtract from the old selection, depending on the previous selection
+ * direction.
+ * </p>
+ */
+void doSelectionPageDown(int pixels) {
+	int oldColumnX = columnX = getPointAtOffset(caretOffset).x;
+	doPageDown(true, pixels);
+	columnX = oldColumnX;
+}
+/**
+ * Scrolls one page up so that the first line (truncated or whole)
+ * of the current page becomes the fully visible last line.
+ * <p>
+ * The caret is scrolled the same number of lines so that its location 
+ * relative to the top line remains the same. The exception is the beginning 
+ * of the text where a full page scroll is not possible. In this case the
+ * caret is moved in front of the first character.
+ * </p><p>
+ * Adjusts the selection according to the caret change. This can either add
+ * to or subtract from the old selection, depending on the previous selection
+ * direction.
+ * </p>
+ */
+void doSelectionPageUp(int pixels) {
+	int oldColumnX = columnX = getPointAtOffset(caretOffset).x;
+	doPageUp(true, pixels);
+	columnX = oldColumnX;
+}
+/**
+ * Moves the caret to the end of the next word .
+ */
+void doSelectionWordNext() {
+	int newCaretOffset = getWordNext(caretOffset, SWT.MOVEMENT_WORD);
+	// Force symmetrical movement for word next and previous. Fixes 14536
+	caretAlignment = OFFSET_LEADING;
+	// don't change caret position if in single line mode and the cursor 
+	// would be on a different line. fixes 5673
+	if (!isSingleLine() || 
+		content.getLineAtOffset(caretOffset) == content.getLineAtOffset(newCaretOffset)) {
+		caretOffset = newCaretOffset;
+		showCaret();
+	}
+}
+/**
+ * Moves the caret to the start of the previous word.
+ */
+void doSelectionWordPrevious() {
+	caretAlignment = OFFSET_LEADING;
+	caretOffset = getWordPrevious(caretOffset, SWT.MOVEMENT_WORD);
+	int caretLine = content.getLineAtOffset(caretOffset);
+	// word previous always comes from bottom line. when
+	// wrapping lines, stay on bottom line when on line boundary
+	if (wordWrap && caretLine < content.getLineCount() - 1 &&
+		caretOffset == content.getOffsetAtLine(caretLine + 1)) {
+		caretLine++;
+	}
+	showCaret();
+}
+/**
+ * Moves the caret one character to the left.  Do not go to the previous line.
+ * When in a bidi locale and at a R2L character the caret is moved to the 
+ * beginning of the R2L segment (visually right) and then one character to the 
+ * left (visually left because it's now in a L2R segment).
+ */
+void doVisualPrevious() {
+	caretOffset = getClusterPrevious(caretOffset, getCaretLine());
+	showCaret();
+}
+/**
+ * Moves the caret one character to the right.  Do not go to the next line.
+ * When in a bidi locale and at a R2L character the caret is moved to the 
+ * end of the R2L segment (visually left) and then one character to the 
+ * right (visually right because it's now in a L2R segment).
+ */
+void doVisualNext() {
+	caretOffset = getClusterNext(caretOffset, getCaretLine());
+	showCaret();
+}
+/**
+ * Moves the caret to the end of the next word.
+ * If a selection exists, move the caret to the end of the selection
+ * and remove the selection.
+ */
+void doWordNext() {
+	if (selection.y - selection.x > 0) {
+		caretOffset = selection.y;
+		showCaret();
+	} else {
+		doSelectionWordNext();
+	}
+}
+/**
+ * Moves the caret to the start of the previous word.
+ * If a selection exists, move the caret to the start of the selection
+ * and remove the selection.
+ */
+void doWordPrevious() {
+	if (selection.y - selection.x > 0) {
+		caretOffset = selection.x;
+		showCaret();
+	} else {
+		doSelectionWordPrevious();
+	}
+}
+/** 
+ * Ends the autoscroll process.
+ */
+void endAutoScroll() {
+	autoScrollDirection = SWT.NULL;
+}
+public Color getBackground() {
+	checkWidget();
+	if (background == null) {
+		return getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND);
+	}
+	return background;
+}
+/**
+ * Returns the baseline, in pixels.
+ *  
+ * Note: this API should not be used if a StyleRange attribute causes lines to 
+ * have different heights (i.e. different fonts, rise, etc). 
+ *
+ * @return baseline the baseline
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @since 3.0
+ * 
+ * @see #getBaseline(int)
+ */
+public int getBaseline() {
+	checkWidget();
+	return renderer.getBaseline();
+}
+/**
+ * Returns the baseline at the given offset, in pixels. 
+ *
+ * @param offset the offset
+ * 
+ * @return baseline the baseline
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *   <li>ERROR_INVALID_RANGE when the offset is outside the valid range (< 0 or > getCharCount())</li> 
+ * </ul>
+ *  
+ * @since 3.2
+ */
+public int getBaseline(int offset) {
+	checkWidget();
+	if (!(0 <= offset && offset <= content.getCharCount())) {
+		SWT.error(SWT.ERROR_INVALID_RANGE);
+	}
+	if (isFixedLineHeight()) {
+		return renderer.getBaseline();
+	}
+	int lineIndex = content.getLineAtOffset(offset);
+	int lineOffset = content.getOffsetAtLine(lineIndex);
+	TextLayout layout = renderer.getTextLayout(lineIndex);
+	int lineInParagraph = layout.getLineIndex(Math.min(offset - lineOffset, layout.getText().length()));
+	FontMetrics metrics = layout.getLineMetrics(lineInParagraph);
+	renderer.disposeTextLayout(layout);
+	return metrics.getAscent() + metrics.getLeading();
+}
+/**
+ * Gets the BIDI coloring mode.  When true the BIDI text display
+ * algorithm is applied to segments of text that are the same
+ * color.
+ *
+ * @return the current coloring mode
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @deprecated use BidiSegmentListener instead.
+ */
+public boolean getBidiColoring() {
+	checkWidget();
+	return bidiColoring;
+}
+/** 
+ * Returns the index of the last fully visible line.
+ *
+ * @return index of the last fully visible line.
+ */
+int getBottomIndex() {
+	int bottomIndex;
+	if (isFixedLineHeight()) {
+		int lineCount = 1;
+		int lineHeight = renderer.getLineHeight();
+		if (lineHeight != 0) {
+			// calculate the number of lines that are fully visible
+			int partialTopLineHeight = topIndex * lineHeight - getVerticalScrollOffset();
+			lineCount = (clientAreaHeight - partialTopLineHeight) / lineHeight;
+		}
+		bottomIndex = Math.min(content.getLineCount() - 1, topIndex + Math.max(0, lineCount - 1));
+	} else {
+		int clientAreaHeight = this.clientAreaHeight - bottomMargin;
+		bottomIndex = getLineIndex(clientAreaHeight);
+		if (bottomIndex > 0) {
+			int linePixel = getLinePixel(bottomIndex);
+			int lineHeight = renderer.getLineHeight(bottomIndex);
+			if (linePixel + lineHeight > clientAreaHeight) {
+				if (getLinePixel(bottomIndex - 1) >= topMargin) {
+					bottomIndex--;
+				}
+			}
+		}
+	}
+	return bottomIndex;
+}
+Rectangle getBoundsAtOffset(int offset) {
+	int lineIndex = content.getLineAtOffset(offset);
+	int lineOffset = content.getOffsetAtLine(lineIndex);
+	String line = content.getLine(lineIndex);
+	Rectangle bounds;
+	if (line.length() != 0) {
+		int offsetInLine = offset - lineOffset;
+		TextLayout layout = renderer.getTextLayout(lineIndex);
+		bounds = layout.getBounds(offsetInLine, offsetInLine);
+		renderer.disposeTextLayout(layout);
+	} else {
+		bounds = new Rectangle (0, 0, 0, renderer.getLineHeight());
+	}
+	if (offset == caretOffset) {
+		int lineEnd = lineOffset + line.length();
+		if (offset == lineEnd && caretAlignment == PREVIOUS_OFFSET_TRAILING) {
+			bounds.width += getCaretWidth();
+		}
+	}
+	bounds.x += leftMargin - horizontalScrollOffset;
+	bounds.y += getLinePixel(lineIndex);
+	return bounds;
+}
+/**
+ * Returns the caret position relative to the start of the text.
+ *
+ * @return the caret position relative to the start of the text.
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getCaretOffset() {
+	checkWidget();
+	return caretOffset;
+}
+/**
+ * Returns the caret width.
+ *
+ * @return the caret width, 0 if caret is null.
+ */
+int getCaretWidth() {
+	Caret caret = getCaret();
+	if (caret == null) return 0;
+	return caret.getSize().x;
+}
+Object getClipboardContent(int clipboardType) {
+	TextTransfer plainTextTransfer = TextTransfer.getInstance();
+	return clipboard.getContents(plainTextTransfer, clipboardType);
+}
+int getClusterNext(int offset, int lineIndex) {
+	int lineOffset = content.getOffsetAtLine(lineIndex);	
+	TextLayout layout = renderer.getTextLayout(lineIndex);
+	offset -= lineOffset;
+	offset = layout.getNextOffset(offset, SWT.MOVEMENT_CLUSTER);
+	offset += lineOffset;
+	renderer.disposeTextLayout(layout);
+	return offset;
+}
+int getClusterPrevious(int offset, int lineIndex) {
+	int lineOffset = content.getOffsetAtLine(lineIndex);	
+	TextLayout layout = renderer.getTextLayout(lineIndex);
+	offset -= lineOffset;
+	offset = layout.getPreviousOffset(offset, SWT.MOVEMENT_CLUSTER);
+	offset += lineOffset;
+	renderer.disposeTextLayout(layout);
+	return offset;
+}
+/**
+ * Returns the content implementation that is used for text storage.
+ * 
+ * @return content the user defined content implementation that is used for
+ * text storage or the default content implementation if no user defined 
+ * content implementation has been set.
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public StyledTextContent getContent() {
+	checkWidget();
+	return content;
+}
+public boolean getDragDetect () {
+	checkWidget ();
+	return dragDetect;
+}
+/** 
+ * Returns whether the widget implements double click mouse behavior.
+ *
+ * @return true if double clicking a word selects the word, false if double clicks
+ * have the same effect as regular mouse clicks
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public boolean getDoubleClickEnabled() {
+	checkWidget();
+	return doubleClickEnabled;
+}
+/**
+ * Returns whether the widget content can be edited.
+ *
+ * @return true if content can be edited, false otherwise
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public boolean getEditable() {
+	checkWidget();
+	return editable;
+}
+public Color getForeground() {
+	checkWidget();
+	if (foreground == null) {
+		return getDisplay().getSystemColor(SWT.COLOR_LIST_FOREGROUND);
+	}
+	return foreground;
+}
+/** 
+ * Returns the horizontal scroll increment.
+ *
+ * @return horizontal scroll increment.
+ */
+int getHorizontalIncrement() {	
+	return renderer.averageCharWidth;
+}
+/** 
+ * Returns the horizontal scroll offset relative to the start of the line.
+ *
+ * @return horizontal scroll offset relative to the start of the line,
+ * measured in character increments starting at 0, if > 0 the content is scrolled
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getHorizontalIndex() {
+	checkWidget();
+	return horizontalScrollOffset / getHorizontalIncrement();
+}
+/** 
+ * Returns the horizontal scroll offset relative to the start of the line.
+ *
+ * @return the horizontal scroll offset relative to the start of the line,
+ * measured in pixel starting at 0, if > 0 the content is scrolled.
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getHorizontalPixel() {
+	checkWidget();
+	return horizontalScrollOffset;
+}
+/**
+ * Returns the line indentation of the widget.
+ * 
+ * @return the line indentation
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *  
+ * @see #getLineIndent(int)
+ * 
+ * @since 3.2
+ */
+public int getIndent() {
+	checkWidget();
+	return indent;
+}
+/**
+ * Returns whether the widget justifies lines.
+ * 
+ * @return whether lines are justified
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *  
+ * @see #getLineJustify(int)
+ * 
+ * @since 3.2
+ */
+public boolean getJustify() {
+	checkWidget();
+	return justify;
+}
+/** 
+ * Returns the action assigned to the key.
+ * Returns SWT.NULL if there is no action associated with the key.
+ *
+ * @param key a key code defined in SWT.java or a character. 
+ * 	Optionally ORd with a state mask.  Preferred state masks are one or more of
+ *  SWT.MOD1, SWT.MOD2, SWT.MOD3, since these masks account for modifier platform 
+ *  differences.  However, there may be cases where using the specific state masks
+ *  (i.e., SWT.CTRL, SWT.SHIFT, SWT.ALT, SWT.COMMAND) makes sense.
+ * @return one of the predefined actions defined in ST.java or SWT.NULL 
+ * 	if there is no action associated with the key.
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getKeyBinding(int key) {
+	checkWidget();
+	Integer action = (Integer) keyActionMap.get(new Integer(key));	
+	return action == null ? SWT.NULL : action.intValue();
+}
+/**
+ * Gets the number of characters.
+ *
+ * @return number of characters in the widget
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getCharCount() {
+	checkWidget();
+	return content.getCharCount();
+}
+/**
+ * Returns the line at the given line index without delimiters.
+ * Index 0 is the first line of the content. When there are not
+ * any lines, getLine(0) is a valid call that answers an empty string.
+ * <p>
+ *
+ * @param lineIndex index of the line to return.
+ * @return the line text without delimiters
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *   <li>ERROR_INVALID_RANGE when the line index is outside the valid range (< 0 or >= getLineCount())</li> 
+ * </ul>
+ * @since 3.4
+ */
+public String getLine(int lineIndex) {
+	checkWidget();
+	if (lineIndex < 0 || 
+		(lineIndex > 0 && lineIndex >= content.getLineCount())) {
+		SWT.error(SWT.ERROR_INVALID_RANGE);		
+	}
+	return content.getLine(lineIndex);
+}
+/**
+ * Returns the alignment of the line at the given index.
+ * 
+ * @param index the index of the line
+ * 
+ * @return the line alignment
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT when the index is invalid</li>
+ * </ul>
+ * 
+ * @see #getAlignment()
+ * 
+ * @since 3.2
+ */
+public int getLineAlignment(int index) {
+	checkWidget();
+	if (index < 0 || index > content.getLineCount()) {
+		SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	}
+	return renderer.getLineAlignment(index, alignment);
+}
+/**
+ * Returns the line at the specified offset in the text
+ * where 0 &lt; offset &lt; getCharCount() so that getLineAtOffset(getCharCount())
+ * returns the line of the insert location.
+ *
+ * @param offset offset relative to the start of the content. 
+ * 	0 <= offset <= getCharCount()
+ * @return line at the specified offset in the text
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *   <li>ERROR_INVALID_RANGE when the offset is outside the valid range (< 0 or > getCharCount())</li> 
+ * </ul>
+ */
+public int getLineAtOffset(int offset) {
+	checkWidget();	
+	if (offset < 0 || offset > getCharCount()) {
+		SWT.error(SWT.ERROR_INVALID_RANGE);		
+	}
+	return content.getLineAtOffset(offset);
+}
+/**
+ * Returns the background color of the line at the given index.
+ * Returns null if a LineBackgroundListener has been set or if no background 
+ * color has been specified for the line. Should not be called if a
+ * LineBackgroundListener has been set since the listener maintains the
+ * line background colors.
+ * 
+ * @param index the index of the line
+ * @return the background color of the line at the given index.
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT when the index is invalid</li>
+ * </ul>
+ */
+public Color getLineBackground(int index) {
+	checkWidget();
+	if (index < 0 || index > content.getLineCount()) {
+		SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	}
+	return isListening(LineGetBackground) ? null : renderer.getLineBackground(index, null);
+}
+/**
+ * Returns the bullet of the line at the given index.
+ * 
+ * @param index the index of the line
+ * 
+ * @return the line bullet
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT when the index is invalid</li>
+ * </ul>
+ * 
+ * @since 3.2
+ */
+public Bullet getLineBullet(int index) {
+	checkWidget();
+	if (index < 0 || index > content.getLineCount()) {
+		SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	}
+	return isListening(LineGetStyle) ? null : renderer.getLineBullet(index, null);
+}
+/**
+ * Returns the line background data for the given line or null if 
+ * there is none.
+ * 
+ * @param lineOffset offset of the line start relative to the start
+ * 	of the content.
+ * @param line line to get line background data for
+ * @return line background data for the given line.
+ */
+StyledTextEvent getLineBackgroundData(int lineOffset, String line) {
+	return sendLineEvent(LineGetBackground, lineOffset, line);
+}
+/** 
+ * Gets the number of text lines.
+ *
+ * @return the number of lines in the widget
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getLineCount() {
+	checkWidget();
+	return content.getLineCount();
+}
+/**
+ * Returns the number of lines that can be completely displayed in the 
+ * widget client area.
+ *
+ * @return number of lines that can be completely displayed in the widget 
+ * 	client area.
+ */
+int getLineCountWhole() {
+	if (isFixedLineHeight()) {
+		int lineHeight = renderer.getLineHeight();
+		return lineHeight != 0 ? clientAreaHeight / lineHeight : 1;
+	}
+	return getBottomIndex() - topIndex + 1;
+}
+/**
+ * Returns the line delimiter used for entering new lines by key down
+ * or paste operation.
+ *
+ * @return line delimiter used for entering new lines by key down
+ * or paste operation.
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public String getLineDelimiter() {
+	checkWidget();
+	return content.getLineDelimiter();
+}
+/**
+ * Returns the line height.
+ * <p>
+ * Note: this API should not be used if a StyleRange attribute causes lines to 
+ * have different heights (i.e. different fonts, rise, etc).
+ * </p>
+ *
+ * @return line height in pixel.
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @see #getLineHeight(int)
+ */
+public int getLineHeight() {
+	checkWidget();
+	return renderer.getLineHeight();
+}
+/**
+ * Returns the line height at the given offset.
+ *
+ * @param offset the offset
+ *  
+ * @return line height in pixels
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *   <li>ERROR_INVALID_RANGE when the offset is outside the valid range (< 0 or > getCharCount())</li> 
+ * </ul> 
+ * 
+ * @since 3.2
+ */
+public int getLineHeight(int offset) {
+	checkWidget();
+	if (!(0 <= offset && offset <= content.getCharCount())) {
+		SWT.error(SWT.ERROR_INVALID_RANGE);
+	}
+	if (isFixedLineHeight()) {
+		return renderer.getLineHeight();
+	}
+	int lineIndex = content.getLineAtOffset(offset);
+	int lineOffset = content.getOffsetAtLine(lineIndex);
+	TextLayout layout = renderer.getTextLayout(lineIndex);
+	int lineInParagraph = layout.getLineIndex(Math.min(offset - lineOffset, layout.getText().length()));
+	int height = layout.getLineBounds(lineInParagraph).height;
+	renderer.disposeTextLayout(layout);
+	return height;
+}
+/**
+ * Returns the indentation of the line at the given index.
+ * 
+ * @param index the index of the line
+ * 
+ * @return the line indentation
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT when the index is invalid</li>
+ * </ul>
+ * 
+ * @see #getIndent()
+ * 
+ * @since 3.2
+ */
+public int getLineIndent(int index) {
+	checkWidget();
+	if (index < 0 || index > content.getLineCount()) {
+		SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	}
+	return isListening(LineGetStyle) ? 0 : renderer.getLineIndent(index, indent);
+}
+/**
+ * Returns whether the line at the given index is justified.
+ * 
+ * @param index the index of the line
+ * 
+ * @return whether the line is justified 
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT when the index is invalid</li>
+ * </ul>
+ * 
+ * @see #getJustify()
+ * 
+ * @since 3.2
+ */
+public boolean getLineJustify(int index) {
+	checkWidget();
+	if (index < 0 || index > content.getLineCount()) {
+		SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	}
+	return isListening(LineGetStyle) ? false : renderer.getLineJustify(index, justify);	
+}
+/**
+ * Returns the line spacing of the widget.
+ * 
+ * @return the line spacing
+ *  
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.2
+ */
+public int getLineSpacing() {
+	checkWidget();
+	return lineSpacing;
+}
+/**
+ * Returns the line style data for the given line or null if there is 
+ * none.
+ * <p>
+ * If there is a LineStyleListener but it does not set any styles, 
+ * the StyledTextEvent.styles field will be initialized to an empty 
+ * array.
+ * </p>
+ * 
+ * @param lineOffset offset of the line start relative to the start of 
+ * 	the content.
+ * @param line line to get line styles for
+ * @return line style data for the given line. Styles may start before 
+ * 	line start and end after line end
+ */
+StyledTextEvent getLineStyleData(int lineOffset, String line) {
+	return sendLineEvent(LineGetStyle, lineOffset, line);
+}
+/**
+ * Returns the top pixel, relative to the client area, of a given line.
+ * Clamps out of ranges index.
+ *  
+ * @param lineIndex the line index, the max value is lineCount. If
+ * lineIndex == lineCount it returns the bottom pixel of the last line.
+ * It means this function can be used to retrieve the bottom pixel of any line.
+ * 
+ * @return the top pixel of a given line index
+ * 
+ * @since 3.2
+ */
+public int getLinePixel(int lineIndex) {
+	checkWidget();
+	int lineCount = content.getLineCount();
+	lineIndex = Math.max(0, Math.min(lineCount, lineIndex));
+	if (isFixedLineHeight()) {
+		int lineHeight = renderer.getLineHeight();
+		return lineIndex * lineHeight - getVerticalScrollOffset() + topMargin;
+	}
+	if (lineIndex == topIndex) return topIndexY + topMargin;
+	int height = topIndexY;
+	if (lineIndex > topIndex) {
+		for (int i = topIndex; i < lineIndex; i++) {
+			height += renderer.getLineHeight(i);
+		}
+	} else {
+		for (int i = topIndex - 1; i >= lineIndex; i--) {
+			height -= renderer.getLineHeight(i);
+		}
+	}
+	return height + topMargin;
+}
+/**
+ * Returns the line index for a y, relative to the client area.
+ * The line index returned is always in the range 0..lineCount - 1.
+ * 
+ * @param y the y-coordinate pixel
+ * 
+ * @return the line index for a given y-coordinate pixel
+ *
+ * @since 3.2
+ */
+public int getLineIndex(int y) {
+	checkWidget();
+	y -= topMargin;
+	if (isFixedLineHeight()) {
+		int lineHeight = renderer.getLineHeight();
+		int lineIndex = (y + getVerticalScrollOffset()) / lineHeight;
+		int lineCount = content.getLineCount();
+		lineIndex = Math.max(0, Math.min(lineCount - 1, lineIndex));
+		return lineIndex;
+	}
+	if (y == topIndexY) return topIndex;
+	int line = topIndex;
+	if (y < topIndexY) {
+		while (y < topIndexY && line > 0) {
+			y += renderer.getLineHeight(--line);
+		}
+	} else {
+		int lineCount = content.getLineCount();
+		int lineHeight = renderer.getLineHeight(line);
+		while (y - lineHeight >= topIndexY && line < lineCount - 1) {
+			y -= lineHeight;
+			lineHeight = renderer.getLineHeight(++line);
+		}
+	}
+	return line;
+}
+/**
+ * Returns the x, y location of the upper left corner of the character 
+ * bounding box at the specified offset in the text. The point is 
+ * relative to the upper left corner of the widget client area.
+ *
+ * @param offset offset relative to the start of the content. 
+ * 	0 <= offset <= getCharCount()
+ * @return x, y location of the upper left corner of the character 
+ * 	bounding box at the specified offset in the text.
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *   <li>ERROR_INVALID_RANGE when the offset is outside the valid range (< 0 or > getCharCount())</li> 
+ * </ul>
+ */
+public Point getLocationAtOffset(int offset) {
+	checkWidget();
+	if (offset < 0 || offset > getCharCount()) {
+		SWT.error(SWT.ERROR_INVALID_RANGE);		
+	}
+	return getPointAtOffset(offset);
+}
+/**
+ * Returns the character offset of the first character of the given line.
+ *
+ * @param lineIndex index of the line, 0 based relative to the first 
+ * 	line in the content. 0 <= lineIndex < getLineCount(), except
+ * 	lineIndex may always be 0
+ * @return offset offset of the first character of the line, relative to
+ * 	the beginning of the document. The first character of the document is
+ *	at offset 0.  
+ *  When there are not any lines, getOffsetAtLine(0) is a valid call that 
+ * 	answers 0.
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *   <li>ERROR_INVALID_RANGE when the line index is outside the valid range (< 0 or >= getLineCount())</li> 
+ * </ul>
+ * @since 2.0
+ */
+public int getOffsetAtLine(int lineIndex) {
+	checkWidget();
+	if (lineIndex < 0 || 
+		(lineIndex > 0 && lineIndex >= content.getLineCount())) {
+		SWT.error(SWT.ERROR_INVALID_RANGE);		
+	}
+	return content.getOffsetAtLine(lineIndex);
+}
+/**
+ * Returns the offset of the character at the given location relative 
+ * to the first character in the document.
+ * <p>
+ * The return value reflects the character offset that the caret will
+ * be placed at if a mouse click occurred at the specified location.
+ * If the x coordinate of the location is beyond the center of a character
+ * the returned offset will be behind the character.
+ * </p>
+ *
+ * @param point the origin of character bounding box relative to 
+ * 	the origin of the widget client area.
+ * @return offset of the character at the given location relative 
+ * 	to the first character in the document.
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *   <li>ERROR_NULL_ARGUMENT when point is null</li>
+ *   <li>ERROR_INVALID_ARGUMENT when there is no character at the specified location</li>
+ * </ul>
+ */
+public int getOffsetAtLocation(Point point) {
+	checkWidget();
+	if (point == null) {
+		SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	}
+	int[] trailing = new int[1];
+	int offset = getOffsetAtPoint(point.x, point.y, trailing, true);
+	if (offset == -1) {
+		SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	}
+	return offset + trailing[0];
+}
+int getOffsetAtPoint(int x, int y) {
+	int lineIndex = getLineIndex(y);
+	y -= getLinePixel(lineIndex);
+	return getOffsetAtPoint(x, y, lineIndex);
+}
+/**
+ * Returns the offset at the specified x location in the specified line.
+ *
+ * @param x	x location of the mouse location
+ * @param line	line the mouse location is in
+ * @return the offset at the specified x location in the specified line,
+ * 	relative to the beginning of the document
+ */
+int getOffsetAtPoint(int x, int y, int lineIndex) {
+	TextLayout layout = renderer.getTextLayout(lineIndex);
+	x += horizontalScrollOffset - leftMargin;
+	int[] trailing = new int[1];	
+	int offsetInLine = layout.getOffset(x, y, trailing);
+	caretAlignment = OFFSET_LEADING;
+	if (trailing[0] != 0) {
+		int lineInParagraph = layout.getLineIndex(offsetInLine + trailing[0]);
+		int lineStart = layout.getLineOffsets()[lineInParagraph];
+		if (offsetInLine + trailing[0] == lineStart) {
+			offsetInLine += trailing[0];
+			caretAlignment = PREVIOUS_OFFSET_TRAILING;
+		} else {
+			String line = content.getLine(lineIndex);			
+			int level;
+			int offset = offsetInLine;
+			while (offset > 0 && Character.isDigit(line.charAt(offset))) offset--;
+			if (offset == 0 && Character.isDigit(line.charAt(offset))) {
+				level = isMirrored() ? 1 : 0;
+			} else {
+				level = layout.getLevel(offset) & 0x1;
+			}
+			offsetInLine += trailing[0];
+			int trailingLevel = layout.getLevel(offsetInLine) & 0x1;
+			if ((level ^ trailingLevel) != 0) {
+				caretAlignment = PREVIOUS_OFFSET_TRAILING;
+			} else {
+				caretAlignment = OFFSET_LEADING;
+			}
+		}
+	}
+	renderer.disposeTextLayout(layout);
+	return offsetInLine + content.getOffsetAtLine(lineIndex);
+}
+int getOffsetAtPoint(int x, int y, int[] trailing, boolean inTextOnly) {
+	if (inTextOnly && y + getVerticalScrollOffset() < 0 || x + horizontalScrollOffset < 0) {
+		return -1;
+	}
+	int bottomIndex = getPartialBottomIndex();
+	int height = getLinePixel(bottomIndex + 1);
+	if (inTextOnly && y > height) {
+		return -1;
+	}
+	int lineIndex = getLineIndex(y);
+	int lineOffset = content.getOffsetAtLine(lineIndex);
+	TextLayout layout = renderer.getTextLayout(lineIndex);	
+	x += horizontalScrollOffset - leftMargin ;
+	y -= getLinePixel(lineIndex);
+	int offset = layout.getOffset(x, y, trailing);
+	Rectangle rect = layout.getLineBounds(layout.getLineIndex(offset));
+	renderer.disposeTextLayout(layout);
+	if (inTextOnly && !(rect.x  <= x && x <=  rect.x + rect.width)) {
+		return -1;
+	}
+	return offset + lineOffset;
+}
+/**
+ * Returns the orientation of the receiver.
+ *
+ * @return the orientation style
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 2.1.2
+ */
+public int getOrientation () {
+	checkWidget();
+	return isMirrored() ? SWT.RIGHT_TO_LEFT : SWT.LEFT_TO_RIGHT;
+}
+/** 
+ * Returns the index of the last partially visible line.
+ *
+ * @return index of the last partially visible line.
+ */
+int getPartialBottomIndex() {
+	if (isFixedLineHeight()) {
+		int lineHeight = renderer.getLineHeight();
+		int partialLineCount = Compatibility.ceil(clientAreaHeight, lineHeight);
+		return Math.max(0, Math.min(content.getLineCount(), topIndex + partialLineCount) - 1);
+	}
+	return getLineIndex(clientAreaHeight - bottomMargin);
+}
+/** 
+ * Returns the index of the first partially visible line.
+ *
+ * @return index of the first partially visible line.
+ */
+int getPartialTopIndex() {
+	if (isFixedLineHeight()) {
+		int lineHeight = renderer.getLineHeight();
+		return getVerticalScrollOffset() / lineHeight;
+	}
+	return topIndexY <= 0 ? topIndex : topIndex - 1;
+}
+/**
+ * Returns the content in the specified range using the platform line 
+ * delimiter to separate lines.
+ *
+ * @param writer the TextWriter to write line text into
+ * @return the content in the specified range using the platform line 
+ * 	delimiter to separate lines as written by the specified TextWriter.
+ */
+String getPlatformDelimitedText(TextWriter writer) {
+	int end = writer.getStart() + writer.getCharCount();
+	int startLine = content.getLineAtOffset(writer.getStart());
+	int endLine = content.getLineAtOffset(end);
+	String endLineText = content.getLine(endLine);
+	int endLineOffset = content.getOffsetAtLine(endLine);
+	
+	for (int i = startLine; i <= endLine; i++) {
+		writer.writeLine(content.getLine(i), content.getOffsetAtLine(i));
+		if (i < endLine) {
+			writer.writeLineDelimiter(PlatformLineDelimiter);
+		}
+	}
+	if (end > endLineOffset + endLineText.length()) {
+		writer.writeLineDelimiter(PlatformLineDelimiter);
+	}
+	writer.close();
+	return writer.toString();
+}
+/**
+ * Returns all the ranges of text that have an associated StyleRange.
+ * Returns an empty array if a LineStyleListener has been set. 
+ * Should not be called if a LineStyleListener has been set since the 
+ * listener maintains the styles.
+ * <p>
+ * The ranges array contains start and length pairs.  Each pair refers to
+ * the corresponding style in the styles array.  For example, the pair
+ * that starts at ranges[n] with length ranges[n+1] uses the style
+ * at styles[n/2] returned by <code>getStyleRanges(int, int, boolean)</code>.
+ * </p>
+ * 
+ * @return the ranges or an empty array if a LineStyleListener has been set.
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.2
+ * 
+ * @see #getStyleRanges(boolean)
+ */
+public int[] getRanges() {
+	checkWidget();
+	if (!isListening(LineGetStyle)) {
+		int[] ranges = renderer.getRanges(0, content.getCharCount());
+		if (ranges != null) return ranges;
+	}
+	return new int[0];
+}
+/**
+ * Returns the ranges of text that have an associated StyleRange.
+ * Returns an empty array if a LineStyleListener has been set. 
+ * Should not be called if a LineStyleListener has been set since the 
+ * listener maintains the styles.
+ * <p>
+ * The ranges array contains start and length pairs.  Each pair refers to
+ * the corresponding style in the styles array.  For example, the pair
+ * that starts at ranges[n] with length ranges[n+1] uses the style
+ * at styles[n/2] returned by <code>getStyleRanges(int, int, boolean)</code>.
+ * </p>
+ *
+ * @param start the start offset of the style ranges to return
+ * @param length the number of style ranges to return
+ * 
+ * @return the ranges or an empty array if a LineStyleListener has been set.
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *   <li>ERROR_INVALID_RANGE if start or length are outside the widget content</li> 
+ * </ul> 
+ * 
+ * @since 3.2
+ * 
+ * @see #getStyleRanges(int, int, boolean)
+ */
+public int[] getRanges(int start, int length) {
+	checkWidget();
+	int contentLength = getCharCount();
+	int end = start + length;
+	if (start > end || start < 0 || end > contentLength) {
+		SWT.error(SWT.ERROR_INVALID_RANGE);
+	}
+	if (!isListening(LineGetStyle)) {
+		int[] ranges = renderer.getRanges(start, length);
+		if (ranges != null) return ranges;
+	}
+	return new int[0];
+}
+/**
+ * Returns the selection.
+ * <p>
+ * Text selections are specified in terms of caret positions.  In a text
+ * widget that contains N characters, there are N+1 caret positions, 
+ * ranging from 0..N
+ * </p>
+ *
+ * @return start and end of the selection, x is the offset of the first 
+ * 	selected character, y is the offset after the last selected character.
+ *  The selection values returned are visual (i.e., x will always always be   
+ *  <= y).  To determine if a selection is right-to-left (RtoL) vs. left-to-right 
+ *  (LtoR), compare the caretOffset to the start and end of the selection 
+ *  (e.g., caretOffset == start of selection implies that the selection is RtoL).
+ * @see #getSelectionRange
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Point getSelection() {
+	checkWidget();
+	return new Point(selection.x, selection.y);
+}
+/**
+ * Returns the selection.
+ *
+ * @return start and length of the selection, x is the offset of the 
+ * 	first selected character, relative to the first character of the 
+ * 	widget content. y is the length of the selection. 
+ *  The selection values returned are visual (i.e., length will always always be   
+ *  positive).  To determine if a selection is right-to-left (RtoL) vs. left-to-right 
+ *  (LtoR), compare the caretOffset to the start and end of the selection 
+ *  (e.g., caretOffset == start of selection implies that the selection is RtoL).
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Point getSelectionRange() {
+	checkWidget();
+	return new Point(selection.x, selection.y - selection.x);
+}
+/**
+ * Returns the receiver's selection background color.
+ *
+ * @return the selection background color
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @since 2.1
+ */
+public Color getSelectionBackground() {
+	checkWidget();
+	if (selectionBackground == null) {
+		return getDisplay().getSystemColor(SWT.COLOR_LIST_SELECTION);
+	}
+	return selectionBackground;
+}
+/**
+ * Gets the number of selected characters.
+ *
+ * @return the number of selected characters.
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getSelectionCount() {
+	checkWidget();
+	return getSelectionRange().y;
+}
+/**
+ * Returns the receiver's selection foreground color.
+ *
+ * @return the selection foreground color
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @since 2.1
+ */
+public Color getSelectionForeground() {
+	checkWidget();
+	if (selectionForeground == null) {
+		return getDisplay().getSystemColor(SWT.COLOR_LIST_SELECTION_TEXT);
+	}
+	return selectionForeground;
+}
+/**
+ * Returns the selected text.
+ *
+ * @return selected text, or an empty String if there is no selection.
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public String getSelectionText() {
+	checkWidget();
+	return content.getTextRange(selection.x, selection.y - selection.x);
+}
+public int getStyle() {
+	int style = super.getStyle();
+	style &= ~(SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT | SWT.MIRRORED);
+	if (isMirrored()) {
+		style |= SWT.RIGHT_TO_LEFT | SWT.MIRRORED;
+	} else {
+		style |= SWT.LEFT_TO_RIGHT;
+	}
+	return style;
+}
+
+/**
+ * Returns the text segments that should be treated as if they 
+ * had a different direction than the surrounding text.
+ *
+ * @param lineOffset offset of the first character in the line. 
+ * 	0 based from the beginning of the document.
+ * @param line text of the line to specify bidi segments for
+ * @return text segments that should be treated as if they had a
+ * 	different direction than the surrounding text. Only the start 
+ * 	index of a segment is specified, relative to the start of the 
+ * 	line. Always starts with 0 and ends with the line length. 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the segment indices returned 
+ * 		by the listener do not start with 0, are not in ascending order,
+ * 		exceed the line length or have duplicates</li>
+ * </ul>
+ */
+int [] getBidiSegments(int lineOffset, String line) {
+	if (!isBidi()) return null;
+	if (!isListening(LineGetSegments)) {
+		return getBidiSegmentsCompatibility(line, lineOffset);
+	}
+	StyledTextEvent event = sendLineEvent(LineGetSegments, lineOffset, line);
+	int lineLength = line.length();
+	int[] segments;
+	if (event == null || event.segments == null || event.segments.length == 0) {
+		segments = new int[] {0, lineLength};
+	} else {
+		int segmentCount = event.segments.length;
+		
+		// test segment index consistency
+		if (event.segments[0] != 0) {
+			SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+		} 	
+		for (int i = 1; i < segmentCount; i++) {
+			if (event.segments[i] <= event.segments[i - 1] || event.segments[i] > lineLength) {
+				SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+			} 	
+		}
+		// ensure that last segment index is line end offset
+		if (event.segments[segmentCount - 1] != lineLength) {
+			segments = new int[segmentCount + 1];
+			System.arraycopy(event.segments, 0, segments, 0, segmentCount);
+			segments[segmentCount] = lineLength;
+		} else {
+			segments = event.segments;
+		}
+	}
+	return segments;
+}
+/**
+ * @see #getBidiSegments
+ * Supports deprecated setBidiColoring API. Remove when API is removed.
+ */
+int [] getBidiSegmentsCompatibility(String line, int lineOffset) {
+	int lineLength = line.length();
+	if (!bidiColoring) {
+		return new int[] {0, lineLength};
+	}
+	StyleRange [] styles = null;
+	StyledTextEvent event = getLineStyleData(lineOffset, line);
+	if (event != null) {
+		styles = event.styles;
+	} else {
+		styles = renderer.getStyleRanges(lineOffset, lineLength, true);
+	}
+	if (styles == null || styles.length == 0) {
+		return new int[] {0, lineLength};
+	}
+	int k=0, count = 1;
+	while (k < styles.length && styles[k].start == 0 && styles[k].length == lineLength) {
+		k++;
+	}
+	int[] offsets = new int[(styles.length - k) * 2 + 2];
+	for (int i = k; i < styles.length; i++) {
+		StyleRange style = styles[i];
+		int styleLineStart = Math.max(style.start - lineOffset, 0);
+		int styleLineEnd = Math.max(style.start + style.length - lineOffset, styleLineStart);
+		styleLineEnd = Math.min (styleLineEnd, line.length ());
+		if (i > 0 && count > 1 &&
+			((styleLineStart >= offsets[count-2] && styleLineStart <= offsets[count-1]) ||
+			 (styleLineEnd >= offsets[count-2] && styleLineEnd <= offsets[count-1])) &&
+			 style.similarTo(styles[i-1])) {
+			offsets[count-2] = Math.min(offsets[count-2], styleLineStart);
+			offsets[count-1] = Math.max(offsets[count-1], styleLineEnd);
+		} else {
+			if (styleLineStart > offsets[count - 1]) {
+				offsets[count] = styleLineStart;
+				count++;
+			}
+			offsets[count] = styleLineEnd;
+			count++;
+		}
+	}
+	// add offset for last non-colored segment in line, if any
+	if (lineLength > offsets[count-1]) {
+		offsets [count] = lineLength;
+		count++;
+	}
+	if (count == offsets.length) {
+		return offsets;
+	}
+	int [] result = new int [count];
+	System.arraycopy (offsets, 0, result, 0, count);
+	return result;
+}
+/**
+ * Returns the style range at the given offset.
+ * <p>
+ * Returns null if a LineStyleListener has been set or if a style is not set
+ * for the offset. 
+ * Should not be called if a LineStyleListener has been set since the 
+ * listener maintains the styles.
+ * </p>
+ *
+ * @param offset the offset to return the style for. 
+ * 	0 <= offset < getCharCount() must be true.
+ * @return a StyleRange with start == offset and length == 1, indicating
+ * 	the style at the given offset. null if a LineStyleListener has been set 
+ * 	or if a style is not set for the given offset.
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *   <li>ERROR_INVALID_ARGUMENT when the offset is invalid</li>
+ * </ul>
+ */
+public StyleRange getStyleRangeAtOffset(int offset) {
+	checkWidget();
+	if (offset < 0 || offset >= getCharCount()) {
+		SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	}
+	if (!isListening(LineGetStyle)) {
+		StyleRange[] ranges = renderer.getStyleRanges(offset, 1, true);
+		if (ranges != null) return ranges[0];
+	}
+	return null;
+}
+/**
+ * Returns the styles.
+ * <p>
+ * Returns an empty array if a LineStyleListener has been set. 
+ * Should not be called if a LineStyleListener has been set since the 
+ * listener maintains the styles.
+ * <p></p>
+ * Note: Because a StyleRange includes the start and length, the
+ * same instance cannot occur multiple times in the array of styles.
+ * If the same style attributes, such as font and color, occur in
+ * multiple StyleRanges, <code>getStyleRanges(boolean)</code>
+ * can be used to get the styles without the ranges.
+ * </p>
+ *
+ * @return the styles or an empty array if a LineStyleListener has been set.
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see #getStyleRanges(boolean)
+ */
+public StyleRange[] getStyleRanges() {
+	checkWidget();
+	return getStyleRanges(0, content.getCharCount(), true);
+}
+/**
+ * Returns the styles.
+ * <p>
+ * Returns an empty array if a LineStyleListener has been set. 
+ * Should not be called if a LineStyleListener has been set since the 
+ * listener maintains the styles.
+ * </p><p>
+ * Note: When <code>includeRanges</code> is true, the start and length
+ * fields of each StyleRange will be valid, however the StyleRange
+ * objects may need to be cloned. When <code>includeRanges</code> is
+ * false, <code>getRanges(int, int)</code> can be used to get the
+ * associated ranges.
+ * </p>
+ * 
+ * @param includeRanges whether the start and length field of the StyleRanges should be set.
+ * 
+ * @return the styles or an empty array if a LineStyleListener has been set.
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.2
+ * 
+ * @see #getRanges(int, int)
+ * @see #setStyleRanges(int[], StyleRange[])
+ */
+public StyleRange[] getStyleRanges(boolean includeRanges) {
+	checkWidget();
+	return getStyleRanges(0, content.getCharCount(), includeRanges);
+}
+/**
+ * Returns the styles for the given text range.
+ * <p>
+ * Returns an empty array if a LineStyleListener has been set. 
+ * Should not be called if a LineStyleListener has been set since the 
+ * listener maintains the styles.
+ * </p><p>
+ * Note: Because the StyleRange includes the start and length, the
+ * same instance cannot occur multiple times in the array of styles.
+ * If the same style attributes, such as font and color, occur in
+ * multiple StyleRanges, <code>getStyleRanges(int, int, boolean)</code>
+ * can be used to get the styles without the ranges.
+ * </p>
+ * @param start the start offset of the style ranges to return
+ * @param length the number of style ranges to return
+ *
+ * @return the styles or an empty array if a LineStyleListener has 
+ *  been set.  The returned styles will reflect the given range.  The first 
+ *  returned <code>StyleRange</code> will have a starting offset >= start 
+ *  and the last returned <code>StyleRange</code> will have an ending 
+ *  offset <= start + length - 1
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *   <li>ERROR_INVALID_RANGE when start and/or end are outside the widget content</li> 
+ * </ul>
+ * 
+ * @see #getStyleRanges(int, int, boolean)
+ * 
+ * @since 3.0
+ */
+public StyleRange[] getStyleRanges(int start, int length) {
+	checkWidget();
+	return getStyleRanges(start, length, true);
+}
+/**
+ * Returns the styles for the given text range.
+ * <p>
+ * Returns an empty array if a LineStyleListener has been set. 
+ * Should not be called if a LineStyleListener has been set since the 
+ * listener maintains the styles.
+ * </p><p>
+ * Note: When <code>includeRanges</code> is true, the start and length
+ * fields of each StyleRange will be valid, however the StyleRange
+ * objects may need to be cloned. When <code>includeRanges</code> is
+ * false, <code>getRanges(int, int)</code> can be used to get the
+ * associated ranges.
+ * </p>
+ * 
+ * @param start the start offset of the style ranges to return
+ * @param length the number of style ranges to return
+ * @param includeRanges whether the start and length field of the StyleRanges should be set.
+ *
+ * @return the styles or an empty array if a LineStyleListener has 
+ *  been set.  The returned styles will reflect the given range.  The first 
+ *  returned <code>StyleRange</code> will have a starting offset >= start 
+ *  and the last returned <code>StyleRange</code> will have an ending 
+ *  offset <= start + length - 1
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *   <li>ERROR_INVALID_RANGE when start and/or end are outside the widget content</li> 
+ * </ul>
+ * 
+ * @since 3.2
+ * 
+ * @see #getRanges(int, int)
+ * @see #setStyleRanges(int[], StyleRange[])
+ */
+public StyleRange[] getStyleRanges(int start, int length, boolean includeRanges) {
+	checkWidget();
+	int contentLength = getCharCount();
+	int end = start + length;
+	if (start > end || start < 0 || end > contentLength) {
+		SWT.error(SWT.ERROR_INVALID_RANGE);
+	}
+	if (!isListening(LineGetStyle)) {
+		StyleRange[] ranges = renderer.getStyleRanges(start, length, includeRanges);
+		if (ranges != null) return ranges;
+	}
+	return new StyleRange[0];
+}
+/**
+ * Returns the tab width measured in characters.
+ *
+ * @return tab width measured in characters
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getTabs() {
+	checkWidget();
+	return tabLength;
+}
+/**
+ * Returns a copy of the widget content.
+ *
+ * @return copy of the widget content
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public String getText() {
+	checkWidget();
+	return content.getTextRange(0, getCharCount());
+}
+/**
+ * Returns the widget content between the two offsets.
+ *
+ * @param start offset of the first character in the returned String
+ * @param end offset of the last character in the returned String 
+ * @return widget content starting at start and ending at end
+ * @see #getTextRange(int,int)
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *   <li>ERROR_INVALID_RANGE when start and/or end are outside the widget content</li> 
+ * </ul>
+ */
+public String getText(int start, int end) {
+	checkWidget();
+	int contentLength = getCharCount();
+	if (start < 0 || start >= contentLength || end < 0 || end >= contentLength || start > end) {
+		SWT.error(SWT.ERROR_INVALID_RANGE);
+	}
+	return content.getTextRange(start, end - start + 1);
+}
+/**
+ * Returns the smallest bounding rectangle that includes the characters between two offsets.
+ *
+ * @param start offset of the first character included in the bounding box
+ * @param end offset of the last character included in the bounding box 
+ * @return bounding box of the text between start and end
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *   <li>ERROR_INVALID_RANGE when start and/or end are outside the widget content</li> 
+ * </ul>
+ * @since 3.1
+ */
+public Rectangle getTextBounds(int start, int end) {
+	checkWidget();	
+	int contentLength = getCharCount();	
+	if (start < 0 || start >= contentLength || end < 0 || end >= contentLength || start > end) {
+		SWT.error(SWT.ERROR_INVALID_RANGE);
+	}
+	int lineStart = content.getLineAtOffset(start);
+	int lineEnd = content.getLineAtOffset(end);
+	Rectangle rect;
+	int y = getLinePixel(lineStart);
+	int height = 0;
+	int left = 0x7fffffff, right = 0;
+	for (int i = lineStart; i <= lineEnd; i++) {
+		int lineOffset = content.getOffsetAtLine(i);		
+		TextLayout layout = renderer.getTextLayout(i);
+		int length = layout.getText().length();
+		if (length > 0) {
+			if (i == lineStart) {
+				if (i == lineEnd) {
+					rect = layout.getBounds(start - lineOffset, end - lineOffset);
+				} else {
+					rect = layout.getBounds(start - lineOffset, length);
+				}
+				y += rect.y;
+			} else if (i == lineEnd) {
+				rect = layout.getBounds(0, end - lineOffset);
+			} else {
+				rect = layout.getBounds();
+			}
+			left = Math.min(left, rect.x);
+			right = Math.max(right, rect.x + rect.width);
+			height += rect.height;
+		} else {
+			height += renderer.getLineHeight();
+		}
+		renderer.disposeTextLayout(layout);
+	}
+	rect = new Rectangle (left, y, right-left, height);
+	rect.x += leftMargin - horizontalScrollOffset;
+	return rect;
+}
+/**
+ * Returns the widget content starting at start for length characters.
+ *
+ * @param start offset of the first character in the returned String
+ * @param length number of characters to return 
+ * @return widget content starting at start and extending length characters.
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *   <li>ERROR_INVALID_RANGE when start and/or length are outside the widget content</li> 
+ * </ul>
+ */
+public String getTextRange(int start, int length) {
+	checkWidget();
+	int contentLength = getCharCount();
+	int end = start + length;
+	if (start > end || start < 0 || end > contentLength) {
+		SWT.error(SWT.ERROR_INVALID_RANGE);
+	}	
+	return content.getTextRange(start, length);
+}
+/**
+ * Returns the maximum number of characters that the receiver is capable of holding.
+ * 
+ * @return the text limit
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getTextLimit() {
+	checkWidget();
+	return textLimit;
+}
+/**
+ * Gets the top index.
+ * <p>
+ * The top index is the index of the fully visible line that is currently 
+ * at the top of the widget or the topmost partially visible line if no line is fully visible. 
+ * The top index changes when the widget is scrolled. Indexing is zero based.
+ * </p>
+ *
+ * @return the index of the top line
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getTopIndex() {
+	checkWidget();
+	return topIndex;
+}
+/**
+ * Gets the top pixel.
+ * <p>
+ * The top pixel is the pixel position of the line that is 
+ * currently at the top of the widget. The text widget can be scrolled by pixels 
+ * by dragging the scroll thumb so that a partial line may be displayed at the top 
+ * the widget.  The top pixel changes when the widget is scrolled.  The top pixel 
+ * does not include the widget trimming.
+ * </p>
+ *
+ * @return pixel position of the top line
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getTopPixel() {
+	checkWidget();
+	return getVerticalScrollOffset();
+}
+/** 
+ * Returns the vertical scroll increment.
+ *
+ * @return vertical scroll increment.
+ */
+int getVerticalIncrement() {
+	return renderer.getLineHeight();
+}
+int getVerticalScrollOffset() {
+	if (verticalScrollOffset == -1) {
+		renderer.calculate(0, topIndex);
+		int height = 0;
+		for (int i = 0; i < topIndex; i++) {
+			height += renderer.getLineHeight(i);
+		}
+		height -= topIndexY;
+		verticalScrollOffset = height;
+	}
+	return verticalScrollOffset;
+}
+int getVisualLineIndex(TextLayout layout, int offsetInLine) {
+	int lineIndex = layout.getLineIndex(offsetInLine);
+	int[] offsets = layout.getLineOffsets();
+	if (lineIndex != 0 && offsetInLine == offsets[lineIndex]) {
+		int lineY = layout.getLineBounds(lineIndex).y;
+		int caretY = getCaret().getLocation().y - topMargin - getLinePixel(getCaretLine());
+		if (lineY > caretY) lineIndex--;
+ 	}
+	return lineIndex;
+}
+int getCaretDirection() {
+	if (!isBidiCaret()) return SWT.DEFAULT;
+	if (ime.getCompositionOffset() != -1) return SWT.DEFAULT;
+	if (!updateCaretDirection && caretDirection != SWT.NULL) return caretDirection;
+	updateCaretDirection = false;
+	int caretLine = getCaretLine();
+	int lineOffset = content.getOffsetAtLine(caretLine);
+	String line = content.getLine(caretLine);
+	int offset = caretOffset - lineOffset;
+	int lineLength = line.length();
+	if (lineLength == 0) return isMirrored() ? SWT.RIGHT : SWT.LEFT;
+	if (caretAlignment == PREVIOUS_OFFSET_TRAILING && offset > 0) offset--;
+	if (offset == lineLength && offset > 0) offset--;
+	while (offset > 0 && Character.isDigit(line.charAt(offset))) offset--;
+	if (offset == 0 && Character.isDigit(line.charAt(offset))) {
+		return isMirrored() ? SWT.RIGHT : SWT.LEFT;
+	}
+	TextLayout layout = renderer.getTextLayout(caretLine);
+	int level = layout.getLevel(offset);
+	renderer.disposeTextLayout(layout);
+	return ((level & 1) != 0) ? SWT.RIGHT : SWT.LEFT;
+}
+/*
+ * Returns the index of the line the caret is on.
+ */
+int getCaretLine() {
+	return content.getLineAtOffset(caretOffset);
+}
+int getWrapWidth () {
+	if (wordWrap && !isSingleLine()) {
+		int width = clientAreaWidth - leftMargin - rightMargin - getCaretWidth();
+		return width > 0 ? width : 1;
+	}
+	return -1;
+}
+int getWordNext (int offset, int movement) {
+	int newOffset, lineOffset;
+	String lineText;
+	if (offset >= getCharCount()) {
+		newOffset = offset;
+		int lineIndex = content.getLineCount() - 1;
+		lineOffset = content.getOffsetAtLine(lineIndex);
+		lineText = content.getLine(lineIndex);
+	} else {
+		int lineIndex = content.getLineAtOffset(offset);
+		lineOffset = content.getOffsetAtLine(lineIndex);
+		lineText = content.getLine(lineIndex);
+		int lineLength = lineText.length();
+		if (offset == lineOffset + lineLength) {
+			newOffset = content.getOffsetAtLine(lineIndex + 1);
+		} else {
+			TextLayout layout = renderer.getTextLayout(lineIndex);
+			newOffset = lineOffset + layout.getNextOffset(offset - lineOffset, movement);
+			renderer.disposeTextLayout(layout);
+		}
+	}
+	return sendWordBoundaryEvent(WordNext, movement, offset, newOffset, lineText, lineOffset);
+}
+int getWordPrevious(int offset, int movement) {
+	int newOffset, lineOffset;
+	String lineText;
+	if (offset <= 0) {
+		newOffset = 0;
+		int lineIndex = content.getLineAtOffset(newOffset);
+		lineOffset = content.getOffsetAtLine(lineIndex);
+		lineText = content.getLine(lineIndex);
+	} else {
+		int lineIndex = content.getLineAtOffset(offset);
+		lineOffset = content.getOffsetAtLine(lineIndex);
+		lineText = content.getLine(lineIndex);
+		if (offset == lineOffset) {
+			String nextLineText = content.getLine(lineIndex - 1);
+			int nextLineOffset = content.getOffsetAtLine(lineIndex - 1); 
+			newOffset = nextLineOffset + nextLineText.length();
+		} else {
+			TextLayout layout = renderer.getTextLayout(lineIndex);
+			newOffset = lineOffset + layout.getPreviousOffset(offset - lineOffset, movement);
+			renderer.disposeTextLayout(layout); 
+		}
+	}
+	return sendWordBoundaryEvent(WordPrevious, movement, offset, newOffset, lineText, lineOffset);
+}
+/**
+ * Returns whether the widget wraps lines.
+ *
+ * @return true if widget wraps lines, false otherwise
+ * @since 2.0
+ */
+public boolean getWordWrap() {
+	checkWidget();
+	return wordWrap;
+}
+/** 
+ * Returns the location of the given offset.
+ * <p>
+ * <b>NOTE:</b> Does not return correct values for true italic fonts (vs. slanted fonts).
+ * </p>
+ *
+ * @return location of the character at the given offset in the line.
+ */
+Point getPointAtOffset(int offset) {
+	int lineIndex = content.getLineAtOffset(offset);
+	String line = content.getLine(lineIndex);
+	int lineOffset = content.getOffsetAtLine(lineIndex);
+	int offsetInLine = offset - lineOffset;
+	int lineLength = line.length();
+	if (lineIndex < content.getLineCount() - 1) {
+		int endLineOffset = content.getOffsetAtLine(lineIndex + 1) - 1;
+		if (lineLength < offsetInLine && offsetInLine <= endLineOffset) {
+			offsetInLine = lineLength;
+		}
+	}
+	Point point;
+	TextLayout layout = renderer.getTextLayout(lineIndex);
+	if (lineLength != 0  && offsetInLine <= lineLength) {
+		if (offsetInLine == lineLength) {
+			point = layout.getLocation(offsetInLine - 1, true);
+		} else {
+			switch (caretAlignment) {
+				case OFFSET_LEADING:
+					point = layout.getLocation(offsetInLine, false);
+					break;
+				case PREVIOUS_OFFSET_TRAILING:
+				default:
+					if (offsetInLine == 0) {
+						point = layout.getLocation(offsetInLine, false);
+					} else {
+						point = layout.getLocation(offsetInLine - 1, true);
+					}
+					break;
+			}
+		}
+	} else {
+		point = new Point(layout.getIndent(), 0);
+	}
+	renderer.disposeTextLayout(layout);
+	point.x += leftMargin - horizontalScrollOffset;
+	point.y += getLinePixel(lineIndex);
+	return point;
+}
+/** 
+ * Inserts a string.  The old selection is replaced with the new text.  
+ *
+ * @param string the string
+ * @see #replaceTextRange(int,int,String)
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT when string is null</li>
+ * </ul>
+ */
+public void insert(String string) {
+	checkWidget();
+	if (string == null) {
+		SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	}
+	Point sel = getSelectionRange();
+	replaceTextRange(sel.x, sel.y, string);
+}
+/**
+ * Creates content change listeners and set the default content model.
+ */
+void installDefaultContent() {
+	textChangeListener = new TextChangeListener() {
+		public void textChanging(TextChangingEvent event) {
+			handleTextChanging(event);
+		}
+		public void textChanged(TextChangedEvent event) {
+			handleTextChanged(event);
+		}
+		public void textSet(TextChangedEvent event) {
+			handleTextSet(event);
+		}
+	};
+	content = new DefaultContent();
+	content.addTextChangeListener(textChangeListener);
+}
+/** 
+ * Adds event listeners
+ */
+void installListeners() {
+	ScrollBar verticalBar = getVerticalBar();
+	ScrollBar horizontalBar = getHorizontalBar();
+	
+	listener = new Listener() {
+		public void handleEvent(Event event) {
+			switch (event.type) {
+				case SWT.Dispose: handleDispose(event); break;
+				case SWT.KeyDown: handleKeyDown(event); break;
+				case SWT.KeyUp: handleKeyUp(event); break;
+				case SWT.MouseDown: handleMouseDown(event); break;
+				case SWT.MouseUp: handleMouseUp(event); break;
+				case SWT.MouseMove: handleMouseMove(event); break;
+				case SWT.Paint: handlePaint(event); break;
+				case SWT.Resize: handleResize(event); break;
+				case SWT.Traverse: handleTraverse(event); break;
+			}
+		}		
+	};
+	addListener(SWT.Dispose, listener);
+	addListener(SWT.KeyDown, listener);
+	addListener(SWT.KeyUp, listener);
+	addListener(SWT.MouseDown, listener);
+	addListener(SWT.MouseUp, listener);
+	addListener(SWT.MouseMove, listener);
+	addListener(SWT.Paint, listener);
+	addListener(SWT.Resize, listener);
+	addListener(SWT.Traverse, listener);
+	ime.addListener(SWT.ImeComposition, new Listener() {
+		public void handleEvent(Event event) {
+			switch (event.detail) {
+				case SWT.COMPOSITION_SELECTION: handleCompositionSelection(event); break;
+				case SWT.COMPOSITION_CHANGED: handleCompositionChanged(event); break;
+				case SWT.COMPOSITION_OFFSET: handleCompositionOffset(event); break;
+			}
+		}
+	});
+	if (verticalBar != null) {
+		verticalBar.addListener(SWT.Selection, new Listener() {
+			public void handleEvent(Event event) {
+				handleVerticalScroll(event);
+			}
+		});
+	}
+	if (horizontalBar != null) {
+		horizontalBar.addListener(SWT.Selection, new Listener() {
+			public void handleEvent(Event event) {
+				handleHorizontalScroll(event);
+			}
+		});
+	}
+}
+void internalRedrawRange(int start, int length) {
+	if (length <= 0) return;
+	int end = start + length;
+	int startLine = content.getLineAtOffset(start);
+	int endLine = content.getLineAtOffset(end);
+	int partialBottomIndex = getPartialBottomIndex();
+	int partialTopIndex = getPartialTopIndex();
+	if (startLine > partialBottomIndex || endLine < partialTopIndex) {
+		return;
+	}
+	if (partialTopIndex > startLine) {
+		startLine = partialTopIndex;
+		start = 0;
+	} else {
+		start -= content.getOffsetAtLine(startLine);
+	}
+	if (partialBottomIndex < endLine) {
+		endLine = partialBottomIndex + 1;
+		end = 0;
+	} else {
+		end -= content.getOffsetAtLine(endLine);
+	}
+
+	TextLayout layout = renderer.getTextLayout(startLine);
+	int lineX = leftMargin - horizontalScrollOffset, startLineY = getLinePixel(startLine);
+	int[] offsets = layout.getLineOffsets();
+	int startIndex = layout.getLineIndex(Math.min(start, layout.getText().length()));
+	
+	/* Redraw end of line before start line if wrapped and start offset is first char */
+	if (wordWrap && startIndex > 0 && offsets[startIndex] == start) {
+		Rectangle rect = layout.getLineBounds(startIndex - 1);
+		rect.x = rect.width;
+		rect.width = clientAreaWidth - rightMargin - rect.x;
+		rect.x += lineX;
+		rect.y += startLineY;
+		super.redraw(rect.x, rect.y, rect.width, rect.height, false);
+	}
+	
+	if (startLine == endLine) {
+		int endIndex = layout.getLineIndex(Math.min(end, layout.getText().length()));
+		if (startIndex == endIndex) {
+			/* Redraw rect between start and end offset if start and end offsets are in same wrapped line */
+			Rectangle rect = layout.getBounds(start, end - 1);
+			rect.x += lineX;
+			rect.y += startLineY;
+			super.redraw(rect.x, rect.y, rect.width, rect.height, false);
+			renderer.disposeTextLayout(layout);
+			return;
+		}
+	}
+
+	/* Redraw start line from the start offset to the end of client area */
+	Rectangle startRect = layout.getBounds(start, offsets[startIndex + 1] - 1);
+	if (startRect.height == 0) {
+		Rectangle bounds = layout.getLineBounds(startIndex);
+		startRect.x = bounds.width;
+		startRect.y = bounds.y;
+		startRect.height = bounds.height;
+	}
+	startRect.x += lineX;
+	startRect.y += startLineY;
+	startRect.width = clientAreaWidth - rightMargin - startRect.x;
+	super.redraw(startRect.x, startRect.y, startRect.width, startRect.height, false);
+
+	/* Redraw end line from the beginning of the line to the end offset */
+	if (startLine != endLine) {
+		renderer.disposeTextLayout(layout);
+		layout = renderer.getTextLayout(endLine);
+		offsets = layout.getLineOffsets();
+	}
+	int endIndex = layout.getLineIndex(Math.min(end, layout.getText().length()));
+	Rectangle endRect = layout.getBounds(offsets[endIndex], end - 1);
+	if (endRect.height == 0) {
+		Rectangle bounds = layout.getLineBounds(endIndex);
+		endRect.y = bounds.y;
+		endRect.height = bounds.height;
+	}
+	endRect.x += lineX;
+	endRect.y += getLinePixel(endLine);
+	super.redraw(endRect.x, endRect.y, endRect.width, endRect.height, false);
+	renderer.disposeTextLayout(layout);
+
+	/* Redraw all lines in between start and end line */
+	int y = startRect.y + startRect.height;
+	if (endRect.y > y) {
+		super.redraw(leftMargin, y, clientAreaWidth - rightMargin - leftMargin, endRect.y - y, false);
+	}
+}
+void handleCompositionOffset (Event event) {
+	int[] trailing = new int [1];
+	event.index = getOffsetAtPoint(event.x, event.y, trailing, true);
+	event.count = trailing[0];
+}
+void handleCompositionSelection (Event event) {
+	event.start = selection.x;
+	event.end = selection.y;
+	event.text = getSelectionText();
+}
+void handleCompositionChanged(Event event) {
+	String text = event.text;
+	int start = event.start;
+	int end = event.end;
+	int length = text.length();
+	if (length == ime.getCommitCount()) {
+		content.replaceTextRange(start, end - start, "");
+		caretOffset = ime.getCompositionOffset();
+		caretWidth = 0;
+		caretDirection = SWT.NULL;
+	} else {
+		content.replaceTextRange(start, end - start, text);
+		caretOffset = ime.getCaretOffset();
+		if (ime.getWideCaret()) {
+			start = ime.getCompositionOffset();
+			int lineIndex = getCaretLine();
+			int lineOffset = content.getOffsetAtLine(lineIndex);
+			TextLayout layout = renderer.getTextLayout(lineIndex);	
+			caretWidth = layout.getBounds(start - lineOffset, start + length - 1 - lineOffset).width;
+			renderer.disposeTextLayout(layout);
+		}
+	}
+	showCaret();
+}
+/** 
+ * Frees resources.
+ */
+void handleDispose(Event event) {
+	removeListener(SWT.Dispose, listener);
+	notifyListeners(SWT.Dispose, event);
+	event.type = SWT.None;
+
+	clipboard.dispose();
+	if (renderer != null) {
+		renderer.dispose();
+		renderer = null;
+	}
+	if (content != null) {
+		content.removeTextChangeListener(textChangeListener);
+		content = null;
+	}
+	if (defaultCaret != null) {
+		defaultCaret.dispose();
+		defaultCaret = null;
+	}
+	if (leftCaretBitmap != null) {
+		leftCaretBitmap.dispose();
+		leftCaretBitmap = null;
+	}
+	if (rightCaretBitmap != null) {
+		rightCaretBitmap.dispose();
+		rightCaretBitmap = null;
+	}
+	if (isBidiCaret()) {
+		BidiUtil.removeLanguageListener(this);
+	}
+	selectionBackground = null;
+	selectionForeground = null;
+	textChangeListener = null;
+	selection = null;
+	doubleClickSelection = null;
+	keyActionMap = null;
+	background = null;
+	foreground = null;
+	clipboard = null;
+}
+/** 
+ * Scrolls the widget horizontally.
+ */
+void handleHorizontalScroll(Event event) {
+	int scrollPixel = getHorizontalBar().getSelection() - horizontalScrollOffset;
+	scrollHorizontal(scrollPixel, false);
+}
+/**
+ * If an action has been registered for the key stroke execute the action.
+ * Otherwise, if a character has been entered treat it as new content.
+ *
+ * @param event keyboard event
+ */
+void handleKey(Event event) {
+	int action;
+	caretAlignment = PREVIOUS_OFFSET_TRAILING;
+	if (event.keyCode != 0) {
+		// special key pressed (e.g., F1)
+		action = getKeyBinding(event.keyCode | event.stateMask);
+	} else {
+		// character key pressed
+		action = getKeyBinding(event.character | event.stateMask);
+		if (action == SWT.NULL) {
+			// see if we have a control character
+			if ((event.stateMask & SWT.CTRL) != 0 && (event.character >= 0) && event.character <= 31) {
+				// get the character from the CTRL+char sequence, the control
+				// key subtracts 64 from the value of the key that it modifies
+				int c = event.character + 64;
+				action = getKeyBinding(c | event.stateMask);
+			}
+		}
+	}
+	if (action == SWT.NULL) {
+		boolean ignore = false;
+		
+		if (IS_CARBON) {
+			// Ignore accelerator key combinations (we do not want to 
+			// insert a character in the text in this instance). Do not  
+			// ignore COMMAND+ALT combinations since that key sequence
+			// produces characters on the mac.
+			ignore = (event.stateMask ^ SWT.COMMAND) == 0 ||
+					(event.stateMask ^ (SWT.COMMAND | SWT.SHIFT)) == 0;
+		} else if (IS_MOTIF) {
+			// Ignore accelerator key combinations (we do not want to 
+			// insert a character in the text in this instance). Do not  
+			// ignore ALT combinations since this key sequence
+			// produces characters on motif.
+			ignore = (event.stateMask ^ SWT.CTRL) == 0 ||
+					(event.stateMask ^ (SWT.CTRL | SWT.SHIFT)) == 0;
+		} else {
+			// Ignore accelerator key combinations (we do not want to 
+			// insert a character in the text in this instance). Don't  
+			// ignore CTRL+ALT combinations since that is the Alt Gr 
+			// key on some keyboards.  See bug 20953. 
+			ignore = (event.stateMask ^ SWT.ALT) == 0 || 
+					(event.stateMask ^ SWT.CTRL) == 0 ||
+					(event.stateMask ^ (SWT.ALT | SWT.SHIFT)) == 0 ||
+					(event.stateMask ^ (SWT.CTRL | SWT.SHIFT)) == 0;
+		}
+		// -ignore anything below SPACE except for line delimiter keys and tab.
+		// -ignore DEL 
+		if (!ignore && event.character > 31 && event.character != SWT.DEL || 
+		    event.character == SWT.CR || event.character == SWT.LF || 
+		    event.character == TAB) {
+			doContent(event.character);
+			update();
+		}
+	} else {
+		invokeAction(action);
+	}
+}
+/**
+ * If a VerifyKey listener exists, verify that the key that was entered
+ * should be processed.
+ *
+ * @param event keyboard event
+ */
+void handleKeyDown(Event event) {
+	if (clipboardSelection == null) {
+		clipboardSelection = new Point(selection.x, selection.y);
+	}
+	
+	Event verifyEvent = new Event();
+	verifyEvent.character = event.character;
+	verifyEvent.keyCode = event.keyCode;
+	verifyEvent.stateMask = event.stateMask;
+	verifyEvent.doit = true;
+	notifyListeners(VerifyKey, verifyEvent);
+	if (verifyEvent.doit) {
+		handleKey(event);
+	}
+}
+/**
+ * Update the Selection Clipboard.
+ *
+ * @param event keyboard event
+ */
+void handleKeyUp(Event event) {
+	if (clipboardSelection != null) {
+		if (clipboardSelection.x != selection.x || clipboardSelection.y != selection.y) {
+			try {
+				if (selection.y - selection.x > 0) {
+					setClipboardContent(selection.x, selection.y - selection.x, DND.SELECTION_CLIPBOARD);
+				}
+			} catch (SWTError error) {
+				// Copy to clipboard failed. This happens when another application 
+				// is accessing the clipboard while we copy. Ignore the error.
+				// Fixes 1GDQAVN
+				// Rethrow all other errors. Fixes bug 17578.
+				if (error.code != DND.ERROR_CANNOT_SET_CLIPBOARD) {
+					throw error;
+				}
+			}
+		}
+	}
+	clipboardSelection = null;
+}
+/** 
+ * Updates the caret location and selection if mouse button 1 has been 
+ * pressed.
+ */
+void handleMouseDown(Event event) {
+	//force focus (object support)
+	forceFocus();
+		
+	//drag detect
+	if (dragDetect && checkDragDetect(event)) return;
+		
+	//paste clipboard selection
+	if (event.button == 2) {
+		String text = (String)getClipboardContent(DND.SELECTION_CLIPBOARD);
+		if (text != null && text.length() > 0) {
+			// position cursor
+			doMouseLocationChange(event.x, event.y, false);
+			// insert text
+			Event e = new Event();
+			e.start = selection.x;
+			e.end = selection.y;
+			e.text = getModelDelimitedText(text);
+			sendKeyEvent(e);
+		}
+	}
+	
+	//set selection
+	if ((event.button != 1) || (IS_CARBON && (event.stateMask & SWT.MOD4) != 0)) {
+		return;	
+	}
+	clickCount = event.count;
+	if (clickCount == 1) {
+		boolean select = (event.stateMask & SWT.MOD2) != 0;
+		doMouseLocationChange(event.x, event.y, select);
+	} else {
+		if (doubleClickEnabled) {
+			clearSelection(false);
+			int offset = getOffsetAtPoint(event.x, event.y);
+			int lineIndex = content.getLineAtOffset(offset);
+			int lineOffset = content.getOffsetAtLine(lineIndex);
+			int lineEnd = content.getCharCount();
+			if (lineIndex + 1 < content.getLineCount()) {
+				lineEnd = content.getOffsetAtLine(lineIndex + 1);
+			}
+			int start, end;
+			if ((clickCount & 1) == 0) {
+				start = Math.max(0, getWordPrevious(offset, SWT.MOVEMENT_WORD_START));
+				end = Math.min(content.getCharCount(), getWordNext(start, SWT.MOVEMENT_WORD_END));
+			} else {
+				start = lineOffset;
+				end = lineEnd;
+			}
+			caretOffset = start;
+			resetSelection();
+			caretOffset = end;
+			showCaret();
+			doMouseSelection();
+			doubleClickSelection = new Point(selection.x, selection.y);
+		}
+	}
+}
+/** 
+ * Updates the caret location and selection if mouse button 1 is pressed 
+ * during the mouse move.
+ */
+void handleMouseMove(Event event) {
+	if (clickCount == 0) return;
+	doMouseLocationChange(event.x, event.y, true);
+	update();
+	doAutoScroll(event);
+}
+/** 
+ * Autoscrolling ends when the mouse button is released.
+ */
+void handleMouseUp(Event event) {
+	clickCount = 0;
+	endAutoScroll();
+	if (event.button == 1) {
+		try {
+			if (selection.y - selection.x > 0) {
+				setClipboardContent(selection.x, selection.y - selection.x, DND.SELECTION_CLIPBOARD);
+			}
+		} catch (SWTError error) {
+			// Copy to clipboard failed. This happens when another application 
+			// is accessing the clipboard while we copy. Ignore the error.
+			// Fixes 1GDQAVN
+			// Rethrow all other errors. Fixes bug 17578.
+			if (error.code != DND.ERROR_CANNOT_SET_CLIPBOARD) {
+				throw error;
+			}
+		}
+	}
+}
+/**
+ * Renders the invalidated area specified in the paint event.
+ *
+ * @param event paint event
+ */
+void handlePaint(Event event) {
+	if (event.width == 0 || event.height == 0) return;
+	if (clientAreaWidth == 0 || clientAreaHeight == 0) return;
+
+	int startLine = getLineIndex(event.y);
+	int y = getLinePixel(startLine);
+	int endY = event.y + event.height;
+	GC gc = event.gc;
+	Color background = getBackground();
+	Color foreground = getForeground();
+	if (endY > 0) {
+		int lineCount = isSingleLine() ? 1 : content.getLineCount();
+		int x = leftMargin - horizontalScrollOffset;
+		for (int i = startLine; y < endY && i < lineCount; i++) {
+			y += renderer.drawLine(i, x, y, gc, background, foreground);
+		}
+		if (y < endY) {
+			gc.setBackground(background);
+			drawBackground(gc, 0, y, clientAreaWidth, endY - y);
+		}
+	}
+	// fill the margin background
+	gc.setBackground(background);
+	if (topMargin > 0) {
+		drawBackground(gc, 0, 0, clientAreaWidth, topMargin);
+	}
+	if (bottomMargin > 0) {
+		drawBackground(gc, 0, clientAreaHeight - bottomMargin, clientAreaWidth, bottomMargin);
+	}
+	if (leftMargin > 0) {
+		drawBackground(gc, 0, 0, leftMargin, clientAreaHeight);
+	}
+	if (rightMargin > 0) {
+		drawBackground(gc, clientAreaWidth - rightMargin, 0, rightMargin, clientAreaHeight);
+	}
+}
+/**
+ * Recalculates the scroll bars. Rewraps all lines when in word 
+ * wrap mode.
+ *
+ * @param event resize event
+ */
+void handleResize(Event event) {
+	int oldHeight = clientAreaHeight;
+	int oldWidth = clientAreaWidth;
+	Rectangle clientArea = getClientArea();
+	clientAreaHeight = clientArea.height;
+	clientAreaWidth = clientArea.width;
+	/* Redraw the old or new right/bottom margin if needed */
+	if (oldWidth != clientAreaWidth) {
+		if (rightMargin > 0) {
+			int x = (oldWidth < clientAreaWidth ? oldWidth : clientAreaWidth) - rightMargin; 
+			super.redraw(x, 0, rightMargin, oldHeight, false);
+		}
+	}
+	if (oldHeight != clientAreaHeight) {
+		if (bottomMargin > 0) {
+			int y = (oldHeight < clientAreaHeight ? oldHeight : clientAreaHeight) - bottomMargin; 
+			super.redraw(0, y, oldWidth, bottomMargin, false);
+		}
+	}
+	if (wordWrap) {
+		if (oldWidth != clientAreaWidth) {
+			renderer.reset(0, content.getLineCount());
+			verticalScrollOffset = -1;
+			renderer.calculateIdle();
+			super.redraw();
+		}
+		if (oldHeight != clientAreaHeight) {
+			if (oldHeight == 0) topIndexY = 0;
+			setScrollBars(true);
+		}
+		setCaretLocation();
+	} else  {
+		renderer.calculateClientArea();
+		setScrollBars(true);
+		claimRightFreeSpace();
+		// StyledText allows any value for horizontalScrollOffset when clientArea is zero
+		// in setHorizontalPixel() and setHorisontalOffset(). Fixes bug 168429.
+		if (clientAreaWidth != 0) {
+			ScrollBar horizontalBar = getHorizontalBar();
+			if (horizontalBar != null && horizontalBar.getVisible()) {
+				if (horizontalScrollOffset != horizontalBar.getSelection()) {
+					horizontalBar.setSelection(horizontalScrollOffset);
+					horizontalScrollOffset = horizontalBar.getSelection();
+				}
+			}
+		}
+	}
+	claimBottomFreeSpace();
+	//TODO FIX TOP INDEX DURING RESIZE
+//	if (oldHeight != clientAreaHeight || wordWrap) {
+//		calculateTopIndex(0);
+//	}
+}
+/**
+ * Updates the caret position and selection and the scroll bars to reflect 
+ * the content change.
+ */
+void handleTextChanged(TextChangedEvent event) {
+	int offset = ime.getCompositionOffset();
+	if (offset != -1 && lastTextChangeStart < offset) {
+		ime.setCompositionOffset(offset + lastTextChangeNewCharCount - lastTextChangeReplaceCharCount);
+	}
+	int firstLine = content.getLineAtOffset(lastTextChangeStart);
+	resetCache(firstLine, 0);
+	if (!isFixedLineHeight() && topIndex > firstLine) {
+		topIndex = firstLine;
+		topIndexY = 0;
+		super.redraw();
+	} else {
+		int lastLine = firstLine + lastTextChangeNewLineCount;
+		int firstLineTop = getLinePixel(firstLine);
+		int newLastLineBottom = getLinePixel(lastLine + 1);
+		if (lastLineBottom != newLastLineBottom) {
+			super.redraw();
+		} else {
+			super.redraw(0, firstLineTop, clientAreaWidth, newLastLineBottom - firstLineTop, false);
+			redrawLinesBullet(renderer.redrawLines);
+		}
+	}
+	renderer.redrawLines = null;
+	// update selection/caret location after styles have been changed.
+	// otherwise any text measuring could be incorrect
+	// 
+	// also, this needs to be done after all scrolling. Otherwise, 
+	// selection redraw would be flushed during scroll which is wrong.
+	// in some cases new text would be drawn in scroll source area even 
+	// though the intent is to scroll it.
+	updateSelection(lastTextChangeStart, lastTextChangeReplaceCharCount, lastTextChangeNewCharCount);
+	if (lastTextChangeReplaceLineCount > 0 || wordWrap) {
+		claimBottomFreeSpace();
+	}
+	if (lastTextChangeReplaceCharCount > 0) {
+		claimRightFreeSpace();
+	}
+}
+/**
+ * Updates the screen to reflect a pending content change.
+ *
+ * @param event .start the start offset of the change
+ * @param event .newText text that is going to be inserted or empty String 
+ *	if no text will be inserted
+ * @param event .replaceCharCount length of text that is going to be replaced
+ * @param event .newCharCount length of text that is going to be inserted
+ * @param event .replaceLineCount number of lines that are going to be replaced
+ * @param event .newLineCount number of new lines that are going to be inserted
+ */
+void handleTextChanging(TextChangingEvent event) {
+	if (event.replaceCharCount < 0) {
+		event.start += event.replaceCharCount;
+		event.replaceCharCount *= -1;
+	}
+	lastTextChangeStart = event.start;
+	lastTextChangeNewLineCount = event.newLineCount;
+	lastTextChangeNewCharCount = event.newCharCount;
+	lastTextChangeReplaceLineCount = event.replaceLineCount;
+	lastTextChangeReplaceCharCount = event.replaceCharCount;	
+	int lineIndex = content.getLineAtOffset(event.start);
+	int srcY = getLinePixel(lineIndex + event.replaceLineCount + 1);
+	int destY = getLinePixel(lineIndex + 1) + event.newLineCount * renderer.getLineHeight();
+	lastLineBottom = destY;
+	if (srcY < 0 && destY < 0) {
+		lastLineBottom += srcY - destY;
+		verticalScrollOffset += destY - srcY;
+		calculateTopIndex(destY - srcY);
+		setScrollBars(true);
+	} else {
+		scrollText(srcY, destY);
+	}
+
+	renderer.textChanging(event);
+	
+	// Update the caret offset if it is greater than the length of the content.
+	// This is necessary since style range API may be called between the
+	// handleTextChanging and handleTextChanged events and this API sets the
+	// caretOffset.
+	int newEndOfText = content.getCharCount() - event.replaceCharCount + event.newCharCount;
+	if (caretOffset > newEndOfText) caretOffset = newEndOfText;
+}
+/**
+ * Called when the widget content is set programmatically, overwriting 
+ * the old content. Resets the caret position, selection and scroll offsets. 
+ * Recalculates the content width and scroll bars. Redraws the widget.
+ *
+ * @param event text change event. 
+ */
+void handleTextSet(TextChangedEvent event) {
+	reset();
+}
+/**
+ * Called when a traversal key is pressed.
+ * Allow tab next traversal to occur when the widget is in single 
+ * line mode or in multi line and non-editable mode . 
+ * When in editable multi line mode we want to prevent the tab 
+ * traversal and receive the tab key event instead.
+ *
+ * @param event the event
+ */
+void handleTraverse(Event event) {
+	switch (event.detail) {
+		case SWT.TRAVERSE_ESCAPE:
+		case SWT.TRAVERSE_PAGE_NEXT:
+		case SWT.TRAVERSE_PAGE_PREVIOUS:
+			event.doit = true;
+			break;
+		case SWT.TRAVERSE_RETURN:
+		case SWT.TRAVERSE_TAB_NEXT:
+		case SWT.TRAVERSE_TAB_PREVIOUS:
+			if ((getStyle() & SWT.SINGLE) != 0) {
+				event.doit = true;
+			} else {
+				if (!editable || (event.stateMask & SWT.MODIFIER_MASK) != 0) {
+					event.doit = true;
+				}
+			}
+			break;
+	}
+}
+/** 
+ * Scrolls the widget vertically.
+ */
+void handleVerticalScroll(Event event) {
+	int scrollPixel = getVerticalBar().getSelection() - getVerticalScrollOffset();
+	scrollVertical(scrollPixel, false);
+}
+/**
+ * Add accessibility support for the widget.
+ */
+void initializeAccessible() {
+	final Accessible accessible = getAccessible();
+	accessible.addAccessibleListener(new AccessibleAdapter() {
+		public void getName (AccessibleEvent e) {
+			String name = null;
+			Label label = getAssociatedLabel ();
+			if (label != null) {
+				name = stripMnemonic (label.getText());
+			}
+			e.result = name;
+		}
+		public void getHelp(AccessibleEvent e) {
+			e.result = getToolTipText();
+		}
+		public void getKeyboardShortcut(AccessibleEvent e) {
+			String shortcut = null;
+			Label label = getAssociatedLabel ();
+			if (label != null) {
+				String text = label.getText ();
+				if (text != null) {
+					char mnemonic = _findMnemonic (text);
+					if (mnemonic != '\0') {
+						shortcut = "Alt+"+mnemonic; //$NON-NLS-1$
+					}
+				}
+			}
+			e.result = shortcut;
+		}
+	});
+	accessible.addAccessibleTextListener(new AccessibleTextAdapter() {
+		public void getCaretOffset(AccessibleTextEvent e) {
+			e.offset = StyledText.this.getCaretOffset();
+		}
+		public void getSelectionRange(AccessibleTextEvent e) {
+			Point selection = StyledText.this.getSelectionRange();
+			e.offset = selection.x;
+			e.length = selection.y;
+		}
+	});
+	accessible.addAccessibleControlListener(new AccessibleControlAdapter() {
+		public void getRole(AccessibleControlEvent e) {
+			e.detail = ACC.ROLE_TEXT;
+		}
+		public void getState(AccessibleControlEvent e) {
+			int state = 0;
+			if (isEnabled()) state |= ACC.STATE_FOCUSABLE;
+			if (isFocusControl()) state |= ACC.STATE_FOCUSED;
+			if (!isVisible()) state |= ACC.STATE_INVISIBLE;
+			if (!getEditable()) state |= ACC.STATE_READONLY;
+			e.detail = state;
+		}
+		public void getValue(AccessibleControlEvent e) {
+			e.result = StyledText.this.getText();
+		}
+	});	
+	addListener(SWT.FocusIn, new Listener() {
+		public void handleEvent(Event event) {
+			accessible.setFocus(ACC.CHILDID_SELF);
+		}
+	});	
+}
+/* 
+ * Return the Label immediately preceding the receiver in the z-order, 
+ * or null if none. 
+ */
+Label getAssociatedLabel () {
+	Control[] siblings = getParent ().getChildren ();
+	for (int i = 0; i < siblings.length; i++) {
+		if (siblings [i] == StyledText.this) {
+			if (i > 0 && siblings [i-1] instanceof Label) {
+				return (Label) siblings [i-1];
+			}
+		}
+	}
+	return null;
+}
+String stripMnemonic (String string) {
+	int index = 0;
+	int length = string.length ();
+	do {
+		while ((index < length) && (string.charAt (index) != '&')) index++;
+		if (++index >= length) return string;
+		if (string.charAt (index) != '&') {
+			return string.substring(0, index-1) + string.substring(index, length);
+		}
+		index++;
+	} while (index < length);
+ 	return string;
+}
+/*
+ * Return the lowercase of the first non-'&' character following
+ * an '&' character in the given string. If there are no '&'
+ * characters in the given string, return '\0'.
+ */
+char _findMnemonic (String string) {
+	if (string == null) return '\0';
+	int index = 0;
+	int length = string.length ();
+	do {
+		while (index < length && string.charAt (index) != '&') index++;
+		if (++index >= length) return '\0';
+		if (string.charAt (index) != '&') return Character.toLowerCase (string.charAt (index));
+		index++;
+	} while (index < length);
+ 	return '\0';
+}
+/**
+ * Executes the action.
+ *
+ * @param action one of the actions defined in ST.java
+ */
+public void invokeAction(int action) {
+	checkWidget();
+	updateCaretDirection = true;
+	switch (action) {
+		// Navigation
+		case ST.LINE_UP:
+			doLineUp(false);
+			clearSelection(true);
+			break;
+		case ST.LINE_DOWN:
+			doLineDown(false);
+			clearSelection(true);
+			break;
+		case ST.LINE_START:
+			doLineStart();
+			clearSelection(true);
+			break;
+		case ST.LINE_END:
+			doLineEnd();
+			clearSelection(true);
+			break;
+		case ST.COLUMN_PREVIOUS:
+			doCursorPrevious();
+			clearSelection(true);
+			break;
+		case ST.COLUMN_NEXT:
+			doCursorNext();
+			clearSelection(true);
+			break;
+		case ST.PAGE_UP:
+			doPageUp(false, -1);
+			clearSelection(true);
+			break;
+		case ST.PAGE_DOWN:
+			doPageDown(false, -1);
+			clearSelection(true);
+			break;
+		case ST.WORD_PREVIOUS:
+			doWordPrevious();
+			clearSelection(true);
+			break;
+		case ST.WORD_NEXT:
+			doWordNext();
+			clearSelection(true);
+			break;
+		case ST.TEXT_START:
+			doContentStart();
+			clearSelection(true);
+			break;
+		case ST.TEXT_END:
+			doContentEnd();
+			clearSelection(true);
+			break;
+		case ST.WINDOW_START:
+			doPageStart();
+			clearSelection(true);
+			break;
+		case ST.WINDOW_END:
+			doPageEnd();
+			clearSelection(true);
+			break;
+		// Selection	
+		case ST.SELECT_LINE_UP:
+			doSelectionLineUp();
+			break;
+		case ST.SELECT_ALL:
+			selectAll();
+			break;
+		case ST.SELECT_LINE_DOWN:
+			doSelectionLineDown();
+			break;
+		case ST.SELECT_LINE_START:
+			doLineStart();
+			doSelection(ST.COLUMN_PREVIOUS);
+			break;
+		case ST.SELECT_LINE_END:
+			doLineEnd();
+			doSelection(ST.COLUMN_NEXT);
+			break;
+		case ST.SELECT_COLUMN_PREVIOUS:
+			doSelectionCursorPrevious();
+			doSelection(ST.COLUMN_PREVIOUS);
+			break;
+		case ST.SELECT_COLUMN_NEXT:
+			doSelectionCursorNext();
+			doSelection(ST.COLUMN_NEXT);
+			break;
+		case ST.SELECT_PAGE_UP:
+			doSelectionPageUp(-1);
+			break;
+		case ST.SELECT_PAGE_DOWN:
+			doSelectionPageDown(-1);
+			break;
+		case ST.SELECT_WORD_PREVIOUS:
+			doSelectionWordPrevious();
+			doSelection(ST.COLUMN_PREVIOUS);
+			break;
+		case ST.SELECT_WORD_NEXT:
+			doSelectionWordNext();
+			doSelection(ST.COLUMN_NEXT);
+			break;
+		case ST.SELECT_TEXT_START:
+			doContentStart();
+			doSelection(ST.COLUMN_PREVIOUS);
+			break;
+		case ST.SELECT_TEXT_END:
+			doContentEnd();
+			doSelection(ST.COLUMN_NEXT);
+			break;
+		case ST.SELECT_WINDOW_START:
+			doPageStart();
+			doSelection(ST.COLUMN_PREVIOUS);
+			break;
+		case ST.SELECT_WINDOW_END:
+			doPageEnd();
+			doSelection(ST.COLUMN_NEXT);
+			break;
+		// Modification			
+		case ST.CUT:
+			cut();
+			break;
+		case ST.COPY:
+			copy();
+			break;
+		case ST.PASTE:
+			paste();
+			break;
+		case ST.DELETE_PREVIOUS:
+			doBackspace();
+			break;
+		case ST.DELETE_NEXT:
+			doDelete();
+			break;
+		case ST.DELETE_WORD_PREVIOUS:
+			doDeleteWordPrevious();
+			break;
+		case ST.DELETE_WORD_NEXT:
+			doDeleteWordNext();
+			break;
+		// Miscellaneous
+		case ST.TOGGLE_OVERWRITE:
+			overwrite = !overwrite;		// toggle insert/overwrite mode
+			break;
+	}
+}
+/**
+ * Temporary until SWT provides this
+ */
+boolean isBidi() {
+	return IS_GTK || IS_CARBON || BidiUtil.isBidiPlatform() || isMirrored;
+}
+boolean isBidiCaret() {
+	return BidiUtil.isBidiPlatform();
+}
+boolean isFixedLineHeight() {
+	return fixedLineHeight;
+}
+/**
+ * Returns whether the given offset is inside a multi byte line delimiter.
+ * Example: 
+ * "Line1\r\n" isLineDelimiter(5) == false but isLineDelimiter(6) == true
+ * 
+ * @return true if the given offset is inside a multi byte line delimiter.
+ * false if the given offset is before or after a line delimiter.
+ */
+boolean isLineDelimiter(int offset) {
+	int line = content.getLineAtOffset(offset);
+	int lineOffset = content.getOffsetAtLine(line);	
+	int offsetInLine = offset - lineOffset;
+	// offsetInLine will be greater than line length if the line 
+	// delimiter is longer than one character and the offset is set
+	// in between parts of the line delimiter.
+	return offsetInLine > content.getLine(line).length();
+}
+/**
+ * Returns whether the widget is mirrored (right oriented/right to left 
+ * writing order). 
+ * 
+ * @return isMirrored true=the widget is right oriented, false=the widget 
+ * 	is left oriented
+ */
+boolean isMirrored() {
+	return isMirrored;
+}
+/**
+ * Returns whether the widget can have only one line.
+ *
+ * @return true if widget can have only one line, false if widget can have 
+ * 	multiple lines
+ */
+boolean isSingleLine() {
+	return (getStyle() & SWT.SINGLE) != 0;
+}
+/**
+ * Sends the specified verify event, replace/insert text as defined by 
+ * the event and send a modify event.
+ *
+ * @param event	the text change event. 
+ *	<ul>
+ *	<li>event.start - the replace start offset</li>
+ * 	<li>event.end - the replace end offset</li>
+ * 	<li>event.text - the new text</li>
+ *	</ul>
+ * @param updateCaret whether or not he caret should be set behind
+ *	the new text
+ */
+void modifyContent(Event event, boolean updateCaret) {
+	event.doit = true;
+	notifyListeners(SWT.Verify, event);
+	if (event.doit) {
+		StyledTextEvent styledTextEvent = null;
+		int replacedLength = event.end - event.start;
+		if (isListening(ExtendedModify)) {
+			styledTextEvent = new StyledTextEvent(content);
+			styledTextEvent.start = event.start;
+			styledTextEvent.end = event.start + event.text.length();
+			styledTextEvent.text = content.getTextRange(event.start, replacedLength);
+		}
+		if (updateCaret) {
+			//Fix advancing flag for delete/backspace key on direction boundary
+			if (event.text.length() == 0) {
+				int lineIndex = content.getLineAtOffset(event.start);
+				int lineOffset = content.getOffsetAtLine(lineIndex);
+				TextLayout layout = renderer.getTextLayout(lineIndex);
+				int levelStart = layout.getLevel(event.start - lineOffset);
+				int lineIndexEnd = content.getLineAtOffset(event.end);
+				if (lineIndex != lineIndexEnd) {
+					renderer.disposeTextLayout(layout);
+					lineOffset = content.getOffsetAtLine(lineIndexEnd);
+					layout = renderer.getTextLayout(lineIndexEnd);
+				}
+				int levelEnd = layout.getLevel(event.end - lineOffset);
+				renderer.disposeTextLayout(layout);
+				if (levelStart != levelEnd) {
+					caretAlignment = PREVIOUS_OFFSET_TRAILING;
+				} else {
+					caretAlignment = OFFSET_LEADING;
+				}
+			}
+		}
+		content.replaceTextRange(event.start, replacedLength, event.text);
+		// set the caret position prior to sending the modify event.
+		// fixes 1GBB8NJ
+		if (updateCaret) {
+			// always update the caret location. fixes 1G8FODP
+			setSelection(event.start + event.text.length(), 0, true);
+			showCaret();
+		}
+		sendModifyEvent(event);
+		if (isListening(ExtendedModify)) {
+			notifyListeners(ExtendedModify, styledTextEvent);
+		}
+	}
+}
+void paintObject(GC gc, int x, int y, int ascent, int descent, StyleRange style, Bullet bullet, int bulletIndex) {
+	if (isListening(PaintObject)) {
+		StyledTextEvent event = new StyledTextEvent (content) ;
+		event.gc = gc;
+		event.x = x;
+		event.y = y;
+		event.ascent = ascent;
+		event.descent = descent;
+		event.style = style;
+		event.bullet = bullet;
+		event.bulletIndex = bulletIndex;
+		notifyListeners(PaintObject, event);
+	}
+}
+/** 
+ * Replaces the selection with the text on the <code>DND.CLIPBOARD</code>  
+ * clipboard  or, if there is no selection,  inserts the text at the current 
+ * caret offset.   If the widget has the SWT.SINGLE style and the 
+ * clipboard text contains more than one line, only the first line without
+ * line delimiters is  inserted in the widget.
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void paste(){
+	checkWidget();	
+	String text = (String) getClipboardContent(DND.CLIPBOARD);
+	if (text != null && text.length() > 0) {
+		Event event = new Event();
+		event.start = selection.x;
+		event.end = selection.y;
+		event.text = getModelDelimitedText(text);
+		sendKeyEvent(event);
+	}
+}
+/** 
+ * Prints the widget's text to the default printer.
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void print() {
+	checkWidget();
+	Printer printer = new Printer();
+	StyledTextPrintOptions options = new StyledTextPrintOptions();
+	options.printTextForeground = true;
+	options.printTextBackground = true;
+	options.printTextFontStyle = true;
+	options.printLineBackground = true;	
+	new Printing(this, printer, options).run();
+	printer.dispose();
+}
+/** 
+ * Returns a runnable that will print the widget's text
+ * to the specified printer.
+ * <p>
+ * The runnable may be run in a non-UI thread.
+ * </p>
+ * 
+ * @param printer the printer to print to
+ *
+ * @return a <code>Runnable</code> for printing the receiver's text
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT when printer is null</li>
+ * </ul>
+ */
+public Runnable print(Printer printer) {
+	checkWidget();	
+	if (printer == null) {
+		SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	}
+	StyledTextPrintOptions options = new StyledTextPrintOptions();
+	options.printTextForeground = true;
+	options.printTextBackground = true;
+	options.printTextFontStyle = true;
+	options.printLineBackground = true;
+	return print(printer, options);
+}
+/** 
+ * Returns a runnable that will print the widget's text
+ * to the specified printer.
+ * <p>
+ * The runnable may be run in a non-UI thread.
+ * </p>
+ * 
+ * @param printer the printer to print to
+ * @param options print options to use during printing
+ *
+ * @return a <code>Runnable</code> for printing the receiver's text
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT when printer or options is null</li>
+ * </ul>
+ * @since 2.1
+ */
+public Runnable print(Printer printer, StyledTextPrintOptions options) {
+	checkWidget();
+	if (printer == null || options == null) {
+		SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	}
+	return new Printing(this, printer, options);
+}
+/**
+ * Causes the entire bounds of the receiver to be marked
+ * as needing to be redrawn. The next time a paint request
+ * is processed, the control will be completely painted.
+ * <p>
+ * Recalculates the content width for all lines in the bounds.
+ * When a <code>LineStyleListener</code> is used a redraw call 
+ * is the only notification to the widget that styles have changed 
+ * and that the content width may have changed.
+ * </p>
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see Control#update()
+ */
+public void redraw() {
+	super.redraw();
+	int itemCount = getPartialBottomIndex() - topIndex + 1;
+	renderer.reset(topIndex, itemCount);
+	renderer.calculate(topIndex, itemCount);
+	setScrollBars(false);
+}
+/**
+ * Causes the rectangular area of the receiver specified by
+ * the arguments to be marked as needing to be redrawn. 
+ * The next time a paint request is processed, that area of
+ * the receiver will be painted. If the <code>all</code> flag
+ * is <code>true</code>, any children of the receiver which
+ * intersect with the specified area will also paint their
+ * intersecting areas. If the <code>all</code> flag is 
+ * <code>false</code>, the children will not be painted.
+ * <p>
+ * Marks the content width of all lines in the specified rectangle
+ * as unknown. Recalculates the content width of all visible lines.
+ * When a <code>LineStyleListener</code> is used a redraw call 
+ * is the only notification to the widget that styles have changed 
+ * and that the content width may have changed.
+ * </p>
+ *
+ * @param x the x coordinate of the area to draw
+ * @param y the y coordinate of the area to draw
+ * @param width the width of the area to draw
+ * @param height the height of the area to draw
+ * @param all <code>true</code> if children should redraw, and <code>false</code> otherwise
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see Control#update()
+ */
+public void redraw(int x, int y, int width, int height, boolean all) {
+	super.redraw(x, y, width, height, all);
+	if (height > 0) {
+		int firstLine = getLineIndex(y);
+		int lastLine = getLineIndex(y + height);
+		resetCache(firstLine, lastLine - firstLine + 1);
+	}
+}
+void redrawLines(int startLine, int lineCount) {
+	// do nothing if redraw range is completely invisible	
+	int partialBottomIndex = getPartialBottomIndex();
+	if (startLine > partialBottomIndex || startLine + lineCount - 1 < topIndex) {
+		return;
+	}
+	// only redraw visible lines
+	if (startLine < topIndex) {
+		lineCount -= topIndex - startLine;
+		startLine = topIndex;
+	}
+	if (startLine + lineCount - 1 > partialBottomIndex) {
+		lineCount = partialBottomIndex - startLine + 1;
+	}
+	startLine -= topIndex;
+	int redrawTop = getLinePixel(startLine);
+	int redrawBottom = getLinePixel(startLine + lineCount);
+	int redrawWidth = clientAreaWidth - leftMargin - rightMargin; 
+	super.redraw(leftMargin, redrawTop, redrawWidth, redrawBottom - redrawTop, true);
+}
+void redrawLinesBullet (int[] redrawLines) {
+	if (redrawLines == null) return;
+	int topIndex = getPartialTopIndex();
+	int bottomIndex = getPartialBottomIndex();
+	for (int i = 0; i < redrawLines.length; i++) {
+		int lineIndex = redrawLines[i];
+		if (!(topIndex <= lineIndex && lineIndex <= bottomIndex)) continue;
+		int width = -1;
+		Bullet bullet = renderer.getLineBullet(lineIndex, null);
+		if (bullet != null) {
+			StyleRange style = bullet.style;
+			GlyphMetrics metrics = style.metrics;
+			width = metrics.width;
+		}
+		if (width == -1) width = getClientArea().width;
+		int height = renderer.getLineHeight(lineIndex);
+		int y = getLinePixel(lineIndex);
+		super.redraw(0, y, width, height, false);
+	}
+}
+/** 
+ * Redraws the specified text range.
+ *
+ * @param start offset of the first character to redraw
+ * @param length number of characters to redraw
+ * @param clearBackground true if the background should be cleared as
+ *  part of the redraw operation.  If true, the entire redraw range will
+ *  be cleared before anything is redrawn.  If the redraw range includes
+ *	the last character of a line (i.e., the entire line is redrawn) the 
+ * 	line is cleared all the way to the right border of the widget.
+ * 	The redraw operation will be faster and smoother if clearBackground 
+ * 	is set to false.  Whether or not the flag can be set to false depends 
+ * 	on the type of change that has taken place.  If font styles or 
+ * 	background colors for the redraw range have changed, clearBackground 
+ * 	should be set to true.  If only foreground colors have changed for 
+ * 	the redraw range, clearBackground can be set to false. 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *   <li>ERROR_INVALID_RANGE when start and/or end are outside the widget content</li> 
+ * </ul>
+ */
+public void redrawRange(int start, int length, boolean clearBackground) {
+	checkWidget();
+	int end = start + length;
+	int contentLength = content.getCharCount();
+	if (start > end || start < 0 || end > contentLength) {
+		SWT.error(SWT.ERROR_INVALID_RANGE);
+	}
+	int firstLine = content.getLineAtOffset(start);
+	int lastLine = content.getLineAtOffset(end);
+	resetCache(firstLine, lastLine - firstLine + 1);
+	internalRedrawRange(start, length);
+}
+/**
+ * Removes the specified bidirectional segment listener.
+ *
+ * @param listener the listener which should no longer be notified
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT when listener is null</li>
+ * </ul>
+ * 
+ * @since 2.0
+ */
+public void removeBidiSegmentListener(BidiSegmentListener listener) {
+	checkWidget();
+	if (listener == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	removeListener(LineGetSegments, listener);	
+}
+/**
+ * Removes the specified extended modify listener.
+ *
+ * @param extendedModifyListener the listener which should no longer be notified
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT when listener is null</li>
+ * </ul>
+ */
+public void removeExtendedModifyListener(ExtendedModifyListener extendedModifyListener) {
+	checkWidget();
+	if (extendedModifyListener == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	removeListener(ExtendedModify, extendedModifyListener);	
+}
+/**
+ * Removes the specified line background listener.
+ *
+ * @param listener the listener which should no longer be notified
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT when listener is null</li>
+ * </ul>
+ */
+public void removeLineBackgroundListener(LineBackgroundListener listener) {
+	checkWidget();
+	if (listener == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	removeListener(LineGetBackground, listener);
+}
+/**
+ * Removes the specified line style listener.
+ *
+ * @param listener the listener which should no longer be notified
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT when listener is null</li>
+ * </ul>
+ */
+public void removeLineStyleListener(LineStyleListener listener) {
+	checkWidget();
+	if (listener == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	removeListener(LineGetStyle, listener);
+}
+/**
+ * Removes the specified modify listener.
+ *
+ * @param modifyListener the listener which should no longer be notified
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT when listener is null</li>
+ * </ul>
+ */
+public void removeModifyListener(ModifyListener modifyListener) {
+	checkWidget();
+	if (modifyListener == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	removeListener(SWT.Modify, modifyListener);
+}
+/**
+ * Removes the specified listener.
+ *
+ * @param listener the listener which should no longer be notified
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT when listener is null</li>
+ * </ul>
+ * @since 3.2
+ */
+public void removePaintObjectListener(PaintObjectListener listener) {
+	checkWidget();
+	if (listener == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	removeListener(PaintObject, listener);
+}
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the user changes the receiver's selection.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #addSelectionListener
+ */
+public void removeSelectionListener(SelectionListener listener) {
+	checkWidget();
+	if (listener == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	removeListener(SWT.Selection, listener);
+}
+/**
+ * Removes the specified verify listener.
+ *
+ * @param verifyListener the listener which should no longer be notified
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT when listener is null</li>
+ * </ul>
+ */
+public void removeVerifyListener(VerifyListener verifyListener) {
+	checkWidget();
+	if (verifyListener == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	removeListener(SWT.Verify, verifyListener);
+}
+/**
+ * Removes the specified key verify listener.
+ *
+ * @param listener the listener which should no longer be notified
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT when listener is null</li>
+ * </ul>
+ */
+public void removeVerifyKeyListener(VerifyKeyListener listener) {
+	if (listener == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	removeListener(VerifyKey, listener);
+}
+/**
+ * Removes the specified word movement listener.
+ *
+ * @param listener the listener which should no longer be notified
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT when listener is null</li>
+ * </ul>
+ * 
+ * @see MovementEvent
+ * @see MovementListener
+ * @see #addWordMovementListener
+ * 
+ * @since 3.3
+ */
+
+public void removeWordMovementListener(MovementListener listener) {
+	checkWidget();
+	if (listener == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	removeListener(WordNext, listener);	
+	removeListener(WordPrevious, listener);
+}
+/** 
+ * Replaces the styles in the given range with new styles.  This method
+ * effectively deletes the styles in the given range and then adds the
+ * the new styles. 
+ * <p>
+ * Note: Because a StyleRange includes the start and length, the
+ * same instance cannot occur multiple times in the array of styles.
+ * If the same style attributes, such as font and color, occur in
+ * multiple StyleRanges, <code>setStyleRanges(int, int, int[], StyleRange[])</code>
+ * can be used to share styles and reduce memory usage.
+ * </p><p>
+ * Should not be called if a LineStyleListener has been set since the 
+ * listener maintains the styles.
+ * </p>
+ *
+ * @param start offset of first character where styles will be deleted
+ * @param length length of the range to delete styles in
+ * @param ranges StyleRange objects containing the new style information.
+ * The ranges should not overlap and should be within the specified start 
+ * and length. The style rendering is undefined if the ranges do overlap
+ * or are ill-defined. Must not be null.
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *   <li>ERROR_INVALID_RANGE when either start or end is outside the valid range (0 <= offset <= getCharCount())</li> 
+ *   <li>ERROR_NULL_ARGUMENT when ranges is null</li>
+ * </ul>
+ * 
+ * @since 2.0
+ * 
+ * @see #setStyleRanges(int, int, int[], StyleRange[])
+ */
+public void replaceStyleRanges(int start, int length, StyleRange[] ranges) {
+	checkWidget();
+	if (isListening(LineGetStyle)) return;
+ 	if (ranges == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ 	setStyleRanges(start, length, null, ranges, false);
+}
+/**
+ * Replaces the given text range with new text.
+ * If the widget has the SWT.SINGLE style and "text" contains more than 
+ * one line, only the first line is rendered but the text is stored 
+ * unchanged. A subsequent call to getText will return the same text 
+ * that was set. Note that only a single line of text should be set when 
+ * the SWT.SINGLE style is used.
+ * <p>
+ * <b>NOTE:</b> During the replace operation the current selection is
+ * changed as follows:
+ * <ul>	
+ * <li>selection before replaced text: selection unchanged
+ * <li>selection after replaced text: adjust the selection so that same text 
+ * remains selected
+ * <li>selection intersects replaced text: selection is cleared and caret
+ * is placed after inserted text
+ * </ul>
+ * </p>
+ *
+ * @param start offset of first character to replace
+ * @param length number of characters to replace. Use 0 to insert text
+ * @param text new text. May be empty to delete text.
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *   <li>ERROR_INVALID_RANGE when either start or end is outside the valid range (0 <= offset <= getCharCount())</li> 
+ *   <li>ERROR_INVALID_ARGUMENT when either start or end is inside a multi byte line delimiter. 
+ * 		Splitting a line delimiter for example by inserting text in between the CR and LF and deleting part of a line delimiter is not supported</li>  
+ *   <li>ERROR_NULL_ARGUMENT when string is null</li>
+ * </ul>
+ */
+public void replaceTextRange(int start, int length, String text) {
+	checkWidget();
+	if (text == null) {
+		SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	}
+	int contentLength = getCharCount();
+	int end = start + length;
+	if (start > end || start < 0 || end > contentLength) {
+		SWT.error(SWT.ERROR_INVALID_RANGE);
+	}
+	Event event = new Event();
+	event.start = start;
+	event.end = end;
+	event.text = text;
+	modifyContent(event, false);
+}
+/**
+ * Resets the caret position, selection and scroll offsets. Recalculate
+ * the content width and scroll bars. Redraw the widget.
+ */
+void reset() {
+	ScrollBar verticalBar = getVerticalBar();
+	ScrollBar horizontalBar = getHorizontalBar();
+	caretOffset = 0;
+	topIndex = 0;
+	topIndexY = 0;
+	verticalScrollOffset = 0;
+	horizontalScrollOffset = 0;	
+	resetSelection();
+	renderer.setContent(content);
+	if (verticalBar != null) {
+		verticalBar.setSelection(0);
+	}
+	if (horizontalBar != null) {
+		horizontalBar.setSelection(0);	
+	}
+	resetCache(0, 0);
+	setCaretLocation();
+	super.redraw();
+}
+void resetCache(int firstLine, int count) {
+	int maxLineIndex = renderer.maxWidthLineIndex;
+	renderer.reset(firstLine, count);
+	renderer.calculateClientArea();
+	if (0 <= maxLineIndex && maxLineIndex < content.getLineCount()) {
+		renderer.calculate(maxLineIndex, 1);
+	}
+	setScrollBars(true);
+	if (!isFixedLineHeight()) {
+		if (topIndex > firstLine) {
+			verticalScrollOffset = -1;
+		}
+		renderer.calculateIdle();
+	}
+}
+/**
+ * Resets the selection.
+ */
+void resetSelection() {
+	selection.x = selection.y = caretOffset;
+	selectionAnchor = -1;
+}
+
+public void scroll(int destX, int destY, int x, int y, int width, int height, boolean all) {
+	super.scroll(destX, destY, x, y, width, height, false);
+	if (all) {
+		int deltaX = destX - x, deltaY = destY - y;
+		Control[] children = getChildren();
+		for (int i=0; i<children.length; i++) {
+			Control child = children[i];
+			Rectangle rect = child.getBounds();
+			child.setLocation(rect.x + deltaX, rect.y + deltaY);
+		}
+	}
+}
+
+/**
+ * Scrolls the widget horizontally.
+ *
+ * @param pixels number of pixels to scroll, > 0 = scroll left,
+ * 	< 0 scroll right
+ * @param adjustScrollBar 
+ * 	true= the scroll thumb will be moved to reflect the new scroll offset.
+ * 	false = the scroll thumb will not be moved
+ * @return 
+ *	true=the widget was scrolled 
+ *	false=the widget was not scrolled, the given offset is not valid.
+ */
+boolean scrollHorizontal(int pixels, boolean adjustScrollBar) {
+	if (pixels == 0) {
+		return false;
+	}
+	ScrollBar horizontalBar = getHorizontalBar();
+	if (horizontalBar != null && adjustScrollBar) {
+		horizontalBar.setSelection(horizontalScrollOffset + pixels);
+	}
+	int scrollHeight = clientAreaHeight - topMargin - bottomMargin;
+	if (pixels > 0) {
+		int sourceX = leftMargin + pixels;
+		int scrollWidth = clientAreaWidth - sourceX - rightMargin;
+		if (scrollWidth > 0) {
+			scroll(leftMargin, topMargin, sourceX, topMargin, scrollWidth, scrollHeight, true);
+		}
+		if (sourceX > scrollWidth) {
+			super.redraw(leftMargin + scrollWidth, topMargin, pixels - scrollWidth, scrollHeight, true);
+		}
+	} else {
+		int destinationX = leftMargin - pixels;
+		int scrollWidth = clientAreaWidth - destinationX - rightMargin;
+		if (scrollWidth > 0) {
+			scroll(destinationX, topMargin, leftMargin, topMargin, scrollWidth, scrollHeight, true);
+		}
+		if (destinationX > scrollWidth) {
+			super.redraw(leftMargin + scrollWidth, topMargin, -pixels - scrollWidth, scrollHeight, true);
+		}
+	}
+	horizontalScrollOffset += pixels;
+	setCaretLocation();
+	return true;
+}
+/**
+ * Scrolls the widget vertically.
+ *
+ * @param pixel the new vertical scroll offset
+ * @param adjustScrollBar 
+ * 	true= the scroll thumb will be moved to reflect the new scroll offset.
+ * 	false = the scroll thumb will not be moved
+ * @return 
+ *	true=the widget was scrolled 
+ *	false=the widget was not scrolled
+ */
+boolean scrollVertical(int pixels, boolean adjustScrollBar) {
+	if (pixels == 0) {
+		return false;
+	}
+	if (verticalScrollOffset != -1) {
+		ScrollBar verticalBar = getVerticalBar();
+		if (verticalBar != null && adjustScrollBar) {
+			verticalBar.setSelection(verticalScrollOffset + pixels);
+		}
+		int scrollWidth = clientAreaWidth - leftMargin - rightMargin;
+		if (pixels > 0) {
+			int sourceY = topMargin + pixels;
+			int scrollHeight = clientAreaHeight - sourceY - bottomMargin;
+			if (scrollHeight > 0) {
+				scroll(leftMargin, topMargin, leftMargin, sourceY, scrollWidth, scrollHeight, true);
+			}
+			if (sourceY > scrollHeight) {
+				int redrawY = Math.max(0, topMargin + scrollHeight);
+				int redrawHeight = Math.min(clientAreaHeight, pixels - scrollHeight);
+				super.redraw(leftMargin, redrawY, scrollWidth, redrawHeight, true);
+			}
+		} else {
+			int destinationY = topMargin - pixels;
+			int scrollHeight = clientAreaHeight - destinationY - bottomMargin;
+			if (scrollHeight > 0) {
+				scroll(leftMargin, destinationY, leftMargin, topMargin, scrollWidth, scrollHeight, true);
+			}
+			if (destinationY > scrollHeight) {
+				int redrawY = Math.max(0, topMargin + scrollHeight);
+				int redrawHeight = Math.min(clientAreaHeight, -pixels - scrollHeight);
+				super.redraw(leftMargin, redrawY, scrollWidth, redrawHeight, true);
+			}
+		}
+		verticalScrollOffset += pixels;
+		calculateTopIndex(pixels);
+	} else {
+		calculateTopIndex(pixels);
+		super.redraw();
+	}
+	setCaretLocation();
+	return true;
+}
+void scrollText(int srcY, int destY) {
+	if (srcY == destY) return;
+	int deltaY = destY - srcY;
+	int scrollWidth = clientAreaWidth - leftMargin - rightMargin, scrollHeight;
+	if (deltaY > 0) {
+		scrollHeight = clientAreaHeight - srcY - bottomMargin;
+	} else {
+		scrollHeight = clientAreaHeight - destY - bottomMargin;
+	}
+	scroll(leftMargin, destY, leftMargin, srcY, scrollWidth, scrollHeight, true);
+	if ((0 < srcY + scrollHeight) && (topMargin > srcY)) {
+		super.redraw(leftMargin, deltaY, scrollWidth, topMargin, false);
+	}
+	if ((0 < destY + scrollHeight) && (topMargin > destY)) {
+		super.redraw(leftMargin, 0, scrollWidth, topMargin, false);
+	}
+	if ((clientAreaHeight - bottomMargin < srcY + scrollHeight) && (clientAreaHeight > srcY)) {
+		super.redraw(leftMargin, clientAreaHeight - bottomMargin + deltaY, scrollWidth, bottomMargin, false);
+	}
+	if ((clientAreaHeight - bottomMargin < destY + scrollHeight) && (clientAreaHeight > destY)) {
+		super.redraw(leftMargin, clientAreaHeight - bottomMargin, scrollWidth, bottomMargin, false);
+	}
+}
+/** 
+ * Selects all the text.
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void selectAll() {
+	checkWidget();
+	setSelection(0, Math.max(getCharCount(),0));
+}
+/**
+ * Replaces/inserts text as defined by the event.
+ *
+ * @param event the text change event. 
+ *	<ul>
+ *	<li>event.start - the replace start offset</li>
+ * 	<li>event.end - the replace end offset</li>
+ * 	<li>event.text - the new text</li>
+ *	</ul>
+ */
+void sendKeyEvent(Event event) {
+	if (editable) {
+		modifyContent(event, true);
+	}
+}
+/**
+ * Returns a StyledTextEvent that can be used to request data such 
+ * as styles and background color for a line.
+ * <p>
+ * The specified line may be a visual (wrapped) line if in word 
+ * wrap mode. The returned object will always be for a logical 
+ * (unwrapped) line.
+ * </p>
+ *
+ * @param lineOffset offset of the line. This may be the offset of
+ * 	a visual line if the widget is in word wrap mode.
+ * @param line line text. This may be the text of a visual line if 
+ * 	the widget is in word wrap mode.
+ * @return StyledTextEvent that can be used to request line data 
+ * 	for the given line.
+ */
+StyledTextEvent sendLineEvent(int eventType, int lineOffset, String line) {
+	StyledTextEvent event = null;
+	if (isListening(eventType)) {
+		event = new StyledTextEvent(content);
+		event.detail = lineOffset;
+		event.text = line;
+		event.alignment = alignment;
+		event.indent = indent;
+		event.justify = justify;
+		notifyListeners(eventType, event);
+	}
+	return event;
+}
+void sendModifyEvent(Event event) {
+	Accessible accessible = getAccessible();
+	if (event.text.length() == 0) {
+		accessible.textChanged(ACC.TEXT_DELETE, event.start, event.end - event.start);
+	} else {
+		if (event.start == event.end) {
+			accessible.textChanged(ACC.TEXT_INSERT, event.start, event.text.length());
+		} else {
+			accessible.textChanged(ACC.TEXT_DELETE, event.start, event.end - event.start);
+			accessible.textChanged(ACC.TEXT_INSERT, event.start, event.text.length());	
+		}
+	}
+	notifyListeners(SWT.Modify, event);
+}
+/**
+ * Sends the specified selection event.
+ */
+void sendSelectionEvent() {
+	getAccessible().textSelectionChanged();
+	Event event = new Event();
+	event.x = selection.x;
+	event.y = selection.y;
+	notifyListeners(SWT.Selection, event);
+}
+int sendWordBoundaryEvent(int eventType, int movement, int offset, int newOffset, String lineText, int lineOffset) {
+	if (isListening(eventType)) {
+		StyledTextEvent event = new StyledTextEvent(content);
+		event.detail = lineOffset;
+		event.text = lineText;
+		event.count = movement;
+		event.start = offset;
+		event.end = newOffset;
+		notifyListeners(eventType, event);
+		offset = event.end;
+		if (offset != newOffset) {
+			int length = getCharCount();
+			if (offset < 0) {
+				offset = 0;
+			} else if (offset > length) {
+				offset = length;
+			} else {
+				if (isLineDelimiter(offset)) {
+					SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+				}
+			}
+		}
+		return offset;
+	}
+	return newOffset;
+}
+/**
+ * Sets the alignment of the widget. The argument should be one of <code>SWT.LEFT</code>, 
+ * <code>SWT.CENTER</code> or <code>SWT.RIGHT</code>. The alignment applies for all lines.
+ * </p><p>
+ * Note that if <code>SWT.MULTI</code> is set, then <code>SWT.WRAP</code> must also be set
+ * in order to stabilize the right edge before setting alignment.
+ * </p>
+ * 
+ * @param alignment the new alignment
+ *  
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see #setLineAlignment(int, int, int)
+ *  
+ * @since 3.2
+ */
+public void setAlignment(int alignment) {
+	checkWidget();
+	alignment &= (SWT.LEFT | SWT.RIGHT | SWT.CENTER);
+	if (alignment == 0 || this.alignment == alignment) return;
+	this.alignment = alignment;
+	resetCache(0, content.getLineCount());
+	setCaretLocation();
+	super.redraw();
+}
+/**
+ * @see Control#setBackground(Color)
+ */
+public void setBackground(Color color) {
+	checkWidget();
+	background = color;
+	super.setBackground(color);
+	super.redraw();
+}
+/**
+ * Sets the receiver's caret.  Set the caret's height and location.
+ * 
+ * </p>
+ * @param caret the new caret for the receiver
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setCaret(Caret caret) {
+	checkWidget ();
+	super.setCaret(caret);
+	caretDirection = SWT.NULL;
+	if (caret != null) {
+		setCaretLocation();
+	}
+}
+/**
+ * Sets the BIDI coloring mode.  When true the BIDI text display
+ * algorithm is applied to segments of text that are the same
+ * color.
+ *
+ * @param mode the new coloring mode
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @deprecated use BidiSegmentListener instead.
+ */
+public void setBidiColoring(boolean mode) {
+	checkWidget();
+	bidiColoring = mode;
+}
+/**
+ * Moves the Caret to the current caret offset.
+ */
+void setCaretLocation() {
+	Point newCaretPos = getPointAtOffset(caretOffset);
+	setCaretLocation(newCaretPos, getCaretDirection());
+}
+void setCaretLocation(Point location, int direction) {
+	Caret caret = getCaret();
+	if (caret != null) {
+		boolean isDefaultCaret = caret == defaultCaret;
+		int lineHeight = renderer.getLineHeight();
+		int caretHeight = lineHeight;
+		if (!isFixedLineHeight() && isDefaultCaret) {
+			caretHeight = getBoundsAtOffset(caretOffset).height;
+			if (caretHeight != lineHeight) {
+				direction = SWT.DEFAULT;
+			}
+		}
+		int imageDirection = direction;
+		if (isMirrored()) {
+			if (imageDirection == SWT.LEFT) {
+				imageDirection = SWT.RIGHT;
+			} else if (imageDirection == SWT.RIGHT) {
+				imageDirection = SWT.LEFT;
+			}
+		}
+		if (isDefaultCaret && imageDirection == SWT.RIGHT) {
+			location.x -= (caret.getSize().x - 1);
+		}
+		if (isDefaultCaret) {
+			caret.setBounds(location.x, location.y, caretWidth, caretHeight);
+		} else {
+			caret.setLocation(location);
+		}
+		getAccessible().textCaretMoved(getCaretOffset());
+		if (direction != caretDirection) {
+			caretDirection = direction;
+			if (isDefaultCaret) {
+				if (imageDirection == SWT.DEFAULT) {
+					defaultCaret.setImage(null);
+				} else if (imageDirection == SWT.LEFT) {
+					defaultCaret.setImage(leftCaretBitmap);
+				} else if (imageDirection == SWT.RIGHT) {
+					defaultCaret.setImage(rightCaretBitmap);
+				}
+			}
+			if (caretDirection == SWT.LEFT) {
+				BidiUtil.setKeyboardLanguage(BidiUtil.KEYBOARD_NON_BIDI);
+			} else if (caretDirection == SWT.RIGHT) {
+				BidiUtil.setKeyboardLanguage(BidiUtil.KEYBOARD_BIDI);
+			}
+		}
+	}
+	columnX = location.x;
+}
+/**
+ * Sets the caret offset.
+ *
+ * @param offset caret offset, relative to the first character in the text.
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *   <li>ERROR_INVALID_ARGUMENT when either the start or the end of the selection range is inside a 
+ * multi byte line delimiter (and thus neither clearly in front of or after the line delimiter)
+ * </ul>
+ */
+public void setCaretOffset(int offset) {
+	checkWidget();
+	int length = getCharCount();
+	if (length > 0 && offset != caretOffset) {
+		if (offset < 0) {
+			caretOffset = 0;
+		} else if (offset > length) {
+			caretOffset = length;
+		} else {
+			if (isLineDelimiter(offset)) {
+				// offset is inside a multi byte line delimiter. This is an 
+				// illegal operation and an exception is thrown. Fixes 1GDKK3R
+				SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+			}
+			caretOffset = offset;
+		}
+		caretAlignment = PREVIOUS_OFFSET_TRAILING;
+		// clear the selection if the caret is moved.
+		// don't notify listeners about the selection change.
+		clearSelection(false);
+	}
+	setCaretLocation();
+}	
+/**
+ * Copies the specified text range to the clipboard.  The text will be placed
+ * in the clipboard in plain text format and RTF format.
+ *
+ * @param start start index of the text
+ * @param length length of text to place in clipboard
+ * 
+ * @exception SWTError, see Clipboard.setContents
+ * @see org.eclipse.swt.dnd.Clipboard#setContents
+ */
+void setClipboardContent(int start, int length, int clipboardType) throws SWTError {
+	if (clipboardType == DND.SELECTION_CLIPBOARD && !(IS_MOTIF || IS_GTK)) return;
+	TextTransfer plainTextTransfer = TextTransfer.getInstance();
+	TextWriter plainTextWriter = new TextWriter(start, length);
+	String plainText = getPlatformDelimitedText(plainTextWriter);
+	Object[] data;
+	Transfer[] types;
+	if (clipboardType == DND.SELECTION_CLIPBOARD) {
+		data = new Object[]{plainText};
+		types = new Transfer[]{plainTextTransfer};
+	} else {
+		RTFTransfer rtfTransfer = RTFTransfer.getInstance();
+		RTFWriter rtfWriter = new RTFWriter(start, length);
+		String rtfText = getPlatformDelimitedText(rtfWriter);
+		data = new Object[]{rtfText, plainText};
+		types = new Transfer[]{rtfTransfer, plainTextTransfer};
+	}
+	clipboard.setContents(data, types, clipboardType);
+}
+/**
+ * Sets the content implementation to use for text storage.
+ *
+ * @param newContent StyledTextContent implementation to use for text storage.
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT when listener is null</li>
+ * </ul>
+ */
+public void setContent(StyledTextContent newContent) {
+	checkWidget();	
+	if (newContent == null) {
+		SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	}
+	if (content != null) {
+		content.removeTextChangeListener(textChangeListener);
+	}
+	content = newContent;
+	content.addTextChangeListener(textChangeListener);
+	reset();
+}
+/**
+ * Sets the receiver's cursor to the cursor specified by the
+ * argument.  Overridden to handle the null case since the 
+ * StyledText widget uses an ibeam as its default cursor.
+ *
+ * @see Control#setCursor(Cursor)
+ */
+public void setCursor (Cursor cursor) {
+	if (cursor == null) {
+		Display display = getDisplay();
+		super.setCursor(display.getSystemCursor(SWT.CURSOR_IBEAM));
+	} else {
+		super.setCursor(cursor);
+	}
+}
+/** 
+ * Sets whether the widget implements double click mouse behavior.
+ * </p>
+ *
+ * @param enable if true double clicking a word selects the word, if false
+ * 	double clicks have the same effect as regular mouse clicks.
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setDoubleClickEnabled(boolean enable) {
+	checkWidget();
+	doubleClickEnabled = enable;
+}
+public void setDragDetect (boolean dragDetect) {
+	checkWidget ();
+	this.dragDetect = dragDetect;
+}
+/**
+ * Sets whether the widget content can be edited.
+ * </p>
+ *
+ * @param editable if true content can be edited, if false content can not be 
+ * 	edited
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setEditable(boolean editable) {
+	checkWidget();
+	this.editable = editable;
+}
+/**
+ * Sets a new font to render text with.
+ * <p>
+ * <b>NOTE:</b> Italic fonts are not supported unless they have no overhang
+ * and the same baseline as regular fonts.
+ * </p>
+ *
+ * @param font new font
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setFont(Font font) {
+	checkWidget();
+	int oldLineHeight = renderer.getLineHeight();
+	super.setFont(font);	
+	renderer.setFont(getFont(), tabLength);
+	// keep the same top line visible. fixes 5815
+	if (isFixedLineHeight()) {
+		int lineHeight = renderer.getLineHeight();
+		if (lineHeight != oldLineHeight) {
+			int vscroll = (getVerticalScrollOffset() * lineHeight / oldLineHeight) - getVerticalScrollOffset();
+			scrollVertical(vscroll, true);
+		}
+	}
+	resetCache(0, content.getLineCount());
+	claimBottomFreeSpace();	
+	calculateScrollBars();
+	if (isBidiCaret()) createCaretBitmaps();
+	caretDirection = SWT.NULL;
+	setCaretLocation();
+	super.redraw();
+}
+public void setForeground(Color color) {
+	checkWidget();
+	foreground = color;
+	super.setForeground(getForeground());
+	super.redraw();
+}
+/** 
+ * Sets the horizontal scroll offset relative to the start of the line.
+ * Do nothing if there is no text set.
+ * <p>
+ * <b>NOTE:</b> The horizontal index is reset to 0 when new text is set in the 
+ * widget.
+ * </p>
+ *
+ * @param offset horizontal scroll offset relative to the start 
+ * 	of the line, measured in character increments starting at 0, if 
+ * 	equal to 0 the content is not scrolled, if > 0 = the content is scrolled.
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setHorizontalIndex(int offset) {
+	checkWidget();
+	if (getCharCount() == 0) {
+		return;
+	}	
+	if (offset < 0) {
+		offset = 0;
+	}
+	offset *= getHorizontalIncrement();
+	// allow any value if client area width is unknown or 0. 
+	// offset will be checked in resize handler.
+	// don't use isVisible since width is known even if widget 
+	// is temporarily invisible
+	if (clientAreaWidth > 0) {
+		int width = renderer.getWidth();
+		// prevent scrolling if the content fits in the client area.
+		// align end of longest line with right border of client area
+		// if offset is out of range.
+		if (offset > width - clientAreaWidth) {
+			offset = Math.max(0, width - clientAreaWidth);
+		}
+	}
+	scrollHorizontal(offset - horizontalScrollOffset, true);
+}
+/** 
+ * Sets the horizontal pixel offset relative to the start of the line.
+ * Do nothing if there is no text set.
+ * <p>
+ * <b>NOTE:</b> The horizontal pixel offset is reset to 0 when new text 
+ * is set in the widget.
+ * </p>
+ *
+ * @param pixel horizontal pixel offset relative to the start 
+ * 	of the line.
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @since 2.0
+ */
+public void setHorizontalPixel(int pixel) {
+	checkWidget();
+	if (getCharCount() == 0) {
+		return;
+	}	
+	if (pixel < 0) {
+		pixel = 0;
+	}
+	// allow any value if client area width is unknown or 0. 
+	// offset will be checked in resize handler.
+	// don't use isVisible since width is known even if widget 
+	// is temporarily invisible
+	if (clientAreaWidth > 0) {
+		int width = renderer.getWidth();
+		// prevent scrolling if the content fits in the client area.
+		// align end of longest line with right border of client area
+		// if offset is out of range.
+		if (pixel > width - clientAreaWidth) {
+			pixel = Math.max(0, width - clientAreaWidth);
+		}
+	}
+	scrollHorizontal(pixel - horizontalScrollOffset, true);
+}
+/**
+ * Sets the line indentation of the widget.
+ * <p>
+ * It is the amount of blank space, in pixels, at the beginning of each line. 
+ * When a line wraps in several lines only the first one is indented. 
+ * </p>
+ * 
+ * @param indent the new indent
+ *  
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see #setLineIndent(int, int, int)
+ *  
+ * @since 3.2
+ */
+public void setIndent(int indent) {
+	checkWidget();
+	if (this.indent == indent || indent < 0) return;
+	this.indent = indent;
+	resetCache(0, content.getLineCount());
+	setCaretLocation();
+	super.redraw();	
+}
+/**
+ * Sets whether the widget should justify lines.  
+ * 
+ * @param justify whether lines should be justified
+ *  
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see #setLineJustify(int, int, boolean)
+ *  
+ * @since 3.2
+ */
+public void setJustify(boolean justify) {
+	checkWidget();
+	if (this.justify == justify) return;
+	this.justify = justify;
+	resetCache(0, content.getLineCount());
+	setCaretLocation();
+	super.redraw();	
+}
+/** 
+ * Maps a key to an action.
+ * <p>
+ * One action can be associated with N keys. However, each key can only 
+ * have one action (key:action is N:1 relation).
+ * </p>
+ *
+ * @param key a key code defined in SWT.java or a character. 
+ * 	Optionally ORd with a state mask.  Preferred state masks are one or more of
+ *  SWT.MOD1, SWT.MOD2, SWT.MOD3, since these masks account for modifier platform 
+ *  differences.  However, there may be cases where using the specific state masks
+ *  (i.e., SWT.CTRL, SWT.SHIFT, SWT.ALT, SWT.COMMAND) makes sense.
+ * @param action one of the predefined actions defined in ST.java. 
+ * 	Use SWT.NULL to remove a key binding.
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setKeyBinding(int key, int action) {
+	checkWidget();
+	int modifierValue = key & SWT.MODIFIER_MASK;
+	char keyChar = (char)(key & SWT.KEY_MASK);
+	if (Compatibility.isLetter(keyChar)) {
+		// make the keybinding case insensitive by adding it
+		// in its upper and lower case form
+		char ch = Character.toUpperCase(keyChar);
+		int newKey = ch | modifierValue;
+		if (action == SWT.NULL) {
+			keyActionMap.remove(new Integer(newKey));
+		} else {
+		 	keyActionMap.put(new Integer(newKey), new Integer(action));
+		}
+		ch = Character.toLowerCase(keyChar);
+		newKey = ch | modifierValue;
+		if (action == SWT.NULL) {
+			keyActionMap.remove(new Integer(newKey));
+		} else {
+		 	keyActionMap.put(new Integer(newKey), new Integer(action));
+		}
+	} else {
+		if (action == SWT.NULL) {
+			keyActionMap.remove(new Integer(key));
+		} else {
+		 	keyActionMap.put(new Integer(key), new Integer(action));
+		}
+	}		
+}
+/**
+ * Sets the alignment of the specified lines. The argument should be one of <code>SWT.LEFT</code>, 
+ * <code>SWT.CENTER</code> or <code>SWT.RIGHT</code>.
+ * <p><p>
+ * Note that if <code>SWT.MULTI</code> is set, then <code>SWT.WRAP</code> must also be set
+ * in order to stabilize the right edge before setting alignment.
+ * </p>
+ * Should not be called if a LineStyleListener has been set since the listener 
+ * maintains the line attributes.
+ * </p><p>
+ * All line attributes are maintained relative to the line text, not the 
+ * line index that is specified in this method call.
+ * During text changes, when entire lines are inserted or removed, the line 
+ * attributes that are associated with the lines after the change 
+ * will "move" with their respective text. An entire line is defined as 
+ * extending from the first character on a line to the last and including the 
+ * line delimiter. 
+ * </p><p>
+ * When two lines are joined by deleting a line delimiter, the top line 
+ * attributes take precedence and the attributes of the bottom line are deleted. 
+ * For all other text changes line attributes will remain unchanged. 
+ *   
+ * @param startLine first line the alignment is applied to, 0 based
+ * @param lineCount number of lines the alignment applies to.
+ * @param alignment line alignment
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *   <li>ERROR_INVALID_ARGUMENT when the specified line range is invalid</li>
+ * </ul>
+ * @see #setAlignment(int)
+ * @since 3.2
+ */
+public void setLineAlignment(int startLine, int lineCount, int alignment) {
+	checkWidget();
+	if (isListening(LineGetStyle)) return;
+	if (startLine < 0 || startLine + lineCount > content.getLineCount()) {
+		SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	}
+
+	renderer.setLineAlignment(startLine, lineCount, alignment);
+	resetCache(startLine, lineCount);
+	redrawLines(startLine, lineCount);
+	int caretLine = getCaretLine();
+	if (startLine <= caretLine && caretLine < startLine + lineCount) {
+		setCaretLocation();
+	}
+}
+/** 
+ * Sets the background color of the specified lines.
+ * <p>
+ * The background color is drawn for the width of the widget. All
+ * line background colors are discarded when setText is called.
+ * The text background color if defined in a StyleRange overlays the 
+ * line background color. 
+ * </p><p>
+ * Should not be called if a LineBackgroundListener has been set since the 
+ * listener maintains the line backgrounds.
+ * </p><p>
+ * All line attributes are maintained relative to the line text, not the 
+ * line index that is specified in this method call.
+ * During text changes, when entire lines are inserted or removed, the line 
+ * attributes that are associated with the lines after the change 
+ * will "move" with their respective text. An entire line is defined as 
+ * extending from the first character on a line to the last and including the 
+ * line delimiter. 
+ * </p><p>
+ * When two lines are joined by deleting a line delimiter, the top line 
+ * attributes take precedence and the attributes of the bottom line are deleted. 
+ * For all other text changes line attributes will remain unchanged. 
+ * </p>
+ * 
+ * @param startLine first line the color is applied to, 0 based
+ * @param lineCount number of lines the color applies to.
+ * @param background line background color
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *   <li>ERROR_INVALID_ARGUMENT when the specified line range is invalid</li>
+ * </ul>
+ */
+public void setLineBackground(int startLine, int lineCount, Color background) {
+	checkWidget();	
+	if (isListening(LineGetBackground)) return;
+	if (startLine < 0 || startLine + lineCount > content.getLineCount()) {
+		SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	}
+	if (background != null) {
+		renderer.setLineBackground(startLine, lineCount, background);
+	} else {
+		renderer.clearLineBackground(startLine, lineCount);
+	}
+	redrawLines(startLine, lineCount);
+}
+/**
+ * Sets the bullet of the specified lines.
+ * <p>
+ * Should not be called if a LineStyleListener has been set since the listener 
+ * maintains the line attributes.
+ * </p><p>
+ * All line attributes are maintained relative to the line text, not the 
+ * line index that is specified in this method call.
+ * During text changes, when entire lines are inserted or removed, the line 
+ * attributes that are associated with the lines after the change 
+ * will "move" with their respective text. An entire line is defined as 
+ * extending from the first character on a line to the last and including the 
+ * line delimiter. 
+ * </p><p>
+ * When two lines are joined by deleting a line delimiter, the top line 
+ * attributes take precedence and the attributes of the bottom line are deleted. 
+ * For all other text changes line attributes will remain unchanged.
+ * </p>
+ *
+ * @param startLine first line the bullet is applied to, 0 based
+ * @param lineCount number of lines the bullet applies to.
+ * @param bullet line bullet
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *   <li>ERROR_INVALID_ARGUMENT when the specified line range is invalid</li>
+ * </ul>
+ * @since 3.2
+ */
+public void setLineBullet(int startLine, int lineCount, Bullet bullet) {
+	checkWidget();
+	if (isListening(LineGetStyle)) return;	
+	if (startLine < 0 || startLine + lineCount > content.getLineCount()) {
+		SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	}
+
+	renderer.setLineBullet(startLine, lineCount, bullet);
+	resetCache(startLine, lineCount);
+	redrawLines(startLine, lineCount);
+	int caretLine = getCaretLine();
+	if (startLine <= caretLine && caretLine < startLine + lineCount) {
+		setCaretLocation();
+	}
+}
+void setVariableLineHeight () {
+	if (!fixedLineHeight) return;
+	fixedLineHeight = false;
+	renderer.calculateIdle();
+}
+/**
+ * Sets the indent of the specified lines.
+ * <p>
+ * Should not be called if a LineStyleListener has been set since the listener 
+ * maintains the line attributes.
+ * </p><p>
+ * All line attributes are maintained relative to the line text, not the 
+ * line index that is specified in this method call.
+ * During text changes, when entire lines are inserted or removed, the line 
+ * attributes that are associated with the lines after the change 
+ * will "move" with their respective text. An entire line is defined as 
+ * extending from the first character on a line to the last and including the 
+ * line delimiter. 
+ * </p><p>
+ * When two lines are joined by deleting a line delimiter, the top line 
+ * attributes take precedence and the attributes of the bottom line are deleted. 
+ * For all other text changes line attributes will remain unchanged.
+ * </p>
+ *
+ * @param startLine first line the indent is applied to, 0 based
+ * @param lineCount number of lines the indent applies to.
+ * @param indent line indent
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *   <li>ERROR_INVALID_ARGUMENT when the specified line range is invalid</li>
+ * </ul>
+ * @see #setIndent(int)
+ * @since 3.2
+ */
+public void setLineIndent(int startLine, int lineCount, int indent) {
+	checkWidget();
+	if (isListening(LineGetStyle)) return;
+	if (startLine < 0 || startLine + lineCount > content.getLineCount()) {
+		SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	}
+
+	renderer.setLineIndent(startLine, lineCount, indent);
+	resetCache(startLine, lineCount);
+	redrawLines(startLine, lineCount);
+	int caretLine = getCaretLine();
+	if (startLine <= caretLine && caretLine < startLine + lineCount) {
+		setCaretLocation();
+	}
+}
+/**
+ * Sets the justify of the specified lines.
+ * <p>
+ * Should not be called if a LineStyleListener has been set since the listener 
+ * maintains the line attributes.
+ * </p><p>
+ * All line attributes are maintained relative to the line text, not the 
+ * line index that is specified in this method call.
+ * During text changes, when entire lines are inserted or removed, the line 
+ * attributes that are associated with the lines after the change 
+ * will "move" with their respective text. An entire line is defined as 
+ * extending from the first character on a line to the last and including the 
+ * line delimiter. 
+ * </p><p>
+ * When two lines are joined by deleting a line delimiter, the top line 
+ * attributes take precedence and the attributes of the bottom line are deleted. 
+ * For all other text changes line attributes will remain unchanged.
+ * </p>
+ *  
+ * @param startLine first line the justify is applied to, 0 based
+ * @param lineCount number of lines the justify applies to.
+ * @param justify true if lines should be justified
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *   <li>ERROR_INVALID_ARGUMENT when the specified line range is invalid</li>
+ * </ul>
+ * @see #setJustify(boolean)
+ * @since 3.2
+ */
+public void setLineJustify(int startLine, int lineCount, boolean justify) {
+	checkWidget();
+	if (isListening(LineGetStyle)) return;
+	if (startLine < 0 || startLine + lineCount > content.getLineCount()) {
+		SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	}
+
+	renderer.setLineJustify(startLine, lineCount, justify);
+	resetCache(startLine, lineCount);
+	redrawLines(startLine, lineCount);
+	int caretLine = getCaretLine();
+	if (startLine <= caretLine && caretLine < startLine + lineCount) {
+		setCaretLocation();
+	}
+}
+/**
+ * Sets the line spacing of the widget. The line spacing applies for all lines.
+ * 
+ * @param lineSpacing the line spacing
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @since 3.2
+ */
+public void setLineSpacing(int lineSpacing) {
+	checkWidget();
+	if (this.lineSpacing == lineSpacing || lineSpacing < 0) return;
+	this.lineSpacing = lineSpacing;	
+	setVariableLineHeight();
+	resetCache(0, content.getLineCount());
+	setCaretLocation();
+	super.redraw();
+}
+void setMargins (int leftMargin, int topMargin, int rightMargin, int bottomMargin) {
+	checkWidget();
+	this.leftMargin = leftMargin;
+	this.topMargin = topMargin;
+	this.rightMargin = rightMargin;
+	this.bottomMargin = bottomMargin;
+	setCaretLocation();
+}
+/**
+ * Flips selection anchor based on word selection direction.
+ */
+void setMouseWordSelectionAnchor() {
+	if (clickCount > 1) {
+		if (caretOffset < doubleClickSelection.x) {
+			selectionAnchor = doubleClickSelection.y;
+		} else if (caretOffset > doubleClickSelection.y) {
+			selectionAnchor = doubleClickSelection.x;
+		}
+	}
+}
+/**
+ * Sets the orientation of the receiver, which must be one
+ * of the constants <code>SWT.LEFT_TO_RIGHT</code> or <code>SWT.RIGHT_TO_LEFT</code>.
+ *
+ * @param orientation new orientation style
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 2.1.2
+ */
+public void setOrientation(int orientation) {
+	if ((orientation & (SWT.RIGHT_TO_LEFT | SWT.LEFT_TO_RIGHT)) == 0) { 
+		return;
+	}
+	if ((orientation & SWT.RIGHT_TO_LEFT) != 0 && (orientation & SWT.LEFT_TO_RIGHT) != 0) {
+		return;	
+	}
+	if ((orientation & SWT.RIGHT_TO_LEFT) != 0 && isMirrored()) {
+		return;	
+	} 
+	if ((orientation & SWT.LEFT_TO_RIGHT) != 0 && !isMirrored()) {
+		return;
+	}
+	if (!BidiUtil.setOrientation(this, orientation)) {
+		return;
+	}
+	isMirrored = (orientation & SWT.RIGHT_TO_LEFT) != 0;
+	caretDirection = SWT.NULL;
+	resetCache(0, content.getLineCount());
+	setCaretLocation();
+	keyActionMap.clear();
+	createKeyBindings();
+	super.redraw();
+}
+/**
+ * Adjusts the maximum and the page size of the scroll bars to 
+ * reflect content width/length changes.
+ * 
+ * @param vertical indicates if the vertical scrollbar also needs to be set 
+ */
+void setScrollBars(boolean vertical) {
+	int inactive = 1;
+	if (vertical || !isFixedLineHeight()) {
+		ScrollBar verticalBar = getVerticalBar();
+		if (verticalBar != null) {
+			int maximum = renderer.getHeight();
+			// only set the real values if the scroll bar can be used 
+			// (ie. because the thumb size is less than the scroll maximum)
+			// avoids flashing on Motif, fixes 1G7RE1J and 1G5SE92
+			if (clientAreaHeight < maximum) {
+				verticalBar.setMaximum(maximum);
+				verticalBar.setThumb(clientAreaHeight);
+				verticalBar.setPageIncrement(clientAreaHeight);
+			} else if (verticalBar.getThumb() != inactive || verticalBar.getMaximum() != inactive) {
+				verticalBar.setValues(
+					verticalBar.getSelection(),
+					verticalBar.getMinimum(),
+					inactive,
+					inactive,
+					verticalBar.getIncrement(),
+					inactive);
+			}
+		}
+	}
+	ScrollBar horizontalBar = getHorizontalBar();
+	if (horizontalBar != null && horizontalBar.getVisible()) {
+		int maximum = renderer.getWidth();
+		// only set the real values if the scroll bar can be used 
+		// (ie. because the thumb size is less than the scroll maximum)
+		// avoids flashing on Motif, fixes 1G7RE1J and 1G5SE92
+		if (clientAreaWidth < maximum) {
+			horizontalBar.setMaximum(maximum);
+			horizontalBar.setThumb(clientAreaWidth - leftMargin - rightMargin);
+			horizontalBar.setPageIncrement(clientAreaWidth - leftMargin - rightMargin);
+		} else if (horizontalBar.getThumb() != inactive || horizontalBar.getMaximum() != inactive) {
+			horizontalBar.setValues(
+				horizontalBar.getSelection(),
+				horizontalBar.getMinimum(),
+				inactive,
+				inactive,
+				horizontalBar.getIncrement(),
+				inactive);
+		}
+	}
+}
+/** 
+ * Sets the selection to the given position and scrolls it into view.  Equivalent to setSelection(start,start).
+ *
+ * @param start new caret position
+ * @see #setSelection(int,int)
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *   <li>ERROR_INVALID_ARGUMENT when either the start or the end of the selection range is inside a 
+ * multi byte line delimiter (and thus neither clearly in front of or after the line delimiter)
+ * </ul> 
+ */
+public void setSelection(int start) {
+	// checkWidget test done in setSelectionRange	
+	setSelection(start, start);
+}
+/** 
+ * Sets the selection and scrolls it into view.
+ * <p>
+ * Indexing is zero based.  Text selections are specified in terms of
+ * caret positions.  In a text widget that contains N characters, there are 
+ * N+1 caret positions, ranging from 0..N
+ * </p>
+ *
+ * @param point x=selection start offset, y=selection end offset
+ * 	The caret will be placed at the selection start when x > y.
+ * @see #setSelection(int,int)
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *   <li>ERROR_NULL_ARGUMENT when point is null</li>
+ *   <li>ERROR_INVALID_ARGUMENT when either the start or the end of the selection range is inside a 
+ * multi byte line delimiter (and thus neither clearly in front of or after the line delimiter)
+ * </ul> 
+ */
+public void setSelection(Point point) {
+	checkWidget();
+	if (point == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);	
+	setSelection(point.x, point.y);
+}
+/**
+ * Sets the receiver's selection background color to the color specified
+ * by the argument, or to the default system color for the control
+ * if the argument is null.
+ *
+ * @param color the new color (or null)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li> 
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @since 2.1
+ */
+public void setSelectionBackground (Color color) {
+	checkWidget ();
+	if (color != null) {
+		if (color.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	}
+	selectionBackground = color;
+	super.redraw();
+}
+/**
+ * Sets the receiver's selection foreground color to the color specified
+ * by the argument, or to the default system color for the control
+ * if the argument is null. 
+ * <p>
+ * Note that this is a <em>HINT</em>. Some platforms do not allow the application
+ * to change the selection foreground color.
+ * </p>
+ * @param color the new color (or null)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li> 
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @since 2.1
+ */
+public void setSelectionForeground (Color color) {
+	checkWidget ();
+	if (color != null) {
+		if (color.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	}
+	selectionForeground = color;
+	super.redraw();
+}
+/** 
+ * Sets the selection and scrolls it into view.
+ * <p>
+ * Indexing is zero based.  Text selections are specified in terms of
+ * caret positions.  In a text widget that contains N characters, there are 
+ * N+1 caret positions, ranging from 0..N
+ * </p>
+ *
+ * @param start selection start offset. The caret will be placed at the 
+ * 	selection start when start > end.
+ * @param end selection end offset
+ * @see #setSelectionRange(int,int)
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *   <li>ERROR_INVALID_ARGUMENT when either the start or the end of the selection range is inside a 
+ * multi byte line delimiter (and thus neither clearly in front of or after the line delimiter)
+ * </ul>
+ */
+public void setSelection(int start, int end) {
+	setSelectionRange(start, end - start);
+	showSelection();
+}
+/** 
+ * Sets the selection.
+ * <p>
+ * The new selection may not be visible. Call showSelection to scroll 
+ * the selection into view.
+ * </p>
+ *
+ * @param start offset of the first selected character, start >= 0 must be true.
+ * @param length number of characters to select, 0 <= start + length 
+ * 	<= getCharCount() must be true. 
+ * 	A negative length places the caret at the selection start.
+ * @param sendEvent a Selection event is sent when set to true and when 
+ * 	the selection is reset.
+ */
+void setSelection(int start, int length, boolean sendEvent) {
+	int end = start + length;
+	if (start > end) {
+		int temp = end;
+		end = start;
+		start = temp;
+	}
+	// is the selection range different or is the selection direction 
+	// different?
+	if (selection.x != start || selection.y != end || 
+		(length > 0 && selectionAnchor != selection.x) || 
+		(length < 0 && selectionAnchor != selection.y)) {
+		clearSelection(sendEvent);
+		if (length < 0) {
+			selectionAnchor = selection.y = end;
+			caretOffset = selection.x = start;
+		} else {
+			selectionAnchor = selection.x = start;
+			caretOffset = selection.y = end;
+		}
+		caretAlignment = PREVIOUS_OFFSET_TRAILING;
+		internalRedrawRange(selection.x, selection.y - selection.x);
+	}
+}
+/** 
+ * Sets the selection.
+ * <p>
+ * The new selection may not be visible. Call showSelection to scroll the selection
+ * into view. A negative length places the caret at the visual start of the selection.
+ * </p>
+ *
+ * @param start offset of the first selected character
+ * @param length number of characters to select
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *   <li>ERROR_INVALID_ARGUMENT when either the start or the end of the selection range is inside a 
+ * multi byte line delimiter (and thus neither clearly in front of or after the line delimiter)
+ * </ul>
+ */
+public void setSelectionRange(int start, int length) {
+	checkWidget();
+	int contentLength = getCharCount();
+	start = Math.max(0, Math.min (start, contentLength));
+	int end = start + length;
+	if (end < 0) {
+		length = -start;
+	} else {
+		if (end > contentLength) length = contentLength - start;
+	}
+	if (isLineDelimiter(start) || isLineDelimiter(start + length)) {
+		// the start offset or end offset of the selection range is inside a 
+		// multi byte line delimiter. This is an illegal operation and an exception 
+		// is thrown. Fixes 1GDKK3R
+		SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	}
+	setSelection(start, length, false);
+	setCaretLocation();
+}
+/** 
+ * Adds the specified style.
+ * <p>
+ * The new style overwrites existing styles for the specified range.
+ * Existing style ranges are adjusted if they partially overlap with 
+ * the new style. To clear an individual style, call setStyleRange 
+ * with a StyleRange that has null attributes. 
+ * </p><p>
+ * Should not be called if a LineStyleListener has been set since the 
+ * listener maintains the styles.
+ * </p>
+ *
+ * @param range StyleRange object containing the style information.
+ * Overwrites the old style in the given range. May be null to delete
+ * all styles.
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *   <li>ERROR_INVALID_RANGE when the style range is outside the valid range (> getCharCount())</li> 
+ * </ul>
+ */
+public void setStyleRange(StyleRange range) {
+	checkWidget();
+	if (isListening(LineGetStyle)) return;
+	if (range != null) {
+		if (range.isUnstyled()) {
+			setStyleRanges(range.start, range.length, null, null, false);
+		} else {
+			setStyleRanges(range.start, 0, null, new StyleRange[]{range}, false);
+		}
+	} else {
+		setStyleRanges(0, 0, null, null, true);
+	}
+}
+/** 
+ * Clears the styles in the range specified by <code>start</code> and 
+ * <code>length</code> and adds the new styles.
+ * <p>
+ * The ranges array contains start and length pairs.  Each pair refers to
+ * the corresponding style in the styles array.  For example, the pair
+ * that starts at ranges[n] with length ranges[n+1] uses the style
+ * at styles[n/2].  The range fields within each StyleRange are ignored.
+ * If ranges or styles is null, the specified range is cleared.
+ * </p><p>
+ * Note: It is expected that the same instance of a StyleRange will occur
+ * multiple times within the styles array, reducing memory usage.
+ * </p><p>
+ * Should not be called if a LineStyleListener has been set since the 
+ * listener maintains the styles.
+ * </p>
+ *
+ * @param start offset of first character where styles will be deleted
+ * @param length length of the range to delete styles in
+ * @param ranges the array of ranges.  The ranges must not overlap and must be in order.
+ * @param styles the array of StyleRanges.  The range fields within the StyleRange are unused.
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT when an element in the styles array is null</li>
+ *    <li>ERROR_INVALID_RANGE when the number of ranges and style do not match (ranges.length * 2 == styles.length)</li> 
+ *    <li>ERROR_INVALID_RANGE when a range is outside the valid range (> getCharCount() or less than zero)</li> 
+ *    <li>ERROR_INVALID_RANGE when a range overlaps</li> 
+ * </ul>
+ * 
+ * @since 3.2 
+ */
+public void setStyleRanges(int start, int length, int[] ranges, StyleRange[] styles) {
+	checkWidget();
+	if (isListening(LineGetStyle)) return;
+	if (ranges == null || styles == null) {
+		setStyleRanges(start, length, null, null, false);
+	} else {
+		setStyleRanges(start, length, ranges, styles, false);
+	}
+}
+/** 
+ * Sets styles to be used for rendering the widget content.
+ * <p>
+ * All styles in the widget will be replaced with the given set of ranges and styles.
+ * The ranges array contains start and length pairs.  Each pair refers to
+ * the corresponding style in the styles array.  For example, the pair
+ * that starts at ranges[n] with length ranges[n+1] uses the style
+ * at styles[n/2].  The range fields within each StyleRange are ignored.
+ * If either argument is null, the styles are cleared.
+ * </p><p>
+ * Note: It is expected that the same instance of a StyleRange will occur
+ * multiple times within the styles array, reducing memory usage.
+ * </p><p>
+ * Should not be called if a LineStyleListener has been set since the 
+ * listener maintains the styles.
+ * </p>
+ *
+ * @param ranges the array of ranges.  The ranges must not overlap and must be in order.
+ * @param styles the array of StyleRanges.  The range fields within the StyleRange are unused.
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT when an element in the styles array is null</li>
+ *    <li>ERROR_INVALID_RANGE when the number of ranges and style do not match (ranges.length * 2 == styles.length)</li> 
+ *    <li>ERROR_INVALID_RANGE when a range is outside the valid range (> getCharCount() or less than zero)</li> 
+ *    <li>ERROR_INVALID_RANGE when a range overlaps</li> 
+ * </ul>
+ * 
+ * @since 3.2 
+ */
+public void setStyleRanges(int[] ranges, StyleRange[] styles) {
+	checkWidget();
+	if (isListening(LineGetStyle)) return;
+	if (ranges == null || styles == null) {
+		setStyleRanges(0, 0, null, null, true);
+	} else {
+		setStyleRanges(0, 0, ranges, styles, true);
+	}
+}
+void setStyleRanges(int start, int length, int[] ranges, StyleRange[] styles, boolean reset) {
+	int charCount = content.getCharCount();
+	int end = start + length;
+	if (start > end || start < 0) {
+		SWT.error(SWT.ERROR_INVALID_RANGE);
+	}
+	if (styles != null) {
+		if (end > charCount) {
+			SWT.error(SWT.ERROR_INVALID_RANGE);
+		}
+		if (ranges != null) {
+			if (ranges.length != styles.length << 1) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+		}
+		int lastOffset = 0;
+		boolean variableHeight = false; 
+		for (int i = 0; i < styles.length; i ++) {
+			if (styles[i] == null) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+			int rangeStart, rangeLength;
+			if (ranges != null) {
+				rangeStart = ranges[i << 1];
+				rangeLength = ranges[(i << 1) + 1];
+			} else {
+				rangeStart = styles[i].start;
+				rangeLength = styles[i].length;
+			}
+			if (rangeLength < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT); 
+			if (!(0 <= rangeStart && rangeStart + rangeLength <= charCount)) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+			if (lastOffset > rangeStart) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+			variableHeight |= styles[i].isVariableHeight();
+			lastOffset = rangeStart + rangeLength;
+		}
+		if (variableHeight) setVariableLineHeight();
+	}
+	int rangeStart = start, rangeEnd = end;
+	if (styles != null && styles.length > 0) {
+		if (ranges != null) {
+			rangeStart = ranges[0];
+			rangeEnd = ranges[ranges.length - 2] + ranges[ranges.length - 1];
+		} else {
+			rangeStart = styles[0].start;
+			rangeEnd = styles[styles.length - 1].start + styles[styles.length - 1].length;
+		}
+	}
+	int lastLineBottom = 0;
+	if (!isFixedLineHeight() && !reset) {
+		int lineEnd = content.getLineAtOffset(Math.max(end, rangeEnd));
+		int partialTopIndex = getPartialTopIndex();
+		int partialBottomIndex = getPartialBottomIndex();
+		if (partialTopIndex <= lineEnd && lineEnd <= partialBottomIndex) {
+			lastLineBottom = getLinePixel(lineEnd + 1);
+		}
+	}
+	if (reset) {
+		renderer.setStyleRanges(null, null);
+	} else {
+		renderer.updateRanges(start, length, length);
+	}
+	if (styles != null && styles.length > 0) {
+		renderer.setStyleRanges(ranges, styles);
+	}
+	if (reset) {
+		resetCache(0, content.getLineCount());
+		super.redraw();
+	} else {
+		int lineStart = content.getLineAtOffset(Math.min(start, rangeStart));
+		int lineEnd = content.getLineAtOffset(Math.max(end, rangeEnd));
+		resetCache(lineStart, lineEnd - lineStart + 1);
+		int partialTopIndex = getPartialTopIndex();
+		int partialBottomIndex = getPartialBottomIndex();
+		if (!(lineStart > partialBottomIndex || lineEnd < partialTopIndex)) {
+			int y = 0;
+			int height = clientAreaHeight;
+			if (partialTopIndex <= lineStart && lineStart <= partialBottomIndex) {
+				int lineTop = Math.max(y, getLinePixel(lineStart));
+				y = lineTop;
+				height -= lineTop;
+			}
+			if (partialTopIndex <= lineEnd && lineEnd <= partialBottomIndex) {
+				int newLastLineBottom = getLinePixel(lineEnd + 1);
+				if (!isFixedLineHeight()) {
+					scrollText(lastLineBottom, newLastLineBottom);
+				}
+				height = newLastLineBottom - y;
+			}
+			super.redraw(0, y, clientAreaWidth, height, false);		
+		}
+	}
+	setCaretLocation();
+}
+/** 
+ * Sets styles to be used for rendering the widget content. All styles 
+ * in the widget will be replaced with the given set of styles.
+ * <p>
+ * Note: Because a StyleRange includes the start and length, the
+ * same instance cannot occur multiple times in the array of styles.
+ * If the same style attributes, such as font and color, occur in
+ * multiple StyleRanges, <code>setStyleRanges(int[], StyleRange[])</code>
+ * can be used to share styles and reduce memory usage.
+ * </p><p>
+ * Should not be called if a LineStyleListener has been set since the 
+ * listener maintains the styles.
+ * </p>
+ *
+ * @param ranges StyleRange objects containing the style information.
+ * The ranges should not overlap. The style rendering is undefined if 
+ * the ranges do overlap. Must not be null. The styles need to be in order.
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT when the list of ranges is null</li>
+ *    <li>ERROR_INVALID_RANGE when the last of the style ranges is outside the valid range (> getCharCount())</li> 
+ * </ul>
+ * 
+ * @see #setStyleRanges(int[], StyleRange[])
+ */
+public void setStyleRanges(StyleRange[] ranges) {
+	checkWidget();
+	if (isListening(LineGetStyle)) return;
+ 	if (ranges == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	setStyleRanges(0, 0, null, ranges, true);
+}
+/** 
+ * Sets the tab width. 
+ *
+ * @param tabs tab width measured in characters.
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setTabs(int tabs) {
+	checkWidget();	
+	tabLength = tabs;
+	renderer.setFont(null, tabs);
+	resetCache(0, content.getLineCount());
+	setCaretLocation();
+	super.redraw();
+}
+/** 
+ * Sets the widget content. 
+ * If the widget has the SWT.SINGLE style and "text" contains more than 
+ * one line, only the first line is rendered but the text is stored 
+ * unchanged. A subsequent call to getText will return the same text 
+ * that was set.
+ * <p>
+ * <b>Note:</b> Only a single line of text should be set when the SWT.SINGLE 
+ * style is used.
+ * </p>
+ *
+ * @param text new widget content. Replaces existing content. Line styles 
+ * 	that were set using StyledText API are discarded.  The
+ * 	current selection is also discarded.
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT when string is null</li>
+ * </ul>
+ */
+public void setText(String text) {
+	checkWidget();
+	if (text == null) {
+		SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	}
+	Event event = new Event();
+	event.start = 0;
+	event.end = getCharCount();
+	event.text = text;
+	event.doit = true;	
+	notifyListeners(SWT.Verify, event);
+	if (event.doit) {
+		StyledTextEvent styledTextEvent = null;
+		if (isListening(ExtendedModify)) {
+			styledTextEvent = new StyledTextEvent(content);
+			styledTextEvent.start = event.start;
+			styledTextEvent.end = event.start + event.text.length();
+			styledTextEvent.text = content.getTextRange(event.start, event.end - event.start);
+		}
+		content.setText(event.text);
+		sendModifyEvent(event);	
+		if (styledTextEvent != null) {
+			notifyListeners(ExtendedModify, styledTextEvent);
+		}
+	}
+}
+/**
+ * Sets the text limit to the specified number of characters.
+ * <p>
+ * The text limit specifies the amount of text that
+ * the user can type into the widget.
+ * </p>
+ *
+ * @param limit the new text limit.
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *   <li>ERROR_CANNOT_BE_ZERO when limit is 0</li>
+ * </ul>
+ */
+public void setTextLimit(int limit) {
+	checkWidget();
+	if (limit == 0) {
+		SWT.error(SWT.ERROR_CANNOT_BE_ZERO);
+	}
+	textLimit = limit;
+}
+/**
+ * Sets the top index. Do nothing if there is no text set.
+ * <p>
+ * The top index is the index of the line that is currently at the top 
+ * of the widget. The top index changes when the widget is scrolled.
+ * Indexing starts from zero.
+ * Note: The top index is reset to 0 when new text is set in the widget.
+ * </p>
+ *
+ * @param topIndex new top index. Must be between 0 and 
+ * 	getLineCount() - fully visible lines per page. If no lines are fully 
+ * 	visible the maximum value is getLineCount() - 1. An out of range 
+ * 	index will be adjusted accordingly.
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setTopIndex(int topIndex) {
+	checkWidget();
+	if (getCharCount() == 0) {
+		return;
+	}
+	int lineCount = content.getLineCount(), pixel;
+	if (isFixedLineHeight()) {
+		int pageSize = Math.max(1, Math.min(lineCount, getLineCountWhole()));
+		if (topIndex < 0) {
+			topIndex = 0;
+		} else if (topIndex > lineCount - pageSize) {
+			topIndex = lineCount - pageSize;
+		}
+		pixel = getLinePixel(topIndex);
+	} else {
+		topIndex = Math.max(0, Math.min(lineCount - 1, topIndex));
+		pixel = getLinePixel(topIndex);
+		if (pixel > 0) {
+			pixel = getAvailableHeightBellow(pixel);
+		} else {
+			pixel = getAvailableHeightAbove(pixel);
+		}
+	} 
+	scrollVertical(pixel, true);
+}
+/**
+ * Sets the top pixel offset. Do nothing if there is no text set.
+ * <p>
+ * The top pixel offset is the vertical pixel offset of the widget. The
+ * widget is scrolled so that the given pixel position is at the top.
+ * The top index is adjusted to the corresponding top line.
+ * Note: The top pixel is reset to 0 when new text is set in the widget.
+ * </p>
+ *
+ * @param pixel new top pixel offset. Must be between 0 and 
+ * 	(getLineCount() - visible lines per page) / getLineHeight()). An out
+ * 	of range offset will be adjusted accordingly.
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @since 2.0
+ */
+public void setTopPixel(int pixel) {
+	checkWidget();
+	if (getCharCount() == 0) {
+		return;
+	}	
+	if (pixel < 0) pixel = 0;
+	int lineCount = content.getLineCount();
+	int height = clientAreaHeight - topMargin - bottomMargin;
+	int verticalOffset = getVerticalScrollOffset();
+	if (isFixedLineHeight()) {
+		int maxTopPixel = Math.max(0, lineCount * getVerticalIncrement() - height);
+		if (pixel > maxTopPixel) pixel = maxTopPixel;
+		pixel -= verticalOffset; 
+	} else {
+		pixel -= verticalOffset;
+		if (pixel > 0) {
+			pixel = getAvailableHeightBellow(pixel);
+		}
+	}
+	scrollVertical(pixel, true);
+}
+/**
+ * Sets whether the widget wraps lines.
+ * <p>
+ * This overrides the creation style bit SWT.WRAP.
+ * </p>
+ *
+ * @param wrap true=widget wraps lines, false=widget does not wrap lines
+ * @since 2.0
+ */
+public void setWordWrap(boolean wrap) {
+	checkWidget();
+	if ((getStyle() & SWT.SINGLE) != 0) return;
+	if (wordWrap == wrap) return;
+	wordWrap = wrap;
+	setVariableLineHeight();
+	resetCache(0, content.getLineCount());
+	horizontalScrollOffset = 0;
+	ScrollBar horizontalBar = getHorizontalBar();
+	if (horizontalBar != null) {
+		horizontalBar.setVisible(!wordWrap);
+	}
+	setScrollBars(true);
+	setCaretLocation();
+	super.redraw();
+}
+boolean showLocation(Rectangle rect, boolean scrollPage) {
+	int clientAreaWidth = this.clientAreaWidth - leftMargin - rightMargin;
+	int clientAreaHeight = this.clientAreaHeight - topMargin - bottomMargin;
+	boolean scrolled = false;
+	if (rect.y <= topMargin) {
+		scrolled = scrollVertical(rect.y - topMargin, true);
+	} else if (rect.y + rect.height > clientAreaHeight) {
+		if (clientAreaHeight == 0) {
+			scrolled = scrollVertical(rect.y, true);
+		} else {
+			scrolled = scrollVertical(rect.y + rect.height - clientAreaHeight, true);
+		}
+	}
+	if (clientAreaWidth > 0) {
+		int minScroll = scrollPage ? clientAreaWidth / 4 : 0;
+		if (rect.x < leftMargin) {
+			int scrollWidth = Math.max(leftMargin - rect.x, minScroll);
+			int maxScroll = horizontalScrollOffset;
+			scrolled = scrollHorizontal(-Math.min(maxScroll, scrollWidth), true);
+		} else if (rect.x + rect.width > clientAreaWidth) {
+			int scrollWidth =  Math.max(rect.x + rect.width - clientAreaWidth, minScroll);
+			int maxScroll = renderer.getWidth() - horizontalScrollOffset - this.clientAreaWidth;
+			scrolled = scrollHorizontal(Math.min(maxScroll, scrollWidth), true);
+		}
+	}
+	return scrolled;
+}
+/**
+ * Sets the caret location and scrolls the caret offset into view.
+ */
+void showCaret() {
+	Rectangle bounds = getBoundsAtOffset(caretOffset);
+	if (!showLocation(bounds, true)) {
+		setCaretLocation();
+	}
+}
+/**
+ * Scrolls the selection into view.
+ * <p>
+ * The end of the selection will be scrolled into view.
+ * Note that if a right-to-left selection exists, the end of the selection is
+ * the visual beginning of the selection (i.e., where the caret is located).
+ * </p>
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void showSelection() {
+	checkWidget();
+	// is selection from right-to-left?
+	boolean rightToLeft = caretOffset == selection.x;
+	int startOffset, endOffset;
+	if (rightToLeft) {
+		startOffset = selection.y;
+		endOffset = selection.x;
+	} else {
+		startOffset = selection.x;
+		endOffset = selection.y;
+	}
+	
+	Rectangle startBounds = getBoundsAtOffset(startOffset);
+	Rectangle endBounds = getBoundsAtOffset(endOffset);
+	
+	// can the selection be fully displayed within the widget's visible width?
+	int w = clientAreaWidth - leftMargin - rightMargin;
+	boolean selectionFits = rightToLeft ? startBounds.x - endBounds.x <= w : endBounds.x - startBounds.x <= w;
+	if (selectionFits) {
+		// show as much of the selection as possible by first showing
+		// the start of the selection
+		if (showLocation(startBounds, false)) {
+			// endX value could change if showing startX caused a scroll to occur
+			endBounds = getBoundsAtOffset(endOffset);
+		}
+		// the character at endOffset is not part of the selection
+		endBounds.width = 0;
+		showLocation(endBounds, false);
+	} else {
+		// just show the end of the selection since the selection start 
+		// will not be visible
+		showLocation(endBounds, true);
+	}
+}
+/**
+ * Updates the selection and caret position depending on the text change.
+ * <p>
+ * If the selection intersects with the replaced text, the selection is 
+ * reset and the caret moved to the end of the new text.
+ * If the selection is behind the replaced text it is moved so that the
+ * same text remains selected.  If the selection is before the replaced text 
+ * it is left unchanged.
+ * </p>
+ *
+ * @param startOffset offset of the text change
+ * @param replacedLength length of text being replaced
+ * @param newLength length of new text
+ */
+void updateSelection(int startOffset, int replacedLength, int newLength) {
+	if (selection.y <= startOffset) {
+		// selection ends before text change
+		if (wordWrap) setCaretLocation();
+		return;
+	}
+	if (selection.x < startOffset) {
+		// clear selection fragment before text change
+		internalRedrawRange(selection.x, startOffset - selection.x);
+	}
+	if (selection.y > startOffset + replacedLength && selection.x < startOffset + replacedLength) {
+		// clear selection fragment after text change.
+		// do this only when the selection is actually affected by the 
+		// change. Selection is only affected if it intersects the change (1GDY217).
+		int netNewLength = newLength - replacedLength;
+		int redrawStart = startOffset + newLength;
+		internalRedrawRange(redrawStart, selection.y + netNewLength - redrawStart);
+	}
+	if (selection.y > startOffset && selection.x < startOffset + replacedLength) {
+		// selection intersects replaced text. set caret behind text change
+		setSelection(startOffset + newLength, 0, true);
+	} else {
+		// move selection to keep same text selected
+		setSelection(selection.x + newLength - replacedLength, selection.y - selection.x, true);
+	}
+	setCaretLocation();
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/custom/StyledTextContent.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/custom/StyledTextContent.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/custom/StyledTextContent.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,207 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.custom;
+
+
+/**
+ * Clients may implement the StyledTextContent interface to provide a 
+ * custom store for the StyledText widget content. The StyledText widget 
+ * interacts with its StyledTextContent in order to access and update 
+ * the text that is being displayed and edited in the widget. 
+ * A custom content implementation can be set in the widget using the
+ * StyledText.setContent API.
+ */
+public interface StyledTextContent {
+
+/**
+ * Called by StyledText to add itself as an Observer to content changes.
+ * See TextChangeListener for a description of the listener methods that
+ * are called when text changes occur.
+ * <p>
+ *
+ * @param listener the listener
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT when listener is null</li>
+ * </ul>
+ */
+public void addTextChangeListener(TextChangeListener listener);
+
+/**
+ * Return the number of characters in the content.
+ * <p>
+ *
+ * @return the number of characters in the content.
+ */
+public int getCharCount();
+
+/**
+ * Return the line at the given line index without delimiters.
+ * <p>
+ *
+ * @param lineIndex index of the line to return. Does not include 
+ *	delimiters of preceding lines. Index 0 is the first line of the 
+ * 	content.
+ * @return the line text without delimiters
+ */
+public String getLine(int lineIndex);
+
+/**
+ * Return the line index at the given character offset.
+ * <p>
+ *
+ * @param offset offset of the line to return. The first character of the 
+ * 	document is at offset 0.  An offset of getLength() is valid and should 
+ *	answer the number of lines. 
+ * @return the line index. The first line is at index 0.  If the character 
+ * 	at offset is a delimiter character, answer the line index of the line 
+ * 	that is delimited. 
+ * 	For example, if text = "\r\n\r\n", and delimiter = "\r\n", then:
+ * <ul>
+ * <li>getLineAtOffset(0) == 0
+ * <li>getLineAtOffset(1) == 0
+ * <li>getLineAtOffset(2) == 1
+ * <li>getLineAtOffset(3) == 1
+ * <li>getLineAtOffset(4) == 2
+ * </ul>
+ */
+public int getLineAtOffset(int offset);
+
+/**
+ * Return the number of lines.  Should answer 1 when no text is specified.
+ * The  StyledText widget relies on this behavior for drawing the cursor.
+ * <p>
+ *
+ * @return the number of lines.  For example:
+ * <ul>
+ * <li>	text value ==> getLineCount		
+ * <li>	null ==> 1		
+ * <li>	"" ==> 1		
+ * <li>	"a\n" ==> 2			
+ * <li>	"\n\n" ==> 3			
+ * </ul>
+ */
+public int getLineCount();
+
+/**
+ * Return the line delimiter that should be used by the StyledText 
+ * widget when inserting new lines. New lines entered using key strokes 
+ * and paste operations use this line delimiter.
+ * Implementors may use System.getProperty("line.separator") to return
+ * the platform line delimiter.
+ * <p>
+ *
+ * @return the line delimiter that should be used by the StyledText widget
+ *	when inserting new lines.
+ */
+public String getLineDelimiter();
+
+/**
+ * Return the character offset of the first character of the given line.
+ * <p>
+ * <b>NOTE:</b> When there is no text (i.e., no lines), getOffsetAtLine(0) 
+ * is a valid call that should return 0.
+ * </p>
+ *
+ * @param lineIndex index of the line. The first line is at index 0.
+ * @return offset offset of the first character of the line. The first 
+ * 	character of the document is at offset 0.  The return value should 
+ * 	include line delimiters.  
+ * 	For example, if text = "\r\ntest\r\n" and delimiter = "\r\n", then:
+ * <ul>
+ * <li>getOffsetAtLine(0) == 0
+ * <li>getOffsetAtLine(1) == 2
+ * <li>getOffsetAtLine(2) == 8
+ * </ul>
+ */
+public int getOffsetAtLine(int lineIndex);
+
+/**
+ * Returns a string representing the content at the given range.
+ * <p>
+ *
+ * @param start the start offset of the text to return. Offset 0 is the 
+ * 	first character of the document.
+ * @param length the length of the text to return
+ * @return the text at the given range
+ */
+public String getTextRange(int start, int length);
+
+/**
+ * Remove the specified text changed listener.
+ * <p>
+ *
+ * @param listener the listener which should no longer be notified
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT when listener is null</li>
+ * </ul>
+ */
+public void removeTextChangeListener(TextChangeListener listener);
+
+/**
+ * Replace the text with "newText" starting at position "start" 
+ * for a length of "replaceLength".
+ * <p>
+ * Implementors have to notify the TextChangeListeners that were added 
+ * using <code>addTextChangeListener</code> before and after the content 
+ * is changed. A <code>TextChangingEvent</code> has to be sent to the 
+ * textChanging method before the content is changed and a 
+ * <code>TextChangedEvent</code> has to be sent to the textChanged method
+ * after the content has changed.
+ * The text change that occurs after the <code>TextChangingEvent</code> 
+ * has been sent has to be consistent with the data provided in the 
+ * <code>TextChangingEvent</code>.
+ * This data will be cached by the widget and will be used when the 
+ * <code>TextChangedEvent</code> is received.
+ * <p>
+ * The <code>TextChangingEvent</code> should be set as follows:
+ * <ul>
+ * <li>event.start = start of the replaced text
+ * <li>event.newText = text that is going to be inserted or empty String 
+ *	if no text will be inserted
+ * <li>event.replaceCharCount = length of text that is going to be replaced
+ * <li>event.newCharCount = length of text that is going to be inserted
+ * <li>event.replaceLineCount = number of lines that are going to be replaced
+ * <li>event.newLineCount = number of new lines that are going to be inserted
+ * </ul>
+ * <b>NOTE:</b> newLineCount is the number of inserted lines and replaceLineCount 
+ * is the number of deleted lines based on the change that occurs visually.  
+ * For example:
+ * <ul>
+ * <li>(replaceText, newText) ==> (replaceLineCount, newLineCount)
+ * <li>("", "\n") ==> (0, 1)
+ * <li>("\n\n", "a") ==> (2, 0)
+ * <li>("a", "\n\n") ==> (0, 2)
+ * <li>("\n", "") ==> (1, 0)
+ * </ul>
+ * </p>
+ *
+ * @param start start offset of text to replace, none of the offsets include 
+ *	delimiters of preceding lines, offset 0 is the first character of the 
+ * 	document 
+ * @param replaceLength length of text to replace
+ * @param text text to replace
+ * @see TextChangeListener
+ */
+public void replaceTextRange(int start, int replaceLength, String text);
+
+/**
+ * Set text to "text".
+ * Implementors have to send a <code>TextChangedEvent</code> to the 
+ * textSet method of the TextChangeListeners that were added using 
+ * <code>addTextChangeListener</code>.
+ * <p>
+ *
+ * @param text the new text
+ * @see TextChangeListener
+ */
+public void setText(String text);
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/custom/StyledTextDropTargetEffect.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/custom/StyledTextDropTargetEffect.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/custom/StyledTextDropTargetEffect.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,242 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.custom;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.dnd.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+
+/**
+ * This adapter class provides a default drag under effect (eg. select and scroll) 
+ * when a drag occurs over a <code>StyledText</code>.
+ * 
+ * <p>Classes that wish to provide their own drag under effect for a <code>StyledText</code>
+ * can extend this class, override the <code>StyledTextDropTargetEffect.dragOver</code>
+ * method and override any other applicable methods in <code>StyledTextDropTargetEffect</code> to 
+ * display their own drag under effect.</p>
+ *
+ * Subclasses that override any methods of this class should call the corresponding
+ * <code>super</code> method to get the default drag under effect implementation.
+ *
+ * <p>The feedback value is either one of the FEEDBACK constants defined in 
+ * class <code>DND</code> which is applicable to instances of this class, 
+ * or it must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>DND</code> effect constants. 
+ * </p>
+ * <p>
+ * <dl>
+ * <dt><b>Feedback:</b></dt>
+ * <dd>FEEDBACK_SELECT, FEEDBACK_SCROLL</dd>
+ * </dl>
+ * </p>
+ * 
+ * @see DropTargetAdapter
+ * @see DropTargetEvent
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ * 
+ * @since 3.3
+ */
+public class StyledTextDropTargetEffect extends DropTargetEffect {
+	static final int CARET_WIDTH = 2;
+	static final int SCROLL_HYSTERESIS = 100; // milli seconds
+	static final int SCROLL_TOLERANCE = 20; // pixels
+	
+	int currentOffset = -1;
+	long scrollBeginTime;
+	int scrollX = -1, scrollY = -1;
+	Listener paintListener;
+	
+	/**
+	 * Creates a new <code>StyledTextDropTargetEffect</code> to handle the drag under effect on the specified 
+	 * <code>StyledText</code>.
+	 * 
+	 * @param styledText the <code>StyledText</code> over which the user positions the cursor to drop the data
+	 */
+	public StyledTextDropTargetEffect(StyledText styledText) {
+		super(styledText);
+		paintListener = new Listener () {
+			public void handleEvent (Event event) {
+				if (currentOffset != -1) {
+					StyledText text = (StyledText) getControl();
+					Point position = text.getLocationAtOffset(currentOffset);
+					int height = text.getLineHeight(currentOffset);
+					event.gc.setBackground(event.display.getSystemColor (SWT.COLOR_BLACK));
+					event.gc.fillRectangle(position.x, position.y, CARET_WIDTH, height);
+				}
+			}
+		};
+	}
+	
+	/**
+	 * This implementation of <code>dragEnter</code> provides a default drag under effect
+	 * for the feedback specified in <code>event.feedback</code>.
+	 * 
+	 * For additional information see <code>DropTargetAdapter.dragEnter</code>.
+	 * 
+	 * Subclasses that override this method should call <code>super.dragEnter(event)</code>
+	 * to get the default drag under effect implementation.
+	 *
+	 * @param event  the information associated with the drag start event
+	 * 
+	 * @see DropTargetAdapter
+	 * @see DropTargetEvent
+	 */
+	public void dragEnter(DropTargetEvent event) {
+		currentOffset = -1;
+		scrollBeginTime = 0;
+		scrollX = -1;
+		scrollY = -1;
+		getControl().removeListener(SWT.Paint, paintListener);
+		getControl().addListener (SWT.Paint, paintListener);
+	}
+	
+	/**
+	 * This implementation of <code>dragLeave</code> provides a default drag under effect
+	 * for the feedback specified in <code>event.feedback</code>.
+	 * 
+	 * For additional information see <code>DropTargetAdapter.dragLeave</code>.
+	 * 
+	 * Subclasses that override this method should call <code>super.dragLeave(event)</code>
+	 * to get the default drag under effect implementation.
+	 *
+	 * @param event  the information associated with the drag leave event
+	 * 
+	 * @see DropTargetAdapter
+	 * @see DropTargetEvent
+	 */
+	public void dragLeave(DropTargetEvent event) {
+		StyledText text = (StyledText) getControl();
+		if (currentOffset != -1) {
+			refreshCaret(text, currentOffset, -1);
+		}
+		text.removeListener(SWT.Paint, paintListener);
+		scrollBeginTime = 0;
+		scrollX = -1;
+		scrollY = -1;
+	}
+
+	/**
+	 * This implementation of <code>dragOver</code> provides a default drag under effect
+	 * for the feedback specified in <code>event.feedback</code>.
+	 * 
+	 * For additional information see <code>DropTargetAdapter.dragOver</code>.
+	 * 
+	 * Subclasses that override this method should call <code>super.dragOver(event)</code>
+	 * to get the default drag under effect implementation.
+	 *
+	 * @param event  the information associated with the drag over event
+	 * 
+	 * @see DropTargetAdapter
+	 * @see DropTargetEvent
+	 * @see DND#FEEDBACK_SELECT
+	 * @see DND#FEEDBACK_SCROLL
+	 */
+	public void dragOver(DropTargetEvent event) {
+		int effect = event.feedback;
+		StyledText text = (StyledText) getControl();
+		
+		Point pt = text.getDisplay().map(null, text, event.x, event.y);
+		if ((effect & DND.FEEDBACK_SCROLL) == 0) {
+			scrollBeginTime = 0;
+			scrollX = scrollY = -1;
+		} else {
+			if (text.getCharCount() == 0) {
+				scrollBeginTime = 0;
+				scrollX = scrollY = -1;
+			} else {
+				if (scrollX != -1 && scrollY != -1 && scrollBeginTime != 0 &&
+					(pt.x >= scrollX && pt.x <= (scrollX + SCROLL_TOLERANCE) ||
+					 pt.y >= scrollY && pt.y <= (scrollY + SCROLL_TOLERANCE))) {
+					if (System.currentTimeMillis() >= scrollBeginTime) {
+						Rectangle area = text.getClientArea();
+						GC gc = new GC(text);
+						FontMetrics fm = gc.getFontMetrics();
+						gc.dispose();
+						int charWidth = fm.getAverageCharWidth();
+						int scrollAmount = 10*charWidth;
+						if (pt.x < area.x + 3*charWidth) {
+							int leftPixel = text.getHorizontalPixel();
+							text.setHorizontalPixel(leftPixel - scrollAmount);
+						}
+						if (pt.x > area.width - 3*charWidth) {
+							int leftPixel = text.getHorizontalPixel();
+							text.setHorizontalPixel(leftPixel + scrollAmount);
+						}
+						int lineHeight = text.getLineHeight();
+						if (pt.y < area.y + lineHeight) {
+							int topPixel = text.getTopPixel();
+							text.setTopPixel(topPixel - lineHeight);
+						}
+						if (pt.y > area.height - lineHeight) {
+							int topPixel = text.getTopPixel();
+							text.setTopPixel(topPixel + lineHeight);
+						}
+						scrollBeginTime = 0;
+						scrollX = scrollY = -1;
+					}
+				} else {
+					scrollBeginTime = System.currentTimeMillis() + SCROLL_HYSTERESIS;
+					scrollX = pt.x;
+					scrollY = pt.y;
+				}
+			}
+		}
+			
+		if ((effect & DND.FEEDBACK_SELECT) != 0) {
+			int[] trailing = new int [1];
+			int newOffset = text.getOffsetAtPoint(pt.x, pt.y, trailing, false);
+			newOffset += trailing [0];
+			if (newOffset != currentOffset) {
+				refreshCaret(text, currentOffset, newOffset);
+				currentOffset = newOffset;
+			}
+		}
+	}
+
+	void refreshCaret(StyledText text, int oldOffset, int newOffset) {
+		if (oldOffset != newOffset) {
+			if (oldOffset != -1) {
+				Point oldPos = text.getLocationAtOffset(oldOffset);
+				int oldHeight = text.getLineHeight(oldOffset);
+				text.redraw (oldPos.x, oldPos.y, CARET_WIDTH, oldHeight, false);
+			}
+			if (newOffset != -1) {
+				Point newPos = text.getLocationAtOffset(newOffset);
+				int newHeight = text.getLineHeight(newOffset);
+				text.redraw (newPos.x, newPos.y, CARET_WIDTH, newHeight, false);
+			}
+		}
+	}
+
+	/**
+	 * This implementation of <code>dropAccept</code> provides a default drag under effect
+	 * for the feedback specified in <code>event.feedback</code>.
+	 * 
+	 * For additional information see <code>DropTargetAdapter.dropAccept</code>.
+	 * 
+	 * Subclasses that override this method should call <code>super.dropAccept(event)</code>
+	 * to get the default drag under effect implementation.
+	 *
+	 * @param event  the information associated with the drop accept event
+	 * 
+	 * @see DropTargetAdapter
+	 * @see DropTargetEvent
+	 */
+	public void dropAccept(DropTargetEvent event) {
+		if (currentOffset != -1) {
+			StyledText text = (StyledText) getControl();
+			text.setSelection(currentOffset);
+			currentOffset = -1;
+		}
+	}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/custom/StyledTextEvent.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/custom/StyledTextEvent.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/custom/StyledTextEvent.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.custom;
+
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+
+/**
+ *
+ */ 
+class StyledTextEvent extends Event {
+	// used by LineStyleEvent
+	int[] ranges;
+	StyleRange[] styles;
+	int alignment;
+	int indent;
+	boolean justify;
+	Bullet bullet;
+	int bulletIndex;
+	// used by LineBackgroundEvent
+	Color lineBackground;
+	// used by BidiSegmentEvent
+	int[] segments;	
+	// used by TextChangedEvent
+	int replaceCharCount; 	
+	int newCharCount; 
+	int replaceLineCount;
+	int newLineCount;
+	// used by PaintObjectEvent
+	int x;
+	int y;
+	int ascent;
+	int descent;
+	StyleRange style;
+
+StyledTextEvent (StyledTextContent content) {
+	super();
+	data = content;	
+}
+}
+
+

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/custom/StyledTextListener.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/custom/StyledTextListener.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/custom/StyledTextListener.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,95 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.custom;
+
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.internal.SWTEventListener;
+
+class StyledTextListener extends TypedListener {
+/**
+ */
+StyledTextListener(SWTEventListener listener) {
+	super(listener);
+}
+/**
+ * Process StyledText events by invoking the event's handler.
+ *
+ * @param e the event to handle
+ */
+public void handleEvent(Event e) {
+	
+	switch (e.type) {
+		case StyledText.ExtendedModify:
+			ExtendedModifyEvent extendedModifyEvent = new ExtendedModifyEvent((StyledTextEvent) e);
+			((ExtendedModifyListener) eventListener).modifyText(extendedModifyEvent);
+			break;		
+		case StyledText.LineGetBackground:
+			LineBackgroundEvent lineBgEvent = new LineBackgroundEvent((StyledTextEvent) e);
+			((LineBackgroundListener) eventListener).lineGetBackground(lineBgEvent);
+			((StyledTextEvent) e).lineBackground = lineBgEvent.lineBackground;
+			break;		
+		case StyledText.LineGetSegments:
+			BidiSegmentEvent segmentEvent = new BidiSegmentEvent((StyledTextEvent) e);
+			((BidiSegmentListener) eventListener).lineGetSegments(segmentEvent);
+			((StyledTextEvent) e).segments = segmentEvent.segments;
+			break;		
+		case StyledText.LineGetStyle:
+			LineStyleEvent lineStyleEvent = new LineStyleEvent((StyledTextEvent) e);
+			((LineStyleListener) eventListener).lineGetStyle(lineStyleEvent);
+			((StyledTextEvent) e).ranges = lineStyleEvent.ranges;
+			((StyledTextEvent) e).styles = lineStyleEvent.styles;
+			((StyledTextEvent) e).alignment = lineStyleEvent.alignment;
+			((StyledTextEvent) e).indent = lineStyleEvent.indent;
+			((StyledTextEvent) e).justify = lineStyleEvent.justify;
+			((StyledTextEvent) e).bullet = lineStyleEvent.bullet;
+			((StyledTextEvent) e).bulletIndex = lineStyleEvent.bulletIndex;
+			break;
+		case StyledText.PaintObject:
+			PaintObjectEvent paintObjectEvent = new PaintObjectEvent((StyledTextEvent) e);
+			((PaintObjectListener) eventListener).paintObject(paintObjectEvent);
+			break;			
+		case StyledText.VerifyKey:
+			VerifyEvent verifyEvent = new VerifyEvent(e);
+			((VerifyKeyListener) eventListener).verifyKey(verifyEvent);
+			e.doit = verifyEvent.doit;
+			break;
+		case StyledText.TextChanged: {
+			TextChangedEvent textChangedEvent = new TextChangedEvent((StyledTextContent) e.data);
+			((TextChangeListener) eventListener).textChanged(textChangedEvent);
+			break;
+		}
+		case StyledText.TextChanging:
+			TextChangingEvent textChangingEvent = new TextChangingEvent((StyledTextContent) e.data, (StyledTextEvent) e);
+			((TextChangeListener) eventListener).textChanging(textChangingEvent);
+			break;
+		case StyledText.TextSet: {
+			TextChangedEvent textChangedEvent = new TextChangedEvent((StyledTextContent) e.data);
+			((TextChangeListener) eventListener).textSet(textChangedEvent);
+			break;
+		}
+		case StyledText.WordNext: {
+			MovementEvent wordBoundaryEvent = new MovementEvent((StyledTextEvent) e);
+			((MovementListener) eventListener).getNextOffset(wordBoundaryEvent);
+			((StyledTextEvent) e).end = wordBoundaryEvent.newOffset;
+			break;
+		}
+		case StyledText.WordPrevious: {
+			MovementEvent wordBoundaryEvent = new MovementEvent((StyledTextEvent) e);
+			((MovementListener) eventListener).getPreviousOffset(wordBoundaryEvent);
+			((StyledTextEvent) e).end = wordBoundaryEvent.newOffset;
+			break;
+		}
+	}
+}
+}
+
+

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/custom/StyledTextPrintOptions.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/custom/StyledTextPrintOptions.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/custom/StyledTextPrintOptions.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,104 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.custom;
+
+/**
+ * Use StyledTextPrintOptions to specify printing options for the
+ * StyledText.print(Printer, StyledTextPrintOptions) API.
+ * <p>
+ * The following example prints a right aligned page number in the footer,
+ * sets the job name to "Example" and prints line background colors but no other
+ * formatting:
+ * </p>
+ * <pre>
+ * StyledTextPrintOptions options = new StyledTextPrintOptions();
+ * options.footer = "\t\t&lt;page&gt;"; 
+ * options.jobName = "Example";
+ * options.printLineBackground = true;
+ * 
+ * Runnable runnable = styledText.print(new Printer(), options); 
+ * runnable.run();
+ * </pre>
+ *
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ *
+ * @since 2.1
+ */
+public class StyledTextPrintOptions {
+	/**
+	 * Page number placeholder constant for use in <code>header</code>
+	 * and <code>footer</code>. Value is <code>&lt;page&gt;</code>
+	 */
+	public static final String PAGE_TAG = "<page>";
+	/**
+	 * Separator constant for use in <code>header</code> and
+	 * <code>footer</code>. Value is <code>\t</code>
+	 */
+	public static final String SEPARATOR = "\t";
+	/**
+	 * Formatted text to print in the header of each page.
+	 * <p>"left '\t' center '\t' right"</p>
+	 * <p>left, center, right = &lt;page&gt; | #CDATA</p>
+	 * <p>Header and footer are defined as three separate regions for arbitrary
+	 * text or the page number placeholder &lt;page&gt;
+	 * (<code>StyledTextPrintOptions.PAGE_TAG</code>). The three regions are 
+	 * left aligned, centered and right aligned. They are separated by a tab
+	 * character (<code>StyledTextPrintOptions.SEPARATOR</code>).
+	 */
+	public String header = null;
+	/**
+	 * Formatted text to print in the footer of each page.
+	 * <p>"left '\t' center '\t' right"</p>
+	 * <p>left, center, right = &lt;page&gt; | #CDATA</p>
+	 * <p>Header and footer are defined as three separate regions for arbitrary
+	 * text or the page number placeholder &lt;page&gt;
+	 * (<code>StyledTextPrintOptions.PAGE_TAG</code>). The three regions are 
+	 * left aligned, centered and right aligned. They are separated by a tab
+	 * character (<code>StyledTextPrintOptions.SEPARATOR</code>).
+	 */
+	public String footer = null;
+	/**
+	 * Name of the print job.
+	 */
+	public String jobName = null;
+	
+	/**
+	 * Print the text foreground color. Default value is <code>false</code>.
+	 */
+	public boolean printTextForeground = false;
+	/**
+	 * Print the text background color. Default value is <code>false</code>.
+	 */
+	public boolean printTextBackground = false;
+	/**
+	 * Print the font styles. Default value is <code>false</code>.
+	 */
+	public boolean printTextFontStyle = false;
+	/**
+	 * Print the line background color. Default value is <code>false</code>.
+	 */
+	public boolean printLineBackground = false;
+	
+	/**
+	 * Print line numbers. Default value is <code>false</code>.
+	 * 
+	 * @since 3.3
+	 */
+	public boolean printLineNumbers = false;
+	
+	/**
+	 * Labels used for printing line numbers.
+	 * 
+	 * @since 3.4
+	 */
+	public String[] lineLabels = null;
+	
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/custom/StyledTextRenderer.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/custom/StyledTextRenderer.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/custom/StyledTextRenderer.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,1519 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.custom;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+
+/**
+ * A StyledTextRenderer renders the content of a StyledText widget.
+ * This class can be used to render to the display or to a printer.
+ */
+class StyledTextRenderer {
+	Device device;
+	StyledText styledText;
+	StyledTextContent content;
+
+	/* Font info */
+	Font regularFont, boldFont, italicFont, boldItalicFont;
+	int tabWidth;
+	int ascent, descent;
+	int averageCharWidth;
+	
+	/* Line data */
+	int topIndex = -1;
+	TextLayout[] layouts;
+	int lineCount;
+	int[] lineWidth;
+	int[] lineHeight;
+	LineInfo[] lines;
+	int maxWidth;
+	int maxWidthLineIndex;
+	boolean idleRunning;
+	
+	/* Bullet */
+	Bullet[] bullets;
+	int[] bulletsIndices;
+	int[] redrawLines;
+	
+	/* Style data */
+	int[] ranges;
+	int styleCount;	
+	StyleRange[] styles;
+	StyleRange[] stylesSet;
+	int stylesSetCount = 0;
+	final static int BULLET_MARGIN = 8;
+	
+	final static boolean COMPACT_STYLES = true;
+	final static boolean MERGE_STYLES = true;
+	
+	final static int GROW = 32;
+	final static int IDLE_TIME = 50;
+	final static int CACHE_SIZE = 128;
+	
+	final static int BACKGROUND = 1 << 0;
+	final static int ALIGNMENT = 1 << 1;
+	final static int INDENT = 1 << 2;
+	final static int JUSTIFY = 1 << 3;
+	final static int SEGMENTS = 1 << 5;
+	
+	static class LineInfo {
+		int flags;
+		Color background;
+		int alignment;
+		int indent;
+		boolean justify;
+		int[] segments;
+
+		public LineInfo() {
+		}
+		public LineInfo(LineInfo info) {
+			if (info != null) {
+				flags = info.flags;
+				background = info.background;
+				alignment = info.alignment;
+				indent = info.indent;
+				justify = info.justify;
+				segments = info.segments;
+			}
+		}
+	}
+	
+StyledTextRenderer(Device device, StyledText styledText) {
+	this.device = device;
+	this.styledText = styledText;
+}
+int addMerge(int[] mergeRanges, StyleRange[] mergeStyles, int mergeCount, int modifyStart, int modifyEnd) {
+	int rangeCount = styleCount << 1;
+	StyleRange endStyle = null;
+	int endStart = 0, endLength = 0;
+	if (modifyEnd < rangeCount) {
+		endStyle = styles[modifyEnd >> 1];
+		endStart = ranges[modifyEnd];
+		endLength = ranges[modifyEnd + 1];
+	}
+	int grow = mergeCount - (modifyEnd - modifyStart);
+	if (rangeCount + grow >= ranges.length) {
+		int[] tmpRanges = new int[ranges.length + grow + (GROW << 1)];
+		System.arraycopy(ranges, 0, tmpRanges, 0, modifyStart);
+		StyleRange[] tmpStyles = new StyleRange[styles.length + (grow >> 1) + GROW];
+		System.arraycopy(styles, 0, tmpStyles, 0, modifyStart >> 1);
+		if (rangeCount > modifyEnd) {
+			System.arraycopy(ranges, modifyEnd, tmpRanges, modifyStart + mergeCount, rangeCount - modifyEnd);
+			System.arraycopy(styles, modifyEnd >> 1, tmpStyles, (modifyStart + mergeCount) >> 1, styleCount - (modifyEnd >> 1));
+		}
+		ranges = tmpRanges;
+		styles = tmpStyles;
+	} else {
+		if (rangeCount > modifyEnd) {
+			System.arraycopy(ranges, modifyEnd, ranges, modifyStart + mergeCount, rangeCount - modifyEnd);
+			System.arraycopy(styles, modifyEnd >> 1, styles, (modifyStart + mergeCount) >> 1, styleCount - (modifyEnd >> 1));
+		}
+	}
+	if (MERGE_STYLES) {
+		int j = modifyStart;	
+		for (int i = 0; i < mergeCount; i += 2) {
+			if (j > 0 && ranges[j - 2] + ranges[j - 1] == mergeRanges[i] && mergeStyles[i >> 1].similarTo(styles[(j - 2) >> 1])) {
+				ranges[j - 1] += mergeRanges[i + 1];
+			} else {
+				styles[j >> 1] = mergeStyles[i >> 1];
+				ranges[j++] = mergeRanges[i];
+				ranges[j++] = mergeRanges[i + 1];
+			}
+		}
+		if (endStyle != null && ranges[j - 2] + ranges[j - 1] == endStart && endStyle.similarTo(styles[(j - 2) >> 1])) {
+			ranges[j - 1] += endLength;
+			modifyEnd += 2;
+			mergeCount += 2;
+		}
+		if (rangeCount > modifyEnd) {
+			System.arraycopy(ranges, modifyStart + mergeCount, ranges, j, rangeCount - modifyEnd);
+			System.arraycopy(styles, (modifyStart + mergeCount) >> 1, styles, j >> 1, styleCount - (modifyEnd >> 1));
+		}
+		grow = (j - modifyStart) - (modifyEnd - modifyStart);
+	} else {
+		System.arraycopy(mergeRanges, 0, ranges, modifyStart, mergeCount);
+		System.arraycopy(mergeStyles, 0, styles, modifyStart >> 1, mergeCount >> 1);
+	}
+	styleCount += grow >> 1;
+	return grow;
+}
+int addMerge(StyleRange[] mergeStyles, int mergeCount, int modifyStart, int modifyEnd) {
+	int grow = mergeCount - (modifyEnd - modifyStart);
+	StyleRange endStyle = null;
+	if (modifyEnd < styleCount) endStyle = styles[modifyEnd];
+	if (styleCount + grow >= styles.length) {
+		StyleRange[] tmpStyles = new StyleRange[styles.length + grow + GROW];
+		System.arraycopy(styles, 0, tmpStyles, 0, modifyStart);
+		if (styleCount > modifyEnd) {
+			System.arraycopy(styles, modifyEnd, tmpStyles, modifyStart + mergeCount, styleCount - modifyEnd);
+		}
+		styles = tmpStyles;
+	} else {
+		if (styleCount > modifyEnd) {
+			System.arraycopy(styles, modifyEnd, styles, modifyStart + mergeCount, styleCount - modifyEnd);
+		}
+	}
+	if (MERGE_STYLES) {
+		int j = modifyStart;
+		for (int i = 0; i < mergeCount; i++) {
+			StyleRange newStyle = mergeStyles[i], style;
+			if (j > 0 && (style = styles[j - 1]).start + style.length == newStyle.start && newStyle.similarTo(style)) {
+				style.length += newStyle.length;
+			} else {
+				styles[j++] = newStyle;
+			}
+		}
+		StyleRange style = styles[j - 1];
+		if (endStyle != null && style.start + style.length == endStyle.start && endStyle.similarTo(style)) {
+			style.length += endStyle.length;
+			modifyEnd++;
+			mergeCount++;
+		}
+		if (styleCount > modifyEnd) {
+			System.arraycopy(styles, modifyStart + mergeCount, styles, j, styleCount - modifyEnd);
+		}
+		grow = (j - modifyStart) - (modifyEnd - modifyStart);
+	} else {
+		System.arraycopy(mergeStyles, 0, styles, modifyStart, mergeCount);
+	}
+	styleCount += grow;
+	return grow;
+}
+void calculate(int startLine, int lineCount) {
+	int endLine = startLine + lineCount;
+	if (startLine < 0 || endLine > lineWidth.length) {
+		return;
+	}
+	int hTrim = styledText.leftMargin + styledText.rightMargin + styledText.getCaretWidth();
+	for (int i = startLine; i < endLine; i++) {
+		if (lineWidth[i] == -1 || lineHeight[i] == -1) {
+			TextLayout layout = getTextLayout(i);
+			Rectangle rect = layout.getBounds();
+			lineWidth[i] = rect.width + hTrim;
+			lineHeight[i] = rect.height;
+			disposeTextLayout(layout);
+		}
+		if (lineWidth[i] > maxWidth) {
+			maxWidth = lineWidth[i];
+			maxWidthLineIndex = i;
+		}
+	}
+}
+void calculateClientArea () {
+	int index = styledText.getTopIndex();
+	int lineCount = content.getLineCount();
+	int height = styledText.getClientArea().height;
+	int y = 0;
+	while (height > y && lineCount > index) {
+		calculate(index, 1);
+		y += lineHeight[index++];
+	}
+}
+void calculateIdle () {
+	if (idleRunning) return;
+	Runnable runnable = new Runnable() {
+		public void run() {
+			if (styledText == null) return;
+			int i;
+			long start = System.currentTimeMillis();
+			for (i = 0; i < lineCount; i++) {
+				if (lineHeight[i] == -1 || lineWidth[i] == -1) {
+					calculate(i, 1);
+					if (System.currentTimeMillis() - start > IDLE_TIME) break;
+				}
+			}
+			if (i < lineCount) {
+				Display display = styledText.getDisplay();				
+				display.asyncExec(this);
+			} else {
+				idleRunning = false;
+				styledText.setScrollBars(true);
+				ScrollBar bar = styledText.getVerticalBar();
+				if (bar != null) {
+					bar.setSelection(styledText.getVerticalScrollOffset());
+				}					
+			}
+		}
+	};		
+	Display display = styledText.getDisplay();
+	display.asyncExec(runnable);
+	idleRunning = true;
+}
+void clearLineBackground(int startLine, int count) {
+	if (lines == null) return;
+	for (int i = startLine; i < startLine + count; i++) {
+		LineInfo info = lines[i];
+		if (info != null) {
+			info.flags &= ~BACKGROUND;
+			info.background = null;
+			if (info.flags == 0) lines[i] = null;
+		}
+	}
+}
+void clearLineStyle(int startLine, int count) {
+	if (lines == null) return;
+	for (int i = startLine; i < startLine + count; i++) {
+		LineInfo info = lines[i];
+		if (info != null) {
+			info.flags &= ~(ALIGNMENT | INDENT | JUSTIFY);
+			if (info.flags == 0) lines[i] = null;
+		}
+	}
+}
+void copyInto(StyledTextRenderer renderer) {
+	if (ranges != null) {
+		int[] newRanges = renderer.ranges = new int[styleCount << 1];
+		System.arraycopy(ranges, 0, newRanges, 0, newRanges.length);
+	}
+	if (styles != null) {
+		StyleRange[] newStyles = renderer.styles = new StyleRange[styleCount];
+		for (int i = 0; i < newStyles.length; i++) {
+			newStyles[i] = (StyleRange)styles[i].clone();
+		}
+		renderer.styleCount = styleCount;
+	}
+	if (lines != null) {
+		LineInfo[] newLines = renderer.lines = new LineInfo[lineCount];
+		for (int i = 0; i < newLines.length; i++) {
+			newLines[i] = new LineInfo(lines[i]);				
+		}
+		renderer.lineCount = lineCount;
+	}
+}
+void dispose() {
+	if (boldFont != null) boldFont.dispose();
+	if (italicFont != null) italicFont.dispose();
+	if (boldItalicFont != null) boldItalicFont.dispose();
+	boldFont = italicFont = boldItalicFont = null;
+	reset();
+	content = null;
+	device = null;
+	styledText = null;
+}
+void disposeTextLayout (TextLayout layout) {
+	if (layouts != null) {
+		for (int i = 0; i < layouts.length; i++) {
+			if (layouts[i] == layout) return;
+		}
+	}
+	layout.dispose();
+}
+void drawBullet(Bullet bullet, GC gc, int paintX, int paintY, int index, int lineAscent, int lineDescent) {
+	StyleRange style = bullet.style;
+	GlyphMetrics metrics = style.metrics;
+	Color color = style.foreground;
+	if (color != null) gc.setForeground(color);
+	if ((bullet.type & ST.BULLET_DOT) != 0 && StyledText.IS_MOTIF) {
+		int size = Math.max(4, (lineAscent + lineDescent) / 4);
+		if ((size & 1) == 0) size++;
+		if (color == null) {
+			Display display = styledText.getDisplay();
+			color = display.getSystemColor(SWT.COLOR_BLACK);
+		}
+		gc.setBackground(color);
+		int x = paintX + Math.max(0, metrics.width - size - BULLET_MARGIN);
+		gc.fillArc(x, paintY + size, size + 1, size + 1, 0, 360);
+		return;
+	}
+	Font font = style.font;
+	if (font != null) gc.setFont(font);
+	String string = "";
+	int type = bullet.type & (ST.BULLET_DOT|ST.BULLET_NUMBER|ST.BULLET_LETTER_LOWER|ST.BULLET_LETTER_UPPER);
+	switch (type) {
+		case ST.BULLET_DOT: string = "\u2022"; break;
+		case ST.BULLET_NUMBER: string = String.valueOf(index); break;
+		case ST.BULLET_LETTER_LOWER: string = String.valueOf((char) (index % 26 + 97)); break;
+		case ST.BULLET_LETTER_UPPER: string = String.valueOf((char) (index % 26 + 65)); break;
+	}
+	if ((bullet.type & ST.BULLET_TEXT) != 0) string += bullet.text;
+	Display display = styledText.getDisplay();
+	TextLayout layout = new TextLayout(display);
+	layout.setText(string);
+	layout.setAscent(lineAscent);
+	layout.setDescent(lineDescent);
+	style = (StyleRange)style.clone();
+	style.metrics = null;
+	if (style.font == null) style.font = getFont(style.fontStyle);
+	layout.setStyle(style, 0, string.length());	
+	int x = paintX + Math.max(0, metrics.width - layout.getBounds().width - BULLET_MARGIN);
+	layout.draw(gc, x, paintY);
+	layout.dispose();
+}
+int drawLine(int lineIndex, int paintX, int paintY, GC gc, Color widgetBackground, Color widgetForeground) {
+	TextLayout layout = getTextLayout(lineIndex);
+	String line = content.getLine(lineIndex);
+	int lineOffset = content.getOffsetAtLine(lineIndex);
+	int lineLength = line.length();
+	Point selection = styledText.getSelection();
+	int selectionStart = selection.x - lineOffset;
+	int selectionEnd = selection.y - lineOffset;
+	Rectangle client = styledText.getClientArea();  
+	Color lineBackground = getLineBackground(lineIndex, null);
+	StyledTextEvent event = styledText.getLineBackgroundData(lineOffset, line);
+	if (event != null && event.lineBackground != null) lineBackground = event.lineBackground;
+	int height = layout.getBounds().height;
+	if (lineBackground != null) {
+		gc.setBackground(lineBackground);
+		gc.fillRectangle(client.x, paintY, client.width, height);
+	} else {
+		gc.setBackground(widgetBackground);
+		styledText.drawBackground(gc, client.x, paintY, client.width, height);
+	}
+	gc.setForeground(widgetForeground);
+	if (selectionStart == selectionEnd || (selectionEnd <= 0 && selectionStart > lineLength - 1)) {
+		layout.draw(gc, paintX, paintY);
+	} else {
+		int start = Math.max(0, selectionStart);
+		int end = Math.min(lineLength, selectionEnd);
+		Color selectionFg = styledText.getSelectionForeground();
+		Color selectionBg = styledText.getSelectionBackground();
+		int flags;
+		if ((styledText.getStyle() & SWT.FULL_SELECTION) != 0) {
+			flags = SWT.FULL_SELECTION;
+		} else {
+			flags = SWT.DELIMITER_SELECTION;
+		}
+		if (selectionStart <= lineLength && lineLength < selectionEnd ) {
+			flags |= SWT.LAST_LINE_SELECTION;
+		}
+		layout.draw(gc, paintX, paintY, start, end - 1, selectionFg, selectionBg, flags);
+	}
+	
+	// draw objects
+	Bullet bullet = null;
+	int bulletIndex = -1;
+	if (bullets != null) {
+		if (bulletsIndices != null) {
+			int index = lineIndex - topIndex;
+			if (0 <= index && index < CACHE_SIZE) {
+				bullet = bullets[index];
+				bulletIndex = bulletsIndices[index];
+			}
+		} else {
+			for (int i = 0; i < bullets.length; i++) {
+				bullet = bullets[i];
+				bulletIndex = bullet.indexOf(lineIndex);
+				if (bulletIndex != -1) break;
+			}
+		}
+	}
+	if (bulletIndex != -1 && bullet != null) {
+		FontMetrics metrics = layout.getLineMetrics(0);
+		int lineAscent = metrics.getAscent() + metrics.getLeading();
+		if (bullet.type == ST.BULLET_CUSTOM) {
+			bullet.style.start = lineOffset;
+			styledText.paintObject(gc, paintX, paintY, lineAscent, metrics.getDescent(), bullet.style, bullet, bulletIndex);
+		} else {
+			drawBullet(bullet, gc, paintX, paintY, bulletIndex, lineAscent, metrics.getDescent());
+		}
+	}
+	TextStyle[] styles = layout.getStyles();
+	int[] ranges = null;
+	for (int i = 0; i < styles.length; i++) {
+		if (styles[i].metrics != null) {
+			if (ranges == null) ranges = layout.getRanges();
+			int start = ranges[i << 1];
+			int length = ranges[(i << 1) + 1] - start;
+			Point point = layout.getLocation(start, false);
+			FontMetrics metrics = layout.getLineMetrics(layout.getLineIndex(start));
+			StyleRange style = (StyleRange)((StyleRange)styles[i]).clone();
+			style.start = start + lineOffset;
+			style.length = length;
+			int lineAscent = metrics.getAscent() + metrics.getLeading();
+			styledText.paintObject(gc, point.x + paintX, point.y + paintY, lineAscent, metrics.getDescent(), style, null, 0);
+		}
+	}
+	disposeTextLayout(layout);
+	return height;
+}
+int getBaseline() {
+	return ascent;
+}
+Font getFont(int style) {
+	switch (style) {
+		case SWT.BOLD:
+			if (boldFont != null) return boldFont;
+			return boldFont = new Font(device, getFontData(style));
+		case SWT.ITALIC:
+			if (italicFont != null) return italicFont;
+			return italicFont = new Font(device, getFontData(style));
+		case SWT.BOLD | SWT.ITALIC:
+			if (boldItalicFont != null) return boldItalicFont;
+			return boldItalicFont = new Font(device, getFontData(style));
+		default:
+			return regularFont;
+	}
+}
+FontData[] getFontData(int style) {
+	FontData[] fontDatas = regularFont.getFontData();
+	for (int i = 0; i < fontDatas.length; i++) {
+		fontDatas[i].setStyle(style);
+	}
+	return fontDatas;
+}
+int getHeight () {
+	int defaultLineHeight = getLineHeight();
+	if (styledText.isFixedLineHeight()) {
+		return lineCount * defaultLineHeight;
+	}
+	int totalHeight = 0;
+	int width = styledText.getWrapWidth();
+	for (int i = 0; i < lineCount; i++) {
+		int height = lineHeight[i];
+		if (height == -1) {
+			if (width > 0) {
+				int length = content.getLine(i).length();
+				height = ((length * averageCharWidth / width) + 1) * defaultLineHeight;
+			} else {
+				height = defaultLineHeight;
+			}
+		}
+		totalHeight += height;
+	}
+	return totalHeight + styledText.topMargin + styledText.bottomMargin;
+}
+int getLineAlignment(int index, int defaultAlignment) {
+	if (lines == null) return defaultAlignment;
+	LineInfo info = lines[index];
+	if (info != null && (info.flags & ALIGNMENT) != 0) {
+		return info.alignment;
+	}
+	return defaultAlignment;
+}
+Color getLineBackground(int index, Color defaultBackground) {
+	if (lines == null) return defaultBackground;
+	LineInfo info = lines[index];
+	if (info != null && (info.flags & BACKGROUND) != 0) {
+		return info.background;
+	}
+	return defaultBackground;
+}
+Bullet getLineBullet (int index, Bullet defaultBullet) {
+	if (bullets == null) return defaultBullet;
+	if (bulletsIndices != null) return defaultBullet;
+	for (int i = 0; i < bullets.length; i++) {
+		Bullet bullet = bullets[i];
+		if (bullet.indexOf(index) != -1) return bullet;
+	}
+	return defaultBullet;
+}
+int getLineHeight() {
+	return ascent + descent;
+}
+int getLineHeight(int lineIndex) {
+	if (lineHeight[lineIndex] == -1) {
+		calculate(lineIndex, 1);
+	}
+	return lineHeight[lineIndex];
+}
+int getLineIndent(int index, int defaultIndent) {
+	if (lines == null) return defaultIndent;
+	LineInfo info = lines[index];
+	if (info != null && (info.flags & INDENT) != 0) {
+		return info.indent;
+	}
+	return defaultIndent;
+}
+boolean getLineJustify(int index, boolean defaultJustify) {
+	if (lines == null) return defaultJustify;
+	LineInfo info = lines[index];
+	if (info != null && (info.flags & JUSTIFY) != 0) {
+		return info.justify;
+	}
+	return defaultJustify;
+}
+int[] getLineSegments(int index, int[] defaultSegments) {
+	if (lines == null) return defaultSegments;
+	LineInfo info = lines[index];
+	if (info != null && (info.flags & SEGMENTS) != 0) {
+		return info.segments;
+	}
+	return defaultSegments;
+}
+int getRangeIndex(int offset, int low, int high) {
+	if (styleCount == 0) return 0;
+	if (ranges != null)  {
+		while (high - low > 2) {
+			int index = ((high + low) / 2) / 2 * 2;
+			int end = ranges[index] + ranges[index + 1];
+			if (end > offset) {
+				high = index;
+			} else {
+				low = index;
+			}
+		}
+	} else {
+		while (high - low > 1) {
+			int index = ((high + low) / 2);
+			int end = styles[index].start + styles[index].length;
+			if (end > offset) {
+				high = index;
+			} else {
+				low = index;
+			}
+		}
+	}
+	return high;
+}
+int[] getRanges(int start, int length) {
+	int[] newRanges;
+	int end = start + length - 1;
+	if (ranges != null) {
+		int rangeCount = styleCount << 1;
+		int rangeStart = getRangeIndex(start, -1, rangeCount);
+		if (rangeStart >= rangeCount) return null;
+		if (ranges[rangeStart] > end) return null;
+		int rangeEnd = Math.min(rangeCount - 2, getRangeIndex(end, rangeStart - 1, rangeCount) + 1);
+		newRanges = new int[rangeEnd - rangeStart + 2];
+		System.arraycopy(ranges, rangeStart, newRanges, 0, newRanges.length);
+	} else {
+		int rangeStart = getRangeIndex(start, -1, styleCount);
+		if (rangeStart >= styleCount) return null;
+		if (styles[rangeStart].start > end) return null;
+		int rangeEnd = Math.min(styleCount - 1, getRangeIndex(end, rangeStart - 1, styleCount));
+		newRanges = new int[(rangeEnd - rangeStart + 1) << 1];
+		for (int i = rangeStart, j = 0; i <= rangeEnd; i++, j += 2) {
+			StyleRange style = styles[i];
+			newRanges[j] = style.start;
+			newRanges[j + 1] = style.length;
+		}		
+	}
+	if (start > newRanges[0]) {
+		newRanges[1] = newRanges[0] + newRanges[1] - start;
+		newRanges[0] = start;
+	}
+	if (end < newRanges[newRanges.length - 2] + newRanges[newRanges.length - 1] - 1) {
+		newRanges[newRanges.length - 1] = end - newRanges[newRanges.length - 2] + 1;
+	}
+	return newRanges;
+}
+StyleRange[] getStyleRanges(int start, int length, boolean includeRanges) {
+	StyleRange[] newStyles;
+	int end = start + length - 1;
+	if (ranges != null) {
+		int rangeCount = styleCount << 1;
+		int rangeStart = getRangeIndex(start, -1, rangeCount);
+		if (rangeStart >= rangeCount) return null;
+		if (ranges[rangeStart] > end) return null;
+		int rangeEnd = Math.min(rangeCount - 2, getRangeIndex(end, rangeStart - 1, rangeCount) + 1);
+		newStyles = new StyleRange[((rangeEnd - rangeStart) >> 1) + 1];
+		if (includeRanges) {
+			for (int i = rangeStart, j = 0; i <= rangeEnd; i += 2, j++) {
+				newStyles[j] = (StyleRange)styles[i >> 1].clone();
+				newStyles[j].start = ranges[i];
+				newStyles[j].length = ranges[i + 1];
+			}
+		} else {
+			System.arraycopy(styles, rangeStart >> 1, newStyles, 0, newStyles.length);
+		}
+	} else {
+		int rangeStart = getRangeIndex(start, -1, styleCount);
+		if (rangeStart >= styleCount) return null;
+		if (styles[rangeStart].start > end) return null;
+		int rangeEnd = Math.min(styleCount - 1, getRangeIndex(end, rangeStart - 1, styleCount));
+		newStyles = new StyleRange[rangeEnd - rangeStart + 1];
+		System.arraycopy(styles, rangeStart, newStyles, 0, newStyles.length);
+	}
+	StyleRange style = newStyles[0];
+	if (start > style.start) {
+		if (!includeRanges || ranges == null) newStyles[0] = style = (StyleRange)style.clone();
+		style.length = style.start + style.length - start;
+		style.start = start;
+	}
+	style = newStyles[newStyles.length - 1];
+	if (end < style.start + style.length - 1) {
+		if (end < style.start) {
+			StyleRange[] tmp = new StyleRange[newStyles.length - 1];
+			System.arraycopy(newStyles, 0, tmp, 0, newStyles.length - 1);
+			newStyles = tmp;
+		} else {
+			if (!includeRanges || ranges == null) newStyles[newStyles.length - 1] = style = (StyleRange)style.clone();
+			style.length = end - style.start + 1;
+		}
+	}
+	return newStyles;
+}
+StyleRange getStyleRange(StyleRange style) {
+	if (style.start == 0 && style.length == 0 && style.fontStyle == SWT.NORMAL) return style;
+	StyleRange clone = (StyleRange)style.clone();
+	clone.start = clone.length = 0;
+	clone.fontStyle = SWT.NORMAL;
+	if (clone.font == null) clone.font = getFont(style.fontStyle);
+	return clone;
+}
+TextLayout getTextLayout(int lineIndex) {
+	return getTextLayout(lineIndex, styledText.getOrientation(), styledText.getWrapWidth(), styledText.lineSpacing);
+}
+TextLayout getTextLayout(int lineIndex, int orientation, int width, int lineSpacing) {
+	TextLayout layout = null;
+	if (styledText != null) {
+		int topIndex = styledText.topIndex > 0 ? styledText.topIndex - 1 : 0;	
+		if (layouts == null || topIndex != this.topIndex) {
+			TextLayout[] newLayouts = new TextLayout[CACHE_SIZE];
+			if (layouts != null) {
+				for (int i = 0; i < layouts.length; i++) {
+					if (layouts[i] != null) {
+						int layoutIndex = (i + this.topIndex) - topIndex;
+						if (0 <= layoutIndex && layoutIndex < newLayouts.length) {
+							newLayouts[layoutIndex] = layouts[i];
+						} else {
+							layouts[i].dispose();
+						}
+					}
+				}
+			}
+			if (bullets != null && bulletsIndices != null && topIndex != this.topIndex) {
+				int delta = topIndex - this.topIndex;
+				if (delta > 0) {
+					if (delta < bullets.length) {
+						System.arraycopy(bullets, delta, bullets, 0, bullets.length - delta);
+						System.arraycopy(bulletsIndices, delta, bulletsIndices, 0, bulletsIndices.length - delta);
+					}
+					int startIndex = Math.max(0, bullets.length - delta);
+					for (int i = startIndex; i < bullets.length; i++) bullets[i] = null;
+				} else {
+					if (-delta < bullets.length) {
+						System.arraycopy(bullets, 0, bullets, -delta, bullets.length + delta);
+						System.arraycopy(bulletsIndices, 0, bulletsIndices, -delta, bulletsIndices.length + delta);
+					}
+					int endIndex = Math.min(bullets.length, -delta);
+					for (int i = 0; i < endIndex; i++) bullets[i] = null;
+				}
+			}
+			this.topIndex = topIndex;
+			layouts = newLayouts;
+		}
+		if (layouts != null) {
+			int layoutIndex = lineIndex - topIndex;
+			if (0 <= layoutIndex && layoutIndex < layouts.length) {
+				layout = layouts[layoutIndex];
+				if (layout != null) {
+					if (lineWidth[lineIndex] != -1) return layout;
+				} else {
+					layout = layouts[layoutIndex] = new TextLayout(device);
+				}
+			}
+		}
+	}
+	if (layout == null) layout = new TextLayout(device);
+	String line = content.getLine(lineIndex);
+	int lineOffset = content.getOffsetAtLine(lineIndex);
+	int[] segments = null;
+	int indent = 0;
+	int alignment = SWT.LEFT;
+	boolean justify = false;
+	Bullet bullet = null;
+	int[] ranges = null;
+	StyleRange[] styles = null;
+	int rangeStart = 0, styleCount = 0;
+	StyledTextEvent event = null;
+	if (styledText != null) {
+		event = styledText.getLineStyleData(lineOffset, line);
+		segments = styledText.getBidiSegments(lineOffset, line);
+		indent = styledText.indent;
+		alignment = styledText.alignment;
+		justify = styledText.justify;
+	}
+	if (event != null) {
+		indent = event.indent;
+		alignment = event.alignment;
+		justify = event.justify;
+		bullet = event.bullet;
+		ranges = event.ranges;
+		styles = event.styles;
+		if (styles != null) {
+			styleCount = styles.length;
+			if (styledText.isFixedLineHeight()) {
+				for (int i = 0; i < styleCount; i++) {
+					if (styles[i].isVariableHeight()) {
+						styledText.verticalScrollOffset = -1;
+						styledText.setVariableLineHeight();
+						styledText.redraw();
+						break;
+					}
+				}
+			}
+		}
+		if (bullets == null || bulletsIndices == null) {
+			bullets = new Bullet[CACHE_SIZE];
+			bulletsIndices = new int[CACHE_SIZE];
+		}
+		int index = lineIndex - topIndex;
+		if (0 <= index && index < CACHE_SIZE) {
+			bullets[index] = bullet;
+			bulletsIndices[index] = event.bulletIndex;
+		}
+	} else {
+		if (lines != null) {
+			LineInfo info = lines[lineIndex];
+			if (info != null) {
+				if ((info.flags & INDENT) != 0) indent = info.indent;
+				if ((info.flags & ALIGNMENT) != 0) alignment = info.alignment;
+				if ((info.flags & JUSTIFY) != 0) justify = info.justify;
+				if ((info.flags & SEGMENTS) != 0) segments = info.segments;
+			}
+		}
+		if (bulletsIndices != null) {
+			bullets = null;
+			bulletsIndices = null;
+		}
+		if (bullets != null) {
+			for (int i = 0; i < bullets.length; i++) {
+				if (bullets[i].indexOf(lineIndex) != -1) {
+					bullet = bullets[i];
+					break;
+				}
+			}
+		}
+		ranges = this.ranges;
+		styles = this.styles;
+		styleCount = this.styleCount;
+		if (ranges != null) {
+			rangeStart = getRangeIndex(lineOffset, -1, styleCount << 1);
+		} else {
+			rangeStart = getRangeIndex(lineOffset, -1, styleCount);
+		}
+	}
+	if (bullet != null) {
+		StyleRange style = bullet.style;
+		GlyphMetrics metrics = style.metrics;
+		indent += metrics.width;
+	}
+	layout.setFont(regularFont);
+	layout.setAscent(ascent);
+	layout.setDescent(descent);
+	layout.setText(line);
+	layout.setOrientation(orientation);
+	layout.setSegments(segments);
+	layout.setWidth(width);
+	layout.setSpacing(lineSpacing);
+	layout.setTabs(new int[]{tabWidth});
+	layout.setIndent(indent);
+	layout.setAlignment(alignment);
+	layout.setJustify(justify);
+	
+	int lastOffset = 0;
+	int length = line.length();
+	if (styles != null) {
+		if (ranges != null) {
+			int rangeCount = styleCount << 1;
+			for (int i = rangeStart; i < rangeCount; i += 2) {
+				int start, end;
+				if (lineOffset > ranges[i]) {
+					start = 0;
+					end = Math.min (length, ranges[i + 1] - lineOffset + ranges[i]);
+				} else {
+					start = ranges[i] - lineOffset;
+					end = Math.min(length, start + ranges[i + 1]);
+				}
+				if (start >= length) break;
+				if (lastOffset < start) {
+					layout.setStyle(null, lastOffset, start - 1);
+				}
+				layout.setStyle(getStyleRange(styles[i >> 1]), start, end);
+				lastOffset = Math.max(lastOffset, end);
+			}
+		} else {
+			for (int i = rangeStart; i < styleCount; i++) {
+				int start, end;
+				if (lineOffset > styles[i].start) {
+					start = 0;
+					end = Math.min (length, styles[i].length - lineOffset + styles[i].start);
+				} else {
+					start = styles[i].start - lineOffset;
+					end = Math.min(length, start + styles[i].length);
+				}
+				if (start >= length) break;
+				if (lastOffset < start) {
+					layout.setStyle(null, lastOffset, start - 1);
+				}
+				layout.setStyle(getStyleRange(styles[i]), start, end);
+				lastOffset = Math.max(lastOffset, end);
+			}
+		}
+	}
+	if (lastOffset < length) layout.setStyle(null, lastOffset, length);
+	if (styledText != null && styledText.ime != null) {
+		IME ime = styledText.ime;
+		int compositionOffset = ime.getCompositionOffset();
+		if (compositionOffset != -1) {
+			int commitCount = ime.getCommitCount();
+			int compositionLength = ime.getText().length();
+			if (compositionLength != commitCount) {
+				int compositionLine = content.getLineAtOffset(compositionOffset);
+				if (compositionLine == lineIndex) {
+					int[] imeRanges = ime.getRanges();
+					TextStyle[] imeStyles = ime.getStyles();
+					if (imeRanges.length > 0) {
+						for (int i = 0; i < imeStyles.length; i++) {
+							int start = imeRanges[i*2] - lineOffset;
+							int end = imeRanges[i*2+1] - lineOffset;
+							TextStyle imeStyle = imeStyles[i], userStyle;
+							for (int j = start; j <= end; j++) {
+								userStyle = layout.getStyle(j);
+								if (userStyle == null && j > 0) userStyle = layout.getStyle(j - 1);
+								if (userStyle == null && j + 1 < length) userStyle = layout.getStyle(j + 1);
+								if (userStyle == null) {
+									layout.setStyle(imeStyle, j, j);
+								} else {
+									TextStyle newStyle = new TextStyle(imeStyle);
+									if (newStyle.font == null) newStyle.font = userStyle.font;
+									if (newStyle.foreground == null) newStyle.foreground = userStyle.foreground;
+									if (newStyle.background == null) newStyle.background = userStyle.background;
+									layout.setStyle(newStyle, j, j);
+								}
+							}
+						}
+					} else {
+						int start = compositionOffset - lineOffset;
+						int end = start + compositionLength - 1;
+						TextStyle userStyle = layout.getStyle(start);
+						if (userStyle == null) {
+							if (start > 0) userStyle = layout.getStyle(start - 1);
+							if (userStyle == null && end + 1 < length) userStyle = layout.getStyle(end + 1);
+							if (userStyle != null) {
+								TextStyle newStyle = new TextStyle();
+								newStyle.font = userStyle.font;
+								newStyle.foreground = userStyle.foreground;
+								newStyle.background = userStyle.background;
+								layout.setStyle(newStyle, start, end);
+							}
+						}
+					}
+				}
+			}
+		}
+	}
+	
+	if (styledText != null && styledText.isFixedLineHeight()) {
+		int index = -1;
+		int lineCount = layout.getLineCount();
+		int height = getLineHeight();
+		for (int i = 0; i < lineCount; i++) {
+			int lineHeight = layout.getLineBounds(i).height;
+			if (lineHeight > height) {
+				height = lineHeight;
+				index = i;
+			}
+		}
+		if (index != -1) {
+			FontMetrics metrics = layout.getLineMetrics(index);
+			ascent = metrics.getAscent() + metrics.getLeading();
+			descent = metrics.getDescent();
+			if (layouts != null) {
+				for (int i = 0; i < layouts.length; i++) {
+					if (layouts[i] != null && layouts[i] != layout) {
+						layouts[i].setAscent(ascent);
+						layouts[i].setDescent(descent);
+					}
+				}
+			}
+			if (styledText.verticalScrollOffset != 0) {
+				int topIndex = styledText.topIndex;
+				int topIndexY = styledText.topIndexY;
+				int lineHeight = getLineHeight();
+				if (topIndexY >= 0) {
+					styledText.verticalScrollOffset = (topIndex - 1) * lineHeight + lineHeight - topIndexY;
+				} else {
+					styledText.verticalScrollOffset = topIndex * lineHeight - topIndexY;
+				}
+			}
+			styledText.calculateScrollBars();
+			if (styledText.isBidiCaret()) styledText.createCaretBitmaps();
+			styledText.caretDirection = SWT.NULL;
+			styledText.setCaretLocation();
+			styledText.redraw();
+		}
+	}
+	return layout;
+}
+int getWidth() {
+	return maxWidth;
+}
+void reset() {
+	if (layouts != null) {
+		for (int i = 0; i < layouts.length; i++) {
+			TextLayout layout = layouts[i];
+			if (layout != null) layout.dispose();
+		}
+		layouts = null;
+	}
+	topIndex = -1;
+	stylesSetCount = styleCount = lineCount = 0;
+	ranges = null;
+	styles = null;
+	stylesSet = null;
+	lines = null;
+	lineWidth = null;
+	lineHeight = null;
+	bullets = null;
+	bulletsIndices = null;
+	redrawLines = null;
+}
+void reset(int startLine, int lineCount) {
+	int endLine = startLine + lineCount;
+	if (startLine < 0 || endLine > lineWidth.length) return;
+	for (int i = startLine; i < endLine; i++) {
+		lineWidth[i] = -1;
+		lineHeight[i] = -1;
+	}
+	if (startLine <= maxWidthLineIndex && maxWidthLineIndex < endLine) {
+		maxWidth = 0;
+		maxWidthLineIndex = -1;
+		if (lineCount != this.lineCount) {
+			for (int i = 0; i < this.lineCount; i++) {
+				if (lineWidth[i] > maxWidth) {
+					maxWidth = lineWidth[i];
+					maxWidthLineIndex = i;
+				}
+			}
+		}
+	}
+}
+void setContent(StyledTextContent content) {
+	reset();
+	this.content = content;
+	lineCount = content.getLineCount();
+	lineWidth = new int[lineCount];
+	lineHeight = new int[lineCount];
+	reset(0, lineCount);
+}
+void setFont(Font font, int tabs) {
+	TextLayout layout = new TextLayout(device);
+	layout.setFont(regularFont);
+	if (font != null) {
+		if (boldFont != null) boldFont.dispose();
+		if (italicFont != null) italicFont.dispose();
+		if (boldItalicFont != null) boldItalicFont.dispose();
+		boldFont = italicFont = boldItalicFont = null;
+		regularFont = font;
+		layout.setText("    ");
+		layout.setFont(font);
+		layout.setStyle(new TextStyle(getFont(SWT.NORMAL), null, null), 0, 0);
+		layout.setStyle(new TextStyle(getFont(SWT.BOLD), null, null), 1, 1);
+		layout.setStyle(new TextStyle(getFont(SWT.ITALIC), null, null), 2, 2);
+		layout.setStyle(new TextStyle(getFont(SWT.BOLD | SWT.ITALIC), null, null), 3, 3);
+		FontMetrics metrics = layout.getLineMetrics(0);
+		ascent = metrics.getAscent() + metrics.getLeading();
+		descent = metrics.getDescent();
+		boldFont.dispose();
+		italicFont.dispose();
+		boldItalicFont.dispose();
+		boldFont = italicFont = boldItalicFont = null;
+	}
+	layout.dispose();
+	layout = new TextLayout(device);
+	layout.setFont(regularFont);
+	StringBuffer tabBuffer = new StringBuffer(tabs);
+	for (int i = 0; i < tabs; i++) {
+		tabBuffer.append(' ');
+	}
+	layout.setText(tabBuffer.toString());
+	tabWidth = layout.getBounds().width;
+	layout.dispose();
+	if (styledText != null) {
+		GC gc = new GC(styledText);
+		averageCharWidth = gc.getFontMetrics().getAverageCharWidth();
+		gc.dispose();
+	}
+}
+void setLineAlignment(int startLine, int count, int alignment) {
+	if (lines == null) lines = new LineInfo[lineCount];
+	for (int i = startLine; i < startLine + count; i++) {
+		if (lines[i] == null) {
+			lines[i] = new LineInfo();
+		}
+		lines[i].flags |= ALIGNMENT;
+		lines[i].alignment = alignment;
+	}
+}
+void setLineBackground(int startLine, int count, Color background) {
+	if (lines == null) lines = new LineInfo[lineCount];
+	for (int i = startLine; i < startLine + count; i++) {
+		if (lines[i] == null) {
+			lines[i] = new LineInfo();
+		}
+		lines[i].flags |= BACKGROUND;
+		lines[i].background = background;
+	}
+}
+void setLineBullet(int startLine, int count, Bullet bullet) {
+	if (bulletsIndices != null) {
+		bulletsIndices = null;
+		bullets = null;
+	}
+	if (bullets == null) {
+		if (bullet == null) return;
+		bullets = new Bullet[1];
+		bullets[0] = bullet;
+	}
+	int index = 0;
+	while (index < bullets.length) {
+		if (bullet == bullets[index]) break;
+		index++;
+	}
+	if (bullet != null) {
+		if (index == bullets.length) {
+			Bullet[] newBulletsList = new Bullet[bullets.length + 1];
+			System.arraycopy(bullets, 0, newBulletsList, 0, bullets.length);
+			newBulletsList[index] = bullet;
+			bullets = newBulletsList;
+		}
+		bullet.addIndices(startLine, count);
+	} else {
+		updateBullets(startLine, count, 0, false);
+		styledText.redrawLinesBullet(redrawLines);
+		redrawLines = null;
+	}
+}
+void setLineIndent(int startLine, int count, int indent) {
+	if (lines == null) lines = new LineInfo[lineCount];
+	for (int i = startLine; i < startLine + count; i++) {
+		if (lines[i] == null) {
+			lines[i] = new LineInfo();
+		}
+		lines[i].flags |= INDENT;
+		lines[i].indent = indent;
+	}
+}
+void setLineJustify(int startLine, int count, boolean justify) {
+	if (lines == null) lines = new LineInfo[lineCount];
+	for (int i = startLine; i < startLine + count; i++) {
+		if (lines[i] == null) {
+			lines[i] = new LineInfo();
+		}
+		lines[i].flags |= JUSTIFY;
+		lines[i].justify = justify;
+	}
+}
+void setLineSegments(int startLine, int count, int[] segments) {
+	if (lines == null) lines = new LineInfo[lineCount];
+	for (int i = startLine; i < startLine + count; i++) {
+		if (lines[i] == null) {
+			lines[i] = new LineInfo();
+		}
+		lines[i].flags |= SEGMENTS;
+		lines[i].segments = segments;
+	}
+}
+void setStyleRanges (int[] newRanges, StyleRange[] newStyles) {
+	if (newStyles == null) {
+		stylesSetCount = styleCount = 0;
+		ranges = null;
+		styles = null;
+		stylesSet = null;
+		return;
+	}
+	if (newRanges == null && COMPACT_STYLES) {
+		newRanges = new int[newStyles.length << 1];		
+		StyleRange[] tmpStyles = new StyleRange[newStyles.length];
+		if (stylesSet == null) stylesSet = new StyleRange[4];
+		for (int i = 0, j = 0; i < newStyles.length; i++) {
+			StyleRange newStyle = newStyles[i];
+			newRanges[j++] = newStyle.start;
+			newRanges[j++] = newStyle.length;
+			int index = 0;
+			while (index < stylesSetCount) {
+				if (stylesSet[index].similarTo(newStyle)) break;
+				index++;
+			}
+			if (index == stylesSetCount) {
+				if (stylesSetCount == stylesSet.length) {
+					StyleRange[] tmpStylesSet = new StyleRange[stylesSetCount + 4];
+					System.arraycopy(stylesSet, 0, tmpStylesSet, 0, stylesSetCount);
+					stylesSet = tmpStylesSet;
+				}
+				stylesSet[stylesSetCount++] = newStyle;
+			}
+			tmpStyles[i] = stylesSet[index];
+		}
+		newStyles = tmpStyles;
+	}
+	
+	if (styleCount == 0) {
+		if (newRanges != null) {
+			ranges = new int[newRanges.length];
+			System.arraycopy(newRanges, 0, ranges, 0, ranges.length);
+		}
+		styles = new StyleRange[newStyles.length];
+		System.arraycopy(newStyles, 0, styles, 0, styles.length);
+		styleCount = newStyles.length;
+		return;
+	}
+	if (newRanges != null && ranges == null) {
+		ranges = new int[styles.length << 1];
+		for (int i = 0, j = 0; i < styleCount; i++) {
+			ranges[j++] = styles[i].start;
+			ranges[j++] = styles[i].length;
+		}
+	}
+	if (newRanges == null && ranges != null) {
+		newRanges = new int[newStyles.length << 1];
+		for (int i = 0, j = 0; i < newStyles.length; i++) {
+			newRanges[j++] = newStyles[i].start;
+			newRanges[j++] = newStyles[i].length;
+		}
+	}
+	if (ranges != null) {
+		int rangeCount = styleCount << 1;
+		int start = newRanges[0];
+		int modifyStart = getRangeIndex(start, -1, rangeCount), modifyEnd;
+		boolean insert = modifyStart == rangeCount;
+		if (!insert) {
+			int end = newRanges[newRanges.length - 2] + newRanges[newRanges.length - 1];
+			modifyEnd = getRangeIndex(end, modifyStart - 1, rangeCount);
+			insert = modifyStart == modifyEnd && ranges[modifyStart] >= end;
+		}
+		if (insert) {
+			addMerge(newRanges, newStyles, newRanges.length, modifyStart, modifyStart);
+			return;
+		}
+		modifyEnd = modifyStart;
+		int[] mergeRanges = new int[6];
+		StyleRange[] mergeStyles = new StyleRange[3];
+		for (int i = 0; i < newRanges.length; i += 2) {
+			int newStart = newRanges[i];
+			int newEnd = newStart + newRanges[i + 1];
+			if (newStart == newEnd) continue;
+			int modifyLast = 0, mergeCount = 0;
+			while (modifyEnd < rangeCount) {
+				if (newStart >= ranges[modifyStart] + ranges[modifyStart + 1]) modifyStart += 2;
+				if (ranges[modifyEnd] + ranges[modifyEnd + 1] > newEnd) break;
+				modifyEnd += 2;
+			}
+			if (ranges[modifyStart] < newStart && newStart < ranges[modifyStart] + ranges[modifyStart + 1]) {
+				mergeStyles[mergeCount >> 1] = styles[modifyStart >> 1];
+				mergeRanges[mergeCount] = ranges[modifyStart];
+				mergeRanges[mergeCount + 1] = newStart - ranges[modifyStart];				
+				mergeCount += 2;
+			}
+			mergeStyles[mergeCount >> 1] = newStyles[i >> 1];
+			mergeRanges[mergeCount] = newStart;
+			mergeRanges[mergeCount + 1] = newRanges[i + 1];
+			mergeCount += 2;
+			if (modifyEnd < rangeCount && ranges[modifyEnd] < newEnd && newEnd < ranges[modifyEnd] + ranges[modifyEnd + 1]) {
+				mergeStyles[mergeCount >> 1] = styles[modifyEnd >> 1];
+				mergeRanges[mergeCount] = newEnd;
+				mergeRanges[mergeCount + 1] = ranges[modifyEnd] + ranges[modifyEnd + 1] - newEnd;
+				mergeCount += 2;
+				modifyLast = 2;
+			}
+			int grow = addMerge(mergeRanges, mergeStyles, mergeCount, modifyStart, modifyEnd + modifyLast);
+			rangeCount += grow;
+			modifyStart = modifyEnd += grow;
+		}
+	} else {
+		int start = newStyles[0].start;
+		int modifyStart = getRangeIndex(start, -1, styleCount), modifyEnd;
+		boolean insert = modifyStart == styleCount;
+		if (!insert) {
+			int end = newStyles[newStyles.length - 1].start + newStyles[newStyles.length - 1].length;
+			modifyEnd = getRangeIndex(end, modifyStart - 1, styleCount);
+			insert = modifyStart == modifyEnd && styles[modifyStart].start >= end;
+		}
+		if (insert) {
+			addMerge(newStyles, newStyles.length, modifyStart, modifyStart);
+			return;
+		}
+		modifyEnd = modifyStart;
+		StyleRange[] mergeStyles = new StyleRange[3];
+		for (int i = 0; i < newStyles.length; i++) {
+			StyleRange newStyle = newStyles[i], style; 
+			int newStart = newStyle.start;
+			int newEnd = newStart + newStyle.length;
+			if (newStart == newEnd) continue;
+			int modifyLast = 0, mergeCount = 0;
+			while (modifyEnd < styleCount) {
+				if (newStart >= styles[modifyStart].start + styles[modifyStart].length) modifyStart++;
+				if (styles[modifyEnd].start + styles[modifyEnd].length > newEnd) break;
+				modifyEnd++;
+			}
+			style = styles[modifyStart];
+			if (style.start < newStart && newStart < style.start + style.length) {
+				style = mergeStyles[mergeCount++] = (StyleRange)style.clone();
+				style.length = newStart - style.start;
+			}
+			mergeStyles[mergeCount++] = newStyle;
+			if (modifyEnd < styleCount) {
+				style = styles[modifyEnd];
+				if (style.start < newEnd && newEnd < style.start + style.length) {
+					style = mergeStyles[mergeCount++] = (StyleRange)style.clone();
+					style.length += style.start - newEnd;
+					style.start = newEnd;
+					modifyLast = 1;
+				}
+			}
+			int grow = addMerge(mergeStyles, mergeCount, modifyStart, modifyEnd + modifyLast);
+			modifyStart = modifyEnd += grow;
+		}
+	}
+}
+void textChanging(TextChangingEvent event) {
+	int start = event.start;
+	int newCharCount = event.newCharCount, replaceCharCount = event.replaceCharCount;
+	int newLineCount = event.newLineCount, replaceLineCount = event.replaceLineCount;
+	
+	updateRanges(start, replaceCharCount, newCharCount);	
+	
+	int startLine = content.getLineAtOffset(start);
+	if (replaceCharCount == content.getCharCount()) lines = null;
+	if (replaceLineCount == lineCount) {
+		lineCount = newLineCount;
+		lineWidth = new int[lineCount];
+		lineHeight = new int[lineCount];
+		reset(0, lineCount);
+	} else {
+		int delta = newLineCount - replaceLineCount;
+		if (lineCount + delta > lineWidth.length) {
+			int[] newWidths = new int[lineCount + delta + GROW];
+			System.arraycopy(lineWidth, 0, newWidths, 0, lineCount);
+			lineWidth = newWidths;			
+			int[] newHeights = new int[lineCount + delta + GROW];
+			System.arraycopy(lineHeight, 0, newHeights, 0, lineCount);
+			lineHeight = newHeights;
+		}
+		if (lines != null) {
+			if (lineCount + delta > lines.length) {
+				LineInfo[] newLines = new LineInfo[lineCount + delta + GROW];
+				System.arraycopy(lines, 0, newLines, 0, lineCount);
+				lines = newLines;
+			}
+		}
+		int startIndex = startLine + replaceLineCount + 1;
+		int endIndex = startLine + newLineCount + 1;
+		System.arraycopy(lineWidth, startIndex, lineWidth, endIndex, lineCount - startIndex);
+		System.arraycopy(lineHeight, startIndex, lineHeight, endIndex, lineCount - startIndex);
+		for (int i = startLine; i < endIndex; i++) {
+			lineWidth[i] = lineHeight[i] = -1;
+		}
+		for (int i = lineCount + delta; i < lineCount; i++) {
+			lineWidth[i] = lineHeight[i] = -1;
+		}
+		if (layouts != null) {
+			int layoutStartLine = startLine - topIndex;
+			int layoutEndLine = layoutStartLine + replaceLineCount + 1;
+			for (int i = layoutStartLine; i < layoutEndLine; i++) {
+				if (0 <= i && i < layouts.length) {
+					if (layouts[i] != null) layouts[i].dispose();
+					layouts[i] = null;
+					if (bullets != null && bulletsIndices != null) bullets[i] = null;
+				}
+			}
+			if (delta > 0) {
+				for (int i = layouts.length - 1; i >= layoutEndLine; i--) {
+					if (0 <= i && i < layouts.length) {
+						endIndex = i + delta;
+						if (0 <= endIndex && endIndex < layouts.length) {
+							layouts[endIndex] = layouts[i];
+							layouts[i] = null;
+							if (bullets != null && bulletsIndices != null) {
+								bullets[endIndex] = bullets[i];
+								bulletsIndices[endIndex] = bulletsIndices[i];
+								bullets[i] = null;
+							}
+						} else {
+							if (layouts[i] != null) layouts[i].dispose();
+							layouts[i] = null;
+							if (bullets != null && bulletsIndices != null) bullets[i] = null;
+						}
+					}
+				}
+			} else if (delta < 0) {
+				for (int i = layoutEndLine; i < layouts.length; i++) {
+					if (0 <= i && i < layouts.length) {
+						endIndex = i + delta;
+						if (0 <= endIndex && endIndex < layouts.length) {
+							layouts[endIndex] = layouts[i];
+							layouts[i] = null;
+							if (bullets != null && bulletsIndices != null) {
+								bullets[endIndex] = bullets[i];
+								bulletsIndices[endIndex] = bulletsIndices[i];
+								bullets[i] = null;
+							}
+						} else {
+							if (layouts[i] != null) layouts[i].dispose();
+							layouts[i] = null;
+							if (bullets != null && bulletsIndices != null) bullets[i] = null;
+						}
+					}
+				}
+			}
+		}
+		if (replaceLineCount != 0 || newLineCount != 0) {
+			int startLineOffset = content.getOffsetAtLine(startLine);
+			if (startLineOffset != start) startLine++;
+			updateBullets(startLine, replaceLineCount, newLineCount, true);
+			if (lines != null) {
+				startIndex = startLine + replaceLineCount;
+				endIndex = startLine + newLineCount;
+				System.arraycopy(lines, startIndex, lines, endIndex, lineCount - startIndex);
+				for (int i = startLine; i < endIndex; i++) {
+					lines[i] = null;
+				}
+				for (int i = lineCount + delta; i < lineCount; i++) {
+					lines[i] = null;
+				}
+			}
+		}
+		lineCount += delta;
+		if (maxWidthLineIndex != -1 && startLine <= maxWidthLineIndex && maxWidthLineIndex <= startLine + replaceLineCount) {
+			maxWidth = 0;
+			maxWidthLineIndex = -1;
+			for (int i = 0; i < lineCount; i++) {
+				if (lineWidth[i] > maxWidth) {
+					maxWidth = lineWidth[i];
+					maxWidthLineIndex = i;
+				}
+			}
+		}
+	}
+}
+void updateBullets(int startLine, int replaceLineCount, int newLineCount, boolean update) {
+	if (bullets == null) return;
+	if (bulletsIndices != null) return;
+	for (int i = 0; i < bullets.length; i++) {
+		Bullet bullet = bullets[i];
+		int[] lines = bullet.removeIndices(startLine, replaceLineCount, newLineCount, update);
+		if (lines != null) {
+			if (redrawLines == null) {
+				redrawLines = lines;
+			} else {
+				int[] newRedrawBullets = new int[redrawLines.length + lines.length];
+				System.arraycopy(redrawLines, 0, newRedrawBullets, 0, redrawLines.length);
+				System.arraycopy(lines, 0, newRedrawBullets, redrawLines.length, lines.length);
+				redrawLines = newRedrawBullets;
+			}
+		}
+	}
+	int removed = 0;
+	for (int i = 0; i < bullets.length; i++) {
+		if (bullets[i].size() == 0) removed++;
+	}
+	if (removed > 0) {
+		if (removed == bullets.length) {
+			bullets = null;
+		} else {
+			Bullet[] newBulletsList = new Bullet[bullets.length - removed];
+			for (int i = 0, j = 0; i < bullets.length; i++) {
+				Bullet bullet = bullets[i];
+				if (bullet.size() > 0) newBulletsList[j++] = bullet;
+			}
+			bullets = newBulletsList;
+		}
+	}
+}
+void updateRanges(int start, int replaceCharCount, int newCharCount) {
+	if (styleCount == 0 || (replaceCharCount == 0 && newCharCount == 0)) return;
+	if (ranges != null) {
+		int rangeCount = styleCount << 1;
+		int modifyStart = getRangeIndex(start, -1, rangeCount);
+		if (modifyStart == rangeCount) return;
+		int end = start + replaceCharCount;
+		int modifyEnd = getRangeIndex(end, modifyStart - 1, rangeCount);
+		int offset = newCharCount - replaceCharCount;
+		if (modifyStart == modifyEnd && ranges[modifyStart] < start && end < ranges[modifyEnd] + ranges[modifyEnd + 1]) {
+			if (newCharCount == 0) {
+				ranges[modifyStart + 1] -= replaceCharCount;
+				modifyEnd += 2;
+			} else {
+				if (rangeCount + 2 > ranges.length) {
+					int[] newRanges = new int[ranges.length + (GROW << 1)];
+					System.arraycopy(ranges, 0, newRanges, 0, rangeCount);
+					ranges = newRanges;
+					StyleRange[] newStyles = new StyleRange[styles.length + GROW];
+					System.arraycopy(styles, 0, newStyles, 0, styleCount);
+					styles = newStyles;
+				}
+				System.arraycopy(ranges, modifyStart + 2, ranges, modifyStart + 4, rangeCount - (modifyStart + 2));
+				System.arraycopy(styles, (modifyStart + 2) >> 1, styles, (modifyStart + 4) >> 1, styleCount - ((modifyStart + 2) >> 1));
+				ranges[modifyStart + 3] = ranges[modifyStart] + ranges[modifyStart + 1] - end;
+				ranges[modifyStart + 2] = start + newCharCount;
+				ranges[modifyStart + 1] = start - ranges[modifyStart];
+				styles[(modifyStart >> 1) + 1] = styles[modifyStart >> 1]; 
+				rangeCount += 2;
+				styleCount++;
+				modifyEnd += 4;
+			}
+			if (offset != 0) {
+				for (int i = modifyEnd; i < rangeCount; i += 2) {
+					ranges[i] += offset;
+				}
+			}
+		} else {
+			if (ranges[modifyStart] < start && start < ranges[modifyStart] + ranges[modifyStart + 1]) {
+				ranges[modifyStart + 1] = start - ranges[modifyStart];
+				modifyStart += 2;
+			}
+			if (modifyEnd < rangeCount && ranges[modifyEnd] < end && end < ranges[modifyEnd] + ranges[modifyEnd + 1]) {
+				ranges[modifyEnd + 1] = ranges[modifyEnd] + ranges[modifyEnd + 1] - end;
+				ranges[modifyEnd] = end;
+			}
+			if (offset != 0) {
+				for (int i = modifyEnd; i < rangeCount; i += 2) {
+					ranges[i] += offset;
+				}
+			}
+			System.arraycopy(ranges, modifyEnd, ranges, modifyStart, rangeCount - modifyEnd);
+			System.arraycopy(styles, modifyEnd >> 1, styles, modifyStart >> 1, styleCount - (modifyEnd >> 1));
+			styleCount -= (modifyEnd - modifyStart) >> 1;
+		}
+	} else {
+		int modifyStart = getRangeIndex(start, -1, styleCount);
+		if (modifyStart == styleCount) return;
+		int end = start + replaceCharCount;
+		int modifyEnd = getRangeIndex(end, modifyStart - 1, styleCount);
+		int offset = newCharCount - replaceCharCount;
+		if (modifyStart == modifyEnd && styles[modifyStart].start < start && end < styles[modifyEnd].start + styles[modifyEnd].length) {
+			if (newCharCount == 0) {
+				styles[modifyStart].length -= replaceCharCount;
+				modifyEnd++;
+			} else {
+				if (styleCount + 1 > styles.length) {
+					StyleRange[] newStyles = new StyleRange[styles.length + GROW];
+					System.arraycopy(styles, 0, newStyles, 0, styleCount);
+					styles = newStyles;
+				}
+				System.arraycopy(styles, modifyStart + 1, styles, modifyStart + 2, styleCount - (modifyStart + 1));
+				styles[modifyStart + 1] = (StyleRange)styles[modifyStart].clone();
+				styles[modifyStart + 1].length = styles[modifyStart].start + styles[modifyStart].length - end;
+				styles[modifyStart + 1].start = start + newCharCount;
+				styles[modifyStart].length = start - styles[modifyStart].start;
+				styleCount++;
+				modifyEnd += 2;
+			}
+			if (offset != 0) {
+				for (int i = modifyEnd; i < styleCount; i++) {
+					styles[i].start += offset;
+				}
+			}
+		} else {
+			if (styles[modifyStart].start < start && start < styles[modifyStart].start + styles[modifyStart].length) {
+				styles[modifyStart].length = start - styles[modifyStart].start;
+				modifyStart++;
+			}
+			if (modifyEnd < styleCount && styles[modifyEnd].start < end && end < styles[modifyEnd].start + styles[modifyEnd].length) {
+				styles[modifyEnd].length = styles[modifyEnd].start + styles[modifyEnd].length - end;
+				styles[modifyEnd].start = end;
+			}
+			if (offset != 0) {
+				for (int i = modifyEnd; i < styleCount; i++) {
+					styles[i].start += offset;
+				}
+			}
+			System.arraycopy(styles, modifyEnd, styles, modifyStart, styleCount - modifyEnd);
+			styleCount -= modifyEnd - modifyStart;
+		}
+	}
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/custom/TableCursor.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/custom/TableCursor.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/custom/TableCursor.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,759 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.custom;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.events.*;
+
+/**
+ * A TableCursor provides a way for the user to navigate around a Table
+ * using the keyboard.  It also provides a mechanism for selecting an
+ * individual cell in a table.
+ * 
+ * <p> Here is an example of using a TableCursor to navigate to a cell and then edit it.
+ * 
+ * <code><pre>
+ *  public static void main(String[] args) {
+ *		Display display = new Display();
+ *		Shell shell = new Shell(display);
+ *		shell.setLayout(new GridLayout());
+ *	
+ *		// create a a table with 3 columns and fill with data
+ *		final Table table = new Table(shell, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
+ *		table.setLayoutData(new GridData(GridData.FILL_BOTH));
+ *		TableColumn column1 = new TableColumn(table, SWT.NONE);
+ *		TableColumn column2 = new TableColumn(table, SWT.NONE);
+ *		TableColumn column3 = new TableColumn(table, SWT.NONE);
+ *		for (int i = 0; i &lt; 100; i++) {
+ *			TableItem item = new TableItem(table, SWT.NONE);
+ *			item.setText(new String[] { "cell "+i+" 0", "cell "+i+" 1", "cell "+i+" 2"});
+ *		}
+ *		column1.pack();
+ *		column2.pack();
+ *		column3.pack();
+ *	
+ *		// create a TableCursor to navigate around the table
+ *		final TableCursor cursor = new TableCursor(table, SWT.NONE);
+ *		// create an editor to edit the cell when the user hits "ENTER" 
+ *		// while over a cell in the table
+ *		final ControlEditor editor = new ControlEditor(cursor);
+ *		editor.grabHorizontal = true;
+ *		editor.grabVertical = true;
+ *	
+ *		cursor.addSelectionListener(new SelectionAdapter() {
+ *			// when the TableEditor is over a cell, select the corresponding row in 
+ *			// the table
+ *			public void widgetSelected(SelectionEvent e) {
+ *				table.setSelection(new TableItem[] {cursor.getRow()});
+ *			}
+ *			// when the user hits "ENTER" in the TableCursor, pop up a text editor so that 
+ *			// they can change the text of the cell
+ *			public void widgetDefaultSelected(SelectionEvent e){
+ *				final Text text = new Text(cursor, SWT.NONE);
+ *				TableItem row = cursor.getRow();
+ *				int column = cursor.getColumn();
+ *				text.setText(row.getText(column));
+ *				text.addKeyListener(new KeyAdapter() {
+ *					public void keyPressed(KeyEvent e) {
+ *						// close the text editor and copy the data over 
+ *						// when the user hits "ENTER"
+ *						if (e.character == SWT.CR) {
+ *							TableItem row = cursor.getRow();
+ *							int column = cursor.getColumn();
+ *							row.setText(column, text.getText());
+ *							text.dispose();
+ *						}
+ *						// close the text editor when the user hits "ESC"
+ *						if (e.character == SWT.ESC) {
+ *							text.dispose();
+ *						}
+ *					}
+ *				});
+ *				editor.setEditor(text);
+ *				text.setFocus();
+ *			}
+ *		});
+ *		// Hide the TableCursor when the user hits the "MOD1" or "MOD2" key.
+ *		// This allows the user to select multiple items in the table.
+ *		cursor.addKeyListener(new KeyAdapter() {
+ *			public void keyPressed(KeyEvent e) {
+ *				if (e.keyCode == SWT.MOD1 || 
+ *				    e.keyCode == SWT.MOD2 || 
+ *				    (e.stateMask & SWT.MOD1) != 0 || 
+ *				    (e.stateMask & SWT.MOD2) != 0) {
+ *					cursor.setVisible(false);
+ *				}
+ *			}
+ *		});
+ *		// Show the TableCursor when the user releases the "MOD2" or "MOD1" key.
+ *		// This signals the end of the multiple selection task.
+ *		table.addKeyListener(new KeyAdapter() {
+ *			public void keyReleased(KeyEvent e) {
+ *				if (e.keyCode == SWT.MOD1 && (e.stateMask & SWT.MOD2) != 0) return;
+ *				if (e.keyCode == SWT.MOD2 && (e.stateMask & SWT.MOD1) != 0) return;
+ *				if (e.keyCode != SWT.MOD1 && (e.stateMask & SWT.MOD1) != 0) return;
+ *				if (e.keyCode != SWT.MOD2 && (e.stateMask & SWT.MOD2) != 0) return;
+ *			
+ *				TableItem[] selection = table.getSelection();
+ *				TableItem row = (selection.length == 0) ? table.getItem(table.getTopIndex()) : selection[0];
+ *				table.showItem(row);
+ *				cursor.setSelection(row, 0);
+ *				cursor.setVisible(true);
+ *				cursor.setFocus();
+ *			}
+ *		});
+ *	
+ *		shell.open();
+ *		while (!shell.isDisposed()) {
+ *			if (!display.readAndDispatch())
+ *				display.sleep();
+ *		}
+ *		display.dispose();
+ *	}
+ * </pre></code>
+ * 
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>BORDER</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Selection, DefaultSelection</dd>
+ * </dl>
+ * 
+ * @since 2.0
+ *
+ * @see <a href="http://www.eclipse.org/swt/snippets/#tablecursor">TableCursor snippets</a>
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a> 
+ */
+public class TableCursor extends Canvas {
+	Table table;
+	TableItem row = null;
+	TableColumn column = null;
+	Listener tableListener, resizeListener, disposeItemListener, disposeColumnListener;
+
+	Color background = null;
+	Color foreground = null;
+
+	// By default, invert the list selection colors
+	static final int BACKGROUND = SWT.COLOR_LIST_SELECTION_TEXT;
+	static final int FOREGROUND = SWT.COLOR_LIST_SELECTION;
+
+/**
+ * Constructs a new instance of this class given its parent
+ * table and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a Table control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT#BORDER
+ * @see Widget#checkSubclass()
+ * @see Widget#getStyle()
+ */
+public TableCursor(Table parent, int style) {
+	super(parent, style);
+	table = parent;
+	setBackground(null);
+	setForeground(null);
+	
+	Listener listener = new Listener() {
+		public void handleEvent(Event event) {
+			switch (event.type) {
+				case SWT.Dispose :
+					dispose(event);
+					break;
+				case SWT.FocusIn :
+				case SWT.FocusOut :
+					redraw();
+					break;
+				case SWT.KeyDown :
+					keyDown(event);
+					break;
+				case SWT.Paint :
+					paint(event);
+					break;
+				case SWT.Traverse : {
+					event.doit = true;
+					switch (event.detail) {
+						case SWT.TRAVERSE_ARROW_NEXT :
+						case SWT.TRAVERSE_ARROW_PREVIOUS :
+						case SWT.TRAVERSE_RETURN :
+							event.doit = false;
+							break;
+					}
+					break;
+				}
+			}
+		}
+	};
+	int[] events = new int[] {SWT.Dispose, SWT.FocusIn, SWT.FocusOut, SWT.KeyDown, SWT.Paint, SWT.Traverse};
+	for (int i = 0; i < events.length; i++) {
+		addListener(events[i], listener);
+	}
+
+	tableListener = new Listener() {
+		public void handleEvent(Event event) {
+			switch (event.type) {
+				case SWT.MouseDown :
+					tableMouseDown(event);
+					break;
+				case SWT.FocusIn :
+					tableFocusIn(event);
+					break;
+			}
+		}
+	};
+	table.addListener(SWT.FocusIn, tableListener);
+	table.addListener(SWT.MouseDown, tableListener);
+
+	disposeItemListener = new Listener() {
+		public void handleEvent(Event event) {
+			unhookRowColumnListeners();
+			row = null;
+			column = null;
+			_resize();
+		}
+	};
+	disposeColumnListener = new Listener() {
+		public void handleEvent(Event event) {
+			unhookRowColumnListeners();
+			row = null;
+			column = null;
+			_resize();
+		}
+	};
+	resizeListener = new Listener() {
+		public void handleEvent(Event event) {
+			_resize();
+		}
+	};
+	ScrollBar hBar = table.getHorizontalBar();
+	if (hBar != null) {
+		hBar.addListener(SWT.Selection, resizeListener);
+	}
+	ScrollBar vBar = table.getVerticalBar();
+	if (vBar != null) {
+		vBar.addListener(SWT.Selection, resizeListener);
+	}
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the user changes the receiver's selection, by sending
+ * it one of the messages defined in the <code>SelectionListener</code>
+ * interface.
+ * <p>
+ * When <code>widgetSelected</code> is called, the item field of the event object is valid.
+ * If the receiver has <code>SWT.CHECK</code> style set and the check selection changes,
+ * the event object detail field contains the value <code>SWT.CHECK</code>.
+ * <code>widgetDefaultSelected</code> is typically called when an item is double-clicked.
+ * </p>
+ *
+ * @param listener the listener which should be notified when the user changes the receiver's selection
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see SelectionEvent
+ * @see #removeSelectionListener(SelectionListener)
+ * 
+ */
+public void addSelectionListener(SelectionListener listener) {
+	checkWidget();
+	if (listener == null)
+		SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	TypedListener typedListener = new TypedListener(listener);
+	addListener(SWT.Selection, typedListener);
+	addListener(SWT.DefaultSelection, typedListener);
+}
+
+void dispose(Event event) {
+	table.removeListener(SWT.FocusIn, tableListener);
+	table.removeListener(SWT.MouseDown, tableListener);
+	unhookRowColumnListeners();
+	ScrollBar hBar = table.getHorizontalBar();
+	if (hBar != null) {
+		hBar.removeListener(SWT.Selection, resizeListener);
+	}
+	ScrollBar vBar = table.getVerticalBar();
+	if (vBar != null) {
+		vBar.removeListener(SWT.Selection, resizeListener);
+	}
+}
+
+void keyDown(Event event) {
+	if (row == null) return;
+	switch (event.character) {
+		case SWT.CR :
+			notifyListeners(SWT.DefaultSelection, new Event());
+			return;
+	}
+	int rowIndex = table.indexOf(row);
+	int columnIndex = column == null ? 0 : table.indexOf(column);
+	switch (event.keyCode) {
+		case SWT.ARROW_UP :
+			setRowColumn(Math.max(0, rowIndex - 1), columnIndex, true);
+			break;
+		case SWT.ARROW_DOWN :
+			setRowColumn(Math.min(rowIndex + 1, table.getItemCount() - 1), columnIndex, true);
+			break;
+        case SWT.ARROW_LEFT :
+        case SWT.ARROW_RIGHT :
+        	{	
+        		int columnCount = table.getColumnCount();
+        		if (columnCount == 0) break;
+        		int[] order = table.getColumnOrder();
+        		int index = 0;
+        		while (index < order.length) {
+        			if (order[index] == columnIndex) break;
+        			index++;
+				}
+				if (index == order.length) index = 0;
+		        int leadKey = (getStyle() & SWT.RIGHT_TO_LEFT) != 0 ? SWT.ARROW_RIGHT : SWT.ARROW_LEFT;
+		        if (event.keyCode == leadKey) {
+		           setRowColumn(rowIndex, order[Math.max(0, index - 1)], true);
+		        } else {
+		           setRowColumn(rowIndex, order[Math.min(columnCount - 1, index + 1)], true);
+		        }
+		        break;
+        	}
+		case SWT.HOME :
+			setRowColumn(0, columnIndex, true);
+			break;
+		case SWT.END :
+			{
+				int i = table.getItemCount() - 1;
+				setRowColumn(i, columnIndex, true);
+				break;
+			}
+		case SWT.PAGE_UP :
+			{
+				int index = table.getTopIndex();
+				if (index == rowIndex) {
+					Rectangle rect = table.getClientArea();
+					TableItem item = table.getItem(index);
+					Rectangle itemRect = item.getBounds(0);
+					rect.height -= itemRect.y;
+					int height = table.getItemHeight();
+					int page = Math.max(1, rect.height / height);
+					index = Math.max(0, index - page + 1);
+				}
+				setRowColumn(index, columnIndex, true);
+				break;
+			}
+		case SWT.PAGE_DOWN :
+			{
+				int index = table.getTopIndex();
+				Rectangle rect = table.getClientArea();
+				TableItem item = table.getItem(index);
+				Rectangle itemRect = item.getBounds(0);
+				rect.height -= itemRect.y;
+				int height = table.getItemHeight();
+				int page = Math.max(1, rect.height / height);
+				int end = table.getItemCount() - 1;
+				index = Math.min(end, index + page - 1);
+				if (index == rowIndex) {
+					index = Math.min(end, index + page - 1);
+				}
+				setRowColumn(index, columnIndex, true);
+				break;
+			}
+	}
+}
+
+void paint(Event event) {
+	if (row == null) return;
+	int columnIndex = column == null ? 0 : table.indexOf(column);
+	GC gc = event.gc;
+	Display display = getDisplay();
+	gc.setBackground(getBackground());
+	gc.setForeground(getForeground());
+	gc.fillRectangle(event.x, event.y, event.width, event.height);
+	int x = 0;
+	Point size = getSize();
+	Image image = row.getImage(columnIndex);
+	if (image != null) {
+		Rectangle imageSize = image.getBounds();
+		int imageY = (size.y - imageSize.height) / 2;
+		gc.drawImage(image, x, imageY);
+		x += imageSize.width;
+	}
+	String text = row.getText(columnIndex);
+	if (text.length() > 0) {
+		Rectangle bounds = row.getBounds(columnIndex);
+		Point extent = gc.stringExtent(text);
+		// Temporary code - need a better way to determine table trim
+		String platform = SWT.getPlatform();
+		if ("win32".equals(platform)) { //$NON-NLS-1$
+			if (table.getColumnCount() == 0 || columnIndex == 0) {
+				x += 2; 
+			} else {
+				int alignmnent = column.getAlignment();
+				switch (alignmnent) {
+					case SWT.LEFT:
+						x += 6;
+						break;
+					case SWT.RIGHT:
+						x = bounds.width - extent.x - 6;
+						break;
+					case SWT.CENTER:
+						x += (bounds.width - x - extent.x) / 2;
+						break;
+				}
+			}
+		}  else {
+			if (table.getColumnCount() == 0) {
+				x += 5; 
+			} else {
+				int alignmnent = column.getAlignment();
+				switch (alignmnent) {
+					case SWT.LEFT:
+						x += 5;
+						break;
+					case SWT.RIGHT:
+						x = bounds.width- extent.x - 2;
+						break;
+					case SWT.CENTER:
+						x += (bounds.width - x - extent.x) / 2 + 2;
+						break;
+				}
+			}
+		}
+		int textY = (size.y - extent.y) / 2;
+		gc.drawString(text, x, textY);
+	}
+	if (isFocusControl()) {
+		gc.setBackground(display.getSystemColor(SWT.COLOR_BLACK));
+		gc.setForeground(display.getSystemColor(SWT.COLOR_WHITE));
+		gc.drawFocus(0, 0, size.x, size.y);
+	}
+}
+
+void tableFocusIn(Event event) {
+	if (isDisposed()) return;
+	if (isVisible()) {
+		if (row == null && column == null) return;
+		setFocus();
+	}
+}
+
+void tableMouseDown(Event event) {
+	if (isDisposed() || !isVisible()) return;
+	Point pt = new Point(event.x, event.y);
+	int lineWidth = table.getLinesVisible() ? table.getGridLineWidth() : 0;
+	TableItem item = table.getItem(pt);
+	if ((table.getStyle() & SWT.FULL_SELECTION) != 0) {
+		if (item == null) return;
+	} else {
+		int start = item != null ? table.indexOf(item) : table.getTopIndex();
+		int end = table.getItemCount();
+		Rectangle clientRect = table.getClientArea();
+		for (int i = start; i < end; i++) {
+			TableItem nextItem = table.getItem(i);
+			Rectangle rect = nextItem.getBounds(0);
+			if (pt.y >= rect.y && pt.y < rect.y + rect.height + lineWidth) {
+				item = nextItem;
+				break;
+			}
+			if (rect.y > clientRect.y + clientRect.height) 	return;
+		}
+		if (item == null) return;
+	}
+	TableColumn newColumn = null;
+	int columnCount = table.getColumnCount();
+	if (columnCount == 0) {
+		if ((table.getStyle() & SWT.FULL_SELECTION) == 0) {
+			Rectangle rect = item.getBounds(0);
+			rect.width += lineWidth;
+			rect.height += lineWidth;
+			if (!rect.contains(pt)) return;
+		}
+	} else {
+		for (int i = 0; i < columnCount; i++) {
+			Rectangle rect = item.getBounds(i);
+			rect.width += lineWidth;
+			rect.height += lineWidth;
+			if (rect.contains(pt)) {
+				newColumn = table.getColumn(i);
+				break;
+			}
+		}
+		if (newColumn == null) {
+			if ((table.getStyle() & SWT.FULL_SELECTION) == 0) return;
+			newColumn = table.getColumn(0);
+		}
+	}
+	setRowColumn(item, newColumn, true);
+	setFocus();
+	return;
+}
+void setRowColumn(int row, int column, boolean notify) {
+	TableItem item = row == -1 ? null : table.getItem(row);
+	TableColumn col = column == -1 || table.getColumnCount() == 0 ? null : table.getColumn(column);
+	setRowColumn(item, col, notify);
+}
+void setRowColumn(TableItem row, TableColumn column, boolean notify) {
+	if (this.row == row && this.column == column) {
+		return;
+	}
+	if (this.row != null && this.row != row) {
+		this.row.removeListener(SWT.Dispose, disposeItemListener);
+		this.row = null;
+	}
+	if (this.column != null && this.column != column) {
+		this.column.removeListener(SWT.Dispose, disposeColumnListener);
+		this.column.removeListener(SWT.Move, resizeListener);
+		this.column.removeListener(SWT.Resize, resizeListener);
+		this.column = null;
+	}
+	if (row != null) {
+		if (this.row != row) {
+			this.row = row;
+			row.addListener(SWT.Dispose, disposeItemListener);
+			table.showItem(row);
+		}
+		if (this.column != column && column != null) {
+			this.column = column;
+			column.addListener(SWT.Dispose, disposeColumnListener);
+			column.addListener(SWT.Move, resizeListener);
+			column.addListener(SWT.Resize, resizeListener);
+			table.showColumn(column);
+		}
+		int columnIndex = column == null ? 0 : table.indexOf(column);
+		setBounds(row.getBounds(columnIndex));
+		redraw();
+		if (notify) {
+			notifyListeners(SWT.Selection, new Event());
+		}
+	}
+}
+
+public void setVisible(boolean visible) {
+	checkWidget();
+	if (visible) _resize();
+	super.setVisible(visible);
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the user changes the receiver's selection.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #addSelectionListener(SelectionListener)
+ * 
+ * @since 3.0
+ */
+public void removeSelectionListener(SelectionListener listener) {
+	checkWidget();
+	if (listener == null) {
+		SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	}
+	removeListener(SWT.Selection, listener);
+	removeListener(SWT.DefaultSelection, listener);	
+}
+
+void _resize() {
+	if (row == null) {
+		setBounds(-200, -200, 0, 0);
+	} else {
+		int columnIndex = column == null ? 0 : table.indexOf(column);
+		setBounds(row.getBounds(columnIndex));
+	}
+}
+/**
+ * Returns the column over which the TableCursor is positioned.
+ *
+ * @return the column for the current position
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getColumn() {
+	checkWidget();
+	return column == null ? 0 : table.indexOf(column);
+}
+/**
+ * Returns the background color that the receiver will use to draw.
+ *
+ * @return the receiver's background color
+ */
+public Color getBackground() {
+	checkWidget();
+	if (background == null) {
+		return getDisplay().getSystemColor(BACKGROUND);
+	}
+	return background;
+}
+/**
+ * Returns the foreground color that the receiver will use to draw.
+ *
+ * @return the receiver's foreground color
+ */
+public Color getForeground() {
+	checkWidget();
+	if (foreground == null) {
+		return getDisplay().getSystemColor(FOREGROUND);
+	}
+	return foreground;
+}
+/**
+ * Returns the row over which the TableCursor is positioned.
+ *
+ * @return the item for the current position
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public TableItem getRow() {
+	checkWidget();
+	return row;
+}
+/**
+ * Sets the receiver's background color to the color specified
+ * by the argument, or to the default system color for the control
+ * if the argument is null.
+ * <p>
+ * Note: This operation is a hint and may be overridden by the platform.
+ * For example, on Windows the background of a Button cannot be changed.
+ * </p>
+ * @param color the new color (or null)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li> 
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setBackground (Color color) {
+	background = color;
+	super.setBackground(getBackground());
+	redraw();
+}
+/**
+ * Sets the receiver's foreground color to the color specified
+ * by the argument, or to the default system color for the control
+ * if the argument is null.
+ * <p>
+ * Note: This operation is a hint and may be overridden by the platform.
+ * </p>
+ * @param color the new color (or null)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li> 
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setForeground (Color color) {
+	foreground = color;
+	super.setForeground(getForeground());
+	redraw();
+}
+/**
+ * Positions the TableCursor over the cell at the given row and column in the parent table. 
+ *
+ * @param row the index of the row for the cell to select
+ * @param column the index of column for the cell to select
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ */
+public void setSelection(int row, int column) {
+	checkWidget();
+	int columnCount = table.getColumnCount();
+	int maxColumnIndex =  columnCount == 0 ? 0 : columnCount - 1;
+	if (row < 0
+	    || row >= table.getItemCount()
+		|| column < 0
+		|| column > maxColumnIndex)
+		SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	setRowColumn(row, column, false);
+}
+/**
+ * Positions the TableCursor over the cell at the given row and column in the parent table. 
+ *
+ * @param row the TableItem of the row for the cell to select
+ * @param column the index of column for the cell to select
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ */
+public void setSelection(TableItem row, int column) {
+	checkWidget();
+	int columnCount = table.getColumnCount();
+	int maxColumnIndex =  columnCount == 0 ? 0 : columnCount - 1;
+	if (row == null
+		|| row.isDisposed()
+		|| column < 0
+		|| column > maxColumnIndex)
+		SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	setRowColumn(table.indexOf(row), column, false);
+}
+void unhookRowColumnListeners() {
+	if (column != null) {
+		column.removeListener(SWT.Dispose, disposeColumnListener);
+		column.removeListener(SWT.Move, resizeListener);
+		column.removeListener(SWT.Resize, resizeListener);
+		column = null;
+	}
+	if (row != null) {
+		row.removeListener(SWT.Dispose, disposeItemListener);
+		row = null;
+	}
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/custom/TableEditor.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/custom/TableEditor.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/custom/TableEditor.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,260 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.custom;
+
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+
+/**
+*
+* A TableEditor is a manager for a Control that appears above a cell in a Table and tracks with the
+* moving and resizing of that cell.  It can be used to display a text widget above a cell
+* in a Table so that the user can edit the contents of that cell.  It can also be used to display
+* a button that can launch a dialog for modifying the contents of the associated cell.
+*
+* <p> Here is an example of using a TableEditor:
+* <code><pre>
+*	final Table table = new Table(shell, SWT.FULL_SELECTION | SWT.HIDE_SELECTION);
+*	TableColumn column1 = new TableColumn(table, SWT.NONE);
+*	TableColumn column2 = new TableColumn(table, SWT.NONE);
+*	for (int i = 0; i &lt; 10; i++) {
+*		TableItem item = new TableItem(table, SWT.NONE);
+*		item.setText(new String[] {"item " + i, "edit this value"});
+*	}
+*	column1.pack();
+*	column2.pack();
+*	
+*	final TableEditor editor = new TableEditor(table);
+*	//The editor must have the same size as the cell and must
+*	//not be any smaller than 50 pixels.
+*	editor.horizontalAlignment = SWT.LEFT;
+*	editor.grabHorizontal = true;
+*	editor.minimumWidth = 50;
+*	// editing the second column
+*	final int EDITABLECOLUMN = 1;
+*	
+*	table.addSelectionListener(new SelectionAdapter() {
+*		public void widgetSelected(SelectionEvent e) {
+*			// Clean up any previous editor control
+*			Control oldEditor = editor.getEditor();
+*			if (oldEditor != null) oldEditor.dispose();
+*	
+*			// Identify the selected row
+*			TableItem item = (TableItem)e.item;
+*			if (item == null) return;
+*	
+*			// The control that will be the editor must be a child of the Table
+*			Text newEditor = new Text(table, SWT.NONE);
+*			newEditor.setText(item.getText(EDITABLECOLUMN));
+*			newEditor.addModifyListener(new ModifyListener() {
+*				public void modifyText(ModifyEvent e) {
+*					Text text = (Text)editor.getEditor();
+*					editor.getItem().setText(EDITABLECOLUMN, text.getText());
+*				}
+*			});
+*			newEditor.selectAll();
+*			newEditor.setFocus();
+*			editor.setEditor(newEditor, item, EDITABLECOLUMN);
+*		}
+*	});
+* </pre></code>
+*
+* @see <a href="http://www.eclipse.org/swt/snippets/#tableeditor">TableEditor snippets</a>
+* @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+*/
+public class TableEditor extends ControlEditor {
+	Table table;
+	TableItem item;
+	int column = -1;
+	ControlListener columnListener;
+	Runnable timer;
+	static final int TIMEOUT = 1500;
+/**
+* Creates a TableEditor for the specified Table.
+*
+* @param table the Table Control above which this editor will be displayed
+*
+*/
+public TableEditor (Table table) {
+	super(table);
+	this.table = table;
+	
+	columnListener = new ControlListener() {
+		public void controlMoved(ControlEvent e){
+			layout ();
+		}
+		public void controlResized(ControlEvent e){
+			layout ();
+		}
+	};
+	timer = new Runnable () {
+		public void run() {
+			layout ();
+		}
+	};
+	
+	// To be consistent with older versions of SWT, grabVertical defaults to true
+	grabVertical = true;
+}
+Rectangle computeBounds () {
+	if (item == null || column == -1 || item.isDisposed()) return new Rectangle(0, 0, 0, 0);
+	Rectangle cell = item.getBounds(column);
+	Rectangle rect = item.getImageBounds(column);
+	cell.x = rect.x + rect.width;
+	cell.width -= rect.width;
+	Rectangle area = table.getClientArea();
+	if (cell.x < area.x + area.width) {
+		if (cell.x + cell.width > area.x + area.width) {
+			cell.width = area.x + area.width - cell.x;
+		}
+	}
+	Rectangle editorRect = new Rectangle(cell.x, cell.y, minimumWidth, minimumHeight);
+
+	if (grabHorizontal) {
+		editorRect.width = Math.max(cell.width, minimumWidth);
+	}
+	
+	if (grabVertical) {
+		editorRect.height = Math.max(cell.height, minimumHeight);
+	}
+	
+	if (horizontalAlignment == SWT.RIGHT) {
+		editorRect.x += cell.width - editorRect.width;
+	} else if (horizontalAlignment == SWT.LEFT) {
+		// do nothing - cell.x is the right answer
+	} else { // default is CENTER
+		editorRect.x += (cell.width - editorRect.width)/2;
+	}
+	
+	if (verticalAlignment == SWT.BOTTOM) {
+		editorRect.y += cell.height - editorRect.height;
+	} else if (verticalAlignment == SWT.TOP) {
+		// do nothing - cell.y is the right answer
+	} else { // default is CENTER
+		editorRect.y += (cell.height - editorRect.height)/2;
+	}
+	return editorRect;
+}
+/**
+ * Removes all associations between the TableEditor and the cell in the table.  The
+ * Table and the editor Control are <b>not</b> disposed.
+ */
+public void dispose () {
+	if (table != null && !table.isDisposed()) {
+		if (this.column > -1 && this.column < table.getColumnCount()){
+			TableColumn tableColumn = table.getColumn(this.column);
+			tableColumn.removeControlListener(columnListener);
+		}
+	}
+	columnListener = null;
+	table = null;
+	item = null;
+	column = -1;
+	timer = null;
+	super.dispose();
+}
+/**
+* Returns the zero based index of the column of the cell being tracked by this editor.
+*
+* @return the zero based index of the column of the cell being tracked by this editor
+*/
+public int getColumn () {
+	return column;
+}
+/**
+* Returns the TableItem for the row of the cell being tracked by this editor.
+*
+* @return the TableItem for the row of the cell being tracked by this editor
+*/
+public TableItem getItem () {
+	return item;
+}
+void resize () {
+	layout();
+	/*
+	 * On some platforms, the table scrolls when an item that
+	 * is partially visible at the bottom of the table is
+	 * selected.  Ensure that the correct row is edited by
+	 * laying out one more time in a timerExec().
+	 */
+	if (table != null) {
+		Display display = table.getDisplay();
+		display.timerExec(-1, timer);
+		display.timerExec(TIMEOUT, timer);
+	}
+}
+/**
+* Sets the zero based index of the column of the cell being tracked by this editor.
+* 
+* @param column the zero based index of the column of the cell being tracked by this editor 
+*/
+public void setColumn(int column) {
+	int columnCount = table.getColumnCount();
+	// Separately handle the case where the table has no TableColumns.
+	// In this situation, there is a single default column.
+	if (columnCount == 0) {
+		this.column = (column == 0) ? 0 : -1;
+		resize();
+		return;
+	}
+	if (this.column > -1 && this.column < columnCount){
+		TableColumn tableColumn = table.getColumn(this.column);
+		tableColumn.removeControlListener(columnListener);
+		this.column = -1;
+	}
+
+	if (column < 0  || column >= table.getColumnCount()) return;	
+		
+	this.column = column;
+	TableColumn tableColumn = table.getColumn(this.column);
+	tableColumn.addControlListener(columnListener);
+	resize();
+}
+/**
+* Specifies the <code>TableItem</code> that is to be edited.
+*
+* @param item the item to be edited
+*/
+public void setItem (TableItem item) {	
+	this.item = item;
+	resize();
+}
+public void setEditor (Control editor) {
+	super.setEditor(editor);
+	resize();
+}
+/**
+* Specify the Control that is to be displayed and the cell in the table that it is to be positioned above.
+*
+* <p>Note: The Control provided as the editor <b>must</b> be created with its parent being the Table control
+* specified in the TableEditor constructor.
+* 
+* @param editor the Control that is displayed above the cell being edited
+* @param item the TableItem for the row of the cell being tracked by this editor
+* @param column the zero based index of the column of the cell being tracked by this editor
+*/
+public void setEditor (Control editor, TableItem item, int column) {
+	setItem(item);
+	setColumn(column);
+	setEditor(editor);
+}
+public void layout () {
+	if (table == null || table.isDisposed()) return;
+	if (item == null || item.isDisposed()) return;
+	int columnCount = table.getColumnCount();
+	if (columnCount == 0 && column != 0) return;
+	if (columnCount > 0 && (column < 0 || column >= columnCount)) return;
+	super.layout();
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/custom/TableTree.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/custom/TableTree.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/custom/TableTree.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,814 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.custom;
+
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+
+/** 
+ * A TableTree is a selectable user interface object
+ * that displays a hierarchy of items, and issues
+ * notification when an item is selected.
+ * A TableTree may be single or multi select.
+ * <p>
+ * The item children that may be added to instances of this class
+ * must be of type <code>TableTreeItem</code>.
+ * </p><p>
+ * Note that although this class is a subclass of <code>Composite</code>,
+ * it does not make sense to add <code>Control</code> children to it,
+ * or set a layout on it.
+ * </p><p>
+ * <dl>
+ *	<dt><b>Styles:</b> <dd> SINGLE, MULTI, CHECK, FULL_SELECTION
+ *	<dt><b>Events:</b> <dd> Selection, DefaultSelection, Collapse, Expand
+ * </dl>
+ * <p>
+ * Note: Only one of the styles SINGLE, and MULTI may be specified.
+ * </p>
+ * 
+ * @deprecated As of 3.1 use Tree, TreeItem and TreeColumn
+ */
+public class TableTree extends Composite {
+	Table table;
+	TableTreeItem[] items = EMPTY_ITEMS;
+	Image plusImage, minusImage, sizeImage;
+
+	/*
+	* TableTreeItems are not treated as children but rather as items.
+	* When the TableTree is disposed, all children are disposed because 
+	* TableTree inherits this behaviour from Composite.  The items
+	* must be disposed separately.  Because TableTree is not part of
+	* the org.eclipse.swt.widgets package, the method releaseWidget can 
+	* not be overridden (this is how items are disposed of in Table and Tree).
+	* Instead, the items are disposed of in response to the dispose event on the
+	* TableTree.  The "inDispose" flag is used to distinguish between disposing
+	* one TableTreeItem (e.g. when removing an entry from the TableTree) and 
+	* disposing the entire TableTree.
+	*/
+	boolean inDispose = false;
+	
+	static final TableTreeItem[] EMPTY_ITEMS = new TableTreeItem [0];	
+	static final String[] EMPTY_TEXTS = new String [0];	
+	static final Image[] EMPTY_IMAGES = new Image [0];
+	static final String ITEMID = "TableTreeItemID"; //$NON-NLS-1$
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a widget which will be the parent of the new instance (cannot be null)
+ * @param style the style of widget to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * </ul>
+ *
+ * @see SWT#SINGLE
+ * @see SWT#MULTI
+ * @see SWT#CHECK
+ * @see SWT#FULL_SELECTION
+ * @see #getStyle
+ */
+public TableTree(Composite parent, int style) {
+	super(parent, checkStyle (style));
+	table = new Table(this, style);
+	Listener tableListener = new Listener() {
+		public void handleEvent(Event e) {
+			switch (e.type) {
+			case SWT.MouseDown: onMouseDown(e); break;
+			case SWT.Selection: onSelection(e); break;
+			case SWT.DefaultSelection: onSelection(e); break;
+			case SWT.KeyDown: onKeyDown(e); break;
+			}
+		}
+	};
+	int[] tableEvents = new int[]{SWT.MouseDown, 
+		                           SWT.Selection, 
+		                           SWT.DefaultSelection, 
+		                           SWT.KeyDown};
+	for (int i = 0; i < tableEvents.length; i++) {
+		table.addListener(tableEvents[i], tableListener);
+	}
+	
+	Listener listener = new Listener() {
+		public void handleEvent(Event e) {
+			switch (e.type) {
+			case SWT.Dispose: onDispose(e); break;
+			case SWT.Resize:  onResize(e); break;
+			case SWT.FocusIn: onFocusIn(e); break;
+			}
+		}
+	};
+	int[] events = new int[]{SWT.Dispose, 
+		                      SWT.Resize, 
+		                      SWT.FocusIn};
+	for (int i = 0; i < events.length; i++) {
+		addListener(events[i], listener);
+	}	                      
+}
+
+int addItem(TableTreeItem item, int index) {
+	if (index < 0 || index > items.length) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	TableTreeItem[] newItems = new TableTreeItem[items.length + 1];
+	System.arraycopy(items, 0, newItems, 0, index);
+	newItems[index] = item;
+	System.arraycopy(items, index, newItems, index + 1, items.length - index); 
+	items = newItems;
+
+	/* Return the index in the table where this table should be inserted */
+	if (index == items.length - 1 ) 
+		return table.getItemCount();
+	else 
+		return table.indexOf(items[index+1].tableItem);
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the user changes the receiver's selection, by sending
+ * it one of the messages defined in the <code>SelectionListener</code>
+ * interface.
+ * <p>
+ * When <code>widgetSelected</code> is called, the item field of the event object is valid.
+ * If the receiver has <code>SWT.CHECK</code> style set and the check selection changes,
+ * the event object detail field contains the value <code>SWT.CHECK</code>.
+ * <code>widgetDefaultSelected</code> is typically called when an item is double-clicked.
+ * The item field of the event object is valid for default selection, but the detail field is not used.
+ * </p>
+ *
+ * @param listener the listener which should be notified when the user changes the receiver's selection
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent
+ */
+public void addSelectionListener(SelectionListener listener) {
+	checkWidget();
+	if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+	TypedListener typedListener = new TypedListener (listener);
+	addListener (SWT.Selection,typedListener);
+	addListener (SWT.DefaultSelection,typedListener);
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when an item in the receiver is expanded or collapsed
+ * by sending it one of the messages defined in the <code>TreeListener</code>
+ * interface.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see TreeListener
+ * @see #removeTreeListener
+ */
+public void addTreeListener(TreeListener listener) {
+	checkWidget();
+	if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+	TypedListener typedListener = new TypedListener (listener);
+	addListener (SWT.Expand, typedListener);
+	addListener (SWT.Collapse, typedListener);
+}
+private static int checkStyle (int style) {
+	int mask = SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT; 
+	style = style & mask;
+	return style;
+} 
+public Point computeSize (int wHint, int hHint, boolean changed) {
+	checkWidget();
+	return table.computeSize (wHint, hHint, changed);
+}
+public Rectangle computeTrim (int x, int y, int width, int height) {
+	checkWidget();
+	return table.computeTrim(x, y, width, height);
+}
+
+/**
+ * Deselects all items.
+ * <p>
+ * If an item is selected, it is deselected.
+ * If an item is not selected, it remains unselected.
+ *
+ * @exception SWTException <ul>
+ *	<li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread
+ *	<li>ERROR_WIDGET_DISPOSED when the widget has been disposed
+ * </ul>
+ */
+public void deselectAll () {
+	checkWidget();
+	table.deselectAll();
+}
+
+/* Expand upward from the specified leaf item. */
+void expandItem (TableTreeItem item) {
+	if (item == null) return;
+	expandItem(item.parentItem);
+	if (!item.getVisible()) item.setVisible(true);
+	if ( !item.expanded && item.items.length > 0) {
+		item.setExpanded(true);
+		Event event = new Event();
+		event.item = item;
+		notifyListeners(SWT.Expand, event);
+	}
+}
+public Color getBackground () {
+	// This method must be overridden otherwise, in a TableTree in which the first
+	// item has no sub items, a grey (Widget background colour) square will appear in
+	// the first column of the first item.
+	// It is not possible in the constructor to set the background of the TableTree
+	// to be the same as the background of the Table because this interferes with 
+	// the TableTree adapting to changes in the System color settings.
+	return table.getBackground();
+}
+public Rectangle getClientArea () {
+	return table.getClientArea();
+}
+public Color getForeground () {
+	return table.getForeground();
+}
+public Font getFont () {
+	return table.getFont();
+}
+/**
+ * Gets the number of items.
+ * <p>
+ * @return the number of items in the widget
+ */
+public int getItemCount () {
+	//checkWidget();
+	return items.length;
+}
+
+/**
+ * Gets the height of one item.
+ * <p>
+ * This operation will fail if the height of
+ * one item could not be queried from the OS.
+ *
+ * @return the height of one item in the widget
+ *
+ * @exception SWTException <ul>
+ *	<li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread
+ *	<li>ERROR_WIDGET_DISPOSED when the widget has been disposed
+ * </ul>
+ */
+public int getItemHeight () {
+	checkWidget();
+	return table.getItemHeight();
+}
+
+/**
+ * Gets the items.
+ * <p>
+ * @return the items in the widget
+ */
+public TableTreeItem [] getItems () {
+	//checkWidget();
+	TableTreeItem[] newItems = new TableTreeItem[items.length];
+	System.arraycopy(items, 0, newItems, 0, items.length);
+	return newItems;
+}
+
+/**
+ * Gets the selected items.
+ * <p>
+ * This operation will fail if the selected
+ * items cannot be queried from the OS.
+ *
+ * @return the selected items in the widget
+ *
+ * @exception SWTException <ul>
+ *		<li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+ *		<li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+ *	</ul>
+ */
+public TableTreeItem [] getSelection () {
+	checkWidget();
+	TableItem[] selection = table.getSelection();
+	TableTreeItem [] result = new TableTreeItem[selection.length];
+	for (int i = 0; i < selection.length; i++){
+		result[i] = (TableTreeItem) selection[i].getData(ITEMID);
+	}
+	return result;
+}
+
+/**
+ * Gets the number of selected items.
+ * <p>
+ * This operation will fail if the number of selected
+ * items cannot be queried from the OS.
+ *
+ * @return the number of selected items in the widget
+ *
+ * @exception SWTException <ul>
+ *		<li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+ *		<li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+ *	</ul>
+ */
+public int getSelectionCount () {
+	checkWidget();
+	return table.getSelectionCount();
+}
+
+public int getStyle () {
+	checkWidget();
+	return table.getStyle();
+}
+
+/**
+ * Returns the underlying Table control.
+ *
+ * @return the underlying Table control
+ */
+public Table getTable () {
+	//checkWidget();
+	return table;
+}
+
+void createImages () {
+	
+	int itemHeight = sizeImage.getBounds().height;
+	// Calculate border around image. 
+	// At least 9 pixels are needed to draw the image
+	// Leave at least a 6 pixel border.
+	int indent = Math.min(6, (itemHeight - 9) / 2);
+	indent = Math.max(0, indent);
+	int size = Math.max (10, itemHeight - 2 * indent); 
+	size = ((size + 1) / 2) * 2; // size must be an even number
+	int midpoint = indent + size / 2;
+	
+	Color foreground = getForeground();
+	Color plusMinus = getDisplay().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW);
+	Color background = getBackground();
+	
+	/* Plus image */
+	PaletteData palette = new PaletteData(new RGB[]{foreground.getRGB(), background.getRGB(), plusMinus.getRGB()});
+	ImageData imageData = new ImageData(itemHeight, itemHeight, 4, palette);
+	imageData.transparentPixel = 1;
+	plusImage = new Image(getDisplay(), imageData);
+	GC gc = new GC(plusImage);
+	gc.setBackground(background);
+	gc.fillRectangle(0, 0, itemHeight, itemHeight);
+	gc.setForeground(plusMinus);
+	gc.drawRectangle(indent, indent, size, size);
+	gc.setForeground(foreground);
+	gc.drawLine(midpoint, indent + 2, midpoint, indent + size - 2);
+	gc.drawLine(indent + 2, midpoint, indent + size - 2, midpoint);
+	gc.dispose();
+	
+	/* Minus image */
+	palette = new PaletteData(new RGB[]{foreground.getRGB(), background.getRGB(), plusMinus.getRGB()});
+	imageData = new ImageData(itemHeight, itemHeight, 4, palette);
+	imageData.transparentPixel = 1;
+	minusImage = new Image(getDisplay(), imageData);
+	gc = new GC(minusImage);
+	gc.setBackground(background);
+	gc.fillRectangle(0, 0, itemHeight, itemHeight);
+	gc.setForeground(plusMinus);
+	gc.drawRectangle(indent, indent, size, size);
+	gc.setForeground(foreground);
+	gc.drawLine(indent + 2, midpoint, indent + size - 2, midpoint);
+	gc.dispose();
+}
+
+Image getPlusImage() {
+	if (plusImage == null) createImages();
+	return plusImage;
+}
+
+Image getMinusImage() {
+	if (minusImage == null) createImages();
+	return minusImage;
+}
+
+/**
+ * Gets the index of an item.
+ * 
+ * <p>The widget is searched starting at 0 until an
+ * item is found that is equal to the search item.
+ * If no item is found, -1 is returned.  Indexing
+ * is zero based.  This index is relative to the parent only.
+ *
+ * @param item the search item
+ * @return the index of the item or -1
+ */
+public int indexOf (TableTreeItem item) {
+	//checkWidget();
+	for (int i = 0; i < items.length; i++) {
+		if (item == items[i]) return i;
+	}
+	return -1;
+}
+
+void onDispose(Event e) {
+	/*
+	 * Usually when an item is disposed, destroyItem will change the size of the items array
+	 * and dispose of the underlying table items.
+	 * Since the whole table tree is being disposed, this is not necessary.  For speed
+	 * the inDispose flag is used to skip over this part of the item dispose.
+	 */
+	inDispose = true;
+	for (int i = 0; i < items.length; i++) {
+		items[i].dispose();
+	}
+	inDispose = false;
+	if (plusImage != null) plusImage.dispose();
+	if (minusImage != null) minusImage.dispose();
+	if (sizeImage != null) sizeImage.dispose();
+	plusImage = minusImage = sizeImage = null;
+}
+
+void onResize(Event e) {
+	Point size = getSize();
+	table.setBounds(0, 0, size.x, size.y);
+}
+
+void onSelection(Event e) {
+	Event event = new Event();
+	TableItem tableItem = (TableItem)e.item;
+	TableTreeItem item = getItem(tableItem);
+    event.item = item;
+
+	if (e.type == SWT.Selection && e.detail == SWT.CHECK && item != null) {
+		event.detail = SWT.CHECK;
+		item.checked = tableItem.getChecked();
+	}
+	notifyListeners(e.type, event);
+}
+/**
+ * Returns the item at the given, zero-relative index in the
+ * receiver. Throws an exception if the index is out of range.
+ *
+ * @param index the index of the item to return
+ * @return the item at the given index
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.1
+ */
+public TableTreeItem getItem (int index) {
+	checkWidget();
+	int count = items.length;
+	if (!(0 <= index && index < count)) SWT.error (SWT.ERROR_INVALID_RANGE);
+	return items [index];
+}
+
+/**
+ * Returns the item at the given point in the receiver
+ * or null if no such item exists. The point is in the
+ * coordinate system of the receiver.
+ *
+ * @param point the point used to locate the item
+ * @return the item at the given point
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the point is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public TableTreeItem getItem(Point point) {
+	checkWidget();
+	TableItem item = table.getItem(point);
+	if (item == null) return null;
+	return getItem(item);
+	
+}
+TableTreeItem getItem(TableItem tableItem) {
+	if (tableItem == null) return null;
+	for (int i = 0; i < items.length; i++) {
+	    	TableTreeItem item = items[i].getItem(tableItem);
+	    	if (item != null) return item;
+	}
+	return null;
+}
+void onFocusIn (Event e) {
+	table.setFocus();
+}
+
+void onKeyDown (Event e) {
+	TableTreeItem[] selection = getSelection();
+	if (selection.length == 0) return;
+	TableTreeItem item = selection[0];
+	int type = 0;
+	if (e.keyCode == SWT.ARROW_RIGHT || e.keyCode == SWT.ARROW_LEFT) {
+		int trailKey = (getStyle() & SWT.MIRRORED) != 0 ? SWT.ARROW_LEFT : SWT.ARROW_RIGHT;
+		if (e.keyCode == trailKey) {
+			if (item.getItemCount() == 0) return;
+			if (item.getExpanded()) {
+				TableTreeItem newSelection = item.getItems()[0];
+				table.setSelection(new TableItem[]{newSelection.tableItem});
+				showItem(newSelection);
+				type = SWT.Selection;
+			} else {
+				item.setExpanded(true);
+				type = SWT.Expand;
+			}
+		} else {
+			if (item.getExpanded()) {
+				item.setExpanded(false);
+				type = SWT.Collapse;
+			} else {
+				TableTreeItem parent = item.getParentItem();
+				if (parent != null) {
+					int index = parent.indexOf(item);
+					if (index != 0) return;
+					table.setSelection(new TableItem[]{parent.tableItem});
+					type = SWT.Selection;
+				}
+			}
+		}
+	}
+	if (e.character == '*') {
+		item.expandAll(true);
+	}
+	if (e.character == '-') {
+		if (item.getExpanded()) {
+			item.setExpanded(false);
+			type = SWT.Collapse;
+		}
+	}
+	if (e.character == '+') {
+		if (item.getItemCount() > 0 && !item.getExpanded()) {
+			item.setExpanded(true);
+			type = SWT.Expand;
+		}
+	} 
+	if (type == 0) return;
+	Event event = new Event();
+	event.item = item;
+	notifyListeners(type, event);
+}
+void onMouseDown(Event event) {
+	/* If user clicked on the [+] or [-], expand or collapse the tree. */
+	TableItem[] items = table.getItems();
+	for (int i = 0; i < items.length; i++) {
+		Rectangle rect = items[i].getImageBounds(0);
+		if (rect.contains(event.x, event.y)) {
+			TableTreeItem item = (TableTreeItem) items[i].getData(ITEMID);
+			event = new Event();
+			event.item = item;
+			item.setExpanded(!item.getExpanded());
+			if (item.getExpanded()) {
+				notifyListeners(SWT.Expand, event);
+			} else {
+				notifyListeners(SWT.Collapse, event);
+			}
+			return;
+		}
+	}
+}
+
+/**
+ * Removes all items.
+ * <p>
+ * This operation will fail when an item
+ * could not be removed in the OS.
+ *
+ * @exception SWTException <ul>
+ *	<li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread
+ * 	<li>ERROR_WIDGET_DISPOSED when the widget has been disposed
+ * </ul>
+ */
+public void removeAll () {
+	checkWidget();
+	setRedraw(false);
+	for (int i = items.length - 1; i >= 0; i--) {
+		items[i].dispose();
+	}
+	items = EMPTY_ITEMS;
+	setRedraw(true);
+}
+
+void removeItem(TableTreeItem item) {
+	int index = 0;
+	while (index < items.length && items[index] != item) index++;
+	if (index == items.length) return;
+	TableTreeItem[] newItems = new TableTreeItem[items.length - 1];
+	System.arraycopy(items, 0, newItems, 0, index);
+	System.arraycopy(items, index + 1, newItems, index, items.length - index - 1);
+	items = newItems;
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the user changes the receiver's selection.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #addSelectionListener
+ */
+public void removeSelectionListener (SelectionListener listener) {
+	checkWidget();
+	if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+	removeListener(SWT.Selection, listener);
+	removeListener(SWT.DefaultSelection, listener);
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when items in the receiver are expanded or collapsed.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see TreeListener
+ * @see #addTreeListener
+ */
+public void removeTreeListener (TreeListener listener) {
+	checkWidget();
+	if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+	removeListener(SWT.Expand, listener);
+	removeListener(SWT.Collapse, listener);
+}
+
+/**
+ * Selects all of the items in the receiver.
+ * <p>
+ * If the receiver is single-select, do nothing.
+ *
+ * @exception SWTException <ul>
+ *	<li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread
+ *	<li>ERROR_WIDGET_DISPOSED when the widget has been disposed
+ * </ul>
+ */
+public void selectAll () {
+	checkWidget();
+	table.selectAll();
+}
+public void setBackground (Color color) {
+	super.setBackground(color);
+	table.setBackground(color);
+	if (sizeImage != null) {
+		GC gc = new GC (sizeImage);
+		gc.setBackground(getBackground());
+		Rectangle size = sizeImage.getBounds();
+		gc.fillRectangle(size);
+		gc.dispose();
+	}
+}
+public void setEnabled (boolean enabled) {
+	super.setEnabled(enabled);
+	table.setEnabled(enabled);
+}
+public void setFont (Font font) {
+	super.setFont(font);
+	table.setFont(font);
+}
+public void setForeground (Color color) {
+	super.setForeground(color);
+	table.setForeground(color);
+}
+public void setMenu (Menu menu) {
+	super.setMenu(menu);
+	table.setMenu(menu);
+}
+
+/**
+ * Sets the receiver's selection to be the given array of items.
+ * The current selection is cleared before the new items are selected.
+ * <p>
+ * Items that are not in the receiver are ignored.
+ * If the receiver is single-select and multiple items are specified,
+ * then all items are ignored.
+ *
+ * @param items the array of items
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the array of items is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if one of the item has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see TableTree#deselectAll()
+ */
+public void setSelection (TableTreeItem[] items) {
+	checkWidget ();
+	if (items == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+	int length = items.length;
+	if (length == 0 || ((table.getStyle() & SWT.SINGLE) != 0 && length > 1)) {
+		deselectAll();
+		return;
+	}
+	TableItem[] tableItems = new TableItem[length];
+	for (int i = 0; i < length; i++) {
+		if (items[i] == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+		if (!items[i].getVisible()) expandItem (items[i]);
+		tableItems[i] = items[i].tableItem;
+	}
+	table.setSelection(tableItems);
+}
+public void setToolTipText (String string) {
+	super.setToolTipText(string);
+	table.setToolTipText(string);
+}
+
+/**
+ * Shows the item.  If the item is already showing in the receiver,
+ * this method simply returns.  Otherwise, the items are scrolled
+ * and expanded until the item is visible.
+ *
+ * @param item the item to be shown
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the item is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the item has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see TableTree#showSelection()
+ */
+public void showItem (TableTreeItem item) {
+	checkWidget();
+	if (item == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+	if (!item.getVisible()) expandItem (item);
+	TableItem tableItem = item.tableItem;
+	table.showItem(tableItem);
+}
+
+/**
+ * Shows the selection.
+ * <p>
+ * If there is no selection or the selection
+ * is already visible, this method does nothing.
+ * If the selection is scrolled out of view,
+ * the top index of the widget is changed such
+ * that selection becomes visible.
+ *
+ * @exception SWTException <ul>
+ *	<li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread
+ *	<li>ERROR_WIDGET_DISPOSED when the widget has been disposed
+ * </ul>
+ */
+public void showSelection () {
+	checkWidget();
+	table.showSelection();
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/custom/TableTreeEditor.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/custom/TableTreeEditor.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/custom/TableTreeEditor.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,259 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.custom;
+
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.events.*;
+/**
+*
+* A TableTreeEditor is a manager for a Control that appears above a cell in a TableTree
+* and tracks with the moving and resizing of that cell.  It can be used to display a
+* text widget above a cell in a TableTree so that the user can edit the contents of 
+* that cell.  It can also be used to display a button that can launch a dialog for 
+* modifying the contents of the associated cell.
+*
+* <p> Here is an example of using a TableTreeEditor:
+* <code><pre>
+*	final TableTree tableTree = new TableTree(shell, SWT.FULL_SELECTION | SWT.HIDE_SELECTION);
+*	final Table table = tableTree.getTable();
+*	TableColumn column1 = new TableColumn(table, SWT.NONE);
+*	TableColumn column2 = new TableColumn(table, SWT.NONE);
+*	for (int i = 0; i &lt; 10; i++) {
+*		TableTreeItem item = new TableTreeItem(tableTree, SWT.NONE);
+*		item.setText(0, "item " + i);
+*		item.setText(1, "edit this value");
+*		for (int j = 0; j &lt; 3; j++) {
+*			TableTreeItem subitem = new TableTreeItem(item, SWT.NONE);
+*			subitem.setText(0, "subitem " + i + " " + j);
+*			subitem.setText(1, "edit this value");
+*		}
+*	}
+*	column1.setWidth(100);
+*	column2.pack();
+*	
+*	final TableTreeEditor editor = new TableTreeEditor(tableTree);
+*	//The editor must have the same size as the cell and must
+*	//not be any smaller than 50 pixels.
+*	editor.horizontalAlignment = SWT.LEFT;
+*	editor.grabHorizontal = true;
+*	editor.minimumWidth = 50;
+*	// editing the second column
+*	final int EDITABLECOLUMN = 1;
+*	
+*	tableTree.addSelectionListener(new SelectionAdapter() {
+*		public void widgetSelected(SelectionEvent e) {
+*			// Clean up any previous editor control
+*			Control oldEditor = editor.getEditor();
+*			if (oldEditor != null) oldEditor.dispose();
+*	
+*			// Identify the selected row
+*			TableTreeItem item = (TableTreeItem)e.item;
+*			if (item == null) return;
+*	
+*			// The control that will be the editor must be a child of the Table
+*			Text newEditor = new Text(table, SWT.NONE);
+*			newEditor.setText(item.getText(EDITABLECOLUMN));
+*			newEditor.addModifyListener(new ModifyListener() {
+*				public void modifyText(ModifyEvent e) {
+*					Text text = (Text)editor.getEditor();
+*					editor.getItem().setText(EDITABLECOLUMN, text.getText());
+*				}
+*			});
+*			newEditor.selectAll();
+*			newEditor.setFocus();
+*			editor.setEditor(newEditor, item, EDITABLECOLUMN);
+*		}
+*	});
+* </pre></code>
+* 
+* @deprecated As of 3.1 use TreeEditor with Tree, TreeItem and TreeColumn
+*/
+public class TableTreeEditor extends ControlEditor {
+
+	TableTree tableTree;
+	TableTreeItem item;
+	int column = -1;
+	ControlListener columnListener;
+	TreeListener treeListener;
+/**
+* Creates a TableTreeEditor for the specified TableTree.
+*
+* @param tableTree the TableTree Control above which this editor will be displayed
+*
+*/
+public TableTreeEditor (TableTree tableTree) {
+	super(tableTree.getTable());
+	this.tableTree = tableTree;
+
+	treeListener = new TreeListener () {
+		final Runnable runnable = new Runnable() {
+			public void run() {
+				if (editor == null || editor.isDisposed()) return;
+				if (TableTreeEditor.this.tableTree.isDisposed()) return;
+				layout();
+				editor.setVisible(true);
+			}
+		};
+		public void treeCollapsed(TreeEvent e) {
+			if (editor == null || editor.isDisposed ()) return;
+			editor.setVisible(false);
+			e.display.asyncExec(runnable);
+		}
+		public void treeExpanded(TreeEvent e) {
+			if (editor == null || editor.isDisposed ()) return;
+			editor.setVisible(false);
+			e.display.asyncExec(runnable);
+		}
+	};
+	tableTree.addTreeListener(treeListener);
+	
+	columnListener = new ControlListener() {
+		public void controlMoved(ControlEvent e){
+			layout ();
+		}
+		public void controlResized(ControlEvent e){
+			layout ();
+		}
+	};
+	
+	// To be consistent with older versions of SWT, grabVertical defaults to true
+	grabVertical = true;
+}
+Rectangle computeBounds () {
+	if (item == null || column == -1 || item.isDisposed() || item.tableItem == null) return new Rectangle(0, 0, 0, 0);
+	Rectangle cell = item.getBounds(column);
+	Rectangle area = tableTree.getClientArea();
+	if (cell.x < area.x + area.width) {
+		if (cell.x + cell.width > area.x + area.width) {
+			cell.width = area.x + area.width - cell.x;
+		}
+	}
+	Rectangle editorRect = new Rectangle(cell.x, cell.y, minimumWidth, minimumHeight);
+
+	if (grabHorizontal) {
+		editorRect.width = Math.max(cell.width, minimumWidth);
+	}
+	
+	if (grabVertical) {
+		editorRect.height = Math.max(cell.height, minimumHeight);
+	}
+	
+	if (horizontalAlignment == SWT.RIGHT) {
+		editorRect.x += cell.width - editorRect.width;
+	} else if (horizontalAlignment == SWT.LEFT) {
+		// do nothing - cell.x is the right answer
+	} else { // default is CENTER
+		editorRect.x += (cell.width - editorRect.width)/2;
+	}
+	
+	if (verticalAlignment == SWT.BOTTOM) {
+		editorRect.y += cell.height - editorRect.height;
+	} else if (verticalAlignment == SWT.TOP) {
+		// do nothing - cell.y is the right answer
+	} else { // default is CENTER
+		editorRect.y += (cell.height - editorRect.height)/2;
+	}
+	return editorRect;
+}
+/**
+ * Removes all associations between the TableTreeEditor and the cell in the table tree.  The
+ * TableTree and the editor Control are <b>not</b> disposed.
+ */
+public void dispose () {
+	if (tableTree != null && !tableTree.isDisposed()) {
+		Table table = tableTree.getTable();
+		if (table != null && !table.isDisposed()) {
+			if (this.column > -1 && this.column < table.getColumnCount()){
+				TableColumn tableColumn = table.getColumn(this.column);
+				tableColumn.removeControlListener(columnListener);
+			}
+		}
+		if (treeListener != null) tableTree.removeTreeListener(treeListener);
+	}
+	treeListener = null;
+	columnListener = null;
+	tableTree = null;
+	item = null;
+	column = -1;
+	super.dispose();
+}
+/**
+* Returns the zero based index of the column of the cell being tracked by this editor.
+*
+* @return the zero based index of the column of the cell being tracked by this editor
+*/
+public int getColumn () {
+	return column;
+}
+/**
+* Returns the TableTreeItem for the row of the cell being tracked by this editor.
+*
+* @return the TableTreeItem for the row of the cell being tracked by this editor
+*/
+public TableTreeItem getItem () {
+	return item;
+}
+public void setColumn(int column) {
+	Table table = tableTree.getTable();
+	int columnCount = table.getColumnCount();
+	// Separately handle the case where the table has no TableColumns.
+	// In this situation, there is a single default column.
+	if (columnCount == 0) {
+		this.column = (column == 0) ? 0 : -1;
+		layout();
+		return;
+	}
+	if (this.column > -1 && this.column < columnCount){
+		TableColumn tableColumn = table.getColumn(this.column);
+		tableColumn.removeControlListener(columnListener);
+		this.column = -1;
+	}
+
+	if (column < 0  || column >= table.getColumnCount()) return;	
+		
+	this.column = column;
+	TableColumn tableColumn = table.getColumn(this.column);
+	tableColumn.addControlListener(columnListener);
+	layout();
+}
+public void setItem (TableTreeItem item) {	
+	this.item = item;
+	layout();
+}
+
+/**
+* Specify the Control that is to be displayed and the cell in the table that it is to be positioned above.
+*
+* <p>Note: The Control provided as the editor <b>must</b> be created with its parent being the Table control
+* specified in the TableEditor constructor.
+* 
+* @param editor the Control that is displayed above the cell being edited
+* @param item the TableItem for the row of the cell being tracked by this editor
+* @param column the zero based index of the column of the cell being tracked by this editor
+*/
+public void setEditor (Control editor, TableTreeItem item, int column) {
+	setItem(item);
+	setColumn(column);
+	setEditor(editor);
+}
+public void layout () {
+	if (tableTree == null || tableTree.isDisposed()) return;
+	if (item == null || item.isDisposed()) return;
+	Table table = tableTree.getTable();
+	int columnCount = table.getColumnCount();
+	if (columnCount == 0 && column != 0) return;
+	if (columnCount > 0 && (column < 0 || column >= columnCount)) return;
+	super.layout();
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/custom/TableTreeItem.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/custom/TableTreeItem.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/custom/TableTreeItem.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,876 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.custom;
+
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+
+/**
+ * A TableTreeItem is a selectable user interface object
+ * that represents an item in a hierarchy of items in a
+ * TableTree.
+ * 
+ * @deprecated As of 3.1 use Tree, TreeItem and TreeColumn
+ */
+public class TableTreeItem extends Item {
+	TableItem tableItem;
+	TableTree parent;
+	TableTreeItem parentItem;
+	TableTreeItem [] items = TableTree.EMPTY_ITEMS;
+	String[] texts = TableTree.EMPTY_TEXTS;
+	Image[] images = TableTree.EMPTY_IMAGES;
+	Color background;
+	Color foreground;
+	Font font;
+	boolean expanded;
+	boolean checked;
+	boolean grayed;
+
+/**
+ * Constructs a new instance of this class given its parent
+ * (which must be a <code>TableTree</code>)
+ * and a style value describing its behavior and appearance.
+ * The item is added to the end of the items maintained by its parent.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * </ul>
+ *
+ * @see SWT
+ * @see Widget#getStyle()
+ */
+public TableTreeItem(TableTree parent, int style) {
+	this (parent, style, parent.getItemCount());
+}
+
+/**
+ * Constructs a new instance of this class given its parent
+ * (which must be a <code>TableTree</code>,
+ * a style value describing its behavior and appearance, and the index
+ * at which to place it in the items maintained by its parent.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ * @param index the index to store the receiver in its parent
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * </ul>
+ *
+ * @see SWT
+ * @see Widget#getStyle()
+ */
+public TableTreeItem(TableTree parent, int style, int index) {
+	this (parent, null, style, index);
+}
+
+/**
+ * Constructs a new instance of this class given its parent
+ * (which must be a <code>TableTreeItem</code>)
+ * and a style value describing its behavior and appearance.
+ * The item is added to the end of the items maintained by its parent.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * </ul>
+ *
+ * @see SWT
+ * @see Widget#getStyle()
+ */
+public TableTreeItem(TableTreeItem parent, int style) {
+	this (parent, style, parent.getItemCount());
+}
+
+/**
+ * Constructs a new instance of this class given its parent
+ * (which must be a <code>TableTreeItem</code>),
+ * a style value describing its behavior and appearance, and the index
+ * at which to place it in the items maintained by its parent.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ * @param index the index to store the receiver in its parent
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * </ul>
+ *
+ * @see SWT
+ * @see Widget#getStyle()
+ */
+public TableTreeItem(TableTreeItem parent, int style, int index) {
+	this (parent.getParent(), parent, style, index);
+}
+
+TableTreeItem(TableTree parent, TableTreeItem parentItem, int style, int index) {
+	super(parent, style);
+	this.parent = parent;
+	this.parentItem = parentItem;
+	if (parentItem == null) {
+		
+		/* Root items are visible immediately */
+		int tableIndex = parent.addItem(this, index);
+		tableItem = new TableItem(parent.getTable(), style, tableIndex);
+		tableItem.setData(TableTree.ITEMID, this);
+		addCheck();
+		/*
+		* Feature in the Table.  The table uses the first image that
+		* is inserted into the table to size the table rows.  If the
+		* user is allowed to insert the first image, this will cause
+		* the +/- images to be scaled.  The fix is to insert a dummy
+		* image to force the size.
+		*/
+		if (parent.sizeImage == null) {
+			int itemHeight = parent.getItemHeight();
+			parent.sizeImage = new Image(parent.getDisplay(), itemHeight, itemHeight);
+			GC gc = new GC (parent.sizeImage);
+			gc.setBackground(parent.getBackground());
+			gc.fillRectangle(0, 0, itemHeight, itemHeight);
+			gc.dispose();
+			tableItem.setImage(0, parent.sizeImage);
+		}
+	} else {
+		parentItem.addItem(this, index);
+	}
+}
+void addCheck() {
+	Table table = parent.getTable();
+	if ((table.getStyle() & SWT.CHECK) == 0) return;
+	tableItem.setChecked(checked);
+	tableItem.setGrayed(grayed);
+}
+void addItem(TableTreeItem item, int index) {
+	if (item == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	if (index < 0 || index > items.length) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+		
+	/* Now that item has a sub-node it must indicate that it can be expanded */
+	if (items.length == 0 && index == 0) {
+		if (tableItem != null) {
+			Image image = expanded ? parent.getMinusImage() : parent.getPlusImage();
+			tableItem.setImage(0, image);
+		}
+	}
+	
+	/* Put the item in the items list */
+	TableTreeItem[] newItems = new TableTreeItem[items.length + 1];
+	System.arraycopy(items, 0, newItems, 0, index);
+	newItems[index] = item;
+	System.arraycopy(items, index, newItems, index + 1, items.length - index);
+	items = newItems;
+	if (expanded) item.setVisible(true);
+}
+
+/**
+ * Returns the receiver's background color.
+ *
+ * @return the background color
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 2.0
+ * 
+ */
+public Color getBackground () {
+	checkWidget ();
+	return (background == null) ? parent.getBackground() : background;
+}
+
+/**
+ * Returns a rectangle describing the receiver's size and location
+ * relative to its parent.
+ *
+ * @return the receiver's bounding rectangle
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Rectangle getBounds (int index) {
+	checkWidget();
+	if (tableItem != null) {
+		return tableItem.getBounds(index);
+	} else {
+		return new Rectangle(0, 0, 0, 0);
+	}
+}
+/**
+ * Returns <code>true</code> if the receiver is checked,
+ * and false otherwise.  When the parent does not have
+ * the <code>CHECK style, return false.
+ *
+ * @return the checked state of the checkbox
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public boolean getChecked () {
+	checkWidget();
+	if (tableItem == null) return checked;
+	return tableItem.getChecked();
+}
+
+/**
+ * Returns <code>true</code> if the receiver is grayed,
+ * and false otherwise. When the parent does not have
+ * the <code>CHECK</code> style, return false.
+ *
+ * @return the grayed state of the checkbox
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 2.1
+ */
+public boolean getGrayed () {
+	checkWidget();
+	if (tableItem == null) return grayed;
+	return tableItem.getGrayed();
+}
+
+/**
+ * Returns <code>true</code> if the receiver is expanded,
+ * and false otherwise.
+ * <p>
+ *
+ * @return the expanded state
+ */
+public boolean getExpanded () {
+	//checkWidget();
+	return expanded;
+}
+
+/**
+ * Returns the font that the receiver will use to paint textual information for this item.
+ *
+ * @return the receiver's font
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 3.0
+ */
+public Font getFont () {
+	checkWidget ();
+	return (font == null) ? parent.getFont() : font;
+}
+/**
+ * Returns the foreground color that the receiver will use to draw.
+ *
+ * @return the receiver's foreground color
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 2.0
+ * 
+ */
+public Color getForeground () {
+	checkWidget ();
+	return (foreground == null) ? parent.getForeground() : foreground;
+}
+/**
+ * Gets the first image.
+ * <p>
+ * The image in column 0 is reserved for the [+] and [-]
+ * images of the tree, therefore getImage(0) will return null.
+ *
+ * @return the image at index 0
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Image getImage () {
+	checkWidget();
+	return getImage(0);
+}
+
+/**
+ * Gets the image at the specified index.
+ * <p>
+ * Indexing is zero based. The image can be null.
+ * The image in column 0 is reserved for the [+] and [-]
+ * images of the tree, therefore getImage(0) will return null.
+ * Return null if the index is out of range.
+ *
+ * @param index the index of the image
+ * @return the image at the specified index or null
+ */
+public Image getImage (int index) {
+	//checkWidget();
+	if (0 < index && index < images.length) return images[index];
+	return null;
+}
+
+int getIndent() {
+	if (parentItem == null) return 0;
+	return parentItem.getIndent() + 1;
+}
+
+/**
+ * Returns the item at the given, zero-relative index in the
+ * receiver. Throws an exception if the index is out of range.
+ *
+ * @param index the index of the item to return
+ * @return the item at the given index
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.1
+ */
+public TableTreeItem getItem (int index) {
+	checkWidget();
+	int count = items.length;
+	if (!(0 <= index && index < count)) SWT.error (SWT.ERROR_INVALID_RANGE);
+	return items [index];
+}
+
+/**
+ * Returns the number of items contained in the receiver
+ * that are direct item children of the receiver.
+ *
+ * @return the number of items
+ */
+public int getItemCount () {
+	//checkWidget();
+	return items.length;
+}
+
+/**
+ * Returns an array of <code>TableTreeItem</code>s which are the
+ * direct item children of the receiver.
+ * <p>
+ * Note: This is not the actual structure used by the receiver
+ * to maintain its list of items, so modifying the array will
+ * not affect the receiver. 
+ * </p>
+ *
+ * @return the receiver's items
+ */
+public TableTreeItem[] getItems () {
+	//checkWidget();
+	TableTreeItem[] newItems = new TableTreeItem[items.length];
+	System.arraycopy(items, 0, newItems, 0, items.length);
+	return newItems;
+}
+
+TableTreeItem getItem(TableItem tableItem) {
+	if (tableItem == null) return null;
+	if (this.tableItem == tableItem) return this;
+	for (int i = 0; i < items.length; i++) {
+		TableTreeItem item =  items[i].getItem(tableItem);
+	    	if (item != null) return item;
+	}
+	return null;
+}
+
+/**
+ * Returns the receiver's parent, which must be a <code>TableTree</code>.
+ *
+ * @return the receiver's parent
+ */
+public TableTree getParent () {
+	//checkWidget();
+	return parent;
+}
+
+/**
+ * Returns the receiver's parent item, which must be a
+ * <code>TableTreeItem</code> or null when the receiver is a
+ * root.
+ *
+ * @return the receiver's parent item
+ */
+public TableTreeItem getParentItem () {
+	//checkWidget();
+	return parentItem;
+}
+public String getText () {
+	checkWidget();
+	return getText(0);
+}
+
+/**
+ * Gets the item text at the specified index.
+ * <p>
+ * Indexing is zero based.
+ *
+ * This operation will fail when the index is out
+ * of range or an item could not be queried from
+ * the OS.
+ *
+ * @param index the index of the item
+ * @return the item text at the specified index, which can be null
+ */
+public String getText(int index) {
+	//checkWidget();
+	if (0 <= index && index < texts.length) return texts[index];
+	return null;
+}
+
+boolean getVisible () {
+	return tableItem != null;
+}
+
+/**
+ * Gets the index of the specified item.
+ * 
+ * <p>The widget is searched starting at 0 until an
+ * item is found that is equal to the search item.
+ * If no item is found, -1 is returned.  Indexing
+ * is zero based.  This index is relative to the parent only.
+ *
+ * @param item the search item
+ * @return the index of the item or -1 if the item is not found
+ *
+ */
+public int indexOf (TableTreeItem item) {
+	//checkWidget();	
+	for (int i = 0; i < items.length; i++) {
+		if (items[i] == item) return i;
+	}
+	return -1;
+}
+
+void expandAll(boolean notify) {
+	if (items.length == 0) return;
+	if (!expanded) {
+		setExpanded(true);
+		if (notify) {
+			Event event = new Event();
+			event.item = this;
+			parent.notifyListeners(SWT.Expand, event);
+		}
+	}
+	for (int i = 0; i < items.length; i++) {
+		items[i].expandAll(notify);
+	}
+}
+int expandedIndexOf (TableTreeItem item) {	
+	int index = 0;
+	for (int i = 0; i < items.length; i++) {
+		if (items[i] == item) return index;
+		if (items[i].expanded) index += items[i].visibleChildrenCount ();
+		index++;
+	}
+	return -1;
+}
+
+int visibleChildrenCount () {
+	int count = 0;
+	for (int i = 0; i < items.length; i++) {
+		if (items[i].getVisible ()) {
+			count += 1 + items[i].visibleChildrenCount ();
+		}
+	}
+	return count;
+}
+
+public void dispose () {
+	if (isDisposed()) return;
+	for (int i = items.length - 1; i >= 0; i--) {
+		items[i].dispose();
+	}
+	super.dispose();
+	if (!parent.inDispose) {
+		if (parentItem != null) {
+			parentItem.removeItem(this);
+		} else {
+			parent.removeItem(this);
+		}
+		if (tableItem != null) tableItem.dispose();
+	}
+	items = null;
+	parentItem = null;
+	parent = null;
+	images = null;
+	texts = null;
+	tableItem = null;
+	foreground = null;
+	background = null;
+	font = null;
+}
+
+void removeItem(TableTreeItem item) {
+	int index = 0;
+	while (index < items.length && items[index] != item) index++;
+	if (index == items.length) return;
+	TableTreeItem[] newItems = new TableTreeItem[items.length - 1];
+	System.arraycopy(items, 0, newItems, 0, index);
+	System.arraycopy(items, index + 1, newItems, index, items.length - index - 1);
+	items = newItems;
+	if (items.length == 0) {
+		if (tableItem != null) tableItem.setImage(0, null);
+	}
+}
+
+/**
+ * Sets the receiver's background color to the color specified
+ * by the argument, or to the default system color for the item
+ * if the argument is null.
+ *
+ * @param color the new color (or null)
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li> 
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 2.0
+ * 
+ */
+public void setBackground (Color color) {
+	checkWidget ();
+	if (color != null && color.isDisposed ()) {
+		SWT.error (SWT.ERROR_INVALID_ARGUMENT);
+	}
+	if (tableItem != null) {
+		tableItem.setBackground(color);
+	}
+	background = color;
+}
+
+/**
+ * Sets the checked state of the checkbox for this item.  This state change 
+ * only applies if the Table was created with the SWT.CHECK style.
+ *
+ * @param checked the new checked state of the checkbox
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setChecked (boolean checked) {
+	checkWidget();
+	Table table = parent.getTable();
+	if ((table.getStyle() & SWT.CHECK) == 0) return;
+	if (tableItem != null) {
+		tableItem.setChecked(checked);
+	}
+	this.checked = checked;
+}
+
+/**
+ * Sets the grayed state of the checkbox for this item.  This state change 
+ * only applies if the Table was created with the SWT.CHECK style.
+ *
+ * @param grayed the new grayed state of the checkbox; 
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 2.1
+ */
+public void setGrayed (boolean grayed) {
+	checkWidget();
+	Table table = parent.getTable();
+	if ((table.getStyle() & SWT.CHECK) == 0) return;
+	if (tableItem != null) {
+		tableItem.setGrayed(grayed);
+	}
+	this.grayed = grayed;
+}
+
+/**
+ * Sets the expanded state.
+ * <p>
+ * @param expanded the new expanded state.
+ *
+ * @exception SWTException <ul>
+ *		<li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+ *		<li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+ *	</ul>
+ */
+public void setExpanded (boolean expanded) {
+	checkWidget();
+	if (items.length == 0) return;
+	if (this.expanded == expanded) return;
+	this.expanded = expanded;
+	if (tableItem == null) return;
+	parent.setRedraw(false);
+	for (int i = 0; i < items.length; i++) {
+		items[i].setVisible(expanded);
+	}
+	Image image = expanded ? parent.getMinusImage() : parent.getPlusImage();
+	tableItem.setImage(0, image);
+	parent.setRedraw(true);
+}
+
+/**
+ * Sets the font that the receiver will use to paint textual information
+ * for this item to the font specified by the argument, or to the default font
+ * for that kind of control if the argument is null.
+ *
+ * @param font the new font (or null)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li> 
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.0
+ */
+public void setFont (Font font){
+	checkWidget ();
+	if (font != null && font.isDisposed ()) {
+		SWT.error (SWT.ERROR_INVALID_ARGUMENT);
+	}
+	if (tableItem != null) {
+		tableItem.setFont(font);
+	}
+	this.font = font;
+}
+/**
+ * Sets the receiver's foreground color to the color specified
+ * by the argument, or to the default system color for the item
+ * if the argument is null.
+ *
+ * @param color the new color (or null)
+ *
+ * @since 2.0
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li> 
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 2.0
+ * 
+ */
+public void setForeground (Color color) {
+	checkWidget ();
+	if (color != null && color.isDisposed ()) {
+		SWT.error (SWT.ERROR_INVALID_ARGUMENT);
+	}
+	if (tableItem != null) {
+		tableItem.setForeground(color);
+	}
+	foreground = color;
+}
+
+/**
+ * Sets the image at an index.
+ * <p>
+ * The image can be null.
+ * The image in column 0 is reserved for the [+] and [-]
+ * images of the tree, therefore do nothing if index is 0.
+ *
+ * @param image the new image or null
+ *
+ * @exception SWTException <ul>
+ *		<li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+ *		<li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+ *	</ul>
+ */
+public void setImage (int index, Image image) {
+	checkWidget();
+	int columnCount = Math.max(parent.getTable().getColumnCount(), 1);
+	if (index <= 0 || index >= columnCount) return;
+	if (images.length < columnCount) {
+		Image[] newImages = new Image[columnCount];
+		System.arraycopy(images, 0, newImages, 0, images.length);
+		images = newImages;
+	}
+	images[index] = image;
+	if (tableItem != null) tableItem.setImage(index, image);
+}
+
+/**
+ * Sets the first image.
+ * <p>
+ * The image can be null.
+ * The image in column 0 is reserved for the [+] and [-]
+ * images of the tree, therefore do nothing.
+ *
+ * @param image the new image or null
+ * 
+ * @exception SWTException <ul>
+ *		<li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+ *		<li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+ *	</ul>
+ */
+public void setImage (Image image) {
+	setImage(0, image);
+}
+
+/**
+ * Sets the widget text.
+ * <p>
+ *
+ * The widget text for an item is the label of the
+ * item or the label of the text specified by a column
+ * number.
+ *
+ * @param index the column number
+ * @param text the new text
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the text is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *		<li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+ *		<li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+ *	</ul>
+ */
+public void setText(int index, String text) {
+	checkWidget();
+	if (text == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+	int columnCount = Math.max(parent.getTable().getColumnCount(), 1);
+	if (index < 0 || index >= columnCount) return;
+	if (texts.length < columnCount) {
+		String[] newTexts = new String[columnCount];
+		System.arraycopy(texts, 0, newTexts, 0, texts.length);
+		texts = newTexts;
+	}
+	texts[index] = text;
+	if (tableItem != null) tableItem.setText(index, text);
+}
+public void setText (String string) {
+	setText(0, string);
+}
+
+void setVisible (boolean show) {
+	if (parentItem == null) return; // this is a root and can not be toggled between visible and hidden
+	if (getVisible() == show) return;
+
+	if (show) {
+		if (!parentItem.getVisible()) return; // parentItem must already be visible
+		// create underlying table item and set data in table item to stored data
+		Table table = parent.getTable();
+		int parentIndex = table.indexOf(parentItem.tableItem);
+		int index = parentItem.expandedIndexOf(this) + parentIndex + 1;
+		if (index < 0) return;
+		tableItem = new TableItem(table, getStyle(), index);
+		tableItem.setData(TableTree.ITEMID, this);
+		tableItem.setImageIndent(getIndent());
+		if (background != null) tableItem.setBackground(background);
+		if (foreground != null) tableItem.setForeground(foreground);
+		if (font != null) tableItem.setFont(font);
+		addCheck();
+
+		// restore fields to item
+		// ignore any images in the first column
+		int columnCount = Math.max(table.getColumnCount(), 1);
+		for (int i = 0; i < columnCount; i++) {
+			if (i < texts.length && texts[i] != null) setText(i, texts[i]);
+			if (i < images.length && images[i] != null) setImage(i, images[i]);
+		}
+
+		// display the children and the appropriate [+]/[-] symbol as required
+		if (items.length != 0) {
+			if (expanded) {
+				tableItem.setImage(0, parent.getMinusImage());
+				for (int i = 0, length = items.length; i < length; i++) {
+					items[i].setVisible(true);
+				}
+			} else {
+				tableItem.setImage(0, parent.getPlusImage());
+			}
+		}
+		
+	} else {
+
+		for (int i = 0, length = items.length; i < length; i++) {
+			items[i].setVisible(false);
+		}
+		// remove row from table
+		tableItem.dispose();
+		tableItem = null;
+	}
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/custom/TextChangeListener.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/custom/TextChangeListener.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/custom/TextChangeListener.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.custom;
+
+
+import org.eclipse.swt.internal.SWTEventListener;
+
+/**
+ * The StyledText widget implements this listener to receive
+ * notifications when changes to the model occur.
+ * It is not intended to be implemented by clients or by 
+ * implementors of StyledTextContent. 
+ * Clients should listen to the ModifyEvent or ExtendedModifyEvent 
+ * that is sent by the StyledText widget to receive text change 
+ * notifications.
+ * Implementors of StyledTextContent should call the textChanging
+ * and textChanged methods when text changes occur as described 
+ * below. If the entire text is replaced the textSet method 
+ * should be called instead.
+ */
+public interface TextChangeListener extends SWTEventListener {
+
+/**
+ * This method is called when the content is about to be changed.
+ * Callers also need to call the textChanged method after the 
+ * content change has been applied. The widget only updates the 
+ * screen properly when it receives both events. 
+ * 
+ * @param event the text changing event. All event fields need
+ * 	to be set by the sender.
+ * @see TextChangingEvent
+ */
+public void textChanging(TextChangingEvent event);
+/**
+ * This method is called when the content has changed.
+ * Callers need to have called the textChanging method prior to 
+ * applying the content change and calling this method. The widget 
+ * only updates the screen properly when it receives both events.
+ * 
+ * @param event the text changed event
+ */
+public void textChanged(TextChangedEvent event);
+/**
+ * This method is called instead of the textChanging/textChanged 
+ * combination when the entire old content has been replaced 
+ * (e.g., by a call to StyledTextContent.setText()).
+ * 
+ * @param event the text changed event
+ */
+public void textSet(TextChangedEvent event);
+}
+
+

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/custom/TextChangedEvent.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/custom/TextChangedEvent.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/custom/TextChangedEvent.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.custom;
+
+import org.eclipse.swt.events.*;
+
+/**
+ * This event is sent by the StyledTextContent implementor when a change to 
+ * the text occurs.
+ *
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public class TextChangedEvent extends TypedEvent {
+
+	static final long serialVersionUID = 3258696524257835065L;
+
+/**
+ * Create the TextChangedEvent to be used by the StyledTextContent implementor.
+ * <p>
+ *
+ * @param source the object that will be sending the TextChangedEvent, 
+ * 	cannot be null	
+ */
+public TextChangedEvent(StyledTextContent source) {
+	super(source);
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/custom/TextChangingEvent.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/custom/TextChangingEvent.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/custom/TextChangingEvent.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.custom;
+
+
+import org.eclipse.swt.events.*;
+
+/**
+ * This event is sent by the StyledTextContent implementor when a change
+ * to the text is about to occur.
+ *
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public class TextChangingEvent extends TypedEvent {
+	/**
+	 * Start offset of the text that is going to be replaced
+	 */
+	public int start;
+	/**
+	 * Text that is going to be inserted or empty string
+	 * if no text will be inserted
+	 */
+	public String newText;
+	/**
+	 * Length of text that is going to be replaced
+	 */
+	public int replaceCharCount;
+	/**
+	 * Length of text that is going to be inserted
+	 */
+	public int newCharCount;
+	/**
+	 * Number of lines that are going to be replaced
+	 */
+	public int replaceLineCount;
+	/**
+	 * Number of new lines that are going to be inserted
+	 */
+	public int newLineCount;
+
+	static final long serialVersionUID = 3257290210114352439L;
+	
+/**
+ * Create the TextChangedEvent to be used by the StyledTextContent implementor.
+ * <p>
+ *
+ * @param source the object that will be sending the new TextChangingEvent, 
+ * 	cannot be null	
+ */
+public TextChangingEvent(StyledTextContent source) {
+	super(source);
+}
+TextChangingEvent(StyledTextContent source, StyledTextEvent e) {
+	super(source);
+	start = e.start;
+	replaceCharCount = e.replaceCharCount;
+	newCharCount = e.newCharCount;
+	replaceLineCount = e.replaceLineCount;
+	newLineCount = e.newLineCount;
+	newText = e.text;
+}
+
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/custom/TreeEditor.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/custom/TreeEditor.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/custom/TreeEditor.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,319 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.custom;
+
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+
+/**
+*
+* A TreeEditor is a manager for a Control that appears above a cell in a Tree and tracks with the
+* moving and resizing of that cell.  It can be used to display a text widget above a cell
+* in a Tree so that the user can edit the contents of that cell.  It can also be used to display
+* a button that can launch a dialog for modifying the contents of the associated cell.
+*
+* <p> Here is an example of using a TreeEditor:
+* <code><pre>
+*	final Tree tree = new Tree(shell, SWT.BORDER);
+*	for (int i = 0; i &lt; 3; i++) {
+*		TreeItem item = new TreeItem(tree, SWT.NONE);
+*		item.setText("item " + i);
+*		for (int j = 0; j &lt; 3; j++) {
+*			TreeItem subItem = new TreeItem(item, SWT.NONE);
+*			subItem.setText("item " + i + " " + j);
+*		}
+*	}
+*	
+*	final TreeEditor editor = new TreeEditor(tree);
+*	//The editor must have the same size as the cell and must
+*	//not be any smaller than 50 pixels.
+*	editor.horizontalAlignment = SWT.LEFT;
+*	editor.grabHorizontal = true;
+*	editor.minimumWidth = 50;
+*	
+*	tree.addSelectionListener(new SelectionAdapter() {
+*		public void widgetSelected(SelectionEvent e) {
+*			// Clean up any previous editor control
+*			Control oldEditor = editor.getEditor();
+*			if (oldEditor != null) oldEditor.dispose();
+*	
+*			// Identify the selected row
+*			TreeItem item = (TreeItem)e.item;
+*			if (item == null) return;
+*	
+*			// The control that will be the editor must be a child of the Tree
+*			Text newEditor = new Text(tree, SWT.NONE);
+*			newEditor.setText(item.getText());
+*			newEditor.addModifyListener(new ModifyListener() {
+*				public void modifyText(ModifyEvent e) {
+*					Text text = (Text)editor.getEditor();
+*					editor.getItem().setText(text.getText());
+*				}
+*			});
+*			newEditor.selectAll();
+*			newEditor.setFocus();
+*			editor.setEditor(newEditor, item);
+*		}
+*	});
+* </pre></code>
+*
+* @see <a href="http://www.eclipse.org/swt/snippets/#treeeditor">TreeEditor snippets</a>
+* @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+*/
+public class TreeEditor extends ControlEditor {	
+	Tree tree;
+	TreeItem item;
+	int column = 0;
+	ControlListener columnListener;
+	TreeListener treeListener;
+	Runnable timer;
+	static final int TIMEOUT = 1500;
+	
+/**
+* Creates a TreeEditor for the specified Tree.
+*
+* @param tree the Tree Control above which this editor will be displayed
+*
+*/
+public TreeEditor (Tree tree) {
+	super(tree);
+	this.tree = tree;
+
+	columnListener = new ControlListener() {
+		public void controlMoved(ControlEvent e){
+			layout();
+		}
+		public void controlResized(ControlEvent e){
+			layout();
+		}
+	};
+	timer = new Runnable () {
+		public void run() {
+			layout ();
+		}
+	};
+	treeListener = new TreeListener () {
+		final Runnable runnable = new Runnable() {
+			public void run() {
+				if (editor == null || editor.isDisposed()) return;
+				if (TreeEditor.this.tree.isDisposed()) return;
+				layout();
+				editor.setVisible(true);
+			}
+		};
+		public void treeCollapsed(TreeEvent e) {
+			if (editor == null || editor.isDisposed ()) return;
+			editor.setVisible(false);
+			e.display.asyncExec(runnable);
+		}
+		public void treeExpanded(TreeEvent e) {
+			if (editor == null || editor.isDisposed ()) return;
+			editor.setVisible(false);
+			e.display.asyncExec(runnable);
+		}
+	};
+	tree.addTreeListener(treeListener);
+	
+	// To be consistent with older versions of SWT, grabVertical defaults to true
+	grabVertical = true;
+}
+
+Rectangle computeBounds () {
+	if (item == null || column == -1 || item.isDisposed()) return new Rectangle(0, 0, 0, 0);
+	Rectangle cell = item.getBounds(column);
+	Rectangle rect = item.getImageBounds(column);
+	cell.x = rect.x + rect.width;
+	cell.width -= rect.width;
+	Rectangle area = tree.getClientArea();
+	if (cell.x < area.x + area.width) {
+		if (cell.x + cell.width > area.x + area.width) {
+			cell.width = area.x + area.width - cell.x;
+		}
+	}
+	Rectangle editorRect = new Rectangle(cell.x, cell.y, minimumWidth, minimumHeight);
+
+	if (grabHorizontal) {
+		if (tree.getColumnCount() == 0) {
+			// Bounds of tree item only include the text area - stretch out to include 
+			// entire client area
+			cell.width = area.x + area.width - cell.x;
+		}
+		editorRect.width = Math.max(cell.width, minimumWidth);
+	}
+	
+	if (grabVertical) {
+		editorRect.height = Math.max(cell.height, minimumHeight);
+	}
+	
+	if (horizontalAlignment == SWT.RIGHT) {
+		editorRect.x += cell.width - editorRect.width;
+	} else if (horizontalAlignment == SWT.LEFT) {
+		// do nothing - cell.x is the right answer
+	} else { // default is CENTER
+		editorRect.x += (cell.width - editorRect.width)/2;
+	}
+	// don't let the editor overlap with the +/- of the tree
+	editorRect.x = Math.max(cell.x, editorRect.x);
+	
+	if (verticalAlignment == SWT.BOTTOM) {
+		editorRect.y += cell.height - editorRect.height;
+	} else if (verticalAlignment == SWT.TOP) {
+		// do nothing - cell.y is the right answer
+	} else { // default is CENTER
+		editorRect.y += (cell.height - editorRect.height)/2;
+	}
+	return editorRect;
+}
+
+/**
+ * Removes all associations between the TreeEditor and the row in the tree.  The
+ * tree and the editor Control are <b>not</b> disposed.
+ */
+public void dispose () {
+	if (tree != null && !tree.isDisposed()) {
+		if (this.column > -1 && this.column < tree.getColumnCount()){
+			TreeColumn treeColumn = tree.getColumn(this.column);
+			treeColumn.removeControlListener(columnListener);
+		}
+		if (treeListener != null) tree.removeTreeListener(treeListener);
+	}
+	columnListener = null;
+	treeListener = null;
+	tree = null;
+	item = null;
+	column = 0;
+	timer = null;
+	super.dispose();
+}
+
+/**
+* Returns the zero based index of the column of the cell being tracked by this editor.
+*
+* @return the zero based index of the column of the cell being tracked by this editor
+*
+* @since 3.1
+*/
+public int getColumn () {
+	return column;
+}
+
+/**
+* Returns the TreeItem for the row of the cell being tracked by this editor.
+*
+* @return the TreeItem for the row of the cell being tracked by this editor
+*/
+public TreeItem getItem () {
+	return item;
+}
+
+void resize () {
+	layout();
+	/*
+	 * On some platforms, the table scrolls when an item that
+	 * is partially visible at the bottom of the table is
+	 * selected.  Ensure that the correct row is edited by
+	 * laying out one more time in a timerExec().
+	 */
+	if (tree != null) {
+		Display display = tree.getDisplay();
+		display.timerExec(-1, timer);
+		display.timerExec(TIMEOUT, timer);
+	}
+}
+
+/**
+* Sets the zero based index of the column of the cell being tracked by this editor.
+* 
+* @param column the zero based index of the column of the cell being tracked by this editor
+*
+* @since 3.1
+*/
+public void setColumn(int column) {
+	int columnCount = tree.getColumnCount();
+	// Separately handle the case where the tree has no TreeColumns.
+	// In this situation, there is a single default column.
+	if (columnCount == 0) {
+		this.column = (column == 0) ? 0 : -1;
+		resize();
+		return;
+	}
+	if (this.column > -1 && this.column < columnCount){
+		TreeColumn treeColumn = tree.getColumn(this.column);
+		treeColumn.removeControlListener(columnListener);
+		this.column = -1;
+	}
+
+	if (column < 0  || column >= tree.getColumnCount()) return;	
+		
+	this.column = column;
+	TreeColumn treeColumn = tree.getColumn(this.column);
+	treeColumn.addControlListener(columnListener);
+	resize();
+}
+
+/**
+* Specifies the <code>TreeItem</code> that is to be edited.
+*
+* @param item the item to be edited
+*/
+public void setItem (TreeItem item) {
+	this.item = item;
+	resize();
+}
+
+/**
+* Specify the Control that is to be displayed and the cell in the tree that it is to be positioned above.
+*
+* <p>Note: The Control provided as the editor <b>must</b> be created with its parent being the Tree control
+* specified in the TreeEditor constructor.
+* 
+* @param editor the Control that is displayed above the cell being edited
+* @param item the TreeItem for the row of the cell being tracked by this editor
+* @param column the zero based index of the column of the cell being tracked by this editor
+*
+* @since 3.1
+*/
+public void setEditor (Control editor, TreeItem item, int column) {
+	setItem(item);
+	setColumn(column);
+	setEditor(editor);
+}
+public void setEditor (Control editor) {
+	super.setEditor(editor);
+	resize();
+}
+
+/**
+* Specify the Control that is to be displayed and the cell in the tree that it is to be positioned above.
+*
+* <p>Note: The Control provided as the editor <b>must</b> be created with its parent being the Tree control
+* specified in the TreeEditor constructor.
+* 
+* @param editor the Control that is displayed above the cell being edited
+* @param item the TreeItem for the row of the cell being tracked by this editor
+*/
+public void setEditor (Control editor, TreeItem item) {
+	setItem(item);
+	setEditor(editor);
+}
+
+public void layout () {
+	if (tree == null || tree.isDisposed()) return;
+	if (item == null || item.isDisposed()) return;	
+	int columnCount = tree.getColumnCount();
+	if (columnCount == 0 && column != 0) return;
+	if (columnCount > 0 && (column < 0 || column >= columnCount)) return;
+	super.layout();
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/custom/VerifyKeyListener.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/custom/VerifyKeyListener.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/custom/VerifyKeyListener.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.custom;
+
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.internal.SWTEventListener;
+
+/**
+ * Classes which implement this interface provide a method
+ * that deals with the event that is generated when a
+ * key is pressed.
+ *
+ * @see VerifyEvent
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public interface VerifyKeyListener extends SWTEventListener {
+/**
+ * The following event fields are used:<ul>
+ * <li>event.character is the character that was typed (input)</li>
+ * <li>event.keyCode is the key code that was typed (input)</li>
+ * <li>event.stateMask is the state of the keyboard (input)</li>
+ * <li>event.doit is processed or not (output)</li>
+ * </ul>
+ * @param event the verify event
+ * @see VerifyEvent
+ */
+public void verifyKey (VerifyEvent event);
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/custom/ViewForm.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/custom/ViewForm.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/custom/ViewForm.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,470 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.custom;
+
+
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.*;
+
+/**
+ * Instances of this class implement a Composite that positions and sizes
+ * children and allows programmatic control of layout and border parameters. 
+ * ViewForm is used in the workbench to lay out a view's label/menu/toolbar
+ * local bar.
+ * <p>
+ * Note that although this class is a subclass of <code>Composite</code>,
+ * it does not make sense to set a layout on it.
+ * </p><p>
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>BORDER, FLAT</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>(None)</dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ *
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+
+public class ViewForm extends Composite {
+
+	/**
+	 * marginWidth specifies the number of pixels of horizontal margin
+	 * that will be placed along the left and right edges of the form.
+	 *
+	 * The default value is 0.
+	 */
+ 	public int marginWidth = 0;
+	/**
+	 * marginHeight specifies the number of pixels of vertical margin
+	 * that will be placed along the top and bottom edges of the form.
+	 *
+	 * The default value is 0.
+	 */
+ 	public int marginHeight = 0;
+ 	/**
+	 * horizontalSpacing specifies the number of pixels between the right
+	 * edge of one cell and the left edge of its neighbouring cell to
+	 * the right.
+	 *
+	 * The default value is 1.
+	 */
+ 	public int horizontalSpacing = 1;
+	/**
+	 * verticalSpacing specifies the number of pixels between the bottom
+	 * edge of one cell and the top edge of its neighbouring cell underneath.
+	 *
+	 * The default value is 1.
+	 */
+ 	public int verticalSpacing = 1;
+	
+	/**
+	 * Color of innermost line of drop shadow border.
+	 * 
+	 * NOTE This field is badly named and can not be fixed for backwards compatibility.
+	 * It should be capitalized.
+	 * 
+	 * @deprecated
+	 */
+	public static RGB borderInsideRGB  = new RGB (132, 130, 132);
+	/**
+	 * Color of middle line of drop shadow border.
+	 * 
+	 * NOTE This field is badly named and can not be fixed for backwards compatibility.
+	 * It should be capitalized.
+	 * 
+	 * @deprecated
+	 */
+	public static RGB borderMiddleRGB  = new RGB (143, 141, 138);
+	/**
+	 * Color of outermost line of drop shadow border.
+	 * 
+	 * NOTE This field is badly named and can not be fixed for backwards compatibility.
+	 * It should be capitalized.
+	 * 
+	 * @deprecated
+	 */
+	public static RGB borderOutsideRGB = new RGB (171, 168, 165);
+	
+	// SWT widgets
+	Control topLeft;
+	Control topCenter;
+	Control topRight;
+	Control content;
+	
+	// Configuration and state info
+	boolean separateTopCenter = false;
+	boolean showBorder = false;
+	
+	int separator = -1;
+	int borderTop = 0;
+	int borderBottom = 0;
+	int borderLeft = 0;
+	int borderRight = 0;
+	int highlight = 0;
+	Point oldSize;
+	
+	Color selectionBackground;
+	
+	static final int OFFSCREEN = -200;
+	static final int BORDER1_COLOR = SWT.COLOR_WIDGET_NORMAL_SHADOW;
+	static final int SELECTION_BACKGROUND = SWT.COLOR_LIST_BACKGROUND;
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a widget which will be the parent of the new instance (cannot be null)
+ * @param style the style of widget to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * </ul>
+ *
+ * @see SWT#BORDER
+ * @see SWT#FLAT
+ * @see #getStyle()
+ */		
+public ViewForm(Composite parent, int style) {
+	super(parent, checkStyle(style));
+	super.setLayout(new ViewFormLayout());
+	
+	setBorderVisible((style & SWT.BORDER) != 0);
+	
+	Listener listener = new Listener() {
+		public void handleEvent(Event e) {
+			switch (e.type) {
+				case SWT.Dispose: onDispose(); break;
+				case SWT.Paint: onPaint(e.gc); break;
+				case SWT.Resize: onResize(); break;
+			}
+		}
+	};
+	
+	int[] events = new int[] {SWT.Dispose, SWT.Paint, SWT.Resize};
+	
+	for (int i = 0; i < events.length; i++) {
+		addListener(events[i], listener);
+	}
+}
+
+static int checkStyle (int style) {
+	int mask = SWT.FLAT | SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT;
+	return style & mask | SWT.NO_REDRAW_RESIZE;
+}
+
+//protected void checkSubclass () {
+//	String name = getClass().getName ();
+//	String validName = ViewForm.class.getName();
+//	if (!validName.equals(name)) {
+//		SWT.error (SWT.ERROR_INVALID_SUBCLASS);
+//	}
+//}
+
+public Rectangle computeTrim (int x, int y, int width, int height) {
+	checkWidget ();
+	int trimX = x - borderLeft - highlight;
+	int trimY = y - borderTop - highlight;
+	int trimWidth = width + borderLeft + borderRight + 2*highlight;
+	int trimHeight = height + borderTop + borderBottom + 2*highlight;
+	return new Rectangle(trimX, trimY, trimWidth, trimHeight);
+}
+public Rectangle getClientArea() {
+	checkWidget();
+	Rectangle clientArea = super.getClientArea();
+	clientArea.x += borderLeft;
+	clientArea.y += borderTop;
+	clientArea.width -= borderLeft + borderRight;
+	clientArea.height -= borderTop + borderBottom;
+	return clientArea;
+}
+/**
+* Returns the content area.
+* 
+* @return the control in the content area of the pane or null
+*/
+public Control getContent() {
+	//checkWidget();
+	return content;
+}
+/**
+* Returns Control that appears in the top center of the pane.
+* Typically this is a toolbar.
+* 
+* @return the control in the top center of the pane or null
+*/
+public Control getTopCenter() {
+	//checkWidget();
+	return topCenter;
+}
+/**
+* Returns the Control that appears in the top left corner of the pane.
+* Typically this is a label such as CLabel.
+* 
+* @return the control in the top left corner of the pane or null
+*/
+public Control getTopLeft() {
+	//checkWidget();
+	return topLeft;
+}
+/**
+* Returns the control in the top right corner of the pane.
+* Typically this is a Close button or a composite with a Menu and Close button.
+* 
+* @return the control in the top right corner of the pane or null
+*/
+public Control getTopRight() {
+	//checkWidget();
+	return topRight;
+}
+void onDispose() {
+	topLeft = null;
+	topCenter = null;
+	topRight = null;
+	content = null;
+	oldSize = null;
+	selectionBackground = null;
+}
+void onPaint(GC gc) {
+	Color gcForeground = gc.getForeground();
+	Point size = getSize();
+	Color border = getDisplay().getSystemColor(BORDER1_COLOR);
+	if (showBorder) {
+		gc.setForeground(border);
+		gc.drawRectangle(0, 0, size.x - 1, size.y - 1);
+		if (highlight > 0) {
+			int x1 = 1;
+			int y1 = 1;
+			int x2 = size.x - 1;
+			int y2 = size.y - 1;
+			int[] shape = new int[] {x1,y1, x2,y1, x2,y2, x1,y2, x1,y1+highlight,
+					           x1+highlight,y1+highlight, x1+highlight,y2-highlight, 
+							   x2-highlight,y2-highlight, x2-highlight,y1+highlight, x1,y1+highlight};
+			Color highlightColor = getDisplay().getSystemColor(SWT.COLOR_LIST_SELECTION);
+			gc.setBackground(highlightColor);
+			gc.fillPolygon(shape);
+		}
+	}
+	if (separator > -1) {
+		gc.setForeground(border);
+		gc.drawLine(borderLeft + highlight, separator, size.x - borderLeft - borderRight - highlight, separator);
+	}
+	gc.setForeground(gcForeground);
+}
+void onResize() {
+	Point size = getSize();
+	if (oldSize == null || oldSize.x == 0 || oldSize.y == 0) {
+		redraw();
+	} else {
+		int width = 0;
+		if (oldSize.x < size.x) {
+			width = size.x - oldSize.x + borderRight + highlight;
+		} else if (oldSize.x > size.x) {
+			width = borderRight + highlight;			
+		}
+		redraw(size.x - width, 0, width, size.y, false);
+		
+		int height = 0;
+		if (oldSize.y < size.y) {
+			height = size.y - oldSize.y + borderBottom + highlight;		
+		}
+		if (oldSize.y > size.y) {
+			height = borderBottom + highlight;		
+		}
+		redraw(0, size.y - height, size.x, height, false);
+	}
+	oldSize = size;
+}
+/**
+* Sets the content.
+* Setting the content to null will remove it from 
+* the pane - however, the creator of the content must dispose of the content.
+* 
+* @param content the control to be displayed in the content area or null
+* 
+* @exception SWTException <ul>
+*    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+*    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+*    <li>ERROR_INVALID_ARGUMENT - if the control is not a child of this ViewForm</li>
+* </ul>
+*/
+public void setContent(Control content) {
+	checkWidget();
+	if (content != null && content.getParent() != this) {
+		SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	}
+	if (this.content != null && !this.content.isDisposed()) {
+		this.content.setBounds(OFFSCREEN, OFFSCREEN, 0, 0);
+	}
+	this.content = content;
+	layout(false);
+}
+/**
+ * Sets the layout which is associated with the receiver to be
+ * the argument which may be null.
+ * <p>
+ * Note: No Layout can be set on this Control because it already
+ * manages the size and position of its children.
+ * </p>
+ *
+ * @param layout the receiver's new layout or null
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setLayout (Layout layout) {
+	checkWidget();
+	return;
+}
+void setSelectionBackground (Color color) {
+	checkWidget();
+	if (selectionBackground == color) return;
+	if (color == null) color = getDisplay().getSystemColor(SELECTION_BACKGROUND);
+	selectionBackground = color;
+	redraw();
+}
+/**
+* Set the control that appears in the top center of the pane.
+* Typically this is a toolbar.
+* The topCenter is optional.  Setting the topCenter to null will remove it from 
+* the pane - however, the creator of the topCenter must dispose of the topCenter.
+* 
+* @param topCenter the control to be displayed in the top center or null
+* 
+* @exception SWTException <ul>
+*    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+*    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+*    <li>ERROR_INVALID_ARGUMENT - if the control is not a child of this ViewForm</li>
+* </ul>
+*/
+public void setTopCenter(Control topCenter) {
+	checkWidget();
+	if (topCenter != null && topCenter.getParent() != this) {
+		SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	}
+	if (this.topCenter != null && !this.topCenter.isDisposed()) {
+		Point size = this.topCenter.getSize();
+		this.topCenter.setLocation(OFFSCREEN - size.x, OFFSCREEN - size.y);
+	}
+	this.topCenter = topCenter;
+	layout(false);
+}
+/**
+* Set the control that appears in the top left corner of the pane.
+* Typically this is a label such as CLabel.
+* The topLeft is optional.  Setting the top left control to null will remove it from 
+* the pane - however, the creator of the control must dispose of the control.
+* 
+* @param c the control to be displayed in the top left corner or null
+* 
+* @exception SWTException <ul>
+*    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+*    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+*    <li>ERROR_INVALID_ARGUMENT - if the control is not a child of this ViewForm</li>
+* </ul>
+*/
+public void setTopLeft(Control c) {
+	checkWidget();
+	if (c != null && c.getParent() != this) {
+		SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	}
+	if (this.topLeft != null && !this.topLeft.isDisposed()) {
+		Point size = this.topLeft.getSize();
+		this.topLeft.setLocation(OFFSCREEN - size.x, OFFSCREEN - size.y);
+	}
+	this.topLeft = c;
+	layout(false);
+}
+/**
+* Set the control that appears in the top right corner of the pane.
+* Typically this is a Close button or a composite with a Menu and Close button.
+* The topRight is optional.  Setting the top right control to null will remove it from 
+* the pane - however, the creator of the control must dispose of the control.
+* 
+* @param c the control to be displayed in the top right corner or null
+* 
+* @exception SWTException <ul>
+*    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+*    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+*    <li>ERROR_INVALID_ARGUMENT - if the control is not a child of this ViewForm</li>
+* </ul>
+*/
+public void setTopRight(Control c) {
+	checkWidget();
+	if (c != null && c.getParent() != this) {
+		SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	}
+	if (this.topRight != null && !this.topRight.isDisposed()) {
+		Point size = this.topRight.getSize();
+		this.topRight.setLocation(OFFSCREEN - size.x, OFFSCREEN - size.y);
+	}
+	this.topRight = c;
+	layout(false);
+}
+/**
+* Specify whether the border should be displayed or not.
+* 
+* @param show true if the border should be displayed
+* 
+* @exception SWTException <ul>
+*    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+*    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+* </ul>
+*/
+public void setBorderVisible(boolean show) {
+	checkWidget();
+	if (showBorder == show) return;
+	
+	showBorder = show;
+	if (showBorder) {
+		borderLeft = borderTop = borderRight = borderBottom = 1;
+		if ((getStyle() & SWT.FLAT)== 0) highlight = 2;
+	} else {
+		borderBottom = borderTop = borderLeft = borderRight = 0;
+		highlight = 0;
+	}
+	layout(false);
+	redraw();
+}
+/**
+* If true, the topCenter will always appear on a separate line by itself, otherwise the 
+* topCenter will appear in the top row if there is room and will be moved to the second row if
+* required.
+* 
+* @param show true if the topCenter will always appear on a separate line by itself
+* 
+* @exception SWTException <ul>
+*    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+*    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+* </ul>
+*/
+public void setTopCenterSeparate(boolean show) {
+	checkWidget();
+	separateTopCenter = show;
+	layout(false);
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/custom/ViewFormLayout.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/custom/ViewFormLayout.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/custom/ViewFormLayout.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,202 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.custom;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+
+/**
+ * This class provides the layout for ViewForm
+ * 
+ * @see ViewForm
+ */
+class ViewFormLayout extends Layout {
+
+protected Point computeSize(Composite composite, int wHint, int hHint, boolean flushCache) {
+	ViewForm form = (ViewForm)composite;
+	Control left = form.topLeft;
+	Control center = form.topCenter;
+	Control right = form.topRight;
+	Control content = form.content;
+	
+	Point leftSize = new Point(0, 0);
+	if (left != null) {
+		leftSize = computeChildSize(left, SWT.DEFAULT, SWT.DEFAULT, flushCache);
+	}
+	Point centerSize = new Point(0, 0);
+	if (center != null) {
+		 centerSize = computeChildSize(center, SWT.DEFAULT, SWT.DEFAULT, flushCache);
+	}
+	Point rightSize = new Point(0, 0);
+	if (right != null) {
+		 rightSize = computeChildSize(right, SWT.DEFAULT, SWT.DEFAULT, flushCache);
+	}
+	Point size = new Point(0, 0);
+	// calculate width of title bar
+	if (form.separateTopCenter ||
+	    (wHint != SWT.DEFAULT &&  leftSize.x + centerSize.x + rightSize.x > wHint)) {
+		size.x = leftSize.x + rightSize.x;
+		if (leftSize.x > 0 && rightSize.x > 0) size.x += form.horizontalSpacing;
+		size.x = Math.max(centerSize.x, size.x);
+		size.y = Math.max(leftSize.y, rightSize.y);
+		if (center != null){
+			size.y += centerSize.y;
+			if (left != null ||right != null)size.y += form.verticalSpacing;
+		}	
+	} else {
+		size.x = leftSize.x + centerSize.x + rightSize.x;
+		int count = -1;
+		if (leftSize.x > 0) count++;
+		if (centerSize.x > 0) count++;
+		if (rightSize.x > 0) count++;
+		if (count > 0) size.x += count * form.horizontalSpacing;
+		size.y = Math.max(leftSize.y, Math.max(centerSize.y, rightSize.y));
+	}
+	
+	if (content != null) {
+		if (left != null || right != null || center != null) size.y += 1; // allow space for a vertical separator
+		Point contentSize = new Point(0, 0);
+		contentSize = computeChildSize(content, SWT.DEFAULT, SWT.DEFAULT, flushCache); 
+		size.x = Math.max (size.x, contentSize.x);
+		size.y += contentSize.y;
+		if (size.y > contentSize.y) size.y += form.verticalSpacing;
+	}
+	
+	size.x += 2*form.marginWidth;
+	size.y += 2*form.marginHeight;
+	
+	if (wHint != SWT.DEFAULT) size.x  = wHint;
+	if (hHint != SWT.DEFAULT) size.y = hHint;
+	
+	return size;
+}
+
+Point computeChildSize(Control control, int wHint, int hHint, boolean flushCache) {
+	Object data = control.getLayoutData();
+	if (data == null || !(data instanceof CLayoutData)) {
+		data = new CLayoutData();
+		control.setLayoutData(data);
+	}
+	return ((CLayoutData)data).computeSize(control, wHint, hHint, flushCache);
+}
+
+int computeTrim(Control c) {
+	if (c instanceof Scrollable) {
+		Rectangle rect = ((Scrollable) c).computeTrim (0, 0, 0, 0);
+		return rect.width;
+	}
+	return c.getBorderWidth () * 2;
+}
+
+protected boolean flushCache(Control control) {
+	Object data = control.getLayoutData();
+	if (data != null && data instanceof CLayoutData) ((CLayoutData)data).flushCache();
+	return true;
+}
+
+protected void layout(Composite composite, boolean flushCache) {
+	ViewForm form = (ViewForm)composite;
+	Control left = form.topLeft;
+	Control center = form.topCenter;
+	Control right = form.topRight;
+	Control content = form.content;
+	
+	Rectangle rect = composite.getClientArea();
+	
+	Point leftSize = new Point(0, 0);
+	if (left != null && !left.isDisposed()) {
+		leftSize = computeChildSize(left, SWT.DEFAULT, SWT.DEFAULT, flushCache);
+	}
+	Point centerSize = new Point(0, 0);
+	if (center != null && !center.isDisposed()) {
+		 centerSize = computeChildSize(center, SWT.DEFAULT, SWT.DEFAULT, flushCache);
+	}
+	Point rightSize = new Point(0, 0);
+	if (right != null && !right.isDisposed()) {
+		 rightSize = computeChildSize(right, SWT.DEFAULT, SWT.DEFAULT, flushCache);
+	}
+	
+	int minTopWidth = leftSize.x + centerSize.x + rightSize.x + 2*form.marginWidth + 2*form.highlight;
+	int count = -1;
+	if (leftSize.x > 0) count++;
+	if (centerSize.x > 0) count++;
+	if (rightSize.x > 0) count++;
+	if (count > 0) minTopWidth += count * form.horizontalSpacing;
+		
+	int x = rect.x + rect.width - form.marginWidth - form.highlight;
+	int y = rect.y + form.marginHeight + form.highlight;
+	
+	boolean top = false;
+	if (form.separateTopCenter || minTopWidth > rect.width) {
+		int topHeight = Math.max(rightSize.y, leftSize.y);
+		if (right != null && !right.isDisposed()) {
+			top = true;
+			x -= rightSize.x;
+			right.setBounds(x, y, rightSize.x, topHeight);
+			x -= form.horizontalSpacing;
+		}
+		if (left != null && !left.isDisposed()) {
+			top = true;
+			int trim = computeTrim(left);
+			int leftW = x - rect.x - form.marginWidth - form.highlight - trim;
+			leftSize = computeChildSize(left, leftW, SWT.DEFAULT, false);
+			left.setBounds(rect.x + form.marginWidth + form.highlight, y, leftSize.x, topHeight);
+		}
+		if (top) y += topHeight + form.verticalSpacing;
+		if (center != null && !center.isDisposed()) {
+			top = true;
+			int trim = computeTrim(center);
+			int w = rect.width - 2*form.marginWidth - 2*form.highlight - trim;
+			centerSize = computeChildSize(center, w, SWT.DEFAULT, false);
+			center.setBounds(rect.x + rect.width - form.marginWidth - form.highlight - centerSize.x, y, centerSize.x, centerSize.y);
+			y += centerSize.y + form.verticalSpacing;
+		}		
+	} else {
+		int topHeight = Math.max(rightSize.y, Math.max(centerSize.y, leftSize.y));
+		if (right != null && !right.isDisposed()) {
+			top = true;
+			x -= rightSize.x;
+			right.setBounds(x, y, rightSize.x, topHeight);
+			x -= form.horizontalSpacing;
+		}
+		if (center != null && !center.isDisposed()) {
+			top = true;
+			x -= centerSize.x;
+			center.setBounds(x, y, centerSize.x, topHeight);
+			x -= form.horizontalSpacing;
+		}
+		if (left != null && !left.isDisposed()) {
+			top = true;
+			Rectangle trim = left instanceof Composite ? ((Composite)left).computeTrim(0, 0, 0, 0) : new Rectangle(0, 0, 0, 0);
+			int w = x - rect.x - form.marginWidth - form.highlight - trim.width;
+			int h = topHeight - trim.height;
+			leftSize = computeChildSize(left, w, h, false);
+			left.setBounds(rect.x + form.marginWidth + form.highlight, y, leftSize.x, topHeight);
+		}
+		if (top)y += topHeight + form.verticalSpacing;
+	}
+	int oldSeperator = form.separator;
+	form.separator = -1;
+	if (content != null && !content.isDisposed()) {
+		if (left != null || right!= null || center != null){
+			form.separator = y;
+			y++;
+		}
+		 content.setBounds(rect.x + form.marginWidth + form.highlight, y, rect.width - 2 * form.marginWidth - 2*form.highlight, rect.y + rect.height - y - form.marginHeight - form.highlight);
+	}
+	if (oldSeperator != -1 && form.separator != -1) {
+		int t = Math.min(form.separator, oldSeperator);
+		int b = Math.max(form.separator, oldSeperator);
+		form.redraw(form.borderLeft, t, form.getSize().x - form.borderLeft - form.borderRight, b - t, false);
+	}
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/ByteArrayTransfer.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/ByteArrayTransfer.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/ByteArrayTransfer.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,189 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.dnd;
+
+import org.eclipse.swt.internal.gtk.*;
+
+/**
+ * The class <code>ByteArrayTransfer</code> provides a platform specific 
+ * mechanism for converting a java <code>byte[]</code> to a platform 
+ * specific representation of the byte array and vice versa.
+ *
+ * <p><code>ByteArrayTransfer</code> is never used directly but is sub-classed 
+ * by transfer agents that convert between data in a java format such as a
+ * <code>String</code> and a platform specific byte array.
+ * 
+ * <p>If the data you are converting <b>does not</b> map to a 
+ * <code>byte[]</code>, you should sub-class <code>Transfer</code> directly 
+ * and do your own mapping to a platform data type.</p>
+ * 
+ * <p>The following snippet shows a subclass of ByteArrayTransfer that transfers
+ * data defined by the class <code>MyType</code>.</p>
+ * 
+ * <pre><code>
+ * public class MyType {
+ *	public String fileName;
+ *	public long fileLength;
+ *	public long lastModified;
+ * }
+ * </code></pre>
+ * 
+ * <pre><code>
+ * public class MyTypeTransfer extends ByteArrayTransfer {
+ *	
+ *	private static final String MYTYPENAME = "my_type_name";
+ *	private static final int MYTYPEID = registerType(MYTYPENAME);
+ *	private static MyTypeTransfer _instance = new MyTypeTransfer();
+ * 
+ * private MyTypeTransfer() {}
+ * 
+ * public static MyTypeTransfer getInstance () {
+ * 	return _instance;
+ * }
+ * public void javaToNative (Object object, TransferData transferData) {
+ * 	if (object == null || !(object instanceof MyType[])) return;
+ * 	
+ * 	if (isSupportedType(transferData)) {
+ * 		MyType[] myTypes = (MyType[]) object;	
+ * 		try {
+ * 			// write data to a byte array and then ask super to convert to pMedium
+ * 			ByteArrayOutputStream out = new ByteArrayOutputStream();
+ * 			DataOutputStream writeOut = new DataOutputStream(out);
+ * 			for (int i = 0, length = myTypes.length; i &lt; length;  i++){
+ * 				byte[] buffer = myTypes[i].fileName.getBytes();
+ * 				writeOut.writeInt(buffer.length);
+ * 				writeOut.write(buffer);
+ * 				writeOut.writeLong(myTypes[i].fileLength);
+ * 				writeOut.writeLong(myTypes[i].lastModified);
+ * 			}
+ * 			byte[] buffer = out.toByteArray();
+ * 			writeOut.close();
+ * 
+ * 			super.javaToNative(buffer, transferData);
+ * 			
+ * 		} catch (IOException e) {
+ * 		}
+ * 	}
+ * }
+ * public Object nativeToJava(TransferData transferData){	
+ * 
+ * 	if (isSupportedType(transferData)) {
+ * 		
+ * 		byte[] buffer = (byte[])super.nativeToJava(transferData);
+ * 		if (buffer == null) return null;
+ * 		
+ * 		MyType[] myData = new MyType[0];
+ * 		try {
+ * 			ByteArrayInputStream in = new ByteArrayInputStream(buffer);
+ * 			DataInputStream readIn = new DataInputStream(in);
+ * 			while(readIn.available() > 20) {
+ * 				MyType datum = new MyType();
+ * 				int size = readIn.readInt();
+ * 				byte[] name = new byte[size];
+ * 				readIn.read(name);
+ * 				datum.fileName = new String(name);
+ * 				datum.fileLength = readIn.readLong();
+ * 				datum.lastModified = readIn.readLong();
+ * 				MyType[] newMyData = new MyType[myData.length + 1];
+ * 				System.arraycopy(myData, 0, newMyData, 0, myData.length);
+ * 				newMyData[myData.length] = datum;
+ * 				myData = newMyData;
+ * 			}
+ * 			readIn.close();
+ * 		} catch (IOException ex) {
+ * 			return null;
+ * 		}
+ * 		return myData;
+ * 	}
+ * 
+ * 	return null;
+ * }
+ * protected String[] getTypeNames(){
+ * 	return new String[]{MYTYPENAME};
+ * }
+ * protected int[] getTypeIds(){
+ * 	return new int[] {MYTYPEID};
+ * }
+ * }
+ * </code></pre>
+ *
+ * @see Transfer
+ */
+public abstract class ByteArrayTransfer extends Transfer {
+
+public TransferData[] getSupportedTypes() {
+	int[] types = getTypeIds();
+	TransferData[] data = new TransferData[types.length];
+	for (int i = 0; i < types.length; i++) {
+		data[i] = new TransferData();
+		data[i].type = types[i];
+	}
+	return data;
+}
+
+public boolean isSupportedType(TransferData transferData){
+	if (transferData == null) return false;
+	int[] types = getTypeIds();
+	for (int i = 0; i < types.length; i++) {
+		if (transferData.type == types[i]) return true;
+	}
+	return false;
+}
+
+/**
+ * This implementation of <code>javaToNative</code> converts a java 
+ * <code>byte[]</code> to a platform specific representation.
+ * 
+ * @param object a java <code>byte[]</code> containing the data to be converted
+ * @param transferData an empty <code>TransferData</code> object that will
+ *  	be filled in on return with the platform specific format of the data
+ * 
+ * @see Transfer#nativeToJava
+ */
+protected void javaToNative (Object object, TransferData transferData) {
+	transferData.result = 0;
+	if (!checkByteArray(object) || !isSupportedType(transferData)) {
+		DND.error(DND.ERROR_INVALID_DATA);
+	}
+	byte[] buffer = (byte[])object;
+	if (buffer.length == 0) return;
+	int /*long*/ pValue = OS.g_malloc(buffer.length);
+	if (pValue == 0) return;
+	OS.memmove(pValue, buffer, buffer.length);
+	transferData.length = buffer.length;
+	transferData.format = 8;
+	transferData.pValue = pValue;
+	transferData.result = 1;
+}
+
+/**
+ * This implementation of <code>nativeToJava</code> converts a platform specific 
+ * representation of a byte array to a java <code>byte[]</code>.   
+ * 
+ * @param transferData the platform specific representation of the data to be converted
+ * @return a java <code>byte[]</code> containing the converted data if the conversion was
+ * 		successful; otherwise null
+ * 
+ * @see Transfer#javaToNative
+ */
+protected Object nativeToJava(TransferData transferData) {
+	if ( !isSupportedType(transferData) || transferData.pValue == 0) return null;
+	int size = transferData.format * transferData.length / 8;
+	if (size == 0) return null;
+	byte[] buffer = new byte[size];
+	OS.memmove(buffer, transferData.pValue, size);
+	return buffer;
+}
+
+boolean checkByteArray(Object object) {
+	return (object != null && object instanceof byte[] && ((byte[])object).length > 0);
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/Clipboard.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/Clipboard.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/Clipboard.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,621 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.dnd;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.internal.Converter;
+import org.eclipse.swt.internal.gtk.GtkSelectionData;
+import org.eclipse.swt.internal.gtk.OS;
+import org.eclipse.swt.widgets.Display;
+
+/**
+ * The <code>Clipboard</code> provides a mechanism for transferring data from one
+ * application to another or within an application.
+ * 
+ * <p>IMPORTANT: This class is <em>not</em> intended to be subclassed.</p>
+ *
+ * @see <a href="http://www.eclipse.org/swt/snippets/#clipboard">Clipboard snippets</a>
+ * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: ClipboardExample</a>
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public class Clipboard {
+
+	private Display display;
+	
+	static int /*long*/ GTKCLIPBOARD;
+	static int /*long*/ GTKPRIMARYCLIPBOARD;
+	private static int /*long*/ TARGET;
+	
+	static {
+		GTKCLIPBOARD = OS.gtk_clipboard_get(OS.GDK_NONE);
+		byte[] buffer = Converter.wcsToMbcs(null, "PRIMARY", true);
+		int /*long*/ primary = OS.gdk_atom_intern(buffer, false);
+		GTKPRIMARYCLIPBOARD = OS.gtk_clipboard_get(primary);
+		buffer = Converter.wcsToMbcs(null, "TARGETS", true);
+		TARGET = OS.gdk_atom_intern(buffer, false);
+	}
+
+/**
+ * Constructs a new instance of this class.  Creating an instance of a Clipboard
+ * may cause system resources to be allocated depending on the platform.  It is therefore
+ * mandatory that the Clipboard instance be disposed when no longer required.
+ *
+ * @param display the display on which to allocate the clipboard
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see Clipboard#dispose
+ * @see Clipboard#checkSubclass
+ */
+public Clipboard(Display display) {	
+	checkSubclass ();
+	if (display == null) {
+		display = Display.getCurrent();
+		if (display == null) {
+			display = Display.getDefault();
+		}
+	}
+	if (display.getThread() != Thread.currentThread()) {
+		DND.error(SWT.ERROR_THREAD_INVALID_ACCESS);
+	}
+	this.display = display;
+}
+
+/**
+ * Checks that this class can be subclassed.
+ * <p>
+ * The SWT class library is intended to be subclassed 
+ * only at specific, controlled points. This method enforces this
+ * rule unless it is overridden.
+ * </p><p>
+ * <em>IMPORTANT:</em> By providing an implementation of this
+ * method that allows a subclass of a class which does not 
+ * normally allow subclassing to be created, the implementer
+ * agrees to be fully responsible for the fact that any such
+ * subclass will likely fail between SWT releases and will be
+ * strongly platform specific. No support is provided for
+ * user-written classes which are implemented in this fashion.
+ * </p><p>
+ * The ability to subclass outside of the allowed SWT classes
+ * is intended purely to enable those not on the SWT development
+ * team to implement patches in order to get around specific
+ * limitations in advance of when those limitations can be
+ * addressed by the team. Subclassing should not be attempted
+ * without an intimate and detailed understanding of the hierarchy.
+ * </p>
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ */
+protected void checkSubclass () {
+	String name = getClass().getName ();
+	String validName = Clipboard.class.getName();
+	if (!validName.equals(name)) {
+		DND.error (SWT.ERROR_INVALID_SUBCLASS);
+	}
+}
+/**
+ * Throws an <code>SWTException</code> if the receiver can not
+ * be accessed by the caller. This may include both checks on
+ * the state of the receiver and more generally on the entire
+ * execution context. This method <em>should</em> be called by
+ * widget implementors to enforce the standard SWT invariants.
+ * <p>
+ * Currently, it is an error to invoke any method (other than
+ * <code>isDisposed()</code>) on a widget that has had its 
+ * <code>dispose()</code> method called. It is also an error
+ * to call widget methods from any thread that is different
+ * from the thread that created the widget.
+ * </p><p>
+ * In future releases of SWT, there may be more or fewer error
+ * checks and exceptions may be thrown for different reasons.
+ * </p>
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+protected void checkWidget () {
+	Display display = this.display;
+	if (display == null) DND.error (SWT.ERROR_WIDGET_DISPOSED);
+	if (display.getThread() != Thread.currentThread ()) DND.error (SWT.ERROR_THREAD_INVALID_ACCESS);
+	if (display.isDisposed()) DND.error(SWT.ERROR_WIDGET_DISPOSED);
+}
+
+/**
+ * If this clipboard is currently the owner of the data on the system clipboard,
+ * clear the contents.  If this clipboard is not the owner, then nothing is done.
+ * Note that there are clipboard assistant applications that take ownership of 
+ * data or make copies of data when it is placed on the clipboard.  In these 
+ * cases, it may not be possible to clear the clipboard.
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.1
+ */
+public void clearContents() {
+	clearContents(DND.CLIPBOARD);
+}
+
+/**
+ * If this clipboard is currently the owner of the data on the specified 
+ * clipboard, clear the contents.  If this clipboard is not the owner, then 
+ * nothing is done.
+ * 
+ * <p>Note that there are clipboard assistant applications that take ownership
+ * of data or make copies of data when it is placed on the clipboard.  In these 
+ * cases, it may not be possible to clear the clipboard.</p>
+ * 
+ * <p>The clipboards value is either one of the clipboard constants defined in
+ * class <code>DND</code>, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>DND</code> clipboard constants.</p>
+ * 
+ * @param clipboards to be cleared
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see DND#CLIPBOARD
+ * @see DND#SELECTION_CLIPBOARD
+ * 
+ * @since 3.1
+ */
+public void clearContents(int clipboards) {
+	checkWidget();
+	ClipboardProxy proxy = ClipboardProxy._getInstance(display);
+	proxy.clear(this, clipboards);
+}
+
+/**
+ * Disposes of the operating system resources associated with the clipboard. 
+ * The data will still be available on the system clipboard after the dispose 
+ * method is called.  
+ * 
+ * <p>NOTE: On some platforms the data will not be available once the application
+ * has exited or the display has been disposed.</p>
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * </ul>
+ */
+public void dispose () {
+	if (isDisposed()) return;
+	if (display.getThread() != Thread.currentThread()) DND.error(SWT.ERROR_THREAD_INVALID_ACCESS);
+	display = null;
+}
+
+/**
+ * Retrieve the data of the specified type currently available on the system 
+ * clipboard.  Refer to the specific subclass of <code>Transfer</code> to 
+ * determine the type of object returned.
+ * 
+ * <p>The following snippet shows text and RTF text being retrieved from the 
+ * clipboard:</p>
+ * 
+ *    <code><pre>
+ *    Clipboard clipboard = new Clipboard(display);
+ *    TextTransfer textTransfer = TextTransfer.getInstance();
+ *    String textData = (String)clipboard.getContents(textTransfer);
+ *    if (textData != null) System.out.println("Text is "+textData);
+ *    RTFTransfer rtfTransfer = RTFTransfer.getInstance();
+ *    String rtfData = (String)clipboard.getContents(rtfTransfer);
+ *    if (rtfData != null) System.out.println("RTF Text is "+rtfData);
+ *    clipboard.dispose();
+ *    </code></pre>
+ * 
+ * @param transfer the transfer agent for the type of data being requested
+ * @return the data obtained from the clipboard or null if no data of this type is available
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if transfer is null</li>
+ * </ul>
+ * 
+ * @see Transfer
+ */
+public Object getContents(Transfer transfer) {
+	return getContents(transfer, DND.CLIPBOARD);
+}
+
+/**
+ * Retrieve the data of the specified type currently available on the specified 
+ * clipboard.  Refer to the specific subclass of <code>Transfer</code> to 
+ * determine the type of object returned.
+ * 
+ * <p>The following snippet shows text and RTF text being retrieved from the 
+ * clipboard:</p>
+ * 
+ *    <code><pre>
+ *    Clipboard clipboard = new Clipboard(display);
+ *    TextTransfer textTransfer = TextTransfer.getInstance();
+ *    String textData = (String)clipboard.getContents(textTransfer);
+ *    if (textData != null) System.out.println("Text is "+textData);
+ *    RTFTransfer rtfTransfer = RTFTransfer.getInstance();
+ *    String rtfData = (String)clipboard.getContents(rtfTransfer, DND.CLIPBOARD);
+ *    if (rtfData != null) System.out.println("RTF Text is "+rtfData);
+ *    clipboard.dispose();
+ *    </code></pre>
+ * 
+ * <p>The clipboards value is either one of the clipboard constants defined in
+ * class <code>DND</code>, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>DND</code> clipboard constants.</p>
+ * 
+ * @param transfer the transfer agent for the type of data being requested
+ * @param clipboards on which to look for data
+ *  
+ * @return the data obtained from the clipboard or null if no data of this type is available
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if transfer is null</li>
+ * </ul>
+ * 
+ * @see Transfer
+ * @see DND#CLIPBOARD
+ * @see DND#SELECTION_CLIPBOARD
+ * 
+ * @since 3.1
+ */
+public Object getContents(Transfer transfer, int clipboards) {
+	checkWidget();
+	if (transfer == null) DND.error(SWT.ERROR_NULL_ARGUMENT);
+	int /*long*/ selection_data = 0;
+	int[] typeIds = transfer.getTypeIds();
+	for (int i = 0; i < typeIds.length; i++) {
+		if ((clipboards & DND.CLIPBOARD) != 0) {
+			selection_data = gtk_clipboard_wait_for_contents(GTKCLIPBOARD, typeIds[i]);
+		}
+		if (selection_data != 0) break;
+		if ((clipboards & DND.SELECTION_CLIPBOARD) != 0) {
+			selection_data = gtk_clipboard_wait_for_contents(GTKPRIMARYCLIPBOARD, typeIds[i]);
+		}
+	}
+	if (selection_data == 0) return null;
+	GtkSelectionData gtkSelectionData = new GtkSelectionData();
+	OS.memmove(gtkSelectionData, selection_data, GtkSelectionData.sizeof);
+	TransferData tdata = new TransferData();
+	tdata.type = gtkSelectionData.type;
+	tdata.pValue = gtkSelectionData.data;
+	tdata.length = gtkSelectionData.length;
+	tdata.format = gtkSelectionData.format;
+	Object result = transfer.nativeToJava(tdata);
+	OS.gtk_selection_data_free(selection_data);
+	return result;
+}
+
+/**
+ * Returns <code>true</code> if the clipboard has been disposed,
+ * and <code>false</code> otherwise.
+ * <p>
+ * This method gets the dispose state for the clipboard.
+ * When a clipboard has been disposed, it is an error to
+ * invoke any other method using the clipboard.
+ * </p>
+ *
+ * @return <code>true</code> when the widget is disposed and <code>false</code> otherwise
+ * 
+ * @since 3.0
+ */
+public boolean isDisposed () {
+	return (display == null);
+}
+
+/**
+ * Place data of the specified type on the system clipboard.  More than one type
+ * of data can be placed on the system clipboard at the same time.  Setting the
+ * data clears any previous data from the system clipboard, regardless of type.
+ * 
+ * <p>NOTE: On some platforms, the data is immediately copied to the system
+ * clipboard but on other platforms it is provided upon request.  As a result,
+ * if the application modifies the data object it has set on the clipboard, that 
+ * modification may or may not be available when the data is subsequently 
+ * requested.</p>
+ *
+ * <p>The following snippet shows text and RTF text being set on the copy/paste
+ * clipboard:
+ * </p>
+ * 
+ * <code><pre>
+ * 	Clipboard clipboard = new Clipboard(display);
+ *	String textData = "Hello World";
+ *	String rtfData = "{\\rtf1\\b\\i Hello World}";
+ *	TextTransfer textTransfer = TextTransfer.getInstance();
+ *	RTFTransfer rtfTransfer = RTFTransfer.getInstance();
+ *	Transfer[] transfers = new Transfer[]{textTransfer, rtfTransfer};
+ *	Object[] data = new Object[]{textData, rtfData};
+ *	clipboard.setContents(data, transfers);
+ *	clipboard.dispose();
+ * </code></pre>
+ *
+ * @param data the data to be set in the clipboard
+ * @param dataTypes the transfer agents that will convert the data to its 
+ * platform specific format; each entry in the data array must have a 
+ * corresponding dataType
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if data is null or datatypes is null 
+ *          or the length of data is not the same as the length of dataTypes</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *  @exception SWTError <ul>
+ *    <li>ERROR_CANNOT_SET_CLIPBOARD - if the clipboard is locked or otherwise unavailable</li>
+ * </ul>
+ * 
+ * <p>NOTE: ERROR_CANNOT_SET_CLIPBOARD should be an SWTException, since it is a
+ * recoverable error, but can not be changed due to backward compatibility.</p>
+ */
+public void setContents(Object[] data, Transfer[] dataTypes) {
+	setContents(data, dataTypes, DND.CLIPBOARD);
+}
+
+/**
+ * Place data of the specified type on the specified clipboard.  More than one 
+ * type of data can be placed on the specified clipboard at the same time.
+ * Setting the data clears any previous data from the specified
+ * clipboard, regardless of type.
+ * 
+ * <p>NOTE: On some platforms, the data is immediately copied to the specified
+ * clipboard but on other platforms it is provided upon request.  As a result, 
+ * if the application modifies the data object it has set on the clipboard, that 
+ * modification may or may not be available when the data is subsequently 
+ * requested.</p>
+ *
+ * <p>The clipboards value is either one of the clipboard constants defined in
+ * class <code>DND</code>, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>DND</code> clipboard constants.</p>
+ * 
+ * <p>The following snippet shows text and RTF text being set on the copy/paste
+ * clipboard:
+ * </p>
+ * 
+ * <code><pre>
+ * 	Clipboard clipboard = new Clipboard(display);
+ *	String textData = "Hello World";
+ *	String rtfData = "{\\rtf1\\b\\i Hello World}";
+ *	TextTransfer textTransfer = TextTransfer.getInstance();
+ *	RTFTransfer rtfTransfer = RTFTransfer.getInstance();
+ *	Transfer[] transfers = new Transfer[]{textTransfer, rtfTransfer};
+ *	Object[] data = new Object[]{textData, rtfData};
+ *	clipboard.setContents(data, transfers, DND.CLIPBOARD);
+ *	clipboard.dispose();
+ * </code></pre>
+ *
+ * @param data the data to be set in the clipboard
+ * @param dataTypes the transfer agents that will convert the data to its 
+ * platform specific format; each entry in the data array must have a 
+ * corresponding dataType
+ * @param clipboards on which to set the data
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if data is null or datatypes is null 
+ *          or the length of data is not the same as the length of dataTypes</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *  @exception SWTError <ul>
+ *    <li>ERROR_CANNOT_SET_CLIPBOARD - if the clipboard is locked or otherwise unavailable</li>
+ * </ul>
+ * 
+ * <p>NOTE: ERROR_CANNOT_SET_CLIPBOARD should be an SWTException, since it is a
+ * recoverable error, but can not be changed due to backward compatibility.</p>
+ * 
+ * @see DND#CLIPBOARD
+ * @see DND#SELECTION_CLIPBOARD
+ * 
+ * @since 3.1
+ */
+public void setContents(Object[] data, Transfer[] dataTypes, int clipboards) {
+	checkWidget();
+	if (data == null || dataTypes == null || data.length != dataTypes.length || data.length == 0) {
+		DND.error(SWT.ERROR_INVALID_ARGUMENT);
+	}
+	for (int i = 0; i < data.length; i++) {
+		if (data[i] == null || dataTypes[i] == null || !dataTypes[i].validate(data[i])) {
+			DND.error(SWT.ERROR_INVALID_ARGUMENT);
+		}
+	}
+	ClipboardProxy proxy = ClipboardProxy._getInstance(display);
+	if (!proxy.setData(this, data, dataTypes, clipboards)) {
+		DND.error(DND.ERROR_CANNOT_SET_CLIPBOARD);
+	}
+}
+
+/**
+ * Returns an array of the data types currently available on the system 
+ * clipboard. Use with Transfer.isSupportedType.
+ *
+ * @return array of data types currently available on the system clipboard
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see Transfer#isSupportedType
+ * 
+ * @since 3.0
+ */
+public TransferData[] getAvailableTypes() {
+	return getAvailableTypes(DND.CLIPBOARD);
+}
+
+/**
+ * Returns an array of the data types currently available on the specified 
+ * clipboard. Use with Transfer.isSupportedType.
+ * 
+ * <p>The clipboards value is either one of the clipboard constants defined in
+ * class <code>DND</code>, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>DND</code> clipboard constants.</p>
+ * 
+ * @param clipboards from which to get the data types
+ * @return array of data types currently available on the specified clipboard
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see Transfer#isSupportedType
+ * @see DND#CLIPBOARD
+ * @see DND#SELECTION_CLIPBOARD
+ * 
+ * @since 3.1
+ */
+public TransferData[] getAvailableTypes(int clipboards) {
+	checkWidget();
+	TransferData[] result = null;
+	if ((clipboards & DND.CLIPBOARD) != 0) {
+		int[] types = getAvailableClipboardTypes();
+		result = new TransferData[types.length];
+		for (int i = 0; i < types.length; i++) {
+			result[i] = new TransferData();
+			result[i].type = types[i];
+		}
+	}
+	if ((clipboards & DND.SELECTION_CLIPBOARD) != 0) {
+		int[] types = getAvailablePrimaryTypes();
+		int offset = 0;
+		if (result != null) {
+			TransferData[] newResult = new TransferData[result.length + types.length];
+			System.arraycopy(result,0, newResult, 0, result.length);
+			offset = result.length;
+			result = newResult;
+		} else {
+			result = new TransferData[types.length];
+		}
+		for (int i = 0; i < types.length; i++) {
+			result[offset+i] = new TransferData();
+			result[offset+i].type = types[i];
+		}
+	}
+	return result == null ? new TransferData[0] : result;
+}
+
+/**
+ * Returns a platform specific list of the data types currently available on the 
+ * system clipboard.
+ * 
+ * <p>Note: <code>getAvailableTypeNames</code> is a utility for writing a Transfer 
+ * sub-class.  It should NOT be used within an application because it provides 
+ * platform specific information.</p>
+ * 
+ * @return a platform specific list of the data types currently available on the 
+ * system clipboard
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public String[] getAvailableTypeNames() {
+	checkWidget();
+	int[] types1 = getAvailableClipboardTypes();
+	int[] types2 = getAvailablePrimaryTypes();
+	String[] result = new String[types1.length + types2.length];
+	int count = 0;
+	for (int i = 0; i < types1.length; i++) {
+		int /*long*/ pName = OS.gdk_atom_name(types1[i]);
+		if (pName == 0) {
+			continue;
+		}
+		byte[] buffer = new byte [OS.strlen(pName)];
+		OS.memmove (buffer, pName, buffer.length);
+		OS.g_free (pName);
+		result[count++] = "GTKCLIPBOARD "+new String (Converter.mbcsToWcs (null, buffer));
+	}
+	for (int i = 0; i < types2.length; i++) {
+		int /*long*/ pName = OS.gdk_atom_name(types2[i]);
+		if (pName == 0) {
+			continue;
+		}
+		byte[] buffer = new byte [OS.strlen(pName)];
+		OS.memmove (buffer, pName, buffer.length);
+		OS.g_free (pName);
+		result[count++] = "GTKPRIMARYCLIPBOARD "+new String (Converter.mbcsToWcs (null, buffer));
+	}
+	if (count < result.length){
+		String[] temp = new String[count];
+		System.arraycopy(result, 0, temp, 0, count);
+		result = temp;
+	}
+	return result;
+}
+
+private  int[] getAvailablePrimaryTypes() {
+	int[] types = new int[0];
+	int /*long*/ selection_data = gtk_clipboard_wait_for_contents(GTKPRIMARYCLIPBOARD, TARGET);
+	if (selection_data != 0) {
+		try {
+			GtkSelectionData gtkSelectionData = new GtkSelectionData();
+			OS.memmove(gtkSelectionData, selection_data, GtkSelectionData.sizeof);
+			if (gtkSelectionData.length != 0) {
+				types = new int[gtkSelectionData.length * 8 / gtkSelectionData.format];
+				OS.memmove(types, gtkSelectionData.data, gtkSelectionData.length);
+			}
+		} finally {
+			OS.gtk_selection_data_free(selection_data);
+		}
+	}
+	return types;
+}
+private int[] getAvailableClipboardTypes () {
+	int[] types = new int[0];
+	int /*long*/ selection_data  = gtk_clipboard_wait_for_contents(GTKCLIPBOARD, TARGET);
+	if (selection_data != 0) {
+		try {
+			GtkSelectionData gtkSelectionData = new GtkSelectionData();
+			OS.memmove(gtkSelectionData, selection_data, GtkSelectionData.sizeof);
+			if (gtkSelectionData.length != 0) {
+				types = new int[gtkSelectionData.length * 8 / gtkSelectionData.format];
+				OS.memmove(types, gtkSelectionData.data, gtkSelectionData.length);
+			}
+		} finally {
+			OS.gtk_selection_data_free(selection_data);
+		}
+	}
+	return types;
+}
+
+int /*long*/ gtk_clipboard_wait_for_contents(int /*long*/ clipboard, int /*long*/ target) {
+	String key = "org.eclipse.swt.internal.gtk.dispatchEvent";
+	Display display = this.display;
+	display.setData(key, new int[]{OS.GDK_PROPERTY_NOTIFY, OS.GDK_SELECTION_CLEAR, OS.GDK_SELECTION_REQUEST, OS.GDK_SELECTION_NOTIFY});
+	int /*long*/ selection_data = OS.gtk_clipboard_wait_for_contents(clipboard, target);
+	display.setData(key, null);
+	return selection_data;
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/ClipboardProxy.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/ClipboardProxy.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/ClipboardProxy.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,191 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.dnd;
+
+ 
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.internal.Callback;
+import org.eclipse.swt.internal.Converter;
+import org.eclipse.swt.internal.gtk.GtkSelectionData;
+import org.eclipse.swt.internal.gtk.GtkTargetEntry;
+import org.eclipse.swt.internal.gtk.OS;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+
+class ClipboardProxy {
+	/* Data is not flushed to the clipboard immediately.
+	 * This class will remember the data and provide it when requested. 
+	 */
+	Object[] clipboardData;
+	Transfer[] clipboardDataTypes;
+	Object[] primaryClipboardData;
+	Transfer[] primaryClipboardDataTypes;
+
+	Display display;
+	Clipboard activeClipboard = null;
+	Clipboard activePrimaryClipboard = null;
+	Callback getFunc;
+	Callback clearFunc;
+	
+	static String ID = "CLIPBOARD PROXY OBJECT"; //$NON-NLS-1$
+
+static ClipboardProxy _getInstance(final Display display) {
+	ClipboardProxy proxy = (ClipboardProxy) display.getData(ID);
+	if (proxy != null) return proxy;
+	proxy = new ClipboardProxy(display);
+	display.setData(ID, proxy);
+	display.addListener(SWT.Dispose, new Listener() {
+		public void handleEvent(Event event) {
+			ClipboardProxy clipbordProxy = (ClipboardProxy)display.getData(ID);
+			if (clipbordProxy == null) return;
+			display.setData(ID, null);
+			clipbordProxy.dispose();
+		}
+	});
+	return proxy;
+}	
+
+ClipboardProxy(Display display) {	
+	this.display = display;
+	getFunc = new Callback( this, "getFunc", 4); //$NON-NLS-1$
+	if (getFunc.getAddress() == 0) SWT.error(SWT.ERROR_NO_MORE_CALLBACKS);
+	clearFunc = new Callback( this, "clearFunc", 2); //$NON-NLS-1$
+	if (clearFunc.getAddress() == 0) SWT.error(SWT.ERROR_NO_MORE_CALLBACKS);
+}
+
+void clear (Clipboard owner, int clipboards) {
+	if ((clipboards & DND.CLIPBOARD) != 0 && activeClipboard == owner) {
+		OS.gtk_clipboard_clear(Clipboard.GTKCLIPBOARD);
+	}
+	if ((clipboards & DND.SELECTION_CLIPBOARD) != 0 && activePrimaryClipboard == owner) {
+		OS.gtk_clipboard_clear(Clipboard.GTKPRIMARYCLIPBOARD);
+	}
+}
+
+int /*long*/ clearFunc(int /*long*/ clipboard,int /*long*/ user_data_or_owner){
+	if (clipboard == Clipboard.GTKCLIPBOARD) {
+		activeClipboard = null;
+		clipboardData = null;
+		clipboardDataTypes = null;
+	}
+	if (clipboard == Clipboard.GTKPRIMARYCLIPBOARD) {
+		activePrimaryClipboard = null;
+		primaryClipboardData = null;
+		primaryClipboardDataTypes = null;
+	}
+	return 1;
+}
+
+void dispose () {
+	if (display == null) return;
+	if (activeClipboard != null) OS.gtk_clipboard_clear(Clipboard.GTKCLIPBOARD);
+	if (activePrimaryClipboard != null) OS.gtk_clipboard_clear(Clipboard.GTKPRIMARYCLIPBOARD);
+	display = null;
+	if (getFunc != null ) getFunc.dispose();
+	getFunc = null;
+	if (clearFunc != null) clearFunc.dispose();
+	clearFunc = null;
+	clipboardData = null;
+	clipboardDataTypes = null;
+	primaryClipboardData = null;
+	primaryClipboardDataTypes = null;
+}
+
+/**
+ * This function provides the data to the clipboard on request.
+ * When this clipboard is disposed, the data will no longer be available.
+ */
+int /*long*/ getFunc(int /*long*/ clipboard, int /*long*/ selection_data, int /*long*/ info, int /*long*/ user_data_or_owner){
+	if (selection_data == 0) return 0;
+	GtkSelectionData selectionData = new GtkSelectionData();
+	OS.memmove(selectionData, selection_data, GtkSelectionData.sizeof);
+	TransferData tdata = new TransferData();
+	tdata.type = selectionData.target;
+	Transfer[] types = (clipboard == Clipboard.GTKCLIPBOARD) ? clipboardDataTypes : primaryClipboardDataTypes;
+	int index = -1;
+	for (int i = 0; i < types.length; i++) {
+		if (types[i].isSupportedType(tdata)) {
+			index = i;
+			break;
+		}
+	}
+	if (index == -1) return 0;
+	Object[] data = (clipboard == Clipboard.GTKCLIPBOARD) ? clipboardData : primaryClipboardData;
+	types[index].javaToNative(data[index], tdata);
+	if (tdata.format < 8 || tdata.format % 8 != 0) {
+		return 0;
+	}
+	OS.gtk_selection_data_set(selection_data, tdata.type, tdata.format, tdata.pValue, tdata.length);	
+	OS.g_free(tdata.pValue);
+	return 1;
+}
+
+boolean setData(Clipboard owner, Object[] data, Transfer[] dataTypes, int clipboards) {	
+	GtkTargetEntry[] entries = new  GtkTargetEntry [0];
+	int /*long*/ pTargetsList = 0;
+	try {
+		for (int i = 0; i < dataTypes.length; i++) {
+			Transfer transfer = dataTypes[i];
+			int[] typeIds = transfer.getTypeIds();
+			String[] typeNames = transfer.getTypeNames();
+			for (int j = 0; j < typeIds.length; j++) {
+				GtkTargetEntry	entry = new GtkTargetEntry();						
+				entry.info = typeIds[j];
+				byte[] buffer = Converter.wcsToMbcs(null, typeNames[j], true);
+				int /*long*/ pName = OS.g_malloc(buffer.length);
+				OS.memmove(pName, buffer, buffer.length);
+				entry.target = pName;
+				GtkTargetEntry[] tmp = new GtkTargetEntry [entries.length + 1];
+				System.arraycopy(entries, 0, tmp, 0, entries.length);
+				tmp[entries.length] = entry;
+				entries = tmp;				
+			}	
+		}
+		
+		pTargetsList = OS.g_malloc(GtkTargetEntry.sizeof * entries.length);
+		int offset = 0;
+		for (int i = 0; i < entries.length; i++) {
+			OS.memmove(pTargetsList + offset, entries[i], GtkTargetEntry.sizeof);
+			offset += GtkTargetEntry.sizeof;
+		}
+		if ((clipboards & DND.CLIPBOARD) != 0) {
+			if (activeClipboard != null) OS.gtk_clipboard_clear(Clipboard.GTKCLIPBOARD);
+			clipboardData = data;
+			clipboardDataTypes = dataTypes;
+			int /*long*/ getFuncProc = getFunc.getAddress();
+			int /*long*/ clearFuncProc = clearFunc.getAddress();
+			if (!OS.gtk_clipboard_set_with_data(Clipboard.GTKCLIPBOARD, pTargetsList, entries.length, getFuncProc, clearFuncProc, 0)) {
+				return false;
+			}
+			activeClipboard = owner;
+		}
+		if ((clipboards & DND.SELECTION_CLIPBOARD) != 0) {
+			if (activePrimaryClipboard != null) OS.gtk_clipboard_clear(Clipboard.GTKPRIMARYCLIPBOARD);
+			primaryClipboardData = data;
+			primaryClipboardDataTypes = dataTypes;
+			int /*long*/ getFuncProc = getFunc.getAddress();
+			int /*long*/ clearFuncProc = clearFunc.getAddress();
+			if (!OS.gtk_clipboard_set_with_data(Clipboard.GTKPRIMARYCLIPBOARD, pTargetsList, entries.length, getFuncProc, clearFuncProc, 0)) {
+				return false;
+			}
+			activePrimaryClipboard = owner;
+		}
+		return true;
+	} finally {
+		for (int i = 0; i < entries.length; i++) {
+			GtkTargetEntry entry = entries[i];
+			if( entry.target != 0) OS.g_free(entry.target);
+		}
+		if (pTargetsList != 0) OS.g_free(pTargetsList);
+	}
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/DND.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/DND.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/DND.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,285 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.dnd;
+
+ 
+import org.eclipse.swt.*;
+
+/**
+ *
+ * Class DND contains all the constants used in defining a 
+ * DragSource or a DropTarget.
+ *
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public class DND {
+	
+	/**
+	 * The transfer mechanism for data that is being cut
+	 * and then pasted or copied and then pasted (value is 1).
+	 * 
+	 * @see Clipboard
+	 * 
+	 * @since 3.1
+	 */
+	public final static int CLIPBOARD = 1 << 0;
+	
+	/**
+	 * The transfer mechanism for clients that use the selection 
+	 * mechanism (value is 2).
+	 * 
+	 * @see Clipboard
+	 *
+	 * @since 3.1
+	 */
+	public final static int SELECTION_CLIPBOARD = 1 << 1;
+
+	/**
+	 * Drag and Drop Operation: no drag/drop operation performed
+	 * (value is 0).
+	 */
+	public final static int DROP_NONE = 0;
+	
+	/**
+	 * Drag and Drop Operation: a copy of the data in the drag source is 
+	 * added to the drop target (value is 1 &lt;&lt; 0).
+	 */
+	public final static int DROP_COPY = 1 << 0;
+	
+	/**
+	 * Drag and Drop Operation: a copy of the data is added to the drop target and 
+	 * the original data is removed from the drag source (value is 1 &lt;&lt; 1).
+	 */
+	public final static int DROP_MOVE = 1 << 1;
+	
+	/**
+	 * Drag and Drop Operation: the drop target makes a link to the data in 
+	 * the drag source (value is 1 &lt;&lt; 2).
+	 */
+	public final static int DROP_LINK = 1 << 2;
+	
+	/**
+	 * Drag and Drop Operation: the drop target moves the data and the drag source removes 
+	 * any references to the data and updates its display.  This is not available on all platforms
+	 * and is only used when a non-SWT application is the drop target.  In this case, the SWT 
+	 * drag source is informed in the dragFinished event that the drop target has moved the data.
+	 * (value is 1 &lt;&lt; 3).
+	 * 
+	 * @see DragSourceListener#dragFinished
+	 */
+	public final static int DROP_TARGET_MOVE = 1 << 3;
+	
+	/**
+	 * Drag and Drop Operation: During a dragEnter event or a dragOperationChanged, if no modifier keys
+	 * are pressed, the operation is set to DROP_DEFAULT.  The application can choose what the default 
+	 * operation should be by setting a new value in the operation field.  If no value is choosen, the
+	 * default operation for the platform will be selected (value is 1 &lt;&lt; 4).
+	 * 
+	 * @see DropTargetListener#dragEnter
+	 * @see DropTargetListener#dragOperationChanged
+	 * @since 2.0 
+	 */
+	public final static int DROP_DEFAULT = 1 << 4;
+	
+	/**
+	 * DragSource Event: the drop has successfully completed or has been terminated (such as hitting 
+	 * the ESC key); perform cleanup such as removing data on a move operation (value is 2000).
+	 */
+	public static final int DragEnd		= 2000;
+	
+	/**
+	 * DragSource Event: the data to be dropped is required from the drag source (value is 2001).
+	 */
+	public static final int DragSetData = 2001;
+	
+	/**
+	 * DropTarget Event: the cursor has entered the drop target boundaries (value is 2002).
+	 */
+	public static final int DragEnter	= 2002;
+	
+	/**
+	 * DropTarget Event: the cursor has left the drop target boundaries OR the drop
+	 * operation has been cancelled (such as by hitting ECS) OR the drop is about to 
+	 * happen (user has released the mouse button over this target) (value is 2003).
+	 */
+	public static final int DragLeave	= 2003;
+	
+	/**
+	 * DropTarget Event: the cursor is over the drop target (value is 2004).
+	 */
+	public static final int	DragOver	= 2004;
+	
+	/**
+	 * DropTarget Event: the operation being performed has changed usually due to the user 
+	 * changing the selected modifier keys while dragging (value is 2005).
+	 */
+	public static final int DragOperationChanged = 2005;
+	
+	/**
+	 * DropTarget Event: the data has been dropped (value is 2006).
+	 */
+	public static final int	Drop = 2006;
+	
+	/**
+	 * DropTarget Event: the drop target is given a last chance to modify the drop (value is 2007).
+	 */
+	public static final int	DropAccept	= 2007;
+	
+	/**
+	 * DragSource Event: a drag is about to begin (value is 2008).
+	 */
+	public static final int	DragStart = 2008;
+
+	/**
+	 * DropTarget drag under effect: No effect is shown (value is 0).
+	 */
+	public static final int FEEDBACK_NONE = 0;
+	
+	/**
+	 * DropTarget drag under effect: The item under the cursor is selected; applies to tables
+	 * and trees (value is 1).
+	 */
+	public static final int FEEDBACK_SELECT = 1;
+	
+	/**
+	 * DropTarget drag under effect: An insertion mark is shown before the item under the cursor; applies to 
+	 * trees (value is 2).
+	 */
+	public static final int FEEDBACK_INSERT_BEFORE = 2;
+	
+	/**
+	 * DropTarget drag under effect:An insertion mark is shown after the item under the cursor; applies to
+	 * trees (value is 4).
+	 */	
+	public static final int FEEDBACK_INSERT_AFTER = 4;
+	
+	/**
+	 * DropTarget drag under effect: The widget is scrolled up or down to allow the user to drop on items that 
+	 * are not currently visible;  applies to tables and trees (value is 8).
+	 */	
+	public static final int FEEDBACK_SCROLL = 8;
+	
+	/**
+	 * DropTarget drag under effect: The item currently under the cursor is expanded to allow the user to 
+	 * select a drop target from a sub item; applies to trees (value is 16).
+	 */	
+	public static final int FEEDBACK_EXPAND = 16;
+
+	/**
+	 * Error code: drag source can not be initialized (value is 2000).
+	 */
+	public static final int ERROR_CANNOT_INIT_DRAG = 2000;
+	
+	/**
+	 * Error code: drop target cannot be initialized (value is 2001).
+	 */
+	public static final int ERROR_CANNOT_INIT_DROP = 2001;
+	
+	/**
+	 * Error code: Data can not be set on system clipboard (value is 2002).
+	 */
+	public static final int ERROR_CANNOT_SET_CLIPBOARD = 2002;
+	
+	/**
+	 * Error code: Data does not have correct format for type (value is 2003).
+	 * @since 3.1
+	 */
+	public static final int ERROR_INVALID_DATA = 2003;
+	
+	/**
+	 * DropTarget Key: The string constant for looking up the drop target 
+	 * for a control using <code>getData(String)</code>. When a drop target 
+	 * is created for a control, it is stored as a property in the control 
+	 * using <code>setData(String, Object)</code>.
+	 * 
+	 * @since 3.4
+	 */
+	public static final String DROP_TARGET_KEY = "DropTarget"; //$NON-NLS-1$
+	
+	/**
+	 * DragSource Key: The string constant for looking up the drag source 
+	 * for a control using <code>getData(String)</code>. When a drag source 
+	 * is created for a control, it is stored as a property in the control 
+	 * using <code>setData(String, Object)</code>.
+	 * 
+	 * @since 3.4
+	 */
+	public static final String DRAG_SOURCE_KEY = "DragSource"; //$NON-NLS-1$
+
+	static final String INIT_DRAG_MESSAGE = "Cannot initialize Drag"; //$NON-NLS-1$
+	static final String INIT_DROP_MESSAGE = "Cannot initialize Drop"; //$NON-NLS-1$
+	static final String CANNOT_SET_CLIPBOARD_MESSAGE = "Cannot set data in clipboard"; //$NON-NLS-1$
+	static final String INVALID_DATA_MESSAGE = "Data does not have correct format for type"; //$NON-NLS-1$
+
+/**
+ * Throws an appropriate exception based on the passed in error code.
+ *
+ * @param code the DND error code
+ */
+public static void error (int code) {
+	error (code, 0);
+}
+
+/**
+ * Throws an appropriate exception based on the passed in error code.
+ * The <code>hresult</code> argument should be either 0, or the
+ * platform specific error code.
+ * <p>
+ * In DND, errors are reported by throwing one of three exceptions:
+ * <dl>
+ * <dd>java.lang.IllegalArgumentException</dd>
+ * <dt>thrown whenever one of the API methods is invoked with an illegal argument</dt>
+ * <dd>org.eclipse.swt.SWTException (extends java.lang.RuntimeException)</dd>
+ * <dt>thrown whenever a recoverable error happens internally in SWT</dt>
+ * <dd>org.eclipse.swt.SWTError (extends java.lang.Error)</dd>
+ * <dt>thrown whenever a <b>non-recoverable</b> error happens internally in SWT</dt>
+ * </dl>
+ * This method provides the logic which maps between error codes
+ * and one of the above exceptions.
+ * </p>
+ *
+ * @param code the DND error code.
+ * @param hresult the platform specific error code.
+ *
+ * @see SWTError
+ * @see SWTException
+ * @see IllegalArgumentException
+ */
+public static void error (int code, int hresult) {		
+	switch (code) {		
+		/* OS Failure/Limit (fatal, may occur only on some platforms) */
+		case DND.ERROR_CANNOT_INIT_DRAG:{
+			String msg = DND.INIT_DRAG_MESSAGE;
+			if (hresult != 0) msg += " result = "+hresult; //$NON-NLS-1$
+			throw new SWTError (code, msg);
+		}
+		case DND.ERROR_CANNOT_INIT_DROP:{
+			String msg = DND.INIT_DROP_MESSAGE;
+			if (hresult != 0) msg += " result = "+hresult; //$NON-NLS-1$
+			throw new SWTError (code, msg);
+		}
+		case DND.ERROR_CANNOT_SET_CLIPBOARD:{
+			String msg = DND.CANNOT_SET_CLIPBOARD_MESSAGE;
+			if (hresult != 0) msg += " result = "+hresult; //$NON-NLS-1$
+			throw new SWTError (code, msg);
+		}
+		case DND.ERROR_INVALID_DATA:{
+			String msg = DND.INVALID_DATA_MESSAGE;
+			if (hresult != 0) msg += " result = "+hresult; //$NON-NLS-1$
+			throw new SWTException (code, msg);
+		}
+	}
+			
+	/* Unknown/Undefined Error */
+	SWT.error(code);
+}
+
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/DNDEvent.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/DNDEvent.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/DNDEvent.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.dnd;
+
+
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+
+class DNDEvent extends Event {
+	public TransferData dataType;
+	public TransferData[] dataTypes;
+	public int operations;
+	public int feedback;
+	public Image image;
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/DNDListener.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/DNDListener.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/DNDListener.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,121 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.dnd;
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.widgets.*;
+
+
+class DNDListener extends TypedListener {
+	Widget dndWidget;
+/**
+ * DNDListener constructor comment.
+ * @param listener org.eclipse.swt.internal.SWTEventListener
+ */
+DNDListener(SWTEventListener listener) {
+	super(listener);
+}
+public void handleEvent (Event e) {
+	switch (e.type) {
+		case DND.DragStart: {
+			DragSourceEvent event = new DragSourceEvent((DNDEvent)e);
+			DragSourceEffect sourceEffect = ((DragSource) dndWidget).getDragSourceEffect();
+			if (sourceEffect != null) {
+				sourceEffect.dragStart (event);
+			}
+			((DragSourceListener) eventListener).dragStart (event);
+			event.updateEvent((DNDEvent)e);
+			break;
+		}
+		case DND.DragEnd: {
+			DragSourceEvent event = new DragSourceEvent((DNDEvent)e);
+			DragSourceEffect sourceEffect = ((DragSource) dndWidget).getDragSourceEffect();
+			if (sourceEffect != null) {
+				sourceEffect.dragFinished (event);
+			}
+			((DragSourceListener) eventListener).dragFinished (event);
+			event.updateEvent((DNDEvent)e);
+			break;
+		}
+		case DND.DragSetData: {
+			DragSourceEvent event = new DragSourceEvent((DNDEvent)e);
+			DragSourceEffect sourceEffect = ((DragSource) dndWidget).getDragSourceEffect();
+			if (sourceEffect != null) {
+				sourceEffect.dragSetData (event);
+			}
+			((DragSourceListener) eventListener).dragSetData (event);
+			event.updateEvent((DNDEvent)e);
+			break;
+		}
+		case DND.DragEnter: {
+			DropTargetEvent event = new DropTargetEvent((DNDEvent)e);
+			((DropTargetListener) eventListener).dragEnter (event);
+			DropTargetEffect dropEffect = ((DropTarget) dndWidget).getDropTargetEffect();
+			if (dropEffect != null) {
+				dropEffect.dragEnter (event);
+			}
+			event.updateEvent((DNDEvent)e);
+			break;
+		}
+		case DND.DragLeave: {
+			DropTargetEvent event = new DropTargetEvent((DNDEvent)e);
+			((DropTargetListener) eventListener).dragLeave (event);
+			DropTargetEffect dropEffect = ((DropTarget) dndWidget).getDropTargetEffect();
+			if (dropEffect != null) {
+				dropEffect.dragLeave (event);
+			}
+			event.updateEvent((DNDEvent)e);
+			break;
+		}
+		case DND.DragOver: {
+			DropTargetEvent event = new DropTargetEvent((DNDEvent)e);
+			((DropTargetListener) eventListener).dragOver (event);
+			DropTargetEffect dropEffect = ((DropTarget) dndWidget).getDropTargetEffect();
+			if (dropEffect != null) {
+				dropEffect.dragOver (event);
+			}
+			event.updateEvent((DNDEvent)e);
+			break;
+		}
+		case DND.Drop: {
+			DropTargetEvent event = new DropTargetEvent((DNDEvent)e);
+			((DropTargetListener) eventListener).drop (event);
+			DropTargetEffect dropEffect = ((DropTarget) dndWidget).getDropTargetEffect();
+			if (dropEffect != null) {
+				dropEffect.drop (event);
+			}
+			event.updateEvent((DNDEvent)e);
+			break;
+		}
+		case DND.DropAccept: {
+			DropTargetEvent event = new DropTargetEvent((DNDEvent)e);
+			((DropTargetListener) eventListener).dropAccept (event);
+			DropTargetEffect dropEffect = ((DropTarget) dndWidget).getDropTargetEffect();
+			if (dropEffect != null) {
+				dropEffect.dropAccept (event);
+			}
+			event.updateEvent((DNDEvent)e);
+			break;
+		}
+		case DND.DragOperationChanged: {
+			DropTargetEvent event = new DropTargetEvent((DNDEvent)e);
+			((DropTargetListener) eventListener).dragOperationChanged (event);
+			DropTargetEffect dropEffect = ((DropTarget) dndWidget).getDropTargetEffect();
+			if (dropEffect != null) {
+				dropEffect.dragOperationChanged (event);
+			}
+			event.updateEvent((DNDEvent)e);
+			break;
+		}
+		
+	}
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/DragSource.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/DragSource.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/DragSource.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,631 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.dnd;
+
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.gtk.*;
+
+/**
+ *
+ * <code>DragSource</code> defines the source object for a drag and drop transfer.
+ *
+ * <p>IMPORTANT: This class is <em>not</em> intended to be subclassed.</p>
+ *  
+ * <p>A drag source is the object which originates a drag and drop operation. For the specified widget, 
+ * it defines the type of data that is available for dragging and the set of operations that can 
+ * be performed on that data.  The operations can be any bit-wise combination of DND.MOVE, DND.COPY or 
+ * DND.LINK.  The type of data that can be transferred is specified by subclasses of Transfer such as 
+ * TextTransfer or FileTransfer.  The type of data transferred can be a predefined system type or it 
+ * can be a type defined by the application.  For instructions on how to define your own transfer type,
+ * refer to <code>ByteArrayTransfer</code>.</p>
+ *
+ * <p>You may have several DragSources in an application but you can only have one DragSource 
+ * per Control.  Data dragged from this DragSource can be dropped on a site within this application 
+ * or it can be dropped on another application such as an external Text editor.</p>
+ * 
+ * <p>The application supplies the content of the data being transferred by implementing the
+ * <code>DragSourceListener</code> and associating it with the DragSource via DragSource#addDragListener.</p>
+ * 
+ * <p>When a successful move operation occurs, the application is required to take the appropriate 
+ * action to remove the data from its display and remove any associated operating system resources or
+ * internal references.  Typically in a move operation, the drop target makes a copy of the data 
+ * and the drag source deletes the original.  However, sometimes copying the data can take a long 
+ * time (such as copying a large file).  Therefore, on some platforms, the drop target may actually 
+ * move the data in the operating system rather than make a copy.  This is usually only done in 
+ * file transfers.  In this case, the drag source is informed in the DragEnd event that a
+ * DROP_TARGET_MOVE was performed.  It is the responsibility of the drag source at this point to clean 
+ * up its displayed information.  No action needs to be taken on the operating system resources.</p>
+ *
+ * <p> The following example shows a Label widget that allows text to be dragged from it.</p>
+ * 
+ * <code><pre>
+ *	// Enable a label as a Drag Source
+ *	Label label = new Label(shell, SWT.NONE);
+ *	// This example will allow text to be dragged
+ *	Transfer[] types = new Transfer[] {TextTransfer.getInstance()};
+ *	// This example will allow the text to be copied or moved to the drop target
+ *	int operations = DND.DROP_MOVE | DND.DROP_COPY;
+ *	
+ *	DragSource source = new DragSource(label, operations);
+ *	source.setTransfer(types);
+ *	source.addDragListener(new DragSourceListener() {
+ *		public void dragStart(DragSourceEvent e) {
+ *			// Only start the drag if there is actually text in the
+ *			// label - this text will be what is dropped on the target.
+ *			if (label.getText().length() == 0) {
+ *				event.doit = false;
+ *			}
+ *		};
+ *		public void dragSetData(DragSourceEvent event) {
+ *			// A drop has been performed, so provide the data of the 
+ *			// requested type.
+ *			// (Checking the type of the requested data is only 
+ *			// necessary if the drag source supports more than 
+ *			// one data type but is shown here as an example).
+ *			if (TextTransfer.getInstance().isSupportedType(event.dataType)){
+ *				event.data = label.getText();
+ *			}
+ *		}
+ *		public void dragFinished(DragSourceEvent event) {
+ *			// A Move operation has been performed so remove the data
+ *			// from the source
+ *			if (event.detail == DND.DROP_MOVE)
+ *				label.setText("");
+ *		}
+ *	});
+ * </pre></code>
+ *
+ *
+ * <dl>
+ *	<dt><b>Styles</b></dt> <dd>DND.DROP_NONE, DND.DROP_COPY, DND.DROP_MOVE, DND.DROP_LINK</dd>
+ *	<dt><b>Events</b></dt> <dd>DND.DragStart, DND.DragSetData, DND.DragEnd</dd>
+ * </dl>
+ *
+ * @see <a href="http://www.eclipse.org/swt/snippets/#dnd">Drag and Drop snippets</a>
+ * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: DNDExample</a>
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public class DragSource extends Widget {
+
+	// info for registering as a drag source
+	Control control;
+	Listener controlListener;
+	Transfer[] transferAgents = new Transfer[0];
+	DragSourceEffect dragEffect;
+
+	int /*long*/ targetList;
+	
+	//workaround - remember action performed for DragEnd
+	boolean moveData = false;
+	
+	static final String DEFAULT_DRAG_SOURCE_EFFECT = "DEFAULT_DRAG_SOURCE_EFFECT"; //$NON-NLS-1$
+		
+	static Callback DragGetData;
+	static Callback DragEnd;
+	static Callback DragDataDelete;
+	static {
+		DragGetData = new Callback(DragSource.class, "DragGetData", 5);	 //$NON-NLS-1$
+		if (DragGetData.getAddress() == 0) SWT.error(SWT.ERROR_NO_MORE_CALLBACKS);
+		DragEnd = new Callback(DragSource.class, "DragEnd", 2); //$NON-NLS-1$
+		if (DragEnd.getAddress() == 0) SWT.error(SWT.ERROR_NO_MORE_CALLBACKS);
+		DragDataDelete = new Callback(DragSource.class, "DragDataDelete", 2); //$NON-NLS-1$
+		if (DragDataDelete.getAddress() == 0) SWT.error(SWT.ERROR_NO_MORE_CALLBACKS);
+	}
+	
+/**
+ * Creates a new <code>DragSource</code> to handle dragging from the specified <code>Control</code>.
+ * Creating an instance of a DragSource may cause system resources to be allocated depending on the platform.  
+ * It is therefore mandatory that the DragSource instance be disposed when no longer required.
+ *
+ * @param control the <code>Control</code> that the user clicks on to initiate the drag
+ * @param style the bitwise OR'ing of allowed operations; this may be a combination of any of 
+ *					DND.DROP_NONE, DND.DROP_COPY, DND.DROP_MOVE, DND.DROP_LINK
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ * @exception SWTError <ul>
+ *    <li>ERROR_CANNOT_INIT_DRAG - unable to initiate drag source; this will occur if more than one
+ *        drag source is created for a control or if the operating system will not allow the creation
+ *        of the drag source</li>
+ * </ul>
+ * 
+ * <p>NOTE: ERROR_CANNOT_INIT_DRAG should be an SWTException, since it is a
+ * recoverable error, but can not be changed due to backward compatibility.</p>
+ * 
+ * @see Widget#dispose
+ * @see DragSource#checkSubclass
+ * @see DND#DROP_NONE
+ * @see DND#DROP_COPY
+ * @see DND#DROP_MOVE
+ * @see DND#DROP_LINK
+ */
+public DragSource(Control control, int style) {
+	super (control, checkStyle(style));
+	this.control = control;
+	if (DragGetData == null || DragEnd == null || DragDataDelete == null) {
+		DND.error(DND.ERROR_CANNOT_INIT_DRAG);
+	}
+	if (control.getData(DND.DRAG_SOURCE_KEY) != null) {
+		DND.error(DND.ERROR_CANNOT_INIT_DRAG);
+	}
+	control.setData(DND.DRAG_SOURCE_KEY, this);
+
+	OS.g_signal_connect(control.handle, OS.drag_data_get, DragGetData.getAddress(), 0);	
+	OS.g_signal_connect(control.handle, OS.drag_end, DragEnd.getAddress(), 0);
+	OS.g_signal_connect(control.handle, OS.drag_data_delete, DragDataDelete.getAddress(), 0);
+	
+	controlListener = new Listener () {
+		public void handleEvent (Event event) {
+			if (event.type == SWT.Dispose) {
+				if (!DragSource.this.isDisposed()) {
+					DragSource.this.dispose();
+				}
+			}
+			if (event.type == SWT.DragDetect) {
+				if (!DragSource.this.isDisposed()) {
+					DragSource.this.drag(event);
+				}
+			}
+		}
+	};
+	control.addListener (SWT.Dispose, controlListener);
+	control.addListener (SWT.DragDetect, controlListener);
+
+	Object effect = control.getData(DEFAULT_DRAG_SOURCE_EFFECT);
+	if (effect instanceof DragSourceEffect) {
+		dragEffect = (DragSourceEffect) effect;
+	} else if (control instanceof Tree) {
+		dragEffect = new TreeDragSourceEffect((Tree) control);
+	} else if (control instanceof Table) {
+		dragEffect = new TableDragSourceEffect((Table) control);
+	}
+	
+	this.addListener(SWT.Dispose, new Listener() {
+		public void handleEvent(Event e) {
+			onDispose();
+		}
+	});
+}
+
+static int checkStyle (int style) {
+	if (style == SWT.NONE) return DND.DROP_MOVE;
+	return style;
+}
+
+static int /*long*/ DragDataDelete(int /*long*/ widget, int /*long*/ context){
+	DragSource source = FindDragSource(widget);
+	if (source == null) return 0;
+	source.dragDataDelete(widget, context);
+	return 0;
+}
+
+static int /*long*/ DragEnd(int /*long*/ widget, int /*long*/ context){
+	DragSource source = FindDragSource(widget);
+	if (source == null) return 0;
+	source.dragEnd(widget, context);
+	return 0;
+}
+	
+static int /*long*/ DragGetData(int /*long*/ widget, int /*long*/ context, int /*long*/ selection_data,  int /*long*/ info, int /*long*/ time){
+	DragSource source = FindDragSource(widget);
+	if (source == null) return 0;
+	source.dragGetData(widget, context, selection_data, (int)/*64*/info, (int)/*64*/time);
+	return 0;
+}
+
+static DragSource FindDragSource(int /*long*/ handle) {
+	Display display = Display.findDisplay(Thread.currentThread());
+	if (display == null || display.isDisposed()) return null;
+	Widget widget = display.findWidget(handle);
+	if (widget == null) return null;
+	return (DragSource)widget.getData(DND.DRAG_SOURCE_KEY);
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when a drag and drop operation is in progress, by sending
+ * it one of the messages defined in the <code>DragSourceListener</code>
+ * interface.
+ * 
+ * <p><ul>
+ * <li><code>dragStart</code> is called when the user has begun the actions required to drag the widget. 
+ * This event gives the application the chance to decide if a drag should be started.
+ * <li><code>dragSetData</code> is called when the data is required from the drag source.
+ * <li><code>dragFinished</code> is called when the drop has successfully completed (mouse up 
+ * over a valid target) or has been terminated (such as hitting the ESC key). Perform cleanup 
+ * such as removing data from the source side on a successful move operation.
+ * </ul></p>
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see DragSourceListener
+ * @see #getDragListeners
+ * @see #removeDragListener
+ * @see DragSourceEvent
+ */
+public void addDragListener(DragSourceListener listener) {
+	if (listener == null) DND.error (SWT.ERROR_NULL_ARGUMENT);
+	DNDListener typedListener = new DNDListener (listener);
+	typedListener.dndWidget = this;
+	addListener (DND.DragStart, typedListener);
+	addListener (DND.DragSetData, typedListener);
+	addListener (DND.DragEnd, typedListener);
+}
+
+protected void checkSubclass () {
+	String name = getClass().getName ();
+	String validName = DragSource.class.getName();
+	if (!validName.equals(name)) {
+		DND.error (SWT.ERROR_INVALID_SUBCLASS);
+	}
+}
+
+void drag(Event dragEvent) {
+	moveData = false;	
+	DNDEvent event = new DNDEvent();
+	event.widget = this;	
+	event.x = dragEvent.x;
+	event.y = dragEvent.y;
+	event.time = dragEvent.time;
+	event.doit = true;
+	notifyListeners(DND.DragStart, event);
+	if (!event.doit || transferAgents == null || transferAgents.length == 0) return;
+	if (targetList == 0) return;
+	
+	int actions = opToOsOp(getStyle());
+	Image image = event.image; 
+	int /*long*/ context = OS.gtk_drag_begin(control.handle, targetList, actions, 1, 0);
+	if (context != 0 && image != null) {
+		int /*long*/ pixbuf = createPixbuf(image);
+		OS.gtk_drag_set_icon_pixbuf(context, pixbuf, 0, 0);
+		OS.g_object_unref(pixbuf);
+	}
+}
+
+void dragEnd(int /*long*/ widget, int /*long*/ context){
+	/*
+	 * Bug in GTK.  If a drag is initiated using gtk_drag_begin and the 
+	 * mouse is released immediately, the mouse and keyboard remain
+	 * grabbed.  The fix is to release the grab on the mouse and keyboard
+	 * whenever the drag is terminated.
+	 * 
+	 * NOTE: We believe that it is never an error to ungrab when
+	 * a drag is finished.
+	 */
+	OS.gdk_pointer_ungrab(OS.GDK_CURRENT_TIME); 
+	OS.gdk_keyboard_ungrab(OS.GDK_CURRENT_TIME);
+	
+	int operation = DND.DROP_NONE;
+	if (context != 0) {
+		GdkDragContext gdkDragContext = new GdkDragContext ();
+		OS.memmove(gdkDragContext, context, GdkDragContext.sizeof);
+		if (gdkDragContext.dest_window != 0) { //NOTE: if dest_window is 0, drag was aborted
+			if (moveData) {
+				operation = DND.DROP_MOVE;
+			} else {
+				operation = osOpToOp(gdkDragContext.action);
+				if (operation == DND.DROP_MOVE) operation = DND.DROP_NONE;
+			}
+		}
+	}	
+	
+	DNDEvent event = new DNDEvent();
+	event.widget = this;
+	//event.time = ???
+	event.doit = operation != 0;
+	event.detail = operation; 
+	notifyListeners(DND.DragEnd, event);
+	moveData = false;	
+}	
+
+void dragGetData(int /*long*/ widget, int /*long*/ context, int /*long*/ selection_data,  int info, int time){
+	if (selection_data == 0) return;	
+	GtkSelectionData gtkSelectionData = new GtkSelectionData();
+	OS.memmove(gtkSelectionData, selection_data, GtkSelectionData.sizeof);
+	if (gtkSelectionData.target == 0) return;
+	
+	TransferData transferData = new TransferData();
+	transferData.type = gtkSelectionData.target;
+	transferData.pValue = gtkSelectionData.data;
+	transferData.length = gtkSelectionData.length;
+	transferData.format = gtkSelectionData.format;
+		
+	DNDEvent event = new DNDEvent();
+	event.widget = this;
+	event.time = time; 
+	event.dataType = transferData; 
+	notifyListeners(DND.DragSetData, event);
+		
+	Transfer transfer = null;
+	for (int i = 0; i < transferAgents.length; i++) {
+		Transfer transferAgent = transferAgents[i];
+		if (transferAgent != null && transferAgent.isSupportedType(transferData)) {
+			transfer = transferAgent;
+			break;
+		}
+	}
+	if (transfer == null) return;
+	transfer.javaToNative(event.data, transferData);
+	if (transferData.result != 1) return;
+	OS.gtk_selection_data_set(selection_data, transferData.type, transferData.format, transferData.pValue, transferData.length);
+	OS.g_free(transferData.pValue);
+	return;	
+}
+
+void dragDataDelete(int /*long*/ widget, int /*long*/ context){
+	moveData = true;
+}
+
+/**
+ * Returns the Control which is registered for this DragSource.  This is the control that the 
+ * user clicks in to initiate dragging.
+ *
+ * @return the Control which is registered for this DragSource
+ */
+public Control getControl () {
+	return control;
+}
+
+/**
+ * Returns an array of listeners who will be notified when a drag and drop 
+ * operation is in progress, by sending it one of the messages defined in 
+ * the <code>DragSourceListener</code> interface.
+ *
+ * @return the listeners who will be notified when a drag and drop
+ * operation is in progress
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see DragSourceListener
+ * @see #addDragListener
+ * @see #removeDragListener
+ * @see DragSourceEvent
+ * 
+ * @since 3.4
+ */
+public DragSourceListener[] getDragListeners() {
+	Listener[] listeners = getListeners(DND.DragStart);
+	int length = listeners.length;
+	DragSourceListener[] dragListeners = new DragSourceListener[length];
+	int count = 0;
+	for (int i = 0; i < length; i++) {
+		Listener listener = listeners[i];
+		if (listener instanceof DNDListener) {
+			dragListeners[count] = (DragSourceListener) ((DNDListener) listener).getEventListener();
+			count++;
+		}
+	}
+	if (count == length) return dragListeners;
+	DragSourceListener[] result = new DragSourceListener[count];
+	System.arraycopy(dragListeners, 0, result, 0, count);
+	return result;
+}
+
+/**
+ * Returns the drag effect that is registered for this DragSource.  This drag
+ * effect will be used during a drag and drop operation.
+ *
+ * @return the drag effect that is registered for this DragSource
+ * 
+ * @since 3.3
+ */
+public DragSourceEffect getDragSourceEffect() {
+	return dragEffect;
+}
+
+/**
+ * Returns the list of data types that can be transferred by this DragSource.
+ *
+ * @return the list of data types that can be transferred by this DragSource
+ */
+public Transfer[] getTransfer(){
+	return transferAgents;
+}
+
+void onDispose() {
+	if (control == null) return;
+	if (targetList != 0) {
+		OS.gtk_target_list_unref(targetList);
+	}
+	targetList = 0;
+	if (controlListener != null) {
+		control.removeListener(SWT.Dispose, controlListener);
+		control.removeListener(SWT.DragDetect, controlListener);
+	}
+	controlListener = null;
+	control.setData(DND.DRAG_SOURCE_KEY, null);
+	control = null;
+	transferAgents = null;
+}
+
+int opToOsOp(int operation){
+	int osOperation = 0;
+	
+	if ((operation & DND.DROP_COPY) == DND.DROP_COPY)
+		osOperation |= OS.GDK_ACTION_COPY;
+	if ((operation & DND.DROP_MOVE) == DND.DROP_MOVE)
+		osOperation |= OS.GDK_ACTION_MOVE;
+	if ((operation & DND.DROP_LINK) == DND.DROP_LINK)
+		osOperation |= OS.GDK_ACTION_LINK;
+	
+	return osOperation;
+}
+
+int osOpToOp(int osOperation){
+	int operation = DND.DROP_NONE;
+	
+	if ((osOperation & OS.GDK_ACTION_COPY) == OS.GDK_ACTION_COPY)
+		operation |= DND.DROP_COPY;
+	if ((osOperation & OS.GDK_ACTION_MOVE) == OS.GDK_ACTION_MOVE)
+		operation |= DND.DROP_MOVE;
+	if ((osOperation & OS.GDK_ACTION_LINK) == OS.GDK_ACTION_LINK)
+		operation |= DND.DROP_LINK;
+	
+	return operation;
+}		
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when a drag and drop operation is in progress.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see DragSourceListener
+ * @see #addDragListener
+ * @see #getDragListeners
+ */
+public void removeDragListener(DragSourceListener listener) {
+	if (listener == null) DND.error (SWT.ERROR_NULL_ARGUMENT);
+	removeListener (DND.DragStart, listener);
+	removeListener (DND.DragSetData, listener);
+	removeListener (DND.DragEnd, listener);
+}
+
+/**
+ * Specifies the drag effect for this DragSource.  This drag effect will be 
+ * used during a drag and drop operation.
+ *
+ * @param effect the drag effect that is registered for this DragSource
+ * 
+ * @since 3.3
+ */
+public void setDragSourceEffect(DragSourceEffect effect) {
+	dragEffect = effect;
+}
+
+/**
+ * Specifies the list of data types that can be transferred by this DragSource.
+ * The application must be able to provide data to match each of these types when
+ * a successful drop has occurred.
+ * 
+ * @param transferAgents a list of Transfer objects which define the types of data that can be
+ * dragged from this source
+ */
+public void setTransfer(Transfer[] transferAgents){
+	if (targetList != 0) {
+		OS.gtk_target_list_unref(targetList);
+		targetList = 0;
+	}
+	this.transferAgents = transferAgents;
+	if (transferAgents == null || transferAgents.length == 0) return;
+	
+	GtkTargetEntry[] targets = new GtkTargetEntry[0];
+	for (int i = 0; i < transferAgents.length; i++) {
+		Transfer transfer = transferAgents[i];
+		if (transfer != null) {
+			int[] typeIds = transfer.getTypeIds();
+			String[] typeNames = transfer.getTypeNames();
+			for (int j = 0; j < typeIds.length; j++) {
+				GtkTargetEntry entry = new GtkTargetEntry();
+				byte[] buffer = Converter.wcsToMbcs(null, typeNames[j], true);
+				entry.target = OS.g_malloc(buffer.length);
+				OS.memmove(entry.target, buffer, buffer.length);						
+				entry.info = typeIds[j];
+				GtkTargetEntry[] newTargets = new GtkTargetEntry[targets.length + 1];
+				System.arraycopy(targets, 0, newTargets, 0, targets.length);
+				newTargets[targets.length] = entry;
+				targets = newTargets;
+			}	
+		}
+	}
+	
+	int /*long*/ pTargets = OS.g_malloc(targets.length * GtkTargetEntry.sizeof);
+	for (int i = 0; i < targets.length; i++) {
+		OS.memmove(pTargets + i*GtkTargetEntry.sizeof, targets[i], GtkTargetEntry.sizeof);		
+	}			
+	targetList = OS.gtk_target_list_new(pTargets, targets.length);
+	
+	for (int i = 0; i < targets.length; i++) {
+		OS.g_free(targets[i].target);
+	}
+}
+
+static int /*long*/ createPixbuf(Image image) {
+	int [] w = new int [1], h = new int [1];
+ 	OS.gdk_drawable_get_size (image.pixmap, w, h);
+	int /*long*/ colormap = OS.gdk_colormap_get_system ();
+	int /*long*/ pixbuf;
+	boolean hasMask = image.mask != 0 && OS.gdk_drawable_get_depth (image.mask) == 1;
+	if (hasMask) {
+		pixbuf = OS.gdk_pixbuf_new (OS.GDK_COLORSPACE_RGB, true, 8, w [0], h [0]);
+		if (pixbuf == 0) SWT.error (SWT.ERROR_NO_HANDLES);
+		OS.gdk_pixbuf_get_from_drawable (pixbuf, image.pixmap, colormap, 0, 0, 0, 0, w [0], h [0]);
+		int /*long*/ maskPixbuf = OS.gdk_pixbuf_new(OS.GDK_COLORSPACE_RGB, false, 8, w [0], h [0]);
+		if (maskPixbuf == 0) SWT.error (SWT.ERROR_NO_HANDLES);
+		OS.gdk_pixbuf_get_from_drawable(maskPixbuf, image.mask, 0, 0, 0, 0, 0, w [0], h [0]);
+		int stride = OS.gdk_pixbuf_get_rowstride(pixbuf);
+		int /*long*/ pixels = OS.gdk_pixbuf_get_pixels(pixbuf);
+		byte[] line = new byte[stride];
+		int maskStride = OS.gdk_pixbuf_get_rowstride(maskPixbuf);
+		int /*long*/ maskPixels = OS.gdk_pixbuf_get_pixels(maskPixbuf);
+		byte[] maskLine = new byte[maskStride];
+		for (int y=0; y<h[0]; y++) {
+			int /*long*/ offset = pixels + (y * stride);
+			OS.memmove(line, offset, stride);
+			int /*long*/ maskOffset = maskPixels + (y * maskStride);
+			OS.memmove(maskLine, maskOffset, maskStride);
+			for (int x=0; x<w[0]; x++) {
+				if (maskLine[x * 3] == 0) {
+					line[x * 4 + 3] = 0;
+				}
+			}
+			OS.memmove(offset, line, stride);
+		}
+		OS.g_object_unref(maskPixbuf);
+	} else {
+		ImageData data = image.getImageData ();
+		boolean hasAlpha = data.getTransparencyType () == SWT.TRANSPARENCY_ALPHA;
+		pixbuf = OS.gdk_pixbuf_new (OS.GDK_COLORSPACE_RGB, hasAlpha, 8, w [0], h [0]);
+		if (pixbuf == 0) SWT.error (SWT.ERROR_NO_HANDLES);
+		OS.gdk_pixbuf_get_from_drawable (pixbuf, image.pixmap, colormap, 0, 0, 0, 0, w [0], h [0]);
+		if (hasAlpha) {
+			byte [] alpha = data.alphaData;
+			int stride = OS.gdk_pixbuf_get_rowstride (pixbuf);
+			int /*long*/ pixels = OS.gdk_pixbuf_get_pixels (pixbuf);
+			byte [] line = new byte [stride];
+			for (int y = 0; y < h [0]; y++) {
+				int /*long*/ offset = pixels + (y * stride);
+				OS.memmove (line, offset, stride);
+				for (int x = 0; x < w [0]; x++) {
+					line [x*4+3] = alpha [y*w [0]+x];
+				}
+				OS.memmove (offset, line, stride);
+			}
+		}
+	}
+	return pixbuf;
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/DragSourceAdapter.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/DragSourceAdapter.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/DragSourceAdapter.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.dnd;
+
+
+/**
+ * This adapter class provides default implementations for the
+ * methods described by the <code>DragSourceListener</code> interface.
+ * 
+ * <p>Classes that wish to deal with <code>DragSourceEvent</code>s can
+ * extend this class and override only the methods which they are
+ * interested in.</p>
+ *
+ * @see DragSourceListener
+ * @see DragSourceEvent
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public class DragSourceAdapter implements DragSourceListener {
+
+/**
+ * This implementation of <code>dragStart</code> permits the drag operation to start.
+ * For additional information see <code>DragSourceListener.dragStart</code>.
+ * 
+ * @param event the information associated with the drag start event
+ */
+public void dragStart(DragSourceEvent event){}
+
+/**
+ * This implementation of <code>dragFinished</code> does nothing.
+ * For additional information see <code>DragSourceListener.dragFinished</code>.
+ * 
+ * @param event the information associated with the drag finished event
+ */
+public void dragFinished(DragSourceEvent event){}
+
+/**
+ * This implementation of <code>dragSetData</code> does nothing.
+ * For additional information see <code>DragSourceListener.dragSetData</code>.
+ * 
+ * @param event the information associated with the drag set data event
+ */
+public void dragSetData(DragSourceEvent event){}
+
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/DragSourceEffect.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/DragSourceEffect.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/DragSourceEffect.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.dnd;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.widgets.*;
+
+/**
+ * This class provides default implementations to display a drag source
+ * effect during a drag and drop operation. The current implementation
+ * does not provide any visual feedback. 
+ * 
+ * <p>The drag source effect has the same API as the 
+ * <code>DragSourceAdapter</code> so that it can provide custom visual 
+ * feedback when a <code>DragSourceEvent</code> occurs. 
+ * </p>
+ * 
+ * <p>Classes that wish to provide their own drag source effect such as
+ * displaying a default source image during a drag can extend the <code>DragSourceEffect</code> 
+ * class, override the <code>DragSourceAdapter.dragStart</code> method and set 
+ * the field <code>DragSourceEvent.image</code> with their own image.
+ * The image should be disposed when <code>DragSourceAdapter.dragFinished</code> is called.
+ * </p> 
+ *
+ * @see DragSourceAdapter
+ * @see DragSourceEvent
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ * 
+ * @since 3.3
+ */
+public class DragSourceEffect extends DragSourceAdapter {
+	Control control = null;
+
+	/**
+	 * Creates a new <code>DragSourceEffect</code> to handle drag effect from the specified <code>Control</code>.
+	 *
+	 * @param control the <code>Control</code> that the user clicks on to initiate the drag
+	 * 
+	 * @exception IllegalArgumentException <ul>
+	 *    <li>ERROR_NULL_ARGUMENT - if the control is null</li>
+	 * </ul>
+	 */
+	public DragSourceEffect(Control control) {
+		if (control == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+		this.control = control;
+	}
+
+	/**
+	 * Returns the Control which is registered for this DragSourceEffect.  This is the control that the 
+	 * user clicks in to initiate dragging.
+	 *
+	 * @return the Control which is registered for this DragSourceEffect
+	 */
+	public Control getControl() {
+		return control;
+	}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/DragSourceEvent.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/DragSourceEvent.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/DragSourceEvent.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,106 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.dnd;
+
+import org.eclipse.swt.events.TypedEvent;
+import org.eclipse.swt.graphics.*;
+
+/**
+ * The DragSourceEvent contains the event information passed in the methods of the DragSourceListener.
+ * 
+ * @see DragSourceListener
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public class DragSourceEvent extends TypedEvent {
+	/**
+	 * The operation that was performed.
+	 * @see DND#DROP_NONE
+	 * @see DND#DROP_MOVE
+	 * @see DND#DROP_COPY
+	 * @see DND#DROP_LINK
+	 * @see DND#DROP_TARGET_MOVE
+	 */
+ 	public int detail;
+ 	
+ 	/**
+ 	 * In dragStart, the doit field determines if the drag and drop operation 
+ 	 * should proceed; in dragFinished, the doit field indicates whether 
+ 	 * the operation was performed successfully.
+ 	 * <p></p>
+ 	 * In dragStart:
+ 	 * <p>Flag to determine if the drag and drop operation should proceed.
+ 	 * The application can set this value to false to prevent the drag from starting. 
+ 	 * Set to true by default.</p>
+ 	 * 
+ 	 * <p>In dragFinished:</p>
+ 	 * <p>Flag to indicate if the operation was performed successfully. 
+ 	 * True if the operation was performed successfully.</p>
+ 	 */
+ 	public boolean doit;
+
+	/**
+	 * In dragStart, the x coordinate (relative to the control) of the 
+	 * position the mouse went down to start the drag.
+	 * @since 3.2
+	 */
+ 	public int x;
+ 	/**
+	 * In dragStart, the y coordinate (relative to the control) of the 
+	 * position the mouse went down to start the drag .
+	 * @since 3.2
+	 */
+ 	public int y;
+ 	
+ 	/**
+	 * The type of data requested.
+	 * Data provided in the data field must be of the same type.
+ 	 */
+	public TransferData dataType;
+	
+	/**
+	 * The drag source image to be displayed during the drag.
+	 * <p>A value of null indicates that no drag image will be displayed.</p>
+	 * <p>The default value is null.</p>
+	 * 
+	 * @since 3.3
+	 */
+	public Image image;
+
+	static final long serialVersionUID = 3257002142513770808L;
+	
+/**
+ * Constructs a new instance of this class based on the
+ * information in the given untyped event.
+ *
+ * @param e the untyped event containing the information
+ */
+public DragSourceEvent(DNDEvent e) {
+	super(e);
+	this.data = e.data;
+	this.detail = e.detail;
+	this.doit = e.doit;
+	this.dataType = e.dataType;
+	this.x = e.x;
+	this.y = e.y;
+	this.image = e.image;
+}
+void updateEvent(DNDEvent e) {
+	e.widget = this.widget;
+	e.time = this.time;
+	e.data = this.data;
+	e.detail = this.detail;
+	e.doit = this.doit;
+	e.dataType = this.dataType;
+	e.x = this.x;
+	e.y = this.y;
+	e.image = this.image;
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/DragSourceListener.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/DragSourceListener.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/DragSourceListener.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,80 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.dnd;
+
+import org.eclipse.swt.internal.SWTEventListener;
+
+/**
+ * The <code>DragSourceListener</code> class provides event notification to the application for DragSource events.
+ *
+ * <p>When the user drops data on a <code>DropTarget</code>, the application which defines the <code>DragSource</code>
+ * must provide the dropped data by implementing <code>dragSetData</code>.  In the dragSetData, the application
+ * must support all the data types that were specified in the DragSource#setTransfer method.</p>
+ *
+ * <p>After the drop has completed successfully or has been aborted, the application which defines the 
+ * <code>DragSource</code> is required to take the appropriate cleanup action.  In the case of a successful 
+ * <b>move</b> operation, the application must remove the data that was transferred.</p>
+ *
+ */
+public interface DragSourceListener extends SWTEventListener {
+
+/**
+ * The user has begun the actions required to drag the widget. This event gives the application 
+ * the chance to decide if a drag should be started.
+ *
+ * <p>The following fields in the DragSourceEvent apply:
+ * <ul>
+ * <li>(in)widget
+ * <li>(in)time
+ * <li>(in,out)doit
+ * </ul></p>
+ *
+ * @param event the information associated with the drag start event
+ * 
+ * @see DragSourceEvent
+ */
+public void dragStart(DragSourceEvent event);
+
+/**
+ * The data is required from the drag source.
+ *
+ * <p>The following fields in the DragSourceEvent apply:
+ * <ul>
+ * <li>(in)widget
+ * <li>(in)time
+ * <li>(in)dataType - the type of data requested.
+ * <li>(out)data    - the application inserts the actual data here (must match the dataType)
+ * </ul></p>
+ *
+ * @param event the information associated with the drag set data event
+ * 
+ * @see DragSourceEvent
+ */
+public void dragSetData(DragSourceEvent event);
+
+/**
+ * The drop has successfully completed(mouse up over a valid target) or has been terminated (such as hitting 
+ * the ESC key). Perform cleanup such as removing data from the source side on a successful move operation.
+ *
+ * <p>The following fields in the DragSourceEvent apply:
+ * <ul>
+ * <li>(in)widget
+ * <li>(in)time
+ * <li>(in)doit
+ * <li>(in)detail
+ * </ul></p>
+ *
+ * @param event the information associated with the drag finished event
+ * 
+ * @see DragSourceEvent
+ */
+public void dragFinished(DragSourceEvent event);
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/DropTarget.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/DropTarget.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/DropTarget.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,805 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.dnd;
+
+ 
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.gtk.*;
+
+/**
+ *
+ * Class <code>DropTarget</code> defines the target object for a drag and drop transfer.
+ *
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ *
+ * <p>This class identifies the <code>Control</code> over which the user must position the cursor
+ * in order to drop the data being transferred.  It also specifies what data types can be dropped on 
+ * this control and what operations can be performed.  You may have several DropTragets in an 
+ * application but there can only be a one to one mapping between a <code>Control</code> and a <code>DropTarget</code>.
+ * The DropTarget can receive data from within the same application or from other applications 
+ * (such as text dragged from a text editor like Word).</p>
+ *
+ * <code><pre>
+ *	int operations = DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK;
+ *	Transfer[] types = new Transfer[] {TextTransfer.getInstance()};
+ *	DropTarget target = new DropTarget(label, operations);
+ *	target.setTransfer(types);
+ * </code></pre>
+ *
+ * <p>The application is notified of data being dragged over this control and of when a drop occurs by 
+ * implementing the interface <code>DropTargetListener</code> which uses the class 
+ * <code>DropTargetEvent</code>.  The application can modify the type of drag being performed 
+ * on this Control at any stage of the drag by modifying the <code>event.detail</code> field or the 
+ * <code>event.currentDataType</code> field.  When the data is dropped, it is the responsibility of 
+ * the application to copy this data for its own purposes.
+ *
+ * <code><pre>
+ *	target.addDropListener (new DropTargetListener() {
+ *		public void dragEnter(DropTargetEvent event) {};
+ *		public void dragOver(DropTargetEvent event) {};
+ *		public void dragLeave(DropTargetEvent event) {};
+ *		public void dragOperationChanged(DropTargetEvent event) {};
+ *		public void dropAccept(DropTargetEvent event) {}
+ *		public void drop(DropTargetEvent event) {
+ *			// A drop has occurred, copy over the data
+ *			if (event.data == null) { // no data to copy, indicate failure in event.detail
+ *				event.detail = DND.DROP_NONE;
+ *				return;
+ *			}
+ *			label.setText ((String) event.data); // data copied to label text
+ *		}
+ * 	});
+ * </pre></code>
+ *
+ * <dl>
+ *	<dt><b>Styles</b></dt> <dd>DND.DROP_NONE, DND.DROP_COPY, DND.DROP_MOVE, DND.DROP_LINK</dd>
+ *	<dt><b>Events</b></dt> <dd>DND.DragEnter, DND.DragLeave, DND.DragOver, DND.DragOperationChanged, 
+ *                             DND.DropAccept, DND.Drop </dd>
+ * </dl>
+ *
+ * @see <a href="http://www.eclipse.org/swt/snippets/#dnd">Drag and Drop snippets</a>
+ * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: DNDExample</a>
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public class DropTarget extends Widget {
+
+	Control control;
+	Listener controlListener;
+	Transfer[] transferAgents = new Transfer[0];
+	DropTargetEffect dropEffect;
+
+	// Track application selections
+	TransferData selectedDataType;
+	int selectedOperation;
+	
+	// workaround - There is no event for "operation changed" so track operation based on key state
+	int keyOperation = -1;
+	
+	// workaround - Simulate events when the mouse is not moving
+	long dragOverStart;
+	Runnable dragOverHeartbeat;
+	DNDEvent dragOverEvent;
+	
+	int drag_motion_handler;
+	int drag_leave_handler;
+	int drag_data_received_handler;
+	int drag_drop_handler;
+	
+	static final String DEFAULT_DROP_TARGET_EFFECT = "DEFAULT_DROP_TARGET_EFFECT"; //$NON-NLS-1$
+	static final int DRAGOVER_HYSTERESIS = 50;
+	
+	static Callback Drag_Motion;
+	static Callback Drag_Leave;
+	static Callback Drag_Data_Received;
+	static Callback Drag_Drop;
+	
+	 static {	
+		Drag_Motion = new Callback(DropTarget.class, "Drag_Motion", 5); //$NON-NLS-1$
+		if (Drag_Motion.getAddress() == 0) SWT.error(SWT.ERROR_NO_MORE_CALLBACKS);
+		Drag_Leave = new Callback(DropTarget.class, "Drag_Leave", 3); //$NON-NLS-1$
+		if (Drag_Leave.getAddress() == 0) SWT.error(SWT.ERROR_NO_MORE_CALLBACKS);
+		Drag_Data_Received = new Callback(DropTarget.class, "Drag_Data_Received", 7); //$NON-NLS-1$
+		if (Drag_Data_Received.getAddress() == 0) SWT.error(SWT.ERROR_NO_MORE_CALLBACKS);
+		Drag_Drop = new Callback(DropTarget.class, "Drag_Drop", 5); //$NON-NLS-1$
+		if (Drag_Drop.getAddress() == 0) SWT.error(SWT.ERROR_NO_MORE_CALLBACKS);
+	}
+
+/**
+ * Creates a new <code>DropTarget</code> to allow data to be dropped on the specified 
+ * <code>Control</code>.
+ * Creating an instance of a DropTarget may cause system resources to be allocated 
+ * depending on the platform.  It is therefore mandatory that the DropTarget instance 
+ * be disposed when no longer required.
+ * 
+ * @param control the <code>Control</code> over which the user positions the cursor to drop the data
+ * @param style the bitwise OR'ing of allowed operations; this may be a combination of any of 
+ *		   DND.DROP_NONE, DND.DROP_COPY, DND.DROP_MOVE, DND.DROP_LINK
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ * @exception SWTError <ul>
+ *    <li>ERROR_CANNOT_INIT_DROP - unable to initiate drop target; this will occur if more than one
+ *        drop target is created for a control or if the operating system will not allow the creation
+ *        of the drop target</li>
+ * </ul>
+ *
+ * <p>NOTE: ERROR_CANNOT_INIT_DROP should be an SWTException, since it is a
+ * recoverable error, but can not be changed due to backward compatibility.</p>
+ * 
+ * @see Widget#dispose
+ * @see DropTarget#checkSubclass
+ * @see DND#DROP_NONE
+ * @see DND#DROP_COPY
+ * @see DND#DROP_MOVE
+ * @see DND#DROP_LINK
+ */
+public DropTarget(Control control, int style) {
+	super(control, checkStyle(style));
+	this.control = control;
+	if (Drag_Motion == null || Drag_Leave == null || Drag_Data_Received == null || Drag_Drop == null) {
+		 DND.error(DND.ERROR_CANNOT_INIT_DROP);
+	}
+	if (control.getData(DND.DROP_TARGET_KEY) != null) {
+		DND.error(DND.ERROR_CANNOT_INIT_DROP);
+	}
+	control.setData(DND.DROP_TARGET_KEY, this);
+	
+	drag_motion_handler = OS.g_signal_connect(control.handle, OS.drag_motion, Drag_Motion.getAddress(), 0);
+	drag_leave_handler = OS.g_signal_connect(control.handle, OS.drag_leave, Drag_Leave.getAddress(), 0);
+	drag_data_received_handler = OS.g_signal_connect(control.handle, OS.drag_data_received, Drag_Data_Received.getAddress(), 0);
+	drag_drop_handler = OS.g_signal_connect(control.handle, OS.drag_drop, Drag_Drop.getAddress(), 0);
+
+	// Dispose listeners	
+	controlListener = new Listener(){
+		public void handleEvent(Event event){
+			if (!DropTarget.this.isDisposed()){
+				DropTarget.this.dispose();
+			}
+		}
+	};
+	control.addListener(SWT.Dispose, controlListener);
+		
+	this.addListener(SWT.Dispose, new Listener(){
+		public void handleEvent(Event event){
+			onDispose();
+		}	
+	});
+	
+	Object effect = control.getData(DEFAULT_DROP_TARGET_EFFECT);
+	if (effect instanceof DropTargetEffect) {
+		dropEffect = (DropTargetEffect) effect;
+	} else if (control instanceof Table) {
+		dropEffect = new TableDropTargetEffect((Table) control);
+	} else if (control instanceof Tree) {
+		dropEffect = new TreeDropTargetEffect((Tree) control);
+	}
+
+	dragOverHeartbeat = new Runnable() {
+		public void run() {
+			Control control = DropTarget.this.control;
+			if (control == null || control.isDisposed() || dragOverStart == 0) return;
+			long time = System.currentTimeMillis();
+			int delay = DRAGOVER_HYSTERESIS;
+			if (time < dragOverStart) {
+				delay = (int)(dragOverStart - time);
+			} else {
+				dragOverEvent.time += DRAGOVER_HYSTERESIS;
+				int allowedOperations = dragOverEvent.operations;
+				TransferData[] allowedTypes = dragOverEvent.dataTypes;
+				//pass a copy of data types in to listeners in case application modifies it
+				TransferData[] dataTypes = new TransferData[allowedTypes.length];
+				System.arraycopy(allowedTypes, 0, dataTypes, 0, dataTypes.length);
+	
+				DNDEvent event = new DNDEvent();
+				event.widget = dragOverEvent.widget;
+				event.x = dragOverEvent.x;
+				event.y = dragOverEvent.y;
+				event.time = dragOverEvent.time;
+				event.feedback = DND.FEEDBACK_SELECT;
+				event.dataTypes = dataTypes;
+				event.dataType = selectedDataType;
+				event.operations = dragOverEvent.operations;
+				event.detail  = selectedOperation;
+				if (dropEffect != null) {
+					event.item = dropEffect.getItem(dragOverEvent.x, dragOverEvent.y);
+				}
+				selectedDataType = null;
+				selectedOperation = DND.DROP_NONE;
+				notifyListeners(DND.DragOver, event);
+				if (event.dataType != null) {
+					for (int i = 0; i < allowedTypes.length; i++) {
+						if (allowedTypes[i].type == event.dataType.type) {
+							selectedDataType = event.dataType;
+							break;
+						}
+					}
+				}
+				if (selectedDataType != null && (event.detail & allowedOperations) != 0) {
+					selectedOperation = event.detail;
+				}
+			}
+			control = DropTarget.this.control;
+			if (control == null || control.isDisposed()) return;
+			control.getDisplay().timerExec(delay, dragOverHeartbeat);
+		}
+	};
+}
+
+static int checkStyle (int style) {
+	if (style == SWT.NONE) return DND.DROP_MOVE;	
+	return style;
+}
+
+static int /*long*/ Drag_Data_Received ( int /*long*/ widget, int /*long*/ context, int /*long*/ x, int /*long*/ y, int /*long*/ data, int /*long*/ info, int /*long*/ time){
+	DropTarget target = FindDropTarget(widget);
+	if (target == null) return 0;
+	target.drag_data_received (widget, context, (int)/*64*/x, (int)/*64*/y, data, (int)/*64*/info, (int)/*64*/time);
+	return 0;
+}
+
+static int /*long*/ Drag_Drop(int /*long*/ widget, int /*long*/ context, int /*long*/ x, int /*long*/ y, int /*long*/ time) {
+	DropTarget target = FindDropTarget(widget);
+	if (target == null) return 0;
+	return target.drag_drop (widget, context, (int)/*64*/x, (int)/*64*/y, (int)/*64*/time) ? 1 : 0;
+}
+
+static int /*long*/ Drag_Leave ( int /*long*/ widget, int /*long*/ context, int /*long*/ time){
+	DropTarget target = FindDropTarget(widget);
+	if (target == null) return 0;
+	target.drag_leave (widget, context, (int)/*64*/time);
+	return 0;
+}
+
+static int /*long*/ Drag_Motion ( int /*long*/ widget, int /*long*/ context, int /*long*/ x, int /*long*/ y, int /*long*/ time){
+	DropTarget target = FindDropTarget(widget);
+	if (target == null) return 0;
+	return target.drag_motion (widget, context, (int)/*64*/x, (int)/*64*/y, (int)/*64*/time) ? 1 : 0;
+}
+	
+static DropTarget FindDropTarget(int /*long*/ handle) {
+	Display display = Display.findDisplay(Thread.currentThread());
+	if (display == null || display.isDisposed()) return null;
+	Widget widget = display.findWidget(handle);
+	if (widget == null) return null;
+	return (DropTarget)widget.getData(DND.DROP_TARGET_KEY);
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when a drag and drop operation is in progress, by sending
+ * it one of the messages defined in the <code>DropTargetListener</code>
+ * interface.
+ * 
+ * <p><ul>
+ * <li><code>dragEnter</code> is called when the cursor has entered the drop target boundaries
+ * <li><code>dragLeave</code> is called when the cursor has left the drop target boundaries and just before
+ * the drop occurs or is cancelled.
+ * <li><code>dragOperationChanged</code> is called when the operation being performed has changed 
+ * (usually due to the user changing the selected modifier key(s) while dragging)
+ * <li><code>dragOver</code> is called when the cursor is moving over the drop target
+ * <li><code>dropAccept</code> is called just before the drop is performed.  The drop target is given 
+ * the chance to change the nature of the drop or veto the drop by setting the <code>event.detail</code> field
+ * <li><code>drop</code> is called when the data is being dropped
+ * </ul></p>
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see DropTargetListener
+ * @see #getDropListeners
+ * @see #removeDropListener
+ * @see DropTargetEvent
+ */
+public void addDropListener(DropTargetListener listener) {	
+	if (listener == null) DND.error (SWT.ERROR_NULL_ARGUMENT);
+	DNDListener typedListener = new DNDListener (listener);
+	typedListener.dndWidget = this;
+	addListener (DND.DragEnter, typedListener);
+	addListener (DND.DragLeave, typedListener);
+	addListener (DND.DragOver, typedListener);
+	addListener (DND.DragOperationChanged, typedListener);
+	addListener (DND.Drop, typedListener);
+	addListener (DND.DropAccept, typedListener);	
+}	
+
+protected void checkSubclass () {
+	String name = getClass().getName ();
+	String validName = DropTarget.class.getName();
+	if (!validName.equals(name)) {
+		DND.error (SWT.ERROR_INVALID_SUBCLASS);
+	}
+}
+
+void drag_data_received ( int /*long*/ widget, int /*long*/ context, int x, int y, int /*long*/ data, int info, int time){
+	DNDEvent event = new DNDEvent();
+	if (data == 0 || !setEventData(context, x, y, time, event)) {
+		keyOperation = -1;
+		return;
+	}
+	keyOperation = -1;
+	
+	int allowedOperations = event.operations;
+	
+	// Get data in a Java format	
+	Object object = null;
+	TransferData transferData = new TransferData();
+	GtkSelectionData selectionData = new GtkSelectionData(); 
+	OS.memmove(selectionData, data, GtkSelectionData.sizeof);
+	if (selectionData.data != 0) {
+		transferData.type = selectionData.type;
+		transferData.length = selectionData.length;
+		transferData.pValue = selectionData.data;
+		transferData.format = selectionData.format;
+		for (int i = 0; i < transferAgents.length; i++) {
+			Transfer transfer = transferAgents[i];
+			if (transfer != null && transfer.isSupportedType(transferData)) {
+				object = transfer.nativeToJava(transferData);
+				break;
+			}
+		}
+	}
+	if (object == null) {
+		selectedOperation = DND.DROP_NONE;
+	}
+	
+	event.detail = selectedOperation;
+	event.dataType = transferData;
+	event.data = object;
+	selectedOperation = DND.DROP_NONE;
+	notifyListeners(DND.Drop, event);
+	if ((allowedOperations & event.detail) == event.detail) {
+		selectedOperation = event.detail;
+	}
+	//stop native handler
+	OS.g_signal_stop_emission_by_name(widget, OS.drag_data_received);
+	
+	//notify source of action taken
+	OS.gtk_drag_finish(context, selectedOperation != DND.DROP_NONE, selectedOperation== DND.DROP_MOVE, time); 			
+	return;	
+}
+
+boolean drag_drop(int /*long*/ widget, int /*long*/ context, int x, int y, int time) {
+	DNDEvent event = new DNDEvent();
+	if (!setEventData(context, x, y, time, event)) {
+		keyOperation = -1;
+		return false;
+	}
+	keyOperation = -1;
+	
+	int allowedOperations = event.operations;
+	TransferData[] allowedDataTypes = new TransferData[event.dataTypes.length];
+	System.arraycopy(event.dataTypes, 0, allowedDataTypes, 0, allowedDataTypes.length);
+	
+	event.dataType = selectedDataType;
+	event.detail = selectedOperation;
+	selectedDataType = null;
+	selectedOperation = DND.DROP_NONE;
+	notifyListeners(DND.DropAccept,event);
+	if (event.dataType != null) {
+		for (int i = 0; i < allowedDataTypes.length; i++) {
+			if (allowedDataTypes[i].type == event.dataType.type) {
+				selectedDataType = allowedDataTypes[i];
+				break;
+			}
+		}
+	}
+	if (selectedDataType != null && ((event.detail & allowedOperations) == event.detail)) {
+		selectedOperation = event.detail;
+	}
+	if (selectedOperation == DND.DROP_NONE) {
+		// this was not a successful drop
+		return false;
+	}
+	// ask drag source for dropped data
+	OS.gtk_drag_get_data(widget, context, selectedDataType.type, time);
+	return true;
+}
+
+void drag_leave ( int /*long*/ widget, int /*long*/ context, int time){
+	updateDragOverHover(0, null);
+	
+	if (keyOperation == -1) return;
+	keyOperation = -1;
+	
+	DNDEvent event = new DNDEvent();
+	event.widget = this;
+	event.time = time;
+	event.detail = DND.DROP_NONE;
+	notifyListeners(DND.DragLeave, event);
+}
+
+boolean drag_motion ( int /*long*/ widget, int /*long*/ context, int x, int y, int time){
+	int oldKeyOperation = keyOperation;
+	
+	if (oldKeyOperation == -1) { //drag enter
+		selectedDataType = null;
+		selectedOperation = DND.DROP_NONE;
+	}
+		
+	DNDEvent event = new DNDEvent();
+	if (!setEventData(context, x, y, time, event)) {
+		keyOperation = -1;
+		OS.gdk_drag_status(context, 0, time);
+		return false;
+	}
+	
+	int allowedOperations = event.operations;
+	TransferData[] allowedDataTypes = new TransferData[event.dataTypes.length];
+	System.arraycopy(event.dataTypes, 0, allowedDataTypes, 0, allowedDataTypes.length);
+
+	if (oldKeyOperation == -1) {
+		event.type = DND.DragEnter;
+	} else {
+		if (keyOperation == oldKeyOperation) {
+			event.type = DND.DragOver;
+			event.dataType = selectedDataType;
+			event.detail = selectedOperation;
+		} else {
+			event.type = DND.DragOperationChanged;
+			event.dataType = selectedDataType;
+		}
+	}
+	updateDragOverHover(DRAGOVER_HYSTERESIS, event);
+	selectedDataType = null;
+	selectedOperation = DND.DROP_NONE;
+	notifyListeners(event.type, event);	
+	if (event.detail == DND.DROP_DEFAULT) {
+		event.detail = (allowedOperations & DND.DROP_MOVE) != 0 ? DND.DROP_MOVE : DND.DROP_NONE;
+	}
+	if (event.dataType != null) {
+		for (int i = 0; i < allowedDataTypes.length; i++) {
+			if (allowedDataTypes[i].type == event.dataType.type) {
+				selectedDataType = allowedDataTypes[i];
+				break;
+			}
+		}
+	}
+	if (selectedDataType != null && (allowedOperations & event.detail) != 0) {
+		selectedOperation = event.detail;
+	}
+
+	switch (selectedOperation) {
+		case DND.DROP_NONE:
+			OS.gdk_drag_status(context, 0, time);
+			break;		
+		case DND.DROP_COPY:
+			OS.gdk_drag_status(context, OS.GDK_ACTION_COPY, time);
+			break;
+		case DND.DROP_MOVE:
+			OS.gdk_drag_status(context, OS.GDK_ACTION_MOVE, time);
+			break;
+		case DND.DROP_LINK:
+			OS.gdk_drag_status(context, OS.GDK_ACTION_LINK, time);
+			break;
+	}
+	
+	if (oldKeyOperation == -1) {
+		dragOverHeartbeat.run();
+	}
+	return true;
+}
+
+/**
+ * Returns the Control which is registered for this DropTarget.  This is the control over which the 
+ * user positions the cursor to drop the data.
+ *
+ * @return the Control which is registered for this DropTarget
+ */
+public Control getControl () {
+	return control;
+}
+
+/**
+ * Returns an array of listeners who will be notified when a drag and drop 
+ * operation is in progress, by sending it one of the messages defined in 
+ * the <code>DropTargetListener</code> interface.
+ *
+ * @return the listeners who will be notified when a drag and drop 
+ * operation is in progress
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see DropTargetListener
+ * @see #addDropListener
+ * @see #removeDropListener
+ * @see DropTargetEvent
+ * 
+ * @since 3.4
+ */
+public DropTargetListener[] getDropListeners() {
+	Listener[] listeners = getListeners(DND.DragEnter);
+	int length = listeners.length;
+	DropTargetListener[] dropListeners = new DropTargetListener[length];
+	int count = 0;
+	for (int i = 0; i < length; i++) {
+		Listener listener = listeners[i];
+		if (listener instanceof DNDListener) {
+			dropListeners[count] = (DropTargetListener) ((DNDListener) listener).getEventListener();
+			count++;
+		}
+	}
+	if (count == length) return dropListeners;
+	DropTargetListener[] result = new DropTargetListener[count];
+	System.arraycopy(dropListeners, 0, result, 0, count);
+	return result;
+}
+
+/**
+ * Returns the drop effect for this DropTarget.  This drop effect will be 
+ * used during a drag and drop to display the drag under effect on the 
+ * target widget.
+ *
+ * @return the drop effect that is registered for this DropTarget
+ * 
+ * @since 3.3
+ */
+public DropTargetEffect getDropTargetEffect() {
+	return dropEffect;
+}
+
+int getOperationFromKeyState() {
+	int[] state = new int[1];
+	OS.gdk_window_get_pointer(0, null, null, state);
+	boolean ctrl = (state[0] & OS.GDK_CONTROL_MASK) != 0;
+	boolean shift = (state[0] & OS.GDK_SHIFT_MASK) != 0;
+	if (ctrl && shift) return DND.DROP_LINK;
+	if (ctrl)return DND.DROP_COPY;
+	if (shift)return DND.DROP_MOVE;
+	return DND.DROP_DEFAULT;
+}
+
+/**
+ * Returns a list of the data types that can be transferred to this DropTarget.
+ *
+ * @return a list of the data types that can be transferred to this DropTarget
+ */ 
+public Transfer[] getTransfer() { 
+	return transferAgents; 
+}
+
+void onDispose(){
+	if (control == null) return;
+	OS.g_signal_handler_disconnect(control.handle, drag_motion_handler);
+	OS.g_signal_handler_disconnect(control.handle, drag_leave_handler);
+	OS.g_signal_handler_disconnect(control.handle, drag_data_received_handler);
+	OS.g_signal_handler_disconnect(control.handle, drag_drop_handler);
+	if (transferAgents.length != 0)
+		OS.gtk_drag_dest_unset(control.handle);
+	transferAgents = null;
+	if (controlListener != null)
+		control.removeListener(SWT.Dispose, controlListener);
+	control.setData(DND.DROP_TARGET_KEY, null);
+	control = null;
+	controlListener = null;
+}
+
+int opToOsOp(int operation){
+	int osOperation = 0;
+	if ((operation & DND.DROP_COPY) == DND.DROP_COPY)
+		osOperation |= OS.GDK_ACTION_COPY;
+	if ((operation & DND.DROP_MOVE) == DND.DROP_MOVE)
+		osOperation |= OS.GDK_ACTION_MOVE;
+	if ((operation & DND.DROP_LINK) == DND.DROP_LINK)
+		osOperation |= OS.GDK_ACTION_LINK;
+	return osOperation;
+}
+
+int osOpToOp(int osOperation){
+	int operation = DND.DROP_NONE;
+	if ((osOperation & OS.GDK_ACTION_COPY) == OS.GDK_ACTION_COPY)
+		operation |= DND.DROP_COPY;
+	if ((osOperation & OS.GDK_ACTION_MOVE) == OS.GDK_ACTION_MOVE)
+		operation |= DND.DROP_MOVE;
+	if ((osOperation & OS.GDK_ACTION_LINK) == OS.GDK_ACTION_LINK)
+		operation |= DND.DROP_LINK;
+	return operation;
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when a drag and drop operation is in progress.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see DropTargetListener
+ * @see #addDropListener
+ * @see #getDropListeners
+ */
+public void removeDropListener(DropTargetListener listener) {
+	if (listener == null) DND.error (SWT.ERROR_NULL_ARGUMENT);
+	removeListener (DND.DragEnter, listener);
+	removeListener (DND.DragLeave, listener);
+	removeListener (DND.DragOver, listener);
+	removeListener (DND.DragOperationChanged, listener);
+	removeListener (DND.Drop, listener);
+	removeListener (DND.DropAccept, listener);
+}
+
+/**
+ * Specifies the data types that can be transferred to this DropTarget.  If data is 
+ * being dragged that does not match one of these types, the drop target will be notified of 
+ * the drag and drop operation but the currentDataType will be null and the operation 
+ * will be DND.NONE.
+ *
+ * @param transferAgents a list of Transfer objects which define the types of data that can be
+ *						 dropped on this target
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if transferAgents is null</li>
+ * </ul>
+ */
+public void setTransfer(Transfer[] transferAgents){
+	if (transferAgents == null) DND.error(SWT.ERROR_NULL_ARGUMENT);
+	
+	if (this.transferAgents.length != 0) {
+		OS.gtk_drag_dest_unset(control.handle);
+	}
+	this.transferAgents = transferAgents;
+	
+	GtkTargetEntry[] targets = new GtkTargetEntry[0];
+	for (int i = 0; i < transferAgents.length; i++) {
+		Transfer transfer = transferAgents[i];
+		if (transfer != null) {
+			int[] typeIds = transfer.getTypeIds();
+			String[] typeNames = transfer.getTypeNames();
+			for (int j = 0; j < typeIds.length; j++) {
+				GtkTargetEntry entry = new GtkTargetEntry();
+				byte[] buffer = Converter.wcsToMbcs(null, typeNames[j], true);
+				entry.target = OS.g_malloc(buffer.length);
+				OS.memmove(entry.target, buffer, buffer.length);						
+				entry.info = typeIds[j];
+				GtkTargetEntry[] newTargets = new GtkTargetEntry[targets.length + 1];
+				System.arraycopy(targets, 0, newTargets, 0, targets.length);
+				newTargets[targets.length] = entry;
+				targets = newTargets;
+			}
+		}
+	}
+	
+	int /*long*/ pTargets = OS.g_malloc(targets.length * GtkTargetEntry.sizeof);
+	for (int i = 0; i < targets.length; i++) {
+		OS.memmove(pTargets + i*GtkTargetEntry.sizeof, targets[i], GtkTargetEntry.sizeof);		
+	}			
+	
+	int actions = opToOsOp(getStyle());
+	if (control instanceof Combo) {
+		if ((control.getStyle() & SWT.READ_ONLY) == 0) {
+			int /*long*/ entryHandle = OS.gtk_bin_get_child (control.handle);
+			if (entryHandle != 0) {
+				OS.gtk_drag_dest_unset(entryHandle);
+			}
+		}
+	} 
+	OS.gtk_drag_dest_set(control.handle, 0, pTargets, targets.length, actions);
+	
+	for (int i = 0; i < targets.length; i++) {
+		OS.g_free(targets[i].target);
+	}
+}
+
+/**
+ * Specifies the drop effect for this DropTarget.  This drop effect will be 
+ * used during a drag and drop to display the drag under effect on the 
+ * target widget.
+ *
+ * @param effect the drop effect that is registered for this DropTarget
+ * 
+ * @since 3.3
+ */
+public void setDropTargetEffect(DropTargetEffect effect) {
+	dropEffect = effect;
+}
+
+boolean setEventData(int /*long*/ context, int x, int y, int time, DNDEvent event) {
+	if (context == 0) return false;
+	GdkDragContext dragContext = new GdkDragContext();
+	OS.memmove(dragContext, context, GdkDragContext.sizeof);
+	if (dragContext.targets == 0) return false;
+	
+	// get allowed operations
+	int style = getStyle();
+	int operations = osOpToOp(dragContext.actions) & style;
+	if (operations == DND.DROP_NONE) return false;
+	
+	// get current operation
+	int operation = getOperationFromKeyState();
+	keyOperation = operation;
+	if (operation == DND.DROP_DEFAULT) {
+		if ((style & DND.DROP_DEFAULT) == 0) {
+			operation = (operations & DND.DROP_MOVE) != 0 ? DND.DROP_MOVE : DND.DROP_NONE;
+		}
+	} else {
+		if ((operation & operations) == 0) operation = DND.DROP_NONE;
+	}
+
+	// Get allowed transfer types
+	int length = OS.g_list_length(dragContext.targets);
+	TransferData[] dataTypes = new TransferData[0];
+	for (int i = 0; i < length; i++) {
+		int /*long*/ pData = OS.g_list_nth(dragContext.targets, i);
+		GtkTargetPair gtkTargetPair = new GtkTargetPair();
+		OS.memmove(gtkTargetPair, pData, GtkTargetPair.sizeof);
+		TransferData data = new TransferData();
+		data.type = gtkTargetPair.target;
+		for (int j = 0; j < transferAgents.length; j++) {
+			Transfer transfer = transferAgents[j];
+			if (transfer != null && transfer.isSupportedType(data)) {
+				TransferData[] newDataTypes = new TransferData[dataTypes.length + 1];
+				System.arraycopy(dataTypes, 0, newDataTypes, 0, dataTypes.length);
+				newDataTypes[dataTypes.length] = data;
+				dataTypes = newDataTypes;	
+				break;
+			}
+		}
+	}
+	if (dataTypes.length == 0) return false;
+
+	int /*long*/ window = OS.GTK_WIDGET_WINDOW(control.handle);
+	int [] origin_x = new int[1], origin_y = new int[1];
+	OS.gdk_window_get_origin(window, origin_x, origin_y);
+	Point coordinates = new Point(origin_x[0] + x, origin_y[0] + y);
+	
+	event.widget = this;
+	event.x = coordinates.x;
+	event.y = coordinates.y;
+	event.time = time;
+	event.feedback = DND.FEEDBACK_SELECT;
+	event.dataTypes = dataTypes;
+	event.dataType = dataTypes[0];
+	event.operations = operations;
+	event.detail = operation;
+	if (dropEffect != null) {
+		event.item = dropEffect.getItem(coordinates.x, coordinates.y);
+	}
+	return true;
+}
+
+void updateDragOverHover(long delay, DNDEvent event) {
+	if (delay == 0) {
+		dragOverStart = 0;
+		dragOverEvent = null;
+		return;
+	}
+	dragOverStart = System.currentTimeMillis() + delay;
+	if (dragOverEvent == null) dragOverEvent = new DNDEvent();
+	dragOverEvent.x = event.x;
+	dragOverEvent.y = event.y;
+	TransferData[] dataTypes = new TransferData[ event.dataTypes.length];
+	System.arraycopy( event.dataTypes, 0, dataTypes, 0, dataTypes.length);
+	dragOverEvent.dataTypes  = dataTypes;
+	dragOverEvent.operations = event.operations;
+	dragOverEvent.time = event.time;
+}
+
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/DropTargetAdapter.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/DropTargetAdapter.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/DropTargetAdapter.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,85 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.dnd;
+
+
+/**
+ * This adapter class provides default implementations for the
+ * methods described by the <code>DropTargetListener</code> interface.
+ * <p>
+ * Classes that wish to deal with <code>DropTargetEvent</code>s can
+ * extend this class and override only the methods which they are
+ * interested in.
+ * </p>
+ *
+ * @see DropTargetListener
+ * @see DropTargetEvent
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public class DropTargetAdapter implements DropTargetListener {
+
+/**
+ * This implementation of <code>dragEnter</code> permits the default 
+ * operation defined in <code>event.detail</code>to be performed on the current data type
+ * defined in <code>event.currentDataType</code>.
+ * For additional information see <code>DropTargetListener.dragEnter</code>.
+ * 
+ * @param event the information associated with the drag enter event
+ */
+public void dragEnter(DropTargetEvent event){}
+
+/**
+ * This implementation of <code>dragLeave</code> does nothing.
+ * For additional information see <code>DropTargetListener.dragOperationChanged</code>.
+ * 
+ * @param event the information associated with the drag leave event
+ */
+public void dragLeave(DropTargetEvent event){}
+
+/**
+ * This implementation of <code>dragOperationChanged</code> permits the default 
+ * operation defined in <code>event.detail</code>to be performed on the current data type
+ * defined in <code>event.currentDataType</code>.
+ * For additional information see <code>DropTargetListener.dragOperationChanged</code>.
+ * 
+ * @param event the information associated with the drag operation changed event
+ */
+public void dragOperationChanged(DropTargetEvent event){}
+
+/**
+ * This implementation of <code>dragOver</code> permits the default 
+ * operation defined in <code>event.detail</code>to be performed on the current data type
+ * defined in <code>event.currentDataType</code>.
+ * For additional information see <code>DropTargetListener.dragOver</code>.
+ * 
+ * @param event the information associated with the drag over event
+ */
+public void dragOver(DropTargetEvent event){}
+
+/**
+ * This implementation of <code>drop</code> does nothing.
+ * For additional information see <code>DropTargetListener.drop</code>.
+ * 
+ * @param event the information associated with the drop event
+ */
+public void drop(DropTargetEvent event){}
+
+/**
+ * This implementation of <code>dropAccept</code> permits the default 
+ * operation defined in <code>event.detail</code>to be performed on the current data type
+ * defined in <code>event.currentDataType</code>.
+ * For additional information see <code>DropTargetListener.dropAccept</code>.
+ * 
+ * @param event the information associated with the drop accept event
+ */
+public void dropAccept(DropTargetEvent event){}
+
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/DropTargetEffect.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/DropTargetEffect.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/DropTargetEffect.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,170 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.dnd;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+
+
+/**
+ * This class provides a default drag under effect during a drag and drop. 
+ * The current implementation does not provide any visual feedback.
+ * 
+ * <p>The drop target effect has the same API as the 
+ * <code>DropTargetAdapter</code> so that it can provide custom visual 
+ * feedback when a <code>DropTargetEvent</code> occurs. 
+ * </p>
+ * 
+ * <p>Classes that wish to provide their own drag under effect
+ * can extend the <code>DropTargetEffect</code> and override any applicable methods 
+ * in <code>DropTargetAdapter</code> to display their own drag under effect.</p>
+ *
+ * <p>The feedback value is either one of the FEEDBACK constants defined in 
+ * class <code>DND</code> which is applicable to instances of this class, 
+ * or it must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>DND</code> effect constants. 
+ * </p>
+ * <p>
+ * <dl>
+ * <dt><b>Feedback:</b></dt>
+ * <dd>FEEDBACK_EXPAND, FEEDBACK_INSERT_AFTER, FEEDBACK_INSERT_BEFORE, 
+ * FEEDBACK_NONE, FEEDBACK_SELECT, FEEDBACK_SCROLL</dd>
+ * </dl>
+ * </p>
+ * 
+ * @see DropTargetAdapter
+ * @see DropTargetEvent
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ * 
+ * @since 3.3
+ */
+public class DropTargetEffect extends DropTargetAdapter {
+	Control control;
+
+	/**
+	 * Creates a new <code>DropTargetEffect</code> to handle the drag under effect on the specified 
+	 * <code>Control</code>.
+	 * 
+	 * @param control the <code>Control</code> over which the user positions the cursor to drop the data
+	 * 
+	 * @exception IllegalArgumentException <ul>
+	 *    <li>ERROR_NULL_ARGUMENT - if the control is null</li>
+	 * </ul>
+	 */
+	public DropTargetEffect(Control control) {
+		if (control == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+		this.control = control;
+	}
+
+	/**
+	 * Returns the Control which is registered for this DropTargetEffect.  This is the control over which the 
+	 * user positions the cursor to drop the data.
+	 *
+	 * @return the Control which is registered for this DropTargetEffect
+	 */
+	public Control getControl() {
+		return control;
+	}
+	
+	/**
+	 * Returns the item at the given x-y coordinate in the receiver
+	 * or null if no such item exists. The x-y coordinate is in the
+	 * display relative coordinates.
+	 *
+	 * @param x the x coordinate used to locate the item
+	 * @param y the y coordinate used to locate the item
+	 * @return the item at the given x-y coordinate, or null if the coordinate is not in a selectable item
+	 */
+	public Widget getItem(int x, int y) {
+		if (control instanceof Table) {
+			return getItem((Table) control, x, y);
+		}
+		if (control instanceof Tree) {
+			return getItem((Tree) control, x, y);
+		}			
+		return null;
+	}
+	
+	Widget getItem(Table table, int x, int y) {
+		Point coordinates = new Point(x, y);
+		coordinates = table.toControl(coordinates);
+		TableItem item = table.getItem(coordinates);
+		if (item != null) return item;
+		Rectangle area = table.getClientArea();
+		int tableBottom = area.y + area.height;
+		int itemCount = table.getItemCount();
+		for (int i=table.getTopIndex(); i<itemCount; i++) {
+			item = table.getItem(i);
+			Rectangle rect = item.getBounds();
+			rect.x = area.x;
+			rect.width = area.width;
+			if (rect.contains(coordinates)) return item;
+			if (rect.y > tableBottom) break;
+		}
+		return null;
+	}
+	
+	Widget getItem(Tree tree, int x, int y) {
+		Point point = new Point(x, y);
+		point = tree.toControl(point);
+		TreeItem item = tree.getItem(point);
+		if (item == null) {
+			Rectangle area = tree.getClientArea();
+			if (area.contains(point)) {
+				int treeBottom = area.y + area.height;
+				item = tree.getTopItem();
+				while (item != null) {
+					Rectangle rect = item.getBounds();
+					int itemBottom = rect.y + rect.height;
+					if (rect.y <= point.y && point.y < itemBottom) return item;
+					if (itemBottom > treeBottom) break;
+					item = nextItem(tree, item);
+				}
+				return null;
+			}
+		}
+		return item;
+	}
+	
+	TreeItem nextItem(Tree tree, TreeItem item) {
+		if (item == null) return null;
+		if (item.getExpanded() && item.getItemCount() > 0) return item.getItem(0);
+		TreeItem childItem = item;
+		TreeItem parentItem = childItem.getParentItem();
+		int index = parentItem == null ? tree.indexOf(childItem) : parentItem.indexOf(childItem);
+		int count = parentItem == null ? tree.getItemCount() : parentItem.getItemCount();
+		while (true) {
+			if (index + 1 < count) return parentItem == null ? tree.getItem(index + 1) : parentItem.getItem(index + 1);
+			if (parentItem == null) return null;
+			childItem = parentItem;
+			parentItem = childItem.getParentItem();
+			index = parentItem == null ? tree.indexOf(childItem) : parentItem.indexOf(childItem);
+			count = parentItem == null ? tree.getItemCount() : parentItem.getItemCount();
+		}
+	}
+	
+	TreeItem previousItem(Tree tree, TreeItem item) {
+		if (item == null) return null;
+		TreeItem childItem = item;
+		TreeItem parentItem = childItem.getParentItem();
+		int index = parentItem == null ? tree.indexOf(childItem) : parentItem.indexOf(childItem);
+		if (index == 0) return parentItem;
+		TreeItem nextItem = parentItem == null ? tree.getItem(index-1) : parentItem.getItem(index-1);
+		int count = nextItem.getItemCount();
+		while (count > 0 && nextItem.getExpanded()) {
+			nextItem = nextItem.getItem(count - 1);
+			count = nextItem.getItemCount();
+		}
+		return nextItem;
+	}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/DropTargetEvent.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/DropTargetEvent.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/DropTargetEvent.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,117 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.dnd;
+
+import org.eclipse.swt.events.TypedEvent;
+import org.eclipse.swt.widgets.Widget;
+
+/**
+ * The DropTargetEvent contains the event information passed in the methods of the DropTargetListener.
+ *
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public class DropTargetEvent extends TypedEvent {
+	/**
+	 * The x-cordinate of the cursor relative to the <code>Display</code>
+	 */
+	public int x;
+	
+	/**
+	 * The y-cordinate of the cursor relative to the <code>Display</code>
+	 */
+	public int y;
+	
+	/**
+	 * The operation being performed.
+	 * @see DND#DROP_NONE
+	 * @see DND#DROP_MOVE
+	 * @see DND#DROP_COPY
+	 * @see DND#DROP_LINK
+	 */
+	public int detail;
+	
+	/**
+	 * A bitwise OR'ing of the operations that the DragSource can support 
+	 * (e.g. DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK).
+	 * The detail value must be a member of this list or DND.DROP_NONE.
+	 * @see DND#DROP_NONE
+	 * @see DND#DROP_MOVE
+	 * @see DND#DROP_COPY
+	 * @see DND#DROP_LINK
+	 */
+	public int operations;
+	
+	/**
+	 * A bitwise OR'ing of the drag under effect feedback to be displayed to the user
+	 * (e.g. DND.FEEDBACK_SELECT | DND.FEEDBACK_SCROLL | DND.FEEDBACK_EXPAND).
+	 * <p>A value of DND.FEEDBACK_NONE indicates that no drag under effect will be displayed.</p>
+	 * <p>Feedback effects will only be applied if they are applicable.</p>
+	 * <p>The default value is DND.FEEDBACK_SELECT.</p>
+	 * @see DND#FEEDBACK_NONE
+	 * @see DND#FEEDBACK_SELECT
+	 * @see DND#FEEDBACK_INSERT_BEFORE
+	 * @see DND#FEEDBACK_INSERT_AFTER
+	 * @see DND#FEEDBACK_SCROLL
+	 * @see DND#FEEDBACK_EXPAND
+	 */
+	public int feedback;
+	
+	/**
+	 * If the associated control is a table or tree, this field contains the item located 
+	 * at the cursor coordinates.
+	 */
+	public Widget item;
+	
+	/**
+	 * The type of data that will be dropped.
+	 */
+	public TransferData currentDataType;
+	
+	/**
+	 * A list of the types of data that the DragSource is capable of providing.
+	 * The currentDataType must be a member of this list.
+	 */
+	public TransferData[] dataTypes;
+
+	static final long serialVersionUID = 3256727264573338678L;
+	
+/**
+ * Constructs a new instance of this class based on the
+ * information in the given untyped event.
+ *
+ * @param e the untyped event containing the information
+ */
+public DropTargetEvent(DNDEvent e) {
+	super(e);
+	this.data = e.data;
+	this.x = e.x;
+	this.y = e.y;
+	this.detail = e.detail;
+	this.currentDataType = e.dataType;
+	this.dataTypes = e.dataTypes;
+	this.operations = e.operations;
+	this.feedback = e.feedback;
+	this.item = e.item;
+}
+void updateEvent(DNDEvent e) {
+	e.widget = this.widget;
+	e.time = this.time;
+	e.data = this.data;
+	e.x = this.x;
+	e.y = this.y;
+	e.detail = this.detail;
+	e.dataType = this.currentDataType;
+	e.dataTypes = this.dataTypes;
+	e.operations = this.operations;
+	e.feedback = this.feedback;
+	e.item = this.item;
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/DropTargetListener.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/DropTargetListener.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/DropTargetListener.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,250 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.dnd;
+
+import org.eclipse.swt.internal.SWTEventListener;
+
+/**
+ * The <code>DropTargetListener</code> class provides event notification to the application 
+ * for DropTarget events.
+ *
+ * <p>As the user moves the cursor into, over and out of a Control that has been designated 
+ * as a DropTarget, events indicate what operation can be performed and what data can be 
+ * transferred if a drop where to occur at that point.
+ * The application can respond to these events and change the type of data that will 
+ * be dropped by modifying event.currentDataType, or change the operation that will be performed 
+ * by modifying the event.detail field or stop any drop from happening on the current target
+ * by setting the event.detail field to DND_DROP_NONE.</p>
+ *
+ * <p>When the user causes a drop to happen by releasing the mouse over a valid drop target, 
+ * the application has one last chance to change the data type of the drop through the 
+ * DropAccept event.  If the drop is still allowed, the DropAccept event is immediately 
+ * followed by the Drop event.  In the Drop event, the application can still change the
+ * operation that is performed but the data type is fixed.</p>
+ * 
+ * @see DropTargetEvent
+ *
+ */
+public interface DropTargetListener extends SWTEventListener {
+	
+/**
+ * The cursor has entered the drop target boundaries.
+ *
+ * <p>The following fields in the DropTargetEvent apply:
+ * <ul>
+ * <li>(in)widget
+ * <li>(in)time
+ * <li>(in)x
+ * <li>(in)y
+ * <li>(in)dataTypes
+ * <li>(in,out)currentDataType
+ * <li>(in)operations
+ * <li>(in,out)detail
+ * <li>(in,out)feedback
+ * </ul></p>
+ *
+ * <p>The <code>operation</code> value is determined by the modifier keys pressed by the user.  
+ * If no keys are pressed the <code>event.detail</code> field is set to DND.DROP_DEFAULT.  
+ * If the application does not set the <code>event.detail</code> to something other 
+ * than <code>DND.DROP_DEFAULT</code> the operation will be set to the platform defined standard 
+ * default.</p>
+ * 
+ * <p>The <code>currentDataType</code> is determined by the first transfer agent specified in 
+ * setTransfer() that matches a data type provided by the drag source.</p>
+ * 
+ * <p>It is possible to get a DragEnter event when the drag source does not provide any matching data.
+ * In this case, the default operation is DND.DROP_NONE and the currentDataType is null.</p>
+ * 
+ * <p>The application can change the operation that will be performed by modifying the 
+ * <code>detail</code> field but the choice must be one of the values in the <code>operations</code> 
+ * field or DND.DROP_NONE.</p>
+ * 
+ * <p>The application can also change the type of data being requested by 
+ * modifying the <code>currentDataTypes</code> field  but the value must be one of the values 
+ * in the <code>dataTypes</code> list.</p>
+ *
+ * @param event  the information associated with the drag enter event
+ * 
+ * @see DropTargetEvent
+ */
+public void dragEnter(DropTargetEvent event);
+
+/**
+ * The cursor has left the drop target boundaries OR the drop has been cancelled OR the data 
+ * is about to be dropped.
+ *
+ * <p>The following fields in the DropTargetEvent apply:
+ * <ul>
+ * <li>(in)widget
+ * <li>(in)time
+ * <li>(in)x
+ * <li>(in)y
+ * <li>(in)dataTypes
+ * <li>(in)currentDataType
+ * <li>(in)operations
+ * <li>(in)detail
+ * </ul></p>
+ *
+ * @param event  the information associated with the drag leave event
+ *
+ * @see DropTargetEvent
+ */
+public void dragLeave(DropTargetEvent event);
+
+/**
+ * The operation being performed has changed (usually due to the user changing the selected modifier key(s)
+ * while dragging).
+ *
+ * <p>The following fields in the DropTargetEvent apply:
+ * <ul>
+ * <li>(in)widget
+ * <li>(in)time
+ * <li>(in)x
+ * <li>(in)y
+ * <li>(in)dataTypes
+ * <li>(in,out)currentDataType
+ * <li>(in)operations
+ * <li>(in,out)detail
+ * <li>(in,out)feedback
+ * </ul></p>
+ *
+ * <p>The <code>operation</code> value is determined by the modifier keys pressed by the user.  
+ * If no keys are pressed the <code>event.detail</code> field is set to DND.DROP_DEFAULT.  
+ * If the application does not set the <code>event.detail</code> to something other than 
+ * <code>DND.DROP_DEFAULT</code> the operation will be set to the platform defined standard default.</p>
+ * 
+ * <p>The <code>currentDataType</code> value is determined by the value assigned to 
+ * <code>currentDataType</code> in previous dragEnter and dragOver calls.</p>
+ * 
+ * <p>The application can change the operation that will be performed by modifying the 
+ * <code>detail</code> field but the choice must be one of the values in the <code>operations</code> 
+ * field.</p>
+ * 
+ * <p>The application can also change the type of data being requested by modifying 
+ * the <code>currentDataTypes</code> field  but the value must be one of the values in the 
+ * <code>dataTypes</code> list.</p>
+ *
+ * @param event  the information associated with the drag operation changed event
+ * 
+ * @see DropTargetEvent
+ */
+public void dragOperationChanged(DropTargetEvent event);
+
+/**
+ * The cursor is moving over the drop target.
+ *
+ * <p>The following fields in the DropTargetEvent apply:
+ * <ul>
+ * <li>(in)widget
+ * <li>(in)time
+ * <li>(in)x
+ * <li>(in)y
+ * <li>(in)dataTypes
+ * <li>(in,out)currentDataType
+ * <li>(in)operations
+ * <li>(in,out)detail
+ * <li>(in,out)feedback
+ * </ul></p>
+ *
+ * <p>The <code>operation</code> value is determined by the value assigned to 
+ * <code>currentDataType</code> in previous dragEnter and dragOver calls.</p>
+ * 
+ * <p>The <code>currentDataType</code> value is determined by the value assigned to 
+ * <code>currentDataType</code> in previous dragEnter and dragOver calls.</p>
+ * 
+ * <p>The application can change the operation that will be performed by modifying the 
+ * <code>detail</code> field but the choice must be one of the values in the <code>operations</code> 
+ * field.</p>
+ * 
+ * <p>The application can also change the type of data being requested by modifying the 
+ * <code>currentDataTypes</code> field  but the value must be one of the values in the 
+ * <code>dataTypes</code> list.</p>
+ * 
+ * <p>NOTE: At this point the <code>data</code> field is null.  On some platforms, it is possible 
+ * to obtain the data being transferred before the transfer occurs but in most platforms this is 
+ * not possible.  On those platforms where the data is available, the application can access the 
+ * data as follows:</p>
+ * 
+ * <pre><code>
+ * public void dragOver(DropTargetEvent event) {
+ *       TextTransfer textTransfer = TextTransfer.getInstance();
+ *       String data = (String)textTransfer.nativeToJava(event.currentDataType);
+ *       if (data != null) {
+ *           System.out.println("Data to be dropped is (Text)"+data);
+ *       }
+ * };
+ * </code></pre>
+ *
+ * @param event  the information associated with the drag over event
+ * 
+ * @see DropTargetEvent
+ */
+public void dragOver(DropTargetEvent event);
+
+/**
+ * The data is being dropped.  The data field contains java format of the data being dropped.  
+ * To determine the type of the data object, refer to the documentation for the Transfer subclass 
+ * specified in event.currentDataType.
+ *
+ * <p>The following fields in DropTargetEvent apply:
+ * <ul>
+ * <li>(in)widget
+ * <li>(in)time
+ * <li>(in)x 
+ * <li>(in)y
+ * <li>(in,out)detail
+ * <li>(in)currentDataType
+ * <li>(in)data
+ * </ul></p>
+ *
+ * <p>The application can refuse to perform the drop operation by setting the detail 
+ * field to DND.DROP_NONE.</p>
+ *
+ * @param event the information associated with the drop event
+ * 
+ * @see DropTargetEvent
+ */
+public void drop(DropTargetEvent event);
+
+/**
+ * The drop is about to be performed.  
+ * The drop target is given a last chance to change the nature of the drop.
+ * 
+ * <p>The following fields in the DropTargetEvent apply:
+ * <ul>
+ * <li>(in)widget
+ * <li>(in)time
+ * <li>(in)x
+ * <li>(in)y
+ * <li>(in)dataTypes
+ * <li>(in,out)currentDataType
+ * <li>(in)operations
+ * <li>(in,out)detail
+ * </ul></p>
+ *
+ * <p>The application can veto the drop by setting the <code>event.detail</code> field to 
+ * <code>DND.DROP_NONE</code>.</p>
+ *
+ * <p>The application can change the operation that will be performed by modifying the 
+ * <code>detail</code> field but the choice must be one of the values in the 
+ * <code>operations</code> field.</p>
+ * 
+ * <p>The application can also change the type of data being requested by modifying the 
+ * <code>currentDataTypes</code> field  but the value must be one of the values in the <
+ * code>dataTypes</code> list.</p>
+ *
+ * @param event  the information associated with the drop accept event
+ * 
+ * @see DropTargetEvent
+ */
+public void dropAccept(DropTargetEvent event);
+
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/FileTransfer.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/FileTransfer.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/FileTransfer.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,202 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.dnd;
+
+import org.eclipse.swt.internal.gtk.*;
+
+/**
+ * The class <code>FileTransfer</code> provides a platform specific mechanism 
+ * for converting a list of files represented as a java <code>String[]</code> to a 
+ * platform specific representation of the data and vice versa.  
+ * Each <code>String</code> in the array contains the absolute path for a single 
+ * file or directory.
+ * 
+ * <p>An example of a java <code>String[]</code> containing a list of files is shown 
+ * below:</p>
+ * 
+ * <code><pre>
+ *     File file1 = new File("C:\temp\file1");
+ *     File file2 = new File("C:\temp\file2");
+ *     String[] fileData = new String[2];
+ *     fileData[0] = file1.getAbsolutePath();
+ *     fileData[1] = file2.getAbsolutePath();
+ * </code></pre>
+ *
+ * @see Transfer
+ */
+public class FileTransfer extends ByteArrayTransfer {
+	
+	private static FileTransfer _instance = new FileTransfer();
+	private static final String URI_LIST = "text/uri-list"; //$NON-NLS-1$
+	private static final int URI_LIST_ID = registerType(URI_LIST);
+	private static final byte[] separator = new byte[]{'\r', '\n'};
+	
+private FileTransfer() {}
+
+/**
+ * Returns the singleton instance of the FileTransfer class.
+ *
+ * @return the singleton instance of the FileTransfer class
+ */
+public static FileTransfer getInstance () {
+	return _instance;
+}
+
+/**
+ * This implementation of <code>javaToNative</code> converts a list of file names
+ * represented by a java <code>String[]</code> to a platform specific representation.
+ * Each <code>String</code> in the array contains the absolute path for a single 
+ * file or directory.
+ * 
+ * @param object a java <code>String[]</code> containing the file names to be converted
+ * @param transferData an empty <code>TransferData</code> object that will
+ *  	be filled in on return with the platform specific format of the data
+ * 
+ * @see Transfer#nativeToJava
+ */
+public void javaToNative(Object object, TransferData transferData) {
+	transferData.result = 0;
+	if (!checkFile(object) || !isSupportedType(transferData)) {
+		DND.error(DND.ERROR_INVALID_DATA);
+	}
+	String[] files = (String[])object;
+	byte[] buffer = new byte[0];
+	for (int i = 0; i < files.length; i++) {
+		String string = files[i];
+		if (string == null) continue;
+		int length = string.length();
+		if (length == 0) continue;
+		char[] chars = new char[length];
+		string.getChars(0, length, chars, 0);		
+		int /*long*/[] error = new int /*long*/[1];
+		int /*long*/ utf8Ptr = OS.g_utf16_to_utf8(chars, chars.length, null, null, error);
+		if (error[0] != 0 || utf8Ptr == 0) continue;
+		int /*long*/ localePtr = OS.g_filename_from_utf8(utf8Ptr, -1, null, null, error);
+		OS.g_free(utf8Ptr);
+		if (error[0] != 0 || localePtr == 0) continue;
+		int /*long*/ uriPtr = OS.g_filename_to_uri(localePtr, 0, error);
+		OS.g_free(localePtr);
+		if (error[0] != 0 || uriPtr == 0) continue;
+		length = OS.strlen(uriPtr);
+		byte[] temp = new byte[length];
+		OS.memmove (temp, uriPtr, length);
+		OS.g_free(uriPtr);
+		int newLength = (i > 0) ? buffer.length+separator.length+temp.length :  temp.length;
+		byte[] newBuffer = new byte[newLength];
+		int offset = 0;
+		if (i > 0) {
+			System.arraycopy(buffer, 0, newBuffer, 0, buffer.length);
+			offset +=  buffer.length;
+			System.arraycopy(separator, 0, newBuffer, offset, separator.length);
+			offset += separator.length;
+		}
+		System.arraycopy(temp, 0, newBuffer, offset, temp.length);
+		buffer = newBuffer;
+	}
+	if (buffer.length == 0) return;
+	int /*long*/ ptr = OS.g_malloc(buffer.length+1);
+	OS.memset(ptr, '\0', buffer.length+1);
+	OS.memmove(ptr, buffer, buffer.length);
+	transferData.pValue = ptr;
+	transferData.length = buffer.length;
+	transferData.format = 8;
+	transferData.result = 1;
+}
+/**
+ * This implementation of <code>nativeToJava</code> converts a platform specific 
+ * representation of a list of file names to a java <code>String[]</code>.  
+ * Each String in the array contains the absolute path for a single file or directory. 
+ * 
+ * @param transferData the platform specific representation of the data to be converted
+ * @return a java <code>String[]</code> containing a list of file names if the conversion
+ * 		was successful; otherwise null
+ * 
+ * @see Transfer#javaToNative
+ */
+public Object nativeToJava(TransferData transferData) {
+	if ( !isSupportedType(transferData) ||  transferData.pValue == 0 ||  transferData.length <= 0 ) return null;
+	int length = transferData.length;
+	byte[] temp = new byte[length];
+	OS.memmove(temp, transferData.pValue, length);
+	int /*long*/[] files = new int /*long*/[0];
+	int offset = 0;
+	for (int i = 0; i < temp.length - 1; i++) {
+		if (temp[i] == '\r' && temp[i+1] == '\n') {
+			int size =  i - offset;
+			int /*long*/ file = OS.g_malloc(size + 1);
+			byte[] fileBuffer = new byte[size + 1];
+			System.arraycopy(temp, offset, fileBuffer, 0, size);
+			OS.memmove(file, fileBuffer, size + 1);
+			int /*long*/[] newFiles = new int /*long*/[files.length + 1];
+			System.arraycopy(files, 0, newFiles, 0, files.length);
+			newFiles[files.length] = file;
+			files = newFiles;
+			offset = i + 2;
+		}
+	}
+	if (offset < temp.length - 2) {
+		int size =  temp.length - offset;
+		int /*long*/ file = OS.g_malloc(size + 1);
+		byte[] fileBuffer = new byte[size + 1];
+		System.arraycopy(temp, offset, fileBuffer, 0, size);
+		OS.memmove(file, fileBuffer, size + 1);
+		int /*long*/[] newFiles = new int /*long*/[files.length + 1];
+		System.arraycopy(files, 0, newFiles, 0, files.length);
+		newFiles[files.length] = file;
+		files = newFiles;
+	}
+	String[] fileNames = new String[0];
+	for (int i = 0; i < files.length; i++) {
+		int /*long*/[] error = new int /*long*/[1];
+		int /*long*/ localePtr = OS.g_filename_from_uri(files[i], null, error);
+		OS.g_free(files[i]);
+		if (error[0] != 0 || localePtr == 0) continue;
+		int /*long*/ utf8Ptr = OS.g_filename_to_utf8(localePtr, -1, null, null, error);
+		OS.g_free(localePtr);
+		if (error[0] != 0 || utf8Ptr == 0) continue;
+		int /*long*/[] items_written = new int /*long*/[1];
+		int /*long*/ utf16Ptr = OS.g_utf8_to_utf16(utf8Ptr, -1, null, items_written, null);
+		OS.g_free(utf8Ptr);
+		length = (int)/*64*/items_written[0];
+		char[] buffer = new char[length];
+		OS.memmove(buffer, utf16Ptr, length * 2);
+		OS.g_free(utf16Ptr);
+		String name = new String(buffer);
+		String[] newFileNames = new String[fileNames.length + 1];
+		System.arraycopy(fileNames, 0, newFileNames, 0, fileNames.length);
+		newFileNames[fileNames.length] = name;
+		fileNames = newFileNames;
+	}
+	if (fileNames.length == 0) return null;
+	return fileNames;
+}
+
+protected int[] getTypeIds(){
+	return new int[]{URI_LIST_ID};
+}
+
+protected String[] getTypeNames(){
+	return new String[]{URI_LIST};
+}
+
+boolean checkFile(Object object) {
+	if (object == null || !(object instanceof String[]) || ((String[])object).length == 0) return false;
+	String[] strings = (String[])object;
+	for (int i = 0; i < strings.length; i++) {
+		if (strings[i] == null || strings[i].length() == 0) return false;
+	}
+	return true;
+}
+
+protected boolean validate(Object object) {
+	return checkFile(object);
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/HTMLTransfer.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/HTMLTransfer.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/HTMLTransfer.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,113 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.dnd;
+
+import org.eclipse.swt.internal.gtk.*;
+ 
+/**
+ * The class <code>HTMLTransfer</code> provides a platform specific mechanism 
+ * for converting text in HTML format represented as a java <code>String</code> 
+ * to a platform specific representation of the data and vice versa.
+ * 
+ * <p>An example of a java <code>String</code> containing HTML text is shown 
+ * below:</p>
+ * 
+ * <code><pre>
+ *     String htmlData = "<p>This is a paragraph of text.</p>";
+ * </code></pre>
+ *
+ * @see Transfer
+ */
+public class HTMLTransfer extends ByteArrayTransfer {
+
+	private static HTMLTransfer _instance = new HTMLTransfer();
+	private static final String TEXT_HTML = "text/html"; //$NON-NLS-1$
+	private static final int TEXT_HTML_ID = registerType(TEXT_HTML);
+	private static final String TEXT_HTML2 = "TEXT/HTML"; //$NON-NLS-1$
+	private static final int TEXT_HTML2_ID = registerType(TEXT_HTML2);
+
+private HTMLTransfer() {}
+
+/**
+ * Returns the singleton instance of the HTMLTransfer class.
+ *
+ * @return the singleton instance of the HTMLTransfer class
+ */
+public static HTMLTransfer getInstance () {
+	return _instance;
+}
+
+/**
+ * This implementation of <code>javaToNative</code> converts HTML-formatted text
+ * represented by a java <code>String</code> to a platform specific representation.
+ * 
+ * @param object a java <code>String</code> containing HTML text
+ * @param transferData an empty <code>TransferData</code> object that will
+ *  	be filled in on return with the platform specific format of the data
+ * 
+ * @see Transfer#nativeToJava
+ */
+public void javaToNative (Object object, TransferData transferData){
+	transferData.result = 0;
+	if (!checkHTML(object) || !isSupportedType(transferData)) {
+		DND.error(DND.ERROR_INVALID_DATA);
+	}
+	String string = (String)object;
+	int charCount = string.length();
+	char [] chars = new char[charCount +1];
+	string.getChars(0, charCount , chars, 0);
+	int byteCount = chars.length*2;
+	int /*long*/ pValue = OS.g_malloc(byteCount);
+	if (pValue == 0) return;
+	OS.memmove(pValue, chars, byteCount);
+	transferData.length = byteCount;
+	transferData.format = 8;
+	transferData.pValue = pValue;
+	transferData.result = 1;
+}
+
+/**
+ * This implementation of <code>nativeToJava</code> converts a platform specific 
+ * representation of HTML text to a java <code>String</code>.
+ * 
+ * @param transferData the platform specific representation of the data to be converted
+ * @return a java <code>String</code> containing HTML text if the conversion was successful;
+ * 		otherwise null
+ * 
+ * @see Transfer#javaToNative
+ */
+public Object nativeToJava(TransferData transferData){
+	if ( !isSupportedType(transferData) ||  transferData.pValue == 0 ) return null;
+	/* Ensure byteCount is a multiple of 2 bytes */
+	int size = (transferData.format * transferData.length / 8) / 2 * 2;
+	if (size <= 0) return null;			
+	char[] chars = new char [size/2];
+	OS.memmove (chars, transferData.pValue, size);
+	String string = new String (chars);
+	int end = string.indexOf('\0');
+	return (end == -1) ? string : string.substring(0, end);
+}
+protected int[] getTypeIds() {
+	return new int[] {TEXT_HTML_ID, TEXT_HTML2_ID};
+}
+
+protected String[] getTypeNames() {
+	return new String[] {TEXT_HTML, TEXT_HTML2};
+}
+
+boolean checkHTML(Object object) {
+	return (object != null && object instanceof String && ((String)object).length() > 0);
+}
+
+protected boolean validate(Object object) {
+	return checkHTML(object);
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/ImageTransfer.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/ImageTransfer.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/ImageTransfer.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,174 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.dnd;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.Converter;
+import org.eclipse.swt.internal.gtk.*;
+import org.eclipse.swt.widgets.*;
+
+/**
+ * The class <code>ImageTransfer</code> provides a platform specific mechanism 
+ * for converting an Image represented as a java <code>ImageData</code> to a 
+ * platform specific representation of the data and vice versa.  
+ * 
+ * <p>An example of a java <code>ImageData</code> is shown below:</p>
+ * 
+ * <code><pre>
+ *     Image image = new Image(display, "C:\temp\img1.gif");
+ *	   ImageData imgData = image.getImageData();
+ * </code></pre>
+ *
+ * @see Transfer
+ * 
+ * @since 3.4
+ */
+public class ImageTransfer extends ByteArrayTransfer {
+	
+	private static ImageTransfer _instance = new ImageTransfer();
+	
+	private static final String JPEG = "image/jpge"; //$NON-NLS-1$
+	private static final int JPEG_ID = registerType(JPEG);
+	private static final String PNG = "image/png"; //$NON-NLS-1$
+	private static final int PNG_ID = registerType(PNG);
+	private static final String BMP = "image/bmp"; //$NON-NLS-1$
+	private static final int BMP_ID = registerType(BMP);
+	private static final String EPS = "image/eps"; //$NON-NLS-1$
+	private static final int EPS_ID = registerType(EPS);
+	private static final String PCX = "image/pcx"; //$NON-NLS-1$
+	private static final int PCX_ID = registerType(PCX);
+	private static final String PPM = "image/ppm"; //$NON-NLS-1$
+	private static final int PPM_ID = registerType(PPM);
+	private static final String RGB = "image/ppm"; //$NON-NLS-1$
+	private static final int RGB_ID = registerType(RGB);
+	private static final String TGA = "image/tga"; //$NON-NLS-1$
+	private static final int TGA_ID = registerType(TGA);
+	private static final String XBM = "image/xbm"; //$NON-NLS-1$
+	private static final int XBM_ID = registerType(XBM);
+	private static final String XPM = "image/xpm"; //$NON-NLS-1$
+	private static final int XPM_ID = registerType(XPM);
+	private static final String XV = "image/xv"; //$NON-NLS-1$
+	private static final int XV_ID = registerType(XV);	
+	
+private ImageTransfer() {}
+
+/**
+ * Returns the singleton instance of the ImageTransfer class.
+ *
+ * @return the singleton instance of the ImageTransfer class
+ */
+public static ImageTransfer getInstance () {
+	return _instance;
+}
+
+/**
+ * This implementation of <code>javaToNative</code> converts an ImageData object represented
+ * by java <code>ImageData</code> to a platform specific representation.
+ * 
+ * @param object a java <code>ImageData</code> containing the ImageData to be converted
+ * @param transferData an empty <code>TransferData</code> object that will
+ *  	be filled in on return with the platform specific format of the data
+ * 
+ * @see Transfer#nativeToJava
+ */
+public void javaToNative(Object object, TransferData transferData) {
+	if (!checkImage(object) || !isSupportedType(transferData)) {
+		DND.error(DND.ERROR_INVALID_DATA);
+	}
+	if (OS.GTK_VERSION < OS.VERSION (2, 4, 0)) return;
+	
+	ImageData imgData = (ImageData)object;
+	if (imgData == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	Image image = new Image(Display.getCurrent(), imgData);	
+	int /*long*/ pixmap = image.pixmap; 
+ 	int width = imgData.width;
+ 	int height = imgData.height;  	
+ 	int /*long*/ pixbuf = OS.gdk_pixbuf_new(OS.GDK_COLORSPACE_RGB, true, 8, width, height);
+	if (pixbuf == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+	int /*long*/ colormap = OS.gdk_colormap_get_system();
+	OS.gdk_pixbuf_get_from_drawable(pixbuf, pixmap, colormap, 0, 0, 0, 0, width, height);	
+	
+	String typeStr = "";
+	if (transferData.type ==  JPEG_ID) typeStr = "jpeg";
+	if (transferData.type ==  PNG_ID) typeStr = "png";
+	if (transferData.type ==  BMP_ID) typeStr = "bmp";
+	if (transferData.type ==  EPS_ID) typeStr = "eps";
+	if (transferData.type ==  PCX_ID) typeStr = "pcx";
+	if (transferData.type ==  PPM_ID) typeStr = "ppm";
+	if (transferData.type ==  RGB_ID) typeStr = "rgb";
+	if (transferData.type ==  TGA_ID) typeStr = "tga";
+	if (transferData.type ==  XBM_ID) typeStr = "xbm";
+	if (transferData.type ==  XPM_ID) typeStr = "xpm";
+	if (transferData.type ==  XV_ID) typeStr = "xv";
+	byte[] type = Converter.wcsToMbcs(null, typeStr , true);
+	int /*long*/ [] buffer = new int /*long*/ [1];
+	int [] len = new int [1];
+	if (type == null) return;
+	OS.gdk_pixbuf_save_to_buffer(pixbuf, buffer, len, type , null, null);		
+	OS.g_object_unref(pixbuf);
+	image.dispose();
+	transferData.pValue = buffer[0];
+	transferData.length = (len[0] + 3) / 4 * 4;
+	transferData.result = 1;
+	transferData.format = 32;
+}
+
+/**
+ * This implementation of <code>nativeToJava</code> converts a platform specific 
+ * representation of an image to java <code>ImageData</code>.  
+ * 
+ * @param transferData the platform specific representation of the data to be converted
+ * @return a java <code>ImageData</code> of the image if the conversion was successful;
+ * 		otherwise null
+ * 
+ * @see Transfer#javaToNative
+ */
+public Object nativeToJava(TransferData transferData) {
+	ImageData imgData = null;
+	if (transferData.length > 0)
+	{
+		int /*long*/ loader = OS.gdk_pixbuf_loader_new();
+		OS.gdk_pixbuf_loader_write(loader, transferData.pValue, transferData.length, null);
+		OS.gdk_pixbuf_loader_close(loader, null);
+		int /*long*/ pixbuf = OS.gdk_pixbuf_loader_get_pixbuf(loader);
+		if (pixbuf != 0) {
+			OS.g_object_ref(pixbuf);
+			int /*long*/ [] pixmap_return = new int /*long*/ [1];
+			OS.gdk_pixbuf_render_pixmap_and_mask(pixbuf, pixmap_return, null, 0);
+			int /*long*/ handle = pixmap_return[0];
+			if (handle == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+			OS.g_object_unref(loader);
+			Image img = Image.gtk_new(Display.getCurrent(), SWT.BITMAP, handle, 0);		
+			imgData = img.getImageData();
+			img.dispose();
+		}		
+	}
+	return imgData;
+}
+
+protected int[] getTypeIds(){
+	return new int[]{JPEG_ID, PNG_ID, BMP_ID, EPS_ID, PCX_ID, PPM_ID, RGB_ID, TGA_ID, XBM_ID, XPM_ID, XV_ID};	
+}
+
+protected String[] getTypeNames(){
+	return new String[]{JPEG, PNG, BMP, EPS, PCX, PPM, RGB, TGA, XBM, XPM, XV};
+}
+
+boolean checkImage(Object object) {
+	if (object == null || !(object instanceof ImageData)) return false;
+	return true;
+}
+
+protected boolean validate(Object object) {
+	return checkImage(object);
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/RTFTransfer.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/RTFTransfer.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/RTFTransfer.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,114 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.dnd;
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.gtk.*;
+ 
+/**
+ * The class <code>RTFTransfer</code> provides a platform specific mechanism 
+ * for converting text in RTF format represented as a java <code>String</code> 
+ * to a platform specific representation of the data and vice versa.
+ * 
+ * <p>An example of a java <code>String</code> containing RTF text is shown 
+ * below:</p>
+ * 
+ * <code><pre>
+ *     String rtfData = "{\\rtf1{\\colortbl;\\red255\\green0\\blue0;}\\uc1\\b\\i Hello World}";
+ * </code></pre>
+ *
+ * @see Transfer
+ */
+public class RTFTransfer extends ByteArrayTransfer {
+
+	private static RTFTransfer _instance = new RTFTransfer();
+	private static final String TEXT_RTF = "text/rtf"; //$NON-NLS-1$
+	private static final int TEXT_RTF_ID = registerType(TEXT_RTF);
+	private static final String TEXT_RTF2 = "TEXT/RTF"; //$NON-NLS-1$
+	private static final int TEXT_RTF2_ID = registerType(TEXT_RTF2);
+	private static final String APPLICATION_RTF = "application/rtf"; //$NON-NLS-1$
+	private static final int APPLICATION_RTF_ID = registerType(APPLICATION_RTF);
+
+private RTFTransfer() {}
+
+/**
+ * Returns the singleton instance of the RTFTransfer class.
+ *
+ * @return the singleton instance of the RTFTransfer class
+ */
+public static RTFTransfer getInstance () {
+	return _instance;
+}
+
+/**
+ * This implementation of <code>javaToNative</code> converts RTF-formatted text
+ * represented by a java <code>String</code> to a platform specific representation.
+ * 
+ * @param object a java <code>String</code> containing RTF text
+ * @param transferData an empty <code>TransferData</code> object that will
+ *  	be filled in on return with the platform specific format of the data
+ * 
+ * @see Transfer#nativeToJava
+ */
+public void javaToNative (Object object, TransferData transferData){
+	transferData.result = 0;
+	if (!checkRTF(object) || !isSupportedType(transferData)) {
+		DND.error(DND.ERROR_INVALID_DATA);
+	}
+	String string = (String)object;
+	byte [] buffer = Converter.wcsToMbcs (null, string, true);
+	int /*long*/ pValue = OS.g_malloc(buffer.length);
+	if (pValue == 0) return;
+	OS.memmove(pValue, buffer, buffer.length);
+	transferData.length = buffer.length - 1;
+	transferData.format = 8;
+	transferData.pValue = pValue;
+	transferData.result = 1;
+}
+
+/**
+ * This implementation of <code>nativeToJava</code> converts a platform specific 
+ * representation of RTF text to a java <code>String</code>.
+ * 
+ * @param transferData the platform specific representation of the data to be converted
+ * @return a java <code>String</code> containing RTF text if the conversion was successful;
+ * 		otherwise null
+ * 
+ * @see Transfer#javaToNative
+ */
+public Object nativeToJava(TransferData transferData){
+	if ( !isSupportedType(transferData) ||  transferData.pValue == 0 ) return null;
+	int size = transferData.format * transferData.length / 8;
+	if (size == 0) return null;
+	byte[] buffer = new byte[size];
+	OS.memmove(buffer, transferData.pValue, size);
+	char [] chars = Converter.mbcsToWcs (null, buffer);
+	String string = new String (chars);
+	int end = string.indexOf('\0');
+	return (end == -1) ? string : string.substring(0, end);
+}
+
+protected int[] getTypeIds() {
+	return new int[] {TEXT_RTF_ID, TEXT_RTF2_ID, APPLICATION_RTF_ID};
+}
+
+protected String[] getTypeNames() {
+	return new String[] {TEXT_RTF, TEXT_RTF2, APPLICATION_RTF};
+}
+
+boolean checkRTF(Object object) {
+	return (object != null && object instanceof String && ((String)object).length() > 0);
+}
+
+protected boolean validate(Object object) {
+	return checkRTF(object);
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/TableDragSourceEffect.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/TableDragSourceEffect.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/TableDragSourceEffect.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,142 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.dnd;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.gtk.*;
+import org.eclipse.swt.widgets.*;
+
+/**
+ * This class provides default implementations to display a source image
+ * when a drag is initiated from a <code>Table</code>.
+ * 
+ * <p>Classes that wish to provide their own source image for a <code>Table</code> can
+ * extend the <code>TableDragSourceEffect</code> class, override the 
+ * <code>TableDragSourceEffect.dragStart</code> method and set the field 
+ * <code>DragSourceEvent.image</code> with their own image.</p>
+ *
+ * Subclasses that override any methods of this class must call the corresponding
+ * <code>super</code> method to get the default drag source effect implementation.
+ *
+ * @see DragSourceEffect
+ * @see DragSourceEvent
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ * 
+ * @since 3.3
+ */
+public class TableDragSourceEffect extends DragSourceEffect {
+	Image dragSourceImage = null;
+
+	/**
+	 * Creates a new <code>TableDragSourceEffect</code> to handle drag effect 
+	 * from the specified <code>Table</code>.
+	 *
+	 * @param table the <code>Table</code> that the user clicks on to initiate the drag
+	 */
+	public TableDragSourceEffect(Table table) {
+		super(table);
+	}
+
+	/**
+	 * This implementation of <code>dragFinished</code> disposes the image
+	 * that was created in <code>TableDragSourceEffect.dragStart</code>.
+	 * 
+	 * Subclasses that override this method should call <code>super.dragFinished(event)</code>
+	 * to dispose the image in the default implementation.
+	 * 
+	 * @param event the information associated with the drag finished event
+	 */
+	public void dragFinished(DragSourceEvent event) {
+		if (dragSourceImage != null) dragSourceImage.dispose();
+		dragSourceImage = null;		
+	}
+
+	/**
+	 * This implementation of <code>dragStart</code> will create a default
+	 * image that will be used during the drag. The image should be disposed
+	 * when the drag is completed in the <code>TableDragSourceEffect.dragFinished</code>
+	 * method.
+	 * 
+	 * Subclasses that override this method should call <code>super.dragStart(event)</code>
+	 * to use the image from the default implementation.
+	 * 
+	 * @param event the information associated with the drag start event
+	 */
+	public void dragStart(DragSourceEvent event) {
+		event.image = getDragSourceImage(event);
+	}
+	
+	Image getDragSourceImage(DragSourceEvent event) {
+		if (dragSourceImage != null) dragSourceImage.dispose();
+		dragSourceImage = null;		
+		
+		Table table = (Table) control;
+		if (OS.GTK_VERSION < OS.VERSION (2, 2, 0)) return null;
+		//TEMPORARY CODE
+		if (table.isListening(SWT.EraseItem) || table.isListening (SWT.PaintItem)) return null;
+		/*
+		* Bug in GTK.  gtk_tree_selection_get_selected_rows() segmentation faults
+		* in versions smaller than 2.2.4 if the model is NULL.  The fix is
+		* to give a valid pointer instead.
+		*/
+		int /*long*/ handle = table.handle;
+		int /*long*/ selection = OS.gtk_tree_view_get_selection (handle);
+		int /*long*/ [] model = OS.GTK_VERSION < OS.VERSION (2, 2, 4) ? new int /*long*/ [1] : null;
+		int /*long*/ list = OS.gtk_tree_selection_get_selected_rows (selection, model);
+		if (list == 0) return null;
+		int count = Math.min(10, OS.g_list_length (list));
+
+		Display display = table.getDisplay();
+		if (count == 1) {
+			int /*long*/ path = OS.g_list_nth_data (list, 0);
+			int /*long*/ pixmap = OS.gtk_tree_view_create_row_drag_icon(handle, path);
+			dragSourceImage =  Image.gtk_new(display, SWT.ICON, pixmap, 0); 
+		} else {
+			int width = 0, height = 0;
+			int[] w = new int[1], h = new int[1];
+			int[] yy = new int[count], hh = new int[count];
+			int /*long*/ [] pixmaps = new int /*long*/ [count];
+			GdkRectangle rect = new GdkRectangle ();
+			for (int i=0; i<count; i++) {
+				int /*long*/ path = OS.g_list_nth_data (list, i);
+				OS.gtk_tree_view_get_cell_area (handle, path, 0, rect);
+				pixmaps[i] = OS.gtk_tree_view_create_row_drag_icon(handle, path);
+				OS.gdk_drawable_get_size(pixmaps[i], w, h);
+				width = Math.max(width, w[0]);
+				height = rect.y + h[0] - yy[0];
+				yy[i] = rect.y;
+				hh[i] = h[0];
+			}
+			int /*long*/ source = OS.gdk_pixmap_new(OS.GDK_ROOT_PARENT(), width, height, -1);
+			int /*long*/ gcSource = OS.gdk_gc_new(source);
+			int /*long*/ mask = OS.gdk_pixmap_new(OS.GDK_ROOT_PARENT(), width, height, 1);
+			int /*long*/ gcMask = OS.gdk_gc_new(mask);
+			GdkColor color = new GdkColor();
+			color.pixel = 0;
+			OS.gdk_gc_set_foreground(gcMask, color);
+			OS.gdk_draw_rectangle(mask, gcMask, 1, 0, 0, width, height);
+			color.pixel = 1;
+			OS.gdk_gc_set_foreground(gcMask, color);
+			for (int i=0; i<count; i++) {
+				OS.gdk_draw_drawable(source, gcSource, pixmaps[i], 0, 0, 0, yy[i] - yy[0], -1, -1);
+				OS.gdk_draw_rectangle(mask, gcMask, 1, 0, yy[i] - yy[0], width, hh[i]);
+				OS.g_object_unref(pixmaps[i]);
+			}
+			OS.g_object_unref(gcSource);
+			OS.g_object_unref(gcMask);
+			dragSourceImage  = Image.gtk_new(display, SWT.ICON, source, mask);
+		}
+		OS.g_list_free (list);
+		
+		return dragSourceImage;
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/TableDropTargetEffect.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/TableDropTargetEffect.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/TableDropTargetEffect.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,186 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.dnd;
+
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.gtk.*;
+import org.eclipse.swt.widgets.*;
+
+/**
+ * This class provides a default drag under effect (eg. select, insert and scroll) 
+ * when a drag occurs over a <code>Table</code>.
+ * 
+ * <p>Classes that wish to provide their own drag under effect for a <code>Table</code>
+ * can extend the <code>TableDropTargetEffect</code> and override any applicable methods 
+ * in <code>TableDropTargetEffect</code> to display their own drag under effect.</p>
+ * 
+ * Subclasses that override any methods of this class must call the corresponding
+ * <code>super</code> method to get the default drag under effect implementation.
+ *
+ * <p>The feedback value is either one of the FEEDBACK constants defined in 
+ * class <code>DND</code> which is applicable to instances of this class, 
+ * or it must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>DND</code> effect constants. 
+ * </p>
+ * <p>
+ * <dl>
+ * <dt><b>Feedback:</b></dt>
+ * <dd>FEEDBACK_SELECT, FEEDBACK_SCROLL</dd>
+ * </dl>
+ * </p>
+ * 
+ * @see DropTargetAdapter
+ * @see DropTargetEvent
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ * 
+ * @since 3.3
+ */
+public class TableDropTargetEffect extends DropTargetEffect {
+	static final int SCROLL_HYSTERESIS = 150; // milli seconds
+	
+	int scrollIndex;
+	long scrollBeginTime;
+
+	/**
+	 * Creates a new <code>TableDropTargetEffect</code> to handle the drag under effect on the specified 
+	 * <code>Table</code>.
+	 * 
+	 * @param table the <code>Table</code> over which the user positions the cursor to drop the data
+	 */
+	public TableDropTargetEffect(Table table) {
+		super(table);
+	}
+
+	int checkEffect(int effect) {
+		// Some effects are mutually exclusive.  Make sure that only one of the mutually exclusive effects has been specified.
+		if ((effect & DND.FEEDBACK_SELECT) != 0) effect = effect & ~DND.FEEDBACK_INSERT_AFTER & ~DND.FEEDBACK_INSERT_BEFORE;
+		if ((effect & DND.FEEDBACK_INSERT_BEFORE) != 0) effect = effect & ~DND.FEEDBACK_INSERT_AFTER;
+		return effect;
+	}
+
+	/**
+	 * This implementation of <code>dragEnter</code> provides a default drag under effect
+	 * for the feedback specified in <code>event.feedback</code>.
+	 * 
+	 * For additional information see <code>DropTargetAdapter.dragEnter</code>.
+	 * 
+	 * Subclasses that override this method should call <code>super.dragEnter(event)</code>
+	 * to get the default drag under effect implementation.
+	 *
+	 * @param event  the information associated with the drag enter event
+	 * 
+	 * @see DropTargetAdapter
+	 * @see DropTargetEvent
+	 */
+	public void dragEnter(DropTargetEvent event) {
+		scrollBeginTime = 0;
+		scrollIndex = -1;
+	}
+	
+	/**
+	 * This implementation of <code>dragLeave</code> provides a default drag under effect
+	 * for the feedback specified in <code>event.feedback</code>. 
+	 * 
+	 * For additional information see <code>DropTargetAdapter.dragLeave</code>.
+	 * 
+	 * Subclasses that override this method should call <code>super.dragLeave(event)</code>
+	 * to get the default drag under effect implementation.
+	 *
+	 * @param event  the information associated with the drag leave event
+	 * 
+	 * @see DropTargetAdapter
+	 * @see DropTargetEvent
+	 */
+	public void dragLeave(DropTargetEvent event) {
+		Table table = (Table) control;
+		int /*long*/ handle = table.handle;
+		OS.gtk_tree_view_set_drag_dest_row(handle, 0, OS.GTK_TREE_VIEW_DROP_BEFORE);
+
+		scrollBeginTime = 0;
+		scrollIndex = -1;
+	}
+
+	/**
+	 * This implementation of <code>dragOver</code> provides a default drag under effect
+	 * for the feedback specified in <code>event.feedback</code>. The class description 
+	 * lists the FEEDBACK constants that are applicable to the class.
+	 * 
+	 * For additional information see <code>DropTargetAdapter.dragOver</code>.
+	 * 
+	 * Subclasses that override this method should call <code>super.dragOver(event)</code>
+	 * to get the default drag under effect implementation.
+	 *
+	 * @param event  the information associated with the drag over event
+	 * 
+	 * @see DropTargetAdapter
+	 * @see DropTargetEvent
+	 * @see DND#FEEDBACK_SELECT
+	 * @see DND#FEEDBACK_SCROLL
+	 */
+	public void dragOver(DropTargetEvent event) {
+		Table table = (Table) control;
+		int /*long*/ handle = table.handle;
+		int effect = checkEffect(event.feedback);
+		Point coordinates = new Point(event.x, event.y);
+		coordinates = table.toControl(coordinates);
+		int /*long*/ [] path = new int /*long*/ [1];
+		OS.gtk_tree_view_get_path_at_pos (handle, coordinates.x, coordinates.y, path, null, null, null);
+		int index = -1;
+		if (path[0] != 0) {
+			int /*long*/ indices = OS.gtk_tree_path_get_indices (path[0]);
+			if (indices != 0) {
+				int[] temp = new int[1];
+				OS.memmove (temp, indices, 4);
+				index = temp[0];
+			}
+		}
+		if ((effect & DND.FEEDBACK_SCROLL) == 0) {
+			scrollBeginTime = 0;
+			scrollIndex = -1;
+		} else {
+			if (index != -1 && scrollIndex == index && scrollBeginTime != 0) {
+				if (System.currentTimeMillis() >= scrollBeginTime) {
+					if (coordinates.y < table.getItemHeight()) {
+						OS.gtk_tree_path_prev(path[0]);
+					} else {
+						OS.gtk_tree_path_next(path[0]);
+					}
+					if (path[0] != 0) {
+						OS.gtk_tree_view_scroll_to_cell(handle, path[0], 0, false, 0, 0);
+						OS.gtk_tree_path_free(path[0]);
+						path[0] = 0;
+						OS.gtk_tree_view_get_path_at_pos (handle, coordinates.x, coordinates.y, path, null, null, null);
+					}
+					scrollBeginTime = 0;
+					scrollIndex = -1;
+				}
+			} else {
+				scrollBeginTime = System.currentTimeMillis() + SCROLL_HYSTERESIS;
+				scrollIndex = index;
+			}
+		}
+		if (path[0] != 0) {
+			int position = 0;
+			if ((effect & DND.FEEDBACK_SELECT) != 0) position = OS.GTK_TREE_VIEW_DROP_INTO_OR_BEFORE;
+			//if ((effect & DND.FEEDBACK_INSERT_BEFORE) != 0) position = OS.GTK_TREE_VIEW_DROP_BEFORE;
+			//if ((effect & DND.FEEDBACK_INSERT_AFTER) != 0) position = OS.GTK_TREE_VIEW_DROP_AFTER;
+			if (position != 0) {
+				OS.gtk_tree_view_set_drag_dest_row(handle, path[0], OS.GTK_TREE_VIEW_DROP_INTO_OR_BEFORE);
+			} else {
+				OS.gtk_tree_view_set_drag_dest_row(handle, 0, OS.GTK_TREE_VIEW_DROP_BEFORE);
+			}
+		} else {
+			OS.gtk_tree_view_set_drag_dest_row(handle, 0, OS.GTK_TREE_VIEW_DROP_BEFORE);
+		}
+		if (path[0] != 0) OS.gtk_tree_path_free (path [0]);
+	}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/TextTransfer.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/TextTransfer.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/TextTransfer.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,144 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.dnd;
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.gtk.*;
+
+/**
+ * The class <code>TextTransfer</code> provides a platform specific mechanism 
+ * for converting plain text represented as a java <code>String</code> 
+ * to a platform specific representation of the data and vice versa.
+ * 
+ * <p>An example of a java <code>String</code> containing plain text is shown 
+ * below:</p>
+ * 
+ * <code><pre>
+ *     String textData = "Hello World";
+ * </code></pre>
+ * 
+ * @see Transfer
+ */
+public class TextTransfer extends ByteArrayTransfer {
+
+	private static TextTransfer _instance = new TextTransfer();
+	private static final String COMPOUND_TEXT = "COMPOUND_TEXT"; //$NON-NLS-1$
+	private static final String UTF8_STRING = "UTF8_STRING"; //$NON-NLS-1$
+	private static final String STRING = "STRING"; //$NON-NLS-1$
+	private static final int COMPOUND_TEXT_ID = registerType(COMPOUND_TEXT);
+	private static final int UTF8_STRING_ID = registerType(UTF8_STRING);
+	private static final int STRING_ID = registerType(STRING);
+
+private TextTransfer() {}
+
+/**
+ * Returns the singleton instance of the TextTransfer class.
+ *
+ * @return the singleton instance of the TextTransfer class
+ */
+public static TextTransfer getInstance () {
+	return _instance;
+}
+
+/**
+ * This implementation of <code>javaToNative</code> converts plain text
+ * represented by a java <code>String</code> to a platform specific representation.
+ * 
+ * @param object a java <code>String</code> containing text
+ * @param transferData an empty <code>TransferData</code> object that will
+ *  	be filled in on return with the platform specific format of the data
+ *  
+ * @see Transfer#nativeToJava
+ */
+public void javaToNative (Object object, TransferData transferData) {
+	transferData.result = 0;
+	if (!checkText(object) || !isSupportedType(transferData)) {
+		DND.error(DND.ERROR_INVALID_DATA);
+	}
+	String string = (String)object;
+	byte[] utf8 = Converter.wcsToMbcs (null, string, true);
+	if  (transferData.type ==  COMPOUND_TEXT_ID) {
+		int /*long*/[] encoding = new int /*long*/[1];
+		int[] format = new int[1];
+		int /*long*/[] ctext = new int /*long*/[1];
+		int[] length = new int[1];
+		boolean result = OS.gdk_utf8_to_compound_text(utf8, encoding, format, ctext, length);
+		if (!result) return;
+		transferData.type = encoding[0];
+		transferData.format = format[0];
+		transferData.length = length[0];
+		transferData.pValue = ctext[0];
+		transferData.result = 1;
+	} 
+	if (transferData.type == UTF8_STRING_ID) {
+		int /*long*/ pValue = OS.g_malloc(utf8.length);
+		if (pValue ==  0) return;
+		OS.memmove(pValue, utf8, utf8.length);
+		transferData.type = UTF8_STRING_ID;
+		transferData.format = 8;
+		transferData.length = utf8.length - 1;
+		transferData.pValue = pValue;
+		transferData.result = 1;
+	}
+	if (transferData.type == STRING_ID) {
+		int /*long*/ string_target = OS.gdk_utf8_to_string_target(utf8);
+		if (string_target ==  0) return;
+		transferData.type = STRING_ID;
+		transferData.format = 8;
+		transferData.length = OS.strlen(string_target);
+		transferData.pValue = string_target;
+		transferData.result = 1;
+	}
+}
+
+/**
+ * This implementation of <code>nativeToJava</code> converts a platform specific 
+ * representation of plain text to a java <code>String</code>.
+ * 
+ * @param transferData the platform specific representation of the data to be converted
+ * @return a java <code>String</code> containing text if the conversion was successful; otherwise null
+ * 
+ * @see Transfer#javaToNative
+ */
+public Object nativeToJava(TransferData transferData){
+	if (!isSupportedType(transferData) ||  transferData.pValue == 0) return null;
+	int /*long*/[] list = new int /*long*/[1];
+	int count = OS.gdk_text_property_to_utf8_list(transferData.type, transferData.format, transferData.pValue, transferData.length, list);
+	if (count == 0) return null;
+	int /*long*/[] ptr = new int /*long*/[1];
+	OS.memmove(ptr, list[0], OS.PTR_SIZEOF);
+	int length = OS.strlen(ptr[0]);
+	byte[] utf8 = new byte[length];
+	OS.memmove(utf8, ptr[0], length);
+	OS.g_strfreev(list[0]);
+	// convert utf8 byte array to a unicode string
+	char [] unicode = Converter.mbcsToWcs (null, utf8);
+	String string = new String (unicode);
+	int end = string.indexOf('\0');
+	return (end == -1) ? string : string.substring(0, end);
+}
+
+protected int[] getTypeIds() {
+	return new int[] {UTF8_STRING_ID, COMPOUND_TEXT_ID, STRING_ID};
+}
+
+protected String[] getTypeNames() {
+	return new String[] {UTF8_STRING, COMPOUND_TEXT, STRING};
+}
+
+boolean checkText(Object object) {
+	return (object != null && object instanceof String && ((String)object).length() > 0);
+}
+
+protected boolean validate(Object object) {
+	return checkText(object);
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/Transfer.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/Transfer.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/Transfer.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,154 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.dnd;
+
+ 
+import org.eclipse.swt.internal.Converter;
+import org.eclipse.swt.internal.gtk.OS;
+
+/**
+ * <code>Transfer</code> provides a mechanism for converting between a java 
+ * representation of data and a platform specific representation of data and 
+ * vice versa.  It is used in data transfer operations such as drag and drop and 
+ * clipboard copy/paste.
+ *
+ * <p>You should only need to become familiar with this class if you are 
+ * implementing a Transfer subclass and you are unable to subclass the 
+ * ByteArrayTransfer class.</p>
+ * 
+ * @see ByteArrayTransfer
+ * @see <a href="http://www.eclipse.org/swt/snippets/#dnd">Drag and Drop snippets</a>
+ * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: DNDExample</a>
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public abstract class Transfer {
+	
+/**
+ * Returns a list of the platform specific data types that can be converted using 
+ * this transfer agent.
+ *
+ * <p>Only the data type fields of the <code>TransferData</code> objects are filled 
+ * in.</p>
+ *
+ * @return a list of the data types that can be converted using this transfer agent
+ */
+abstract public TransferData[] getSupportedTypes();
+
+/**
+ * Returns true if the <code>TransferData</code> data type can be converted 
+ * using this transfer agent, or false otherwise (including if transferData is
+ * <code>null</code>).
+ *
+ * @param transferData a platform specific description of a data type; only the data
+ *  type fields of the <code>TransferData</code> object need to be filled in
+ *
+ * @return true if the transferData data type can be converted using this transfer 
+ * agent
+ */
+abstract public boolean isSupportedType(TransferData transferData);
+
+/**
+ * Returns the platform specific names of the  data types that can be converted 
+ * using this transfer agent.
+ * 
+ * @return the platform specific names of the data types that can be converted 
+ * using this transfer agent.
+ */
+abstract protected String[] getTypeNames();
+
+/**
+ * Returns the platform specific ids of the  data types that can be converted using 
+ * this transfer agent.
+ * 
+ * @return the platform specific ids of the data types that can be converted using 
+ * this transfer agent
+ */
+abstract protected int[] getTypeIds();
+
+/**
+ * Converts a java representation of data to a platform specific representation of 
+ * the data. 
+ *
+ * <p>On a successful conversion, the transferData.result field will be set as follows:
+ * <ul>
+ * <li>Windows: COM.S_OK
+ * <li>Motif: 1
+ * <li>GTK: 1
+ * <li>Photon: 1
+ * </ul></p>
+ * 
+ * <p>If this transfer agent is unable to perform the conversion, the transferData.result 
+ * field will be set to a failure value as follows:
+ * <ul>
+ * <li>Windows: COM.DV_E_TYMED or COM.E_FAIL
+ * <li>Motif: 0
+ * <li>GTK: 0
+ * <li>Photon: 0
+ * </ul></p>
+ *
+ * @param object a java representation of the data to be converted; the type of
+ * Object that is passed in is dependent on the <code>Transfer</code> subclass.
+ *
+ * @param transferData an empty TransferData object; this object will be 
+ * filled in on return with the platform specific representation of the data
+ * 
+ * @exception org.eclipse.swt.SWTException <ul>
+ *    <li>ERROR_INVALID_DATA - if object does not contain data in a valid format or is <code>null</code></li>
+ * </ul>
+ */
+abstract protected void javaToNative (Object object, TransferData transferData);
+
+/**
+ * Converts a platform specific representation of data to a java representation.
+ * 
+ * @param transferData the platform specific representation of the data to be 
+ * converted
+ *
+ * @return a java representation of the converted data if the conversion was 
+ * successful; otherwise null.  If transferData is <code>null</code> then
+ * <code>null</code> is returned.  The type of Object that is returned is 
+ * dependent on the <code>Transfer</code> subclass.
+ */
+abstract protected Object nativeToJava(TransferData transferData);
+
+/**
+ * Registers a name for a data type and returns the associated unique identifier.
+ *
+ * <p>You may register the same type more than once, the same unique identifier 
+ * will be returned if the type has been previously registered.</p>
+ *
+ * <p>Note: On windows, do <b>not</b> call this method with pre-defined 
+ * Clipboard Format types such as CF_TEXT or CF_BITMAP because the 
+ * pre-defined identifier will not be returned</p>
+ *
+ * @param formatName the name of a data type
+ *
+ * @return the unique identifier associated with this data type
+ */
+public static int registerType(String formatName){
+	if (formatName == null) return OS.GDK_NONE;
+	byte[] buffer = Converter.wcsToMbcs(null, formatName, true);
+	return (int)/*64*/OS.gdk_atom_intern(buffer, false);
+}
+
+/**
+ * Test that the object is of the correct format for this Transfer class.
+ * 
+ * @param object a java representation of the data to be converted
+ * 
+ * @return true if object is of the correct form for this transfer type
+ * 
+ * @since 3.1
+ */
+protected boolean validate(Object object) {
+	return true;
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/TransferData.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/TransferData.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/TransferData.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,98 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.dnd;
+
+ 
+/**
+ * The <code>TransferData</code> class is a platform specific data structure for
+ * describing the type and the contents of data being converted by a transfer agent.
+ *
+ * <p>As an application writer, you do not need to know the specifics of 
+ * TransferData.  TransferData instances are passed to a subclass of Transfer 
+ * and the Transfer object manages the platform specific issues.  
+ * You can ask a Transfer subclass if it can handle this data by calling 
+ * Transfer.isSupportedType(transferData).</p>
+ *
+ * <p>You should only need to become familiar with the fields in this class if you 
+ * are implementing a Transfer subclass and you are unable to subclass the 
+ * ByteArrayTransfer class.</p>
+ *
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public class TransferData {
+	/**
+	 * The type is a unique identifier of a system format or user defined format.
+	 * (Warning: This field is platform dependent)
+	 * <p>
+	 * <b>IMPORTANT:</b> This field is <em>not</em> part of the SWT
+	 * public API. It is marked public only so that it can be shared
+	 * within the packages provided by SWT. It is not available on all
+	 * platforms and should never be accessed from application code.
+	 * </p>
+	 */
+	public int /*long*/ type;
+	
+	/**
+	 * Specifies the number of units in pValue.
+	 * (Warning: This field is platform dependent)
+	 * <p>
+	 * <b>IMPORTANT:</b> This field is <em>not</em> part of the SWT
+	 * public API. It is marked public only so that it can be shared
+	 * within the packages provided by SWT. It is not available on all
+	 * platforms and should never be accessed from application code.
+	 * </p>
+	 * 
+	 * @see TransferData#format for the size of one unit
+	 */
+	public int length;
+	
+	/**
+	 * Specifies the size in bits of a single unit in pValue.
+ 	 * (Warning: This field is platform dependent)
+	 * <p>
+	 * <b>IMPORTANT:</b> This field is <em>not</em> part of the SWT
+	 * public API. It is marked public only so that it can be shared
+	 * within the packages provided by SWT. It is not available on all
+	 * platforms and should never be accessed from application code.
+	 * </p>
+ 	 * 
+ 	 * This is most commonly 8 bits.
+	 */
+	public int format;
+	
+	/**
+	 * Pointer to the data being transferred.
+	 * (Warning: This field is platform dependent)
+	 * <p>
+	 * <b>IMPORTANT:</b> This field is <em>not</em> part of the SWT
+	 * public API. It is marked public only so that it can be shared
+	 * within the packages provided by SWT. It is not available on all
+	 * platforms and should never be accessed from application code.
+	 * </p>
+	 */
+	public int /*long*/ pValue;
+
+	/**
+	 * The result field contains the result of converting a
+	 * java data type into a platform specific value.
+	 * (Warning: This field is platform dependent)
+	 * <p>
+	 * <b>IMPORTANT:</b> This field is <em>not</em> part of the SWT
+	 * public API. It is marked public only so that it can be shared
+	 * within the packages provided by SWT. It is not available on all
+	 * platforms and should never be accessed from application code.
+	 * </p>
+ 	 * <p>The value of result is 1 if the conversion was successful.
+	 * The value of result is 0 if the conversion failed.</p>
+	 */
+	public int result;
+	
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/TreeDragSourceEffect.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/TreeDragSourceEffect.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/TreeDragSourceEffect.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,141 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.dnd;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.gtk.*;
+import org.eclipse.swt.widgets.*;
+
+/**
+ * This class provides default implementations to display a source image
+ * when a drag is initiated from a <code>Tree</code>.
+ * 
+ * <p>Classes that wish to provide their own source image for a <code>Tree</code> can
+ * extend <code>TreeDragSourceEffect</code> class and override the <code>TreeDragSourceEffect.dragStart</code>
+ * method and set the field <code>DragSourceEvent.image</code> with their own image.</p>
+ *
+ * Subclasses that override any methods of this class must call the corresponding
+ * <code>super</code> method to get the default drag under effect implementation.
+ *
+ * @see DragSourceEffect
+ * @see DragSourceEvent
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ * 
+ * @since 3.3
+ */
+public class TreeDragSourceEffect extends DragSourceEffect {
+	Image dragSourceImage = null;
+
+	/**
+	 * Creates a new <code>TreeDragSourceEffect</code> to handle drag effect 
+	 * from the specified <code>Tree</code>.
+	 *
+	 * @param tree the <code>Tree</code> that the user clicks on to initiate the drag
+	 */
+	public TreeDragSourceEffect(Tree tree) {
+		super(tree);
+	}
+
+	/**
+	 * This implementation of <code>dragFinished</code> disposes the image
+	 * that was created in <code>TreeDragSourceEffect.dragStart</code>.
+	 * 
+	 * Subclasses that override this method should call <code>super.dragFinished(event)</code>
+	 * to dispose the image in the default implementation.
+	 * 
+	 * @param event the information associated with the drag finished event
+	 */
+	public void dragFinished(DragSourceEvent event) {
+		if (dragSourceImage != null) dragSourceImage.dispose();
+		dragSourceImage = null;		
+	}
+
+	/**
+	 * This implementation of <code>dragStart</code> will create a default
+	 * image that will be used during the drag. The image should be disposed
+	 * when the drag is completed in the <code>TreeDragSourceEffect.dragFinished</code>
+	 * method.
+	 * 
+	 * Subclasses that override this method should call <code>super.dragStart(event)</code>
+	 * to use the image from the default implementation.
+	 * 
+	 * @param event the information associated with the drag start event
+	 */
+	public void dragStart(DragSourceEvent event) {
+		event.image = getDragSourceImage(event);
+	}
+
+	Image getDragSourceImage(DragSourceEvent event) {
+		if (dragSourceImage != null) dragSourceImage.dispose();
+		dragSourceImage = null;		
+		
+		Tree tree = (Tree) control;
+		if (OS.GTK_VERSION < OS.VERSION (2, 2, 0)) return null;
+		//TEMPORARY CODE
+		if (tree.isListening(SWT.EraseItem) || tree.isListening (SWT.PaintItem)) return null;
+		/*
+		* Bug in GTK.  gtk_tree_selection_get_selected_rows() segmentation faults
+		* in versions smaller than 2.2.4 if the model is NULL.  The fix is
+		* to give a valid pointer instead.
+		*/
+		int /*long*/ handle = tree.handle;
+		int /*long*/ selection = OS.gtk_tree_view_get_selection (handle);
+		int /*long*/ [] model = OS.GTK_VERSION < OS.VERSION (2, 2, 4) ? new int /*long*/ [1] : null;
+		int /*long*/ list = OS.gtk_tree_selection_get_selected_rows (selection, model);
+		if (list == 0) return null;
+		int count = Math.min(10, OS.g_list_length (list));
+
+		Display display = tree.getDisplay();
+		if (count == 1) {
+			int /*long*/ path = OS.g_list_nth_data (list, 0);
+			int /*long*/ pixmap = OS.gtk_tree_view_create_row_drag_icon(handle, path);
+			dragSourceImage =  Image.gtk_new(display, SWT.ICON, pixmap, 0); 
+		} else {
+			int width = 0, height = 0;
+			int[] w = new int[1], h = new int[1];
+			int[] yy = new int[count], hh = new int[count];
+			int /*long*/ [] pixmaps = new int /*long*/ [count];
+			GdkRectangle rect = new GdkRectangle ();
+			for (int i=0; i<count; i++) {
+				int /*long*/ path = OS.g_list_nth_data (list, i);
+				OS.gtk_tree_view_get_cell_area (handle, path, 0, rect);
+				pixmaps[i] = OS.gtk_tree_view_create_row_drag_icon(handle, path);
+				OS.gdk_drawable_get_size(pixmaps[i], w, h);
+				width = Math.max(width, w[0]);
+				height = rect.y + h[0] - yy[0];
+				yy[i] = rect.y;
+				hh[i] = h[0];
+			}
+			int /*long*/ source = OS.gdk_pixmap_new(OS.GDK_ROOT_PARENT(), width, height, -1);
+			int /*long*/ gcSource = OS.gdk_gc_new(source);
+			int /*long*/ mask = OS.gdk_pixmap_new(OS.GDK_ROOT_PARENT(), width, height, 1);
+			int /*long*/ gcMask = OS.gdk_gc_new(mask);
+			GdkColor color = new GdkColor();
+			color.pixel = 0;
+			OS.gdk_gc_set_foreground(gcMask, color);
+			OS.gdk_draw_rectangle(mask, gcMask, 1, 0, 0, width, height);
+			color.pixel = 1;
+			OS.gdk_gc_set_foreground(gcMask, color);
+			for (int i=0; i<count; i++) {
+				OS.gdk_draw_drawable(source, gcSource, pixmaps[i], 0, 0, 0, yy[i] - yy[0], -1, -1);
+				OS.gdk_draw_rectangle(mask, gcMask, 1, 0, yy[i] - yy[0], width, hh[i]);
+				OS.g_object_unref(pixmaps[i]);
+			}
+			OS.g_object_unref(gcSource);
+			OS.g_object_unref(gcMask);
+			dragSourceImage  = Image.gtk_new(display, SWT.ICON, source, mask);
+		}
+		OS.g_list_free (list);
+		
+		return dragSourceImage;
+	}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/TreeDropTargetEffect.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/TreeDropTargetEffect.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/TreeDropTargetEffect.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,222 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.dnd;
+
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.gtk.*;
+import org.eclipse.swt.widgets.*;
+
+/**
+ * This class provides a default drag under effect (eg. select, insert, scroll and expand) 
+ * when a drag occurs over a <code>Tree</code>.
+ * 
+ * <p>Classes that wish to provide their own drag under effect for a <code>Tree</code>
+ * can extend the <code>TreeDropTargetEffect</code> class and override any applicable methods 
+ * in <code>TreeDropTargetEffect</code> to display their own drag under effect.</p>
+ *
+ * Subclasses that override any methods of this class must call the corresponding
+ * <code>super</code> method to get the default drag under effect implementation.
+ *
+ * <p>The feedback value is either one of the FEEDBACK constants defined in 
+ * class <code>DND</code> which is applicable to instances of this class, 
+ * or it must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>DND</code> effect constants. 
+ * </p>
+ * <p>
+ * <dl>
+ * <dt><b>Feedback:</b></dt>
+ * <dd>FEEDBACK_SELECT, FEEDBACK_INSERT_BEFORE, FEEDBACK_INSERT_AFTER, FEEDBACK_EXPAND, FEEDBACK_SCROLL</dd>
+ * </dl>
+ * </p><p>
+ * Note: Only one of the styles FEEDBACK_SELECT, FEEDBACK_INSERT_BEFORE or
+ * FEEDBACK_INSERT_AFTER may be specified.
+ * </p>
+ * 
+ * @see DropTargetAdapter
+ * @see DropTargetEvent
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ * 
+ * @since 3.3
+ */
+public class TreeDropTargetEffect extends DropTargetEffect {
+	static final int SCROLL_HYSTERESIS = 150; // milli seconds
+	static final int EXPAND_HYSTERESIS = 1000; // milli seconds
+
+	int scrollIndex = -1;
+	long scrollBeginTime;
+
+	int expandIndex = -1;
+	long expandBeginTime;
+
+	/**
+	 * Creates a new <code>TreeDropTargetEffect</code> to handle the drag under effect on the specified 
+	 * <code>Tree</code>.
+	 * 
+	 * @param tree the <code>Tree</code> over which the user positions the cursor to drop the data
+	 */
+	public TreeDropTargetEffect(Tree tree) {
+		super(tree);
+	}
+
+	int checkEffect(int effect) {
+		// Some effects are mutually exclusive.  Make sure that only one of the mutually exclusive effects has been specified.
+		if ((effect & DND.FEEDBACK_SELECT) != 0) effect = effect & ~DND.FEEDBACK_INSERT_AFTER & ~DND.FEEDBACK_INSERT_BEFORE;
+		if ((effect & DND.FEEDBACK_INSERT_BEFORE) != 0) effect = effect & ~DND.FEEDBACK_INSERT_AFTER;
+		return effect;
+	}
+
+	/**
+	 * This implementation of <code>dragEnter</code> provides a default drag under effect
+	 * for the feedback specified in <code>event.feedback</code>.
+	 * 
+	 * For additional information see <code>DropTargetAdapter.dragEnter</code>.
+	 * 
+	 * Subclasses that override this method should call <code>super.dragEnter(event)</code>
+	 * to get the default drag under effect implementation.
+	 *
+	 * @param event  the information associated with the drag enter event
+	 * 
+	 * @see DropTargetAdapter
+	 * @see DropTargetEvent
+	 */
+	public void dragEnter(DropTargetEvent event) {
+		expandBeginTime = 0;
+		expandIndex = -1;	
+		scrollBeginTime = 0;
+		scrollIndex = -1;
+	}
+	
+	/**
+	 * This implementation of <code>dragLeave</code> provides a default drag under effect
+	 * for the feedback specified in <code>event.feedback</code>.
+	 * 
+	 * For additional information see <code>DropTargetAdapter.dragLeave</code>.
+	 * 
+	 * Subclasses that override this method should call <code>super.dragLeave(event)</code>
+	 * to get the default drag under effect implementation.
+	 *
+	 * @param event  the information associated with the drag leave event
+	 * 
+	 * @see DropTargetAdapter
+	 * @see DropTargetEvent
+	 */
+	public void dragLeave(DropTargetEvent event) {
+		Tree tree = (Tree) control;
+		int /*long*/ handle = tree.handle;
+		OS.gtk_tree_view_set_drag_dest_row(handle, 0, OS.GTK_TREE_VIEW_DROP_BEFORE);
+
+		scrollBeginTime = 0;
+		scrollIndex = -1;
+		expandBeginTime = 0;
+		expandIndex = -1;
+	}
+
+	/**
+	 * This implementation of <code>dragOver</code> provides a default drag under effect
+	 * for the feedback specified in <code>event.feedback</code>.
+	 * 
+	 * For additional information see <code>DropTargetAdapter.dragOver</code>.
+	 * 
+	 * Subclasses that override this method should call <code>super.dragOver(event)</code>
+	 * to get the default drag under effect implementation.
+	 *
+	 * @param event  the information associated with the drag over event
+	 * 
+	 * @see DropTargetAdapter
+	 * @see DropTargetEvent
+	 * @see DND#FEEDBACK_SELECT
+	 * @see DND#FEEDBACK_INSERT_BEFORE
+	 * @see DND#FEEDBACK_INSERT_AFTER
+	 * @see DND#FEEDBACK_SCROLL
+	 */
+	public void dragOver(DropTargetEvent event) {
+		Tree tree = (Tree) control;
+		int effect = checkEffect(event.feedback);
+
+		int /*long*/ handle = tree.handle;
+		Point coordinates = new Point(event.x, event.y);
+		coordinates = tree.toControl(coordinates);
+		int /*long*/ [] path = new int /*long*/ [1];
+		OS.gtk_tree_view_get_path_at_pos (handle, coordinates.x, coordinates.y, path, null, null, null);
+		int index = -1;
+		if (path[0] != 0) {
+			int /*long*/ indices = OS.gtk_tree_path_get_indices(path[0]);
+			if (indices != 0) {	
+				int depth = OS.gtk_tree_path_get_depth(path[0]);
+				int[] temp = new int[depth];
+				OS.memmove (temp, indices, temp.length * 4);
+				index = temp[temp.length - 1];
+			}
+		}
+		if ((effect & DND.FEEDBACK_SCROLL) == 0) {
+			scrollBeginTime = 0;
+			scrollIndex = -1;
+		} else {
+			if (index != -1 && scrollIndex == index && scrollBeginTime != 0) {
+				if (System.currentTimeMillis() >= scrollBeginTime) {
+					GdkRectangle cellRect = new GdkRectangle ();
+					OS.gtk_tree_view_get_cell_area (handle, path[0], 0, cellRect);
+					if (cellRect.y < cellRect.height) {
+						int[] tx = new int[1], ty = new int[1];
+						OS.gtk_tree_view_widget_to_tree_coords(handle, cellRect.x, cellRect.y - cellRect.height, tx, ty);
+						OS.gtk_tree_view_scroll_to_point (handle, -1, ty[0]);
+					} else {
+						//scroll down
+						OS.gtk_tree_view_get_path_at_pos (handle, coordinates.x, coordinates.y + cellRect.height, path, null, null, null);
+						if (path[0] != 0) {
+							OS.gtk_tree_view_scroll_to_cell(handle, path[0], 0, false, 0, 0);
+							OS.gtk_tree_path_free(path[0]);
+							path[0] = 0;
+						}
+						OS.gtk_tree_view_get_path_at_pos (handle, coordinates.x, coordinates.y, path, null, null, null);	
+					}
+					scrollBeginTime = 0;
+					scrollIndex = -1;
+				}
+			} else {
+				scrollBeginTime = System.currentTimeMillis() + SCROLL_HYSTERESIS;
+				scrollIndex = index;
+			}
+		}
+		if ((effect & DND.FEEDBACK_EXPAND) == 0) {
+			expandBeginTime = 0;
+			expandIndex = -1;
+		} else {
+			if (index != -1 && expandIndex == index && expandBeginTime != 0) {
+				if (System.currentTimeMillis() >= expandBeginTime) {
+					OS.gtk_tree_view_expand_row (handle, path[0], false);
+					expandBeginTime = 0;
+					expandIndex = -1;
+				}
+			} else {
+				expandBeginTime = System.currentTimeMillis() + EXPAND_HYSTERESIS;
+				expandIndex = index;
+			}
+		}
+		if (path[0] != 0) {
+			int position = -1;
+			if ((effect & DND.FEEDBACK_SELECT) != 0) position = OS.GTK_TREE_VIEW_DROP_INTO_OR_BEFORE;
+			if ((effect & DND.FEEDBACK_INSERT_BEFORE) != 0) position = OS.GTK_TREE_VIEW_DROP_BEFORE;
+			if ((effect & DND.FEEDBACK_INSERT_AFTER) != 0) position = OS.GTK_TREE_VIEW_DROP_AFTER;		
+			if (position != -1) {
+				OS.gtk_tree_view_set_drag_dest_row(handle, path[0], position);
+			} else {
+				OS.gtk_tree_view_set_drag_dest_row(handle, 0, OS.GTK_TREE_VIEW_DROP_BEFORE);
+			}
+		} else {
+			OS.gtk_tree_view_set_drag_dest_row(handle, 0, OS.GTK_TREE_VIEW_DROP_BEFORE);
+		}
+		
+		if (path[0] != 0) OS.gtk_tree_path_free (path [0]);
+	}
+
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/URLTransfer.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/URLTransfer.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/dnd/URLTransfer.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,114 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.dnd;
+
+import org.eclipse.swt.internal.gtk.*;
+
+/**
+ * The class <code>URLTransfer</code> provides a platform specific mechanism 
+ * for converting text in URL format represented as a java <code>String</code> 
+ * to a platform specific representation of the data and vice versa. The string
+ * must contain a fully specified url.
+ * 
+ * <p>An example of a java <code>String</code> containing a URL is shown below:</p>
+ * 
+ * <code><pre>
+ *     String url = "http://www.eclipse.org";
+ * </code></pre>
+ *
+ * @see Transfer
+ */
+public class URLTransfer extends ByteArrayTransfer {
+
+	static URLTransfer _instance = new URLTransfer();
+	private static final String TEXT_UNICODE = "text/unicode"; //$NON-NLS-1$
+	private static final String TEXT_XMOZURL = "text/x-moz-url"; //$NON-NLS-1$
+	private static final int TEXT_UNICODE_ID = registerType(TEXT_UNICODE);	
+	private static final int TEXT_XMOZURL_ID = registerType(TEXT_XMOZURL);	
+	
+private URLTransfer() {}
+
+/**
+ * Returns the singleton instance of the URLTransfer class.
+ *
+ * @return the singleton instance of the URLTransfer class
+ */
+public static URLTransfer getInstance () {
+	return _instance;
+}
+
+/**
+ * This implementation of <code>javaToNative</code> converts a URL
+ * represented by a java <code>String</code> to a platform specific representation.
+ * 
+ * @param object a java <code>String</code> containing a URL
+ * @param transferData an empty <code>TransferData</code> object that will
+ *  	be filled in on return with the platform specific format of the data
+ * 
+ * @see Transfer#nativeToJava
+ */
+public void javaToNative (Object object, TransferData transferData){
+	transferData.result = 0;
+	if (!checkURL(object) || !isSupportedType(transferData)) {
+		DND.error(DND.ERROR_INVALID_DATA);
+	}
+	String string = (String)object;
+	int charCount = string.length();
+	char [] chars = new char[charCount +1];
+	string.getChars(0, charCount , chars, 0);
+	int byteCount = chars.length*2;
+	int /*long*/ pValue = OS.g_malloc(byteCount);
+	if (pValue == 0) return;
+	OS.memmove(pValue, chars, byteCount);
+	transferData.length = byteCount;
+	transferData.format = 8;
+	transferData.pValue = pValue;
+	transferData.result = 1;		
+}
+
+/**
+ * This implementation of <code>nativeToJava</code> converts a platform 
+ * specific representation of a URL to a java <code>String</code>.
+ * 
+ * @param transferData the platform specific representation of the data to be converted
+ * @return a java <code>String</code> containing a URL if the conversion was successful;
+ * 		otherwise null
+ * 
+ * @see Transfer#javaToNative
+ */
+public Object nativeToJava(TransferData transferData){
+	if (!isSupportedType(transferData) ||  transferData.pValue == 0) return null;
+	/* Ensure byteCount is a multiple of 2 bytes */
+	int size = (transferData.format * transferData.length / 8) / 2 * 2;
+	if (size <= 0) return null;			
+	char[] chars = new char [size/2];
+	OS.memmove (chars, transferData.pValue, size);
+	String string = new String (chars);
+	int end = string.indexOf('\0');
+	return (end == -1) ? string : string.substring(0, end);
+}
+
+protected int[] getTypeIds(){
+	return new int[] {TEXT_XMOZURL_ID, TEXT_UNICODE_ID};
+}
+
+protected String[] getTypeNames(){
+	return new String[] {TEXT_XMOZURL, TEXT_UNICODE}; 
+}
+
+boolean checkURL(Object object) {
+	return object != null && (object instanceof String) && ((String)object).length() > 0;
+}
+
+protected boolean validate(Object object) {
+	return checkURL(object);
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/events/ArmEvent.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/events/ArmEvent.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/events/ArmEvent.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.events;
+
+
+import org.eclipse.swt.widgets.Event;
+
+/**
+ * Instances of this class are sent as a result of
+ * a widget such as a menu item being armed.
+ *
+ * @see ArmListener
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+
+public final class ArmEvent extends TypedEvent {
+
+	static final long serialVersionUID = 3258126964249212217L;
+
+/**
+ * Constructs a new instance of this class based on the
+ * information in the given untyped event.
+ *
+ * @param e the untyped event containing the information
+ */
+public ArmEvent(Event e) {
+	super(e);
+}
+
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/events/ArmListener.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/events/ArmListener.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/events/ArmListener.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.events;
+
+
+import org.eclipse.swt.internal.SWTEventListener;
+
+/**
+ * Classes which implement this interface provide a method
+ * that deals with the event that is generated when a widget,
+ * such as a menu item, is armed.
+ * <p>
+ * After creating an instance of a class that implements
+ * this interface it can be added to a widget using the
+ * <code>addArmListener</code> method and removed using
+ * the <code>removeArmListener</code> method. When the
+ * widget is armed, the widgetArmed method will be invoked.
+ * </p>
+ *
+ * @see ArmEvent
+ */
+public interface ArmListener extends SWTEventListener {
+
+/**
+ * Sent when a widget is armed, or 'about to be selected'.
+ *
+ * @param e an event containing information about the arm
+ */
+public void widgetArmed(ArmEvent e);
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/events/ControlAdapter.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/events/ControlAdapter.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/events/ControlAdapter.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.events;
+
+
+/**
+ * This adapter class provides default implementations for the
+ * methods described by the <code>ControlListener</code> interface.
+ * <p>
+ * Classes that wish to deal with <code>ControlEvent</code>s can
+ * extend this class and override only the methods which they are
+ * interested in.
+ * </p>
+ *
+ * @see ControlListener
+ * @see ControlEvent
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public abstract class ControlAdapter implements ControlListener {
+
+/**
+ * Sent when the location (x, y) of a control changes relative
+ * to its parent (or relative to the display, for <code>Shell</code>s).
+ * The default behavior is to do nothing.
+ *
+ * @param e an event containing information about the move
+ */
+public void controlMoved(ControlEvent e) {
+}
+
+/**
+ * Sent when the size (width, height) of a control changes.
+ * The default behavior is to do nothing.
+ *
+ * @param e an event containing information about the resize
+ */
+public void controlResized(ControlEvent e) {
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/events/ControlEvent.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/events/ControlEvent.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/events/ControlEvent.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.events;
+
+
+import org.eclipse.swt.widgets.Event;
+
+/**
+ * Instances of this class are sent as a result of
+ * controls being moved or resized.
+ *
+ * @see ControlListener
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+
+public final class ControlEvent extends TypedEvent {
+
+	static final long serialVersionUID = 3258132436155119161L;
+
+/**
+ * Constructs a new instance of this class based on the
+ * information in the given untyped event.
+ *
+ * @param e the untyped event containing the information
+ */
+public ControlEvent(Event e) {
+	super(e);
+}
+
+}
+
+

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/events/ControlListener.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/events/ControlListener.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/events/ControlListener.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.events;
+
+
+import org.eclipse.swt.internal.SWTEventListener;
+
+/**
+ * Classes which implement this interface provide methods
+ * that deal with the events that are generated by moving
+ * and resizing controls. 
+ * <p>
+ * After creating an instance of a class that implements
+ * this interface it can be added to a control using the
+ * <code>addControlListener</code> method and removed using
+ * the <code>removeControlListener</code> method. When a
+ * control is moved or resized, the appropriate method will
+ * be invoked.
+ * </p>
+ *
+ * @see ControlAdapter
+ * @see ControlEvent
+ */
+public interface ControlListener extends SWTEventListener {
+
+/**
+ * Sent when the location (x, y) of a control changes relative
+ * to its parent (or relative to the display, for <code>Shell</code>s).
+ *
+ * @param e an event containing information about the move
+ */
+public void controlMoved(ControlEvent e);
+
+/**
+ * Sent when the size (width, height) of a control changes.
+ *
+ * @param e an event containing information about the resize
+ */
+public void controlResized(ControlEvent e);
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/events/DisposeEvent.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/events/DisposeEvent.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/events/DisposeEvent.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.events;
+
+
+import org.eclipse.swt.widgets.Event;
+
+/**
+ * Instances of this class are sent as a result of
+ * widgets being disposed.
+ *
+ * @see DisposeListener
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+
+public final class DisposeEvent extends TypedEvent {
+
+	static final long serialVersionUID = 3257566187633521206L;
+
+/**
+ * Constructs a new instance of this class based on the
+ * information in the given untyped event.
+ *
+ * @param e the untyped event containing the information
+ */
+public DisposeEvent(Event e) {
+	super(e);
+}
+
+}
+

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/events/DisposeListener.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/events/DisposeListener.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/events/DisposeListener.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.events;
+
+
+import org.eclipse.swt.internal.SWTEventListener;
+
+/**
+ * Classes which implement this interface provide a method
+ * that deals with the event that is generated when a widget
+ * is disposed.
+ * <p>
+ * After creating an instance of a class that implements
+ * this interface it can be added to a widget using the
+ * <code>addDisposeListener</code> method and removed using
+ * the <code>removeDisposeListener</code> method. When a
+ * widget is disposed, the widgetDisposed method will
+ * be invoked.
+ * </p>
+ *
+ * @see DisposeEvent
+ */
+public interface DisposeListener extends SWTEventListener {
+
+/**
+ * Sent when the widget is disposed.
+ *
+ * @param e an event containing information about the dispose
+ */
+public void widgetDisposed(DisposeEvent e);
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/events/DragDetectEvent.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/events/DragDetectEvent.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/events/DragDetectEvent.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.events;
+
+import org.eclipse.swt.widgets.Event;
+
+/**
+ * Instances of this class are sent as a result of
+ * a drag gesture.
+ *
+ * @see DragDetectListener
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ * 
+ * @since 3.3
+ */
+
+public final class DragDetectEvent extends MouseEvent {
+
+	private static final long serialVersionUID = -7229172519733647232L;
+
+/**
+ * Constructs a new instance of this class based on the
+ * information in the given untyped event.
+ *
+ * @param e the untyped event containing the information
+ */
+public DragDetectEvent(Event e) {
+	super(e);
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/events/DragDetectListener.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/events/DragDetectListener.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/events/DragDetectListener.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.events;
+
+
+import org.eclipse.swt.internal.SWTEventListener;
+
+/**
+ * Classes which implement this interface provide methods
+ * that deal with the events that are generated when a drag
+ * gesture is detected.
+ * <p>
+ * After creating an instance of a class that implements
+ * this interface it can be added to a control using the
+ * <code>addDragDetectListener</code> method and removed using
+ * the <code>removeDragDetectListener</code> method. When the
+ * drag is detected, the drageDetected method will be invoked.
+ * </p>
+ *
+ * @see DragDetectEvent
+ * 
+ * @since 3.3
+ */
+public interface DragDetectListener extends SWTEventListener {
+
+/**
+ * Sent when a drag gesture is detected.
+ *
+ * @param e an event containing information about the drag
+ */
+public void dragDetected(DragDetectEvent e);
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/events/ExpandAdapter.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/events/ExpandAdapter.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/events/ExpandAdapter.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.events;
+
+
+/**
+ * This adapter class provides default implementations for the
+ * methods described by the <code>ExpandListener</code> interface.
+ * <p>
+ * Classes that wish to deal with <code>ExpandEvent</code>s can
+ * extend this class and override only the methods which they are
+ * interested in.
+ * </p>
+ *
+ * @see ExpandListener
+ * @see ExpandEvent
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ * 
+ * @since 3.2
+ */
+public abstract class ExpandAdapter implements ExpandListener {
+
+/**
+ * Sent when an item is collapsed.
+ * The default behavior is to do nothing.
+ *
+ * @param e an event containing information about the operation
+ */
+public void itemCollapsed(ExpandEvent e) {
+}
+
+/**
+ * Sent when an item is expanded.
+ * The default behavior is to do nothing.
+ *
+ * @param e an event containing information about the operation
+ */
+public void itemExpanded(ExpandEvent e) {
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/events/ExpandEvent.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/events/ExpandEvent.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/events/ExpandEvent.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.events;
+
+
+import org.eclipse.swt.widgets.*;
+
+/**
+ * Instances of this class are sent as a result of
+ * <code>ExpandItem</code>s being expanded or collapsed.
+ *
+ * @see ExpandListener
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ * 
+ * @since 3.2
+ */
+
+public class ExpandEvent extends SelectionEvent {
+	
+	static final long serialVersionUID = 3976735856884987356L;
+	
+/**
+ * Constructs a new instance of this class based on the
+ * information in the given untyped event.
+ *
+ * @param e the untyped event containing the information
+ */
+public ExpandEvent(Event e) {
+	super(e);
+}
+
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/events/ExpandListener.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/events/ExpandListener.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/events/ExpandListener.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.events;
+
+
+import org.eclipse.swt.internal.SWTEventListener;
+
+/**
+ * Classes which implement this interface provide methods
+ * that deal with the expanding and collapsing of <code>ExpandItem</code>s.
+ *
+ * <p>
+ * After creating an instance of a class that implements
+ * this interface it can be added to a <code>ExpandBar</code> 
+ * control using the <code>addExpandListener</code> method and
+ * removed using the <code>removeExpandListener</code> method. 
+ * When a item of the <code>ExpandBar</code> is expanded or
+ * collapsed, the appropriate method will be invoked.
+ * </p>
+ *
+ * @see ExpandAdapter
+ * @see ExpandEvent
+ * 
+ * @since 3.2
+ */
+public interface ExpandListener extends SWTEventListener {
+
+/**
+ * Sent when an item is collapsed.
+ *
+ * @param e an event containing information about the operation
+ */
+public void itemCollapsed(ExpandEvent e);
+
+/**
+ * Sent when an item is expanded.
+ *
+ * @param e an event containing information about the operation
+ */
+public void itemExpanded(ExpandEvent e);
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/events/FocusAdapter.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/events/FocusAdapter.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/events/FocusAdapter.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.events;
+
+
+/**
+ * This adapter class provides default implementations for the
+ * methods described by the <code>FocusListener</code> interface.
+ * <p>
+ * Classes that wish to deal with <code>FocusEvent</code>s can
+ * extend this class and override only the methods which they are
+ * interested in.
+ * </p>
+ *
+ * @see FocusListener
+ * @see FocusEvent
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public abstract class FocusAdapter implements FocusListener {
+
+/**
+ * Sent when a control gets focus.
+ * The default behavior is to do nothing.
+ *
+ * @param e an event containing information about the focus change
+ */
+public void focusGained(FocusEvent e) {
+}
+
+/**
+ * Sent when a control loses focus.
+ * The default behavior is to do nothing.
+ *
+ * @param e an event containing information about the focus change
+ */
+public void focusLost(FocusEvent e) {
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/events/FocusEvent.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/events/FocusEvent.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/events/FocusEvent.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.events;
+
+
+import org.eclipse.swt.widgets.Event;
+
+/**
+ * Instances of this class are sent as a result of
+ * widgets gaining and losing focus.
+ *
+ * @see FocusListener
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+
+public final class FocusEvent extends TypedEvent {
+
+	static final long serialVersionUID = 3258134643684227381L;
+
+/**
+ * Constructs a new instance of this class based on the
+ * information in the given untyped event.
+ *
+ * @param e the untyped event containing the information
+ */
+public FocusEvent(Event e) {
+	super(e);
+}
+
+}
+

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/events/FocusListener.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/events/FocusListener.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/events/FocusListener.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.events;
+
+
+import org.eclipse.swt.internal.SWTEventListener;
+
+/**
+ * Classes which implement this interface provide methods
+ * that deal with the events that are generated as controls
+ * gain and lose focus.
+ * <p>
+ * After creating an instance of a class that implements
+ * this interface it can be added to a control using the
+ * <code>addFocusListener</code> method and removed using
+ * the <code>removeFocusListener</code> method. When a
+ * control gains or loses focus, the appropriate method
+ * will be invoked.
+ * </p>
+ *
+ * @see FocusAdapter
+ * @see FocusEvent
+ */
+public interface FocusListener extends SWTEventListener {
+
+/**
+ * Sent when a control gets focus.
+ *
+ * @param e an event containing information about the focus change
+ */
+public void focusGained(FocusEvent e);
+
+/**
+ * Sent when a control loses focus.
+ *
+ * @param e an event containing information about the focus change
+ */
+public void focusLost(FocusEvent e);
+}
+

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/events/HelpEvent.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/events/HelpEvent.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/events/HelpEvent.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.events;
+
+
+import org.eclipse.swt.widgets.Event;
+
+/**
+ * Instances of this class are sent as a result of
+ * help being requested for a widget.
+ *
+ * @see HelpListener
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+
+public final class HelpEvent extends TypedEvent {
+
+	static final long serialVersionUID = 3257001038606251315L;
+
+/**
+ * Constructs a new instance of this class based on the
+ * information in the given untyped event.
+ *
+ * @param e the untyped event containing the information
+ */
+public HelpEvent(Event e) {
+	super(e);
+}
+
+}
+

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/events/HelpListener.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/events/HelpListener.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/events/HelpListener.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.events;
+
+
+import org.eclipse.swt.internal.SWTEventListener;
+
+/**
+ * Classes which implement this interface provide a method
+ * that deals with the event that is generated when help is
+ * requested for a control, typically when the user presses F1.
+ * <p>
+ * After creating an instance of a class that implements
+ * this interface it can be added to a control using the
+ * <code>addHelpListener</code> method and removed using
+ * the <code>removeHelpListener</code> method. When help
+ * is requested for a control, the helpRequested method
+ * will be invoked.
+ * </p>
+ *
+ * @see HelpEvent
+ */
+public interface HelpListener extends SWTEventListener {
+
+/**
+ * Sent when help is requested for a control, typically
+ * when the user presses F1.
+ *
+ * @param e an event containing information about the help
+ */
+public void helpRequested(HelpEvent e);
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/events/KeyAdapter.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/events/KeyAdapter.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/events/KeyAdapter.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.events;
+
+
+/**
+ * This adapter class provides default implementations for the
+ * methods described by the <code>KeyListener</code> interface.
+ * <p>
+ * Classes that wish to deal with <code>KeyEvent</code>s can
+ * extend this class and override only the methods which they are
+ * interested in.
+ * </p>
+ *
+ * @see KeyListener
+ * @see KeyEvent
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public abstract class KeyAdapter implements KeyListener {
+
+/**
+ * Sent when a key is pressed on the system keyboard.
+ * The default behavior is to do nothing.
+ *
+ * @param e an event containing information about the key press
+ */
+public void keyPressed(KeyEvent e) {
+}
+
+/**
+ * Sent when a key is released on the system keyboard.
+ * The default behavior is to do nothing.
+ *
+ * @param e an event containing information about the key release
+ */
+public void keyReleased(KeyEvent e) {
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/events/KeyEvent.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/events/KeyEvent.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/events/KeyEvent.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,107 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.events;
+
+
+import org.eclipse.swt.widgets.Event;
+
+/**
+ * Instances of this class are sent as a result of
+ * keys being pressed and released on the keyboard.
+ * <p>
+ * When a key listener is added to a control, the control
+ * will take part in widget traversal.  By default, all
+ * traversal keys (such as the tab key and so on) are
+ * delivered to the control.  In order for a control to take
+ * part in traversal, it should listen for traversal events.
+ * Otherwise, the user can traverse into a control but not
+ * out.  Note that native controls such as table and tree
+ * implement key traversal in the operating system.  It is
+ * not necessary to add traversal listeners for these controls,
+ * unless you want to override the default traversal.
+ * </p>
+ *
+ * @see KeyListener
+ * @see TraverseListener
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+
+public class KeyEvent extends TypedEvent {
+	
+ 	/**
+ 	 * the character represented by the key that was typed.  
+	 * This is the final character that results after all modifiers have been
+ 	 * applied.  For example, when the user types Ctrl+A, the character value
+ 	 * is 0x01.  It is important that applications do not attempt to modify the
+ 	 * character value based on a stateMask (such as SWT.CTRL) or the resulting
+ 	 * character will not be correct.
+ 	 */
+	public char character;
+	
+	/**
+	 * the key code of the key that was typed,
+	 * as defined by the key code constants in class <code>SWT</code>.
+	 * When the character field of the event is ambiguous, this field
+	 * contains the unicode value of the original character.  For example,
+	 * typing Ctrl+M or Return both result in the character '\r' but the
+	 * keyCode field will also contain '\r' when Return was typed.
+	 * 
+	 * @see org.eclipse.swt.SWT
+	 */
+	public int keyCode;
+	
+	/**
+	 * the state of the keyboard modifier keys at the time
+	 * the event was generated, as defined by the key code
+	 * constants in class <code>SWT</code>.
+	 * 
+	 * @see org.eclipse.swt.SWT
+	 */
+	public int stateMask;
+	
+	/**
+	 * A flag indicating whether the operation should be allowed.
+	 * Setting this field to <code>false</code> will cancel the operation.
+	 */
+	public boolean doit;
+
+	static final long serialVersionUID = 3256442491011412789L;
+	
+/**
+ * Constructs a new instance of this class based on the
+ * information in the given untyped event.
+ *
+ * @param e the untyped event containing the information
+ */
+public KeyEvent(Event e) {
+	super(e);
+	this.character = e.character;
+	this.keyCode = e.keyCode;
+	this.stateMask = e.stateMask;
+	this.doit = e.doit;
+}
+
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the event
+ */
+public String toString() {
+	String string = super.toString ();
+	return string.substring (0, string.length() - 1) // remove trailing '}'
+		+ " character='" + ((character == 0) ? "\\0" : "" + character) + "'"
+		+ " keyCode=" + keyCode
+		+ " stateMask=" + stateMask
+		+ " doit=" + doit
+		+ "}";
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/events/KeyListener.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/events/KeyListener.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/events/KeyListener.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.events;
+
+
+import org.eclipse.swt.internal.SWTEventListener;
+
+/**
+ * Classes which implement this interface provide methods
+ * that deal with the events that are generated as keys
+ * are pressed on the system keyboard.
+ * <p>
+ * After creating an instance of a class that implements
+ * this interface it can be added to a control using the
+ * <code>addKeyListener</code> method and removed using
+ * the <code>removeKeyListener</code> method. When a
+ * key is pressed or released, the appropriate method will
+ * be invoked.
+ * </p>
+ *
+ * @see KeyAdapter
+ * @see KeyEvent
+ */
+public interface KeyListener extends SWTEventListener {
+
+/**
+ * Sent when a key is pressed on the system keyboard.
+ *
+ * @param e an event containing information about the key press
+ */
+public void keyPressed(KeyEvent e);
+
+/**
+ * Sent when a key is released on the system keyboard.
+ *
+ * @param e an event containing information about the key release
+ */
+public void keyReleased(KeyEvent e);
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/events/MenuAdapter.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/events/MenuAdapter.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/events/MenuAdapter.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.events;
+
+
+/**
+ * This adapter class provides default implementations for the
+ * methods described by the <code>MenuListener</code> interface.
+ * <p>
+ * Classes that wish to deal with <code>MenuEvent</code>s can
+ * extend this class and override only the methods which they are
+ * interested in.
+ * </p>
+ *
+ * @see MenuListener
+ * @see MenuEvent
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public abstract class MenuAdapter implements MenuListener {
+
+/**
+ * Sent when a menu is hidden.
+ * The default behavior is to do nothing.
+ *
+ * @param e an event containing information about the menu operation
+ */
+public void menuHidden(MenuEvent e) {
+}
+
+/**
+ * Sent when a menu is shown.
+ * The default behavior is to do nothing.
+ *
+ * @param e an event containing information about the menu operation
+ */
+public void menuShown(MenuEvent e) {
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/events/MenuDetectEvent.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/events/MenuDetectEvent.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/events/MenuDetectEvent.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,75 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.events;
+
+
+import org.eclipse.swt.widgets.Event;
+
+/**
+ * Instances of this class are sent whenever the platform-
+ * specific trigger for showing a context menu is detected.
+ *
+ * @see MenuDetectListener
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ *
+ * @since 3.3
+ */
+
+public final class MenuDetectEvent extends TypedEvent {
+
+	/**
+	 * the display-relative x coordinate of the pointer
+	 * at the time the context menu trigger occurred
+	 */
+	public int x;
+	
+	/**
+	 * the display-relative y coordinate of the pointer
+	 * at the time the context menu trigger occurred
+	 */	
+	public int y;
+	
+	/**
+	 * A flag indicating whether the operation should be allowed.
+	 * Setting this field to <code>false</code> will cancel the operation.
+	 */
+	public boolean doit;
+
+	private static final long serialVersionUID = -3061660596590828941L;
+
+/**
+ * Constructs a new instance of this class based on the
+ * information in the given untyped event.
+ *
+ * @param e the untyped event containing the information
+ */
+public MenuDetectEvent(Event e) {
+	super(e);
+	this.x = e.x;
+	this.y = e.y;
+	this.doit = e.doit;
+}
+
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the event
+ */
+public String toString() {
+	String string = super.toString ();
+	return string.substring (0, string.length() - 1) // remove trailing '}'
+		+ " x=" + x
+		+ " y=" + y
+		+ " doit=" + doit
+		+ "}";
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/events/MenuDetectListener.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/events/MenuDetectListener.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/events/MenuDetectListener.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.events;
+
+
+import org.eclipse.swt.internal.SWTEventListener;
+
+/**
+ * Classes which implement this interface provide methods
+ * that deal with the events that are generated when the
+ * platform-specific trigger for showing a context menu is
+ * detected.
+ * <p>
+ * After creating an instance of a class that implements
+ * this interface it can be added to a control or TrayItem
+ * using the <code>addMenuDetectListener</code> method and
+ * removed using the <code>removeMenuDetectListener</code> method.
+ * When the context menu trigger occurs, the
+ * <code>menuDetected</code> method will be invoked.
+ * </p>
+ *
+ * @see MenuDetectEvent
+ *
+ * @since 3.3
+ */
+public interface MenuDetectListener extends SWTEventListener {
+
+/**
+ * Sent when the platform-dependent trigger for showing a menu item is detected.
+ *
+ * @param e an event containing information about the menu detect
+ */
+public void menuDetected (MenuDetectEvent e);
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/events/MenuEvent.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/events/MenuEvent.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/events/MenuEvent.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.events;
+
+
+import org.eclipse.swt.widgets.Event;
+
+/**
+ * Instances of this class are sent as a result of
+ * menus being shown and hidden.
+ *
+ * @see MenuListener
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+
+public final class MenuEvent extends TypedEvent {
+
+	static final long serialVersionUID = 3258132440332383025L;
+
+/**
+ * Constructs a new instance of this class based on the
+ * information in the given untyped event.
+ *
+ * @param e the untyped event containing the information
+ */
+public MenuEvent(Event e) {
+	super(e);
+}
+
+}
+

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/events/MenuListener.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/events/MenuListener.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/events/MenuListener.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.events;
+
+
+import org.eclipse.swt.internal.SWTEventListener;
+
+/**
+ * Classes which implement this interface provide methods
+ * that deal with the hiding and showing of menus.
+ * <p>
+ * After creating an instance of a class that implements
+ * this interface it can be added to a menu using the
+ * <code>addMenuListener</code> method and removed using
+ * the <code>removeMenuListener</code> method. When the
+ * menu is hidden or shown, the appropriate method will
+ * be invoked.
+ * </p>
+ *
+ * @see MenuAdapter
+ * @see MenuEvent
+ */
+public interface MenuListener extends SWTEventListener {
+
+/**
+ * Sent when a menu is hidden.
+ *
+ * @param e an event containing information about the menu operation
+ */
+public void menuHidden(MenuEvent e);
+
+/**
+ * Sent when a menu is shown.
+ *
+ * @param e an event containing information about the menu operation
+ */
+public void menuShown(MenuEvent e);
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/events/ModifyEvent.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/events/ModifyEvent.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/events/ModifyEvent.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.events;
+
+
+import org.eclipse.swt.widgets.Event;
+
+/**
+ * Instances of this class are sent as a result of
+ * text being modified.
+ *
+ * @see ModifyListener
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+
+public final class ModifyEvent extends TypedEvent {
+
+	static final long serialVersionUID = 3258129146227011891L;
+
+/**
+ * Constructs a new instance of this class based on the
+ * information in the given untyped event.
+ *
+ * @param e the untyped event containing the information
+ */
+public ModifyEvent(Event e) {
+	super(e);
+}
+
+}
+

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/events/ModifyListener.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/events/ModifyListener.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/events/ModifyListener.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.events;
+
+
+import org.eclipse.swt.internal.SWTEventListener;
+
+/**
+ * Classes which implement this interface provide a method
+ * that deals with the events that are generated when text
+ * is modified.
+ * <p>
+ * After creating an instance of a class that implements
+ * this interface it can be added to a text widget using the
+ * <code>addModifyListener</code> method and removed using
+ * the <code>removeModifyListener</code> method. When the
+ * text is modified, the modifyText method will be invoked.
+ * </p>
+ *
+ * @see ModifyEvent
+ */
+public interface ModifyListener extends SWTEventListener {
+
+/**
+ * Sent when the text is modified.
+ *
+ * @param e an event containing information about the modify
+ */
+public void modifyText(ModifyEvent e);
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/events/MouseAdapter.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/events/MouseAdapter.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/events/MouseAdapter.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.events;
+
+
+/**
+ * This adapter class provides default implementations for the
+ * methods described by the <code>MouseListener</code> interface.
+ * <p>
+ * Classes that wish to deal with <code>MouseEvent</code>s 
+ * which occur as mouse buttons are pressed and released can
+ * extend this class and override only the methods which they are
+ * interested in.
+ * </p>
+ *
+ * @see MouseListener
+ * @see MouseEvent
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public abstract class MouseAdapter implements MouseListener {
+
+/**
+ * Sent when a mouse button is pressed twice within the 
+ * (operating system specified) double click period.
+ * The default behavior is to do nothing.
+ *
+ * @param e an event containing information about the mouse double click
+ *
+ * @see org.eclipse.swt.widgets.Display#getDoubleClickTime()
+ */
+public void mouseDoubleClick(MouseEvent e) {
+}
+
+/**
+ * Sent when a mouse button is pressed.
+ * The default behavior is to do nothing.
+ *
+ * @param e an event containing information about the mouse button press
+ */
+public void mouseDown(MouseEvent e) {
+}
+
+/**
+ * Sent when a mouse button is released.
+ * The default behavior is to do nothing.
+ *
+ * @param e an event containing information about the mouse button release
+ */
+public void mouseUp(MouseEvent e) {
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/events/MouseEvent.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/events/MouseEvent.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/events/MouseEvent.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,102 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.events;
+
+
+import org.eclipse.swt.widgets.Event;
+
+/**
+ * Instances of this class are sent whenever mouse
+ * related actions occur. This includes mouse buttons
+ * being pressed and released, the mouse pointer being 
+ * moved and the mouse pointer crossing widget boundaries.
+ * <p>
+ * Note: The <code>button</code> field is an integer that
+ * represents the mouse button number.  This is not the same
+ * as the <code>SWT</code> mask constants <code>BUTTONx</code>.
+ * </p>
+ *
+ * @see MouseListener
+ * @see MouseMoveListener
+ * @see MouseTrackListener
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+
+public class MouseEvent extends TypedEvent {
+	
+	/**
+	 * the button that was pressed or released; 1 for the
+	 * first button, 2 for the second button, and 3 for the
+	 * third button, etc.
+	 */
+	public int button;
+	
+	/**
+	 * the state of the keyboard modifier keys at the time
+	 * the event was generated
+	 */
+	public int stateMask;
+	
+	/**
+	 * the widget-relative, x coordinate of the pointer
+	 * at the time the mouse button was pressed or released
+	 */
+	public int x;
+	
+	/**
+	 * the widget-relative, y coordinate of the pointer
+	 * at the time the mouse button was pressed or released
+	 */	
+	public int y;
+	
+	/**
+	 * the number times the mouse has been clicked, as defined
+	 * by the operating system; 1 for the first click, 2 for the
+	 * second click and so on.
+	 * 
+	 * @since 3.3
+	 */
+	public int count;
+
+	static final long serialVersionUID = 3257288037011566898L;
+	
+/**
+ * Constructs a new instance of this class based on the
+ * information in the given untyped event.
+ *
+ * @param e the untyped event containing the information
+ */
+public MouseEvent(Event e) {
+	super(e);
+	this.x = e.x;
+	this.y = e.y;
+	this.button = e.button;
+	this.stateMask = e.stateMask;
+	this.count = e.count;
+}
+
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the event
+ */
+public String toString() {
+	String string = super.toString ();
+	return string.substring (0, string.length() - 1) // remove trailing '}'
+		+ " button=" + button
+		+ " stateMask=" + stateMask
+		+ " x=" + x
+		+ " y=" + y
+		+ " count=" + count
+		+ "}";
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/events/MouseListener.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/events/MouseListener.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/events/MouseListener.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.events;
+
+
+import org.eclipse.swt.internal.SWTEventListener;
+
+/**
+ * Classes which implement this interface provide methods
+ * that deal with the events that are generated as mouse buttons
+ * are pressed.
+ * <p>
+ * After creating an instance of a class that implements
+ * this interface it can be added to a control using the
+ * <code>addMouseListener</code> method and removed using
+ * the <code>removeMouseListener</code> method. When a
+ * mouse button is pressed or released, the appropriate method
+ * will be invoked.
+ * </p>
+ *
+ * @see MouseAdapter
+ * @see MouseEvent
+ */
+public interface MouseListener extends SWTEventListener {
+
+/**
+ * Sent when a mouse button is pressed twice within the 
+ * (operating system specified) double click period.
+ *
+ * @param e an event containing information about the mouse double click
+ *
+ * @see org.eclipse.swt.widgets.Display#getDoubleClickTime()
+ */
+public void mouseDoubleClick(MouseEvent e);
+
+/**
+ * Sent when a mouse button is pressed.
+ *
+ * @param e an event containing information about the mouse button press
+ */
+public void mouseDown(MouseEvent e);
+
+/**
+ * Sent when a mouse button is released.
+ *
+ * @param e an event containing information about the mouse button release
+ */
+public void mouseUp(MouseEvent e);
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/events/MouseMoveListener.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/events/MouseMoveListener.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/events/MouseMoveListener.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.events;
+
+
+import org.eclipse.swt.internal.SWTEventListener;
+
+/**
+ * Classes which implement this interface provide a method
+ * that deals with the events that are generated as the mouse
+ * pointer moves.
+ * <p>
+ * After creating an instance of a class that implements
+ * this interface it can be added to a control using the
+ * <code>addMouseMoveListener</code> method and removed using
+ * the <code>removeMouseMoveListener</code> method. As the
+ * mouse moves, the mouseMove method will be invoked.
+ * </p>
+ *
+ * @see MouseEvent
+ */
+public interface MouseMoveListener extends SWTEventListener {
+
+/**
+ * Sent when the mouse moves.
+ *
+ * @param e an event containing information about the mouse move
+ */
+public void mouseMove(MouseEvent e);
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/events/MouseTrackAdapter.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/events/MouseTrackAdapter.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/events/MouseTrackAdapter.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.events;
+
+
+/**
+ * This adapter class provides default implementations for the
+ * methods described by the <code>MouseTrackListener</code> interface.
+ * <p>
+ * Classes that wish to deal with <code>MouseEvent</code>s which
+ * occur as the mouse pointer passes (or hovers) over controls can
+ * extend this class and override only the methods which they are
+ * interested in.
+ * </p>
+ *
+ * @see MouseTrackListener
+ * @see MouseEvent
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public abstract class MouseTrackAdapter implements MouseTrackListener {
+
+/**
+ * Sent when the mouse pointer passes into the area of
+ * the screen covered by a control.
+ * The default behavior is to do nothing.
+ *
+ * @param e an event containing information about the mouse enter
+ */
+public void mouseEnter(MouseEvent e) {
+}
+
+/**
+ * Sent when the mouse pointer passes out of the area of
+ * the screen covered by a control.
+ * The default behavior is to do nothing.
+ *
+ * @param e an event containing information about the mouse exit
+ */
+public void mouseExit(MouseEvent e) {
+}
+
+/**
+ * Sent when the mouse pointer hovers (that is, stops moving
+ * for an (operating system specified) period of time) over
+ * a control.
+ * The default behavior is to do nothing.
+ *
+ * @param e an event containing information about the hover
+ */
+public void mouseHover(MouseEvent e) {
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/events/MouseTrackListener.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/events/MouseTrackListener.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/events/MouseTrackListener.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.events;
+
+
+import org.eclipse.swt.internal.SWTEventListener;
+
+/**
+ * Classes which implement this interface provide methods
+ * that deal with the events that are generated as the mouse
+ * pointer passes (or hovers) over controls.
+ * <p>
+ * After creating an instance of a class that implements
+ * this interface it can be added to a control using the
+ * <code>addMouseTrackListener</code> method and removed using
+ * the <code>removeMouseTrackListener</code> method. When the
+ * mouse pointer passes into or out of the area of the screen
+ * covered by a control or pauses while over a control, the
+ * appropriate method will be invoked.
+ * </p>
+ *
+ * @see MouseTrackAdapter
+ * @see MouseEvent
+ */
+public interface MouseTrackListener extends SWTEventListener {
+
+/**
+ * Sent when the mouse pointer passes into the area of
+ * the screen covered by a control.
+ *
+ * @param e an event containing information about the mouse enter
+ */
+public void mouseEnter(MouseEvent e);
+
+/**
+ * Sent when the mouse pointer passes out of the area of
+ * the screen covered by a control.
+ *
+ * @param e an event containing information about the mouse exit
+ */
+public void mouseExit(MouseEvent e);
+
+/**
+ * Sent when the mouse pointer hovers (that is, stops moving
+ * for an (operating system specified) period of time) over
+ * a control.
+ *
+ * @param e an event containing information about the hover
+ */
+public void mouseHover(MouseEvent e);
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/events/MouseWheelListener.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/events/MouseWheelListener.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/events/MouseWheelListener.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.events;
+
+
+import org.eclipse.swt.internal.SWTEventListener;
+
+/**
+ * Classes which implement this interface provide a method
+ * that deals with the event that is generated as the mouse
+ * wheel is scrolled.
+ * <p>
+ * After creating an instance of a class that implements
+ * this interface it can be added to a control using the
+ * <code>addMouseWheelListener</code> method and removed using
+ * the <code>removeMouseWheelListener</code> method. When the
+ * mouse wheel is scrolled the <code>mouseScrolled</code> method
+ * will be invoked.
+ * </p>
+ *
+ * @see MouseEvent
+ *
+ * @since 3.3
+ */
+public interface MouseWheelListener extends SWTEventListener {
+
+/**
+ * Sent when the mouse wheel is scrolled.
+ *
+ * @param e an event containing information about the mouse wheel action
+ */
+public void mouseScrolled (MouseEvent e);	
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/events/PaintEvent.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/events/PaintEvent.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/events/PaintEvent.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,102 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.events;
+
+
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.graphics.GC;
+
+/**
+ * Instances of this class are sent as a result of
+ * visible areas of controls requiring re-painting.
+ *
+ * @see PaintListener
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+
+public final class PaintEvent extends TypedEvent {
+	
+	/**
+	 * the graphics context to use when painting
+	 * that is configured to use the colors, font and
+	 * damaged region of the control.  It is valid
+	 * only during the paint and must not be disposed
+	 */
+	public GC gc;
+	
+	/**
+	 * the x offset of the bounding rectangle of the 
+	 * region that requires painting
+	 */
+	public int x;
+	
+	/**
+	 * the y offset of the bounding rectangle of the 
+	 * region that requires painting
+	 */
+	public int y;
+	
+	/**
+	 * the width of the bounding rectangle of the 
+	 * region that requires painting
+	 */
+	public int width;
+	
+	/**
+	 * the height of the bounding rectangle of the 
+	 * region that requires painting
+	 */
+	public int height;
+
+	/**
+	 * the number of following paint events which
+     * are pending which may always be zero on
+	 * some platforms
+	 */
+	public int count;
+
+	static final long serialVersionUID = 3256446919205992497L;
+	
+/**
+ * Constructs a new instance of this class based on the
+ * information in the given untyped event.
+ *
+ * @param e the untyped event containing the information
+ */
+public PaintEvent(Event e) {
+	super(e);
+	this.gc = e.gc;
+	this.x = e.x;
+	this.y = e.y;
+	this.width = e.width;
+	this.height = e.height;
+	this.count = e.count;
+}
+
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the event
+ */
+public String toString() {
+	String string = super.toString ();
+	return string.substring (0, string.length() - 1) // remove trailing '}'
+		+ " gc=" + gc
+		+ " x=" + x
+		+ " y=" + y
+		+ " width=" + width
+		+ " height=" + height
+		+ " count=" + count
+		+ "}";
+}
+}
+

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/events/PaintListener.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/events/PaintListener.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/events/PaintListener.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.events;
+
+
+import org.eclipse.swt.internal.SWTEventListener;
+
+/**
+ * Classes which implement this interface provide methods
+ * that deal with the events that are generated when the
+ * control needs to be painted. 
+ * <p>
+ * After creating an instance of a class that implements
+ * this interface it can be added to a control using the
+ * <code>addPaintListener</code> method and removed using
+ * the <code>removePaintListener</code> method. When a
+ * paint event occurs, the paintControl method will be
+ * invoked.
+ * </p>
+ *
+ * @see PaintEvent
+ */
+public interface PaintListener extends SWTEventListener {
+
+/**
+ * Sent when a paint event occurs for the control.
+ *
+ * @param e an event containing information about the paint
+ */
+public void paintControl(PaintEvent e);
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/events/SelectionAdapter.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/events/SelectionAdapter.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/events/SelectionAdapter.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.events;
+
+
+/**
+ * This adapter class provides default implementations for the
+ * methods described by the <code>SelectionListener</code> interface.
+ * <p>
+ * Classes that wish to deal with <code>SelectionEvent</code>s can
+ * extend this class and override only the methods which they are
+ * interested in.
+ * </p>
+ *
+ * @see SelectionListener
+ * @see SelectionEvent
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public abstract class SelectionAdapter implements SelectionListener {
+
+/**
+ * Sent when selection occurs in the control.
+ * The default behavior is to do nothing.
+ *
+ * @param e an event containing information about the selection
+ */
+public void widgetSelected(SelectionEvent e) {
+}
+
+/**
+ * Sent when default selection occurs in the control.
+ * The default behavior is to do nothing.
+ *
+ * @param e an event containing information about the default selection
+ */
+public void widgetDefaultSelected(SelectionEvent e) {
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/events/SelectionEvent.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/events/SelectionEvent.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/events/SelectionEvent.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,142 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.events;
+
+
+import org.eclipse.swt.widgets.*;
+
+/**
+ * Instances of this class are sent as a result of
+ * widgets being selected.
+ * <p>
+ * Note: The fields that are filled in depend on the widget.
+ * </p>
+ *
+ * @see SelectionListener
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+
+public class SelectionEvent extends TypedEvent {
+	
+	/**
+	 * The item that was selected.
+	 */
+	public Widget item;
+	
+	/**
+	 * Extra detail information about the selection, depending on the widget.
+	 * 
+	 * <p><b>Sash</b><ul>
+	 * <li>{@link org.eclipse.swt.SWT#DRAG}</li>
+	 * </ul></p><p><b>ScrollBar and Slider</b><ul>
+	 * <li>{@link org.eclipse.swt.SWT#DRAG}</li>
+	 * <li>{@link org.eclipse.swt.SWT#HOME}</li>
+	 * <li>{@link org.eclipse.swt.SWT#END}</li>
+	 * <li>{@link org.eclipse.swt.SWT#ARROW_DOWN}</li>
+	 * <li>{@link org.eclipse.swt.SWT#ARROW_UP}</li>
+	 * <li>{@link org.eclipse.swt.SWT#PAGE_DOWN}</li>
+	 * <li>{@link org.eclipse.swt.SWT#PAGE_UP}</li>
+	 * </ul></p><p><b>Table and Tree</b><ul>
+	 * <li>{@link org.eclipse.swt.SWT#CHECK}</li>
+	 * </ul></p><p><b>Text</b><ul>
+	 * <li>{@link org.eclipse.swt.SWT#CANCEL}</li>
+	 * </ul></p><p><b>CoolItem and ToolItem</b><ul>
+	 * <li>{@link org.eclipse.swt.SWT#ARROW}</li>
+	 * </ul></p>
+	 */
+	public int detail;
+
+	/**
+	 * The x location of the selected area.
+	 */
+	public int x;
+	
+	/**
+	 * The y location of selected area.
+	 */
+	public int y;
+	
+	/**
+	 * The width of selected area.
+	 */
+	public int width;
+	
+	/**
+	 * The height of selected area.
+	 */
+	public int height;
+
+	/**
+	 * The state of the keyboard modifier keys at the time
+	 * the event was generated.
+	 */
+	public int stateMask;
+
+	/**
+	 * The text of the hyperlink that was selected.
+	 * This will be either the text of the hyperlink or the value of its HREF,
+	 * if one was specified.
+	 * 
+	 * @see org.eclipse.swt.widgets.Link#setText(String)
+	 * @since 3.1
+	 */
+	public String text;
+	
+	/**
+	 * A flag indicating whether the operation should be allowed.
+	 * Setting this field to <code>false</code> will cancel the
+	 * operation, depending on the widget.
+	 */
+	public boolean doit;
+	
+	static final long serialVersionUID = 3976735856884987953L;
+	
+/**
+ * Constructs a new instance of this class based on the
+ * information in the given untyped event.
+ *
+ * @param e the untyped event containing the information
+ */
+public SelectionEvent(Event e) {
+	super(e);
+	this.item = e.item;
+	this.x = e.x;
+	this.y = e.y;
+	this.width = e.width;
+	this.height = e.height;
+	this.detail = e.detail;
+	this.stateMask = e.stateMask;
+	this.text = e.text;
+	this.doit = e.doit;
+}
+
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the event
+ */
+public String toString() {
+	String string = super.toString ();
+	return string.substring (0, string.length() - 1) // remove trailing '}'
+		+ " item=" + item
+		+ " detail=" + detail
+		+ " x=" + x
+		+ " y=" + y
+		+ " width=" + width
+		+ " height=" + height
+		+ " stateMask=" + stateMask
+		+ " text=" + text
+		+ " doit=" + doit
+		+ "}";
+}
+}
+

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/events/SelectionListener.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/events/SelectionListener.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/events/SelectionListener.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.events;
+
+
+import org.eclipse.swt.internal.SWTEventListener;
+
+/**
+ * Classes which implement this interface provide methods
+ * that deal with the events that are generated when selection
+ * occurs in a control.
+ * <p>
+ * After creating an instance of a class that implements
+ * this interface it can be added to a control using the
+ * <code>addSelectionListener</code> method and removed using
+ * the <code>removeSelectionListener</code> method. When
+ * selection occurs in a control the appropriate method
+ * will be invoked.
+ * </p>
+ *
+ * @see SelectionAdapter
+ * @see SelectionEvent
+ */
+public interface SelectionListener extends SWTEventListener {
+
+/**
+ * Sent when selection occurs in the control.
+ * <p>
+ * For example, selection occurs in a List when the user selects
+ * an item or items with the keyboard or mouse.  On some platforms,
+ * the event occurs when a mouse button or key is pressed.  On others,
+ * it happens when the mouse or key is released.  The exact key or
+ * mouse gesture that causes this event is platform specific.
+ * </p>
+ *
+ * @param e an event containing information about the selection
+ */
+public void widgetSelected(SelectionEvent e);
+
+/**
+ * Sent when default selection occurs in the control.
+ * <p>
+ * For example, on some platforms default selection occurs in a List
+ * when the user double-clicks an item or types return in a Text.
+ * On some platforms, the event occurs when a mouse button or key is
+ * pressed.  On others, it happens when the mouse or key is released.
+ * The exact key or mouse gesture that causes this event is platform
+ * specific.
+ * </p>
+ *
+ * @param e an event containing information about the default selection
+ */
+public void widgetDefaultSelected(SelectionEvent e);
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/events/ShellAdapter.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/events/ShellAdapter.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/events/ShellAdapter.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.events;
+
+
+/**
+ * This adapter class provides default implementations for the
+ * methods described by the <code>ShellListener</code> interface.
+ * <p>
+ * Classes that wish to deal with <code>ShellEvent</code>s can
+ * extend this class and override only the methods which they are
+ * interested in.
+ * </p>
+ *
+ * @see ShellListener
+ * @see ShellEvent
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public abstract class ShellAdapter implements ShellListener {
+
+/**
+ * Sent when a shell becomes the active window.
+ * The default behavior is to do nothing.
+ *
+ * @param e an event containing information about the activation
+ */
+public void shellActivated(ShellEvent e) {
+}
+
+/**
+ * Sent when a shell is closed.
+ * The default behavior is to do nothing.
+ *
+ * @param e an event containing information about the close
+ */
+public void shellClosed(ShellEvent e) {
+}
+
+/**
+ * Sent when a shell stops being the active window.
+ * The default behavior is to do nothing.
+ *
+ * @param e an event containing information about the deactivation
+ */
+public void shellDeactivated(ShellEvent e) {
+}
+
+/**
+ * Sent when a shell is un-minimized.
+ * The default behavior is to do nothing.
+ *
+ * @param e an event containing information about the un-minimization
+ */
+public void shellDeiconified(ShellEvent e) {
+}
+
+/**
+ * Sent when a shell is minimized.
+ * The default behavior is to do nothing.
+ *
+ * @param e an event containing information about the minimization
+ */
+public void shellIconified(ShellEvent e) {
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/events/ShellEvent.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/events/ShellEvent.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/events/ShellEvent.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.events;
+
+
+import org.eclipse.swt.widgets.Event;
+
+/**
+ * Instances of this class are sent as a result of
+ * operations being performed on shells.
+ *
+ * @see ShellListener
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+
+public final class ShellEvent extends TypedEvent {
+
+	/**
+	 * A flag indicating whether the operation should be allowed.
+	 * Setting this field to <code>false</code> will cancel the operation.
+	 */
+	public boolean doit;
+	
+	static final long serialVersionUID = 3257569490479888441L;
+	
+/**
+ * Constructs a new instance of this class based on the
+ * information in the given untyped event.
+ *
+ * @param e the untyped event containing the information
+ */
+public ShellEvent(Event e) {
+	super(e);
+	this.doit = e.doit;
+}
+
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the event
+ */
+public String toString() {
+	String string = super.toString ();
+	return string.substring (0, string.length() - 1) // remove trailing '}'
+		+ " doit=" + doit
+		+ "}";
+}
+}
+

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/events/ShellListener.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/events/ShellListener.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/events/ShellListener.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.events;
+
+
+import org.eclipse.swt.internal.SWTEventListener;
+
+/**
+ * Classes which implement this interface provide methods
+ * that deal with changes in state of <code>Shell</code>s.
+ * <p>
+ * After creating an instance of a class that implements
+ * this interface it can be added to a shell using the
+ * <code>addShellListener</code> method and removed using
+ * the <code>removeShellListener</code> method. When the
+ * state of the shell changes, the appropriate method will
+ * be invoked.
+ * </p>
+ *
+ * @see ShellAdapter
+ * @see ShellEvent
+ */
+public interface ShellListener extends SWTEventListener {
+
+/**
+ * Sent when a shell becomes the active window.
+ *
+ * @param e an event containing information about the activation
+ */
+public void shellActivated(ShellEvent e);
+
+/**
+ * Sent when a shell is closed.
+ *
+ * @param e an event containing information about the close
+ */
+public void shellClosed(ShellEvent e);
+
+/**
+ * Sent when a shell stops being the active window.
+ *
+ * @param e an event containing information about the deactivation
+ */
+public void shellDeactivated(ShellEvent e);
+
+/**
+ * Sent when a shell is un-minimized.
+ *
+ * @param e an event containing information about the un-minimization
+ */
+public void shellDeiconified(ShellEvent e);
+
+/**
+ * Sent when a shell is minimized.
+ *
+ * @param e an event containing information about the minimization
+ */
+public void shellIconified(ShellEvent e);
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/events/TraverseEvent.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/events/TraverseEvent.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/events/TraverseEvent.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,137 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.events;
+
+
+import org.eclipse.swt.widgets.*;
+
+/**
+ * Instances of this class are sent as a result of
+ * widget traversal actions.
+ * <p>
+ * The traversal event allows fine control over keyboard traversal
+ * in a control both to implement traversal and override the default
+ * traversal behavior defined by the system.  This is achieved using
+ * two fields, <code>detail</code> and <code>doit</code>.
+ * </p><p>
+ * When a control is traversed, a traverse event is sent.  The detail
+ * describes the type of traversal and the doit field indicates the default
+ * behavior of the system.  For example, when a right arrow key is pressed
+ * in a text control, the detail field is <code>TRAVERSE_ARROW_NEXT</code>
+ * and the doit field is <code>false</code>, indicating that the system
+ * will not traverse to the next tab item and the arrow key will be
+ * delivered to the text control.  If the same key is pressed in a radio
+ * button, the doit field will be <code>true</code>, indicating that
+ * traversal is to proceed to the next tab item, possibly another radio
+ * button in the group and that the arrow key is not to be delivered
+ * to the radio button.
+ * </p><p>
+ * How can the traversal event be used to implement traversal?
+ * When a tab key is pressed in a canvas, the detail field will be
+ * <code>TRAVERSE_TAB_NEXT</code> and the doit field will be
+ * <code>false</code>.  The default behavior of the system is to
+ * provide no traversal for canvas controls.  This means that by
+ * default in a canvas, a key listener will see every key that the
+ * user types, including traversal keys.  To understand why this
+ * is so, it is important to understand that only the widget implementor
+ * can decide which traversal is appropriate for the widget.  Returning
+ * to the <code>TRAVERSE_TAB_NEXT</code> example, a text widget implemented
+ * by a canvas would typically want to use the tab key to insert a
+ * tab character into the widget.  A list widget implementation, on the
+ * other hand, would like the system default traversal behavior.  Using
+ * only the doit flag, both implementations are possible.  The text widget
+ * implementor sets doit to <code>false</code>, ensuring that the system
+ * will not traverse and that the tab key will be delivered to key listeners.
+ * The list widget implementor sets doit to <code>true</code>, indicating
+ * that the system should perform tab traversal and that the key should not
+ * be delivered to the list widget.
+ * </p><p>
+ * How can the traversal event be used to override system traversal?
+ * When the return key is pressed in a single line text control, the
+ * detail field is <code>TRAVERSE_RETURN</code> and the doit field
+ * is <code>true</code>.  This means that the return key will be processed
+ * by the default button, not the text widget.  If the text widget has
+ * a default selection listener, it will not run because the return key
+ * will be processed by the default button.  Imagine that the text control
+ * is being used as an in-place editor and return is used to dispose the
+ * widget.  Setting doit to <code>false</code> will stop the system from
+ * activating the default button but the key will be delivered to the text
+ * control, running the key and selection listeners for the text.  How
+ * can <code>TRAVERSE_RETURN</code> be implemented so that the default button
+ * will not be activated and the text widget will not see the return key?
+ * This is achieved by setting doit to <code>true</code>, and the detail
+ * to <code>TRAVERSE_NONE</code>.
+ * </p><p>
+ * Note: A widget implementor will typically implement traversal using
+ * only the doit flag to either enable or disable system traversal.
+ * </p>
+ * 
+ * @see TraverseListener
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+
+public final class TraverseEvent extends KeyEvent {
+	
+	/**
+	 * The traversal type.
+	 * <p><ul>
+	 * <li>{@link org.eclipse.swt.SWT#TRAVERSE_NONE}</li>
+	 * <li>{@link org.eclipse.swt.SWT#TRAVERSE_ESCAPE}</li>
+	 * <li>{@link org.eclipse.swt.SWT#TRAVERSE_RETURN}</li>
+	 * <li>{@link org.eclipse.swt.SWT#TRAVERSE_TAB_NEXT}</li>
+	 * <li>{@link org.eclipse.swt.SWT#TRAVERSE_TAB_PREVIOUS}</li>
+	 * <li>{@link org.eclipse.swt.SWT#TRAVERSE_ARROW_NEXT}</li>
+	 * <li>{@link org.eclipse.swt.SWT#TRAVERSE_ARROW_PREVIOUS}</li>
+	 * <li>{@link org.eclipse.swt.SWT#TRAVERSE_MNEMONIC}</li>
+	 * <li>{@link org.eclipse.swt.SWT#TRAVERSE_PAGE_NEXT}</li>
+	 * <li>{@link org.eclipse.swt.SWT#TRAVERSE_PAGE_PREVIOUS}</li>
+	 * </ul></p>
+	 * 
+	 * Setting this field will change the type of traversal.
+	 * For example, setting the detail to <code>TRAVERSE_NONE</code>
+	 * causes no traversal action to be taken.
+	 * 
+	 * When used in conjunction with the <code>doit</code> field, the
+	 * traversal detail field can be useful when overriding the default
+	 * traversal mechanism for a control. For example, setting the doit
+	 * field to <code>false</code> will cancel the operation and allow
+	 * the traversal key stroke to be delivered to the control. Setting
+	 * the doit field to <code>true</code> indicates that the traversal
+	 * described by the detail field is to be performed.
+	 */
+	public int detail;
+	
+	static final long serialVersionUID = 3257565105301239349L;
+	
+/**
+ * Constructs a new instance of this class based on the
+ * information in the given untyped event.
+ *
+ * @param e the untyped event containing the information
+ */
+public TraverseEvent(Event e) {
+	super(e);
+	this.detail = e.detail;
+}
+
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the event
+ */
+public String toString() {
+	String string = super.toString ();
+	return string.substring (0, string.length() - 1) // remove trailing '}'
+		+ " detail=" + detail
+		+ "}";
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/events/TraverseListener.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/events/TraverseListener.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/events/TraverseListener.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.events;
+
+
+import org.eclipse.swt.internal.SWTEventListener;
+
+/**
+ * Classes which implement this interface provide a method
+ * that deals with the events that are generated when a
+ * traverse event occurs in a control.
+ * <p>
+ * After creating an instance of a class that implements
+ * this interface it can be added to a control using the
+ * <code>addTraverseListener</code> method and removed using
+ * the <code>removeTraverseListener</code> method. When a
+ * traverse event occurs in a control, the keyTraversed method
+ * will be invoked.
+ * </p>
+ *
+ * @see TraverseEvent
+ */
+public interface TraverseListener extends SWTEventListener {
+
+/**
+ * Sent when a traverse event occurs in a control.
+ * <p>
+ * A traverse event occurs when the user presses a traversal
+ * key. Traversal keys are typically tab and arrow keys, along
+ * with certain other keys on some platforms. Traversal key
+ * constants beginning with <code>TRAVERSE_</code> are defined
+ * in the <code>SWT</code> class.
+ * </p>
+ *
+ * @param e an event containing information about the traverse
+ */
+public void keyTraversed(TraverseEvent e);
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/events/TreeAdapter.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/events/TreeAdapter.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/events/TreeAdapter.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.events;
+
+
+/**
+ * This adapter class provides default implementations for the
+ * methods described by the <code>TreeListener</code> interface.
+ * <p>
+ * Classes that wish to deal with <code>TreeEvent</code>s can
+ * extend this class and override only the methods which they are
+ * interested in.
+ * </p>
+ *
+ * @see TreeListener
+ * @see TreeEvent
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public abstract class TreeAdapter implements TreeListener {
+
+/**
+ * Sent when a tree branch is collapsed.
+ * The default behavior is to do nothing.
+ *
+ * @param e an event containing information about the tree operation
+ */
+public void treeCollapsed(TreeEvent e) {
+}
+
+/**
+ * Sent when a tree branch is expanded.
+ * The default behavior is to do nothing.
+ *
+ * @param e an event containing information about the tree operation
+ */
+public void treeExpanded(TreeEvent e) {
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/events/TreeEvent.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/events/TreeEvent.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/events/TreeEvent.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.events;
+
+
+import org.eclipse.swt.widgets.Event;
+
+/**
+ * Instances of this class are sent as a result of
+ * trees being expanded and collapsed.
+ *
+ * @see TreeListener
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+
+public final class TreeEvent extends SelectionEvent {
+
+	static final long serialVersionUID = 3257282548009677109L;
+
+/**
+ * Constructs a new instance of this class based on the
+ * information in the given untyped event.
+ *
+ * @param e the untyped event containing the information
+ */
+public TreeEvent(Event e) {
+	super(e);
+}
+
+}
+

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/events/TreeListener.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/events/TreeListener.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/events/TreeListener.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.events;
+
+
+import org.eclipse.swt.internal.SWTEventListener;
+
+/**
+ * Classes which implement this interface provide methods
+ * that deal with the expanding and collapsing of tree
+ * branches.
+ * <p>
+ * After creating an instance of a class that implements
+ * this interface it can be added to a tree control using the
+ * <code>addTreeListener</code> method and removed using
+ * the <code>removeTreeListener</code> method. When a branch
+ * of the tree is expanded or collapsed, the appropriate method
+ * will be invoked.
+ * </p>
+ *
+ * @see TreeAdapter
+ * @see TreeEvent
+ */
+public interface TreeListener extends SWTEventListener {
+
+/**
+ * Sent when a tree branch is collapsed.
+ *
+ * @param e an event containing information about the tree operation
+ */
+public void treeCollapsed(TreeEvent e);
+
+/**
+ * Sent when a tree branch is expanded.
+ *
+ * @param e an event containing information about the tree operation
+ */
+public void treeExpanded(TreeEvent e);
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/events/TypedEvent.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/events/TypedEvent.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/events/TypedEvent.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,104 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.events;
+
+
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.internal.SWTEventObject;
+
+/**
+ * This is the super class for all typed event classes provided
+ * by SWT. Typed events contain particular information which is
+ * applicable to the event occurrence.
+ *
+ * @see org.eclipse.swt.widgets.Event
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public class TypedEvent extends SWTEventObject {
+	
+	/**
+	 * the display where the event occurred
+	 * 
+	 * @since 2.0 
+	 */	
+	public Display display;
+		
+	/**
+	 * the widget that issued the event
+	 */
+	public Widget widget;
+	
+	/**
+	 * the time that the event occurred.
+	 * 
+	 * NOTE: This field is an unsigned integer and should
+	 * be AND'ed with 0xFFFFFFFFL so that it can be treated
+	 * as a signed long.
+	 */	
+	public int time;
+	
+	/**
+	 * a field for application use
+	 */
+	public Object data;
+
+	static final long serialVersionUID = 3257285846578377524L;
+	
+/**
+ * Constructs a new instance of this class.
+ *
+ * @param object the object that fired the event
+ */
+public TypedEvent(Object object) {
+	super(object);
+}
+
+/**
+ * Constructs a new instance of this class based on the
+ * information in the argument.
+ *
+ * @param e the low level event to initialize the receiver with
+ */
+public TypedEvent(Event e) {
+	super(e.widget);
+	this.display = e.display;
+	this.widget = e.widget;
+	this.time = e.time;
+	this.data = e.data;
+}
+
+/**
+ * Returns the name of the event. This is the name of
+ * the class without the package name.
+ *
+ * @return the name of the event
+ */
+String getName () {
+	String string = getClass ().getName ();
+	int index = string.lastIndexOf ('.');
+	if (index == -1) return string;
+	return string.substring (index + 1, string.length ());
+}
+
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the event
+ */
+public String toString() {
+	return getName ()
+		+ "{" + widget
+		+ " time=" + time
+		+ " data=" + data
+		+ "}";
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/events/VerifyEvent.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/events/VerifyEvent.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/events/VerifyEvent.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.events;
+
+
+import org.eclipse.swt.widgets.Event;
+
+/**
+ * Instances of this class are sent as a result of
+ * widgets handling keyboard events
+ *
+ * @see VerifyListener
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+
+public final class VerifyEvent extends KeyEvent {
+	
+	/**
+	 * the range of text being modified.
+	 * Setting these fields has no effect.
+	 */
+	public int start, end;
+	
+	/**
+	 * the new text that will be inserted.
+	 * Setting this field will change the text that is about to
+	 * be inserted or deleted.
+	 */
+	public String text;
+
+	static final long serialVersionUID = 3257003246269577014L;
+	
+/**
+ * Constructs a new instance of this class based on the
+ * information in the given untyped event.
+ *
+ * @param e the untyped event containing the information
+ */
+public VerifyEvent(Event e) {
+	super(e);
+	this.start = e.start;
+	this.end = e.end;
+	this.text = e.text;
+}
+
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the event
+ */
+public String toString() {
+	String string = super.toString ();
+	return string.substring (0, string.length() - 1) // remove trailing '}'
+		+ " start=" + start
+		+ " end=" + end
+		+ " text=" + text
+		+ "}";
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/events/VerifyListener.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/events/VerifyListener.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/events/VerifyListener.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.events;
+
+
+import org.eclipse.swt.internal.SWTEventListener;
+
+/**
+ * Classes which implement this interface provide a method
+ * that deals with the events that are generated when text
+ * is about to be modified.
+ * <p>
+ * After creating an instance of a class that implements
+ * this interface it can be added to a text control using the
+ * <code>addVerifyListener</code> method and removed using
+ * the <code>removeVerifyListener</code> method. When the
+ * text is about to be modified, the verifyText method
+ * will be invoked.
+ * </p>
+ *
+ * @see VerifyEvent
+ */
+public interface VerifyListener extends SWTEventListener {
+
+/**
+ * Sent when the text is about to be modified.
+ * <p>
+ * A verify event occurs after the user has done something
+ * to modify the text (typically typed a key), but before
+ * the text is modified. The doit field in the verify event
+ * indicates whether or not to modify the text.
+ * </p>
+ *
+ * @param e an event containing information about the verify
+ */
+public void verifyText(VerifyEvent e);
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/Color.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/Color.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/Color.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,289 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.graphics;
+
+
+import org.eclipse.swt.internal.gtk.*;
+import org.eclipse.swt.*;
+
+/**
+ * Instances of this class manage the operating system resources that
+ * implement SWT's RGB color model. To create a color you can either
+ * specify the individual color components as integers in the range 
+ * 0 to 255 or provide an instance of an <code>RGB</code>. 
+ * <p>
+ * Application code must explicitly invoke the <code>Color.dispose()</code> 
+ * method to release the operating system resources managed by each instance
+ * when those instances are no longer required.
+ * </p>
+ *
+ * @see RGB
+ * @see Device#getSystemColor
+ * @see <a href="http://www.eclipse.org/swt/snippets/#color">Color and RGB snippets</a>
+ * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: PaintExample</a>
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public final class Color extends Resource {
+	/**
+	 * the handle to the OS color resource 
+	 * (Warning: This field is platform dependent)
+	 * <p>
+	 * <b>IMPORTANT:</b> This field is <em>not</em> part of the SWT
+	 * public API. It is marked public only so that it can be shared
+	 * within the packages provided by SWT. It is not available on all
+	 * platforms and should never be accessed from application code.
+	 * </p>
+	 */
+	public GdkColor handle;
+
+Color(Device device) {
+	super(device);
+}
+
+/**	 
+ * Constructs a new instance of this class given a device and the
+ * desired red, green and blue values expressed as ints in the range
+ * 0 to 255 (where 0 is black and 255 is full brightness). On limited
+ * color devices, the color instance created by this call may not have
+ * the same RGB values as the ones specified by the arguments. The
+ * RGB values on the returned instance will be the color values of 
+ * the operating system color.
+ * <p>
+ * You must dispose the color when it is no longer required. 
+ * </p>
+ *
+ * @param device the device on which to allocate the color
+ * @param red the amount of red in the color
+ * @param green the amount of green in the color
+ * @param blue the amount of blue in the color
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the red, green or blue argument is not between 0 and 255</li>
+ * </ul>
+ *
+ * @see #dispose
+ */
+public Color(Device device, int red, int green, int blue) {
+	super(device);
+	init(red, green, blue);
+	init();
+}
+
+/**	 
+ * Constructs a new instance of this class given a device and an
+ * <code>RGB</code> describing the desired red, green and blue values.
+ * On limited color devices, the color instance created by this call
+ * may not have the same RGB values as the ones specified by the
+ * argument. The RGB values on the returned instance will be the color
+ * values of the operating system color.
+ * <p>
+ * You must dispose the color when it is no longer required. 
+ * </p>
+ *
+ * @param device the device on which to allocate the color
+ * @param rgb the RGB values of the desired color
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li>
+ *    <li>ERROR_NULL_ARGUMENT - if the rgb argument is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the red, green or blue components of the argument are not between 0 and 255</li>
+ * </ul>
+ *
+ * @see #dispose
+ */
+public Color(Device device, RGB rgb) {
+	super(device);
+	if (rgb == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	init(rgb.red, rgb.green, rgb.blue);
+	init();
+}
+
+void destroy() {
+	int pixel = handle.pixel;
+	if (device.colorRefCount != null) {
+		/* If this was the last reference, remove the color from the list */
+		if (--device.colorRefCount[pixel] == 0) {
+			device.gdkColors[pixel] = null;
+		}
+	}
+	int /*long*/ colormap = OS.gdk_colormap_get_system();
+	OS.gdk_colormap_free_colors(colormap, handle, 1);
+	handle = null;
+}
+
+/**
+ * Compares the argument to the receiver, and returns true
+ * if they represent the <em>same</em> object using a class
+ * specific comparison.
+ *
+ * @param object the object to compare with this object
+ * @return <code>true</code> if the object is the same as this object and <code>false</code> otherwise
+ *
+ * @see #hashCode
+ */
+public boolean equals(Object object) {
+	if (object == this) return true;
+	if (!(object instanceof Color)) return false;
+	Color color = (Color)object;
+	GdkColor gdkColor = color.handle;
+	if (handle == gdkColor) return true;
+	return device == color.device && handle.red == gdkColor.red &&
+		handle.green == gdkColor.green && handle.blue == gdkColor.blue;
+}
+
+/**
+ * Returns the amount of blue in the color, from 0 to 255.
+ *
+ * @return the blue component of the color
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public int getBlue() {
+	if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	return (handle.blue >> 8) & 0xFF;
+}
+
+/**
+ * Returns the amount of green in the color, from 0 to 255.
+ *
+ * @return the green component of the color
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public int getGreen() {
+	if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	return (handle.green >> 8) & 0xFF;
+}
+
+/**
+ * Returns the amount of red in the color, from 0 to 255.
+ *
+ * @return the red component of the color
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public int getRed() {
+	if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	return (handle.red >> 8) & 0xFF;
+}
+
+/**
+ * Returns an integer hash code for the receiver. Any two 
+ * objects that return <code>true</code> when passed to 
+ * <code>equals</code> must return the same value for this
+ * method.
+ *
+ * @return the receiver's hash
+ *
+ * @see #equals
+ */
+public int hashCode() {
+	if (isDisposed()) return 0;
+	return handle.red ^ handle.green ^ handle.blue;
+}
+
+/**
+ * Returns an <code>RGB</code> representing the receiver.
+ *
+ * @return the RGB for the color
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public RGB getRGB () {
+	if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	return new RGB(getRed(), getGreen(), getBlue());
+}
+
+/**	 
+ * Invokes platform specific functionality to allocate a new color.
+ * <p>
+ * <b>IMPORTANT:</b> This method is <em>not</em> part of the public
+ * API for <code>Color</code>. It is marked public only so that it
+ * can be shared within the packages provided by SWT. It is not
+ * available on all platforms, and should never be called from
+ * application code.
+ * </p>
+ *
+ * @param device the device on which to allocate the color
+ * @param handle the handle for the color
+ * 
+ * @private
+ */
+public static Color gtk_new(Device device, GdkColor gdkColor) {
+	Color color = new Color(device);
+	color.handle = gdkColor;
+	return color;
+}
+
+void init(int red, int green, int blue) {
+	if ((red > 255) || (red < 0) ||
+		(green > 255) || (green < 0) ||
+		(blue > 255) || (blue < 0)) {
+			SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	}
+	GdkColor gdkColor = new GdkColor();
+	gdkColor.red = (short)((red & 0xFF) | ((red & 0xFF) << 8));
+	gdkColor.green = (short)((green & 0xFF) | ((green & 0xFF) << 8));
+	gdkColor.blue = (short)((blue & 0xFF) | ((blue & 0xFF) << 8));
+	int /*long*/ colormap = OS.gdk_colormap_get_system();
+	if (!OS.gdk_colormap_alloc_color(colormap, gdkColor, true, true)) {
+		/* Allocate black. */
+		gdkColor = new GdkColor();
+		OS.gdk_colormap_alloc_color(colormap, gdkColor, true, true);
+	}
+	handle = gdkColor;
+	if (device.colorRefCount != null) {
+		/* Make a copy of the color to put in the colors array */
+		GdkColor colorCopy = new GdkColor();
+		colorCopy.red = handle.red;
+		colorCopy.green = handle.green;
+		colorCopy.blue = handle.blue;
+		colorCopy.pixel = handle.pixel;
+		device.gdkColors[colorCopy.pixel] = colorCopy;
+		device.colorRefCount[colorCopy.pixel]++;
+	}
+}
+
+/**
+ * Returns <code>true</code> if the color has been disposed,
+ * and <code>false</code> otherwise.
+ * <p>
+ * This method gets the dispose state for the color.
+ * When a color has been disposed, it is an error to
+ * invoke any other method using the color.
+ *
+ * @return <code>true</code> when the color is disposed and <code>false</code> otherwise
+ */
+public boolean isDisposed() {
+	return handle == null;
+}
+
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the receiver
+ */
+public String toString () {
+	if (isDisposed()) return "Color {*DISPOSED*}";
+	return "Color {" + getRed() + ", " + getGreen() + ", " + getBlue() + "}";
+}
+
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/Cursor.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/Cursor.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/Cursor.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,527 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.graphics;
+
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.gtk.*;
+
+/**
+ * Instances of this class manage operating system resources that
+ * specify the appearance of the on-screen pointer. To create a
+ * cursor you specify the device and either a simple cursor style
+ * describing one of the standard operating system provided cursors
+ * or the image and mask data for the desired appearance.
+ * <p>
+ * Application code must explicitly invoke the <code>Cursor.dispose()</code> 
+ * method to release the operating system resources managed by each instance
+ * when those instances are no longer required.
+ * </p>
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>
+ *   CURSOR_ARROW, CURSOR_WAIT, CURSOR_CROSS, CURSOR_APPSTARTING, CURSOR_HELP,
+ *   CURSOR_SIZEALL, CURSOR_SIZENESW, CURSOR_SIZENS, CURSOR_SIZENWSE, CURSOR_SIZEWE,
+ *   CURSOR_SIZEN, CURSOR_SIZES, CURSOR_SIZEE, CURSOR_SIZEW, CURSOR_SIZENE, CURSOR_SIZESE,
+ *   CURSOR_SIZESW, CURSOR_SIZENW, CURSOR_UPARROW, CURSOR_IBEAM, CURSOR_NO, CURSOR_HAND
+ * </dd>
+ * </dl>
+ * <p>
+ * Note: Only one of the above styles may be specified.
+ * </p>
+ *
+ * @see <a href="http://www.eclipse.org/swt/snippets/#cursor">Cursor snippets</a>
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public final class Cursor extends Resource {
+	/**
+	 * the handle to the OS cursor resource
+	 * (Warning: This field is platform dependent)
+	 * <p>
+	 * <b>IMPORTANT:</b> This field is <em>not</em> part of the SWT
+	 * public API. It is marked public only so that it can be shared
+	 * within the packages provided by SWT. It is not available on all
+	 * platforms and should never be accessed from application code.
+	 * </p>
+	 */
+	public int /*long*/ handle;
+
+	static final byte[] APPSTARTING_SRC = {
+		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
+		0x0c, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00,
+		0x7c, 0x00, 0x00, 0x00, (byte)0xfc, 0x00, 0x00, 0x00, (byte)0xfc, 0x01, 0x00, 0x00,
+		(byte)0xfc, 0x3b, 0x00, 0x00, 0x7c, 0x38, 0x00, 0x00, 0x6c, 0x54, 0x00, 0x00,
+		(byte)0xc4, (byte)0xdc, 0x00, 0x00, (byte)0xc0, 0x44, 0x00, 0x00, (byte)0x80, 0x39, 0x00, 0x00,
+		(byte)0x80, 0x39, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+
+	static final byte[] APPSTARTING_MASK = {
+		0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00,
+		0x1e, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00,
+		(byte)0xfe, 0x00, 0x00, 0x00, (byte)0xfe, 0x01, 0x00, 0x00, (byte)0xfe, 0x3b, 0x00, 0x00,
+		(byte)0xfe, 0x7f, 0x00, 0x00, (byte)0xfe, 0x7f, 0x00, 0x00, (byte)0xfe, (byte)0xfe, 0x00, 0x00,
+		(byte)0xee, (byte)0xff, 0x01, 0x00, (byte)0xe4, (byte)0xff, 0x00, 0x00, (byte)0xc0, 0x7f, 0x00, 0x00,
+		(byte)0xc0, 0x7f, 0x00, 0x00, (byte)0x80, 0x39, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+
+Cursor (Device device) {
+	super(device);
+}
+
+/**	 
+ * Constructs a new cursor given a device and a style
+ * constant describing the desired cursor appearance.
+ * <p>
+ * You must dispose the cursor when it is no longer required. 
+ * </p>
+ *
+ * @param device the device on which to allocate the cursor
+ * @param style the style of cursor to allocate
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li>
+ *    <li>ERROR_INVALID_ARGUMENT - when an unknown style is specified</li>
+ * </ul>
+ * @exception SWTError <ul>
+ *    <li>ERROR_NO_HANDLES - if a handle could not be obtained for cursor creation</li>
+ * </ul>
+ *
+ * @see SWT#CURSOR_ARROW
+ * @see SWT#CURSOR_WAIT
+ * @see SWT#CURSOR_CROSS
+ * @see SWT#CURSOR_APPSTARTING
+ * @see SWT#CURSOR_HELP
+ * @see SWT#CURSOR_SIZEALL
+ * @see SWT#CURSOR_SIZENESW
+ * @see SWT#CURSOR_SIZENS
+ * @see SWT#CURSOR_SIZENWSE
+ * @see SWT#CURSOR_SIZEWE
+ * @see SWT#CURSOR_SIZEN
+ * @see SWT#CURSOR_SIZES
+ * @see SWT#CURSOR_SIZEE
+ * @see SWT#CURSOR_SIZEW
+ * @see SWT#CURSOR_SIZENE
+ * @see SWT#CURSOR_SIZESE
+ * @see SWT#CURSOR_SIZESW
+ * @see SWT#CURSOR_SIZENW
+ * @see SWT#CURSOR_UPARROW
+ * @see SWT#CURSOR_IBEAM
+ * @see SWT#CURSOR_NO
+ * @see SWT#CURSOR_HAND
+ */
+public Cursor(Device device, int style) {
+	super(device);
+	int shape = 0;
+	switch (style) {
+		case SWT.CURSOR_APPSTARTING:	break;
+		case SWT.CURSOR_ARROW:			shape = OS.GDK_LEFT_PTR; break;
+		case SWT.CURSOR_WAIT:			shape = OS.GDK_WATCH; break;
+		case SWT.CURSOR_CROSS:			shape = OS.GDK_CROSS; break;
+		case SWT.CURSOR_HAND:			shape = OS.GDK_HAND2; break;
+		case SWT.CURSOR_HELP:			shape = OS.GDK_QUESTION_ARROW; break;
+		case SWT.CURSOR_SIZEALL:		shape = OS.GDK_FLEUR; break;
+		case SWT.CURSOR_SIZENESW:		shape = OS.GDK_SIZING; break;
+		case SWT.CURSOR_SIZENS:			shape = OS.GDK_DOUBLE_ARROW; break;
+		case SWT.CURSOR_SIZENWSE:		shape = OS.GDK_SIZING; break;
+		case SWT.CURSOR_SIZEWE:			shape = OS.GDK_SB_H_DOUBLE_ARROW; break;
+		case SWT.CURSOR_SIZEN:			shape = OS.GDK_TOP_SIDE; break;
+		case SWT.CURSOR_SIZES:			shape = OS.GDK_BOTTOM_SIDE; break;
+		case SWT.CURSOR_SIZEE:			shape = OS.GDK_RIGHT_SIDE; break;
+		case SWT.CURSOR_SIZEW:			shape = OS.GDK_LEFT_SIDE; break;
+		case SWT.CURSOR_SIZENE:			shape = OS.GDK_TOP_RIGHT_CORNER; break;
+		case SWT.CURSOR_SIZESE:			shape = OS.GDK_BOTTOM_RIGHT_CORNER; break;
+		case SWT.CURSOR_SIZESW:			shape = OS.GDK_BOTTOM_LEFT_CORNER; break;
+		case SWT.CURSOR_SIZENW:			shape = OS.GDK_TOP_LEFT_CORNER; break;
+		case SWT.CURSOR_UPARROW:		shape = OS.GDK_SB_UP_ARROW; break;
+		case SWT.CURSOR_IBEAM:			shape = OS.GDK_XTERM; break;
+		case SWT.CURSOR_NO:				shape = OS.GDK_X_CURSOR; break;
+		default:
+			SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	}
+	if (shape == 0 && style == SWT.CURSOR_APPSTARTING) {
+		handle = createCursor(APPSTARTING_SRC, APPSTARTING_MASK, 32, 32, 2, 2, true);		
+	} else {
+		handle = OS.gdk_cursor_new(shape);
+	}
+	if (handle == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+	init();
+}
+
+/**	 
+ * Constructs a new cursor given a device, image and mask
+ * data describing the desired cursor appearance, and the x
+ * and y coordinates of the <em>hotspot</em> (that is, the point
+ * within the area covered by the cursor which is considered
+ * to be where the on-screen pointer is "pointing").
+ * <p>
+ * The mask data is allowed to be null, but in this case the source
+ * must be an ImageData representing an icon that specifies both
+ * color data and mask data.
+ * <p>
+ * You must dispose the cursor when it is no longer required. 
+ * </p>
+ *
+ * @param device the device on which to allocate the cursor
+ * @param source the color data for the cursor
+ * @param mask the mask data for the cursor (or null)
+ * @param hotspotX the x coordinate of the cursor's hotspot
+ * @param hotspotY the y coordinate of the cursor's hotspot
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li>
+ *    <li>ERROR_NULL_ARGUMENT - if the source is null</li>
+ *    <li>ERROR_NULL_ARGUMENT - if the mask is null and the source does not have a mask</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the source and the mask are not the same 
+ *          size, or if the hotspot is outside the bounds of the image</li>
+ * </ul>
+ * @exception SWTError <ul>
+ *    <li>ERROR_NO_HANDLES - if a handle could not be obtained for cursor creation</li>
+ * </ul>
+ */
+public Cursor(Device device, ImageData source, ImageData mask, int hotspotX, int hotspotY) {
+	super(device);
+	if (source == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	if (mask == null) {
+		if (!(source.getTransparencyType() == SWT.TRANSPARENCY_MASK)) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+		mask = source.getTransparencyMask();
+	}
+	/* Check the bounds. Mask must be the same size as source */
+	if (mask.width != source.width || mask.height != source.height) {
+		SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	}
+	/* Check the hotspots */
+	if (hotspotX >= source.width || hotspotX < 0 ||
+		hotspotY >= source.height || hotspotY < 0) {
+		SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	}
+	/* Convert depth to 1 */
+	source = ImageData.convertMask(source);
+	mask = ImageData.convertMask(mask);
+
+	/* Swap the bits in each byte and convert to appropriate scanline pad */
+	byte[] sourceData = new byte[source.data.length];
+	byte[] maskData = new byte[mask.data.length];
+	byte[] data = source.data;
+	for (int i = 0; i < data.length; i++) {
+		byte s = data[i];
+		sourceData[i] = (byte)(((s & 0x80) >> 7) |
+			((s & 0x40) >> 5) |
+			((s & 0x20) >> 3) |
+			((s & 0x10) >> 1) |
+			((s & 0x08) << 1) |
+			((s & 0x04) << 3) |
+			((s & 0x02) << 5) |
+			((s & 0x01) << 7));
+		sourceData[i] = (byte) ~sourceData[i];
+	}
+	sourceData = ImageData.convertPad(sourceData, source.width, source.height, source.depth, source.scanlinePad, 1);
+	data = mask.data;
+	for (int i = 0; i < data.length; i++) {
+		byte s = data[i];
+		maskData[i] = (byte)(((s & 0x80) >> 7) |
+			((s & 0x40) >> 5) |
+			((s & 0x20) >> 3) |
+			((s & 0x10) >> 1) |
+			((s & 0x08) << 1) |
+			((s & 0x04) << 3) |
+			((s & 0x02) << 5) |
+			((s & 0x01) << 7));
+		maskData[i] = (byte) ~maskData[i];
+	}
+	maskData = ImageData.convertPad(maskData, mask.width, mask.height, mask.depth, mask.scanlinePad, 1);
+	handle = createCursor(maskData, sourceData, source.width, source.height, hotspotX, hotspotY, true);
+	if (handle == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+	init();
+}
+
+/**	 
+ * Constructs a new cursor given a device, image data describing
+ * the desired cursor appearance, and the x and y coordinates of
+ * the <em>hotspot</em> (that is, the point within the area
+ * covered by the cursor which is considered to be where the
+ * on-screen pointer is "pointing").
+ * <p>
+ * You must dispose the cursor when it is no longer required. 
+ * </p>
+ *
+ * @param device the device on which to allocate the cursor
+ * @param source the image data for the cursor
+ * @param hotspotX the x coordinate of the cursor's hotspot
+ * @param hotspotY the y coordinate of the cursor's hotspot
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li>
+ *    <li>ERROR_NULL_ARGUMENT - if the image is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the hotspot is outside the bounds of the
+ * 		 image</li>
+ * </ul>
+ * @exception SWTError <ul>
+ *    <li>ERROR_NO_HANDLES - if a handle could not be obtained for cursor creation</li>
+ * </ul>
+ * 
+ * @since 3.0
+ */
+public Cursor(Device device, ImageData source, int hotspotX, int hotspotY) {
+	super(device);
+	if (source == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	if (hotspotX >= source.width || hotspotX < 0 ||
+		hotspotY >= source.height || hotspotY < 0) {
+		SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	}
+	int /*long*/ display = 0;
+	if (OS.GTK_VERSION >= OS.VERSION(2, 4, 0) && OS.gdk_display_supports_cursor_color(display = OS.gdk_display_get_default ())) {
+		int width = source.width;
+		int height = source.height;
+		PaletteData palette = source.palette;	
+		int /*long*/ pixbuf = OS.gdk_pixbuf_new(OS.GDK_COLORSPACE_RGB, true, 8, width, height);
+		if (pixbuf == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+		int stride = OS.gdk_pixbuf_get_rowstride(pixbuf);
+		int /*long*/ data = OS.gdk_pixbuf_get_pixels(pixbuf);
+		byte[] buffer = source.data;
+		if (!palette.isDirect || source.depth != 24 || stride != source.bytesPerLine || palette.redMask != 0xFF000000 || palette.greenMask != 0xFF0000 || palette.blueMask != 0xFF00) {
+			buffer = new byte[source.width * source.height * 4];
+			if (palette.isDirect) {
+				ImageData.blit(ImageData.BLIT_SRC,
+					source.data, source.depth, source.bytesPerLine, source.getByteOrder(), 0, 0, source.width, source.height, palette.redMask, palette.greenMask, palette.blueMask,
+					ImageData.ALPHA_OPAQUE, null, 0, 0, 0, 
+					buffer, 32, source.width * 4, ImageData.MSB_FIRST, 0, 0, source.width, source.height, 0xFF000000, 0xFF0000, 0xFF00,
+					false, false);
+			} else {
+				RGB[] rgbs = palette.getRGBs();
+				int length = rgbs.length;
+				byte[] srcReds = new byte[length];
+				byte[] srcGreens = new byte[length];
+				byte[] srcBlues = new byte[length];
+				for (int i = 0; i < rgbs.length; i++) {
+					RGB rgb = rgbs[i];
+					if (rgb == null) continue;
+					srcReds[i] = (byte)rgb.red;
+					srcGreens[i] = (byte)rgb.green;
+					srcBlues[i] = (byte)rgb.blue;
+				}
+				ImageData.blit(ImageData.BLIT_SRC,
+					source.data, source.depth, source.bytesPerLine, source.getByteOrder(), 0, 0, source.width, source.height, srcReds, srcGreens, srcBlues,
+					ImageData.ALPHA_OPAQUE, null, 0, 0, 0,
+					buffer, 32, source.width * 4, ImageData.MSB_FIRST, 0, 0, source.width, source.height, 0xFF000000, 0xFF0000, 0xFF00,
+					false, false);
+			}
+			if (source.maskData != null || source.transparentPixel != -1) {
+				ImageData mask = source.getTransparencyMask();
+				byte[] maskData = mask.data;
+				int maskBpl = mask.bytesPerLine;
+				int offset = 3, maskOffset = 0;
+				for (int y = 0; y<source.height; y++) {
+					for (int x = 0; x<source.width; x++) {
+						buffer[offset] = ((maskData[maskOffset + (x >> 3)]) & (1 << (7 - (x & 0x7)))) != 0 ? (byte)0xff : 0;
+						offset += 4;
+					}
+					maskOffset += maskBpl;
+				}
+			} else if (source.alpha != -1) {
+				byte alpha = (byte)source.alpha;
+				for (int i=3; i<buffer.length; i+=4) {
+					buffer[i] = alpha;				
+				}
+			} else if (source.alphaData != null) {
+				byte[] alphaData = source.alphaData;
+				for (int i=3; i<buffer.length; i+=4) {
+					buffer[i] = alphaData[i/4];
+				}
+			}
+		}
+		OS.memmove(data, buffer, stride * height);
+		handle = OS.gdk_cursor_new_from_pixbuf(display, pixbuf, hotspotX, hotspotY);
+		OS.g_object_unref(pixbuf);
+	} else {
+	
+		ImageData mask = source.getTransparencyMask();
+	
+		/* Ensure depth is equal to 1 */
+		if (source.depth > 1) {
+			/* Create a destination image with no data */
+			ImageData newSource = new ImageData(
+				source.width, source.height, 1, ImageData.bwPalette(),
+				1, null, 0, null, null, -1, -1, 0, 0, 0, 0, 0);
+	
+			byte[] newReds = new byte[]{0, (byte)255}, newGreens = newReds, newBlues = newReds;
+	
+			/* Convert the source to a black and white image of depth 1 */
+			PaletteData palette = source.palette;
+			if (palette.isDirect) {
+				ImageData.blit(ImageData.BLIT_SRC,
+						source.data, source.depth, source.bytesPerLine, source.getByteOrder(), 0, 0, source.width, source.height, palette.redMask, palette.greenMask, palette.blueMask,
+						ImageData.ALPHA_OPAQUE, null, 0, 0, 0,
+						newSource.data, newSource.depth, newSource.bytesPerLine, newSource.getByteOrder(), 0, 0, newSource.width, newSource.height, newReds, newGreens, newBlues,
+						false, false);
+			} else {
+				RGB[] rgbs = palette.getRGBs();
+				int length = rgbs.length;
+				byte[] srcReds = new byte[length];
+				byte[] srcGreens = new byte[length];
+				byte[] srcBlues = new byte[length];
+				for (int i = 0; i < rgbs.length; i++) {
+					RGB rgb = rgbs[i];
+					if (rgb == null) continue;
+					srcReds[i] = (byte)rgb.red;
+					srcGreens[i] = (byte)rgb.green;
+					srcBlues[i] = (byte)rgb.blue;
+				}
+				ImageData.blit(ImageData.BLIT_SRC,
+						source.data, source.depth, source.bytesPerLine, source.getByteOrder(), 0, 0, source.width, source.height, srcReds, srcGreens, srcBlues,
+						ImageData.ALPHA_OPAQUE, null, 0, 0, 0,
+						newSource.data, newSource.depth, newSource.bytesPerLine, newSource.getByteOrder(), 0, 0, newSource.width, newSource.height, newReds, newGreens, newBlues,
+						false, false);
+			}
+			source = newSource;
+		}
+	
+		/* Swap the bits in each byte and convert to appropriate scanline pad */
+		byte[] sourceData = new byte[source.data.length];
+		byte[] maskData = new byte[mask.data.length];
+		byte[] data = source.data;
+		for (int i = 0; i < data.length; i++) {
+			byte s = data[i];
+			sourceData[i] = (byte)(((s & 0x80) >> 7) |
+				((s & 0x40) >> 5) |
+				((s & 0x20) >> 3) |
+				((s & 0x10) >> 1) |
+				((s & 0x08) << 1) |
+				((s & 0x04) << 3) |
+				((s & 0x02) << 5) |
+				((s & 0x01) << 7));
+		}
+		sourceData = ImageData.convertPad(sourceData, source.width, source.height, source.depth, source.scanlinePad, 1);
+		data = mask.data;
+		for (int i = 0; i < data.length; i++) {
+			byte s = data[i];
+			maskData[i] = (byte)(((s & 0x80) >> 7) |
+				((s & 0x40) >> 5) |
+				((s & 0x20) >> 3) |
+				((s & 0x10) >> 1) |
+				((s & 0x08) << 1) |
+				((s & 0x04) << 3) |
+				((s & 0x02) << 5) |
+				((s & 0x01) << 7));
+		}
+		maskData = ImageData.convertPad(maskData, mask.width, mask.height, mask.depth, mask.scanlinePad, 1);
+		handle = createCursor(sourceData, maskData, source.width, source.height, hotspotX, hotspotY, false);
+	}
+	if (handle == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+	init();
+}
+
+int /*long*/ createCursor(byte[] sourceData, byte[] maskData, int width, int height, int hotspotX, int hotspotY, boolean reverse) {
+	int /*long*/ sourcePixmap = OS.gdk_bitmap_create_from_data(0, sourceData, width, height);
+	int /*long*/ maskPixmap = OS.gdk_bitmap_create_from_data(0, maskData, width, height);
+	int /*long*/ cursor = 0;
+	if (sourcePixmap != 0 && maskPixmap != 0) {
+		GdkColor foreground = new GdkColor();
+		if (!reverse) foreground.red = foreground.green = foreground.blue = (short)0xFFFF;
+		GdkColor background = new GdkColor();
+		if (reverse) background.red = background.green = background.blue = (short)0xFFFF;
+		cursor = OS.gdk_cursor_new_from_pixmap (sourcePixmap, maskPixmap, foreground, background, hotspotX, hotspotY);
+	}	
+	if (sourcePixmap != 0) OS.g_object_unref (sourcePixmap);
+	if (maskPixmap != 0) OS.g_object_unref (maskPixmap);
+	return cursor;
+}
+
+void destroy() {
+	OS.gdk_cursor_destroy(handle);
+	handle = 0;
+}
+
+/**
+ * Compares the argument to the receiver, and returns true
+ * if they represent the <em>same</em> object using a class
+ * specific comparison.
+ *
+ * @param object the object to compare with this object
+ * @return <code>true</code> if the object is the same as this object and <code>false</code> otherwise
+ *
+ * @see #hashCode
+ */
+public boolean equals(Object object) {
+	if (object == this) return true;
+	if (!(object instanceof Cursor)) return false;
+	Cursor cursor = (Cursor) object;
+	return device == cursor.device && handle == cursor.handle;
+}
+
+/**	 
+ * Invokes platform specific functionality to allocate a new cursor.
+ * <p>
+ * <b>IMPORTANT:</b> This method is <em>not</em> part of the public
+ * API for <code>Cursor</code>. It is marked public only so that it
+ * can be shared within the packages provided by SWT. It is not
+ * available on all platforms, and should never be called from
+ * application code.
+ * </p>
+ *
+ * @param device the device on which to allocate the color
+ * @param handle the handle for the cursor
+ * 
+ * @private
+ */
+public static Cursor gtk_new(Device device, int /*long*/ handle) {
+	Cursor cursor = new Cursor(device);
+	cursor.handle = handle;
+	return cursor;
+}
+
+/**
+ * Returns an integer hash code for the receiver. Any two 
+ * objects that return <code>true</code> when passed to 
+ * <code>equals</code> must return the same value for this
+ * method.
+ *
+ * @return the receiver's hash
+ *
+ * @see #equals
+ */
+public int hashCode() {
+	return (int)/*64*/handle;
+}
+
+/**
+ * Returns <code>true</code> if the cursor has been disposed,
+ * and <code>false</code> otherwise.
+ * <p>
+ * This method gets the dispose state for the cursor.
+ * When a cursor has been disposed, it is an error to
+ * invoke any other method using the cursor.
+ *
+ * @return <code>true</code> when the cursor is disposed and <code>false</code> otherwise
+ */
+public boolean isDisposed() {
+	return handle == 0;
+}
+
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the receiver
+ */
+public String toString () {
+	if (isDisposed()) return "Cursor {*DISPOSED*}";
+	return "Cursor {" + handle + "}";
+}
+
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/Device.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/Device.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/Device.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,887 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.graphics;
+
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.gtk.*;
+
+/**
+ * This class is the abstract superclass of all device objects,
+ * such as the Display device and the Printer device. Devices
+ * can have a graphics context (GC) created for them, and they
+ * can be drawn on by sending messages to the associated GC.
+ *
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public abstract class Device implements Drawable {
+	/**
+	 * the handle to the X Display
+	 * (Warning: This field is platform dependent)
+	 * <p>
+	 * <b>IMPORTANT:</b> This field is <em>not</em> part of the SWT
+	 * public API. It is marked protected only so that it can be shared
+	 * within the packages provided by SWT. It is not available on all
+	 * platforms and should never be accessed from application code.
+	 * </p>
+	 */
+	protected int /*long*/ xDisplay;
+	int /*long*/ shellHandle;
+
+	/* Debugging */
+	public static boolean DEBUG;
+	boolean debug = DEBUG;
+	boolean tracking = DEBUG;
+	Error [] errors;
+	Object [] objects;
+	Object trackingLock;
+	
+	/* Colormap and reference count */
+	GdkColor [] gdkColors;
+	int [] colorRefCount;
+	
+	/* Disposed flag */
+	boolean disposed;
+	
+	/* Warning and Error Handlers */
+	int /*long*/ logProc;
+	Callback logCallback;
+	//NOT DONE - get list of valid names
+	String [] log_domains = {"GLib-GObject", "GLib", "GObject", "Pango", "ATK", "GdkPixbuf", "Gdk", "Gtk", "GnomeVFS"};
+	int [] handler_ids = new int [log_domains.length];
+	int warningLevel;
+	
+	/* X Warning and Error Handlers */
+	static Callback XErrorCallback, XIOErrorCallback;
+	static int /*long*/ XErrorProc, XIOErrorProc, XNullErrorProc, XNullIOErrorProc;
+	static Device[] Devices = new Device[4];
+
+	/*
+	* The following colors are listed in the Windows
+	* Programmer's Reference as the colors in the default
+	* palette.
+	*/
+	Color COLOR_BLACK, COLOR_DARK_RED, COLOR_DARK_GREEN, COLOR_DARK_YELLOW, COLOR_DARK_BLUE;
+	Color COLOR_DARK_MAGENTA, COLOR_DARK_CYAN, COLOR_GRAY, COLOR_DARK_GRAY, COLOR_RED;
+	Color COLOR_GREEN, COLOR_YELLOW, COLOR_BLUE, COLOR_MAGENTA, COLOR_CYAN, COLOR_WHITE;
+
+	/* System Font */
+	Font systemFont;
+	
+	int /*long*/ emptyTab;
+
+	boolean useXRender;
+
+	static boolean CAIRO_LOADED;
+
+	/*
+	* TEMPORARY CODE. When a graphics object is
+	* created and the device parameter is null,
+	* the current Display is used. This presents
+	* a problem because SWT graphics does not
+	* reference classes in SWT widgets. The correct
+	* fix is to remove this feature. Unfortunately,
+	* too many application programs rely on this
+	* feature.
+	*
+	* This code will be removed in the future.
+	*/
+	protected static Device CurrentDevice;
+	protected static Runnable DeviceFinder;
+	static {
+		try {
+			Class.forName ("org.eclipse.swt.widgets.Display");
+		} catch (Throwable e) {}
+	}	
+
+/*
+* TEMPORARY CODE.
+*/
+static synchronized Device getDevice () {
+	if (DeviceFinder != null) DeviceFinder.run();
+	Device device = CurrentDevice;
+	CurrentDevice = null;
+	return device;
+}
+
+/**
+ * Constructs a new instance of this class.
+ * <p>
+ * You must dispose the device when it is no longer required. 
+ * </p>
+ *
+ * @see #create
+ * @see #init
+ * 
+ * @since 3.1
+ */
+public Device() {
+	this(null);
+}
+
+/**
+ * Constructs a new instance of this class.
+ * <p>
+ * You must dispose the device when it is no longer required. 
+ * </p>
+ *
+ * @param data the DeviceData which describes the receiver
+ *
+ * @see #create
+ * @see #init
+ * @see DeviceData
+ */
+public Device(DeviceData data) {
+	synchronized (Device.class) {
+		if (data != null) {
+			debug = data.debug;
+			tracking = data.tracking;
+		}
+		if (tracking) {
+			errors = new Error [128];
+			objects = new Object [128];
+			trackingLock = new Object ();
+		}
+		create (data);
+		init ();
+		register (this);
+	}
+}
+
+void checkCairo() {
+	if (CAIRO_LOADED) return;
+	try {
+		/* Check if cairo is available on the system */
+		byte[] buffer = Converter.wcsToMbcs(null, "libcairo.so.2", true);
+		int /*long*/ libcairo = OS.dlopen(buffer, OS.RTLD_LAZY);
+		if (libcairo != 0) {
+			OS.dlclose(libcairo);
+		} else {
+			try {
+				System.loadLibrary("cairo-swt");
+			} catch (UnsatisfiedLinkError e) {
+				/* Ignore problems loading the fallback library */
+			}
+		}
+		Class.forName("org.eclipse.swt.internal.cairo.Cairo");
+		CAIRO_LOADED = true;
+	} catch (Throwable t) {
+		SWT.error(SWT.ERROR_NO_GRAPHICS_LIBRARY, t, " [Cairo is required]");
+	}
+}
+
+/**
+ * Throws an <code>SWTException</code> if the receiver can not
+ * be accessed by the caller. This may include both checks on
+ * the state of the receiver and more generally on the entire
+ * execution context. This method <em>should</em> be called by
+ * device implementors to enforce the standard SWT invariants.
+ * <p>
+ * Currently, it is an error to invoke any method (other than
+ * <code>isDisposed()</code> and <code>dispose()</code>) on a
+ * device that has had its <code>dispose()</code> method called.
+ * </p><p>
+ * In future releases of SWT, there may be more or fewer error
+ * checks and exceptions may be thrown for different reasons.
+ * <p>
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+protected void checkDevice () {
+	if (disposed) SWT.error(SWT.ERROR_DEVICE_DISPOSED);
+}
+
+/**
+ * Creates the device in the operating system.  If the device
+ * does not have a handle, this method may do nothing depending
+ * on the device.
+ * <p>
+ * This method is called before <code>init</code>.
+ * </p><p>
+ * Subclasses are supposed to reimplement this method and not
+ * call the <code>super</code> implementation.
+ * </p>
+ *
+ * @param data the DeviceData which describes the receiver
+ *
+ * @see #init
+ */
+protected void create (DeviceData data) {
+}
+
+/**
+ * Disposes of the operating system resources associated with
+ * the receiver. After this method has been invoked, the receiver
+ * will answer <code>true</code> when sent the message
+ * <code>isDisposed()</code>.
+ *
+ * @see #release
+ * @see #destroy
+ * @see #checkDevice
+ */
+public void dispose () {
+	synchronized (Device.class) {
+		if (isDisposed()) return;
+		checkDevice ();
+		release ();
+		destroy ();
+		deregister (this);
+		xDisplay = 0;
+		disposed = true;
+		if (tracking) {
+			synchronized (trackingLock) {
+				objects = null;
+				errors = null;
+				trackingLock = null;
+			}
+		}
+	}
+}
+
+void dispose_Object (Object object) {
+	synchronized (trackingLock) {
+		for (int i=0; i<objects.length; i++) {
+			if (objects [i] == object) {
+				objects [i] = null;
+				errors [i] = null;
+				return;
+			}
+		}
+	}
+}
+
+static synchronized Device findDevice (int /*long*/ xDisplay) {
+	for (int i=0; i<Devices.length; i++) {
+		Device device = Devices [i];
+		if (device != null && device.xDisplay == xDisplay) {
+			return device;
+		}
+	}
+	return null;
+}
+
+synchronized static void deregister (Device device) {
+	for (int i=0; i<Devices.length; i++) {
+		if (device == Devices [i]) Devices [i] = null;
+	}
+}
+
+/**
+ * Destroys the device in the operating system and releases
+ * the device's handle.  If the device does not have a handle,
+ * this method may do nothing depending on the device.
+ * <p>
+ * This method is called after <code>release</code>.
+ * </p><p>
+ * Subclasses are supposed to reimplement this method and not
+ * call the <code>super</code> implementation.
+ * </p>
+ *
+ * @see #dispose
+ * @see #release
+ */
+protected void destroy () {
+}
+
+/**
+ * Returns a rectangle describing the receiver's size and location.
+ *
+ * @return the bounding rectangle
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public Rectangle getBounds () {
+	checkDevice ();
+	return new Rectangle(0, 0, 0, 0);
+}
+
+/**
+ * Returns a <code>DeviceData</code> based on the receiver.
+ * Modifications made to this <code>DeviceData</code> will not
+ * affect the receiver.
+ *
+ * @return a <code>DeviceData</code> containing the device's data and attributes
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see DeviceData
+ */
+public DeviceData getDeviceData () {
+	checkDevice();
+	DeviceData data = new DeviceData ();
+	data.debug = debug;
+	data.tracking = tracking;
+	if (tracking) {
+		synchronized (trackingLock) {
+			int count = 0, length = objects.length;
+			for (int i=0; i<length; i++) {
+				if (objects [i] != null) count++;
+			}
+			int index = 0;
+			data.objects = new Object [count];
+			data.errors = new Error [count];
+			for (int i=0; i<length; i++) {
+				if (objects [i] != null) {
+					data.objects [index] = objects [i];
+					data.errors [index] = errors [i];
+					index++;
+				}
+			}
+		}
+	} else {
+		data.objects = new Object [0];
+		data.errors = new Error [0];
+	}
+	return data;
+}
+
+/**
+ * Returns a rectangle which describes the area of the
+ * receiver which is capable of displaying data.
+ * 
+ * @return the client area
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see #getBounds
+ */
+public Rectangle getClientArea () {
+	checkDevice ();
+	return getBounds ();
+}
+
+/**
+ * Returns the bit depth of the screen, which is the number of
+ * bits it takes to represent the number of unique colors that
+ * the screen is currently capable of displaying. This number 
+ * will typically be one of 1, 8, 15, 16, 24 or 32.
+ *
+ * @return the depth of the screen
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public int getDepth () {
+	checkDevice ();
+	return 0;
+}
+
+/**
+ * Returns a point whose x coordinate is the horizontal
+ * dots per inch of the display, and whose y coordinate
+ * is the vertical dots per inch of the display.
+ *
+ * @return the horizontal and vertical DPI
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public Point getDPI () {
+	checkDevice ();
+	return new Point (72, 72);
+}
+
+/**
+ * Returns <code>FontData</code> objects which describe
+ * the fonts that match the given arguments. If the
+ * <code>faceName</code> is null, all fonts will be returned.
+ *
+ * @param faceName the name of the font to look for, or null
+ * @param scalable if true only scalable fonts are returned, otherwise only non-scalable fonts are returned.
+ * @return the matching font data
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public FontData[] getFontList (String faceName, boolean scalable) {
+	checkDevice ();
+	if (!scalable) return new FontData[0];
+	int /*long*/[] family = new int /*long*/[1];
+	int /*long*/[] face = new int /*long*/[1];
+	int /*long*/[] families = new int /*long*/[1];
+	int[] n_families = new int[1];
+	int /*long*/[] faces = new int /*long*/[1];
+	int[] n_faces = new int[1];
+	int /*long*/ context = OS.gdk_pango_context_get();
+	OS.pango_context_list_families(context, families, n_families);
+	int nFds = 0;
+	FontData[] fds = new FontData[faceName != null ? 4 : n_families[0]];
+	for (int i=0; i<n_families[0]; i++) {
+		OS.memmove(family, families[0] + i * OS.PTR_SIZEOF, OS.PTR_SIZEOF);
+		boolean match = true;
+		if (faceName != null) {
+			int /*long*/ familyName = OS.pango_font_family_get_name(family[0]);
+			int length = OS.strlen(familyName);
+			byte[] buffer = new byte[length];
+			OS.memmove(buffer, familyName, length);
+			String name = new String(Converter.mbcsToWcs(null, buffer));
+			match = Compatibility.equalsIgnoreCase(faceName, name);
+		}
+		if (match) {
+		    OS.pango_font_family_list_faces(family[0], faces, n_faces);
+		    for (int j=0; j<n_faces[0]; j++) {
+		        OS.memmove(face, faces[0] + j * OS.PTR_SIZEOF, OS.PTR_SIZEOF);
+		        int /*long*/ fontDesc = OS.pango_font_face_describe(face[0]);
+		        Font font = Font.gtk_new(this, fontDesc);
+		        FontData data = font.getFontData()[0];
+				if (nFds == fds.length) {
+					FontData[] newFds = new FontData[fds.length + n_families[0]];
+					System.arraycopy(fds, 0, newFds, 0, nFds);
+					fds = newFds;
+				}
+				fds[nFds++] = data;
+				OS.pango_font_description_free(fontDesc);
+		    }
+		    OS.g_free(faces[0]);
+		    if (faceName != null) break;
+		}
+	}
+	OS.g_free(families[0]);
+	OS.g_object_unref(context);
+	if (nFds == fds.length) return fds;
+	FontData[] result = new FontData[nFds];
+	System.arraycopy(fds, 0, result, 0, nFds);
+	return result;
+}
+
+/**
+ * Returns the matching standard color for the given
+ * constant, which should be one of the color constants
+ * specified in class <code>SWT</code>. Any value other
+ * than one of the SWT color constants which is passed
+ * in will result in the color black. This color should
+ * not be freed because it was allocated by the system,
+ * not the application.
+ *
+ * @param id the color constant
+ * @return the matching color
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see SWT
+ */
+public Color getSystemColor (int id) {
+	checkDevice ();
+	switch (id) {
+		case SWT.COLOR_BLACK: 				return COLOR_BLACK;
+		case SWT.COLOR_DARK_RED: 			return COLOR_DARK_RED;
+		case SWT.COLOR_DARK_GREEN:	 		return COLOR_DARK_GREEN;
+		case SWT.COLOR_DARK_YELLOW: 		return COLOR_DARK_YELLOW;
+		case SWT.COLOR_DARK_BLUE: 			return COLOR_DARK_BLUE;
+		case SWT.COLOR_DARK_MAGENTA: 		return COLOR_DARK_MAGENTA;
+		case SWT.COLOR_DARK_CYAN: 			return COLOR_DARK_CYAN;
+		case SWT.COLOR_GRAY: 				return COLOR_GRAY;
+		case SWT.COLOR_DARK_GRAY: 			return COLOR_DARK_GRAY;
+		case SWT.COLOR_RED: 				return COLOR_RED;
+		case SWT.COLOR_GREEN: 				return COLOR_GREEN;
+		case SWT.COLOR_YELLOW: 				return COLOR_YELLOW;
+		case SWT.COLOR_BLUE: 				return COLOR_BLUE;
+		case SWT.COLOR_MAGENTA: 			return COLOR_MAGENTA;
+		case SWT.COLOR_CYAN: 				return COLOR_CYAN;
+		case SWT.COLOR_WHITE: 				return COLOR_WHITE;
+	}
+	return COLOR_BLACK;
+}
+
+/**
+ * Returns a reasonable font for applications to use.
+ * On some platforms, this will match the "default font"
+ * or "system font" if such can be found.  This font
+ * should not be freed because it was allocated by the
+ * system, not the application.
+ * <p>
+ * Typically, applications which want the default look
+ * should simply not set the font on the widgets they
+ * create. Widgets are always created with the correct
+ * default font for the class of user-interface component
+ * they represent.
+ * </p>
+ *
+ * @return a font
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public Font getSystemFont () {
+	checkDevice ();
+	return systemFont;
+}
+
+/**
+ * Returns <code>true</code> if the underlying window system prints out
+ * warning messages on the console, and <code>setWarnings</code>
+ * had previously been called with <code>true</code>.
+ *
+ * @return <code>true</code>if warnings are being handled, and <code>false</code> otherwise
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public boolean getWarnings () {
+	checkDevice ();
+	return warningLevel == 0;
+}
+
+/**
+ * Initializes any internal resources needed by the
+ * device.
+ * <p>
+ * This method is called after <code>create</code>.
+ * </p><p>
+ * If subclasses reimplement this method, they must
+ * call the <code>super</code> implementation.
+ * </p>
+ * 
+ * @see #create
+ */
+protected void init () {
+	if (xDisplay != 0) {
+		int[] event_basep = new int[1], error_basep = new int [1];
+		if (OS.XRenderQueryExtension (xDisplay, event_basep, error_basep)) {
+			int[] major_versionp = new int[1], minor_versionp = new int [1];
+			OS.XRenderQueryVersion (xDisplay, major_versionp, minor_versionp);
+			useXRender = major_versionp[0] > 0 || (major_versionp[0] == 0 && minor_versionp[0] >= 8);
+		}
+	}
+
+	if (debug) {
+		if (xDisplay != 0) {
+			/* Create the warning and error callbacks */
+			Class clazz = getClass ();
+			synchronized (clazz) {
+				int index = 0;
+				while (index < Devices.length) {
+					if (Devices [index] != null) break;
+					index++;
+				}
+				if (index == Devices.length) {
+					XErrorCallback = new Callback (clazz, "XErrorProc", 2);
+					XNullErrorProc = XErrorCallback.getAddress ();
+					if (XNullErrorProc == 0) SWT.error (SWT.ERROR_NO_MORE_CALLBACKS);
+					XIOErrorCallback = new Callback (clazz, "XIOErrorProc", 1);
+					XNullIOErrorProc = XIOErrorCallback.getAddress ();
+					if (XNullIOErrorProc == 0) SWT.error (SWT.ERROR_NO_MORE_CALLBACKS);
+					XErrorProc = OS.XSetErrorHandler (XNullErrorProc);
+					XIOErrorProc = OS.XSetIOErrorHandler (XNullIOErrorProc);
+				}
+			}
+			OS.XSynchronize (xDisplay, true);
+		}
+	}
+	
+	/* Create GTK warnings and error callbacks */
+	if (xDisplay != 0) {
+		logCallback = new Callback (this, "logProc", 4);
+		logProc = logCallback.getAddress ();
+		if (logProc == 0) SWT.error (SWT.ERROR_NO_MORE_CALLBACKS);
+		
+		/* Set GTK warning and error handlers */
+		if (debug) {
+			int flags = OS.G_LOG_LEVEL_MASK | OS.G_LOG_FLAG_FATAL | OS.G_LOG_FLAG_RECURSION;
+			for (int i=0; i<log_domains.length; i++) {
+				byte [] log_domain = Converter.wcsToMbcs (null, log_domains [i], true);
+				handler_ids [i] = OS.g_log_set_handler (log_domain, flags, logProc, 0);
+			}
+		}
+	}
+	
+	/* Create the standard colors */
+	COLOR_BLACK = new Color (this, 0,0,0);
+	COLOR_DARK_RED = new Color (this, 0x80,0,0);
+	COLOR_DARK_GREEN = new Color (this, 0,0x80,0);
+	COLOR_DARK_YELLOW = new Color (this, 0x80,0x80,0);
+	COLOR_DARK_BLUE = new Color (this, 0,0,0x80);
+	COLOR_DARK_MAGENTA = new Color (this, 0x80,0,0x80);
+	COLOR_DARK_CYAN = new Color (this, 0,0x80,0x80);
+	COLOR_GRAY = new Color (this, 0xC0,0xC0,0xC0);
+	COLOR_DARK_GRAY = new Color (this, 0x80,0x80,0x80);
+	COLOR_RED = new Color (this, 0xFF,0,0);
+	COLOR_GREEN = new Color (this, 0,0xFF,0);
+	COLOR_YELLOW = new Color (this, 0xFF,0xFF,0);
+	COLOR_BLUE = new Color (this, 0,0,0xFF);
+	COLOR_MAGENTA = new Color (this, 0xFF,0,0xFF);
+	COLOR_CYAN = new Color (this, 0,0xFF,0xFF);
+	COLOR_WHITE = new Color (this, 0xFF,0xFF,0xFF);
+
+	emptyTab = OS.pango_tab_array_new(1, false);
+	if (emptyTab == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+	OS.pango_tab_array_set_tab(emptyTab, 0, OS.PANGO_TAB_LEFT, 1);
+
+	shellHandle = OS.gtk_window_new(OS.GTK_WINDOW_TOPLEVEL);
+	if (shellHandle == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+	OS.gtk_widget_realize(shellHandle);
+
+	/* Initialize the system font slot */
+	systemFont = getSystemFont ();
+}
+
+/**	 
+ * Invokes platform specific functionality to allocate a new GC handle.
+ * <p>
+ * <b>IMPORTANT:</b> This method is <em>not</em> part of the public
+ * API for <code>Device</code>. It is marked public only so that it
+ * can be shared within the packages provided by SWT. It is not
+ * available on all platforms, and should never be called from
+ * application code.
+ * </p>
+ *
+ * @param data the platform specific GC data 
+ * @return the platform specific GC handle
+ */
+public abstract int /*long*/ internal_new_GC (GCData data);
+
+/**	 
+ * Invokes platform specific functionality to dispose a GC handle.
+ * <p>
+ * <b>IMPORTANT:</b> This method is <em>not</em> part of the public
+ * API for <code>Device</code>. It is marked public only so that it
+ * can be shared within the packages provided by SWT. It is not
+ * available on all platforms, and should never be called from
+ * application code.
+ * </p>
+ *
+ * @param hDC the platform specific GC handle
+ * @param data the platform specific GC data 
+ */
+public abstract void internal_dispose_GC (int /*long*/ handle, GCData data);
+
+/**
+ * Returns <code>true</code> if the device has been disposed,
+ * and <code>false</code> otherwise.
+ * <p>
+ * This method gets the dispose state for the device.
+ * When a device has been disposed, it is an error to
+ * invoke any other method using the device.
+ *
+ * @return <code>true</code> when the device is disposed and <code>false</code> otherwise
+ */
+public boolean isDisposed () {
+	synchronized (Device.class) {
+		return disposed;
+	}
+}
+
+/**
+ * Loads the font specified by a file.  The font will be
+ * present in the list of fonts available to the application.
+ *
+ * @param path the font file path
+ * @return whether the font was successfully loaded
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if path is null</li>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see Font
+ * 
+ * @since 3.3
+ */
+public boolean loadFont (String path) {
+	checkDevice();
+	if (path == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+	byte [] buffer = Converter.wcsToMbcs (null, path, true);
+	return OS.FcConfigAppFontAddFile (0, buffer);
+}
+
+int /*long*/ logProc (int /*long*/ log_domain, int /*long*/ log_level, int /*long*/ message, int /*long*/ user_data) {
+	if (warningLevel == 0) {
+		if (DEBUG || debug) {
+			new Error ().printStackTrace ();
+		}
+		OS.g_log_default_handler (log_domain, (int)/*64*/log_level, message, 0);
+	}
+	return 0;
+}
+
+void new_Object (Object object) {
+	synchronized (trackingLock) {
+		for (int i=0; i<objects.length; i++) {
+			if (objects [i] == null) {
+				objects [i] = object;
+				errors [i] = new Error ();
+				return;
+			}
+		}
+		Object [] newObjects = new Object [objects.length + 128];
+		System.arraycopy (objects, 0, newObjects, 0, objects.length);
+		newObjects [objects.length] = object;
+		objects = newObjects;
+		Error [] newErrors = new Error [errors.length + 128];
+		System.arraycopy (errors, 0, newErrors, 0, errors.length);
+		newErrors [errors.length] = new Error ();
+		errors = newErrors;
+	}
+}
+
+static synchronized void register (Device device) {
+	for (int i=0; i<Devices.length; i++) {
+		if (Devices [i] == null) {
+			Devices [i] = device;
+			return;
+		}
+	}
+	Device [] newDevices = new Device [Devices.length + 4];
+	System.arraycopy (Devices, 0, newDevices, 0, Devices.length);
+	newDevices [Devices.length] = device;
+	Devices = newDevices;
+}
+
+/**
+ * Releases any internal resources back to the operating
+ * system and clears all fields except the device handle.
+ * <p>
+ * When a device is destroyed, resources that were acquired
+ * on behalf of the programmer need to be returned to the
+ * operating system.  For example, if the device allocated a
+ * font to be used as the system font, this font would be
+ * freed in <code>release</code>.  Also,to assist the garbage
+ * collector and minimize the amount of memory that is not
+ * reclaimed when the programmer keeps a reference to a
+ * disposed device, all fields except the handle are zero'd.
+ * The handle is needed by <code>destroy</code>.
+ * </p>
+ * This method is called before <code>destroy</code>.
+ * </p><p>
+ * If subclasses reimplement this method, they must
+ * call the <code>super</code> implementation.
+ * </p>
+ *
+ * @see #dispose
+ * @see #destroy
+ */
+protected void release () {
+	if (shellHandle != 0) OS.gtk_widget_destroy(shellHandle);
+	shellHandle = 0;
+
+	if (gdkColors != null) {
+		int /*long*/ colormap = OS.gdk_colormap_get_system();
+		for (int i = 0; i < gdkColors.length; i++) {
+			GdkColor color = gdkColors [i];
+			if (color != null) {
+				while (colorRefCount [i] > 0) {
+					OS.gdk_colormap_free_colors(colormap, color, 1);
+					--colorRefCount [i];
+				}
+			}
+		}
+	}
+	gdkColors = null;
+	colorRefCount = null;
+	COLOR_BLACK = COLOR_DARK_RED = COLOR_DARK_GREEN = COLOR_DARK_YELLOW = COLOR_DARK_BLUE =
+	COLOR_DARK_MAGENTA = COLOR_DARK_CYAN = COLOR_GRAY = COLOR_DARK_GRAY = COLOR_RED =
+	COLOR_GREEN = COLOR_YELLOW = COLOR_BLUE = COLOR_MAGENTA = COLOR_CYAN = COLOR_WHITE = null;
+		
+	if (emptyTab != 0) OS.pango_tab_array_free(emptyTab);
+	emptyTab = 0;
+
+	/* Free the GTK error and warning handler */
+	if (xDisplay != 0) {
+		for (int i=0; i<handler_ids.length; i++) {
+			if (handler_ids [i] != 0) {
+				byte [] log_domain = Converter.wcsToMbcs (null, log_domains [i], true);
+				OS.g_log_remove_handler (log_domain, handler_ids [i]);
+				handler_ids [i] = 0;
+			}
+		}
+		logCallback.dispose ();  logCallback = null;
+		handler_ids = null;  log_domains = null;
+		logProc = 0;
+	}
+}
+
+/**
+ * If the underlying window system supports printing warning messages
+ * to the console, setting warnings to <code>false</code> prevents these
+ * messages from being printed. If the argument is <code>true</code> then
+ * message printing is not blocked.
+ *
+ * @param warnings <code>true</code>if warnings should be printed, and <code>false</code> otherwise
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void setWarnings (boolean warnings) {
+	checkDevice ();
+	if (warnings) {
+		if (--warningLevel == 0) {
+			if (debug) return;
+			if (logProc != 0) {
+				for (int i=0; i<handler_ids.length; i++) {
+					if (handler_ids [i] != 0) {
+						byte [] log_domain = Converter.wcsToMbcs (null, log_domains [i], true);
+						OS.g_log_remove_handler (log_domain, handler_ids [i]);
+						handler_ids [i] = 0;
+					}
+				}
+			}
+		}
+	} else {
+		if (warningLevel++ == 0) {
+			if (debug) return;
+			if (logProc != 0) {
+				int flags = OS.G_LOG_LEVEL_MASK | OS.G_LOG_FLAG_FATAL | OS.G_LOG_FLAG_RECURSION;
+				for (int i=0; i<log_domains.length; i++) {
+					byte [] log_domain = Converter.wcsToMbcs (null, log_domains [i], true);
+					handler_ids [i] = OS.g_log_set_handler (log_domain, flags, logProc, 0);
+				}
+			}
+		}
+	}
+}
+
+static int /*long*/ XErrorProc (int /*long*/ xDisplay, int /*long*/ xErrorEvent) {
+	Device device = findDevice (xDisplay);
+	if (device != null) {
+		if (device.warningLevel == 0) {
+			if (DEBUG || device.debug) {
+				new SWTError ().printStackTrace ();
+			}
+			OS.Call (XErrorProc, xDisplay, xErrorEvent);
+		}
+	} else {
+		if (DEBUG) new SWTError ().printStackTrace ();
+		OS.Call (XErrorProc, xDisplay, xErrorEvent);
+	}
+	return 0;
+}
+
+static int /*long*/ XIOErrorProc (int /*long*/ xDisplay) {
+	Device device = findDevice (xDisplay);
+	if (device != null) {
+		if (DEBUG || device.debug) {
+			new SWTError ().printStackTrace ();
+		}
+	} else {
+		if (DEBUG) new SWTError ().printStackTrace ();
+	}
+	OS.Call (XIOErrorProc, xDisplay, 0);
+	return 0;
+}
+
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/DeviceData.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/DeviceData.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/DeviceData.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.graphics;
+
+
+public class DeviceData {
+	/*
+	* The following fields are platform dependent.
+	* <p>
+	* <b>IMPORTANT:</b> These fields are <em>not</em> part of the SWT
+	* public API. They are marked public only so that they can be shared
+	* within the packages provided by SWT. They are not available on all
+	* platforms and should never be accessed from application code.
+	* </p>
+	*/
+	public String display_name;
+	public String application_name;
+	public String application_class;
+
+	/*
+	* Debug fields - may not be honoured
+	* on some SWT platforms.
+	*/
+	public boolean debug;
+	public boolean tracking;
+	public Error [] errors;
+	public Object [] objects;
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/Drawable.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/Drawable.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/Drawable.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.graphics;
+
+
+/**
+ * Implementers of <code>Drawable</code> can have a graphics context (GC)
+ * created for them, and then they can be drawn on by sending messages to
+ * their associated GC. SWT images, and device objects such as the Display
+ * device and the Printer device, are drawables.
+ * <p>
+ * <b>IMPORTANT:</b> This class is <em>not</em> part of the SWT
+ * public API. It is marked public only so that it can be shared
+ * within the packages provided by SWT. It should never be
+ * referenced from application code.
+ * </p>
+ * 
+ * @see Device
+ * @see Image
+ * @see GC
+ */
+public interface Drawable {
+
+/**	 
+ * Invokes platform specific functionality to allocate a new GC handle.
+ * <p>
+ * <b>IMPORTANT:</b> This method is <em>not</em> part of the public
+ * API for <code>Drawable</code>. It is marked public only so that it
+ * can be shared within the packages provided by SWT. It is not
+ * available on all platforms, and should never be called from
+ * application code.
+ * </p>
+ *
+ * @param data the platform specific GC data 
+ * @return the platform specific GC handle
+ */
+ 
+public int /*long*/ internal_new_GC (GCData data);
+
+/**	 
+ * Invokes platform specific functionality to dispose a GC handle.
+ * <p>
+ * <b>IMPORTANT:</b> This method is <em>not</em> part of the public
+ * API for <code>Drawable</code>. It is marked public only so that it
+ * can be shared within the packages provided by SWT. It is not
+ * available on all platforms, and should never be called from
+ * application code.
+ * </p>
+ *
+ * @param handle the platform specific GC handle
+ * @param data the platform specific GC data 
+ */
+public void internal_dispose_GC (int /*long*/ handle, GCData data);
+
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/Font.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/Font.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/Font.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,288 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.graphics;
+
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.gtk.*;
+
+/**
+ * Instances of this class manage operating system resources that
+ * define how text looks when it is displayed. Fonts may be constructed
+ * by providing a device and either name, size and style information
+ * or a <code>FontData</code> object which encapsulates this data.
+ * <p>
+ * Application code must explicitly invoke the <code>Font.dispose()</code> 
+ * method to release the operating system resources managed by each instance
+ * when those instances are no longer required.
+ * </p>
+ *
+ * @see FontData
+ * @see <a href="http://www.eclipse.org/swt/snippets/#font">Font snippets</a>
+ * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Examples: GraphicsExample, PaintExample</a>
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public final class Font extends Resource {
+	/**
+	 * the handle to the OS font resource
+	 * (Warning: This field is platform dependent)
+	 * <p>
+	 * <b>IMPORTANT:</b> This field is <em>not</em> part of the SWT
+	 * public API. It is marked public only so that it can be shared
+	 * within the packages provided by SWT. It is not available on all
+	 * platforms and should never be accessed from application code.
+	 * </p>
+	 */
+	public int /*long*/ handle;
+	
+Font(Device device) {
+	super(device);
+}
+
+/**	 
+ * Constructs a new font given a device and font data
+ * which describes the desired font's appearance.
+ * <p>
+ * You must dispose the font when it is no longer required. 
+ * </p>
+ *
+ * @param device the device to create the font on
+ * @param fd the FontData that describes the desired font (must not be null)
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li>
+ *    <li>ERROR_NULL_ARGUMENT - if the fd argument is null</li>
+ * </ul>
+ * @exception SWTError <ul>
+ *    <li>ERROR_NO_HANDLES - if a font could not be created from the given font data</li>
+ * </ul>
+ */
+public Font(Device device, FontData fd) {
+	super(device);
+	if (fd == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	init(fd.getName(), fd.getHeightF(), fd.getStyle(), fd.string);
+	init();
+}
+
+/**	 
+ * Constructs a new font given a device and an array
+ * of font data which describes the desired font's
+ * appearance.
+ * <p>
+ * You must dispose the font when it is no longer required. 
+ * </p>
+ *
+ * @param device the device to create the font on
+ * @param fds the array of FontData that describes the desired font (must not be null)
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li>
+ *    <li>ERROR_NULL_ARGUMENT - if the fds argument is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the length of fds is zero</li>
+ *    <li>ERROR_NULL_ARGUMENT - if any fd in the array is null</li>
+ * </ul>
+ * @exception SWTError <ul>
+ *    <li>ERROR_NO_HANDLES - if a font could not be created from the given font data</li>
+ * </ul>
+ * 
+ * @since 2.1
+ */
+public Font(Device device, FontData[] fds) {
+	super(device);
+	if (fds == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	if (fds.length == 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	for (int i=0; i<fds.length; i++) {
+		if (fds[i] == null) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	}
+	FontData fd = fds[0];
+	init(fd.getName(), fd.getHeightF(), fd.getStyle(), fd.string);
+	init();
+}
+
+/**	 
+ * Constructs a new font given a device, a font name,
+ * the height of the desired font in points, and a font
+ * style.
+ * <p>
+ * You must dispose the font when it is no longer required. 
+ * </p>
+ *
+ * @param device the device to create the font on
+ * @param name the name of the font (must not be null)
+ * @param height the font height in points
+ * @param style a bit or combination of NORMAL, BOLD, ITALIC
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li>
+ *    <li>ERROR_NULL_ARGUMENT - if the name argument is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the height is negative</li>
+ * </ul>
+ * @exception SWTError <ul>
+ *    <li>ERROR_NO_HANDLES - if a font could not be created from the given arguments</li>
+ * </ul>
+ */
+public Font(Device device, String name, int height, int style) {
+	super(device);
+	init(name, height, style, null);
+	init();
+}
+
+/*public*/ Font(Device device, String name, float height, int style) {
+	super(device);
+	init(name, height, style, null);
+	init();
+}
+
+void destroy() {
+	OS.pango_font_description_free(handle);
+	handle = 0;
+}
+
+/**
+ * Compares the argument to the receiver, and returns true
+ * if they represent the <em>same</em> object using a class
+ * specific comparison.
+ *
+ * @param object the object to compare with this object
+ * @return <code>true</code> if the object is the same as this object and <code>false</code> otherwise
+ *
+ * @see #hashCode
+ */
+public boolean equals(Object object) {
+	if (object == this) return true;
+	if (!(object instanceof Font)) return false;
+	return handle == ((Font)object).handle;
+}
+
+/**
+ * Returns an array of <code>FontData</code>s representing the receiver.
+ * On Windows, only one FontData will be returned per font. On X however, 
+ * a <code>Font</code> object <em>may</em> be composed of multiple X 
+ * fonts. To support this case, we return an array of font data objects.
+ *
+ * @return an array of font data objects describing the receiver
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public FontData[] getFontData() {
+	if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+
+	int /*long*/ family = OS.pango_font_description_get_family(handle);
+	int length = OS.strlen(family);
+	byte[] buffer = new byte[length];
+	OS.memmove(buffer, family, length);
+	String name = new String(Converter.mbcsToWcs(null, buffer));
+	float height = (float)OS.pango_font_description_get_size(handle) / OS.PANGO_SCALE;
+	int pangoStyle = OS.pango_font_description_get_style(handle);
+	int pangoWeight = OS.pango_font_description_get_weight(handle);
+	int style = SWT.NORMAL;
+	if (pangoStyle == OS.PANGO_STYLE_ITALIC) style |= SWT.ITALIC;
+	if (pangoStyle == OS.PANGO_STYLE_OBLIQUE) style |= SWT.ROMAN;
+	if (pangoWeight >= OS.PANGO_WEIGHT_BOLD) style |= SWT.BOLD;
+	int /*long*/ fontString = OS.pango_font_description_to_string (handle);
+	length = OS.strlen (fontString);
+	buffer = new byte [length + 1];
+	OS.memmove (buffer, fontString, length);	
+	OS.g_free (fontString);
+	FontData data = new FontData(name, height, style);
+	data.string = buffer;
+	return new FontData[]{data};
+}
+
+/**	 
+ * Invokes platform specific functionality to allocate a new font.
+ * <p>
+ * <b>IMPORTANT:</b> This method is <em>not</em> part of the public
+ * API for <code>Font</code>. It is marked public only so that it
+ * can be shared within the packages provided by SWT. It is not
+ * available on all platforms, and should never be called from
+ * application code.
+ * </p>
+ *
+ * @param device the device on which to allocate the color
+ * @param handle the handle for the font
+ * 
+ * @private
+ */
+public static Font gtk_new(Device device, int /*long*/ handle) {
+	Font font = new Font(device);
+	font.handle = handle;
+	return font;
+}
+
+/**
+ * Returns an integer hash code for the receiver. Any two 
+ * objects that return <code>true</code> when passed to 
+ * <code>equals</code> must return the same value for this
+ * method.
+ *
+ * @return the receiver's hash
+ *
+ * @see #equals
+ */
+public int hashCode() {
+	return (int)/*64*/handle;
+}
+
+void init(String name, float height, int style, byte[] fontString) {
+	if (name == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	if (height < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	if (fontString != null) {
+		handle = OS.pango_font_description_from_string (fontString);
+		if (handle == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+	} else {
+		handle = OS.pango_font_description_new();
+		if (handle == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+		byte[] buffer = Converter.wcsToMbcs(null, name, true);
+		OS.pango_font_description_set_family(handle, buffer);
+		if (height > 0) {
+			OS.pango_font_description_set_size(handle, (int)(0.5f + height * OS.PANGO_SCALE));
+		}
+		OS.pango_font_description_set_stretch(handle, OS.PANGO_STRETCH_NORMAL);
+		int pangoStyle = OS.PANGO_STYLE_NORMAL;
+		int pangoWeight = OS.PANGO_WEIGHT_NORMAL;
+		if ((style & SWT.ITALIC) != 0) pangoStyle = OS.PANGO_STYLE_ITALIC;
+		if ((style & SWT.ROMAN) != 0) pangoStyle = OS.PANGO_STYLE_OBLIQUE;
+		if ((style & SWT.BOLD) != 0) pangoWeight = OS.PANGO_WEIGHT_BOLD;
+		OS.pango_font_description_set_style(handle, pangoStyle);
+		OS.pango_font_description_set_weight(handle, pangoWeight);
+	}
+}
+
+/**
+ * Returns <code>true</code> if the font has been disposed,
+ * and <code>false</code> otherwise.
+ * <p>
+ * This method gets the dispose state for the font.
+ * When a font has been disposed, it is an error to
+ * invoke any other method using the font.
+ *
+ * @return <code>true</code> when the font is disposed and <code>false</code> otherwise
+ */
+public boolean isDisposed() {
+	return handle == 0;
+}
+
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the receiver
+ */
+public String toString () {
+	if (isDisposed()) return "Font {*DISPOSED*}";
+	return "Font {" + handle + "}";
+}
+
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/FontData.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/FontData.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/FontData.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,446 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.graphics;
+
+
+import org.eclipse.swt.*;
+
+/**
+ * Instances of this class describe operating system fonts.
+ * <p>
+ * For platform-independent behaviour, use the get and set methods
+ * corresponding to the following properties:
+ * <dl>
+ * <dt>height</dt><dd>the height of the font in points</dd>
+ * <dt>name</dt><dd>the face name of the font, which may include the foundry</dd>
+ * <dt>style</dt><dd>A bitwise combination of NORMAL, ITALIC and BOLD</dd>
+ * </dl>
+ * If extra, platform-dependent functionality is required:
+ * <ul>
+ * <li>On <em>Windows</em>, the data member of the <code>FontData</code>
+ * corresponds to a Windows <code>LOGFONT</code> structure whose fields
+ * may be retrieved and modified.</li>
+ * <li>On <em>X</em>, the fields of the <code>FontData</code> correspond
+ * to the entries in the font's XLFD name and may be retrieved and modified.
+ * </ul>
+ * Application code does <em>not</em> need to explicitly release the
+ * resources managed by each instance when those instances are no longer
+ * required, and thus no <code>dispose()</code> method is provided.
+ *
+ * @see Font
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public final class FontData {
+	/**
+	 * the font name
+	 * (Warning: This field is platform dependent)
+	 * <p>
+	 * <b>IMPORTANT:</b> This field is <em>not</em> part of the SWT
+	 * public API. It is marked public only so that it can be shared
+	 * within the packages provided by SWT. It is not available on all
+	 * platforms and should never be accessed from application code.
+	 * </p>
+	 */
+	public String name;
+
+	/**
+	 * The height of the font data in points
+	 * (Warning: This field is platform dependent)
+	 * <p>
+	 * <b>IMPORTANT:</b> This field is <em>not</em> part of the SWT
+	 * public API. It is marked public only so that it can be shared
+	 * within the packages provided by SWT. It is not available on all
+	 * platforms and should never be accessed from application code.
+	 * </p>
+	 */
+	public float height;
+
+	/**
+	 * the font style
+	 * (Warning: This field is platform dependent)
+	 * <p>
+	 * <b>IMPORTANT:</b> This field is <em>not</em> part of the SWT
+	 * public API. It is marked public only so that it can be shared
+	 * within the packages provided by SWT. It is not available on all
+	 * platforms and should never be accessed from application code.
+	 * </p>
+	 */
+	public int style;
+	
+	/**
+	 * the Pango string 
+	 * (Warning: This field is platform dependent)
+	 * <p>
+	 * <b>IMPORTANT:</b> This field is <em>not</em> part of the SWT
+	 * public API. It is marked public only so that it can be shared
+	 * within the packages provided by SWT. It is not available on all
+	 * platforms and should never be accessed from application code.
+	 * </p>
+	 */
+	public byte[] string;
+
+	/**
+	 * The locales of the font
+	 */
+	String lang, country, variant;
+	
+/**	 
+ * Constructs a new uninitialized font data.
+ */
+public FontData () {
+	this("", 12, SWT.NORMAL);
+}
+
+/**
+ * Constructs a new FontData given a string representation
+ * in the form generated by the <code>FontData.toString</code>
+ * method.
+ * <p>
+ * Note that the representation varies between platforms,
+ * and a FontData can only be created from a string that was 
+ * generated on the same platform.
+ * </p>
+ *
+ * @param string the string representation of a <code>FontData</code> (must not be null)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the argument is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the argument does not represent a valid description</li>
+ * </ul>
+ *
+ * @see #toString
+ */
+public FontData(String string) {
+	if (string == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	int start = 0;
+	int end = string.indexOf('|');
+	if (end == -1) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	String version1 = string.substring(start, end);
+	try {
+		if (Integer.parseInt(version1) != 1) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	} catch (NumberFormatException e) {
+		SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	}
+	
+	start = end + 1;
+	end = string.indexOf('|', start);
+	if (end == -1) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	String name = string.substring(start, end);
+	
+	start = end + 1;
+	end = string.indexOf('|', start);
+	if (end == -1) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	float height = 0;
+	try {
+		height = Float.parseFloat(string.substring(start, end));
+	} catch (NumberFormatException e) {
+		SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	}
+	
+	start = end + 1;
+	end = string.indexOf('|', start);
+	if (end == -1) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	int style = 0;
+	try {
+		style = Integer.parseInt(string.substring(start, end));
+	} catch (NumberFormatException e) {
+		SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	}
+
+	start = end + 1;
+	end = string.indexOf('|', start);
+	setName(name);
+	setHeight(height);
+	setStyle(style);
+	if (end == -1) return;
+	String platform = string.substring(start, end);
+
+	start = end + 1;
+	end = string.indexOf('|', start);
+	if (end == -1) return;
+	String version2 = string.substring(start, end);
+
+	if (platform.equals("GTK") && version2.equals("1")) {
+		return;
+	}
+}
+
+/**	 
+ * Constructs a new font data given a font name,
+ * the height of the desired font in points, 
+ * and a font style.
+ *
+ * @param name the name of the font (must not be null)
+ * @param height the font height in points
+ * @param style a bit or combination of NORMAL, BOLD, ITALIC
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - when the font name is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the height is negative</li>
+ * </ul>
+ */
+public FontData(String name, int height, int style) {
+	setName(name);
+	setHeight(height);
+	setStyle(style);
+}
+
+/*public*/ FontData(String name, float height, int style) {
+	setName(name);
+	setHeight(height);
+	setStyle(style);
+}
+
+/**
+ * Compares the argument to the receiver, and returns true
+ * if they represent the <em>same</em> object using a class
+ * specific comparison.
+ *
+ * @param object the object to compare with this object
+ * @return <code>true</code> if the object is the same as this object and <code>false</code> otherwise
+ *
+ * @see #hashCode
+ */
+public boolean equals (Object object) {
+	if (object == this) return true;
+	if (!(object instanceof FontData)) return false;
+	FontData data = (FontData)object;
+	return name.equals(data.name) && height == data.height && style == data.style;
+}
+
+/**
+ * Returns the height of the receiver in points.
+ *
+ * @return the height of this FontData
+ *
+ * @see #setHeight(int)
+ */
+public int getHeight() {
+	return (int)(0.5f + height);
+}
+
+/*public*/ float getHeightF() {
+	return height;
+}
+
+/**
+ * Returns the locale of the receiver.
+ * <p>
+ * The locale determines which platform character set this
+ * font is going to use. Widgets and graphics operations that
+ * use this font will convert UNICODE strings to the platform
+ * character set of the specified locale.
+ * </p>
+ * <p>
+ * On platforms where there are multiple character sets for a
+ * given language/country locale, the variant portion of the
+ * locale will determine the character set.
+ * </p>
+ * 
+ * @return the <code>String</code> representing a Locale object
+ * @since 3.0
+ */
+public String getLocale () {
+	StringBuffer buffer = new StringBuffer ();
+	char sep = '_';
+	if (lang != null) {
+		buffer.append (lang);
+		buffer.append (sep);
+	}
+	if (country != null) {
+		buffer.append (country);
+		buffer.append (sep);
+	}
+	if (variant != null) {
+		buffer.append (variant);
+	}
+	
+	String result = buffer.toString ();
+	int length = result.length ();
+	if (length > 0) {
+		if (result.charAt (length - 1) == sep) {
+			result = result.substring (0, length - 1);
+		}
+	} 
+	return result;
+}
+
+/**
+ * Returns the name of the receiver.
+ * On platforms that support font foundries, the return value will
+ * be the foundry followed by a dash ("-") followed by the face name.
+ *
+ * @return the name of this <code>FontData</code>
+ *
+ * @see #setName
+ */
+public String getName() {
+	return name;
+}
+
+/**
+ * Returns the style of the receiver which is a bitwise OR of 
+ * one or more of the <code>SWT</code> constants NORMAL, BOLD
+ * and ITALIC.
+ *
+ * @return the style of this <code>FontData</code>
+ * 
+ * @see #setStyle
+ */
+public int getStyle() {
+	return style;
+}
+
+/**
+ * Returns an integer hash code for the receiver. Any two 
+ * objects that return <code>true</code> when passed to 
+ * <code>equals</code> must return the same value for this
+ * method.
+ *
+ * @return the receiver's hash
+ *
+ * @see #equals
+ */
+public int hashCode () {
+	return name.hashCode() ^ getHeight() ^ style;
+}
+
+/**
+ * Sets the height of the receiver. The parameter is
+ * specified in terms of points, where a point is one
+ * seventy-second of an inch.
+ *
+ * @param height the height of the <code>FontData</code>
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the height is negative</li>
+ * </ul>
+ * 
+ * @see #getHeight
+ */
+public void setHeight(int height) {
+	if (height < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	this.height = height;
+	this.string = null;
+}
+
+/*public*/ void setHeight(float height) {
+	if (height < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	this.height = height;
+	this.string = null;
+}
+
+/**
+ * Sets the locale of the receiver.
+ * <p>
+ * The locale determines which platform character set this
+ * font is going to use. Widgets and graphics operations that
+ * use this font will convert UNICODE strings to the platform
+ * character set of the specified locale.
+ * </p>
+ * <p>
+ * On platforms where there are multiple character sets for a
+ * given language/country locale, the variant portion of the
+ * locale will determine the character set.
+ * </p>
+ * 
+ * @param locale the <code>String</code> representing a Locale object
+ * @see java.util.Locale#toString
+ */
+public void setLocale(String locale) {
+	lang = country = variant = null;
+	if (locale != null) {
+		char sep = '_';
+		int length = locale.length();
+		int firstSep, secondSep;
+		
+		firstSep = locale.indexOf(sep);
+		if (firstSep == -1) {
+			firstSep = secondSep = length;
+		} else {
+			secondSep = locale.indexOf(sep, firstSep + 1);
+			if (secondSep == -1) secondSep = length;
+		}
+		if (firstSep > 0) lang = locale.substring(0, firstSep);
+		if (secondSep > firstSep + 1) country = locale.substring(firstSep + 1, secondSep);
+		if (length > secondSep + 1) variant = locale.substring(secondSep + 1);
+	}	
+}
+
+/**
+ * Sets the name of the receiver.
+ * <p>
+ * Some platforms support font foundries. On these platforms, the name
+ * of the font specified in setName() may have one of the following forms:
+ * <ol>
+ * <li>a face name (for example, "courier")</li>
+ * <li>a foundry followed by a dash ("-") followed by a face name (for example, "adobe-courier")</li>
+ * </ol>
+ * In either case, the name returned from getName() will include the
+ * foundry.
+ * </p>
+ * <p>
+ * On platforms that do not support font foundries, only the face name
+ * (for example, "courier") is used in <code>setName()</code> and 
+ * <code>getName()</code>.
+ * </p>
+ *
+ * @param name the name of the font data (must not be null)
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - when the font name is null</li>
+ * </ul>
+ *
+ * @see #getName
+ */
+public void setName(String name) {
+	if (name == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	this.name = name;
+	this.string = null;
+}
+
+/**
+ * Sets the style of the receiver to the argument which must
+ * be a bitwise OR of one or more of the <code>SWT</code> 
+ * constants NORMAL, BOLD and ITALIC.  All other style bits are
+ * ignored.
+ *
+ * @param style the new style for this <code>FontData</code>
+ *
+ * @see #getStyle
+ */
+public void setStyle(int style) {
+	this.style = style;
+	this.string = null;
+}
+
+/**
+ * Returns a string representation of the receiver which is suitable
+ * for constructing an equivalent instance using the 
+ * <code>FontData(String)</code> constructor.
+ *
+ * @return a string representation of the FontData
+ *
+ * @see FontData
+ */
+public String toString() {
+	StringBuffer buffer = new StringBuffer();
+	buffer.append("1|");
+	buffer.append(getName());
+	buffer.append("|");
+	buffer.append(getHeightF());
+	buffer.append("|");
+	buffer.append(getStyle());
+	buffer.append("|");
+	buffer.append("GTK|1|");	
+	return buffer.toString();
+}
+
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/FontMetrics.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/FontMetrics.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/FontMetrics.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,133 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.graphics;
+
+
+/**
+ * Instances of this class provide measurement information
+ * about fonts including ascent, descent, height, leading
+ * space between rows, and average character width.
+ * <code>FontMetrics</code> are obtained from <code>GC</code>s
+ * using the <code>getFontMetrics()</code> method.
+ *
+ * @see GC#getFontMetrics
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public final class FontMetrics {
+	int ascent, descent, averageCharWidth, leading, height;
+
+FontMetrics() {
+}
+
+/**
+ * Compares the argument to the receiver, and returns true
+ * if they represent the <em>same</em> object using a class
+ * specific comparison.
+ *
+ * @param object the object to compare with this object
+ * @return <code>true</code> if the object is the same as this object and <code>false</code> otherwise
+ *
+ * @see #hashCode
+ */
+public boolean equals (Object object) {
+	if (object == this) return true;
+	if (!(object instanceof FontMetrics)) return false;
+	FontMetrics metrics = (FontMetrics)object;
+	return ascent == metrics.ascent && descent == metrics.descent &&
+		averageCharWidth == metrics.averageCharWidth && leading == metrics.leading &&
+		height == metrics.height;
+}
+
+/**
+ * Returns the ascent of the font described by the receiver. A
+ * font's <em>ascent</em> is the distance from the baseline to the 
+ * top of actual characters, not including any of the leading area,
+ * measured in pixels.
+ *
+ * @return the ascent of the font
+ */
+public int getAscent() {
+	return ascent;
+}
+
+/**
+ * Returns the average character width, measured in pixels,
+ * of the font described by the receiver.
+ *
+ * @return the average character width of the font
+ */
+public int getAverageCharWidth() {
+	return averageCharWidth;
+}
+
+/**
+ * Returns the descent of the font described by the receiver. A
+ * font's <em>descent</em> is the distance from the baseline to the
+ * bottom of actual characters, not including any of the leading area,
+ * measured in pixels.
+ *
+ * @return the descent of the font
+ */
+public int getDescent() {
+	return descent;
+}
+
+/**
+ * Returns the height of the font described by the receiver, 
+ * measured in pixels. A font's <em>height</em> is the sum of
+ * its ascent, descent and leading area.
+ *
+ * @return the height of the font
+ *
+ * @see #getAscent
+ * @see #getDescent
+ * @see #getLeading
+ */
+public int getHeight() {
+	return height;
+}
+
+/**
+ * Returns the leading area of the font described by the
+ * receiver. A font's <em>leading area</em> is the space
+ * above its ascent which may include accents or other marks.
+ *
+ * @return the leading space of the font
+ */
+public int getLeading() {
+	return leading;
+}
+
+public static FontMetrics gtk_new(int ascent, int descent, int averageCharWidth, int leading, int height) {
+	FontMetrics fontMetrics = new FontMetrics();
+	fontMetrics.ascent = ascent;
+	fontMetrics.descent = descent;
+	fontMetrics.averageCharWidth = averageCharWidth;
+	fontMetrics.leading = leading;
+	fontMetrics.height = height;
+	return fontMetrics;
+}
+
+/**
+ * Returns an integer hash code for the receiver. Any two 
+ * objects that return <code>true</code> when passed to 
+ * <code>equals</code> must return the same value for this
+ * method.
+ *
+ * @return the receiver's hash
+ *
+ * @see #equals
+ */
+public int hashCode() {
+	return ascent ^ descent ^ averageCharWidth ^ leading ^ height;
+}
+
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/GC.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/GC.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/GC.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,4001 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.graphics;
+
+
+import org.eclipse.swt.internal.cairo.*;
+import org.eclipse.swt.internal.gtk.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.*;
+
+/**
+ * Class <code>GC</code> is where all of the drawing capabilities that are 
+ * supported by SWT are located. Instances are used to draw on either an 
+ * <code>Image</code>, a <code>Control</code>, or directly on a <code>Display</code>.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>LEFT_TO_RIGHT, RIGHT_TO_LEFT</dd>
+ * </dl>
+ * 
+ * <p>
+ * The SWT drawing coordinate system is the two-dimensional space with the origin
+ * (0,0) at the top left corner of the drawing area and with (x,y) values increasing
+ * to the right and downward respectively.
+ * </p>
+ * 
+ * <p>
+ * Application code must explicitly invoke the <code>GC.dispose()</code> 
+ * method to release the operating system resources managed by each instance
+ * when those instances are no longer required. This is <em>particularly</em>
+ * important on Windows95 and Windows98 where the operating system has a limited
+ * number of device contexts available.
+ * </p>
+ * 
+ * <p>
+ * Note: Only one of LEFT_TO_RIGHT and RIGHT_TO_LEFT may be specified.
+ * </p>
+ *
+ * @see org.eclipse.swt.events.PaintEvent
+ * @see <a href="http://www.eclipse.org/swt/snippets/#gc">GC snippets</a>
+ * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Examples: GraphicsExample, PaintExample</a>
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public final class GC extends Resource {
+	/**
+	 * the handle to the OS device context
+	 * (Warning: This field is platform dependent)
+	 * <p>
+	 * <b>IMPORTANT:</b> This field is <em>not</em> part of the SWT
+	 * public API. It is marked public only so that it can be shared
+	 * within the packages provided by SWT. It is not available on all
+	 * platforms and should never be accessed from application code.
+	 * </p>
+	 */
+	public int /*long*/ handle;
+	
+	Drawable drawable;
+	GCData data;
+
+	final static int FOREGROUND = 1 << 0;
+	final static int BACKGROUND = 1 << 1;
+	final static int FONT = 1 << 2;
+	final static int LINE_STYLE = 1 << 3;
+	final static int LINE_CAP = 1 << 4;
+	final static int LINE_JOIN = 1 << 5;
+	final static int LINE_WIDTH = 1 << 6;
+	final static int LINE_MITERLIMIT = 1 << 7;
+	final static int BACKGROUND_BG = 1 << 8;
+	final static int DRAW_OFFSET = 1 << 9;	
+	final static int DRAW = FOREGROUND | LINE_WIDTH | LINE_STYLE  | LINE_CAP  | LINE_JOIN | LINE_MITERLIMIT | DRAW_OFFSET;
+	final static int FILL = BACKGROUND;
+
+	static final float[] LINE_DOT = new float[]{1, 1};
+	static final float[] LINE_DASH = new float[]{3, 1};
+	static final float[] LINE_DASHDOT = new float[]{3, 1, 1, 1};
+	static final float[] LINE_DASHDOTDOT = new float[]{3, 1, 1, 1, 1, 1};
+	static final float[] LINE_DOT_ZERO = new float[]{3, 3};
+	static final float[] LINE_DASH_ZERO = new float[]{18, 6};
+	static final float[] LINE_DASHDOT_ZERO = new float[]{9, 6, 3, 6};
+	static final float[] LINE_DASHDOTDOT_ZERO = new float[]{9, 3, 3, 3, 3, 3};
+
+GC() {
+}
+
+/**	 
+ * Constructs a new instance of this class which has been
+ * configured to draw on the specified drawable. Sets the
+ * foreground color, background color and font in the GC
+ * to match those in the drawable.
+ * <p>
+ * You must dispose the graphics context when it is no longer required. 
+ * </p>
+ * @param drawable the drawable to draw on
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the drawable is null</li>
+ *    <li>ERROR_NULL_ARGUMENT - if there is no current device</li>
+ *    <li>ERROR_INVALID_ARGUMENT
+ *          - if the drawable is an image that is not a bitmap or an icon
+ *          - if the drawable is an image or printer that is already selected
+ *            into another graphics context</li>
+ * </ul>
+ * @exception SWTError <ul>
+ *    <li>ERROR_NO_HANDLES if a handle could not be obtained for GC creation</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS if not called from the thread that created the drawable</li>
+ * </ul>
+ */
+public GC(Drawable drawable) {
+	this(drawable, 0);
+}
+
+/**	 
+ * Constructs a new instance of this class which has been
+ * configured to draw on the specified drawable. Sets the
+ * foreground color, background color and font in the GC
+ * to match those in the drawable.
+ * <p>
+ * You must dispose the graphics context when it is no longer required. 
+ * </p>
+ * 
+ * @param drawable the drawable to draw on
+ * @param style the style of GC to construct
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the drawable is null</li>
+ *    <li>ERROR_NULL_ARGUMENT - if there is no current device</li>
+ *    <li>ERROR_INVALID_ARGUMENT
+ *          - if the drawable is an image that is not a bitmap or an icon
+ *          - if the drawable is an image or printer that is already selected
+ *            into another graphics context</li>
+ * </ul>
+ * @exception SWTError <ul>
+ *    <li>ERROR_NO_HANDLES if a handle could not be obtained for GC creation</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS if not called from the thread that created the drawable</li>
+ * </ul>
+ *  
+ * @since 2.1.2
+ */
+public GC(Drawable drawable, int style) {
+	if (drawable == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	GCData data = new GCData();
+	data.style = checkStyle(style);
+	int /*long*/ gdkGC = drawable.internal_new_GC(data);
+	Device device = data.device;
+	if (device == null) device = Device.getDevice();
+	if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	this.device = data.device = device;
+	init(drawable, data, gdkGC);
+	init();
+}
+
+static void addCairoString(int /*long*/ cairo, String string, float x, float y, Font font) {
+	byte[] buffer = Converter.wcsToMbcs(null, string, true);
+	if (OS.GTK_VERSION >= OS.VERSION(2, 8, 0)) {
+		int /*long*/ layout = OS.pango_cairo_create_layout(cairo);
+		if (layout == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+		OS.pango_layout_set_text(layout, buffer, -1);
+		OS.pango_layout_set_font_description(layout, font.handle);
+		double[] currentX = new double[1], currentY = new double[1];
+		Cairo.cairo_get_current_point(cairo, currentX, currentY);
+		if (currentX[0] != x || currentY[0] != y) {
+			Cairo.cairo_move_to(cairo, x, y);
+		}
+		OS.pango_cairo_layout_path(cairo, layout);
+		OS.g_object_unref(layout);
+	} else {
+		GC.setCairoFont(cairo, font);
+		cairo_font_extents_t extents = new cairo_font_extents_t();
+		Cairo.cairo_font_extents(cairo, extents);
+		double baseline = y + extents.ascent;
+		Cairo.cairo_move_to(cairo, x, baseline);
+		Cairo.cairo_text_path(cairo, buffer);
+	}
+}
+
+static int checkStyle (int style) {
+	if ((style & SWT.LEFT_TO_RIGHT) != 0) style &= ~SWT.RIGHT_TO_LEFT;
+	return style & (SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT);
+}
+
+public static GC gtk_new(int /*long*/ handle, GCData data) {
+	GC gc = new GC();
+	gc.device = data.device;
+	gc.init(null, data, handle);
+	return gc;
+}
+
+public static GC gtk_new(Drawable drawable, GCData data) {
+	GC gc = new GC();
+	int /*long*/ gdkGC = drawable.internal_new_GC(data);
+	gc.device = data.device;
+	gc.init(drawable, data, gdkGC);
+	return gc;
+}
+
+void checkGC (int mask) {
+	int state = data.state;
+	if ((state & mask) == mask) return;
+	state = (state ^ mask) & mask;	
+	data.state |= mask;
+	int /*long*/ cairo = data.cairo;
+	if (cairo != 0) {
+		if ((state & (BACKGROUND | FOREGROUND)) != 0) {
+			GdkColor color;
+			Pattern pattern;
+			if ((state & FOREGROUND) != 0) {
+				color = data.foreground;
+				pattern = data.foregroundPattern;
+				data.state &= ~BACKGROUND;
+			} else {
+				color = data.background;
+				pattern = data.backgroundPattern;
+				data.state &= ~FOREGROUND;
+			}
+			if  (pattern != null) {
+				if ((data.style & SWT.MIRRORED) != 0 && pattern.surface != 0) {
+					int /*long*/ newPattern = Cairo.cairo_pattern_create_for_surface(pattern.surface);
+					if (newPattern == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+					Cairo.cairo_pattern_set_extend(newPattern, Cairo.CAIRO_EXTEND_REPEAT);
+					double[] matrix = {-1, 0, 0, 1, 0, 0};
+					Cairo.cairo_pattern_set_matrix(newPattern, matrix);
+					Cairo.cairo_set_source(cairo, newPattern);
+					Cairo.cairo_pattern_destroy(newPattern);
+				} else {
+					Cairo.cairo_set_source(cairo, pattern.handle);
+				}
+			} else {
+				Cairo.cairo_set_source_rgba(cairo, (color.red & 0xFFFF) / (float)0xFFFF, (color.green & 0xFFFF) / (float)0xFFFF, (color.blue & 0xFFFF) / (float)0xFFFF, data.alpha / (float)0xFF);
+			}
+		}
+		if ((state & FONT) != 0) {
+			if (data.layout != 0) {
+				Font font = data.font;
+				OS.pango_layout_set_font_description(data.layout, font.handle);
+			}
+			if (OS.GTK_VERSION < OS.VERSION(2, 8, 0)) {
+				setCairoFont(cairo, data.font);
+			}
+		}
+		if ((state & LINE_CAP) != 0) {
+			int cap_style = 0;
+			switch (data.lineCap) {
+				case SWT.CAP_ROUND: cap_style = Cairo.CAIRO_LINE_CAP_ROUND; break;
+				case SWT.CAP_FLAT: cap_style = Cairo.CAIRO_LINE_CAP_BUTT; break;
+				case SWT.CAP_SQUARE: cap_style = Cairo.CAIRO_LINE_CAP_SQUARE; break;
+			}
+			Cairo.cairo_set_line_cap(cairo, cap_style);
+		}
+		if ((state & LINE_JOIN) != 0) {
+			int join_style = 0;
+			switch (data.lineJoin) {
+				case SWT.JOIN_MITER: join_style = Cairo.CAIRO_LINE_JOIN_MITER; break;
+				case SWT.JOIN_ROUND:  join_style = Cairo.CAIRO_LINE_JOIN_ROUND; break;
+				case SWT.JOIN_BEVEL: join_style = Cairo.CAIRO_LINE_JOIN_BEVEL; break;
+			}
+			Cairo.cairo_set_line_join(cairo, join_style);
+		}
+		if ((state & LINE_WIDTH) != 0) {
+			Cairo.cairo_set_line_width(cairo, data.lineWidth == 0 ? 1 : data.lineWidth);
+			switch (data.lineStyle) {
+				case SWT.LINE_DOT:
+				case SWT.LINE_DASH:
+				case SWT.LINE_DASHDOT:
+				case SWT.LINE_DASHDOTDOT:
+					state |= LINE_STYLE;
+			}
+		}
+		if ((state & LINE_STYLE) != 0) {
+			float dashesOffset = 0;
+			float[] dashes = null;
+			float width = data.lineWidth;
+			switch (data.lineStyle) {
+				case SWT.LINE_SOLID: break;
+				case SWT.LINE_DASH: dashes = width != 0 ? LINE_DASH : LINE_DASH_ZERO; break;
+				case SWT.LINE_DOT: dashes = width != 0 ? LINE_DOT : LINE_DOT_ZERO; break;
+				case SWT.LINE_DASHDOT: dashes = width != 0 ? LINE_DASHDOT : LINE_DASHDOT_ZERO; break;
+				case SWT.LINE_DASHDOTDOT: dashes = width != 0 ? LINE_DASHDOTDOT : LINE_DASHDOTDOT_ZERO; break;
+				case SWT.LINE_CUSTOM: dashes = data.lineDashes; break;
+			}
+			if (dashes != null) {
+				dashesOffset = data.lineDashesOffset;
+				double[] cairoDashes = new double[dashes.length];
+				for (int i = 0; i < cairoDashes.length; i++) {
+					cairoDashes[i] = width == 0 || data.lineStyle == SWT.LINE_CUSTOM ? dashes[i] : dashes[i] * width;
+				}
+				Cairo.cairo_set_dash(cairo, cairoDashes, cairoDashes.length, dashesOffset);
+			} else {
+				Cairo.cairo_set_dash(cairo, null, 0, 0);
+			}
+		}
+		if ((state & LINE_MITERLIMIT) != 0) {
+			Cairo.cairo_set_miter_limit(cairo, data.lineMiterLimit);
+		}
+		if ((state & DRAW_OFFSET) != 0) {
+			data.cairoXoffset = data.cairoYoffset = 0;
+			double[] matrix = new double[6];
+			Cairo.cairo_get_matrix(cairo, matrix);
+			double[] dx = new double[]{1};
+			double[] dy = new double[]{1};
+			Cairo.cairo_user_to_device_distance(cairo, dx, dy);
+			double scaling = dx[0];
+			if (scaling < 0) scaling = -scaling;
+			double strokeWidth = data.lineWidth * scaling;
+			if (strokeWidth == 0 || ((int)strokeWidth % 2) == 1) {
+				data.cairoXoffset = 0.5 / scaling;
+			}
+			scaling = dy[0];
+			if (scaling < 0) scaling = -scaling;
+			strokeWidth = data.lineWidth * scaling;
+			if (strokeWidth == 0 || ((int)strokeWidth % 2) == 1) {
+				data.cairoYoffset = 0.5 / scaling;
+			}
+		}
+		return;
+	}
+	if ((state & (BACKGROUND | FOREGROUND)) != 0) {
+		GdkColor foreground;
+		if ((state & FOREGROUND) != 0) {
+			foreground = data.foreground;
+			data.state &= ~BACKGROUND;
+		} else {
+			foreground = data.background;
+			data.state &= ~FOREGROUND;
+		}
+		OS.gdk_gc_set_foreground(handle, foreground);
+	}
+	if ((state & BACKGROUND_BG) != 0) {
+		GdkColor background = data.background;
+		OS.gdk_gc_set_background(handle, background);
+	}
+	if ((state & FONT) != 0) {
+		if (data.layout != 0) {
+			Font font = data.font;
+			OS.pango_layout_set_font_description(data.layout, font.handle);
+		}
+	}
+	if ((state & (LINE_CAP | LINE_JOIN | LINE_STYLE | LINE_WIDTH)) != 0) {
+		int cap_style = 0;
+		int join_style = 0;
+		int width = (int)data.lineWidth;
+		int line_style = 0;
+		float[] dashes = null;
+		switch (data.lineCap) {
+			case SWT.CAP_ROUND: cap_style = OS.GDK_CAP_ROUND; break;
+			case SWT.CAP_FLAT: cap_style = OS.GDK_CAP_BUTT; break;
+			case SWT.CAP_SQUARE: cap_style = OS.GDK_CAP_PROJECTING; break;
+		}
+		switch (data.lineJoin) {
+			case SWT.JOIN_ROUND: join_style = OS.GDK_JOIN_ROUND; break;
+			case SWT.JOIN_MITER: join_style = OS.GDK_JOIN_MITER; break;
+			case SWT.JOIN_BEVEL: join_style = OS.GDK_JOIN_BEVEL; break;
+		}
+		switch (data.lineStyle) {
+			case SWT.LINE_SOLID: break;
+			case SWT.LINE_DASH: dashes = width != 0 ? LINE_DASH : LINE_DASH_ZERO; break;
+			case SWT.LINE_DOT: dashes = width != 0 ? LINE_DOT : LINE_DOT_ZERO; break;
+			case SWT.LINE_DASHDOT: dashes = width != 0 ? LINE_DASHDOT : LINE_DASHDOT_ZERO; break;
+			case SWT.LINE_DASHDOTDOT: dashes = width != 0 ? LINE_DASHDOTDOT : LINE_DASHDOTDOT_ZERO; break;
+			case SWT.LINE_CUSTOM: dashes = data.lineDashes; break;
+		}
+		if (dashes != null) {
+			if ((state & LINE_STYLE) != 0) {
+				byte[] dash_list = new byte[dashes.length];
+				for (int i = 0; i < dash_list.length; i++) {
+					dash_list[i] = (byte)(width == 0 || data.lineStyle == SWT.LINE_CUSTOM ? dashes[i] : dashes[i] * width);
+				}
+				OS.gdk_gc_set_dashes(handle, 0, dash_list, dash_list.length);
+			}
+			line_style = OS.GDK_LINE_ON_OFF_DASH;
+		} else {
+			line_style = OS.GDK_LINE_SOLID;
+		}
+		OS.gdk_gc_set_line_attributes(handle, width, line_style, cap_style, join_style);
+	}
+}
+
+int /*long*/ convertRgn(int /*long*/ rgn, double[] matrix) {
+	int /*long*/ newRgn = OS.gdk_region_new();
+	int[] nRects = new int[1];
+	int /*long*/[] rects = new int /*long*/[1];
+	OS.gdk_region_get_rectangles(rgn, rects, nRects);
+	GdkRectangle rect = new GdkRectangle();
+	int[] pointArray = new int[8];
+	double[] x = new double[1], y = new double[1];
+	for (int i=0; i<nRects[0]; i++) {
+		OS.memmove(rect, rects[0] + (i * GdkRectangle.sizeof), GdkRectangle.sizeof);
+		x[0] = rect.x;
+		y[0] = rect.y;
+		Cairo.cairo_matrix_transform_point(matrix, x, y);
+		pointArray[0] = (int)x[0];
+		pointArray[1] = (int)y[0];
+		x[0] = rect.x + rect.width;
+		y[0] = rect.y;
+		Cairo.cairo_matrix_transform_point(matrix, x, y);
+		pointArray[2] = (int)Math.round(x[0]);
+		pointArray[3] = (int)y[0];
+		x[0] = rect.x + rect.width;
+		y[0] = rect.y + rect.height;
+		Cairo.cairo_matrix_transform_point(matrix, x, y);
+		pointArray[4] = (int)Math.round(x[0]);
+		pointArray[5] = (int)Math.round(y[0]);
+		x[0] = rect.x;
+		y[0] = rect.y + rect.height;
+		Cairo.cairo_matrix_transform_point(matrix, x, y);
+		pointArray[6] = (int)x[0];
+		pointArray[7] = (int)Math.round(y[0]);
+		int /*long*/ polyRgn = OS.gdk_region_polygon(pointArray, pointArray.length / 2, OS.GDK_EVEN_ODD_RULE);
+		OS.gdk_region_union(newRgn, polyRgn);
+		OS.gdk_region_destroy(polyRgn);
+	}
+	if (rects[0] != 0) OS.g_free(rects[0]);
+	return newRgn;
+}
+
+/**
+ * Copies a rectangular area of the receiver at the specified
+ * position into the image, which must be of type <code>SWT.BITMAP</code>.
+ *
+ * @param image the image to copy into
+ * @param x the x coordinate in the receiver of the area to be copied
+ * @param y the y coordinate in the receiver of the area to be copied
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the image is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the image is not a bitmap or has been disposed</li> 
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void copyArea(Image image, int x, int y) {
+	if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	if (image == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	if (image.type != SWT.BITMAP || image.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	Rectangle rect = image.getBounds();
+	int /*long*/ gdkGC = OS.gdk_gc_new(image.pixmap);
+	if (gdkGC == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+	OS.gdk_gc_set_subwindow(gdkGC, OS.GDK_INCLUDE_INFERIORS);
+	OS.gdk_draw_drawable(image.pixmap, gdkGC, data.drawable, x, y, 0, 0, rect.width, rect.height);
+	OS.g_object_unref(gdkGC);
+}
+
+/**
+ * Copies a rectangular area of the receiver at the source
+ * position onto the receiver at the destination position.
+ *
+ * @param srcX the x coordinate in the receiver of the area to be copied
+ * @param srcY the y coordinate in the receiver of the area to be copied
+ * @param width the width of the area to copy
+ * @param height the height of the area to copy
+ * @param destX the x coordinate in the receiver of the area to copy to
+ * @param destY the y coordinate in the receiver of the area to copy to
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void copyArea(int srcX, int srcY, int width, int height, int destX, int destY) {
+	copyArea(srcX, srcY, width, height, destX, destY, true);
+}
+/**
+ * Copies a rectangular area of the receiver at the source
+ * position onto the receiver at the destination position.
+ *
+ * @param srcX the x coordinate in the receiver of the area to be copied
+ * @param srcY the y coordinate in the receiver of the area to be copied
+ * @param width the width of the area to copy
+ * @param height the height of the area to copy
+ * @param destX the x coordinate in the receiver of the area to copy to
+ * @param destY the y coordinate in the receiver of the area to copy to
+ * @param paint if <code>true</code> paint events will be generated for old and obscured areas
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @since 3.1 
+ */
+public void copyArea(int srcX, int srcY, int width, int height, int destX, int destY, boolean paint) {
+	if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	if (width <= 0 || height <= 0) return;
+	int deltaX = destX - srcX, deltaY = destY - srcY;
+	if (deltaX == 0 && deltaY == 0) return;
+	int /*long*/ drawable = data.drawable;
+	if (data.image == null && paint) OS.gdk_gc_set_exposures(handle, true);
+	OS.gdk_draw_drawable(drawable, handle, drawable, srcX, srcY, destX, destY, width, height);
+	if (data.image == null & paint) {
+		OS.gdk_gc_set_exposures(handle, false);
+		boolean disjoint = (destX + width < srcX) || (srcX + width < destX) || (destY + height < srcY) || (srcY + height < destY);
+		GdkRectangle rect = new GdkRectangle ();
+		if (disjoint) {
+			rect.x = srcX;
+			rect.y = srcY;
+			rect.width = width;
+			rect.height = height;
+			OS.gdk_window_invalidate_rect (drawable, rect, false);
+//			OS.gdk_window_clear_area_e(drawable, srcX, srcY, width, height);
+		} else {
+			if (deltaX != 0) {
+				int newX = destX - deltaX;
+				if (deltaX < 0) newX = destX + width;
+				rect.x = newX;
+				rect.y = srcY;
+				rect.width = Math.abs(deltaX);
+				rect.height = height;
+				OS.gdk_window_invalidate_rect (drawable, rect, false);
+//				OS.gdk_window_clear_area_e(drawable, newX, srcY, Math.abs(deltaX), height);
+			}
+			if (deltaY != 0) {
+				int newY = destY - deltaY;
+				if (deltaY < 0) newY = destY + height;
+				rect.x = srcX;
+				rect.y = newY;
+				rect.width = width;
+				rect.height = Math.abs(deltaY);
+				OS.gdk_window_invalidate_rect (drawable, rect, false);
+//				OS.gdk_window_clear_area_e(drawable, srcX, newY, width, Math.abs(deltaY));
+			}
+		}
+	}
+}
+
+void createLayout() {
+	int /*long*/ context = OS.gdk_pango_context_get();
+	if (context == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+	data.context = context;
+	int /*long*/ layout = OS.pango_layout_new(context);
+	if (layout == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+	data.layout = layout;
+	OS.pango_context_set_language(context, OS.gtk_get_default_language());
+	OS.pango_context_set_base_dir(context, (data.style & SWT.MIRRORED) != 0 ? OS.PANGO_DIRECTION_RTL : OS.PANGO_DIRECTION_LTR);
+	OS.gdk_pango_context_set_colormap(context, OS.gdk_colormap_get_system());	
+	if (OS.GTK_VERSION >= OS.VERSION(2, 4, 0)) {
+		OS.pango_layout_set_auto_dir(layout, false);
+	}
+}
+
+void disposeLayout() {
+	data.string = null;
+	if (data.context != 0) OS.g_object_unref(data.context);
+	if (data.layout != 0) OS.g_object_unref(data.layout);
+	data.layout = data.context = 0;
+}
+
+void destroy() {
+	if (data.disposeCairo) {
+		int /*long*/ cairo = data.cairo;
+		if (cairo != 0) Cairo.cairo_destroy(cairo);
+		data.cairo = 0;
+	}
+
+	/* Free resources */
+	int /*long*/ clipRgn = data.clipRgn;
+	if (clipRgn != 0) OS.gdk_region_destroy(clipRgn);
+	Image image = data.image;
+	if (image != null) {
+		image.memGC = null;
+		if (image.transparentPixel != -1) image.createMask();
+	}
+	
+	disposeLayout();
+
+	/* Dispose the GC */
+	if (drawable != null) {
+		drawable.internal_dispose_GC(handle, data);
+	}
+	data.drawable = data.clipRgn = 0;
+	drawable = null;
+	handle = 0;
+	data.image = null;
+	data.string = null;
+	data = null;
+}
+
+/**
+ * Draws the outline of a circular or elliptical arc 
+ * within the specified rectangular area.
+ * <p>
+ * The resulting arc begins at <code>startAngle</code> and extends  
+ * for <code>arcAngle</code> degrees, using the current color.
+ * Angles are interpreted such that 0 degrees is at the 3 o'clock
+ * position. A positive value indicates a counter-clockwise rotation
+ * while a negative value indicates a clockwise rotation.
+ * </p><p>
+ * The center of the arc is the center of the rectangle whose origin 
+ * is (<code>x</code>, <code>y</code>) and whose size is specified by the 
+ * <code>width</code> and <code>height</code> arguments. 
+ * </p><p>
+ * The resulting arc covers an area <code>width + 1</code> pixels wide
+ * by <code>height + 1</code> pixels tall.
+ * </p>
+ *
+ * @param x the x coordinate of the upper-left corner of the arc to be drawn
+ * @param y the y coordinate of the upper-left corner of the arc to be drawn
+ * @param width the width of the arc to be drawn
+ * @param height the height of the arc to be drawn
+ * @param startAngle the beginning angle
+ * @param arcAngle the angular extent of the arc, relative to the start angle
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void drawArc(int x, int y, int width, int height, int startAngle, int arcAngle) {
+	if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	checkGC(DRAW);
+	if (width < 0) {
+		x = x + width;
+		width = -width;
+	}
+	if (height < 0) {
+		y = y + height;
+		height = -height;
+	}
+	if (width == 0 || height == 0 || arcAngle == 0) return;
+	int /*long*/ cairo = data.cairo;
+	if (cairo != 0) {
+		double xOffset = data.cairoXoffset, yOffset = data.cairoYoffset;
+		if (width == height) {
+            if (arcAngle >= 0) {
+                Cairo.cairo_arc_negative(cairo, x + xOffset + width / 2f, y + yOffset + height / 2f, width / 2f, -startAngle * (float)Compatibility.PI / 180, -(startAngle + arcAngle) * (float)Compatibility.PI / 180);
+            } else { 
+                Cairo.cairo_arc(cairo, x + xOffset + width / 2f, y + yOffset + height / 2f, width / 2f, -startAngle * (float)Compatibility.PI / 180, -(startAngle + arcAngle) * (float)Compatibility.PI / 180);
+            }
+		} else {
+			Cairo.cairo_save(cairo);
+			Cairo.cairo_translate(cairo, x + xOffset + width / 2f, y + yOffset + height / 2f);
+			Cairo.cairo_scale(cairo, width / 2f, height / 2f);
+            if (arcAngle >= 0) {
+                Cairo.cairo_arc_negative(cairo, 0, 0, 1, -startAngle * (float)Compatibility.PI / 180, -(startAngle + arcAngle) * (float)Compatibility.PI / 180);
+            } else {
+                Cairo.cairo_arc(cairo, 0, 0, 1, -startAngle * (float)Compatibility.PI / 180, -(startAngle + arcAngle) * (float)Compatibility.PI / 180);
+            }
+			Cairo.cairo_restore(cairo);
+		}
+		Cairo.cairo_stroke(cairo);
+		return;
+	}
+	OS.gdk_draw_arc(data.drawable, handle, 0, x, y, width, height, startAngle * 64, arcAngle * 64);
+}
+
+/** 
+ * Draws a rectangle, based on the specified arguments, which has
+ * the appearance of the platform's <em>focus rectangle</em> if the
+ * platform supports such a notion, and otherwise draws a simple
+ * rectangle in the receiver's foreground color.
+ *
+ * @param x the x coordinate of the rectangle
+ * @param y the y coordinate of the rectangle
+ * @param width the width of the rectangle
+ * @param height the height of the rectangle
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see #drawRectangle(int, int, int, int)
+ */
+public void drawFocus(int x, int y, int width, int height) {
+	if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	/*
+	* Feature in GTK.  The function gtk_widget_get_default_style() 
+	* can't be used here because gtk_paint_focus() uses GCs, which
+	* are not valid in the default style. The fix is to use a style
+	* from a widget.
+	*/
+	int /*long*/ style = OS.gtk_widget_get_style(data.device.shellHandle);
+	int /*long*/ cairo = data.cairo;
+	if (cairo != 0) {
+		checkGC(FOREGROUND);
+		int[] lineWidth = new int[1];
+		OS.gtk_widget_style_get(data.device.shellHandle, OS.focus_line_width, lineWidth, 0);
+		Cairo.cairo_save(cairo);		
+		Cairo.cairo_set_line_width(cairo, lineWidth[0]);
+		double[] dashes = new double[]{1, 1};
+		double dash_offset = -lineWidth[0] / 2f;
+		while (dash_offset < 0) dash_offset += 2;
+		Cairo.cairo_set_dash(cairo, dashes, dashes.length, dash_offset);
+		Cairo.cairo_rectangle(cairo, x + lineWidth[0] / 2f, y + lineWidth[0] / 2f, width, height);
+		Cairo.cairo_stroke(cairo);
+		Cairo.cairo_restore(cairo);
+		return;
+	}
+	OS.gtk_paint_focus(style, data.drawable, OS.GTK_STATE_NORMAL, null, data.device.shellHandle, new byte[1], x, y, width, height);
+}
+
+/**
+ * Draws the given image in the receiver at the specified
+ * coordinates.
+ *
+ * @param image the image to draw
+ * @param x the x coordinate of where to draw
+ * @param y the y coordinate of where to draw
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the image is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the given coordinates are outside the bounds of the image</li>
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * @exception SWTError <ul>
+ *    <li>ERROR_NO_HANDLES - if no handles are available to perform the operation</li>
+ * </ul>
+ */
+public void drawImage(Image image, int x, int y) {
+	if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	if (image == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	if (image.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	drawImage(image, 0, 0, -1, -1, x, y, -1, -1, true);
+}
+
+/**
+ * Copies a rectangular area from the source image into a (potentially
+ * different sized) rectangular area in the receiver. If the source
+ * and destination areas are of differing sizes, then the source
+ * area will be stretched or shrunk to fit the destination area
+ * as it is copied. The copy fails if any part of the source rectangle
+ * lies outside the bounds of the source image, or if any of the width
+ * or height arguments are negative.
+ *
+ * @param image the source image
+ * @param srcX the x coordinate in the source image to copy from
+ * @param srcY the y coordinate in the source image to copy from
+ * @param srcWidth the width in pixels to copy from the source
+ * @param srcHeight the height in pixels to copy from the source
+ * @param destX the x coordinate in the destination to copy to
+ * @param destY the y coordinate in the destination to copy to
+ * @param destWidth the width in pixels of the destination rectangle
+ * @param destHeight the height in pixels of the destination rectangle
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the image is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if any of the width or height arguments are negative.
+ *    <li>ERROR_INVALID_ARGUMENT - if the source rectangle is not contained within the bounds of the source image</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * @exception SWTError <ul>
+ *    <li>ERROR_NO_HANDLES - if no handles are available to perform the operation</li>
+ * </ul>
+ */
+public void drawImage(Image image, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight) {
+	if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	if (srcWidth == 0 || srcHeight == 0 || destWidth == 0 || destHeight == 0) return;
+	if (srcX < 0 || srcY < 0 || srcWidth < 0 || srcHeight < 0 || destWidth < 0 || destHeight < 0) {
+		SWT.error (SWT.ERROR_INVALID_ARGUMENT);
+	}
+	if (image == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	if (image.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	drawImage(image, srcX, srcY, srcWidth, srcHeight, destX, destY, destWidth, destHeight, false);
+}
+
+void drawImage(Image srcImage, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight, boolean simple) {
+	int[] width = new int[1];
+	int[] height = new int[1];
+ 	OS.gdk_drawable_get_size(srcImage.pixmap, width, height);
+ 	int imgWidth = width[0];
+ 	int imgHeight = height[0];
+ 	if (simple) {
+ 		srcWidth = destWidth = imgWidth;
+ 		srcHeight = destHeight = imgHeight;
+ 	} else {
+ 		simple = srcX == 0 && srcY == 0 &&
+ 			srcWidth == destWidth && destWidth == imgWidth &&
+ 			srcHeight == destHeight && destHeight == imgHeight;
+		if (srcX + srcWidth > imgWidth || srcY + srcHeight > imgHeight) {
+			SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+		}
+ 	}
+	int /*long*/ cairo = data.cairo;
+	if (cairo != 0) {
+		if (data.alpha != 0) {
+			srcImage.createSurface();
+			Cairo.cairo_save(cairo);
+			if ((data.style & SWT.MIRRORED) != 0) {
+				Cairo.cairo_scale(cairo, -1f,  1);
+				Cairo.cairo_translate(cairo, - 2 * destX - destWidth, 0);
+			}
+			Cairo.cairo_rectangle(cairo, destX , destY, destWidth, destHeight);
+			Cairo.cairo_clip(cairo);
+			Cairo.cairo_translate(cairo, destX - srcX, destY - srcY);
+			if (srcWidth != destWidth || srcHeight != destHeight) {
+				Cairo.cairo_scale(cairo, destWidth / (float)srcWidth,  destHeight / (float)srcHeight);
+			}
+			int filter = Cairo.CAIRO_FILTER_GOOD;
+			switch (data.interpolation) {
+				case SWT.DEFAULT: filter = Cairo.CAIRO_FILTER_GOOD; break;
+				case SWT.NONE: filter = Cairo.CAIRO_FILTER_NEAREST; break;
+				case SWT.LOW: filter = Cairo.CAIRO_FILTER_FAST; break;
+				case SWT.HIGH: filter = Cairo.CAIRO_FILTER_BEST; break;
+			}
+			int /*long*/ pattern = Cairo.cairo_pattern_create_for_surface(srcImage.surface);
+			if (pattern == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+			if (srcWidth != destWidth || srcHeight != destHeight) {
+				/*
+				* Bug in Cairo.  When drawing the image streched with an interpolation
+				* alghorithm, the edges of the image are faded.  This is not a bug, but
+				* it is not desired.  To avoid the faded edges, it should be possible to
+				* use cairo_pattern_set_extend() to set the pattern extend to either
+				* CAIRO_EXTEND_REFLECT or CAIRO_EXTEND_PAD, but these are not implemented
+				* in some versions of cairo (1.2.x) and have bugs in others (in 1.4.2 it
+				* draws with black edges).  The fix is to implement CAIRO_EXTEND_REFLECT
+				* by creating an image that is 3 times bigger than the original, drawing
+				* the original image in every quadrant (with an appropriate transform) and
+				* use this image as the pattern.
+				* 
+				* NOTE: For some reaons, it is necessary to use CAIRO_EXTEND_PAD with
+				* the image that was created or the edges are still faded.
+				*/
+				if (Cairo.cairo_version () >= Cairo.CAIRO_VERSION_ENCODE(1, 4, 0)) {
+					int /*long*/ surface = Cairo.cairo_image_surface_create(Cairo.CAIRO_FORMAT_ARGB32, imgWidth * 3, imgHeight * 3);
+					int /*long*/ cr = Cairo.cairo_create(surface);
+					Cairo.cairo_set_source_surface(cr, srcImage.surface, imgWidth, imgHeight);
+					Cairo.cairo_paint(cr);
+					Cairo.cairo_scale(cr, -1, -1);
+					Cairo.cairo_set_source_surface(cr, srcImage.surface, -imgWidth, -imgHeight);
+					Cairo.cairo_paint(cr);
+					Cairo.cairo_set_source_surface(cr, srcImage.surface, -imgWidth * 3, -imgHeight);
+					Cairo.cairo_paint(cr);
+					Cairo.cairo_set_source_surface(cr, srcImage.surface, -imgWidth, -imgHeight * 3);
+					Cairo.cairo_paint(cr);
+					Cairo.cairo_set_source_surface(cr, srcImage.surface, -imgWidth * 3, -imgHeight * 3);
+					Cairo.cairo_paint(cr);
+					Cairo.cairo_scale(cr, 1, -1);
+					Cairo.cairo_set_source_surface(cr, srcImage.surface, -imgWidth, imgHeight);
+					Cairo.cairo_paint(cr);
+					Cairo.cairo_set_source_surface(cr, srcImage.surface, -imgWidth * 3, imgHeight);
+					Cairo.cairo_paint(cr);
+					Cairo.cairo_scale(cr, -1, -1);
+					Cairo.cairo_set_source_surface(cr, srcImage.surface, imgWidth, -imgHeight);
+					Cairo.cairo_paint(cr);
+					Cairo.cairo_set_source_surface(cr, srcImage.surface, imgWidth, -imgHeight * 3);
+					Cairo.cairo_paint(cr);
+					Cairo.cairo_destroy(cr);
+					int /*long*/ newPattern = Cairo.cairo_pattern_create_for_surface(surface);
+					Cairo.cairo_surface_destroy(surface);
+					if (newPattern == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+					Cairo.cairo_pattern_destroy(pattern);
+					pattern = newPattern;
+					Cairo.cairo_pattern_set_extend(pattern, Cairo.CAIRO_EXTEND_PAD);
+					double[] matrix = new double[6]; 
+					Cairo.cairo_matrix_init_translate(matrix, imgWidth, imgHeight);
+					Cairo.cairo_pattern_set_matrix(pattern, matrix);
+				}
+//				Cairo.cairo_pattern_set_extend(pattern, Cairo.CAIRO_EXTEND_REFLECT);
+			}
+			Cairo.cairo_pattern_set_filter(pattern, filter);
+			Cairo.cairo_set_source(cairo, pattern);
+			if (data.alpha != 0xFF) {
+				Cairo.cairo_paint_with_alpha(cairo, data.alpha / (float)0xFF);
+			} else {
+				Cairo.cairo_paint(cairo);
+			}
+			Cairo.cairo_restore(cairo);
+			Cairo.cairo_pattern_destroy(pattern);
+		}
+		return;
+	}
+	if (srcImage.alpha != -1 || srcImage.alphaData != null) {
+		drawImageAlpha(srcImage, srcX, srcY, srcWidth, srcHeight, destX, destY, destWidth, destHeight, simple, imgWidth, imgHeight);
+	} else if (srcImage.transparentPixel != -1 || srcImage.mask != 0) {
+		drawImageMask(srcImage, srcX, srcY, srcWidth, srcHeight, destX, destY, destWidth, destHeight, simple, imgWidth, imgHeight);
+	} else {
+		drawImage(srcImage, srcX, srcY, srcWidth, srcHeight, destX, destY, destWidth, destHeight, simple, imgWidth, imgHeight);
+	}
+}
+void drawImage(Image srcImage, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight, boolean simple, int imgWidth, int imgHeight) {
+	if (srcWidth == destWidth && srcHeight == destHeight) {
+		OS.gdk_draw_drawable(data.drawable, handle, srcImage.pixmap, srcX, srcY, destX, destY, destWidth, destHeight);
+	} else {
+		if (device.useXRender) {
+			drawImageXRender(srcImage, srcX, srcY, srcWidth, srcHeight, destX, destY, destWidth, destHeight, simple, imgWidth, imgHeight, 0, -1);
+			return;
+		}
+		int /*long*/ pixbuf = scale(srcImage.pixmap, srcX, srcY, srcWidth, srcHeight, destWidth, destHeight);
+		if (pixbuf != 0) {
+			OS.gdk_pixbuf_render_to_drawable(pixbuf, data.drawable, handle, 0, 0, destX, destY, destWidth, destHeight, OS.GDK_RGB_DITHER_NORMAL, 0, 0);
+			OS.g_object_unref(pixbuf);
+		}
+	}
+}
+void drawImageAlpha(Image srcImage, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight, boolean simple, int imgWidth, int imgHeight) {
+	if (srcImage.alpha == 0) return;
+	if (srcImage.alpha == 255) {
+		drawImage(srcImage, srcX, srcY, srcWidth, srcHeight, destX, destY, destWidth, destHeight, simple, imgWidth, imgHeight);
+		return;
+	}
+	if (device.useXRender) {
+		drawImageXRender(srcImage, srcX, srcY, srcWidth, srcHeight, destX, destY, destWidth, destHeight, simple, imgWidth, imgHeight, srcImage.mask, OS.PictStandardA8);
+		return;
+	}
+	int /*long*/ pixbuf = OS.gdk_pixbuf_new(OS.GDK_COLORSPACE_RGB, true, 8, srcWidth, srcHeight);
+	if (pixbuf == 0) return;
+	int /*long*/ colormap = OS.gdk_colormap_get_system();
+	OS.gdk_pixbuf_get_from_drawable(pixbuf, srcImage.pixmap, colormap, srcX, srcY, 0, 0, srcWidth, srcHeight);
+	int stride = OS.gdk_pixbuf_get_rowstride(pixbuf);
+	int /*long*/ pixels = OS.gdk_pixbuf_get_pixels(pixbuf);
+	byte[] line = new byte[stride];
+	byte alpha = (byte)srcImage.alpha;
+	byte[] alphaData = srcImage.alphaData;
+	for (int y=0; y<srcHeight; y++) {
+		int alphaIndex = (y + srcY) * imgWidth + srcX;
+		OS.memmove(line, pixels + (y * stride), stride);
+		for (int x=3; x<stride; x+=4) {
+			line[x] = alphaData == null ? alpha : alphaData[alphaIndex++];
+		}
+		OS.memmove(pixels + (y * stride), line, stride);
+	}
+	if (srcWidth != destWidth || srcHeight != destHeight) {
+		int /*long*/ scaledPixbuf = OS.gdk_pixbuf_scale_simple(pixbuf, destWidth, destHeight, OS.GDK_INTERP_BILINEAR);
+		OS.g_object_unref(pixbuf);
+		if (scaledPixbuf == 0) return;
+		pixbuf = scaledPixbuf;
+	}
+	/*
+	* Feature in GTK.  gdk_draw_pixbuf was introduced in GTK+ 2.2.0 and
+	* supports clipping.
+	*/
+	if (OS.GTK_VERSION >= OS.VERSION (2, 2, 0)) {
+		OS.gdk_draw_pixbuf(data.drawable, handle, pixbuf, 0, 0, destX, destY, destWidth, destHeight, OS.GDK_RGB_DITHER_NORMAL, 0, 0);
+	} else {
+		OS.gdk_pixbuf_render_to_drawable_alpha(pixbuf, data.drawable, 0, 0, destX, destY, destWidth, destHeight, OS.GDK_PIXBUF_ALPHA_BILEVEL, 128, OS.GDK_RGB_DITHER_NORMAL, 0, 0);
+	}
+	OS.g_object_unref(pixbuf);
+}
+void drawImageMask(Image srcImage, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight, boolean simple, int imgWidth, int imgHeight) {
+	int /*long*/ drawable = data.drawable;
+	int /*long*/ colorPixmap = srcImage.pixmap;
+	/* Generate the mask if necessary. */
+	if (srcImage.transparentPixel != -1) srcImage.createMask();
+	int /*long*/ maskPixmap = srcImage.mask;
+
+	if (device.useXRender) {
+		drawImageXRender(srcImage, srcX, srcY, srcWidth, srcHeight, destX, destY, destWidth, destHeight, simple, imgWidth, imgHeight, maskPixmap, OS.PictStandardA1);
+	} else {
+		if (srcWidth != destWidth || srcHeight != destHeight) {
+			int /*long*/ pixbuf = OS.gdk_pixbuf_new(OS.GDK_COLORSPACE_RGB, true, 8, srcWidth, srcHeight);
+			if (pixbuf != 0) {
+				int /*long*/ colormap = OS.gdk_colormap_get_system();
+				OS.gdk_pixbuf_get_from_drawable(pixbuf, colorPixmap, colormap, srcX, srcY, 0, 0, srcWidth, srcHeight);
+				int /*long*/ maskPixbuf = OS.gdk_pixbuf_new(OS.GDK_COLORSPACE_RGB, false, 8, srcWidth, srcHeight);
+				if (maskPixbuf != 0) {
+					OS.gdk_pixbuf_get_from_drawable(maskPixbuf, maskPixmap, 0, srcX, srcY, 0, 0, srcWidth, srcHeight);
+					int stride = OS.gdk_pixbuf_get_rowstride(pixbuf);
+					int /*long*/ pixels = OS.gdk_pixbuf_get_pixels(pixbuf);
+					byte[] line = new byte[stride];
+					int maskStride = OS.gdk_pixbuf_get_rowstride(maskPixbuf);
+					int /*long*/ maskPixels = OS.gdk_pixbuf_get_pixels(maskPixbuf);
+					byte[] maskLine = new byte[maskStride];
+					for (int y=0; y<srcHeight; y++) {
+						int /*long*/ offset = pixels + (y * stride);
+						OS.memmove(line, offset, stride);
+						int /*long*/ maskOffset = maskPixels + (y * maskStride);
+						OS.memmove(maskLine, maskOffset, maskStride);
+						for (int x=0; x<srcWidth; x++) {
+							if (maskLine[x * 3] == 0) {
+								line[x*4+3] = 0;
+							}
+						}
+						OS.memmove(offset, line, stride);
+					}
+					OS.g_object_unref(maskPixbuf);
+					int /*long*/ scaledPixbuf = OS.gdk_pixbuf_scale_simple(pixbuf, destWidth, destHeight, OS.GDK_INTERP_BILINEAR);
+					if (scaledPixbuf != 0) {
+						int /*long*/[] colorBuffer = new int /*long*/[1];
+						int /*long*/[] maskBuffer = new int /*long*/[1];
+						OS.gdk_pixbuf_render_pixmap_and_mask(scaledPixbuf, colorBuffer, maskBuffer, 128);
+						colorPixmap = colorBuffer[0];
+						maskPixmap = maskBuffer[0];
+						OS.g_object_unref(scaledPixbuf);
+					}
+				}
+				OS.g_object_unref(pixbuf);
+			}
+			srcX = 0;
+			srcY = 0;
+			srcWidth = destWidth;
+			srcHeight = destHeight;
+		}
+	
+		/* Merge clipping with mask if necessary */
+		if (data.clipRgn != 0)	 {
+			int newWidth =  srcX + srcWidth;
+			int newHeight = srcY + srcHeight;
+			int bytesPerLine = (newWidth + 7) / 8;
+			byte[] maskData = new byte[bytesPerLine * newHeight];
+			int /*long*/ mask = OS.gdk_bitmap_create_from_data(0, maskData, newWidth, newHeight);
+			if (mask != 0) {
+				int /*long*/ gc = OS.gdk_gc_new(mask);
+				OS.gdk_region_offset(data.clipRgn, -destX + srcX, -destY + srcY);
+				OS.gdk_gc_set_clip_region(gc, data.clipRgn);
+				OS.gdk_region_offset(data.clipRgn, destX - srcX, destY - srcY);
+				GdkColor color = new GdkColor();
+				color.pixel = 1;
+				OS.gdk_gc_set_foreground(gc, color);
+				OS.gdk_draw_rectangle(mask, gc, 1, 0, 0, newWidth, newHeight);
+				OS.gdk_gc_set_function(gc, OS.GDK_AND);
+				OS.gdk_draw_drawable(mask, gc, maskPixmap, 0, 0, 0, 0, newWidth, newHeight);
+				OS.g_object_unref(gc);
+				if (maskPixmap != 0 && srcImage.mask != maskPixmap) OS.g_object_unref(maskPixmap);
+				maskPixmap = mask;
+			}
+		}
+	
+		/* Blit cliping the mask */
+		GdkGCValues values = new GdkGCValues();
+		OS.gdk_gc_get_values(handle, values);
+		OS.gdk_gc_set_clip_mask(handle, maskPixmap);
+		OS.gdk_gc_set_clip_origin(handle, destX - srcX, destY - srcY);
+		OS.gdk_draw_drawable(drawable, handle, colorPixmap, srcX, srcY, destX, destY, srcWidth, srcHeight);
+		OS.gdk_gc_set_values(handle, values, OS.GDK_GC_CLIP_MASK | OS.GDK_GC_CLIP_X_ORIGIN | OS.GDK_GC_CLIP_Y_ORIGIN);
+		if (data.clipRgn != 0) OS.gdk_gc_set_clip_region(handle, data.clipRgn);
+	}
+
+	/* Destroy scaled pixmaps */
+	if (colorPixmap != 0 && srcImage.pixmap != colorPixmap) OS.g_object_unref(colorPixmap);
+	if (maskPixmap != 0 && srcImage.mask != maskPixmap) OS.g_object_unref(maskPixmap);
+	/* Destroy the image mask if the there is a GC created on the image */
+	if (srcImage.transparentPixel != -1 && srcImage.memGC != null) srcImage.destroyMask();
+}
+void drawImageXRender(Image srcImage, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight, boolean simple, int imgWidth, int imgHeight, int /*long*/ maskPixmap, int maskType) {
+	int translateX = 0, translateY = 0;
+	int /*long*/ drawable = data.drawable;
+	if (data.image == null && !data.realDrawable) {
+		int[] x = new int[1], y = new int[1];
+		int /*long*/ [] real_drawable = new int /*long*/ [1];
+		OS.gdk_window_get_internal_paint_info(drawable, real_drawable, x, y);
+		drawable = real_drawable[0];
+		translateX = -x[0];
+		translateY = -y[0];
+	}
+	int /*long*/ xDisplay = OS.GDK_DISPLAY();
+	int /*long*/ maskPict = 0;
+	if (maskPixmap != 0) {
+		int attribCount = 0;
+		XRenderPictureAttributes attrib = null;
+		if (srcImage.alpha != -1) {
+			attribCount = 1;
+			attrib = new XRenderPictureAttributes();
+			attrib.repeat = true;
+		}
+		maskPict = OS.XRenderCreatePicture(xDisplay, OS.gdk_x11_drawable_get_xid(maskPixmap), OS.XRenderFindStandardFormat(xDisplay, maskType), attribCount, attrib);
+		if (maskPict == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+	}
+	int /*long*/ format = OS.XRenderFindVisualFormat(xDisplay, OS.gdk_x11_visual_get_xvisual(OS.gdk_visual_get_system()));
+	int /*long*/ destPict = OS.XRenderCreatePicture(xDisplay, OS.gdk_x11_drawable_get_xid(drawable), format, 0, null);
+	if (destPict == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+	int /*long*/ srcPict = OS.XRenderCreatePicture(xDisplay, OS.gdk_x11_drawable_get_xid(srcImage.pixmap), format, 0, null);
+	if (srcPict == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+	if (srcWidth != destWidth || srcHeight != destHeight) {
+		int[] transform = new int[]{(int)(((float)srcWidth / destWidth) * 65536), 0, 0, 0, (int)(((float)srcHeight / destHeight) * 65536), 0, 0, 0, 65536};
+		OS.XRenderSetPictureTransform(xDisplay, srcPict, transform);
+		if (maskPict != 0) OS.XRenderSetPictureTransform(xDisplay, maskPict, transform);
+		srcX *= destWidth / (float)srcWidth;
+		srcY *= destHeight / (float)srcHeight;
+	}
+	int /*long*/ clipping = data.clipRgn;
+	if (data.damageRgn != 0) {
+		if (clipping == 0) {
+			clipping = data.damageRgn;
+		} else {
+			clipping = OS.gdk_region_new();
+			OS.gdk_region_union(clipping, data.clipRgn);
+			OS.gdk_region_intersect(clipping, data.damageRgn);
+		}
+	}
+	if (clipping != 0) {
+		int[] nRects = new int[1];
+		int /*long*/[] rects = new int /*long*/[1];
+		OS.gdk_region_get_rectangles(clipping, rects, nRects);
+		GdkRectangle rect = new GdkRectangle();
+		short[] xRects = new short[nRects[0] * 4];
+		for (int i=0, j=0; i<nRects[0]; i++, j+=4) {
+			OS.memmove(rect, rects[0] + (i * GdkRectangle.sizeof), GdkRectangle.sizeof);
+			xRects[j] = (short)rect.x;
+			xRects[j+1] = (short)rect.y;
+			xRects[j+2] = (short)rect.width;
+			xRects[j+3] = (short)rect.height;
+		}
+		OS.XRenderSetPictureClipRectangles(xDisplay, destPict, translateX, translateY, xRects, nRects[0]);
+		if (clipping != data.clipRgn && clipping != data.damageRgn) {
+			OS.gdk_region_destroy(clipping);
+		}
+		if (rects[0] != 0) OS.g_free(rects[0]);
+	}
+	OS.XRenderComposite(xDisplay, maskPict != 0 ? OS.PictOpOver : OS.PictOpSrc, srcPict, maskPict, destPict, srcX, srcY, srcX, srcY, destX + translateX, destY + translateY, destWidth, destHeight);
+	OS.XRenderFreePicture(xDisplay, destPict);
+	OS.XRenderFreePicture(xDisplay, srcPict);
+	if (maskPict != 0) OS.XRenderFreePicture(xDisplay, maskPict);
+}
+int /*long*/ scale(int /*long*/ src, int srcX, int srcY, int srcWidth, int srcHeight, int destWidth, int destHeight) {
+	int /*long*/ pixbuf = OS.gdk_pixbuf_new(OS.GDK_COLORSPACE_RGB, false, 8, srcWidth, srcHeight);
+	if (pixbuf == 0) return 0;
+	int /*long*/ colormap = OS.gdk_colormap_get_system();
+	OS.gdk_pixbuf_get_from_drawable(pixbuf, src, colormap, srcX, srcY, 0, 0, srcWidth, srcHeight);
+	int /*long*/ scaledPixbuf = OS.gdk_pixbuf_scale_simple(pixbuf, destWidth, destHeight, OS.GDK_INTERP_BILINEAR);
+	OS.g_object_unref(pixbuf);
+	return scaledPixbuf;
+}
+
+/** 
+ * Draws a line, using the foreground color, between the points 
+ * (<code>x1</code>, <code>y1</code>) and (<code>x2</code>, <code>y2</code>).
+ *
+ * @param x1 the first point's x coordinate
+ * @param y1 the first point's y coordinate
+ * @param x2 the second point's x coordinate
+ * @param y2 the second point's y coordinate
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void drawLine(int x1, int y1, int x2, int y2) {
+	if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	checkGC(DRAW);
+	int /*long*/ cairo = data.cairo;
+	if (cairo != 0) {
+		double xOffset = data.cairoXoffset, yOffset = data.cairoYoffset;
+		Cairo.cairo_move_to(cairo, x1 + xOffset, y1 + yOffset);
+		Cairo.cairo_line_to(cairo, x2 + xOffset, y2 + yOffset);
+		Cairo.cairo_stroke(cairo);
+		return;
+	}
+	OS.gdk_draw_line (data.drawable, handle, x1, y1, x2, y2);
+}
+
+/** 
+ * Draws the outline of an oval, using the foreground color,
+ * within the specified rectangular area.
+ * <p>
+ * The result is a circle or ellipse that fits within the 
+ * rectangle specified by the <code>x</code>, <code>y</code>, 
+ * <code>width</code>, and <code>height</code> arguments. 
+ * </p><p> 
+ * The oval covers an area that is <code>width + 1</code> 
+ * pixels wide and <code>height + 1</code> pixels tall.
+ * </p>
+ *
+ * @param x the x coordinate of the upper left corner of the oval to be drawn
+ * @param y the y coordinate of the upper left corner of the oval to be drawn
+ * @param width the width of the oval to be drawn
+ * @param height the height of the oval to be drawn
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void drawOval(int x, int y, int width, int height) {
+	if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	checkGC(DRAW);
+	if (width < 0) {
+		x = x + width;
+		width = -width;
+	}
+	if (height < 0) {
+		y = y + height;
+		height = -height;
+	}
+	int /*long*/ cairo = data.cairo;
+	if (cairo != 0) {
+		double xOffset = data.cairoXoffset, yOffset = data.cairoYoffset;
+		if (width == height) {
+			Cairo.cairo_arc_negative(cairo, x + xOffset + width / 2f, y + yOffset + height / 2f, width / 2f, 0, -2 * (float)Compatibility.PI);
+		} else {
+			Cairo.cairo_save(cairo);
+			Cairo.cairo_translate(cairo, x + xOffset + width / 2f, y + yOffset + height / 2f);
+			Cairo.cairo_scale(cairo, width / 2f, height / 2f);
+			Cairo.cairo_arc_negative(cairo, 0, 0, 1, 0, -2 * (float)Compatibility.PI);
+			Cairo.cairo_restore(cairo);
+		}
+		Cairo.cairo_stroke(cairo);
+		return;
+	}
+	OS.gdk_draw_arc(data.drawable, handle, 0, x, y, width, height, 0, 23040);
+}
+
+/** 
+ * Draws the path described by the parameter.
+ * <p>
+ * This operation requires the operating system's advanced
+ * graphics subsystem which may not be available on some
+ * platforms.
+ * </p>
+ * 
+ * @param path the path to draw
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parameter is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the parameter has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_NO_GRAPHICS_LIBRARY - if advanced graphics are not available</li>
+ * </ul>
+ * 
+ * @see Path
+ * 
+ * @since 3.1
+ */
+public void drawPath(Path path) {
+	if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	if (path == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	if (path.handle == 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	initCairo();
+	checkGC(DRAW);
+	int /*long*/ cairo = data.cairo;
+	Cairo.cairo_save(cairo);
+	double xOffset = data.cairoXoffset, yOffset = data.cairoYoffset;
+	Cairo.cairo_translate(cairo, xOffset, yOffset);
+	int /*long*/ copy = Cairo.cairo_copy_path(path.handle);
+	if (copy == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+	Cairo.cairo_append_path(cairo, copy);
+	Cairo.cairo_path_destroy(copy);
+	Cairo.cairo_stroke(cairo);
+	Cairo.cairo_restore(cairo);
+}
+
+/** 
+ * Draws a pixel, using the foreground color, at the specified
+ * point (<code>x</code>, <code>y</code>).
+ * <p>
+ * Note that the receiver's line attributes do not affect this
+ * operation.
+ * </p>
+ *
+ * @param x the point's x coordinate
+ * @param y the point's y coordinate
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *  
+ * @since 3.0
+ */
+public void drawPoint (int x, int y) {
+	if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	checkGC(DRAW);
+	int /*long*/ cairo = data.cairo;
+	if (cairo != 0) {
+		Cairo.cairo_rectangle(cairo, x, y, 1, 1);
+		Cairo.cairo_fill(cairo);
+		return;
+	}
+	OS.gdk_draw_point(data.drawable, handle, x, y);
+}
+
+/** 
+ * Draws the closed polygon which is defined by the specified array
+ * of integer coordinates, using the receiver's foreground color. The array 
+ * contains alternating x and y values which are considered to represent
+ * points which are the vertices of the polygon. Lines are drawn between
+ * each consecutive pair, and between the first pair and last pair in the
+ * array.
+ *
+ * @param pointArray an array of alternating x and y values which are the vertices of the polygon
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT if pointArray is null</li>
+ * </ul>	
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void drawPolygon(int[] pointArray) {
+	if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	if (pointArray == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	checkGC(DRAW);
+	int /*long*/ cairo = data.cairo;
+	if (cairo != 0) {
+		drawPolyline(cairo, pointArray, true);
+		Cairo.cairo_stroke(cairo);
+		return;
+	}
+	OS.gdk_draw_polygon(data.drawable, handle, 0, pointArray, pointArray.length / 2);
+}
+
+/** 
+ * Draws the polyline which is defined by the specified array
+ * of integer coordinates, using the receiver's foreground color. The array 
+ * contains alternating x and y values which are considered to represent
+ * points which are the corners of the polyline. Lines are drawn between
+ * each consecutive pair, but not between the first pair and last pair in
+ * the array.
+ *
+ * @param pointArray an array of alternating x and y values which are the corners of the polyline
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the point array is null</li>
+ * </ul>	
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void drawPolyline(int[] pointArray) {
+	if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	if (pointArray == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	checkGC(DRAW);
+	int /*long*/ cairo = data.cairo;
+	if (cairo != 0) {
+		drawPolyline(cairo, pointArray, false);
+		Cairo.cairo_stroke(cairo);
+		return;
+	}
+	OS.gdk_draw_lines(data.drawable, handle, pointArray, pointArray.length / 2);
+}
+
+void drawPolyline(int /*long*/ cairo, int[] pointArray, boolean close) {
+	int count = pointArray.length / 2;
+	if (count == 0) return;
+	double xOffset = data.cairoXoffset, yOffset = data.cairoYoffset;
+	Cairo.cairo_move_to(cairo, pointArray[0] + xOffset, pointArray[1] + yOffset);
+	for (int i = 1, j=2; i < count; i++, j += 2) {
+		Cairo.cairo_line_to(cairo, pointArray[j] + xOffset, pointArray[j + 1] + yOffset);
+	}
+	if (close) Cairo.cairo_close_path(cairo);
+}
+
+/** 
+ * Draws the outline of the rectangle specified by the arguments,
+ * using the receiver's foreground color. The left and right edges
+ * of the rectangle are at <code>x</code> and <code>x + width</code>. 
+ * The top and bottom edges are at <code>y</code> and <code>y + height</code>. 
+ *
+ * @param x the x coordinate of the rectangle to be drawn
+ * @param y the y coordinate of the rectangle to be drawn
+ * @param width the width of the rectangle to be drawn
+ * @param height the height of the rectangle to be drawn
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void drawRectangle(int x, int y, int width, int height) {
+	if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	checkGC(DRAW);
+	if (width < 0) {
+		x = x + width;
+		width = -width;
+	}
+	if (height < 0) {
+		y = y + height;
+		height = -height;
+	}
+	int /*long*/ cairo = data.cairo;
+	if (cairo != 0) {
+		double xOffset = data.cairoXoffset, yOffset = data.cairoYoffset;
+		Cairo.cairo_rectangle(cairo, x + xOffset, y + yOffset, width, height);
+		Cairo.cairo_stroke(cairo);
+		return;
+	}
+	OS.gdk_draw_rectangle(data.drawable, handle, 0, x, y, width, height);
+}
+
+/** 
+ * Draws the outline of the specified rectangle, using the receiver's
+ * foreground color. The left and right edges of the rectangle are at
+ * <code>rect.x</code> and <code>rect.x + rect.width</code>. The top 
+ * and bottom edges are at <code>rect.y</code> and 
+ * <code>rect.y + rect.height</code>. 
+ *
+ * @param rect the rectangle to draw
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the rectangle is null</li>
+ * </ul>	
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void drawRectangle(Rectangle rect) {
+	if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	drawRectangle (rect.x, rect.y, rect.width, rect.height);
+}
+/** 
+ * Draws the outline of the round-cornered rectangle specified by 
+ * the arguments, using the receiver's foreground color. The left and
+ * right edges of the rectangle are at <code>x</code> and <code>x + width</code>. 
+ * The top and bottom edges are at <code>y</code> and <code>y + height</code>.
+ * The <em>roundness</em> of the corners is specified by the 
+ * <code>arcWidth</code> and <code>arcHeight</code> arguments, which
+ * are respectively the width and height of the ellipse used to draw
+ * the corners.
+ *
+ * @param x the x coordinate of the rectangle to be drawn
+ * @param y the y coordinate of the rectangle to be drawn
+ * @param width the width of the rectangle to be drawn
+ * @param height the height of the rectangle to be drawn
+ * @param arcWidth the width of the arc
+ * @param arcHeight the height of the arc
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void drawRoundRectangle(int x, int y, int width, int height, int arcWidth, int arcHeight) {
+	if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	checkGC(DRAW);
+	int nx = x;
+	int ny = y;
+	int nw = width;
+	int nh = height;
+	int naw = arcWidth;
+	int nah = arcHeight;
+	if (nw < 0) {
+		nw = 0 - nw;
+		nx = nx - nw;
+	}
+	if (nh < 0) {
+		nh = 0 - nh;
+		ny = ny -nh;
+	}
+	if (naw < 0) naw = 0 - naw;
+	if (nah < 0) nah = 0 - nah;
+	int /*long*/ cairo = data.cairo;
+	if (cairo != 0) {
+		double xOffset = data.cairoXoffset, yOffset = data.cairoYoffset;
+		if (naw == 0 || nah == 0) {
+			Cairo.cairo_rectangle(cairo, x + xOffset, y + yOffset, width, height);
+		} else {
+			float naw2 = naw / 2f;
+			float nah2 = nah / 2f;
+			float fw = nw / naw2;
+			float fh = nh / nah2;
+			Cairo.cairo_save(cairo);
+			Cairo.cairo_translate(cairo, nx + xOffset, ny + yOffset);
+			Cairo.cairo_scale(cairo, naw2, nah2);
+			Cairo.cairo_move_to(cairo, fw - 1, 0);
+		    Cairo.cairo_arc(cairo, fw - 1, 1, 1, Compatibility.PI + Compatibility.PI/2.0, Compatibility.PI*2.0);
+		    Cairo.cairo_arc(cairo, fw - 1, fh - 1, 1, 0, Compatibility.PI/2.0);
+		    Cairo.cairo_arc(cairo, 1, fh - 1, 1, Compatibility.PI/2, Compatibility.PI);
+		    Cairo.cairo_arc(cairo, 1, 1, 1, Compatibility.PI, 270.0*Compatibility.PI/180.0);
+			Cairo.cairo_close_path(cairo);
+			Cairo.cairo_restore(cairo);
+		}
+		Cairo.cairo_stroke(cairo);
+		return;
+	}
+	int naw2 = naw / 2;
+	int nah2 = nah / 2;
+	int /*long*/ drawable = data.drawable;
+	if (nw > naw) {
+		if (nh > nah) {
+			OS.gdk_draw_arc(drawable, handle, 0, nx, ny, naw, nah, 5760, 5760);
+			OS.gdk_draw_line(drawable, handle, nx + naw2, ny, nx + nw - naw2, ny);
+			OS.gdk_draw_arc(drawable, handle, 0, nx + nw - naw, ny, naw, nah, 0, 5760);
+			OS.gdk_draw_line(drawable, handle, nx + nw, ny + nah2, nx + nw, ny + nh - nah2);
+			OS.gdk_draw_arc(drawable, handle, 0, nx + nw - naw, ny + nh - nah, naw, nah, 17280, 5760);
+			OS.gdk_draw_line(drawable,handle, nx + naw2, ny + nh, nx + nw - naw2, ny + nh);
+			OS.gdk_draw_arc(drawable, handle, 0, nx, ny + nh - nah, naw, nah, 11520, 5760);
+			OS.gdk_draw_line(drawable, handle,  nx, ny + nah2, nx, ny + nh - nah2);
+		} else {
+			OS.gdk_draw_arc(drawable, handle, 0, nx, ny, naw, nh, 5760, 11520);
+			OS.gdk_draw_line(drawable, handle, nx + naw2, ny, nx + nw - naw2, ny);
+			OS.gdk_draw_arc(drawable, handle, 0, nx + nw - naw, ny, naw, nh, 17280, 11520);
+			OS.gdk_draw_line(drawable,handle, nx + naw2, ny + nh, nx + nw - naw2, ny + nh);
+		}
+	} else {
+		if (nh > nah) {
+			OS.gdk_draw_arc(drawable, handle, 0, nx, ny, nw, nah, 0, 11520);
+			OS.gdk_draw_line(drawable, handle, nx + nw, ny + nah2, nx + nw, ny + nh - nah2);
+			OS.gdk_draw_arc(drawable, handle, 0, nx, ny + nh - nah, nw, nah, 11520, 11520);
+			OS.gdk_draw_line(drawable,handle, nx, ny + nah2, nx, ny + nh - nah2);
+		} else {
+			OS.gdk_draw_arc(drawable, handle, 0, nx, ny, nw, nh, 0, 23040);
+		}
+	}
+}
+
+/** 
+ * Draws the given string, using the receiver's current font and
+ * foreground color. No tab expansion or carriage return processing
+ * will be performed. The background of the rectangular area where
+ * the string is being drawn will be filled with the receiver's
+ * background color.
+ *
+ * @param string the string to be drawn
+ * @param x the x coordinate of the top left corner of the rectangular area where the string is to be drawn
+ * @param y the y coordinate of the top left corner of the rectangular area where the string is to be drawn
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ * </ul>	
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void drawString (String string, int x, int y) {
+	drawString(string, x, y, false);
+}
+/** 
+ * Draws the given string, using the receiver's current font and
+ * foreground color. No tab expansion or carriage return processing
+ * will be performed. If <code>isTransparent</code> is <code>true</code>,
+ * then the background of the rectangular area where the string is being
+ * drawn will not be modified, otherwise it will be filled with the
+ * receiver's background color.
+ *
+ * @param string the string to be drawn
+ * @param x the x coordinate of the top left corner of the rectangular area where the string is to be drawn
+ * @param y the y coordinate of the top left corner of the rectangular area where the string is to be drawn
+ * @param isTransparent if <code>true</code> the background will be transparent, otherwise it will be opaque
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ * </ul>	
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void drawString(String string, int x, int y, boolean isTransparent) {
+	drawText(string, x, y, isTransparent ? SWT.DRAW_TRANSPARENT : 0);
+}
+
+/** 
+ * Draws the given string, using the receiver's current font and
+ * foreground color. Tab expansion and carriage return processing
+ * are performed. The background of the rectangular area where
+ * the text is being drawn will be filled with the receiver's
+ * background color.
+ *
+ * @param string the string to be drawn
+ * @param x the x coordinate of the top left corner of the rectangular area where the text is to be drawn
+ * @param y the y coordinate of the top left corner of the rectangular area where the text is to be drawn
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ * </ul>	
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void drawText(String string, int x, int y) {
+	drawText(string, x, y, SWT.DRAW_DELIMITER | SWT.DRAW_TAB);
+}
+
+/** 
+ * Draws the given string, using the receiver's current font and
+ * foreground color. Tab expansion and carriage return processing
+ * are performed. If <code>isTransparent</code> is <code>true</code>,
+ * then the background of the rectangular area where the text is being
+ * drawn will not be modified, otherwise it will be filled with the
+ * receiver's background color.
+ *
+ * @param string the string to be drawn
+ * @param x the x coordinate of the top left corner of the rectangular area where the text is to be drawn
+ * @param y the y coordinate of the top left corner of the rectangular area where the text is to be drawn
+ * @param isTransparent if <code>true</code> the background will be transparent, otherwise it will be opaque
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ * </ul>	
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void drawText(String string, int x, int y, boolean isTransparent) {
+	int flags = SWT.DRAW_DELIMITER | SWT.DRAW_TAB;
+	if (isTransparent) flags |= SWT.DRAW_TRANSPARENT;
+	drawText(string, x, y, flags);
+}
+
+/** 
+ * Draws the given string, using the receiver's current font and
+ * foreground color. Tab expansion, line delimiter and mnemonic
+ * processing are performed according to the specified flags. If
+ * <code>flags</code> includes <code>DRAW_TRANSPARENT</code>,
+ * then the background of the rectangular area where the text is being
+ * drawn will not be modified, otherwise it will be filled with the
+ * receiver's background color.
+ * <p>
+ * The parameter <code>flags</code> may be a combination of:
+ * <dl>
+ * <dt><b>DRAW_DELIMITER</b></dt>
+ * <dd>draw multiple lines</dd>
+ * <dt><b>DRAW_TAB</b></dt>
+ * <dd>expand tabs</dd>
+ * <dt><b>DRAW_MNEMONIC</b></dt>
+ * <dd>underline the mnemonic character</dd>
+ * <dt><b>DRAW_TRANSPARENT</b></dt>
+ * <dd>transparent background</dd>
+ * </dl>
+ * </p>
+ *
+ * @param string the string to be drawn
+ * @param x the x coordinate of the top left corner of the rectangular area where the text is to be drawn
+ * @param y the y coordinate of the top left corner of the rectangular area where the text is to be drawn
+ * @param flags the flags specifying how to process the text
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ * </ul>	
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void drawText (String string, int x, int y, int flags) {
+	if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	if (string == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	if (string.length() == 0) return;
+	int /*long*/ cairo = data.cairo;
+	if (cairo != 0) {
+		if (OS.GTK_VERSION < OS.VERSION(2, 8, 0)) {
+			//TODO - honor flags
+			checkGC(FOREGROUND | FONT);
+			cairo_font_extents_t extents = new cairo_font_extents_t();
+			Cairo.cairo_font_extents(cairo, extents);
+			double baseline = y + extents.ascent;
+			Cairo.cairo_move_to(cairo, x, baseline);
+			byte[] buffer = Converter.wcsToMbcs(null, string, true);
+			Cairo.cairo_show_text(cairo, buffer);
+			Cairo.cairo_new_path(cairo);
+			return;
+		}
+	}
+	setString(string, flags);
+	if (cairo != 0) {
+		if ((flags & SWT.DRAW_TRANSPARENT) == 0) {
+			checkGC(BACKGROUND);
+			int[] width = new int[1], height = new int[1];
+			OS.pango_layout_get_size(data.layout, width, height);
+			Cairo.cairo_rectangle(cairo, x, y, OS.PANGO_PIXELS(width[0]), OS.PANGO_PIXELS(height[0]));
+			Cairo.cairo_fill(cairo);
+		}
+		checkGC(FOREGROUND | FONT);
+		if ((data.style & SWT.MIRRORED) != 0) {
+			Cairo.cairo_save(cairo);
+			int[] width = new int[1], height = new int[1];
+			OS.pango_layout_get_size(data.layout, width, height);
+			Cairo.cairo_scale(cairo, -1f,  1);
+			Cairo.cairo_translate(cairo, -2 * x - OS.PANGO_PIXELS(width[0]), 0);
+		}
+		Cairo.cairo_move_to(cairo, x, y);
+		OS.pango_cairo_show_layout(cairo, data.layout);
+		if ((data.style & SWT.MIRRORED) != 0) {
+			Cairo.cairo_restore(cairo);
+		}
+		Cairo.cairo_new_path(cairo);
+		return;
+	}
+	checkGC(FOREGROUND | FONT | BACKGROUND_BG);
+	GdkColor background = null;
+	if ((flags & SWT.DRAW_TRANSPARENT) == 0) background = data.background;
+	if (!data.xorMode) {
+		OS.gdk_draw_layout_with_colors(data.drawable, handle, x, y, data.layout, null, background);
+	} else {
+		int /*long*/ layout = data.layout;
+		int[] w = new int[1], h = new int[1];
+		OS.pango_layout_get_size(layout, w, h);
+		int width = OS.PANGO_PIXELS(w[0]);
+		int height = OS.PANGO_PIXELS(h[0]);
+		int /*long*/ pixmap = OS.gdk_pixmap_new(OS.GDK_ROOT_PARENT(), width, height, -1);
+		if (pixmap == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+		int /*long*/ gdkGC = OS.gdk_gc_new(pixmap);
+		if (gdkGC == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+		GdkColor black = new GdkColor();
+		OS.gdk_gc_set_foreground(gdkGC, black);
+		OS.gdk_draw_rectangle(pixmap, gdkGC, 1, 0, 0, width, height);
+		OS.gdk_gc_set_foreground(gdkGC, data.foreground);
+		OS.gdk_draw_layout_with_colors(pixmap, gdkGC, 0, 0, layout, null, background);
+		OS.g_object_unref(gdkGC);
+		OS.gdk_draw_drawable(data.drawable, handle, pixmap, 0, 0, x, y, width, height);
+		OS.g_object_unref(pixmap);
+	}
+}
+
+/**
+ * Compares the argument to the receiver, and returns true
+ * if they represent the <em>same</em> object using a class
+ * specific comparison.
+ *
+ * @param object the object to compare with this object
+ * @return <code>true</code> if the object is the same as this object and <code>false</code> otherwise
+ *
+ * @see #hashCode
+ */
+public boolean equals(Object object) {
+	if (object == this) return true;
+	if (!(object instanceof GC)) return false;
+	return handle == ((GC)object).handle;
+}
+
+/**
+ * Fills the interior of a circular or elliptical arc within
+ * the specified rectangular area, with the receiver's background
+ * color.
+ * <p>
+ * The resulting arc begins at <code>startAngle</code> and extends  
+ * for <code>arcAngle</code> degrees, using the current color.
+ * Angles are interpreted such that 0 degrees is at the 3 o'clock
+ * position. A positive value indicates a counter-clockwise rotation
+ * while a negative value indicates a clockwise rotation.
+ * </p><p>
+ * The center of the arc is the center of the rectangle whose origin 
+ * is (<code>x</code>, <code>y</code>) and whose size is specified by the 
+ * <code>width</code> and <code>height</code> arguments. 
+ * </p><p>
+ * The resulting arc covers an area <code>width + 1</code> pixels wide
+ * by <code>height + 1</code> pixels tall.
+ * </p>
+ *
+ * @param x the x coordinate of the upper-left corner of the arc to be filled
+ * @param y the y coordinate of the upper-left corner of the arc to be filled
+ * @param width the width of the arc to be filled
+ * @param height the height of the arc to be filled
+ * @param startAngle the beginning angle
+ * @param arcAngle the angular extent of the arc, relative to the start angle
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see #drawArc
+ */
+public void fillArc(int x, int y, int width, int height, int startAngle, int arcAngle) {
+	if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	checkGC(FILL);
+	if (width < 0) {
+		x = x + width;
+		width = -width;
+	}
+	if (height < 0) {
+		y = y + height;
+		height = -height;
+	}
+	if (width == 0 || height == 0 || arcAngle == 0) return;
+	int /*long*/ cairo = data.cairo;
+	if (cairo != 0) {
+		if (width == height) {
+            if (arcAngle >= 0) {
+            	Cairo.cairo_arc_negative(cairo, x + width / 2f, y + height / 2f, width / 2f, -startAngle * (float)Compatibility.PI / 180,  -(startAngle + arcAngle) * (float)Compatibility.PI / 180);
+            } else {
+            	Cairo.cairo_arc(cairo, x + width / 2f, y + height / 2f, width / 2f, -startAngle * (float)Compatibility.PI / 180,  -(startAngle + arcAngle) * (float)Compatibility.PI / 180);
+            }
+			Cairo.cairo_line_to(cairo, x + width / 2f, y + height / 2f);
+		} else {
+			Cairo.cairo_save(cairo);
+			Cairo.cairo_translate(cairo, x + width / 2f, y + height / 2f);
+			Cairo.cairo_scale(cairo, width / 2f, height / 2f);
+			if (arcAngle >= 0) {
+				Cairo.cairo_arc_negative(cairo, 0, 0, 1, -startAngle * (float)Compatibility.PI / 180,  -(startAngle + arcAngle) * (float)Compatibility.PI / 180);
+			} else {
+				Cairo.cairo_arc(cairo, 0, 0, 1, -startAngle * (float)Compatibility.PI / 180,  -(startAngle + arcAngle) * (float)Compatibility.PI / 180);
+			}
+			Cairo.cairo_line_to(cairo, 0, 0);
+			Cairo.cairo_restore(cairo);
+		}
+		Cairo.cairo_fill(cairo);
+		return;
+	}
+	OS.gdk_draw_arc(data.drawable, handle, 1, x, y, width, height, startAngle * 64, arcAngle * 64);
+}
+
+/**
+ * Fills the interior of the specified rectangle with a gradient
+ * sweeping from left to right or top to bottom progressing
+ * from the receiver's foreground color to its background color.
+ *
+ * @param x the x coordinate of the rectangle to be filled
+ * @param y the y coordinate of the rectangle to be filled
+ * @param width the width of the rectangle to be filled, may be negative
+ *        (inverts direction of gradient if horizontal)
+ * @param height the height of the rectangle to be filled, may be negative
+ *        (inverts direction of gradient if vertical)
+ * @param vertical if true sweeps from top to bottom, else 
+ *        sweeps from left to right
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see #drawRectangle(int, int, int, int)
+ */
+public void fillGradientRectangle(int x, int y, int width, int height, boolean vertical) {
+	if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	if ((width == 0) || (height == 0)) return;
+	
+	/* Rewrite this to use GdkPixbuf */
+	
+	RGB backgroundRGB, foregroundRGB;
+	backgroundRGB = getBackground().getRGB();
+	foregroundRGB = getForeground().getRGB();
+
+	RGB fromRGB, toRGB;
+	fromRGB = foregroundRGB;
+	toRGB   = backgroundRGB;
+	boolean swapColors = false;
+	if (width < 0) {
+		x += width; width = -width;
+		if (! vertical) swapColors = true;
+	}
+	if (height < 0) {
+		y += height; height = -height;
+		if (vertical) swapColors = true;
+	}
+	if (swapColors) {
+		fromRGB = backgroundRGB;
+		toRGB   = foregroundRGB;
+	}
+	if (fromRGB.equals(toRGB)) {
+		fillRectangle(x, y, width, height);
+		return;
+	}
+	int /*long*/ cairo = data.cairo;
+	if (cairo != 0) {
+		int /*long*/ pattern;
+		if (vertical) {
+			pattern = Cairo.cairo_pattern_create_linear (0.0, 0.0, 0.0, 1.0);
+		} else {
+			pattern = Cairo.cairo_pattern_create_linear (0.0, 0.0, 1.0, 0.0);
+		}
+		Cairo.cairo_pattern_add_color_stop_rgba (pattern, 0, fromRGB.red / 255f, fromRGB.green / 255f, fromRGB.blue / 255f, data.alpha / 255f);
+		Cairo.cairo_pattern_add_color_stop_rgba (pattern, 1, toRGB.red / 255f, toRGB.green / 255f, toRGB.blue / 255f, data.alpha / 255f);
+		Cairo.cairo_save(cairo);
+		Cairo.cairo_translate(cairo, x, y);
+		Cairo.cairo_scale(cairo, width, height);
+		Cairo.cairo_rectangle(cairo, 0, 0, 1, 1);
+		Cairo.cairo_set_source(cairo, pattern);
+		Cairo.cairo_fill(cairo);
+		Cairo.cairo_restore(cairo);
+		Cairo.cairo_pattern_destroy(pattern);
+		return;
+	}
+	ImageData.fillGradientRectangle(this, data.device,
+		x, y, width, height, vertical, fromRGB, toRGB,
+		8, 8, 8);
+}
+
+/** 
+ * Fills the interior of an oval, within the specified
+ * rectangular area, with the receiver's background
+ * color.
+ *
+ * @param x the x coordinate of the upper left corner of the oval to be filled
+ * @param y the y coordinate of the upper left corner of the oval to be filled
+ * @param width the width of the oval to be filled
+ * @param height the height of the oval to be filled
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see #drawOval
+ */
+public void fillOval(int x, int y, int width, int height) {
+	if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	checkGC(FILL);
+	if (width < 0) {
+		x = x + width;
+		width = -width;
+	}
+	if (height < 0) {
+		y = y + height;
+		height = -height;
+	}
+	int /*long*/ cairo = data.cairo;
+	if (cairo != 0) {
+		if (width == height) {
+			Cairo.cairo_arc_negative(cairo, x + width / 2f, y + height / 2f, width / 2f, 0, 2 * (float)Compatibility.PI);
+		} else {
+			Cairo.cairo_save(cairo);
+			Cairo.cairo_translate(cairo, x + width / 2f, y + height / 2f);
+			Cairo.cairo_scale(cairo, width / 2f, height / 2f);
+			Cairo.cairo_arc_negative(cairo, 0, 0, 1, 0, 2 * (float)Compatibility.PI);
+			Cairo.cairo_restore(cairo);
+		}
+		Cairo.cairo_fill(cairo);
+		return;
+	}
+	OS.gdk_draw_arc(data.drawable, handle, 1, x, y, width, height, 0, 23040);
+}
+
+/** 
+ * Fills the path described by the parameter.
+ * <p>
+ * This operation requires the operating system's advanced
+ * graphics subsystem which may not be available on some
+ * platforms.
+ * </p>
+ *
+ * @param path the path to fill
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parameter is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the parameter has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_NO_GRAPHICS_LIBRARY - if advanced graphics are not available</li>
+ * </ul>
+ * 
+ * @see Path
+ * 
+ * @since 3.1
+ */
+public void fillPath (Path path) {
+	if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	if (path == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	if (path.handle == 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	initCairo();
+	checkGC(FILL);
+	int /*long*/ cairo = data.cairo;
+	int /*long*/ copy = Cairo.cairo_copy_path(path.handle);
+	if (copy == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+	Cairo.cairo_append_path(cairo, copy);
+	Cairo.cairo_path_destroy(copy);
+	Cairo.cairo_fill(cairo);
+}
+
+/** 
+ * Fills the interior of the closed polygon which is defined by the
+ * specified array of integer coordinates, using the receiver's
+ * background color. The array contains alternating x and y values
+ * which are considered to represent points which are the vertices of
+ * the polygon. Lines are drawn between each consecutive pair, and
+ * between the first pair and last pair in the array.
+ *
+ * @param pointArray an array of alternating x and y values which are the vertices of the polygon
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT if pointArray is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see #drawPolygon	
+ */
+public void fillPolygon(int[] pointArray) {
+	if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	if (pointArray == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	checkGC(FILL);
+	int /*long*/ cairo = data.cairo;
+	if (cairo != 0) {
+		drawPolyline(cairo, pointArray, true);
+		Cairo.cairo_fill(cairo);
+		return;
+	}
+	OS.gdk_draw_polygon(data.drawable, handle, 1, pointArray, pointArray.length / 2);
+}
+
+/** 
+ * Fills the interior of the rectangle specified by the arguments,
+ * using the receiver's background color. 
+ *
+ * @param x the x coordinate of the rectangle to be filled
+ * @param y the y coordinate of the rectangle to be filled
+ * @param width the width of the rectangle to be filled
+ * @param height the height of the rectangle to be filled
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see #drawRectangle(int, int, int, int)
+ */
+public void fillRectangle(int x, int y, int width, int height) {
+	if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	checkGC(FILL);
+	if (width < 0) {
+		x = x + width;
+		width = -width;
+	}
+	if (height < 0) {
+		y = y + height;
+		height = -height;
+	}
+	int /*long*/ cairo = data.cairo; 
+	if (cairo != 0) {
+		Cairo.cairo_rectangle(cairo, x, y, width, height);
+		Cairo.cairo_fill(cairo);
+		return;
+	}
+	OS.gdk_draw_rectangle(data.drawable, handle, 1, x, y, width, height);
+}
+
+/** 
+ * Fills the interior of the specified rectangle, using the receiver's
+ * background color. 
+ *
+ * @param rect the rectangle to be filled
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the rectangle is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see #drawRectangle(int, int, int, int)
+ */
+public void fillRectangle(Rectangle rect) {
+	if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	fillRectangle(rect.x, rect.y, rect.width, rect.height);
+}
+
+/** 
+ * Fills the interior of the round-cornered rectangle specified by 
+ * the arguments, using the receiver's background color. 
+ *
+ * @param x the x coordinate of the rectangle to be filled
+ * @param y the y coordinate of the rectangle to be filled
+ * @param width the width of the rectangle to be filled
+ * @param height the height of the rectangle to be filled
+ * @param arcWidth the width of the arc
+ * @param arcHeight the height of the arc
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see #drawRoundRectangle
+ */
+public void fillRoundRectangle(int x, int y, int width, int height, int arcWidth, int arcHeight) {
+	if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	checkGC(FILL);
+	int nx = x;
+	int ny = y;
+	int nw = width;
+	int nh = height;
+	int naw = arcWidth;
+	int nah = arcHeight;
+	if (nw < 0) {
+		nw = 0 - nw;
+		nx = nx - nw;
+	}
+	if (nh < 0) {
+		nh = 0 - nh;
+		ny = ny -nh;
+	}
+	if (naw < 0) naw = 0 - naw;
+	if (nah < 0) nah = 0 - nah;
+	int /*long*/ cairo = data.cairo;
+	if (cairo != 0) {
+		if (naw == 0 || nah == 0) {
+			Cairo.cairo_rectangle(cairo, x, y, width, height);
+		} else {
+			float naw2 = naw / 2f;
+			float nah2 = nah / 2f;
+			float fw = nw / naw2;
+			float fh = nh / nah2;
+			Cairo.cairo_save(cairo);
+			Cairo.cairo_translate(cairo, nx, ny);
+			Cairo.cairo_scale(cairo, naw2, nah2);
+			Cairo.cairo_move_to(cairo, fw - 1, 0);
+		    Cairo.cairo_arc(cairo, fw - 1, 1, 1, Compatibility.PI + Compatibility.PI/2.0, Compatibility.PI*2.0);
+		    Cairo.cairo_arc(cairo, fw - 1, fh - 1, 1, 0, Compatibility.PI/2.0);
+		    Cairo.cairo_arc(cairo, 1, fh - 1, 1, Compatibility.PI/2, Compatibility.PI);
+		    Cairo.cairo_arc(cairo, 1, 1, 1, Compatibility.PI, 270.0*Compatibility.PI/180.0);		
+			Cairo.cairo_close_path(cairo);
+			Cairo.cairo_restore(cairo);
+		}
+		Cairo.cairo_fill(cairo);
+		return;
+	}
+	int naw2 = naw / 2;
+	int nah2 = nah / 2;
+	int /*long*/ drawable = data.drawable;
+	if (nw > naw) {
+		if (nh > nah) {
+			OS.gdk_draw_arc(drawable, handle, 1, nx, ny, naw, nah, 5760, 5760);
+			OS.gdk_draw_rectangle(drawable, handle, 1, nx + naw2, ny, nw - naw2 * 2, nh);
+			OS.gdk_draw_arc(drawable, handle, 1, nx + nw - naw, ny, naw, nah, 0, 5760);
+			OS.gdk_draw_rectangle(drawable, handle, 1, nx, ny + nah2, naw2, nh - nah2 * 2);
+			OS.gdk_draw_arc(drawable, handle, 1, nx + nw - naw, ny + nh - nah, naw, nah, 17280, 5760);
+			OS.gdk_draw_rectangle(drawable, handle, 1, nx + nw - naw2, ny + nah2, naw2, nh - nah2 * 2);
+			OS.gdk_draw_arc(drawable, handle, 1, nx, ny + nh - nah, naw, nah, 11520, 5760);
+		} else {
+			OS.gdk_draw_arc(drawable, handle, 1, nx, ny, naw, nh, 5760, 11520);
+			OS.gdk_draw_rectangle(drawable, handle, 1, nx + naw2, ny, nw - naw2 * 2, nh);
+			OS.gdk_draw_arc(drawable, handle, 1, nx + nw - naw, ny, naw, nh, 17280, 11520);
+		}
+	} else {
+		if (nh > nah) {
+			OS.gdk_draw_arc(drawable, handle, 1, nx, ny, nw, nah, 0, 11520);
+			OS.gdk_draw_rectangle(drawable, handle, 1, nx, ny + nah2, nw, nh - nah2 * 2);
+			OS.gdk_draw_arc(drawable, handle, 1, nx, ny + nh - nah, nw, nah, 11520, 11520);
+		} else {
+			OS.gdk_draw_arc(drawable, handle, 1, nx, ny, nw, nh, 0, 23040);
+		}
+	}
+}
+
+int fixMnemonic (char [] buffer) {
+	int i=0, j=0;
+	int mnemonic=-1;
+	while (i < buffer.length) {
+		if ((buffer [j++] = buffer [i++]) == '&') {
+			if (i == buffer.length) {continue;}
+			if (buffer [i] == '&') {i++; continue;}
+			if (mnemonic == -1) mnemonic = j;
+			j--;
+		}
+	}
+	while (j < buffer.length) buffer [j++] = 0;
+	return mnemonic;
+}
+
+/**
+ * Returns the <em>advance width</em> of the specified character in
+ * the font which is currently selected into the receiver.
+ * <p>
+ * The advance width is defined as the horizontal distance the cursor
+ * should move after printing the character in the selected font.
+ * </p>
+ *
+ * @param ch the character to measure
+ * @return the distance in the x direction to move past the character before painting the next
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public int getAdvanceWidth(char ch) {	
+	if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	//BOGUS
+	return stringExtent(new String(new char[]{ch})).x;
+}
+
+/**
+ * Returns <code>true</code> if receiver is using the operating system's
+ * advanced graphics subsystem.  Otherwise, <code>false</code> is returned
+ * to indicate that normal graphics are in use.
+ * <p>
+ * Advanced graphics may not be installed for the operating system.  In this
+ * case, <code>false</code> is always returned.  Some operating system have
+ * only one graphics subsystem.  If this subsystem supports advanced graphics,
+ * then <code>true</code> is always returned.  If any graphics operation such
+ * as alpha, antialias, patterns, interpolation, paths, clipping or transformation
+ * has caused the receiver to switch from regular to advanced graphics mode,
+ * <code>true</code> is returned.  If the receiver has been explicitly switched
+ * to advanced mode and this mode is supported, <code>true</code> is returned.
+ * </p>
+ *
+ * @return the advanced value
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @see #setAdvanced
+ * 
+ * @since 3.1
+ */
+public boolean getAdvanced() {
+	if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	return data.cairo != 0;
+}
+
+/**
+ * Returns the receiver's alpha value. The alpha value
+ * is between 0 (transparent) and 255 (opaque).
+ *
+ * @return the alpha value
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @since 3.1
+ */
+public int getAlpha() {
+	if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	return data.alpha;
+}
+
+/**
+ * Returns the receiver's anti-aliasing setting value, which will be
+ * one of <code>SWT.DEFAULT</code>, <code>SWT.OFF</code> or
+ * <code>SWT.ON</code>. Note that this controls anti-aliasing for all
+ * <em>non-text drawing</em> operations.
+ *
+ * @return the anti-aliasing setting
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @see #getTextAntialias
+ * 
+ * @since 3.1
+ */
+public int getAntialias() {
+	if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+    if (data.cairo == 0) return SWT.DEFAULT;
+    int antialias = Cairo.cairo_get_antialias(data.cairo);
+	switch (antialias) {
+		case Cairo.CAIRO_ANTIALIAS_DEFAULT: return SWT.DEFAULT;
+		case Cairo.CAIRO_ANTIALIAS_NONE: return SWT.OFF;
+		case Cairo.CAIRO_ANTIALIAS_GRAY:
+		case Cairo.CAIRO_ANTIALIAS_SUBPIXEL: return SWT.ON;
+	}
+	return SWT.DEFAULT;
+}
+
+/** 
+ * Returns the background color.
+ *
+ * @return the receiver's background color
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public Color getBackground() {
+	if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	return Color.gtk_new(data.device, data.background);
+}
+
+/** 
+ * Returns the background pattern. The default value is
+ * <code>null</code>.
+ *
+ * @return the receiver's background pattern
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @see Pattern
+ * 
+ * @since 3.1
+ */
+public Pattern getBackgroundPattern() {
+	if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	return data.backgroundPattern;
+}
+
+/**
+ * Returns the width of the specified character in the font
+ * selected into the receiver. 
+ * <p>
+ * The width is defined as the space taken up by the actual
+ * character, not including the leading and tailing whitespace
+ * or overhang.
+ * </p>
+ *
+ * @param ch the character to measure
+ * @return the width of the character
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public int getCharWidth(char ch) {
+	if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	//BOGUS
+	return stringExtent(new String(new char[]{ch})).x;
+}
+
+/** 
+ * Returns the bounding rectangle of the receiver's clipping
+ * region. If no clipping region is set, the return value
+ * will be a rectangle which covers the entire bounds of the
+ * object the receiver is drawing on.
+ *
+ * @return the bounding rectangle of the clipping region
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public Rectangle getClipping() {
+	if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	/* Calculate visible bounds in device space */
+	int x = 0, y = 0, width = 0, height = 0;
+	if (data.width != -1 && data.height != -1) {
+		width = data.width;
+		height = data.height;
+	} else {
+		int[] w = new int[1], h = new int[1];
+		OS.gdk_drawable_get_size(data.drawable, w, h);
+		width = w[0];
+		height = h[0];
+	}
+	/* Intersect visible bounds with clipping in device space and then convert then to user space */
+	int /*long*/ cairo = data.cairo;
+	int /*long*/ clipRgn = data.clipRgn;
+	int /*long*/ damageRgn = data.damageRgn;
+	if (clipRgn != 0 || damageRgn != 0 || cairo != 0) {
+		int /*long*/ rgn = OS.gdk_region_new();
+		GdkRectangle rect = new GdkRectangle();
+		rect.width = width;
+		rect.height = height;
+		OS.gdk_region_union_with_rect(rgn, rect);
+		if (damageRgn != 0) {
+			OS.gdk_region_intersect (rgn, damageRgn);
+		}
+		/* Intersect visible bounds with clipping */
+		if (clipRgn != 0) {
+			/* Convert clipping to device space if needed */
+			if (data.clippingTransform != null) {
+				clipRgn = convertRgn(clipRgn, data.clippingTransform);
+				OS.gdk_region_intersect(rgn, clipRgn);
+				OS.gdk_region_destroy(clipRgn);
+			} else {
+				OS.gdk_region_intersect(rgn, clipRgn);
+			}
+		}
+		/* Convert to user space */
+		if (cairo != 0) {
+			double[] matrix = new double[6];
+			Cairo.cairo_get_matrix(cairo, matrix);
+			Cairo.cairo_matrix_invert(matrix);
+			clipRgn = convertRgn(rgn, matrix);
+			OS.gdk_region_destroy(rgn);
+			rgn = clipRgn;
+		}
+		OS.gdk_region_get_clipbox(rgn, rect);
+		OS.gdk_region_destroy(rgn);
+		x = rect.x;
+		y = rect.y;
+		width = rect.width;
+		height = rect.height;
+	}
+	return new Rectangle(x, y, width, height);
+}
+
+/** 
+ * Sets the region managed by the argument to the current
+ * clipping region of the receiver.
+ *
+ * @param region the region to fill with the clipping region
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the region is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the region is disposed</li>
+ * </ul>	
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void getClipping(Region region) {	
+	if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	if (region == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	if (region.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	int /*long*/ clipping = region.handle;
+	OS.gdk_region_subtract(clipping, clipping);
+	int /*long*/ cairo = data.cairo;
+	int /*long*/ clipRgn = data.clipRgn;
+	if (clipRgn == 0) {
+		GdkRectangle rect = new GdkRectangle();
+		if (data.width != -1 && data.height != -1) {
+			rect.width = data.width;
+			rect.height = data.height;
+		} else {
+			int[] width = new int[1], height = new int[1];
+			OS.gdk_drawable_get_size(data.drawable, width, height);
+			rect.width = width[0];
+			rect.height = height[0];
+		}
+		OS.gdk_region_union_with_rect(clipping, rect);
+	} else {
+		/* Convert clipping to device space if needed */
+		if (data.clippingTransform != null) {
+			int /*long*/ rgn = convertRgn(clipRgn, data.clippingTransform);
+			OS.gdk_region_union(clipping, rgn);
+			OS.gdk_region_destroy(rgn);
+		} else {
+			OS.gdk_region_union(clipping, clipRgn);
+		}
+	}
+	if (data.damageRgn != 0) {
+		OS.gdk_region_intersect(clipping, data.damageRgn);
+	}
+	/* Convert to user space */
+	if (cairo != 0) {
+		double[] matrix = new double[6];
+		Cairo.cairo_get_matrix(cairo, matrix);
+		Cairo.cairo_matrix_invert(matrix);
+		int /*long*/ rgn = convertRgn(clipping, matrix);
+		OS.gdk_region_subtract(clipping, clipping);
+		OS.gdk_region_union(clipping, rgn);
+		OS.gdk_region_destroy(rgn);
+	}
+}
+
+/** 
+ * Returns the receiver's fill rule, which will be one of
+ * <code>SWT.FILL_EVEN_ODD</code> or <code>SWT.FILL_WINDING</code>.
+ *
+ * @return the receiver's fill rule
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @since 3.1
+ */
+public int getFillRule() {
+	if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	int /*long*/ cairo = data.cairo;
+	if (cairo == 0) return SWT.FILL_EVEN_ODD;
+	return Cairo.cairo_get_fill_rule(cairo) == Cairo.CAIRO_FILL_RULE_WINDING ? SWT.FILL_WINDING : SWT.FILL_EVEN_ODD;
+}
+
+/** 
+ * Returns the font currently being used by the receiver
+ * to draw and measure text.
+ *
+ * @return the receiver's font
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public Font getFont() {
+	if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	return data.font;
+}
+
+/**
+ * Returns a FontMetrics which contains information
+ * about the font currently being used by the receiver
+ * to draw and measure text.
+ *
+ * @return font metrics for the receiver's font
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public FontMetrics getFontMetrics() {
+	if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	if (data.context == 0) createLayout();
+	checkGC(FONT);
+	Font font = data.font;
+	int /*long*/ context = data.context;
+	int /*long*/ lang = OS.pango_context_get_language(context);
+	int /*long*/ metrics = OS.pango_context_get_metrics(context, font.handle, lang);
+	FontMetrics fm = new FontMetrics();
+	fm.ascent = OS.PANGO_PIXELS(OS.pango_font_metrics_get_ascent(metrics));
+	fm.descent = OS.PANGO_PIXELS(OS.pango_font_metrics_get_descent(metrics));
+	fm.averageCharWidth = OS.PANGO_PIXELS(OS.pango_font_metrics_get_approximate_char_width(metrics));
+	fm.height = fm.ascent + fm.descent;
+	OS.pango_font_metrics_unref(metrics);
+	return fm;
+}
+
+/** 
+ * Returns the receiver's foreground color.
+ *
+ * @return the color used for drawing foreground things
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public Color getForeground() {	
+	if (handle == 0) SWT.error(SWT.ERROR_WIDGET_DISPOSED);
+	return Color.gtk_new(data.device, data.foreground);
+}
+
+/** 
+ * Returns the foreground pattern. The default value is
+ * <code>null</code>.
+ *
+ * @return the receiver's foreground pattern
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @see Pattern
+ * 
+ * @since 3.1
+ */
+public Pattern getForegroundPattern() {
+	if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	return data.foregroundPattern;
+}
+
+/** 
+ * Returns the GCData.
+ * <p>
+ * <b>IMPORTANT:</b> This method is <em>not</em> part of the public
+ * API for <code>GC</code>. It is marked public only so that it
+ * can be shared within the packages provided by SWT. It is not
+ * available on all platforms, and should never be called from
+ * application code.
+ * </p>
+ *
+ * @return the receiver's GCData
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @see GCData
+ * 
+ * @since 3.2
+ */
+public GCData getGCData() {
+	if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	return data;
+}
+
+/** 
+ * Returns the receiver's interpolation setting, which will be one of
+ * <code>SWT.DEFAULT</code>, <code>SWT.NONE</code>, 
+ * <code>SWT.LOW</code> or <code>SWT.HIGH</code>.
+ *
+ * @return the receiver's interpolation setting
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @since 3.1
+ */
+public int getInterpolation() {
+	if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	return data.interpolation;
+}
+
+/** 
+ * Returns the receiver's line attributes.
+ *
+ * @return the line attributes used for drawing lines
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @since 3.3 
+ */
+public LineAttributes getLineAttributes() {
+	if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	float[] dashes = null;
+	if (data.lineDashes != null) {
+		dashes = new float[data.lineDashes.length];
+		System.arraycopy(data.lineDashes, 0, dashes, 0, dashes.length);
+	}
+	return new LineAttributes(data.lineWidth, data.lineCap, data.lineJoin, data.lineStyle, dashes, data.lineDashesOffset, data.lineMiterLimit);
+}
+
+/** 
+ * Returns the receiver's line cap style, which will be one
+ * of the constants <code>SWT.CAP_FLAT</code>, <code>SWT.CAP_ROUND</code>,
+ * or <code>SWT.CAP_SQUARE</code>.
+ *
+ * @return the cap style used for drawing lines
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @since 3.1 
+ */
+public int getLineCap() {
+	if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	return data.lineCap;
+}
+
+/** 
+ * Returns the receiver's line dash style. The default value is
+ * <code>null</code>.
+ *
+ * @return the line dash style used for drawing lines
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @since 3.1 
+ */
+public int[] getLineDash() {
+	if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	if (data.lineDashes == null) return null;
+	int[] lineDashes = new int[data.lineDashes.length];
+	for (int i = 0; i < lineDashes.length; i++) {
+		lineDashes[i] = (int)data.lineDashes[i];
+	}
+	return lineDashes;
+}
+
+/** 
+ * Returns the receiver's line join style, which will be one
+ * of the constants <code>SWT.JOIN_MITER</code>, <code>SWT.JOIN_ROUND</code>,
+ * or <code>SWT.JOIN_BEVEL</code>.
+ *
+ * @return the join style used for drawing lines
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @since 3.1 
+ */
+public int getLineJoin() {
+	if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	return data.lineJoin;
+}
+
+/** 
+ * Returns the receiver's line style, which will be one
+ * of the constants <code>SWT.LINE_SOLID</code>, <code>SWT.LINE_DASH</code>,
+ * <code>SWT.LINE_DOT</code>, <code>SWT.LINE_DASHDOT</code> or
+ * <code>SWT.LINE_DASHDOTDOT</code>.
+ *
+ * @return the style used for drawing lines
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public int getLineStyle() {
+	if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	return data.lineStyle;
+}
+
+/** 
+ * Returns the width that will be used when drawing lines
+ * for all of the figure drawing operations (that is,
+ * <code>drawLine</code>, <code>drawRectangle</code>, 
+ * <code>drawPolyline</code>, and so forth.
+ *
+ * @return the receiver's line width 
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public int getLineWidth() {
+	if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	return (int)data.lineWidth;
+}
+
+/**
+ * Returns the receiver's style information.
+ * <p>
+ * Note that the value which is returned by this method <em>may
+ * not match</em> the value which was provided to the constructor
+ * when the receiver was created. This can occur when the underlying
+ * operating system does not support a particular combination of
+ * requested styles. 
+ * </p>
+ *
+ * @return the style bits
+ *  
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *   
+ * @since 2.1.2
+ */
+public int getStyle () {
+	if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	return data.style;
+}
+
+/**
+ * Returns the receiver's text drawing anti-aliasing setting value,
+ * which will be one of <code>SWT.DEFAULT</code>, <code>SWT.OFF</code> or
+ * <code>SWT.ON</code>. Note that this controls anti-aliasing
+ * <em>only</em> for text drawing operations.
+ *
+ * @return the anti-aliasing setting
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @see #getAntialias
+ * 
+ * @since 3.1
+ */
+public int getTextAntialias() {
+    if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+    if (data.cairo == 0) return SWT.DEFAULT;
+    int antialias = Cairo.CAIRO_ANTIALIAS_DEFAULT;
+    if (OS.GTK_VERSION < OS.VERSION(2, 8, 0)) {
+    	int /*long*/ options = Cairo.cairo_font_options_create();
+    	Cairo.cairo_get_font_options(data.cairo, options);
+    	antialias = Cairo.cairo_font_options_get_antialias(options);
+    	Cairo.cairo_font_options_destroy(options);
+    } else {
+    	if (data.context != 0) {
+    		int /*long*/ options = OS.pango_cairo_context_get_font_options(data.context);
+    		if (options != 0) antialias = Cairo.cairo_font_options_get_antialias(options);
+    	}
+    }
+	switch (antialias) {
+		case Cairo.CAIRO_ANTIALIAS_DEFAULT: return SWT.DEFAULT;
+		case Cairo.CAIRO_ANTIALIAS_NONE: return SWT.OFF;
+		case Cairo.CAIRO_ANTIALIAS_GRAY:
+		case Cairo.CAIRO_ANTIALIAS_SUBPIXEL: return SWT.ON;
+	}
+	return SWT.DEFAULT;
+}
+
+/** 
+ * Sets the parameter to the transform that is currently being
+ * used by the receiver.
+ *
+ * @param transform the destination to copy the transform into
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parameter is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the parameter has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @see Transform
+ * 
+ * @since 3.1
+ */
+public void getTransform(Transform transform) {
+	if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	if (transform == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	if (transform.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	int /*long*/ cairo = data.cairo;
+	if (cairo != 0) {
+		Cairo.cairo_get_matrix(cairo, transform.handle);
+		double[] identity = identity();
+		Cairo.cairo_matrix_invert(identity);
+		Cairo.cairo_matrix_multiply(transform.handle, transform.handle, identity);
+	} else {
+		transform.setElements(1, 0, 0, 1, 0, 0);
+	}
+}
+
+/** 
+ * Returns <code>true</code> if this GC is drawing in the mode
+ * where the resulting color in the destination is the
+ * <em>exclusive or</em> of the color values in the source
+ * and the destination, and <code>false</code> if it is
+ * drawing in the mode where the destination color is being
+ * replaced with the source color value.
+ *
+ * @return <code>true</code> true if the receiver is in XOR mode, and false otherwise
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public boolean getXORMode() {
+	if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	return data.xorMode;
+}
+
+/**
+ * Returns an integer hash code for the receiver. Any two 
+ * objects that return <code>true</code> when passed to 
+ * <code>equals</code> must return the same value for this
+ * method.
+ *
+ * @return the receiver's hash
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see #equals
+ */
+public int hashCode() {
+	return (int)/*64*/handle;
+}
+
+double[] identity() {
+	double[] identity = new double[6];
+	if ((data.style & SWT.MIRRORED) != 0) {
+		int[] w = new int[1], h = new int[1];
+		OS.gdk_drawable_get_size(data.drawable, w, h);
+		Cairo.cairo_matrix_init(identity, -1, 0, 0, 1, w[0], 0);
+	} else {
+		Cairo.cairo_matrix_init_identity(identity);
+	}
+	return identity;
+}
+
+void init(Drawable drawable, GCData data, int /*long*/ gdkGC) {
+	if (data.foreground != null) data.state &= ~FOREGROUND;
+	if (data.background != null) data.state &= ~(BACKGROUND | BACKGROUND_BG);
+	if (data.font != null) data.state &= ~FONT;
+
+	Image image = data.image;
+	if (image != null) {
+		image.memGC = this;
+		/*
+		 * The transparent pixel mask might change when drawing on
+		 * the image.  Destroy it so that it is regenerated when
+		 * necessary.
+		 */
+		if (image.transparentPixel != -1) image.destroyMask();
+	}
+	this.drawable = drawable;
+	this.data = data;
+	handle = gdkGC;
+	if ((data.style & SWT.MIRRORED) != 0) {
+	  initCairo();
+	  int /*long*/ cairo = data.cairo;
+	  Cairo.cairo_set_matrix(cairo, identity());
+	}
+}
+
+void initCairo() {
+	data.device.checkCairo();
+	int /*long*/ cairo = data.cairo;
+	if (cairo != 0) return;
+	int /*long*/ xDisplay = OS.GDK_DISPLAY();
+	int /*long*/ xVisual = OS.gdk_x11_visual_get_xvisual(OS.gdk_visual_get_system());
+	int /*long*/ xDrawable = 0;
+	int translateX = 0, translateY = 0;
+	int /*long*/ drawable = data.drawable;
+	if (data.image != null) {
+		xDrawable = OS.GDK_PIXMAP_XID(drawable);
+	} else {
+		if (!data.realDrawable) {
+			int[] x = new int[1], y = new int[1];
+			int /*long*/ [] real_drawable = new int /*long*/ [1];
+			OS.gdk_window_get_internal_paint_info(drawable, real_drawable, x, y);
+			xDrawable = OS.gdk_x11_drawable_get_xid(real_drawable[0]);
+			translateX = -x[0];
+			translateY = -y[0];
+		}
+	}
+	int[] w = new int[1], h = new int[1];
+	OS.gdk_drawable_get_size(drawable, w, h);
+	int width = w[0], height = h[0];
+	int /*long*/ surface = Cairo.cairo_xlib_surface_create(xDisplay, xDrawable, xVisual, width, height);
+	if (surface == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+	Cairo.cairo_surface_set_device_offset(surface, translateX, translateY);
+	data.cairo = cairo = Cairo.cairo_create(surface);
+	Cairo.cairo_surface_destroy(surface);
+	if (cairo == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+	data.disposeCairo = true;
+	Cairo.cairo_set_fill_rule(cairo, Cairo.CAIRO_FILL_RULE_EVEN_ODD);
+	data.state &= ~(BACKGROUND | FOREGROUND | FONT | LINE_WIDTH | LINE_CAP | LINE_JOIN | LINE_STYLE | DRAW_OFFSET);
+	setCairoClip(cairo, data.clipRgn);
+}
+
+/**
+ * Returns <code>true</code> if the receiver has a clipping
+ * region set into it, and <code>false</code> otherwise.
+ * If this method returns false, the receiver will draw on all
+ * available space in the destination. If it returns true, 
+ * it will draw only in the area that is covered by the region
+ * that can be accessed with <code>getClipping(region)</code>.
+ *
+ * @return <code>true</code> if the GC has a clipping region, and <code>false</code> otherwise
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public boolean isClipped() {
+	if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	return data.clipRgn != 0;
+}
+
+/**
+ * Returns <code>true</code> if the GC has been disposed,
+ * and <code>false</code> otherwise.
+ * <p>
+ * This method gets the dispose state for the GC.
+ * When a GC has been disposed, it is an error to
+ * invoke any other method using the GC.
+ *
+ * @return <code>true</code> when the GC is disposed and <code>false</code> otherwise
+ */
+public boolean isDisposed() {
+	return handle == 0;
+}
+
+boolean isIdentity(double[] matrix) {
+	if (matrix == null) return true;
+	return matrix[0] == 1 && matrix[1] == 0 && matrix[2] == 0 && matrix[3] == 1 && matrix[4] == 0 && matrix[5] == 0;
+}
+
+/**
+ * Sets the receiver to always use the operating system's advanced graphics
+ * subsystem for all graphics operations if the argument is <code>true</code>.
+ * If the argument is <code>false</code>, the advanced graphics subsystem is 
+ * no longer used, advanced graphics state is cleared and the normal graphics
+ * subsystem is used from now on.
+ * <p>
+ * Normally, the advanced graphics subsystem is invoked automatically when
+ * any one of the alpha, antialias, patterns, interpolation, paths, clipping
+ * or transformation operations in the receiver is requested.  When the receiver
+ * is switched into advanced mode, the advanced graphics subsystem performs both
+ * advanced and normal graphics operations.  Because the two subsystems are
+ * different, their output may differ.  Switching to advanced graphics before
+ * any graphics operations are performed ensures that the output is consistent.
+ * </p><p>
+ * Advanced graphics may not be installed for the operating system.  In this
+ * case, this operation does nothing.  Some operating system have only one
+ * graphics subsystem, so switching from normal to advanced graphics does
+ * nothing.  However, switching from advanced to normal graphics will always
+ * clear the advanced graphics state, even for operating systems that have
+ * only one graphics subsystem.
+ * </p>
+ *
+ * @param advanced the new advanced graphics state
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @see #setAlpha
+ * @see #setAntialias
+ * @see #setBackgroundPattern
+ * @see #setClipping(Path)
+ * @see #setForegroundPattern
+ * @see #setLineAttributes
+ * @see #setInterpolation
+ * @see #setTextAntialias
+ * @see #setTransform
+ * @see #getAdvanced
+ * 
+ * @since 3.1
+ */
+public void setAdvanced(boolean advanced) {
+	if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	if ((data.style & SWT.MIRRORED) != 0) {
+		if (!advanced) {
+			setAlpha(0xFF);
+			setAntialias(SWT.DEFAULT);
+			setBackgroundPattern(null);
+			setClipping(0);
+			setForegroundPattern(null);
+			setInterpolation(SWT.DEFAULT);
+			setTextAntialias(SWT.DEFAULT);
+			setTransform(null);
+		}
+		return;
+	}
+	if (advanced && data.cairo != 0) return;
+	if (advanced) {
+		try {
+			initCairo();
+		} catch (SWTException e) {}
+	} else {
+		if (!data.disposeCairo) return;
+		int /*long*/ cairo = data.cairo;
+		if (cairo != 0) Cairo.cairo_destroy(cairo);
+		data.cairo = 0;
+		data.interpolation = SWT.DEFAULT;
+		data.backgroundPattern = data.foregroundPattern = null;
+		data.state = 0;
+		setClipping(0);
+	}
+}
+
+/**
+ * Sets the receiver's alpha value which must be
+ * between 0 (transparent) and 255 (opaque).
+ * <p>
+ * This operation requires the operating system's advanced
+ * graphics subsystem which may not be available on some
+ * platforms.
+ * </p>
+ * @param alpha the alpha value
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_NO_GRAPHICS_LIBRARY - if advanced graphics are not available</li>
+ * </ul>
+ * 
+ * @see #getAdvanced
+ * @see #setAdvanced
+ * 
+ * @since 3.1
+ */
+public void setAlpha(int alpha) {
+	if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	if (data.cairo == 0 && (alpha & 0xff) == 0xff) return;
+	initCairo();
+	data.alpha = alpha & 0xff;
+	data.state &= ~(BACKGROUND | FOREGROUND | BACKGROUND_BG);
+}
+
+/**
+ * Sets the receiver's anti-aliasing value to the parameter, 
+ * which must be one of <code>SWT.DEFAULT</code>, <code>SWT.OFF</code>
+ * or <code>SWT.ON</code>. Note that this controls anti-aliasing for all
+ * <em>non-text drawing</em> operations.
+ * <p>
+ * This operation requires the operating system's advanced
+ * graphics subsystem which may not be available on some
+ * platforms.
+ * </p>
+ *
+ * @param antialias the anti-aliasing setting
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the parameter is not one of <code>SWT.DEFAULT</code>,
+ *                                 <code>SWT.OFF</code> or <code>SWT.ON</code></li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_NO_GRAPHICS_LIBRARY - if advanced graphics are not available</li>
+ * </ul>
+ * 
+ * @see #getAdvanced
+ * @see #setAdvanced
+ * @see #setTextAntialias
+ * 
+ * @since 3.1
+ */
+public void setAntialias(int antialias) {
+	if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	if (data.cairo == 0 && antialias == SWT.DEFAULT) return;
+	int mode = 0;
+	switch (antialias) {
+		case SWT.DEFAULT: mode = Cairo.CAIRO_ANTIALIAS_DEFAULT; break;
+		case SWT.OFF: mode = Cairo.CAIRO_ANTIALIAS_NONE; break;
+		case SWT.ON: mode = Cairo.CAIRO_ANTIALIAS_GRAY;
+            break;
+		default:
+			SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	}
+    initCairo();
+    int /*long*/ cairo = data.cairo;
+    Cairo.cairo_set_antialias(cairo, mode);
+}
+
+/**
+ * Sets the background color. The background color is used
+ * for fill operations and as the background color when text
+ * is drawn.
+ *
+ * @param color the new background color for the receiver
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the color is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the color has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void setBackground(Color color) {
+	if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	if (color == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	if (color.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	data.background = color.handle;
+	data.backgroundPattern = null;
+	data.state &= ~(BACKGROUND | BACKGROUND_BG);
+}
+
+/** 
+ * Sets the background pattern. The default value is <code>null</code>.
+ * <p>
+ * This operation requires the operating system's advanced
+ * graphics subsystem which may not be available on some
+ * platforms.
+ * </p>
+ * 
+ * @param pattern the new background pattern
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the parameter has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_NO_GRAPHICS_LIBRARY - if advanced graphics are not available</li>
+ * </ul>
+ * 
+ * @see Pattern
+ * @see #getAdvanced
+ * @see #setAdvanced
+ * 
+ * @since 3.1
+ */
+public void setBackgroundPattern(Pattern pattern) {
+	if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	if (pattern != null && pattern.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	if (data.cairo == 0 && pattern == null) return;
+	initCairo();
+	if (data.backgroundPattern == pattern) return;
+	data.backgroundPattern = pattern;
+	data.state &= ~BACKGROUND;
+}
+
+static void setCairoFont(int /*long*/ cairo, Font font) {
+	setCairoFont(cairo, font.handle);
+}
+
+static void setCairoFont(int /*long*/ cairo, int /*long*/ font) {
+	int /*long*/ family = OS.pango_font_description_get_family(font);
+	int length = OS.strlen(family);
+	byte[] buffer = new byte[length + 1];
+	OS.memmove(buffer, family, length);
+	//TODO - convert font height from pango to cairo
+	double height = OS.PANGO_PIXELS(OS.pango_font_description_get_size(font)) * 96 / 72;
+	int pangoStyle = OS.pango_font_description_get_style(font);
+	int pangoWeight = OS.pango_font_description_get_weight(font);
+	int slant = Cairo.CAIRO_FONT_SLANT_NORMAL;
+	if (pangoStyle == OS.PANGO_STYLE_ITALIC) slant = Cairo.CAIRO_FONT_SLANT_ITALIC;
+	if (pangoStyle == OS.PANGO_STYLE_OBLIQUE) slant = Cairo.CAIRO_FONT_SLANT_OBLIQUE;
+	int weight = Cairo.CAIRO_FONT_WEIGHT_NORMAL;
+	if (pangoWeight == OS.PANGO_WEIGHT_BOLD) weight = Cairo.CAIRO_FONT_WEIGHT_BOLD;
+	Cairo.cairo_select_font_face(cairo, buffer, slant, weight);
+	Cairo.cairo_set_font_size(cairo, height);
+}
+
+static void setCairoClip(int /*long*/ cairo, int /*long*/ clipRgn) {
+	Cairo.cairo_reset_clip(cairo);
+	if (clipRgn == 0) return;
+	if (OS.GTK_VERSION >= OS.VERSION(2, 8, 0)) {
+		OS.gdk_cairo_region(cairo, clipRgn);
+	} else {
+		int[] nRects = new int[1];
+		int /*long*/[] rects = new int /*long*/[1];
+		OS.gdk_region_get_rectangles(clipRgn, rects, nRects);
+		GdkRectangle rect = new GdkRectangle();
+		for (int i=0; i<nRects[0]; i++) {
+			OS.memmove(rect, rects[0] + (i * GdkRectangle.sizeof), GdkRectangle.sizeof);
+			Cairo.cairo_rectangle(cairo, rect.x, rect.y, rect.width, rect.height);
+		}
+		if (rects[0] != 0) OS.g_free(rects[0]);
+	}
+	Cairo.cairo_clip(cairo);
+}
+
+static void setCairoPatternColor(int /*long*/ pattern, int offset, Color c, int alpha) {
+	GdkColor color = c.handle;
+	double aa = (alpha & 0xFF) / (double)0xFF;
+	double red = ((color.red & 0xFFFF) / (double)0xFFFF);
+	double green = ((color.green & 0xFFFF) / (double)0xFFFF);
+	double blue = ((color.blue & 0xFFFF) / (double)0xFFFF);
+	Cairo.cairo_pattern_add_color_stop_rgba(pattern, offset, red, green, blue, aa);
+}
+
+void setClipping(int /*long*/ clipRgn) {
+	int /*long*/ cairo = data.cairo;
+	if (clipRgn == 0) {
+		if (data.clipRgn != 0) {
+			OS.gdk_region_destroy(data.clipRgn);
+			data.clipRgn = 0;
+		}
+		if (cairo != 0) {
+			data.clippingTransform = null;
+			setCairoClip(cairo, clipRgn);
+		} else {
+			int /*long*/ clipping = data.damageRgn != 0 ? data.damageRgn : 0;
+			OS.gdk_gc_set_clip_region(handle, clipping);
+		}
+	} else {
+		if (data.clipRgn == 0) data.clipRgn = OS.gdk_region_new();
+		OS.gdk_region_subtract(data.clipRgn, data.clipRgn);
+		OS.gdk_region_union(data.clipRgn, clipRgn);
+		if (cairo != 0) {
+			if (data.clippingTransform == null) data.clippingTransform = new double[6];
+			Cairo.cairo_get_matrix(cairo, data.clippingTransform);
+			setCairoClip(cairo, clipRgn);
+		} else {
+			int /*long*/ clipping = clipRgn;
+			if (data.damageRgn != 0) {
+				clipping = OS.gdk_region_new();
+				OS.gdk_region_union(clipping, clipRgn);
+				OS.gdk_region_intersect(clipping, data.damageRgn);
+			}
+			OS.gdk_gc_set_clip_region(handle, clipping);
+			if (clipping != clipRgn) OS.gdk_region_destroy(clipping);
+		}
+	}
+}
+
+/**
+ * Sets the area of the receiver which can be changed
+ * by drawing operations to the rectangular area specified
+ * by the arguments.
+ *
+ * @param x the x coordinate of the clipping rectangle
+ * @param y the y coordinate of the clipping rectangle
+ * @param width the width of the clipping rectangle
+ * @param height the height of the clipping rectangle
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void setClipping(int x, int y, int width, int height) {
+	if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	if (width < 0) {
+		x = x + width;
+		width = -width;
+	}
+	if (height < 0) {
+		y = y + height;
+		height = -height;
+	}
+	GdkRectangle rect = new GdkRectangle();
+	rect.x = x;
+	rect.y = y;
+	rect.width = width;
+	rect.height = height;
+	int /*long*/ clipRgn = OS.gdk_region_new();
+	OS.gdk_region_union_with_rect(clipRgn, rect);
+	setClipping(clipRgn);
+	OS.gdk_region_destroy(clipRgn);
+}
+
+/**
+ * Sets the area of the receiver which can be changed
+ * by drawing operations to the path specified
+ * by the argument.  
+ * <p>
+ * This operation requires the operating system's advanced
+ * graphics subsystem which may not be available on some
+ * platforms.
+ * </p>
+ * 
+ * @param path the clipping path.
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the path has been disposed</li>
+ * </ul> 
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_NO_GRAPHICS_LIBRARY - if advanced graphics are not available</li>
+ * </ul>
+ * 
+ * @see Path
+ * @see #getAdvanced
+ * @see #setAdvanced
+ * 
+ * @since 3.1
+ */
+public void setClipping(Path path) {
+	if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	if (path != null && path.isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	setClipping(0);
+	if (path != null) {
+		initCairo();
+		int /*long*/ cairo = data.cairo;
+		int /*long*/ copy = Cairo.cairo_copy_path(path.handle);
+		if (copy == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+		Cairo.cairo_append_path(cairo, copy);
+		Cairo.cairo_path_destroy(copy);
+		Cairo.cairo_clip(cairo);
+	}
+}
+
+/**
+ * Sets the area of the receiver which can be changed
+ * by drawing operations to the rectangular area specified
+ * by the argument.  Specifying <code>null</code> for the
+ * rectangle reverts the receiver's clipping area to its
+ * original value.
+ *
+ * @param rect the clipping rectangle or <code>null</code>
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void setClipping(Rectangle rect) {
+	if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	if (rect == null) {
+		setClipping(0);
+	} else {
+		setClipping(rect.x, rect.y, rect.width, rect.height);
+	}
+}
+/**
+ * Sets the area of the receiver which can be changed
+ * by drawing operations to the region specified
+ * by the argument.  Specifying <code>null</code> for the
+ * region reverts the receiver's clipping area to its
+ * original value.
+ *
+ * @param region the clipping region or <code>null</code>
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the region has been disposed</li>
+ * </ul> 
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void setClipping(Region region) {
+	if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	if (region != null && region.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	setClipping(region != null ? region.handle : 0);
+}
+
+/** 
+ * Sets the font which will be used by the receiver
+ * to draw and measure text to the argument. If the
+ * argument is null, then a default font appropriate
+ * for the platform will be used instead.
+ *
+ * @param font the new font for the receiver, or null to indicate a default font
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the font has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void setFont(Font font) {
+	if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	if (font != null && font.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	data.font = font != null ? font : data.device.systemFont;
+	data.state &= ~FONT;
+	data.stringWidth = data.stringHeight = -1;
+}
+
+/** 
+ * Sets the receiver's fill rule to the parameter, which must be one of
+ * <code>SWT.FILL_EVEN_ODD</code> or <code>SWT.FILL_WINDING</code>.
+ *
+ * @param rule the new fill rule
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the rule is not one of <code>SWT.FILL_EVEN_ODD</code>
+ *                                 or <code>SWT.FILL_WINDING</code></li>
+ * </ul> 
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @since 3.1
+ */
+public void setFillRule(int rule) {
+	if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	int cairo_mode = Cairo.CAIRO_FILL_RULE_EVEN_ODD;
+	switch (rule) {
+		case SWT.FILL_WINDING:
+			cairo_mode = Cairo.CAIRO_FILL_RULE_WINDING; break;
+		case SWT.FILL_EVEN_ODD:
+			cairo_mode = Cairo.CAIRO_FILL_RULE_EVEN_ODD; break;
+		default:
+			SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	}
+	//TODO - need fill rule in X, GDK has no API
+	initCairo();
+	int /*long*/ cairo = data.cairo;
+	if (cairo != 0) {
+		Cairo.cairo_set_fill_rule(cairo, cairo_mode);
+	}
+}
+
+/**
+ * Sets the foreground color. The foreground color is used
+ * for drawing operations including when text is drawn.
+ *
+ * @param color the new foreground color for the receiver
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the color is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the color has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void setForeground(Color color) {	
+	if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	if (color == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	if (color.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	data.foreground = color.handle;
+	data.foregroundPattern = null;
+	data.state &= ~FOREGROUND;
+}
+
+/** 
+ * Sets the foreground pattern. The default value is <code>null</code>.
+ * <p>
+ * This operation requires the operating system's advanced
+ * graphics subsystem which may not be available on some
+ * platforms.
+ * </p>
+ * @param pattern the new foreground pattern
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the parameter has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_NO_GRAPHICS_LIBRARY - if advanced graphics are not available</li>
+ * </ul>
+ * 
+ * @see Pattern
+ * @see #getAdvanced
+ * @see #setAdvanced
+ * 
+ * @since 3.1
+ */
+public void setForegroundPattern(Pattern pattern) {
+	if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	if (pattern != null && pattern.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	if (data.cairo == 0 && pattern == null) return;
+	initCairo();
+	if (data.foregroundPattern == pattern) return;
+	data.foregroundPattern = pattern;
+	data.state &= ~FOREGROUND;
+}
+
+/** 
+ * Sets the receiver's interpolation setting to the parameter, which
+ * must be one of <code>SWT.DEFAULT</code>, <code>SWT.NONE</code>, 
+ * <code>SWT.LOW</code> or <code>SWT.HIGH</code>.
+ * <p>
+ * This operation requires the operating system's advanced
+ * graphics subsystem which may not be available on some
+ * platforms.
+ * </p>
+ * 
+ * @param interpolation the new interpolation setting
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the rule is not one of <code>SWT.DEFAULT</code>, 
+ *                                 <code>SWT.NONE</code>, <code>SWT.LOW</code> or <code>SWT.HIGH</code>
+ * </ul> 
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_NO_GRAPHICS_LIBRARY - if advanced graphics are not available</li>
+ * </ul>
+ * 
+ * @see #getAdvanced
+ * @see #setAdvanced
+ * 
+ * @since 3.1
+ */
+public void setInterpolation(int interpolation) {
+	if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	if (data.cairo == 0 && interpolation == SWT.DEFAULT) return;
+	switch (interpolation) {
+		case SWT.DEFAULT:
+		case SWT.NONE:
+		case SWT.LOW:
+		case SWT.HIGH:
+			break;
+		default:
+			SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	}
+	initCairo();
+	data.interpolation = interpolation;
+}
+
+/**
+ * Sets the receiver's line attributes.
+ * <p>
+ * This operation requires the operating system's advanced
+ * graphics subsystem which may not be available on some
+ * platforms.
+ * </p>
+ * @param attributes the line attributes
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the attributes is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if any of the line attributes is not valid</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_NO_GRAPHICS_LIBRARY - if advanced graphics are not available</li>
+ * </ul>
+ * 
+ * @see LineAttributes
+ * @see #getAdvanced
+ * @see #setAdvanced
+ * 
+ * @since 3.3
+ */
+public void setLineAttributes(LineAttributes attributes) {
+	if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	if (attributes == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	int mask = 0;
+	float lineWidth = attributes.width;
+	if (lineWidth != data.lineWidth) {
+		mask |= LINE_WIDTH | DRAW_OFFSET;
+	}
+	int lineStyle = attributes.style;
+	if (lineStyle != data.lineStyle) {
+		mask |= LINE_STYLE;
+		switch (lineStyle) {
+			case SWT.LINE_SOLID:
+			case SWT.LINE_DASH:
+			case SWT.LINE_DOT:
+			case SWT.LINE_DASHDOT:
+			case SWT.LINE_DASHDOTDOT:
+				break;
+			case SWT.LINE_CUSTOM:
+				if (attributes.dash == null) lineStyle = SWT.LINE_SOLID;
+				break;
+			default:
+				SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+		}
+	}
+	int join = attributes.join;
+	if (join != data.lineJoin) {
+		mask |= LINE_JOIN;
+		switch (join) {
+			case SWT.CAP_ROUND:
+			case SWT.CAP_FLAT:
+			case SWT.CAP_SQUARE:
+				break;
+			default:
+				SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+		}
+	}
+	int cap = attributes.cap;
+	if (cap != data.lineCap) {
+		mask |= LINE_CAP;
+		switch (cap) {
+			case SWT.JOIN_MITER:
+			case SWT.JOIN_ROUND:
+			case SWT.JOIN_BEVEL:
+				break;
+			default:
+				SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+		}
+	}
+	float[] dashes = attributes.dash;
+	float[] lineDashes = data.lineDashes;
+	if (dashes != null && dashes.length > 0) {
+		boolean changed = lineDashes == null || lineDashes.length != dashes.length;
+		for (int i = 0; i < dashes.length; i++) {
+			float dash = dashes[i];
+			if (dash <= 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+			if (!changed && lineDashes[i] != dash) changed = true;
+		}
+		if (changed) {
+			float[] newDashes = new float[dashes.length];
+			System.arraycopy(dashes, 0, newDashes, 0, dashes.length);
+			dashes = newDashes;
+			mask |= LINE_STYLE;
+		} else {
+			dashes = lineDashes;
+		}
+	} else {
+		if (lineDashes != null && lineDashes.length > 0) {
+			mask |= LINE_STYLE;
+		} else {
+			dashes = lineDashes;
+		}
+	}
+	float dashOffset = attributes.dashOffset;
+	if (dashOffset != data.lineDashesOffset) {
+		mask |= LINE_STYLE;		
+	}
+	float miterLimit = attributes.miterLimit;
+	if (miterLimit != data.lineMiterLimit) {
+		mask |= LINE_MITERLIMIT;		
+	}
+	initCairo();
+	if (mask == 0) return;
+	data.lineWidth = lineWidth;
+	data.lineStyle = lineStyle;
+	data.lineCap = cap;
+	data.lineJoin = join;
+	data.lineDashes = dashes;
+	data.lineDashesOffset = dashOffset;
+	data.lineMiterLimit = miterLimit;
+	data.state &= ~mask;
+}
+
+/** 
+ * Sets the receiver's line cap style to the argument, which must be one
+ * of the constants <code>SWT.CAP_FLAT</code>, <code>SWT.CAP_ROUND</code>,
+ * or <code>SWT.CAP_SQUARE</code>.
+ *
+ * @param cap the cap style to be used for drawing lines
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the style is not valid</li>
+ * </ul> 
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @since 3.1 
+ */
+public void setLineCap(int cap) {
+	if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	if (data.lineCap == cap) return;
+	switch (cap) {
+		case SWT.CAP_ROUND:
+		case SWT.CAP_FLAT:
+		case SWT.CAP_SQUARE:
+			break;
+		default:
+			SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	}
+	data.lineCap = cap;
+	data.state &= ~LINE_CAP;
+}
+
+/** 
+ * Sets the receiver's line dash style to the argument. The default
+ * value is <code>null</code>. If the argument is not <code>null</code>,
+ * the receiver's line style is set to <code>SWT.LINE_CUSTOM</code>, otherwise
+ * it is set to <code>SWT.LINE_SOLID</code>.
+ *
+ * @param dashes the dash style to be used for drawing lines
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if any of the values in the array is less than or equal 0</li>
+ * </ul> 
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @since 3.1 
+ */
+public void setLineDash(int[] dashes) {
+	if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	float[] lineDashes = data.lineDashes;
+	if (dashes != null && dashes.length > 0) {
+		boolean changed = data.lineStyle != SWT.LINE_CUSTOM || lineDashes == null || lineDashes.length != dashes.length;
+		for (int i = 0; i < dashes.length; i++) {
+			int dash = dashes[i];
+			if (dash <= 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+			if (!changed && lineDashes[i] != dash) changed = true;
+		}
+		if (!changed) return;
+		data.lineDashes = new float[dashes.length];
+		for (int i = 0; i < dashes.length; i++) {
+			data.lineDashes[i] = dashes[i];
+		}
+		data.lineStyle = SWT.LINE_CUSTOM;
+	} else {
+		if (data.lineStyle == SWT.LINE_SOLID && (lineDashes == null || lineDashes.length == 0)) return;
+		data.lineDashes = null;
+		data.lineStyle = SWT.LINE_SOLID;
+	}
+	data.state &= ~LINE_STYLE;
+}
+
+/** 
+ * Sets the receiver's line join style to the argument, which must be one
+ * of the constants <code>SWT.JOIN_MITER</code>, <code>SWT.JOIN_ROUND</code>,
+ * or <code>SWT.JOIN_BEVEL</code>.
+ *
+ * @param join the join style to be used for drawing lines
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the style is not valid</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @since 3.1 
+ */
+public void setLineJoin(int join) {
+	if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	if (data.lineJoin == join) return;
+	switch (join) {
+		case SWT.JOIN_MITER:
+		case SWT.JOIN_ROUND:
+		case SWT.JOIN_BEVEL:
+			break;
+		default:
+			SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	}
+	data.lineJoin = join;
+	data.state &= ~LINE_JOIN;
+}
+
+/** 
+ * Sets the receiver's line style to the argument, which must be one
+ * of the constants <code>SWT.LINE_SOLID</code>, <code>SWT.LINE_DASH</code>,
+ * <code>SWT.LINE_DOT</code>, <code>SWT.LINE_DASHDOT</code> or
+ * <code>SWT.LINE_DASHDOTDOT</code>.
+ *
+ * @param lineStyle the style to be used for drawing lines
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the style is not valid</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void setLineStyle(int lineStyle) {
+	if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	if (data.lineStyle == lineStyle) return;
+	switch (lineStyle) {
+		case SWT.LINE_SOLID:
+		case SWT.LINE_DASH:
+		case SWT.LINE_DOT:
+		case SWT.LINE_DASHDOT:
+		case SWT.LINE_DASHDOTDOT:
+			break;
+		case SWT.LINE_CUSTOM:
+			if (data.lineDashes == null) lineStyle = SWT.LINE_SOLID;
+			break;
+		default:
+			SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	}
+	data.lineStyle = lineStyle;
+	data.state &= ~LINE_STYLE;
+}
+
+/** 
+ * Sets the width that will be used when drawing lines
+ * for all of the figure drawing operations (that is,
+ * <code>drawLine</code>, <code>drawRectangle</code>, 
+ * <code>drawPolyline</code>, and so forth.
+ * <p>
+ * Note that line width of zero is used as a hint to
+ * indicate that the fastest possible line drawing
+ * algorithms should be used. This means that the
+ * output may be different from line width one.
+ * </p>
+ *
+ * @param lineWidth the width of a line
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void setLineWidth(int lineWidth) {
+	if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	if (data.lineWidth == lineWidth) return;
+	data.lineWidth = lineWidth;
+	data.state &= ~(LINE_WIDTH | DRAW_OFFSET);
+}
+
+void setString(String string, int flags) {
+	if (data.layout == 0) createLayout();
+	if (string == data.string && (flags & ~SWT.DRAW_TRANSPARENT) == (data.drawFlags  & ~SWT.DRAW_TRANSPARENT)) {
+		return;
+	}
+	byte[] buffer;
+	int mnemonic, length = string.length ();
+	int /*long*/ layout = data.layout;
+	char[] text = new char[length];
+	string.getChars(0, length, text, 0);	
+	if ((flags & SWT.DRAW_MNEMONIC) != 0 && (mnemonic = fixMnemonic(text)) != -1) {
+		char[] text1 = new char[mnemonic - 1];
+		System.arraycopy(text, 0, text1, 0, text1.length);
+		byte[] buffer1 = Converter.wcsToMbcs(null, text1, false);
+		char[] text2 = new char[text.length - mnemonic];
+		System.arraycopy(text, mnemonic - 1, text2, 0, text2.length);
+		byte[] buffer2 = Converter.wcsToMbcs(null, text2, false);
+		buffer = new byte[buffer1.length + buffer2.length];
+		System.arraycopy(buffer1, 0, buffer, 0, buffer1.length);
+		System.arraycopy(buffer2, 0, buffer, buffer1.length, buffer2.length);
+		int /*long*/ attr_list = OS.pango_attr_list_new();
+		int /*long*/ attr = OS.pango_attr_underline_new(OS.PANGO_UNDERLINE_LOW);
+		PangoAttribute attribute = new PangoAttribute();
+		OS.memmove(attribute, attr, PangoAttribute.sizeof);
+		attribute.start_index = buffer1.length;
+		attribute.end_index = buffer1.length + 1;
+		OS.memmove(attr, attribute, PangoAttribute.sizeof);
+		OS.pango_attr_list_insert(attr_list, attr);
+		OS.pango_layout_set_attributes(layout, attr_list);
+		OS.pango_attr_list_unref(attr_list);
+	} else {
+		buffer = Converter.wcsToMbcs(null, text, false);
+		OS.pango_layout_set_attributes(layout, 0);
+	}
+	OS.pango_layout_set_text(layout, buffer, buffer.length);
+	OS.pango_layout_set_single_paragraph_mode(layout, (flags & SWT.DRAW_DELIMITER) == 0);
+	OS.pango_layout_set_tabs(layout, (flags & SWT.DRAW_TAB) != 0 ? 0 : data.device.emptyTab);
+	data.string = string;
+	data.stringWidth = data.stringHeight = -1;
+	data.drawFlags = flags;
+}
+
+/**
+ * Sets the receiver's text anti-aliasing value to the parameter, 
+ * which must be one of <code>SWT.DEFAULT</code>, <code>SWT.OFF</code>
+ * or <code>SWT.ON</code>. Note that this controls anti-aliasing only
+ * for all <em>text drawing</em> operations.
+ * <p>
+ * This operation requires the operating system's advanced
+ * graphics subsystem which may not be available on some
+ * platforms.
+ * </p>
+ * 
+ * @param antialias the anti-aliasing setting
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the parameter is not one of <code>SWT.DEFAULT</code>,
+ *                                 <code>SWT.OFF</code> or <code>SWT.ON</code></li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_NO_GRAPHICS_LIBRARY - if advanced graphics are not available</li>
+ * </ul>
+ * 
+ * @see #getAdvanced
+ * @see #setAdvanced
+ * @see #setAntialias
+ * 
+ * @since 3.1
+ */
+public void setTextAntialias(int antialias) {
+    if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	if (data.cairo == 0 && antialias == SWT.DEFAULT) return;
+	int mode = 0;
+	switch (antialias) {
+		case SWT.DEFAULT: mode = Cairo.CAIRO_ANTIALIAS_DEFAULT; break;
+		case SWT.OFF: mode = Cairo.CAIRO_ANTIALIAS_NONE; break;
+		case SWT.ON: mode = Cairo.CAIRO_ANTIALIAS_GRAY;
+            break;
+		default:
+			SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	}
+    initCairo();
+    int /*long*/ options = Cairo.cairo_font_options_create();
+    Cairo.cairo_font_options_set_antialias(options, mode);
+    if (OS.GTK_VERSION < OS.VERSION(2, 8, 0)) {
+    	Cairo.cairo_set_font_options(data.cairo, options);
+    } else {
+    	if (data.context == 0) createLayout();
+    	OS.pango_cairo_context_set_font_options(data.context, options);
+    }
+    Cairo.cairo_font_options_destroy(options);
+}
+
+/**
+ * Sets the transform that is currently being used by the receiver. If
+ * the argument is <code>null</code>, the current transform is set to
+ * the identity transform.
+ * <p>
+ * This operation requires the operating system's advanced
+ * graphics subsystem which may not be available on some
+ * platforms.
+ * </p>
+ * 
+ * @param transform the transform to set
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the parameter has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_NO_GRAPHICS_LIBRARY - if advanced graphics are not available</li>
+ * </ul>
+ * 
+ * @see Transform
+ * @see #getAdvanced
+ * @see #setAdvanced
+ * 
+ * @since 3.1
+ */
+public void setTransform(Transform transform) {
+	if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	if (transform != null && transform.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	if (data.cairo == 0 && transform == null) return;
+	initCairo();
+	int /*long*/ cairo = data.cairo;
+	double[] identity = identity();
+	if (transform != null) {
+		Cairo.cairo_matrix_multiply(identity, transform.handle, identity);
+	} 
+	Cairo.cairo_set_matrix(cairo, identity);
+	data.state &= ~DRAW_OFFSET;
+}
+
+/** 
+ * If the argument is <code>true</code>, puts the receiver
+ * in a drawing mode where the resulting color in the destination
+ * is the <em>exclusive or</em> of the color values in the source
+ * and the destination, and if the argument is <code>false</code>,
+ * puts the receiver in a drawing mode where the destination color
+ * is replaced with the source color value.
+ * <p>
+ * Note that this mode in fundamentally unsupportable on certain
+ * platforms, notably Carbon (Mac OS X). Clients that want their
+ * code to run on all platforms need to avoid this method.
+ * </p>
+ *
+ * @param xor if <code>true</code>, then <em>xor</em> mode is used, otherwise <em>source copy</em> mode is used
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @deprecated this functionality is not supported on some platforms
+ */
+public void setXORMode(boolean xor) {
+	if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	OS.gdk_gc_set_function(handle, xor ? OS.GDK_XOR : OS.GDK_COPY);
+	data.xorMode = xor;
+}
+
+/**
+ * Returns the extent of the given string. No tab
+ * expansion or carriage return processing will be performed.
+ * <p>
+ * The <em>extent</em> of a string is the width and height of
+ * the rectangular area it would cover if drawn in a particular
+ * font (in this case, the current font in the receiver).
+ * </p>
+ *
+ * @param string the string to measure
+ * @return a point containing the extent of the string
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public Point stringExtent(String string) {	
+	return textExtent(string, 0);
+}
+
+/**
+ * Returns the extent of the given string. Tab expansion and
+ * carriage return processing are performed.
+ * <p>
+ * The <em>extent</em> of a string is the width and height of
+ * the rectangular area it would cover if drawn in a particular
+ * font (in this case, the current font in the receiver).
+ * </p>
+ *
+ * @param string the string to measure
+ * @return a point containing the extent of the string
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public Point textExtent(String string) {
+	return textExtent(string, SWT.DRAW_DELIMITER | SWT.DRAW_TAB);
+}
+
+/**
+ * Returns the extent of the given string. Tab expansion, line
+ * delimiter and mnemonic processing are performed according to
+ * the specified flags, which can be a combination of:
+ * <dl>
+ * <dt><b>DRAW_DELIMITER</b></dt>
+ * <dd>draw multiple lines</dd>
+ * <dt><b>DRAW_TAB</b></dt>
+ * <dd>expand tabs</dd>
+ * <dt><b>DRAW_MNEMONIC</b></dt>
+ * <dd>underline the mnemonic character</dd>
+ * <dt><b>DRAW_TRANSPARENT</b></dt>
+ * <dd>transparent background</dd>
+ * </dl>
+ * <p>
+ * The <em>extent</em> of a string is the width and height of
+ * the rectangular area it would cover if drawn in a particular
+ * font (in this case, the current font in the receiver).
+ * </p>
+ *
+ * @param string the string to measure
+ * @param flags the flags specifying how to process the text
+ * @return a point containing the extent of the string
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public Point textExtent(String string, int flags) {
+	if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	if (string == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	int /*long*/ cairo = data.cairo;
+	if (cairo != 0) {
+		if (OS.GTK_VERSION < OS.VERSION(2, 8, 0)) {
+			//TODO - honor flags
+			checkGC(FONT);
+			byte[] buffer = Converter.wcsToMbcs(null, string, true);
+			cairo_font_extents_t font_extents = new cairo_font_extents_t();
+			Cairo.cairo_font_extents(cairo, font_extents);
+			cairo_text_extents_t extents = new cairo_text_extents_t();
+			Cairo.cairo_text_extents(cairo, buffer, extents);
+			return new Point((int)extents.width, (int)font_extents.height);
+		}
+	}
+	setString(string, flags);
+	checkGC(FONT);
+	if (data.stringWidth != -1) return new Point(data.stringWidth, data.stringHeight);
+	int[] width = new int[1], height = new int[1];
+	OS.pango_layout_get_size(data.layout, width, height);
+	return new Point(data.stringWidth = OS.PANGO_PIXELS(width[0]), data.stringHeight = OS.PANGO_PIXELS(height[0]));
+}
+
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the receiver
+ */
+public String toString () {
+	if (isDisposed()) return "GC {*DISPOSED*}";
+	return "GC {" + handle + "}";
+}
+
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/GCData.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/GCData.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/GCData.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.graphics;
+
+
+import org.eclipse.swt.internal.gtk.*;
+import org.eclipse.swt.*;
+
+/**
+ * Instances of this class are descriptions of GCs in terms
+ * of unallocated platform-specific data fields.
+ * <p>
+ * <b>IMPORTANT:</b> This class is <em>not</em> part of the public
+ * API for SWT. It is marked public only so that it can be shared
+ * within the packages provided by SWT. It is not available on all
+ * platforms, and should never be called from application code.
+ * </p>
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public final class GCData {
+	public Device device;
+	public int style, state = -1;
+	public GdkColor foreground;
+	public GdkColor background;
+	public Font font;
+	public Pattern foregroundPattern;
+	public Pattern backgroundPattern;
+	public int /*long*/ clipRgn;
+	public float lineWidth;
+	public int lineStyle = SWT.LINE_SOLID;
+	public float[] lineDashes;
+	public float lineDashesOffset;
+	public float lineMiterLimit = 10;
+	public int lineCap = SWT.CAP_FLAT;
+	public int lineJoin = SWT.JOIN_MITER;
+	public boolean xorMode;
+	public int alpha = 0xFF;
+	public int interpolation = SWT.DEFAULT;
+
+	public int /*long*/ context;
+	public int /*long*/ layout;
+	public int /*long*/ damageRgn;
+	public Image image;
+	public int /*long*/ drawable;	
+	public int /*long*/ cairo;
+	public double cairoXoffset, cairoYoffset;
+	public boolean disposeCairo;
+	public double[] clippingTransform;
+	public String string;
+	public int stringWidth = -1;
+	public int stringHeight = -1;
+	public int drawFlags;
+	public boolean realDrawable;
+	public int width = -1, height = -1;
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/GlyphMetrics.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/GlyphMetrics.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/GlyphMetrics.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,114 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.graphics;
+
+import org.eclipse.swt.*;
+
+/**
+ * Instances of this class represent glyph metrics.
+ * <p>
+ * The hashCode() method in this class uses the values of the public
+ * fields to compute the hash value. When storing instances of the
+ * class in hashed collections, do not modify these fields after the
+ * object has been inserted.  
+ * </p>
+ * <p>
+ * Application code does <em>not</em> need to explicitly release the
+ * resources managed by each instance when those instances are no longer
+ * required, and thus no <code>dispose()</code> method is provided.
+ * </p>
+ * 
+ * @see TextStyle
+ * @see TextLayout
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ * 
+ * @since 3.2
+ */
+public final class GlyphMetrics {
+	
+	/**
+	 * the ascent of the GlyphMetrics
+	 */
+	public int ascent;
+	
+	/**
+	 * the descent of the GlyphMetrics
+	 */
+	public int descent;
+	
+	/**
+	 * the width of the GlyphMetrics
+	 */
+	public int width;
+	
+/**
+ * Constructs an instance of this class with the given
+ * ascent, descent and width values.
+ *
+ * @param ascent the GlyphMetrics ascent
+ * @param descent the GlyphMetrics descent
+ * @param width the GlyphMetrics width
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the ascent, descent or width argument is negative</li>
+ * </ul>
+ */
+public GlyphMetrics(int ascent, int descent, int width) {
+	if (ascent < 0 || descent < 0 || width < 0) {
+		SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	}
+	this.ascent = ascent;
+	this.descent = descent;
+	this.width = width;
+}
+
+/**
+ * Compares the argument to the receiver, and returns true
+ * if they represent the <em>same</em> object using a class
+ * specific comparison.
+ *
+ * @param object the object to compare with this object
+ * @return <code>true</code> if the object is the same as this object and <code>false</code> otherwise
+ *
+ * @see #hashCode()
+ */
+public boolean equals (Object object) {
+	if (object == this) return true;
+	if (!(object instanceof GlyphMetrics)) return false;
+	GlyphMetrics metrics = (GlyphMetrics)object;
+	return metrics.ascent == ascent && metrics.descent == descent && metrics.width == width;
+}
+
+/**
+ * Returns an integer hash code for the receiver. Any two 
+ * objects that return <code>true</code> when passed to 
+ * <code>equals</code> must return the same value for this
+ * method.
+ *
+ * @return the receiver's hash
+ *
+ * @see #equals(Object)
+ */
+public int hashCode () {
+	return ascent ^ descent ^ width;
+}
+
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the <code>GlyphMetrics</code>
+ */
+public String toString () {
+	return "GlyphMetrics {" + ascent + ", " + descent + ", " + width + "}"; //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+}
+
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/Image.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/Image.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/Image.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,1163 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.graphics;
+
+ 
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.cairo.*;
+import org.eclipse.swt.internal.gtk.*;
+import org.eclipse.swt.*;
+
+import java.io.*;
+ 
+/**
+ * Instances of this class are graphics which have been prepared
+ * for display on a specific device. That is, they are ready
+ * to paint using methods such as <code>GC.drawImage()</code>
+ * and display on widgets with, for example, <code>Button.setImage()</code>.
+ * <p>
+ * If loaded from a file format that supports it, an
+ * <code>Image</code> may have transparency, meaning that certain
+ * pixels are specified as being transparent when drawn. Examples
+ * of file formats that support transparency are GIF and PNG.
+ * </p><p>
+ * There are two primary ways to use <code>Images</code>. 
+ * The first is to load a graphic file from disk and create an
+ * <code>Image</code> from it. This is done using an <code>Image</code>
+ * constructor, for example:
+ * <pre>
+ *    Image i = new Image(device, "C:\\graphic.bmp");
+ * </pre>
+ * A graphic file may contain a color table specifying which
+ * colors the image was intended to possess. In the above example,
+ * these colors will be mapped to the closest available color in
+ * SWT. It is possible to get more control over the mapping of
+ * colors as the image is being created, using code of the form:
+ * <pre>
+ *    ImageData data = new ImageData("C:\\graphic.bmp"); 
+ *    RGB[] rgbs = data.getRGBs(); 
+ *    // At this point, rgbs contains specifications of all
+ *    // the colors contained within this image. You may
+ *    // allocate as many of these colors as you wish by
+ *    // using the Color constructor Color(RGB), then
+ *    // create the image:
+ *    Image i = new Image(device, data);
+ * </pre>
+ * <p>
+ * Applications which require even greater control over the image
+ * loading process should use the support provided in class
+ * <code>ImageLoader</code>.
+ * </p><p>
+ * Application code must explicitly invoke the <code>Image.dispose()</code> 
+ * method to release the operating system resources managed by each instance
+ * when those instances are no longer required.
+ * </p>
+ *
+ * @see Color
+ * @see ImageData
+ * @see ImageLoader
+ * @see <a href="http://www.eclipse.org/swt/snippets/#image">Image snippets</a>
+ * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Examples: GraphicsExample, ImageAnalyzer</a>
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public final class Image extends Resource implements Drawable {
+
+	/**
+	 * specifies whether the receiver is a bitmap or an icon
+	 * (one of <code>SWT.BITMAP</code>, <code>SWT.ICON</code>)
+	 * <p>
+	 * <b>IMPORTANT:</b> This field is <em>not</em> part of the SWT
+	 * public API. It is marked public only so that it can be shared
+	 * within the packages provided by SWT. It is not available on all
+	 * platforms and should never be accessed from application code.
+	 * </p>
+	 */
+	public int type;
+	
+	/**
+	 * The handle to the OS pixmap resource.
+	 * (Warning: This field is platform dependent)
+	 * <p>
+	 * <b>IMPORTANT:</b> This field is <em>not</em> part of the SWT
+	 * public API. It is marked public only so that it can be shared
+	 * within the packages provided by SWT. It is not available on all
+	 * platforms and should never be accessed from application code.
+	 * </p>
+	 */
+	public int /*long*/ pixmap;
+	
+	/**
+	 * The handle to the OS mask resource.
+	 * (Warning: This field is platform dependent)
+	 * <p>
+	 * <b>IMPORTANT:</b> This field is <em>not</em> part of the SWT
+	 * public API. It is marked public only so that it can be shared
+	 * within the packages provided by SWT. It is not available on all
+	 * platforms and should never be accessed from application code.
+	 * </p>
+	 */
+	public int /*long*/ mask;
+
+	int /*long*/ surface, surfaceData;
+	
+	/**
+	 * specifies the transparent pixel
+	 */
+	int transparentPixel = -1;
+	
+	/**
+	 * The GC the image is currently selected in.
+	 */
+	GC memGC;
+
+	/**
+	 * The alpha data of the image.
+	 */
+	byte[] alphaData;
+	
+	/**
+	 * The global alpha value to be used for every pixel.
+	 */
+	int alpha = -1;
+	
+	/**
+	 * The width of the image.
+	 */
+	int width = -1;
+	
+	/**
+	 * The height of the image.
+	 */
+	int height = -1;
+	
+	/**
+	 * Specifies the default scanline padding.
+	 */
+	static final int DEFAULT_SCANLINE_PAD = 4;
+
+Image(Device device) {
+	super(device);
+}
+
+/**
+ * Constructs an empty instance of this class with the
+ * specified width and height. The result may be drawn upon
+ * by creating a GC and using any of its drawing operations,
+ * as shown in the following example:
+ * <pre>
+ *    Image i = new Image(device, width, height);
+ *    GC gc = new GC(i);
+ *    gc.drawRectangle(0, 0, 50, 50);
+ *    gc.dispose();
+ * </pre>
+ * <p>
+ * Note: Some platforms may have a limitation on the size
+ * of image that can be created (size depends on width, height,
+ * and depth). For example, Windows 95, 98, and ME do not allow
+ * images larger than 16M.
+ * </p>
+ *
+ * @param device the device on which to create the image
+ * @param width the width of the new image
+ * @param height the height of the new image
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if either the width or height is negative or zero</li>
+ * </ul>
+ * @exception SWTError <ul>
+ *    <li>ERROR_NO_HANDLES if a handle could not be obtained for image creation</li>
+ * </ul>
+ */
+public Image(Device device, int width, int height) {
+	super(device);
+	init(width, height);
+	init();
+}
+
+/**
+ * Constructs a new instance of this class based on the
+ * provided image, with an appearance that varies depending
+ * on the value of the flag. The possible flag values are:
+ * <dl>
+ * <dt><b>{@link SWT#IMAGE_COPY}</b></dt>
+ * <dd>the result is an identical copy of srcImage</dd>
+ * <dt><b>{@link SWT#IMAGE_DISABLE}</b></dt>
+ * <dd>the result is a copy of srcImage which has a <em>disabled</em> look</dd>
+ * <dt><b>{@link SWT#IMAGE_GRAY}</b></dt>
+ * <dd>the result is a copy of srcImage which has a <em>gray scale</em> look</dd>
+ * </dl>
+ *
+ * @param device the device on which to create the image
+ * @param srcImage the image to use as the source
+ * @param flag the style, either <code>IMAGE_COPY</code>, <code>IMAGE_DISABLE</code> or <code>IMAGE_GRAY</code>
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li>
+ *    <li>ERROR_NULL_ARGUMENT - if srcImage is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the flag is not one of <code>IMAGE_COPY</code>, <code>IMAGE_DISABLE</code> or <code>IMAGE_GRAY</code></li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_INVALID_IMAGE - if the image is not a bitmap or an icon, or is otherwise in an invalid state</li>
+ *    <li>ERROR_UNSUPPORTED_DEPTH - if the depth of the image is not supported</li>
+ * </ul>
+ * @exception SWTError <ul>
+ *    <li>ERROR_NO_HANDLES if a handle could not be obtained for image creation</li>
+ * </ul>
+ */
+public Image(Device device, Image srcImage, int flag) {
+	super(device);
+	if (srcImage == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	if (srcImage.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	switch (flag) {
+		case SWT.IMAGE_COPY:
+		case SWT.IMAGE_DISABLE:
+		case SWT.IMAGE_GRAY:
+			break;
+		default:
+			SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	}
+	device = this.device;
+	this.type = srcImage.type;
+
+	/* Get source image size */
+	int[] w = new int[1], h = new int[1];
+ 	OS.gdk_drawable_get_size(srcImage.pixmap, w, h);
+ 	int width = w[0];
+ 	int height = h[0];
+ 	
+ 	/* Copy the mask */
+	if ((srcImage.type == SWT.ICON && srcImage.mask != 0) || srcImage.transparentPixel != -1) {
+		/* Generate the mask if necessary. */
+		if (srcImage.transparentPixel != -1) srcImage.createMask();
+		int /*long*/ mask = OS.gdk_pixmap_new(0, width, height, 1);
+		if (mask == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+		int /*long*/ gdkGC = OS.gdk_gc_new(mask);
+		if (gdkGC == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+		OS.gdk_draw_drawable(mask, gdkGC, srcImage.mask, 0, 0, 0, 0, width, height);
+		OS.g_object_unref(gdkGC);
+		this.mask = mask;
+		/* Destroy the image mask if the there is a GC created on the image */
+		if (srcImage.transparentPixel != -1 && srcImage.memGC != null) srcImage.destroyMask();
+	}
+
+	/* Copy transparent pixel and alpha data */
+	if (flag != SWT.IMAGE_DISABLE) transparentPixel = srcImage.transparentPixel;
+	alpha = srcImage.alpha;
+	if (srcImage.alphaData != null) {
+		alphaData = new byte[srcImage.alphaData.length];
+		System.arraycopy(srcImage.alphaData, 0, alphaData, 0, alphaData.length);
+	}
+	createAlphaMask(width, height);
+
+	/* Create the new pixmap */
+	int /*long*/ pixmap = OS.gdk_pixmap_new (OS.GDK_ROOT_PARENT(), width, height, -1);
+	if (pixmap == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+	int /*long*/ gdkGC = OS.gdk_gc_new(pixmap);
+	if (gdkGC == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+	this.pixmap = pixmap;
+	
+	if (flag == SWT.IMAGE_COPY) {
+		OS.gdk_draw_drawable(pixmap, gdkGC, srcImage.pixmap, 0, 0, 0, 0, width, height);
+		OS.g_object_unref(gdkGC);
+	} else {
+		
+		/* Retrieve the source pixmap data */
+		int /*long*/ pixbuf = OS.gdk_pixbuf_new(OS.GDK_COLORSPACE_RGB, false, 8, width, height);
+		if (pixbuf == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+		int /*long*/ colormap = OS.gdk_colormap_get_system();
+		OS.gdk_pixbuf_get_from_drawable(pixbuf, srcImage.pixmap, colormap, 0, 0, 0, 0, width, height);
+		int stride = OS.gdk_pixbuf_get_rowstride(pixbuf);
+		int /*long*/ pixels = OS.gdk_pixbuf_get_pixels(pixbuf);
+	
+		/* Apply transformation */
+		switch (flag) {
+			case SWT.IMAGE_DISABLE: {
+				Color zeroColor = device.getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW);
+				RGB zeroRGB = zeroColor.getRGB();
+				byte zeroRed = (byte)zeroRGB.red;
+				byte zeroGreen = (byte)zeroRGB.green;
+				byte zeroBlue = (byte)zeroRGB.blue;
+				Color oneColor = device.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND);
+				RGB oneRGB = oneColor.getRGB();
+				byte oneRed = (byte)oneRGB.red;
+				byte oneGreen = (byte)oneRGB.green;
+				byte oneBlue = (byte)oneRGB.blue;
+				byte[] line = new byte[stride];
+				for (int y=0; y<height; y++) {
+					OS.memmove(line, pixels + (y * stride), stride);
+					for (int x=0; x<width; x++) {
+						int offset = x*3;
+						int red = line[offset] & 0xFF;
+						int green = line[offset+1] & 0xFF;
+						int blue = line[offset+2] & 0xFF;
+						int intensity = red * red + green * green + blue * blue;
+						if (intensity < 98304) {
+							line[offset] = zeroRed;
+							line[offset+1] = zeroGreen;
+							line[offset+2] = zeroBlue;
+						} else {
+							line[offset] = oneRed;
+							line[offset+1] = oneGreen;
+							line[offset+2] = oneBlue;
+						}
+					}
+					OS.memmove(pixels + (y * stride), line, stride);
+				}
+				break;
+			}
+			case SWT.IMAGE_GRAY: {			
+				byte[] line = new byte[stride];
+				for (int y=0; y<height; y++) {
+					OS.memmove(line, pixels + (y * stride), stride);
+					for (int x=0; x<width; x++) {
+						int offset = x*3;
+						int red = line[offset] & 0xFF;
+						int green = line[offset+1] & 0xFF;
+						int blue = line[offset+2] & 0xFF;
+						byte intensity = (byte)((red+red+green+green+green+green+green+blue) >> 3);
+						line[offset] = line[offset+1] = line[offset+2] = intensity;
+					}
+					OS.memmove(pixels + (y * stride), line, stride);
+				}
+				break;
+			}
+		}
+	
+		/* Copy data back to destination pixmap */
+		OS.gdk_pixbuf_render_to_drawable(pixbuf, pixmap, gdkGC, 0, 0, 0, 0, width, height, OS.GDK_RGB_DITHER_NORMAL, 0, 0);
+		
+		/* Free resources */
+		OS.g_object_unref(pixbuf);
+		OS.g_object_unref(gdkGC);
+	}
+	init();
+}
+
+/**
+ * Constructs an empty instance of this class with the
+ * width and height of the specified rectangle. The result
+ * may be drawn upon by creating a GC and using any of its
+ * drawing operations, as shown in the following example:
+ * <pre>
+ *    Image i = new Image(device, boundsRectangle);
+ *    GC gc = new GC(i);
+ *    gc.drawRectangle(0, 0, 50, 50);
+ *    gc.dispose();
+ * </pre>
+ * <p>
+ * Note: Some platforms may have a limitation on the size
+ * of image that can be created (size depends on width, height,
+ * and depth). For example, Windows 95, 98, and ME do not allow
+ * images larger than 16M.
+ * </p>
+ *
+ * @param device the device on which to create the image
+ * @param bounds a rectangle specifying the image's width and height (must not be null)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li>
+ *    <li>ERROR_NULL_ARGUMENT - if the bounds rectangle is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if either the rectangle's width or height is negative</li>
+ * </ul>
+ * @exception SWTError <ul>
+ *    <li>ERROR_NO_HANDLES if a handle could not be obtained for image creation</li>
+ * </ul>
+ */
+public Image(Device device, Rectangle bounds) {
+	super(device);
+	if (bounds == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	init(bounds.width, bounds.height);
+	init();
+}
+
+/**
+ * Constructs an instance of this class from the given
+ * <code>ImageData</code>.
+ *
+ * @param device the device on which to create the image
+ * @param data the image data to create the image from (must not be null)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li>
+ *    <li>ERROR_NULL_ARGUMENT - if the image data is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_UNSUPPORTED_DEPTH - if the depth of the ImageData is not supported</li>
+ * </ul>
+ * @exception SWTError <ul>
+ *    <li>ERROR_NO_HANDLES if a handle could not be obtained for image creation</li>
+ * </ul>
+ */
+public Image(Device device, ImageData data) {
+	super(device);
+	init(data);
+	init();
+}
+
+/**
+ * Constructs an instance of this class, whose type is 
+ * <code>SWT.ICON</code>, from the two given <code>ImageData</code>
+ * objects. The two images must be the same size. Pixel transparency
+ * in either image will be ignored.
+ * <p>
+ * The mask image should contain white wherever the icon is to be visible,
+ * and black wherever the icon is to be transparent. In addition,
+ * the source image should contain black wherever the icon is to be
+ * transparent.
+ * </p>
+ *
+ * @param device the device on which to create the icon
+ * @param source the color data for the icon
+ * @param mask the mask data for the icon
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li>
+ *    <li>ERROR_NULL_ARGUMENT - if either the source or mask is null </li>
+ *    <li>ERROR_INVALID_ARGUMENT - if source and mask are different sizes</li>
+ * </ul>
+ * @exception SWTError <ul>
+ *    <li>ERROR_NO_HANDLES if a handle could not be obtained for image creation</li>
+ * </ul>
+ */
+public Image(Device device, ImageData source, ImageData mask) {
+	super(device);
+	if (source == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	if (mask == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	if (source.width != mask.width || source.height != mask.height) {
+		SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	}
+	mask = ImageData.convertMask (mask);
+	ImageData image = new ImageData(source.width, source.height, source.depth, source.palette, source.scanlinePad, source.data);
+	image.maskPad = mask.scanlinePad;
+	image.maskData = mask.data;
+	init(image);
+	init();
+}
+
+/**
+ * Constructs an instance of this class by loading its representation
+ * from the specified input stream. Throws an error if an error
+ * occurs while loading the image, or if the result is an image
+ * of an unsupported type.  Application code is still responsible
+ * for closing the input stream.
+ * <p>
+ * This constructor is provided for convenience when loading a single
+ * image only. If the stream contains multiple images, only the first
+ * one will be loaded. To load multiple images, use 
+ * <code>ImageLoader.load()</code>.
+ * </p><p>
+ * This constructor may be used to load a resource as follows:
+ * </p>
+ * <pre>
+ *     static Image loadImage (Display display, Class clazz, String string) {
+ *          InputStream stream = clazz.getResourceAsStream (string);
+ *          if (stream == null) return null;
+ *          Image image = null;
+ *          try {
+ *               image = new Image (display, stream);
+ *          } catch (SWTException ex) {
+ *          } finally {
+ *               try {
+ *                    stream.close ();
+ *               } catch (IOException ex) {}
+ *          }
+ *          return image;
+ *     }
+ * </pre>
+ *
+ * @param device the device on which to create the image
+ * @param stream the input stream to load the image from
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li>
+ *    <li>ERROR_NULL_ARGUMENT - if the stream is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_IO - if an IO error occurs while reading from the stream</li>
+ *    <li>ERROR_INVALID_IMAGE - if the image stream contains invalid data </li>
+ *    <li>ERROR_UNSUPPORTED_DEPTH - if the image stream describes an image with an unsupported depth</li>
+ *    <li>ERROR_UNSUPPORTED_FORMAT - if the image stream contains an unrecognized format</li>
+ * </ul>
+ * @exception SWTError <ul>
+ *    <li>ERROR_NO_HANDLES if a handle could not be obtained for image creation</li>
+ * </ul>
+ */
+public Image(Device device, InputStream stream) {
+	super(device);
+	init(new ImageData(stream));
+	init();
+}
+
+/**
+ * Constructs an instance of this class by loading its representation
+ * from the file with the specified name. Throws an error if an error
+ * occurs while loading the image, or if the result is an image
+ * of an unsupported type.
+ * <p>
+ * This constructor is provided for convenience when loading
+ * a single image only. If the specified file contains
+ * multiple images, only the first one will be used.
+ *
+ * @param device the device on which to create the image
+ * @param filename the name of the file to load the image from
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li>
+ *    <li>ERROR_NULL_ARGUMENT - if the file name is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_IO - if an IO error occurs while reading from the file</li>
+ *    <li>ERROR_INVALID_IMAGE - if the image file contains invalid data </li>
+ *    <li>ERROR_UNSUPPORTED_DEPTH - if the image file describes an image with an unsupported depth</li>
+ *    <li>ERROR_UNSUPPORTED_FORMAT - if the image file contains an unrecognized format</li>
+ * </ul>
+ * @exception SWTError <ul>
+ *    <li>ERROR_NO_HANDLES if a handle could not be obtained for image creation</li>
+ * </ul>
+ */
+public Image(Device device, String filename) {
+	super(device);
+	if (filename == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	try {
+		int length = filename.length ();
+		char [] chars = new char [length];
+		filename.getChars (0, length, chars, 0);
+		byte [] buffer = Converter.wcsToMbcs(null, chars, true);
+		int /*long*/ pixbuf = OS.gdk_pixbuf_new_from_file(buffer, null);
+		if (pixbuf != 0) {
+			boolean hasAlpha = OS.gdk_pixbuf_get_has_alpha(pixbuf);
+			if (hasAlpha) {
+				/*
+				* Bug in GTK. Depending on the image (seems to affect images that have
+				* some degree of transparency all over the image), gdk_pixbuff_render_pixmap_and_mask()
+				* will return a corrupt pixmap. To avoid this, read in and store the alpha channel data
+				* for the image and then set it to 0xFF to prevent any possible corruption from 
+				* gdk_pixbuff_render_pixmap_and_mask(). 
+				*/
+				int width = OS.gdk_pixbuf_get_width(pixbuf);
+				int height = OS.gdk_pixbuf_get_height(pixbuf);
+				int stride = OS.gdk_pixbuf_get_rowstride(pixbuf);
+				int /*long*/ pixels = OS.gdk_pixbuf_get_pixels(pixbuf);
+				byte[] line = new byte[stride];
+				alphaData = new byte[width * height];
+				for (int y = 0; y < height; y++) {
+					OS.memmove(line, pixels + (y * stride), stride);
+					for (int x = 0; x < width; x++) {
+						alphaData[y*width+x] = line[x*4 + 3];
+						line[x*4 + 3] = (byte) 0xFF;
+					}
+					OS.memmove(pixels + (y * stride), line, stride);
+				}
+				createAlphaMask(width, height);
+			}
+			int /*long*/ [] pixmap_return = new int /*long*/ [1];
+			OS.gdk_pixbuf_render_pixmap_and_mask(pixbuf, pixmap_return, null, 0);
+			this.type = SWT.BITMAP;
+			this.pixmap = pixmap_return[0];
+			if (pixmap == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+			OS.g_object_unref (pixbuf);
+			return;
+		}
+	} catch (SWTException e) {}
+	init(new ImageData(filename));
+	init();
+}
+
+void createAlphaMask (int width, int height) {
+	if (device.useXRender && (alpha != -1 || alphaData != null)) {
+		mask = OS.gdk_pixmap_new(0, alpha != -1 ? 1 : width, alpha != -1 ? 1 : height, 8);
+		if (mask == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+		int /*long*/ gc = OS.gdk_gc_new(mask);
+		if (alpha != -1) {
+			GdkColor color = new GdkColor();
+			color.pixel = (alpha & 0xFF) << 8 | (alpha & 0xFF);
+			OS.gdk_gc_set_foreground(gc, color);
+			OS.gdk_draw_rectangle(mask, gc, 1, 0, 0, 1, 1);
+		} else {
+			int /*long*/ imagePtr = OS.gdk_drawable_get_image(mask, 0, 0, width, height);
+			if (imagePtr == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+			GdkImage gdkImage = new GdkImage();
+			OS.memmove(gdkImage, imagePtr);
+			if (gdkImage.bpl == width) {
+				OS.memmove(gdkImage.mem, alphaData, alphaData.length);
+			} else {
+				byte[] line = new byte[gdkImage.bpl];
+				for (int y = 0; y < height; y++) {
+					System.arraycopy(alphaData, width * y, line, 0, width);
+					OS.memmove(gdkImage.mem + (gdkImage.bpl * y), line, gdkImage.bpl);
+				}
+			}
+			OS.gdk_draw_image(mask, gc, imagePtr, 0, 0, 0, 0, width, height);
+			OS.g_object_unref(imagePtr);
+		}		
+		OS.g_object_unref(gc);
+	}
+}
+
+/**
+ * Create the receiver's mask if necessary.
+ */
+void createMask() {
+	if (mask != 0) return;
+	mask = createMask(getImageData(), false);
+	if (mask == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+}
+
+int /*long*/ createMask(ImageData image, boolean copy) {
+	ImageData mask = image.getTransparencyMask();
+	byte[] data = mask.data;
+	byte[] maskData = copy ? new byte[data.length] : data;
+	for (int i = 0; i < maskData.length; i++) {
+		byte s = data[i];
+		maskData[i] = (byte)(((s & 0x80) >> 7) | ((s & 0x40) >> 5) |
+			((s & 0x20) >> 3) | ((s & 0x10) >> 1) | ((s & 0x08) << 1) |
+			((s & 0x04) << 3) | ((s & 0x02) << 5) |	((s & 0x01) << 7));
+	}
+	maskData = ImageData.convertPad(maskData, mask.width, mask.height, mask.depth, mask.scanlinePad, 1);
+	return OS.gdk_bitmap_create_from_data(0, maskData, mask.width, mask.height);
+}
+
+void createSurface() {
+	if (surface != 0) return;
+	/* Generate the mask if necessary. */
+	if (transparentPixel != -1) createMask();
+	int[] w = new int[1], h = new int[1];
+	OS.gdk_drawable_get_size(pixmap, w, h);
+	int width = w[0], height = h[0];
+	if (mask != 0 || alpha != -1 || alphaData != null) {
+	 	int /*long*/ pixbuf = OS.gdk_pixbuf_new(OS.GDK_COLORSPACE_RGB, true, 8, width, height);
+		if (pixbuf == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+		int /*long*/ colormap = OS.gdk_colormap_get_system();
+		OS.gdk_pixbuf_get_from_drawable(pixbuf, pixmap, colormap, 0, 0, 0, 0, width, height);
+		int stride = OS.gdk_pixbuf_get_rowstride(pixbuf);
+		int /*long*/ pixels = OS.gdk_pixbuf_get_pixels(pixbuf);		
+		byte[] line = new byte[stride];
+		if (mask != 0 && OS.gdk_drawable_get_depth(mask) == 1) {
+			int /*long*/ maskPixbuf = OS.gdk_pixbuf_new(OS.GDK_COLORSPACE_RGB, false, 8, width, height);
+			if (maskPixbuf == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+			OS.gdk_pixbuf_get_from_drawable(maskPixbuf, mask, 0, 0, 0, 0, 0, width, height);
+			int maskStride = OS.gdk_pixbuf_get_rowstride(maskPixbuf);
+			int /*long*/ maskPixels = OS.gdk_pixbuf_get_pixels(maskPixbuf);
+			byte[] maskLine = new byte[maskStride];
+			int /*long*/ offset = pixels, maskOffset = maskPixels;
+			for (int y=0; y<height; y++) {
+				OS.memmove(line, offset, stride);
+				OS.memmove(maskLine, maskOffset, maskStride);
+				for (int x=0, offset1=0; x<width; x++, offset1 += 4) {
+					if (maskLine[x * 3] == 0) {
+						line[offset1 + 0] = line[offset1 + 1] = line[offset1 + 2] = line[offset1 + 3] = 0;
+					}
+					byte temp = line[offset1];
+					line[offset1] = line[offset1 + 2];
+					line[offset1 + 2] = temp;
+				}
+				OS.memmove(offset, line, stride);
+				offset += stride;
+				maskOffset += maskStride;
+			}
+			OS.g_object_unref(maskPixbuf);
+		} else if (alpha != -1) {
+			int /*long*/ offset = pixels;
+			for (int y=0; y<height; y++) {
+				OS.memmove(line, offset, stride);
+				for (int x=0, offset1=0; x<width; x++, offset1 += 4) {
+					line[offset1+3] = (byte)alpha;
+					/* pre-multiplied alpha */
+					int r = ((line[offset1 + 0] & 0xFF) * alpha) + 128;
+					r = (r + (r >> 8)) >> 8;
+					int g = ((line[offset1 + 1] & 0xFF) * alpha) + 128;
+					g = (g + (g >> 8)) >> 8;
+					int b = ((line[offset1 + 2] & 0xFF) * alpha) + 128;
+					b = (b + (b >> 8)) >> 8;
+					line[offset1 + 0] = (byte)b;
+					line[offset1 + 1] = (byte)g;
+					line[offset1 + 2] = (byte)r;
+				}
+				OS.memmove(offset, line, stride);
+				offset += stride;
+			}
+		} else if (alphaData != null) {
+			int /*long*/ offset = pixels;
+			for (int y = 0; y < h [0]; y++) {
+				OS.memmove (line, offset, stride);
+				for (int x=0, offset1=0; x<width; x++, offset1 += 4) {
+					int alpha = alphaData [y*w [0]+x] & 0xFF;
+					line[offset1+3] = (byte)alpha;
+					/* pre-multiplied alpha */
+					int r = ((line[offset1 + 0] & 0xFF) * alpha) + 128;
+					r = (r + (r >> 8)) >> 8;
+					int g = ((line[offset1 + 1] & 0xFF) * alpha) + 128;
+					g = (g + (g >> 8)) >> 8;
+					int b = ((line[offset1 + 2] & 0xFF) * alpha) + 128;
+					b = (b + (b >> 8)) >> 8;
+					line[offset1 + 0] = (byte)b;
+					line[offset1 + 1] = (byte)g;
+					line[offset1 + 2] = (byte)r;
+				}
+				OS.memmove (offset, line, stride);
+				offset += stride;
+			}
+		} else {
+			int /*long*/ offset = pixels;
+			for (int y = 0; y < h [0]; y++) {
+				OS.memmove (line, offset, stride);
+				for (int x=0, offset1=0; x<width; x++, offset1 += 4) {
+					line[offset1+3] = (byte)0xFF;
+					byte temp = line[offset1];
+					line[offset1] = line[offset1 + 2];
+					line[offset1 + 2] = temp;
+				}
+				OS.memmove (offset, line, stride);
+				offset += stride;
+			}
+		}
+		surfaceData = OS.g_malloc(stride * height);
+		OS.memmove(surfaceData, pixels, stride * height);
+		surface = Cairo.cairo_image_surface_create_for_data(surfaceData, Cairo.CAIRO_FORMAT_ARGB32, width, height, stride);
+		OS.g_object_unref(pixbuf);
+	} else {
+		int /*long*/ xDisplay = OS.GDK_DISPLAY();
+		int /*long*/ xDrawable = OS.GDK_PIXMAP_XID(pixmap);
+		int /*long*/ xVisual = OS.gdk_x11_visual_get_xvisual(OS.gdk_visual_get_system());
+		surface = Cairo.cairo_xlib_surface_create(xDisplay, xDrawable, xVisual, width, height);
+	}
+	/* Destroy the image mask if the there is a GC created on the image */
+	if (transparentPixel != -1 && memGC != null) destroyMask();
+}
+
+/**
+ * Destroy the receiver's mask if it exists.
+ */
+void destroyMask() {
+	if (mask == 0) return;
+	OS.g_object_unref(mask);
+	mask = 0;
+}
+
+void destroy() {
+	if (memGC != null) memGC.dispose();
+	if (pixmap != 0) OS.g_object_unref(pixmap);
+	if (mask != 0) OS.g_object_unref(mask);
+	if (surface != 0) Cairo.cairo_surface_destroy(surface);
+	if (surfaceData != 0) OS.g_free(surfaceData);
+	surfaceData = surface = pixmap = mask = 0;
+	memGC = null;
+}
+
+/**
+ * Compares the argument to the receiver, and returns true
+ * if they represent the <em>same</em> object using a class
+ * specific comparison.
+ *
+ * @param object the object to compare with this object
+ * @return <code>true</code> if the object is the same as this object and <code>false</code> otherwise
+ *
+ * @see #hashCode
+ */
+public boolean equals (Object object) {
+	if (object == this) return true;
+	if (!(object instanceof Image)) return false;
+	Image image = (Image)object;
+	return device == image.device && pixmap == image.pixmap;
+}
+
+/**
+ * Returns the color to which to map the transparent pixel, or null if
+ * the receiver has no transparent pixel.
+ * <p>
+ * There are certain uses of Images that do not support transparency
+ * (for example, setting an image into a button or label). In these cases,
+ * it may be desired to simulate transparency by using the background
+ * color of the widget to paint the transparent pixels of the image.
+ * Use this method to check which color will be used in these cases
+ * in place of transparency. This value may be set with setBackground().
+ * <p>
+ *
+ * @return the background color of the image, or null if there is no transparency in the image
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public Color getBackground() {
+	if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	if (transparentPixel == -1) return null;
+	//NOT DONE
+	return null;
+}
+
+/**
+ * Returns the bounds of the receiver. The rectangle will always
+ * have x and y values of 0, and the width and height of the
+ * image.
+ *
+ * @return a rectangle specifying the image's bounds
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_INVALID_IMAGE - if the image is not a bitmap or an icon</li>
+ * </ul>
+ */
+public Rectangle getBounds() {
+	if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	if (width != -1 && height != -1) {
+		return new Rectangle(0, 0, width, height);
+	}
+	int[] w = new int[1]; int[] h = new int[1];
+	OS.gdk_drawable_get_size(pixmap, w, h);
+	return new Rectangle(0, 0, width = w[0], height = h[0]);
+}
+
+/**
+ * Returns an <code>ImageData</code> based on the receiver
+ * Modifications made to this <code>ImageData</code> will not
+ * affect the Image.
+ *
+ * @return an <code>ImageData</code> containing the image's data and attributes
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_INVALID_IMAGE - if the image is not a bitmap or an icon</li>
+ * </ul>
+ *
+ * @see ImageData
+ */
+public ImageData getImageData() {
+	if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+
+	int[] w = new int[1], h = new int[1];
+ 	OS.gdk_drawable_get_size(pixmap, w, h);
+ 	int width = w[0], height = h[0]; 	
+ 	int /*long*/ pixbuf = OS.gdk_pixbuf_new(OS.GDK_COLORSPACE_RGB, false, 8, width, height);
+	if (pixbuf == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+	int /*long*/ colormap = OS.gdk_colormap_get_system();
+	OS.gdk_pixbuf_get_from_drawable(pixbuf, pixmap, colormap, 0, 0, 0, 0, width, height);
+	int stride = OS.gdk_pixbuf_get_rowstride(pixbuf);
+	int /*long*/ pixels = OS.gdk_pixbuf_get_pixels(pixbuf);
+	byte[] srcData = new byte[stride * height];
+	OS.memmove(srcData, pixels, srcData.length);
+	OS.g_object_unref(pixbuf);
+
+	PaletteData palette = new PaletteData(0xFF0000, 0xFF00, 0xFF);
+	ImageData data = new ImageData(width, height, 24, palette);
+	data.data = srcData;
+	data.bytesPerLine = stride;
+
+	if (transparentPixel == -1 && type == SWT.ICON && mask != 0) {
+		/* Get the icon mask data */
+		int /*long*/ gdkImagePtr = OS.gdk_drawable_get_image(mask, 0, 0, width, height);
+		if (gdkImagePtr == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+		GdkImage gdkImage = new GdkImage();
+		OS.memmove(gdkImage, gdkImagePtr);
+		byte[] maskData = new byte[gdkImage.bpl * gdkImage.height];
+		OS.memmove(maskData, gdkImage.mem, maskData.length);
+		OS.g_object_unref(gdkImagePtr);
+		int maskPad;
+		for (maskPad = 1; maskPad < 128; maskPad++) {
+			int bpl = (((width + 7) / 8) + (maskPad - 1)) / maskPad * maskPad;
+			if (gdkImage.bpl == bpl) break;
+		}
+		/* Make mask scanline pad equals to 2 */
+		data.maskPad = 2;
+		maskData = ImageData.convertPad(maskData, width, height, 1, maskPad, data.maskPad);
+		/* Bit swap the mask data if necessary */
+		if (gdkImage.byte_order == OS.GDK_LSB_FIRST) {
+			for (int i = 0; i < maskData.length; i++) {
+				byte b = maskData[i];
+				maskData[i] = (byte)(((b & 0x01) << 7) | ((b & 0x02) << 5) | 
+					((b & 0x04) << 3) |	((b & 0x08) << 1) | ((b & 0x10) >> 1) | 
+					((b & 0x20) >> 3) |	((b & 0x40) >> 5) | ((b & 0x80) >> 7));
+			}
+		}
+		data.maskData = maskData;
+	}
+	data.transparentPixel = transparentPixel;
+	data.alpha = alpha;
+	if (alpha == -1 && alphaData != null) {
+		data.alphaData = new byte[alphaData.length];
+		System.arraycopy(alphaData, 0, data.alphaData, 0, alphaData.length);
+	}
+	return data;
+}
+
+/**	 
+ * Invokes platform specific functionality to allocate a new image.
+ * <p>
+ * <b>IMPORTANT:</b> This method is <em>not</em> part of the public
+ * API for <code>Image</code>. It is marked public only so that it
+ * can be shared within the packages provided by SWT. It is not
+ * available on all platforms, and should never be called from
+ * application code.
+ * </p>
+ *
+ * @param device the device on which to allocate the color
+ * @param type the type of the image (<code>SWT.BITMAP</code> or <code>SWT.ICON</code>)
+ * @param pixmap the OS handle for the image
+ * @param mask the OS handle for the image mask
+ *
+ * @private
+ */
+public static Image gtk_new(Device device, int type, int /*long*/ pixmap, int /*long*/ mask) {
+	Image image = new Image(device);
+	image.type = type;
+	image.pixmap = pixmap;
+	image.mask = mask;
+	return image;
+}
+
+/**
+ * Returns an integer hash code for the receiver. Any two 
+ * objects that return <code>true</code> when passed to 
+ * <code>equals</code> must return the same value for this
+ * method.
+ *
+ * @return the receiver's hash
+ *
+ * @see #equals
+ */
+public int hashCode () {
+	return (int)/*64*/pixmap;
+}
+
+void init(int width, int height) {
+	if (width <= 0 || height <= 0) {
+		SWT.error (SWT.ERROR_INVALID_ARGUMENT);
+	}
+	this.type = SWT.BITMAP;
+
+	/* Create the pixmap */
+	this.pixmap = OS.gdk_pixmap_new(OS.GDK_ROOT_PARENT(), width, height, -1);
+	if (pixmap == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+	/* Fill the bitmap with white */
+	GdkColor white = new GdkColor();
+	white.red = (short)0xFFFF;
+	white.green = (short)0xFFFF;
+	white.blue = (short)0xFFFF;
+	int /*long*/ colormap = OS.gdk_colormap_get_system();
+	OS.gdk_colormap_alloc_color(colormap, white, true, true);
+	int /*long*/ gdkGC = OS.gdk_gc_new(pixmap);
+	OS.gdk_gc_set_foreground(gdkGC, white);
+	OS.gdk_draw_rectangle(pixmap, gdkGC, 1, 0, 0, width, height);
+	OS.g_object_unref(gdkGC);
+	OS.gdk_colormap_free_colors(colormap, white, 1);
+}
+
+void init(ImageData image) {
+	if (image == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	int width = image.width;
+	int height = image.height;
+	PaletteData palette = image.palette;
+	if (!(((image.depth == 1 || image.depth == 2 || image.depth == 4 || image.depth == 8) && !palette.isDirect) ||
+		((image.depth == 8) || (image.depth == 16 || image.depth == 24 || image.depth == 32) && palette.isDirect)))
+			SWT.error (SWT.ERROR_UNSUPPORTED_DEPTH);
+	int /*long*/ pixbuf = OS.gdk_pixbuf_new(OS.GDK_COLORSPACE_RGB, false, 8, width, height);
+	if (pixbuf == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+	int stride = OS.gdk_pixbuf_get_rowstride(pixbuf);
+	int /*long*/ data = OS.gdk_pixbuf_get_pixels(pixbuf);
+	byte[] buffer = image.data;
+	if (!palette.isDirect || image.depth != 24 || stride != image.bytesPerLine || palette.redMask != 0xFF0000 || palette.greenMask != 0xFF00 || palette.blueMask != 0xFF) {
+		buffer = new byte[stride * height];
+		if (palette.isDirect) {
+			ImageData.blit(ImageData.BLIT_SRC,
+				image.data, image.depth, image.bytesPerLine, image.getByteOrder(), 0, 0, width, height, palette.redMask, palette.greenMask, palette.blueMask,
+				ImageData.ALPHA_OPAQUE, null, 0, 0, 0, 
+				buffer, 24, stride, ImageData.MSB_FIRST, 0, 0, width, height, 0xFF0000, 0xFF00, 0xFF,
+				false, false);
+		} else {
+			RGB[] rgbs = palette.getRGBs();
+			int length = rgbs.length;
+			byte[] srcReds = new byte[length];
+			byte[] srcGreens = new byte[length];
+			byte[] srcBlues = new byte[length];
+			for (int i = 0; i < rgbs.length; i++) {
+				RGB rgb = rgbs[i];
+				if (rgb == null) continue;
+				srcReds[i] = (byte)rgb.red;
+				srcGreens[i] = (byte)rgb.green;
+				srcBlues[i] = (byte)rgb.blue;
+			}
+			ImageData.blit(ImageData.BLIT_SRC,
+				image.data, image.depth, image.bytesPerLine, image.getByteOrder(), 0, 0, width, height, srcReds, srcGreens, srcBlues,
+				ImageData.ALPHA_OPAQUE, null, 0, 0, 0,
+				buffer, 24, stride, ImageData.MSB_FIRST, 0, 0, width, height, 0xFF0000, 0xFF00, 0xFF,
+				false, false);
+		}
+	}
+	OS.memmove(data, buffer, stride * height);
+	int /*long*/ pixmap = OS.gdk_pixmap_new (OS.GDK_ROOT_PARENT(), width, height, -1);
+	if (pixmap == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+	int /*long*/ gdkGC = OS.gdk_gc_new(pixmap);
+	if (gdkGC == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+	OS.gdk_pixbuf_render_to_drawable(pixbuf, pixmap, gdkGC, 0, 0, 0, 0, width, height, OS.GDK_RGB_DITHER_NORMAL, 0, 0);
+	OS.g_object_unref(gdkGC);
+	OS.g_object_unref(pixbuf);
+	
+	boolean isIcon = image.getTransparencyType() == SWT.TRANSPARENCY_MASK;
+	if (isIcon || image.transparentPixel != -1) {
+		if (image.transparentPixel != -1) {
+			RGB rgb = null;
+			if (palette.isDirect) {
+				rgb = palette.getRGB(image.transparentPixel);
+			} else {
+				if (image.transparentPixel < palette.colors.length) {
+					rgb = palette.getRGB(image.transparentPixel);
+				}
+			}
+			if (rgb != null) {
+				transparentPixel = rgb.red << 16 | rgb.green << 8 | rgb.blue;
+			}
+		}
+		int /*long*/ mask = createMask(image, isIcon);
+		if (mask == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+		this.mask = mask;
+		if (isIcon) {
+			this.type = SWT.ICON;
+		} else {
+			this.type = SWT.BITMAP;
+		}
+	} else {
+		this.type = SWT.BITMAP;
+		this.mask = 0;
+		this.alpha = image.alpha;
+		if (image.alpha == -1 && image.alphaData != null) {
+			this.alphaData = new byte[image.alphaData.length];
+			System.arraycopy(image.alphaData, 0, this.alphaData, 0, alphaData.length);
+		}
+		createAlphaMask(width, height);
+	}
+	this.pixmap = pixmap;
+}
+
+/**	 
+ * Invokes platform specific functionality to allocate a new GC handle.
+ * <p>
+ * <b>IMPORTANT:</b> This method is <em>not</em> part of the public
+ * API for <code>Image</code>. It is marked public only so that it
+ * can be shared within the packages provided by SWT. It is not
+ * available on all platforms, and should never be called from
+ * application code.
+ * </p>
+ *
+ * @param data the platform specific GC data 
+ * @return the platform specific GC handle
+ */
+public int /*long*/ internal_new_GC (GCData data) {
+	if (pixmap == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	if (type != SWT.BITMAP || memGC != null) {
+		SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	}
+	int /*long*/ gdkGC = OS.gdk_gc_new(pixmap);
+	if (data != null) {
+		int mask = SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT;
+		if ((data.style & mask) == 0) {
+			data.style |= SWT.LEFT_TO_RIGHT;
+		} else {
+			if ((data.style & SWT.RIGHT_TO_LEFT) != 0) {
+				data.style |= SWT.MIRRORED;
+			}
+		}
+		data.device = device;
+		data.drawable = pixmap;
+		data.background = device.COLOR_WHITE.handle;
+		data.foreground = device.COLOR_BLACK.handle;
+		data.font = device.systemFont;
+		data.image = this;
+	}
+	return gdkGC;
+}
+
+/**	 
+ * Invokes platform specific functionality to dispose a GC handle.
+ * <p>
+ * <b>IMPORTANT:</b> This method is <em>not</em> part of the public
+ * API for <code>Image</code>. It is marked public only so that it
+ * can be shared within the packages provided by SWT. It is not
+ * available on all platforms, and should never be called from
+ * application code.
+ * </p>
+ *
+ * @param hDC the platform specific GC handle
+ * @param data the platform specific GC data 
+ */
+public void internal_dispose_GC (int /*long*/ gdkGC, GCData data) {
+	OS.g_object_unref(gdkGC);
+}
+
+/**
+ * Returns <code>true</code> if the image has been disposed,
+ * and <code>false</code> otherwise.
+ * <p>
+ * This method gets the dispose state for the image.
+ * When an image has been disposed, it is an error to
+ * invoke any other method using the image.
+ *
+ * @return <code>true</code> when the image is disposed and <code>false</code> otherwise
+ */
+public boolean isDisposed() {
+	return pixmap == 0;
+}
+
+/**
+ * Sets the color to which to map the transparent pixel.
+ * <p>
+ * There are certain uses of <code>Images</code> that do not support
+ * transparency (for example, setting an image into a button or label).
+ * In these cases, it may be desired to simulate transparency by using
+ * the background color of the widget to paint the transparent pixels
+ * of the image. This method specifies the color that will be used in
+ * these cases. For example:
+ * <pre>
+ *    Button b = new Button();
+ *    image.setBackground(b.getBackground());
+ *    b.setImage(image);
+ * </pre>
+ * </p><p>
+ * The image may be modified by this operation (in effect, the
+ * transparent regions may be filled with the supplied color).  Hence
+ * this operation is not reversible and it is not legal to call
+ * this function twice or with a null argument.
+ * </p><p>
+ * This method has no effect if the receiver does not have a transparent
+ * pixel value.
+ * </p>
+ *
+ * @param color the color to use when a transparent pixel is specified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the color is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the color has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void setBackground(Color color) {
+	if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	if (color == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	if (color.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	if (transparentPixel == -1) return;
+	//NOT DONE
+}
+
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the receiver
+ */
+public String toString () {
+	if (isDisposed()) return "Image {*DISPOSED*}";
+	return "Image {" + pixmap + "}";
+}
+
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/ImageData.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/ImageData.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/ImageData.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,3616 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.graphics;
+
+
+import java.io.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.CloneableCompatibility;
+
+/**
+ * Instances of this class are device-independent descriptions
+ * of images. They are typically used as an intermediate format
+ * between loading from or writing to streams and creating an 
+ * <code>Image</code>.
+ * <p>
+ * Note that the public fields <code>x</code>, <code>y</code>, 
+ * <code>disposalMethod</code> and <code>delayTime</code> are
+ * typically only used when the image is in a set of images used
+ * for animation.
+ * </p>
+ *
+ * @see Image
+ * @see ImageLoader
+ * @see <a href="http://www.eclipse.org/swt/snippets/#image">ImageData snippets</a>
+ * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: ImageAnalyzer</a>
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+
+public final class ImageData implements CloneableCompatibility {
+	
+	/**
+	 * The width of the image, in pixels.
+	 */
+	public int width;
+
+	/**
+	 * The height of the image, in pixels.
+	 */
+	public int height;
+
+	/**
+	 * The color depth of the image, in bits per pixel.
+	 * <p>
+	 * Note that a depth of 8 or less does not necessarily
+	 * mean that the image is palette indexed, or
+	 * conversely that a depth greater than 8 means that
+	 * the image is direct color.  Check the associated
+	 * PaletteData's isDirect field for such determinations.
+	 */
+	public int depth;
+
+	/**
+	 * The scanline padding.
+	 * <p>
+	 * If one scanline of the image is not a multiple of
+	 * this number, it will be padded with zeros until it is.
+	 * </p>
+	 */
+	public int scanlinePad;
+
+	/**
+	 * The number of bytes per scanline.
+	 * <p>
+	 * This is a multiple of the scanline padding.
+	 * </p>
+	 */
+	public int bytesPerLine;
+
+	/**
+	 * The pixel data of the image.
+	 * <p>
+	 * Note that for 16 bit depth images the pixel data is stored
+	 * in least significant byte order; however, for 24bit and
+	 * 32bit depth images the pixel data is stored in most
+	 * significant byte order.
+	 * </p>
+	 */
+	public byte[] data;
+
+	/**
+	 * The color table for the image.
+	 */
+	public PaletteData palette;
+
+	/**
+	 * The transparent pixel.
+	 * <p>
+	 * Pixels with this value are transparent.
+	 * </p><p>
+	 * The default is -1 which means 'no transparent pixel'.
+	 * </p>
+	 */
+	public int transparentPixel;
+
+	/**
+	 * An icon-specific field containing the data from the icon mask.
+	 * <p>
+	 * This is a 1 bit bitmap stored with the most significant
+	 * bit first.  The number of bytes per scanline is
+	 * '((width + 7) / 8 + (maskPad - 1)) / maskPad * maskPad'.
+	 * </p><p>
+	 * The default is null which means 'no transparency mask'.
+	 * </p>
+	 */
+	public byte[] maskData;
+
+	/**
+	 * An icon-specific field containing the scanline pad of the mask.
+	 * <p>
+	 * If one scanline of the transparency mask is not a
+	 * multiple of this number, it will be padded with zeros until
+	 * it is.
+	 * </p>
+	 */
+	public int maskPad;
+	
+	/**
+	 * The alpha data of the image.
+	 * <p>
+	 * Every pixel can have an <em>alpha blending</em> value that
+	 * varies from 0, meaning fully transparent, to 255 meaning
+	 * fully opaque.  The number of bytes per scanline is
+	 * 'width'.
+	 * </p>
+	 */
+	public byte[] alphaData;
+	
+	/**
+	 * The global alpha value to be used for every pixel.
+	 * <p>
+	 * If this value is set, the <code>alphaData</code> field
+	 * is ignored and when the image is rendered each pixel
+	 * will be blended with the background an amount
+	 * proportional to this value.
+	 * </p><p>
+	 * The default is -1 which means 'no global alpha value'
+	 * </p>
+	 */
+	public int alpha;
+
+	/**
+	 * The type of file from which the image was read.
+	 * 
+	 * It is expressed as one of the following values:
+	 * <dl>
+	 * <dt><code>IMAGE_BMP</code></dt>
+	 * <dd>Windows BMP file format, no compression</dd>
+	 * <dt><code>IMAGE_BMP_RLE</code></dt>
+	 * <dd>Windows BMP file format, RLE compression if appropriate</dd>
+	 * <dt><code>IMAGE_GIF</code></dt>
+	 * <dd>GIF file format</dd>
+	 * <dt><code>IMAGE_ICO</code></dt>
+	 * <dd>Windows ICO file format</dd>
+	 * <dt><code>IMAGE_JPEG</code></dt>
+	 * <dd>JPEG file format</dd>
+	 * <dt><code>IMAGE_PNG</code></dt>
+	 * <dd>PNG file format</dd>
+	 * </dl>
+	 */
+	public int type;
+
+	/**
+	 * The x coordinate of the top left corner of the image
+	 * within the logical screen (this field corresponds to
+	 * the GIF89a Image Left Position value).
+	 */
+	public int x;
+
+	/**
+	 * The y coordinate of the top left corner of the image
+	 * within the logical screen (this field corresponds to
+	 * the GIF89a Image Top Position value).
+	 */
+	public int y;
+
+	/**
+	 * A description of how to dispose of the current image
+	 * before displaying the next.
+	 * 
+	 * It is expressed as one of the following values:
+	 * <dl>
+	 * <dt><code>DM_UNSPECIFIED</code></dt>
+	 * <dd>disposal method not specified</dd>
+	 * <dt><code>DM_FILL_NONE</code></dt>
+	 * <dd>do nothing - leave the image in place</dd>
+	 * <dt><code>DM_FILL_BACKGROUND</code></dt>
+	 * <dd>fill with the background color</dd>
+	 * <dt><code>DM_FILL_PREVIOUS</code></dt>
+	 * <dd>restore the previous picture</dd>
+	 * </dl>
+	 * (this field corresponds to the GIF89a Disposal Method value)
+	 */
+	public int disposalMethod;
+
+	/**
+	 * The time to delay before displaying the next image
+	 * in an animation (this field corresponds to the GIF89a
+	 * Delay Time value).
+	 */
+	public int delayTime;
+
+	/**
+	 * Arbitrary channel width data to 8-bit conversion table.
+	 */
+	static final byte[][] ANY_TO_EIGHT = new byte[9][];
+	static {
+		for (int b = 0; b < 9; ++b) {
+			byte[] data = ANY_TO_EIGHT[b] = new byte[1 << b];
+			if (b == 0) continue;
+			int inc = 0;
+			for (int bit = 0x10000; (bit >>= b) != 0;) inc |= bit;
+			for (int v = 0, p = 0; v < 0x10000; v+= inc) data[p++] = (byte)(v >> 8);
+		}
+	}
+	static final byte[] ONE_TO_ONE_MAPPING = ANY_TO_EIGHT[8];
+
+	/**
+	 * Scaled 8x8 Bayer dither matrix.
+	 */
+	static final int[][] DITHER_MATRIX = {
+		{ 0xfc0000, 0x7c0000, 0xdc0000, 0x5c0000, 0xf40000, 0x740000, 0xd40000, 0x540000 },
+		{ 0x3c0000, 0xbc0000, 0x1c0000, 0x9c0000, 0x340000, 0xb40000, 0x140000, 0x940000 },
+		{ 0xcc0000, 0x4c0000, 0xec0000, 0x6c0000, 0xc40000, 0x440000, 0xe40000, 0x640000 },
+		{ 0x0c0000, 0x8c0000, 0x2c0000, 0xac0000, 0x040000, 0x840000, 0x240000, 0xa40000 },
+		{ 0xf00000, 0x700000, 0xd00000, 0x500000, 0xf80000, 0x780000, 0xd80000, 0x580000 },
+		{ 0x300000, 0xb00000, 0x100000, 0x900000, 0x380000, 0xb80000, 0x180000, 0x980000 },
+		{ 0xc00000, 0x400000, 0xe00000, 0x600000, 0xc80000, 0x480000, 0xe80000, 0x680000 },
+		{ 0x000000, 0x800000, 0x200000, 0xa00000, 0x080000, 0x880000, 0x280000, 0xa80000 }
+	};
+
+/**
+ * Constructs a new, empty ImageData with the given width, height,
+ * depth and palette. The data will be initialized to an (all zero)
+ * array of the appropriate size.
+ *
+ * @param width the width of the image
+ * @param height the height of the image
+ * @param depth the depth of the image
+ * @param palette the palette of the image (must not be null)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the width or height is negative, or if the depth is not
+ *        	one of 1, 2, 4, 8, 16, 24 or 32</li>
+ *    <li>ERROR_NULL_ARGUMENT - if the palette is null</li>
+ * </ul>
+ */
+public ImageData(int width, int height, int depth, PaletteData palette) {
+	this(width, height, depth, palette,
+		4, null, 0, null,
+		null, -1, -1, SWT.IMAGE_UNDEFINED,
+		0, 0, 0, 0);
+}
+
+/**
+ * Constructs a new, empty ImageData with the given width, height,
+ * depth, palette, scanlinePad and data.
+ *
+ * @param width the width of the image
+ * @param height the height of the image
+ * @param depth the depth of the image
+ * @param palette the palette of the image
+ * @param scanlinePad the padding of each line, in bytes
+ * @param data the data of the image
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the width or height is negative, or if the depth is not
+ *        	one of 1, 2, 4, 8, 16, 24 or 32, or the data array is too small to contain the image data</li>
+ *    <li>ERROR_NULL_ARGUMENT - if the palette or data is null</li>
+ *    <li>ERROR_CANNOT_BE_ZERO - if the scanlinePad is zero</li>
+ * </ul>
+ */
+public ImageData(int width, int height, int depth, PaletteData palette, int scanlinePad, byte[] data) {
+	this(width, height, depth, palette,
+		scanlinePad, checkData(data), 0, null,
+		null, -1, -1, SWT.IMAGE_UNDEFINED,
+		0, 0, 0, 0);
+}
+
+/**
+ * Constructs an <code>ImageData</code> loaded from the specified
+ * input stream. Throws an error if an error occurs while loading
+ * the image, or if the image has an unsupported type.  Application
+ * code is still responsible for closing the input stream.
+ * <p>
+ * This constructor is provided for convenience when loading a single
+ * image only. If the stream contains multiple images, only the first
+ * one will be loaded. To load multiple images, use 
+ * <code>ImageLoader.load()</code>.
+ * </p><p>
+ * This constructor may be used to load a resource as follows:
+ * </p>
+ * <pre>
+ *     static ImageData loadImageData (Class clazz, String string) {
+ *          InputStream stream = clazz.getResourceAsStream (string);
+ *          if (stream == null) return null;
+ *          ImageData imageData = null;
+ *          try {
+ *               imageData = new ImageData (stream);
+ *          } catch (SWTException ex) {
+ *          } finally {
+ *               try {
+ *                    stream.close ();
+ *               } catch (IOException ex) {}
+ *          }
+ *          return imageData;
+ *     }
+ * </pre>
+ *
+ * @param stream the input stream to load the image from (must not be null)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the stream is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_IO - if an IO error occurs while reading from the stream</li>
+ *    <li>ERROR_INVALID_IMAGE - if the image stream contains invalid data</li>
+ *    <li>ERROR_UNSUPPORTED_FORMAT - if the image stream contains an unrecognized format</li>
+ * </ul>
+ *
+ * @see ImageLoader#load(InputStream)
+ */
+public ImageData(InputStream stream) {
+	ImageData[] data = ImageDataLoader.load(stream);
+	if (data.length < 1) SWT.error(SWT.ERROR_INVALID_IMAGE);
+	ImageData i = data[0];
+	setAllFields(
+		i.width,
+		i.height,
+		i.depth,
+		i.scanlinePad,
+		i.bytesPerLine,
+		i.data,
+		i.palette,
+		i.transparentPixel,
+		i.maskData,
+		i.maskPad,
+		i.alphaData,
+		i.alpha,
+		i.type,
+		i.x,
+		i.y,
+		i.disposalMethod,
+		i.delayTime);
+}
+
+/**
+ * Constructs an <code>ImageData</code> loaded from a file with the
+ * specified name. Throws an error if an error occurs loading the
+ * image, or if the image has an unsupported type.
+ * <p>
+ * This constructor is provided for convenience when loading a single
+ * image only. If the file contains multiple images, only the first
+ * one will be loaded. To load multiple images, use 
+ * <code>ImageLoader.load()</code>.
+ * </p>
+ *
+ * @param filename the name of the file to load the image from (must not be null)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the file name is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_IO - if an IO error occurs while reading from the file</li>
+ *    <li>ERROR_INVALID_IMAGE - if the image file contains invalid data</li>
+ *    <li>ERROR_UNSUPPORTED_FORMAT - if the image file contains an unrecognized format</li>
+ * </ul>
+ */
+public ImageData(String filename) {
+	ImageData[] data = ImageDataLoader.load(filename);
+	if (data.length < 1) SWT.error(SWT.ERROR_INVALID_IMAGE);
+	ImageData i = data[0];
+	setAllFields(
+		i.width,
+		i.height,
+		i.depth,
+		i.scanlinePad,
+		i.bytesPerLine,
+		i.data,
+		i.palette,
+		i.transparentPixel,
+		i.maskData,
+		i.maskPad,
+		i.alphaData,
+		i.alpha,
+		i.type,
+		i.x,
+		i.y,
+		i.disposalMethod,
+		i.delayTime);
+}
+
+/**
+ * Prevents uninitialized instances from being created outside the package.
+ */
+ImageData() {
+}
+
+/**
+ * Constructs an image data by giving values for all non-computable fields.
+ * <p>
+ * This method is for internal use, and is not described further.
+ * </p>
+ */
+ImageData(
+	int width, int height, int depth, PaletteData palette,
+	int scanlinePad, byte[] data, int maskPad, byte[] maskData,
+	byte[] alphaData, int alpha, int transparentPixel, int type,
+	int x, int y, int disposalMethod, int delayTime)
+{
+
+	if (palette == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	if (!(depth == 1 || depth == 2 || depth == 4 || depth == 8
+		|| depth == 16 || depth == 24 || depth == 32)) {
+		SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	}
+	if (width <= 0 || height <= 0) {
+		SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	}
+	if (scanlinePad == 0) SWT.error (SWT.ERROR_CANNOT_BE_ZERO);
+
+	int bytesPerLine = (((width * depth + 7) / 8) + (scanlinePad - 1))
+		/ scanlinePad * scanlinePad;
+	
+	/*
+	 * When the image is being loaded from a PNG, we need to use the theoretical minimum
+	 * number of bytes per line to check whether there is enough data, because the actual
+	 * number of bytes per line is calculated based on the given depth, which may be larger
+	 * than the actual depth of the PNG.
+	 */
+	int minBytesPerLine = type == SWT.IMAGE_PNG ? ((((width + 7) / 8) + 3) / 4) * 4 : bytesPerLine;
+	if (data != null && data.length < minBytesPerLine * height) {
+		SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	}
+	setAllFields(
+		width,
+		height,
+		depth,
+		scanlinePad,
+		bytesPerLine,
+		data != null ? data : new byte[bytesPerLine * height],
+		palette,
+		transparentPixel,
+		maskData,
+		maskPad,
+		alphaData,
+		alpha,
+		type,
+		x,
+		y,
+		disposalMethod,
+		delayTime);
+}
+
+/**
+ * Initializes all fields in the receiver. This method must be called
+ * by all public constructors to ensure that all fields are initialized
+ * for a new ImageData object. If a new field is added to the class,
+ * then it must be added to this method.
+ * <p>
+ * This method is for internal use, and is not described further.
+ * </p>
+ */
+void setAllFields(int width, int height, int depth, int scanlinePad,
+	int bytesPerLine, byte[] data, PaletteData palette, int transparentPixel,
+	byte[] maskData, int maskPad, byte[] alphaData, int alpha,
+	int type, int x, int y, int disposalMethod, int delayTime) {
+
+	this.width = width;
+	this.height = height;
+	this.depth = depth;
+	this.scanlinePad = scanlinePad;
+	this.bytesPerLine = bytesPerLine;
+	this.data = data;
+	this.palette = palette;
+	this.transparentPixel = transparentPixel;
+	this.maskData = maskData;
+	this.maskPad = maskPad;
+	this.alphaData = alphaData;
+	this.alpha = alpha;
+	this.type = type;
+	this.x = x;
+	this.y = y;
+	this.disposalMethod = disposalMethod;
+	this.delayTime = delayTime;
+}
+
+/**	 
+ * Invokes internal SWT functionality to create a new instance of
+ * this class.
+ * <p>
+ * <b>IMPORTANT:</b> This method is <em>not</em> part of the public
+ * API for <code>ImageData</code>. It is marked public only so that it
+ * can be shared within the packages provided by SWT. It is subject
+ * to change without notice, and should never be called from
+ * application code.
+ * </p>
+ * <p>
+ * This method is for internal use, and is not described further.
+ * </p>
+ */
+public static ImageData internal_new(
+	int width, int height, int depth, PaletteData palette,
+	int scanlinePad, byte[] data, int maskPad, byte[] maskData,
+	byte[] alphaData, int alpha, int transparentPixel, int type,
+	int x, int y, int disposalMethod, int delayTime)
+{
+	return new ImageData(
+		width, height, depth, palette, scanlinePad, data, maskPad, maskData,
+		alphaData, alpha, transparentPixel, type, x, y, disposalMethod, delayTime);
+}
+
+ImageData colorMaskImage(int pixel) {
+	ImageData mask = new ImageData(width, height, 1, bwPalette(),
+		2, null, 0, null, null, -1, -1, SWT.IMAGE_UNDEFINED,
+		0, 0, 0, 0);
+	int[] row = new int[width];
+	for (int y = 0; y < height; y++) {
+		getPixels(0, y, width, row, 0);
+		for (int i = 0; i < width; i++) {
+			if (pixel != -1 && row[i] == pixel) {
+				row[i] = 0;
+			} else {
+				row[i] = 1;
+			}
+		}
+		mask.setPixels(0, y, width, row, 0);
+	}
+	return mask;
+}
+
+static byte[] checkData(byte [] data) {
+	if (data == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	return data;
+}
+
+/**
+ * Returns a new instance of the same class as the receiver,
+ * whose slots have been filled in with <em>copies</em> of
+ * the values in the slots of the receiver. That is, the
+ * returned object is a <em>deep copy</em> of the receiver.
+ *
+ * @return a copy of the receiver.
+ */
+public Object clone() {
+	byte[] cloneData = new byte[data.length];
+	System.arraycopy(data, 0, cloneData, 0, data.length);
+	byte[] cloneMaskData = null;
+	if (maskData != null) {
+		cloneMaskData = new byte[maskData.length];
+		System.arraycopy(maskData, 0, cloneMaskData, 0, maskData.length);
+	}
+	byte[] cloneAlphaData = null;
+	if (alphaData != null) {
+		cloneAlphaData = new byte[alphaData.length];
+		System.arraycopy(alphaData, 0, cloneAlphaData, 0, alphaData.length);
+	}
+	return new ImageData(
+		width,
+		height,
+		depth,
+		palette,
+		scanlinePad,
+		cloneData,
+		maskPad,
+		cloneMaskData,
+		cloneAlphaData,
+		alpha,
+		transparentPixel,
+		type,
+		x,
+		y,
+		disposalMethod,
+		delayTime);
+}
+
+/**
+ * Returns the alpha value at offset <code>x</code> in
+ * scanline <code>y</code> in the receiver's alpha data.
+ * The alpha value is between 0 (transparent) and
+ * 255 (opaque).
+ *
+ * @param x the x coordinate of the pixel to get the alpha value of
+ * @param y the y coordinate of the pixel to get the alpha value of
+ * @return the alpha value at the given coordinates
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if either argument is out of range</li>
+ * </ul>
+ */
+public int getAlpha(int x, int y) {
+	if (x >= width || y >= height || x < 0 || y < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+
+	if (alphaData == null) return 255;
+	return alphaData[y * width + x] & 0xFF;
+}
+
+/**
+ * Returns <code>getWidth</code> alpha values starting at offset
+ * <code>x</code> in scanline <code>y</code> in the receiver's alpha
+ * data starting at <code>startIndex</code>. The alpha values
+ * are unsigned, between <code>(byte)0</code> (transparent) and
+ * <code>(byte)255</code> (opaque).
+ *
+ * @param x the x position of the pixel to begin getting alpha values
+ * @param y the y position of the pixel to begin getting alpha values
+ * @param getWidth the width of the data to get
+ * @param alphas the buffer in which to put the alpha values
+ * @param startIndex the offset into the image to begin getting alpha values
+ *
+ * @exception IndexOutOfBoundsException if getWidth is too large
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if pixels is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if x or y is out of bounds</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if getWidth is negative</li>
+ * </ul>
+ */
+public void getAlphas(int x, int y, int getWidth, byte[] alphas, int startIndex) {
+	if (alphas == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	if (getWidth < 0 || x >= width || y >= height || x < 0 || y < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	if (getWidth == 0) return;
+
+	if (alphaData == null) {
+		int endIndex = startIndex + getWidth;
+		for (int i = startIndex; i < endIndex; i++) {
+			alphas[i] = (byte)255;
+		}
+		return;
+	}
+	// may throw an IndexOutOfBoundsException
+	System.arraycopy(alphaData, y * width + x, alphas, startIndex, getWidth);
+}
+
+/**
+ * Returns the pixel value at offset <code>x</code> in
+ * scanline <code>y</code> in the receiver's data.
+ *
+ * @param x the x position of the pixel to get
+ * @param y the y position of the pixel to get
+ * @return the pixel at the given coordinates
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if either argument is out of bounds</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_UNSUPPORTED_DEPTH if the depth is not one of 1, 2, 4, 8, 16, 24 or 32</li>
+ * </ul>
+ */
+public int getPixel(int x, int y) {
+	if (x >= width || y >= height || x < 0 || y < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	int index;
+	int theByte;
+	int mask;
+	switch (depth) {
+		case 32:
+			index = (y * bytesPerLine) + (x * 4);
+			return ((data[index] & 0xFF) << 24) + ((data[index+1] & 0xFF) << 16) +
+					((data[index+2] & 0xFF) << 8) + (data[index+3] & 0xFF);
+		case 24:
+			index = (y * bytesPerLine) + (x * 3);
+			return ((data[index] & 0xFF) << 16) + ((data[index+1] & 0xFF) << 8) +
+				(data[index+2] & 0xFF);
+		case 16:
+			index = (y * bytesPerLine) + (x * 2);
+			return ((data[index+1] & 0xFF) << 8) + (data[index] & 0xFF);
+		case 8:
+			index = (y * bytesPerLine) + x ;
+			return data[index] & 0xFF;
+		case 4:
+			index = (y * bytesPerLine) + (x >> 1);
+			theByte = data[index] & 0xFF;
+			if ((x & 0x1) == 0) {
+				return theByte >> 4;
+			} else {
+				return theByte & 0x0F;
+			}
+		case 2:
+			index = (y * bytesPerLine) + (x >> 2);
+			theByte = data[index] & 0xFF;
+			int offset = 3 - (x % 4);
+			mask = 3 << (offset * 2);
+			return (theByte & mask) >> (offset * 2);
+		case 1:
+			index = (y * bytesPerLine) + (x >> 3);
+			theByte = data[index] & 0xFF;
+			mask = 1 << (7 - (x & 0x7));
+			if ((theByte & mask) == 0) {
+				return 0;
+			} else {
+				return 1;
+			}
+	}
+	SWT.error(SWT.ERROR_UNSUPPORTED_DEPTH);
+	return 0;
+}
+
+/**
+ * Returns <code>getWidth</code> pixel values starting at offset
+ * <code>x</code> in scanline <code>y</code> in the receiver's
+ * data starting at <code>startIndex</code>.
+ *
+ * @param x the x position of the first pixel to get
+ * @param y the y position of the first pixel to get
+ * @param getWidth the width of the data to get
+ * @param pixels the buffer in which to put the pixels
+ * @param startIndex the offset into the byte array to begin storing pixels
+ *
+ * @exception IndexOutOfBoundsException if getWidth is too large
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if pixels is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if x or y is out of bounds</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if getWidth is negative</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_UNSUPPORTED_DEPTH - if the depth is not one of 1, 2, 4 or 8
+ *        (For higher depths, use the int[] version of this method.)</li>
+ * </ul>
+ */
+public void getPixels(int x, int y, int getWidth, byte[] pixels, int startIndex) {
+	if (pixels == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	if (getWidth < 0 || x >= width || y >= height || x < 0 || y < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	if (getWidth == 0) return;
+	int index;
+	int theByte;
+	int mask = 0;
+	int n = getWidth;
+	int i = startIndex;
+	int srcX = x, srcY = y;
+	switch (depth) {
+		case 8:
+			index = (y * bytesPerLine) + x;
+			for (int j = 0; j < getWidth; j++) {
+				pixels[i] = data[index];
+				i++;
+				srcX++;
+				if (srcX >= width) {
+					srcY++;
+					index = srcY * bytesPerLine;
+					srcX = 0;
+				} else {
+					index++;
+				}
+			}
+			return;
+		case 4:
+			index = (y * bytesPerLine) + (x >> 1);
+			if ((x & 0x1) == 1) {
+				theByte = data[index] & 0xFF;
+				pixels[i] = (byte)(theByte & 0x0F);
+				i++;
+				n--;
+				srcX++;
+				if (srcX >= width) {
+					srcY++;
+					index = srcY * bytesPerLine;
+					srcX = 0;
+				} else {
+					index++;
+				}
+			}
+			while (n > 1) {
+				theByte = data[index] & 0xFF;
+				pixels[i] = (byte)(theByte >> 4);
+				i++;
+				n--;
+				srcX++;
+				if (srcX >= width) {
+					srcY++;
+					index = srcY * bytesPerLine;
+					srcX = 0;
+				} else {
+					pixels[i] = (byte)(theByte & 0x0F);
+					i++;
+					n--;
+					srcX++;
+					if (srcX >= width) {
+						srcY++;
+						index = srcY * bytesPerLine;
+						srcX = 0;
+					} else {
+						index++;
+					}
+				}
+			}
+			if (n > 0) {
+				theByte = data[index] & 0xFF;
+				pixels[i] = (byte)(theByte >> 4);
+			}
+			return;
+		case 2:
+			index = (y * bytesPerLine) + (x >> 2);
+			theByte = data[index] & 0xFF;
+			int offset;
+			while (n > 0) {
+				offset = 3 - (srcX % 4);
+				mask = 3 << (offset * 2);
+				pixels[i] = (byte)((theByte & mask) >> (offset * 2));
+				i++;
+				n--;
+				srcX++;
+				if (srcX >= width) {
+					srcY++;
+					index = srcY * bytesPerLine;
+					if (n > 0) theByte = data[index] & 0xFF;
+					srcX = 0;
+				} else {
+					if (offset == 0) {
+						index++;
+						theByte = data[index] & 0xFF;
+					}
+				}
+			}
+			return;
+		case 1:
+			index = (y * bytesPerLine) + (x >> 3);
+			theByte = data[index] & 0xFF;
+			while (n > 0) {
+				mask = 1 << (7 - (srcX & 0x7));
+				if ((theByte & mask) == 0) {
+					pixels[i] = 0;
+				} else {
+					pixels[i] = 1;
+				}
+				i++;
+				n--;
+				srcX++;
+				if (srcX >= width) {
+					srcY++;
+					index = srcY * bytesPerLine;
+					if (n > 0) theByte = data[index] & 0xFF;
+					srcX = 0;
+				} else {
+					if (mask == 1) {
+						index++;
+						if (n > 0) theByte = data[index] & 0xFF;
+					}
+				}
+			}
+			return;
+	}
+	SWT.error(SWT.ERROR_UNSUPPORTED_DEPTH);
+}
+
+/**
+ * Returns <code>getWidth</code> pixel values starting at offset
+ * <code>x</code> in scanline <code>y</code> in the receiver's
+ * data starting at <code>startIndex</code>.
+ *
+ * @param x the x position of the first pixel to get
+ * @param y the y position of the first pixel to get
+ * @param getWidth the width of the data to get
+ * @param pixels the buffer in which to put the pixels
+ * @param startIndex the offset into the buffer to begin storing pixels
+ *
+ * @exception IndexOutOfBoundsException if getWidth is too large
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if pixels is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if x or y is out of bounds</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if getWidth is negative</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_UNSUPPORTED_DEPTH - if the depth is not one of 1, 2, 4, 8, 16, 24 or 32</li>
+ * </ul>
+ */
+public void getPixels(int x, int y, int getWidth, int[] pixels, int startIndex) {
+	if (pixels == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	if (getWidth < 0 || x >= width || y >= height || x < 0 || y < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	if (getWidth == 0) return;
+	int index;
+	int theByte;
+	int mask;
+	int n = getWidth;
+	int i = startIndex;
+	int srcX = x, srcY = y;
+	switch (depth) {
+		case 32:
+			index = (y * bytesPerLine) + (x * 4);
+			i = startIndex;
+			for (int j = 0; j < getWidth; j++) {
+				pixels[i] = ((data[index] & 0xFF) << 24) | ((data[index+1] & 0xFF) << 16)
+					| ((data[index+2] & 0xFF) << 8) | (data[index+3] & 0xFF);
+				i++;
+				srcX++;
+				if (srcX >= width) {
+					srcY++;
+					index = srcY * bytesPerLine;
+					srcX = 0;
+				} else {
+					index += 4;
+				}
+			}
+			return;
+		case 24:
+			index = (y * bytesPerLine) + (x * 3);
+			for (int j = 0; j < getWidth; j++) {
+				pixels[i] = ((data[index] & 0xFF) << 16) | ((data[index+1] & 0xFF) << 8)
+					| (data[index+2] & 0xFF);
+				i++;
+				srcX++;
+				if (srcX >= width) {
+					srcY++;
+					index = srcY * bytesPerLine;
+					srcX = 0;
+				} else {
+					index += 3;
+				}
+			}
+			return;
+		case 16:
+			index = (y * bytesPerLine) + (x * 2);
+			for (int j = 0; j < getWidth; j++) {
+				pixels[i] = ((data[index+1] & 0xFF) << 8) + (data[index] & 0xFF);
+				i++;
+				srcX++;
+				if (srcX >= width) {
+					srcY++;
+					index = srcY * bytesPerLine;
+					srcX = 0;
+				} else {
+					index += 2;
+				}
+			}
+			return;
+		case 8:
+			index = (y * bytesPerLine) + x;
+			for (int j = 0; j < getWidth; j++) {
+				pixels[i] = data[index] & 0xFF;
+				i++;
+				srcX++;
+				if (srcX >= width) {
+					srcY++;
+					index = srcY * bytesPerLine;
+					srcX = 0;
+				} else {
+					index++;
+				}
+			}
+			return;
+		case 4:
+			index = (y * bytesPerLine) + (x >> 1);
+			if ((x & 0x1) == 1) {
+				theByte = data[index] & 0xFF;
+				pixels[i] = theByte & 0x0F;
+				i++;
+				n--;
+				srcX++;
+				if (srcX >= width) {
+					srcY++;
+					index = srcY * bytesPerLine;
+					srcX = 0;
+				} else {
+					index++;
+				}
+			}
+			while (n > 1) {
+				theByte = data[index] & 0xFF;
+				pixels[i] = theByte >> 4;
+				i++;
+				n--;
+				srcX++;
+				if (srcX >= width) {
+					srcY++;
+					index = srcY * bytesPerLine;
+					srcX = 0;
+				} else {
+					pixels[i] = theByte & 0x0F;
+					i++;
+					n--;
+					srcX++;
+					if (srcX >= width) {
+						srcY++;
+						index = srcY * bytesPerLine;
+						srcX = 0;
+					} else {
+						index++;
+					}
+				}
+			}
+			if (n > 0) {
+				theByte = data[index] & 0xFF;
+				pixels[i] = theByte >> 4;
+			}
+			return;
+		case 2:
+			index = (y * bytesPerLine) + (x >> 2);
+			theByte = data[index] & 0xFF;
+			int offset;
+			while (n > 0) {
+				offset = 3 - (srcX % 4);
+				mask = 3 << (offset * 2);
+				pixels[i] = (byte)((theByte & mask) >> (offset * 2));
+				i++;
+				n--;
+				srcX++;
+				if (srcX >= width) {
+					srcY++;
+					index = srcY * bytesPerLine;
+					if (n > 0) theByte = data[index] & 0xFF;
+					srcX = 0;
+				} else {
+					if (offset == 0) {
+						index++;
+						theByte = data[index] & 0xFF;
+					}
+				}
+			}
+			return;
+		case 1:
+			index = (y * bytesPerLine) + (x >> 3);
+			theByte = data[index] & 0xFF;
+			while (n > 0) {
+				mask = 1 << (7 - (srcX & 0x7));
+				if ((theByte & mask) == 0) {
+					pixels[i] = 0;
+				} else {
+					pixels[i] = 1;
+				}
+				i++;
+				n--;
+				srcX++;
+				if (srcX >= width) {
+					srcY++;
+					index = srcY * bytesPerLine;
+					if (n > 0) theByte = data[index] & 0xFF;
+					srcX = 0;
+				} else {
+					if (mask == 1) {
+						index++;
+						if (n > 0) theByte = data[index] & 0xFF;
+					}
+				}
+			}
+			return;
+	}
+	SWT.error(SWT.ERROR_UNSUPPORTED_DEPTH);
+}
+
+/**
+ * Returns an array of <code>RGB</code>s which comprise the
+ * indexed color table of the receiver, or null if the receiver
+ * has a direct color model.
+ *
+ * @return the RGB values for the image or null if direct color
+ *
+ * @see PaletteData#getRGBs()
+ */
+public RGB[] getRGBs() {
+	return palette.getRGBs();
+}
+
+/**
+ * Returns an <code>ImageData</code> which specifies the
+ * transparency mask information for the receiver. If the
+ * receiver has no transparency or is not an icon, returns
+ * an opaque mask.
+ *
+ * @return the transparency mask
+ */
+public ImageData getTransparencyMask() {
+	if (getTransparencyType() == SWT.TRANSPARENCY_MASK) {
+		return new ImageData(width, height, 1, bwPalette(), maskPad, maskData);
+	} else {
+		return colorMaskImage(transparentPixel);
+	}
+}
+
+/**
+ * Returns the image transparency type, which will be one of
+ * <code>SWT.TRANSPARENCY_NONE</code>, <code>SWT.TRANSPARENCY_MASK</code>,
+ * <code>SWT.TRANSPARENCY_PIXEL</code> or <code>SWT.TRANSPARENCY_ALPHA</code>.
+ *
+ * @return the receiver's transparency type
+ */
+public int getTransparencyType() {
+	if (maskData != null) return SWT.TRANSPARENCY_MASK;
+	if (transparentPixel != -1) return SWT.TRANSPARENCY_PIXEL;
+	if (alphaData != null) return SWT.TRANSPARENCY_ALPHA;
+	return SWT.TRANSPARENCY_NONE;
+}
+
+/**
+ * Returns the byte order of the receiver.
+ * 
+ * @return MSB_FIRST or LSB_FIRST
+ */
+int getByteOrder() {
+	return depth != 16 ? MSB_FIRST : LSB_FIRST;
+}
+
+/**
+ * Returns a copy of the receiver which has been stretched or
+ * shrunk to the specified size. If either the width or height
+ * is negative, the resulting image will be inverted in the
+ * associated axis.
+ *
+ * @param width the width of the new ImageData
+ * @param height the height of the new ImageData
+ * @return a scaled copy of the image
+ */
+public ImageData scaledTo(int width, int height) {
+	/* Create a destination image with no data */
+	final boolean flipX = (width < 0);
+	if (flipX) width = - width;
+	final boolean flipY = (height < 0);
+	if (flipY) height = - height;
+
+	ImageData dest = new ImageData(
+		width, height, depth, palette,
+		scanlinePad, null, 0, null,
+		null, -1, transparentPixel, type,
+		x, y, disposalMethod, delayTime);
+
+	/* Scale the image contents */
+	if (palette.isDirect) blit(BLIT_SRC,
+		this.data, this.depth, this.bytesPerLine, this.getByteOrder(), 0, 0, this.width, this.height, 0, 0, 0,
+		ALPHA_OPAQUE, null, 0, 0, 0,
+		dest.data, dest.depth, dest.bytesPerLine, dest.getByteOrder(), 0, 0, dest.width, dest.height, 0, 0, 0,
+		flipX, flipY);
+	else blit(BLIT_SRC,
+		this.data, this.depth, this.bytesPerLine, this.getByteOrder(), 0, 0, this.width, this.height, null, null, null,
+		ALPHA_OPAQUE, null, 0, 0, 0,
+		dest.data, dest.depth, dest.bytesPerLine, dest.getByteOrder(), 0, 0, dest.width, dest.height, null, null, null,
+		flipX, flipY);
+	
+	/* Scale the image mask or alpha */
+	if (maskData != null) {
+		dest.maskPad = this.maskPad;
+		int destBpl = (dest.width + 7) / 8;
+		destBpl = (destBpl + (dest.maskPad - 1)) / dest.maskPad * dest.maskPad;
+		dest.maskData = new byte[destBpl * dest.height];
+		int srcBpl = (this.width + 7) / 8;
+		srcBpl = (srcBpl + (this.maskPad - 1)) / this.maskPad * this.maskPad;
+		blit(BLIT_SRC,
+			this.maskData, 1, srcBpl, MSB_FIRST, 0, 0, this.width, this.height, null, null, null,
+			ALPHA_OPAQUE, null, 0, 0, 0,
+			dest.maskData, 1, destBpl, MSB_FIRST, 0, 0, dest.width, dest.height, null, null, null,
+			flipX, flipY);
+	} else if (alpha != -1) {
+		dest.alpha = this.alpha;
+	} else if (alphaData != null) {
+		dest.alphaData = new byte[dest.width * dest.height];
+		blit(BLIT_SRC,
+			this.alphaData, 8, this.width, MSB_FIRST, 0, 0, this.width, this.height, null, null, null,
+			ALPHA_OPAQUE, null, 0, 0, 0,
+			dest.alphaData, 8, dest.width, MSB_FIRST, 0, 0, dest.width, dest.height, null, null, null,
+			flipX, flipY);
+	}
+	return dest;
+}
+
+/**
+ * Sets the alpha value at offset <code>x</code> in
+ * scanline <code>y</code> in the receiver's alpha data.
+ * The alpha value must be between 0 (transparent)
+ * and 255 (opaque).
+ *
+ * @param x the x coordinate of the alpha value to set
+ * @param y the y coordinate of the alpha value to set
+ * @param alpha the value to set the alpha to
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if x or y is out of bounds</li>
+ *  </ul>
+ */
+public void setAlpha(int x, int y, int alpha) {
+	if (x >= width || y >= height || x < 0 || y < 0 || alpha < 0 || alpha > 255)
+		SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	
+	if (alphaData == null) alphaData = new byte[width * height];
+	alphaData[y * width + x] = (byte)alpha;	
+}
+
+/**
+ * Sets the alpha values starting at offset <code>x</code> in
+ * scanline <code>y</code> in the receiver's alpha data to the
+ * values from the array <code>alphas</code> starting at
+ * <code>startIndex</code>. The alpha values must be between
+ * <code>(byte)0</code> (transparent) and <code>(byte)255</code> (opaque)
+ *
+ * @param x the x coordinate of the pixel to being setting the alpha values
+ * @param y the y coordinate of the pixel to being setting the alpha values
+ * @param putWidth the width of the alpha values to set
+ * @param alphas the alpha values to set
+ * @param startIndex the index at which to begin setting
+ *
+ * @exception IndexOutOfBoundsException if putWidth is too large
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if pixels is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if x or y is out of bounds</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if putWidth is negative</li>
+ * </ul>
+ */
+public void setAlphas(int x, int y, int putWidth, byte[] alphas, int startIndex) {
+	if (alphas == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	if (putWidth < 0 || x >= width || y >= height || x < 0 || y < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	if (putWidth == 0) return;
+	
+	if (alphaData == null) alphaData = new byte[width * height];
+	// may throw an IndexOutOfBoundsException
+	System.arraycopy(alphas, startIndex, alphaData, y * width + x, putWidth);
+}
+
+/**
+ * Sets the pixel value at offset <code>x</code> in
+ * scanline <code>y</code> in the receiver's data.
+ *
+ * @param x the x coordinate of the pixel to set
+ * @param y the y coordinate of the pixel to set
+ * @param pixelValue the value to set the pixel to
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if x or y is out of bounds</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_UNSUPPORTED_DEPTH if the depth is not one of 1, 2, 4, 8, 16, 24 or 32</li>
+ * </ul>
+ */
+public void setPixel(int x, int y, int pixelValue) {
+	if (x >= width || y >= height || x < 0 || y < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	int index;
+	byte theByte;
+	int mask;
+	switch (depth) {
+		case 32:
+			index = (y * bytesPerLine) + (x * 4);
+			data[index]  = (byte)((pixelValue >> 24) & 0xFF);
+			data[index + 1] = (byte)((pixelValue >> 16) & 0xFF);
+			data[index + 2] = (byte)((pixelValue >> 8) & 0xFF);
+			data[index + 3] = (byte)(pixelValue & 0xFF);
+			return;
+		case 24:
+			index = (y * bytesPerLine) + (x * 3);
+			data[index] = (byte)((pixelValue >> 16) & 0xFF);
+			data[index + 1] = (byte)((pixelValue >> 8) & 0xFF);
+			data[index + 2] = (byte)(pixelValue & 0xFF);
+			return;
+		case 16:
+			index = (y * bytesPerLine) + (x * 2);
+			data[index + 1] = (byte)((pixelValue >> 8) & 0xFF);
+			data[index] = (byte)(pixelValue & 0xFF);
+			return;
+		case 8:
+			index = (y * bytesPerLine) + x ;
+			data[index] = (byte)(pixelValue & 0xFF);
+			return;
+		case 4:
+			index = (y * bytesPerLine) + (x >> 1);
+			if ((x & 0x1) == 0) {
+				data[index] = (byte)((data[index] & 0x0F) | ((pixelValue & 0x0F) << 4));
+			} else {
+				data[index] = (byte)((data[index] & 0xF0) | (pixelValue & 0x0F));
+			}
+			return;
+		case 2:
+			index = (y * bytesPerLine) + (x >> 2);
+			theByte = data[index];
+			int offset = 3 - (x % 4);
+			mask = 0xFF ^ (3 << (offset * 2));
+			data[index] = (byte)((data[index] & mask) | (pixelValue << (offset * 2)));
+			return;
+		case 1:
+			index = (y * bytesPerLine) + (x >> 3);
+			theByte = data[index];
+			mask = 1 << (7 - (x & 0x7));
+			if ((pixelValue & 0x1) == 1) {
+				data[index] = (byte)(theByte | mask);
+			} else {
+				data[index] = (byte)(theByte & (mask ^ -1));
+			}
+			return;
+	}
+	SWT.error(SWT.ERROR_UNSUPPORTED_DEPTH);
+}
+
+/**
+ * Sets the pixel values starting at offset <code>x</code> in
+ * scanline <code>y</code> in the receiver's data to the
+ * values from the array <code>pixels</code> starting at
+ * <code>startIndex</code>.
+ *
+ * @param x the x position of the pixel to set
+ * @param y the y position of the pixel to set
+ * @param putWidth the width of the pixels to set
+ * @param pixels the pixels to set
+ * @param startIndex the index at which to begin setting
+ *
+ * @exception IndexOutOfBoundsException if putWidth is too large
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if pixels is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if x or y is out of bounds</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if putWidth is negative</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_UNSUPPORTED_DEPTH if the depth is not one of 1, 2, 4, 8
+ *        (For higher depths, use the int[] version of this method.)</li>
+ * </ul>
+ */
+public void setPixels(int x, int y, int putWidth, byte[] pixels, int startIndex) {
+	if (pixels == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	if (putWidth < 0 || x >= width || y >= height || x < 0 || y < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	if (putWidth == 0) return;
+	int index;
+	int theByte;
+	int mask;
+	int n = putWidth;
+	int i = startIndex;
+	int srcX = x, srcY = y;
+	switch (depth) {
+		case 8:
+			index = (y * bytesPerLine) + x;
+			for (int j = 0; j < putWidth; j++) {
+				data[index] = (byte)(pixels[i] & 0xFF);
+				i++;
+				srcX++;
+				if (srcX >= width) {
+					srcY++;
+					index = srcY * bytesPerLine;
+					srcX = 0;
+				} else {
+					index++;
+				}
+			}
+			return;
+		case 4:
+			index = (y * bytesPerLine) + (x >> 1);
+			boolean high = (x & 0x1) == 0;
+			while (n > 0) {
+				theByte = pixels[i] & 0x0F;
+				if (high) {
+					data[index] = (byte)((data[index] & 0x0F) | (theByte << 4));
+				} else {
+					data[index] = (byte)((data[index] & 0xF0) | theByte);
+				}
+				i++;
+				n--;
+				srcX++;
+				if (srcX >= width) {
+					srcY++;
+					index = srcY * bytesPerLine;
+					high = true;
+					srcX = 0;
+				} else {
+					if (!high) index++;
+					high = !high;
+				}
+			}
+			return;
+		case 2:
+			byte [] masks = { (byte)0xFC, (byte)0xF3, (byte)0xCF, (byte)0x3F };
+			index = (y * bytesPerLine) + (x >> 2);
+			int offset = 3 - (x % 4);
+			while (n > 0) {
+				theByte = pixels[i] & 0x3;
+				data[index] = (byte)((data[index] & masks[offset]) | (theByte << (offset * 2)));
+				i++;
+				n--;
+				srcX++;
+				if (srcX >= width) {
+					srcY++;
+					index = srcY * bytesPerLine;
+					offset = 0;
+					srcX = 0;
+				} else {
+					if (offset == 0) {
+						index++;
+						offset = 3;
+					} else {
+						offset--;
+					}
+				}
+			}
+			return;
+		case 1:
+			index = (y * bytesPerLine) + (x >> 3);
+			while (n > 0) {
+				mask = 1 << (7 - (srcX & 0x7));
+				if ((pixels[i] & 0x1) == 1) {
+					data[index] = (byte)((data[index] & 0xFF) | mask);
+				} else {
+					data[index] = (byte)((data[index] & 0xFF) & (mask ^ -1));
+				}
+				i++;
+				n--;
+				srcX++;
+				if (srcX >= width) {
+					srcY++;
+					index = srcY * bytesPerLine;
+					srcX = 0;
+				} else {
+					if (mask == 1) {
+						index++;
+					}
+				}
+			}
+			return;
+	}
+	SWT.error(SWT.ERROR_UNSUPPORTED_DEPTH);
+}
+
+/**
+ * Sets the pixel values starting at offset <code>x</code> in
+ * scanline <code>y</code> in the receiver's data to the
+ * values from the array <code>pixels</code> starting at
+ * <code>startIndex</code>.
+ *
+ * @param x the x position of the pixel to set
+ * @param y the y position of the pixel to set
+ * @param putWidth the width of the pixels to set
+ * @param pixels the pixels to set
+ * @param startIndex the index at which to begin setting
+ *
+ * @exception IndexOutOfBoundsException if putWidth is too large
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if pixels is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if x or y is out of bounds</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if putWidth is negative</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_UNSUPPORTED_DEPTH if the depth is not one of 1, 2, 4, 8, 16, 24 or 32</li>
+ * </ul>
+ */
+public void setPixels(int x, int y, int putWidth, int[] pixels, int startIndex) {
+	if (pixels == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	if (putWidth < 0 || x >= width || y >= height || x < 0 || y < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	if (putWidth == 0) return;
+	int index;
+	int theByte;
+	int mask;
+	int n = putWidth;
+	int i = startIndex;
+	int pixel;
+	int srcX = x, srcY = y;
+	switch (depth) {
+		case 32:
+			index = (y * bytesPerLine) + (x * 4);
+			for (int j = 0; j < putWidth; j++) {
+				pixel = pixels[i];
+				data[index] = (byte)((pixel >> 24) & 0xFF);
+				data[index + 1] = (byte)((pixel >> 16) & 0xFF);
+				data[index + 2] = (byte)((pixel >> 8) & 0xFF);
+				data[index + 3] = (byte)(pixel & 0xFF);
+				i++;
+				srcX++;
+				if (srcX >= width) {
+					srcY++;
+					index = srcY * bytesPerLine;
+					srcX = 0;
+				} else {
+					index += 4;
+				}
+			}
+			return;
+		case 24:
+			index = (y * bytesPerLine) + (x * 3);
+			for (int j = 0; j < putWidth; j++) {
+				pixel = pixels[i];
+				data[index] = (byte)((pixel >> 16) & 0xFF);
+				data[index + 1] = (byte)((pixel >> 8) & 0xFF);
+				data[index + 2] = (byte)(pixel & 0xFF);
+				i++;
+				srcX++;
+				if (srcX >= width) {
+					srcY++;
+					index = srcY * bytesPerLine;
+					srcX = 0;
+				} else {
+					index += 3;
+				}
+			}
+			return;
+		case 16:
+			index = (y * bytesPerLine) + (x * 2);
+			for (int j = 0; j < putWidth; j++) {
+				pixel = pixels[i];
+				data[index] = (byte)(pixel & 0xFF);
+				data[index + 1] = (byte)((pixel >> 8) & 0xFF);
+				i++;
+				srcX++;
+				if (srcX >= width) {
+					srcY++;
+					index = srcY * bytesPerLine;
+					srcX = 0;
+				} else {
+					index += 2;
+				}
+			}
+			return;
+		case 8:
+			index = (y * bytesPerLine) + x;
+			for (int j = 0; j < putWidth; j++) {
+				data[index] = (byte)(pixels[i] & 0xFF);
+				i++;
+				srcX++;
+				if (srcX >= width) {
+					srcY++;
+					index = srcY * bytesPerLine;
+					srcX = 0;
+				} else {
+					index++;
+				}
+			}
+			return;
+		case 4:
+			index = (y * bytesPerLine) + (x >> 1);
+			boolean high = (x & 0x1) == 0;
+			while (n > 0) {
+				theByte = pixels[i] & 0x0F;
+				if (high) {
+					data[index] = (byte)((data[index] & 0x0F) | (theByte << 4));
+				} else {
+					data[index] = (byte)((data[index] & 0xF0) | theByte);
+				}
+				i++;
+				n--;
+				srcX++;
+				if (srcX >= width) {
+					srcY++;
+					index = srcY * bytesPerLine;
+					high = true;
+					srcX = 0;
+				} else {
+					if (!high) index++;
+					high = !high;
+				}
+			}
+			return;
+		case 2:
+			byte [] masks = { (byte)0xFC, (byte)0xF3, (byte)0xCF, (byte)0x3F };
+			index = (y * bytesPerLine) + (x >> 2);
+			int offset = 3 - (x % 4);
+			while (n > 0) {
+				theByte = pixels[i] & 0x3;
+				data[index] = (byte)((data[index] & masks[offset]) | (theByte << (offset * 2)));
+				i++;
+				n--;
+				srcX++;
+				if (srcX >= width) {
+					srcY++;
+					index = srcY * bytesPerLine;
+					offset = 3;
+					srcX = 0;
+				} else {
+					if (offset == 0) {
+						index++;
+						offset = 3;
+					} else {
+						offset--;
+					}
+				}
+			}
+			return;
+		case 1:
+			index = (y * bytesPerLine) + (x >> 3);
+			while (n > 0) {
+				mask = 1 << (7 - (srcX & 0x7));
+				if ((pixels[i] & 0x1) == 1) {
+					data[index] = (byte)((data[index] & 0xFF) | mask);
+				} else {
+					data[index] = (byte)((data[index] & 0xFF) & (mask ^ -1));
+				}
+				i++;
+				n--;
+				srcX++;
+				if (srcX >= width) {
+					srcY++;
+					index = srcY * bytesPerLine;
+					srcX = 0;
+				} else {
+					if (mask == 1) {
+						index++;
+					}
+				}
+			}
+			return;
+	}
+	SWT.error(SWT.ERROR_UNSUPPORTED_DEPTH);
+}
+
+/**
+ * Returns a palette with 2 colors: black & white.
+ */
+static PaletteData bwPalette() {
+	return new PaletteData(new RGB[] {new RGB(0, 0, 0), new RGB(255, 255, 255)});
+}
+
+/**
+ * Gets the offset of the most significant bit for
+ * the given mask.
+ */
+static int getMSBOffset(int mask) {
+	for (int i = 31; i >= 0; i--) {
+		if (((mask >> i) & 0x1) != 0) return i + 1;
+	}
+	return 0;
+}
+
+/**
+ * Finds the closest match.
+ */
+static int closestMatch(int depth, byte red, byte green, byte blue, int redMask, int greenMask, int blueMask, byte[] reds, byte[] greens, byte[] blues) {
+	if (depth > 8) {
+		int rshift = 32 - getMSBOffset(redMask);
+		int gshift = 32 - getMSBOffset(greenMask);
+		int bshift = 32 - getMSBOffset(blueMask);
+		return (((red << 24) >>> rshift) & redMask) |
+			(((green << 24) >>> gshift) & greenMask) |
+			(((blue << 24) >>> bshift) & blueMask);
+	}
+	int r, g, b;
+	int minDistance = 0x7fffffff;
+	int nearestPixel = 0;
+	int n = reds.length;
+	for (int j = 0; j < n; j++) {
+		r = (reds[j] & 0xFF) - (red & 0xFF);
+		g = (greens[j] & 0xFF) - (green & 0xFF);
+		b = (blues[j] & 0xFF) - (blue & 0xFF);
+		int distance = r*r + g*g + b*b;
+		if (distance < minDistance) {
+			nearestPixel = j;
+			if (distance == 0) break;
+			minDistance = distance;
+		}
+	}
+	return nearestPixel;
+}
+
+static final ImageData convertMask(ImageData mask) {
+	if (mask.depth == 1) return mask;
+	PaletteData palette = new PaletteData(new RGB[] {new RGB(0, 0, 0), new RGB(255,255,255)});
+	ImageData newMask = new ImageData(mask.width, mask.height, 1, palette);
+	/* Find index of black in mask palette */
+	int blackIndex = 0;
+	RGB[] rgbs = mask.getRGBs();
+	if (rgbs != null) {
+		while (blackIndex < rgbs.length) {
+			if (rgbs[blackIndex].equals(palette.colors[0])) break;
+			blackIndex++;
+		}
+	}
+	int[] pixels = new int[mask.width];
+	for (int y = 0; y < mask.height; y++) {
+		mask.getPixels(0, y, mask.width, pixels, 0);
+		for (int i = 0; i < pixels.length; i++) {
+			if (pixels[i] == blackIndex) {
+				pixels[i] = 0;
+			} else {
+				pixels[i] = 1;
+			}
+		}
+		newMask.setPixels(0, y, mask.width, pixels, 0);
+	}
+	return newMask;
+}
+
+static final byte[] convertPad(byte[] data, int width, int height, int depth, int pad, int newPad) {
+	if (pad == newPad) return data;
+	int stride = (width * depth + 7) / 8;
+	int bpl = (stride + (pad - 1)) / pad * pad;	
+	int newBpl = (stride + (newPad - 1)) / newPad * newPad;
+	byte[] newData = new byte[height * newBpl];
+	int srcIndex = 0, destIndex = 0;
+	for (int y = 0; y < height; y++) {
+		System.arraycopy(data, srcIndex, newData, destIndex, stride);
+		srcIndex += bpl;
+		destIndex += newBpl;
+	}
+	return newData;
+}
+
+/**
+ * Blit operation bits to be OR'ed together to specify the desired operation.
+ */
+static final int
+	BLIT_SRC = 1,     // copy source directly, else applies logic operations
+	BLIT_ALPHA = 2,   // enable alpha blending
+	BLIT_DITHER = 4;  // enable dithering in low color modes
+
+/**
+ * Alpha mode, values 0 - 255 specify global alpha level
+ */
+static final int
+	ALPHA_OPAQUE = 255,           // Fully opaque (ignores any alpha data)
+	ALPHA_TRANSPARENT = 0,        // Fully transparent (ignores any alpha data)
+	ALPHA_CHANNEL_SEPARATE = -1,  // Use alpha channel from separate alphaData
+	ALPHA_CHANNEL_SOURCE = -2,    // Use alpha channel embedded in sourceData
+	ALPHA_MASK_UNPACKED = -3,     // Use transparency mask formed by bytes in alphaData (non-zero is opaque)
+	ALPHA_MASK_PACKED = -4,       // Use transparency mask formed by packed bits in alphaData
+	ALPHA_MASK_INDEX = -5,        // Consider source palette indices transparent if in alphaData array
+	ALPHA_MASK_RGB = -6;          // Consider source RGBs transparent if in RGB888 format alphaData array
+
+/**
+ * Byte and bit order constants.
+ */
+static final int LSB_FIRST = 0;
+static final int MSB_FIRST = 1;
+
+/**
+ * Data types (internal)
+ */
+private static final int
+	// direct / true color formats with arbitrary masks & shifts
+	TYPE_GENERIC_8 = 0,
+	TYPE_GENERIC_16_MSB = 1,
+	TYPE_GENERIC_16_LSB = 2,
+	TYPE_GENERIC_24 = 3,
+	TYPE_GENERIC_32_MSB = 4,
+	TYPE_GENERIC_32_LSB = 5,
+	// palette indexed color formats
+	TYPE_INDEX_8 = 6,
+	TYPE_INDEX_4 = 7,
+	TYPE_INDEX_2 = 8,
+	TYPE_INDEX_1_MSB = 9,
+	TYPE_INDEX_1_LSB = 10;
+
+/**
+ * Blits a direct palette image into a direct palette image.
+ * <p>
+ * Note: When the source and destination depth, order and masks
+ * are pairwise equal and the blitter operation is BLIT_SRC,
+ * the masks are ignored.  Hence when not changing the image
+ * data format, 0 may be specified for the masks.
+ * </p>
+ * 
+ * @param op the blitter operation: a combination of BLIT_xxx flags
+ *        (see BLIT_xxx constants)
+ * @param srcData the source byte array containing image data
+ * @param srcDepth the source depth: one of 8, 16, 24, 32
+ * @param srcStride the source number of bytes per line
+ * @param srcOrder the source byte ordering: one of MSB_FIRST or LSB_FIRST;
+ *        ignored if srcDepth is not 16 or 32
+ * @param srcX the top-left x-coord of the source blit region
+ * @param srcY the top-left y-coord of the source blit region
+ * @param srcWidth the width of the source blit region
+ * @param srcHeight the height of the source blit region
+ * @param srcRedMask the source red channel mask
+ * @param srcGreenMask the source green channel mask
+ * @param srcBlueMask the source blue channel mask
+ * @param alphaMode the alpha blending or mask mode, may be
+ *        an integer 0-255 for global alpha; ignored if BLIT_ALPHA
+ *        not specified in the blitter operations
+ *        (see ALPHA_MODE_xxx constants)
+ * @param alphaData the alpha blending or mask data, varies depending
+ *        on the value of alphaMode and sometimes ignored
+ * @param alphaStride the alpha data number of bytes per line
+ * @param alphaX the top-left x-coord of the alpha blit region
+ * @param alphaY the top-left y-coord of the alpha blit region
+ * @param destData the destination byte array containing image data
+ * @param destDepth the destination depth: one of 8, 16, 24, 32
+ * @param destStride the destination number of bytes per line
+ * @param destOrder the destination byte ordering: one of MSB_FIRST or LSB_FIRST;
+ *        ignored if destDepth is not 16 or 32
+ * @param destX the top-left x-coord of the destination blit region
+ * @param destY the top-left y-coord of the destination blit region
+ * @param destWidth the width of the destination blit region
+ * @param destHeight the height of the destination blit region
+ * @param destRedMask the destination red channel mask
+ * @param destGreenMask the destination green channel mask
+ * @param destBlueMask the destination blue channel mask
+ * @param flipX if true the resulting image is flipped along the vertical axis
+ * @param flipY if true the resulting image is flipped along the horizontal axis
+ */
+static void blit(int op,
+	byte[] srcData, int srcDepth, int srcStride, int srcOrder,
+	int srcX, int srcY, int srcWidth, int srcHeight,
+	int srcRedMask, int srcGreenMask, int srcBlueMask,
+	int alphaMode, byte[] alphaData, int alphaStride, int alphaX, int alphaY,
+	byte[] destData, int destDepth, int destStride, int destOrder,
+	int destX, int destY, int destWidth, int destHeight,
+	int destRedMask, int destGreenMask, int destBlueMask,
+	boolean flipX, boolean flipY) {
+	if ((destWidth <= 0) || (destHeight <= 0) || (alphaMode == ALPHA_TRANSPARENT)) return;
+
+	// these should be supplied as params later
+	final int srcAlphaMask = 0, destAlphaMask = 0;
+
+	/*** Prepare scaling data ***/
+	final int dwm1 = destWidth - 1;
+	final int sfxi = (dwm1 != 0) ? (int)((((long)srcWidth << 16) - 1) / dwm1) : 0;
+	final int dhm1 = destHeight - 1;
+	final int sfyi = (dhm1 != 0) ? (int)((((long)srcHeight << 16) - 1) / dhm1) : 0;
+
+	/*** Prepare source-related data ***/
+	final int sbpp, stype;
+	switch (srcDepth) {
+		case 8:
+			sbpp = 1;
+			stype = TYPE_GENERIC_8;
+			break;
+		case 16:
+			sbpp = 2;
+			stype = (srcOrder == MSB_FIRST) ? TYPE_GENERIC_16_MSB : TYPE_GENERIC_16_LSB;
+			break;
+		case 24:
+			sbpp = 3;
+			stype = TYPE_GENERIC_24;
+			break;
+		case 32:
+			sbpp = 4;
+			stype = (srcOrder == MSB_FIRST) ? TYPE_GENERIC_32_MSB : TYPE_GENERIC_32_LSB;
+			break;
+		default:
+			//throw new IllegalArgumentException("Invalid source type");
+			return;
+	}			
+	int spr = srcY * srcStride + srcX * sbpp;
+
+	/*** Prepare destination-related data ***/
+	final int dbpp, dtype;
+	switch (destDepth) {
+		case 8:
+			dbpp = 1;
+			dtype = TYPE_GENERIC_8;
+			break;
+		case 16:
+			dbpp = 2;
+			dtype = (destOrder == MSB_FIRST) ? TYPE_GENERIC_16_MSB : TYPE_GENERIC_16_LSB;
+			break;
+		case 24:
+			dbpp = 3;
+			dtype = TYPE_GENERIC_24;
+			break;
+		case 32:
+			dbpp = 4;
+			dtype = (destOrder == MSB_FIRST) ? TYPE_GENERIC_32_MSB : TYPE_GENERIC_32_LSB;
+			break;
+		default:
+			//throw new IllegalArgumentException("Invalid destination type");
+			return;
+	}			
+	int dpr = ((flipY) ? destY + dhm1 : destY) * destStride + ((flipX) ? destX + dwm1 : destX) * dbpp;
+	final int dprxi = (flipX) ? -dbpp : dbpp;
+	final int dpryi = (flipY) ? -destStride : destStride;
+
+	/*** Prepare special processing data ***/
+	int apr;
+	if ((op & BLIT_ALPHA) != 0) {
+		switch (alphaMode) {
+			case ALPHA_MASK_UNPACKED:
+			case ALPHA_CHANNEL_SEPARATE:
+				if (alphaData == null) alphaMode = 0x10000;
+				apr = alphaY * alphaStride + alphaX;
+				break;
+			case ALPHA_MASK_PACKED:
+				if (alphaData == null) alphaMode = 0x10000;
+				alphaStride <<= 3;
+				apr = alphaY * alphaStride + alphaX;
+				break;
+			case ALPHA_MASK_INDEX:
+				//throw new IllegalArgumentException("Invalid alpha type");
+				return;
+			case ALPHA_MASK_RGB:
+				if (alphaData == null) alphaMode = 0x10000;
+				apr = 0;
+				break;
+			default:
+				alphaMode = (alphaMode << 16) / 255; // prescale
+			case ALPHA_CHANNEL_SOURCE:
+				apr = 0;
+				break;
+		}
+	} else {
+		alphaMode = 0x10000;
+		apr = 0;
+	}
+
+	/*** Blit ***/
+	int dp = dpr;
+	int sp = spr;
+	if ((alphaMode == 0x10000) && (stype == dtype) &&
+		(srcRedMask == destRedMask) && (srcGreenMask == destGreenMask) &&
+		(srcBlueMask == destBlueMask) && (srcAlphaMask == destAlphaMask)) {
+		/*** Fast blit (straight copy) ***/
+		switch (sbpp) {
+			case 1:
+				for (int dy = destHeight, sfy = sfyi; dy > 0; --dy, sp = spr += (sfy >>> 16) * srcStride, sfy = (sfy & 0xffff) + sfyi, dp = dpr += dpryi) {
+					for (int dx = destWidth, sfx = sfxi; dx > 0; --dx, dp += dprxi, sfx = (sfx & 0xffff) + sfxi) {
+						destData[dp] = srcData[sp];
+						sp += (sfx >>> 16);
+					}
+				}
+				break;					
+			case 2:
+				for (int dy = destHeight, sfy = sfyi; dy > 0; --dy, sp = spr += (sfy >>> 16) * srcStride, sfy = (sfy & 0xffff) + sfyi, dp = dpr += dpryi) {
+					for (int dx = destWidth, sfx = sfxi; dx > 0; --dx, dp += dprxi, sfx = (sfx & 0xffff) + sfxi) {
+						destData[dp] = srcData[sp];
+						destData[dp + 1] = srcData[sp + 1];
+						sp += (sfx >>> 16) * 2;
+					}
+				}
+				break;
+			case 3:
+				for (int dy = destHeight, sfy = sfyi; dy > 0; --dy, sp = spr += (sfy >>> 16) * srcStride, sfy = (sfy & 0xffff) + sfyi, dp = dpr += dpryi) {
+					for (int dx = destWidth, sfx = sfxi; dx > 0; --dx, dp += dprxi, sfx = (sfx & 0xffff) + sfxi) {
+						destData[dp] = srcData[sp];
+						destData[dp + 1] = srcData[sp + 1];
+						destData[dp + 2] = srcData[sp + 2];
+						sp += (sfx >>> 16) * 3;
+					}
+				}
+				break;
+			case 4:
+				for (int dy = destHeight, sfy = sfyi; dy > 0; --dy, sp = spr += (sfy >>> 16) * srcStride, sfy = (sfy & 0xffff) + sfyi, dp = dpr += dpryi) {
+					for (int dx = destWidth, sfx = sfxi; dx > 0; --dx, dp += dprxi, sfx = (sfx & 0xffff) + sfxi) {
+						destData[dp] = srcData[sp];
+						destData[dp + 1] = srcData[sp + 1];
+						destData[dp + 2] = srcData[sp + 2];
+						destData[dp + 3] = srcData[sp + 3];
+						sp += (sfx >>> 16) * 4;
+					}
+				}
+				break;
+		}
+		return;
+	}
+	/*** Comprehensive blit (apply transformations) ***/
+	final int srcRedShift = getChannelShift(srcRedMask);
+	final byte[] srcReds = ANY_TO_EIGHT[getChannelWidth(srcRedMask, srcRedShift)];
+	final int srcGreenShift = getChannelShift(srcGreenMask);
+	final byte[] srcGreens = ANY_TO_EIGHT[getChannelWidth(srcGreenMask, srcGreenShift)];
+	final int srcBlueShift = getChannelShift(srcBlueMask);
+	final byte[] srcBlues = ANY_TO_EIGHT[getChannelWidth(srcBlueMask, srcBlueShift)];
+	final int srcAlphaShift = getChannelShift(srcAlphaMask);
+	final byte[] srcAlphas = ANY_TO_EIGHT[getChannelWidth(srcAlphaMask, srcAlphaShift)];
+
+	final int destRedShift = getChannelShift(destRedMask);
+	final int destRedWidth = getChannelWidth(destRedMask, destRedShift);
+	final byte[] destReds = ANY_TO_EIGHT[destRedWidth];
+	final int destRedPreShift = 8 - destRedWidth;
+	final int destGreenShift = getChannelShift(destGreenMask);
+	final int destGreenWidth = getChannelWidth(destGreenMask, destGreenShift);
+	final byte[] destGreens = ANY_TO_EIGHT[destGreenWidth];
+	final int destGreenPreShift = 8 - destGreenWidth;
+	final int destBlueShift = getChannelShift(destBlueMask);
+	final int destBlueWidth = getChannelWidth(destBlueMask, destBlueShift);
+	final byte[] destBlues = ANY_TO_EIGHT[destBlueWidth];
+	final int destBluePreShift = 8 - destBlueWidth;
+	final int destAlphaShift = getChannelShift(destAlphaMask);
+	final int destAlphaWidth = getChannelWidth(destAlphaMask, destAlphaShift);
+	final byte[] destAlphas = ANY_TO_EIGHT[destAlphaWidth];
+	final int destAlphaPreShift = 8 - destAlphaWidth;
+
+	int ap = apr, alpha = alphaMode;
+	int r = 0, g = 0, b = 0, a = 0;
+	int rq = 0, gq = 0, bq = 0, aq = 0;
+	for (int dy = destHeight, sfy = sfyi; dy > 0; --dy,
+			sp = spr += (sfy >>> 16) * srcStride,
+			ap = apr += (sfy >>> 16) * alphaStride,
+			sfy = (sfy & 0xffff) + sfyi,
+			dp = dpr += dpryi) {
+		for (int dx = destWidth, sfx = sfxi; dx > 0; --dx,
+				dp += dprxi,
+				sfx = (sfx & 0xffff) + sfxi) {
+			/*** READ NEXT PIXEL ***/
+			switch (stype) {
+				case TYPE_GENERIC_8: {
+					final int data = srcData[sp] & 0xff;
+					sp += (sfx >>> 16);
+					r = srcReds[(data & srcRedMask) >>> srcRedShift] & 0xff;
+					g = srcGreens[(data & srcGreenMask) >>> srcGreenShift] & 0xff;
+					b = srcBlues[(data & srcBlueMask) >>> srcBlueShift] & 0xff;
+					a = srcAlphas[(data & srcAlphaMask) >>> srcAlphaShift] & 0xff;
+				} break;
+				case TYPE_GENERIC_16_MSB: {
+					final int data = ((srcData[sp] & 0xff) << 8) | (srcData[sp + 1] & 0xff);
+					sp += (sfx >>> 16) * 2;
+					r = srcReds[(data & srcRedMask) >>> srcRedShift] & 0xff;
+					g = srcGreens[(data & srcGreenMask) >>> srcGreenShift] & 0xff;
+					b = srcBlues[(data & srcBlueMask) >>> srcBlueShift] & 0xff;
+					a = srcAlphas[(data & srcAlphaMask) >>> srcAlphaShift] & 0xff;
+				} break;
+				case TYPE_GENERIC_16_LSB: {
+					final int data = ((srcData[sp + 1] & 0xff) << 8) | (srcData[sp] & 0xff);
+					sp += (sfx >>> 16) * 2;
+					r = srcReds[(data & srcRedMask) >>> srcRedShift] & 0xff;
+					g = srcGreens[(data & srcGreenMask) >>> srcGreenShift] & 0xff;
+					b = srcBlues[(data & srcBlueMask) >>> srcBlueShift] & 0xff;
+					a = srcAlphas[(data & srcAlphaMask) >>> srcAlphaShift] & 0xff;
+				} break;
+				case TYPE_GENERIC_24: {
+					final int data = (( ((srcData[sp] & 0xff) << 8) |
+						(srcData[sp + 1] & 0xff)) << 8) |
+						(srcData[sp + 2] & 0xff);
+					sp += (sfx >>> 16) * 3;
+					r = srcReds[(data & srcRedMask) >>> srcRedShift] & 0xff;
+					g = srcGreens[(data & srcGreenMask) >>> srcGreenShift] & 0xff;
+					b = srcBlues[(data & srcBlueMask) >>> srcBlueShift] & 0xff;
+					a = srcAlphas[(data & srcAlphaMask) >>> srcAlphaShift] & 0xff;
+				} break;
+				case TYPE_GENERIC_32_MSB: {
+					final int data = (( (( ((srcData[sp] & 0xff) << 8) |
+						(srcData[sp + 1] & 0xff)) << 8) |
+						(srcData[sp + 2] & 0xff)) << 8) |
+						(srcData[sp + 3] & 0xff);
+					sp += (sfx >>> 16) * 4;
+					r = srcReds[(data & srcRedMask) >>> srcRedShift] & 0xff;
+					g = srcGreens[(data & srcGreenMask) >>> srcGreenShift] & 0xff;
+					b = srcBlues[(data & srcBlueMask) >>> srcBlueShift] & 0xff;
+					a = srcAlphas[(data & srcAlphaMask) >>> srcAlphaShift] & 0xff;
+				} break;
+				case TYPE_GENERIC_32_LSB: {
+					final int data = (( (( ((srcData[sp + 3] & 0xff) << 8) |
+						(srcData[sp + 2] & 0xff)) << 8) |
+						(srcData[sp + 1] & 0xff)) << 8) |
+						(srcData[sp] & 0xff);
+					sp += (sfx >>> 16) * 4;
+					r = srcReds[(data & srcRedMask) >>> srcRedShift] & 0xff;
+					g = srcGreens[(data & srcGreenMask) >>> srcGreenShift] & 0xff;
+					b = srcBlues[(data & srcBlueMask) >>> srcBlueShift] & 0xff;
+					a = srcAlphas[(data & srcAlphaMask) >>> srcAlphaShift] & 0xff;
+				} break;
+			}
+
+			/*** DO SPECIAL PROCESSING IF REQUIRED ***/
+			switch (alphaMode) {
+				case ALPHA_CHANNEL_SEPARATE:
+					alpha = ((alphaData[ap] & 0xff) << 16) / 255;
+					ap += (sfx >> 16);
+					break;
+				case ALPHA_CHANNEL_SOURCE:
+					alpha = (a << 16) / 255;
+					break;
+				case ALPHA_MASK_UNPACKED:
+					alpha = (alphaData[ap] != 0) ? 0x10000 : 0;
+					ap += (sfx >> 16);
+					break;						
+				case ALPHA_MASK_PACKED:
+					alpha = (alphaData[ap >> 3] << ((ap & 7) + 9)) & 0x10000;
+					ap += (sfx >> 16);
+					break;
+				case ALPHA_MASK_RGB:
+					alpha = 0x10000;
+					for (int i = 0; i < alphaData.length; i += 3) {
+						if ((r == alphaData[i]) && (g == alphaData[i + 1]) && (b == alphaData[i + 2])) {
+							alpha = 0x0000;
+							break;
+						}
+					}
+					break;
+			}
+			if (alpha != 0x10000) {
+				if (alpha == 0x0000) continue;
+				switch (dtype) {
+					case TYPE_GENERIC_8: {
+						final int data = destData[dp] & 0xff;
+						rq = destReds[(data & destRedMask) >>> destRedShift] & 0xff;
+						gq = destGreens[(data & destGreenMask) >>> destGreenShift] & 0xff;
+						bq = destBlues[(data & destBlueMask) >>> destBlueShift] & 0xff;
+						aq = destAlphas[(data & destAlphaMask) >>> destAlphaShift] & 0xff;
+					} break;
+					case TYPE_GENERIC_16_MSB: {
+						final int data = ((destData[dp] & 0xff) << 8) | (destData[dp + 1] & 0xff);
+						rq = destReds[(data & destRedMask) >>> destRedShift] & 0xff;
+						gq = destGreens[(data & destGreenMask) >>> destGreenShift] & 0xff;
+						bq = destBlues[(data & destBlueMask) >>> destBlueShift] & 0xff;
+						aq = destAlphas[(data & destAlphaMask) >>> destAlphaShift] & 0xff;
+					} break;
+					case TYPE_GENERIC_16_LSB: {
+						final int data = ((destData[dp + 1] & 0xff) << 8) | (destData[dp] & 0xff);
+						rq = destReds[(data & destRedMask) >>> destRedShift] & 0xff;
+						gq = destGreens[(data & destGreenMask) >>> destGreenShift] & 0xff;
+						bq = destBlues[(data & destBlueMask) >>> destBlueShift] & 0xff;
+						aq = destAlphas[(data & destAlphaMask) >>> destAlphaShift] & 0xff;
+					} break;
+					case TYPE_GENERIC_24: {
+						final int data = (( ((destData[dp] & 0xff) << 8) |
+							(destData[dp + 1] & 0xff)) << 8) |
+							(destData[dp + 2] & 0xff);
+						rq = destReds[(data & destRedMask) >>> destRedShift] & 0xff;
+						gq = destGreens[(data & destGreenMask) >>> destGreenShift] & 0xff;
+						bq = destBlues[(data & destBlueMask) >>> destBlueShift] & 0xff;
+						aq = destAlphas[(data & destAlphaMask) >>> destAlphaShift] & 0xff;
+					} break;
+					case TYPE_GENERIC_32_MSB: {
+						final int data = (( (( ((destData[dp] & 0xff) << 8) |
+							(destData[dp + 1] & 0xff)) << 8) |
+							(destData[dp + 2] & 0xff)) << 8) |
+							(destData[dp + 3] & 0xff);
+						rq = destReds[(data & destRedMask) >>> destRedShift] & 0xff;
+						gq = destGreens[(data & destGreenMask) >>> destGreenShift] & 0xff;
+						bq = destBlues[(data & destBlueMask) >>> destBlueShift] & 0xff;
+						aq = destAlphas[(data & destAlphaMask) >>> destAlphaShift] & 0xff;
+					} break;
+					case TYPE_GENERIC_32_LSB: {
+						final int data = (( (( ((destData[dp + 3] & 0xff) << 8) |
+							(destData[dp + 2] & 0xff)) << 8) |
+							(destData[dp + 1] & 0xff)) << 8) |
+							(destData[dp] & 0xff);
+						rq = destReds[(data & destRedMask) >>> destRedShift] & 0xff;
+						gq = destGreens[(data & destGreenMask) >>> destGreenShift] & 0xff;
+						bq = destBlues[(data & destBlueMask) >>> destBlueShift] & 0xff;
+						aq = destAlphas[(data & destAlphaMask) >>> destAlphaShift] & 0xff;
+					} break;
+				}
+				// Perform alpha blending
+				a = aq + ((a - aq) * alpha >> 16);
+				r = rq + ((r - rq) * alpha >> 16);
+				g = gq + ((g - gq) * alpha >> 16);
+				b = bq + ((b - bq) * alpha >> 16);
+			}
+
+			/*** WRITE NEXT PIXEL ***/
+			final int data = 
+				(r >>> destRedPreShift << destRedShift) |
+				(g >>> destGreenPreShift << destGreenShift) |
+				(b >>> destBluePreShift << destBlueShift) |
+				(a >>> destAlphaPreShift << destAlphaShift);
+			switch (dtype) {
+				case TYPE_GENERIC_8: {
+					destData[dp] = (byte) data;
+				} break;
+				case TYPE_GENERIC_16_MSB: {
+					destData[dp] = (byte) (data >>> 8);
+					destData[dp + 1] = (byte) (data & 0xff);
+				} break;
+				case TYPE_GENERIC_16_LSB: {
+					destData[dp] = (byte) (data & 0xff);
+					destData[dp + 1] = (byte) (data >>> 8);
+				} break;
+				case TYPE_GENERIC_24: {
+					destData[dp] = (byte) (data >>> 16);
+					destData[dp + 1] = (byte) (data >>> 8);
+					destData[dp + 2] = (byte) (data & 0xff);
+				} break;
+				case TYPE_GENERIC_32_MSB: {
+					destData[dp] = (byte) (data >>> 24);
+					destData[dp + 1] = (byte) (data >>> 16);
+					destData[dp + 2] = (byte) (data >>> 8);
+					destData[dp + 3] = (byte) (data & 0xff);
+				} break;
+				case TYPE_GENERIC_32_LSB: {
+					destData[dp] = (byte) (data & 0xff);
+					destData[dp + 1] = (byte) (data >>> 8);
+					destData[dp + 2] = (byte) (data >>> 16);
+					destData[dp + 3] = (byte) (data >>> 24);
+				} break;
+			}
+		}
+	}			
+}
+
+/**
+ * Blits an index palette image into an index palette image.
+ * <p>
+ * Note: The source and destination red, green, and blue
+ * arrays may be null if no alpha blending or dither is to be
+ * performed.
+ * </p>
+ * 
+ * @param op the blitter operation: a combination of BLIT_xxx flags
+ *        (see BLIT_xxx constants)
+ * @param srcData the source byte array containing image data
+ * @param srcDepth the source depth: one of 1, 2, 4, 8
+ * @param srcStride the source number of bytes per line
+ * @param srcOrder the source byte ordering: one of MSB_FIRST or LSB_FIRST;
+ *        ignored if srcDepth is not 1
+ * @param srcX the top-left x-coord of the source blit region
+ * @param srcY the top-left y-coord of the source blit region
+ * @param srcWidth the width of the source blit region
+ * @param srcHeight the height of the source blit region
+ * @param srcReds the source palette red component intensities
+ * @param srcGreens the source palette green component intensities
+ * @param srcBlues the source palette blue component intensities
+ * @param alphaMode the alpha blending or mask mode, may be
+ *        an integer 0-255 for global alpha; ignored if BLIT_ALPHA
+ *        not specified in the blitter operations
+ *        (see ALPHA_MODE_xxx constants)
+ * @param alphaData the alpha blending or mask data, varies depending
+ *        on the value of alphaMode and sometimes ignored
+ * @param alphaStride the alpha data number of bytes per line
+ * @param alphaX the top-left x-coord of the alpha blit region
+ * @param alphaY the top-left y-coord of the alpha blit region
+ * @param destData the destination byte array containing image data
+ * @param destDepth the destination depth: one of 1, 2, 4, 8
+ * @param destStride the destination number of bytes per line
+ * @param destOrder the destination byte ordering: one of MSB_FIRST or LSB_FIRST;
+ *        ignored if destDepth is not 1
+ * @param destX the top-left x-coord of the destination blit region
+ * @param destY the top-left y-coord of the destination blit region
+ * @param destWidth the width of the destination blit region
+ * @param destHeight the height of the destination blit region
+ * @param destReds the destination palette red component intensities
+ * @param destGreens the destination palette green component intensities
+ * @param destBlues the destination palette blue component intensities
+ * @param flipX if true the resulting image is flipped along the vertical axis
+ * @param flipY if true the resulting image is flipped along the horizontal axis
+ */
+static void blit(int op,
+	byte[] srcData, int srcDepth, int srcStride, int srcOrder,
+	int srcX, int srcY, int srcWidth, int srcHeight,
+	byte[] srcReds, byte[] srcGreens, byte[] srcBlues,
+	int alphaMode, byte[] alphaData, int alphaStride, int alphaX, int alphaY,
+	byte[] destData, int destDepth, int destStride, int destOrder,
+	int destX, int destY, int destWidth, int destHeight,
+	byte[] destReds, byte[] destGreens, byte[] destBlues,
+	boolean flipX, boolean flipY) {
+	if ((destWidth <= 0) || (destHeight <= 0) || (alphaMode == ALPHA_TRANSPARENT)) return;
+
+	/*** Prepare scaling data ***/
+	final int dwm1 = destWidth - 1;
+	final int sfxi = (dwm1 != 0) ? (int)((((long)srcWidth << 16) - 1) / dwm1) : 0;
+	final int dhm1 = destHeight - 1;
+	final int sfyi = (dhm1 != 0) ? (int)((((long)srcHeight << 16) - 1) / dhm1) : 0;
+
+	/*** Prepare source-related data ***/
+	final int stype;
+	switch (srcDepth) {
+		case 8:
+			stype = TYPE_INDEX_8;
+			break;
+		case 4:
+			srcStride <<= 1;
+			stype = TYPE_INDEX_4;
+			break;
+		case 2:
+			srcStride <<= 2;
+			stype = TYPE_INDEX_2;
+			break;
+		case 1:
+			srcStride <<= 3;
+			stype = (srcOrder == MSB_FIRST) ? TYPE_INDEX_1_MSB : TYPE_INDEX_1_LSB;
+			break;
+		default:
+			//throw new IllegalArgumentException("Invalid source type");
+			return;		
+	}			
+	int spr = srcY * srcStride + srcX;
+
+	/*** Prepare destination-related data ***/
+	final int dtype;
+	switch (destDepth) {
+		case 8:
+			dtype = TYPE_INDEX_8;
+			break;
+		case 4:
+			destStride <<= 1;
+			dtype = TYPE_INDEX_4;
+			break;
+		case 2:
+			destStride <<= 2;
+			dtype = TYPE_INDEX_2;
+			break;
+		case 1:
+			destStride <<= 3;
+			dtype = (destOrder == MSB_FIRST) ? TYPE_INDEX_1_MSB : TYPE_INDEX_1_LSB;
+			break;
+		default:
+			//throw new IllegalArgumentException("Invalid source type");
+			return;
+	}			
+	int dpr = ((flipY) ? destY + dhm1 : destY) * destStride + ((flipX) ? destX + dwm1 : destX);
+	final int dprxi = (flipX) ? -1 : 1;
+	final int dpryi = (flipY) ? -destStride : destStride;
+
+	/*** Prepare special processing data ***/
+	int apr;
+	if ((op & BLIT_ALPHA) != 0) {
+		switch (alphaMode) {
+			case ALPHA_MASK_UNPACKED:
+			case ALPHA_CHANNEL_SEPARATE:
+				if (alphaData == null) alphaMode = 0x10000;
+				apr = alphaY * alphaStride + alphaX;
+				break;
+			case ALPHA_MASK_PACKED:
+				if (alphaData == null) alphaMode = 0x10000;
+				alphaStride <<= 3;
+				apr = alphaY * alphaStride + alphaX;
+				break;
+			case ALPHA_MASK_INDEX:
+			case ALPHA_MASK_RGB:
+				if (alphaData == null) alphaMode = 0x10000;
+				apr = 0;
+				break;
+			default:
+				alphaMode = (alphaMode << 16) / 255; // prescale
+			case ALPHA_CHANNEL_SOURCE:
+				apr = 0;
+				break;
+		}
+	} else {
+		alphaMode = 0x10000;
+		apr = 0;
+	}
+	final boolean ditherEnabled = (op & BLIT_DITHER) != 0;
+
+	/*** Blit ***/
+	int dp = dpr;
+	int sp = spr;
+	int ap = apr;
+	int destPaletteSize = 1 << destDepth;
+	if ((destReds != null) && (destReds.length < destPaletteSize)) destPaletteSize = destReds.length;
+	byte[] paletteMapping = null;
+	boolean isExactPaletteMapping = true;
+	switch (alphaMode) {
+		case 0x10000:
+			/*** If the palettes and formats are equivalent use a one-to-one mapping ***/
+			if ((stype == dtype) &&
+				(srcReds == destReds) && (srcGreens == destGreens) && (srcBlues == destBlues)) {
+				paletteMapping = ONE_TO_ONE_MAPPING;
+				break;
+			/*** If palettes have not been supplied, supply a suitable mapping ***/
+			} else if ((srcReds == null) || (destReds == null)) {
+				if (srcDepth <= destDepth) {
+					paletteMapping = ONE_TO_ONE_MAPPING;
+				} else {
+					paletteMapping = new byte[1 << srcDepth];
+					int mask = (0xff << destDepth) >>> 8;
+					for (int i = 0; i < paletteMapping.length; ++i) paletteMapping[i] = (byte)(i & mask);
+				}
+				break;
+			}
+		case ALPHA_MASK_UNPACKED:
+		case ALPHA_MASK_PACKED:
+		case ALPHA_MASK_INDEX:
+		case ALPHA_MASK_RGB:
+			/*** Generate a palette mapping ***/
+			int srcPaletteSize = 1 << srcDepth;
+			paletteMapping = new byte[srcPaletteSize];
+			if ((srcReds != null) && (srcReds.length < srcPaletteSize)) srcPaletteSize = srcReds.length;
+			for (int i = 0, r, g, b, index; i < srcPaletteSize; ++i) {
+				r = srcReds[i] & 0xff;
+				g = srcGreens[i] & 0xff;
+				b = srcBlues[i] & 0xff;
+				index = 0;
+				int minDistance = 0x7fffffff;
+				for (int j = 0, dr, dg, db, distance; j < destPaletteSize; ++j) {
+					dr = (destReds[j] & 0xff) - r;
+					dg = (destGreens[j] & 0xff) - g;
+					db = (destBlues[j] & 0xff) - b;
+					distance = dr * dr + dg * dg + db * db;
+					if (distance < minDistance) {
+						index = j;
+						if (distance == 0) break;
+						minDistance = distance;
+					}
+				}
+				paletteMapping[i] = (byte)index;
+				if (minDistance != 0) isExactPaletteMapping = false;
+			}
+			break;
+	}
+	if ((paletteMapping != null) && (isExactPaletteMapping || ! ditherEnabled)) {
+		if ((stype == dtype) && (alphaMode == 0x10000)) {
+			/*** Fast blit (copy w/ mapping) ***/
+			switch (stype) {
+				case TYPE_INDEX_8:
+					for (int dy = destHeight, sfy = sfyi; dy > 0; --dy, sp = spr += (sfy >>> 16) * srcStride, sfy = (sfy & 0xffff) + sfyi, dp = dpr += dpryi) {
+						for (int dx = destWidth, sfx = sfxi; dx > 0; --dx, dp += dprxi, sfx = (sfx & 0xffff) + sfxi) {
+							destData[dp] = paletteMapping[srcData[sp] & 0xff];
+							sp += (sfx >>> 16);
+						}
+					}
+					break;					
+				case TYPE_INDEX_4:
+					for (int dy = destHeight, sfy = sfyi; dy > 0; --dy, sp = spr += (sfy >>> 16) * srcStride, sfy = (sfy & 0xffff) + sfyi, dp = dpr += dpryi) {
+						for (int dx = destWidth, sfx = sfxi; dx > 0; --dx, dp += dprxi, sfx = (sfx & 0xffff) + sfxi) {
+							final int v;
+							if ((sp & 1) != 0) v = paletteMapping[srcData[sp >> 1] & 0x0f];
+							else v = (srcData[sp >> 1] >>> 4) & 0x0f;
+							sp += (sfx >>> 16);
+							if ((dp & 1) != 0) destData[dp >> 1] = (byte)((destData[dp >> 1] & 0xf0) | v);
+							else destData[dp >> 1] = (byte)((destData[dp >> 1] & 0x0f) | (v << 4));
+						}
+					}
+					break;
+				case TYPE_INDEX_2:
+					for (int dy = destHeight, sfy = sfyi; dy > 0; --dy, sp = spr += (sfy >>> 16) * srcStride, sfy = (sfy & 0xffff) + sfyi, dp = dpr += dpryi) {
+						for (int dx = destWidth, sfx = sfxi; dx > 0; --dx, dp += dprxi, sfx = (sfx & 0xffff) + sfxi) {
+							final int index = paletteMapping[(srcData[sp >> 2] >>> (6 - (sp & 3) * 2)) & 0x03];
+							sp += (sfx >>> 16);
+							final int shift = 6 - (dp & 3) * 2;
+							destData[dp >> 2] = (byte)(destData[dp >> 2] & ~(0x03 << shift) | (index << shift));
+						}
+					}
+					break;					
+				case TYPE_INDEX_1_MSB:
+					for (int dy = destHeight, sfy = sfyi; dy > 0; --dy, sp = spr += (sfy >>> 16) * srcStride, sfy = (sfy & 0xffff) + sfyi, dp = dpr += dpryi) {
+						for (int dx = destWidth, sfx = sfxi; dx > 0; --dx, dp += dprxi, sfx = (sfx & 0xffff) + sfxi) {
+							final int index = paletteMapping[(srcData[sp >> 3] >>> (7 - (sp & 7))) & 0x01];
+							sp += (sfx >>> 16);
+							final int shift = 7 - (dp & 7);
+							destData[dp >> 3] = (byte)(destData[dp >> 3] & ~(0x01 << shift) | (index << shift));
+						}
+					}
+					break;					
+				case TYPE_INDEX_1_LSB:
+					for (int dy = destHeight, sfy = sfyi; dy > 0; --dy, sp = spr += (sfy >>> 16) * srcStride, sfy = (sfy & 0xffff) + sfyi, dp = dpr += dpryi) {
+						for (int dx = destWidth, sfx = sfxi; dx > 0; --dx, dp += dprxi, sfx = (sfx & 0xffff) + sfxi) {
+							final int index = paletteMapping[(srcData[sp >> 3] >>> (sp & 7)) & 0x01];
+							sp += (sfx >>> 16);
+							final int shift = dp & 7;
+							destData[dp >> 3] = (byte)(destData[dp >> 3] & ~(0x01 << shift) | (index << shift));
+						}
+					}
+					break;
+			}
+		} else {
+			/*** Convert between indexed modes using mapping and mask ***/
+			for (int dy = destHeight, sfy = sfyi; dy > 0; --dy,
+					sp = spr += (sfy >>> 16) * srcStride,
+					sfy = (sfy & 0xffff) + sfyi,
+					dp = dpr += dpryi) {
+				for (int dx = destWidth, sfx = sfxi; dx > 0; --dx,
+						dp += dprxi,
+						sfx = (sfx & 0xffff) + sfxi) {
+					int index;
+					/*** READ NEXT PIXEL ***/
+					switch (stype) {
+						case TYPE_INDEX_8:
+							index = srcData[sp] & 0xff;
+							sp += (sfx >>> 16);
+							break;					
+						case TYPE_INDEX_4:
+							if ((sp & 1) != 0) index = srcData[sp >> 1] & 0x0f;
+							else index = (srcData[sp >> 1] >>> 4) & 0x0f;
+							sp += (sfx >>> 16);
+							break;					
+						case TYPE_INDEX_2:
+							index = (srcData[sp >> 2] >>> (6 - (sp & 3) * 2)) & 0x03;
+							sp += (sfx >>> 16);
+							break;					
+						case TYPE_INDEX_1_MSB:
+							index = (srcData[sp >> 3] >>> (7 - (sp & 7))) & 0x01;
+							sp += (sfx >>> 16);
+							break;					
+						case TYPE_INDEX_1_LSB:
+							index = (srcData[sp >> 3] >>> (sp & 7)) & 0x01;
+							sp += (sfx >>> 16);
+							break;
+						default:
+							return;
+					}
+					/*** APPLY MASK ***/
+					switch (alphaMode) {
+						case ALPHA_MASK_UNPACKED: {
+							final byte mask = alphaData[ap];
+							ap += (sfx >> 16);
+							if (mask == 0) continue;
+						} break;
+						case ALPHA_MASK_PACKED: {
+							final int mask = alphaData[ap >> 3] & (1 << (ap & 7));
+							ap += (sfx >> 16);
+							if (mask == 0) continue;
+						} break;
+						case ALPHA_MASK_INDEX: {
+							int i = 0;
+							while (i < alphaData.length) {
+								if (index == (alphaData[i] & 0xff)) break;
+							}
+							if (i < alphaData.length) continue;
+						} break;
+						case ALPHA_MASK_RGB: {
+							final byte r = srcReds[index], g = srcGreens[index], b = srcBlues[index];
+							int i = 0;
+							while (i < alphaData.length) {
+								if ((r == alphaData[i]) && (g == alphaData[i + 1]) && (b == alphaData[i + 2])) break;
+								i += 3;
+							}
+							if (i < alphaData.length) continue;
+						} break;
+					}
+					index = paletteMapping[index] & 0xff;
+			
+					/*** WRITE NEXT PIXEL ***/
+					switch (dtype) {
+						case TYPE_INDEX_8:
+							destData[dp] = (byte) index;
+							break;
+						case TYPE_INDEX_4:
+							if ((dp & 1) != 0) destData[dp >> 1] = (byte)((destData[dp >> 1] & 0xf0) | index);
+							else destData[dp >> 1] = (byte)((destData[dp >> 1] & 0x0f) | (index << 4));
+							break;					
+						case TYPE_INDEX_2: {
+							final int shift = 6 - (dp & 3) * 2;
+							destData[dp >> 2] = (byte)(destData[dp >> 2] & ~(0x03 << shift) | (index << shift));
+						} break;					
+						case TYPE_INDEX_1_MSB: {
+							final int shift = 7 - (dp & 7);
+							destData[dp >> 3] = (byte)(destData[dp >> 3] & ~(0x01 << shift) | (index << shift));
+						} break;
+						case TYPE_INDEX_1_LSB: {
+							final int shift = dp & 7;
+							destData[dp >> 3] = (byte)(destData[dp >> 3] & ~(0x01 << shift) | (index << shift));
+						} break;					
+					}
+				}
+			}
+		}
+		return;
+	}
+		
+	/*** Comprehensive blit (apply transformations) ***/
+	int alpha = alphaMode;
+	int index = 0;
+	int indexq = 0;
+	int lastindex = 0, lastr = -1, lastg = -1, lastb = -1;
+	final int[] rerr, gerr, berr;
+	if (ditherEnabled) {
+		rerr = new int[destWidth + 2];
+		gerr = new int[destWidth + 2];
+		berr = new int[destWidth + 2];
+	} else {
+		rerr = null; gerr = null; berr = null;
+	}
+	for (int dy = destHeight, sfy = sfyi; dy > 0; --dy,
+			sp = spr += (sfy >>> 16) * srcStride,
+			ap = apr += (sfy >>> 16) * alphaStride,
+			sfy = (sfy & 0xffff) + sfyi,
+			dp = dpr += dpryi) {
+		int lrerr = 0, lgerr = 0, lberr = 0;
+		for (int dx = destWidth, sfx = sfxi; dx > 0; --dx,
+				dp += dprxi,
+				sfx = (sfx & 0xffff) + sfxi) {
+			/*** READ NEXT PIXEL ***/
+			switch (stype) {
+				case TYPE_INDEX_8:
+					index = srcData[sp] & 0xff;
+					sp += (sfx >>> 16);
+					break;
+				case TYPE_INDEX_4:
+					if ((sp & 1) != 0) index = srcData[sp >> 1] & 0x0f;
+					else index = (srcData[sp >> 1] >>> 4) & 0x0f;
+					sp += (sfx >>> 16);
+					break;
+				case TYPE_INDEX_2:
+					index = (srcData[sp >> 2] >>> (6 - (sp & 3) * 2)) & 0x03;
+					sp += (sfx >>> 16);
+					break;
+				case TYPE_INDEX_1_MSB:
+					index = (srcData[sp >> 3] >>> (7 - (sp & 7))) & 0x01;
+					sp += (sfx >>> 16);
+					break;
+				case TYPE_INDEX_1_LSB:
+					index = (srcData[sp >> 3] >>> (sp & 7)) & 0x01;
+					sp += (sfx >>> 16);
+					break;
+			}
+
+			/*** DO SPECIAL PROCESSING IF REQUIRED ***/
+			int r = srcReds[index] & 0xff, g = srcGreens[index] & 0xff, b = srcBlues[index] & 0xff;
+			switch (alphaMode) {
+				case ALPHA_CHANNEL_SEPARATE:
+					alpha = ((alphaData[ap] & 0xff) << 16) / 255;
+					ap += (sfx >> 16);
+					break;
+				case ALPHA_MASK_UNPACKED:
+					alpha = (alphaData[ap] != 0) ? 0x10000 : 0;
+					ap += (sfx >> 16);
+					break;						
+				case ALPHA_MASK_PACKED:
+					alpha = (alphaData[ap >> 3] << ((ap & 7) + 9)) & 0x10000;
+					ap += (sfx >> 16);
+					break;
+				case ALPHA_MASK_INDEX: { // could speed up using binary search if we sorted the indices
+					int i = 0;
+					while (i < alphaData.length) {
+						if (index == (alphaData[i] & 0xff)) break;
+					}
+					if (i < alphaData.length) continue;
+				} break;
+				case ALPHA_MASK_RGB: {
+					int i = 0;
+					while (i < alphaData.length) {
+						if ((r == (alphaData[i] & 0xff)) &&
+							(g == (alphaData[i + 1] & 0xff)) &&
+							(b == (alphaData[i + 2] & 0xff))) break;
+						i += 3;
+					}
+					if (i < alphaData.length) continue;
+				} break;
+			}
+			if (alpha != 0x10000) {
+				if (alpha == 0x0000) continue;
+				switch (dtype) {
+					case TYPE_INDEX_8:
+						indexq = destData[dp] & 0xff;
+						break;
+					case TYPE_INDEX_4:
+						if ((dp & 1) != 0) indexq = destData[dp >> 1] & 0x0f;
+						else indexq = (destData[dp >> 1] >>> 4) & 0x0f;
+						break;
+					case TYPE_INDEX_2:
+						indexq = (destData[dp >> 2] >>> (6 - (dp & 3) * 2)) & 0x03;
+						break;
+					case TYPE_INDEX_1_MSB:
+						indexq = (destData[dp >> 3] >>> (7 - (dp & 7))) & 0x01;
+						break;
+					case TYPE_INDEX_1_LSB:
+						indexq = (destData[dp >> 3] >>> (dp & 7)) & 0x01;
+						break;
+				}
+				// Perform alpha blending
+				final int rq = destReds[indexq] & 0xff;
+				final int gq = destGreens[indexq] & 0xff;
+				final int bq = destBlues[indexq] & 0xff;
+				r = rq + ((r - rq) * alpha >> 16);
+				g = gq + ((g - gq) * alpha >> 16);
+				b = bq + ((b - bq) * alpha >> 16);
+			}
+
+			/*** MAP COLOR TO THE PALETTE ***/
+			if (ditherEnabled) {
+				// Floyd-Steinberg error diffusion
+				r += rerr[dx] >> 4;
+				if (r < 0) r = 0; else if (r > 255) r = 255;
+				g += gerr[dx] >> 4;
+				if (g < 0) g = 0; else if (g > 255) g = 255;
+				b += berr[dx] >> 4;
+				if (b < 0) b = 0; else if (b > 255) b = 255;
+				rerr[dx] = lrerr;
+				gerr[dx] = lgerr;
+				berr[dx] = lberr;
+			}
+			if (r != lastr || g != lastg || b != lastb) {
+				// moving the variable declarations out seems to make the JDK JIT happier...
+				for (int j = 0, dr, dg, db, distance, minDistance = 0x7fffffff; j < destPaletteSize; ++j) {
+					dr = (destReds[j] & 0xff) - r;
+					dg = (destGreens[j] & 0xff) - g;
+					db = (destBlues[j] & 0xff) - b;
+					distance = dr * dr + dg * dg + db * db;
+					if (distance < minDistance) {
+						lastindex = j;
+						if (distance == 0) break;
+						minDistance = distance;
+					}
+				}
+				lastr = r; lastg = g; lastb = b;
+			}
+			if (ditherEnabled) {
+				// Floyd-Steinberg error diffusion, cont'd...
+				final int dxm1 = dx - 1, dxp1 = dx + 1;
+				int acc;
+				rerr[dxp1] += acc = (lrerr = r - (destReds[lastindex] & 0xff)) + lrerr + lrerr;
+				rerr[dx] += acc += lrerr + lrerr;
+				rerr[dxm1] += acc + lrerr + lrerr;
+				gerr[dxp1] += acc = (lgerr = g - (destGreens[lastindex] & 0xff)) + lgerr + lgerr;
+				gerr[dx] += acc += lgerr + lgerr;
+				gerr[dxm1] += acc + lgerr + lgerr;
+				berr[dxp1] += acc = (lberr = b - (destBlues[lastindex] & 0xff)) + lberr + lberr;
+				berr[dx] += acc += lberr + lberr;
+				berr[dxm1] += acc + lberr + lberr;
+			}
+
+			/*** WRITE NEXT PIXEL ***/
+			switch (dtype) {
+				case TYPE_INDEX_8:
+					destData[dp] = (byte) lastindex;
+					break;
+				case TYPE_INDEX_4:
+					if ((dp & 1) != 0) destData[dp >> 1] = (byte)((destData[dp >> 1] & 0xf0) | lastindex);
+					else destData[dp >> 1] = (byte)((destData[dp >> 1] & 0x0f) | (lastindex << 4));
+					break;
+				case TYPE_INDEX_2: {
+					final int shift = 6 - (dp & 3) * 2;
+					destData[dp >> 2] = (byte)(destData[dp >> 2] & ~(0x03 << shift) | (lastindex << shift));
+				} break;					
+				case TYPE_INDEX_1_MSB: {
+					final int shift = 7 - (dp & 7);
+					destData[dp >> 3] = (byte)(destData[dp >> 3] & ~(0x01 << shift) | (lastindex << shift));
+				} break;
+				case TYPE_INDEX_1_LSB: {
+					final int shift = dp & 7;
+					destData[dp >> 3] = (byte)(destData[dp >> 3] & ~(0x01 << shift) | (lastindex << shift));
+				} break;					
+			}
+		}
+	}
+}
+
+/**
+ * Blits an index palette image into a direct palette image.
+ * <p>
+ * Note: The source and destination masks and palettes must
+ * always be fully specified.
+ * </p>
+ * 
+ * @param op the blitter operation: a combination of BLIT_xxx flags
+ *        (see BLIT_xxx constants)
+ * @param srcData the source byte array containing image data
+ * @param srcDepth the source depth: one of 1, 2, 4, 8
+ * @param srcStride the source number of bytes per line
+ * @param srcOrder the source byte ordering: one of MSB_FIRST or LSB_FIRST;
+ *        ignored if srcDepth is not 1
+ * @param srcX the top-left x-coord of the source blit region
+ * @param srcY the top-left y-coord of the source blit region
+ * @param srcWidth the width of the source blit region
+ * @param srcHeight the height of the source blit region
+ * @param srcReds the source palette red component intensities
+ * @param srcGreens the source palette green component intensities
+ * @param srcBlues the source palette blue component intensities
+ * @param alphaMode the alpha blending or mask mode, may be
+ *        an integer 0-255 for global alpha; ignored if BLIT_ALPHA
+ *        not specified in the blitter operations
+ *        (see ALPHA_MODE_xxx constants)
+ * @param alphaData the alpha blending or mask data, varies depending
+ *        on the value of alphaMode and sometimes ignored
+ * @param alphaStride the alpha data number of bytes per line
+ * @param alphaX the top-left x-coord of the alpha blit region
+ * @param alphaY the top-left y-coord of the alpha blit region
+ * @param destData the destination byte array containing image data
+ * @param destDepth the destination depth: one of 8, 16, 24, 32
+ * @param destStride the destination number of bytes per line
+ * @param destOrder the destination byte ordering: one of MSB_FIRST or LSB_FIRST;
+ *        ignored if destDepth is not 16 or 32
+ * @param destX the top-left x-coord of the destination blit region
+ * @param destY the top-left y-coord of the destination blit region
+ * @param destWidth the width of the destination blit region
+ * @param destHeight the height of the destination blit region
+ * @param destRedMask the destination red channel mask
+ * @param destGreenMask the destination green channel mask
+ * @param destBlueMask the destination blue channel mask
+ * @param flipX if true the resulting image is flipped along the vertical axis
+ * @param flipY if true the resulting image is flipped along the horizontal axis
+ */
+static void blit(int op,
+	byte[] srcData, int srcDepth, int srcStride, int srcOrder,
+	int srcX, int srcY, int srcWidth, int srcHeight,
+	byte[] srcReds, byte[] srcGreens, byte[] srcBlues,
+	int alphaMode, byte[] alphaData, int alphaStride, int alphaX, int alphaY,
+	byte[] destData, int destDepth, int destStride, int destOrder,
+	int destX, int destY, int destWidth, int destHeight,
+	int destRedMask, int destGreenMask, int destBlueMask,
+	boolean flipX, boolean flipY) {
+	if ((destWidth <= 0) || (destHeight <= 0) || (alphaMode == ALPHA_TRANSPARENT)) return;
+
+	// these should be supplied as params later
+	final int destAlphaMask = 0;
+
+	/*** Prepare scaling data ***/
+	final int dwm1 = destWidth - 1;
+	final int sfxi = (dwm1 != 0) ? (int)((((long)srcWidth << 16) - 1) / dwm1) : 0;
+	final int dhm1 = destHeight - 1;
+	final int sfyi = (dhm1 != 0) ? (int)((((long)srcHeight << 16) - 1) / dhm1) : 0;
+
+	/*** Prepare source-related data ***/
+	final int stype;
+	switch (srcDepth) {
+		case 8:
+			stype = TYPE_INDEX_8;
+			break;
+		case 4:
+			srcStride <<= 1;
+			stype = TYPE_INDEX_4;
+			break;
+		case 2:
+			srcStride <<= 2;
+			stype = TYPE_INDEX_2;
+			break;
+		case 1:
+			srcStride <<= 3;
+			stype = (srcOrder == MSB_FIRST) ? TYPE_INDEX_1_MSB : TYPE_INDEX_1_LSB;
+			break;
+		default:
+			//throw new IllegalArgumentException("Invalid source type");
+			return;
+	}			
+	int spr = srcY * srcStride + srcX;
+
+	/*** Prepare destination-related data ***/
+	final int dbpp, dtype;
+	switch (destDepth) {
+		case 8:
+			dbpp = 1;
+			dtype = TYPE_GENERIC_8;
+			break;
+		case 16:
+			dbpp = 2;
+			dtype = (destOrder == MSB_FIRST) ? TYPE_GENERIC_16_MSB : TYPE_GENERIC_16_LSB;
+			break;
+		case 24:
+			dbpp = 3;
+			dtype = TYPE_GENERIC_24;
+			break;
+		case 32:
+			dbpp = 4;
+			dtype = (destOrder == MSB_FIRST) ? TYPE_GENERIC_32_MSB : TYPE_GENERIC_32_LSB;
+			break;
+		default:
+			//throw new IllegalArgumentException("Invalid destination type");
+			return;
+	}			
+	int dpr = ((flipY) ? destY + dhm1 : destY) * destStride + ((flipX) ? destX + dwm1 : destX) * dbpp;
+	final int dprxi = (flipX) ? -dbpp : dbpp;
+	final int dpryi = (flipY) ? -destStride : destStride;
+
+	/*** Prepare special processing data ***/
+	int apr;
+	if ((op & BLIT_ALPHA) != 0) {
+		switch (alphaMode) {
+			case ALPHA_MASK_UNPACKED:
+			case ALPHA_CHANNEL_SEPARATE:
+				if (alphaData == null) alphaMode = 0x10000;
+				apr = alphaY * alphaStride + alphaX;
+				break;
+			case ALPHA_MASK_PACKED:
+				if (alphaData == null) alphaMode = 0x10000;
+				alphaStride <<= 3;
+				apr = alphaY * alphaStride + alphaX;
+				break;
+			case ALPHA_MASK_INDEX:
+			case ALPHA_MASK_RGB:
+				if (alphaData == null) alphaMode = 0x10000;
+				apr = 0;
+				break;
+			default:
+				alphaMode = (alphaMode << 16) / 255; // prescale
+			case ALPHA_CHANNEL_SOURCE:
+				apr = 0;
+				break;
+		}
+	} else {
+		alphaMode = 0x10000;
+		apr = 0;
+	}
+
+	/*** Comprehensive blit (apply transformations) ***/
+	final int destRedShift = getChannelShift(destRedMask);
+	final int destRedWidth = getChannelWidth(destRedMask, destRedShift);
+	final byte[] destReds = ANY_TO_EIGHT[destRedWidth];
+	final int destRedPreShift = 8 - destRedWidth;
+	final int destGreenShift = getChannelShift(destGreenMask);
+	final int destGreenWidth = getChannelWidth(destGreenMask, destGreenShift);
+	final byte[] destGreens = ANY_TO_EIGHT[destGreenWidth];
+	final int destGreenPreShift = 8 - destGreenWidth;
+	final int destBlueShift = getChannelShift(destBlueMask);
+	final int destBlueWidth = getChannelWidth(destBlueMask, destBlueShift);
+	final byte[] destBlues = ANY_TO_EIGHT[destBlueWidth];
+	final int destBluePreShift = 8 - destBlueWidth;
+	final int destAlphaShift = getChannelShift(destAlphaMask);
+	final int destAlphaWidth = getChannelWidth(destAlphaMask, destAlphaShift);
+	final byte[] destAlphas = ANY_TO_EIGHT[destAlphaWidth];
+	final int destAlphaPreShift = 8 - destAlphaWidth;
+
+	int dp = dpr;
+	int sp = spr;
+	int ap = apr, alpha = alphaMode;
+	int r = 0, g = 0, b = 0, a = 0, index = 0;
+	int rq = 0, gq = 0, bq = 0, aq = 0;
+	for (int dy = destHeight, sfy = sfyi; dy > 0; --dy,
+			sp = spr += (sfy >>> 16) * srcStride,
+			ap = apr += (sfy >>> 16) * alphaStride,
+			sfy = (sfy & 0xffff) + sfyi,
+			dp = dpr += dpryi) {
+		for (int dx = destWidth, sfx = sfxi; dx > 0; --dx,
+				dp += dprxi,
+				sfx = (sfx & 0xffff) + sfxi) {
+			/*** READ NEXT PIXEL ***/
+			switch (stype) {
+				case TYPE_INDEX_8:
+					index = srcData[sp] & 0xff;
+					sp += (sfx >>> 16);
+					break;
+				case TYPE_INDEX_4:
+					if ((sp & 1) != 0) index = srcData[sp >> 1] & 0x0f;
+					else index = (srcData[sp >> 1] >>> 4) & 0x0f;
+					sp += (sfx >>> 16);
+					break;
+				case TYPE_INDEX_2:
+					index = (srcData[sp >> 2] >>> (6 - (sp & 3) * 2)) & 0x03;
+					sp += (sfx >>> 16);
+					break;
+				case TYPE_INDEX_1_MSB:
+					index = (srcData[sp >> 3] >>> (7 - (sp & 7))) & 0x01;
+					sp += (sfx >>> 16);
+					break;
+				case TYPE_INDEX_1_LSB:
+					index = (srcData[sp >> 3] >>> (sp & 7)) & 0x01;
+					sp += (sfx >>> 16);
+					break;
+			}
+
+			/*** DO SPECIAL PROCESSING IF REQUIRED ***/
+			r = srcReds[index] & 0xff;
+			g = srcGreens[index] & 0xff;
+			b = srcBlues[index] & 0xff;
+			switch (alphaMode) {
+				case ALPHA_CHANNEL_SEPARATE:
+					alpha = ((alphaData[ap] & 0xff) << 16) / 255;
+					ap += (sfx >> 16);
+					break;
+				case ALPHA_MASK_UNPACKED:
+					alpha = (alphaData[ap] != 0) ? 0x10000 : 0;
+					ap += (sfx >> 16);
+					break;						
+				case ALPHA_MASK_PACKED:
+					alpha = (alphaData[ap >> 3] << ((ap & 7) + 9)) & 0x10000;
+					ap += (sfx >> 16);
+					break;
+				case ALPHA_MASK_INDEX: { // could speed up using binary search if we sorted the indices
+					int i = 0;
+					while (i < alphaData.length) {
+						if (index == (alphaData[i] & 0xff)) break;
+					}
+					if (i < alphaData.length) continue;
+				} break;
+				case ALPHA_MASK_RGB: {
+					int i = 0;
+					while (i < alphaData.length) {
+						if ((r == (alphaData[i] & 0xff)) &&
+							(g == (alphaData[i + 1] & 0xff)) &&
+							(b == (alphaData[i + 2] & 0xff))) break;
+						i += 3;
+					}
+					if (i < alphaData.length) continue;
+				} break;
+			}
+			if (alpha != 0x10000) {
+				if (alpha == 0x0000) continue;
+				switch (dtype) {
+					case TYPE_GENERIC_8: {
+						final int data = destData[dp] & 0xff;
+						rq = destReds[(data & destRedMask) >>> destRedShift] & 0xff;
+						gq = destGreens[(data & destGreenMask) >>> destGreenShift] & 0xff;
+						bq = destBlues[(data & destBlueMask) >>> destBlueShift] & 0xff;
+						aq = destAlphas[(data & destAlphaMask) >>> destAlphaShift] & 0xff;
+					} break;
+					case TYPE_GENERIC_16_MSB: {
+						final int data = ((destData[dp] & 0xff) << 8) | (destData[dp + 1] & 0xff);
+						rq = destReds[(data & destRedMask) >>> destRedShift] & 0xff;
+						gq = destGreens[(data & destGreenMask) >>> destGreenShift] & 0xff;
+						bq = destBlues[(data & destBlueMask) >>> destBlueShift] & 0xff;
+						aq = destAlphas[(data & destAlphaMask) >>> destAlphaShift] & 0xff;
+					} break;
+					case TYPE_GENERIC_16_LSB: {
+						final int data = ((destData[dp + 1] & 0xff) << 8) | (destData[dp] & 0xff);
+						rq = destReds[(data & destRedMask) >>> destRedShift] & 0xff;
+						gq = destGreens[(data & destGreenMask) >>> destGreenShift] & 0xff;
+						bq = destBlues[(data & destBlueMask) >>> destBlueShift] & 0xff;
+						aq = destAlphas[(data & destAlphaMask) >>> destAlphaShift] & 0xff;
+					} break;
+					case TYPE_GENERIC_24: {
+						final int data = (( ((destData[dp] & 0xff) << 8) |
+							(destData[dp + 1] & 0xff)) << 8) |
+							(destData[dp + 2] & 0xff);
+						rq = destReds[(data & destRedMask) >>> destRedShift] & 0xff;
+						gq = destGreens[(data & destGreenMask) >>> destGreenShift] & 0xff;
+						bq = destBlues[(data & destBlueMask) >>> destBlueShift] & 0xff;
+						aq = destAlphas[(data & destAlphaMask) >>> destAlphaShift] & 0xff;
+					} break;
+					case TYPE_GENERIC_32_MSB: {
+						final int data = (( (( ((destData[dp] & 0xff) << 8) |
+							(destData[dp + 1] & 0xff)) << 8) |
+							(destData[dp + 2] & 0xff)) << 8) |
+							(destData[dp + 3] & 0xff);
+						rq = destReds[(data & destRedMask) >>> destRedShift] & 0xff;
+						gq = destGreens[(data & destGreenMask) >>> destGreenShift] & 0xff;
+						bq = destBlues[(data & destBlueMask) >>> destBlueShift] & 0xff;
+						aq = destAlphas[(data & destAlphaMask) >>> destAlphaShift] & 0xff;
+					} break;
+					case TYPE_GENERIC_32_LSB: {
+						final int data = (( (( ((destData[dp + 3] & 0xff) << 8) |
+							(destData[dp + 2] & 0xff)) << 8) |
+							(destData[dp + 1] & 0xff)) << 8) |
+							(destData[dp] & 0xff);
+						rq = destReds[(data & destRedMask) >>> destRedShift] & 0xff;
+						gq = destGreens[(data & destGreenMask) >>> destGreenShift] & 0xff;
+						bq = destBlues[(data & destBlueMask) >>> destBlueShift] & 0xff;
+						aq = destAlphas[(data & destAlphaMask) >>> destAlphaShift] & 0xff;
+					} break;
+				}
+				// Perform alpha blending
+				a = aq + ((a - aq) * alpha >> 16);
+				r = rq + ((r - rq) * alpha >> 16);
+				g = gq + ((g - gq) * alpha >> 16);
+				b = bq + ((b - bq) * alpha >> 16);
+			}
+
+			/*** WRITE NEXT PIXEL ***/
+			final int data = 
+				(r >>> destRedPreShift << destRedShift) |
+				(g >>> destGreenPreShift << destGreenShift) |
+				(b >>> destBluePreShift << destBlueShift) |
+				(a >>> destAlphaPreShift << destAlphaShift);
+			switch (dtype) {
+				case TYPE_GENERIC_8: {
+					destData[dp] = (byte) data;
+				} break;
+				case TYPE_GENERIC_16_MSB: {
+					destData[dp] = (byte) (data >>> 8);
+					destData[dp + 1] = (byte) (data & 0xff);
+				} break;
+				case TYPE_GENERIC_16_LSB: {
+					destData[dp] = (byte) (data & 0xff);
+					destData[dp + 1] = (byte) (data >>> 8);
+				} break;
+				case TYPE_GENERIC_24: {
+					destData[dp] = (byte) (data >>> 16);
+					destData[dp + 1] = (byte) (data >>> 8);
+					destData[dp + 2] = (byte) (data & 0xff);
+				} break;
+				case TYPE_GENERIC_32_MSB: {
+					destData[dp] = (byte) (data >>> 24);
+					destData[dp + 1] = (byte) (data >>> 16);
+					destData[dp + 2] = (byte) (data >>> 8);
+					destData[dp + 3] = (byte) (data & 0xff);
+				} break;
+				case TYPE_GENERIC_32_LSB: {
+					destData[dp] = (byte) (data & 0xff);
+					destData[dp + 1] = (byte) (data >>> 8);
+					destData[dp + 2] = (byte) (data >>> 16);
+					destData[dp + 3] = (byte) (data >>> 24);
+				} break;
+			}
+		}
+	}			
+}
+
+/**
+ * Blits a direct palette image into an index palette image.
+ * <p>
+ * Note: The source and destination masks and palettes must
+ * always be fully specified.
+ * </p>
+ * 
+ * @param op the blitter operation: a combination of BLIT_xxx flags
+ *        (see BLIT_xxx constants)
+ * @param srcData the source byte array containing image data
+ * @param srcDepth the source depth: one of 8, 16, 24, 32
+ * @param srcStride the source number of bytes per line
+ * @param srcOrder the source byte ordering: one of MSB_FIRST or LSB_FIRST;
+ *        ignored if srcDepth is not 16 or 32
+ * @param srcX the top-left x-coord of the source blit region
+ * @param srcY the top-left y-coord of the source blit region
+ * @param srcWidth the width of the source blit region
+ * @param srcHeight the height of the source blit region
+ * @param srcRedMask the source red channel mask
+ * @param srcGreenMask the source green channel mask
+ * @param srcBlueMask the source blue channel mask
+ * @param alphaMode the alpha blending or mask mode, may be
+ *        an integer 0-255 for global alpha; ignored if BLIT_ALPHA
+ *        not specified in the blitter operations
+ *        (see ALPHA_MODE_xxx constants)
+ * @param alphaData the alpha blending or mask data, varies depending
+ *        on the value of alphaMode and sometimes ignored
+ * @param alphaStride the alpha data number of bytes per line
+ * @param alphaX the top-left x-coord of the alpha blit region
+ * @param alphaY the top-left y-coord of the alpha blit region
+ * @param destData the destination byte array containing image data
+ * @param destDepth the destination depth: one of 1, 2, 4, 8
+ * @param destStride the destination number of bytes per line
+ * @param destOrder the destination byte ordering: one of MSB_FIRST or LSB_FIRST;
+ *        ignored if destDepth is not 1
+ * @param destX the top-left x-coord of the destination blit region
+ * @param destY the top-left y-coord of the destination blit region
+ * @param destWidth the width of the destination blit region
+ * @param destHeight the height of the destination blit region
+ * @param destReds the destination palette red component intensities
+ * @param destGreens the destination palette green component intensities
+ * @param destBlues the destination palette blue component intensities
+ * @param flipX if true the resulting image is flipped along the vertical axis
+ * @param flipY if true the resulting image is flipped along the horizontal axis
+ */
+static void blit(int op,
+	byte[] srcData, int srcDepth, int srcStride, int srcOrder,
+	int srcX, int srcY, int srcWidth, int srcHeight,
+	int srcRedMask, int srcGreenMask, int srcBlueMask,
+	int alphaMode, byte[] alphaData, int alphaStride, int alphaX, int alphaY,
+	byte[] destData, int destDepth, int destStride, int destOrder,
+	int destX, int destY, int destWidth, int destHeight,
+	byte[] destReds, byte[] destGreens, byte[] destBlues,
+	boolean flipX, boolean flipY) {
+	if ((destWidth <= 0) || (destHeight <= 0) || (alphaMode == ALPHA_TRANSPARENT)) return;
+
+	// these should be supplied as params later
+	final int srcAlphaMask = 0;
+
+	/*** Prepare scaling data ***/
+	final int dwm1 = destWidth - 1;
+	final int sfxi = (dwm1 != 0) ? (int)((((long)srcWidth << 16) - 1) / dwm1) : 0;
+	final int dhm1 = destHeight - 1;
+	final int sfyi = (dhm1 != 0) ? (int)((((long)srcHeight << 16) - 1) / dhm1) : 0;
+
+	/*** Prepare source-related data ***/
+	final int sbpp, stype;
+	switch (srcDepth) {
+		case 8:
+			sbpp = 1;
+			stype = TYPE_GENERIC_8;
+			break;
+		case 16:
+			sbpp = 2;
+			stype = (srcOrder == MSB_FIRST) ? TYPE_GENERIC_16_MSB : TYPE_GENERIC_16_LSB;
+			break;
+		case 24:
+			sbpp = 3;
+			stype = TYPE_GENERIC_24;
+			break;
+		case 32:
+			sbpp = 4;
+			stype = (srcOrder == MSB_FIRST) ? TYPE_GENERIC_32_MSB : TYPE_GENERIC_32_LSB;
+			break;
+		default:
+			//throw new IllegalArgumentException("Invalid source type");
+			return;
+	}			
+	int spr = srcY * srcStride + srcX * sbpp;
+
+	/*** Prepare destination-related data ***/
+	final int dtype;
+	switch (destDepth) {
+		case 8:
+			dtype = TYPE_INDEX_8;
+			break;
+		case 4:
+			destStride <<= 1;
+			dtype = TYPE_INDEX_4;
+			break;
+		case 2:
+			destStride <<= 2;
+			dtype = TYPE_INDEX_2;
+			break;
+		case 1:
+			destStride <<= 3;
+			dtype = (destOrder == MSB_FIRST) ? TYPE_INDEX_1_MSB : TYPE_INDEX_1_LSB;
+			break;
+		default:
+			//throw new IllegalArgumentException("Invalid source type");
+			return;
+	}			
+	int dpr = ((flipY) ? destY + dhm1 : destY) * destStride + ((flipX) ? destX + dwm1 : destX);
+	final int dprxi = (flipX) ? -1 : 1;
+	final int dpryi = (flipY) ? -destStride : destStride;
+
+	/*** Prepare special processing data ***/
+	int apr;
+	if ((op & BLIT_ALPHA) != 0) {
+		switch (alphaMode) {
+			case ALPHA_MASK_UNPACKED:
+			case ALPHA_CHANNEL_SEPARATE:
+				if (alphaData == null) alphaMode = 0x10000;
+				apr = alphaY * alphaStride + alphaX;
+				break;
+			case ALPHA_MASK_PACKED:
+				if (alphaData == null) alphaMode = 0x10000;
+				alphaStride <<= 3;
+				apr = alphaY * alphaStride + alphaX;
+				break;
+			case ALPHA_MASK_INDEX:
+				//throw new IllegalArgumentException("Invalid alpha type");
+				return;
+			case ALPHA_MASK_RGB:
+				if (alphaData == null) alphaMode = 0x10000;
+				apr = 0;
+				break;
+			default:
+				alphaMode = (alphaMode << 16) / 255; // prescale
+			case ALPHA_CHANNEL_SOURCE:
+				apr = 0;
+				break;
+		}
+	} else {
+		alphaMode = 0x10000;
+		apr = 0;
+	}
+	final boolean ditherEnabled = (op & BLIT_DITHER) != 0;
+
+	/*** Comprehensive blit (apply transformations) ***/
+	final int srcRedShift = getChannelShift(srcRedMask);
+	final byte[] srcReds = ANY_TO_EIGHT[getChannelWidth(srcRedMask, srcRedShift)];
+	final int srcGreenShift = getChannelShift(srcGreenMask);
+	final byte[] srcGreens = ANY_TO_EIGHT[getChannelWidth(srcGreenMask, srcGreenShift)];
+	final int srcBlueShift = getChannelShift(srcBlueMask);
+	final byte[] srcBlues = ANY_TO_EIGHT[getChannelWidth(srcBlueMask, srcBlueShift)];
+	final int srcAlphaShift = getChannelShift(srcAlphaMask);
+	final byte[] srcAlphas = ANY_TO_EIGHT[getChannelWidth(srcAlphaMask, srcAlphaShift)];
+
+	int dp = dpr;
+	int sp = spr;
+	int ap = apr, alpha = alphaMode;
+	int r = 0, g = 0, b = 0, a = 0;
+	int indexq = 0;
+	int lastindex = 0, lastr = -1, lastg = -1, lastb = -1;
+	final int[] rerr, gerr, berr;
+	int destPaletteSize = 1 << destDepth;
+	if ((destReds != null) && (destReds.length < destPaletteSize)) destPaletteSize = destReds.length;
+	if (ditherEnabled) {
+		rerr = new int[destWidth + 2];
+		gerr = new int[destWidth + 2];
+		berr = new int[destWidth + 2];
+	} else {
+		rerr = null; gerr = null; berr = null;
+	}
+	for (int dy = destHeight, sfy = sfyi; dy > 0; --dy,
+			sp = spr += (sfy >>> 16) * srcStride,
+			ap = apr += (sfy >>> 16) * alphaStride,
+			sfy = (sfy & 0xffff) + sfyi,
+			dp = dpr += dpryi) {
+		int lrerr = 0, lgerr = 0, lberr = 0;
+		for (int dx = destWidth, sfx = sfxi; dx > 0; --dx,
+				dp += dprxi,
+				sfx = (sfx & 0xffff) + sfxi) {
+			/*** READ NEXT PIXEL ***/
+			switch (stype) {
+				case TYPE_GENERIC_8: {
+					final int data = srcData[sp] & 0xff;
+					sp += (sfx >>> 16);
+					r = srcReds[(data & srcRedMask) >>> srcRedShift] & 0xff;
+					g = srcGreens[(data & srcGreenMask) >>> srcGreenShift] & 0xff;
+					b = srcBlues[(data & srcBlueMask) >>> srcBlueShift] & 0xff;
+					a = srcAlphas[(data & srcAlphaMask) >>> srcAlphaShift] & 0xff;
+				} break;
+				case TYPE_GENERIC_16_MSB: {
+					final int data = ((srcData[sp] & 0xff) << 8) | (srcData[sp + 1] & 0xff);
+					sp += (sfx >>> 16) * 2;
+					r = srcReds[(data & srcRedMask) >>> srcRedShift] & 0xff;
+					g = srcGreens[(data & srcGreenMask) >>> srcGreenShift] & 0xff;
+					b = srcBlues[(data & srcBlueMask) >>> srcBlueShift] & 0xff;
+					a = srcAlphas[(data & srcAlphaMask) >>> srcAlphaShift] & 0xff;
+				} break;
+				case TYPE_GENERIC_16_LSB: {
+					final int data = ((srcData[sp + 1] & 0xff) << 8) | (srcData[sp] & 0xff);
+					sp += (sfx >>> 16) * 2;
+					r = srcReds[(data & srcRedMask) >>> srcRedShift] & 0xff;
+					g = srcGreens[(data & srcGreenMask) >>> srcGreenShift] & 0xff;
+					b = srcBlues[(data & srcBlueMask) >>> srcBlueShift] & 0xff;
+					a = srcAlphas[(data & srcAlphaMask) >>> srcAlphaShift] & 0xff;
+				} break;
+				case TYPE_GENERIC_24: {
+					final int data = (( ((srcData[sp] & 0xff) << 8) |
+						(srcData[sp + 1] & 0xff)) << 8) |
+						(srcData[sp + 2] & 0xff);
+					sp += (sfx >>> 16) * 3;
+					r = srcReds[(data & srcRedMask) >>> srcRedShift] & 0xff;
+					g = srcGreens[(data & srcGreenMask) >>> srcGreenShift] & 0xff;
+					b = srcBlues[(data & srcBlueMask) >>> srcBlueShift] & 0xff;
+					a = srcAlphas[(data & srcAlphaMask) >>> srcAlphaShift] & 0xff;
+				} break;
+				case TYPE_GENERIC_32_MSB: {
+					final int data = (( (( ((srcData[sp] & 0xff) << 8) |
+						(srcData[sp + 1] & 0xff)) << 8) |
+						(srcData[sp + 2] & 0xff)) << 8) |
+						(srcData[sp + 3] & 0xff);
+					sp += (sfx >>> 16) * 4;
+					r = srcReds[(data & srcRedMask) >>> srcRedShift] & 0xff;
+					g = srcGreens[(data & srcGreenMask) >>> srcGreenShift] & 0xff;
+					b = srcBlues[(data & srcBlueMask) >>> srcBlueShift] & 0xff;
+					a = srcAlphas[(data & srcAlphaMask) >>> srcAlphaShift] & 0xff;
+				} break;
+				case TYPE_GENERIC_32_LSB: {
+					final int data = (( (( ((srcData[sp + 3] & 0xff) << 8) |
+						(srcData[sp + 2] & 0xff)) << 8) |
+						(srcData[sp + 1] & 0xff)) << 8) |
+						(srcData[sp] & 0xff);
+					sp += (sfx >>> 16) * 4;
+					r = srcReds[(data & srcRedMask) >>> srcRedShift] & 0xff;
+					g = srcGreens[(data & srcGreenMask) >>> srcGreenShift] & 0xff;
+					b = srcBlues[(data & srcBlueMask) >>> srcBlueShift] & 0xff;
+					a = srcAlphas[(data & srcAlphaMask) >>> srcAlphaShift] & 0xff;
+				} break;
+			}
+
+			/*** DO SPECIAL PROCESSING IF REQUIRED ***/
+			switch (alphaMode) {
+				case ALPHA_CHANNEL_SEPARATE:
+					alpha = ((alphaData[ap] & 0xff) << 16) / 255;
+					ap += (sfx >> 16);
+					break;
+				case ALPHA_CHANNEL_SOURCE:
+					alpha = (a << 16) / 255;
+					break;
+				case ALPHA_MASK_UNPACKED:
+					alpha = (alphaData[ap] != 0) ? 0x10000 : 0;
+					ap += (sfx >> 16);
+					break;						
+				case ALPHA_MASK_PACKED:
+					alpha = (alphaData[ap >> 3] << ((ap & 7) + 9)) & 0x10000;
+					ap += (sfx >> 16);
+					break;
+				case ALPHA_MASK_RGB:
+					alpha = 0x10000;
+					for (int i = 0; i < alphaData.length; i += 3) {
+						if ((r == alphaData[i]) && (g == alphaData[i + 1]) && (b == alphaData[i + 2])) {
+							alpha = 0x0000;
+							break;
+						}
+					}
+					break;
+			}
+			if (alpha != 0x10000) {
+				if (alpha == 0x0000) continue;
+				switch (dtype) {
+					case TYPE_INDEX_8:
+						indexq = destData[dp] & 0xff;
+						break;
+					case TYPE_INDEX_4:
+						if ((dp & 1) != 0) indexq = destData[dp >> 1] & 0x0f;
+						else indexq = (destData[dp >> 1] >>> 4) & 0x0f;
+						break;
+					case TYPE_INDEX_2:
+						indexq = (destData[dp >> 2] >>> (6 - (dp & 3) * 2)) & 0x03;
+						break;
+					case TYPE_INDEX_1_MSB:
+						indexq = (destData[dp >> 3] >>> (7 - (dp & 7))) & 0x01;
+						break;
+					case TYPE_INDEX_1_LSB:
+						indexq = (destData[dp >> 3] >>> (dp & 7)) & 0x01;
+						break;
+				}
+				// Perform alpha blending
+				final int rq = destReds[indexq] & 0xff;
+				final int gq = destGreens[indexq] & 0xff;
+				final int bq = destBlues[indexq] & 0xff;
+				r = rq + ((r - rq) * alpha >> 16);
+				g = gq + ((g - gq) * alpha >> 16);
+				b = bq + ((b - bq) * alpha >> 16);
+			}
+
+			/*** MAP COLOR TO THE PALETTE ***/
+			if (ditherEnabled) {
+				// Floyd-Steinberg error diffusion
+				r += rerr[dx] >> 4;
+				if (r < 0) r = 0; else if (r > 255) r = 255;
+				g += gerr[dx] >> 4;
+				if (g < 0) g = 0; else if (g > 255) g = 255;
+				b += berr[dx] >> 4;
+				if (b < 0) b = 0; else if (b > 255) b = 255;
+				rerr[dx] = lrerr;
+				gerr[dx] = lgerr;
+				berr[dx] = lberr;
+			}
+			if (r != lastr || g != lastg || b != lastb) {
+				// moving the variable declarations out seems to make the JDK JIT happier...
+				for (int j = 0, dr, dg, db, distance, minDistance = 0x7fffffff; j < destPaletteSize; ++j) {
+					dr = (destReds[j] & 0xff) - r;
+					dg = (destGreens[j] & 0xff) - g;
+					db = (destBlues[j] & 0xff) - b;
+					distance = dr * dr + dg * dg + db * db;
+					if (distance < minDistance) {
+						lastindex = j;
+						if (distance == 0) break;
+						minDistance = distance;
+					}
+				}
+				lastr = r; lastg = g; lastb = b;
+			}
+			if (ditherEnabled) {
+				// Floyd-Steinberg error diffusion, cont'd...
+				final int dxm1 = dx - 1, dxp1 = dx + 1;
+				int acc;
+				rerr[dxp1] += acc = (lrerr = r - (destReds[lastindex] & 0xff)) + lrerr + lrerr;
+				rerr[dx] += acc += lrerr + lrerr;
+				rerr[dxm1] += acc + lrerr + lrerr;
+				gerr[dxp1] += acc = (lgerr = g - (destGreens[lastindex] & 0xff)) + lgerr + lgerr;
+				gerr[dx] += acc += lgerr + lgerr;
+				gerr[dxm1] += acc + lgerr + lgerr;
+				berr[dxp1] += acc = (lberr = b - (destBlues[lastindex] & 0xff)) + lberr + lberr;
+				berr[dx] += acc += lberr + lberr;
+				berr[dxm1] += acc + lberr + lberr;
+			}
+
+			/*** WRITE NEXT PIXEL ***/
+			switch (dtype) {
+				case TYPE_INDEX_8:
+					destData[dp] = (byte) lastindex;
+					break;
+				case TYPE_INDEX_4:
+					if ((dp & 1) != 0) destData[dp >> 1] = (byte)((destData[dp >> 1] & 0xf0) | lastindex);
+					else destData[dp >> 1] = (byte)((destData[dp >> 1] & 0x0f) | (lastindex << 4));
+					break;
+				case TYPE_INDEX_2: {
+					final int shift = 6 - (dp & 3) * 2;
+					destData[dp >> 2] = (byte)(destData[dp >> 2] & ~(0x03 << shift) | (lastindex << shift));
+				} break;					
+				case TYPE_INDEX_1_MSB: {
+					final int shift = 7 - (dp & 7);
+					destData[dp >> 3] = (byte)(destData[dp >> 3] & ~(0x01 << shift) | (lastindex << shift));
+				} break;
+				case TYPE_INDEX_1_LSB: {
+					final int shift = dp & 7;
+					destData[dp >> 3] = (byte)(destData[dp >> 3] & ~(0x01 << shift) | (lastindex << shift));
+				} break;					
+			}
+		}
+	}
+}
+
+/**
+ * Computes the required channel shift from a mask.
+ */
+static int getChannelShift(int mask) {
+	if (mask == 0) return 0;
+	int i;
+	for (i = 0; ((mask & 1) == 0) && (i < 32); ++i) {
+		mask >>>= 1;
+	}
+	return i;
+}
+
+/**
+ * Computes the required channel width (depth) from a mask.
+ */
+static int getChannelWidth(int mask, int shift) {
+	if (mask == 0) return 0;
+	int i;
+	mask >>>= shift;
+	for (i = shift; ((mask & 1) != 0) && (i < 32); ++i) {
+		mask >>>= 1;
+	}
+	return i - shift;
+}
+
+/**
+ * Extracts a field from packed RGB data given a mask for that field.
+ */
+static byte getChannelField(int data, int mask) {
+	final int shift = getChannelShift(mask);
+	return ANY_TO_EIGHT[getChannelWidth(mask, shift)][(data & mask) >>> shift];
+}
+
+/**
+ * Creates an ImageData containing one band's worth of a gradient filled
+ * block.  If <code>vertical</code> is true, the band must be tiled
+ * horizontally to fill a region, otherwise it must be tiled vertically.
+ *
+ * @param width the width of the region to be filled
+ * @param height the height of the region to be filled
+ * @param vertical if true sweeps from top to bottom, else
+ *        sweeps from left to right
+ * @param fromRGB the color to start with
+ * @param toRGB the color to end with
+ * @param redBits the number of significant red bits, 0 for palette modes
+ * @param greenBits the number of significant green bits, 0 for palette modes
+ * @param blueBits the number of significant blue bits, 0 for palette modes
+ * @return the new ImageData
+ */
+static ImageData createGradientBand(
+	int width, int height, boolean vertical,
+	RGB fromRGB, RGB toRGB,
+	int redBits, int greenBits, int blueBits) {
+	/* Gradients are drawn as tiled bands */
+	final int bandWidth, bandHeight, bitmapDepth;
+	final byte[] bitmapData;
+	final PaletteData paletteData;
+	/* Select an algorithm depending on the depth of the screen */
+	if (redBits != 0 && greenBits != 0 && blueBits != 0) {
+		paletteData = new PaletteData(0x0000ff00, 0x00ff0000, 0xff000000);
+		bitmapDepth = 32;
+		if (redBits >= 8 && greenBits >= 8 && blueBits >= 8) {
+			/* Precise color */
+			final int steps;
+			if (vertical) {
+				bandWidth = 1;
+				bandHeight = height;
+				steps = bandHeight > 1 ? bandHeight - 1 : 1;
+			} else {
+				bandWidth = width;
+				bandHeight = 1;
+				steps = bandWidth > 1 ? bandWidth - 1 : 1;
+			}
+			final int bytesPerLine = bandWidth * 4;
+			bitmapData = new byte[bandHeight * bytesPerLine];
+			buildPreciseGradientChannel(fromRGB.blue, toRGB.blue, steps, bandWidth, bandHeight, vertical, bitmapData, 0, bytesPerLine);
+			buildPreciseGradientChannel(fromRGB.green, toRGB.green, steps, bandWidth, bandHeight, vertical, bitmapData, 1, bytesPerLine);
+			buildPreciseGradientChannel(fromRGB.red, toRGB.red, steps, bandWidth, bandHeight, vertical, bitmapData, 2, bytesPerLine);
+		} else {
+			/* Dithered color */
+			final int steps;
+			if (vertical) {
+				bandWidth = (width < 8) ? width : 8;
+				bandHeight = height;
+				steps = bandHeight > 1 ? bandHeight - 1 : 1;
+			} else {
+				bandWidth = width;
+				bandHeight = (height < 8) ? height : 8;
+				steps = bandWidth > 1 ? bandWidth - 1 : 1;
+			}
+			final int bytesPerLine = bandWidth * 4;
+			bitmapData = new byte[bandHeight * bytesPerLine];
+			buildDitheredGradientChannel(fromRGB.blue, toRGB.blue, steps, bandWidth, bandHeight, vertical, bitmapData, 0, bytesPerLine, blueBits);
+			buildDitheredGradientChannel(fromRGB.green, toRGB.green, steps, bandWidth, bandHeight, vertical, bitmapData, 1, bytesPerLine, greenBits);
+			buildDitheredGradientChannel(fromRGB.red, toRGB.red, steps, bandWidth, bandHeight, vertical, bitmapData, 2, bytesPerLine, redBits);			
+		}
+	} else {
+		/* Dithered two tone */
+		paletteData = new PaletteData(new RGB[] { fromRGB, toRGB });
+		bitmapDepth = 8;
+		final int blendi;
+		if (vertical) {
+			bandWidth = (width < 8) ? width : 8;
+			bandHeight = height;
+			blendi = (bandHeight > 1) ? 0x1040000 / (bandHeight - 1) + 1 : 1;
+		} else {
+			bandWidth = width;
+			bandHeight = (height < 8) ? height : 8;
+			blendi = (bandWidth > 1) ? 0x1040000 / (bandWidth - 1) + 1 : 1;
+		}
+		final int bytesPerLine = (bandWidth + 3) & -4;
+		bitmapData = new byte[bandHeight * bytesPerLine];
+		if (vertical) {
+			for (int dy = 0, blend = 0, dp = 0; dy < bandHeight;
+				++dy, blend += blendi, dp += bytesPerLine) {
+				for (int dx = 0; dx < bandWidth; ++dx) {
+					bitmapData[dp + dx] = (blend + DITHER_MATRIX[dy & 7][dx]) <
+						0x1000000 ? (byte)0 : (byte)1;
+				}
+			}		
+		} else {
+			for (int dx = 0, blend = 0; dx < bandWidth; ++dx, blend += blendi) {
+				for (int dy = 0, dptr = dx; dy < bandHeight; ++dy, dptr += bytesPerLine) {
+					bitmapData[dptr] = (blend + DITHER_MATRIX[dy][dx & 7]) <
+						0x1000000 ? (byte)0 : (byte)1;
+				}
+			}
+		}
+	}
+	return new ImageData(bandWidth, bandHeight, bitmapDepth, paletteData, 4, bitmapData);
+}
+
+/* 
+ * Fill in gradated values for a color channel
+ */
+static final void buildPreciseGradientChannel(int from, int to, int steps,
+	int bandWidth, int bandHeight, boolean vertical,
+	byte[] bitmapData, int dp, int bytesPerLine) {
+	int val = from << 16;
+	final int inc = ((to << 16) - val) / steps + 1;
+	if (vertical) {
+		for (int dy = 0; dy < bandHeight; ++dy, dp += bytesPerLine) {
+			bitmapData[dp] = (byte)(val >>> 16);
+			val += inc;
+		}
+	} else {
+		for (int dx = 0; dx < bandWidth; ++dx, dp += 4) {
+			bitmapData[dp] = (byte)(val >>> 16);
+			val += inc;
+		}
+	}		
+}
+
+/* 
+ * Fill in dithered gradated values for a color channel
+ */
+static final void buildDitheredGradientChannel(int from, int to, int steps,
+	int bandWidth, int bandHeight, boolean vertical,
+	byte[] bitmapData, int dp, int bytesPerLine, int bits) {
+	final int mask = 0xff00 >>> bits;
+	int val = from << 16;
+	final int inc = ((to << 16) - val) / steps + 1;
+	if (vertical) {
+		for (int dy = 0; dy < bandHeight; ++dy, dp += bytesPerLine) {
+			for (int dx = 0, dptr = dp; dx < bandWidth; ++dx, dptr += 4) {
+				final int thresh = DITHER_MATRIX[dy & 7][dx] >>> bits;
+				int temp = val + thresh;
+				if (temp > 0xffffff) bitmapData[dptr] = -1;
+				else bitmapData[dptr] = (byte)((temp >>> 16) & mask);
+			}
+			val += inc;
+		}
+	} else {
+		for (int dx = 0; dx < bandWidth; ++dx, dp += 4) {
+			for (int dy = 0, dptr = dp; dy < bandHeight; ++dy, dptr += bytesPerLine) {
+				final int thresh = DITHER_MATRIX[dy][dx & 7] >>> bits;
+				int temp = val + thresh;
+				if (temp > 0xffffff) bitmapData[dptr] = -1;
+				else bitmapData[dptr] = (byte)((temp >>> 16) & mask);
+			}
+			val += inc;
+		}
+	}
+}
+
+/**
+ * Renders a gradient onto a GC.
+ * <p>
+ * This is a GC helper.
+ * </p>
+ *
+ * @param gc the GC to render the gradient onto
+ * @param device the device the GC belongs to
+ * @param x the top-left x coordinate of the region to be filled
+ * @param y the top-left y coordinate of the region to be filled
+ * @param width the width of the region to be filled
+ * @param height the height of the region to be filled
+ * @param vertical if true sweeps from top to bottom, else
+ *        sweeps from left to right
+ * @param fromRGB the color to start with
+ * @param toRGB the color to end with
+ * @param redBits the number of significant red bits, 0 for palette modes
+ * @param greenBits the number of significant green bits, 0 for palette modes
+ * @param blueBits the number of significant blue bits, 0 for palette modes
+ */
+static void fillGradientRectangle(GC gc, Device device,
+	int x, int y, int width, int height, boolean vertical,
+	RGB fromRGB, RGB toRGB,
+	int redBits, int greenBits, int blueBits) {
+	/* Create the bitmap and tile it */
+	ImageData band = createGradientBand(width, height, vertical,
+		fromRGB, toRGB, redBits, greenBits, blueBits);
+	Image image = new Image(device, band);
+	if ((band.width == 1) || (band.height == 1)) {
+		gc.drawImage(image, 0, 0, band.width, band.height, x, y, width, height);
+	} else {
+		if (vertical) {
+			for (int dx = 0; dx < width; dx += band.width) {
+				int blitWidth = width - dx;
+				if (blitWidth > band.width) blitWidth = band.width;
+				gc.drawImage(image, 0, 0, blitWidth, band.height, dx + x, y, blitWidth, band.height);
+			}
+		} else {
+			for (int dy = 0; dy < height; dy += band.height) {
+				int blitHeight = height - dy;
+				if (blitHeight > band.height) blitHeight = band.height;
+				gc.drawImage(image, 0, 0, band.width, blitHeight, x, dy + y, band.width, blitHeight);
+			}
+		}
+	}
+	image.dispose();
+}
+
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/ImageDataLoader.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/ImageDataLoader.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/ImageDataLoader.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.graphics;
+
+import java.io.*;
+
+/**
+ * Internal class that separates ImageData from ImageLoader
+ * to allow removal of ImageLoader from the toolkit.
+ */
+class ImageDataLoader {
+
+	public static ImageData[] load(InputStream stream) {
+		return new ImageLoader().load(stream);
+	}
+
+	public static ImageData[] load(String filename) {
+		return new ImageLoader().load(filename);
+	}
+
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/ImageLoader.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/ImageLoader.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/ImageLoader.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,323 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.graphics;
+
+
+import java.io.*;
+import java.util.Vector;
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.Compatibility;
+import org.eclipse.swt.internal.image.*;
+
+/**
+ * Instances of this class are used to load images from,
+ * and save images to, a file or stream.
+ * <p>
+ * Currently supported image formats are:
+ * </p><ul>
+ * <li>BMP (Windows or OS/2 Bitmap)</li>
+ * <li>ICO (Windows Icon)</li>
+ * <li>JPEG</li>
+ * <li>GIF</li>
+ * <li>PNG</li>
+ * <li>TIFF</li>
+ * </ul>
+ * <code>ImageLoaders</code> can be used to:
+ * <ul>
+ * <li>load/save single images in all formats</li>
+ * <li>load/save multiple images (GIF/ICO/TIFF)</li>
+ * <li>load/save animated GIF images</li>
+ * <li>load interlaced GIF/PNG images</li>
+ * <li>load progressive JPEG images</li>
+ * </ul>
+ *
+ * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: ImageAnalyzer</a>
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+ 
+public class ImageLoader {
+	
+	/**
+	 * the array of ImageData objects in this ImageLoader.
+	 * This array is read in when the load method is called,
+	 * and it is written out when the save method is called
+	 */
+	public ImageData[] data;
+	
+	/**
+	 * the width of the logical screen on which the images
+	 * reside, in pixels (this corresponds to the GIF89a
+	 * Logical Screen Width value)
+	 */
+	public int logicalScreenWidth;
+
+	/**
+	 * the height of the logical screen on which the images
+	 * reside, in pixels (this corresponds to the GIF89a
+	 * Logical Screen Height value)
+	 */
+	public int logicalScreenHeight;
+
+	/**
+	 * the background pixel for the logical screen (this 
+	 * corresponds to the GIF89a Background Color Index value).
+	 * The default is -1 which means 'unspecified background'
+	 * 
+	 */
+	public int backgroundPixel;
+
+	/**
+	 * the number of times to repeat the display of a sequence
+	 * of animated images (this corresponds to the commonly-used
+	 * GIF application extension for "NETSCAPE 2.0 01").
+	 * The default is 1. A value of 0 means 'display repeatedly'
+	 */
+	public int repeatCount;
+		
+	/*
+	 * the set of ImageLoader event listeners, created on demand
+	 */
+	Vector imageLoaderListeners;
+
+/**
+ * Construct a new empty ImageLoader.
+ */
+public ImageLoader() {
+	reset();
+}
+
+/**
+ * Resets the fields of the ImageLoader, except for the
+ * <code>imageLoaderListeners</code> field.
+ */
+void reset() {
+	data = null;
+	logicalScreenWidth = 0;
+	logicalScreenHeight = 0;
+	backgroundPixel = -1;
+	repeatCount = 1;
+}
+
+/**
+ * Loads an array of <code>ImageData</code> objects from the
+ * specified input stream. Throws an error if either an error
+ * occurs while loading the images, or if the images are not
+ * of a supported type. Returns the loaded image data array.
+ *
+ * @param stream the input stream to load the images from
+ * @return an array of <code>ImageData</code> objects loaded from the specified input stream
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the stream is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_IO - if an IO error occurs while reading from the stream</li>
+ *    <li>ERROR_INVALID_IMAGE - if the image stream contains invalid data</li>
+ *    <li>ERROR_UNSUPPORTED_FORMAT - if the image stream contains an unrecognized format</li>
+ * </ul>
+ */
+public ImageData[] load(InputStream stream) {
+	if (stream == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	reset();
+	data = FileFormat.load(stream, this);
+	return data;
+}
+
+/**
+ * Loads an array of <code>ImageData</code> objects from the
+ * file with the specified name. Throws an error if either
+ * an error occurs while loading the images, or if the images are
+ * not of a supported type. Returns the loaded image data array.
+ *
+ * @param filename the name of the file to load the images from
+ * @return an array of <code>ImageData</code> objects loaded from the specified file
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the file name is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_IO - if an IO error occurs while reading from the file</li>
+ *    <li>ERROR_INVALID_IMAGE - if the image file contains invalid data</li>
+ *    <li>ERROR_UNSUPPORTED_FORMAT - if the image file contains an unrecognized format</li>
+ * </ul>
+ */
+public ImageData[] load(String filename) {
+	if (filename == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	InputStream stream = null;
+	try {
+		stream = Compatibility.newFileInputStream(filename);
+		return load(stream);
+	} catch (IOException e) {
+		SWT.error(SWT.ERROR_IO, e);
+	} finally {
+		try {
+			if (stream != null) stream.close();
+		} catch (IOException e) {
+			// Ignore error
+		}
+	}
+	return null;
+}
+
+/**
+ * Saves the image data in this ImageLoader to the specified stream.
+ * The format parameter can have one of the following values:
+ * <dl>
+ * <dt><code>IMAGE_BMP</code></dt>
+ * <dd>Windows BMP file format, no compression</dd>
+ * <dt><code>IMAGE_BMP_RLE</code></dt>
+ * <dd>Windows BMP file format, RLE compression if appropriate</dd>
+ * <dt><code>IMAGE_GIF</code></dt>
+ * <dd>GIF file format</dd>
+ * <dt><code>IMAGE_ICO</code></dt>
+ * <dd>Windows ICO file format</dd>
+ * <dt><code>IMAGE_JPEG</code></dt>
+ * <dd>JPEG file format</dd>
+ * <dt><code>IMAGE_PNG</code></dt>
+ * <dd>PNG file format</dd>
+ * </dl>
+ *
+ * @param stream the output stream to write the images to
+ * @param format the format to write the images in
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the stream is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_IO - if an IO error occurs while writing to the stream</li>
+ *    <li>ERROR_INVALID_IMAGE - if the image data contains invalid data</li>
+ *    <li>ERROR_UNSUPPORTED_FORMAT - if the image data cannot be saved to the requested format</li>
+ * </ul>
+ */
+public void save(OutputStream stream, int format) {
+	if (stream == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	FileFormat.save(stream, format, this);
+}
+
+/**
+ * Saves the image data in this ImageLoader to a file with the specified name.
+ * The format parameter can have one of the following values:
+ * <dl>
+ * <dt><code>IMAGE_BMP</code></dt>
+ * <dd>Windows BMP file format, no compression</dd>
+ * <dt><code>IMAGE_BMP_RLE</code></dt>
+ * <dd>Windows BMP file format, RLE compression if appropriate</dd>
+ * <dt><code>IMAGE_GIF</code></dt>
+ * <dd>GIF file format</dd>
+ * <dt><code>IMAGE_ICO</code></dt>
+ * <dd>Windows ICO file format</dd>
+ * <dt><code>IMAGE_JPEG</code></dt>
+ * <dd>JPEG file format</dd>
+ * <dt><code>IMAGE_PNG</code></dt>
+ * <dd>PNG file format</dd>
+ * </dl>
+ *
+ * @param filename the name of the file to write the images to
+ * @param format the format to write the images in
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the file name is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_IO - if an IO error occurs while writing to the file</li>
+ *    <li>ERROR_INVALID_IMAGE - if the image data contains invalid data</li>
+ *    <li>ERROR_UNSUPPORTED_FORMAT - if the image data cannot be saved to the requested format</li>
+ * </ul>
+ */
+public void save(String filename, int format) {
+	if (filename == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	OutputStream stream = null;
+	try {
+		stream = Compatibility.newFileOutputStream(filename);
+	} catch (IOException e) {
+		SWT.error(SWT.ERROR_IO, e);
+	}
+	save(stream, format);
+	try {
+		stream.close();
+	} catch (IOException e) {
+	}
+}
+
+/**	 
+ * Adds the listener to the collection of listeners who will be
+ * notified when image data is either partially or completely loaded.
+ * <p>
+ * An ImageLoaderListener should be added before invoking
+ * one of the receiver's load methods. The listener's 
+ * <code>imageDataLoaded</code> method is called when image
+ * data has been partially loaded, as is supported by interlaced
+ * GIF/PNG or progressive JPEG images.
+ *
+ * @param listener the listener which should be notified
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * 
+ * @see ImageLoaderListener
+ * @see ImageLoaderEvent
+ */
+public void addImageLoaderListener(ImageLoaderListener listener) {
+	if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+	if (imageLoaderListeners == null) {
+		imageLoaderListeners = new Vector();
+	}
+	imageLoaderListeners.addElement(listener);
+}
+
+/**	 
+ * Removes the listener from the collection of listeners who will be
+ * notified when image data is either partially or completely loaded.
+ *
+ * @param listener the listener which should no longer be notified
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * 
+ * @see #addImageLoaderListener(ImageLoaderListener)
+ */
+public void removeImageLoaderListener(ImageLoaderListener listener) {
+	if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+	if (imageLoaderListeners == null) return;
+	imageLoaderListeners.removeElement(listener);
+}
+
+/**	 
+ * Returns <code>true</code> if the receiver has image loader
+ * listeners, and <code>false</code> otherwise.
+ *
+ * @return <code>true</code> if there are <code>ImageLoaderListener</code>s, and <code>false</code> otherwise
+ *
+ * @see #addImageLoaderListener(ImageLoaderListener)
+ * @see #removeImageLoaderListener(ImageLoaderListener)
+ */
+public boolean hasListeners() {
+	return imageLoaderListeners != null && imageLoaderListeners.size() > 0;
+}
+
+/**	 
+ * Notifies all image loader listeners that an image loader event
+ * has occurred. Pass the specified event object to each listener.
+ *
+ * @param event the <code>ImageLoaderEvent</code> to send to each <code>ImageLoaderListener</code>
+ */
+public void notifyListeners(ImageLoaderEvent event) {
+	if (!hasListeners()) return;
+	int size = imageLoaderListeners.size();
+	for (int i = 0; i < size; i++) {
+		ImageLoaderListener listener = (ImageLoaderListener) imageLoaderListeners.elementAt(i);
+		listener.imageDataLoaded(event);
+	}
+}
+
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/ImageLoaderEvent.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/ImageLoaderEvent.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/ImageLoaderEvent.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,87 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.graphics;
+
+
+import org.eclipse.swt.internal.SWTEventObject;
+
+/**
+ * Instances of this class are sent as a result of the incremental
+ * loading of image data.
+ * <p>
+ * <b>Notes:</b>
+ * </p><ul>
+ * <li>The number of events which will be sent when loading images
+ * is not constant. It varies by image type, and for JPEG images it 
+ * varies from image to image.</li>
+ * <li>For image sources which contain multiple images, the 
+ * <code>endOfImage</code> flag in the event will be set to true
+ * after each individual image is loaded.</li>
+ * </ul>
+ * 
+ * @see ImageLoader
+ * @see ImageLoaderListener
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+
+public class ImageLoaderEvent extends SWTEventObject {
+	
+	/**
+	 * if the <code>endOfImage</code> flag is false, then this is a
+	 * partially complete copy of the current <code>ImageData</code>,
+	 * otherwise this is a completely loaded <code>ImageData</code>
+	 */
+	public ImageData imageData;
+
+	/**
+	 * the zero-based count of image data increments -- this is
+	 * equivalent to the number of events that have been generated
+	 * while loading a particular image
+	 */
+	public int incrementCount;
+
+	/**
+	 * If this flag is true, then the current image data has been
+	 * completely loaded, otherwise the image data is only partially
+	 * loaded, and further ImageLoader events will occur unless an
+	 * exception is thrown
+	 */
+	public boolean endOfImage;
+	
+	static final long serialVersionUID = 3257284738325558065L;
+	
+/**
+ * Constructs a new instance of this class given the event source and
+ * the values to store in its fields.
+ *
+ * @param source the ImageLoader that was loading when the event occurred
+ * @param imageData the image data for the event
+ * @param incrementCount the image data increment for the event
+ * @param endOfImage the end of image flag for the event
+ */
+public ImageLoaderEvent(ImageLoader source, ImageData imageData, int incrementCount, boolean endOfImage) {
+	super(source);
+	this.imageData = imageData;
+	this.incrementCount = incrementCount;
+	this.endOfImage = endOfImage;
+}
+
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the event
+ */
+public String toString () {
+	return "ImageLoaderEvent {source=" + source + " imageData=" + imageData + " incrementCount=" + incrementCount + " endOfImage=" + endOfImage + "}"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+}
+
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/ImageLoaderListener.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/ImageLoaderListener.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/ImageLoaderListener.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.graphics;
+
+
+import org.eclipse.swt.internal.SWTEventListener;
+
+/**
+ * Classes which implement this interface provide methods
+ * that deal with the incremental loading of image data. 
+ * <p>
+ * After creating an instance of a class that implements
+ * this interface it can be added to an image loader using the
+ * <code>addImageLoaderListener</code> method and removed using
+ * the <code>removeImageLoaderListener</code> method. When
+ * image data is either partially or completely loaded, this
+ * method will be invoked.
+ * </p>
+ *
+ * @see ImageLoader
+ * @see ImageLoaderEvent
+ */
+
+public interface ImageLoaderListener extends SWTEventListener {
+
+/**
+ * Sent when image data is either partially or completely loaded.
+ * <p>
+ * The timing of when this method is called varies depending on
+ * the format of the image being loaded.
+ * </p>
+ *
+ * @param e an event containing information about the image loading operation
+ */
+public void imageDataLoaded(ImageLoaderEvent e);
+
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/LineAttributes.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/LineAttributes.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/LineAttributes.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,122 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.graphics;
+
+import org.eclipse.swt.*;
+
+/**
+ * <code>LineAttributes</code> defines a set of line attributes that
+ * can be modified in a GC.
+ * <p>
+ * Application code does <em>not</em> need to explicitly release the
+ * resources managed by each instance when those instances are no longer
+ * required, and thus no <code>dispose()</code> method is provided.
+ * </p>
+ * 
+ * @see GC#getLineAttributes()
+ * @see GC#setLineAttributes(LineAttributes)
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ *  
+ * @since 3.3
+ */
+public class LineAttributes {
+
+	/**
+	 * The line width.
+	 */
+	public float width;
+
+	/**
+	 * The line style.
+	 * 
+	 * @see org.eclipse.swt.SWT#LINE_CUSTOM
+	 * @see org.eclipse.swt.SWT#LINE_DASH
+	 * @see org.eclipse.swt.SWT#LINE_DASHDOT
+	 * @see org.eclipse.swt.SWT#LINE_DASHDOTDOT
+	 * @see org.eclipse.swt.SWT#LINE_DOT
+	 * @see org.eclipse.swt.SWT#LINE_SOLID
+	 */
+	public int style;
+
+	/**
+	 * The line cap style.
+	 * 
+	 * @see org.eclipse.swt.SWT#CAP_FLAT
+	 * @see org.eclipse.swt.SWT#CAP_ROUND
+	 * @see org.eclipse.swt.SWT#CAP_SQUARE
+	 */
+	public int cap;
+
+	/**
+	 * The line join style.
+	 * 
+	 * @see org.eclipse.swt.SWT#JOIN_BEVEL
+	 * @see org.eclipse.swt.SWT#JOIN_MITER
+	 * @see org.eclipse.swt.SWT#JOIN_ROUND
+	 */
+	public int join;
+
+	/**
+	 * The line dash style for SWT.LINE_CUSTOM.
+	 */
+	public float[] dash;
+
+	/**
+	 * The line dash style offset for SWT.LINE_CUSTOM.
+	 */
+	public float dashOffset;
+
+	/**
+	 * The line miter limit.
+	 */
+	public float miterLimit;
+
+/** 
+ * Create a new line attributes with the specified line width.
+ *
+ * @param width the line width
+ */
+public LineAttributes(float width) {
+	this(width, SWT.CAP_FLAT, SWT.JOIN_MITER, SWT.LINE_SOLID, null, 0, 10);
+}
+	
+/** 
+ * Create a new line attributes with the specified line cap, join and width.
+ *
+ * @param width the line width
+ * @param cap the line cap style
+ * @param join the line join style
+ */
+public LineAttributes(float width, int cap, int join) {
+	this(width, cap, join, SWT.LINE_SOLID, null, 0, 10);
+}
+
+/** 
+ * Create a new line attributes with the specified arguments.
+ *
+ * @param width the line width
+ * @param cap the line cap style
+ * @param join the line join style
+ * @param style the line style
+ * @param dash the line dash style
+ * @param dashOffset the line dash style offset
+ * @param miterLimit the line miter limit
+ */
+public LineAttributes(float width, int cap, int join, int style, float[] dash, float dashOffset, float miterLimit) {
+	this.width = width;
+	this.cap = cap;
+	this.join = join;
+	this.style = style;
+	this.dash = dash;
+	this.dashOffset = dashOffset;
+	this.miterLimit = miterLimit;
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/PaletteData.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/PaletteData.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/PaletteData.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,214 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.graphics;
+
+
+import org.eclipse.swt.*;
+
+/**
+ * Instances of this class describe the color data used by an image.
+ * <p>
+ * Depending on the depth of the image, the PaletteData can take one
+ * of two forms, indicated by the isDirect field:
+ * </p>
+ * <dl>
+ * <dt>
+ * <em>isDirect is false</em>
+ * </dt>
+ * <dd>
+ * If isDirect is <code>false</code>, this palette is an indexed
+ * palette which maps pixel values to RGBs. The actual RGB values
+ * may be retrieved by using the getRGBs() method.
+ * </dd>
+ * <dt>
+ * <em>isDirect is true</em>
+ * </dt>
+ * <dd>
+ * If isDirect is <code>true</code>, this palette is a direct color
+ * palette. Instead of containing RGB values, it contains red,
+ * green and blue mask and shift information which indicates how
+ * the color components may be extracted from a given pixel.
+ * This means that the RGB value is actually encoded in the pixel value.
+ * <p>
+ * In this case, the shift data is the number of bits required to shift
+ * the RGB value to the left in order to align the high bit of the
+ * corresponding mask with the high bit of the first byte. This number
+ * may be negative, so care must be taken when shifting. For example,
+ * with a red mask of 0xFF0000, the red shift would be -16. With a red
+ * mask of 0x1F, the red shift would be 3.
+ * </p>
+ * </dd>
+ * </dl>
+ *
+ * @see Image
+ * @see RGB
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+ 
+public final class PaletteData {
+	
+	/**
+	 * true if the receiver is a direct palette, 
+	 * and false otherwise
+	 */
+	public boolean isDirect;
+	
+	/**
+	 * the RGB values for an indexed palette, where the
+	 * indices of the array correspond to pixel values
+	 */
+	public RGB[] colors;
+	
+	/**
+	 * the red mask for a direct palette
+	 */
+	public int redMask;
+	
+	/**
+	 * the green mask for a direct palette
+	 */
+	public int greenMask;
+	
+	/**
+	 * the blue mask for a direct palette
+	 */
+	public int blueMask;
+	
+	/**
+	 * the red shift for a direct palette
+	 */
+	public int redShift;
+	
+	/**
+	 * the green shift for a direct palette
+	 */
+	public int greenShift;
+	
+	/**
+	 * the blue shift for a direct palette
+	 */
+	public int blueShift;
+
+/**
+ * Constructs a new indexed palette given an array of RGB values.
+ *
+ * @param colors the array of <code>RGB</code>s for the palette
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the argument is null</li>
+ * </ul>
+ */
+public PaletteData(RGB[] colors) {
+	if (colors == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	this.colors = colors;
+	this.isDirect = false;
+}
+
+/**
+ * Constructs a new direct palette given the red, green and blue masks.
+ *
+ * @param redMask the red mask
+ * @param greenMask the green mask
+ * @param blueMask the blue mask
+ */
+public PaletteData(int redMask, int greenMask, int blueMask) {
+	this.redMask = redMask;
+	this.greenMask = greenMask;
+	this.blueMask = blueMask;
+	this.isDirect = true;
+	this.redShift = shiftForMask(redMask);
+	this.greenShift = shiftForMask(greenMask);
+	this.blueShift = shiftForMask(blueMask);
+}
+
+/**
+ * Returns the pixel value corresponding to the given <code>RGB</code>.
+ *
+ * @param rgb the RGB to get the pixel value for
+ * @return the pixel value for the given RGB
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the argument is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the RGB is not found in the palette</li>
+ * </ul>
+ */
+public int getPixel(RGB rgb) {
+	if (rgb == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	if (isDirect) {
+		int pixel = 0;
+		pixel |= (redShift < 0 ? rgb.red << -redShift : rgb.red >>> redShift) & redMask;
+		pixel |= (greenShift < 0 ? rgb.green << -greenShift : rgb.green >>> greenShift) & greenMask;
+		pixel |= (blueShift < 0 ? rgb.blue << -blueShift : rgb.blue >>> blueShift) & blueMask;
+		return pixel;
+	} else {
+		for (int i = 0; i < colors.length; i++) {
+			if (colors[i].equals(rgb)) return i;
+		}
+		/* The RGB did not exist in the palette */
+		SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+		return 0;
+	}
+}
+
+/**
+ * Returns an <code>RGB</code> corresponding to the given pixel value.
+ *
+ * @param pixel the pixel to get the RGB value for
+ * @return the RGB value for the given pixel
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the argument is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the pixel does not exist in the palette</li>
+ * </ul>
+ */
+public RGB getRGB(int pixel) {
+	if (isDirect) {
+		int r = pixel & redMask;
+		r = (redShift < 0) ? r >>> -redShift : r << redShift;
+		int g = pixel & greenMask;
+		g = (greenShift < 0) ? g >>> -greenShift : g << greenShift;
+		int b = pixel & blueMask;
+		b = (blueShift < 0) ? b >>> -blueShift : b << blueShift;
+		return new RGB(r, g, b);
+	} else {
+		if (pixel < 0 || pixel >= colors.length) {
+			SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+		}
+		return colors[pixel];
+	}
+}
+
+/**
+ * Returns all the RGB values in the receiver if it is an
+ * indexed palette, or null if it is a direct palette.
+ *
+ * @return the <code>RGB</code>s for the receiver or null
+ */
+public RGB[] getRGBs() {
+	return colors;
+}
+
+/**
+ * Computes the shift value for a given mask.
+ *
+ * @param mask the mask to compute the shift for
+ * @return the shift amount
+ *
+ * @see PaletteData
+ */
+int shiftForMask(int mask) {
+	for (int i = 31; i >= 0; i--) { 
+		if (((mask >> i) & 0x1) != 0) return 7 - i;
+	}
+	return 32;
+}
+
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/Path.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/Path.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/Path.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,700 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.graphics;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.cairo.*;
+
+/**
+ * Instances of this class represent paths through the two-dimensional
+ * coordinate system. Paths do not have to be continuous, and can be
+ * described using lines, rectangles, arcs, cubic or quadratic bezier curves,
+ * glyphs, or other paths.
+ * <p>
+ * Application code must explicitly invoke the <code>Path.dispose()</code> 
+ * method to release the operating system resources managed by each instance
+ * when those instances are no longer required.
+ * </p>
+ * <p>
+ * This class requires the operating system's advanced graphics subsystem
+ * which may not be available on some platforms.
+ * </p>
+ *
+ * @see <a href="http://www.eclipse.org/swt/snippets/#path">Path, Pattern snippets</a>
+ * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: GraphicsExample</a>
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ * 
+ * @since 3.1
+ */
+public class Path extends Resource {
+	
+	/**
+	 * the OS resource for the Path
+	 * (Warning: This field is platform dependent)
+	 * <p>
+	 * <b>IMPORTANT:</b> This field is <em>not</em> part of the SWT
+	 * public API. It is marked public only so that it can be shared
+	 * within the packages provided by SWT. It is not available on all
+	 * platforms and should never be accessed from application code.
+	 * </p>
+	 */
+	public int /*long*/ handle;
+	
+	boolean moved, closed = true;
+
+/**
+ * Constructs a new empty Path.
+ * <p>
+ * This operation requires the operating system's advanced
+ * graphics subsystem which may not be available on some
+ * platforms.
+ * </p>
+ * 
+ * @param device the device on which to allocate the path
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the device is null and there is no current device</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_NO_GRAPHICS_LIBRARY - if advanced graphics are not available</li>
+ * </ul>
+ * @exception SWTError <ul>
+ *    <li>ERROR_NO_HANDLES if a handle for the path could not be obtained</li>
+ * </ul>
+ * 
+ * @see #dispose()
+ */
+public Path (Device device) {
+	super(device);
+	this.device.checkCairo();
+	int /*long*/ surface = Cairo.cairo_image_surface_create(Cairo.CAIRO_FORMAT_ARGB32, 1, 1);
+	if (surface == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+	handle = Cairo.cairo_create(surface);
+	Cairo.cairo_surface_destroy(surface);
+	if (handle == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+	init();
+}
+
+/**
+ * Constructs a new Path that is a copy of <code>path</code>. If
+ * <code>flatness</code> is less than or equal to zero, an unflatten
+ * copy of the path is created. Otherwise, it specifies the maximum
+ * error between the path and its flatten copy. Smaller numbers give
+ * better approximation.
+ * <p>
+ * This operation requires the operating system's advanced
+ * graphics subsystem which may not be available on some
+ * platforms.
+ * </p>
+ * 
+ * @param device the device on which to allocate the path
+ * @param path the path to make a copy
+ * @param flatness the flatness value
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the device is null and there is no current device</li>
+ *    <li>ERROR_NULL_ARGUMENT - if the path is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the path has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_NO_GRAPHICS_LIBRARY - if advanced graphics are not available</li>
+ * </ul>
+ * @exception SWTError <ul>
+ *    <li>ERROR_NO_HANDLES if a handle for the path could not be obtained</li>
+ * </ul>
+ * 
+ * @see #dispose()
+ * @since 3.4
+ */
+public Path (Device device, Path path, float flatness) {
+	super(device);
+	if (path == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	if (path.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	int /*long*/ surface = Cairo.cairo_image_surface_create(Cairo.CAIRO_FORMAT_ARGB32, 1, 1);
+	if (surface == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+	handle = Cairo.cairo_create(surface);
+	Cairo.cairo_surface_destroy(surface);
+	if (handle == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+	int /*long*/ copy;
+	flatness = Math.max(0, flatness);
+	if (flatness == 0) {
+		copy = Cairo.cairo_copy_path(path.handle);		
+	} else {
+		double tolerance = Cairo.cairo_get_tolerance(path.handle);
+		Cairo.cairo_set_tolerance(path.handle, flatness);
+		copy = Cairo.cairo_copy_path_flat(path.handle);
+		Cairo.cairo_set_tolerance(path.handle, tolerance);
+	}
+	if (copy == 0) {
+		Cairo.cairo_destroy(handle);
+		SWT.error(SWT.ERROR_NO_HANDLES);
+	}
+	Cairo.cairo_append_path(handle, copy);
+	Cairo.cairo_path_destroy(copy);
+	init();
+}
+
+/**
+ * Constructs a new Path with the specifed PathData.
+ * <p>
+ * This operation requires the operating system's advanced
+ * graphics subsystem which may not be available on some
+ * platforms.
+ * </p>
+ * 
+ * @param device the device on which to allocate the path
+ * @param data the data for the path
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the device is null and there is no current device</li>
+ *    <li>ERROR_NULL_ARGUMENT - if the data is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_NO_GRAPHICS_LIBRARY - if advanced graphics are not available</li>
+ * </ul>
+ * @exception SWTError <ul>
+ *    <li>ERROR_NO_HANDLES if a handle for the path could not be obtained</li>
+ * </ul>
+ * 
+ * @see #dispose()
+ * @since 3.4
+ */
+public Path (Device device, PathData data) {
+	this(device);
+	if (data == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	init(data);
+}
+
+/**
+ * Adds to the receiver a circular or elliptical arc that lies within
+ * the specified rectangular area.
+ * <p>
+ * The resulting arc begins at <code>startAngle</code> and extends  
+ * for <code>arcAngle</code> degrees.
+ * Angles are interpreted such that 0 degrees is at the 3 o'clock
+ * position. A positive value indicates a counter-clockwise rotation
+ * while a negative value indicates a clockwise rotation.
+ * </p><p>
+ * The center of the arc is the center of the rectangle whose origin 
+ * is (<code>x</code>, <code>y</code>) and whose size is specified by the 
+ * <code>width</code> and <code>height</code> arguments. 
+ * </p><p>
+ * The resulting arc covers an area <code>width + 1</code> pixels wide
+ * by <code>height + 1</code> pixels tall.
+ * </p>
+ *
+ * @param x the x coordinate of the upper-left corner of the arc
+ * @param y the y coordinate of the upper-left corner of the arc
+ * @param width the width of the arc
+ * @param height the height of the arc
+ * @param startAngle the beginning angle
+ * @param arcAngle the angular extent of the arc, relative to the start angle
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void addArc(float x, float y, float width, float height, float startAngle, float arcAngle) {
+	if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	moved = true;
+	if (width == height) {
+		float angle = -startAngle * (float)Compatibility.PI / 180;
+		if (closed) Cairo.cairo_move_to(handle, (x + width / 2f) + width / 2f * Math.cos(angle), (y + height / 2f) + height / 2f * Math.sin(angle));
+		if (arcAngle >= 0) {
+			Cairo.cairo_arc_negative(handle, x + width / 2f, y + height / 2f, width / 2f, angle, -(startAngle + arcAngle) * (float)Compatibility.PI / 180);
+		} else {
+			Cairo.cairo_arc(handle, x + width / 2f, y + height / 2f, width / 2f, angle, -(startAngle + arcAngle) * (float)Compatibility.PI / 180);
+		}
+	} else {
+		Cairo.cairo_save(handle);
+		Cairo.cairo_translate(handle, x + width / 2f, y + height / 2f);
+		Cairo.cairo_scale(handle, width / 2f, height / 2f);
+		float angle = -startAngle * (float)Compatibility.PI / 180;
+		if (closed) Cairo.cairo_move_to(handle, Math.cos(angle), Math.sin(angle));
+		if (arcAngle >= 0) {
+			Cairo.cairo_arc_negative(handle, 0, 0, 1, angle, -(startAngle + arcAngle) * (float)Compatibility.PI / 180);
+		} else {
+			Cairo.cairo_arc(handle, 0, 0, 1, angle, -(startAngle + arcAngle) * (float)Compatibility.PI / 180);
+		}
+		Cairo.cairo_restore(handle);
+	}
+	closed = false;
+	if (Math.abs(arcAngle) >= 360) close();
+}
+
+/**
+ * Adds to the receiver the path described by the parameter.
+ *
+ * @param path the path to add to the receiver
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parameter is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the parameter has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void addPath(Path path) {
+	if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	if (path == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	if (path.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	moved = false;
+	int /*long*/ copy = Cairo.cairo_copy_path(path.handle);
+	if (copy == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+	Cairo.cairo_append_path(handle, copy);
+	Cairo.cairo_path_destroy(copy);
+	closed = path.closed;
+}
+
+/**
+ * Adds to the receiver the rectangle specified by x, y, width and height.
+ *
+ * @param x the x coordinate of the rectangle to add
+ * @param y the y coordinate of the rectangle to add
+ * @param width the width of the rectangle to add
+ * @param height the height of the rectangle to add
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void addRectangle(float x, float y, float width, float height) {
+	if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	moved = false;
+	Cairo.cairo_rectangle(handle, x, y, width, height);
+	closed = true;
+}
+
+/**
+ * Adds to the receiver the pattern of glyphs generated by drawing
+ * the given string using the given font starting at the point (x, y).
+ *
+ * @param string the text to use
+ * @param x the x coordinate of the starting point
+ * @param y the y coordinate of the starting point
+ * @param font the font to use
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the font is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the font has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void addString(String string, float x, float y, Font font) {
+	if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	if (font == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	if (font.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	moved = false;
+	GC.addCairoString(handle, string, x, y, font);
+	closed = true;
+}
+
+/**
+ * Closes the current sub path by adding to the receiver a line
+ * from the current point of the path back to the starting point
+ * of the sub path.
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void close() {
+	if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	Cairo.cairo_close_path(handle);
+	moved = false;
+	closed = true;
+}
+
+/**
+ * Returns <code>true</code> if the specified point is contained by
+ * the receiver and false otherwise.
+ * <p>
+ * If outline is <code>true</code>, the point (x, y) checked for containment in
+ * the receiver's outline. If outline is <code>false</code>, the point is
+ * checked to see if it is contained within the bounds of the (closed) area
+ * covered by the receiver.
+ *
+ * @param x the x coordinate of the point to test for containment
+ * @param y the y coordinate of the point to test for containment
+ * @param gc the GC to use when testing for containment
+ * @param outline controls whether to check the outline or contained area of the path
+ * @return <code>true</code> if the path contains the point and <code>false</code> otherwise
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the gc is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the gc has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public boolean contains(float x, float y, GC gc, boolean outline) {
+	if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	if (gc == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	if (gc.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	//TODO - see Windows
+	gc.initCairo();
+	gc.checkGC(GC.LINE_CAP | GC.LINE_JOIN | GC.LINE_STYLE | GC.LINE_WIDTH);
+	boolean result = false;
+	int /*long*/ cairo = gc.data.cairo;
+	int /*long*/ copy = Cairo.cairo_copy_path(handle);
+	if (copy == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+	Cairo.cairo_append_path(cairo, copy);
+	Cairo.cairo_path_destroy(copy);
+	if (outline) {
+		result = Cairo.cairo_in_stroke(cairo, x, y) != 0;		
+	} else {
+		result = Cairo.cairo_in_fill(cairo, x, y) != 0;
+	}
+	Cairo.cairo_new_path(cairo);
+	return result;
+}
+
+/**
+ * Adds to the receiver a cubic bezier curve based on the parameters.
+ *
+ * @param cx1 the x coordinate of the first control point of the spline
+ * @param cy1 the y coordinate of the first control of the spline
+ * @param cx2 the x coordinate of the second control of the spline
+ * @param cy2 the y coordinate of the second control of the spline
+ * @param x the x coordinate of the end point of the spline
+ * @param y the y coordinate of the end point of the spline
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void cubicTo(float cx1, float cy1, float cx2, float cy2, float x, float y) {
+	if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	if (!moved) {
+		double[] currentX = new double[1], currentY = new double[1];
+		Cairo.cairo_get_current_point(handle, currentX, currentY);
+		Cairo.cairo_move_to(handle, currentX[0], currentY[0]);
+		moved = true;
+	}
+	Cairo.cairo_curve_to(handle, cx1, cy1, cx2, cy2, x, y);
+	closed = false;
+}
+
+/**
+ * Replaces the first four elements in the parameter with values that
+ * describe the smallest rectangle that will completely contain the
+ * receiver (i.e. the bounding box).
+ *
+ * @param bounds the array to hold the result
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parameter is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the parameter is too small to hold the bounding box</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void getBounds(float[] bounds) {
+	if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	if (bounds == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	if (bounds.length < 4) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	int /*long*/ copy = Cairo.cairo_copy_path(handle);
+	if (copy == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+	cairo_path_t path = new cairo_path_t();
+	Cairo.memmove(path, copy, cairo_path_t.sizeof);
+	double minX = 0, minY = 0, maxX = 0, maxY = 0;
+	if (path.num_data > 0) {
+		minX = minY = Double.POSITIVE_INFINITY;
+		maxX = maxY = Double.NEGATIVE_INFINITY;
+		int i = 0;
+		double[] points = new double[6]; 
+		cairo_path_data_t data = new cairo_path_data_t();
+		while (i < path.num_data) {
+			int /*long*/ offset = path.data + i * cairo_path_data_t.sizeof;
+			Cairo.memmove(data, offset, cairo_path_data_t.sizeof);
+			switch (data.type) {
+				case Cairo.CAIRO_PATH_MOVE_TO:
+					Cairo.memmove(points, offset + cairo_path_data_t.sizeof, cairo_path_data_t.sizeof);
+					minX = Math.min(minX, points[0]);
+					minY = Math.min(minY, points[1]);
+					maxX = Math.max(maxX, points[0]);
+					maxY = Math.max(maxY, points[1]);
+					break;
+				case Cairo.CAIRO_PATH_LINE_TO:
+					Cairo.memmove(points, offset + cairo_path_data_t.sizeof, cairo_path_data_t.sizeof);
+					minX = Math.min(minX, points[0]);
+					minY = Math.min(minY, points[1]);
+					maxX = Math.max(maxX, points[0]);
+					maxY = Math.max(maxY, points[1]);
+					break;
+				case Cairo.CAIRO_PATH_CURVE_TO:
+					Cairo.memmove(points, offset + cairo_path_data_t.sizeof, cairo_path_data_t.sizeof * 3);
+					minX = Math.min(minX, points[0]);
+					minY = Math.min(minY, points[1]);
+					maxX = Math.max(maxX, points[0]);
+					maxY = Math.max(maxY, points[1]);
+					minX = Math.min(minX, points[2]);
+					minY = Math.min(minY, points[3]);
+					maxX = Math.max(maxX, points[2]);
+					maxY = Math.max(maxY, points[3]);
+					minX = Math.min(minX, points[4]);
+					minY = Math.min(minY, points[5]);
+					maxX = Math.max(maxX, points[4]);
+					maxY = Math.max(maxY, points[5]);
+					break;
+				case Cairo.CAIRO_PATH_CLOSE_PATH: break;
+			}
+			i += data.length;
+		}
+	}
+	bounds[0] = (float)minX;
+	bounds[1] = (float)minY;
+	bounds[2] = (float)(maxX - minX);
+	bounds[3] = (float)(maxY - minY);
+	Cairo.cairo_path_destroy(copy);
+}
+
+/**
+ * Replaces the first two elements in the parameter with values that
+ * describe the current point of the path.
+ *
+ * @param point the array to hold the result
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parameter is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the parameter is too small to hold the end point</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void getCurrentPoint(float[] point) {
+	if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	if (point == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	if (point.length < 2) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	double[] x = new double[1], y = new double[1];
+	Cairo.cairo_get_current_point(handle, x, y);
+	point[0] = (float)x[0];
+	point[1] = (float)y[0];
+}
+
+/**
+ * Returns a device independent representation of the receiver.
+ * 
+ * @return the PathData for the receiver
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @see PathData
+ */
+public PathData getPathData() {
+	if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	int /*long*/ copy = Cairo.cairo_copy_path(handle);
+	if (copy == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+	cairo_path_t path = new cairo_path_t();
+	Cairo.memmove(path, copy, cairo_path_t.sizeof);
+	byte[] types = new byte[path.num_data];
+	float[] pts = new float[path.num_data * 6];
+	int typeIndex = 0, ptsIndex = 0;
+	if (path.num_data > 0) {
+		int i = 0;
+		double[] points = new double[6]; 
+		cairo_path_data_t data = new cairo_path_data_t();
+		while (i < path.num_data) {
+			int /*long*/ offset = path.data + i * cairo_path_data_t.sizeof;
+			Cairo.memmove(data, offset, cairo_path_data_t.sizeof);
+			switch (data.type) {
+				case Cairo.CAIRO_PATH_MOVE_TO:
+					types[typeIndex++] = SWT.PATH_MOVE_TO;
+					Cairo.memmove(points, offset + cairo_path_data_t.sizeof, cairo_path_data_t.sizeof);
+					pts[ptsIndex++] = (float)points[0];
+					pts[ptsIndex++] = (float)points[1];
+					break;
+				case Cairo.CAIRO_PATH_LINE_TO:
+					types[typeIndex++] = SWT.PATH_LINE_TO;
+					Cairo.memmove(points, offset + cairo_path_data_t.sizeof, cairo_path_data_t.sizeof);
+					pts[ptsIndex++] = (float)points[0];
+					pts[ptsIndex++] = (float)points[1];
+					break;
+				case Cairo.CAIRO_PATH_CURVE_TO:
+					types[typeIndex++] = SWT.PATH_CUBIC_TO;
+					Cairo.memmove(points, offset + cairo_path_data_t.sizeof, cairo_path_data_t.sizeof * 3);
+					pts[ptsIndex++] = (float)points[0];
+					pts[ptsIndex++] = (float)points[1];
+					pts[ptsIndex++] = (float)points[2];
+					pts[ptsIndex++] = (float)points[3];
+					pts[ptsIndex++] = (float)points[4];
+					pts[ptsIndex++] = (float)points[5];
+					break;
+				case Cairo.CAIRO_PATH_CLOSE_PATH:
+					types[typeIndex++] = SWT.PATH_CLOSE;
+					break;
+			}
+			i += data.length;
+		}
+	}
+	if (typeIndex != types.length) {
+		byte[] newTypes = new byte[typeIndex];
+		System.arraycopy(types, 0, newTypes, 0, typeIndex);
+		types = newTypes;
+	}
+	if (ptsIndex != pts.length) {
+		float[] newPts = new float[ptsIndex];
+		System.arraycopy(pts, 0, newPts, 0, ptsIndex);
+		pts = newPts;
+	}
+	Cairo.cairo_path_destroy(copy);
+	PathData result = new PathData();
+	result.types = types;
+	result.points = pts;
+	return result;
+}
+
+/**
+ * Adds to the receiver a line from the current point to
+ * the point specified by (x, y).
+ *
+ * @param x the x coordinate of the end of the line to add
+ * @param y the y coordinate of the end of the line to add
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void lineTo(float x, float y) {
+	if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	if (!moved) {
+		double[] currentX = new double[1], currentY = new double[1];
+		Cairo.cairo_get_current_point(handle, currentX, currentY);
+		Cairo.cairo_move_to(handle, currentX[0], currentY[0]);
+		moved = true;
+	}
+	Cairo.cairo_line_to(handle, x, y);
+	closed = false;
+}
+
+/**
+ * Sets the current point of the receiver to the point
+ * specified by (x, y). Note that this starts a new
+ * sub path.
+ *
+ * @param x the x coordinate of the new end point
+ * @param y the y coordinate of the new end point
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void moveTo(float x, float y) {
+	if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	/*
+	* Bug in Cairo.  If cairo_move_to() is not called at the
+	* begining of a subpath, the first cairo_line_to() or
+	* cairo_curve_to() segment do not output anything.  The fix
+	* is to detect that the app did not call cairo_move_to()
+	* before those calls and call it explicitly. 
+	*/
+	moved = true;
+	Cairo.cairo_move_to(handle, x, y);
+	closed = true;
+}
+
+/**
+ * Adds to the receiver a quadratic curve based on the parameters.
+ *
+ * @param cx the x coordinate of the control point of the spline
+ * @param cy the y coordinate of the control point of the spline
+ * @param x the x coordinate of the end point of the spline
+ * @param y the y coordinate of the end point of the spline
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void quadTo(float cx, float cy, float x, float y) {
+	if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	double[] currentX = new double[1], currentY = new double[1];
+	Cairo.cairo_get_current_point(handle, currentX, currentY);
+	if (!moved) {
+		Cairo.cairo_move_to(handle, currentX[0], currentY[0]);
+		moved = true;
+	}
+	float x0 = (float)currentX[0];
+	float y0 = (float)currentY[0];
+	float cx1 = x0 + 2 * (cx - x0) / 3;
+	float cy1 = y0 + 2 * (cy - y0) / 3;
+	float cx2 = cx1 + (x - x0) / 3;
+	float cy2 = cy1 + (y - y0) / 3;
+	Cairo.cairo_curve_to(handle, cx1, cy1, cx2, cy2, x, y);
+	closed = false;
+}
+
+void destroy() {
+	Cairo.cairo_destroy(handle);
+	handle = 0;
+}
+
+void init(PathData data) {
+	byte[] types = data.types;
+	float[] points = data.points;
+	for (int i = 0, j = 0; i < types.length; i++) {
+		switch (types[i]) {
+			case SWT.PATH_MOVE_TO:
+				moveTo(points[j++], points[j++]);
+				break;
+			case SWT.PATH_LINE_TO:
+				lineTo(points[j++], points[j++]);
+				break;
+			case SWT.PATH_CUBIC_TO:
+				cubicTo(points[j++], points[j++], points[j++], points[j++], points[j++], points[j++]);
+				break;
+			case SWT.PATH_QUAD_TO:
+				quadTo(points[j++], points[j++], points[j++], points[j++]);
+				break;
+			case SWT.PATH_CLOSE:
+				close();
+				break;
+			default:
+				dispose();
+				SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+		}
+	}
+}
+
+/**
+ * Returns <code>true</code> if the Path has been disposed,
+ * and <code>false</code> otherwise.
+ * <p>
+ * This method gets the dispose state for the Path.
+ * When a Path has been disposed, it is an error to
+ * invoke any other method using the Path.
+ *
+ * @return <code>true</code> when the Path is disposed, and <code>false</code> otherwise
+ */
+public boolean isDisposed() {
+	return handle == 0;
+}
+
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the receiver
+ */
+public String toString() {
+	if (isDisposed()) return "Path {*DISPOSED*}";
+	return "Path {" + handle + "}";
+}
+
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/PathData.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/PathData.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/PathData.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.graphics;
+
+
+/**
+ * Instances of this class describe device-independent paths.
+ *
+ * @see Path
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ * 
+ * @since 3.1
+ */
+public final class PathData {
+	
+	/**
+	 * The type of each point. 
+	 */
+	public byte[] types;
+	
+	/**
+	 * The points of a path.
+	 */
+	public float[] points;
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/Pattern.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/Pattern.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/Pattern.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,205 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.graphics;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.cairo.*;
+
+/**
+ * Instances of this class represent patterns to use while drawing. Patterns
+ * can be specified either as bitmaps or gradients.
+ * <p>
+ * Application code must explicitly invoke the <code>Pattern.dispose()</code> 
+ * method to release the operating system resources managed by each instance
+ * when those instances are no longer required.
+ * </p>
+ * <p>
+ * This class requires the operating system's advanced graphics subsystem
+ * which may not be available on some platforms.
+ * </p>
+ * 
+ * @see <a href="http://www.eclipse.org/swt/snippets/#path">Path, Pattern snippets</a>
+ * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: GraphicsExample</a>
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ *
+ * @since 3.1
+ */
+public class Pattern extends Resource {
+
+	/**
+	 * the OS resource for the Pattern
+	 * (Warning: This field is platform dependent)
+	 * <p>
+	 * <b>IMPORTANT:</b> This field is <em>not</em> part of the SWT
+	 * public API. It is marked public only so that it can be shared
+	 * within the packages provided by SWT. It is not available on all
+	 * platforms and should never be accessed from application code.
+	 * </p>
+	 */
+	public int /*long*/ handle;
+	
+	int /*long*/ surface;
+
+/**
+ * Constructs a new Pattern given an image. Drawing with the resulting
+ * pattern will cause the image to be tiled over the resulting area.
+ * <p>
+ * This operation requires the operating system's advanced
+ * graphics subsystem which may not be available on some
+ * platforms.
+ * </p>
+ * 
+ * @param device the device on which to allocate the pattern
+ * @param image the image that the pattern will draw
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the device is null and there is no current device, or the image is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_NO_GRAPHICS_LIBRARY - if advanced graphics are not available</li>
+ * </ul>
+ * @exception SWTError <ul>
+ *    <li>ERROR_NO_HANDLES if a handle for the pattern could not be obtained</li>
+ * </ul>
+ * 
+ * @see #dispose()
+ */
+public Pattern(Device device, Image image) {
+	super(device);
+	if (image == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	if (image.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	this.device.checkCairo();
+	image.createSurface();
+	handle = Cairo.cairo_pattern_create_for_surface(image.surface);
+	if (handle == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+	Cairo.cairo_pattern_set_extend(handle, Cairo.CAIRO_EXTEND_REPEAT);
+	surface = image.surface;
+	init();
+}
+
+/**
+ * Constructs a new Pattern that represents a linear, two color
+ * gradient. Drawing with the pattern will cause the resulting area to be
+ * tiled with the gradient specified by the arguments.
+ * <p>
+ * This operation requires the operating system's advanced
+ * graphics subsystem which may not be available on some
+ * platforms.
+ * </p>
+ * 
+ * @param device the device on which to allocate the pattern
+ * @param x1 the x coordinate of the starting corner of the gradient
+ * @param y1 the y coordinate of the starting corner of the gradient
+ * @param x2 the x coordinate of the ending corner of the gradient
+ * @param y2 the y coordinate of the ending corner of the gradient
+ * @param color1 the starting color of the gradient
+ * @param color2 the ending color of the gradient
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the device is null and there is no current device, 
+ *                              or if either color1 or color2 is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if either color1 or color2 has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_NO_GRAPHICS_LIBRARY - if advanced graphics are not available</li>
+ * </ul>
+ * @exception SWTError <ul>
+ *    <li>ERROR_NO_HANDLES if a handle for the pattern could not be obtained</li>
+ * </ul>
+ * 
+ * @see #dispose()
+ */
+public Pattern(Device device, float x1, float y1, float x2, float y2, Color color1, Color color2) {
+	this(device, x1, y1, x2, y2, color1, 0xFF, color2, 0xFF);
+}
+/**
+ * Constructs a new Pattern that represents a linear, two color
+ * gradient. Drawing with the pattern will cause the resulting area to be
+ * tiled with the gradient specified by the arguments.
+ * <p>
+ * This operation requires the operating system's advanced
+ * graphics subsystem which may not be available on some
+ * platforms.
+ * </p>
+ * 
+ * @param device the device on which to allocate the pattern
+ * @param x1 the x coordinate of the starting corner of the gradient
+ * @param y1 the y coordinate of the starting corner of the gradient
+ * @param x2 the x coordinate of the ending corner of the gradient
+ * @param y2 the y coordinate of the ending corner of the gradient
+ * @param color1 the starting color of the gradient
+ * @param alpha1 the starting alpha value of the gradient
+ * @param color2 the ending color of the gradient
+ * @param alpha2 the ending alpha value of the gradient
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the device is null and there is no current device, 
+ *                              or if either color1 or color2 is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if either color1 or color2 has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_NO_GRAPHICS_LIBRARY - if advanced graphics are not available</li>
+ * </ul>
+ * @exception SWTError <ul>
+ *    <li>ERROR_NO_HANDLES if a handle for the pattern could not be obtained</li>
+ * </ul>
+ * 
+ * @see #dispose()
+ * 
+ * @since 3.2
+ */
+public Pattern(Device device, float x1, float y1, float x2, float y2, Color color1, int alpha1, Color color2, int alpha2) {
+	super(device);
+	if (color1 == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	if (color1.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	if (color2 == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	if (color2.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	this.device.checkCairo();
+	handle = Cairo.cairo_pattern_create_linear(x1, y1, x2, y2);
+	if (handle == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+	GC.setCairoPatternColor(handle, 0, color1, alpha1);
+	GC.setCairoPatternColor(handle, 1, color2, alpha2);
+	Cairo.cairo_pattern_set_extend(handle, Cairo.CAIRO_EXTEND_REPEAT);
+	init();
+}
+	
+void destroy() {
+	Cairo.cairo_pattern_destroy(handle);
+	handle = surface = 0;
+}
+
+/**
+ * Returns <code>true</code> if the Pattern has been disposed,
+ * and <code>false</code> otherwise.
+ * <p>
+ * This method gets the dispose state for the Pattern.
+ * When a Pattern has been disposed, it is an error to
+ * invoke any other method using the Pattern.
+ *
+ * @return <code>true</code> when the Pattern is disposed, and <code>false</code> otherwise
+ */
+public boolean isDisposed() {
+	return handle == 0;
+}
+
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the receiver
+ */
+public String toString() {
+	if (isDisposed()) return "Pattern {*DISPOSED*}";
+	return "Pattern {" + handle + "}";
+}
+	
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/Point.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/Point.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/Point.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,108 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.graphics;
+
+
+import org.eclipse.swt.internal.SerializableCompatibility;
+
+/**
+ * Instances of this class represent places on the (x, y)
+ * coordinate plane.
+ * <p>
+ * The coordinate space for rectangles and points is considered
+ * to have increasing values downward and to the right from its
+ * origin making this the normal, computer graphics oriented notion
+ * of (x, y) coordinates rather than the strict mathematical one.
+ * </p>
+ * <p>
+ * The hashCode() method in this class uses the values of the public
+ * fields to compute the hash value. When storing instances of the
+ * class in hashed collections, do not modify these fields after the
+ * object has been inserted.  
+ * </p>
+ * <p>
+ * Application code does <em>not</em> need to explicitly release the
+ * resources managed by each instance when those instances are no longer
+ * required, and thus no <code>dispose()</code> method is provided.
+ * </p>
+ *
+ * @see Rectangle
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+
+public final class Point implements SerializableCompatibility {
+	
+	/**
+	 * the x coordinate of the point
+	 */
+	public int x;
+	
+	/**
+	 * the y coordinate of the point
+	 */
+	public int y;
+	
+	static final long serialVersionUID = 3257002163938146354L;
+	
+/**
+ * Constructs a new point with the given x and y coordinates.
+ *
+ * @param x the x coordinate of the new point
+ * @param y the y coordinate of the new point
+ */
+public Point (int x, int y) {
+	this.x = x;
+	this.y = y;
+}
+
+/**
+ * Compares the argument to the receiver, and returns true
+ * if they represent the <em>same</em> object using a class
+ * specific comparison.
+ *
+ * @param object the object to compare with this object
+ * @return <code>true</code> if the object is the same as this object and <code>false</code> otherwise
+ *
+ * @see #hashCode()
+ */
+public boolean equals (Object object) {
+	if (object == this) return true;
+	if (!(object instanceof Point)) return false;
+	Point p = (Point)object;
+	return (p.x == this.x) && (p.y == this.y);
+}
+
+/**
+ * Returns an integer hash code for the receiver. Any two 
+ * objects that return <code>true</code> when passed to 
+ * <code>equals</code> must return the same value for this
+ * method.
+ *
+ * @return the receiver's hash
+ *
+ * @see #equals(Object)
+ */
+public int hashCode () {
+	return x ^ y;
+}
+
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the point
+ */
+public String toString () {
+	return "Point {" + x + ", " + y + "}"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+}
+
+}
+

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/RGB.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/RGB.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/RGB.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,226 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.graphics;
+
+import org.eclipse.swt.internal.SerializableCompatibility;
+import org.eclipse.swt.*;
+
+/**
+ * Instances of this class are descriptions of colors in
+ * terms of the primary additive color model (red, green and
+ * blue). A color may be described in terms of the relative
+ * intensities of these three primary colors. The brightness
+ * of each color is specified by a value in the range 0 to 255,
+ * where 0 indicates no color (blackness) and 255 indicates
+ * maximum intensity.
+ * <p>
+ * The hashCode() method in this class uses the values of the public
+ * fields to compute the hash value. When storing instances of the
+ * class in hashed collections, do not modify these fields after the
+ * object has been inserted.  
+ * </p>
+ * <p>
+ * Application code does <em>not</em> need to explicitly release the
+ * resources managed by each instance when those instances are no longer
+ * required, and thus no <code>dispose()</code> method is provided.
+ * </p>
+ *
+ * @see Color
+ * @see <a href="http://www.eclipse.org/swt/snippets/#color">Color and RGB snippets</a>
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+
+public final class RGB implements SerializableCompatibility {
+	
+	/**
+	 * the red component of the RGB
+	 */
+	public int red;
+	
+	/**
+	 * the green component of the RGB
+	 */
+	public int green;
+	
+	/**
+	 * the blue component of the RGB
+	 */
+	public int blue;
+	
+	static final long serialVersionUID = 3258415023461249074L;
+	
+/**
+ * Constructs an instance of this class with the given
+ * red, green and blue values.
+ *
+ * @param red the red component of the new instance
+ * @param green the green component of the new instance
+ * @param blue the blue component of the new instance
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the red, green or blue argument is not between 0 and 255</li>
+ * </ul>
+ */
+public RGB(int red, int green, int blue) {
+	if ((red > 255) || (red < 0) ||
+		(green > 255) || (green < 0) ||
+		(blue > 255) || (blue < 0))
+			SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	this.red = red;
+	this.green = green;
+	this.blue = blue;
+}
+
+/**
+* Constructs an instance of this class with the given
+* hue, saturation, and brightness.
+*
+* @param hue the hue value for the HSB color (from 0 to 360)
+* @param saturation the saturation value for the HSB color (from 0 to 1)
+* @param brightness the brightness value for the HSB color (from 0 to 1)
+*
+* @exception IllegalArgumentException <ul>
+*    <li>ERROR_INVALID_ARGUMENT - if the hue is not between 0 and 360 or
+*    the saturation or brightness is not between 0 and 1</li>
+* </ul>
+* 
+* @since 3.2
+*/
+public RGB(float hue, float saturation, float brightness) {
+	if (hue < 0 || hue > 360 || saturation < 0 || saturation > 1 || 
+		brightness < 0 || brightness > 1) {
+		SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	}
+	float r, g, b;
+	if (saturation == 0) {
+		r = g = b = brightness; 
+	} else {
+		if (hue == 360) hue = 0;
+		hue /= 60;	
+		int i = (int)hue;
+		float f = hue - i;
+		float p = brightness * (1 - saturation);
+		float q = brightness * (1 - saturation * f);
+		float t = brightness * (1 - saturation * (1 - f));
+		switch(i) {
+			case 0:
+				r = brightness;
+				g = t;
+				b = p;
+				break;
+			case 1:
+				r = q;
+				g = brightness;
+				b = p;
+				break;
+			case 2:
+				r = p;
+				g = brightness;
+				b = t;
+				break;
+			case 3:
+				r = p;
+				g = q;
+				b = brightness;
+				break;
+			case 4:
+				r = t;
+				g = p;
+				b = brightness;
+				break;
+			case 5:
+			default:
+				r = brightness;
+				g = p;
+				b = q;
+				break;
+		}
+	}
+	red = (int)(r * 255 + 0.5);
+	green = (int)(g * 255 + 0.5);
+	blue = (int)(b * 255 + 0.5);	
+}
+
+/**
+ * Returns the hue, saturation, and brightness of the color.
+ * 
+ * @return color space values in float format (hue, saturation, brightness)
+ *
+ * @since 3.2
+ */
+public float[] getHSB() {	
+	float r = red / 255f;
+	float g = green / 255f;
+	float b = blue / 255f;
+	float max = Math.max(Math.max(r, g), b);
+	float min = Math.min(Math.min(r, g), b);
+	float delta = max - min;
+	float hue = 0;
+	float brightness = max;
+	float saturation = max == 0 ? 0 : (max - min) / max;
+	if (delta != 0) {
+		if (r == max) {
+			hue = (g  - b) / delta;
+		} else {
+			if (g == max) {
+				hue = 2 + (b - r) / delta;	
+			} else {
+				hue = 4 + (r - g) / delta;
+			}
+		}
+		hue *= 60;
+		if (hue < 0) hue += 360;
+	}
+	return new float[] {hue, saturation, brightness};
+}	
+
+/**
+ * Compares the argument to the receiver, and returns true
+ * if they represent the <em>same</em> object using a class
+ * specific comparison.
+ *
+ * @param object the object to compare with this object
+ * @return <code>true</code> if the object is the same as this object and <code>false</code> otherwise
+ *
+ * @see #hashCode()
+ */
+public boolean equals(Object object) {
+	if (object == this) return true;
+	if (!(object instanceof RGB)) return false;
+	RGB rgb = (RGB)object;
+	return (rgb.red == this.red) && (rgb.green == this.green) && (rgb.blue == this.blue);
+}
+
+/**
+ * Returns an integer hash code for the receiver. Any two 
+ * objects that return <code>true</code> when passed to 
+ * <code>equals</code> must return the same value for this
+ * method.
+ *
+ * @return the receiver's hash
+ *
+ * @see #equals(Object)
+ */
+public int hashCode() {
+	return (blue << 16) | (green << 8) | red;
+}
+
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the <code>RGB</code>
+ */
+public String toString() {
+	return "RGB {" + red + ", " + green + ", " + blue + "}"; //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+}
+
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/Rectangle.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/Rectangle.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/Rectangle.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,346 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.graphics;
+
+
+import org.eclipse.swt.internal.SerializableCompatibility;
+import org.eclipse.swt.*;
+
+/**
+ * Instances of this class represent rectangular areas in an
+ * (x, y) coordinate system. The top left corner of the rectangle
+ * is specified by its x and y values, and the extent of the
+ * rectangle is specified by its width and height.
+ * <p>
+ * The coordinate space for rectangles and points is considered
+ * to have increasing values downward and to the right from its
+ * origin making this the normal, computer graphics oriented notion
+ * of (x, y) coordinates rather than the strict mathematical one.
+ * </p>
+ * <p>
+ * The hashCode() method in this class uses the values of the public
+ * fields to compute the hash value. When storing instances of the
+ * class in hashed collections, do not modify these fields after the
+ * object has been inserted.  
+ * </p>
+ * <p>
+ * Application code does <em>not</em> need to explicitly release the
+ * resources managed by each instance when those instances are no longer
+ * required, and thus no <code>dispose()</code> method is provided.
+ * </p>
+ *
+ * @see Point
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+
+public final class Rectangle implements SerializableCompatibility {
+	
+	/**
+	 * the x coordinate of the rectangle
+	 */
+	public int x;
+	
+	/**
+	 * the y coordinate of the rectangle
+	 */
+	public int y;
+	
+	/**
+	 * the width of the rectangle
+	 */
+	public int width;
+	
+	/**
+	 * the height of the rectangle
+	 */
+	public int height;
+
+	static final long serialVersionUID = 3256439218279428914L;
+	
+/**
+ * Construct a new instance of this class given the 
+ * x, y, width and height values.
+ *
+ * @param x the x coordinate of the origin of the rectangle
+ * @param y the y coordinate of the origin of the rectangle
+ * @param width the width of the rectangle
+ * @param height the height of the rectangle
+ */
+public Rectangle (int x, int y, int width, int height) {
+	this.x = x;
+	this.y = y;
+	this.width = width;
+	this.height = height;
+}
+
+/**
+ * Destructively replaces the x, y, width and height values
+ * in the receiver with ones which represent the union of the
+ * rectangles specified by the receiver and the given rectangle.
+ * <p>
+ * The union of two rectangles is the smallest single rectangle
+ * that completely covers both of the areas covered by the two
+ * given rectangles.
+ * </p>
+ *
+ * @param rect the rectangle to merge with the receiver
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the argument is null</li>
+ * </ul>
+ */
+public void add (Rectangle rect) {
+	if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	int left = x < rect.x ? x : rect.x;
+	int top = y < rect.y ? y : rect.y;
+	int lhs = x + width;
+	int rhs = rect.x + rect.width;
+	int right = lhs > rhs ? lhs : rhs;
+	lhs = y + height;
+	rhs = rect.y + rect.height;
+	int bottom = lhs > rhs ? lhs : rhs;
+	x = left;  y = top;  width = right - left;  height = bottom - top;
+}
+
+/**
+ * Returns <code>true</code> if the point specified by the
+ * arguments is inside the area specified by the receiver,
+ * and <code>false</code> otherwise.
+ *
+ * @param x the x coordinate of the point to test for containment
+ * @param y the y coordinate of the point to test for containment
+ * @return <code>true</code> if the rectangle contains the point and <code>false</code> otherwise
+ */
+public boolean contains (int x, int y) {
+	return (x >= this.x) && (y >= this.y) && ((x - this.x) < width) && ((y - this.y) < height);
+}
+
+/**
+ * Returns <code>true</code> if the given point is inside the
+ * area specified by the receiver, and <code>false</code>
+ * otherwise.
+ *
+ * @param pt the point to test for containment
+ * @return <code>true</code> if the rectangle contains the point and <code>false</code> otherwise
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the argument is null</li>
+ * </ul>
+ */
+public boolean contains (Point pt) {
+	if (pt == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	return contains(pt.x, pt.y);
+}
+
+/**
+ * Compares the argument to the receiver, and returns true
+ * if they represent the <em>same</em> object using a class
+ * specific comparison.
+ *
+ * @param object the object to compare with this object
+ * @return <code>true</code> if the object is the same as this object and <code>false</code> otherwise
+ *
+ * @see #hashCode()
+ */
+public boolean equals (Object object) {
+	if (object == this) return true;
+	if (!(object instanceof Rectangle)) return false;
+	Rectangle r = (Rectangle)object;
+	return (r.x == this.x) && (r.y == this.y) && (r.width == this.width) && (r.height == this.height);
+}
+
+/**
+ * Returns an integer hash code for the receiver. Any two 
+ * objects that return <code>true</code> when passed to 
+ * <code>equals</code> must return the same value for this
+ * method.
+ *
+ * @return the receiver's hash
+ *
+ * @see #equals(Object)
+ */
+public int hashCode () {
+	return x ^ y ^ width ^ height;
+}
+
+/**
+ * Destructively replaces the x, y, width and height values
+ * in the receiver with ones which represent the intersection of the
+ * rectangles specified by the receiver and the given rectangle.
+ *
+ * @param rect the rectangle to intersect with the receiver
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the argument is null</li>
+ * </ul>
+ * 
+ * since 3.0
+ */
+public void intersect (Rectangle rect) {
+	if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	if (this == rect) return;
+	int left = x > rect.x ? x : rect.x;
+	int top = y > rect.y ? y : rect.y;
+	int lhs = x + width;
+	int rhs = rect.x + rect.width;
+	int right = lhs < rhs ? lhs : rhs;
+	lhs = y + height;
+	rhs = rect.y + rect.height;
+	int bottom = lhs < rhs ? lhs : rhs;
+	x = right < left ? 0 : left;
+	y = bottom < top ? 0 : top;
+	width = right < left ? 0 : right - left;
+	height = bottom < top ? 0 : bottom - top;
+}
+
+/**
+ * Returns a new rectangle which represents the intersection
+ * of the receiver and the given rectangle. 
+ * <p>
+ * The intersection of two rectangles is the rectangle that
+ * covers the area which is contained within both rectangles.
+ * </p>
+ *
+ * @param rect the rectangle to intersect with the receiver
+ * @return the intersection of the receiver and the argument
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the argument is null</li>
+ * </ul>
+ */
+public Rectangle intersection (Rectangle rect) {
+	if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	if (this == rect) return new Rectangle (x, y, width, height);
+	int left = x > rect.x ? x : rect.x;
+	int top = y > rect.y ? y : rect.y;
+	int lhs = x + width;
+	int rhs = rect.x + rect.width;
+	int right = lhs < rhs ? lhs : rhs;
+	lhs = y + height;
+	rhs = rect.y + rect.height;
+	int bottom = lhs < rhs ? lhs : rhs;
+	return new Rectangle (
+		right < left ? 0 : left,
+		bottom < top ? 0 : top,
+		right < left ? 0 : right - left,
+		bottom < top ? 0 : bottom - top);
+}
+
+/**
+ * Returns <code>true</code> if the rectangle described by the
+ * arguments intersects with the receiver and <code>false</code>
+ * otherwise.
+ * <p>
+ * Two rectangles intersect if the area of the rectangle
+ * representing their intersection is not empty.
+ * </p>
+ *
+ * @param x the x coordinate of the origin of the rectangle
+ * @param y the y coordinate of the origin of the rectangle
+ * @param width the width of the rectangle
+ * @param height the height of the rectangle
+ * @return <code>true</code> if the rectangle intersects with the receiver, and <code>false</code> otherwise
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the argument is null</li>
+ * </ul>
+ *
+ * @see #intersection(Rectangle)
+ * @see #isEmpty()
+ * 
+ * @since 3.0
+ */
+public boolean intersects (int x, int y, int width, int height) {
+	return (x < this.x + this.width) && (y < this.y + this.height) &&
+		(x + width > this.x) && (y + height > this.y);
+}
+
+/**
+ * Returns <code>true</code> if the given rectangle intersects
+ * with the receiver and <code>false</code> otherwise.
+ * <p>
+ * Two rectangles intersect if the area of the rectangle
+ * representing their intersection is not empty.
+ * </p>
+ *
+ * @param rect the rectangle to test for intersection
+ * @return <code>true</code> if the rectangle intersects with the receiver, and <code>false</code> otherwise
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the argument is null</li>
+ * </ul>
+ *
+ * @see #intersection(Rectangle)
+ * @see #isEmpty()
+ */
+public boolean intersects (Rectangle rect) {
+	if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	return rect == this || intersects (rect.x, rect.y, rect.width, rect.height);
+}
+		
+/**
+ * Returns <code>true</code> if the receiver does not cover any
+ * area in the (x, y) coordinate plane, and <code>false</code> if
+ * the receiver does cover some area in the plane.
+ * <p>
+ * A rectangle is considered to <em>cover area</em> in the 
+ * (x, y) coordinate plane if both its width and height are 
+ * non-zero.
+ * </p>
+ *
+ * @return <code>true</code> if the receiver is empty, and <code>false</code> otherwise
+ */
+public boolean isEmpty () {
+	return (width <= 0) || (height <= 0);
+}
+
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the rectangle
+ */
+public String toString () {
+	return "Rectangle {" + x + ", " + y + ", " + width + ", " + height + "}"; //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+}
+
+/**
+ * Returns a new rectangle which represents the union of
+ * the receiver and the given rectangle.
+ * <p>
+ * The union of two rectangles is the smallest single rectangle
+ * that completely covers both of the areas covered by the two
+ * given rectangles.
+ * </p>
+ *
+ * @param rect the rectangle to perform union with
+ * @return the union of the receiver and the argument
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the argument is null</li>
+ * </ul>
+ *
+ * @see #add(Rectangle)
+ */
+public Rectangle union (Rectangle rect) {
+	if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	int left = x < rect.x ? x : rect.x;
+	int top = y < rect.y ? y : rect.y;
+	int lhs = x + width;
+	int rhs = rect.x + rect.width;
+	int right = lhs > rhs ? lhs : rhs;
+	lhs = y + height;
+	rhs = rect.y + rect.height;
+	int bottom = lhs > rhs ? lhs : rhs;
+	return new Rectangle (left, top, right - left, bottom - top);
+}
+
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/Region.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/Region.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/Region.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,594 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.graphics;
+
+
+import org.eclipse.swt.internal.gtk.*;
+import org.eclipse.swt.*;
+
+/**
+ * Instances of this class represent areas of an x-y coordinate
+ * system that are aggregates of the areas covered by a number
+ * of polygons.
+ * <p>
+ * Application code must explicitly invoke the <code>Region.dispose()</code> 
+ * method to release the operating system resources managed by each instance
+ * when those instances are no longer required.
+ * </p>
+ * 
+ * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: GraphicsExample</a>
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public final class Region extends Resource {
+	/**
+	 * the OS resource for the region
+	 * (Warning: This field is platform dependent)
+	 * <p>
+	 * <b>IMPORTANT:</b> This field is <em>not</em> part of the SWT
+	 * public API. It is marked public only so that it can be shared
+	 * within the packages provided by SWT. It is not available on all
+	 * platforms and should never be accessed from application code.
+	 * </p>
+	 */
+	public int /*long*/ handle;
+
+/**
+ * Constructs a new empty region.
+ * 
+ * @exception SWTError <ul>
+ *    <li>ERROR_NO_HANDLES if a handle could not be obtained for region creation</li>
+ * </ul>
+ */
+public Region() {
+	this(null);
+}
+
+/**
+ * Constructs a new empty region.
+ * <p>
+ * You must dispose the region when it is no longer required. 
+ * </p>
+ *
+ * @param device the device on which to allocate the region
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li>
+ * </ul>
+ * @exception SWTError <ul>
+ *    <li>ERROR_NO_HANDLES if a handle could not be obtained for region creation</li>
+ * </ul>
+ *
+ * @see #dispose
+ * 
+ * @since 3.0
+ */
+public Region(Device device) {
+	super(device);
+	handle = OS.gdk_region_new();
+	if (handle == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+	init();
+}
+
+Region(Device device, int /*long*/ handle) {
+	super(device);
+	this.handle = handle;
+}
+
+/**
+ * Adds the given polygon to the collection of polygons
+ * the receiver maintains to describe its area.
+ *
+ * @param pointArray points that describe the polygon to merge with the receiver
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the argument is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @since 3.0
+*
+ */
+public void add (int[] pointArray) {
+	if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	if (pointArray == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	/*
+	* Bug in GTK. If gdk_region_polygon() is called with one point,
+	* it segment faults. The fix is to make sure that it is called 
+	* with enough points for a polygon.
+	*/
+	if (pointArray.length < 6) return;
+	int /*long*/ polyRgn = OS.gdk_region_polygon(pointArray, pointArray.length / 2, OS.GDK_EVEN_ODD_RULE);
+	OS.gdk_region_union(handle, polyRgn);
+	OS.gdk_region_destroy(polyRgn);
+}
+
+/**
+ * Adds the given rectangle to the collection of polygons
+ * the receiver maintains to describe its area.
+ *
+ * @param rect the rectangle to merge with the receiver
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the argument is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the rectangle's width or height is negative</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void add(Rectangle rect) {
+	if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	add (rect.x, rect.y, rect.width, rect.height);
+}
+
+/**
+ * Adds the given rectangle to the collection of polygons
+ * the receiver maintains to describe its area.
+ *
+ * @param x the x coordinate of the rectangle
+ * @param y the y coordinate of the rectangle
+ * @param width the width coordinate of the rectangle
+ * @param height the height coordinate of the rectangle
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the rectangle's width or height is negative</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @since 3.1
+ */
+public void add(int x, int y, int width, int height) {
+	if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	if (width < 0 || height < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	GdkRectangle gdkRect = new GdkRectangle();
+	gdkRect.x = x;
+	gdkRect.y = y;
+	gdkRect.width = width;
+	gdkRect.height = height;
+	OS.gdk_region_union_with_rect(handle, gdkRect);
+}
+
+/**
+ * Adds all of the polygons which make up the area covered
+ * by the argument to the collection of polygons the receiver
+ * maintains to describe its area.
+ *
+ * @param region the region to merge
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the argument is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void add(Region region) {
+	if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	if (region == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	if (region.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	OS.gdk_region_union(handle, region.handle);
+}
+
+/**
+ * Returns <code>true</code> if the point specified by the
+ * arguments is inside the area specified by the receiver,
+ * and <code>false</code> otherwise.
+ *
+ * @param x the x coordinate of the point to test for containment
+ * @param y the y coordinate of the point to test for containment
+ * @return <code>true</code> if the region contains the point and <code>false</code> otherwise
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public boolean contains(int x, int y) {
+	if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	return OS.gdk_region_point_in(handle, x, y);
+}
+
+/**
+ * Returns <code>true</code> if the given point is inside the
+ * area specified by the receiver, and <code>false</code>
+ * otherwise.
+ *
+ * @param pt the point to test for containment
+ * @return <code>true</code> if the region contains the point and <code>false</code> otherwise
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the argument is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public boolean contains(Point pt) {
+	if (pt == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	return contains(pt.x, pt.y);
+}
+
+void destroy() {
+	OS.gdk_region_destroy(handle);
+	handle = 0;
+}
+
+/**
+ * Compares the argument to the receiver, and returns true
+ * if they represent the <em>same</em> object using a class
+ * specific comparison.
+ *
+ * @param object the object to compare with this object
+ * @return <code>true</code> if the object is the same as this object and <code>false</code> otherwise
+ *
+ * @see #hashCode
+ */
+public boolean equals(Object object) {
+	if (this == object) return true;
+	if (!(object instanceof Region)) return false;
+	Region region = (Region)object;
+	return handle == region.handle;
+}
+
+/**
+ * Returns a rectangle which represents the rectangular
+ * union of the collection of polygons the receiver
+ * maintains to describe its area.
+ *
+ * @return a bounding rectangle for the region
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see Rectangle#union
+ */
+public Rectangle getBounds() {
+	if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	GdkRectangle gdkRect = new GdkRectangle();
+	OS.gdk_region_get_clipbox(handle, gdkRect);
+	return new Rectangle(gdkRect.x, gdkRect.y, gdkRect.width, gdkRect.height);
+}
+
+public static Region gtk_new(Device device, int /*long*/ handle) {
+	return new Region(device, handle);
+}
+
+/**
+ * Returns an integer hash code for the receiver. Any two 
+ * objects that return <code>true</code> when passed to 
+ * <code>equals</code> must return the same value for this
+ * method.
+ *
+ * @return the receiver's hash
+ *
+ * @see #equals
+ */
+public int hashCode() {
+	return (int)/*64*/handle;
+}
+
+/**
+ * Intersects the given rectangle to the collection of polygons
+ * the receiver maintains to describe its area.
+ *
+ * @param rect the rectangle to intersect with the receiver
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the argument is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the rectangle's width or height is negative</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @since 3.0
+ */
+public void intersect(Rectangle rect) {
+	if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	intersect (rect.x, rect.y, rect.width, rect.height);
+}
+
+/**
+ * Intersects the given rectangle to the collection of polygons
+ * the receiver maintains to describe its area.
+ *
+ * @param x the x coordinate of the rectangle
+ * @param y the y coordinate of the rectangle
+ * @param width the width coordinate of the rectangle
+ * @param height the height coordinate of the rectangle
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the rectangle's width or height is negative</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @since 3.1
+ */
+public void intersect(int x, int y, int width, int height) {
+	if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	if (width < 0 || height < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	GdkRectangle gdkRect = new GdkRectangle();
+	gdkRect.x = x;
+	gdkRect.y = y;
+	gdkRect.width = width;
+	gdkRect.height = height;
+	int /*long*/ rectRgn = OS.gdk_region_rectangle(gdkRect);
+	OS.gdk_region_intersect(handle, rectRgn);
+	OS.gdk_region_destroy(rectRgn);
+}
+
+/**
+ * Intersects all of the polygons which make up the area covered
+ * by the argument to the collection of polygons the receiver
+ * maintains to describe its area.
+ *
+ * @param region the region to intersect
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the argument is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @since 3.0
+ */
+public void intersect(Region region) {
+	if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	if (region == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	if (region.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	OS.gdk_region_intersect(handle, region.handle);
+}
+
+/**
+ * Returns <code>true</code> if the rectangle described by the
+ * arguments intersects with any of the polygons the receiver
+ * maintains to describe its area, and <code>false</code> otherwise.
+ *
+ * @param x the x coordinate of the origin of the rectangle
+ * @param y the y coordinate of the origin of the rectangle
+ * @param width the width of the rectangle
+ * @param height the height of the rectangle
+ * @return <code>true</code> if the rectangle intersects with the receiver, and <code>false</code> otherwise
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see Rectangle#intersects(Rectangle)
+ */
+public boolean intersects (int x, int y, int width, int height) {
+	if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	GdkRectangle gdkRect = new GdkRectangle();
+	gdkRect.x = x;
+	gdkRect.y = y;
+	gdkRect.width = width;
+	gdkRect.height = height;
+	return OS.gdk_region_rect_in(handle, gdkRect) != OS.GDK_OVERLAP_RECTANGLE_OUT;
+}
+/**
+ * Returns <code>true</code> if the given rectangle intersects
+ * with any of the polygons the receiver maintains to describe
+ * its area and <code>false</code> otherwise.
+ *
+ * @param rect the rectangle to test for intersection
+ * @return <code>true</code> if the rectangle intersects with the receiver, and <code>false</code> otherwise
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the argument is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see Rectangle#intersects(Rectangle)
+ */
+public boolean intersects(Rectangle rect) {
+	if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	return intersects(rect.x, rect.y, rect.width, rect.height);
+}
+
+/**
+ * Returns <code>true</code> if the region has been disposed,
+ * and <code>false</code> otherwise.
+ * <p>
+ * This method gets the dispose state for the region.
+ * When a region has been disposed, it is an error to
+ * invoke any other method using the region.
+ *
+ * @return <code>true</code> when the region is disposed, and <code>false</code> otherwise
+ */
+public boolean isDisposed() {
+	return handle == 0;
+}
+
+/**
+ * Returns <code>true</code> if the receiver does not cover any
+ * area in the (x, y) coordinate plane, and <code>false</code> if
+ * the receiver does cover some area in the plane.
+ *
+ * @return <code>true</code> if the receiver is empty, and <code>false</code> otherwise
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public boolean isEmpty() {
+	if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	return OS.gdk_region_empty(handle);
+}
+
+/**
+ * Subtracts the given polygon from the collection of polygons
+ * the receiver maintains to describe its area.
+ *
+ * @param pointArray points that describe the polygon to merge with the receiver
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the argument is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @since 3.0
+ */
+public void subtract (int[] pointArray) {
+	if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	if (pointArray == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	/*
+	* Bug in GTK. If gdk_region_polygon() is called with one point,
+	* it segment faults. The fix is to make sure that it is called 
+	* with enough points for a polygon.
+	*/
+	if (pointArray.length < 6) return;
+	int /*long*/ polyRgn = OS.gdk_region_polygon(pointArray, pointArray.length / 2, OS.GDK_EVEN_ODD_RULE);
+	OS.gdk_region_subtract(handle, polyRgn);
+	OS.gdk_region_destroy(polyRgn);
+}
+
+/**
+ * Subtracts the given rectangle from the collection of polygons
+ * the receiver maintains to describe its area.
+ *
+ * @param rect the rectangle to subtract from the receiver
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the argument is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the rectangle's width or height is negative</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @since 3.0
+ */
+public void subtract(Rectangle rect) {
+	if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	subtract (rect.x, rect.y, rect.width, rect.height);
+}
+
+/**
+ * Subtracts the given rectangle from the collection of polygons
+ * the receiver maintains to describe its area.
+ *
+ * @param x the x coordinate of the rectangle
+ * @param y the y coordinate of the rectangle
+ * @param width the width coordinate of the rectangle
+ * @param height the height coordinate of the rectangle
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the rectangle's width or height is negative</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @since 3.1
+ */
+public void subtract(int x, int y, int width, int height) {
+	if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	if (width < 0 || height < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	GdkRectangle gdkRect = new GdkRectangle();
+	gdkRect.x = x;
+	gdkRect.y = y;
+	gdkRect.width = width;
+	gdkRect.height = height;
+	int /*long*/ rectRgn = OS.gdk_region_rectangle(gdkRect);
+	OS.gdk_region_subtract(handle, rectRgn);
+	OS.gdk_region_destroy(rectRgn);
+}
+
+/**
+ * Subtracts all of the polygons which make up the area covered
+ * by the argument from the collection of polygons the receiver
+ * maintains to describe its area.
+ *
+ * @param region the region to subtract
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the argument is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @since 3.0
+ */
+public void subtract(Region region) {
+	if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	if (region == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	if (region.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	OS.gdk_region_subtract(handle, region.handle);
+}
+
+/**
+ * Translate all of the polygons the receiver maintains to describe
+ * its area by the specified point.
+ *
+ * @param x the x coordinate of the point to translate
+ * @param y the y coordinate of the point to translate
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @since 3.1
+ */
+public void translate (int x, int y) {
+	if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	OS.gdk_region_offset (handle, x, y);
+}
+
+/**
+ * Translate all of the polygons the receiver maintains to describe
+ * its area by the specified point.
+ *
+ * @param pt the point to translate
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the argument is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @since 3.1
+ */
+public void translate (Point pt) {
+	if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	if (pt == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	translate (pt.x, pt.y);
+}
+
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the receiver
+ */
+public String toString () {
+	if (isDisposed()) return "Region {*DISPOSED*}";
+	return "Region {" + handle + "}";
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/Resource.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/Resource.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/Resource.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,100 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.graphics;
+
+import org.eclipse.swt.*;
+
+/**
+ * This class is the abstract superclass of all graphics resource objects.  
+ * Resources created by the application must be disposed.
+ * <p>
+ * IMPORTANT: This class is intended to be subclassed <em>only</em>
+ * within the SWT implementation. However, it has not been marked
+ * final to allow those outside of the SWT development team to implement
+ * patched versions of the class in order to get around specific
+ * limitations in advance of when those limitations can be addressed
+ * by the team.  Any class built using subclassing to access the internals
+ * of this class will likely fail to compile or run between releases and
+ * may be strongly platform specific. Subclassing should not be attempted
+ * without an intimate and detailed understanding of the workings of the
+ * hierarchy. No support is provided for user-written classes which are
+ * implemented as subclasses of this class.
+ * </p>
+ *
+ * @see #dispose
+ * @see #isDisposed
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ * 
+ * @since 3.1
+ */
+public abstract class Resource {
+    
+	/**
+	 * the device where this resource was created
+	 */
+	Device device;
+
+public Resource() {
+}
+
+Resource(Device device) {
+	if (device == null) device = Device.getDevice();
+	if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	this.device = device;
+}
+
+void destroy() {
+}
+
+/**
+ * Disposes of the operating system resources associated with
+ * this resource. Applications must dispose of all resources
+ * which they allocate.
+ */
+public void dispose() {
+	if (device == null) return;
+	if (device.isDisposed()) return;
+	destroy();
+	if (device.tracking) device.dispose_Object(this);
+	device = null;
+}
+
+/**
+ * Returns the <code>Device</code> where this resource was
+ * created.
+ *
+ * @return <code>Device</code> the device of the receiver
+ * 
+ * @since 3.2
+ */
+public Device getDevice() {
+	Device device = this.device;
+	if (device == null || isDisposed ()) SWT.error (SWT.ERROR_GRAPHIC_DISPOSED);
+	return device;
+}
+
+void init() {
+	if (device.tracking) device.new_Object(this);
+}
+
+/**
+ * Returns <code>true</code> if the resource has been disposed,
+ * and <code>false</code> otherwise.
+ * <p>
+ * This method gets the dispose state for the resource.
+ * When a resource has been disposed, it is an error to
+ * invoke any other method using the resource.
+ *
+ * @return <code>true</code> when the resource is disposed and <code>false</code> otherwise
+ */
+public abstract boolean isDisposed();
+
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/TextLayout.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/TextLayout.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/TextLayout.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,2180 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.graphics;
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.cairo.*;
+import org.eclipse.swt.internal.gtk.*;
+import org.eclipse.swt.*;
+
+/**
+ * <code>TextLayout</code> is a graphic object that represents
+ * styled text.
+ * <p>
+ * Instances of this class provide support for drawing, cursor
+ * navigation, hit testing, text wrapping, alignment, tab expansion
+ * line breaking, etc.  These are aspects required for rendering internationalized text.
+ * </p><p>
+ * Application code must explicitly invoke the <code>TextLayout#dispose()</code> 
+ * method to release the operating system resources managed by each instance
+ * when those instances are no longer required.
+ * </p>
+ * 
+ * @see <a href="http://www.eclipse.org/swt/snippets/#textlayout">TextLayout, TextStyle snippets</a>
+ * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: CustomControlExample, StyledText tab</a>
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ * 
+ * @since 3.0
+ */
+public final class TextLayout extends Resource {
+	
+	static class StyleItem {
+		TextStyle style;
+		int start;
+
+		public String toString () {
+			return "StyleItem {" + start + ", " + style + "}";
+		}
+	}
+
+	Font font;
+	String text;
+	int ascent, descent;
+	int[] segments;
+	int[] tabs;
+	StyleItem[] styles;
+	int /*long*/ layout, context, attrList;
+	int[] invalidOffsets;
+	static final char LTR_MARK = '\u200E', RTL_MARK = '\u200F', ZWS = '\u200B', ZWNBS = '\uFEFF';
+
+/**	 
+ * Constructs a new instance of this class on the given device.
+ * <p>
+ * You must dispose the text layout when it is no longer required. 
+ * </p>
+ * 
+ * @param device the device on which to allocate the text layout
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li>
+ * </ul>
+ * 
+ * @see #dispose()
+ */
+public TextLayout (Device device) {
+	super(device);
+	device = this.device;
+	context = OS.gdk_pango_context_get();
+	if (context == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+	OS.pango_context_set_language(context, OS.gtk_get_default_language());
+	OS.pango_context_set_base_dir(context, OS.PANGO_DIRECTION_LTR);
+	OS.gdk_pango_context_set_colormap(context, OS.gdk_colormap_get_system());
+	layout = OS.pango_layout_new(context);
+	if (layout == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+	OS.pango_layout_set_font_description(layout, device.systemFont.handle);
+	OS.pango_layout_set_wrap(layout, OS.PANGO_WRAP_WORD_CHAR);
+	OS.pango_layout_set_tabs(layout, device.emptyTab);
+	if (OS.GTK_VERSION >= OS.VERSION(2, 4, 0)) {
+		OS.pango_layout_set_auto_dir(layout, false);
+	}
+	text = "";
+	ascent = descent = -1;
+	styles = new StyleItem[2];
+	styles[0] = new StyleItem();
+	styles[1] = new StyleItem();
+	init();
+}
+
+void checkLayout() {
+	if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+}
+
+void computeRuns () {
+	if (attrList != 0) return;
+	String segmentsText = getSegmentsText();
+	byte[] buffer = Converter.wcsToMbcs(null, segmentsText, false);
+	OS.pango_layout_set_text (layout, buffer, buffer.length);
+	if (styles.length == 2 && styles[0].style == null && ascent == -1 && descent == -1 && segments == null) return;
+	int /*long*/ ptr = OS.pango_layout_get_text(layout);
+	attrList = OS.pango_attr_list_new();	
+	PangoAttribute attribute = new PangoAttribute();
+	char[] chars = null;
+	int segementsLength = segmentsText.length();
+	if ((ascent != -1  || descent != -1) && segementsLength > 0) {
+		PangoRectangle rect = new PangoRectangle();
+		if (ascent != -1) rect.y =  -(ascent  * OS.PANGO_SCALE);
+		rect.height = (Math.max(0, ascent) + Math.max(0, descent)) * OS.PANGO_SCALE;
+		int lineCount = OS.pango_layout_get_line_count(layout);
+		chars = new char[segementsLength + lineCount * 2];
+		int oldPos = 0, lineIndex = 0;
+		PangoLayoutLine line = new PangoLayoutLine();
+		while (lineIndex < lineCount) {
+			int /*long*/ linePtr = OS.pango_layout_get_line(layout, lineIndex);
+			OS.memmove(line, linePtr, PangoLayoutLine.sizeof);
+			int bytePos = line.start_index;
+			/* Note: The length in bytes of ZWS and ZWNBS are both equals to 3 */
+			int offset = lineIndex * 6;
+			int /*long*/ attr = OS.pango_attr_shape_new (rect, rect);
+			OS.memmove (attribute, attr, PangoAttribute.sizeof);
+			attribute.start_index = bytePos + offset;
+			attribute.end_index = bytePos + offset + 3;
+			OS.memmove (attr, attribute, PangoAttribute.sizeof);
+			OS.pango_attr_list_insert(attrList, attr);
+			attr = OS.pango_attr_shape_new (rect, rect);
+			OS.memmove (attribute, attr, PangoAttribute.sizeof);
+			attribute.start_index = bytePos + offset + 3;
+			attribute.end_index = bytePos + offset + 6;
+			OS.memmove (attr, attribute, PangoAttribute.sizeof);
+			OS.pango_attr_list_insert(attrList, attr);			
+			int pos = (int)/*64*/OS.g_utf8_pointer_to_offset(ptr, ptr + bytePos);
+			chars[pos + lineIndex * 2] = ZWS;
+			chars[pos + lineIndex * 2 + 1] = ZWNBS;
+			segmentsText.getChars(oldPos, pos, chars,  oldPos + lineIndex * 2);
+			oldPos = pos;
+			lineIndex++;
+		}
+		segmentsText.getChars(oldPos, segementsLength, chars,  oldPos + lineIndex * 2);
+		buffer = Converter.wcsToMbcs(null, chars, false);
+		OS.pango_layout_set_text (layout, buffer, buffer.length);
+		ptr = OS.pango_layout_get_text(layout);
+	} else {
+		chars = new char[segementsLength];
+		segmentsText.getChars(0, segementsLength, chars, 0);
+	}
+	int offsetCount = 0;
+	for (int i = 0; i < chars.length; i++) {
+		char c = chars[i];
+		if (c == LTR_MARK || c == RTL_MARK || c == ZWNBS || c == ZWS) {
+			offsetCount++;
+		}
+	}
+	invalidOffsets = new int[offsetCount];
+	offsetCount = 0;
+	for (int i = 0; i < chars.length; i++) {
+		char c = chars[i];
+		if (c == LTR_MARK || c == RTL_MARK || c == ZWNBS || c == ZWS) {
+			invalidOffsets[offsetCount++] = i;
+		}
+	}
+	int strlen = OS.strlen(ptr);
+	Font defaultFont = font != null ? font : device.systemFont;
+	for (int i = 0; i < styles.length - 1; i++) {
+		StyleItem styleItem = styles[i];
+		TextStyle style = styleItem.style; 
+		if (style == null) continue;
+		int start = translateOffset(styleItem.start);
+		int end = translateOffset(styles[i+1].start - 1);
+		int byteStart = (int)/*64*/(OS.g_utf8_offset_to_pointer(ptr, start) - ptr);
+		int byteEnd = (int)/*64*/(OS.g_utf8_offset_to_pointer(ptr, end + 1) - ptr);
+		byteStart = Math.min(byteStart, strlen);
+		byteEnd = Math.min(byteEnd, strlen);
+		Font font = style.font;
+		if (font != null && !font.isDisposed() && !defaultFont.equals(font)) {
+			int /*long*/ attr = OS.pango_attr_font_desc_new (font.handle);
+			OS.memmove (attribute, attr, PangoAttribute.sizeof);
+			attribute.start_index = byteStart;
+			attribute.end_index = byteEnd;
+			OS.memmove (attr, attribute, PangoAttribute.sizeof);
+			OS.pango_attr_list_insert(attrList, attr);
+		}
+		if (style.underline) {
+			int underlineStyle = OS.PANGO_UNDERLINE_NONE;
+			switch (style.underlineStyle) {
+				case SWT.UNDERLINE_SINGLE:
+					underlineStyle = OS.PANGO_UNDERLINE_SINGLE; 
+					break;
+				case SWT.UNDERLINE_DOUBLE:
+					underlineStyle = OS.PANGO_UNDERLINE_DOUBLE; 
+					break;
+				case SWT.UNDERLINE_SQUIGGLE:
+				case SWT.UNDERLINE_ERROR:
+					if (OS.GTK_VERSION >= OS.VERSION(2, 4, 0)) {
+						underlineStyle = OS.PANGO_UNDERLINE_ERROR;
+					}
+					break;
+			}
+			if (underlineStyle != OS.PANGO_UNDERLINE_NONE && style.underlineColor == null) {
+				int /*long*/ attr = OS.pango_attr_underline_new(underlineStyle);
+				OS.memmove(attribute, attr, PangoAttribute.sizeof);
+				attribute.start_index = byteStart;
+				attribute.end_index = byteEnd;
+				OS.memmove(attr, attribute, PangoAttribute.sizeof);
+				OS.pango_attr_list_insert(attrList, attr);
+			}
+		}
+		if (style.strikeout && style.strikeoutColor == null) {
+			int /*long*/ attr = OS.pango_attr_strikethrough_new(true);
+			OS.memmove(attribute, attr, PangoAttribute.sizeof);
+			attribute.start_index = byteStart;
+			attribute.end_index = byteEnd;
+			OS.memmove(attr, attribute, PangoAttribute.sizeof);
+			OS.pango_attr_list_insert(attrList, attr);
+		}
+		Color foreground = style.foreground;
+		if (foreground != null && !foreground.isDisposed()) {
+			GdkColor fg = foreground.handle;
+			int /*long*/ attr = OS.pango_attr_foreground_new(fg.red, fg.green, fg.blue);
+			OS.memmove (attribute, attr, PangoAttribute.sizeof);
+			attribute.start_index = byteStart;
+			attribute.end_index = byteEnd;
+			OS.memmove (attr, attribute, PangoAttribute.sizeof);
+			OS.pango_attr_list_insert(attrList, attr);
+		}
+		Color background = style.background;
+		if (background != null && !background.isDisposed()) {
+			GdkColor bg = background.handle;
+			int /*long*/ attr = OS.pango_attr_background_new(bg.red, bg.green, bg.blue);
+			OS.memmove (attribute, attr, PangoAttribute.sizeof);
+			attribute.start_index = byteStart;
+			attribute.end_index = byteEnd;
+			OS.memmove (attr, attribute, PangoAttribute.sizeof);
+			OS.pango_attr_list_insert(attrList, attr);
+		}
+		GlyphMetrics metrics = style.metrics;
+		if (metrics != null) {
+			PangoRectangle rect = new PangoRectangle();
+			rect.y =  -(metrics.ascent * OS.PANGO_SCALE);
+			rect.height = (metrics.ascent + metrics.descent) * OS.PANGO_SCALE;
+			rect.width = metrics.width * OS.PANGO_SCALE;
+			int /*long*/ attr = OS.pango_attr_shape_new (rect, rect);
+			OS.memmove (attribute, attr, PangoAttribute.sizeof);
+			attribute.start_index = byteStart;
+			attribute.end_index = byteEnd;
+			OS.memmove (attr, attribute, PangoAttribute.sizeof);
+			OS.pango_attr_list_insert(attrList, attr);
+		}
+		int rise = style.rise;
+		if (rise != 0) {
+			int /*long*/ attr = OS.pango_attr_rise_new (rise * OS.PANGO_SCALE);
+			OS.memmove (attribute, attr, PangoAttribute.sizeof);
+			attribute.start_index = byteStart;
+			attribute.end_index = byteEnd;
+			OS.memmove (attr, attribute, PangoAttribute.sizeof);
+			OS.pango_attr_list_insert(attrList, attr);
+		}
+	}
+	OS.pango_layout_set_attributes(layout, attrList);
+}
+
+int[] computePolyline(int left, int top, int right, int bottom) {
+	int height = bottom - top; // can be any number
+	int width = 2 * height; // must be even
+	int peaks = Compatibility.ceil(right - left, width);
+	if (peaks == 0 && right - left > 2) {
+		peaks = 1;
+	}
+	int length = ((2 * peaks) + 1) * 2;
+	if (length < 0) return new int[0];
+	
+	int[] coordinates = new int[length];
+	for (int i = 0; i < peaks; i++) {
+		int index = 4 * i;
+		coordinates[index] = left + (width * i);
+		coordinates[index+1] = bottom;
+		coordinates[index+2] = coordinates[index] + width / 2;
+		coordinates[index+3] = top;
+	}
+	coordinates[length-2] = left + (width * peaks);
+	coordinates[length-1] = bottom;
+	return coordinates;
+}
+
+void destroy() {
+	font = null;
+	text = null;
+	styles = null;
+	freeRuns();
+	if (layout != 0) OS.g_object_unref(layout);
+	layout = 0;
+	if (context != 0) OS.g_object_unref(context);
+	context = 0;
+}
+
+/**
+ * Draws the receiver's text using the specified GC at the specified
+ * point.
+ * 
+ * @param gc the GC to draw
+ * @param x the x coordinate of the top left corner of the rectangular area where the text is to be drawn
+ * @param y the y coordinate of the top left corner of the rectangular area where the text is to be drawn
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the gc is null</li>
+ * </ul>
+ */
+public void draw(GC gc, int x, int y) {
+	draw(gc, x, y, -1, -1, null, null);
+}
+
+/**
+ * Draws the receiver's text using the specified GC at the specified
+ * point.
+ * 
+ * @param gc the GC to draw
+ * @param x the x coordinate of the top left corner of the rectangular area where the text is to be drawn
+ * @param y the y coordinate of the top left corner of the rectangular area where the text is to be drawn
+ * @param selectionStart the offset where the selections starts, or -1 indicating no selection
+ * @param selectionEnd the offset where the selections ends, or -1 indicating no selection
+ * @param selectionForeground selection foreground, or NULL to use the system default color
+ * @param selectionBackground selection background, or NULL to use the system default color
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the gc is null</li>
+ * </ul>
+ */
+public void draw(GC gc, int x, int y, int selectionStart, int selectionEnd, Color selectionForeground, Color selectionBackground) {
+	draw(gc, x, y, selectionStart, selectionEnd, selectionForeground, selectionBackground, 0);
+}
+
+/**
+ * Draws the receiver's text using the specified GC at the specified
+ * point.
+ * <p>
+ * The parameter <code>flags</code> can include one of <code>SWT.DELIMITER_SELECTION</code>
+ * or <code>SWT.FULL_SELECTION</code> to specify the selection behavior on all lines except
+ * for the last line, and can also include <code>SWT.LAST_LINE_SELECTION</code> to extend
+ * the specified selection behavior to the last line.
+ * </p>
+ * @param gc the GC to draw
+ * @param x the x coordinate of the top left corner of the rectangular area where the text is to be drawn
+ * @param y the y coordinate of the top left corner of the rectangular area where the text is to be drawn
+ * @param selectionStart the offset where the selections starts, or -1 indicating no selection
+ * @param selectionEnd the offset where the selections ends, or -1 indicating no selection
+ * @param selectionForeground selection foreground, or NULL to use the system default color
+ * @param selectionBackground selection background, or NULL to use the system default color
+ * @param flags drawing options
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the gc is null</li>
+ * </ul>
+ * 
+ * @since 3.3
+ */
+public void draw(GC gc, int x, int y, int selectionStart, int selectionEnd, Color selectionForeground, Color selectionBackground, int flags) {	
+	checkLayout ();
+	computeRuns();
+	if (gc == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	if (gc.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	if (selectionForeground != null && selectionForeground.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	if (selectionBackground != null && selectionBackground.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	gc.checkGC(GC.FOREGROUND);
+	int length = text.length();
+	boolean hasSelection = selectionStart <= selectionEnd && selectionStart != -1 && selectionEnd != -1;
+	GCData data = gc.data;
+	int /*long*/ cairo = data.cairo;
+	if (flags != 0 && (hasSelection || (flags & SWT.LAST_LINE_SELECTION) != 0)) {
+		int /*long*/[] attrs = new int /*long*/[1];
+		int[] nAttrs = new int[1];
+		PangoLogAttr logAttr = new PangoLogAttr();
+		PangoRectangle rect = new PangoRectangle();
+		int lineCount = OS.pango_layout_get_line_count(layout);
+		int /*long*/ ptr = OS.pango_layout_get_text(layout);
+		int /*long*/ iter = OS.pango_layout_get_iter(layout);
+		if (selectionBackground == null) selectionBackground = device.getSystemColor(SWT.COLOR_LIST_SELECTION);
+		if (cairo != 0 && OS.GTK_VERSION >= OS.VERSION(2, 8, 0)) {
+			Cairo.cairo_save(cairo);
+			GdkColor color = selectionBackground.handle;
+			Cairo.cairo_set_source_rgba(cairo, (color.red & 0xFFFF) / (float)0xFFFF, (color.green & 0xFFFF) / (float)0xFFFF, (color.blue & 0xFFFF) / (float)0xFFFF, data.alpha / (float)0xFF);
+		} else {
+			OS.gdk_gc_set_foreground(gc.handle, selectionBackground.handle);
+		}
+		int lineIndex = 0;
+		do {
+			int lineEnd;
+			OS.pango_layout_iter_get_line_extents(iter, null, rect);
+			if (OS.pango_layout_iter_next_line(iter)) {
+				int bytePos = OS.pango_layout_iter_get_index(iter);
+				lineEnd = (int)/*64*/OS.g_utf8_pointer_to_offset(ptr, ptr + bytePos);
+			} else {
+				lineEnd = (int)/*64*/OS.g_utf8_strlen(ptr, -1);
+			}
+			boolean extent = false;
+			if (lineIndex == lineCount - 1 && (flags & SWT.LAST_LINE_SELECTION) != 0) {
+				extent = true;
+			} else {
+				if (attrs[0] == 0) OS.pango_layout_get_log_attrs(layout, attrs, nAttrs);
+				OS.memmove(logAttr, attrs[0] + lineEnd * PangoLogAttr.sizeof, PangoLogAttr.sizeof);
+				if (!logAttr.is_line_break) {
+					if (selectionStart <= lineEnd && lineEnd <= selectionEnd) extent = true;
+				} else {
+					if (selectionStart <= lineEnd && lineEnd < selectionEnd && (flags & SWT.FULL_SELECTION) != 0) {
+						extent = true;
+					}
+				}
+			}
+			if (extent) {
+				int lineX = x + OS.PANGO_PIXELS(rect.x) + OS.PANGO_PIXELS(rect.width);
+				int lineY = y + OS.PANGO_PIXELS(rect.y);
+				int height = OS.PANGO_PIXELS(rect.height);
+				if (ascent != -1 && descent != -1) {
+					height = Math.max (height, ascent + descent);
+				}
+				int width = (flags & SWT.FULL_SELECTION) != 0 ? 0x7fffffff : height / 3;
+				if (cairo != 0 && OS.GTK_VERSION >= OS.VERSION(2, 8, 0)) {
+					Cairo.cairo_rectangle(cairo, lineX, lineY, width, height);
+					Cairo.cairo_fill(cairo);
+				} else {
+					OS.gdk_draw_rectangle(data.drawable, gc.handle, 1, lineX, lineY, width, height);
+				}
+			}
+			lineIndex++;
+		} while (lineIndex < lineCount);
+		OS.pango_layout_iter_free(iter);
+		if (attrs[0] != 0) OS.g_free(attrs[0]);
+		if (cairo != 0 && OS.GTK_VERSION >= OS.VERSION(2, 8, 0)) {
+			Cairo.cairo_restore(cairo);	
+		} else {
+			OS.gdk_gc_set_foreground(gc.handle, data.foreground);
+		}
+	}
+	if (length == 0) return;
+	if (!hasSelection) {
+		if (cairo != 0 && OS.GTK_VERSION >= OS.VERSION(2, 8, 0)) {
+			if ((data.style & SWT.MIRRORED) != 0) {
+				Cairo.cairo_save(cairo);
+				Cairo.cairo_scale(cairo, -1,  1);
+				Cairo.cairo_translate(cairo, -2 * x - width(), 0);
+			}
+			Cairo.cairo_move_to(cairo, x, y);
+			OS.pango_cairo_show_layout(cairo, layout);
+			drawBorder(gc, x, y, null);
+			if ((data.style & SWT.MIRRORED) != 0) {
+			    Cairo.cairo_restore(cairo);
+			}
+		} else {
+			OS.gdk_draw_layout(data.drawable, gc.handle, x, y, layout);
+			drawBorder(gc, x, y, null);
+		}
+	} else {
+		selectionStart = Math.min(Math.max(0, selectionStart), length - 1);
+		selectionEnd = Math.min(Math.max(0, selectionEnd), length - 1);
+		length = (int)/*64*/OS.g_utf8_strlen(OS.pango_layout_get_text(layout), -1);
+		selectionStart = translateOffset(selectionStart);
+		selectionEnd = translateOffset(selectionEnd);
+		if (selectionForeground == null) selectionForeground = device.getSystemColor(SWT.COLOR_LIST_SELECTION_TEXT);
+		if (selectionBackground == null) selectionBackground = device.getSystemColor(SWT.COLOR_LIST_SELECTION);
+		boolean fullSelection = selectionStart == 0 && selectionEnd == length - 1;
+		if (fullSelection) {
+			if (cairo != 0 && OS.GTK_VERSION >= OS.VERSION(2, 8, 0)) {
+				int /*long*/ ptr = OS.pango_layout_get_text(layout);
+				if ((data.style & SWT.MIRRORED) != 0) {
+					Cairo.cairo_save(cairo);
+					Cairo.cairo_scale(cairo, -1,  1);
+					Cairo.cairo_translate(cairo, -2 * x - width(), 0);
+				}
+				drawWithCairo(gc, x, y, 0, OS.strlen(ptr), fullSelection, selectionForeground.handle, selectionBackground.handle);
+				if ((data.style & SWT.MIRRORED) != 0) {
+					Cairo.cairo_restore(cairo);
+				}
+			} else {
+				OS.gdk_draw_layout_with_colors(data.drawable, gc.handle, x, y, layout, selectionForeground.handle, selectionBackground.handle);
+				drawBorder(gc, x, y, selectionForeground.handle);
+			}
+		} else {
+			int /*long*/ ptr = OS.pango_layout_get_text(layout);
+			int byteSelStart = (int)/*64*/(OS.g_utf8_offset_to_pointer(ptr, selectionStart) - ptr);
+			int byteSelEnd = (int)/*64*/(OS.g_utf8_offset_to_pointer(ptr, selectionEnd + 1) - ptr);
+			int strlen = OS.strlen(ptr);
+			byteSelStart = Math.min(byteSelStart, strlen);
+			byteSelEnd = Math.min(byteSelEnd, strlen);
+			if (cairo != 0 && OS.GTK_VERSION >= OS.VERSION(2, 8, 0)) {
+				if ((data.style & SWT.MIRRORED) != 0) {
+					Cairo.cairo_save(cairo);
+					Cairo.cairo_scale(cairo, -1,  1);
+					Cairo.cairo_translate(cairo, -2 * x - width(), 0);
+				}
+				drawWithCairo(gc, x, y, byteSelStart, byteSelEnd, fullSelection, selectionForeground.handle, selectionBackground.handle);
+				if ((data.style & SWT.MIRRORED) != 0) {
+					Cairo.cairo_restore(cairo);
+				}
+			} else {
+				Region clipping = new Region();
+				gc.getClipping(clipping);
+				OS.gdk_draw_layout(data.drawable, gc.handle, x, y, layout);
+				drawBorder(gc, x, y, null);
+				int[] ranges = new int[]{byteSelStart, byteSelEnd};
+				int /*long*/ rgn = OS.gdk_pango_layout_get_clip_region(layout, x, y, ranges, ranges.length / 2);
+				if (rgn != 0) {
+					OS.gdk_gc_set_clip_region(gc.handle, rgn);
+					OS.gdk_region_destroy(rgn);
+				}
+				OS.gdk_draw_layout_with_colors(data.drawable, gc.handle, x, y, layout, selectionForeground.handle, selectionBackground.handle);
+				drawBorder(gc, x, y, selectionForeground.handle);
+				gc.setClipping(clipping);
+				clipping.dispose();
+			}
+		}
+	}
+}
+
+void drawWithCairo(GC gc, int x, int y, int start, int end, boolean fullSelection, GdkColor fg, GdkColor bg) {
+	GCData data = gc.data;
+	int /*long*/ cairo = data.cairo;
+	Cairo.cairo_save(cairo);
+	if (!fullSelection) {
+		Cairo.cairo_move_to(cairo, x, y);
+		OS.pango_cairo_show_layout(cairo, layout);
+		drawBorder(gc, x, y, null);
+	}
+	int[] ranges = new int[]{start, end};
+	int /*long*/ rgn = OS.gdk_pango_layout_get_clip_region(layout, x, y, ranges, ranges.length / 2);
+	if (rgn != 0) {
+		OS.gdk_cairo_region(cairo, rgn);
+		Cairo.cairo_clip(cairo);
+		Cairo.cairo_set_source_rgba(cairo, (bg.red & 0xFFFF) / (float)0xFFFF, (bg.green & 0xFFFF) / (float)0xFFFF, (bg.blue & 0xFFFF) / (float)0xFFFF, data.alpha / (float)0xFF);
+		Cairo.cairo_paint(cairo);
+		OS.gdk_region_destroy(rgn);
+	}
+	Cairo.cairo_set_source_rgba(cairo, (fg.red & 0xFFFF) / (float)0xFFFF, (fg.green & 0xFFFF) / (float)0xFFFF, (fg.blue & 0xFFFF) / (float)0xFFFF, data.alpha / (float)0xFF);
+	Cairo.cairo_move_to(cairo, x, y);
+	OS.pango_cairo_show_layout(cairo, layout);
+	drawBorder(gc, x, y, fg);
+	Cairo.cairo_restore(cairo);
+}
+
+void drawBorder(GC gc, int x, int y, GdkColor selectionColor) {
+	GCData data = gc.data;
+	int /*long*/ cairo = data.cairo;
+	int /*long*/ gdkGC = gc.handle;
+	int /*long*/ ptr = OS.pango_layout_get_text(layout);
+	GdkGCValues gcValues = null;
+	if (cairo != 0 && OS.GTK_VERSION >= OS.VERSION(2, 8, 0)) {
+		Cairo.cairo_save(cairo);
+	}
+	for (int i = 0; i < styles.length - 1; i++) {
+		TextStyle style = styles[i].style;
+		if (style == null) continue;
+		
+		boolean drawBorder = style.borderStyle != SWT.NONE;
+		if (drawBorder && !style.isAdherentBorder(styles[i+1].style)) {
+			int start = styles[i].start;
+			for (int j = i; j > 0 && style.isAdherentBorder(styles[j-1].style); j--) {
+				start = styles[j - 1].start;
+			}
+			start = translateOffset(start);
+			int end = translateOffset(styles[i+1].start - 1);
+			int byteStart = (int)/*64*/(OS.g_utf8_offset_to_pointer(ptr, start) - ptr);
+			int byteEnd = (int)/*64*/(OS.g_utf8_offset_to_pointer(ptr, end + 1) - ptr);
+			int[] ranges = new int[]{byteStart, byteEnd};
+			int /*long*/ rgn = OS.gdk_pango_layout_get_clip_region(layout, x, y, ranges, ranges.length / 2);
+			if (rgn != 0) {
+				int[] nRects = new int[1];
+				int /*long*/[] rects = new int /*long*/[1];
+				OS.gdk_region_get_rectangles(rgn, rects, nRects);
+				GdkRectangle rect = new GdkRectangle();
+				GdkColor color = null;
+				if (color == null && style.borderColor != null) color = style.borderColor.handle;
+				if (color == null && selectionColor != null) color = selectionColor;
+				if (color == null && style.foreground != null) color = style.foreground.handle;
+				if (color == null) color = data.foreground;
+				int width = 1;
+				float[] dashes = null;
+				switch (style.borderStyle) {
+					case SWT.BORDER_SOLID: break;
+					case SWT.BORDER_DASH: dashes = width != 0 ? GC.LINE_DASH : GC.LINE_DASH_ZERO; break;
+					case SWT.BORDER_DOT: dashes = width != 0 ? GC.LINE_DOT : GC.LINE_DOT_ZERO; break;
+				}
+				if (cairo != 0 && OS.GTK_VERSION >= OS.VERSION(2, 8, 0)) {
+					Cairo.cairo_set_source_rgba(cairo, (color.red & 0xFFFF) / (float)0xFFFF, (color.green & 0xFFFF) / (float)0xFFFF, (color.blue & 0xFFFF) / (float)0xFFFF, data.alpha / (float)0xFF);
+					Cairo.cairo_set_line_width(cairo, width);
+					if (dashes != null) {
+						double[] cairoDashes = new double[dashes.length];
+						for (int j = 0; j < cairoDashes.length; j++) {
+							cairoDashes[j] = width == 0 || data.lineStyle == SWT.LINE_CUSTOM ? dashes[j] : dashes[j] * width;
+						}
+						Cairo.cairo_set_dash(cairo, cairoDashes, cairoDashes.length, 0);
+					} else {
+						Cairo.cairo_set_dash(cairo, null, 0, 0);
+					}
+					for (int j=0; j<nRects[0]; j++) {
+						OS.memmove(rect, rects[0] + (j * GdkRectangle.sizeof), GdkRectangle.sizeof);
+						Cairo.cairo_rectangle(cairo, rect.x + 0.5, rect.y + 0.5, rect.width - 1, rect.height - 1);
+					}
+					Cairo.cairo_stroke(cairo);
+				} else {
+					if (gcValues == null) {
+						gcValues = new GdkGCValues();
+						OS.gdk_gc_get_values(gdkGC, gcValues);
+					}
+					OS.gdk_gc_set_foreground(gdkGC, color);
+					int cap_style = OS.GDK_CAP_BUTT;
+					int join_style = OS.GDK_JOIN_MITER;
+					int line_style = 0;
+					if (dashes != null) {
+						byte[] dash_list = new byte[dashes.length];
+						for (int j = 0; j < dash_list.length; j++) {
+							dash_list[j] = (byte)(width == 0 || data.lineStyle == SWT.LINE_CUSTOM ? dashes[j] : dashes[j] * width);
+						}
+						OS.gdk_gc_set_dashes(gdkGC, 0, dash_list, dash_list.length);
+						line_style = OS.GDK_LINE_ON_OFF_DASH;
+					} else {
+						line_style = OS.GDK_LINE_SOLID;
+					}
+					OS.gdk_gc_set_line_attributes(gdkGC, width, line_style, cap_style, join_style);
+					for (int j=0; j<nRects[0]; j++) {
+						OS.memmove(rect, rects[0] + (j * GdkRectangle.sizeof), GdkRectangle.sizeof);
+						OS.gdk_draw_rectangle(data.drawable, gdkGC, 0, rect.x, rect.y, rect.width - 1, rect.height - 1);
+					}
+				}
+				if (rects[0] != 0) OS.g_free(rects[0]);
+				OS.gdk_region_destroy(rgn);
+			}
+		}
+		
+		boolean drawUnderline = false;
+		if (style.underline && style.underlineColor != null) drawUnderline = true;
+		if (style.underline && (style.underlineStyle == SWT.UNDERLINE_ERROR || style.underlineStyle == SWT.UNDERLINE_SQUIGGLE)&& OS.GTK_VERSION < OS.VERSION(2, 4, 0)) drawUnderline = true;
+		if (drawUnderline && !style.isAdherentUnderline(styles[i+1].style)) {
+			int start = styles[i].start;
+			for (int j = i; j > 0 && style.isAdherentUnderline(styles[j-1].style); j--) {
+				start = styles[j - 1].start;
+			}
+			start = translateOffset(start);
+			int end = translateOffset(styles[i+1].start - 1);
+			int byteStart = (int)/*64*/(OS.g_utf8_offset_to_pointer(ptr, start) - ptr);
+			int byteEnd = (int)/*64*/(OS.g_utf8_offset_to_pointer(ptr, end + 1) - ptr);
+			int[] ranges = new int[]{byteStart, byteEnd};
+			int /*long*/ rgn = OS.gdk_pango_layout_get_clip_region(layout, x, y, ranges, ranges.length / 2);
+			if (rgn != 0) {
+				int[] nRects = new int[1];
+				int /*long*/[] rects = new int /*long*/[1];
+				OS.gdk_region_get_rectangles(rgn, rects, nRects);
+				GdkRectangle rect = new GdkRectangle();
+				GdkColor color = null;
+				if (color == null && style.underlineColor != null) color = style.underlineColor.handle;
+				if (color == null && selectionColor != null) color = selectionColor;
+				if (color == null && style.foreground != null) color = style.foreground.handle;
+				if (color == null) color = data.foreground;
+				if (cairo != 0 && OS.GTK_VERSION >= OS.VERSION(2, 8, 0)) {
+					Cairo.cairo_set_source_rgba(cairo, (color.red & 0xFFFF) / (float)0xFFFF, (color.green & 0xFFFF) / (float)0xFFFF, (color.blue & 0xFFFF) / (float)0xFFFF, data.alpha / (float)0xFF);
+				} else {
+					if (gcValues == null) {
+						gcValues = new GdkGCValues();
+						OS.gdk_gc_get_values(gdkGC, gcValues);
+					}
+					OS.gdk_gc_set_foreground(gdkGC, color);
+				}
+				int underlinePosition = -1;
+				int underlineThickness = 1;
+				if (OS.GTK_VERSION >= OS.VERSION(2, 6, 0)) {
+					Font font = style.font;
+					if (font == null) font = this.font;
+					if (font == null) font = device.systemFont;
+					int /*long*/ lang = OS.pango_context_get_language(context);
+					int /*long*/ metrics = OS.pango_context_get_metrics(context, font.handle, lang);
+					underlinePosition = OS.PANGO_PIXELS(OS.pango_font_metrics_get_underline_position(metrics));
+					underlineThickness = OS.PANGO_PIXELS(OS.pango_font_metrics_get_underline_thickness(metrics));
+					OS.pango_font_metrics_unref(metrics);
+				}
+				for (int j=0; j<nRects[0]; j++) {
+					OS.memmove(rect, rects[0] + (j * GdkRectangle.sizeof), GdkRectangle.sizeof);
+					int offset = getOffset(rect.x - x, rect.y - y, null);
+					int lineIndex = getLineIndex(offset);
+					FontMetrics metrics = getLineMetrics(lineIndex);
+					int underlineY = rect.y + metrics.ascent - underlinePosition - style.rise;
+					switch (style.underlineStyle) {
+						case SWT.UNDERLINE_SQUIGGLE:
+						case SWT.UNDERLINE_ERROR: {
+							int squigglyThickness = underlineThickness;
+							int squigglyHeight = 2 * squigglyThickness;
+							int squigglyY = Math.min(underlineY, rect.y + rect.height - squigglyHeight - 1);
+							int[] points = computePolyline(rect.x, squigglyY, rect.x + rect.width, squigglyY + squigglyHeight);
+							if (cairo != 0 && OS.GTK_VERSION >= OS.VERSION(2, 8, 0)) {
+								Cairo.cairo_set_line_width(cairo, squigglyThickness);
+								Cairo.cairo_set_line_cap(cairo, Cairo.CAIRO_LINE_CAP_BUTT);
+								Cairo.cairo_set_line_join(cairo, Cairo.CAIRO_LINE_JOIN_MITER);
+								if (points.length > 0) {
+									double xOffset = 0.5, yOffset = 0.5; 
+									Cairo.cairo_move_to(cairo, points[0] + xOffset, points[1] + yOffset);
+									for (int k = 2; k < points.length; k += 2) {
+										Cairo.cairo_line_to(cairo, points[k] + xOffset, points[k + 1] + yOffset);
+									}
+									Cairo.cairo_stroke(cairo);
+								}
+							} else {	
+								OS.gdk_gc_set_line_attributes(gdkGC, squigglyThickness, OS.GDK_LINE_SOLID, OS.GDK_CAP_BUTT, OS.GDK_JOIN_MITER);
+								OS.gdk_draw_lines(data.drawable, gdkGC, points, points.length / 2);
+							}
+							break;
+						}
+						case SWT.UNDERLINE_DOUBLE:
+							if (cairo != 0 && OS.GTK_VERSION >= OS.VERSION(2, 8, 0)) {
+								Cairo.cairo_rectangle(cairo, rect.x, underlineY + underlineThickness * 2, rect.width, underlineThickness);
+								Cairo.cairo_fill(cairo);
+							} else {
+								OS.gdk_draw_rectangle(data.drawable, gdkGC, 1, rect.x, underlineY + underlineThickness * 2, rect.width, underlineThickness);
+							}
+							//FALLTHROUGH
+						case SWT.UNDERLINE_SINGLE:
+							if (cairo != 0 && OS.GTK_VERSION >= OS.VERSION(2, 8, 0)) {
+								Cairo.cairo_rectangle(cairo, rect.x, underlineY, rect.width, underlineThickness);
+								Cairo.cairo_fill(cairo);
+							} else {
+								OS.gdk_draw_rectangle(data.drawable, gdkGC, 1, rect.x, underlineY, rect.width, underlineThickness);
+							}
+							break;
+					}
+				}
+				if (rects[0] != 0) OS.g_free(rects[0]);
+				OS.gdk_region_destroy(rgn);
+			}
+		}
+		
+		boolean drawStrikeout = false;
+		if (style.strikeout && style.strikeoutColor != null) drawStrikeout = true;
+		if (drawStrikeout && !style.isAdherentStrikeout(styles[i+1].style)) {
+			int start = styles[i].start;
+			for (int j = i; j > 0 && style.isAdherentStrikeout(styles[j-1].style); j--) {
+				start = styles[j - 1].start;
+			}
+			start = translateOffset(start);
+			int end = translateOffset(styles[i+1].start - 1);
+			int byteStart = (int)/*64*/(OS.g_utf8_offset_to_pointer(ptr, start) - ptr);
+			int byteEnd = (int)/*64*/(OS.g_utf8_offset_to_pointer(ptr, end + 1) - ptr);
+			int[] ranges = new int[]{byteStart, byteEnd};
+			int /*long*/ rgn = OS.gdk_pango_layout_get_clip_region(layout, x, y, ranges, ranges.length / 2);
+			if (rgn != 0) {
+				int[] nRects = new int[1];
+				int /*long*/[] rects = new int /*long*/[1];
+				OS.gdk_region_get_rectangles(rgn, rects, nRects);
+				GdkRectangle rect = new GdkRectangle();
+				GdkColor color = null;
+				if (color == null && style.strikeoutColor != null) color = style.strikeoutColor.handle;
+				if (color == null && selectionColor != null) color = selectionColor;
+				if (color == null && style.foreground != null) color = style.foreground.handle;
+				if (color == null) color = data.foreground;
+				if (cairo != 0 && OS.GTK_VERSION >= OS.VERSION(2, 8, 0)) {
+					Cairo.cairo_set_source_rgba(cairo, (color.red & 0xFFFF) / (float)0xFFFF, (color.green & 0xFFFF) / (float)0xFFFF, (color.blue & 0xFFFF) / (float)0xFFFF, data.alpha / (float)0xFF);
+				} else {
+					if (gcValues == null) {
+						gcValues = new GdkGCValues();
+						OS.gdk_gc_get_values(gdkGC, gcValues);
+					}
+					OS.gdk_gc_set_foreground(gdkGC, color);
+				}
+				int strikeoutPosition = -1;
+				int strikeoutThickness = 1;
+				if (OS.GTK_VERSION >= OS.VERSION(2, 6, 0)) {
+					Font font = style.font;
+					if (font == null) font = this.font;
+					if (font == null) font = device.systemFont;
+					int /*long*/ lang = OS.pango_context_get_language(context);
+					int /*long*/ metrics = OS.pango_context_get_metrics(context, font.handle, lang);
+					strikeoutPosition = OS.PANGO_PIXELS(OS.pango_font_metrics_get_strikethrough_position(metrics));
+					strikeoutThickness = OS.PANGO_PIXELS(OS.pango_font_metrics_get_strikethrough_thickness(metrics));
+					OS.pango_font_metrics_unref(metrics);
+				}
+				for (int j=0; j<nRects[0]; j++) {
+					OS.memmove(rect, rects[0] + (j * GdkRectangle.sizeof), GdkRectangle.sizeof);
+					int strikeoutY = rect.y + rect.height / 2 - style.rise;
+					if (OS.GTK_VERSION >= OS.VERSION(2, 6, 0)) {
+						int offset = getOffset(rect.x - x, rect.y - y, null);
+						int lineIndex = getLineIndex(offset);
+						FontMetrics metrics = getLineMetrics(lineIndex);
+						strikeoutY = rect.y + metrics.ascent - strikeoutPosition - style.rise;
+					}
+					if (cairo != 0 && OS.GTK_VERSION >= OS.VERSION(2, 8, 0)) {
+						Cairo.cairo_rectangle(cairo, rect.x, strikeoutY, rect.width, strikeoutThickness);
+						Cairo.cairo_fill(cairo);
+					} else {
+						OS.gdk_draw_rectangle(data.drawable, gdkGC, 1, rect.x, strikeoutY, rect.width, strikeoutThickness);
+					}
+				}
+				if (rects[0] != 0) OS.g_free(rects[0]);
+				OS.gdk_region_destroy(rgn);
+			}
+		}
+	}
+	if (gcValues != null) {
+		int mask = OS.GDK_GC_FOREGROUND | OS.GDK_GC_LINE_WIDTH | OS.GDK_GC_LINE_STYLE | OS.GDK_GC_CAP_STYLE | OS.GDK_GC_JOIN_STYLE;
+		OS.gdk_gc_set_values(gdkGC, gcValues, mask);
+		data.state &= ~GC.LINE_STYLE;
+	}
+	if (cairo != 0 && OS.GTK_VERSION >= OS.VERSION(2, 8, 0)) {
+		Cairo.cairo_restore(cairo);
+	}
+}
+
+void freeRuns() {
+	if (attrList == 0) return;
+	OS.pango_layout_set_attributes(layout, 0);
+	OS.pango_attr_list_unref(attrList);
+	attrList = 0;
+	invalidOffsets = null;
+}
+
+/** 
+ * Returns the receiver's horizontal text alignment, which will be one
+ * of <code>SWT.LEFT</code>, <code>SWT.CENTER</code> or
+ * <code>SWT.RIGHT</code>.
+ *
+ * @return the alignment used to positioned text horizontally
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public int getAlignment() {
+	checkLayout();
+	int align = OS.pango_layout_get_alignment(layout);
+	boolean rtl = OS.pango_context_get_base_dir(context) == OS.PANGO_DIRECTION_RTL;
+	switch (align) {
+		case OS.PANGO_ALIGN_LEFT: return rtl ? SWT.RIGHT : SWT.LEFT;
+		case OS.PANGO_ALIGN_RIGHT: return rtl ? SWT.LEFT : SWT.RIGHT;
+	}
+	return SWT.CENTER;
+}
+
+/**
+ * Returns the ascent of the receiver.
+ *
+ * @return the ascent
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @see #getDescent()
+ * @see #setDescent(int)
+ * @see #setAscent(int)
+ * @see #getLineMetrics(int)
+ */
+public int getAscent () {
+	checkLayout();
+	return ascent;
+}
+
+/**
+ * Returns the bounds of the receiver. The width returned is either the
+ * width of the longest line or the width set using {@link TextLayout#setWidth(int)}.
+ * To obtain the text bounds of a line use {@link TextLayout#getLineBounds(int)}.
+ * 
+ * @return the bounds of the receiver
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @see #setWidth(int)
+ * @see #getLineBounds(int)
+ */
+public Rectangle getBounds() {
+	checkLayout();
+	computeRuns();
+	int[] w = new int[1], h = new int[1];
+	OS.pango_layout_get_size(layout, w, h);
+	int wrapWidth = OS.pango_layout_get_width(layout);
+	w[0] = wrapWidth != -1 ? wrapWidth : w[0] + OS.pango_layout_get_indent(layout);
+	int width = OS.PANGO_PIXELS(w[0]);
+	int height = OS.PANGO_PIXELS(h[0]);
+	if (ascent != -1 && descent != -1) {
+		height = Math.max (height, ascent + descent);
+	}
+	return new Rectangle(0, 0, width, height);
+}
+
+/**
+ * Returns the bounds for the specified range of characters. The
+ * bounds is the smallest rectangle that encompasses all characters
+ * in the range. The start and end offsets are inclusive and will be
+ * clamped if out of range.
+ * 
+ * @param start the start offset
+ * @param end the end offset
+ * @return the bounds of the character range
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public Rectangle getBounds(int start, int end) {
+	checkLayout();
+	computeRuns();
+	int length = text.length();
+	if (length == 0) return new Rectangle(0, 0, 0, 0);
+	if (start > end) return new Rectangle(0, 0, 0, 0);
+	start = Math.min(Math.max(0, start), length - 1);
+	end = Math.min(Math.max(0, end), length - 1);
+	start = translateOffset(start);
+	end = translateOffset(end);
+	int /*long*/ ptr = OS.pango_layout_get_text(layout);
+	int byteStart = (int)/*64*/(OS.g_utf8_offset_to_pointer (ptr, start) - ptr);
+	int byteEnd = (int)/*64*/(OS.g_utf8_offset_to_pointer (ptr, end + 1) - ptr);
+	int strlen = OS.strlen(ptr);
+	byteStart = Math.min(byteStart, strlen);
+	byteEnd = Math.min(byteEnd, strlen);
+	int[] ranges = new int[]{byteStart, byteEnd};
+	int /*long*/ clipRegion = OS.gdk_pango_layout_get_clip_region(layout, 0, 0, ranges, 1);
+	if (clipRegion == 0) return new Rectangle(0, 0, 0, 0);
+	GdkRectangle rect = new GdkRectangle();
+	
+	/* 
+	* Bug in Pango. The region returned by gdk_pango_layout_get_clip_region()
+	* includes areas from lines outside of the requested range.  The fix
+	* is to subtract these areas from the clip region.
+	*/
+	PangoRectangle pangoRect = new PangoRectangle();
+	int /*long*/ iter = OS.pango_layout_get_iter(layout);
+	if (iter == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+	int /*long*/ linesRegion = OS.gdk_region_new();
+	if (linesRegion == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+	int lineEnd = 0;
+	do {
+		OS.pango_layout_iter_get_line_extents(iter, null, pangoRect);
+		if (OS.pango_layout_iter_next_line(iter)) {
+			lineEnd = OS.pango_layout_iter_get_index(iter) - 1;
+		} else {
+			lineEnd = strlen;
+		}
+		if (byteStart > lineEnd) continue;
+		rect.x = OS.PANGO_PIXELS(pangoRect.x);
+		rect.y = OS.PANGO_PIXELS(pangoRect.y);
+		rect.width = OS.PANGO_PIXELS(pangoRect.width);
+		rect.height = OS.PANGO_PIXELS(pangoRect.height);
+		OS.gdk_region_union_with_rect(linesRegion, rect);
+	} while (lineEnd + 1 <= byteEnd);
+	OS.gdk_region_intersect(clipRegion, linesRegion);
+	OS.gdk_region_destroy(linesRegion);
+	OS.pango_layout_iter_free(iter);
+	
+	OS.gdk_region_get_clipbox(clipRegion, rect);
+	OS.gdk_region_destroy(clipRegion);
+	if (OS.pango_context_get_base_dir(context) == OS.PANGO_DIRECTION_RTL) {
+		rect.x = width() - rect.x - rect.width;
+	}
+	return new Rectangle(rect.x, rect.y, rect.width, rect.height);
+}
+
+/**
+ * Returns the descent of the receiver.
+ *
+ * @return the descent
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @see #getAscent()
+ * @see #setAscent(int)
+ * @see #setDescent(int)
+ * @see #getLineMetrics(int)
+ */
+public int getDescent () {
+	checkLayout();
+	return descent;
+}
+
+/** 
+ * Returns the default font currently being used by the receiver
+ * to draw and measure text.
+ *
+ * @return the receiver's font
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public Font getFont () {
+	checkLayout();
+	return font;
+}
+
+/**
+* Returns the receiver's indent.
+*
+* @return the receiver's indent
+* 
+* @exception SWTException <ul>
+*    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+* </ul>
+* 
+* @since 3.2
+*/
+public int getIndent () {
+	checkLayout();
+	return OS.PANGO_PIXELS(OS.pango_layout_get_indent(layout));
+}
+
+/**
+* Returns the receiver's justification.
+*
+* @return the receiver's justification
+* 
+* @exception SWTException <ul>
+*    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+* </ul>
+* 
+* @since 3.2
+*/
+public boolean getJustify () {
+	checkLayout();
+	return OS.pango_layout_get_justify(layout);
+}
+
+/**
+ * Returns the embedding level for the specified character offset. The
+ * embedding level is usually used to determine the directionality of a
+ * character in bidirectional text.
+ * 
+ * @param offset the character offset
+ * @return the embedding level
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the character offset is out of range</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ */
+public int getLevel(int offset) {
+	checkLayout();
+	computeRuns();
+	int length = text.length();
+	if (!(0 <= offset && offset <= length)) SWT.error(SWT.ERROR_INVALID_RANGE);
+	offset = translateOffset(offset);
+	int /*long*/ iter = OS.pango_layout_get_iter(layout);
+	if (iter == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+	int level = 0;
+	PangoItem item = new PangoItem();
+	PangoLayoutRun run = new PangoLayoutRun();
+	int /*long*/ ptr = OS.pango_layout_get_text(layout);
+	int /*long*/ byteOffset = OS.g_utf8_offset_to_pointer(ptr, offset) - ptr;
+	int strlen = OS.strlen(ptr);
+	byteOffset = Math.min(byteOffset, strlen);
+	do {
+		int /*long*/ runPtr = OS.pango_layout_iter_get_run(iter);
+		if (runPtr != 0) {
+			OS.memmove(run, runPtr, PangoLayoutRun.sizeof);
+			OS.memmove(item, run.item, PangoItem.sizeof);
+			if (item.offset <= byteOffset && byteOffset < item.offset + item.length) {
+				level = item.analysis_level;
+				break;
+			}
+		}
+	} while (OS.pango_layout_iter_next_run(iter));
+	OS.pango_layout_iter_free(iter);
+	return level;
+}
+
+/**
+ * Returns the bounds of the line for the specified line index.
+ * 
+ * @param lineIndex the line index
+ * @return the line bounds 
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the line index is out of range</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public Rectangle getLineBounds(int lineIndex) {
+	checkLayout();
+	computeRuns();
+	int lineCount = OS.pango_layout_get_line_count(layout);
+	if (!(0 <= lineIndex && lineIndex < lineCount)) SWT.error(SWT.ERROR_INVALID_RANGE);
+	int /*long*/ iter = OS.pango_layout_get_iter(layout);
+	if (iter == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+	for (int i = 0; i < lineIndex; i++) OS.pango_layout_iter_next_line(iter);
+	PangoRectangle rect = new PangoRectangle();
+	OS.pango_layout_iter_get_line_extents(iter, null, rect);
+	OS.pango_layout_iter_free(iter);
+	int x = OS.PANGO_PIXELS(rect.x);
+	int y = OS.PANGO_PIXELS(rect.y);
+	int width = OS.PANGO_PIXELS(rect.width);
+	int height = OS.PANGO_PIXELS(rect.height);
+	if (ascent != -1 && descent != -1) {
+		height = Math.max (height, ascent + descent);
+	}
+	if (OS.pango_context_get_base_dir(context) == OS.PANGO_DIRECTION_RTL) {
+		x = width() - x - width;
+	}
+	return new Rectangle(x, y, width, height);
+}
+
+/**
+ * Returns the receiver's line count. This includes lines caused
+ * by wrapping.
+ *
+ * @return the line count
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public int getLineCount() {
+	checkLayout ();
+	computeRuns();
+	return OS.pango_layout_get_line_count(layout);
+}
+
+/**
+ * Returns the index of the line that contains the specified
+ * character offset.
+ * 
+ * @param offset the character offset
+ * @return the line index
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the character offset is out of range</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public int getLineIndex(int offset) {
+	checkLayout ();
+	computeRuns();
+	int length = text.length();
+	if (!(0 <= offset && offset <= length)) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	offset = translateOffset(offset);
+	int line = 0;
+	int /*long*/ ptr = OS.pango_layout_get_text(layout);
+	int /*long*/ byteOffset = OS.g_utf8_offset_to_pointer(ptr,offset) - ptr;
+	int strlen = OS.strlen(ptr);
+	byteOffset = Math.min(byteOffset, strlen);
+	int /*long*/ iter = OS.pango_layout_get_iter(layout);
+	if (iter == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+	while (OS.pango_layout_iter_next_line(iter)) {
+		if (OS.pango_layout_iter_get_index(iter) > byteOffset) break;
+		line++;
+	}
+	OS.pango_layout_iter_free(iter);
+	return line;
+}
+
+/**
+ * Returns the font metrics for the specified line index.
+ * 
+ * @param lineIndex the line index
+ * @return the font metrics 
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the line index is out of range</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public FontMetrics getLineMetrics (int lineIndex) {
+	checkLayout ();
+	computeRuns();
+	int lineCount = OS.pango_layout_get_line_count(layout);
+	if (!(0 <= lineIndex && lineIndex < lineCount)) SWT.error(SWT.ERROR_INVALID_RANGE);
+	int ascent = 0, descent = 0;
+	PangoLayoutLine line = new PangoLayoutLine();
+	OS.memmove(line, OS.pango_layout_get_line(layout, lineIndex), PangoLayoutLine.sizeof);
+	if (line.runs == 0) {
+		int /*long*/ font = this.font != null ? this.font.handle : device.systemFont.handle;
+		int /*long*/ lang = OS.pango_context_get_language(context);
+		int /*long*/ metrics = OS.pango_context_get_metrics(context, font, lang);
+		ascent = OS.pango_font_metrics_get_ascent(metrics);
+		descent = OS.pango_font_metrics_get_descent(metrics);
+		OS.pango_font_metrics_unref(metrics);
+	} else {
+		PangoRectangle rect = new PangoRectangle();
+		OS.pango_layout_line_get_extents(OS.pango_layout_get_line(layout, lineIndex), null, rect);
+		ascent = -rect.y;
+		descent = rect.height - ascent;
+	}
+	ascent = Math.max(this.ascent, OS.PANGO_PIXELS(ascent));
+	descent = Math.max(this.descent, OS.PANGO_PIXELS(descent));
+	return FontMetrics.gtk_new(ascent, descent, 0, 0, ascent + descent);
+}
+
+/**
+ * Returns the line offsets.  Each value in the array is the
+ * offset for the first character in a line except for the last
+ * value, which contains the length of the text.
+ * 
+ * @return the line offsets
+ *  
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public int[] getLineOffsets() {
+	checkLayout();
+	computeRuns();
+	int lineCount = OS.pango_layout_get_line_count(layout);
+	int[] offsets = new int [lineCount + 1];
+	int /*long*/ ptr = OS.pango_layout_get_text(layout);
+	PangoLayoutLine line = new PangoLayoutLine();
+	for (int i = 0; i < lineCount; i++) {
+		int /*long*/ linePtr = OS.pango_layout_get_line(layout, i);
+		OS.memmove(line, linePtr, PangoLayoutLine.sizeof);
+		int pos = (int)/*64*/OS.g_utf8_pointer_to_offset(ptr, ptr + line.start_index);
+		offsets[i] = untranslateOffset(pos);
+	}
+	offsets[lineCount] = text.length();						 
+	return offsets;
+}
+
+/**
+ * Returns the location for the specified character offset. The
+ * <code>trailing</code> argument indicates whether the offset
+ * corresponds to the leading or trailing edge of the cluster.
+ * 
+ * @param offset the character offset
+ * @param trailing the trailing flag
+ * @return the location of the character offset
+ *  
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @see #getOffset(Point, int[])
+ * @see #getOffset(int, int, int[])
+ */
+public Point getLocation(int offset, boolean trailing) {
+	checkLayout();
+	computeRuns();
+	int length = text.length();
+	if (!(0 <= offset && offset <= length)) SWT.error(SWT.ERROR_INVALID_RANGE);
+	offset = translateOffset(offset);
+	int /*long*/ ptr = OS.pango_layout_get_text(layout);
+	int byteOffset = (int)/*64*/(OS.g_utf8_offset_to_pointer(ptr, offset) - ptr);
+	int strlen = OS.strlen(ptr);
+	byteOffset = Math.min(byteOffset, strlen);
+	PangoRectangle pos = new PangoRectangle();
+	OS.pango_layout_index_to_pos(layout, byteOffset, pos);
+	int x = trailing ? pos.x + pos.width : pos.x;
+	int y = pos.y;
+	x = OS.PANGO_PIXELS(x);
+	if (OS.pango_context_get_base_dir(context) == OS.PANGO_DIRECTION_RTL) {
+		x = width() - x;
+	}
+	return new Point(x, OS.PANGO_PIXELS(y));
+}
+
+/**
+ * Returns the next offset for the specified offset and movement
+ * type.  The movement is one of <code>SWT.MOVEMENT_CHAR</code>, 
+ * <code>SWT.MOVEMENT_CLUSTER</code>, <code>SWT.MOVEMENT_WORD</code>,
+ * <code>SWT.MOVEMENT_WORD_END</code> or <code>SWT.MOVEMENT_WORD_START</code>.
+ * 
+ * @param offset the start offset
+ * @param movement the movement type 
+ * @return the next offset
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the offset is out of range</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @see #getPreviousOffset(int, int)
+ */
+public int getNextOffset (int offset, int movement) {
+	return _getOffset(offset, movement, true);
+}
+
+int _getOffset (int offset, int movement, boolean forward) {
+	checkLayout();
+	computeRuns();
+	int length = text.length();
+	if (!(0 <= offset && offset <= length)) SWT.error(SWT.ERROR_INVALID_RANGE);
+	if (forward) {
+		if (offset == length) return length;
+	} else {
+		if (offset == 0) return 0;
+	}
+	int step = forward ? 1 : -1;
+	if ((movement & SWT.MOVEMENT_CHAR) != 0) return offset + step;
+	int /*long*/[] attrs = new int /*long*/[1];
+	int[] nAttrs = new int[1];
+	OS.pango_layout_get_log_attrs(layout, attrs, nAttrs);
+	if (attrs[0] == 0) return offset + step;
+	length = (int)/*64*/OS.g_utf8_strlen(OS.pango_layout_get_text(layout), -1);
+	offset = translateOffset(offset);
+	PangoLogAttr logAttr = new PangoLogAttr();
+	offset = validateOffset(offset, step);
+	while (0 < offset && offset < length) {
+		OS.memmove(logAttr, attrs[0] + offset * PangoLogAttr.sizeof, PangoLogAttr.sizeof);
+		if (((movement & SWT.MOVEMENT_CLUSTER) != 0) && logAttr.is_cursor_position) break; 
+		if ((movement & SWT.MOVEMENT_WORD) != 0) {
+			if (forward) {
+				if (logAttr.is_word_end) break;
+			} else {
+				if (logAttr.is_word_start) break;
+			}
+		}
+		if ((movement & SWT.MOVEMENT_WORD_START) != 0) {
+			if (logAttr.is_word_start) break;
+		}
+		if ((movement & SWT.MOVEMENT_WORD_END) != 0) {
+			if (logAttr.is_word_end) break;
+		}
+		offset = validateOffset(offset, step);
+	}
+	OS.g_free(attrs[0]);
+	return Math.min(Math.max(0, untranslateOffset(offset)), text.length());
+}
+
+/**
+ * Returns the character offset for the specified point.  
+ * For a typical character, the trailing argument will be filled in to 
+ * indicate whether the point is closer to the leading edge (0) or
+ * the trailing edge (1).  When the point is over a cluster composed 
+ * of multiple characters, the trailing argument will be filled with the 
+ * position of the character in the cluster that is closest to
+ * the point.
+ * 
+ * @param point the point
+ * @param trailing the trailing buffer
+ * @return the character offset
+ *  
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the trailing length is less than <code>1</code></li>
+ *    <li>ERROR_NULL_ARGUMENT - if the point is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @see #getLocation(int, boolean)
+ */
+public int getOffset(Point point, int[] trailing) {
+	checkLayout();
+	if (point == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	return getOffset(point.x, point.y, trailing);
+}
+
+/**
+ * Returns the character offset for the specified point.  
+ * For a typical character, the trailing argument will be filled in to 
+ * indicate whether the point is closer to the leading edge (0) or
+ * the trailing edge (1).  When the point is over a cluster composed 
+ * of multiple characters, the trailing argument will be filled with the 
+ * position of the character in the cluster that is closest to
+ * the point.
+ * 
+ * @param x the x coordinate of the point
+ * @param y the y coordinate of the point
+ * @param trailing the trailing buffer
+ * @return the character offset
+ *  
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the trailing length is less than <code>1</code></li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @see #getLocation(int, boolean)
+ */
+public int getOffset(int x, int y, int[] trailing) {
+	checkLayout();
+	computeRuns();
+	if (trailing != null && trailing.length < 1) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	if (OS.pango_context_get_base_dir(context) == OS.PANGO_DIRECTION_RTL) {
+		x = width() - x;
+	}
+	
+	/*
+	* Feature in GTK.  pango_layout_xy_to_index() returns the 
+	* logical end/start offset of a line when the coordinates are outside 
+	* the line bounds. In SWT the correct behavior is to return the closest 
+	* visual offset. The fix is to clamp the coordinates inside the  
+	* line bounds.
+	*/
+	int /*long*/ iter = OS.pango_layout_get_iter(layout);
+	if (iter == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+	PangoRectangle rect = new PangoRectangle();
+	do {
+		OS.pango_layout_iter_get_line_extents(iter, null, rect);
+		rect.y = OS.PANGO_PIXELS(rect.y);
+		rect.height = OS.PANGO_PIXELS(rect.height);
+		if (rect.y <= y && y < rect.y + rect.height) {
+			rect.x = OS.PANGO_PIXELS(rect.x);
+			rect.width = OS.PANGO_PIXELS(rect.width);
+			if (x >= rect.x + rect.width) x = rect.x + rect.width - 1;
+			if (x < rect.x) x = rect.x;
+			break;
+		}
+	} while (OS.pango_layout_iter_next_line(iter));
+	OS.pango_layout_iter_free(iter);
+	
+	int[] index = new int[1];
+	int[] piTrailing = new int[1];
+	OS.pango_layout_xy_to_index(layout, x * OS.PANGO_SCALE, y * OS.PANGO_SCALE, index, piTrailing);
+	int /*long*/ ptr = OS.pango_layout_get_text(layout);
+	int offset = (int)/*64*/OS.g_utf8_pointer_to_offset(ptr, ptr + index[0]);
+	if (trailing != null) trailing[0] = piTrailing[0];
+	return untranslateOffset(offset);
+}
+
+/**
+ * Returns the orientation of the receiver.
+ *
+ * @return the orientation style
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public int getOrientation() {
+	checkLayout();
+	int baseDir = OS.pango_context_get_base_dir(context);
+	return baseDir == OS.PANGO_DIRECTION_RTL ? SWT.RIGHT_TO_LEFT : SWT.LEFT_TO_RIGHT;
+}
+
+/**
+ * Returns the previous offset for the specified offset and movement
+ * type.  The movement is one of <code>SWT.MOVEMENT_CHAR</code>, 
+ * <code>SWT.MOVEMENT_CLUSTER</code> or <code>SWT.MOVEMENT_WORD</code>,
+ * <code>SWT.MOVEMENT_WORD_END</code> or <code>SWT.MOVEMENT_WORD_START</code>.
+ * 
+ * @param offset the start offset
+ * @param movement the movement type 
+ * @return the previous offset
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the offset is out of range</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @see #getNextOffset(int, int)
+ */
+public int getPreviousOffset (int index, int movement) {
+	return _getOffset(index, movement, false);
+}
+
+/**
+ * Gets the ranges of text that are associated with a <code>TextStyle</code>.
+ *
+ * @return the ranges, an array of offsets representing the start and end of each
+ * text style. 
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @see #getStyles()
+ * 
+ * @since 3.2
+ */
+public int[] getRanges () {
+	checkLayout();
+	int[] result = new int[styles.length * 2];
+	int count = 0;
+	for (int i=0; i<styles.length - 1; i++) {
+		if (styles[i].style != null) {
+			result[count++] = styles[i].start;
+			result[count++] = styles[i + 1].start - 1;
+		}
+	}
+	if (count != result.length) {
+		int[] newResult = new int[count];
+		System.arraycopy(result, 0, newResult, 0, count);
+		result = newResult;
+	}
+	return result;
+}
+
+/**
+ * Returns the text segments offsets of the receiver.
+ *
+ * @return the text segments offsets
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public int[] getSegments() {
+	checkLayout();
+	return segments;
+}
+
+String getSegmentsText() {
+	if (segments == null) return text;
+	int nSegments = segments.length;
+	if (nSegments <= 1) return text;
+	int length = text.length();
+	if (length == 0) return text;
+	if (nSegments == 2) {
+		if (segments[0] == 0 && segments[1] == length) return text;
+	}
+	char[] oldChars = new char[length];
+	text.getChars(0, length, oldChars, 0);
+	char[] newChars = new char[length + nSegments];
+	int charCount = 0, segmentCount = 0;
+	char separator = getOrientation() == SWT.RIGHT_TO_LEFT ? RTL_MARK : LTR_MARK;
+	while (charCount < length) {
+		if (segmentCount < nSegments && charCount == segments[segmentCount]) {
+			newChars[charCount + segmentCount++] = separator;
+		} else {
+			newChars[charCount + segmentCount] = oldChars[charCount++];
+		}
+	}
+	if (segmentCount < nSegments) {
+		segments[segmentCount] = charCount;
+		newChars[charCount + segmentCount++] = separator;
+	}
+	return new String(newChars, 0, Math.min(charCount + segmentCount, newChars.length));
+}
+
+/**
+ * Returns the line spacing of the receiver.
+ *
+ * @return the line spacing
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public int getSpacing () {
+	checkLayout();	
+	return OS.PANGO_PIXELS(OS.pango_layout_get_spacing(layout));
+}
+
+/**
+ * Gets the style of the receiver at the specified character offset.
+ *
+ * @param offset the text offset
+ * @return the style or <code>null</code> if not set
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the character offset is out of range</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public TextStyle getStyle (int offset) {
+	checkLayout();
+	int length = text.length();
+	if (!(0 <= offset && offset < length)) SWT.error(SWT.ERROR_INVALID_RANGE);
+	for (int i=1; i<styles.length; i++) {
+		StyleItem item = styles[i];
+		if (item.start > offset) {
+			return styles[i - 1].style;
+		}
+	}
+	return null;
+}
+
+/**
+ * Gets all styles of the receiver.
+ *
+ * @return the styles
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @see #getRanges()
+ * 
+ * @since 3.2
+ */
+public TextStyle[] getStyles () {
+	checkLayout();
+	TextStyle[] result = new TextStyle[styles.length];
+	int count = 0;
+	for (int i=0; i<styles.length; i++) {
+		if (styles[i].style != null) {
+			result[count++] = styles[i].style;
+		}
+	}
+	if (count != result.length) {
+		TextStyle[] newResult = new TextStyle[count];
+		System.arraycopy(result, 0, newResult, 0, count);
+		result = newResult;
+	}
+	return result;
+}
+
+/**
+ * Returns the tab list of the receiver.
+ *
+ * @return the tab list
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public int[] getTabs() {
+	checkLayout();
+	return tabs;
+}
+
+/**
+ * Gets the receiver's text, which will be an empty
+ * string if it has never been set.
+ *
+ * @return the receiver's text
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public String getText () {
+	checkLayout ();
+	return text;
+}
+
+/**
+ * Returns the width of the receiver.
+ *
+ * @return the width
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public int getWidth () {
+	checkLayout ();
+	int width = OS.pango_layout_get_width(layout);
+	return width != -1 ? OS.PANGO_PIXELS(width) : -1;
+}
+
+/**
+ * Returns <code>true</code> if the text layout has been disposed,
+ * and <code>false</code> otherwise.
+ * <p>
+ * This method gets the dispose state for the text layout.
+ * When a text layout has been disposed, it is an error to
+ * invoke any other method using the text layout.
+ * </p>
+ *
+ * @return <code>true</code> when the text layout is disposed and <code>false</code> otherwise
+ */
+public boolean isDisposed () {
+	return layout == 0;
+}
+
+/**
+ * Sets the text alignment for the receiver. The alignment controls
+ * how a line of text is positioned horizontally. The argument should
+ * be one of <code>SWT.LEFT</code>, <code>SWT.RIGHT</code> or <code>SWT.CENTER</code>.
+ * <p>
+ * The default alignment is <code>SWT.LEFT</code>.  Note that the receiver's
+ * width must be set in order to use <code>SWT.RIGHT</code> or <code>SWT.CENTER</code>
+ * alignment.
+ * </p>
+ *
+ * @param alignment the new alignment 
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @see #setWidth(int)
+ */
+public void setAlignment (int alignment) {
+	checkLayout();
+	int mask = SWT.LEFT | SWT.CENTER | SWT.RIGHT;
+	alignment &= mask;
+	if (alignment == 0) return;
+	if ((alignment & SWT.LEFT) != 0) alignment = SWT.LEFT; 
+	if ((alignment & SWT.RIGHT) != 0) alignment = SWT.RIGHT;
+	boolean rtl = OS.pango_context_get_base_dir(context) == OS.PANGO_DIRECTION_RTL;
+	int align = OS.PANGO_ALIGN_CENTER;
+	switch (alignment) {
+		case SWT.LEFT: 
+			align = rtl ? OS.PANGO_ALIGN_RIGHT : OS.PANGO_ALIGN_LEFT; 
+			break;
+		case SWT.RIGHT: 
+			align = rtl ? OS.PANGO_ALIGN_LEFT : OS.PANGO_ALIGN_RIGHT; 
+			break;
+	}
+	OS.pango_layout_set_alignment(layout, align);
+}
+
+/**
+ * Sets the ascent of the receiver. The ascent is distance in pixels
+ * from the baseline to the top of the line and it is applied to all
+ * lines. The default value is <code>-1</code> which means that the
+ * ascent is calculated from the line fonts.
+ *
+ * @param ascent the new ascent
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the ascent is less than <code>-1</code></li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @see #setDescent(int)
+ * @see #getLineMetrics(int)
+ */
+public void setAscent (int ascent) {
+	checkLayout();
+	if (ascent < -1) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	if (this.ascent == ascent) return;
+	freeRuns();
+	this.ascent = ascent;
+}
+
+/**
+ * Sets the descent of the receiver. The descent is distance in pixels
+ * from the baseline to the bottom of the line and it is applied to all
+ * lines. The default value is <code>-1</code> which means that the
+ * descent is calculated from the line fonts.
+ *
+ * @param descent the new descent
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the descent is less than <code>-1</code></li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @see #setAscent(int)
+ * @see #getLineMetrics(int)
+ */
+public void setDescent (int descent) {
+	checkLayout();
+	if (descent < -1) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	if (this.descent == descent) return;
+	freeRuns();
+	this.descent = descent;
+}
+
+/** 
+ * Sets the default font which will be used by the receiver
+ * to draw and measure text. If the
+ * argument is null, then a default font appropriate
+ * for the platform will be used instead. Note that a text
+ * style can override the default font.
+ *
+ * @param font the new font for the receiver, or null to indicate a default font
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the font has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void setFont (Font font) {
+	checkLayout ();
+	if (font != null && font.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	Font oldFont = this.font;
+	if (oldFont == font) return;
+	freeRuns();
+	this.font = font;
+	if (oldFont != null && oldFont.equals(font)) return;
+	OS.pango_layout_set_font_description(layout, font != null ? font.handle : device.systemFont.handle);
+}
+
+/**
+ * Sets the indent of the receiver. This indent it applied of the first line of 
+ * each paragraph.  
+ *
+ * @param indent new indent
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @since 3.2
+ */
+public void setIndent (int indent) {
+	checkLayout();
+	if (indent < 0) return;
+	OS.pango_layout_set_indent(layout, indent * OS.PANGO_SCALE);
+}
+
+/**
+ * Sets the justification of the receiver. Note that the receiver's
+ * width must be set in order to use justification. 
+ *
+ * @param justify new justify
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @since 3.2
+ */
+public void setJustify (boolean justify) {
+	checkLayout();
+	OS.pango_layout_set_justify(layout, justify);
+}
+
+/**
+ * Sets the orientation of the receiver, which must be one
+ * of <code>SWT.LEFT_TO_RIGHT</code> or <code>SWT.RIGHT_TO_LEFT</code>.
+ *
+ * @param orientation new orientation style
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void setOrientation(int orientation) {
+	checkLayout();
+	int mask = SWT.RIGHT_TO_LEFT | SWT.LEFT_TO_RIGHT;
+	orientation &= mask;
+	if (orientation == 0) return;
+	if ((orientation & SWT.LEFT_TO_RIGHT) != 0) orientation = SWT.LEFT_TO_RIGHT;
+	int baseDir = orientation == SWT.RIGHT_TO_LEFT ? OS.PANGO_DIRECTION_RTL : OS.PANGO_DIRECTION_LTR;
+	if (OS.pango_context_get_base_dir(context) == baseDir) return;
+	OS.pango_context_set_base_dir(context, baseDir);
+	OS.pango_layout_context_changed(layout);
+	int align = OS.pango_layout_get_alignment(layout);
+	if (align != OS.PANGO_ALIGN_CENTER) {
+		align = align == OS.PANGO_ALIGN_LEFT ? OS.PANGO_ALIGN_RIGHT : OS.PANGO_ALIGN_LEFT;
+		OS.pango_layout_set_alignment(layout, align);
+	}
+}
+
+/**
+ * Sets the line spacing of the receiver.  The line spacing
+ * is the space left between lines.
+ *
+ * @param spacing the new line spacing 
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the spacing is negative</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void setSpacing (int spacing) {
+	checkLayout();
+	if (spacing < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	OS.pango_layout_set_spacing(layout, spacing * OS.PANGO_SCALE);
+}
+
+/**
+ * Sets the offsets of the receiver's text segments. Text segments are used to
+ * override the default behaviour of the bidirectional algorithm.
+ * Bidirectional reordering can happen within a text segment but not 
+ * between two adjacent segments.
+ * <p>
+ * Each text segment is determined by two consecutive offsets in the 
+ * <code>segments</code> arrays. The first element of the array should 
+ * always be zero and the last one should always be equals to length of
+ * the text.
+ * </p>
+ * 
+ * @param segments the text segments offset
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void setSegments(int[] segments) {
+	checkLayout();
+	if (this.segments == null && segments == null) return;
+	if (this.segments != null && segments !=null) {
+		if (this.segments.length == segments.length) {
+			int i;
+			for (i = 0; i <segments.length; i++) {
+				if (this.segments[i] != segments[i]) break;
+			}
+			if (i == segments.length) return;
+		}
+	}
+	freeRuns();
+	this.segments = segments;
+}
+
+/**
+ * Sets the style of the receiver for the specified range.  Styles previously
+ * set for that range will be overwritten.  The start and end offsets are
+ * inclusive and will be clamped if out of range.
+ * 
+ * @param style the style
+ * @param start the start offset
+ * @param end the end offset
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void setStyle (TextStyle style, int start, int end) {
+	checkLayout();
+	int length = text.length();
+	if (length == 0) return;
+	if (start > end) return;
+	start = Math.min(Math.max(0, start), length - 1);
+	end = Math.min(Math.max(0, end), length - 1);
+	
+	/*
+	* Bug in Pango. Pango 1.2.2 will cause a segmentation fault if a style
+	* is not applied for a whole ligature.  The fix is to applied the
+	* style for the whole ligature.
+	* 
+	* NOTE that fix only LamAlef ligatures. 
+	*/
+	if (start > 0 && isAlef(text.charAt(start)) && isLam(text.charAt(start - 1))) {
+		start--;
+	}
+	if (end < length - 1 && isLam(text.charAt(end)) && isAlef(text.charAt(end + 1))) {
+		end++;
+	}
+
+	int low = -1;
+	int high = styles.length;
+	while (high - low > 1) {
+		int index = (high + low) / 2;
+		if (styles[index + 1].start > start) {
+			high = index;
+		} else {
+			low = index;
+		}
+	}
+	if (0 <= high && high < styles.length) {
+		StyleItem item = styles[high];
+		if (item.start == start && styles[high + 1].start - 1 == end) {
+			if (style == null) {
+				if (item.style == null) return;
+			} else {
+				if (style.equals(item.style)) return;
+			}
+		}
+	}
+	freeRuns();
+	int modifyStart = high;
+	int modifyEnd = modifyStart;
+	while (modifyEnd < styles.length) {
+		if (styles[modifyEnd + 1].start > end) break;
+		modifyEnd++;
+	}
+	if (modifyStart == modifyEnd) {
+		int styleStart = styles[modifyStart].start; 
+		int styleEnd = styles[modifyEnd + 1].start - 1;
+		if (styleStart == start && styleEnd == end) {
+			styles[modifyStart].style = style;
+			return;
+		}
+		if (styleStart != start && styleEnd != end) {
+			StyleItem[] newStyles = new StyleItem[styles.length + 2];
+			System.arraycopy(styles, 0, newStyles, 0, modifyStart + 1);
+			StyleItem item = new StyleItem();
+			item.start = start;
+			item.style = style;
+			newStyles[modifyStart + 1] = item;	
+			item = new StyleItem();
+			item.start = end + 1;
+			item.style = styles[modifyStart].style;
+			newStyles[modifyStart + 2] = item;
+			System.arraycopy(styles, modifyEnd + 1, newStyles, modifyEnd + 3, styles.length - modifyEnd - 1);
+			styles = newStyles;
+			return;
+		}
+	}
+	if (start == styles[modifyStart].start) modifyStart--;
+	if (end == styles[modifyEnd + 1].start - 1) modifyEnd++;
+	int newLength = styles.length + 1 - (modifyEnd - modifyStart - 1);
+	StyleItem[] newStyles = new StyleItem[newLength];
+	System.arraycopy(styles, 0, newStyles, 0, modifyStart + 1);	
+	StyleItem item = new StyleItem();
+	item.start = start;
+	item.style = style;
+	newStyles[modifyStart + 1] = item;
+	styles[modifyEnd].start = end + 1;
+	System.arraycopy(styles, modifyEnd, newStyles, modifyStart + 2, styles.length - modifyEnd);
+	styles = newStyles;
+}
+
+/**
+ * Sets the receiver's tab list. Each value in the tab list specifies
+ * the space in pixels from the origin of the text layout to the respective
+ * tab stop.  The last tab stop width is repeated continuously.
+ * 
+ * @param tabs the new tab list
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void setTabs(int[] tabs) {
+	checkLayout();
+	if (this.tabs == null && tabs == null) return;
+	if (this.tabs!= null && tabs != null) {
+		if (this.tabs.length == tabs.length) {
+			int i;
+			for (i = 0; i <tabs.length; i++) {
+				if (this.tabs[i] != tabs[i]) break;
+			}
+			if (i == tabs.length) return;
+		}
+	}
+	this.tabs = tabs;
+	if (tabs == null) {
+		OS.pango_layout_set_tabs(layout, device.emptyTab);
+	} else {
+		int /*long*/ tabArray = OS.pango_tab_array_new(tabs.length, true);
+		if (tabArray != 0) {
+			for (int i = 0; i < tabs.length; i++) {
+				OS.pango_tab_array_set_tab(tabArray, i, OS.PANGO_TAB_LEFT, tabs[i]);
+			}
+			OS.pango_layout_set_tabs(layout, tabArray);
+			OS.pango_tab_array_free(tabArray);
+		}		
+	}
+	/*
+	* Bug in Pango. A change in the tab stop array is not automatically reflected in the
+	* pango layout object because the call pango_layout_set_tabs() does not free the 
+	* lines cache. The fix to use pango_layout_context_changed() to free the lines cache.
+	*/
+	OS.pango_layout_context_changed(layout);
+}
+
+/**
+ * Sets the receiver's text.
+ *
+ * @param text the new text
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the text is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void setText (String text) {
+	checkLayout ();
+	if (text == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	if (text.equals(this.text)) return;
+	freeRuns();
+	this.text = text;
+	styles = new StyleItem[2];
+	styles[0] = new StyleItem();
+	styles[1] = new StyleItem();
+	styles[styles.length - 1].start = text.length();
+}
+
+/**
+ * Sets the line width of the receiver, which determines how
+ * text should be wrapped and aligned. The default value is
+ * <code>-1</code> which means wrapping is disabled.
+ *
+ * @param width the new width 
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the width is <code>0</code> or less than <code>-1</code></li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @see #setAlignment(int)
+ */
+public void setWidth (int width) {
+	checkLayout ();
+	if (width < -1 || width == 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	freeRuns();
+	if (width == -1) {
+		OS.pango_layout_set_width(layout, -1);
+		boolean rtl = OS.pango_context_get_base_dir(context) == OS.PANGO_DIRECTION_RTL;
+		OS.pango_layout_set_alignment(layout, rtl ? OS.PANGO_ALIGN_RIGHT : OS.PANGO_ALIGN_LEFT);
+	} else {
+		OS.pango_layout_set_width(layout, width * OS.PANGO_SCALE);
+	}
+}
+
+static final boolean isLam(int ch) {
+	return ch == 0x0644;
+}
+
+static final boolean isAlef(int ch) {
+	switch (ch) {
+		case 0x0622:
+		case 0x0623:
+		case 0x0625:
+		case 0x0627:
+		case 0x0649:
+		case 0x0670:
+		case 0x0671:
+		case 0x0672:
+		case 0x0673:
+		case 0x0675:
+			return true;
+	}
+	return false;
+}
+
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the receiver
+ */
+public String toString () {
+	if (isDisposed()) return "TextLayout {*DISPOSED*}";
+	return "TextLayout {" + layout + "}";
+}
+
+/*
+ *  Translate a client offset to an internal offset
+ */
+int translateOffset(int offset) {
+	int length = text.length();
+	if (length == 0) return offset;
+	if (invalidOffsets == null) return offset;
+	for (int i = 0; i < invalidOffsets.length; i++) {
+		if (offset < invalidOffsets[i]) break; 
+		offset++;
+	}
+	return offset;
+}
+
+/*
+ *  Translate an internal offset to a client offset
+ */
+int untranslateOffset(int offset) {
+	int length = text.length();
+	if (length == 0) return offset;
+	if (invalidOffsets == null) return offset;
+	for (int i = 0; i < invalidOffsets.length; i++) {
+		if (offset == invalidOffsets[i]) {
+			offset++;
+			continue;
+		}
+		if (offset < invalidOffsets[i]) {
+			return offset - i;
+		}
+	}
+	return offset - invalidOffsets.length;
+}
+
+int validateOffset(int offset, int step) {
+	if (invalidOffsets == null) return offset + step;
+	int i = step > 0 ? 0 : invalidOffsets.length - 1;
+	do {
+		offset += step;
+		while (0 <= i && i < invalidOffsets.length) {
+			if (invalidOffsets[i] == offset) break;
+			i += step;
+		}
+	} while (0 <= i && i < invalidOffsets.length);
+	return offset;
+}
+
+int width () {
+	int wrapWidth = OS.pango_layout_get_width(layout);
+	if (wrapWidth != -1) return OS.PANGO_PIXELS(wrapWidth); 
+	int[] w = new int[1], h = new int[1];
+	OS.pango_layout_get_size(layout, w, h);
+	return OS.PANGO_PIXELS(w[0] + OS.pango_layout_get_indent(layout));
+}
+
+} 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/TextStyle.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/TextStyle.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/TextStyle.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,336 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.graphics;
+
+import org.eclipse.swt.*;
+
+/**
+ * <code>TextStyle</code> defines a set of styles that can be applied
+ * to a range of text.
+ * <p>
+ * The hashCode() method in this class uses the values of the public
+ * fields to compute the hash value. When storing instances of the
+ * class in hashed collections, do not modify these fields after the
+ * object has been inserted.  
+ * </p>
+ * <p>
+ * Application code does <em>not</em> need to explicitly release the
+ * resources managed by each instance when those instances are no longer
+ * required, and thus no <code>dispose()</code> method is provided.
+ * </p>
+ * 
+ * @see TextLayout
+ * @see Font
+ * @see Color
+ * @see <a href="http://www.eclipse.org/swt/snippets/#textlayout">TextLayout, TextStyle snippets</a>
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ *  
+ * @since 3.0
+ */
+public class TextStyle {
+
+	/**
+	 * the font of the style
+	 */
+	public Font font;
+
+	/**
+	 * the foreground of the style
+	 */
+	public Color foreground;
+
+	/**
+	 * the background of the style
+	 */
+	public Color background;
+
+	/**
+	 * the underline flag of the style. The default underline
+	 * style is <code>SWT.UNDERLINE_SINGLE</code>.
+	 * 
+	 * 
+	 * @since 3.1
+	 */	
+	public boolean underline;
+	
+	/**
+	 * the underline color of the style
+	 * 
+	 * @since 3.4
+	 */	
+	public Color underlineColor;
+
+	/**
+	 * the underline style. This style is ignored when
+	 * <code>underline</code> is false.
+	 * <p> 
+	 * This value should be one of <code>SWT.UNDERLINE_SINGLE</code>,
+	 * <code>SWT.UNDERLINE_DOUBLE</code>, <code>SWT.UNDERLINE_ERROR</code>,
+	 * or <code>SWT.UNDERLINE_SQUIGGLE</code>.
+	 * </p>
+	 * 
+	 * @see SWT#UNDERLINE_SINGLE
+	 * @see SWT#UNDERLINE_DOUBLE 
+	 * @see SWT#UNDERLINE_ERROR
+	 * @see SWT#UNDERLINE_SQUIGGLE
+	 * 
+	 * @since 3.4
+	 */	
+	public int underlineStyle;
+
+	/**
+	 * the strikeout flag of the style
+	 * 
+	 * @since 3.1
+	 */	
+	public boolean strikeout;
+	
+	/**
+	 * the strikeout color of the style
+	 * 
+	 * @since 3.4
+	 */	
+	public Color strikeoutColor;
+	
+	/**
+	 * the border style. The default border style is <code>SWT.NONE</code>.
+	 * <p> 
+	 * This value should be one of <code>SWT.BORDER_SOLID</code>,
+	 * <code>SWT.BORDER_DASH</code>,<code>SWT.BORDER_DOT</code> or
+	 * <code>SWT.NONE</code>.
+	 * </p>
+	 * 
+	 * @see SWT#BORDER_SOLID
+	 * @see SWT#BORDER_DASH 
+	 * @see SWT#BORDER_DOT
+	 * @see SWT#NONE
+	 * 
+	 * @since 3.4
+	 */	
+	public int borderStyle;
+	
+	/**
+	 * the border color of the style
+	 * 
+	 * @since 3.4
+	 */	
+	public Color borderColor;
+	
+	/**
+	 * the GlyphMetrics of the style
+	 * 
+	 * @since 3.2
+	 */	
+	public GlyphMetrics metrics;
+	
+	/**
+	 * the baseline rise of the style. 
+	 * 
+	 * @since 3.2
+	 */	
+	public int rise;
+
+/** 
+ * Create an empty text style.
+ *
+ * @since 3.4
+ */
+public TextStyle () {
+}
+	
+/** 
+ * Create a new text style with the specified font, foreground
+ * and background.
+ *
+ * @param font the font of the style, <code>null</code> if none 
+ * @param foreground the foreground color of the style, <code>null</code> if none 
+ * @param background the background color of the style, <code>null</code> if none
+ */
+public TextStyle (Font font, Color foreground, Color background) {
+	if (font != null && font.isDisposed()) SWT.error (SWT.ERROR_INVALID_ARGUMENT);
+	if (foreground != null && foreground.isDisposed()) SWT.error (SWT.ERROR_INVALID_ARGUMENT);
+	if (background != null && background.isDisposed()) SWT.error (SWT.ERROR_INVALID_ARGUMENT);	
+	this.font = font;
+	this.foreground = foreground;
+	this.background = background;
+}
+
+
+/** 
+ * Create a new text style from an existing text style.
+ * 
+ * @param style the style to copy 
+ *
+ * @since 3.4
+ */
+public TextStyle (TextStyle style) {
+	if (style == null) SWT.error (SWT.ERROR_INVALID_ARGUMENT);
+	font = style.font;
+	foreground = style.foreground;
+	background = style.background;
+	underline = style.underline;
+	underlineColor = style.underlineColor;
+	underlineStyle = style.underlineStyle;
+	strikeout = style.strikeout;
+	strikeoutColor = style.strikeoutColor;
+	borderStyle = style.borderStyle;
+	borderColor = style.borderColor;
+	metrics = style.metrics;
+	rise = style.rise;
+}
+
+/**
+ * Compares the argument to the receiver, and returns true
+ * if they represent the <em>same</em> object using a class
+ * specific comparison.
+ *
+ * @param object the object to compare with this object
+ * @return <code>true</code> if the object is the same as this object and <code>false</code> otherwise
+ *
+ * @see #hashCode()
+ */
+public boolean equals(Object object) {
+	if (object == this) return true;
+	if (object == null) return false;
+	if (!(object instanceof TextStyle)) return false;
+	TextStyle style = (TextStyle)object;	
+	if (foreground != null) {
+		if (!foreground.equals(style.foreground)) return false;
+	} else if (style.foreground != null) return false;
+	if (background != null) {
+		if (!background.equals(style.background)) return false;
+	} else if (style.background != null) return false;
+	if (font != null) {
+		if (!font.equals(style.font)) return false;
+	} else if (style.font != null) return false;
+	if (metrics != null || style.metrics != null) return false;
+	if (underline != style.underline) return false;
+	if (underlineStyle != style.underlineStyle) return false;
+	if (borderStyle != style.borderStyle) return false;
+	if (strikeout != style.strikeout) return false;
+	if (rise != style.rise) return false;
+	if (underlineColor != null) {
+		if (!underlineColor.equals(style.underlineColor)) return false;
+	} else if (style.underlineColor != null) return false;
+	if (strikeoutColor != null) {
+		if (!strikeoutColor.equals(style.strikeoutColor)) return false;
+	} else if (style.strikeoutColor != null) return false;
+	if (underlineStyle != style.underlineStyle) return false;
+	if (borderColor != null) {
+		if (!borderColor.equals(style.borderColor)) return false;
+	} else if (style.borderColor != null) return false;
+	return true;
+}
+
+/**
+ * Returns an integer hash code for the receiver. Any two 
+ * objects that return <code>true</code> when passed to 
+ * <code>equals</code> must return the same value for this
+ * method.
+ *
+ * @return the receiver's hash
+ *
+ * @see #equals(Object)
+ */
+public int hashCode() {
+	int hash = 0;
+	if (foreground != null) hash ^= foreground.hashCode();
+	if (background != null) hash ^= background.hashCode();	
+	if (font != null) hash ^= font.hashCode();
+	if (metrics != null) hash ^= metrics.hashCode();
+	if (underline) hash ^= hash;
+	if (strikeout) hash ^= hash;
+	hash ^= rise;
+	if (underlineColor != null) hash ^= underlineColor.hashCode();
+	if (strikeoutColor != null) hash ^= strikeoutColor.hashCode();
+	if (borderColor != null) hash ^= borderColor.hashCode();
+	hash ^= underlineStyle;
+	return hash;
+}
+
+boolean isAdherentBorder(TextStyle style) {
+	if (this == style) return true;
+	if (style == null) return false;
+	if (borderStyle != style.borderStyle) return false;
+	if (borderColor != null) {
+		if (!borderColor.equals(style.borderColor)) return false;
+	} else if (style.borderColor != null) return false;
+	return true;
+}
+
+boolean isAdherentUnderline(TextStyle style) {
+	if (this == style) return true;
+	if (style == null) return false;
+	if (underline != style.underline) return false;
+	if (underlineStyle != style.underlineStyle) return false;
+	if (underlineColor != null) {
+		if (!underlineColor.equals(style.underlineColor)) return false;
+	} else if (style.underlineColor != null) return false;
+	return true;
+}
+
+boolean isAdherentStrikeout(TextStyle style) {
+	if (this == style) return true;
+	if (style == null) return false;
+	if (strikeout != style.strikeout) return false;
+	if (strikeoutColor != null) {
+		if (!strikeoutColor.equals(style.strikeoutColor)) return false;
+	} else if (style.strikeoutColor != null) return false;
+	return true;
+}
+
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the <code>TextStyle</code>
+ */
+public String toString () {
+	StringBuffer buffer = new StringBuffer("TextStyle {");
+	int startLength = buffer.length();
+	if (font != null) {
+		if (buffer.length() > startLength) buffer.append(", ");
+		buffer.append("font=");
+		buffer.append(font);
+	}
+	if (foreground != null) {
+		if (buffer.length() > startLength) buffer.append(", ");
+		buffer.append("foreground=");
+		buffer.append(foreground);
+	}
+	if (background != null) {
+		if (buffer.length() > startLength) buffer.append(", ");
+		buffer.append("background=");
+		buffer.append(background);
+	}
+	if (underline) {
+		if (buffer.length() > startLength) buffer.append(", ");
+		buffer.append("underlined");
+	}
+	if (strikeout) {
+		if (buffer.length() > startLength) buffer.append(", ");
+		buffer.append("striked out");
+	}
+	if (rise != 0) {
+		if (buffer.length() > startLength) buffer.append(", ");
+		buffer.append("rise=");
+		buffer.append(rise);
+	}
+	if (metrics != null) {
+		if (buffer.length() > startLength) buffer.append(", ");
+		buffer.append("metrics=");
+		buffer.append(metrics);
+	}
+	buffer.append("}");
+	return buffer.toString();
+}
+
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/Transform.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/Transform.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/graphics/Transform.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,387 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.graphics;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.cairo.*;
+
+/**
+ * Instances of this class represent transformation matrices for 
+ * points expressed as (x, y) pairs of floating point numbers.
+ * <p>
+ * Application code must explicitly invoke the <code>Transform.dispose()</code> 
+ * method to release the operating system resources managed by each instance
+ * when those instances are no longer required.
+ * </p>
+ * <p>
+ * This class requires the operating system's advanced graphics subsystem
+ * which may not be available on some platforms.
+ * </p>
+ * 
+ * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: GraphicsExample</a>
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ * 
+ * @since 3.1
+ */
+public class Transform extends Resource {
+	/**
+	 * the OS resource for the Transform
+	 * (Warning: This field is platform dependent)
+	 * <p>
+	 * <b>IMPORTANT:</b> This field is <em>not</em> part of the SWT
+	 * public API. It is marked public only so that it can be shared
+	 * within the packages provided by SWT. It is not available on all
+	 * platforms and should never be accessed from application code.
+	 * </p>
+	 */
+	public double[] handle;
+	
+/**
+ * Constructs a new identity Transform.
+ * <p>
+ * This operation requires the operating system's advanced
+ * graphics subsystem which may not be available on some
+ * platforms.
+ * </p>
+ * 
+ * @param device the device on which to allocate the Transform
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_NO_GRAPHICS_LIBRARY - if advanced graphics are not available</li>
+ * </ul>
+ * @exception SWTError <ul>
+ *    <li>ERROR_NO_HANDLES if a handle for the Transform could not be obtained</li>
+ * </ul>
+ * 
+ * @see #dispose()
+ */
+public Transform (Device device) {
+	this(device, 1, 0, 0, 1, 0, 0);
+}
+
+/**
+ * Constructs a new Transform given an array of elements that represent the 
+ * matrix that describes the transformation.
+ * <p>
+ * This operation requires the operating system's advanced
+ * graphics subsystem which may not be available on some
+ * platforms.
+ * </p>
+ * 
+ * @param device the device on which to allocate the Transform
+ * @param elements an array of floats that describe the transformation matrix
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device, or the elements array is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the elements array is too small to hold the matrix values</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_NO_GRAPHICS_LIBRARY - if advanced graphics are not available</li>
+ * </ul>
+ * @exception SWTError <ul>
+ *    <li>ERROR_NO_HANDLES if a handle for the Transform could not be obtained</li>
+ * </ul>
+ * 
+ * @see #dispose()
+ */
+public Transform(Device device, float[] elements) {
+	this (device, checkTransform(elements)[0], elements[1], elements[2], elements[3], elements[4], elements[5]);
+}
+
+/**
+ * Constructs a new Transform given all of the elements that represent the 
+ * matrix that describes the transformation.
+ * <p>
+ * This operation requires the operating system's advanced
+ * graphics subsystem which may not be available on some
+ * platforms.
+ * </p>
+ * 
+ * @param device the device on which to allocate the Transform
+ * @param m11 the first element of the first row of the matrix
+ * @param m12 the second element of the first row of the matrix
+ * @param m21 the first element of the second row of the matrix
+ * @param m22 the second element of the second row of the matrix
+ * @param dx the third element of the first row of the matrix
+ * @param dy the third element of the second row of the matrix
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_NO_GRAPHICS_LIBRARY - if advanced graphics are not available</li>
+ * </ul>
+ * @exception SWTError <ul>
+ *    <li>ERROR_NO_HANDLES if a handle for the Transform could not be obtained</li>
+ * </ul>
+ * 
+ * @see #dispose()
+ */
+public Transform (Device device, float m11, float m12, float m21, float m22, float dx, float dy) {
+	super(device);
+	this.device.checkCairo();
+	handle = new double[6];
+	if (handle == null) SWT.error(SWT.ERROR_NO_HANDLES);
+	Cairo.cairo_matrix_init(handle, m11, m12, m21, m22, dx, dy);
+	init();
+}
+
+static float[] checkTransform(float[] elements) {
+	if (elements == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	if (elements.length < 6) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	return elements;
+}
+
+void destroy() {
+	handle = null;
+}
+
+/**
+ * Fills the parameter with the values of the transformation matrix
+ * that the receiver represents, in the order {m11, m12, m21, m22, dx, dy}.
+ *
+ * @param elements array to hold the matrix values
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parameter is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the parameter is too small to hold the matrix values</li>
+ * </ul>
+ */
+public void getElements(float[] elements) {
+	if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	if (elements == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	if (elements.length < 6) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	elements[0] = (float)handle[0];
+	elements[1] = (float)handle[1];
+	elements[2] = (float)handle[2];
+	elements[3] = (float)handle[3];
+	elements[4] = (float)handle[4];
+	elements[5] = (float)handle[5];
+}
+
+/**
+ * Modifies the receiver such that the matrix it represents becomes the
+ * identity matrix. 
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @since 3.4
+ */
+public void identity() {
+	if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	Cairo.cairo_matrix_init(handle, 1, 0, 0, 1, 0, 0);
+}
+
+/**
+ * Modifies the receiver such that the matrix it represents becomes
+ * the mathematical inverse of the matrix it previously represented. 
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_CANNOT_INVERT_MATRIX - if the matrix is not invertible</li>
+ * </ul>
+ */
+public void invert() {
+	if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	if (Cairo.cairo_matrix_invert(handle) != 0) {
+		SWT.error(SWT.ERROR_CANNOT_INVERT_MATRIX);
+	}
+}
+
+/**
+ * Returns <code>true</code> if the Transform has been disposed,
+ * and <code>false</code> otherwise.
+ * <p>
+ * This method gets the dispose state for the Transform.
+ * When a Transform has been disposed, it is an error to
+ * invoke any other method using the Transform.
+ *
+ * @return <code>true</code> when the Transform is disposed, and <code>false</code> otherwise
+ */
+public boolean isDisposed() {
+	return handle == null;
+}
+
+/**
+ * Returns <code>true</code> if the Transform represents the identity matrix
+ * and false otherwise.
+ *
+ * @return <code>true</code> if the receiver is an identity Transform, and <code>false</code> otherwise
+ */
+public boolean isIdentity() {
+	if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	float[] m  = new float[6];
+	getElements(m);
+	return m[0] == 1 && m[1] == 0 && m[2] == 0 && m[3] == 1 && m[4] == 0 && m[5] == 0;
+}
+
+/**
+ * Modifies the receiver such that the matrix it represents becomes the
+ * the result of multiplying the matrix it previously represented by the
+ * argument. 
+ *
+ * @param matrix the matrix to multiply the receiver by
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parameter is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the parameter has been disposed</li>
+ * </ul>
+ */
+public void multiply(Transform matrix) {
+	if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	if (matrix == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	if (matrix.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	Cairo.cairo_matrix_multiply(handle, matrix.handle, handle);
+}
+
+/**
+ * Modifies the receiver so that it represents a transformation that is
+ * equivalent to its previous transformation rotated by the specified angle.
+ * The angle is specified in degrees and for the identity transform 0 degrees
+ * is at the 3 o'clock position. A positive value indicates a clockwise rotation
+ * while a negative value indicates a counter-clockwise rotation.
+ *
+ * @param angle the angle to rotate the transformation by
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void rotate(float angle) {
+	if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	Cairo.cairo_matrix_rotate(handle, angle * (float)Compatibility.PI / 180);
+}
+
+/**
+ * Modifies the receiver so that it represents a transformation that is
+ * equivalent to its previous transformation scaled by (scaleX, scaleY).
+ * 
+ * @param scaleX the amount to scale in the X direction
+ * @param scaleY the amount to scale in the Y direction
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void scale(float scaleX, float scaleY) {
+	if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	Cairo.cairo_matrix_scale(handle, scaleX, scaleY);
+}
+
+/**
+ * Modifies the receiver to represent a new transformation given all of
+ * the elements that represent the matrix that describes that transformation.
+ * 
+ * @param m11 the first element of the first row of the matrix
+ * @param m12 the second element of the first row of the matrix
+ * @param m21 the first element of the second row of the matrix
+ * @param m22 the second element of the second row of the matrix
+ * @param dx the third element of the first row of the matrix
+ * @param dy the third element of the second row of the matrix
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void setElements(float m11, float m12, float m21, float m22, float dx, float dy) {
+	if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	Cairo.cairo_matrix_init(handle, m11, m12, m21, m22, dx, dy);
+}
+
+/**
+ * Modifies the receiver so that it represents a transformation that is
+ * equivalent to its previous transformation sheared by (shearX, shearY).
+ * 
+ * @param shearX the shear factor in the X direction
+ * @param shearY the shear factor in the Y direction
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @since 3.4
+ */
+public void shear(float shearX, float shearY) {
+	if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	double[] matrix = {1, shearX, shearY, 1, 0, 0};
+	Cairo.cairo_matrix_multiply(handle, matrix, handle);
+}
+
+/** 
+ * Given an array containing points described by alternating x and y values,
+ * modify that array such that each point has been replaced with the result of
+ * applying the transformation represented by the receiver to that point.
+ *
+ * @param pointArray an array of alternating x and y values to be transformed
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the point array is null</li>
+ * </ul>	
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void transform(float[] pointArray) {
+	if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	if (pointArray == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	double[] dx = new double[1], dy = new double[1];
+	int length = pointArray.length / 2;
+	for (int i = 0, j = 0; i < length; i++, j += 2) {
+		dx[0] = pointArray[j];
+		dy[0] = pointArray[j + 1];
+		Cairo.cairo_matrix_transform_point(handle, dx, dy);
+		pointArray[j] = (float)dx[0];
+		pointArray[j + 1] = (float)dy[0];
+	}
+}
+
+/**
+ * Modifies the receiver so that it represents a transformation that is
+ * equivalent to its previous transformation translated by (offsetX, offsetY).
+ * 
+ * @param offsetX the distance to translate in the X direction
+ * @param offsetY the distance to translate in the Y direction
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void translate(float offsetX, float offsetY) {
+	if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+	Cairo.cairo_matrix_translate(handle, offsetX, offsetY);
+}
+
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the receiver
+ */
+public String toString() {
+	if (isDisposed()) return "Transform {*DISPOSED*}";
+	float[] elements = new float[6];
+	getElements(elements);
+	return "Transform {" + elements [0] + "," + elements [1] + "," +elements [2] + "," +elements [3] + "," +elements [4] + "," +elements [5] + "}";
+}
+
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/BidiUtil.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/BidiUtil.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/BidiUtil.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,114 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal;
+
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.widgets.Control;
+
+/*
+ * This class is supplied so that the StyledText code that supports bidi text (supported
+ * for win platforms) is not platform dependent.  Bidi text is not implemented on 
+ * emulated platforms.
+ */
+public class BidiUtil {
+	// Keyboard language types
+	public static final int KEYBOARD_NON_BIDI = 0;
+	public static final int KEYBOARD_BIDI = 1;
+
+	// bidi rendering input flag constants, not used
+	// on emulated platforms
+	public static final int CLASSIN = 1;
+	public static final int LINKBEFORE = 2;
+	public static final int LINKAFTER = 4;
+
+	// bidi rendering/ordering constants, not used on 
+	// emulated platforms
+	public static final int CLASS_HEBREW = 2;
+	public static final int CLASS_ARABIC = 2;
+	public static final int CLASS_LOCALNUMBER = 4;
+	public static final int CLASS_LATINNUMBER = 5;	
+	public static final int REORDER = 0;				
+	public static final int LIGATE = 0;
+	public static final int GLYPHSHAPE = 0;
+
+/*
+ * Not implemented.
+ */
+public static void addLanguageListener(int /*long*/ hwnd, Runnable runnable) {
+}
+public static void addLanguageListener (Control control, Runnable runnable) {
+}
+/*
+ * Not implemented.
+ *
+ */
+public static void drawGlyphs(GC gc, char[] renderBuffer, int[] renderDx, int x, int y) {
+}
+/*
+ * Bidi not supported on emulated platforms.
+ *
+ */
+public static boolean isBidiPlatform() {
+	return false;
+}
+/*
+ * Not implemented.
+ */
+public static boolean isKeyboardBidi() {
+	return false;
+}
+/*
+ * Not implemented.
+ */
+public static int getFontBidiAttributes(GC gc) {
+	return 0;	
+}
+/*
+ *  Not implemented.
+ *
+ */
+public static void getOrderInfo(GC gc, String text, int[] order, byte[] classBuffer, int flags, int [] offsets) {
+}
+/*
+ *  Not implemented. Returns null.
+ *
+ */
+public static char[] getRenderInfo(GC gc, String text, int[] order, byte[] classBuffer, int[] dx, int flags, int[] offsets) {
+	return null;
+}
+/*
+ * Not implemented. Returns 0.
+ */
+public static int getKeyboardLanguage() {
+	return 0;
+}
+/*
+ * Not implemented.
+ */
+public static void removeLanguageListener(int /*long*/ hwnd) {
+}	
+public static void removeLanguageListener (Control control) {
+}
+/*
+ * Not implemented.
+ */
+public static void setKeyboardLanguage(int language) {
+}
+/*
+ * Not implemented.
+ */
+public static boolean setOrientation(int /*long*/ hwnd, int orientation) {
+	return false;
+}
+public static boolean setOrientation (Control control, int orientation) {
+	return false;
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/C.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/C.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/C.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal;
+
+public class C extends Platform {
+
+	static {
+		if ("Linux".equals (System.getProperty ("os.name")) && "motif".equals (Platform.PLATFORM)) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+			try {
+				Library.loadLibrary ("libXm.so.2", false); //$NON-NLS-1$
+			} catch (Throwable ex) {}
+		}
+		Library.loadLibrary ("swt"); //$NON-NLS-1$
+	}
+
+	public static final int PTR_SIZEOF = PTR_sizeof ();
+
+public static final native void free (int /*long*/ ptr);
+public static final native int /*long*/ getenv (byte[] wcsToMbcs);
+public static final native int /*long*/ malloc (int /*long*/ size);
+public static final native void memmove (int /*long*/ dest, byte[] src, int /*long*/ size);
+public static final native void memmove (int /*long*/ dest, char[] src, int /*long*/ size);
+public static final native void memmove (int /*long*/ dest, double[] src, int /*long*/ size);
+public static final native void memmove (int /*long*/ dest, float[] src, int /*long*/ size);
+public static final native void memmove (int /*long*/ dest, int[] src, int /*long*/ size);
+public static final native void memmove (int /*long*/ dest, long[] src, int /*long*/ size);
+public static final native void memmove (int /*long*/ dest, short[] src, int /*long*/ size);
+public static final native void memmove (byte[] dest, char[] src, int /*long*/ size);
+public static final native void memmove (byte[] dest, int /*long*/ src, int /*long*/ size);
+public static final native void memmove (int /*long*/ dest, int /*long*/ src, int /*long*/ size);
+public static final native void memmove (char[] dest, int /*long*/ src, int /*long*/ size);
+public static final native void memmove (double[] dest, int /*long*/ src, int /*long*/ size);
+public static final native void memmove (float[] dest, int /*long*/ src, int /*long*/ size);
+public static final native void memmove (int[] dest, byte[] src, int /*long*/ size);
+public static final native void memmove (short[] dest, int /*long*/ src, int /*long*/ size);
+public static final native void memmove (int[] dest, int /*long*/ src, int /*long*/ size);
+public static final native void memmove (long[] dest, int /*long*/ src, int /*long*/ size);
+public static final native int /*long*/ memset (int /*long*/ buffer, int c, int /*long*/ num);
+public static final native int PTR_sizeof ();
+public static final native int strlen (int /*long*/ s);
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/Callback.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/Callback.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/Callback.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,243 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal;
+
+
+/**
+ * Instances of this class represent entry points into Java
+ * which can be invoked from operating system level callback
+ * routines.
+ * <p>
+ * IMPORTANT: A callback is only valid when invoked on the
+ * thread which created it. The results are undefined (and
+ * typically bad) when a callback is passed out to the 
+ * operating system (or other code) in such a way that the
+ * callback is called from a different thread.
+ */
+
+public class Callback {
+	
+	Object object;
+	String method, signature;
+	int argCount;
+	int /*long*/ address, errorResult;
+	boolean isStatic, isArrayBased;
+
+	static final String PTR_SIGNATURE = C.PTR_SIZEOF == 4 ? "I" : "J"; //$NON-NLS-1$  //$NON-NLS-2$
+	static final String SIGNATURE_0 = getSignature(0);
+	static final String SIGNATURE_1 = getSignature(1);
+	static final String SIGNATURE_2 = getSignature(2);
+	static final String SIGNATURE_3 = getSignature(3);
+	static final String SIGNATURE_4 = getSignature(4);
+	static final String SIGNATURE_N = "(["+PTR_SIGNATURE+")"+PTR_SIGNATURE; //$NON-NLS-1$  //$NON-NLS-2$
+
+/**
+ * Constructs a new instance of this class given an object
+ * to send the message to, a string naming the method to
+ * invoke and an argument count. Note that, if the object
+ * is an instance of <code>Class</code> it is assumed that
+ * the method is a static method on that class.
+ *
+ * @param object the object to send the message to
+ * @param method the name of the method to invoke
+ * @param argCount the number of arguments that the method takes
+ */
+public Callback (Object object, String method, int argCount) {
+	this (object, method, argCount, false);
+}
+
+/**
+ * Constructs a new instance of this class given an object
+ * to send the message to, a string naming the method to
+ * invoke, an argument count and a flag indicating whether
+ * or not the arguments will be passed in an array. Note 
+ * that, if the object is an instance of <code>Class</code>
+ * it is assumed that the method is a static method on that
+ * class.
+ *
+ * @param object the object to send the message to
+ * @param method the name of the method to invoke
+ * @param argCount the number of arguments that the method takes
+ * @param isArrayBased <code>true</code> if the arguments should be passed in an array and false otherwise
+ */
+public Callback (Object object, String method, int argCount, boolean isArrayBased) {
+	this (object, method, argCount, isArrayBased, 0);
+}
+
+/**
+ * Constructs a new instance of this class given an object
+ * to send the message to, a string naming the method to
+ * invoke, an argument count, a flag indicating whether
+ * or not the arguments will be passed in an array and a value
+ * to return when an exception happens. Note that, if
+ * the object is an instance of <code>Class</code>
+ * it is assumed that the method is a static method on that
+ * class.
+ *
+ * @param object the object to send the message to
+ * @param method the name of the method to invoke
+ * @param argCount the number of arguments that the method takes
+ * @param isArrayBased <code>true</code> if the arguments should be passed in an array and false otherwise
+ * @param errorResult the return value if the java code throws an exception
+ */
+public Callback (Object object, String method, int argCount, boolean isArrayBased, int /*long*/ errorResult) {
+
+	/* Set the callback fields */
+	this.object = object;
+	this.method = method;
+	this.argCount = argCount;
+	this.isStatic = object instanceof Class;
+	this.isArrayBased = isArrayBased;
+	this.errorResult = errorResult;
+	
+	/* Inline the common cases */
+	if (isArrayBased) {
+		signature = SIGNATURE_N;
+	} else {
+		switch (argCount) {
+			case 0: signature = SIGNATURE_0; break; //$NON-NLS-1$
+			case 1: signature = SIGNATURE_1; break; //$NON-NLS-1$
+			case 2: signature = SIGNATURE_2; break; //$NON-NLS-1$
+			case 3: signature = SIGNATURE_3; break; //$NON-NLS-1$
+			case 4: signature = SIGNATURE_4; break; //$NON-NLS-1$
+			default:
+				signature = getSignature(argCount);
+		}
+	}
+	
+	/* Bind the address */
+	address = bind (this, object, method, signature, argCount, isStatic, isArrayBased, errorResult);
+}
+
+/**
+ * Allocates the native level resources associated with the
+ * callback. This method is only invoked from within the
+ * constructor for the argument.
+ *
+ * @param callback the callback to bind
+ * @param object the callback's object
+ * @param method the callback's method
+ * @param signature the callback's method signature
+ * @param argCount the callback's method argument count
+ * @param isStatic whether the callback's method is static
+ * @param isArrayBased whether the callback's method is array based
+ * @param errorResult the callback's error result
+ */
+static native synchronized int /*long*/ bind (Callback callback, Object object, String method, String signature, int argCount, boolean isStatic, boolean isArrayBased, int /*long*/ errorResult);
+
+/**
+ * Releases the native level resources associated with the callback,
+ * and removes all references between the callback and
+ * other objects. This helps to prevent (bad) application code
+ * from accidentally holding onto extraneous garbage.
+ */
+public void dispose () {
+	if (object == null) return;
+	unbind (this);
+	object = method = signature = null;
+	address = 0;
+}
+
+/**
+ * Returns the address of a block of machine code which will
+ * invoke the callback represented by the receiver.
+ *
+ * @return the callback address
+ */
+public int /*long*/ getAddress () {
+	return address;
+}
+
+/**
+ * Returns the SWT platform name.
+ *
+ * @return the platform name of the currently running SWT
+ */
+public static native String getPlatform ();
+
+/**
+ * Returns the number of times the system has been recursively entered
+ * through a callback.
+ * <p>
+ * Note: This should not be called by application code.
+ * </p>
+ * 
+ * @return the entry count
+ * 
+ * @since 2.1
+ */
+public static native int getEntryCount ();
+
+static String getSignature(int argCount) {
+	String signature = "("; //$NON-NLS-1$
+	for (int i = 0; i < argCount; i++) signature += PTR_SIGNATURE;
+	signature += ")" + PTR_SIGNATURE; //$NON-NLS-1$
+	return signature;
+}
+
+/**
+ * Indicates whether or not callbacks which are triggered at the
+ * native level should cause the messages described by the matching
+ * <code>Callback</code> objects to be invoked. This method is used
+ * to safely shut down SWT when it is run within environments
+ * which can generate spurious events.
+ * <p>
+ * Note: This should not be called by application code.
+ * </p>
+ *
+ * @param enable true if callbacks should be invoked
+ */
+public static final native synchronized void setEnabled (boolean enable);
+
+/**
+ * Returns whether or not callbacks which are triggered at the
+ * native level should cause the messages described by the matching
+ * <code>Callback</code> objects to be invoked. This method is used
+ * to safely shut down SWT when it is run within environments
+ * which can generate spurious events.
+ * <p>
+ * Note: This should not be called by application code.
+ * </p>
+ *
+ * @return true if callbacks should not be invoked
+ */
+public static final native synchronized boolean getEnabled ();
+
+/**
+ * This might be called directly from native code in environments
+ * which can generate spurious events. Check before removing it.
+ *
+ * @deprecated
+ *
+ * @param ignore true if callbacks should not be invoked
+ */
+static final void ignoreCallbacks (boolean ignore) {
+	setEnabled (!ignore);
+} 
+
+/**
+ * Immediately wipes out all native level state associated
+ * with <em>all</em> callbacks.
+ * <p>
+ * <b>WARNING:</b> This operation is <em>extremely</em> dangerous,
+ * and should never be performed by application code.
+ * </p>
+ */
+public static final native synchronized void reset ();
+
+/**
+ * Releases the native level resources associated with the callback.
+ *
+ * @see #dispose
+ */
+static final native synchronized void unbind (Callback callback);
+
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/CloneableCompatibility.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/CloneableCompatibility.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/CloneableCompatibility.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal; 
+
+
+/**
+ * This interface is the cross-platform version of the
+ * java.lang.Cloneable interface.
+ * <p>
+ * It is part of our effort to provide support for both J2SE
+ * and J2ME platforms. Under this scheme, classes need to 
+ * implement CloneableCompatibility instead of java.lang.Cloneable.
+ * </p>
+ * <p>
+ * Note: java.lang.Cloneable is not part of CLDC.
+ * </p>
+ */
+public interface CloneableCompatibility extends Cloneable {
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/Compatibility.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/Compatibility.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/Compatibility.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,362 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal;
+
+ 
+import java.io.*;
+import java.text.MessageFormat;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+import java.util.zip.InflaterInputStream;
+import java.util.zip.DeflaterOutputStream;
+
+import org.eclipse.swt.SWT;
+
+/**
+ * This class is a placeholder for utility methods commonly
+ * used on J2SE platforms but not supported on some J2ME
+ * profiles.
+ * <p>
+ * It is part of our effort to provide support for both J2SE
+ * and J2ME platforms.
+ * </p>
+ * <p>
+ * IMPORTANT: some of the methods have been modified from their
+ * J2SE parents. Refer to the description of each method for 
+ * specific changes.
+ * </p>
+ * <ul>
+ * <li>Exceptions thrown may differ since J2ME's set of 
+ * exceptions is a subset of J2SE's one.
+ * </li>
+ * <li>The range of the mathematic functions is subject to
+ * change.
+ * </li>		
+ * </ul>
+ */
+public final class Compatibility {
+
+/**
+ * Returns the PI constant as a double.
+ */
+public static double PI = Math.PI;
+
+static double toRadians = PI / 180;
+
+/**
+ * Answers the length of the side adjacent to the given angle
+ * of a right triangle. In other words, it returns the integer
+ * conversion of length * cos (angle).
+ * <p>
+ * IMPORTANT: the j2me version has an additional restriction on
+ * the argument. length must be between -32767 and 32767 (inclusive).
+ * </p>
+ * 
+ * @param angle the angle in degrees
+ * @param length the length of the triangle's hypotenuse
+ * @return the integer conversion of length * cos (angle)
+ */
+public static int cos(int angle, int length) {
+	return (int)(Math.cos(angle * toRadians) * length);
+}
+
+/**
+ * Answers the length of the side opposite to the given angle
+ * of a right triangle. In other words, it returns the integer
+ * conversion of length * sin (angle).
+ * <p>
+ * IMPORTANT: the j2me version has an additional restriction on
+ * the argument. length must be between -32767 and 32767 (inclusive).
+ * </p>
+ * 
+ * @param angle the angle in degrees
+ * @param length the length of the triangle's hypotenuse
+ * @return the integer conversion of length * sin (angle)
+ */
+public static int sin(int angle, int length) {
+	return (int)(Math.sin(angle * toRadians) * length);
+}
+
+/**
+ * Answers the most negative (i.e. closest to negative infinity)
+ * integer value which is greater than the number obtained by dividing
+ * the first argument p by the second argument q.
+ * 
+ * @param p numerator
+ * @param q denominator (must be different from zero)
+ * @return the ceiling of the rational number p / q.
+ */
+public static int ceil(int p, int q) {
+	return (int)Math.ceil((float)p / q);
+}
+
+/**
+ * Answers whether the indicated file exists or not.
+ * 
+ * @param parent the file's parent directory
+ * @param child the file's name
+ * @return true if the file exists
+ */
+public static boolean fileExists(String parent, String child) {
+	return new File (parent, child).exists();
+}
+
+/**
+ * Answers the most positive (i.e. closest to positive infinity)
+ * integer value which is less than the number obtained by dividing
+ * the first argument p by the second argument q.
+ *
+ * @param p numerator
+ * @param q denominator (must be different from zero)
+ * @return the floor of the rational number p / q.
+ */
+public static int floor(int p, int q) {
+	return (int)Math.floor((double)p / q);
+}
+
+/**
+ * Answers the result of rounding to the closest integer the number obtained 
+ * by dividing the first argument p by the second argument q.
+ * <p>
+ * IMPORTANT: the j2me version has an additional restriction on
+ * the arguments. p must be within the range 0 - 32767 (inclusive).
+ * q must be within the range 1 - 32767 (inclusive).
+ * </p>
+ * 
+ * @param p numerator
+ * @param q denominator (must be different from zero)
+ * @return the closest integer to the rational number p / q
+ */
+public static int round(int p, int q) {
+	return Math.round((float)p / q);
+}
+
+/**
+ * Returns 2 raised to the power of the argument.
+ *
+ * @param n an int value between 0 and 30 (inclusive)
+ * @return 2 raised to the power of the argument
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_RANGE - if the argument is not between 0 and 30 (inclusive)</li>
+ * </ul>
+ */
+public static int pow2(int n) {
+	if (n >= 1 && n <= 30)
+		return 2 << (n - 1);
+	else if (n != 0) {
+		SWT.error(SWT.ERROR_INVALID_RANGE);
+	}
+	return 1;
+}
+
+/**
+ * Create an DeflaterOutputStream if such things are supported.
+ * 
+ * @param stream the output stream
+ * @return a deflater stream or <code>null</code>
+ * @exception IOException
+ * 
+ * @since 3.4
+ */
+public static OutputStream newDeflaterOutputStream(OutputStream stream) throws IOException {
+	return new DeflaterOutputStream(stream);
+}
+
+/**
+ * Open a file if such things are supported.
+ * 
+ * @param filename the name of the file to open
+ * @return a stream on the file if it could be opened.
+ * @exception IOException
+ */
+public static InputStream newFileInputStream(String filename) throws IOException {
+	return new FileInputStream(filename);
+}
+
+/**
+ * Open a file if such things are supported.
+ * 
+ * @param filename the name of the file to open
+ * @return a stream on the file if it could be opened.
+ * @exception IOException
+ */
+public static OutputStream newFileOutputStream(String filename) throws IOException {
+	return new FileOutputStream(filename);
+}
+
+/**
+ * Create an InflaterInputStream if such things are supported.
+ * 
+ * @param stream the input stream
+ * @return a inflater stream or <code>null</code>
+ * @exception IOException
+ * 
+ * @since 3.3
+ */
+public static InputStream newInflaterInputStream(InputStream stream) throws IOException {
+	return new BufferedInputStream(new InflaterInputStream(stream));
+}
+
+/**
+ * Answers whether the character is a letter.
+ *
+ * @param c the character
+ * @return true when the character is a letter
+ */
+public static boolean isLetter(char c) {
+	return Character.isLetter(c);
+}
+
+/**
+ * Answers whether the character is a letter or a digit.
+ *
+ * @param c the character
+ * @return true when the character is a letter or a digit
+ */
+public static boolean isLetterOrDigit(char c) {
+	return Character.isLetterOrDigit(c);
+}
+
+/**
+ * Answers whether the character is a Unicode space character.
+ *
+ * @param c	 the character
+ * @return true when the character is a Unicode space character
+ */
+public static boolean isSpaceChar(char c) {
+	return Character.isSpaceChar(c);
+}
+
+/**
+ * Answers whether the character is a whitespace character.
+ *
+ * @param c the character to test
+ * @return true if the character is whitespace
+ */
+public static boolean isWhitespace(char c) {
+	return Character.isWhitespace(c);
+}
+
+/**
+ * Execute a program in a separate platform process if the
+ * underlying platform support this.
+ * <p>
+ * The new process inherits the environment of the caller.
+ * </p>
+ *
+ * @param prog the name of the program to execute
+ *
+ * @exception IOException
+ *  if the program cannot be executed
+ * @exception SecurityException
+ *  if the current SecurityManager disallows program execution
+ */
+public static void exec(String prog) throws java.io.IOException {
+	Runtime.getRuntime().exec(prog);
+}
+
+/**
+ * Execute progArray[0] in a separate platform process if the
+ * underlying platform support this.
+ * <p>
+ * The new process inherits the environment of the caller.
+ * <p>
+ *
+ * @param progArray array containing the program to execute and its arguments
+ *
+ * @exception IOException
+ *  if the program cannot be executed
+ * @exception	SecurityException
+ *  if the current SecurityManager disallows program execution
+ */
+public static void exec(String[] progArray) throws java.io.IOException{
+	Runtime.getRuntime().exec(progArray);
+}
+
+private static ResourceBundle msgs = null;
+
+/**
+ * Returns the NLS'ed message for the given argument. This is only being
+ * called from SWT.
+ * 
+ * @param key the key to look up
+ * @return the message for the given key
+ * 
+ * @see SWT#getMessage(String)
+ */
+public static String getMessage(String key) {
+	String answer = key;
+	
+	if (key == null) {
+		SWT.error (SWT.ERROR_NULL_ARGUMENT);
+	}	
+	if (msgs == null) {
+		try {
+			msgs = ResourceBundle.getBundle("org.eclipse.swt.internal.SWTMessages"); //$NON-NLS-1$
+		} catch (MissingResourceException ex) {
+			answer = key + " (no resource bundle)"; //$NON-NLS-1$
+		}
+	}
+	if (msgs != null) {
+		try {
+			answer = msgs.getString(key);
+		} catch (MissingResourceException ex2) {}
+	}
+	return answer;
+}
+
+public static String getMessage(String key, Object[] args) {
+	String answer = key;
+	
+	if (key == null || args == null) {
+		SWT.error (SWT.ERROR_NULL_ARGUMENT);
+	}
+	if (msgs == null) {
+		try {
+			msgs = ResourceBundle.getBundle("org.eclipse.swt.internal.SWTMessages"); //$NON-NLS-1$
+		} catch (MissingResourceException ex) {
+			answer = key + " (no resource bundle)"; //$NON-NLS-1$
+		}
+	}
+	if (msgs != null) {
+		try {
+			MessageFormat formatter = new MessageFormat("");			
+			formatter.applyPattern(msgs.getString(key));			
+			answer = formatter.format(args);
+		} catch (MissingResourceException ex2) {}
+	}
+	return answer;
+}
+
+/**
+ * Interrupt the current thread. 
+ * <p>
+ * Note that this is not available on CLDC.
+ * </p>
+ */
+public static void interrupt() {
+	Thread.currentThread().interrupt();
+}
+
+/**
+ * Compares two instances of class String ignoring the case of the
+ * characters and answers if they are equal.
+ *
+ * @param s1 string
+ * @param s2 string
+ * @return true if the two instances of class String are equal
+ */
+public static boolean equalsIgnoreCase(String s1, String s2) {
+	return s1.equalsIgnoreCase(s2);
+}
+
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/Converter.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/Converter.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/Converter.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal;
+
+
+import org.eclipse.swt.internal.gtk.OS;
+
+/**
+ * This class implements the conversions between unicode characters
+ * and the <em>platform supported</em> representation for characters.
+ * <p>
+ * Note that, unicode characters which can not be found in the platform
+ * encoding will be converted to an arbitrary platform specific character.
+ * </p>
+ */
+public final class Converter {
+	public static final byte [] NullByteArray = new byte [1];
+	public static final byte [] EmptyByteArray = new byte [0];
+	public static final char [] EmptyCharArray = new char [0];
+
+/**
+ * Returns the default code page for the platform where the
+ * application is currently running.
+ *
+ * @return the default code page
+ */
+public static String defaultCodePage () {
+	return "UTF8";
+}
+
+public static char [] mbcsToWcs (String codePage, byte [] buffer) {
+	int /*long*/ [] items_written = new int /*long*/ [1];
+	int /*long*/ ptr = OS.g_utf8_to_utf16 (buffer, buffer.length, null, items_written, null);
+	if (ptr == 0) return EmptyCharArray;
+	int length = (int)/*64*/items_written [0];
+	char [] chars = new char [length];
+	OS.memmove (chars, ptr, length * 2);
+	OS.g_free (ptr);
+	return chars;
+}
+
+public static byte [] wcsToMbcs (String codePage, String string, boolean terminate) {
+	int length = string.length ();
+	char [] buffer = new char [length];
+	string.getChars (0, length, buffer, 0);
+	return wcsToMbcs (codePage, buffer, terminate);
+}
+
+public static byte [] wcsToMbcs (String codePage, char [] buffer, boolean terminate) {
+	int /*long*/ [] items_read = new int /*long*/ [1], items_written = new int /*long*/ [1];
+	/*
+	* Note that g_utf16_to_utf8()  stops converting 
+	* when it finds the first NULL.
+	*/
+	int /*long*/ ptr = OS.g_utf16_to_utf8 (buffer, buffer.length, items_read, items_written, null);
+	if (ptr == 0) return terminate ? NullByteArray : EmptyByteArray;
+	int written = (int)/*64*/items_written [0];
+	byte [] bytes = new byte [written + (terminate ? 1 : 0)];
+	OS.memmove (bytes, ptr, written);
+	OS.g_free (ptr);
+	return bytes;
+}
+
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/LONG.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/LONG.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/LONG.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal;
+
+public class LONG {
+	public int /*long*/ value;
+	
+	public LONG (int /*long*/ value) {
+		this.value = value;
+	}
+
+	public boolean equals (Object object) {
+		if (object == this) return true;
+		if (!(object instanceof LONG)) return false;
+		LONG obj = (LONG)object;
+		return obj.value == this.value;
+	}
+
+	public int hashCode () {
+		return (int)/*64*/value;
+	}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/Library.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/Library.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/Library.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,236 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal;
+
+import java.io.*;
+
+public class Library {
+
+	/* SWT Version - Mmmm (M=major, mmm=minor) */
+	
+	/**
+	 * SWT Major version number (must be >= 0)
+	 */
+    static int MAJOR_VERSION = 3;
+	
+	/**
+	 * SWT Minor version number (must be in the range 0..999)
+	 */
+    static int MINOR_VERSION = 452;
+	
+	/**
+	 * SWT revision number (must be >= 0)
+	 */
+	static int REVISION = 0;
+	
+	/**
+	 * The JAVA and SWT versions
+	 */
+	public static final int JAVA_VERSION, SWT_VERSION;
+
+	static final String SEPARATOR;
+
+static {
+	SEPARATOR = System.getProperty("file.separator");
+	JAVA_VERSION = parseVersion(System.getProperty("java.version"));
+	SWT_VERSION = SWT_VERSION(MAJOR_VERSION, MINOR_VERSION);
+}
+
+static int parseVersion(String version) {
+	if (version == null) return 0;
+	int major = 0, minor = 0, micro = 0;
+	int length = version.length(), index = 0, start = 0;
+	while (index < length && Character.isDigit(version.charAt(index))) index++;
+	try {
+		if (start < length) major = Integer.parseInt(version.substring(start, index));
+	} catch (NumberFormatException e) {}
+	start = ++index;
+	while (index < length && Character.isDigit(version.charAt(index))) index++;
+	try {
+		if (start < length) minor = Integer.parseInt(version.substring(start, index));
+	} catch (NumberFormatException e) {}
+	start = ++index;
+	while (index < length && Character.isDigit(version.charAt(index))) index++;
+	try {
+		if (start < length) micro = Integer.parseInt(version.substring(start, index));
+	} catch (NumberFormatException e) {}
+	return JAVA_VERSION(major, minor, micro);
+}
+
+/**
+ * Returns the Java version number as an integer.
+ * 
+ * @param major
+ * @param minor
+ * @param micro
+ * @return the version
+ */
+public static int JAVA_VERSION (int major, int minor, int micro) {
+	return (major << 16) + (minor << 8) + micro;
+}
+
+/**
+ * Returns the SWT version number as an integer.
+ * 
+ * @param major
+ * @param minor
+ * @return the version
+ */
+public static int SWT_VERSION (int major, int minor) {
+	return major * 1000 + minor;
+}
+
+static boolean extract (String fileName, String mappedName) {
+	FileOutputStream os = null;
+	InputStream is = null;
+	File file = new File(fileName);
+	try {
+		if (!file.exists ()) {
+			is = Library.class.getResourceAsStream ("/" + mappedName); //$NON-NLS-1$
+			if (is != null) {
+				int read;
+				byte [] buffer = new byte [4096];
+				os = new FileOutputStream (fileName);
+				while ((read = is.read (buffer)) != -1) {
+					os.write(buffer, 0, read);
+				}
+				os.close ();
+				is.close ();
+				if (!Platform.PLATFORM.equals ("win32")) { //$NON-NLS-1$
+					try {
+						Runtime.getRuntime ().exec (new String []{"chmod", "755", fileName}).waitFor(); //$NON-NLS-1$ //$NON-NLS-2$
+					} catch (Throwable e) {}
+				}
+				if (load (fileName)) return true;
+			}
+		}
+	} catch (Throwable e) {
+		try {
+			if (os != null) os.close ();
+		} catch (IOException e1) {}
+		try {
+			if (is != null) is.close ();
+		} catch (IOException e1) {}
+	}
+	if (file.exists ()) file.delete ();
+	return false;
+}
+
+static boolean load (String libName) {
+	try {
+		if (libName.indexOf (SEPARATOR) != -1) {
+			System.load (libName);
+		} else {
+			System.loadLibrary (libName);
+		}		
+		return true;
+	} catch (UnsatisfiedLinkError e) {}
+	return false;
+}
+
+/**
+ * Loads the shared library that matches the version of the
+ * Java code which is currently running.  SWT shared libraries
+ * follow an encoding scheme where the major, minor and revision
+ * numbers are embedded in the library name and this along with
+ * <code>name</code> is used to load the library.  If this fails,
+ * <code>name</code> is used in another attempt to load the library,
+ * this time ignoring the SWT version encoding scheme.
+ *
+ * @param name the name of the library to load
+ */
+public static void loadLibrary (String name) {
+	loadLibrary (name, true);
+}
+
+/**
+ * Loads the shared library that matches the version of the
+ * Java code which is currently running.  SWT shared libraries
+ * follow an encoding scheme where the major, minor and revision
+ * numbers are embedded in the library name and this along with
+ * <code>name</code> is used to load the library.  If this fails,
+ * <code>name</code> is used in another attempt to load the library,
+ * this time ignoring the SWT version encoding scheme.
+ *
+ * @param name the name of the library to load
+ * @param mapName true if the name should be mapped, false otherwise
+ */
+public static void loadLibrary (String name, boolean mapName) {
+	String prop = System.getProperty ("sun.arch.data.model"); //$NON-NLS-1$
+	if (prop == null) prop = System.getProperty ("com.ibm.vm.bitmode"); //$NON-NLS-1$
+	if (prop != null) {
+		if ("32".equals (prop)) { //$NON-NLS-1$
+			 if (0x1FFFFFFFFL == (int /*long*/)0x1FFFFFFFFL) {
+				throw new UnsatisfiedLinkError ("Cannot load 64-bit SWT libraries on 32-bit JVM"); //$NON-NLS-1$
+			 }
+		}
+		if ("64".equals (prop)) { //$NON-NLS-1$
+			if (0x1FFFFFFFFL != (int /*long*/)0x1FFFFFFFFL) {
+				throw new UnsatisfiedLinkError ("Cannot load 32-bit SWT libraries on 64-bit JVM"); //$NON-NLS-1$
+			}		
+		}
+	}
+	
+	/* Compute the library name and mapped name */
+	String libName1, libName2, mappedName1, mappedName2;
+	if (mapName) {
+		String version = System.getProperty ("swt.version"); //$NON-NLS-1$
+		if (version == null) {
+			version = "" + MAJOR_VERSION; //$NON-NLS-1$
+			/* Force 3 digits in minor version number */
+			if (MINOR_VERSION < 10) {
+				version += "00"; //$NON-NLS-1$
+			} else {
+				if (MINOR_VERSION < 100) version += "0"; //$NON-NLS-1$
+			}
+			version += MINOR_VERSION;		
+			/* No "r" until first revision */
+			if (REVISION > 0) version += "r" + REVISION; //$NON-NLS-1$
+		}
+		libName1 = name + "-" + Platform.PLATFORM + "-" + version;  //$NON-NLS-1$ //$NON-NLS-2$
+		libName2 = name + "-" + Platform.PLATFORM;  //$NON-NLS-1$
+		mappedName1 = System.mapLibraryName (libName1);
+		mappedName2 = System.mapLibraryName (libName2);
+	} else {
+		libName1 = libName2 = mappedName1 = mappedName2 = name;
+	}
+
+	/* Try loading library from swt library path */
+	String path = System.getProperty ("swt.library.path"); //$NON-NLS-1$
+	if (path != null) {
+		path = new File (path).getAbsolutePath ();
+		if (load (path + SEPARATOR + mappedName1)) return;
+		if (mapName && load (path + SEPARATOR + mappedName2)) return;
+	}
+
+	/* Try loading library from java library path */
+	if (load (libName1)) return;
+	if (mapName && load (libName2)) return;
+	
+	/* Try loading library from the tmp directory if swt library path is not specified */
+	if (path == null) {
+		path = System.getProperty ("java.io.tmpdir"); //$NON-NLS-1$
+		path = new File (path).getAbsolutePath ();
+		if (load (path + SEPARATOR + mappedName1)) return;
+		if (mapName && load (path + SEPARATOR + mappedName2)) return;
+	}
+		
+	/* Try extracting and loading library from jar */
+	if (path != null) {
+		if (extract (path + SEPARATOR + mappedName1, mappedName1)) return;
+		if (mapName && extract (path + SEPARATOR + mappedName2, mappedName2)) return;
+	}
+	
+	/* Failed to find the library */
+	throw new UnsatisfiedLinkError ("no " + libName1 + " or " + libName2 + " in swt.library.path, java.library.path or the jar file"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+}
+
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/Lock.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/Lock.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/Lock.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal;
+
+/**
+ * Instance of this represent a recursive monitor.
+ */
+public class Lock {
+	int count, waitCount;
+	Thread owner;
+
+/**
+ * Locks the monitor and returns the lock count. If
+ * the lock is owned by another thread, wait until
+ * the lock is released.
+ * 
+ * @return the lock count
+ */
+public int lock() {
+	synchronized (this) {
+		Thread current = Thread.currentThread();
+		if (owner != current) {
+			waitCount++;
+			while (count > 0) {
+				try {
+					wait();
+				} catch (InterruptedException e) {
+					/* Wait forever, just like synchronized blocks */
+				}
+			}
+			--waitCount;
+			owner = current;
+		}
+		return ++count;
+	}
+}
+
+/**
+ * Unlocks the monitor. If the current thread is not
+ * the monitor owner, do nothing.
+ */
+public void unlock() {
+	synchronized (this) {
+		Thread current = Thread.currentThread();
+		if (owner == current) {
+			if (--count == 0) {
+				owner = null;
+				if (waitCount > 0) notifyAll();
+			}
+		}
+	}
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/Platform.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/Platform.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/Platform.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,20 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 IBM Corporation and others. All rights reserved.
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt).  The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html.  If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal;
+
+public class Platform {
+	public static final String PLATFORM = "gtk"; //$NON-NLS-1$
+	public static final Lock lock = new Lock();
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/SWTEventListener.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/SWTEventListener.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/SWTEventListener.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal;
+
+
+import java.util.EventListener;
+
+/**
+ * This interface is the cross-platform version of the
+ * java.util.EventListener interface.
+ * <p>
+ * It is part of our effort to provide support for both J2SE
+ * and J2ME platforms. Under this scheme, classes need to 
+ * implement SWTEventListener instead of java.util.EventListener.
+ * </p>
+ * <p>
+ * Note: java.util.EventListener is not part of CDC and CLDC.
+ * </p>
+ */
+public interface SWTEventListener extends EventListener {
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/SWTEventObject.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/SWTEventObject.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/SWTEventObject.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal;
+
+ 
+import java.util.EventObject;
+
+/**
+ * This class is the cross-platform version of the
+ * java.util.EventObject class.
+ * <p>
+ * It is part of our effort to provide support for both J2SE
+ * and J2ME platforms. Under this scheme, classes need to 
+ * extend SWTEventObject instead of java.util.EventObject.
+ * </p>
+ * <p>
+ * Note: java.util.EventObject is not part of CDC and CLDC.
+ * </p>
+ */
+public class SWTEventObject extends EventObject {
+
+	static final long serialVersionUID = 3258125873411470903L;
+
+/**
+ * Constructs a new instance of this class.
+ *
+ * @param source the object which fired the event
+ */
+public SWTEventObject(Object source) {
+	super(source);
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/SWTMessages.properties
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/SWTMessages.properties	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/SWTMessages.properties	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,75 @@
+###############################################################################
+# Copyright (c) 2000, 2008 IBM Corporation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+#     IBM Corporation - initial API and implementation
+###############################################################################
+SWT_Yes=Yes
+SWT_No=No
+SWT_OK=OK
+SWT_Cancel=Cancel
+SWT_Abort=Abort
+SWT_Retry=Retry
+SWT_Ignore=Ignore
+SWT_Sample=Sample
+SWT_A_Sample_Text=A Sample Text
+SWT_Selection=Selection
+SWT_Current_Selection=Current Selection
+SWT_Font=Font
+SWT_Color=Color
+SWT_Extended_style=Extended style
+SWT_Size=Size
+SWT_Style=Style
+SWT_Save=Save
+SWT_Character_set=Character set
+SWT_ColorDialog_Title=Colors
+SWT_FontDialog_Title=Fonts
+SWT_FontSet=Font Set
+SWT_NewFont=New Font
+SWT_Remove=Remove
+SWT_Up=Up
+SWT_Down=Down
+SWT_Selection=Selection
+SWT_Charset_Western=western
+SWT_Charset_EastEuropean=eastern
+SWT_Charset_SouthEuropean=southern
+SWT_Charset_NorthEuropean=northern
+SWT_Charset_Cyrillic=cyrillic
+SWT_Charset_Arabic=arabic
+SWT_Charset_Greek=greek
+SWT_Charset_Hebrew=hebrew
+SWT_Charset_Turkish=turkish
+SWT_Charset_Nordic=nordic
+SWT_Charset_Thai=thai
+SWT_Charset_BalticRim=baltic rim
+SWT_Charset_Celtic=celtic
+SWT_Charset_Euro=euro
+SWT_Charset_Romanian=romanian
+SWT_Charset_SimplifiedChinese=simp. chinese
+SWT_Charset_TraditionalChinese=trad. chinese
+SWT_Charset_Japanese=japanese
+SWT_Charset_Korean=korean
+SWT_Charset_Unicode=unicode
+SWT_Charset_ASCII=ASCII
+SWT_InputMethods=Input Methods
+SWT_Password=Password:
+SWT_Username=User Name:
+SWT_Switch=Switch
+SWT_Press=Press
+SWT_Open=Open
+SWT_Close=Close
+SWT_Minimize=Minimize
+SWT_Maximize=Maximize
+SWT_Restore=Restore
+SWT_ShowList=Show List
+SWT_FileDownload=File Download
+SWT_Download_File=Download: {0}
+SWT_Download_Location=Saving {0} from {1}
+SWT_Download_Started=Downloading...
+SWT_Download_Status=Download: {0,number,integer} KB of {1,number,integer} KB
+SWT_Authentication_Required=Authentication Required
+SWT_Enter_Username_and_Password=Enter user name and password for {0} at {1}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/SWTMessages.properties
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/SerializableCompatibility.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/SerializableCompatibility.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/SerializableCompatibility.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal;
+
+
+import java.io.Serializable;
+
+/**
+ * This interface is the cross-platform version of the
+ * java.io.Serializable interface.
+ * <p>
+ * It is part of our effort to provide support for both J2SE
+ * and J2ME platforms. Under this scheme, classes need to 
+ * implement SerializableCompatibility instead of
+ * java.io.Serializable.
+ * </p>
+ * <p>
+ * Note: java.io.Serializable is not part of CLDC.
+ * </p>
+ */
+public interface SerializableCompatibility extends Serializable {
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/accessibility/gtk/ATK.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/accessibility/gtk/ATK.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/accessibility/gtk/ATK.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,333 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others. All rights reserved.
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt).  The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html.  If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.accessibility.gtk;
+
+
+import org.eclipse.swt.internal.Library;
+import org.eclipse.swt.internal.gtk.OS;
+
+public class ATK extends OS {
+	static {
+		Library.loadLibrary("swt-atk");
+	}
+	
+	/** Constants */
+	public static final int ATK_RELATION_LABELLED_BY = 4;
+	public static final int ATK_ROLE_CHECK_BOX = 7;
+	public static final int ATK_ROLE_COMBO_BOX = 11;
+	public static final int ATK_ROLE_DIALOG = 16;
+	public static final int ATK_ROLE_DRAWING_AREA = 18;
+	public static final int ATK_ROLE_WINDOW = 68;
+	public static final int ATK_ROLE_LABEL = 28;
+	public static final int ATK_ROLE_LIST = 30;
+	public static final int ATK_ROLE_LIST_ITEM = 31;
+	public static final int ATK_ROLE_MENU = 32;
+	public static final int ATK_ROLE_MENU_BAR = 33;
+	public static final int ATK_ROLE_MENU_ITEM = 34;
+	public static final int ATK_ROLE_PAGE_TAB = 36;
+	public static final int ATK_ROLE_PAGE_TAB_LIST = 37;
+	public static final int ATK_ROLE_PROGRESS_BAR = 41;
+	public static final int ATK_ROLE_PUSH_BUTTON = 42;
+	public static final int ATK_ROLE_RADIO_BUTTON = 43;
+	public static final int ATK_ROLE_SCROLL_BAR = 47;
+	public static final int ATK_ROLE_SEPARATOR = 49;
+	public static final int ATK_ROLE_SLIDER = 50;
+	public static final int ATK_ROLE_TABLE = 54;
+	public static final int ATK_ROLE_TABLE_CELL = 55;
+	public static final int ATK_ROLE_TABLE_COLUMN_HEADER = 56;
+	public static final int ATK_ROLE_TABLE_ROW_HEADER = 57;
+	public static final int ATK_ROLE_TEXT = 60;
+	public static final int ATK_ROLE_TOOL_BAR = 62;
+	public static final int ATK_ROLE_TOOL_TIP = 63;
+	public static final int ATK_ROLE_TREE = 64;
+	public static final int ATK_STATE_ARMED = 2;
+	public static final int ATK_STATE_BUSY = 3;
+	public static final int ATK_STATE_CHECKED = 4;
+	public static final int ATK_STATE_DEFUNCT = 5;
+	public static final int ATK_STATE_EDITABLE = 6;
+	public static final int ATK_STATE_ENABLED = 7;
+	public static final int ATK_STATE_EXPANDED = 9;
+	public static final int ATK_STATE_FOCUSABLE = 10;
+	public static final int ATK_STATE_FOCUSED = 11;
+	public static final int ATK_STATE_MULTISELECTABLE = 16;
+	public static final int ATK_STATE_PRESSED = 18;
+	public static final int ATK_STATE_RESIZABLE = 19;
+	public static final int ATK_STATE_SELECTABLE = 20;
+	public static final int ATK_STATE_SELECTED = 21;
+	public static final int ATK_STATE_SHOWING = 23;
+	public static final int ATK_STATE_TRANSIENT = 26;
+	public static final int ATK_STATE_VISIBLE = 28;
+	public static final int ATK_TEXT_BOUNDARY_CHAR = 0;
+	public static final int ATK_TEXT_BOUNDARY_WORD_START = 1;
+	public static final int ATK_TEXT_BOUNDARY_WORD_END = 2;
+	public static final int ATK_TEXT_BOUNDARY_SENTENCE_START = 3;
+	public static final int ATK_TEXT_BOUNDARY_SENTENCE_END = 4;
+	public static final int ATK_TEXT_BOUNDARY_LINE_START = 5;
+	public static final int ATK_TEXT_BOUNDARY_LINE_END = 6;
+	public static final int ATK_XY_WINDOW = 1;
+	
+	/** Signals */
+	public static final byte[] selection_changed = OS.ascii ("selection_changed");
+	public static final byte[] text_changed_insert = OS.ascii ("text_changed::insert");
+	public static final byte[] text_changed_delete = OS.ascii ("text_changed::delete");
+	public static final byte[] text_caret_moved = OS.ascii ("text_caret_moved");
+	public static final byte[] text_selection_changed = OS.ascii ("text_selection_changed");
+	
+/** 64 bit */
+public static final native int AtkObjectFactory_sizeof ();
+public static final native int AtkObjectFactoryClass_sizeof ();
+	
+/** Natives */
+public static final native int /*long*/ _ATK_ACTION_GET_IFACE (int /*long*/ obj);
+public static final int /*long*/ ATK_ACTION_GET_IFACE (int /*long*/ obj) {
+	lock.lock();
+	try {
+		return _ATK_ACTION_GET_IFACE(obj);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _ATK_COMPONENT_GET_IFACE(int /*long*/ atkHandle);
+public static final int /*long*/ ATK_COMPONENT_GET_IFACE(int /*long*/ atkHandle) {
+	lock.lock();
+	try {
+		return _ATK_COMPONENT_GET_IFACE(atkHandle);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _ATK_OBJECT_FACTORY_CLASS (int /*long*/ klass);
+public static final int /*long*/ ATK_OBJECT_FACTORY_CLASS (int /*long*/ klass) {
+	lock.lock();
+	try {
+		return _ATK_OBJECT_FACTORY_CLASS(klass);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _ATK_SELECTION_GET_IFACE (int /*long*/ obj);
+public static final int /*long*/ ATK_SELECTION_GET_IFACE (int /*long*/ obj) {
+	lock.lock();
+	try {
+		return _ATK_SELECTION_GET_IFACE(obj);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _ATK_TEXT_GET_IFACE (int /*long*/ handle);
+public static final int /*long*/ ATK_TEXT_GET_IFACE (int /*long*/ handle) {
+	lock.lock();
+	try {
+		return _ATK_TEXT_GET_IFACE(handle);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _GTK_ACCESSIBLE (int /*long*/ handle);
+public static final int /*long*/ GTK_ACCESSIBLE (int /*long*/ handle) {
+	lock.lock();
+	try {
+		return _GTK_ACCESSIBLE(handle);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _atk_focus_tracker_notify (int /*long*/ object);
+public static final void atk_focus_tracker_notify (int /*long*/ object) {
+	lock.lock();
+	try {
+		_atk_focus_tracker_notify(object);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _atk_get_default_registry ();
+public static final int /*long*/ atk_get_default_registry () {
+	lock.lock();
+	try {
+		return _atk_get_default_registry();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _atk_object_factory_create_accessible (int /*long*/ factory, int /*long*/ obj);
+public static final int /*long*/ atk_object_factory_create_accessible (int /*long*/ factory, int /*long*/ obj) {
+	lock.lock();
+	try {
+		return _atk_object_factory_create_accessible(factory, obj);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _atk_object_factory_get_accessible_type (int /*long*/ factory);
+public static final int /*long*/ atk_object_factory_get_accessible_type (int /*long*/ factory) {
+	lock.lock();
+	try {
+		return _atk_object_factory_get_accessible_type(factory);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _atk_object_initialize (int /*long*/ accessible, int /*long*/ data);
+public static final void atk_object_initialize (int /*long*/ accessible, int /*long*/ data) {
+	lock.lock();
+	try {
+		_atk_object_initialize(accessible, data);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _atk_object_ref_relation_set (int /*long*/ accessible);
+public static final int /*long*/ atk_object_ref_relation_set (int /*long*/ accessible) {
+	lock.lock();
+	try {
+		return _atk_object_ref_relation_set(accessible);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _atk_registry_get_factory (int /*long*/ registry, int /*long*/ type);
+public static final int /*long*/ atk_registry_get_factory (int /*long*/ registry, int /*long*/ type) {
+	lock.lock();
+	try {
+		return _atk_registry_get_factory(registry, type);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _atk_registry_set_factory_type (int /*long*/ registry, int /*long*/ type, int /*long*/ factory_type);
+public static final void atk_registry_set_factory_type (int /*long*/ registry, int /*long*/ type, int /*long*/ factory_type) {
+	lock.lock();
+	try {
+		_atk_registry_set_factory_type(registry, type, factory_type);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _atk_relation_set_get_n_relations (int /*long*/ set);
+public static final int atk_relation_set_get_n_relations (int /*long*/ set) {
+	lock.lock();
+	try {
+		return _atk_relation_set_get_n_relations(set);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _atk_relation_set_get_relation (int /*long*/ set, int i);
+public static final int /*long*/ atk_relation_set_get_relation (int /*long*/ set, int i) {
+	lock.lock();
+	try {
+		return _atk_relation_set_get_relation (set, i);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _atk_relation_set_remove (int /*long*/ set, int /*long*/ relation);
+public static final void atk_relation_set_remove (int /*long*/ set, int /*long*/ relation) {
+	lock.lock();
+	try {
+		_atk_relation_set_remove (set, relation);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _atk_state_set_add_state (int /*long*/ set, int type);
+public static final boolean atk_state_set_add_state (int /*long*/ set, int type) {
+	lock.lock();
+	try {
+		return _atk_state_set_add_state(set, type);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _atk_state_set_new ();
+public static final int /*long*/ atk_state_set_new () {
+	lock.lock();
+	try {
+		return _atk_state_set_new();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _call (int /*long*/ function, int /*long*/ arg0);
+public static final int /*long*/ call (int /*long*/ function, int /*long*/ arg0) {
+	lock.lock();
+	try {
+		return _call(function, arg0);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _call (int /*long*/ function, int /*long*/ arg0, int /*long*/ arg1);
+public static final int /*long*/ call (int /*long*/ function, int /*long*/ arg0, int /*long*/ arg1) {
+	lock.lock();
+	try {
+		return _call(function, arg0, arg1);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _call (int /*long*/ function, int /*long*/ arg0, int /*long*/ arg1, int /*long*/ arg2);
+public static final int /*long*/ call (int /*long*/ function, int /*long*/ arg0, int /*long*/ arg1, int /*long*/ arg2) {
+	lock.lock();
+	try {
+		return _call(function, arg0, arg1, arg2);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _call (int /*long*/ function, int /*long*/ arg0, int /*long*/ arg1, int /*long*/ arg2, int /*long*/ arg3);
+public static final int /*long*/ call (int /*long*/ function, int /*long*/ arg0, int /*long*/ arg1, int /*long*/ arg2, int /*long*/ arg3) {
+	lock.lock();
+	try {
+		return _call(function, arg0, arg1, arg2, arg3);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _call (int /*long*/ function, int /*long*/ arg0, int /*long*/ arg1, int /*long*/ arg2, int /*long*/ arg3, int /*long*/ arg4);
+public static final int /*long*/ call (int /*long*/ function, int /*long*/ arg0, int /*long*/ arg1, int /*long*/ arg2, int /*long*/ arg3, int /*long*/ arg4) {
+	lock.lock();
+	try {
+		return _call(function, arg0, arg1, arg2, arg3, arg4);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _call (int /*long*/ function, int /*long*/ arg0, int /*long*/ arg1, int /*long*/ arg2, int /*long*/ arg3, int /*long*/ arg4, int /*long*/ arg5);
+public static final int /*long*/ call (int /*long*/ function, int /*long*/ arg0, int /*long*/ arg1, int /*long*/ arg2, int /*long*/ arg3, int /*long*/ arg4, int /*long*/ arg5) {
+	lock.lock();
+	try {
+		return _call(function, arg0, arg1, arg2, arg3, arg4, arg5);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void memmove (AtkActionIface dest, int /*long*/ src);
+public static final native void memmove (AtkComponentIface dest, int /*long*/ src);
+public static final native void memmove (AtkHypertextIface dest, int /*long*/ src);
+public static final native void memmove (AtkObjectClass dest, int /*long*/ src);
+public static final native void memmove (AtkObjectFactoryClass  dest, int /*long*/ src);
+public static final native void memmove (AtkSelectionIface dest, int /*long*/ src);	
+public static final native void memmove (AtkTextIface dest, int /*long*/ src);
+public static final native void memmove (GtkAccessible  dest, int /*long*/ src);
+public static final native void memmove (int /*long*/ dest, AtkActionIface src);
+public static final native void memmove (int /*long*/ dest, AtkComponentIface src);
+public static final native void memmove (int /*long*/ dest, AtkHypertextIface src);
+public static final native void memmove (int /*long*/ dest, AtkObjectClass src);
+public static final native void memmove (int /*long*/ dest, AtkObjectFactoryClass src);
+public static final native void memmove (int /*long*/ dest, AtkSelectionIface src);
+public static final native void memmove (int /*long*/ dest, AtkTextIface src);
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/accessibility/gtk/ATK.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/accessibility/gtk/AtkActionIface.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/accessibility/gtk/AtkActionIface.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/accessibility/gtk/AtkActionIface.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others. All rights reserved.
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt).  The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html.  If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.accessibility.gtk;
+
+
+public class AtkActionIface {
+//	GTypeInterface parent;
+	public int /*long*/ do_action;
+	public int /*long*/ get_n_actions;
+	public int /*long*/ get_description;
+	public int /*long*/ get_name;
+	public int /*long*/ get_keybinding;
+	public int /*long*/ set_description;	
+//   AtkFunction             pad1;
+//   AtkFunction             pad2;
+}
+


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/accessibility/gtk/AtkActionIface.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/accessibility/gtk/AtkComponentIface.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/accessibility/gtk/AtkComponentIface.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/accessibility/gtk/AtkComponentIface.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others. All rights reserved.
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt).  The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html.  If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.accessibility.gtk;
+
+
+public class AtkComponentIface {
+	public int /*long*/ add_focus_handler;
+	public int /*long*/ contains;
+	public int /*long*/ ref_accessible_at_point;
+	public int /*long*/ get_extents;
+	public int /*long*/ get_position;
+	public int /*long*/ get_size;
+	public int /*long*/ grab_focus;
+	public int /*long*/ remove_focus_handler;
+	public int /*long*/ set_extents;
+	public int /*long*/ set_position;
+	public int /*long*/ set_size;
+	public int /*long*/ get_layer;
+	public int /*long*/ get_mdi_zorder;
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/accessibility/gtk/AtkComponentIface.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/accessibility/gtk/AtkHypertextIface.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/accessibility/gtk/AtkHypertextIface.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/accessibility/gtk/AtkHypertextIface.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others. All rights reserved.
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt).  The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html.  If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.accessibility.gtk;
+
+
+public class AtkHypertextIface {
+	public int /*long*/ get_link;
+	public int /*long*/ get_n_links;
+	public int /*long*/ get_link_index;
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/accessibility/gtk/AtkHypertextIface.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/accessibility/gtk/AtkObjectClass.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/accessibility/gtk/AtkObjectClass.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/accessibility/gtk/AtkObjectClass.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others. All rights reserved.
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt).  The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html.  If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.accessibility.gtk;
+
+
+public class AtkObjectClass {
+	public int /*long*/ get_name;
+	public int /*long*/ get_description;
+	public int /*long*/ get_parent;
+	public int /*long*/ get_n_children;
+	public int /*long*/ ref_child;
+	public int /*long*/ get_index_in_parent;
+	public int /*long*/ ref_relation_set;
+	public int /*long*/ get_role;
+	public int /*long*/ get_layer;
+	public int /*long*/ get_mdi_zorder;
+	public int /*long*/ ref_state_set;
+	public int /*long*/ set_name;
+	public int /*long*/ set_description;
+	public int /*long*/ set_parent;
+	public int /*long*/ set_role;
+	public int /*long*/ connect_property_change_handler;
+	public int /*long*/ remove_property_change_handler;
+	public int /*long*/ initialize;
+	public int /*long*/ children_changed;
+	public int /*long*/ focus_event;
+	public int /*long*/ property_change;
+	public int /*long*/ state_change;
+	public int /*long*/ visible_data_changed;
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/accessibility/gtk/AtkObjectClass.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/accessibility/gtk/AtkObjectFactoryClass.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/accessibility/gtk/AtkObjectFactoryClass.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/accessibility/gtk/AtkObjectFactoryClass.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others. All rights reserved.
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt).  The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html.  If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.accessibility.gtk;
+
+
+public class AtkObjectFactoryClass {
+	public int /*long*/ create_accessible;
+	public int /*long*/ invalidate;
+	public int /*long*/ get_accessible_type;
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/accessibility/gtk/AtkObjectFactoryClass.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/accessibility/gtk/AtkSelectionIface.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/accessibility/gtk/AtkSelectionIface.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/accessibility/gtk/AtkSelectionIface.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others. All rights reserved.
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt).  The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html.  If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.accessibility.gtk;
+
+
+public class AtkSelectionIface {
+	public int /*long*/ add_selection;
+	public int /*long*/ clear_selection;
+	public int /*long*/ ref_selection;
+	public int /*long*/ get_selection_count;
+	public int /*long*/ is_child_selected;
+	public int /*long*/ remove_selection;
+	public int /*long*/ select_all_selection;
+	public int /*long*/ selection_changed;
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/accessibility/gtk/AtkSelectionIface.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/accessibility/gtk/AtkTextIface.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/accessibility/gtk/AtkTextIface.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/accessibility/gtk/AtkTextIface.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others. All rights reserved.
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt).  The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html.  If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.accessibility.gtk;
+
+
+public class AtkTextIface {
+	public int /*long*/ get_text;
+	public int /*long*/ get_text_after_offset;
+	public int /*long*/ get_text_at_offset;
+	public int /*long*/ get_character_at_offset;
+	public int /*long*/ get_text_before_offset;
+	public int /*long*/ get_caret_offset;
+	public int /*long*/ get_run_attributes;
+	public int /*long*/ get_default_attributes;
+	public int /*long*/ get_character_extents;
+	public int /*long*/ get_character_count;
+	public int /*long*/ get_offset_at_point;
+	public int /*long*/ get_n_selections;
+	public int /*long*/ get_selection;
+	public int /*long*/ add_selection;
+	public int /*long*/ remove_selection;
+	public int /*long*/ set_selection;
+	public int /*long*/ set_caret_offset;
+	public int /*long*/ text_changed;
+	public int /*long*/ text_caret_moved;
+	public int /*long*/ text_selection_changed;
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/accessibility/gtk/AtkTextIface.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/accessibility/gtk/GtkAccessible.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/accessibility/gtk/GtkAccessible.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/accessibility/gtk/GtkAccessible.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,20 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others. All rights reserved.
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt).  The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html.  If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.accessibility.gtk;
+
+
+public class GtkAccessible {
+	public int /*long*/ widget;
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/accessibility/gtk/GtkAccessible.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/cairo/Cairo.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/cairo/Cairo.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/cairo/Cairo.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,1337 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * -  Binding to permit interfacing between Cairo and SWT
+ * -  Copyright (C) 2005 IBM Corp.  All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package org.eclipse.swt.internal.cairo;
+
+import org.eclipse.swt.internal.*;
+
+public class Cairo extends Platform {
+	static {
+		Library.loadLibrary("swt-cairo");
+	}
+
+	/** Constants */
+	public static final int CAIRO_ANTIALIAS_DEFAULT = 0;
+	public static final int CAIRO_ANTIALIAS_NONE = 1;
+	public static final int CAIRO_ANTIALIAS_GRAY = 2;
+	public static final int CAIRO_ANTIALIAS_SUBPIXEL = 3;
+	public static final int CAIRO_FORMAT_ARGB32 = 0;
+	public static final int CAIRO_FORMAT_RGB24 = 1;
+	public static final int CAIRO_FORMAT_A8 = 2;
+	public static final int CAIRO_FORMAT_A1 = 3;
+	public static final int CAIRO_OPERATOR_CLEAR = 0;
+	public static final int CAIRO_OPERATOR_SRC = 1;
+	public static final int CAIRO_OPERATOR_DST = 2;
+	public static final int CAIRO_OPERATOR_OVER = 3;
+	public static final int CAIRO_OPERATOR_OVER_REVERSE = 4;
+	public static final int CAIRO_OPERATOR_IN = 5;
+	public static final int CAIRO_OPERATOR_IN_REVERSE = 6;
+	public static final int CAIRO_OPERATOR_OUT = 7;
+	public static final int CAIRO_OPERATOR_OUT_REVERSE = 8;
+	public static final int CAIRO_OPERATOR_ATOP = 9;
+	public static final int CAIRO_OPERATOR_ATOP_REVERSE = 10;
+	public static final int CAIRO_OPERATOR_XOR = 11;
+	public static final int CAIRO_OPERATOR_ADD = 12;
+	public static final int CAIRO_OPERATOR_SATURATE = 13;
+	public static final int CAIRO_FILL_RULE_WINDING = 0;
+	public static final int CAIRO_FILL_RULE_EVEN_ODD = 1;
+	public static final int CAIRO_LINE_CAP_BUTT = 0;
+	public static final int CAIRO_LINE_CAP_ROUND = 1;
+	public static final int CAIRO_LINE_CAP_SQUARE = 2;
+	public static final int CAIRO_LINE_JOIN_MITER = 0;
+	public static final int CAIRO_LINE_JOIN_ROUND = 1;
+	public static final int CAIRO_LINE_JOIN_BEVEL = 2;
+	public static final int CAIRO_FONT_SLANT_NORMAL = 0;
+	public static final int CAIRO_FONT_SLANT_ITALIC = 1;
+	public static final int CAIRO_FONT_SLANT_OBLIQUE = 2;
+	public static final int CAIRO_FONT_WEIGHT_NORMAL = 0;
+	public static final int CAIRO_FONT_WEIGHT_BOLD = 1;
+	public static final int CAIRO_STATUS_SUCCESS = 0;
+	public static final int CAIRO_STATUS_NO_MEMORY = 1;
+	public static final int CAIRO_STATUS_INVALID_RESTORE = 2;
+	public static final int CAIRO_STATUS_INVALID_POP_GROUP = 3;
+	public static final int CAIRO_STATUS_NO_CURRENT_POINT = 4;
+	public static final int CAIRO_STATUS_INVALID_MATRIX = 5;
+	public static final int CAIRO_STATUS_NO_TARGET_SURFACE = 6;
+	public static final int CAIRO_STATUS_NULL_POINTER =7;
+	public static final int CAIRO_SURFACE_TYPE_IMAGE = 0;
+	public static final int CAIRO_SURFACE_TYPE_PDF = 1;
+    public static final int CAIRO_SURFACE_TYPE_PS = 2;
+    public static final int CAIRO_SURFACE_TYPE_XLIB = 3;
+    public static final int CAIRO_SURFACE_TYPE_XCB = 4;
+    public static final int CAIRO_SURFACE_TYPE_GLITZ = 5;
+    public static final int CAIRO_SURFACE_TYPE_QUARTZ = 6;
+    public static final int CAIRO_SURFACE_TYPE_WIN32 = 7;
+    public static final int CAIRO_SURFACE_TYPE_BEOS = 8;
+    public static final int CAIRO_SURFACE_TYPE_DIRECTFB = 9;
+    public static final int CAIRO_SURFACE_TYPE_SVG = 10;
+	public static final int CAIRO_FILTER_FAST = 0;
+	public static final int CAIRO_FILTER_GOOD = 1;
+	public static final int CAIRO_FILTER_BEST = 2;
+	public static final int CAIRO_FILTER_NEAREST = 3;
+	public static final int CAIRO_FILTER_BILINEAR = 4;
+	public static final int CAIRO_FILTER_GAUSSIAN = 5;
+	public static final int CAIRO_EXTEND_NONE = 0;
+	public static final int CAIRO_EXTEND_REPEAT = 1;
+	public static final int CAIRO_EXTEND_REFLECT = 2;
+	public static final int CAIRO_EXTEND_PAD = 3;
+	public static final int CAIRO_PATH_MOVE_TO = 0;
+	public static final int CAIRO_PATH_LINE_TO = 1;
+	public static final int CAIRO_PATH_CURVE_TO = 2;
+	public static final int CAIRO_PATH_CLOSE_PATH = 3;
+	
+/** 64*/
+public static final native int cairo_font_extents_t_sizeof ();
+public static final native int cairo_path_data_t_sizeof ();
+public static final native int cairo_path_t_sizeof ();
+public static final native int cairo_text_extents_t_sizeof ();
+	
+/** Natives */
+public static final native int CAIRO_VERSION_ENCODE(int major, int minor, int micro);
+public static final native void _cairo_append_path(int /*long*/ cr, int /*long*/ path);
+public static final void cairo_append_path(int /*long*/ cr, int /*long*/ path) {
+	lock.lock();
+	try {
+		_cairo_append_path(cr, path);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_arc(int /*long*/ cr, double xc, double yc, double radius, double angle1, double angle2);
+public static final void cairo_arc(int /*long*/ cr, double xc, double yc, double radius, double angle1, double angle2) {
+	lock.lock();
+	try {
+		_cairo_arc(cr, xc, yc, radius, angle1, angle2);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_arc_negative(int /*long*/ cr, double xc, double yc, double radius, double angle1, double angle2);
+public static final void cairo_arc_negative(int /*long*/ cr, double xc, double yc, double radius, double angle1, double angle2) {
+	lock.lock();
+	try {
+		_cairo_arc_negative(cr, xc, yc, radius, angle1, angle2);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_clip(int /*long*/ cr);
+public static final void cairo_clip(int /*long*/ cr) {
+	lock.lock();
+	try {
+		_cairo_clip(cr);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_clip_preserve(int /*long*/ cr);
+public static final void cairo_clip_preserve(int /*long*/ cr) {
+	lock.lock();
+	try {
+		_cairo_clip_preserve(cr);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_close_path(int /*long*/ cr);
+public static final void cairo_close_path(int /*long*/ cr) {
+	lock.lock();
+	try {
+		_cairo_close_path(cr);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_copy_page(int /*long*/ cr);
+public static final void cairo_copy_page(int /*long*/ cr) {
+	lock.lock();
+	try {
+		_cairo_copy_page(cr);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _cairo_copy_path(int /*long*/ cr);
+public static final int /*long*/ cairo_copy_path(int /*long*/ cr) {
+	lock.lock();
+	try {
+		return _cairo_copy_path(cr);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _cairo_copy_path_flat(int /*long*/ cr);
+public static final int /*long*/ cairo_copy_path_flat(int /*long*/ cr) {
+	lock.lock();
+	try {
+		return _cairo_copy_path_flat(cr);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _cairo_create(int /*long*/ target);
+public static final int /*long*/ cairo_create(int /*long*/ target) {
+	lock.lock();
+	try {
+		return _cairo_create(target);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_curve_to(int /*long*/ cr, double x1, double y1, double x2, double y2, double x3, double y3);
+public static final void cairo_curve_to(int /*long*/ cr, double x1, double y1, double x2, double y2, double x3, double y3) {
+	lock.lock();
+	try {
+		_cairo_curve_to(cr, x1, y1, x2, y2, x3, y3);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_destroy(int /*long*/ cr);
+public static final void cairo_destroy(int /*long*/ cr) {
+	lock.lock();
+	try {
+		_cairo_destroy(cr);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_device_to_user(int /*long*/ cr, double[] x, double[] y);
+public static final void cairo_device_to_user(int /*long*/ cr, double[] x, double[] y) {
+	lock.lock();
+	try {
+		_cairo_device_to_user(cr, x, y);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_device_to_user_distance(int /*long*/ cr, double[] dx, double[] dy);
+public static final void cairo_device_to_user_distance(int /*long*/ cr, double[] dx, double[] dy) {
+	lock.lock();
+	try {
+		_cairo_device_to_user_distance(cr, dx, dy);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_fill(int /*long*/ cr);
+public static final void cairo_fill(int /*long*/ cr) {
+	lock.lock();
+	try {
+		_cairo_fill(cr);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_fill_extents(int /*long*/ cr, double[] x1, double[] y1, double[] x2, double[] y2);
+public static final void cairo_fill_extents(int /*long*/ cr, double[] x1, double[] y1, double[] x2, double[] y2) {
+	lock.lock();
+	try {
+		_cairo_fill_extents(cr, x1, y1, x2, y2);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_fill_preserve(int /*long*/ cr);
+public static final void cairo_fill_preserve(int /*long*/ cr) {
+	lock.lock();
+	try {
+		_cairo_fill_preserve(cr);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_font_extents(int /*long*/ cr, cairo_font_extents_t extents);
+public static final void cairo_font_extents(int /*long*/ cr, cairo_font_extents_t extents) {
+	lock.lock();
+	try {
+		_cairo_font_extents(cr, extents);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _cairo_font_options_create();
+public static final int /*long*/ cairo_font_options_create() {
+	lock.lock();
+	try {
+		return _cairo_font_options_create();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_font_options_destroy(int /*long*/ options);
+public static final void cairo_font_options_destroy(int /*long*/ options) {
+	lock.lock();
+	try {
+		_cairo_font_options_destroy(options);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _cairo_font_options_get_antialias(int /*long*/ options);
+public static final int cairo_font_options_get_antialias(int /*long*/ options) {
+	lock.lock();
+	try {
+		return _cairo_font_options_get_antialias(options);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_font_options_set_antialias(int /*long*/ options, int antialias);
+public static final void cairo_font_options_set_antialias(int /*long*/ options, int antialias) {
+	lock.lock();
+	try {
+		_cairo_font_options_set_antialias(options, antialias);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _cairo_get_antialias(int /*long*/ cr);
+public static final int cairo_get_antialias(int /*long*/ cr) {
+	lock.lock();
+	try {
+		return _cairo_get_antialias(cr);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_get_current_point(int /*long*/ cr, double[] x, double[] y);
+public static final void cairo_get_current_point(int /*long*/ cr, double[] x, double[] y) {
+	lock.lock();
+	try {
+		_cairo_get_current_point(cr, x, y);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _cairo_get_fill_rule(int /*long*/ cr);
+public static final int cairo_get_fill_rule(int /*long*/ cr) {
+	lock.lock();
+	try {
+		return _cairo_get_fill_rule(cr);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _cairo_get_font_face(int /*long*/ cr);
+public static final int /*long*/ cairo_get_font_face(int /*long*/ cr) {
+	lock.lock();
+	try {
+		return _cairo_get_font_face(cr);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_get_font_matrix(int /*long*/ cr, double[] matrix);
+public static final void cairo_get_font_matrix(int /*long*/ cr, double[] matrix) {
+	lock.lock();
+	try {
+		_cairo_get_font_matrix(cr, matrix);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_get_font_options(int /*long*/ cr, int /*long*/ options);
+public static final void cairo_get_font_options(int /*long*/ cr, int /*long*/ options) {
+	lock.lock();
+	try {
+		_cairo_get_font_options(cr, options);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _cairo_get_line_cap(int /*long*/ cr);
+public static final int cairo_get_line_cap(int /*long*/ cr) {
+	lock.lock();
+	try {
+		return _cairo_get_line_cap(cr);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _cairo_get_line_join(int /*long*/ cr);
+public static final int cairo_get_line_join(int /*long*/ cr) {
+	lock.lock();
+	try {
+		return _cairo_get_line_join(cr);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native double _cairo_get_line_width(int /*long*/ cr);
+public static final double cairo_get_line_width(int /*long*/ cr) {
+	lock.lock();
+	try {
+		return _cairo_get_line_width(cr);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_get_matrix(int /*long*/ cr, double[] matrix);
+public static final void cairo_get_matrix(int /*long*/ cr, double[] matrix) {
+	lock.lock();
+	try {
+		_cairo_get_matrix(cr, matrix);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native double _cairo_get_miter_limit(int /*long*/ cr);
+public static final double cairo_get_miter_limit(int /*long*/ cr) {
+	lock.lock();
+	try {
+		return _cairo_get_miter_limit(cr);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _cairo_get_operator(int /*long*/ cr);
+public static final int cairo_get_operator(int /*long*/ cr) {
+	lock.lock();
+	try {
+		return _cairo_get_operator(cr);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _cairo_get_source(int /*long*/ cr);
+public static final int /*long*/ cairo_get_source(int /*long*/ cr) {
+	lock.lock();
+	try {
+		return _cairo_get_source(cr);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _cairo_get_target(int /*long*/ cr);
+public static final int /*long*/ cairo_get_target(int /*long*/ cr) {
+	lock.lock();
+	try {
+		return _cairo_get_target(cr);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native double _cairo_get_tolerance(int /*long*/ cr);
+public static final double cairo_get_tolerance(int /*long*/ cr) {
+	lock.lock();
+	try {
+		return _cairo_get_tolerance(cr);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_glyph_extents(int /*long*/ cr, int /*long*/ glyphs, int num_glyphs, int /*long*/ extents);
+public static final void cairo_glyph_extents(int /*long*/ cr, int /*long*/ glyphs, int num_glyphs, int /*long*/ extents) {
+	lock.lock();
+	try {
+		_cairo_glyph_extents(cr, glyphs, num_glyphs, extents);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_glyph_path(int /*long*/ cr, int /*long*/ glyphs, int num_glyphs);
+public static final void cairo_glyph_path(int /*long*/ cr, int /*long*/ glyphs, int num_glyphs) {
+	lock.lock();
+	try {
+		_cairo_glyph_path(cr, glyphs, num_glyphs);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_identity_matrix(int /*long*/ cr);
+public static final void cairo_identity_matrix(int /*long*/ cr) {
+	lock.lock();
+	try {
+		_cairo_identity_matrix(cr);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _cairo_image_surface_create(int format, int width, int height);
+public static final int /*long*/ cairo_image_surface_create(int format, int width, int height) {
+	lock.lock();
+	try {
+		return _cairo_image_surface_create(format, width, height);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _cairo_image_surface_create_for_data(int /*long*/ data, int format, int width, int height, int stride);
+public static final int /*long*/ cairo_image_surface_create_for_data(int /*long*/ data, int format, int width, int height, int stride) {
+	lock.lock();
+	try {
+		return _cairo_image_surface_create_for_data(data, format, width, height, stride);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _cairo_image_surface_get_height(int /*long*/ surface);
+public static final int cairo_image_surface_get_height(int /*long*/ surface) {
+	lock.lock();
+	try {
+		return _cairo_image_surface_get_height(surface);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _cairo_image_surface_get_width(int /*long*/ surface);
+public static final int cairo_image_surface_get_width(int /*long*/ surface) {
+	lock.lock();
+	try {
+		return _cairo_image_surface_get_width(surface);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _cairo_in_fill(int /*long*/ cr, double x, double y);
+public static final int cairo_in_fill(int /*long*/ cr, double x, double y) {
+	lock.lock();
+	try {
+		return _cairo_in_fill(cr, x, y);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _cairo_in_stroke(int /*long*/ cr, double x, double y);
+public static final int cairo_in_stroke(int /*long*/ cr, double x, double y) {
+	lock.lock();
+	try {
+		return _cairo_in_stroke(cr, x, y);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_line_to(int /*long*/ cr, double x, double y);
+public static final void cairo_line_to(int /*long*/ cr, double x, double y) {
+	lock.lock();
+	try {
+		_cairo_line_to(cr, x, y);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_mask(int /*long*/ cr, int /*long*/ pattern);
+public static final void cairo_mask(int /*long*/ cr, int /*long*/ pattern) {
+	lock.lock();
+	try {
+		_cairo_mask(cr, pattern);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_mask_surface(int /*long*/ cr, int /*long*/ surface, double surface_x, double surface_y);
+public static final void cairo_mask_surface(int /*long*/ cr, int /*long*/ surface, double surface_x, double surface_y) {
+	lock.lock();
+	try {
+		_cairo_mask_surface(cr, surface, surface_x, surface_y);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_matrix_init(double[] matrix, double xx, double yx, double xy, double yy, double x0, double y0);
+public static final void cairo_matrix_init(double[] matrix, double xx, double yx, double xy, double yy, double x0, double y0) {
+	lock.lock();
+	try {
+		_cairo_matrix_init(matrix, xx, yx, xy, yy, x0, y0);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_matrix_init_identity(double[] matrix);
+public static final void cairo_matrix_init_identity(double[] matrix) {
+	lock.lock();
+	try {
+		_cairo_matrix_init_identity(matrix);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_matrix_init_rotate(double[] matrix, double radians);
+public static final void cairo_matrix_init_rotate(double[] matrix, double radians) {
+	lock.lock();
+	try {
+		_cairo_matrix_init_rotate(matrix, radians);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_matrix_init_scale(double[] matrix, double sx, double sy);
+public static final void cairo_matrix_init_scale(double[] matrix, double sx, double sy) {
+	lock.lock();
+	try {
+		_cairo_matrix_init_scale(matrix, sx, sy);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_matrix_init_translate(double[] matrix, double tx, double ty);
+public static final void cairo_matrix_init_translate(double[] matrix, double tx, double ty) {
+	lock.lock();
+	try {
+		_cairo_matrix_init_translate(matrix, tx, ty);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _cairo_matrix_invert(double[] matrix);
+public static final int cairo_matrix_invert(double[] matrix) {
+	lock.lock();
+	try {
+		return _cairo_matrix_invert(matrix);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_matrix_multiply(double[] result, double[] a, double[] b);
+public static final void cairo_matrix_multiply(double[] result, double[] a, double[] b) {
+	lock.lock();
+	try {
+		_cairo_matrix_multiply(result, a, b);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_matrix_rotate(double[] matrix, double radians);
+public static final void cairo_matrix_rotate(double[] matrix, double radians) {
+	lock.lock();
+	try {
+		_cairo_matrix_rotate(matrix, radians);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_matrix_scale(double[] matrix, double sx, double sy);
+public static final void cairo_matrix_scale(double[] matrix, double sx, double sy) {
+	lock.lock();
+	try {
+		_cairo_matrix_scale(matrix, sx, sy);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_matrix_transform_distance(double[] matrix, double[] dx, double[] dy);
+public static final void cairo_matrix_transform_distance(double[] matrix, double[] dx, double[] dy) {
+	lock.lock();
+	try {
+		_cairo_matrix_transform_distance(matrix, dx, dy);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_matrix_transform_point(double[] matrix, double[] x, double[] y);
+public static final void cairo_matrix_transform_point(double[] matrix, double[] x, double[] y) {
+	lock.lock();
+	try {
+		_cairo_matrix_transform_point(matrix, x, y);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_matrix_translate(double[] matrix, double tx, double ty);
+public static final void cairo_matrix_translate(double[] matrix, double tx, double ty) {
+	lock.lock();
+	try {
+		_cairo_matrix_translate(matrix, tx, ty);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_move_to(int /*long*/ cr, double x, double y);
+public static final void cairo_move_to(int /*long*/ cr, double x, double y) {
+	lock.lock();
+	try {
+		_cairo_move_to(cr, x, y);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_new_path(int /*long*/ cr);
+public static final void cairo_new_path(int /*long*/ cr) {
+	lock.lock();
+	try {
+		_cairo_new_path(cr);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_paint(int /*long*/ cr);
+public static final void cairo_paint(int /*long*/ cr) {
+	lock.lock();
+	try {
+		_cairo_paint(cr);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_paint_with_alpha(int /*long*/ cr, double alpha);
+public static final void cairo_paint_with_alpha(int /*long*/ cr, double alpha) {
+	lock.lock();
+	try {
+		_cairo_paint_with_alpha(cr, alpha);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_path_destroy(int /*long*/ path);
+public static final void cairo_path_destroy(int /*long*/ path) {
+	lock.lock();
+	try {
+		_cairo_path_destroy(path);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_pattern_add_color_stop_rgb(int /*long*/ pattern, double offset, double red, double green, double blue);
+public static final void cairo_pattern_add_color_stop_rgb(int /*long*/ pattern, double offset, double red, double green, double blue) {
+	lock.lock();
+	try {
+		_cairo_pattern_add_color_stop_rgb(pattern, offset, red, green, blue);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_pattern_add_color_stop_rgba(int /*long*/ pattern, double offset, double red, double green, double blue, double alpha);
+public static final void cairo_pattern_add_color_stop_rgba(int /*long*/ pattern, double offset, double red, double green, double blue, double alpha) {
+	lock.lock();
+	try {
+		_cairo_pattern_add_color_stop_rgba(pattern, offset, red, green, blue, alpha);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _cairo_pattern_create_for_surface(int /*long*/ surface);
+public static final int /*long*/ cairo_pattern_create_for_surface(int /*long*/ surface) {
+	lock.lock();
+	try {
+		return _cairo_pattern_create_for_surface(surface);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _cairo_pattern_create_linear(double x0, double y0, double x1, double y1);
+public static final int /*long*/ cairo_pattern_create_linear(double x0, double y0, double x1, double y1) {
+	lock.lock();
+	try {
+		return _cairo_pattern_create_linear(x0, y0, x1, y1);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _cairo_pattern_create_radial(double cx0, double cy0, double radius0, double cx1, double cy1, double radius1);
+public static final int /*long*/ cairo_pattern_create_radial(double cx0, double cy0, double radius0, double cx1, double cy1, double radius1) {
+	lock.lock();
+	try {
+		return _cairo_pattern_create_radial(cx0, cy0, radius0, cx1, cy1, radius1);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_pattern_destroy(int /*long*/ pattern);
+public static final void cairo_pattern_destroy(int /*long*/ pattern) {
+	lock.lock();
+	try {
+		_cairo_pattern_destroy(pattern);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _cairo_pattern_get_extend(int /*long*/ pattern);
+public static final int cairo_pattern_get_extend(int /*long*/ pattern) {
+	lock.lock();
+	try {
+		return _cairo_pattern_get_extend(pattern);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _cairo_pattern_get_filter(int /*long*/ pattern);
+public static final int cairo_pattern_get_filter(int /*long*/ pattern) {
+	lock.lock();
+	try {
+		return _cairo_pattern_get_filter(pattern);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_pattern_get_matrix(int /*long*/ pattern, double[] matrix);
+public static final void cairo_pattern_get_matrix(int /*long*/ pattern, double[] matrix) {
+	lock.lock();
+	try {
+		_cairo_pattern_get_matrix(pattern, matrix);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_pattern_reference(int /*long*/ pattern);
+public static final void cairo_pattern_reference(int /*long*/ pattern) {
+	lock.lock();
+	try {
+		_cairo_pattern_reference(pattern);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_pattern_set_extend(int /*long*/ pattern, int extend);
+public static final void cairo_pattern_set_extend(int /*long*/ pattern, int extend) {
+	lock.lock();
+	try {
+		_cairo_pattern_set_extend(pattern, extend);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_pattern_set_filter(int /*long*/ pattern, int filter);
+public static final void cairo_pattern_set_filter(int /*long*/ pattern, int filter) {
+	lock.lock();
+	try {
+		_cairo_pattern_set_filter(pattern, filter);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_pattern_set_matrix(int /*long*/ pattern, double[] matrix);
+public static final void cairo_pattern_set_matrix(int /*long*/ pattern, double[] matrix) {
+	lock.lock();
+	try {
+		_cairo_pattern_set_matrix(pattern, matrix);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_pdf_surface_set_size(int /*long*/ surface, double width_in_points, double height_in_points);
+public static final void cairo_pdf_surface_set_size(int /*long*/ surface, double width_in_points, double height_in_points) {
+	lock.lock();
+	try {
+		_cairo_pdf_surface_set_size(surface, width_in_points, height_in_points);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_ps_surface_set_size(int /*long*/ surface, double width_in_points, double height_in_points);
+public static final void cairo_ps_surface_set_size(int /*long*/ surface, double width_in_points, double height_in_points) {
+	lock.lock();
+	try {
+		_cairo_ps_surface_set_size(surface, width_in_points, height_in_points);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_rectangle(int /*long*/ cr, double x, double y, double width, double height);
+public static final void cairo_rectangle(int /*long*/ cr, double x, double y, double width, double height) {
+	lock.lock();
+	try {
+		_cairo_rectangle(cr, x, y, width, height);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _cairo_reference(int /*long*/ cr);
+public static final int /*long*/ cairo_reference(int /*long*/ cr) {
+	lock.lock();
+	try {
+		return _cairo_reference(cr);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_rel_curve_to(int /*long*/ cr, double dx1, double dy1, double dx2, double dy2, double dx3, double dy3);
+public static final void cairo_rel_curve_to(int /*long*/ cr, double dx1, double dy1, double dx2, double dy2, double dx3, double dy3) {
+	lock.lock();
+	try {
+		_cairo_rel_curve_to(cr, dx1, dy1, dx2, dy2, dx3, dy3);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_rel_line_to(int /*long*/ cr, double dx, double dy);
+public static final void cairo_rel_line_to(int /*long*/ cr, double dx, double dy) {
+	lock.lock();
+	try {
+		_cairo_rel_line_to(cr, dx, dy);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_rel_move_to(int /*long*/ cr, double dx, double dy);
+public static final void cairo_rel_move_to(int /*long*/ cr, double dx, double dy) {
+	lock.lock();
+	try {
+		_cairo_rel_move_to(cr, dx, dy);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_reset_clip(int /*long*/ cr);
+public static final void cairo_reset_clip(int /*long*/ cr) {
+	lock.lock();
+	try {
+		_cairo_reset_clip(cr);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_restore(int /*long*/ cr);
+public static final void cairo_restore(int /*long*/ cr) {
+	lock.lock();
+	try {
+		_cairo_restore(cr);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_rotate(int /*long*/ cr, double angle);
+public static final void cairo_rotate(int /*long*/ cr, double angle) {
+	lock.lock();
+	try {
+		_cairo_rotate(cr, angle);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_save(int /*long*/ cr);
+public static final void cairo_save(int /*long*/ cr) {
+	lock.lock();
+	try {
+		_cairo_save(cr);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_scale(int /*long*/ cr, double sx, double sy);
+public static final void cairo_scale(int /*long*/ cr, double sx, double sy) {
+	lock.lock();
+	try {
+		_cairo_scale(cr, sx, sy);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_select_font_face(int /*long*/ cr, byte[] family, int slant, int weight);
+public static final void cairo_select_font_face(int /*long*/ cr, byte[] family, int slant, int weight) {
+	lock.lock();
+	try {
+		_cairo_select_font_face(cr, family, slant, weight);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_set_antialias(int /*long*/ cr, int antialias);
+public static final void cairo_set_antialias(int /*long*/ cr, int antialias) {
+	lock.lock();
+	try {
+		_cairo_set_antialias(cr, antialias);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_set_dash(int /*long*/ cr, double[] dashes, int ndash, double offset);
+public static final void cairo_set_dash(int /*long*/ cr, double[] dashes, int ndash, double offset) {
+	lock.lock();
+	try {
+		_cairo_set_dash(cr, dashes, ndash, offset);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_set_fill_rule(int /*long*/ cr, int fill_rule);
+public static final void cairo_set_fill_rule(int /*long*/ cr, int fill_rule) {
+	lock.lock();
+	try {
+		_cairo_set_fill_rule(cr, fill_rule);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_set_font_face(int /*long*/ cr, int /*long*/ font_face);
+public static final void cairo_set_font_face(int /*long*/ cr, int /*long*/ font_face) {
+	lock.lock();
+	try {
+		_cairo_set_font_face(cr, font_face);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_set_font_matrix(int /*long*/ cr, double[] matrix);
+public static final void cairo_set_font_matrix(int /*long*/ cr, double[] matrix) {
+	lock.lock();
+	try {
+		_cairo_set_font_matrix(cr, matrix);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_set_font_options(int /*long*/ cr, int /*long*/ options);
+public static final void cairo_set_font_options(int /*long*/ cr, int /*long*/ options) {
+	lock.lock();
+	try {
+		_cairo_set_font_options(cr, options);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_set_font_size(int /*long*/ cr, double size);
+public static final void cairo_set_font_size(int /*long*/ cr, double size) {
+	lock.lock();
+	try {
+		_cairo_set_font_size(cr, size);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_set_line_cap(int /*long*/ cr, int line_cap);
+public static final void cairo_set_line_cap(int /*long*/ cr, int line_cap) {
+	lock.lock();
+	try {
+		_cairo_set_line_cap(cr, line_cap);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_set_line_join(int /*long*/ cr, int line_join);
+public static final void cairo_set_line_join(int /*long*/ cr, int line_join) {
+	lock.lock();
+	try {
+		_cairo_set_line_join(cr, line_join);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_set_line_width(int /*long*/ cr, double width);
+public static final void cairo_set_line_width(int /*long*/ cr, double width) {
+	lock.lock();
+	try {
+		_cairo_set_line_width(cr, width);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_set_matrix(int /*long*/ cr, double[] matrix);
+public static final void cairo_set_matrix(int /*long*/ cr, double[] matrix) {
+	lock.lock();
+	try {
+		_cairo_set_matrix(cr, matrix);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_set_miter_limit(int /*long*/ cr, double limit);
+public static final void cairo_set_miter_limit(int /*long*/ cr, double limit) {
+	lock.lock();
+	try {
+		_cairo_set_miter_limit(cr, limit);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_set_operator(int /*long*/ cr, int op);
+public static final void cairo_set_operator(int /*long*/ cr, int op) {
+	lock.lock();
+	try {
+		_cairo_set_operator(cr, op);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_set_source(int /*long*/ cr, int /*long*/ source);
+public static final void cairo_set_source(int /*long*/ cr, int /*long*/ source) {
+	lock.lock();
+	try {
+		_cairo_set_source(cr, source);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_set_source_rgb(int /*long*/ cr, double red, double green, double blue);
+public static final void cairo_set_source_rgb(int /*long*/ cr, double red, double green, double blue) {
+	lock.lock();
+	try {
+		_cairo_set_source_rgb(cr, red, green, blue);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_set_source_rgba(int /*long*/ cr, double red, double green, double blue, double alpha);
+public static final void cairo_set_source_rgba(int /*long*/ cr, double red, double green, double blue, double alpha) {
+	lock.lock();
+	try {
+		_cairo_set_source_rgba(cr, red, green, blue, alpha);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_set_source_surface(int /*long*/ cr, int /*long*/ surface, double x, double y);
+public static final void cairo_set_source_surface(int /*long*/ cr, int /*long*/ surface, double x, double y) {
+	lock.lock();
+	try {
+		_cairo_set_source_surface(cr, surface, x, y);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_set_tolerance(int /*long*/ cr, double tolerance);
+public static final void cairo_set_tolerance(int /*long*/ cr, double tolerance) {
+	lock.lock();
+	try {
+		_cairo_set_tolerance(cr, tolerance);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_show_glyphs(int /*long*/ cr, int /*long*/ glyphs, int num_glyphs);
+public static final void cairo_show_glyphs(int /*long*/ cr, int /*long*/ glyphs, int num_glyphs) {
+	lock.lock();
+	try {
+		_cairo_show_glyphs(cr, glyphs, num_glyphs);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_show_page(int /*long*/ cr);
+public static final void cairo_show_page(int /*long*/ cr) {
+	lock.lock();
+	try {
+		_cairo_show_page(cr);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_show_text(int /*long*/ cr, byte[] utf8);
+public static final void cairo_show_text(int /*long*/ cr, byte[] utf8) {
+	lock.lock();
+	try {
+		_cairo_show_text(cr, utf8);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _cairo_status(int /*long*/ cr);
+public static final int cairo_status(int /*long*/ cr) {
+	lock.lock();
+	try {
+		return _cairo_status(cr);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _cairo_status_to_string(int status);
+public static final int /*long*/ cairo_status_to_string(int status) {
+	lock.lock();
+	try {
+		return _cairo_status_to_string(status);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_stroke(int /*long*/ cr);
+public static final void cairo_stroke(int /*long*/ cr) {
+	lock.lock();
+	try {
+		_cairo_stroke(cr);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_stroke_extents(int /*long*/ cr, double[] x1, double[] y1, double[] x2, double[] y2);
+public static final void cairo_stroke_extents(int /*long*/ cr, double[] x1, double[] y1, double[] x2, double[] y2) {
+	lock.lock();
+	try {
+		_cairo_stroke_extents(cr, x1, y1, x2, y2);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_stroke_preserve(int /*long*/ cr);
+public static final void cairo_stroke_preserve(int /*long*/ cr) {
+	lock.lock();
+	try {
+		_cairo_stroke_preserve(cr);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _cairo_surface_create_similar(int /*long*/ other, int format, int width, int height);
+public static final int /*long*/ cairo_surface_create_similar(int /*long*/ other, int format, int width, int height) {
+	lock.lock();
+	try {
+		return _cairo_surface_create_similar(other, format, width, height);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_surface_destroy(int /*long*/ surface);
+public static final void cairo_surface_destroy(int /*long*/ surface) {
+	lock.lock();
+	try {
+		_cairo_surface_destroy(surface);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_surface_finish(int /*long*/ surface);
+public static final void cairo_surface_finish(int /*long*/ surface) {
+	lock.lock();
+	try {
+		_cairo_surface_finish(surface);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _cairo_surface_get_type(int /*long*/ surface);
+public static final int cairo_surface_get_type(int /*long*/ surface) {
+	lock.lock();
+	try {
+		return _cairo_surface_get_type(surface);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _cairo_surface_get_user_data(int /*long*/ surface, int /*long*/ key);
+public static final int /*long*/ cairo_surface_get_user_data(int /*long*/ surface, int /*long*/ key) {
+	lock.lock();
+	try {
+		return _cairo_surface_get_user_data(surface, key);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_surface_reference(int /*long*/ surface);
+public static final void cairo_surface_reference(int /*long*/ surface) {
+	lock.lock();
+	try {
+		_cairo_surface_reference(surface);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_surface_set_device_offset(int /*long*/ surface, double x_offset, double y_offset);
+public static final void cairo_surface_set_device_offset(int /*long*/ surface, double x_offset, double y_offset) {
+	lock.lock();
+	try {
+		_cairo_surface_set_device_offset(surface, x_offset, y_offset);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_surface_set_fallback_resolution(int /*long*/ surface, double x_pixels_per_inch, double y_pixels_per_inch);
+public static final void cairo_surface_set_fallback_resolution(int /*long*/ surface, double x_pixels_per_inch, double y_pixels_per_inch) {
+	lock.lock();
+	try {
+		_cairo_surface_set_fallback_resolution(surface, x_pixels_per_inch, y_pixels_per_inch);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _cairo_surface_set_user_data(int /*long*/ surface, int /*long*/ key, int /*long*/ user_data, int /*long*/ destroy);
+public static final int cairo_surface_set_user_data(int /*long*/ surface, int /*long*/ key, int /*long*/ user_data, int /*long*/ destroy) {
+	lock.lock();
+	try {
+		return _cairo_surface_set_user_data(surface, key, user_data, destroy);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_text_extents(int /*long*/ cr, byte[] utf8, cairo_text_extents_t extents);
+public static final void cairo_text_extents(int /*long*/ cr, byte[] utf8, cairo_text_extents_t extents) {
+	lock.lock();
+	try {
+		_cairo_text_extents(cr, utf8, extents);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_text_path(int /*long*/ cr, byte[] utf8);
+public static final void cairo_text_path(int /*long*/ cr, byte[] utf8) {
+	lock.lock();
+	try {
+		_cairo_text_path(cr, utf8);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_transform(int /*long*/ cr, double[] matrix);
+public static final void cairo_transform(int /*long*/ cr, double[] matrix) {
+	lock.lock();
+	try {
+		_cairo_transform(cr, matrix);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_translate(int /*long*/ cr, double tx, double ty);
+public static final void cairo_translate(int /*long*/ cr, double tx, double ty) {
+	lock.lock();
+	try {
+		_cairo_translate(cr, tx, ty);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_user_to_device(int /*long*/ cr, double[] x, double[] y);
+public static final void cairo_user_to_device(int /*long*/ cr, double[] x, double[] y) {
+	lock.lock();
+	try {
+		_cairo_user_to_device(cr, x, y);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_user_to_device_distance(int /*long*/ cr, double[] dx, double[] dy);
+public static final void cairo_user_to_device_distance(int /*long*/ cr, double[] dx, double[] dy) {
+	lock.lock();
+	try {
+		_cairo_user_to_device_distance(cr, dx, dy);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int cairo_version();
+public static final native int /*long*/ _cairo_xlib_surface_create(int /*long*/ dpy, int /*long*/ drawable, int /*long*/ visual, int width, int height);
+public static final int /*long*/ cairo_xlib_surface_create(int /*long*/ dpy, int /*long*/ drawable, int /*long*/ visual, int width, int height) {
+	lock.lock();
+	try {
+		return _cairo_xlib_surface_create(dpy, drawable, visual, width, height);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _cairo_xlib_surface_create_for_bitmap(int /*long*/ dpy, int /*long*/ pixmap, int /*long*/ screen, int width, int height);
+public static final int /*long*/ cairo_xlib_surface_create_for_bitmap(int /*long*/ dpy, int /*long*/ pixmap, int /*long*/ screen, int width, int height) {
+	lock.lock();
+	try {
+		return _cairo_xlib_surface_create_for_bitmap(dpy, pixmap, screen, width, height);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _cairo_xlib_surface_set_size(int /*long*/ surface, int width, int height);
+public static final void cairo_xlib_surface_set_size(int /*long*/ surface, int width, int height) {
+	lock.lock();
+	try {
+		_cairo_xlib_surface_set_size(surface, width, height);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void memmove(cairo_path_t dest, int /*long*/ src, int /*long*/ size);
+public static final native void memmove(cairo_path_data_t dest, int /*long*/ src, int /*long*/ size);
+public static final native void memmove(double[] dest, int /*long*/ src, int /*long*/ size);
+
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/cairo/Cairo.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/cairo/cairo_font_extents_t.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/cairo/cairo_font_extents_t.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/cairo/cairo_font_extents_t.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,31 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * -  Binding to permit interfacing between Cairo and SWT
+ * -  Copyright (C) 2005 IBM Corp.  All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package org.eclipse.swt.internal.cairo;
+
+
+public class cairo_font_extents_t {
+	public double ascent;
+	public double descent;
+	public double height;
+	public double max_x_advance;
+	public double max_y_advance;
+	public static final int sizeof = Cairo.cairo_font_extents_t_sizeof();
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/cairo/cairo_font_extents_t.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/cairo/cairo_path_data_t.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/cairo/cairo_path_data_t.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/cairo/cairo_path_data_t.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,28 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * -  Binding to permit interfacing between Cairo and SWT
+ * -  Copyright (C) 2005 IBM Corp.  All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package org.eclipse.swt.internal.cairo;
+
+
+public class cairo_path_data_t {
+	public int type;
+	public int length;
+	public static final int sizeof = Cairo.cairo_path_data_t_sizeof();
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/cairo/cairo_path_data_t.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/cairo/cairo_path_t.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/cairo/cairo_path_t.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/cairo/cairo_path_t.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,29 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * -  Binding to permit interfacing between Cairo and SWT
+ * -  Copyright (C) 2005 IBM Corp.  All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package org.eclipse.swt.internal.cairo;
+
+
+public class cairo_path_t {
+	public int status;
+	public int /*long*/ data;
+	public int num_data;
+	public static final int sizeof = Cairo.cairo_path_t_sizeof();
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/cairo/cairo_path_t.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/cairo/cairo_text_extents_t.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/cairo/cairo_text_extents_t.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/cairo/cairo_text_extents_t.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,32 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * -  Binding to permit interfacing between Cairo and SWT
+ * -  Copyright (C) 2005 IBM Corp.  All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package org.eclipse.swt.internal.cairo;
+
+
+public class cairo_text_extents_t {
+	public double x_bearing;
+	public double y_bearing;
+	public double width;
+	public double height;
+	public double x_advance;
+	public double y_advance;
+	public static final int sizeof = Cairo.cairo_text_extents_t_sizeof();
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/cairo/cairo_text_extents_t.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/cde/CDE.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/cde/CDE.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/cde/CDE.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,190 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.cde;
+
+import org.eclipse.swt.internal.*;
+
+public class CDE extends Platform {
+
+	/** Constants */
+	public static final int DtACTION_FILE = 1;
+	public static final String DtDTS_DA_ACTION_LIST = "ACTIONS";
+	public static final String DtDTS_DA_ICON = "ICON";
+	public static final String DtDTS_DA_MIME_TYPE = "MIME_TYPE";
+	public static final String DtDTS_DA_NAME_TEMPLATE = "NAME_TEMPLATE";
+	
+	/** 64 bit */
+	public static final native int DtActionArg_sizeof();
+
+/** Natives */
+public static final native boolean _DtAppInitialize(int /*long*/ appContext, int /*long*/ display, int /*long*/ topWiget, byte[] appName, byte[] appClass);
+public static final boolean DtAppInitialize(int /*long*/ appContext, int /*long*/ display, int /*long*/ topWiget, byte[] appName, byte[] appClass) {
+	lock.lock();
+	try {
+		return _DtAppInitialize(appContext, display, topWiget, appName, appClass);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _DtDbLoad();
+public static final void DtDbLoad() {
+	lock.lock();
+	try {
+		_DtDbLoad();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _DtDtsDataTypeNames();
+public static final int /*long*/ DtDtsDataTypeNames() {
+	lock.lock();
+	try {
+		return _DtDtsDataTypeNames();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _DtDtsFileToDataType(byte[] fileName);
+public static final int /*long*/ DtDtsFileToDataType(byte[] fileName) {
+	lock.lock();
+	try {
+		return _DtDtsFileToDataType(fileName);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _DtDtsDataTypeIsAction(byte[] dataType);
+public static final boolean DtDtsDataTypeIsAction(byte[] dataType) {
+	lock.lock();
+	try {
+		return _DtDtsDataTypeIsAction(dataType);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _DtDtsDataTypeToAttributeValue(byte[] dataType, byte[] attrName, byte[] optName);
+public static final int /*long*/ DtDtsDataTypeToAttributeValue(byte[] dataType, byte[] attrName, byte[] optName) {
+	lock.lock();
+	try {
+		return _DtDtsDataTypeToAttributeValue(dataType, attrName, optName);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _DtDtsFreeDataType(int /*long*/ dataType);
+public static final void DtDtsFreeDataType(int /*long*/ dataType) {
+	lock.lock();
+	try {
+		_DtDtsFreeDataType(dataType);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _DtDtsFreeDataTypeNames(int /*long*/ dataTypeList);
+public static final void DtDtsFreeDataTypeNames(int /*long*/ dataTypeList) {
+	lock.lock();
+	try {
+		_DtDtsFreeDataTypeNames(dataTypeList);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _DtDtsFreeAttributeValue(int /*long*/ attrValue);
+public static final void DtDtsFreeAttributeValue(int /*long*/ attrValue) {
+	lock.lock();
+	try {
+		_DtDtsFreeAttributeValue(attrValue);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native long _DtActionInvoke(int /*long*/ topWidget, byte[] action, DtActionArg args, int argCount, byte[] termOpts, byte[] execHost, byte[] contextDir, int useIndicator, int /*long*/ callback, int /*long*/ clientData);
+public static final long DtActionInvoke(int /*long*/ topWidget, byte[] action, DtActionArg args, int argCount, byte[] termOpts, byte[] execHost, byte[] contextDir, int useIndicator, int /*long*/ callback, int /*long*/ clientData) {
+	lock.lock();
+	try {
+		return _DtActionInvoke(topWidget, action, args, argCount, termOpts, execHost, contextDir, useIndicator, callback, clientData);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _topLevelShellWidgetClass();
+public static final int /*long*/ topLevelShellWidgetClass() {
+	lock.lock();
+	try {
+		return _topLevelShellWidgetClass();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _XtAppCreateShell(byte[] appName, byte[] appClass, int /*long*/ widgetClass, int /*long*/ display, int /*long*/ [] argList, int argCount);
+public static final int /*long*/ XtAppCreateShell(byte[] appName, byte[] appClass, int /*long*/ widgetClass, int /*long*/ display, int /*long*/ [] argList, int argCount) {
+	lock.lock();
+	try {
+		return _XtAppCreateShell(appName, appClass, widgetClass, display, argList, argCount);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _XtCreateApplicationContext();
+public static final int /*long*/ XtCreateApplicationContext() {
+	lock.lock();
+	try {
+		return _XtCreateApplicationContext();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _XtDisplayInitialize(int /*long*/ app_context, int /*long*/ display, byte[] appName, byte[] appClass, int /*long*/ options, int num_options, int /*long*/ [] argc, int argv);
+public static final void XtDisplayInitialize(int /*long*/ appContext, int /*long*/ display, byte[] appName, byte[] appClass, int /*long*/ options, int num_options, int /*long*/ [] argc, int argv) {
+	lock.lock();
+	try {
+		_XtDisplayInitialize(appContext, display, appName, appClass, options, num_options, argc, argv);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _XtRealizeWidget(int /*long*/ widget);
+public static final void XtRealizeWidget(int /*long*/ widget) {
+	lock.lock();
+	try {
+		_XtRealizeWidget(widget);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _XtResizeWidget(int /*long*/ widget, int width, int height, int borderWidth);
+public static final void XtResizeWidget(int /*long*/ widget, int width, int height, int borderWidth) {
+	lock.lock();
+	try {
+		_XtResizeWidget(widget, width, height, borderWidth);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _XtSetMappedWhenManaged(int /*long*/ widget, boolean flag);
+public static final void XtSetMappedWhenManaged(int /*long*/ widget, boolean flag) {
+	lock.lock();
+	try {
+		_XtSetMappedWhenManaged(widget, flag);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _XtToolkitInitialize();
+public static final void XtToolkitInitialize() {
+	lock.lock();
+	try {
+		_XtToolkitInitialize();
+	} finally {
+		lock.unlock();
+	}
+}
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/cde/CDE.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/cde/DtActionArg.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/cde/DtActionArg.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/cde/DtActionArg.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,18 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.cde;
+
+
+public class DtActionArg {
+	public int argClass;
+	public int /*long*/ name;
+	public static final int sizeof = CDE.DtActionArg_sizeof();
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/cde/DtActionArg.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gnome/GNOME.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gnome/GNOME.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gnome/GNOME.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,218 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others. All rights reserved.
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt).  The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html.  If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.gnome;
+
+import org.eclipse.swt.internal.*;
+
+public class GNOME extends Platform {
+	static {
+		Library.loadLibrary("swt-gnome");
+	}
+
+public static final int GNOME_FILE_DOMAIN_PIXMAP = 4;
+public static final int GNOME_ICON_LOOKUP_FLAGS_NONE = 0;
+public static final int GNOME_PARAM_NONE = 0;
+public static final int GNOME_VFS_MIME_APPLICATION_ARGUMENT_TYPE_URIS = 0;
+public static final int GNOME_VFS_OK = 0;
+public static final int GNOME_VFS_MAKE_URI_DIR_NONE = 0;
+public static final int GNOME_VFS_MAKE_URI_DIR_HOMEDIR = 1<<0;
+public static final int GNOME_VFS_MAKE_URI_DIR_CURRENT = 1<<1;
+
+/** 64 bit */
+public static final native int GnomeVFSMimeApplication_sizeof();
+
+/** Natives */
+public static final native void _g_free(int /*long*/ mem);
+public static final void g_free(int /*long*/ mem) {
+	lock.lock();
+	try {
+		_g_free(mem);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _g_list_append(int /*long*/ list, int /*long*/ data);
+public static final int /*long*/ g_list_append(int /*long*/ list, int /*long*/ data) {
+	lock.lock();
+	try {
+		return _g_list_append(list, data);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _g_list_free(int /*long*/ list);
+public static final void g_list_free(int /*long*/ list) {
+	lock.lock();
+	try {
+		_g_list_free(list);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _g_list_next(int /*long*/ list);
+public static final int /*long*/ g_list_next(int /*long*/ list) {
+	lock.lock();
+	try {
+		return _g_list_next(list);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _g_object_unref(int /*long*/ object);
+public static final void g_object_unref(int /*long*/ object) {
+	lock.lock();
+	try {
+		_g_object_unref(object);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gnome_icon_lookup(int /*long*/ icon_theme, int /*long*/ thumbnail_factory, byte[] file_uri, byte[] custom_icon, int /*long*/ file_info, byte[] mime_type, int flags, int[] result);
+public static final int /*long*/ gnome_icon_lookup(int /*long*/ icon_theme, int /*long*/ thumbnail_factory, byte[] file_uri, byte[] custom_icon, int /*long*/ file_info, byte[] mime_type, int flags, int[] result) {
+	lock.lock();
+	try {
+		return _gnome_icon_lookup(icon_theme, thumbnail_factory, file_uri, custom_icon, file_info, mime_type, flags, result);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gnome_icon_theme_lookup_icon(int /*long*/ theme, int /*long*/ icon_name, int size, int /*long*/[] icon_data, int[] base_size);
+public static final int /*long*/ gnome_icon_theme_lookup_icon(int /*long*/ theme, int /*long*/ icon_name, int size, int /*long*/[] icon_data, int[] base_size) {
+	lock.lock();
+	try {
+		return _gnome_icon_theme_lookup_icon(theme, icon_name, size, icon_data, base_size);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gnome_icon_theme_new();
+public static final int /*long*/ gnome_icon_theme_new() {
+	lock.lock();
+	try {
+		return _gnome_icon_theme_new();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gnome_vfs_get_registered_mime_types();
+public static final int /*long*/ gnome_vfs_get_registered_mime_types() {
+	lock.lock();
+	try {
+		return _gnome_vfs_get_registered_mime_types();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _gnome_vfs_init();
+public static final boolean gnome_vfs_init() {
+	lock.lock();
+	try {
+		return _gnome_vfs_init();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gnome_vfs_make_uri_from_input(byte[] uri);
+public static final int /*long*/ gnome_vfs_make_uri_from_input(byte[] uri) {
+	lock.lock();
+	try {
+		return _gnome_vfs_make_uri_from_input(uri);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gnome_vfs_make_uri_from_input_with_dirs(byte[] uri, int dirs);
+public static final int /*long*/ gnome_vfs_make_uri_from_input_with_dirs(byte[] uri, int dirs) {
+	lock.lock();
+	try {
+		return _gnome_vfs_make_uri_from_input_with_dirs(uri, dirs);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gnome_vfs_mime_application_free(int /*long*/ application);
+public static final void gnome_vfs_mime_application_free(int /*long*/ application) {
+	lock.lock();
+	try {
+		_gnome_vfs_mime_application_free(application);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _gnome_vfs_mime_application_launch(int /*long*/ application, int /*long*/ uris);
+public static final int gnome_vfs_mime_application_launch(int /*long*/ application, int /*long*/ uris) {	
+	lock.lock();
+	try {
+		return _gnome_vfs_mime_application_launch(application, uris);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gnome_vfs_mime_extensions_list_free(int /*long*/ list);
+public static final void gnome_vfs_mime_extensions_list_free(int /*long*/ list) {
+	lock.lock();
+	try {
+		_gnome_vfs_mime_extensions_list_free(list);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gnome_vfs_mime_get_default_application(byte[] mimeType);
+public static final int /*long*/ gnome_vfs_mime_get_default_application(byte[] mimeType) {
+	lock.lock();
+	try {
+		return _gnome_vfs_mime_get_default_application(mimeType);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gnome_vfs_mime_get_extensions_list(int /*long*/ mime_type);
+public static final int /*long*/ gnome_vfs_mime_get_extensions_list(int /*long*/ mime_type) {
+	lock.lock();
+	try {
+		return _gnome_vfs_mime_get_extensions_list(mime_type);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gnome_vfs_mime_registered_mime_type_list_free(int /*long*/ list);
+public static final void gnome_vfs_mime_registered_mime_type_list_free(int /*long*/ list) {
+	lock.lock();
+	try {
+		_gnome_vfs_mime_registered_mime_type_list_free(list);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gnome_vfs_mime_type_from_name(byte[] file);
+public static final int /*long*/ gnome_vfs_mime_type_from_name(byte[] file) {
+	lock.lock();
+	try {
+		return _gnome_vfs_mime_type_from_name(file);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _gnome_vfs_url_show(int /*long*/ url);
+public static final int gnome_vfs_url_show(int /*long*/ url) {
+	lock.lock();
+	try {
+		return _gnome_vfs_url_show(url);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void memmove (GnomeVFSMimeApplication dest, int /*long*/ src, int /*long*/ count);
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gnome/GNOME.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gnome/GnomeVFSMimeApplication.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gnome/GnomeVFSMimeApplication.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gnome/GnomeVFSMimeApplication.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others. All rights reserved.
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt).  The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html.  If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.gnome;
+
+ 
+public class GnomeVFSMimeApplication {
+	public int /*long*/ id;
+	public int /*long*/ name;
+	public int /*long*/ command;
+	public boolean can_open_multiple_files;
+	public int expects_uris;
+	public int /*long*/ supported_uri_schemes;
+	public boolean requires_terminal;
+	public static final int sizeof = GNOME.GnomeVFSMimeApplication_sizeof();
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gnome/GnomeVFSMimeApplication.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GInterfaceInfo.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GInterfaceInfo.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GInterfaceInfo.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others. All rights reserved.
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt).  The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html.  If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.gtk;
+
+
+public class GInterfaceInfo {
+	public int /*long*/ interface_init;
+	public int /*long*/ interface_finalize;
+	public int /*long*/ interface_data;
+	public static final int sizeof = OS.GInterfaceInfo_sizeof();
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GInterfaceInfo.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GObjectClass.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GObjectClass.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GObjectClass.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others. All rights reserved.
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt).  The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html.  If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.gtk;
+
+
+public class GObjectClass {
+	public int /*long*/ constructor;
+	public int /*long*/ set_property;
+	public int /*long*/ get_property;
+	public int /*long*/ dispose;
+	public int /*long*/ finalize;
+	public int /*long*/ dispatch_properties_changed;
+	public int /*long*/ notify;
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GObjectClass.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GTypeInfo.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GTypeInfo.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GTypeInfo.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others. All rights reserved.
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt).  The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html.  If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.gtk;
+
+
+public class GTypeInfo {
+	public short class_size;
+	public int /*long*/ base_init;
+	public int /*long*/ base_finalize;
+	public int /*long*/ class_init;
+	public int /*long*/ class_finalize;
+	public int /*long*/ class_data;
+	public short instance_size;
+	public short n_preallocs;
+	public int /*long*/ instance_init;
+	public int /*long*/ value_table;
+	public static final int sizeof = OS.GTypeInfo_sizeof();	
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GTypeInfo.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GTypeQuery.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GTypeQuery.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GTypeQuery.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others. All rights reserved.
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt).  The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html.  If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.gtk;
+
+
+public class GTypeQuery {
+	public int type;
+	public int /*long*/ type_name;
+	public int class_size;
+	public int instance_size;
+	public static final int sizeof = OS.GTypeQuery_sizeof();
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GTypeQuery.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GdkColor.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GdkColor.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GdkColor.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others. All rights reserved.
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt).  The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html.  If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.gtk;
+
+
+public class GdkColor {
+	public int pixel;
+	public short red; 
+	public short green;
+	public short blue;
+	public static final int sizeof = OS.GdkColor_sizeof();
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GdkColor.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GdkDragContext.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GdkDragContext.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GdkDragContext.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others. All rights reserved.
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt).  The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html.  If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.gtk;
+
+
+public class GdkDragContext {     
+   public int protocol;
+   public boolean is_source;
+   public int /*long*/ source_window;
+   public int /*long*/ dest_window;
+   public int /*long*/ targets;
+   public int actions;
+   public int suggested_action;
+   public int action; 
+   public int start_time;
+   public static final int sizeof = OS.GdkDragContext_sizeof();
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GdkDragContext.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GdkEvent.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GdkEvent.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GdkEvent.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others. All rights reserved.
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt).  The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html.  If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.gtk;
+
+
+public class GdkEvent {
+	public int type;
+	public static final int sizeof = OS.GdkEvent_sizeof();
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GdkEvent.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GdkEventAny.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GdkEventAny.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GdkEventAny.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others. All rights reserved.
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt).  The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html.  If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.gtk;
+
+
+public class GdkEventAny extends GdkEvent {
+	public int /*long*/ window;
+	public byte send_event;
+	public static final int sizeof = OS.GdkEventAny_sizeof();
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GdkEventAny.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GdkEventButton.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GdkEventButton.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GdkEventButton.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others. All rights reserved.
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt).  The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html.  If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.gtk;
+
+
+public class GdkEventButton extends GdkEvent {
+	public int /*long*/ window;
+	public byte send_event;
+	public int time;
+	public double x;
+	public double y;
+	public int /*long*/ axes;
+	public int state;
+	public int button;
+	public int /*long*/ device;
+	public double x_root;
+	public double y_root;
+	public static final int sizeof = OS.GdkEventButton_sizeof();
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GdkEventButton.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GdkEventCrossing.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GdkEventCrossing.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GdkEventCrossing.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others. All rights reserved.
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt).  The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html.  If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.gtk;
+
+
+public class GdkEventCrossing extends GdkEvent {
+	public int /*long*/ window;
+	public byte send_event;
+	public int /*long*/ subwindow;
+	public int time;
+	public double x;
+	public double y;
+	public double x_root;
+	public double y_root;
+	public int mode;
+	public int detail;
+	public boolean focus;
+	public int state;
+	public static final int sizeof = OS.GdkEventCrossing_sizeof();
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GdkEventCrossing.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GdkEventExpose.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GdkEventExpose.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GdkEventExpose.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others. All rights reserved.
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt).  The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html.  If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.gtk;
+
+
+public class GdkEventExpose extends GdkEvent {
+	public int /*long*/ window;
+	public byte send_event;
+	public int area_x;
+	public int area_y;
+	public int area_width;
+	public int area_height;
+	public int /*long*/ region;
+	public int count;
+	public static final int sizeof = OS.GdkEventExpose_sizeof();
+}
+


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GdkEventExpose.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GdkEventFocus.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GdkEventFocus.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GdkEventFocus.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others. All rights reserved.
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt).  The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html.  If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.gtk;
+
+
+public class GdkEventFocus extends GdkEvent {
+	public int /*long*/ window;
+	public byte send_event;
+	public short in;
+	public static final int sizeof = OS.GdkEventFocus_sizeof();
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GdkEventFocus.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GdkEventKey.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GdkEventKey.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GdkEventKey.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others. All rights reserved.
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt).  The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html.  If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.gtk;
+
+
+public class GdkEventKey extends GdkEvent {
+	public int /*long*/ window;
+	public byte send_event;
+	public int time;
+	public int state;
+	public int keyval;
+	public int length;
+	public int /*long*/ string;
+	public short hardware_keycode;
+    public byte group;
+   	public static final int sizeof = OS.GdkEventKey_sizeof();
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GdkEventKey.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GdkEventMotion.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GdkEventMotion.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GdkEventMotion.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others. All rights reserved.
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt).  The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html.  If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.gtk;
+
+
+public class GdkEventMotion extends GdkEvent {
+	public int /*long*/ window;
+	public byte send_event;
+	public int time;
+	public double x;
+	public double y;
+	public int /*long*/ axes;
+	public int state;
+	public short is_hint;
+	public int /*long*/ device;
+	public double x_root;
+	public double y_root;
+	public static final int sizeof = OS.GdkEventMotion_sizeof();
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GdkEventMotion.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GdkEventScroll.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GdkEventScroll.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GdkEventScroll.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others. All rights reserved.
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt).  The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html.  If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.gtk;
+
+
+public class GdkEventScroll extends GdkEvent {
+	public int /*long*/ window;
+	public byte send_event;
+	public int time;
+	public double x;
+	public double y;
+	public int state;
+	public int direction;
+	public int /*long*/ device;
+	public double x_root;
+	public double y_root;
+	public static final int sizeof = OS.GdkEventScroll_sizeof();
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GdkEventScroll.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GdkEventVisibility.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GdkEventVisibility.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GdkEventVisibility.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others. All rights reserved.
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt).  The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html.  If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.gtk;
+
+
+public class GdkEventVisibility extends GdkEvent {
+	public int /*long*/ window;
+	public byte send_event; 
+	public int state;
+	public static final int sizeof = OS.GdkEventVisibility_sizeof();
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GdkEventVisibility.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GdkEventWindowState.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GdkEventWindowState.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GdkEventWindowState.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others. All rights reserved.
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt).  The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html.  If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.gtk;
+
+
+public class GdkEventWindowState extends GdkEvent {
+	public int /*long*/ window;
+	public byte send_event; 
+	public int changed_mask;
+	public int new_window_state;
+	public static final int sizeof = OS.GdkEventWindowState_sizeof();
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GdkEventWindowState.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GdkGCValues.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GdkGCValues.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GdkGCValues.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others. All rights reserved.
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt).  The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html.  If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.gtk;
+
+
+public class GdkGCValues {
+	public int foreground_pixel;
+	public short foreground_red;
+	public short foreground_green;
+	public short foreground_blue;
+	public int background_pixel;
+	public short background_red;
+	public short background_green;
+	public short background_blue;
+	public int /*long*/ font;
+	public int /*long*/ function;
+	public int fill;
+	public int /*long*/ tile;
+	public int /*long*/ stipple;
+	public int /*long*/ clip_mask;
+	public int subwindow_mode;
+	public int ts_x_origin;
+	public int ts_y_origin;
+	public int clip_x_origin;
+	public int clip_y_origin;
+	public int graphics_exposures;
+	public int line_width;
+	public int line_style;
+	public int cap_style;
+	public int join_style;
+	public static final int sizeof = OS.GdkGCValues_sizeof();
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GdkGCValues.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GdkGeometry.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GdkGeometry.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GdkGeometry.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others. All rights reserved.
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt).  The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html.  If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.gtk;
+
+
+public class GdkGeometry {
+	public int min_width;
+	public int min_height;
+	public int max_width;
+	public int max_height;
+	public int base_width;
+	public int base_height;
+	public int width_inc;
+	public int height_inc;
+	public double min_aspect;
+	public double max_aspect;
+	public int win_gravity;
+	public static final int sizeof = OS.GdkGeometry_sizeof();
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GdkGeometry.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GdkImage.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GdkImage.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GdkImage.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others. All rights reserved.
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt).  The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html.  If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.gtk;
+
+
+public class GdkImage {
+	public int type;
+	public int /*long*/ visual;
+	public int byte_order;
+	public int width;
+	public int height;
+	public short depth;
+	public short bpp;
+	public short bpl;
+	public short bits_per_pixel;
+	public int /*long*/ mem;
+	public int /*long*/ colormap;
+	public int /*long*/ windowing_data;
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GdkImage.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GdkRectangle.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GdkRectangle.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GdkRectangle.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others. All rights reserved.
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt).  The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html.  If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.gtk;
+
+
+public class GdkRectangle {
+	public int x;
+	public int y;
+	public int width;
+	public int height;
+	public static final int sizeof = OS.GdkRectangle_sizeof();
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GdkRectangle.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GdkVisual.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GdkVisual.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GdkVisual.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others. All rights reserved.
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt).  The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html.  If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.gtk;
+
+
+public class GdkVisual {
+	public int type;
+	public int depth;
+	public int byte_order;
+	public int colormap_size;
+	public int bits_per_rgb;
+	public int red_mask;
+	public int red_shift;
+	public int red_prec;
+	public int green_mask;
+	public int green_shift;
+	public int green_prec;
+	public int blue_mask;
+	public int blue_shift;
+	public int blue_prec;
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GdkVisual.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GdkWindowAttr.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GdkWindowAttr.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GdkWindowAttr.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others. All rights reserved.
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt).  The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html.  If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.gtk;
+
+
+public class GdkWindowAttr {
+	public int /*long*/ title;
+	public int event_mask;
+	public int x, y;
+	public int width;
+	public int height;
+	public int wclass;
+	public int /*long*/ visual;
+	public int /*long*/ colormap;
+	public int window_type;
+	public int /*long*/ cursor;
+	public int /*long*/ wmclass_name;
+	public int /*long*/ wmclass_class;
+	public boolean override_redirect;
+	public static final int sizeof = OS.GdkWindowAttr_sizeof();
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GdkWindowAttr.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GtkAdjustment.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GtkAdjustment.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GtkAdjustment.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others. All rights reserved.
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt).  The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html.  If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.gtk;
+
+
+public class GtkAdjustment {
+	public double lower;
+	public double upper;
+	public double value;
+	public double step_increment;
+	public double page_increment;
+	public double page_size;
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GtkAdjustment.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GtkAllocation.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GtkAllocation.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GtkAllocation.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others. All rights reserved.
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt).  The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html.  If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.gtk;
+
+
+public class GtkAllocation {
+	public int x;
+	public int y;
+	public int width;
+	public int height;
+	public static final int sizeof = OS.GtkAllocation_sizeof();
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GtkAllocation.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GtkBorder.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GtkBorder.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GtkBorder.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others. All rights reserved.
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt).  The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html.  If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.gtk;
+
+
+public class GtkBorder {
+	public int left;
+	public int right;
+	public int top;
+	public int bottom;
+	public static final int sizeof = OS.GtkBorder_sizeof();
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GtkBorder.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GtkCellRendererClass.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GtkCellRendererClass.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GtkCellRendererClass.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others. All rights reserved.
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt).  The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html.  If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.gtk;
+
+
+public class GtkCellRendererClass {
+	public int /*long*/ render;
+	public int /*long*/ get_size;
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GtkCellRendererClass.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GtkColorSelectionDialog.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GtkColorSelectionDialog.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GtkColorSelectionDialog.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others. All rights reserved.
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt).  The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html.  If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.gtk;
+
+
+public class GtkColorSelectionDialog {
+	public int /*long*/ colorsel;
+	public int /*long*/ ok_button;
+	public int /*long*/ cancel_button;
+	public int /*long*/ help_button;
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GtkColorSelectionDialog.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GtkCombo.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GtkCombo.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GtkCombo.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others. All rights reserved.
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt).  The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html.  If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.gtk;
+
+
+public class GtkCombo {
+	public int /*long*/ entry;
+	public int /*long*/ list;
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GtkCombo.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GtkFileSelection.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GtkFileSelection.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GtkFileSelection.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others. All rights reserved.
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt).  The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html.  If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.gtk;
+
+
+public class GtkFileSelection {
+	public int /*long*/ dir_list;
+	public int /*long*/ file_list;
+	public int /*long*/ selection_entry;
+	public int /*long*/ selection_text;
+	public int /*long*/ main_vbox;
+	public int /*long*/ ok_button;
+	public int /*long*/ cancel_button;
+	public int /*long*/ help_button;
+	public int /*long*/ history_pulldown;
+	public int /*long*/ history_menu;
+	public int /*long*/ history_list;
+	public int /*long*/ fileop_dialog;
+	public int /*long*/ fileop_entry;
+	public int /*long*/ fileop_file;
+	public int /*long*/ cmpl_state;			// gpointer
+	public int /*long*/ fileop_c_dir;
+	public int /*long*/ fileop_del_file;
+	public int /*long*/ fileop_ren_file;
+	public int /*long*/ button_area;
+	public int /*long*/ action_area;
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GtkFileSelection.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GtkFixed.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GtkFixed.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GtkFixed.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,20 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others. All rights reserved.
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt).  The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html.  If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.gtk;
+
+
+public class GtkFixed {
+	public int /*long*/ children;
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GtkFixed.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GtkRequisition.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GtkRequisition.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GtkRequisition.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others. All rights reserved.
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt).  The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html.  If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.gtk;
+
+
+public class GtkRequisition {
+	public int width;
+	public int height;
+	public static final int sizeof = OS.GtkRequisition_sizeof();
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GtkRequisition.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GtkSelectionData.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GtkSelectionData.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GtkSelectionData.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others. All rights reserved.
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt).  The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html.  If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.gtk;
+
+
+public class GtkSelectionData {
+	public int /*long*/  selection;
+	public int /*long*/  target;
+	public int /*long*/  type;
+	public int  format;
+	public int /*long*/  data;  
+	public int  length;
+	public static final int sizeof = OS.GtkSelectionData_sizeof();
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GtkSelectionData.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GtkTargetEntry.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GtkTargetEntry.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GtkTargetEntry.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others. All rights reserved.
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt).  The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html.  If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.gtk;
+
+
+public class GtkTargetEntry {
+	public int /*long*/ target;
+	public int flags;
+	public int info;
+	public static final int sizeof = OS.GtkTargetEntry_sizeof();
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GtkTargetEntry.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GtkTargetPair.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GtkTargetPair.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GtkTargetPair.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others. All rights reserved.
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt).  The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html.  If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.gtk;
+
+
+public class GtkTargetPair {
+	public int /*long*/ target;
+	public int flags;
+	public int info;
+	public static final int sizeof = OS.GtkTargetPair_sizeof();
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GtkTargetPair.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GtkWidgetClass.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GtkWidgetClass.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GtkWidgetClass.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,83 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others. All rights reserved.
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt).  The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html.  If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.gtk;
+
+
+public class GtkWidgetClass extends GObjectClass {
+	public int activate_signal;
+	public int set_scroll_adjustments_signal;	
+	public int /*long*/ dispatch_child_properties_changed;
+	public int /*long*/ show;
+	public int /*long*/ show_all;
+	public int /*long*/ hide;
+	public int /*long*/ hide_all;
+	public int /*long*/ map;
+	public int /*long*/ unmap;
+	public int /*long*/ realize;
+	public int /*long*/ unrealize;
+	public int /*long*/ size_request;
+	public int /*long*/ size_allocate;
+	public int /*long*/ state_changed; 
+	public int /*long*/ parent_set;
+	public int /*long*/ hierarchy_changed;
+	public int /*long*/ style_set;
+	public int /*long*/ direction_changed;
+	public int /*long*/ grab_notify;
+	public int /*long*/ child_notify;	
+	public int /*long*/ mnemonic_activate;
+	public int /*long*/ grab_focus;
+	public int /*long*/ focus;
+	public int /*long*/ event;
+	public int /*long*/ button_press_event;
+	public int /*long*/ button_release_event;
+	public int /*long*/ scroll_event;
+	public int /*long*/ motion_notify_event;
+	public int /*long*/ delete_event;
+	public int /*long*/ destroy_event;
+	public int /*long*/ expose_event;
+	public int /*long*/ key_press_event;
+	public int /*long*/ key_release_event;
+	public int /*long*/ enter_notify_event;
+	public int /*long*/ leave_notify_event;
+	public int /*long*/ configure_event;
+	public int /*long*/ focus_in_event;
+	public int /*long*/ focus_out_event;
+	public int /*long*/ map_event;
+	public int /*long*/ unmap_event;
+	public int /*long*/ property_notify_event;
+	public int /*long*/ selection_clear_event;
+	public int /*long*/ selection_request_event;
+	public int /*long*/ selection_notify_event;
+	public int /*long*/ proximity_in_event;
+	public int /*long*/ proximity_out_event;
+	public int /*long*/ visibility_notify_event;
+	public int /*long*/ client_event;
+	public int /*long*/ no_expose_event;
+	public int /*long*/ window_state_event;
+	public int /*long*/ selection_get;
+	public int /*long*/ selection_received;
+	public int /*long*/ drag_begin;
+	public int /*long*/ drag_end;
+	public int /*long*/ drag_data_get;
+	public int /*long*/ drag_data_delete;
+	public int /*long*/ drag_leave;
+	public int /*long*/ drag_motion;
+	public int /*long*/ drag_drop;
+	public int /*long*/ drag_data_received;
+	public int /*long*/ popup_menu;
+	public int /*long*/ show_help;
+	public int /*long*/ get_accessible;
+	public int /*long*/ screen_changed;
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/GtkWidgetClass.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/OS.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/OS.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/OS.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,10789 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others. All rights reserved.
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt).  The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html.  If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.gtk;
+
+ 
+import org.eclipse.swt.internal.*;
+
+public class OS extends C {
+	static {
+		Library.loadLibrary("swt-pi");
+	}
+	
+	/** OS Constants */
+	public static final boolean IsAIX, IsSunOS, IsLinux, IsHPUX;
+	static {
+		
+		/* Initialize the OS flags and locale constants */
+		String osName = System.getProperty ("os.name");
+		boolean isAIX = false, isSunOS = false, isLinux = false, isHPUX = false;
+		if (osName.equals ("Linux")) isLinux = true;
+		if (osName.equals ("AIX")) isAIX = true;
+		if (osName.equals ("Solaris")) isSunOS = true;
+		if (osName.equals ("SunOS")) isSunOS = true;
+		if (osName.equals ("HP-UX")) isHPUX = true;
+		IsAIX = isAIX;  IsSunOS = isSunOS;  IsLinux = isLinux;  IsHPUX = isHPUX;
+	}
+
+	/** Constants */
+	public static final int ATK_RELATION_LABELLED_BY = 4;
+	public static final int G_SIGNAL_MATCH_DATA = 1 << 4;
+	public static final int G_SIGNAL_MATCH_ID = 1 << 0;
+	public static final int GDK_2BUTTON_PRESS = 0x5;
+	public static final int GDK_3BUTTON_PRESS = 0x6;
+	public static final int GDK_ACTION_COPY = 1 << 1;
+	public static final int GDK_ACTION_MOVE = 1 << 2;
+	public static final int GDK_ACTION_LINK = 1 << 3;
+	public static final int GDK_Alt_L = 0xffe9;
+	public static final int GDK_Alt_R = 0xffea;
+	public static final int GDK_AND = 4;
+	public static final int GDK_BackSpace = 0xff08;
+	public static final int GDK_BOTTOM_LEFT_CORNER = 0xc;
+	public static final int GDK_BOTTOM_RIGHT_CORNER = 0xe;
+	public static final int GDK_BOTTOM_SIDE = 0x10;
+	public static final int GDK_BUTTON1_MASK = 0x100;
+	public static final int GDK_BUTTON2_MASK = 0x200;
+	public static final int GDK_BUTTON3_MASK = 0x400;
+	public static final int GDK_BUTTON_MOTION_MASK	= 1 << 4;
+	public static final int GDK_BUTTON1_MOTION_MASK	= 1 << 5;
+	public static final int GDK_BUTTON2_MOTION_MASK	= 1 << 6;
+	public static final int GDK_BUTTON3_MOTION_MASK	= 1 << 7;
+	public static final int GDK_BUTTON_PRESS = 0x4;
+	public static final int GDK_BUTTON_PRESS_MASK = 0x100;
+	public static final int GDK_BUTTON_RELEASE = 0x7;
+	public static final int GDK_BUTTON_RELEASE_MASK = 0x200;
+	public static final int GDK_CAP_BUTT = 0x1;
+	public static final int GDK_CAP_PROJECTING = 3;
+	public static final int GDK_CAP_ROUND = 0x2;
+	public static final int GDK_COLORSPACE_RGB = 0;
+	public static final int GDK_CONFIGURE = 13;
+	public static final int GDK_CONTROL_MASK = 0x4;
+	public static final int GDK_COPY = 0x0;
+	public static final int GDK_CROSS = 0x1e;
+	public static final int GDK_CROSSING_NORMAL = 0;
+	public static final int GDK_CROSSING_GRAB = 1;
+	public static final int GDK_CROSSING_UNGRAB = 2;
+	public static final int GDK_Break = 0xff6b;
+	public static final int GDK_Cancel = 0xff69;
+	public static final int GDK_Caps_Lock = 0xffE5;
+	public static final int GDK_Clear = 0xff0B;
+	public static final int GDK_Control_L = 0xffe3;
+	public static final int GDK_Control_R = 0xffe4;
+	public static final int GDK_CURRENT_TIME = 0x0;
+	public static final int GDK_DECOR_BORDER = 0x2;
+	public static final int GDK_DECOR_MAXIMIZE = 0x40;
+	public static final int GDK_DECOR_MENU = 0x10;
+	public static final int GDK_DECOR_MINIMIZE = 0x20;
+	public static final int GDK_DECOR_RESIZEH = 0x4;
+	public static final int GDK_DECOR_TITLE = 0x8;
+	public static final int GDK_DOUBLE_ARROW = 0x2a;
+	public static final int GDK_Delete = 0xffff;
+	public static final int GDK_Down = 0xff54;
+	public static final int GDK_ENTER_NOTIFY_MASK = 0x1000;
+	public static final int GDK_ENTER_NOTIFY = 10;
+	public static final int GDK_EVEN_ODD_RULE = 0;
+	public static final int GTK_EXPANDER_COLAPSED = 0;
+	public static final int GTK_EXPANDER_SEMI_COLLAPSED = 1;
+	public static final int GTK_EXPANDER_SEMI_EXPANDED = 2;
+	public static final int GTK_EXPANDER_EXPANDED = 3;
+	public static final int GDK_EXPOSE = 2;
+	public static final int GDK_EXPOSURE_MASK = 0x2;
+	public static final int GDK_End = 0xff57;
+	public static final int GDK_Escape = 0xff1b;
+	public static final int GDK_F1 = 0xffbe;
+	public static final int GDK_F10 = 0xffc7;
+	public static final int GDK_F11 = 0xffc8;
+	public static final int GDK_F12 = 0xffc9;
+	public static final int GDK_F13 = 0xffca;
+	public static final int GDK_F14 = 0xffcb;
+	public static final int GDK_F15 = 0xffcc;
+	public static final int GDK_F2 = 0xffbf;
+	public static final int GDK_F3 = 0xffc0;
+	public static final int GDK_F4 = 0xffc1;
+	public static final int GDK_F5 = 0xffc2;
+	public static final int GDK_F6 = 0xffc3;
+	public static final int GDK_F7 = 0xffc4;
+	public static final int GDK_F8 = 0xffc5;
+	public static final int GDK_F9 = 0xffc6;
+	public static final int GDK_FLEUR = 0x34;
+	public static final int GDK_FOCUS_CHANGE = 0xc;
+	public static final int GDK_FOCUS_CHANGE_MASK = 0x4000;
+	public static final int GDK_GC_FOREGROUND = 0x1;
+	public static final int GDK_GC_CLIP_MASK = 0x80;
+	public static final int GDK_GC_CLIP_X_ORIGIN = 0x800;
+	public static final int GDK_GC_CLIP_Y_ORIGIN = 0x1000;
+	public static final int GDK_GC_LINE_WIDTH = 0x4000;
+	public static final int GDK_GC_LINE_STYLE = 0x8000;
+	public static final int GDK_GC_CAP_STYLE = 0x10000;
+	public static final int GDK_GC_JOIN_STYLE = 0x20000;
+	public static final int GDK_GRAB_SUCCESS = 0x0;
+	public static final int GDK_HAND2 = 0x3c;
+	public static final int GDK_Help = 0xFF6A;
+	public static final int GDK_HINT_MIN_SIZE = 1 << 1;
+	public static final int GDK_Home = 0xff50;
+	public static final int GDK_INCLUDE_INFERIORS = 0x1;
+	public static final int GDK_INPUT_ONLY = 1;
+	public static final int GDK_INTERP_BILINEAR = 0x2;
+	public static final int GDK_Insert = 0xff63;
+	public static final int GDK_ISO_Left_Tab = 0xfe20;
+	public static final int GDK_JOIN_MITER = 0x0;
+	public static final int GDK_JOIN_ROUND = 0x1;
+	public static final int GDK_JOIN_BEVEL = 0x2;
+	public static final int GDK_KEY_PRESS = 0x8;
+	public static final int GDK_KEY_PRESS_MASK = 0x400;
+	public static final int GDK_KEY_RELEASE = 0x9;
+	public static final int GDK_KEY_RELEASE_MASK = 0x800;
+	public static final int GDK_KP_0 = 0xffb0;
+	public static final int GDK_KP_1 = 0xffb1;
+	public static final int GDK_KP_2 = 0xffb2;
+	public static final int GDK_KP_3 = 0xffb3;
+	public static final int GDK_KP_4 = 0xffb4;
+	public static final int GDK_KP_5 = 0xffb5;
+	public static final int GDK_KP_6 = 0xffb6;
+	public static final int GDK_KP_7 = 0xffb7;
+	public static final int GDK_KP_8 = 0xffb8;
+	public static final int GDK_KP_9 = 0xffb9;
+	public static final int GDK_KP_Add = 0xffab;
+	public static final int GDK_KP_Decimal = 0xffae;
+	public static final int GDK_KP_Delete = 0xFF9F;
+	public static final int GDK_KP_Divide = 0xffaf;
+	public static final int GDK_KP_Down = 0xFF99;
+	public static final int GDK_KP_End = 0xFF9C;
+	public static final int GDK_KP_Enter = 0xff8d;
+	public static final int GDK_KP_Equal = 0xffbd;
+	public static final int GDK_KP_Home = 0xFF95;
+	public static final int GDK_KP_Insert = 0xFF9E;
+	public static final int GDK_KP_Left = 0xFF96;
+	public static final int GDK_KP_Multiply = 0xffaa;
+	public static final int GDK_KP_Page_Down = 0xFF9B;
+	public static final int GDK_KP_Page_Up = 0xFF9A;
+	public static final int GDK_KP_Right = 0xFF98;
+	public static final int GDK_KP_Subtract = 0xffad;
+	public static final int GDK_KP_Up = 0xFF97;
+	public static final int GDK_LEAVE_NOTIFY = 11;
+	public static final int GDK_LEAVE_NOTIFY_MASK = 0x2000;
+	public static final int GDK_LEFT_PTR = 0x44;
+	public static final int GDK_LEFT_SIDE = 0x46;
+	public static final int GDK_LINE_ON_OFF_DASH = 0x1;
+	public static final int GDK_LINE_SOLID = 0x0;
+	public static final int GDK_Linefeed = 0xff0A;
+	public static final int GDK_LSB_FIRST = 0x0;
+	public static final int GDK_Left = 0xff51;
+	public static final int GDK_Meta_L = 0xFFE7;
+	public static final int GDK_Meta_R = 0xFFE8;
+	public static final int GDK_MAP = 14;
+	public static final int GDK_MOD1_MASK = 0x8;
+	public static final int GDK_MOTION_NOTIFY = 0x3;
+	public static final int GDK_NO_EXPOSE = 30;
+	public static final int GDK_NONE = 0;
+	public static final int GDK_NOTIFY_INFERIOR = 2;
+	public static final int GDK_Num_Lock = 0xFF7F;
+	public static final int GDK_OVERLAP_RECTANGLE_OUT = 0x1;
+	public static final int GDK_PIXBUF_ALPHA_BILEVEL = 0x0;
+	public static final int GDK_POINTER_MOTION_HINT_MASK = 0x8;
+	public static final int GDK_POINTER_MOTION_MASK = 0x4;
+	public static final int GDK_PROPERTY_NOTIFY = 16;
+	public static final int GDK_Page_Down = 0xff56;
+	public static final int GDK_Page_Up = 0xff55;
+	public static final int GDK_Pause = 0xff13;
+	public static final int GDK_Print = 0xff61;
+	public static final int GDK_QUESTION_ARROW = 0x5c;
+	public static final int GDK_RGB_DITHER_NORMAL = 0x1;
+	public static final int GDK_RIGHT_SIDE = 0x60;
+	public static final int GDK_Return = 0xff0d;
+	public static final int GDK_Right = 0xff53;
+	public static final int GDK_space = 0x20;
+	public static final int GDK_SB_H_DOUBLE_ARROW = 0x6c;
+	public static final int GDK_SB_UP_ARROW = 0x72;
+	public static final int GDK_SB_V_DOUBLE_ARROW = 0x74;
+	public static final int GDK_SCROLL_UP = 0; 
+	public static final int GDK_SCROLL_DOWN = 1;
+	public static final int GDK_SCROLL_LEFT = 2;
+	public static final int GDK_SCROLL_RIGHT = 3;
+	public static final int GDK_SELECTION_CLEAR = 17;
+	public static final int GDK_SELECTION_NOTIFY = 19;
+	public static final int GDK_SELECTION_REQUEST = 18;
+	public static final int GDK_SHIFT_MASK = 0x1;
+	public static final int GDK_SIZING = 0x78;
+	public static final int GDK_STIPPLED = 0x2;
+	public static final int GDK_TILED = 0x1;
+	public static final int GDK_Shift_L = 0xffe1;
+	public static final int GDK_Shift_R = 0xffe2;
+	public static final int GDK_SCROLL = 31;
+	public static final int GDK_Scroll_Lock = 0xff14;
+	public static final int GDK_TOP_LEFT_CORNER = 0x86;
+	public static final int GDK_TOP_RIGHT_CORNER = 0x88;
+	public static final int GDK_TOP_SIDE = 0x8a;
+	public static final int GDK_Tab = 0xff09;
+	public static final int GDK_Up = 0xff52;
+	public static final int GDK_WATCH = 0x96;
+	public static final int GDK_XOR = 0x2;
+	public static final int GDK_XTERM = 0x98;
+	public static final int GDK_X_CURSOR = 0x0;
+	public static final int GDK_VISIBILITY_FULLY_OBSCURED = 2;
+	public static final int GDK_VISIBILITY_NOTIFY_MASK = 1 << 17;
+	public static final int GDK_WINDOW_CHILD = 2;
+	public static final int GDK_WINDOW_STATE_ICONIFIED  = 1 << 1;
+	public static final int GDK_WINDOW_STATE_MAXIMIZED  = 1 << 2;
+	public static final int GDK_WINDOW_STATE_FULLSCREEN  = 1 << 4;
+	public static final int GTK_ACCEL_VISIBLE = 0x1;
+	public static final int GTK_ARROW_DOWN = 0x1;
+	public static final int GTK_ARROW_LEFT = 0x2;
+	public static final int GTK_ARROW_RIGHT = 0x3;
+	public static final int GTK_ARROW_UP = 0x0;
+	public static final int GTK_CALENDAR_SHOW_HEADING = 1 << 0;
+	public static final int GTK_CALENDAR_SHOW_DAY_NAMES = 1 << 1;
+	public static final int GTK_CALENDAR_NO_MONTH_CHANGE = 1 << 2;
+	public static final int GTK_CALENDAR_SHOW_WEEK_NUMBERS = 1 << 3;
+	public static final int GTK_CALENDAR_WEEK_START_MONDAY = 1 << 4;
+	public static final int GTK_CAN_DEFAULT = 0x2000;
+	public static final int GTK_CAN_FOCUS = 0x800;
+	public static final int GTK_CELL_RENDERER_MODE_ACTIVATABLE = 1;
+	public static final int GTK_CELL_RENDERER_SELECTED = 1 << 0;
+	public static final int GTK_CELL_RENDERER_FOCUSED = 1 << 4;
+	public static final int GTK_CLIST_SHOW_TITLES = 0x4;
+	public static final int GTK_CORNER_TOP_LEFT = 0x0;
+	public static final int GTK_CORNER_TOP_RIGHT = 0x2;
+	public static final int GTK_DIALOG_DESTROY_WITH_PARENT = 1 << 1;
+	public static final int GTK_DIALOG_MODAL = 1 << 0;
+	public static final int GTK_DIR_TAB_FORWARD = 0;
+	public static final int GTK_DIR_TAB_BACKWARD = 1;
+	public static final int GTK_FILE_CHOOSER_ACTION_OPEN = 0;
+	public static final int GTK_FILE_CHOOSER_ACTION_SAVE = 1;
+	public static final int GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER = 2;
+	public static final int GTK_HAS_FOCUS = 1 << 12;
+	public static final int GTK_ICON_SIZE_MENU = 1;
+	public static final int GTK_ICON_SIZE_SMALL_TOOLBAR = 2;
+	public static final int GTK_ICON_SIZE_LARGE_TOOLBAR = 3;
+	public static final int GTK_ICON_SIZE_DIALOG = 6;
+	public static final int GTK_JUSTIFY_CENTER = 0x2;
+	public static final int GTK_JUSTIFY_LEFT = 0x0;
+	public static final int GTK_JUSTIFY_RIGHT = 0x1;
+	public static final int GTK_MAPPED = 1 << 7;
+	public static final int GTK_MESSAGE_INFO = 0;
+	public static final int GTK_MESSAGE_WARNING = 1;
+	public static final int GTK_MESSAGE_QUESTION = 2;
+	public static final int GTK_MESSAGE_ERROR = 3;
+	public static final int GTK_NO_WINDOW = 1 << 5;
+	public static final int GTK_ORIENTATION_HORIZONTAL = 0x0;
+	public static final int GTK_ORIENTATION_VERTICAL = 0x1;
+	public static final int GTK_PACK_END = 1;
+	public static final int GTK_PACK_START = 0;
+	public static final int GTK_POLICY_ALWAYS = 0x0;
+	public static final int GTK_POLICY_AUTOMATIC = 0x1;
+	public static final int GTK_POLICY_NEVER = 0x2;
+	public static final int GTK_POS_TOP = 0x2;
+	public static final int GTK_POS_BOTTOM = 0x3;
+	public static final int GTK_PRINT_CAPABILITY_PAGE_SET     = 1 << 0;
+	public static final int GTK_PRINT_CAPABILITY_COPIES       = 1 << 1;
+	public static final int GTK_PRINT_CAPABILITY_COLLATE      = 1 << 2;
+	public static final int GTK_PRINT_CAPABILITY_REVERSE      = 1 << 3;
+	public static final int GTK_PRINT_CAPABILITY_SCALE        = 1 << 4;
+	public static final int GTK_PRINT_CAPABILITY_GENERATE_PDF = 1 << 5;
+	public static final int GTK_PRINT_CAPABILITY_GENERATE_PS  = 1 << 6;
+	public static final int GTK_PRINT_CAPABILITY_PREVIEW      = 1 << 7;
+	public static final int GTK_PRINT_PAGES_ALL = 0;
+	public static final int GTK_PRINT_PAGES_CURRENT = 1;
+	public static final int GTK_PRINT_PAGES_RANGES = 2;
+	public static final int GTK_PROGRESS_CONTINUOUS = 0x0;
+	public static final int GTK_PROGRESS_DISCRETE = 0x1;
+	public static final int GTK_PROGRESS_LEFT_TO_RIGHT = 0x0;
+	public static final int GTK_PROGRESS_BOTTOM_TO_TOP = 0x2;
+	public static final int GTK_REALIZED  = 1 << 6;
+	public static final int GTK_RECEIVES_DEFAULT = 1 << 20;
+	public static final int GTK_RELIEF_NONE = 0x2;
+	public static final int GTK_RELIEF_NORMAL = 0;
+	public static final int GTK_RC_BG = 1 << 1;
+	public static final int GTK_RC_FG = 1 << 0;
+	public static final int GTK_RC_TEXT = 1 << 2;
+	public static final int GTK_RC_BASE = 1 << 3;
+	public static final int GTK_RESPONSE_APPLY = 0xfffffff6;
+	public static final int GTK_RESPONSE_CANCEL = 0xfffffffa;
+	public static final int GTK_RESPONSE_OK = 0xfffffffb;
+	public static final int GTK_SCROLL_NONE = 0;
+	public static final int GTK_SCROLL_JUMP = 1;
+	public static final int GTK_SCROLL_STEP_BACKWARD = 2;
+	public static final int GTK_SCROLL_STEP_FORWARD = 3;
+	public static final int GTK_SCROLL_PAGE_BACKWARD = 4;
+	public static final int GTK_SCROLL_PAGE_FORWARD = 5;
+	public static final int GTK_SCROLL_STEP_UP = 6;
+	public static final int GTK_SCROLL_STEP_DOWN = 7;
+	public static final int GTK_SCROLL_PAGE_UP = 8;
+	public static final int GTK_SCROLL_PAGE_DOWN = 9;
+	public static final int GTK_SCROLL_STEP_LEFT = 10;
+	public static final int GTK_SCROLL_STEP_RIGHT = 11;
+	public static final int GTK_SCROLL_PAGE_LEFT = 12;
+	public static final int GTK_SCROLL_PAGE_RIGHT = 13;
+	public static final int GTK_SCROLL_START = 14;
+	public static final int GTK_SCROLL_END = 15;
+	public static final int GTK_SELECTION_BROWSE = 0x2;
+	public static final int GTK_SELECTION_MULTIPLE = 0x3;
+	public static final int GTK_SENSITIVE = 0x200;
+	public static final int GTK_SHADOW_ETCHED_IN = 0x3;
+	public static final int GTK_SHADOW_ETCHED_OUT = 0x4;
+	public static final int GTK_SHADOW_IN = 0x1;
+	public static final int GTK_SHADOW_NONE = 0x0;
+	public static final int GTK_SHADOW_OUT = 0x2;
+	public static final int GTK_STATE_ACTIVE = 0x1;
+	public static final int GTK_STATE_INSENSITIVE = 0x4;
+	public static final int GTK_STATE_NORMAL = 0x0;
+	public static final int GTK_STATE_PRELIGHT = 0x2;
+	public static final int GTK_STATE_SELECTED = 0x3;
+	public static final int GTK_TEXT_DIR_LTR = 1;
+	public static final int GTK_TEXT_DIR_NONE = 0 ;
+	public static final int GTK_TEXT_DIR_RTL = 2;
+	public static final int GTK_TEXT_WINDOW_TEXT = 2;
+	public static final int GTK_TOOLBAR_CHILD_BUTTON = 0x1;
+	public static final int GTK_TOOLBAR_CHILD_RADIOBUTTON = 0x3;
+	public static final int GTK_TOOLBAR_CHILD_TOGGLEBUTTON = 0x2;
+	public static final int GTK_TREE_VIEW_COLUMN_GROW_ONLY = 0;
+	public static final int GTK_TREE_VIEW_COLUMN_AUTOSIZE = 1;
+	public static final int GTK_TREE_VIEW_COLUMN_FIXED = 2;
+	public static final int GTK_TREE_VIEW_DROP_BEFORE = 0;
+	public static final int GTK_TREE_VIEW_DROP_AFTER = 1;
+	public static final int GTK_TREE_VIEW_DROP_INTO_OR_BEFORE = 2;
+	public static final int GTK_TREE_VIEW_DROP_INTO_OR_AFTER = 3;
+	public static final int GDK_UNMAP = 15;
+	public static final int GTK_UNIT_PIXEL = 0;
+	public static final int GTK_UNIT_POINTS = 1;
+	public static final int GTK_UNIT_INCH = 2;
+	public static final int GTK_UNIT_MM = 3;
+	public static final int GTK_VISIBILITY_FULL = 0x2;
+	public static final int GTK_VISIBILITY_NONE = 0x0;
+	public static final int GTK_VISIBLE = 0x100;
+	public static final int GDK_WA_X = 1 << 2;
+	public static final int GDK_WA_Y = 1 << 3;
+	public static final int GDK_WA_VISUAL = 1 << 6;
+	public static final int GTK_WINDOW_POPUP = 0x1;
+	public static final int GTK_WINDOW_TOPLEVEL = 0x0;
+	public static final int GDK_WINDOW_TYPE_HINT_DIALOG = 1;
+	public static final int GTK_WRAP_NONE = 0;
+	public static final int GTK_WRAP_WORD = 2;
+	public static final int GTK_WRAP_WORD_CHAR = 3;
+	public static final int G_LOG_FLAG_FATAL = 0x2;
+	public static final int G_LOG_FLAG_RECURSION = 0x1;
+	public static final int G_LOG_LEVEL_MASK = 0xfffffffc;
+	public static final int None = 0;
+	public static final int PANGO_ALIGN_LEFT = 0;
+	public static final int PANGO_ALIGN_CENTER = 1;
+	public static final int PANGO_ALIGN_RIGHT = 2;
+	public static final int PANGO_ATTR_FOREGROUND = 9;
+	public static final int PANGO_ATTR_BACKGROUND = 10;
+	public static final int PANGO_ATTR_UNDERLINE = 11;
+	public static final int PANGO_ATTR_UNDERLINE_COLOR = 18;
+	public static final int PANGO_DIRECTION_LTR = 0;
+	public static final int PANGO_DIRECTION_RTL = 1;	
+	public static final int PANGO_SCALE = 1024;
+	public static final int PANGO_STRETCH_NORMAL = 0x4;
+	public static final int PANGO_STYLE_ITALIC = 0x2;
+	public static final int PANGO_STYLE_NORMAL = 0x0;
+	public static final int PANGO_STYLE_OBLIQUE = 0x1;
+	public static final int PANGO_TAB_LEFT = 0;
+	public static final int PANGO_UNDERLINE_NONE = 0;
+	public static final int PANGO_UNDERLINE_SINGLE = 1;
+	public static final int PANGO_UNDERLINE_DOUBLE = 2;
+	public static final int PANGO_UNDERLINE_LOW = 3;
+	public static final int PANGO_UNDERLINE_ERROR = 4;
+	public static final int PANGO_WEIGHT_BOLD = 0x2bc;
+	public static final int PANGO_WEIGHT_NORMAL = 0x190;
+	public static final int PANGO_WRAP_WORD = 0;
+	public static final int PANGO_WRAP_WORD_CHAR = 2;
+	public static final int RTLD_LAZY = 1;
+	public static final int XA_CARDINAL = 6;
+	public static final int XA_WINDOW = 33;
+	
+	/** Signals */
+	public static final byte[] activate = ascii("activate");
+	public static final byte[] button_press_event = ascii("button-press-event");
+	public static final byte[] button_release_event = ascii("button-release-event");
+	public static final byte[] changed = ascii("changed");
+	public static final byte[] change_current_page = ascii("change-current-page");
+	public static final byte[] change_value = ascii("change-value");
+	public static final byte[] clicked = ascii("clicked");
+	public static final byte[] commit = ascii("commit");
+	public static final byte[] configure_event = ascii("configure-event");
+	public static final byte[] delete_event = ascii("delete-event");
+	public static final byte[] day_selected = ascii("day-selected");
+	public static final byte[] delete_range = ascii("delete-range");
+	public static final byte[] delete_text = ascii("delete-text");
+	public static final byte[] drag_data_delete = ascii("drag_data_delete");
+	public static final byte[] drag_data_get = ascii("drag_data_get");
+	public static final byte[] drag_data_received = ascii("drag_data_received");
+	public static final byte[] drag_drop = ascii("drag_drop");
+	public static final byte[] drag_end = ascii("drag_end");
+	public static final byte[] drag_leave = ascii("drag_leave");
+	public static final byte[] drag_motion = ascii("drag_motion");
+	public static final byte[] enter_notify_event = ascii("enter-notify-event");
+	public static final byte[] event = ascii("event");
+	public static final byte[] event_after = ascii("event-after");
+	public static final byte[] expand_collapse_cursor_row = ascii("expand-collapse-cursor-row");
+	public static final byte[] expose_event = ascii("expose-event");
+	public static final byte[] focus = ascii("focus");
+	public static final byte[] focus_in_event = ascii("focus-in-event");
+	public static final byte[] focus_out_event = ascii("focus-out-event");
+	public static final byte[] grab_focus = ascii("grab-focus");
+	public static final byte[] hide = ascii("hide");
+	public static final byte[] input = ascii("input");
+	public static final byte[] insert_text = ascii("insert-text");
+	public static final byte[] key_press_event = ascii("key-press-event");
+	public static final byte[] key_release_event = ascii("key-release-event");
+	public static final byte[] leave_notify_event = ascii("leave-notify-event");
+	public static final byte[] map = ascii("map");
+	public static final byte[] map_event = ascii("map-event");
+	public static final byte[] mnemonic_activate = ascii("mnemonic-activate");
+	public static final byte[] month_changed = ascii("month-changed");
+	public static final byte[] motion_notify_event = ascii("motion-notify-event");
+	public static final byte[] move_focus = ascii("move-focus");
+	public static final byte[] output = ascii("output");
+	public static final byte[] popup_menu = ascii("popup-menu");
+	public static final byte[] populate_popup = ascii("populate-popup");
+	public static final byte[] preedit_changed = ascii("preedit-changed");
+	public static final byte[] realize = ascii("realize");
+	public static final byte[] row_activated = ascii("row-activated");
+	public static final byte[] row_changed = ascii("row-changed");
+	public static final byte[] scroll_child = ascii("scroll-child");
+	public static final byte[] scroll_event = ascii("scroll-event");
+	public static final byte[] select = ascii("select");
+	public static final byte[] show = ascii("show");
+	public static final byte[] show_help = ascii("show-help");
+	public static final byte[] size_allocate = ascii("size-allocate");
+	public static final byte[] size_request = ascii("size-request");
+	public static final byte[] style_set = ascii("style-set");
+	public static final byte[] switch_page = ascii("switch-page");
+	public static final byte[] test_collapse_row = ascii("test-collapse-row");
+	public static final byte[] test_expand_row = ascii("test-expand-row");
+	public static final byte[] toggled = ascii("toggled");
+	public static final byte[] unmap = ascii("unmap");
+	public static final byte[] unmap_event = ascii("unmap-event");
+	public static final byte[] unrealize = ascii("unrealize");
+	public static final byte[] value_changed = ascii("value-changed");
+	public static final byte[] visibility_notify_event = ascii("visibility-notify-event");
+	public static final byte[] window_state_event = ascii("window-state-event");
+	
+	/** Properties */
+	public static final byte[] active = ascii("active");
+	public static final byte[] background_gdk = ascii("background-gdk");
+	public static final byte[] button_relief = ascii("button-relief");
+	public static final byte[] cell_background_gdk = ascii("cell-background-gdk");
+	public static final byte[] default_border = ascii("default-border");
+	public static final byte[] expander_size = ascii("expander-size");
+	public static final byte[] fixed_height_mode = ascii("fixed-height-mode");
+	public static final byte[] focus_line_width = ascii("focus-line-width");
+	public static final byte[] font_desc = ascii("font-desc");
+	public static final byte[] foreground_gdk = ascii("foreground-gdk");
+	public static final byte[] gtk_cursor_blink = ascii("gtk-cursor-blink");
+	public static final byte[] gtk_cursor_blink_time = ascii("gtk-cursor-blink-time");
+	public static final byte[] gtk_double_click_time = ascii("gtk-double-click-time");
+	public static final byte[] gtk_entry_select_on_focus = ascii("gtk-entry-select-on-focus");
+	public static final byte[] horizontal_separator = ascii("horizontal-separator");
+	public static final byte[] inconsistent = ascii("inconsistent");
+	public static final byte[] interior_focus = ascii("interior-focus");
+	public static final byte[] mode = ascii("mode");
+	public static final byte[] pixbuf = ascii("pixbuf");
+	public static final byte[] text = ascii("text");
+	public static final byte[] xalign = ascii("xalign");
+	public static final byte[] ypad = ascii("ypad");
+	public static final byte[] GTK_PRINT_SETTINGS_OUTPUT_URI = ascii("output-uri");
+	
+	public static final int GTK_VERSION = VERSION(gtk_major_version(), gtk_minor_version(), gtk_micro_version()); 
+	
+protected static byte [] ascii (String name) {
+	int length = name.length ();
+	char [] chars = new char [length];
+	name.getChars (0, length, chars, 0);
+	byte [] buffer = new byte [length + 1];
+	for (int i=0; i<length; i++) {
+		buffer [i] = (byte) chars [i];
+	}
+	return buffer;
+}
+
+public static int VERSION(int major, int minor, int micro) {
+	return (major << 16) + (minor << 8) + micro;
+}
+
+/** 64 bit */
+public static final native int GInterfaceInfo_sizeof ();
+public static final native int GPollFD_sizeof ();
+public static final native int GTypeInfo_sizeof ();
+public static final native int GTypeQuery_sizeof ();
+public static final native int GdkColor_sizeof();
+public static final native int GdkDragContext_sizeof();
+public static final native int GdkEvent_sizeof();
+public static final native int GdkEventAny_sizeof();
+public static final native int GdkEventButton_sizeof();
+public static final native int GdkEventCrossing_sizeof();
+public static final native int GdkEventExpose_sizeof();
+public static final native int GdkEventFocus_sizeof();
+public static final native int GdkEventKey_sizeof();
+public static final native int GdkEventMotion_sizeof();
+public static final native int GdkEventScroll_sizeof();
+public static final native int GdkEventVisibility_sizeof();
+public static final native int GdkEventWindowState_sizeof();
+public static final native int GdkGCValues_sizeof();
+public static final native int GdkGeometry_sizeof();
+public static final native int GdkImage_sizeof();
+public static final native int GdkRectangle_sizeof();
+public static final native int GdkVisual_sizeof();
+public static final native int GdkWindowAttr_sizeof();
+public static final native int GtkAdjustment_sizeof();
+public static final native int GtkAllocation_sizeof();
+public static final native int GtkBorder_sizeof();
+public static final native int GtkColorSelectionDialog_sizeof();
+public static final native int GtkCombo_sizeof();
+public static final native int GtkFileSelection_sizeof();
+public static final native int GtkFixed_sizeof();
+public static final native int GtkFixedClass_sizeof();
+public static final native int GtkRequisition_sizeof();
+public static final native int GtkSelectionData_sizeof();
+public static final native int GtkTargetEntry_sizeof();
+public static final native int GtkTargetPair_sizeof();
+public static final native int GtkTextIter_sizeof();
+public static final native int GtkCellRendererText_sizeof();
+public static final native int GtkCellRendererTextClass_sizeof();
+public static final native int GtkCellRendererPixbuf_sizeof();
+public static final native int GtkCellRendererPixbufClass_sizeof();
+public static final native int GtkCellRendererToggle_sizeof();
+public static final native int GtkCellRendererToggleClass_sizeof();
+public static final native int GtkTreeIter_sizeof();
+public static final native int PangoAttribute_sizeof();
+public static final native int PangoAttrColor_sizeof();
+public static final native int PangoAttrInt_sizeof();
+public static final native int PangoItem_sizeof();
+public static final native int PangoLayoutLine_sizeof();
+public static final native int PangoLayoutRun_sizeof();
+public static final native int PangoLogAttr_sizeof();
+public static final native int PangoRectangle_sizeof();
+public static final native int XAnyEvent_sizeof();
+public static final native int XButtonEvent_sizeof();
+public static final native int XClientMessageEvent_sizeof();
+public static final native int XEvent_sizeof();
+public static final native int XCrossingEvent_sizeof();
+public static final native int XExposeEvent_sizeof();
+public static final native int XFocusChangeEvent_sizeof();
+public static final native int XVisibilityEvent_sizeof();
+public static final native int XWindowChanges_sizeof();
+public static final native int /*long*/ localeconv_decimal_point();
+public static final native int /*long*/ realpath(byte[] path, byte[] realPath);
+
+/** Object private fields accessors */
+public static final native int GTK_WIDGET_HEIGHT(int /*long*/ widget);
+public static final native int GTK_WIDGET_WIDTH(int /*long*/ widget);
+public static final native int /*long*/ GTK_WIDGET_WINDOW(int /*long*/ widget);
+public static final native int GTK_WIDGET_X(int /*long*/ widget);
+public static final native int GTK_WIDGET_Y(int /*long*/ widget);
+public static final native int /*long*/ GTK_SCROLLED_WINDOW_HSCROLLBAR(int /*long*/ widget);
+public static final native int /*long*/ GTK_SCROLLED_WINDOW_VSCROLLBAR(int /*long*/ widget);
+public static final native int GTK_SCROLLED_WINDOW_SCROLLBAR_SPACING(int /*long*/ widget);
+public static final native void GTK_ACCEL_LABEL_SET_ACCEL_STRING(int /*long*/ acce_label, int /*long*/ string);
+public static final native int /*long*/ GTK_ACCEL_LABEL_GET_ACCEL_STRING(int /*long*/ acce_label);
+public static final native int /*long*/ GTK_ENTRY_IM_CONTEXT(int /*long*/ widget);
+public static final native int /*long*/ GTK_TEXTVIEW_IM_CONTEXT(int /*long*/ widget);
+public static final native int /*long*/ GTK_TOOLTIPS_TIP_WINDOW(int /*long*/ widget);
+public static final native void GTK_TOOLTIPS_SET_ACTIVE(int /*long*/ widget, int /*long*/ data);
+public static final native void GTK_WIDGET_SET_HEIGHT(int /*long*/ widget, int height);
+public static final native void GTK_WIDGET_SET_WIDTH(int /*long*/ widget, int width);
+public static final native void GTK_WIDGET_SET_X(int /*long*/ widget, int x);
+public static final native void GTK_WIDGET_SET_Y(int /*long*/ widget, int y);
+public static final native int GTK_WIDGET_REQUISITION_WIDTH(int /*long*/ widget);
+public static final native int GTK_WIDGET_REQUISITION_HEIGHT(int /*long*/ widget);
+public static final native int GDK_EVENT_TYPE(int /*long*/ event);
+public static final native int /*long*/ GDK_EVENT_WINDOW(int /*long*/ event);
+public static final native int X_EVENT_TYPE(int /*long*/ xevent);
+public static final native int /*long*/ X_EVENT_WINDOW(int /*long*/ xevent);
+
+/** X11 Native methods and constants */
+public static final int Above = 0;
+public static final int Below = 1;
+public static final int ButtonRelease = 5;
+public static final int ClientMessage = 33;
+public static final int CurrentTime = 0;
+public static final int CWSibling = 0x20;
+public static final int CWStackMode = 0x40;
+public static final int EnterNotify = 7;
+public static final int Expose = 12;
+public static final int FocusChangeMask = 1 << 21;
+public static final int FocusIn = 9;
+public static final int FocusOut = 10;
+public static final int GraphicsExpose = 13;
+public static final int NoExpose = 14;
+public static final int ExposureMask = 1 << 15;
+public static final int /*long*/ NoEventMask = 0;
+public static final int NotifyNormal = 0;
+public static final int NotifyGrab = 1;
+public static final int NotifyHint = 1;
+public static final int NotifyUngrab = 2;
+public static final int NotifyWhileGrabbed = 3;
+public static final int NotifyAncestor = 0;
+public static final int NotifyVirtual = 1;
+public static final int NotifyNonlinear = 3;
+public static final int NotifyNonlinearVirtual = 4;
+public static final int NotifyPointer = 5;
+public static final int RevertToParent = 2;
+public static final int VisibilityChangeMask = 1 << 16;
+public static final int VisibilityFullyObscured = 2;
+public static final int VisibilityNotify = 15;
+public static final int SYSTEM_TRAY_REQUEST_DOCK = 0;
+public static final native int _Call(int /*long*/ proc, int /*long*/ arg1, int /*long*/ arg2);
+public static final int Call(int /*long*/ proc, int /*long*/ arg1, int /*long*/ arg2) {
+	lock.lock();
+	try {
+		return _Call(proc, arg1, arg2);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _call (int /*long*/ function, int /*long*/ arg0, int /*long*/ arg1, int /*long*/ arg2, int /*long*/ arg3, int /*long*/ arg4, int /*long*/ arg5, int /*long*/ arg6);
+public static final int /*long*/ call (int /*long*/ function, int /*long*/ arg0, int /*long*/ arg1, int /*long*/ arg2, int /*long*/ arg3, int /*long*/ arg4, int /*long*/ arg5, int /*long*/ arg6) {
+	lock.lock();
+	try {
+		return _call(function, arg0, arg1, arg2, arg3, arg4, arg5, arg6);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean GDK_WINDOWING_X11();
+public static final native int /*long*/ _GDK_PIXMAP_XID(int /*long*/ pixmap);
+public static final int /*long*/ GDK_PIXMAP_XID(int /*long*/ pixmap) {
+	lock.lock();
+	try {
+		return _GDK_PIXMAP_XID(pixmap);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _XCheckMaskEvent(int /*long*/ display, int /*long*/ event_mask, int /*long*/ event_return);
+public static final boolean XCheckMaskEvent(int /*long*/ display, int /*long*/ event_mask, int /*long*/ event_return) {
+	lock.lock();
+	try {
+		return _XCheckMaskEvent(display, event_mask, event_return);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _XCheckWindowEvent(int /*long*/ display, int /*long*/ window, int /*long*/ event_mask, int /*long*/ event_return);
+public static final boolean XCheckWindowEvent(int /*long*/ display, int /*long*/ window, int /*long*/ event_mask, int /*long*/ event_return) {
+	lock.lock();
+	try {
+		return _XCheckWindowEvent(display, window, event_mask, event_return);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _XCheckIfEvent(int /*long*/ display, int /*long*/ event_return, int /*long*/ predicate, int /*long*/ arg);
+public static final boolean XCheckIfEvent(int /*long*/ display, int /*long*/ event_return, int /*long*/ predicate, int /*long*/ arg) {
+	lock.lock();
+	try {
+		return _XCheckIfEvent(display, event_return, predicate, arg);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _XDefaultScreen(int /*long*/ display);
+public static final int XDefaultScreen(int /*long*/ display) {
+	lock.lock();
+	try {
+		return _XDefaultScreen(display);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _XDefaultRootWindow(int /*long*/ display);
+public static final int /*long*/ XDefaultRootWindow(int /*long*/ display) {
+	lock.lock();
+	try {
+		return _XDefaultRootWindow(display);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _XFlush(int /*long*/ display);
+public static final void XFlush(int /*long*/ display) {
+	lock.lock();
+	try {
+		_XFlush(display);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _XFree(int /*long*/ address);
+public static final void XFree(int /*long*/ address) {
+	lock.lock();
+	try {
+		_XFree(address);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _XGetSelectionOwner(int /*long*/ display, int /*long*/ selection);
+public static final int /*long*/ XGetSelectionOwner(int /*long*/ display, int /*long*/ selection) {
+	lock.lock();
+	try {
+		return _XGetSelectionOwner(display, selection);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _XInternAtom(int /*long*/ display, byte[] name, boolean ifExists);
+public static final int /*long*/ XInternAtom(int /*long*/ display, byte[] name, boolean ifExists) {
+	lock.lock();
+	try {
+		return _XInternAtom(display, name, ifExists);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _XQueryPointer(int /*long*/ display, int /*long*/ w, int /*long*/[] root_return, int /*long*/[] child_return, int[] root_x_return, int[] root_y_return, int[] win_x_return, int[] win_y_return, int[] mask_return);
+public static final int XQueryPointer(int /*long*/ display, int /*long*/ w, int /*long*/[] root_return, int /*long*/[] child_return, int[] root_x_return, int[] root_y_return, int[] win_x_return, int[] win_y_return, int[] mask_return) {
+	lock.lock();
+	try {
+		return _XQueryPointer(display, w, root_return, child_return, root_x_return, root_y_return, win_x_return, win_y_return, mask_return);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _XQueryTree(int /*long*/ display, int /*long*/ w, int /*long*/[] root_return, int /*long*/[] parent_return, int /*long*/[] children_return, int[] nchildren_return);
+public static final int XQueryTree(int /*long*/ display, int /*long*/ w, int /*long*/[] root_return, int /*long*/[] parent_return, int /*long*/[] children_return, int[] nchildren_return) {
+	lock.lock();
+	try {
+		return _XQueryTree(display, w, root_return, parent_return, children_return, nchildren_return);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _XKeysymToKeycode(int /*long*/ display, int /*long*/ keysym);
+public static final int XKeysymToKeycode(int /*long*/ display, int /*long*/ keysym) {
+	lock.lock();
+	try {
+		return _XKeysymToKeycode(display, keysym);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _XListProperties(int /*long*/ display, int /*long*/ window, int[] num_prop_return);
+public static final int /*long*/ XListProperties(int /*long*/ display, int /*long*/ window, int[] num_prop_return) {
+	lock.lock();
+	try {
+		return _XListProperties(display, window, num_prop_return);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _XReconfigureWMWindow(int /*long*/ display, int /*long*/ window, int screen, int valueMask, XWindowChanges values);
+public static final int XReconfigureWMWindow(int /*long*/ display, int /*long*/ window, int screen, int valueMask, XWindowChanges values) {
+	lock.lock();
+	try {
+		return _XReconfigureWMWindow(display, window, screen, valueMask, values);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _XSendEvent(int /*long*/ display, int /*long*/ w, boolean propogate, int /*long*/ event_mask, int /*long*/ event_send);
+public static final int XSendEvent(int /*long*/ display, int /*long*/ w, boolean propogate, int /*long*/ event_mask, int /*long*/ event_send) {
+	lock.lock();
+	try {
+		return _XSendEvent(display, w, propogate, event_mask, event_send);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _XSetIOErrorHandler(int /*long*/ handler);
+public static final int /*long*/ XSetIOErrorHandler(int /*long*/ handler) {
+	lock.lock();
+	try {
+		return _XSetIOErrorHandler(handler);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _XSetErrorHandler(int /*long*/ handler);
+public static final int /*long*/ XSetErrorHandler(int /*long*/ handler) {
+	lock.lock();
+	try {
+		return _XSetErrorHandler(handler);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _XSetInputFocus(int /*long*/ display, int /*long*/ window, int revert, int time);
+public static final int XSetInputFocus(int /*long*/ display, int /*long*/ window, int revert, int time) {
+	lock.lock();
+	try {
+		return _XSetInputFocus(display, window, revert, time);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _XSetTransientForHint(int /*long*/ display, int /*long*/ w, int /*long*/ prop_window);
+public static final int XSetTransientForHint(int /*long*/ display, int /*long*/ w, int /*long*/ prop_window) {
+	lock.lock();
+	try {
+		return _XSetTransientForHint(display, w, prop_window);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _XSynchronize(int /*long*/ display, boolean onoff);
+public static final int /*long*/ XSynchronize(int /*long*/ display, boolean onoff) {
+	lock.lock();
+	try {
+		return _XSynchronize(display, onoff);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _XTestFakeButtonEvent(int /*long*/ display, int button, boolean is_press, int /*long*/ delay);
+public static final void XTestFakeButtonEvent(int /*long*/ display, int button, boolean is_press, int /*long*/ delay) {
+	lock.lock();
+	try {
+		_XTestFakeButtonEvent(display, button, is_press, delay);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _XTestFakeKeyEvent(int /*long*/ display, int keycode, boolean is_press, int /*long*/ delay);
+public static final void XTestFakeKeyEvent(int /*long*/ display, int keycode, boolean is_press, int /*long*/ delay) {
+	lock.lock();
+	try {
+		_XTestFakeKeyEvent(display, keycode, is_press, delay);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _XTestFakeMotionEvent(int /*long*/ display, int screen_number, int x, int y, int /*long*/ delay);
+public static final void XTestFakeMotionEvent(int /*long*/ display, int screen_number, int x, int y, int /*long*/ delay) {
+	lock.lock();
+	try {
+		_XTestFakeMotionEvent(display, screen_number, x, y, delay);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _XWarpPointer(int /*long*/ display, int /*long*/ sourceWindow, int /*long*/ destWindow, int sourceX, int sourceY, int sourceWidth, int sourceHeight, int destX, int destY);
+public static final int XWarpPointer(int /*long*/ display, int /*long*/ sourceWindow, int /*long*/ destWindow, int sourceX, int sourceY, int sourceWidth, int sourceHeight, int destX, int destY) {
+	lock.lock();
+	try {
+		return _XWarpPointer(display, sourceWindow, destWindow, sourceX, sourceY, sourceWidth, sourceHeight, destX, destY);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gdk_x11_atom_to_xatom(int /*long*/ atom);
+public static final int /*long*/ gdk_x11_atom_to_xatom(int /*long*/ atom) {
+	lock.lock();
+	try {
+		return _gdk_x11_atom_to_xatom(atom);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gdk_x11_colormap_get_xcolormap(int /*long*/ colormap);
+public static final int /*long*/ gdk_x11_colormap_get_xcolormap(int /*long*/ colormap) {
+	lock.lock();
+	try {
+		return _gdk_x11_colormap_get_xcolormap(colormap);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gdk_x11_drawable_get_xdisplay(int /*long*/ drawable);
+public static final int /*long*/ gdk_x11_drawable_get_xdisplay(int /*long*/ drawable) {
+	lock.lock();
+	try {
+		return _gdk_x11_drawable_get_xdisplay(drawable);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gdk_x11_drawable_get_xid(int /*long*/ drawable);
+public static final int /*long*/ gdk_x11_drawable_get_xid(int /*long*/ drawable) {
+	lock.lock();
+	try {
+		return _gdk_x11_drawable_get_xid(drawable);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gdk_x11_screen_lookup_visual(int /*long*/ screen, int xvisualid);
+public static final int /*long*/ gdk_x11_screen_lookup_visual(int /*long*/ screen, int xvisualid) {
+	lock.lock();
+	try {
+		return _gdk_x11_screen_lookup_visual(screen, xvisualid);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gdk_x11_screen_get_window_manager_name(int /*long*/ screen);
+public static final int /*long*/ gdk_x11_screen_get_window_manager_name(int /*long*/ screen) {	
+	lock.lock();
+	try {
+		return _gdk_x11_screen_get_window_manager_name(screen);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gdk_x11_visual_get_xvisual(int /*long*/ visual);
+public static final int /*long*/ gdk_x11_visual_get_xvisual(int /*long*/ visual) {
+	lock.lock();
+	try {
+		return _gdk_x11_visual_get_xvisual(visual);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gdk_pixmap_foreign_new(int /*long*/ anid);
+public static final int /*long*/ gdk_pixmap_foreign_new(int /*long*/ anid) {
+	lock.lock();
+	try {
+		return _gdk_pixmap_foreign_new(anid);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gdk_window_lookup(int /*long*/ xid);
+public static final int /*long*/ gdk_window_lookup(int /*long*/ xid) {
+	lock.lock();
+	try {
+		return _gdk_window_lookup(xid);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_window_add_filter(int /*long*/ window, int /*long*/ function, int /*long*/ data);
+public static final void gdk_window_add_filter(int /*long*/ window, int /*long*/ function, int /*long*/ data) {
+	lock.lock();
+	try {
+		_gdk_window_add_filter(window, function, data);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_window_remove_filter(int /*long*/ window, int /*long*/ function, int /*long*/ data);
+public static final void gdk_window_remove_filter(int /*long*/ window, int /*long*/ function, int /*long*/ data) {
+	lock.lock();
+	try {
+		_gdk_window_remove_filter(window, function, data);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void memmove(int /*long*/ dest, XButtonEvent src, int /*long*/ size);
+public static final native void memmove(int /*long*/ dest, XClientMessageEvent src, int /*long*/ size);
+public static final native void memmove(int /*long*/ dest, XCrossingEvent src, int /*long*/ size);
+public static final native void memmove(int /*long*/ dest, XExposeEvent src, int /*long*/ size);
+public static final native void memmove(int /*long*/ dest, XFocusChangeEvent src, int /*long*/ size);
+public static final native void memmove(XButtonEvent dest, int /*long*/ src, int /*long*/ size);
+public static final native void memmove(XCrossingEvent dest, int /*long*/ src, int /*long*/ size);
+public static final native void memmove(XExposeEvent dest, int /*long*/ src, int /*long*/ size);
+public static final native void memmove(XFocusChangeEvent dest, int /*long*/ src, int /*long*/ size);
+public static final native void memmove(XVisibilityEvent dest, int /*long*/ src, int /*long*/ size);
+
+/** X render natives and constants */
+public static final int PictStandardARGB32 = 0;
+public static final int PictStandardRGB24 = 1;
+public static final int PictStandardA8 = 2;
+public static final int PictStandardA4 = 3;
+public static final int PictStandardA1 = 4;
+public static final int PictOpSrc = 1;
+public static final int PictOpOver = 3;
+
+public static final native int XRenderPictureAttributes_sizeof();
+public static final native boolean _XRenderQueryExtension(int /*long*/ display, int[] event_basep, int[] error_basep);
+public static final boolean XRenderQueryExtension(int /*long*/ display, int[] event_basep, int[] error_basep) {
+	lock.lock();
+	try {
+		return _XRenderQueryExtension(display, event_basep, error_basep);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _XRenderQueryVersion(int /*long*/ display, int[] major_versionp, int[] minor_versionp);
+public static final int XRenderQueryVersion(int /*long*/ display, int[] major_versionp, int[] minor_versionp) {
+	lock.lock();
+	try {
+		return _XRenderQueryVersion(display, major_versionp, minor_versionp);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _XRenderCreatePicture(int /*long*/ display, int /*long*/ drawable, int /*long*/ format, int /*long*/ valuemask, XRenderPictureAttributes attributes);
+public static final int /*long*/ XRenderCreatePicture(int /*long*/ display, int /*long*/ drawable, int /*long*/ format, int /*long*/ valuemask, XRenderPictureAttributes attributes) {
+	lock.lock();
+	try {
+		return _XRenderCreatePicture(display, drawable, format, valuemask, attributes);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _XRenderSetPictureClipRectangles(int /*long*/ display, int /*long*/ picture, int xOrigin, int yOrigin, short[] rects, int count);
+public static final void XRenderSetPictureClipRectangles(int /*long*/ display, int /*long*/ picture, int xOrigin, int yOrigin, short[] rects, int count) {
+	lock.lock();
+	try {
+		_XRenderSetPictureClipRectangles(display, picture, xOrigin, yOrigin, rects, count);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _XRenderSetPictureTransform(int /*long*/ display, int /*long*/ picture, int[] transform);
+public static final void XRenderSetPictureTransform(int /*long*/ display, int /*long*/ picture, int[] transform) {
+	lock.lock();
+	try {
+		_XRenderSetPictureTransform(display, picture, transform);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _XRenderFreePicture(int /*long*/ display, int /*long*/ picture);
+public static final void XRenderFreePicture(int /*long*/ display, int /*long*/ picture) {
+	lock.lock();
+	try {
+		_XRenderFreePicture(display, picture);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _XRenderComposite(int /*long*/ display, int op, int /*long*/ src, int /*long*/ mask, int /*long*/ dst, int src_x, int src_y, int mask_x, int mask_y, int dst_x, int dst_y, int width, int height);
+public static final void XRenderComposite(int /*long*/ display, int op, int /*long*/ src, int /*long*/ mask, int /*long*/ dst, int src_x, int src_y, int mask_x, int mask_y, int dst_x, int dst_y, int width, int height) {
+	lock.lock();
+	try {
+		_XRenderComposite(display, op, src, mask, dst, src_x, src_y, mask_x, mask_y, dst_x, dst_y, width, height);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _XRenderFindStandardFormat(int /*long*/ display, int format);
+public static final int /*long*/ XRenderFindStandardFormat(int /*long*/ display, int format) {
+	lock.lock();
+	try {
+		return _XRenderFindStandardFormat(display, format);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _XRenderFindVisualFormat(int /*long*/ display, int /*long*/ visual);
+public static final int /*long*/ XRenderFindVisualFormat(int /*long*/ display, int /*long*/ visual) {
+	lock.lock();
+	try {
+		return _XRenderFindVisualFormat(display, visual);
+	} finally {
+		lock.unlock();
+	}
+}
+
+/** Natives */
+public static final native int Call (int /*long*/ func, int /*long*/ arg0, int arg1, int arg2);
+public static final native int /*long*/ _GDK_DISPLAY();
+public static final int /*long*/ GDK_DISPLAY() {
+	lock.lock();
+	try {
+		return _GDK_DISPLAY();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _GDK_ROOT_PARENT();
+public static final int /*long*/ GDK_ROOT_PARENT() {
+	lock.lock();
+	try {
+		return _GDK_ROOT_PARENT();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _GDK_TYPE_COLOR();
+public static final int /*long*/ GDK_TYPE_COLOR() {
+	lock.lock();
+	try {
+		return _GDK_TYPE_COLOR();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _GDK_TYPE_PIXBUF();
+public static final int /*long*/ GDK_TYPE_PIXBUF() {
+	lock.lock();
+	try {
+		return _GDK_TYPE_PIXBUF();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _GTK_IS_BUTTON(int /*long*/ obj);
+public static final boolean GTK_IS_BUTTON(int /*long*/ obj) {
+	lock.lock();
+	try {
+		return _GTK_IS_BUTTON(obj);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _GTK_IS_WINDOW(int /*long*/ obj);
+public static final boolean GTK_IS_WINDOW(int /*long*/ obj) {
+	lock.lock();
+	try {
+		return _GTK_IS_WINDOW(obj);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _GTK_IS_CELL_RENDERER_PIXBUF(int /*long*/ obj);
+public static final boolean GTK_IS_CELL_RENDERER_PIXBUF(int /*long*/ obj) {
+	lock.lock();
+	try {
+		return _GTK_IS_CELL_RENDERER_PIXBUF(obj);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _GTK_IS_CELL_RENDERER_TEXT(int /*long*/ obj);
+public static final boolean GTK_IS_CELL_RENDERER_TEXT(int /*long*/ obj) {
+	lock.lock();
+	try {
+		return _GTK_IS_CELL_RENDERER_TEXT(obj);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _GTK_IS_CELL_RENDERER_TOGGLE(int /*long*/ obj);
+public static final boolean GTK_IS_CELL_RENDERER_TOGGLE(int /*long*/ obj) {
+	lock.lock();
+	try {
+		return _GTK_IS_CELL_RENDERER_TOGGLE(obj);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _GTK_IS_CONTAINER(int /*long*/ obj);
+public static final boolean GTK_IS_CONTAINER(int /*long*/ obj) {
+	lock.lock();
+	try {
+		return _GTK_IS_CONTAINER(obj);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _GTK_IS_IMAGE_MENU_ITEM(int /*long*/ obj);
+public static final boolean GTK_IS_IMAGE_MENU_ITEM(int /*long*/ obj) {
+	lock.lock();
+	try {
+		return _GTK_IS_IMAGE_MENU_ITEM(obj);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _GTK_IS_MENU_ITEM(int /*long*/ obj);
+public static final boolean GTK_IS_MENU_ITEM(int /*long*/ obj) {
+	lock.lock();
+	try {
+		return _GTK_IS_MENU_ITEM(obj);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _GTK_IS_PLUG(int /*long*/ obj);
+public static final boolean GTK_IS_PLUG(int /*long*/ obj) {
+	lock.lock();
+	try {
+		return _GTK_IS_PLUG(obj);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _GTK_STOCK_CANCEL();
+public static final int /*long*/ GTK_STOCK_CANCEL() {
+	lock.lock();
+	try {
+		return _GTK_STOCK_CANCEL();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _GTK_STOCK_OK();
+public static final int /*long*/ GTK_STOCK_OK() {
+	lock.lock();
+	try {
+		return _GTK_STOCK_OK();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _GTK_TYPE_CELL_RENDERER_TEXT();
+public static final int /*long*/ GTK_TYPE_CELL_RENDERER_TEXT() {
+	lock.lock();
+	try {
+		return _GTK_TYPE_CELL_RENDERER_TEXT();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _GTK_TYPE_CELL_RENDERER_PIXBUF();
+public static final int /*long*/ GTK_TYPE_CELL_RENDERER_PIXBUF() {
+	lock.lock();
+	try {
+		return _GTK_TYPE_CELL_RENDERER_PIXBUF();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _GTK_TYPE_CELL_RENDERER_TOGGLE();
+public static final int /*long*/ GTK_TYPE_CELL_RENDERER_TOGGLE() {
+	lock.lock();
+	try {
+		return _GTK_TYPE_CELL_RENDERER_TOGGLE();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _GTK_TYPE_FIXED();
+public static final int /*long*/ GTK_TYPE_FIXED() {
+	lock.lock();
+	try {
+		return _GTK_TYPE_FIXED();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _GTK_TYPE_MENU();
+public static final int /*long*/ GTK_TYPE_MENU() {
+	lock.lock();
+	try {
+		return _GTK_TYPE_MENU();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _GTK_TYPE_WIDGET();
+public static final int /*long*/ GTK_TYPE_WIDGET() {
+	lock.lock();
+	try {
+		return _GTK_TYPE_WIDGET();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _GTK_WIDGET_FLAGS(int /*long*/ wid);
+public static final int GTK_WIDGET_FLAGS(int /*long*/ wid) {
+	lock.lock();
+	try {
+		return _GTK_WIDGET_FLAGS(wid);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _GTK_WIDGET_STATE(int /*long*/ wid);
+public static final int GTK_WIDGET_STATE(int /*long*/ wid) {
+	lock.lock();
+	try {
+		return _GTK_WIDGET_STATE(wid);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _GTK_WIDGET_HAS_DEFAULT(int /*long*/ wid);
+public static final boolean GTK_WIDGET_HAS_DEFAULT(int /*long*/ wid) {
+	lock.lock();
+	try {
+		return _GTK_WIDGET_HAS_DEFAULT(wid);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _GTK_WIDGET_HAS_FOCUS(int /*long*/ wid);
+public static final boolean GTK_WIDGET_HAS_FOCUS(int /*long*/ wid) {
+	lock.lock();
+	try {
+		return _GTK_WIDGET_HAS_FOCUS(wid);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _GTK_WIDGET_IS_SENSITIVE(int /*long*/ wid);
+public static final boolean GTK_WIDGET_IS_SENSITIVE(int /*long*/ wid) {
+	lock.lock();
+	try {
+		return _GTK_WIDGET_IS_SENSITIVE(wid);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _GTK_WIDGET_MAPPED(int /*long*/ wid);
+public static final boolean GTK_WIDGET_MAPPED(int /*long*/ wid) {
+	lock.lock();
+	try {
+		return _GTK_WIDGET_MAPPED(wid);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _GTK_WIDGET_SENSITIVE(int /*long*/ wid);
+public static final boolean GTK_WIDGET_SENSITIVE(int /*long*/ wid) {
+	lock.lock();
+	try {
+		return _GTK_WIDGET_SENSITIVE(wid);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _GTK_WIDGET_SET_FLAGS(int /*long*/ wid, int flag);
+public static final void GTK_WIDGET_SET_FLAGS(int /*long*/ wid, int flag) {
+	lock.lock();
+	try {
+		_GTK_WIDGET_SET_FLAGS(wid, flag);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _GTK_WIDGET_UNSET_FLAGS(int /*long*/ wid, int flag);
+public static final void GTK_WIDGET_UNSET_FLAGS(int /*long*/ wid, int flag) {
+	lock.lock();
+	try {
+		_GTK_WIDGET_UNSET_FLAGS(wid, flag);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _GTK_WIDGET_VISIBLE(int /*long*/ wid);
+public static final boolean GTK_WIDGET_VISIBLE(int /*long*/ wid) {
+	lock.lock();
+	try {
+		return _GTK_WIDGET_VISIBLE(wid);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _G_OBJECT_CLASS (int /*long*/ klass);
+public static final int /*long*/ G_OBJECT_CLASS (int /*long*/ klass) {
+	lock.lock();
+	try {
+		return _G_OBJECT_CLASS(klass);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _G_OBJECT_GET_CLASS (int /*long*/ object);
+public static final int /*long*/ G_OBJECT_GET_CLASS (int /*long*/ object) {
+	lock.lock();
+	try {
+		return _G_OBJECT_GET_CLASS(object);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _G_OBJECT_TYPE_NAME (int /*long*/ object);
+public static final int /*long*/ G_OBJECT_TYPE_NAME (int /*long*/ object) {
+	lock.lock();
+	try {
+		return _G_OBJECT_TYPE_NAME(object);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _G_TYPE_BOOLEAN();
+public static final int /*long*/ G_TYPE_BOOLEAN() {
+	lock.lock();
+	try {
+		return _G_TYPE_BOOLEAN();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _G_TYPE_INT();
+public static final int /*long*/ G_TYPE_INT() {
+	lock.lock();
+	try {
+		return _G_TYPE_INT();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _G_OBJECT_TYPE (int /*long*/ instance);
+public static final int /*long*/ G_OBJECT_TYPE (int /*long*/ instance) {
+	lock.lock();
+	try {
+		return _G_OBJECT_TYPE(instance);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _G_TYPE_STRING();
+public static final int /*long*/ G_TYPE_STRING() {
+	lock.lock();
+	try {
+		return _G_TYPE_STRING();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _PANGO_PIXELS(int dimension);
+public static final int PANGO_PIXELS(int dimension) {
+	lock.lock();
+	try {
+		return _PANGO_PIXELS(dimension);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _PANGO_TYPE_FONT_DESCRIPTION();
+public static final int /*long*/ PANGO_TYPE_FONT_DESCRIPTION() {
+	lock.lock();
+	try {
+		return _PANGO_TYPE_FONT_DESCRIPTION();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _dlclose(int /*long*/ handle);
+public static final int dlclose(int /*long*/ handle) {
+	lock.lock();
+	try {
+		return _dlclose(handle);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _dlopen(byte[] filename, int flag);
+public static final int /*long*/ dlopen(byte[] filename, int flag) {
+	lock.lock();
+	try {
+		return _dlopen(filename, flag);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _dlsym(int /*long*/ handle, byte[] symbol);
+public static final int /*long*/ dlsym(int /*long*/ handle, byte[] symbol) {
+	lock.lock();
+	try {
+		return _dlsym(handle, symbol);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _g_signal_add_emission_hook(int signal_id, int detail, int /*long*/ hook_func, int /*long*/ hook_data, int /*long*/ data_destroy);
+public static final int /*long*/ g_signal_add_emission_hook(int signal_id, int detail, int /*long*/ hook_func, int /*long*/ hook_data, int /*long*/ data_destroy) {
+	lock.lock();
+	try {
+		return _g_signal_add_emission_hook(signal_id, detail, hook_func, hook_data, data_destroy);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _g_signal_remove_emission_hook(int signal_id, int /*long*/ hook_id);
+public static final void g_signal_remove_emission_hook(int signal_id, int /*long*/ hook_id) {
+	lock.lock();
+	try {
+		 _g_signal_remove_emission_hook (signal_id, hook_id);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _g_cclosure_new(int /*long*/ callback_func, int /*long*/ user_data, int /*long*/ destroy_data);
+public static final int /*long*/ g_cclosure_new(int /*long*/ callback_func, int /*long*/ user_data, int /*long*/ destroy_data) {
+	lock.lock();
+	try {
+		return _g_cclosure_new(callback_func, user_data, destroy_data);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _g_closure_ref(int /*long*/ closure);
+public static final int /*long*/ g_closure_ref(int /*long*/ closure) {
+	lock.lock();
+	try {
+		return _g_closure_ref(closure);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _g_closure_unref(int /*long*/ closure);
+public static final void g_closure_unref(int /*long*/ closure) {
+	lock.lock();
+	try {
+		_g_closure_unref(closure);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _g_main_context_acquire(int /*long*/ context);
+public static final boolean g_main_context_acquire(int /*long*/ context) {
+	lock.lock();
+	try {
+		return _g_main_context_acquire(context);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _g_main_context_check(int /*long*/ context, int max_priority, int /*long*/ fds, int n_fds);
+public static final int g_main_context_check(int /*long*/ context, int max_priority, int /*long*/ fds, int n_fds) {
+	lock.lock();
+	try {
+		return _g_main_context_check(context, max_priority, fds, n_fds);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _g_main_context_default();
+public static final int /*long*/ g_main_context_default() {
+	lock.lock();
+	try {
+		return _g_main_context_default();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _g_main_context_iteration(int /*long*/ context, boolean may_block);
+public static final boolean g_main_context_iteration(int /*long*/ context, boolean may_block) {
+	lock.lock();
+	try {
+		return _g_main_context_iteration(context, may_block);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _g_main_context_pending(int /*long*/ context);
+public static final boolean g_main_context_pending(int /*long*/ context) {
+	lock.lock();
+	try {
+		return _g_main_context_pending(context);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _g_main_context_get_poll_func(int /*long*/ context);
+public static final int /*long*/ g_main_context_get_poll_func(int /*long*/ context) {
+	lock.lock();
+	try {
+		return _g_main_context_get_poll_func(context);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _g_main_context_prepare(int /*long*/ context, int[] priority);
+public static final boolean g_main_context_prepare(int /*long*/ context, int[] priority) {
+	lock.lock();
+	try {
+		return _g_main_context_prepare(context, priority);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _g_main_context_query(int /*long*/ context, int max_priority, int[] timeout_, int /*long*/ fds, int n_fds);
+public static final int g_main_context_query(int /*long*/ context, int max_priority, int[] timeout_, int /*long*/ fds, int n_fds) {
+	lock.lock();
+	try {
+		return _g_main_context_query(context, max_priority, timeout_, fds, n_fds);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _g_main_context_release(int /*long*/ context);
+public static final void g_main_context_release(int /*long*/ context) {
+	lock.lock();
+	try {
+		_g_main_context_release(context);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void g_main_context_wakeup(int /*long*/ context);
+public static final native int /*long*/ _g_filename_to_utf8(int /*long*/ opsysstring, int /*long*/ len, int /*long*/[] bytes_read, int /*long*/[] bytes_written, int /*long*/[] error);
+public static final int /*long*/ g_filename_to_utf8(int /*long*/ opsysstring, int /*long*/ len, int /*long*/[] bytes_read, int /*long*/[] bytes_written, int /*long*/[] error) {
+	lock.lock();
+	try {
+		return _g_filename_to_utf8(opsysstring, len, bytes_read, bytes_written, error);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _g_filename_to_uri(int /*long*/ filename, int /*long*/ hostname, int /*long*/[] error);
+public static final int /*long*/ g_filename_to_uri(int /*long*/ filename, int /*long*/ hostname, int /*long*/[] error) {
+	lock.lock();
+	try {
+		return _g_filename_to_uri(filename, hostname, error);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _g_filename_from_utf8(int /*long*/ opsysstring, int /*long*/ len,  int /*long*/[] bytes_read, int /*long*/[] bytes_written, int /*long*/[] error);
+public static final int /*long*/ g_filename_from_utf8(int /*long*/ opsysstring, int /*long*/ len,  int /*long*/[] bytes_read, int /*long*/[] bytes_written, int /*long*/[] error) {
+	lock.lock();
+	try {
+		return _g_filename_from_utf8(opsysstring, len, bytes_read, bytes_written, error);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _g_filename_from_uri(int /*long*/ uri, int /*long*/[] hostname, int /*long*/[] error);
+public static final int /*long*/ g_filename_from_uri(int /*long*/ uri, int /*long*/[] hostname, int /*long*/[] error) {
+	lock.lock();
+	try {
+		return _g_filename_from_uri(uri, hostname, error);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _g_free(int /*long*/ mem);
+public static final void g_free(int /*long*/ mem) {
+	lock.lock();
+	try {
+		_g_free(mem);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _g_idle_add(int /*long*/ function, int /*long*/ data);
+public static final int g_idle_add(int /*long*/ function, int /*long*/ data) {
+	lock.lock();
+	try {
+		return _g_idle_add(function, data);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _g_list_append(int /*long*/ list, int /*long*/ data);
+public static final int /*long*/ g_list_append(int /*long*/ list, int /*long*/ data) {
+	lock.lock();
+	try {
+		return _g_list_append(list, data);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _g_list_data(int /*long*/ list);
+public static final int /*long*/ g_list_data(int /*long*/ list) {
+	lock.lock();
+	try {
+		return _g_list_data(list);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _g_list_free(int /*long*/ list);
+public static final void g_list_free(int /*long*/ list) {
+	lock.lock();
+	try {
+		_g_list_free(list);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _g_list_free_1(int /*long*/ list);
+public static final void g_list_free_1(int /*long*/ list) {
+	lock.lock();
+	try {
+		_g_list_free_1(list);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _g_list_length(int /*long*/ list);
+public static final int g_list_length(int /*long*/ list) {
+	lock.lock();
+	try {
+		return _g_list_length(list);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _g_list_set_next(int /*long*/ list, int /*long*/ llist);
+public static final void g_list_set_next(int /*long*/ list, int /*long*/ llist) {
+	lock.lock();
+	try {
+		_g_list_set_next(list, llist);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _g_list_next(int /*long*/ list);
+public static final int /*long*/ g_list_next(int /*long*/ list) {
+	lock.lock();
+	try {
+		return _g_list_next(list);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _g_list_nth(int /*long*/ list, int n);
+public static final int /*long*/ g_list_nth(int /*long*/ list, int n) {
+	lock.lock();
+	try {
+		return _g_list_nth(list, n);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _g_list_nth_data(int /*long*/ list, int n);
+public static final int /*long*/ g_list_nth_data(int /*long*/ list, int n) {
+	lock.lock();
+	try {
+		return _g_list_nth_data(list, n);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _g_list_prepend(int /*long*/ list, int /*long*/ data);
+public static final int /*long*/ g_list_prepend(int /*long*/ list, int /*long*/ data) {
+	lock.lock();
+	try {
+		return _g_list_prepend(list, data);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _g_list_set_previous(int /*long*/ list, int /*long*/ llist);
+public static final void g_list_set_previous(int /*long*/ list, int /*long*/ llist) {
+	lock.lock();
+	try {
+		_g_list_set_previous(list, llist);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _g_list_previous(int /*long*/ list);
+public static final int /*long*/ g_list_previous(int /*long*/ list) {
+	lock.lock();
+	try {
+		return _g_list_previous(list);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _g_list_remove_link(int /*long*/ list, int /*long*/ link);
+public static final int /*long*/ g_list_remove_link(int /*long*/ list, int /*long*/ link) {
+	lock.lock();
+	try {
+		return _g_list_remove_link(list, link);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _g_list_reverse(int /*long*/ list);
+public static final int /*long*/ g_list_reverse(int /*long*/ list) {
+	lock.lock();
+	try {
+		return _g_list_reverse(list);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _g_locale_from_utf8(int /*long*/ utf8string, int /*long*/ len, int /*long*/[] bytes_read, int /*long*/[] bytes_written, int /*long*/[] error);
+public static final int /*long*/ g_locale_from_utf8(int /*long*/ utf8string, int /*long*/ len, int /*long*/[] bytes_read, int /*long*/[] bytes_written, int /*long*/[] error) {
+	lock.lock();
+	try {
+		return _g_locale_from_utf8(utf8string, len, bytes_read, bytes_written, error);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _g_locale_to_utf8(int /*long*/ opsysstring, int /*long*/ len, int /*long*/[] bytes_read, int /*long*/[] bytes_written, int /*long*/[] error);
+public static final int /*long*/ g_locale_to_utf8(int /*long*/ opsysstring, int /*long*/ len, int /*long*/[] bytes_read, int /*long*/[] bytes_written, int /*long*/[] error) {
+	lock.lock();
+	try {
+		return _g_locale_to_utf8(opsysstring, len, bytes_read, bytes_written, error);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _g_log_default_handler(int /*long*/ log_domain, int log_levels, int /*long*/ message, int /*long*/ unused_data);
+public static final void g_log_default_handler(int /*long*/ log_domain, int log_levels, int /*long*/ message, int /*long*/ unused_data) {
+	lock.lock();
+	try {
+		_g_log_default_handler(log_domain, log_levels, message, unused_data);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _g_log_remove_handler(byte[] log_domain, int handler_id);
+public static final void g_log_remove_handler(byte[] log_domain, int handler_id) {
+	lock.lock();
+	try {
+		_g_log_remove_handler(log_domain, handler_id);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _g_log_set_handler(byte[] log_domain, int log_levels, int /*long*/ log_func, int /*long*/ user_data);
+public static final int g_log_set_handler(byte[] log_domain, int log_levels, int /*long*/ log_func, int /*long*/ user_data) {
+	lock.lock();
+	try {
+		return _g_log_set_handler(log_domain, log_levels, log_func, user_data);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _g_malloc(int /*long*/ size);
+public static final int /*long*/ g_malloc(int /*long*/ size) {
+	lock.lock();
+	try {
+		return _g_malloc(size);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _g_object_get(int /*long*/ object, byte[] first_property_name, int[] value, int /*long*/ terminator);
+public static final void g_object_get(int /*long*/ object, byte[] first_property_name, int[] value, int /*long*/ terminator) {
+	lock.lock();
+	try {
+		_g_object_get(object, first_property_name, value, terminator);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _g_object_get_qdata(int /*long*/ object, int quark);
+public static final int /*long*/ g_object_get_qdata(int /*long*/ object, int quark) {
+	lock.lock();
+	try {
+		return _g_object_get_qdata(object, quark);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _g_object_new (int /*long*/ type, int /*long*/ first_property_name);
+public static final int /*long*/ g_object_new (int /*long*/ type, int /*long*/ first_property_name) {
+	lock.lock();
+	try {
+		return _g_object_new(type, first_property_name);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _g_object_ref(int /*long*/ object);
+public static final int /*long*/ g_object_ref(int /*long*/ object) {
+	lock.lock();
+	try {
+		return _g_object_ref(object);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _g_object_set(int /*long*/ object, byte[] first_property_name, boolean data, int /*long*/ terminator);
+public static final void g_object_set(int /*long*/ object, byte[] first_property_name, boolean data, int /*long*/ terminator) {
+	lock.lock();
+	try {
+		_g_object_set(object, first_property_name, data, terminator);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _g_object_set(int /*long*/ object, byte[] first_property_name, GdkColor data, int /*long*/ terminator);
+public static final void g_object_set(int /*long*/ object, byte[] first_property_name, GdkColor data, int /*long*/ terminator) {
+	lock.lock();
+	try {
+		_g_object_set(object, first_property_name, data, terminator);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _g_object_set(int /*long*/ object, byte[] first_property_name, int data, int /*long*/ terminator);
+public static final void g_object_set(int /*long*/ object, byte[] first_property_name, int data, int /*long*/ terminator) {
+	lock.lock();
+	try {
+		_g_object_set(object, first_property_name, data, terminator);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _g_object_set(int /*long*/ object, byte[] first_property_name, float data, int /*long*/ terminator);
+public static final void g_object_set(int /*long*/ object, byte[] first_property_name, float data, int /*long*/ terminator) {
+	lock.lock();
+	try {
+		_g_object_set(object, first_property_name, data, terminator);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _g_object_set(int /*long*/ object, byte[] first_property_name, long data, int /*long*/ terminator);
+public static final void g_object_set(int /*long*/ object, byte[] first_property_name, long data, int /*long*/ terminator) {
+	lock.lock();
+	try {
+		_g_object_set(object, first_property_name, data, terminator);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _g_object_set_qdata(int /*long*/ object, int quark, int /*long*/ data);
+public static final void g_object_set_qdata(int /*long*/ object, int quark, int /*long*/ data) {
+	lock.lock();
+	try {
+		_g_object_set_qdata(object, quark, data);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _g_object_unref(int /*long*/ object);
+public static final void g_object_unref(int /*long*/ object) {
+	lock.lock();
+	try {
+		_g_object_unref(object);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _g_quark_from_string(byte[] string);
+public static final int g_quark_from_string(byte[] string) {
+	lock.lock();
+	try {
+		return _g_quark_from_string(string);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _g_set_prgname(byte[] prgname);
+public static final void g_set_prgname(byte[] prgname) {
+	lock.lock();
+	try {
+		_g_set_prgname(prgname);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _g_signal_connect(int /*long*/ instance, byte[] detailed_signal, int /*long*/ proc, int /*long*/ data);
+public static final int g_signal_connect(int /*long*/ instance, byte[] detailed_signal, int /*long*/ proc, int /*long*/ data) {
+	lock.lock();
+	try {
+		return _g_signal_connect(instance, detailed_signal, proc, data);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _g_signal_connect_closure(int /*long*/ instance, byte[] detailed_signal, int /*long*/ closure, boolean after);
+public static final int g_signal_connect_closure(int /*long*/ instance, byte[] detailed_signal, int /*long*/ closure, boolean after) {
+	lock.lock();
+	try {
+		return _g_signal_connect_closure(instance, detailed_signal, closure, after);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _g_signal_connect_closure_by_id(int /*long*/ instance, int signal_id, int detail, int /*long*/ closure, boolean after);
+public static final int g_signal_connect_closure_by_id(int /*long*/ instance, int signal_id, int detail, int /*long*/ closure, boolean after) {
+	lock.lock();
+	try {
+		return _g_signal_connect_closure_by_id(instance, signal_id, detail, closure, after);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _g_signal_connect_after(int /*long*/ instance, byte[] detailed_signal, int /*long*/ proc, int /*long*/ data);
+public static final int g_signal_connect_after(int /*long*/ instance, byte[] detailed_signal, int /*long*/ proc, int /*long*/ data) {
+	lock.lock();
+	try {
+		return _g_signal_connect_after(instance, detailed_signal, proc, data);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _g_signal_emit_by_name(int /*long*/ instance, byte[] detailed_signal);
+public static final void g_signal_emit_by_name(int /*long*/ instance, byte[] detailed_signal) {
+	lock.lock();
+	try {
+		_g_signal_emit_by_name(instance, detailed_signal);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _g_signal_emit_by_name(int /*long*/ instance, byte[] detailed_signal, int /*long*/ data);
+public static final void g_signal_emit_by_name(int /*long*/ instance, byte[] detailed_signal, int /*long*/ data) {
+	lock.lock();
+	try {
+		_g_signal_emit_by_name(instance, detailed_signal, data);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _g_signal_emit_by_name(int /*long*/ instance, byte[] detailed_signal, int /*long*/ data1, int /*long*/ data2);
+public static final void g_signal_emit_by_name(int /*long*/ instance, byte[] detailed_signal, int /*long*/ data1, int /*long*/ data2) {
+	lock.lock();
+	try {
+		_g_signal_emit_by_name(instance, detailed_signal, data1, data2);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _g_signal_emit_by_name(int /*long*/ instance, byte[] detailed_signal, byte [] data);
+public static final void g_signal_emit_by_name(int /*long*/ instance, byte[] detailed_signal, byte [] data) {
+	lock.lock();
+	try {
+		_g_signal_emit_by_name(instance, detailed_signal, data);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _g_signal_handler_disconnect(int /*long*/ instance, int handler_id);
+public static final void g_signal_handler_disconnect(int /*long*/ instance, int handler_id) {
+	lock.lock();
+	try {
+		_g_signal_handler_disconnect(instance, handler_id);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _g_signal_handlers_block_matched(int /*long*/ instance, int mask, int signal_id, int detail, int /*long*/ closure, int /*long*/ func, int /*long*/ data);
+public static final int g_signal_handlers_block_matched(int /*long*/ instance, int mask, int signal_id, int detail, int /*long*/ closure, int /*long*/ func, int /*long*/ data) {
+	lock.lock();
+	try {
+		return _g_signal_handlers_block_matched(instance, mask, signal_id, detail, closure, func, data);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _g_signal_handlers_disconnect_matched(int /*long*/ instance, int mask, int signal_id, int detail, int /*long*/ closure, int /*long*/ func, int /*long*/ data);
+public static final int g_signal_handlers_disconnect_matched(int /*long*/ instance, int mask, int signal_id, int detail, int /*long*/ closure, int /*long*/ func, int /*long*/ data) {
+	lock.lock();
+	try {
+		return _g_signal_handlers_disconnect_matched(instance, mask, signal_id, detail, closure, func, data);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _g_signal_handlers_unblock_matched(int /*long*/ instance, int mask, int signal_id, int detail, int /*long*/ closure, int /*long*/ func, int /*long*/ data);
+public static final int g_signal_handlers_unblock_matched(int /*long*/ instance, int mask, int signal_id, int detail, int /*long*/ closure, int /*long*/ func, int /*long*/ data) {
+	lock.lock();
+	try {
+		return _g_signal_handlers_unblock_matched(instance, mask, signal_id, detail, closure, func, data);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _g_signal_lookup (byte[] name, int /*long*/ itype);
+public static final int g_signal_lookup (byte[] name, int /*long*/ itype) {
+	lock.lock();
+	try {
+		return _g_signal_lookup(name, itype);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _g_signal_stop_emission_by_name(int /*long*/ instance, byte[] detailed_signal);
+public static final void g_signal_stop_emission_by_name(int /*long*/ instance, byte[] detailed_signal) {
+	lock.lock();
+	try {
+		_g_signal_stop_emission_by_name(instance, detailed_signal);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean /*long*/ _g_source_remove (int /*long*/ tag);
+public static final boolean /*long*/ g_source_remove (int /*long*/ tag) {
+	lock.lock();
+	try {
+		return _g_source_remove(tag);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _g_slist_data (int /*long*/ list);
+public static final int /*long*/ g_slist_data (int /*long*/ list) {
+	lock.lock();
+	try {
+		return _g_slist_data(list);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _g_slist_free (int /*long*/ list);
+public static final void g_slist_free (int /*long*/ list) {
+	lock.lock();
+	try {
+		_g_slist_free(list);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _g_slist_next (int /*long*/ list);
+public static final int /*long*/ g_slist_next (int /*long*/ list) {
+	lock.lock();
+	try {
+		return _g_slist_next(list);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _g_slist_length (int /*long*/ list);
+public static final int g_slist_length (int /*long*/ list) {
+	lock.lock();
+	try {
+		return _g_slist_length(list);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _g_strfreev(int /*long*/ string_array);
+public static final void g_strfreev(int /*long*/ string_array) {
+	lock.lock();
+	try {
+		_g_strfreev(string_array);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native double _g_strtod(int /*long*/ str, int /*long*/[] endptr);
+public static final double g_strtod(int /*long*/ str, int /*long*/[] endptr) {
+	lock.lock();
+	try {
+		return _g_strtod(str, endptr);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _g_type_add_interface_static (int /*long*/ instance_type, int /*long*/ interface_type, int /*long*/ info);
+public static final void g_type_add_interface_static (int /*long*/ instance_type, int /*long*/ interface_type, int /*long*/ info) {
+	lock.lock();
+	try {
+		_g_type_add_interface_static(instance_type, interface_type, info);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _g_type_class_peek (int /*long*/ g_class);
+public static final int /*long*/ g_type_class_peek (int /*long*/ g_class) {
+	lock.lock();
+	try {
+		return _g_type_class_peek(g_class);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _g_type_class_peek_parent (int /*long*/ g_class);
+public static final int /*long*/ g_type_class_peek_parent (int /*long*/ g_class) {
+	lock.lock();
+	try {
+		return _g_type_class_peek_parent(g_class);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _g_type_from_name (byte[] name);
+public static final int /*long*/ g_type_from_name (byte[] name) {
+	lock.lock();
+	try {
+		return _g_type_from_name(name);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _g_type_interface_peek_parent (int /*long*/ iface);
+public static final int /*long*/ g_type_interface_peek_parent (int /*long*/ iface) {
+	lock.lock();
+	try {
+		return _g_type_interface_peek_parent(iface);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _g_type_is_a (int /*long*/ type, int /*long*/ is_a_type);
+public static final boolean g_type_is_a (int /*long*/ type, int /*long*/ is_a_type) {
+	lock.lock();
+	try {
+		return _g_type_is_a(type, is_a_type);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _g_type_name (int /*long*/ handle);
+public static final int /*long*/ g_type_name (int /*long*/ handle) {
+	lock.lock();
+	try {
+		return _g_type_name(handle);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _g_type_parent (int /*long*/ type);
+public static final int /*long*/ g_type_parent (int /*long*/ type) {
+	lock.lock();
+	try {
+		return _g_type_parent(type);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _g_type_query (int /*long*/ type, int /*long*/ query);
+public static final void g_type_query (int /*long*/ type, int /*long*/ query) {
+	lock.lock();
+	try {
+		_g_type_query(type, query);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _g_type_register_static (int /*long*/ parent_type, byte[] type_name, int /*long*/ info, int flags);
+public static final int /*long*/ g_type_register_static (int /*long*/ parent_type, byte[] type_name, int /*long*/ info, int flags) {
+	lock.lock();
+	try {
+		return _g_type_register_static(parent_type, type_name, info, flags);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _g_thread_init(int /*long*/ vtable);
+public static final void g_thread_init(int /*long*/ vtable) {
+	lock.lock();
+	try {
+		_g_thread_init(vtable);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _g_thread_supported();
+public static final boolean g_thread_supported() {
+	lock.lock();
+	try {
+		return _g_thread_supported();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _g_utf16_to_utf8(char[] str, int /*long*/ len, int /*long*/[] items_read, int /*long*/[] items_written, int /*long*/[] error);
+public static final int /*long*/ g_utf16_to_utf8(char[] str, int /*long*/ len, int /*long*/[] items_read, int /*long*/[] items_written, int /*long*/[] error) {
+	lock.lock();
+	try {
+		return _g_utf16_to_utf8(str, len, items_read, items_written, error);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _g_utf8_offset_to_pointer(int /*long*/ str, int /*long*/ offset);
+public static final int /*long*/ g_utf8_offset_to_pointer(int /*long*/ str, int /*long*/ offset) {
+	lock.lock();
+	try {
+		return _g_utf8_offset_to_pointer(str, offset);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _g_utf8_pointer_to_offset(int /*long*/ str, int /*long*/ pos);
+public static final int /*long*/ g_utf8_pointer_to_offset(int /*long*/ str, int /*long*/ pos) {
+	lock.lock();
+	try {
+		return _g_utf8_pointer_to_offset(str, pos);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _g_utf8_strlen(int /*long*/ str, int /*long*/ max);
+public static final int /*long*/ g_utf8_strlen(int /*long*/ str, int /*long*/ max) {
+	lock.lock();
+	try {
+		return _g_utf8_strlen(str, max);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _g_utf8_to_utf16(byte[] str, int /*long*/ len, int /*long*/[] items_read, int /*long*/[] items_written, int /*long*/[] error);
+public static final int /*long*/ g_utf8_to_utf16(byte[] str, int /*long*/ len, int /*long*/[] items_read, int /*long*/[] items_written, int /*long*/[] error) {
+	lock.lock();
+	try {
+		return _g_utf8_to_utf16(str, len, items_read, items_written, error);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _g_utf8_to_utf16(int /*long*/ str, int /*long*/ len, int /*long*/[] items_read, int /*long*/[] items_written, int /*long*/[] error);
+public static final int /*long*/ g_utf8_to_utf16(int /*long*/ str, int /*long*/ len, int /*long*/[] items_read, int /*long*/[] items_written, int /*long*/[] error) {
+	lock.lock();
+	try {
+		return _g_utf8_to_utf16(str, len, items_read, items_written, error);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _g_value_peek_pointer (int /*long*/ value);
+public static final  int /*long*/ g_value_peek_pointer (int /*long*/ value) {
+	lock.lock();
+	try {
+		return _g_value_peek_pointer(value);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gdk_atom_intern(byte[] atom_name, boolean only_if_exists);
+public static final int /*long*/ gdk_atom_intern(byte[] atom_name, boolean only_if_exists) {
+	lock.lock();
+	try {
+		return _gdk_atom_intern(atom_name, only_if_exists);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gdk_atom_name(int /*long*/ atom);
+public static final int /*long*/ gdk_atom_name(int /*long*/ atom) {
+	lock.lock();
+	try {
+		return _gdk_atom_name(atom);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_beep();
+public static final void gdk_beep() {
+	lock.lock();
+	try {
+		_gdk_beep();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gdk_bitmap_create_from_data(int /*long*/ window, byte[] data, int width, int height);
+public static final int /*long*/ gdk_bitmap_create_from_data(int /*long*/ window, byte[] data, int width, int height) {
+	lock.lock();
+	try {
+		return _gdk_bitmap_create_from_data(window, data, width, height);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_cairo_region(int /*long*/ cairo, int /*long*/ region);
+public static final void gdk_cairo_region(int /*long*/ cairo, int /*long*/ region) {
+	lock.lock();
+	try {
+		_gdk_cairo_region(cairo, region);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_cairo_set_source_color(int /*long*/ cairo, GdkColor color);
+public static final void gdk_cairo_set_source_color(int /*long*/ cairo, GdkColor color) {
+	lock.lock();
+	try {
+		_gdk_cairo_set_source_color(cairo, color);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _gdk_color_white(int /*long*/ colormap, GdkColor color);
+public static final boolean gdk_color_white(int /*long*/ colormap, GdkColor color) {
+	lock.lock();
+	try {
+		return _gdk_color_white(colormap, color);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _gdk_colormap_alloc_color(int /*long*/ colormap, GdkColor color, boolean writeable, boolean best_match);
+public static final boolean gdk_colormap_alloc_color(int /*long*/ colormap, GdkColor color, boolean writeable, boolean best_match) {
+	lock.lock();
+	try {
+		return _gdk_colormap_alloc_color(colormap, color, writeable, best_match);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_colormap_free_colors(int /*long*/ colormap, GdkColor colors, int ncolors);
+public static final void gdk_colormap_free_colors(int /*long*/ colormap, GdkColor colors, int ncolors) {
+	lock.lock();
+	try {
+		_gdk_colormap_free_colors(colormap, colors, ncolors);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gdk_colormap_get_system();
+public static final int /*long*/ gdk_colormap_get_system() {
+	lock.lock();
+	try {
+		return _gdk_colormap_get_system();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_colormap_query_color(int /*long*/ colormap, int /*long*/ pixel, GdkColor result);
+public static final void gdk_colormap_query_color(int /*long*/ colormap, int /*long*/ pixel, GdkColor result) {
+	lock.lock();
+	try {
+		_gdk_colormap_query_color(colormap, pixel, result);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_cursor_destroy(int /*long*/ cursor);
+public static final void gdk_cursor_destroy(int /*long*/ cursor) {
+	lock.lock();
+	try {
+		_gdk_cursor_destroy(cursor);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gdk_cursor_new(int /*long*/ cursor_type);
+public static final int /*long*/ gdk_cursor_new(int /*long*/ cursor_type) {
+	lock.lock();
+	try {
+		return _gdk_cursor_new(cursor_type);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gdk_cursor_new_from_pixmap(int /*long*/ source, int /*long*/ mask, GdkColor fg, GdkColor bg, int x, int y);
+public static final int /*long*/ gdk_cursor_new_from_pixmap(int /*long*/ source, int /*long*/ mask, GdkColor fg, GdkColor bg, int x, int y) {
+	lock.lock();
+	try {
+		return _gdk_cursor_new_from_pixmap(source, mask, fg, bg, x, y);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gdk_cursor_new_from_pixbuf(int /*long*/ display, int /*long*/ pixbuf, int x, int y);
+public static final int /*long*/ gdk_cursor_new_from_pixbuf(int /*long*/ display, int /*long*/ pixbuf, int x, int y) {
+	lock.lock();
+	try {
+		return _gdk_cursor_new_from_pixbuf(display, pixbuf, x, y);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gdk_display_get_default();
+public static final int /*long*/ gdk_display_get_default() {
+	lock.lock();
+	try {
+		return _gdk_display_get_default();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _gdk_display_supports_cursor_color(int /*long*/ display);
+public static final boolean gdk_display_supports_cursor_color(int /*long*/ display) {
+	lock.lock();
+	try {
+		return _gdk_display_supports_cursor_color(display);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_drag_status(int /*long*/ context, int action, int time);
+public static final void gdk_drag_status(int /*long*/ context, int action, int time) {
+	lock.lock();
+	try {
+		_gdk_drag_status(context, action, time);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_draw_arc(int /*long*/ drawable, int /*long*/ gc, int filled, int x, int y, int width, int height, int angle1, int angle2);
+public static final void gdk_draw_arc(int /*long*/ drawable, int /*long*/ gc, int filled, int x, int y, int width, int height, int angle1, int angle2) {
+	lock.lock();
+	try {
+		_gdk_draw_arc(drawable, gc, filled, x, y, width, height, angle1, angle2);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_draw_drawable(int /*long*/ drawable, int /*long*/ gc, int /*long*/ src, int xsrc, int ysrc, int xdest, int ydest, int width, int height);
+public static final void gdk_draw_drawable(int /*long*/ drawable, int /*long*/ gc, int /*long*/ src, int xsrc, int ysrc, int xdest, int ydest, int width, int height) {
+	lock.lock();
+	try {
+		_gdk_draw_drawable(drawable, gc, src, xsrc, ysrc, xdest, ydest, width, height);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_draw_image(int /*long*/ drawable, int /*long*/ gc, int /*long*/ image, int xsrc, int ysrc, int xdest, int ydest, int width, int height);
+public static final void gdk_draw_image(int /*long*/ drawable, int /*long*/ gc, int /*long*/ image, int xsrc, int ysrc, int xdest, int ydest, int width, int height) {
+	lock.lock();
+	try {
+		_gdk_draw_image(drawable, gc, image, xsrc, ysrc, xdest, ydest, width, height);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_draw_layout(int /*long*/ drawable, int /*long*/ gc, int x, int y, int /*long*/ layout);
+public static final void gdk_draw_layout(int /*long*/ drawable, int /*long*/ gc, int x, int y, int /*long*/ layout) {
+	lock.lock();
+	try {
+		_gdk_draw_layout(drawable, gc, x, y, layout);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_draw_layout_with_colors(int /*long*/ drawable, int /*long*/ gc, int x, int y, int /*long*/ layout, GdkColor foreground, GdkColor background);
+public static final void gdk_draw_layout_with_colors(int /*long*/ drawable, int /*long*/ gc, int x, int y, int /*long*/ layout, GdkColor foreground, GdkColor background) {
+	lock.lock();
+	try {
+		_gdk_draw_layout_with_colors(drawable, gc, x, y, layout, foreground, background);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_draw_line(int /*long*/ drawable, int /*long*/ gc, int x1, int y1, int x2, int y2);
+public static final void gdk_draw_line(int /*long*/ drawable, int /*long*/ gc, int x1, int y1, int x2, int y2) {
+	lock.lock();
+	try {
+		_gdk_draw_line(drawable, gc, x1, y1, x2, y2);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_draw_lines(int /*long*/ drawable, int /*long*/ gc, int[] points, int npoints);
+public static final void gdk_draw_lines(int /*long*/ drawable, int /*long*/ gc, int[] points, int npoints) {
+	lock.lock();
+	try {
+		_gdk_draw_lines(drawable, gc, points, npoints);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_draw_pixbuf(int /*long*/ drawable, int /*long*/ gc, int /*long*/ pixbuf, int xsrc, int ysrc, int xdest, int ydest, int width, int height, int dither, int x_dither, int y_dither);
+public static final void gdk_draw_pixbuf(int /*long*/ drawable, int /*long*/ gc, int /*long*/ pixbuf, int xsrc, int ysrc, int xdest, int ydest, int width, int height, int dither, int x_dither, int y_dither) {
+	lock.lock();
+	try {
+		_gdk_draw_pixbuf(drawable, gc, pixbuf, xsrc, ysrc, xdest, ydest, width, height, dither, x_dither, y_dither);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_draw_point(int /*long*/ drawable, int /*long*/ gc, int x, int y);
+public static final void gdk_draw_point(int /*long*/ drawable, int /*long*/ gc, int x, int y) {
+	lock.lock();
+	try {
+		_gdk_draw_point(drawable, gc, x, y);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_draw_polygon(int /*long*/ drawable, int /*long*/ gc, int filled, int[] points, int npoints);
+public static final void gdk_draw_polygon(int /*long*/ drawable, int /*long*/ gc, int filled, int[] points, int npoints) {
+	lock.lock();
+	try {
+		_gdk_draw_polygon(drawable, gc, filled, points, npoints);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_draw_rectangle(int /*long*/ drawable, int /*long*/ gc, int filled, int x, int y, int width, int height);
+public static final void gdk_draw_rectangle(int /*long*/ drawable, int /*long*/ gc, int filled, int x, int y, int width, int height) {
+	lock.lock();
+	try {
+		_gdk_draw_rectangle(drawable, gc, filled, x, y, width, height);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _gdk_drawable_get_depth(int /*long*/ drawable);
+public static final int gdk_drawable_get_depth(int /*long*/ drawable) {
+	lock.lock();
+	try {
+		return _gdk_drawable_get_depth(drawable);
+	} finally {
+		lock.unlock();
+	}
+}
+
+public static final native int /*long*/ _gdk_drawable_get_image(int /*long*/ drawable, int x, int y, int width, int height);
+public static final int /*long*/ gdk_drawable_get_image(int /*long*/ drawable, int x, int y, int width, int height) {
+	lock.lock();
+	try {
+		return _gdk_drawable_get_image(drawable, x, y, width, height);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_drawable_get_size(int /*long*/ drawable, int[] width, int[] height);
+public static final void gdk_drawable_get_size(int /*long*/ drawable, int[] width, int[] height) {
+	lock.lock();
+	try {
+		_gdk_drawable_get_size(drawable, width, height);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gdk_drawable_get_visible_region(int /*long*/ drawable);
+public static final int /*long*/ gdk_drawable_get_visible_region(int /*long*/ drawable) {
+	lock.lock();
+	try {
+		return _gdk_drawable_get_visible_region(drawable);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gdk_event_copy(int /*long*/ event);
+public static final int /*long*/ gdk_event_copy(int /*long*/ event) {
+	lock.lock();
+	try {
+		return _gdk_event_copy(event);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_event_free(int /*long*/ event);
+public static final void gdk_event_free(int /*long*/ event) {
+	lock.lock();
+	try {
+		_gdk_event_free(event);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gdk_event_get();
+public static final int /*long*/ gdk_event_get() {
+	lock.lock();
+	try {
+		return _gdk_event_get();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _gdk_event_get_root_coords(int /*long*/ event, double[] px, double[] py);
+public static final boolean gdk_event_get_root_coords(int /*long*/ event, double[] px, double[] py) {
+	lock.lock();
+	try {
+		return _gdk_event_get_root_coords(event, px, py);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _gdk_event_get_coords(int /*long*/ event, double[] px, double[] py);
+public static final boolean gdk_event_get_coords(int /*long*/ event, double[] px, double[] py) {
+	lock.lock();
+	try {
+		return _gdk_event_get_coords(event, px, py);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gdk_event_get_graphics_expose(int /*long*/ window);
+public static final int /*long*/ gdk_event_get_graphics_expose(int /*long*/ window) {
+	lock.lock();
+	try {
+		return _gdk_event_get_graphics_expose(window);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _gdk_event_get_state(int /*long*/ event, int[] pmod);
+public static final boolean gdk_event_get_state(int /*long*/ event, int[] pmod) {
+	lock.lock();
+	try {
+		return _gdk_event_get_state(event, pmod);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _gdk_event_get_time(int /*long*/ event);
+public static final int gdk_event_get_time(int /*long*/ event) {
+	lock.lock();
+	try {
+		return _gdk_event_get_time(event);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_event_handler_set(int /*long*/ func, int /*long*/ data, int /*long*/ notify);
+public static final void gdk_event_handler_set(int /*long*/ func, int /*long*/ data, int /*long*/ notify) {
+	lock.lock();
+	try {
+		_gdk_event_handler_set(func, data, notify);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gdk_event_new(int type);
+public static final int /*long*/ gdk_event_new(int type) {
+	lock.lock();
+	try {
+		return _gdk_event_new(type);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gdk_event_peek();
+public static final int /*long*/ gdk_event_peek() {
+	lock.lock();
+	try {
+		return _gdk_event_peek();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_event_put(int /*long*/ event);
+public static final void gdk_event_put(int /*long*/ event) {
+	lock.lock();
+	try {
+		_gdk_event_put(event);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_error_trap_push();
+public static final void gdk_error_trap_push() {
+	lock.lock();
+	try {
+		_gdk_error_trap_push();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _gdk_error_trap_pop();
+public static final int gdk_error_trap_pop() {
+	lock.lock();
+	try {
+		return _gdk_error_trap_pop();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_flush();
+public static final void gdk_flush() {
+	lock.lock();
+	try {
+		_gdk_flush();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_free_text_list(int /*long*/ list);
+public static final void gdk_free_text_list(int /*long*/ list) {
+	lock.lock();
+	try {
+		_gdk_free_text_list(list);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_gc_get_values(int /*long*/ gc, GdkGCValues values);
+public static final void gdk_gc_get_values(int /*long*/ gc, GdkGCValues values) {
+	lock.lock();
+	try {
+		_gdk_gc_get_values(gc, values);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gdk_gc_new(int /*long*/ window);
+public static final int /*long*/ gdk_gc_new(int /*long*/ window) {
+	lock.lock();
+	try {
+		return _gdk_gc_new(window);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_gc_set_background(int /*long*/ gc, GdkColor color);
+public static final void gdk_gc_set_background(int /*long*/ gc, GdkColor color) {
+	lock.lock();
+	try {
+		_gdk_gc_set_background(gc, color);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_gc_set_clip_mask(int /*long*/ gc, int /*long*/ mask);
+public static final void gdk_gc_set_clip_mask(int /*long*/ gc, int /*long*/ mask) {
+	lock.lock();
+	try {
+		_gdk_gc_set_clip_mask(gc, mask);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_gc_set_clip_origin(int /*long*/ gc, int x, int y);
+public static final void gdk_gc_set_clip_origin(int /*long*/ gc, int x, int y) {
+	lock.lock();
+	try {
+		_gdk_gc_set_clip_origin(gc, x, y);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_gc_set_clip_rectangle(int /*long*/ gc, GdkRectangle rectangle);
+public static final void gdk_gc_set_clip_rectangle(int /*long*/ gc, GdkRectangle rectangle) {
+	lock.lock();
+	try {
+		_gdk_gc_set_clip_rectangle(gc, rectangle);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_gc_set_clip_region(int /*long*/ gc, int /*long*/ region);
+public static final void gdk_gc_set_clip_region(int /*long*/ gc, int /*long*/ region) {
+	lock.lock();
+	try {
+		_gdk_gc_set_clip_region(gc, region);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_gc_set_dashes(int /*long*/ gc, int dash_offset, byte[] dash_list, int n);
+public static final void gdk_gc_set_dashes(int /*long*/ gc, int dash_offset, byte[] dash_list, int n) {
+	lock.lock();
+	try {
+		_gdk_gc_set_dashes(gc, dash_offset, dash_list, n);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_gc_set_exposures(int /*long*/ gc, boolean exposures);
+public static final void gdk_gc_set_exposures(int /*long*/ gc, boolean exposures) {
+	lock.lock();
+	try {
+		_gdk_gc_set_exposures(gc, exposures);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_gc_set_fill(int /*long*/ gc, int fill);
+public static final void gdk_gc_set_fill(int /*long*/ gc, int fill) {
+	lock.lock();
+	try {
+		_gdk_gc_set_fill(gc, fill);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_gc_set_foreground(int /*long*/ gc, GdkColor color);
+public static final void gdk_gc_set_foreground(int /*long*/ gc, GdkColor color) {
+	lock.lock();
+	try {
+		_gdk_gc_set_foreground(gc, color);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_gc_set_function(int /*long*/ gc, int /*long*/ function);
+public static final void gdk_gc_set_function(int /*long*/ gc, int /*long*/ function) {
+	lock.lock();
+	try {
+		_gdk_gc_set_function(gc, function);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_gc_set_line_attributes(int /*long*/ gc, int line_width, int line_style, int cap_style, int join_style);
+public static final void gdk_gc_set_line_attributes(int /*long*/ gc, int line_width, int line_style, int cap_style, int join_style) {
+	lock.lock();
+	try {
+		_gdk_gc_set_line_attributes(gc, line_width, line_style, cap_style, join_style);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_gc_set_stipple(int /*long*/ gc, int /*long*/ stipple);
+public static final void gdk_gc_set_stipple(int /*long*/ gc, int /*long*/ stipple) {
+	lock.lock();
+	try {
+		_gdk_gc_set_stipple(gc, stipple);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_gc_set_subwindow(int /*long*/ gc, int /*long*/ mode);
+public static final void gdk_gc_set_subwindow(int /*long*/ gc, int /*long*/ mode) {
+	lock.lock();
+	try {
+		_gdk_gc_set_subwindow(gc, mode);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_gc_set_tile(int /*long*/ gc, int /*long*/ tile);
+public static final void gdk_gc_set_tile(int /*long*/ gc, int /*long*/ tile) {
+	lock.lock();
+	try {
+		_gdk_gc_set_tile(gc, tile);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_gc_set_ts_origin(int /*long*/ gc, int x, int y);
+public static final void gdk_gc_set_ts_origin(int /*long*/ gc, int x, int y) {
+	lock.lock();
+	try {
+		_gdk_gc_set_ts_origin(gc, x, y);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_gc_set_values(int /*long*/ gc, GdkGCValues values, int values_mask);
+public static final void gdk_gc_set_values(int /*long*/ gc, GdkGCValues values, int values_mask) {
+	lock.lock();
+	try {
+		_gdk_gc_set_values(gc, values, values_mask);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_keyboard_ungrab(int time);
+public static final void gdk_keyboard_ungrab(int time) {
+	lock.lock();
+	try {
+		_gdk_keyboard_ungrab(time);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gdk_keymap_get_default();
+public static final int /*long*/ gdk_keymap_get_default() {
+	lock.lock();
+	try {
+		return _gdk_keymap_get_default();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _gdk_keymap_translate_keyboard_state (int /*long*/ keymap, int hardware_keycode, int state, int group, int[] keyval, int[] effective_group, int[] level,  int[] consumed_modifiers);
+public static final boolean gdk_keymap_translate_keyboard_state (int /*long*/ keymap, int hardware_keycode, int state, int group, int[] keyval, int[] effective_group, int[] level,  int[] consumed_modifiers) {
+	lock.lock();
+	try {
+		return _gdk_keymap_translate_keyboard_state(keymap, hardware_keycode, state, group, keyval, effective_group, level, consumed_modifiers);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _gdk_keyval_to_lower(int keyval);
+public static final int gdk_keyval_to_lower(int keyval) {
+	lock.lock();
+	try {
+		return _gdk_keyval_to_lower(keyval);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _gdk_keyval_to_unicode(int keyval);
+public static final int gdk_keyval_to_unicode(int keyval) {
+	lock.lock();
+	try {
+		return _gdk_keyval_to_unicode(keyval);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gdk_pango_context_get();
+public static final int /*long*/ gdk_pango_context_get() {
+	lock.lock();
+	try {
+		return _gdk_pango_context_get();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_pango_context_set_colormap(int /*long*/ context, int /*long*/ colormap);
+public static final void gdk_pango_context_set_colormap(int /*long*/ context, int /*long*/ colormap) {
+	lock.lock();
+	try {
+		_gdk_pango_context_set_colormap(context, colormap);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gdk_pango_layout_get_clip_region(int /*long*/ layout, int x_origin, int y_origin, int[] index_ranges, int n_ranges);
+public static final int /*long*/ gdk_pango_layout_get_clip_region(int /*long*/ layout, int x_origin, int y_origin, int[] index_ranges, int n_ranges) {
+	lock.lock();
+	try {
+		return _gdk_pango_layout_get_clip_region(layout, x_origin, y_origin, index_ranges, n_ranges);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_pixbuf_copy_area(int /*long*/ src_pixbuf, int src_x, int src_y, int width, int height, int /*long*/ dest_pixbuf, int dest_x, int dest_y);
+public static final void gdk_pixbuf_copy_area(int /*long*/ src_pixbuf, int src_x, int src_y, int width, int height, int /*long*/ dest_pixbuf, int dest_x, int dest_y) {
+	lock.lock();
+	try {
+		_gdk_pixbuf_copy_area(src_pixbuf, src_x, src_y, width, height, dest_pixbuf, dest_x, dest_y);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gdk_pixbuf_get_from_drawable(int /*long*/ dest, int /*long*/ src, int /*long*/ cmap, int src_x, int src_y, int dest_x, int dest_y, int width, int height);
+public static final int /*long*/ gdk_pixbuf_get_from_drawable(int /*long*/ dest, int /*long*/ src, int /*long*/ cmap, int src_x, int src_y, int dest_x, int dest_y, int width, int height) {
+	lock.lock();
+	try {
+		return _gdk_pixbuf_get_from_drawable(dest, src, cmap, src_x, src_y, dest_x, dest_y, width, height);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _gdk_pixbuf_get_has_alpha(int /*long*/ pixbuf);
+public static final boolean gdk_pixbuf_get_has_alpha(int /*long*/ pixbuf) {
+	lock.lock();
+	try {
+		return _gdk_pixbuf_get_has_alpha(pixbuf);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _gdk_pixbuf_get_height(int /*long*/ pixbuf);
+public static final int gdk_pixbuf_get_height(int /*long*/ pixbuf) {
+	lock.lock();
+	try {
+		return _gdk_pixbuf_get_height(pixbuf);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gdk_pixbuf_get_pixels(int /*long*/ pixbuf);
+public static final int /*long*/ gdk_pixbuf_get_pixels(int /*long*/ pixbuf) {
+	lock.lock();
+	try {
+		return _gdk_pixbuf_get_pixels(pixbuf);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _gdk_pixbuf_get_rowstride(int /*long*/ pixbuf);
+public static final int gdk_pixbuf_get_rowstride(int /*long*/ pixbuf) {
+	lock.lock();
+	try {
+		return _gdk_pixbuf_get_rowstride(pixbuf);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _gdk_pixbuf_get_width(int /*long*/ pixbuf);
+public static final int gdk_pixbuf_get_width(int /*long*/ pixbuf) {
+	lock.lock();
+	try {
+		return _gdk_pixbuf_get_width(pixbuf);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gdk_pixbuf_loader_new();
+public static final int /*long*/ gdk_pixbuf_loader_new() {
+	lock.lock();
+	try {
+		return _gdk_pixbuf_loader_new();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _gdk_pixbuf_loader_close(int /*long*/ loader, int /*long*/ [] error);
+public static final boolean gdk_pixbuf_loader_close(int /*long*/ loader, int /*long*/ [] error) {
+	lock.lock();
+	try {
+		return _gdk_pixbuf_loader_close(loader, error);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gdk_pixbuf_loader_get_pixbuf(int /*long*/ loader);
+public static final int /*long*/ gdk_pixbuf_loader_get_pixbuf(int /*long*/ loader) {
+	lock.lock();
+	try {
+		return _gdk_pixbuf_loader_get_pixbuf(loader);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _gdk_pixbuf_loader_write(int /*long*/ loader, int /*long*/ buffer, int count, int /*long*/ [] error);
+public static final boolean gdk_pixbuf_loader_write(int /*long*/ loader, int /*long*/ buffer, int count, int /*long*/ [] error) {
+	lock.lock();
+	try {
+		return _gdk_pixbuf_loader_write(loader, buffer, count, error);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gdk_pixbuf_new(int colorspace, boolean has_alpha, int bits_per_sample, int width, int height);
+public static final int /*long*/ gdk_pixbuf_new(int colorspace, boolean has_alpha, int bits_per_sample, int width, int height) {
+	lock.lock();
+	try {
+		return _gdk_pixbuf_new(colorspace, has_alpha, bits_per_sample, width, height);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gdk_pixbuf_new_from_file(byte[] filename, int /*long*/ [] error); 
+public static final int /*long*/ gdk_pixbuf_new_from_file(byte[] filename, int /*long*/ [] error) {
+	lock.lock();
+	try {
+		return _gdk_pixbuf_new_from_file(filename, error);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_pixbuf_render_to_drawable(int /*long*/ pixbuf, int /*long*/ drawable, int /*long*/ gc, int src_x, int src_y, int dest_x, int dest_y, int width, int height, int dither, int x_dither, int y_dither);
+public static final void gdk_pixbuf_render_to_drawable(int /*long*/ pixbuf, int /*long*/ drawable, int /*long*/ gc, int src_x, int src_y, int dest_x, int dest_y, int width, int height, int dither, int x_dither, int y_dither) {
+	lock.lock();
+	try {
+		_gdk_pixbuf_render_to_drawable(pixbuf, drawable, gc, src_x, src_y, dest_x, dest_y, width, height, dither, x_dither, y_dither);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_pixbuf_render_to_drawable_alpha(int /*long*/ pixbuf, int /*long*/ drawable, int src_x, int src_y, int dest_x, int dest_y, int width, int height, int alpha_mode, int alpha_threshold, int dither, int x_dither, int y_dither);
+public static final void gdk_pixbuf_render_to_drawable_alpha(int /*long*/ pixbuf, int /*long*/ drawable, int src_x, int src_y, int dest_x, int dest_y, int width, int height, int alpha_mode, int alpha_threshold, int dither, int x_dither, int y_dither) {
+	lock.lock();
+	try {
+		_gdk_pixbuf_render_to_drawable_alpha(pixbuf, drawable, src_x, src_y, dest_x, dest_y, width, height, alpha_mode, alpha_threshold, dither, x_dither, y_dither);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_pixbuf_render_pixmap_and_mask(int /*long*/ pixbuf, int /*long*/[] pixmap_return, int /*long*/[] mask_return, int alpha_threshold);
+public static final void gdk_pixbuf_render_pixmap_and_mask(int /*long*/ pixbuf, int /*long*/[] pixmap_return, int /*long*/[] mask_return, int alpha_threshold) {
+	lock.lock();
+	try {
+		_gdk_pixbuf_render_pixmap_and_mask(pixbuf, pixmap_return, mask_return, alpha_threshold);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _gdk_pixbuf_save_to_buffer(int /*long*/ pixbuf, int /*long*/ [] buffer, int [] buffer_size, byte [] type, int /*long*/ [] error, byte [] terminate);
+public static final boolean gdk_pixbuf_save_to_buffer(int /*long*/ pixbuf, int /*long*/ [] buffer, int [] buffer_size, byte [] type, int /*long*/ [] error, byte [] terminate) {
+	lock.lock();
+	try {
+		return _gdk_pixbuf_save_to_buffer(pixbuf, buffer, buffer_size, type, error, terminate);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_pixbuf_scale(int /*long*/ src, int /*long*/ dest, int dest_x, int dest_y, int dest_width, int dest_height, double offset_x, double offset_y, double scale_x, double scale_y, int interp_type);
+public static final void gdk_pixbuf_scale(int /*long*/ src, int /*long*/ dest, int dest_x, int dest_y, int dest_width, int dest_height, double offset_x, double offset_y, double scale_x, double scale_y, int interp_type) {
+	lock.lock();
+	try {
+		_gdk_pixbuf_scale(src, dest, dest_x, dest_y, dest_width, dest_height, offset_x, offset_y, scale_x, scale_y, interp_type);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gdk_pixbuf_scale_simple(int /*long*/ src, int dest_width, int dest_height, int interp_type);
+public static final int /*long*/ gdk_pixbuf_scale_simple(int /*long*/ src, int dest_width, int dest_height, int interp_type) {
+	lock.lock();
+	try {
+		return _gdk_pixbuf_scale_simple(src, dest_width, dest_height, interp_type);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gdk_pixmap_new(int /*long*/ window, int width, int height, int depth);
+public static final int /*long*/ gdk_pixmap_new(int /*long*/ window, int width, int height, int depth) {
+	lock.lock();
+	try {
+		return _gdk_pixmap_new(window, width, height, depth);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _gdk_pointer_grab(int /*long*/ window, boolean owner_events, int event_mask, int /*long*/ confine_to, int /*long*/ cursor, int time);
+public static final int gdk_pointer_grab(int /*long*/ window, boolean owner_events, int event_mask, int /*long*/ confine_to, int /*long*/ cursor, int time) {
+	lock.lock();
+	try {
+		return _gdk_pointer_grab(window, owner_events, event_mask, confine_to, cursor, time);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _gdk_pointer_is_grabbed();
+public static final boolean gdk_pointer_is_grabbed() {
+	lock.lock();
+	try {
+		return _gdk_pointer_is_grabbed();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_pointer_ungrab(int time);
+public static final void gdk_pointer_ungrab(int time) {
+	lock.lock();
+	try {
+		_gdk_pointer_ungrab(time);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _gdk_property_get(int /*long*/ window, int /*long*/ property, int /*long*/ type, int /*long*/ offset, int /*long*/ length, int pdelete, int /*long*/[] actual_property_type, int[] actual_format, int[] actual_length, int /*long*/[] data);
+public static final boolean gdk_property_get(int /*long*/ window, int /*long*/ property, int /*long*/ type, int /*long*/ offset, int /*long*/ length, int pdelete, int /*long*/[] actual_property_type, int[] actual_format, int[] actual_length, int /*long*/[] data) {
+	lock.lock();
+	try {
+		return _gdk_property_get(window, property, type, offset, length, pdelete, actual_property_type, actual_format, actual_length, data);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_region_destroy(int /*long*/ region);
+public static final void gdk_region_destroy(int /*long*/ region) {
+	lock.lock();
+	try {
+		_gdk_region_destroy(region);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _gdk_region_empty(int /*long*/ region);
+public static final boolean gdk_region_empty(int /*long*/ region) {
+	lock.lock();
+	try {
+		return _gdk_region_empty(region);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_region_get_clipbox(int /*long*/ region, GdkRectangle rectangle);
+public static final void gdk_region_get_clipbox(int /*long*/ region, GdkRectangle rectangle) {
+	lock.lock();
+	try {
+		_gdk_region_get_clipbox(region, rectangle);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_region_get_rectangles(int /*long*/ region, int /*long*/[] rectangles, int[] n_rectangles);
+public static final void gdk_region_get_rectangles(int /*long*/ region, int /*long*/[] rectangles, int[] n_rectangles) {
+	lock.lock();
+	try {
+		_gdk_region_get_rectangles(region, rectangles, n_rectangles);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_region_intersect(int /*long*/ source1, int /*long*/ source2);
+public static final void gdk_region_intersect(int /*long*/ source1, int /*long*/ source2) {
+	lock.lock();
+	try {
+		_gdk_region_intersect(source1, source2);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gdk_region_new();
+public static final int /*long*/ gdk_region_new() {
+	lock.lock();
+	try {
+		return _gdk_region_new();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_region_offset(int /*long*/ region, int dx, int dy);
+public static final void gdk_region_offset(int /*long*/ region, int dx, int dy) {
+	lock.lock();
+	try {
+		_gdk_region_offset(region, dx, dy);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _gdk_region_point_in(int /*long*/ region, int x, int y);
+public static final boolean gdk_region_point_in(int /*long*/ region, int x, int y) {
+	lock.lock();
+	try {
+		return _gdk_region_point_in(region, x, y);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gdk_region_polygon(int[] points, int npoints, int fill_rule);
+public static final int /*long*/ gdk_region_polygon(int[] points, int npoints, int fill_rule) {
+	lock.lock();
+	try {
+		return _gdk_region_polygon(points, npoints, fill_rule);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gdk_region_rectangle(GdkRectangle rectangle);
+public static final int /*long*/ gdk_region_rectangle(GdkRectangle rectangle) {
+	lock.lock();
+	try {
+		return _gdk_region_rectangle(rectangle);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gdk_region_rect_in(int /*long*/ region, GdkRectangle rect);
+public static final int /*long*/ gdk_region_rect_in(int /*long*/ region, GdkRectangle rect) {
+	lock.lock();
+	try {
+		return _gdk_region_rect_in(region, rect);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_region_subtract(int /*long*/ source1, int /*long*/ source2);
+public static final void gdk_region_subtract(int /*long*/ source1, int /*long*/ source2) {
+	lock.lock();
+	try {
+		_gdk_region_subtract(source1, source2);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_region_union(int /*long*/ source1, int /*long*/ source2);
+public static final void gdk_region_union(int /*long*/ source1, int /*long*/ source2) {
+	lock.lock();
+	try {
+		_gdk_region_union(source1, source2);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_region_union_with_rect(int /*long*/ region, GdkRectangle rect);
+public static final void gdk_region_union_with_rect(int /*long*/ region, GdkRectangle rect) {
+	lock.lock();
+	try {
+		_gdk_region_union_with_rect(region, rect);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_rgb_init();
+public static final void gdk_rgb_init() {
+	lock.lock();
+	try {
+		_gdk_rgb_init();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gdk_screen_get_default();
+public static final int /*long*/ gdk_screen_get_default() {
+	lock.lock();
+	try {
+		return _gdk_screen_get_default();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _gdk_screen_get_monitor_at_point (int /*long*/ screen, int x, int y);
+public static final int gdk_screen_get_monitor_at_point (int /*long*/ screen, int x, int y) {
+	lock.lock();
+	try {
+		return _gdk_screen_get_monitor_at_point (screen, x, y);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _gdk_screen_get_monitor_at_window(int /*long*/ screen, int /*long*/ window);
+public static final int gdk_screen_get_monitor_at_window(int /*long*/ screen, int /*long*/ window) {
+	lock.lock();
+	try {
+		return _gdk_screen_get_monitor_at_window(screen, window);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_screen_get_monitor_geometry (int /*long*/ screen, int monitor_num, GdkRectangle dest);
+public static final void gdk_screen_get_monitor_geometry (int /*long*/ screen, int monitor_num, GdkRectangle dest) {
+	lock.lock();
+	try {
+		_gdk_screen_get_monitor_geometry(screen, monitor_num, dest);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _gdk_screen_get_n_monitors(int /*long*/ screen);
+public static final int gdk_screen_get_n_monitors(int /*long*/ screen) {
+	lock.lock();
+	try {
+		return _gdk_screen_get_n_monitors(screen);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _gdk_screen_get_number(int /*long*/ screen);
+public static final int gdk_screen_get_number(int /*long*/ screen) {
+	lock.lock();
+	try {
+		return _gdk_screen_get_number(screen);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _gdk_screen_height();
+public static final int gdk_screen_height() {
+	lock.lock();
+	try {
+		return _gdk_screen_height();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _gdk_screen_width();
+public static final int gdk_screen_width() {
+	lock.lock();
+	try {
+		return _gdk_screen_width();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _gdk_screen_width_mm();
+public static final int gdk_screen_width_mm() {
+	lock.lock();
+	try {
+		return _gdk_screen_width_mm();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_set_program_class(byte[] program_class);
+public static final void gdk_set_program_class(byte[] program_class) {
+	lock.lock();
+	try {
+		_gdk_set_program_class(program_class);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _gdk_utf8_to_compound_text(byte[] str, int /*long*/[] encoding, int[] format, int /*long*/[] ctext, int[] length);
+public static final boolean gdk_utf8_to_compound_text(byte[] str, int /*long*/[] encoding, int[] format, int /*long*/[] ctext, int[] length) {
+	lock.lock();
+	try {
+		return _gdk_utf8_to_compound_text(str, encoding, format, ctext, length);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gdk_utf8_to_string_target(byte[] str);
+public static final int /*long*/ gdk_utf8_to_string_target(byte[] str) {
+	lock.lock();
+	try {
+		return _gdk_utf8_to_string_target(str);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _gdk_text_property_to_utf8_list  (int /*long*/ encoding, int format, int /*long*/ text, int length,  int /*long*/[] list);
+public static final int gdk_text_property_to_utf8_list  (int /*long*/ encoding, int format, int /*long*/ text, int length,  int /*long*/[] list) {
+	lock.lock();
+	try {
+		return _gdk_text_property_to_utf8_list(encoding, format, text, length, list);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_tooltip_trigger_tooltip_query (int /*long*/ display);
+public static final void gtk_tooltip_trigger_tooltip_query (int /*long*/ display){
+	lock.lock();
+	try {
+		 _gtk_tooltip_trigger_tooltip_query (display);
+	} finally {
+		lock.unlock();
+	}
+}
+
+public static final native  int _gdk_unicode_to_keyval(int wc);
+public static final  int gdk_unicode_to_keyval(int wc) {
+	lock.lock();
+	try {
+		return _gdk_unicode_to_keyval(wc);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gdk_visual_get_system();
+public static final int /*long*/ gdk_visual_get_system() {
+	lock.lock();
+	try {
+		return _gdk_visual_get_system();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gdk_window_at_pointer(int[] win_x, int[] win_y);
+public static final int /*long*/ gdk_window_at_pointer(int[] win_x, int[] win_y) {
+	lock.lock();
+	try {
+		return _gdk_window_at_pointer(win_x, win_y);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_window_begin_paint_rect(int /*long*/ window, GdkRectangle rectangle);
+public static final void gdk_window_begin_paint_rect(int /*long*/ window, GdkRectangle rectangle) {
+	lock.lock();
+	try {
+		_gdk_window_begin_paint_rect(window, rectangle);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_window_clear_area(int /*long*/ window, int x, int y, int width, int height);
+public static final void gdk_window_clear_area(int /*long*/ window, int x, int y, int width, int height) {
+	lock.lock();
+	try {
+		_gdk_window_clear_area(window, x, y, width, height);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_window_destroy(int /*long*/ window);
+public static final void gdk_window_destroy(int /*long*/ window) {
+	lock.lock();
+	try {
+		_gdk_window_destroy(window);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_window_end_paint(int /*long*/ window);
+public static final void gdk_window_end_paint(int /*long*/ window) {
+	lock.lock();
+	try {
+		_gdk_window_end_paint(window);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gdk_window_get_children(int /*long*/ window);
+public static final int /*long*/ gdk_window_get_children(int /*long*/ window) {
+	lock.lock();
+	try {
+		return _gdk_window_get_children(window);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _gdk_window_get_events(int /*long*/ window);
+public static final int gdk_window_get_events(int /*long*/ window) {
+	lock.lock();
+	try {
+		return _gdk_window_get_events(window);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_window_focus(int /*long*/ window, int timestamp);
+public static final void gdk_window_focus(int /*long*/ window, int timestamp) {
+	lock.lock();
+	try {
+		_gdk_window_focus(window, timestamp);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_window_freeze_updates(int /*long*/ window);
+public static final void gdk_window_freeze_updates(int /*long*/ window) {
+	lock.lock();
+	try {
+		_gdk_window_freeze_updates(window);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_window_get_frame_extents(int /*long*/ window, GdkRectangle rect);
+public static final void gdk_window_get_frame_extents(int /*long*/ window, GdkRectangle rect) {
+	lock.lock();
+	try {
+		_gdk_window_get_frame_extents(window, rect);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_window_get_internal_paint_info(int /*long*/ window, int /*long*/ [] real_drawable, int[] x_offset, int[] y_offset);
+public static final void gdk_window_get_internal_paint_info(int /*long*/ window, int /*long*/ [] real_drawable, int[] x_offset, int[] y_offset) {
+	lock.lock();
+	try {
+		_gdk_window_get_internal_paint_info(window, real_drawable, x_offset, y_offset);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _gdk_window_get_origin(int /*long*/ window, int[] x, int[] y);
+public static final int gdk_window_get_origin(int /*long*/ window, int[] x, int[] y) {
+	lock.lock();
+	try {
+		return _gdk_window_get_origin(window, x, y);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gdk_window_get_parent(int /*long*/ window);
+public static final int /*long*/ gdk_window_get_parent(int /*long*/ window) {
+	lock.lock();
+	try {
+		return _gdk_window_get_parent(window);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gdk_window_get_pointer(int /*long*/ window, int[] x, int[] y, int[] mask);
+public static final int /*long*/ gdk_window_get_pointer(int /*long*/ window, int[] x, int[] y, int[] mask) {
+	lock.lock();
+	try {
+		return _gdk_window_get_pointer(window, x, y, mask);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_window_get_position(int /*long*/ window, int[] x, int[] y);
+public static final void gdk_window_get_position(int /*long*/ window, int[] x, int[] y) {
+	lock.lock();
+	try {
+		_gdk_window_get_position(window, x, y);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_window_get_user_data(int /*long*/ window, int /*long*/[] data);
+public static final void gdk_window_get_user_data(int /*long*/ window, int /*long*/[] data) {
+	lock.lock();
+	try {
+		_gdk_window_get_user_data(window, data);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_window_hide(int /*long*/ window);
+public static final void gdk_window_hide(int /*long*/ window) {
+	lock.lock();
+	try {
+		_gdk_window_hide(window);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_window_invalidate_rect(int /*long*/ window, GdkRectangle rectangle, boolean invalidate_children);
+public static final void gdk_window_invalidate_rect(int /*long*/ window, GdkRectangle rectangle, boolean invalidate_children) {
+	lock.lock();
+	try {
+		_gdk_window_invalidate_rect(window, rectangle, invalidate_children);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_window_invalidate_region(int /*long*/ window, int /*long*/ region, boolean invalidate_children);
+public static final void gdk_window_invalidate_region(int /*long*/ window, int /*long*/ region, boolean invalidate_children) {
+	lock.lock();
+	try {
+		_gdk_window_invalidate_region(window, region, invalidate_children);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _gdk_window_is_visible(int /*long*/ window);
+public static final boolean gdk_window_is_visible(int /*long*/ window) {
+	lock.lock();
+	try {
+		return _gdk_window_is_visible(window);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_window_move(int /*long*/ window, int x, int y);
+public static final void gdk_window_move(int /*long*/ window, int x, int y) {
+	lock.lock();
+	try {
+		_gdk_window_move(window, x, y);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gdk_window_new(int /*long*/ parent, GdkWindowAttr attributes, int attributes_mask);
+public static final int /*long*/ gdk_window_new(int /*long*/ parent, GdkWindowAttr attributes, int attributes_mask) {
+	lock.lock();
+	try {
+		return _gdk_window_new(parent, attributes, attributes_mask);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_window_lower(int /*long*/ window);
+public static final void gdk_window_lower(int /*long*/ window) {
+	lock.lock();
+	try {
+		_gdk_window_lower(window);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_window_process_all_updates();
+public static final void gdk_window_process_all_updates() {
+	lock.lock();
+	try {
+		_gdk_window_process_all_updates();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_window_process_updates(int /*long*/ window, boolean update_children);
+public static final void gdk_window_process_updates(int /*long*/ window, boolean update_children) {
+	lock.lock();
+	try {
+		_gdk_window_process_updates(window, update_children);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_window_raise(int /*long*/ window);
+public static final void gdk_window_raise(int /*long*/ window) {
+	lock.lock();
+	try {
+		_gdk_window_raise(window);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_window_resize(int /*long*/ window, int width, int height);
+public static final void gdk_window_resize(int /*long*/ window, int width, int height) {
+	lock.lock();
+	try {
+		_gdk_window_resize(window, width, height);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_window_scroll(int /*long*/ window, int dx, int dy);
+public static final void gdk_window_scroll(int /*long*/ window, int dx, int dy) {
+	lock.lock();
+	try {
+		_gdk_window_scroll(window, dx, dy);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_window_set_accept_focus(int /*long*/ window, boolean accept_focus);
+public static final void gdk_window_set_accept_focus(int /*long*/ window, boolean accept_focus) {
+	lock.lock();
+	try {
+		_gdk_window_set_accept_focus(window, accept_focus);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_window_set_back_pixmap(int /*long*/ window, int /*long*/ pixmap, boolean parent_relative);
+public static final void gdk_window_set_back_pixmap(int /*long*/ window, int /*long*/ pixmap, boolean parent_relative) {
+	lock.lock();
+	try {
+		_gdk_window_set_back_pixmap(window, pixmap, parent_relative);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_window_set_cursor(int /*long*/ window, int /*long*/ cursor);
+public static final void gdk_window_set_cursor(int /*long*/ window, int /*long*/ cursor) {
+	lock.lock();
+	try {
+		_gdk_window_set_cursor(window, cursor);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_window_set_debug_updates(boolean setting);
+public static final void gdk_window_set_debug_updates(boolean setting) {	
+	lock.lock();
+	try {
+		_gdk_window_set_debug_updates(setting);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_window_set_decorations(int /*long*/ window, int decorations);
+public static final void gdk_window_set_decorations(int /*long*/ window, int decorations) {
+	lock.lock();
+	try {
+		_gdk_window_set_decorations(window, decorations);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_window_set_events(int /*long*/ window, int event_mask);
+public static final void gdk_window_set_events(int /*long*/ window, int event_mask) {
+	lock.lock();
+	try {
+		_gdk_window_set_events(window, event_mask);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_window_set_icon(int /*long*/ window, int /*long*/ icon_window, int /*long*/ pixmap, int /*long*/ mask);
+public static final void gdk_window_set_icon(int /*long*/ window, int /*long*/ icon_window, int /*long*/ pixmap, int /*long*/ mask) {
+	lock.lock();
+	try {
+		_gdk_window_set_icon(window, icon_window, pixmap, mask);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_window_set_icon_list(int /*long*/ window, int /*long*/ pixbufs);
+public static final void gdk_window_set_icon_list(int /*long*/ window, int /*long*/ pixbufs) {
+	lock.lock();
+	try {
+		_gdk_window_set_icon_list(window, pixbufs);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_window_set_keep_above(int /*long*/ window, boolean setting);
+public static final void gdk_window_set_keep_above(int /*long*/ window, boolean setting) {
+	lock.lock();
+	try {
+		_gdk_window_set_keep_above(window, setting);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_window_set_override_redirect(int /*long*/ window, boolean override_redirect);
+public static final void gdk_window_set_override_redirect(int /*long*/ window, boolean override_redirect) {
+	lock.lock();
+	try {
+		_gdk_window_set_override_redirect(window, override_redirect);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_window_set_user_data(int /*long*/ window, int /*long*/ user_data);
+public static final void gdk_window_set_user_data(int /*long*/ window, int /*long*/ user_data) {
+	lock.lock();
+	try {
+		_gdk_window_set_user_data(window, user_data);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_window_shape_combine_region (int /*long*/ window, int /*long*/  shape_region, int offset_x,  int offset_y);
+public static final void gdk_window_shape_combine_region (int /*long*/ window, int /*long*/  shape_region, int offset_x,  int offset_y) {
+	lock.lock();
+	try {
+		_gdk_window_shape_combine_region(window, shape_region, offset_x, offset_y);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_window_show(int /*long*/ window);
+public static final void gdk_window_show(int /*long*/ window) {
+	lock.lock();
+	try {
+		_gdk_window_show(window);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_window_show_unraised(int /*long*/ window);
+public static final void gdk_window_show_unraised(int /*long*/ window) {
+	lock.lock();
+	try {
+		_gdk_window_show_unraised(window);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gdk_window_thaw_updates(int /*long*/ window);
+public static final void gdk_window_thaw_updates(int /*long*/ window) {
+	lock.lock();
+	try {
+		_gdk_window_thaw_updates(window);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_accel_group_new();
+public static final int /*long*/ gtk_accel_group_new() {
+	lock.lock();
+	try {
+		return _gtk_accel_group_new();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _gtk_accel_groups_activate(int /*long*/ accelGroup, int accelKey, int accelMods);
+public static final boolean gtk_accel_groups_activate(int /*long*/ accelGroup, int accelKey, int accelMods) {
+	lock.lock();
+	try {
+		return _gtk_accel_groups_activate(accelGroup, accelKey, accelMods);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_accel_label_set_accel_widget(int /*long*/ accel_label, int /*long*/ accel_widget);
+public static final void gtk_accel_label_set_accel_widget(int /*long*/ accel_label, int /*long*/ accel_widget) {
+	lock.lock();
+	try {
+		_gtk_accel_label_set_accel_widget(accel_label, accel_widget);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_adjustment_changed(int /*long*/ adjustment);
+public static final void gtk_adjustment_changed(int /*long*/ adjustment) {
+	lock.lock();
+	try {
+		_gtk_adjustment_changed(adjustment);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_adjustment_new(double value, double lower, double upper, double step_increment, double page_increment, double page_size);
+public static final int /*long*/ gtk_adjustment_new(double value, double lower, double upper, double step_increment, double page_increment, double page_size) {
+	lock.lock();
+	try {
+		return _gtk_adjustment_new(value, lower, upper, step_increment, page_increment, page_size);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_adjustment_set_value(int /*long*/ adjustment, double value);
+public static final void gtk_adjustment_set_value(int /*long*/ adjustment, double value) {
+	lock.lock();
+	try {
+		_gtk_adjustment_set_value(adjustment, value);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_adjustment_value_changed(int /*long*/ adjustment);
+public static final void gtk_adjustment_value_changed(int /*long*/ adjustment) {
+	lock.lock();
+	try {
+		_gtk_adjustment_value_changed(adjustment);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_arrow_new(int arrow_type, int shadow_type);
+public static final int /*long*/ gtk_arrow_new(int arrow_type, int shadow_type) {
+	lock.lock();
+	try {
+		return _gtk_arrow_new(arrow_type, shadow_type);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_arrow_set(int /*long*/ arrow, int arrow_type, int shadow_type);
+public static final void gtk_arrow_set(int /*long*/ arrow, int arrow_type, int shadow_type) {
+	lock.lock();
+	try {
+		_gtk_arrow_set(arrow, arrow_type, shadow_type);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_bin_get_child(int /*long*/ bin);
+public static final int /*long*/ gtk_bin_get_child(int /*long*/ bin) {
+	lock.lock();
+	try {
+		return _gtk_bin_get_child(bin);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_box_set_spacing(int /*long*/ box, int spacing);
+public static final void gtk_box_set_spacing(int /*long*/ box, int spacing) {
+	lock.lock();
+	try {
+		_gtk_box_set_spacing(box, spacing);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_box_set_child_packing(int /*long*/ box, int /*long*/ child, boolean expand, boolean fill, int padding, int pack_type);
+public static final void gtk_box_set_child_packing(int /*long*/ box, int /*long*/ child, boolean expand, boolean fill, int padding, int pack_type) {
+	lock.lock();
+	try {
+		_gtk_box_set_child_packing(box, child, expand, fill, padding, pack_type);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_button_clicked(int /*long*/ button);
+public static final void gtk_button_clicked(int /*long*/ button) {
+	lock.lock();
+	try {
+		_gtk_button_clicked(button);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _gtk_button_get_relief(int /*long*/ button);
+public static final int gtk_button_get_relief(int /*long*/ button) {
+	lock.lock();
+	try {
+		return _gtk_button_get_relief(button);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_button_new();
+public static final int /*long*/ gtk_button_new() {
+	lock.lock();
+	try {
+		return _gtk_button_new();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_button_set_relief(int /*long*/ button, int newstyle);
+public static final void gtk_button_set_relief(int /*long*/ button, int newstyle) {
+	lock.lock();
+	try {
+		_gtk_button_set_relief(button, newstyle);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_calendar_new();
+public static final int /*long*/ gtk_calendar_new() {
+	lock.lock();
+	try {
+		return _gtk_calendar_new();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean /*long*/ _gtk_calendar_select_month(int /*long*/ calendar, int month, int year);
+public static final boolean /*long*/ gtk_calendar_select_month(int /*long*/ calendar, int month, int year) {
+	lock.lock();
+	try {
+		return _gtk_calendar_select_month(calendar, month, year);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_calendar_select_day(int /*long*/ calendar, int day);
+public static final void gtk_calendar_select_day(int /*long*/ calendar, int day) {
+	lock.lock();
+	try {
+		_gtk_calendar_select_day(calendar, day);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_calendar_set_display_options(int /*long*/ calendar, int flags);
+public static final void gtk_calendar_set_display_options(int /*long*/ calendar, int flags) {
+	lock.lock();
+	try {
+		_gtk_calendar_set_display_options(calendar, flags);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_calendar_display_options(int /*long*/ calendar, int flags);
+public static final void gtk_calendar_display_options(int /*long*/ calendar, int flags) {
+	lock.lock();
+	try {
+		_gtk_calendar_display_options(calendar, flags);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_calendar_get_date(int /*long*/ calendar, int[] year, int[] month, int[] day);
+public static final void gtk_calendar_get_date(int /*long*/ calendar, int[] year, int[] month, int[] day) {
+	lock.lock();
+	try {
+		_gtk_calendar_get_date(calendar, year, month, day);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_cell_layout_clear(int /*long*/ cell_layout);
+public static final void gtk_cell_layout_clear(int /*long*/ cell_layout) {
+	lock.lock();
+	try {
+		_gtk_cell_layout_clear(cell_layout);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_cell_layout_set_attributes(int /*long*/ cell_layout, int /*long*/ cell, byte[] attribute, int column, int /*long*/ sentinel);
+public static final void gtk_cell_layout_set_attributes(int /*long*/ cell_layout, int /*long*/ cell, byte[] attribute, int column, int /*long*/ sentinel) {
+	lock.lock();
+	try {
+		_gtk_cell_layout_set_attributes(cell_layout, cell, attribute, column, sentinel);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_cell_layout_pack_start(int /*long*/ cell_layout, int /*long*/ cell, boolean expand);
+public static final void gtk_cell_layout_pack_start(int /*long*/ cell_layout, int /*long*/ cell, boolean expand) {
+	lock.lock();
+	try {
+		_gtk_cell_layout_pack_start(cell_layout, cell, expand);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_cell_renderer_get_size(int /*long*/ cell, int /*long*/ widget, GdkRectangle area, int[] x_offset, int[] y_offset, int[] width, int[] height);
+public static final void gtk_cell_renderer_get_size(int /*long*/ cell, int /*long*/ widget, GdkRectangle area, int[] x_offset, int[] y_offset, int[] width, int[] height) {
+	lock.lock();
+	try {
+		_gtk_cell_renderer_get_size(cell, widget, area, x_offset, y_offset, width, height);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_cell_renderer_pixbuf_new();
+public static final int /*long*/ gtk_cell_renderer_pixbuf_new() {
+	lock.lock();
+	try {
+		return _gtk_cell_renderer_pixbuf_new();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_cell_renderer_text_new();
+public static final int /*long*/ gtk_cell_renderer_text_new() {
+	lock.lock();
+	try {
+		return _gtk_cell_renderer_text_new();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_cell_renderer_toggle_new();
+public static final int /*long*/ gtk_cell_renderer_toggle_new() {
+	lock.lock();
+	try {
+		return _gtk_cell_renderer_toggle_new();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_check_button_new();
+public static final int /*long*/ gtk_check_button_new() {
+	lock.lock();
+	try {
+		return _gtk_check_button_new();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _gtk_check_menu_item_get_active(int /*long*/ check_menu_item);
+public static final boolean gtk_check_menu_item_get_active(int /*long*/ check_menu_item) {
+	lock.lock();
+	try {
+		return _gtk_check_menu_item_get_active(check_menu_item);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_check_menu_item_new_with_label(byte[] label);
+public static final int /*long*/ gtk_check_menu_item_new_with_label(byte[] label) {
+	lock.lock();
+	try {
+		return _gtk_check_menu_item_new_with_label(label);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_check_menu_item_set_active(int /*long*/ wid, boolean active);
+public static final void gtk_check_menu_item_set_active(int /*long*/ wid, boolean active) {
+	lock.lock();
+	try {
+		_gtk_check_menu_item_set_active(wid, active);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_check_version(int required_major, int required_minor, int required_micro);
+public static final int /*long*/ gtk_check_version(int required_major, int required_minor, int required_micro) {
+	lock.lock();
+	try {
+		return _gtk_check_version(required_major, required_minor, required_micro);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_clipboard_clear(int /*long*/ clipboard);
+public static final void gtk_clipboard_clear(int /*long*/ clipboard) {
+	lock.lock();
+	try {
+		_gtk_clipboard_clear(clipboard);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_clipboard_get(int /*long*/ selection);
+public static final int /*long*/ gtk_clipboard_get(int /*long*/ selection) {
+	lock.lock();
+	try {
+		return _gtk_clipboard_get(selection);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _gtk_clipboard_set_with_data(int /*long*/ clipboard, int /*long*/ target, int n_targets, int /*long*/ get_func, int /*long*/ clear_func, int /*long*/ user_data);
+public static final boolean gtk_clipboard_set_with_data(int /*long*/ clipboard, int /*long*/ target, int n_targets, int /*long*/ get_func, int /*long*/ clear_func, int /*long*/ user_data) {
+	lock.lock();
+	try {
+		return _gtk_clipboard_set_with_data(clipboard, target, n_targets, get_func, clear_func, user_data);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_clipboard_wait_for_contents(int /*long*/ clipboard, int /*long*/ target);
+public static final int /*long*/ gtk_clipboard_wait_for_contents(int /*long*/ clipboard, int /*long*/ target) {
+	lock.lock();
+	try {
+		return _gtk_clipboard_wait_for_contents(clipboard, target);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_color_selection_dialog_new(byte[] title);
+public static final int /*long*/ gtk_color_selection_dialog_new(byte[] title) {
+	lock.lock();
+	try {
+		return _gtk_color_selection_dialog_new(title);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_color_selection_get_current_color(int /*long*/ colorsel, GdkColor color);
+public static final void gtk_color_selection_get_current_color(int /*long*/ colorsel, GdkColor color) {
+	lock.lock();
+	try {
+		_gtk_color_selection_get_current_color(colorsel, color);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_color_selection_set_current_color(int /*long*/ colorsel, GdkColor color);
+public static final void gtk_color_selection_set_current_color(int /*long*/ colorsel, GdkColor color) {
+	lock.lock();
+	try {
+		_gtk_color_selection_set_current_color(colorsel, color);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_color_selection_set_has_palette(int /*long*/ colorsel, boolean has_palette);
+public static final void gtk_color_selection_set_has_palette(int /*long*/ colorsel, boolean has_palette) {
+	lock.lock();
+	try {
+		_gtk_color_selection_set_has_palette(colorsel, has_palette);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_combo_disable_activate(int /*long*/ combo);
+public static final void gtk_combo_disable_activate(int /*long*/ combo) {
+	lock.lock();
+	try {
+		_gtk_combo_disable_activate(combo);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_combo_new();
+public static final int /*long*/ gtk_combo_new() {
+	lock.lock();
+	try {
+		return _gtk_combo_new();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_combo_set_case_sensitive(int /*long*/ combo, boolean val);
+public static final void gtk_combo_set_case_sensitive(int /*long*/ combo, boolean val) {
+	lock.lock();
+	try {
+		_gtk_combo_set_case_sensitive(combo, val);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_combo_box_set_focus_on_click(int /*long*/ combo, boolean val);
+public static final void gtk_combo_box_set_focus_on_click(int /*long*/ combo, boolean val) {
+	lock.lock();
+	try {
+		_gtk_combo_box_set_focus_on_click(combo, val);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_combo_set_popdown_strings(int /*long*/ combo, int /*long*/ strings);
+public static final void gtk_combo_set_popdown_strings(int /*long*/ combo, int /*long*/ strings) {
+	lock.lock();
+	try {
+		_gtk_combo_set_popdown_strings(combo, strings);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_combo_box_entry_new_text();
+public static final int /*long*/ gtk_combo_box_entry_new_text() {
+	lock.lock();
+	try {
+		return _gtk_combo_box_entry_new_text();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_combo_box_new_text();
+public static final int /*long*/ gtk_combo_box_new_text() {
+	lock.lock();
+	try {
+		return _gtk_combo_box_new_text();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_combo_box_insert_text(int /*long*/ combo_box, int position, byte[] text);
+public static final void gtk_combo_box_insert_text(int /*long*/ combo_box, int position, byte[] text) {
+	lock.lock();
+	try {
+		_gtk_combo_box_insert_text(combo_box, position, text);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_combo_box_remove_text(int /*long*/ combo_box, int position);
+public static final void gtk_combo_box_remove_text(int /*long*/ combo_box, int position) {
+	lock.lock();
+	try {
+		_gtk_combo_box_remove_text(combo_box, position);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _gtk_combo_box_get_active(int /*long*/ combo_box);
+public static final int gtk_combo_box_get_active(int /*long*/ combo_box) {
+	lock.lock();
+	try {
+		return _gtk_combo_box_get_active(combo_box);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_combo_box_get_model(int /*long*/ combo_box);
+public static final int /*long*/ gtk_combo_box_get_model(int /*long*/ combo_box) {
+	lock.lock();
+	try {
+		return _gtk_combo_box_get_model(combo_box);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_combo_box_set_active(int /*long*/ combo_box, int index);
+public static final void gtk_combo_box_set_active(int /*long*/ combo_box, int index) {
+	lock.lock();
+	try {
+		_gtk_combo_box_set_active(combo_box, index);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_combo_box_popup(int /*long*/ combo_box);
+public static final void gtk_combo_box_popup(int /*long*/ combo_box) {
+	lock.lock();
+	try {
+		_gtk_combo_box_popup(combo_box);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_combo_box_popdown(int /*long*/ combo_box);
+public static final void gtk_combo_box_popdown(int /*long*/ combo_box) {
+	lock.lock();
+	try {
+		_gtk_combo_box_popdown(combo_box);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_container_add(int /*long*/ container, int /*long*/ widget);
+public static final void gtk_container_add(int /*long*/ container, int /*long*/ widget) {
+	lock.lock();
+	try {
+		_gtk_container_add(container, widget);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_container_forall(int /*long*/ container, int /*long*/ callback, int /*long*/ callback_data);
+public static final void gtk_container_forall(int /*long*/ container, int /*long*/ callback, int /*long*/ callback_data) {
+	lock.lock();
+	try {
+		_gtk_container_forall(container, callback, callback_data);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _gtk_container_get_border_width(int /*long*/ container);
+public static final int gtk_container_get_border_width(int /*long*/ container) {
+	lock.lock();
+	try {
+		return _gtk_container_get_border_width(container);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_container_get_children(int /*long*/ container);
+public static final int /*long*/ gtk_container_get_children(int /*long*/ container) {
+	lock.lock();
+	try {
+		return _gtk_container_get_children(container);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_container_remove(int /*long*/ container, int /*long*/ widget);
+public static final void gtk_container_remove(int /*long*/ container, int /*long*/ widget) {
+	lock.lock();
+	try {
+		_gtk_container_remove(container, widget);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_container_resize_children(int /*long*/ container);
+public static final void gtk_container_resize_children(int /*long*/ container) {
+	lock.lock();
+	try {
+		_gtk_container_resize_children(container);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_container_set_border_width(int /*long*/ container, int border_width);
+public static final void gtk_container_set_border_width(int /*long*/ container, int border_width) {
+	lock.lock();
+	try {
+		_gtk_container_set_border_width(container, border_width);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_dialog_add_button(int /*long*/ dialog, byte[]  button_text, int response_id);
+public static final int /*long*/ gtk_dialog_add_button(int /*long*/ dialog, byte[]  button_text, int response_id) {
+	lock.lock();
+	try {
+		return _gtk_dialog_add_button(dialog, button_text, response_id);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _gtk_dialog_run(int /*long*/ dialog);
+public static final int gtk_dialog_run(int /*long*/ dialog) {
+	lock.lock();
+	try {
+		return _gtk_dialog_run(dialog);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_drag_begin(int /*long*/ widget, int /*long*/ targets, int actions, int button, int /*long*/ event);
+public static final int /*long*/ gtk_drag_begin(int /*long*/ widget, int /*long*/ targets, int actions, int button, int /*long*/ event) {
+	lock.lock();
+	try {
+		return _gtk_drag_begin(widget, targets, actions, button, event);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _gtk_drag_check_threshold(int /*long*/ widget, int start_x, int start_y, int current_x, int current_y);
+public static final boolean gtk_drag_check_threshold(int /*long*/ widget, int start_x, int start_y, int current_x, int current_y) {
+	lock.lock();
+	try {
+		return _gtk_drag_check_threshold(widget, start_x, start_y, current_x, current_y);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_drag_dest_find_target(int /*long*/ widget, int /*long*/ context, int /*long*/ target_list);
+public static final int /*long*/ gtk_drag_dest_find_target(int /*long*/ widget, int /*long*/ context, int /*long*/ target_list) {
+	lock.lock();
+	try {
+		return _gtk_drag_dest_find_target(widget, context, target_list);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_drag_dest_set(int /*long*/ widget, int flags, int /*long*/ targets, int n_targets, int actions);
+public static final void gtk_drag_dest_set(int /*long*/ widget, int flags, int /*long*/ targets, int n_targets, int actions) {
+	lock.lock();
+	try {
+		_gtk_drag_dest_set(widget, flags, targets, n_targets, actions);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_drag_dest_unset(int /*long*/ widget);
+public static final void gtk_drag_dest_unset(int /*long*/ widget) {
+	lock.lock();
+	try {
+		_gtk_drag_dest_unset(widget);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_drag_finish(int /*long*/ context, boolean success, boolean delete, int time);
+public static final void gtk_drag_finish(int /*long*/ context, boolean success, boolean delete, int time) {
+	lock.lock();
+	try {
+		_gtk_drag_finish(context, success, delete, time);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_drag_get_data(int /*long*/ widget, int /*long*/ context, int /*long*/ target, int time);
+public static final void gtk_drag_get_data(int /*long*/ widget, int /*long*/ context, int /*long*/ target, int time) {
+	lock.lock();
+	try {
+		_gtk_drag_get_data(widget, context, target, time);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_drag_set_icon_pixbuf(int /*long*/ context, int /*long*/ pixbuf, int hot_x, int hot_y);
+public static final void gtk_drag_set_icon_pixbuf(int /*long*/ context, int /*long*/ pixbuf, int hot_x, int hot_y) {
+	lock.lock();
+	try {
+		_gtk_drag_set_icon_pixbuf(context, pixbuf, hot_x, hot_y);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_drawing_area_new();
+public static final int /*long*/ gtk_drawing_area_new() {
+	lock.lock();
+	try {
+		return _gtk_drawing_area_new();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_editable_copy_clipboard(int /*long*/ editable);
+public static final void gtk_editable_copy_clipboard(int /*long*/ editable) {
+	lock.lock();
+	try {
+		_gtk_editable_copy_clipboard(editable);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_editable_cut_clipboard(int /*long*/ editable);
+public static final void gtk_editable_cut_clipboard(int /*long*/ editable) {
+	lock.lock();
+	try {
+		_gtk_editable_cut_clipboard(editable);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_editable_delete_selection(int /*long*/ editable);
+public static final void gtk_editable_delete_selection(int /*long*/ editable) {
+	lock.lock();
+	try {
+		_gtk_editable_delete_selection(editable);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_editable_delete_text(int /*long*/ editable, int start_pos, int end_pos);
+public static final void gtk_editable_delete_text(int /*long*/ editable, int start_pos, int end_pos) {
+	lock.lock();
+	try {
+		_gtk_editable_delete_text(editable, start_pos, end_pos);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_editable_get_chars(int /*long*/ editable, int start_pos, int end_pos);
+public static final int /*long*/ gtk_editable_get_chars(int /*long*/ editable, int start_pos, int end_pos) {
+	lock.lock();
+	try {
+		return _gtk_editable_get_chars(editable, start_pos, end_pos);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _gtk_editable_get_editable(int /*long*/ editable);
+public static final boolean gtk_editable_get_editable(int /*long*/ editable) {
+	lock.lock();
+	try {
+		return _gtk_editable_get_editable(editable);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _gtk_editable_get_position(int /*long*/ editable);
+public static final int gtk_editable_get_position(int /*long*/ editable) {
+	lock.lock();
+	try {
+		return _gtk_editable_get_position(editable);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _gtk_editable_get_selection_bounds(int /*long*/ editable, int[] start, int[] end);
+public static final boolean gtk_editable_get_selection_bounds(int /*long*/ editable, int[] start, int[] end) {
+	lock.lock();
+	try {
+		return _gtk_editable_get_selection_bounds(editable, start, end);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_editable_insert_text(int /*long*/ editable, byte[] new_text, int new_text_length, int[] position);
+public static final void gtk_editable_insert_text(int /*long*/ editable, byte[] new_text, int new_text_length, int[] position) {
+	lock.lock();
+	try {
+		_gtk_editable_insert_text(editable, new_text, new_text_length, position);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_editable_paste_clipboard(int /*long*/ editable);
+public static final void gtk_editable_paste_clipboard(int /*long*/ editable) {
+	lock.lock();
+	try {
+		_gtk_editable_paste_clipboard(editable);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_editable_select_region(int /*long*/ editable, int start, int end);
+public static final void gtk_editable_select_region(int /*long*/ editable, int start, int end) {
+	lock.lock();
+	try {
+		_gtk_editable_select_region(editable, start, end);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_editable_set_editable(int /*long*/ entry, boolean editable);
+public static final void gtk_editable_set_editable(int /*long*/ entry, boolean editable) {
+	lock.lock();
+	try {
+		_gtk_editable_set_editable(entry, editable);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_editable_set_position(int /*long*/ editable, int position);
+public static final void gtk_editable_set_position(int /*long*/ editable, int position) {
+	lock.lock();
+	try {
+		_gtk_editable_set_position(editable, position);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native char _gtk_entry_get_invisible_char(int /*long*/ entry);
+public static final char gtk_entry_get_invisible_char(int /*long*/ entry) {
+	lock.lock();
+	try {
+		return _gtk_entry_get_invisible_char(entry);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_entry_get_layout (int /*long*/ entry);
+public static final int /*long*/ gtk_entry_get_layout (int /*long*/ entry) {
+	lock.lock();
+	try {
+		return _gtk_entry_get_layout(entry);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_entry_get_layout_offsets (int /*long*/ layout, int[] x, int[] y);
+public static final void gtk_entry_get_layout_offsets (int /*long*/ layout, int[] x, int[] y) {
+	lock.lock();
+	try {
+		_gtk_entry_get_layout_offsets(layout, x, y);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _gtk_entry_text_index_to_layout_index (int /*long*/ entry, int index);
+public static final int gtk_entry_text_index_to_layout_index (int /*long*/ entry, int index) {
+	lock.lock();
+	try {
+		return _gtk_entry_text_index_to_layout_index(entry, index);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _gtk_entry_get_max_length(int /*long*/ entry);
+public static final int gtk_entry_get_max_length(int /*long*/ entry) {
+	lock.lock();
+	try {
+		return _gtk_entry_get_max_length(entry);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_entry_get_text(int /*long*/ entry);
+public static final int /*long*/ gtk_entry_get_text(int /*long*/ entry) {
+	lock.lock();
+	try {
+		return _gtk_entry_get_text(entry);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _FcConfigAppFontAddFile(int /*long*/ config, byte[] file);
+public static final boolean FcConfigAppFontAddFile(int /*long*/ config, byte[] file) {
+	lock.lock();
+	try {
+		return _FcConfigAppFontAddFile(config, file);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _gtk_entry_get_visibility(int /*long*/ entry);
+public static final boolean gtk_entry_get_visibility(int /*long*/ entry) {
+	lock.lock();
+	try {
+		return _gtk_entry_get_visibility(entry);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_entry_new();
+public static final int /*long*/ gtk_entry_new() {
+	lock.lock();
+	try {
+		return _gtk_entry_new();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_entry_set_activates_default(int /*long*/ entry, boolean setting);
+public static final void gtk_entry_set_activates_default(int /*long*/ entry, boolean setting) {
+	lock.lock();
+	try {
+		_gtk_entry_set_activates_default(entry, setting);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_entry_set_alignment(int /*long*/ entry, float xalign);
+public static final void gtk_entry_set_alignment(int /*long*/ entry, float xalign) {
+	lock.lock();
+	try {
+		_gtk_entry_set_alignment(entry, xalign);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_entry_set_has_frame(int /*long*/ entry, boolean setting);
+public static final void gtk_entry_set_has_frame(int /*long*/ entry, boolean setting) {
+	lock.lock();
+	try {
+		_gtk_entry_set_has_frame(entry, setting);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_entry_set_invisible_char(int /*long*/ entry, char ch);
+public static final void gtk_entry_set_invisible_char(int /*long*/ entry, char ch) {
+	lock.lock();
+	try {
+		_gtk_entry_set_invisible_char(entry, ch);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_entry_set_max_length(int /*long*/ entry, int max);
+public static final void gtk_entry_set_max_length(int /*long*/ entry, int max) {
+	lock.lock();
+	try {
+		_gtk_entry_set_max_length(entry, max);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_entry_set_text(int /*long*/ entry, byte[] text);
+public static final void gtk_entry_set_text(int /*long*/ entry, byte[] text) {
+	lock.lock();
+	try {
+		_gtk_entry_set_text(entry, text);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_entry_set_visibility(int /*long*/ entry, boolean visible);
+public static final void gtk_entry_set_visibility(int /*long*/ entry, boolean visible) {
+	lock.lock();
+	try {
+		_gtk_entry_set_visibility(entry, visible);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _gtk_events_pending();
+public static final int gtk_events_pending() {
+	lock.lock();
+	try {
+		return _gtk_events_pending();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _gtk_expander_get_expanded(int /*long*/ expander);
+public static final boolean gtk_expander_get_expanded(int /*long*/ expander) {
+	lock.lock();
+	try {
+		return _gtk_expander_get_expanded(expander);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_expander_get_label_widget(int /*long*/ expander);
+public static final int /*long*/ gtk_expander_get_label_widget(int /*long*/ expander) {
+	lock.lock();
+	try {
+		return _gtk_expander_get_label_widget(expander);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_expander_new(byte[] label);
+public static final int /*long*/ gtk_expander_new(byte[] label) {
+	lock.lock();
+	try {
+		return _gtk_expander_new(label);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_expander_set_expanded(int /*long*/ expander, boolean expanded);
+public static final void gtk_expander_set_expanded(int /*long*/ expander, boolean expanded) {
+	lock.lock();
+	try {
+		_gtk_expander_set_expanded(expander, expanded);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_expander_set_label(int /*long*/ expander, byte[] label);
+public static final void gtk_expander_set_label(int /*long*/ expander, byte[] label) {
+	lock.lock();
+	try {
+		_gtk_expander_set_label(expander, label);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_expander_set_label_widget(int /*long*/ expander, int /*long*/ label_widget);
+public static final void  gtk_expander_set_label_widget(int /*long*/ expander, int /*long*/ label_widget) {
+	lock.lock();
+	try {
+		_gtk_expander_set_label_widget(expander, label_widget);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_file_chooser_add_filter(int /*long*/ chooser, int /*long*/ filter);
+public static final void gtk_file_chooser_add_filter(int /*long*/ chooser, int /*long*/ filter) {
+	lock.lock();
+	try {
+		_gtk_file_chooser_add_filter(chooser, filter);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_file_chooser_dialog_new(byte[] title, int /*long*/ parent, int action, int /*long*/ first_button_text, int first_button_id, int /*long*/ second_button_text, int second_button_id, int /*long*/ terminator);
+public static final int /*long*/ gtk_file_chooser_dialog_new(byte[] title, int /*long*/ parent, int action, int /*long*/ first_button_text, int first_button_id, int /*long*/ second_button_text, int second_button_id, int /*long*/ terminator) {
+	lock.lock();
+	try {
+		return _gtk_file_chooser_dialog_new(title, parent, action, first_button_text, first_button_id, second_button_text, second_button_id, terminator);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_file_chooser_get_current_folder(int /*long*/ chooser);
+public static final int /*long*/ gtk_file_chooser_get_current_folder(int /*long*/ chooser) {
+	lock.lock();
+	try {
+		return _gtk_file_chooser_get_current_folder(chooser);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_file_chooser_get_filename(int /*long*/ chooser);
+public static final int /*long*/ gtk_file_chooser_get_filename(int /*long*/ chooser) {
+	lock.lock();
+	try {
+		return _gtk_file_chooser_get_filename(chooser);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_file_chooser_get_filenames(int /*long*/ chooser);
+public static final int /*long*/ gtk_file_chooser_get_filenames(int /*long*/ chooser) {
+	lock.lock();
+	try {
+		return _gtk_file_chooser_get_filenames(chooser);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_file_chooser_get_filter(int /*long*/ chooser);
+public static final int /*long*/ gtk_file_chooser_get_filter(int /*long*/ chooser) {
+	lock.lock();
+	try {
+		return _gtk_file_chooser_get_filter(chooser);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_file_chooser_set_current_folder(int /*long*/ chooser, int /*long*/ filename);
+public static final void gtk_file_chooser_set_current_folder(int /*long*/ chooser, int /*long*/ filename) {
+	lock.lock();
+	try {
+		_gtk_file_chooser_set_current_folder(chooser, filename);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_file_chooser_set_current_name(int /*long*/ chooser, byte[] name);
+public static final void gtk_file_chooser_set_current_name(int /*long*/ chooser, byte[] name) {
+	lock.lock();
+	try {
+		_gtk_file_chooser_set_current_name(chooser, name);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_file_chooser_set_do_overwrite_confirmation(int /*long*/ chooser, boolean do_overwrite_confirmation);
+public static final void gtk_file_chooser_set_do_overwrite_confirmation(int /*long*/ chooser, boolean do_overwrite_confirmation) {
+	lock.lock();
+	try {
+		_gtk_file_chooser_set_do_overwrite_confirmation(chooser, do_overwrite_confirmation);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_file_chooser_set_extra_widget(int /*long*/ chooser, int /*long*/ extra_widget);
+public static final void gtk_file_chooser_set_extra_widget(int /*long*/ chooser, int /*long*/ extra_widget) {
+	lock.lock();
+	try {
+		_gtk_file_chooser_set_extra_widget(chooser, extra_widget);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_file_chooser_set_filename(int /*long*/ chooser, int /*long*/ name);
+public static final void gtk_file_chooser_set_filename(int /*long*/ chooser, int /*long*/ name) {
+	lock.lock();
+	try {
+		_gtk_file_chooser_set_filename(chooser, name);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_file_chooser_set_filter(int /*long*/ chooser, int /*long*/ filter);
+public static final void gtk_file_chooser_set_filter(int /*long*/ chooser, int /*long*/ filter) {
+	lock.lock();
+	try {
+		_gtk_file_chooser_set_filter(chooser, filter);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_file_chooser_set_select_multiple(int /*long*/ chooser, boolean select_multiple);
+public static final void gtk_file_chooser_set_select_multiple(int /*long*/ chooser, boolean select_multiple) {
+	lock.lock();
+	try {
+		_gtk_file_chooser_set_select_multiple(chooser, select_multiple);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_file_filter_add_pattern(int /*long*/ filter, byte[] pattern);
+public static final void gtk_file_filter_add_pattern(int /*long*/ filter, byte[] pattern) {
+	lock.lock();
+	try {
+		_gtk_file_filter_add_pattern(filter, pattern);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_file_filter_new();
+public static final int /*long*/ gtk_file_filter_new() {
+	lock.lock();
+	try {
+		return _gtk_file_filter_new();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_file_filter_get_name(int /*long*/ filter);
+public static final int /*long*/ gtk_file_filter_get_name(int /*long*/ filter) {
+	lock.lock();
+	try {
+		return _gtk_file_filter_get_name(filter);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_file_filter_set_name(int /*long*/ filter, byte[] name);
+public static final void gtk_file_filter_set_name(int /*long*/ filter, byte[] name) {
+	lock.lock();
+	try {
+		_gtk_file_filter_set_name(filter, name);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_file_selection_get_filename(int /*long*/ filesel);
+public static final int /*long*/ gtk_file_selection_get_filename(int /*long*/ filesel) {
+	lock.lock();
+	try {
+		return _gtk_file_selection_get_filename(filesel);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_file_selection_get_selections(int /*long*/ filesel);
+public static final int /*long*/ gtk_file_selection_get_selections(int /*long*/ filesel) {
+	lock.lock();
+	try {
+		return _gtk_file_selection_get_selections(filesel);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_file_selection_hide_fileop_buttons(int /*long*/ filesel);
+public static final void gtk_file_selection_hide_fileop_buttons(int /*long*/ filesel) {
+	lock.lock();
+	try {
+		_gtk_file_selection_hide_fileop_buttons(filesel);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_file_selection_new(byte[] title);
+public static final int /*long*/ gtk_file_selection_new(byte[] title) {
+	lock.lock();
+	try {
+		return _gtk_file_selection_new(title);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_file_selection_set_filename(int /*long*/ filesel, int /*long*/ filename);
+public static final void gtk_file_selection_set_filename(int /*long*/ filesel, int /*long*/ filename) {
+	lock.lock();
+	try {
+		_gtk_file_selection_set_filename(filesel, filename);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_file_selection_set_select_multiple(int /*long*/ filesel, boolean select_multiple);
+public static final void gtk_file_selection_set_select_multiple(int /*long*/ filesel, boolean select_multiple) {
+	lock.lock();
+	try {
+		_gtk_file_selection_set_select_multiple(filesel, select_multiple);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_fixed_move(int /*long*/ fixed, int /*long*/ widget, int x, int y);
+public static final void gtk_fixed_move(int /*long*/ fixed, int /*long*/ widget, int x, int y) {
+	lock.lock();
+	try {
+		_gtk_fixed_move(fixed, widget, x, y);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_fixed_new();
+public static final int /*long*/ gtk_fixed_new() {
+	lock.lock();
+	try {
+		return _gtk_fixed_new();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_fixed_set_has_window(int /*long*/ fixed, boolean has_window);
+public static final void gtk_fixed_set_has_window(int /*long*/ fixed, boolean has_window) {
+	lock.lock();
+	try {
+		_gtk_fixed_set_has_window(fixed, has_window);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_font_selection_dialog_get_font_name(int /*long*/ fsd);
+public static final int /*long*/ gtk_font_selection_dialog_get_font_name(int /*long*/ fsd) {
+	lock.lock();
+	try {
+		return _gtk_font_selection_dialog_get_font_name(fsd);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_font_selection_dialog_new(byte[] title);
+public static final int /*long*/ gtk_font_selection_dialog_new(byte[] title) {
+	lock.lock();
+	try {
+		return _gtk_font_selection_dialog_new(title);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _gtk_font_selection_dialog_set_font_name(int /*long*/ fsd, byte[] fontname);
+public static final boolean gtk_font_selection_dialog_set_font_name(int /*long*/ fsd, byte[] fontname) {
+	lock.lock();
+	try {
+		return _gtk_font_selection_dialog_set_font_name(fsd, fontname);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_frame_new(byte[] label);
+public static final int /*long*/ gtk_frame_new(byte[] label) {
+	lock.lock();
+	try {
+		return _gtk_frame_new(label);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_frame_get_label_widget(int /*long*/ frame);
+public static final int /*long*/ gtk_frame_get_label_widget(int /*long*/ frame) {
+	lock.lock();
+	try {
+		return _gtk_frame_get_label_widget(frame);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_frame_set_label(int /*long*/ frame, byte[] label);
+public static final void gtk_frame_set_label(int /*long*/ frame, byte[] label) {
+	lock.lock();
+	try {
+		_gtk_frame_set_label(frame, label);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_frame_set_label_widget(int /*long*/ frame, int /*long*/ label_widget);
+public static final void gtk_frame_set_label_widget(int /*long*/ frame, int /*long*/ label_widget) {
+	lock.lock();
+	try {
+		_gtk_frame_set_label_widget(frame, label_widget);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_frame_set_shadow_type(int /*long*/ frame, int type);
+public static final void gtk_frame_set_shadow_type(int /*long*/ frame, int type) {
+	lock.lock();
+	try {
+		_gtk_frame_set_shadow_type(frame, type);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_get_current_event();
+public static final int /*long*/ gtk_get_current_event() {
+	lock.lock();
+	try {
+		return _gtk_get_current_event();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _gtk_get_current_event_state (int[] state);
+public static final boolean gtk_get_current_event_state (int[] state) {
+	lock.lock();
+	try {
+		return _gtk_get_current_event_state(state);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _gtk_get_current_event_time();
+public static final int gtk_get_current_event_time() {
+	lock.lock();
+	try {
+		return _gtk_get_current_event_time();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_get_default_language();
+public static final int /*long*/ gtk_get_default_language() {
+	lock.lock();
+	try {
+		return _gtk_get_default_language();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_get_event_widget(int /*long*/ event);
+public static final int /*long*/ gtk_get_event_widget(int /*long*/ event) {
+	lock.lock();
+	try {
+		return _gtk_get_event_widget(event);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_grab_add(int /*long*/ widget);
+public static final void gtk_grab_add(int /*long*/ widget) {
+	lock.lock();
+	try {
+		_gtk_grab_add(widget);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_grab_get_current();
+public static final int /*long*/ gtk_grab_get_current() {
+	lock.lock();
+	try {
+		return _gtk_grab_get_current();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_grab_remove(int /*long*/ widget);
+public static final void gtk_grab_remove(int /*long*/ widget) {
+	lock.lock();
+	try {
+		_gtk_grab_remove(widget);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_hbox_new(boolean homogeneous, int spacing);
+public static final int /*long*/ gtk_hbox_new(boolean homogeneous, int spacing) {
+	lock.lock();
+	try {
+		return _gtk_hbox_new(homogeneous, spacing);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_hscale_new(int /*long*/ adjustment);
+public static final int /*long*/ gtk_hscale_new(int /*long*/ adjustment) {
+	lock.lock();
+	try {
+		return _gtk_hscale_new(adjustment);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_hscrollbar_new(int /*long*/ adjustment);
+public static final int /*long*/ gtk_hscrollbar_new(int /*long*/ adjustment) {
+	lock.lock();
+	try {
+		return _gtk_hscrollbar_new(adjustment);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_hseparator_new();
+public static final int /*long*/ gtk_hseparator_new() {
+	lock.lock();
+	try {
+		return _gtk_hseparator_new();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_icon_factory_lookup_default(byte[] stock_id);
+public static final int /*long*/ gtk_icon_factory_lookup_default(byte[] stock_id) {
+	lock.lock();
+	try {
+		return _gtk_icon_factory_lookup_default(stock_id);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_icon_source_free(int /*long*/ source);
+public static final void gtk_icon_source_free(int /*long*/ source) {
+	lock.lock();
+	try {
+		_gtk_icon_source_free(source);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_icon_source_new();
+public static final int /*long*/ gtk_icon_source_new() {
+	lock.lock();
+	try {
+		return _gtk_icon_source_new();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_icon_source_set_pixbuf(int /*long*/ source, int /*long*/ pixbuf);
+public static final void gtk_icon_source_set_pixbuf(int /*long*/ source, int /*long*/ pixbuf) {
+	lock.lock();
+	try {
+		_gtk_icon_source_set_pixbuf(source, pixbuf);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_icon_set_render_icon(int /*long*/ icon_set, int /*long*/ style, int direction, int state, int size, int /*long*/ widget, int /*long*/ detail);
+public static final int /*long*/ gtk_icon_set_render_icon(int /*long*/ icon_set, int /*long*/ style, int direction, int state, int size, int /*long*/ widget, int /*long*/ detail) {
+	lock.lock();
+	try {
+		return _gtk_icon_set_render_icon(icon_set, style, direction, state, size, widget, detail);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _gtk_im_context_filter_keypress(int /*long*/ context, int /*long*/ event);
+public static final boolean gtk_im_context_filter_keypress(int /*long*/ context, int /*long*/ event) {
+	lock.lock();
+	try {
+		return _gtk_im_context_filter_keypress(context, event);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_im_context_focus_in(int /*long*/ context);
+public static final void gtk_im_context_focus_in(int /*long*/ context) {
+	lock.lock();
+	try {
+		_gtk_im_context_focus_in(context);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_im_context_focus_out(int /*long*/ context);
+public static final void gtk_im_context_focus_out(int /*long*/ context) {
+	lock.lock();
+	try {
+		_gtk_im_context_focus_out(context);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_im_context_get_preedit_string(int /*long*/ context, int /*long*/[] str, int /*long*/[] attrs, int[] cursor_pos);
+public static final void gtk_im_context_get_preedit_string(int /*long*/ context, int /*long*/[] str, int /*long*/[] attrs, int[] cursor_pos) {
+	lock.lock();
+	try {
+		_gtk_im_context_get_preedit_string(context, str, attrs, cursor_pos);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_im_context_get_type();
+public static final int /*long*/ gtk_im_context_get_type() {
+	lock.lock();
+	try {
+		return _gtk_im_context_get_type();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_im_context_reset(int /*long*/ context);
+public static final void gtk_im_context_reset(int /*long*/ context) {
+	lock.lock();
+	try {
+		_gtk_im_context_reset(context);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_im_context_set_client_window(int /*long*/ context, int /*long*/ window);
+public static final void gtk_im_context_set_client_window(int /*long*/ context, int /*long*/ window) {
+	lock.lock();
+	try {
+		_gtk_im_context_set_client_window(context, window);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_im_context_set_cursor_location(int /*long*/ context, GdkRectangle area);
+public static final void gtk_im_context_set_cursor_location(int /*long*/ context, GdkRectangle area) {
+	lock.lock();
+	try {
+		_gtk_im_context_set_cursor_location(context, area);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_im_multicontext_append_menuitems (int /*long*/ context, int /*long*/ menushell);
+public static final void gtk_im_multicontext_append_menuitems (int /*long*/ context, int /*long*/ menushell) {
+	lock.lock();
+	try {
+		_gtk_im_multicontext_append_menuitems(context, menushell);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_im_multicontext_new();
+public static final int /*long*/ gtk_im_multicontext_new() {
+	lock.lock();
+	try {
+		return _gtk_im_multicontext_new();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_image_menu_item_new_with_label(byte[] label);
+public static final int /*long*/ gtk_image_menu_item_new_with_label(byte[] label) {
+	lock.lock();
+	try {
+		return _gtk_image_menu_item_new_with_label(label);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_image_menu_item_set_image(int /*long*/ menu_item, int /*long*/ image);
+public static final void gtk_image_menu_item_set_image(int /*long*/ menu_item, int /*long*/ image) {
+	lock.lock();
+	try {
+		_gtk_image_menu_item_set_image(menu_item, image);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_image_new();
+public static final int /*long*/ gtk_image_new() {
+	lock.lock();
+	try {
+		return _gtk_image_new();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_image_new_from_pixbuf(int /*long*/ pixbuf); 
+public static final int /*long*/ gtk_image_new_from_pixbuf(int /*long*/ pixbuf) {
+	lock.lock();
+	try {
+		return _gtk_image_new_from_pixbuf(pixbuf);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_image_new_from_pixmap(int /*long*/ pixmap, int /*long*/ mask);
+public static final int /*long*/ gtk_image_new_from_pixmap(int /*long*/ pixmap, int /*long*/ mask) {
+	lock.lock();
+	try {
+		return _gtk_image_new_from_pixmap(pixmap, mask);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_image_set_from_pixbuf(int /*long*/ image, int /*long*/ pixbuf);
+public static final void gtk_image_set_from_pixbuf(int /*long*/ image, int /*long*/ pixbuf) {
+	lock.lock();
+	try {
+		_gtk_image_set_from_pixbuf(image, pixbuf);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_image_set_from_pixmap(int /*long*/ image, int /*long*/ pixmap, int /*long*/ mask);
+public static final void gtk_image_set_from_pixmap(int /*long*/ image, int /*long*/ pixmap, int /*long*/ mask) {
+	lock.lock();
+	try {
+		_gtk_image_set_from_pixmap(image, pixmap, mask);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _gtk_init_check(int /*long*/[] argc, int /*long*/[] argv);
+public static final boolean gtk_init_check(int /*long*/[] argc, int /*long*/[] argv) {
+	lock.lock();
+	try {
+		return _gtk_init_check(argc, argv);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_label_get_layout(int /*long*/ label);
+public static final int /*long*/ gtk_label_get_layout(int /*long*/ label) {
+	lock.lock();
+	try {
+		return _gtk_label_get_layout(label);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _gtk_label_get_mnemonic_keyval(int /*long*/ label);
+public static final int gtk_label_get_mnemonic_keyval(int /*long*/ label) {
+	lock.lock();
+	try {
+		return _gtk_label_get_mnemonic_keyval(label);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_label_new(byte[] label);
+public static final int /*long*/ gtk_label_new(byte[] label) {
+	lock.lock();
+	try {
+		return _gtk_label_new(label);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_label_new_with_mnemonic(byte[] str);
+public static final int /*long*/ gtk_label_new_with_mnemonic(byte[] str) {
+	lock.lock();
+	try {
+		return _gtk_label_new_with_mnemonic(str);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_label_set_attributes(int /*long*/ label, int /*long*/ attrs);
+public static final void gtk_label_set_attributes(int /*long*/ label, int /*long*/ attrs) {
+	lock.lock();
+	try {
+		_gtk_label_set_attributes(label, attrs);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_label_set_justify(int /*long*/ label, int jtype);
+public static final void gtk_label_set_justify(int /*long*/ label, int jtype) {
+	lock.lock();
+	try {
+		_gtk_label_set_justify(label, jtype);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_label_set_line_wrap(int /*long*/ label, boolean wrap);
+public static final void gtk_label_set_line_wrap(int /*long*/ label, boolean wrap) {
+	lock.lock();
+	try {
+		_gtk_label_set_line_wrap(label, wrap);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_label_set_line_wrap_mode(int /*long*/ label, int wrap_mode);
+public static final void gtk_label_set_line_wrap_mode(int /*long*/ label, int wrap_mode) {
+	lock.lock();
+	try {
+		_gtk_label_set_line_wrap_mode(label, wrap_mode);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_label_set_text(int /*long*/ label, int /*long*/ str);
+public static final void gtk_label_set_text(int /*long*/ label, int /*long*/ str) {
+	lock.lock();
+	try {
+		_gtk_label_set_text(label, str);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_label_set_text(int /*long*/ label, byte[] str);
+public static final void gtk_label_set_text(int /*long*/ label, byte[] str) {
+	lock.lock();
+	try {
+		_gtk_label_set_text(label, str);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_label_set_text_with_mnemonic(int /*long*/ label, byte[] str);
+public static final void gtk_label_set_text_with_mnemonic(int /*long*/ label, byte[] str) {
+	lock.lock();
+	try {
+		_gtk_label_set_text_with_mnemonic(label, str);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_list_append_items(int /*long*/ list, int /*long*/ items);
+public static final void gtk_list_append_items(int /*long*/ list, int /*long*/ items) {
+	lock.lock();
+	try {
+		_gtk_list_append_items(list, items);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_list_clear_items(int /*long*/ list, int start, int end);
+public static final void gtk_list_clear_items(int /*long*/ list, int start, int end) {
+	lock.lock();
+	try {
+		_gtk_list_clear_items(list, start, end);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_list_insert_items(int /*long*/ list, int /*long*/ items, int position);
+public static final void gtk_list_insert_items(int /*long*/ list, int /*long*/ items, int position) {
+	lock.lock();
+	try {
+		_gtk_list_insert_items(list, items, position);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_list_item_new_with_label(byte[] label);
+public static final int /*long*/ gtk_list_item_new_with_label(byte[] label) {
+	lock.lock();
+	try {
+		return _gtk_list_item_new_with_label(label);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_list_remove_items(int /*long*/ list, int /*long*/ items);
+public static final void gtk_list_remove_items(int /*long*/ list, int /*long*/ items) {
+	lock.lock();
+	try {
+		_gtk_list_remove_items(list, items);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_list_select_item(int /*long*/ list, int item);
+public static final void gtk_list_select_item(int /*long*/ list, int item) {
+	lock.lock();
+	try {
+		_gtk_list_select_item(list, item);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_list_unselect_all(int /*long*/ list);
+public static final void gtk_list_unselect_all(int /*long*/ list) {
+	lock.lock();
+	try {
+		_gtk_list_unselect_all(list);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_list_unselect_item(int /*long*/ list, int item);
+public static final void gtk_list_unselect_item(int /*long*/ list, int item) {
+	lock.lock();
+	try {
+		_gtk_list_unselect_item(list, item);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_list_store_append(int /*long*/ list_store, int /*long*/ iter);
+public static final void gtk_list_store_append(int /*long*/ list_store, int /*long*/ iter) {
+	lock.lock();
+	try {
+		_gtk_list_store_append(list_store, iter);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_list_store_clear(int /*long*/ store);
+public static final void gtk_list_store_clear(int /*long*/ store) {
+	lock.lock();
+	try {
+		_gtk_list_store_clear(store);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_list_store_insert(int /*long*/ list_store, int /*long*/ iter, int position);
+public static final void gtk_list_store_insert(int /*long*/ list_store, int /*long*/ iter, int position) {
+	lock.lock();
+	try {
+		_gtk_list_store_insert(list_store, iter, position);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_list_store_newv(int numColumns, int /*long*/[] types);
+public static final int /*long*/ gtk_list_store_newv(int numColumns, int /*long*/[] types) {
+	lock.lock();
+	try {
+		return _gtk_list_store_newv(numColumns, types);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_list_store_remove(int /*long*/ list_store, int /*long*/ iter);
+public static final void gtk_list_store_remove(int /*long*/ list_store, int /*long*/ iter) {
+	lock.lock();
+	try {
+		_gtk_list_store_remove(list_store, iter);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_list_store_set(int /*long*/ store, int /*long*/ iter, int column, byte[] value, int /*long*/ terminator);
+public static final void gtk_list_store_set(int /*long*/ store, int /*long*/ iter, int column, byte[] value, int /*long*/ terminator) {
+	lock.lock();
+	try {
+		_gtk_list_store_set(store, iter, column, value, terminator);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_list_store_set(int /*long*/ store, int /*long*/ iter, int column, int value, int /*long*/ terminator);
+public static final void gtk_list_store_set(int /*long*/ store, int /*long*/ iter, int column, int value, int /*long*/ terminator) {
+	lock.lock();
+	try {
+		_gtk_list_store_set(store, iter, column, value, terminator);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_list_store_set(int /*long*/ store, int /*long*/ iter, int column, long value, int /*long*/ terminator);
+public static final void gtk_list_store_set(int /*long*/ store, int /*long*/ iter, int column, long value, int /*long*/ terminator) {
+	lock.lock();
+	try {
+		_gtk_list_store_set(store, iter, column, value, terminator);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_list_store_set(int /*long*/ store, int /*long*/ iter, int column, GdkColor value, int /*long*/ terminator);
+public static final void gtk_list_store_set(int /*long*/ store, int /*long*/ iter, int column, GdkColor value, int /*long*/ terminator) {
+	lock.lock();
+	try {
+		_gtk_list_store_set(store, iter, column, value, terminator);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_list_store_set(int /*long*/ store, int /*long*/ iter, int column, boolean value, int /*long*/ terminator);
+public static final void gtk_list_store_set(int /*long*/ store, int /*long*/ iter, int column, boolean value, int /*long*/ terminator) {
+	lock.lock();
+	try {
+		_gtk_list_store_set(store, iter, column, value, terminator);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _gtk_major_version();
+public static final int gtk_major_version() {
+	lock.lock();
+	try {
+		return _gtk_major_version();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _gtk_minor_version();
+public static final int gtk_minor_version() {
+	lock.lock();
+	try {
+		return _gtk_minor_version();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _gtk_micro_version();
+public static final int gtk_micro_version() {
+	lock.lock();
+	try {
+		return _gtk_micro_version();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_main();
+public static final void gtk_main() {
+	lock.lock();
+	try {
+		_gtk_main();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _gtk_main_iteration();
+public static final int gtk_main_iteration() {
+	lock.lock();
+	try {
+		return _gtk_main_iteration();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_main_do_event(int /*long*/ event);
+public static final void gtk_main_do_event(int /*long*/ event) {
+	lock.lock();
+	try {
+		_gtk_main_do_event(event);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_menu_bar_new();
+public static final int /*long*/ gtk_menu_bar_new() {
+	lock.lock();
+	try {
+		return _gtk_menu_bar_new();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_menu_item_remove_submenu(int /*long*/ menu_item);
+public static final void gtk_menu_item_remove_submenu(int /*long*/ menu_item) {
+	lock.lock();
+	try {
+		_gtk_menu_item_remove_submenu(menu_item);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_menu_item_get_submenu(int /*long*/ menu_item);
+public static final int /*long*/ gtk_menu_item_get_submenu(int /*long*/ menu_item) {
+	lock.lock();
+	try {
+		return _gtk_menu_item_get_submenu(menu_item);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_menu_item_set_submenu(int /*long*/ menu_item, int /*long*/ submenu);
+public static final void gtk_menu_item_set_submenu(int /*long*/ menu_item, int /*long*/ submenu) {
+	lock.lock();
+	try {
+		_gtk_menu_item_set_submenu(menu_item, submenu);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_menu_new();
+public static final int /*long*/ gtk_menu_new() {
+	lock.lock();
+	try {
+		return _gtk_menu_new();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_menu_popdown(int /*long*/ menu);
+public static final void gtk_menu_popdown(int /*long*/ menu) {
+	lock.lock();
+	try {
+		_gtk_menu_popdown(menu);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_menu_popup(int /*long*/ menu, int /*long*/ parent_menu_shell, int /*long*/ parent_menu_item, int /*long*/ func, int /*long*/ data, int button, int activate_time);
+public static final void gtk_menu_popup(int /*long*/ menu, int /*long*/ parent_menu_shell, int /*long*/ parent_menu_item, int /*long*/ func, int /*long*/ data, int button, int activate_time) {
+	lock.lock();
+	try {
+		_gtk_menu_popup(menu, parent_menu_shell, parent_menu_item, func, data, button, activate_time);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_menu_shell_deactivate(int /*long*/ menu_shell);
+public static final void gtk_menu_shell_deactivate(int /*long*/ menu_shell) {
+	lock.lock();
+	try {
+		_gtk_menu_shell_deactivate(menu_shell);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_menu_shell_insert(int /*long*/ menu_shell, int /*long*/ child, int position);
+public static final void gtk_menu_shell_insert(int /*long*/ menu_shell, int /*long*/ child, int position) {
+	lock.lock();
+	try {
+		_gtk_menu_shell_insert(menu_shell, child, position);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_menu_shell_select_item(int /*long*/ menu_shell, int /*long*/ menu_item);
+public static final void gtk_menu_shell_select_item(int /*long*/ menu_shell, int /*long*/ menu_item) {
+	lock.lock();
+	try {
+		_gtk_menu_shell_select_item(menu_shell, menu_item);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_menu_shell_set_take_focus(int /*long*/ menu_shell, boolean take_focus);
+public static final void gtk_menu_shell_set_take_focus(int /*long*/ menu_shell, boolean take_focus) {
+	lock.lock();
+	try {
+		_gtk_menu_shell_set_take_focus(menu_shell, take_focus);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_message_dialog_new(int /*long*/ parent, int flags, int type, int buttons, byte[] message_format);
+public static final int /*long*/ gtk_message_dialog_new(int /*long*/ parent, int flags, int type, int buttons, byte[] message_format) {
+	lock.lock();
+	try {
+		return _gtk_message_dialog_new(parent, flags, type, buttons, message_format);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_misc_set_alignment(int /*long*/ misc, float xalign, float yalign);
+public static final void gtk_misc_set_alignment(int /*long*/ misc, float xalign, float yalign) {
+	lock.lock();
+	try {
+		_gtk_misc_set_alignment(misc, xalign, yalign);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _gtk_notebook_get_current_page(int /*long*/ notebook);
+public static final int gtk_notebook_get_current_page(int /*long*/ notebook) {
+	lock.lock();
+	try {
+		return _gtk_notebook_get_current_page(notebook);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _gtk_notebook_get_scrollable(int /*long*/ notebook);
+public static final boolean gtk_notebook_get_scrollable(int /*long*/ notebook) {
+	lock.lock();
+	try {
+		return _gtk_notebook_get_scrollable(notebook);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_notebook_insert_page(int /*long*/ notebook, int /*long*/ child, int /*long*/ tab_label, int position);
+public static final void gtk_notebook_insert_page(int /*long*/ notebook, int /*long*/ child, int /*long*/ tab_label, int position) {
+	lock.lock();
+	try {
+		_gtk_notebook_insert_page(notebook, child, tab_label, position);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_notebook_new();
+public static final int /*long*/ gtk_notebook_new() {
+	lock.lock();
+	try {
+		return _gtk_notebook_new();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_notebook_next_page(int /*long*/ notebook);
+public static final void gtk_notebook_next_page(int /*long*/ notebook) {
+	lock.lock();
+	try {
+		_gtk_notebook_next_page(notebook);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_notebook_prev_page(int /*long*/ notebook);
+public static final void gtk_notebook_prev_page(int /*long*/ notebook) {
+	lock.lock();
+	try {
+		_gtk_notebook_prev_page(notebook);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_notebook_remove_page(int /*long*/ notebook, int page_num);
+public static final void gtk_notebook_remove_page(int /*long*/ notebook, int page_num) {
+	lock.lock();
+	try {
+		_gtk_notebook_remove_page(notebook, page_num);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_notebook_set_current_page(int /*long*/ notebook, int page_num);
+public static final void gtk_notebook_set_current_page(int /*long*/ notebook, int page_num) {
+	lock.lock();
+	try {
+		_gtk_notebook_set_current_page(notebook, page_num);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_notebook_set_scrollable(int /*long*/ notebook, boolean scrollable);
+public static final void gtk_notebook_set_scrollable(int /*long*/ notebook, boolean scrollable) {
+	lock.lock();
+	try {
+		_gtk_notebook_set_scrollable(notebook, scrollable);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_notebook_set_show_tabs(int /*long*/ notebook, boolean show_tabs);
+public static final void gtk_notebook_set_show_tabs(int /*long*/ notebook, boolean show_tabs) {
+	lock.lock();
+	try {
+		_gtk_notebook_set_show_tabs(notebook, show_tabs);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_notebook_set_tab_pos(int /*long*/ notebook, int pos);
+public static final void gtk_notebook_set_tab_pos(int /*long*/ notebook, int pos) {
+	lock.lock();
+	try {
+		_gtk_notebook_set_tab_pos(notebook, pos);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_object_sink(int /*long*/ object);
+public static final void gtk_object_sink(int /*long*/ object) {
+	lock.lock();
+	try {
+		_gtk_object_sink(object);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_page_setup_new ();
+public static final int /*long*/ gtk_page_setup_new () {
+	lock.lock();
+	try {
+		return _gtk_page_setup_new ();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _gtk_page_setup_get_orientation(int /*long*/ setup);
+public static final int gtk_page_setup_get_orientation(int /*long*/ setup) {
+	lock.lock();
+	try {
+		return _gtk_page_setup_get_orientation(setup);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_page_setup_set_orientation(int /*long*/ setup, int orientation);
+public static final void gtk_page_setup_set_orientation(int /*long*/ setup, int orientation) {
+	lock.lock();
+	try {
+		_gtk_page_setup_set_orientation(setup, orientation);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_page_setup_get_paper_size(int /*long*/ setup);
+public static final int /*long*/ gtk_page_setup_get_paper_size(int /*long*/ setup) {
+	lock.lock();
+	try {
+		return _gtk_page_setup_get_paper_size(setup);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_page_setup_set_paper_size(int /*long*/ setup, int /*long*/ size);
+public static final void gtk_page_setup_set_paper_size(int /*long*/ setup, int /*long*/ size) {
+	lock.lock();
+	try {
+		_gtk_page_setup_set_paper_size(setup, size);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native double _gtk_page_setup_get_top_margin(int /*long*/ setup, int unit);
+public static final double gtk_page_setup_get_top_margin(int /*long*/ setup, int unit) {
+	lock.lock();
+	try {
+		return _gtk_page_setup_get_top_margin(setup, unit);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_page_setup_set_top_margin(int /*long*/ setup, double margin, int unit);
+public static final void gtk_page_setup_set_top_margin(int /*long*/ setup, double margin, int unit) {
+	lock.lock();
+	try {
+		_gtk_page_setup_set_top_margin(setup, margin, unit);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native double _gtk_page_setup_get_bottom_margin(int /*long*/ setup, int unit);
+public static final double gtk_page_setup_get_bottom_margin(int /*long*/ setup, int unit) {
+	lock.lock();
+	try {
+		return _gtk_page_setup_get_bottom_margin(setup, unit);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_page_setup_set_bottom_margin(int /*long*/ setup, double margin, int unit);
+public static final void gtk_page_setup_set_bottom_margin(int /*long*/ setup, double margin, int unit) {
+	lock.lock();
+	try {
+		_gtk_page_setup_set_bottom_margin(setup, margin, unit);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native double _gtk_page_setup_get_left_margin(int /*long*/ setup, int unit);
+public static final double gtk_page_setup_get_left_margin(int /*long*/ setup, int unit) {
+	lock.lock();
+	try {
+		return _gtk_page_setup_get_left_margin(setup, unit);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_page_setup_set_left_margin(int /*long*/ setup, double margin, int unit);
+public static final void gtk_page_setup_set_left_margin(int /*long*/ setup, double margin, int unit) {
+	lock.lock();
+	try {
+		_gtk_page_setup_set_left_margin(setup, margin, unit);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native double _gtk_page_setup_get_right_margin(int /*long*/ setup, int unit);
+public static final double gtk_page_setup_get_right_margin(int /*long*/ setup, int unit) {
+	lock.lock();
+	try {
+		return _gtk_page_setup_get_right_margin(setup, unit);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_page_setup_set_right_margin(int /*long*/ setup, double margin, int unit);
+public static final void gtk_page_setup_set_right_margin(int /*long*/ setup, double margin, int unit) {
+	lock.lock();
+	try {
+		_gtk_page_setup_set_right_margin(setup, margin, unit);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native double _gtk_page_setup_get_paper_width(int /*long*/ setup, int unit);
+public static final double gtk_page_setup_get_paper_width(int /*long*/ setup, int unit) {
+	lock.lock();
+	try {
+		return _gtk_page_setup_get_paper_width(setup, unit);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native double _gtk_page_setup_get_paper_height(int /*long*/ setup, int unit);
+public static final double gtk_page_setup_get_paper_height(int /*long*/ setup, int unit) {
+	lock.lock();
+	try {
+		return _gtk_page_setup_get_paper_height(setup, unit);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native double _gtk_page_setup_get_page_width(int /*long*/ setup, int unit);
+public static final double gtk_page_setup_get_page_width(int /*long*/ setup, int unit) {
+	lock.lock();
+	try {
+		return _gtk_page_setup_get_page_width(setup, unit);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native double _gtk_page_setup_get_page_height(int /*long*/ setup, int unit);
+public static final double gtk_page_setup_get_page_height(int /*long*/ setup, int unit) {
+	lock.lock();
+	try {
+		return _gtk_page_setup_get_page_height(setup, unit);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_paint_handle(int /*long*/ style, int /*long*/ window, int state_type, int shadow_type, GdkRectangle area, int /*long*/ widget, byte[] detail, int x , int y, int width, int height, int orientation);
+public static final void gtk_paint_handle(int /*long*/ style, int /*long*/ window, int state_type, int shadow_type, GdkRectangle area, int /*long*/ widget, byte[] detail, int x , int y, int width, int height, int orientation) {
+	lock.lock();
+	try {
+		_gtk_paint_handle(style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, orientation);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_paint_flat_box(int /*long*/ style, int /*long*/ window, int state_type, int shadow_type, GdkRectangle area, int /*long*/ widget, byte[] detail, int x , int y, int width, int height);
+public static final void gtk_paint_flat_box(int /*long*/ style, int /*long*/ window, int state_type, int shadow_type, GdkRectangle area, int /*long*/ widget, byte[] detail, int x , int y, int width, int height) {
+	lock.lock();
+	try {
+		_gtk_paint_flat_box(style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_paint_focus(int /*long*/ style, int /*long*/ window, int state_type, GdkRectangle area, int /*long*/ widget, byte[] detail, int x , int y, int width, int height);
+public static final void gtk_paint_focus(int /*long*/ style, int /*long*/ window, int state_type, GdkRectangle area, int /*long*/ widget, byte[] detail, int x , int y, int width, int height) {
+	lock.lock();
+	try {
+		_gtk_paint_focus(style, window, state_type, area, widget, detail, x, y, width, height);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_paint_option(int /*long*/ style, int /*long*/ window, int state_type, int shadow_type, GdkRectangle area, int /*long*/ widget, byte[] detail, int x , int y, int width, int height);
+public static final void gtk_paint_option(int /*long*/ style, int /*long*/ window, int state_type, int shadow_type, GdkRectangle area, int /*long*/ widget, byte[] detail, int x , int y, int width, int height) {
+	lock.lock();
+	try {
+		_gtk_paint_option(style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_paint_slider(int /*long*/ style, int /*long*/ window, int state_type, int shadow_type, GdkRectangle area, int /*long*/ widget, byte[] detail, int x , int y, int width, int height, int orientation);
+public static final void gtk_paint_slider(int /*long*/ style, int /*long*/ window, int state_type, int shadow_type, GdkRectangle area, int /*long*/ widget, byte[] detail, int x , int y, int width, int height, int orientation) {
+	lock.lock();
+	try {
+		_gtk_paint_slider(style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, orientation);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_paint_tab(int /*long*/ style, int /*long*/ window, int state_type, int shadow_type, GdkRectangle area, int /*long*/ widget, byte[] detail, int x , int y, int width, int height);
+public static final void gtk_paint_tab(int /*long*/ style, int /*long*/ window, int state_type, int shadow_type, GdkRectangle area, int /*long*/ widget, byte[] detail, int x , int y, int width, int height) {
+	lock.lock();
+	try {
+		_gtk_paint_tab(style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_paint_arrow(int /*long*/ style, int /*long*/ window, int state_type, int shadow_type, GdkRectangle area, int /*long*/ widget, byte[] detail, int arrow_type, boolean fill, int x, int y, int width, int height);
+public static final void gtk_paint_arrow(int /*long*/ style, int /*long*/ window, int state_type, int shadow_type, GdkRectangle area, int /*long*/ widget, byte[] detail, int arrow_type, boolean fill, int x, int y, int width, int height) {
+	lock.lock();
+	try {
+		_gtk_paint_arrow(style, window, state_type, shadow_type, area, widget, detail, arrow_type, fill, x, y, width, height);
+	} finally {
+		lock.unlock();
+	}
+}
+
+public static final native void _gtk_paint_box(int /*long*/ style, int /*long*/ window, int state_type, int shadow_type, GdkRectangle area, int /*long*/ widget, byte[] detail, int x , int y, int width, int height);
+public static final void gtk_paint_box(int /*long*/ style, int /*long*/ window, int state_type, int shadow_type, GdkRectangle area, int /*long*/ widget, byte[] detail, int x , int y, int width, int height) {
+	lock.lock();
+	try {
+		_gtk_paint_box(style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_paint_box_gap(int /*long*/ style, int /*long*/ window, int state_type, int shadow_type, GdkRectangle area, int /*long*/ widget, byte[] detail, int x , int y, int width, int height, int gap_side, int gap_x, int gap_width);
+public static final void gtk_paint_box_gap(int /*long*/ style, int /*long*/ window, int state_type, int shadow_type, GdkRectangle area, int /*long*/ widget, byte[] detail, int x , int y, int width, int height, int gap_side, int gap_x, int gap_width) {
+	lock.lock();
+	try {
+		_gtk_paint_box_gap(style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, gap_side, gap_x, gap_width);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_paint_check(int /*long*/ style, int /*long*/ window, int state_type, int shadow_type, GdkRectangle area, int /*long*/ widget, byte[] detail, int x , int y, int width, int height);
+public static final void gtk_paint_check(int /*long*/ style, int /*long*/ window, int state_type, int shadow_type, GdkRectangle area, int /*long*/ widget, byte[] detail, int x , int y, int width, int height) {
+	lock.lock();
+	try {
+		_gtk_paint_check(style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_paint_expander(int /*long*/ style, int /*long*/ window, int state_type, GdkRectangle area, int /*long*/ widget, byte[] detail, int x , int y, int expander_style);
+public static final void gtk_paint_expander(int /*long*/ style, int /*long*/ window, int state_type, GdkRectangle area, int /*long*/ widget, byte[] detail, int x , int y, int expander_style) {
+	lock.lock();
+	try {
+		_gtk_paint_expander(style, window, state_type, area, widget, detail, x, y, expander_style);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_paint_extension(int /*long*/ style, int /*long*/ window, int state_type, int shadow_type, GdkRectangle area, int /*long*/ widget, byte[] detail, int x , int y, int width, int height, int gap_side);
+public static final void gtk_paint_extension(int /*long*/ style, int /*long*/ window, int state_type, int shadow_type, GdkRectangle area, int /*long*/ widget, byte[] detail, int x , int y, int width, int height, int gap_side) {
+	lock.lock();
+	try {
+		_gtk_paint_extension(style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, gap_side);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_paint_hline(int /*long*/ style, int /*long*/ window, int state_type, GdkRectangle area, int /*long*/ widget, byte[] detail, int x1 , int x2, int y);
+public static final void gtk_paint_hline(int /*long*/ style, int /*long*/ window, int state_type, GdkRectangle area, int /*long*/ widget, byte[] detail, int x1 , int x2, int y) {
+	lock.lock();
+	try {
+		_gtk_paint_hline(style, window, state_type, area, widget, detail, x1, x2, y);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_paint_layout(int /*long*/ style, int /*long*/ window, int state_type, boolean use_text, GdkRectangle area, int /*long*/ widget, byte[] detail, int x , int y, int /*long*/ layout);
+public static final void gtk_paint_layout(int /*long*/ style, int /*long*/ window, int state_type, boolean use_text, GdkRectangle area, int /*long*/ widget, byte[] detail, int x , int y, int /*long*/ layout) {
+	lock.lock();
+	try {
+		_gtk_paint_layout(style, window, state_type, use_text, area, widget, detail, x, y, layout);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_paint_shadow_gap(int /*long*/ style, int /*long*/ window, int state_type, int shadow_type, GdkRectangle area, int /*long*/ widget, byte[] detail, int x , int y, int width, int height, int gap_side, int gap_x, int gap_width);
+public static final void gtk_paint_shadow_gap(int /*long*/ style, int /*long*/ window, int state_type, int shadow_type, GdkRectangle area, int /*long*/ widget, byte[] detail, int x , int y, int width, int height, int gap_side, int gap_x, int gap_width) {
+	lock.lock();
+	try {
+		_gtk_paint_shadow_gap(style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, gap_side, gap_x, gap_width);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_paint_shadow(int /*long*/ style, int /*long*/ window, int state_type, int shadow_type, GdkRectangle area, int /*long*/ widget, byte[] detail, int x , int y, int width, int height);
+public static final void gtk_paint_shadow(int /*long*/ style, int /*long*/ window, int state_type, int shadow_type, GdkRectangle area, int /*long*/ widget, byte[] detail, int x , int y, int width, int height) {
+	lock.lock();
+	try {
+		_gtk_paint_shadow(style, window, state_type, shadow_type, area, widget, detail, x, y, width, height);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_paint_vline(int /*long*/ style, int /*long*/ window, int state_type, GdkRectangle area, int /*long*/ widget, byte[] detail, int y1 , int y2, int x);
+public static final void gtk_paint_vline(int /*long*/ style, int /*long*/ window, int state_type, GdkRectangle area, int /*long*/ widget, byte[] detail, int y1 , int y2, int x) {
+	lock.lock();
+	try {
+		_gtk_paint_vline(style, window, state_type, area, widget, detail, y1, y2, x);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_paper_size_free(int /*long*/ size);
+public static final void gtk_paper_size_free(int /*long*/ size) {
+	lock.lock();
+	try {
+		_gtk_paper_size_free(size);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_paper_size_new(byte [] name);
+public static final int /*long*/ gtk_paper_size_new(byte [] name) {
+	lock.lock();
+	try {
+		return _gtk_paper_size_new(name);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_paper_size_new_from_ppd(byte [] ppd_name, byte [] ppd_display_name, double width, double height);
+public static final int /*long*/ gtk_paper_size_new_from_ppd(byte [] ppd_name, byte [] ppd_display_name, double width, double height) {
+	lock.lock();
+	try {
+		return _gtk_paper_size_new_from_ppd(ppd_name, ppd_display_name, width, height);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_paper_size_new_custom(byte [] name, byte [] display_name, double width, double height, int unit);
+public static final int /*long*/ gtk_paper_size_new_custom(byte [] name, byte [] display_name, double width, double height, int unit) {
+	lock.lock();
+	try {
+		return _gtk_paper_size_new_custom(name, display_name, width, height, unit);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_paper_size_get_name(int /*long*/ size);
+public static final int /*long*/ gtk_paper_size_get_name(int /*long*/ size) {
+	lock.lock();
+	try {
+		return _gtk_paper_size_get_name(size);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_paper_size_get_display_name(int /*long*/ size);
+public static final int /*long*/ gtk_paper_size_get_display_name(int /*long*/ size) {
+	lock.lock();
+	try {
+		return _gtk_paper_size_get_display_name(size);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_paper_size_get_ppd_name(int /*long*/ size);
+public static final int /*long*/ gtk_paper_size_get_ppd_name(int /*long*/ size) {
+	lock.lock();
+	try {
+		return _gtk_paper_size_get_ppd_name(size);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native double _gtk_paper_size_get_width(int /*long*/ size, int unit);
+public static final double gtk_paper_size_get_width(int /*long*/ size, int unit) {
+	lock.lock();
+	try {
+		return _gtk_paper_size_get_width(size, unit);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native double _gtk_paper_size_get_height(int /*long*/ size, int unit);
+public static final double gtk_paper_size_get_height(int /*long*/ size, int unit) {
+	lock.lock();
+	try {
+		return _gtk_paper_size_get_height(size, unit);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _gtk_paper_size_is_custom(int /*long*/ size);
+public static final boolean gtk_paper_size_is_custom(int /*long*/ size) {
+	lock.lock();
+	try {
+		return _gtk_paper_size_is_custom(size);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_plug_get_id(int /*long*/ plug);
+public static final int /*long*/ gtk_plug_get_id(int /*long*/ plug) {
+	lock.lock();
+	try {
+		return _gtk_plug_get_id(plug);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_plug_new(int /*long*/ socket_id);
+public static final int /*long*/ gtk_plug_new(int /*long*/ socket_id) {
+	lock.lock();
+	try {
+		return _gtk_plug_new(socket_id);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_printer_get_backend(int /*long*/ printer);
+public static final int /*long*/ gtk_printer_get_backend(int /*long*/ printer) {
+	lock.lock();
+	try {
+		return _gtk_printer_get_backend(printer);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_printer_get_name(int /*long*/ printer);
+public static final int /*long*/ gtk_printer_get_name(int /*long*/ printer) {
+	lock.lock();
+	try {
+		return _gtk_printer_get_name(printer);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _gtk_printer_is_default(int /*long*/ printer);
+public static final boolean gtk_printer_is_default(int /*long*/ printer) {
+	lock.lock();
+	try {
+		return _gtk_printer_is_default(printer);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_enumerate_printers(int /*long*/ func, int /*long*/data, int /*long*/ destroy, boolean wait);
+public static final void gtk_enumerate_printers(int /*long*/ func, int /*long*/data, int /*long*/ destroy, boolean wait) {
+	lock.lock();
+	try {
+		_gtk_enumerate_printers(func, data, destroy, wait);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_print_job_new(byte[] title, int /*long*/ printer, int /*long*/ settings, int /*long*/ page_setup);
+public static final int /*long*/ gtk_print_job_new(byte[] title, int /*long*/ printer, int /*long*/ settings, int /*long*/ page_setup) {
+	lock.lock();
+	try {
+		return _gtk_print_job_new(title, printer, settings, page_setup);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_print_job_get_settings(int /*long*/ job);
+public static final int /*long*/ gtk_print_job_get_settings(int /*long*/ job) {
+	lock.lock();
+	try {
+		return _gtk_print_job_get_settings(job);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_print_job_get_printer(int /*long*/ job);
+public static final int /*long*/ gtk_print_job_get_printer(int /*long*/ job) {
+	lock.lock();
+	try {
+		return _gtk_print_job_get_printer(job);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_print_job_get_title(int /*long*/ job);
+public static final int /*long*/ gtk_print_job_get_title(int /*long*/ job) {
+	lock.lock();
+	try {
+		return _gtk_print_job_get_title(job);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _gtk_print_job_get_status(int /*long*/ job);
+public static final int gtk_print_job_get_status(int /*long*/ job) {
+	lock.lock();
+	try {
+		return _gtk_print_job_get_status(job);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _gtk_print_job_set_source_file(int /*long*/ job, byte[] filename, int /*long*/ error[]);
+public static final boolean gtk_print_job_set_source_file(int /*long*/ job, byte[] filename, int /*long*/ error[]) {
+	lock.lock();
+	try {
+		return _gtk_print_job_set_source_file(job, filename, error);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_print_job_get_surface(int /*long*/ job, int /*long*/ error[]);
+public static final int /*long*/ gtk_print_job_get_surface(int /*long*/ job, int /*long*/ error[]) {
+	lock.lock();
+	try {
+		return _gtk_print_job_get_surface(job, error);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_print_job_send(int /*long*/ job, int /*long*/ callback, int /*long*/ user_data, int /*long*/ dnotify);
+public static final void gtk_print_job_send(int /*long*/ job, int /*long*/ callback, int /*long*/ user_data, int /*long*/ dnotify) {
+	lock.lock();
+	try {
+		_gtk_print_job_send(job, callback, user_data, dnotify);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_print_settings_new();
+public static final int /*long*/ gtk_print_settings_new() {
+	lock.lock();
+	try {
+		return _gtk_print_settings_new();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_print_settings_foreach(int /*long*/ settings, int /*long*/ func, int /*long*/ data);
+public static final void gtk_print_settings_foreach(int /*long*/ settings, int /*long*/ func, int /*long*/ data) {
+	lock.lock();
+	try {
+		_gtk_print_settings_foreach(settings, func, data);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_print_settings_get(int /*long*/ settings, byte [] key);
+public static final int /*long*/ gtk_print_settings_get(int /*long*/ settings, byte [] key) {
+	lock.lock();
+	try {
+		return _gtk_print_settings_get(settings, key);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_print_settings_set(int /*long*/ settings, byte [] key, byte [] value);
+public static final void gtk_print_settings_set(int /*long*/ settings, byte [] key, byte [] value) {
+	lock.lock();
+	try {
+		_gtk_print_settings_set(settings, key, value);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_print_settings_get_printer(int /*long*/ settings);
+public static final int /*long*/ gtk_print_settings_get_printer(int /*long*/ settings) {
+	lock.lock();
+	try {
+		return _gtk_print_settings_get_printer(settings);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_print_settings_set_printer(int /*long*/ settings, byte[] printer);
+public static final void gtk_print_settings_set_printer(int /*long*/ settings, byte[] printer) {
+	lock.lock();
+	try {
+		_gtk_print_settings_set_printer(settings, printer);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _gtk_print_settings_get_orientation(int /*long*/ settings);
+public static final int gtk_print_settings_get_orientation(int /*long*/ settings) {
+	lock.lock();
+	try {
+		return _gtk_print_settings_get_orientation(settings);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_print_settings_set_orientation(int /*long*/ settings, int orientation);
+public static final void gtk_print_settings_set_orientation(int /*long*/ settings, int orientation) {
+	lock.lock();
+	try {
+		_gtk_print_settings_set_orientation(settings, orientation);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _gtk_print_settings_get_collate(int /*long*/ settings);
+public static final boolean gtk_print_settings_get_collate(int /*long*/ settings) {
+	lock.lock();
+	try {
+		return _gtk_print_settings_get_collate(settings);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_print_settings_set_collate(int /*long*/ settings, boolean collate);
+public static final void gtk_print_settings_set_collate(int /*long*/ settings, boolean collate) {
+	lock.lock();
+	try {
+		_gtk_print_settings_set_collate(settings, collate);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _gtk_print_settings_get_n_copies(int /*long*/ settings);
+public static final int gtk_print_settings_get_n_copies(int /*long*/ settings) {
+	lock.lock();
+	try {
+		return _gtk_print_settings_get_n_copies(settings);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_print_settings_set_n_copies(int /*long*/ settings, int num_copies);
+public static final void gtk_print_settings_set_n_copies(int /*long*/ settings, int num_copies) {
+	lock.lock();
+	try {
+		_gtk_print_settings_set_n_copies(settings, num_copies);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _gtk_print_settings_get_print_pages(int /*long*/ settings);
+public static final int gtk_print_settings_get_print_pages(int /*long*/ settings) {
+	lock.lock();
+	try {
+		return _gtk_print_settings_get_print_pages(settings);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_print_settings_set_print_pages(int /*long*/ settings, int pages);
+public static final void gtk_print_settings_set_print_pages(int /*long*/ settings, int pages) {
+	lock.lock();
+	try {
+		_gtk_print_settings_set_print_pages(settings, pages);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_print_settings_get_page_ranges(int /*long*/ settings, int[] num_ranges);
+public static final int /*long*/ gtk_print_settings_get_page_ranges(int /*long*/ settings, int[] num_ranges) {
+	lock.lock();
+	try {
+		return _gtk_print_settings_get_page_ranges(settings, num_ranges);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_print_settings_set_page_ranges(int /*long*/ settings, int[] page_ranges, int num_ranges);
+public static final void gtk_print_settings_set_page_ranges(int /*long*/ settings, int[] page_ranges, int num_ranges) {
+	lock.lock();
+	try {
+		_gtk_print_settings_set_page_ranges(settings, page_ranges, num_ranges);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native double _gtk_print_settings_get_paper_width(int /*long*/ settings, int unit);
+public static final double gtk_print_settings_get_paper_width(int /*long*/ settings, int unit) {
+	lock.lock();
+	try {
+		return _gtk_print_settings_get_paper_width(settings, unit);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native double _gtk_print_settings_get_paper_height(int /*long*/ settings, int unit);
+public static final double gtk_print_settings_get_paper_height(int /*long*/ settings, int unit) {
+	lock.lock();
+	try {
+		return _gtk_print_settings_get_paper_height(settings, unit);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _gtk_print_settings_get_resolution(int /*long*/ settings);
+public static final int gtk_print_settings_get_resolution(int /*long*/ settings) {
+	lock.lock();
+	try {
+		return _gtk_print_settings_get_resolution(settings);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_print_unix_dialog_new(byte[] title, int /*long*/ parent);
+public static final int /*long*/ gtk_print_unix_dialog_new(byte[] title, int /*long*/ parent) {
+	lock.lock();
+	try {
+		return _gtk_print_unix_dialog_new(title, parent);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_print_unix_dialog_set_page_setup(int /*long*/ dialog, int /*long*/ page_setup);
+public static final void gtk_print_unix_dialog_set_page_setup(int /*long*/ dialog, int /*long*/ page_setup) {
+	lock.lock();
+	try {
+		_gtk_print_unix_dialog_set_page_setup(dialog, page_setup);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_print_unix_dialog_get_page_setup(int /*long*/ dialog);
+public static final int /*long*/ gtk_print_unix_dialog_get_page_setup(int /*long*/ dialog) {
+	lock.lock();
+	try {
+		return _gtk_print_unix_dialog_get_page_setup(dialog);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_print_unix_dialog_set_current_page(int /*long*/ dialog, int current_page);
+public static final void gtk_print_unix_dialog_set_current_page(int /*long*/ dialog, int current_page) {
+	lock.lock();
+	try {
+		_gtk_print_unix_dialog_set_current_page(dialog, current_page);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _gtk_print_unix_dialog_get_current_page(int /*long*/ dialog);
+public static final int gtk_print_unix_dialog_get_current_page(int /*long*/ dialog) {
+	lock.lock();
+	try {
+		return _gtk_print_unix_dialog_get_current_page(dialog);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_print_unix_dialog_set_settings(int /*long*/ dialog, int /*long*/ settings);
+public static final void gtk_print_unix_dialog_set_settings(int /*long*/ dialog, int /*long*/ settings) {
+	lock.lock();
+	try {
+		_gtk_print_unix_dialog_set_settings(dialog, settings);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_print_unix_dialog_get_settings(int /*long*/ dialog);
+public static final int /*long*/ gtk_print_unix_dialog_get_settings(int /*long*/ dialog) {
+	lock.lock();
+	try {
+		return _gtk_print_unix_dialog_get_settings(dialog);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_print_unix_dialog_get_selected_printer(int /*long*/ dialog);
+public static final int /*long*/ gtk_print_unix_dialog_get_selected_printer(int /*long*/ dialog) {
+	lock.lock();
+	try {
+		return _gtk_print_unix_dialog_get_selected_printer(dialog);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_print_unix_dialog_set_manual_capabilities(int /*long*/ dialog, int /*long*/ capabilities);
+public static final void gtk_print_unix_dialog_set_manual_capabilities(int /*long*/ dialog, int /*long*/ capabilities) {
+	lock.lock();
+	try {
+		_gtk_print_unix_dialog_set_manual_capabilities(dialog, capabilities);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_progress_bar_new();
+public static final int /*long*/ gtk_progress_bar_new() {
+	lock.lock();
+	try {
+		return _gtk_progress_bar_new();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_progress_bar_pulse(int /*long*/ pbar);
+public static final void gtk_progress_bar_pulse(int /*long*/ pbar) {
+	lock.lock();
+	try {
+		_gtk_progress_bar_pulse(pbar);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_progress_bar_set_fraction(int /*long*/ pbar, double fraction);
+public static final void gtk_progress_bar_set_fraction(int /*long*/ pbar, double fraction) {
+	lock.lock();
+	try {
+		_gtk_progress_bar_set_fraction(pbar, fraction);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_progress_bar_set_orientation(int /*long*/ pbar, int orientation);
+public static final void gtk_progress_bar_set_orientation(int /*long*/ pbar, int orientation) {
+	lock.lock();
+	try {
+		_gtk_progress_bar_set_orientation(pbar, orientation);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_radio_button_get_group(int /*long*/ radio_button);
+public static final int /*long*/ gtk_radio_button_get_group(int /*long*/ radio_button) {
+	lock.lock();
+	try {
+		return _gtk_radio_button_get_group(radio_button);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_radio_button_new(int /*long*/ group);
+public static final int /*long*/ gtk_radio_button_new(int /*long*/ group) {
+	lock.lock();
+	try {
+		return _gtk_radio_button_new(group);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_radio_menu_item_get_group(int /*long*/ radio_menu_item);
+public static final int /*long*/ gtk_radio_menu_item_get_group(int /*long*/ radio_menu_item) {
+	lock.lock();
+	try {
+		return _gtk_radio_menu_item_get_group(radio_menu_item);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_radio_menu_item_new(int /*long*/ group);
+public static final int /*long*/ gtk_radio_menu_item_new(int /*long*/ group) {
+	lock.lock();
+	try {
+		return _gtk_radio_menu_item_new(group);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_radio_menu_item_new_with_label(int /*long*/ group, byte[] label);
+public static final int /*long*/ gtk_radio_menu_item_new_with_label(int /*long*/ group, byte[] label) {
+	lock.lock();
+	try {
+		return _gtk_radio_menu_item_new_with_label(group, label);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_range_get_adjustment(int /*long*/ range);
+public static final int /*long*/ gtk_range_get_adjustment(int /*long*/ range) {
+	lock.lock();
+	try {
+		return _gtk_range_get_adjustment(range);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_range_set_increments(int /*long*/ range, double step, double page);
+public static final void gtk_range_set_increments(int /*long*/ range, double step, double page) {
+	lock.lock();
+	try {
+		_gtk_range_set_increments(range, step, page);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_range_set_inverted(int /*long*/ range, boolean setting);
+public static final void gtk_range_set_inverted(int /*long*/ range, boolean setting) {
+	lock.lock();
+	try {
+		_gtk_range_set_inverted(range, setting);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_range_set_range(int /*long*/ range, double min, double max);
+public static final void gtk_range_set_range(int /*long*/ range, double min, double max) {
+	lock.lock();
+	try {
+		_gtk_range_set_range(range, min, max);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_range_set_value(int /*long*/ range, double value);
+public static final void gtk_range_set_value(int /*long*/ range, double value) {
+	lock.lock();
+	try {
+		_gtk_range_set_value(range, value);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_rc_parse_string(byte[] rc_string);
+public static final void gtk_rc_parse_string(byte[] rc_string) {
+	lock.lock();
+	try {
+		_gtk_rc_parse_string(rc_string);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_rc_style_get_bg_pixmap_name(int /*long*/ style, int index);
+public static final int /*long*/ gtk_rc_style_get_bg_pixmap_name(int /*long*/ style, int index) {
+	lock.lock();
+	try {
+		return _gtk_rc_style_get_bg_pixmap_name(style, index);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _gtk_rc_style_get_color_flags(int /*long*/ style, int index);
+public static final int gtk_rc_style_get_color_flags(int /*long*/ style, int index) {
+	lock.lock();
+	try {
+		return _gtk_rc_style_get_color_flags(style, index);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_rc_style_set_bg(int /*long*/ style, int index, GdkColor color);
+public static final void gtk_rc_style_set_bg(int /*long*/ style, int index, GdkColor color) {
+	lock.lock();
+	try {
+		_gtk_rc_style_set_bg(style, index, color);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_rc_style_set_bg_pixmap_name(int /*long*/ style, int index, int /*long*/ name);
+public static final void gtk_rc_style_set_bg_pixmap_name(int /*long*/ style, int index, int /*long*/ name) {
+	lock.lock();
+	try {
+		_gtk_rc_style_set_bg_pixmap_name(style, index, name);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_rc_style_set_color_flags(int /*long*/ style, int index, int flag);
+public static final void gtk_rc_style_set_color_flags(int /*long*/ style, int index, int flag) {
+	lock.lock();
+	try {
+		_gtk_rc_style_set_color_flags(style, index, flag);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_scale_set_digits(int /*long*/ scale, int digits);
+public static final void gtk_scale_set_digits(int /*long*/ scale, int digits) {
+	lock.lock();
+	try {
+		_gtk_scale_set_digits(scale, digits);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_scale_set_draw_value(int /*long*/ scale, boolean draw_value);
+public static final void gtk_scale_set_draw_value(int /*long*/ scale, boolean draw_value) {
+	lock.lock();
+	try {
+		_gtk_scale_set_draw_value(scale, draw_value);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_rc_style_set_fg(int /*long*/ style, int index, GdkColor color);
+public static final void gtk_rc_style_set_fg(int /*long*/ style, int index, GdkColor color) {
+	lock.lock();
+	try {
+		_gtk_rc_style_set_fg(style, index, color);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_rc_style_set_text(int /*long*/ style, int index, GdkColor color);
+public static final void gtk_rc_style_set_text(int /*long*/ style, int index, GdkColor color) {
+	lock.lock();
+	try {
+		_gtk_rc_style_set_text(style, index, color);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_scrolled_window_add_with_viewport(int /*long*/ scrolled_window, int /*long*/ child);
+public static final void gtk_scrolled_window_add_with_viewport(int /*long*/ scrolled_window, int /*long*/ child) {
+	lock.lock();
+	try {
+		_gtk_scrolled_window_add_with_viewport(scrolled_window, child);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_scrolled_window_get_hadjustment(int /*long*/ scrolled_window);
+public static final int /*long*/ gtk_scrolled_window_get_hadjustment(int /*long*/ scrolled_window) {
+	lock.lock();
+	try {
+		return _gtk_scrolled_window_get_hadjustment(scrolled_window);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_scrolled_window_get_policy(int /*long*/ scrolled_window, int[] hscrollbar_policy, int[] vscrollbar_policy);
+public static final void gtk_scrolled_window_get_policy(int /*long*/ scrolled_window, int[] hscrollbar_policy, int[] vscrollbar_policy) {
+	lock.lock();
+	try {
+		_gtk_scrolled_window_get_policy(scrolled_window, hscrollbar_policy, vscrollbar_policy);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _gtk_scrolled_window_get_shadow_type(int /*long*/ scrolled_window);
+public static final int gtk_scrolled_window_get_shadow_type(int /*long*/ scrolled_window) {
+	lock.lock();
+	try {
+		return _gtk_scrolled_window_get_shadow_type(scrolled_window);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_scrolled_window_get_vadjustment(int /*long*/ scrolled_window);
+public static final int /*long*/ gtk_scrolled_window_get_vadjustment(int /*long*/ scrolled_window) {
+	lock.lock();
+	try {
+		return _gtk_scrolled_window_get_vadjustment(scrolled_window);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_scrolled_window_new(int /*long*/ hadjustment, int /*long*/ vadjustment);
+public static final int /*long*/ gtk_scrolled_window_new(int /*long*/ hadjustment, int /*long*/ vadjustment) {
+	lock.lock();
+	try {
+		return _gtk_scrolled_window_new(hadjustment, vadjustment);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_scrolled_window_set_placement(int /*long*/ scrolled_window, int placement);
+public static final void gtk_scrolled_window_set_placement(int /*long*/ scrolled_window, int placement) {
+	lock.lock();
+	try {
+		_gtk_scrolled_window_set_placement(scrolled_window, placement);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_scrolled_window_set_policy(int /*long*/ scrolled_window, int hscrollbar_policy, int vscrollbar_policy);
+public static final void gtk_scrolled_window_set_policy(int /*long*/ scrolled_window, int hscrollbar_policy, int vscrollbar_policy) {
+	lock.lock();
+	try {
+		_gtk_scrolled_window_set_policy(scrolled_window, hscrollbar_policy, vscrollbar_policy);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_scrolled_window_set_shadow_type(int /*long*/ scrolled_window, int type);
+public static final void gtk_scrolled_window_set_shadow_type(int /*long*/ scrolled_window, int type) {
+	lock.lock();
+	try {
+		_gtk_scrolled_window_set_shadow_type(scrolled_window, type);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_settings_get_default();
+public static final int /*long*/ gtk_settings_get_default() {
+	lock.lock();
+	try {
+		return _gtk_settings_get_default();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_selection_data_free(int /*long*/ selection_data);
+public static final void gtk_selection_data_free(int /*long*/ selection_data) {
+	lock.lock();
+	try {
+		_gtk_selection_data_free(selection_data);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_selection_data_set(int /*long*/ selection_data, int /*long*/ type, int format, int /*long*/ data, int length);
+public static final void gtk_selection_data_set(int /*long*/ selection_data, int /*long*/ type, int format, int /*long*/ data, int length) {
+	lock.lock();
+	try {
+		_gtk_selection_data_set(selection_data, type, format, data, length);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_separator_menu_item_new();
+public static final int /*long*/ gtk_separator_menu_item_new() {
+	lock.lock();
+	try {
+		return _gtk_separator_menu_item_new();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_set_locale();
+public static final int /*long*/ gtk_set_locale() {
+	lock.lock();
+	try {
+		return _gtk_set_locale();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_socket_get_id(int /*long*/ socket);
+public static final int /*long*/ gtk_socket_get_id(int /*long*/ socket) {
+	lock.lock();
+	try {
+		return _gtk_socket_get_id(socket);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_socket_new();
+public static final int /*long*/ gtk_socket_new() {
+	lock.lock();
+	try {
+		return _gtk_socket_new();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_spin_button_new(int /*long*/ adjustment, double climb_rate, int digits);
+public static final int /*long*/ gtk_spin_button_new(int /*long*/ adjustment, double climb_rate, int digits) {
+	lock.lock();
+	try {
+		return _gtk_spin_button_new(adjustment, climb_rate, digits);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_spin_button_get_adjustment(int /*long*/ spin_button);
+public static final int /*long*/ gtk_spin_button_get_adjustment(int /*long*/ spin_button) {
+	lock.lock();
+	try {
+		return _gtk_spin_button_get_adjustment(spin_button);
+	} finally {
+		lock.unlock();
+	}
+}
+
+public static final native int _gtk_spin_button_get_digits(int /*long*/ spin_button);
+public static final int gtk_spin_button_get_digits(int /*long*/ spin_button) {
+	lock.lock();
+	try {
+		return _gtk_spin_button_get_digits(spin_button);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_spin_button_set_digits(int /*long*/ spin_button, int digits);
+public static final void gtk_spin_button_set_digits(int /*long*/ spin_button, int digits) {
+	lock.lock();
+	try {
+		_gtk_spin_button_set_digits(spin_button, digits);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_spin_button_set_increments(int /*long*/ spin_button, double step, double page);
+public static final void gtk_spin_button_set_increments(int /*long*/ spin_button, double step, double page) {
+	lock.lock();
+	try {
+		_gtk_spin_button_set_increments(spin_button, step, page);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_spin_button_set_range(int /*long*/ spin_button, double max, double min);
+public static final void gtk_spin_button_set_range(int /*long*/ spin_button, double max, double min) {
+	lock.lock();
+	try {
+		_gtk_spin_button_set_range(spin_button, max, min);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_spin_button_set_value(int /*long*/ spin_button, double value);
+public static final void gtk_spin_button_set_value(int /*long*/ spin_button, double value) {
+	lock.lock();
+	try {
+		_gtk_spin_button_set_value(spin_button, value);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_spin_button_set_wrap(int /*long*/ spin_button, boolean wrap);
+public static final void gtk_spin_button_set_wrap(int /*long*/ spin_button, boolean wrap) {
+	lock.lock();
+	try {
+		_gtk_spin_button_set_wrap(spin_button, wrap);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_spin_button_update(int /*long*/ spin_button);
+public static final void gtk_spin_button_update(int /*long*/ spin_button) {
+	lock.lock();
+	try {
+		_gtk_spin_button_update(spin_button);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_style_get_base(int /*long*/ style, int index, GdkColor color);
+public static final void gtk_style_get_base(int /*long*/ style, int index, GdkColor color) {
+	lock.lock();
+	try {
+		_gtk_style_get_base(style, index, color);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_style_get_black(int /*long*/ style, GdkColor color);
+public static final void gtk_style_get_black(int /*long*/ style, GdkColor color) {
+	lock.lock();
+	try {
+		_gtk_style_get_black(style, color);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_style_get_bg(int /*long*/ style, int index, GdkColor color);
+public static final void gtk_style_get_bg(int /*long*/ style, int index, GdkColor color) {
+	lock.lock();
+	try {
+		_gtk_style_get_bg(style, index, color);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_style_get_dark(int /*long*/ style, int index, GdkColor color);
+public static final void gtk_style_get_dark(int /*long*/ style, int index, GdkColor color) {
+	lock.lock();
+	try {
+		_gtk_style_get_dark(style, index, color);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_style_get_fg(int /*long*/ style, int index, GdkColor color);
+public static final void gtk_style_get_fg(int /*long*/ style, int index, GdkColor color) {
+	lock.lock();
+	try {
+		_gtk_style_get_fg(style, index, color);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_style_get_fg_gc(int /*long*/ style, int index, int /*long*/[] gc);
+public static final void gtk_style_get_fg_gc(int /*long*/ style, int index, int /*long*/[] gc) {
+	lock.lock();
+	try {
+		_gtk_style_get_fg_gc(style, index, gc);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_style_get_bg_gc(int /*long*/ style, int index, int /*long*/[] gc);
+public static final void gtk_style_get_bg_gc(int /*long*/ style, int index, int /*long*/[] gc) {
+	lock.lock();
+	try {
+		_gtk_style_get_bg_gc(style, index, gc);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_style_get_light_gc(int /*long*/ style, int index, int /*long*/[] gc);
+public static final void gtk_style_get_light_gc(int /*long*/ style, int index, int /*long*/[] gc) {
+	lock.lock();
+	try {
+		_gtk_style_get_light_gc(style, index, gc);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_style_get_dark_gc(int /*long*/ style, int index, int /*long*/[] gc);
+public static final void gtk_style_get_dark_gc(int /*long*/ style, int index, int /*long*/[] gc) {
+	lock.lock();
+	try {
+		_gtk_style_get_dark_gc(style, index, gc);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_style_get_mid_gc(int /*long*/ style, int index, int /*long*/[] gc);
+public static final void gtk_style_get_mid_gc(int /*long*/ style, int index, int /*long*/[] gc) {
+	lock.lock();
+	try {
+		_gtk_style_get_mid_gc(style, index, gc);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_style_get_text_gc(int /*long*/ style, int index, int /*long*/[] gc);
+public static final void gtk_style_get_text_gc(int /*long*/ style, int index, int /*long*/[] gc) {
+	lock.lock();
+	try {
+		_gtk_style_get_text_gc(style, index, gc);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_style_get_text_aa_gc(int /*long*/ style, int index, int /*long*/[] gc);
+public static final void gtk_style_get_text_aa_gc(int /*long*/ style, int index, int /*long*/[] gc) {
+	lock.lock();
+	try {
+		_gtk_style_get_text_aa_gc(style, index, gc);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_style_get_black_gc(int /*long*/ style, int /*long*/[] gc);
+public static final void gtk_style_get_black_gc(int /*long*/ style, int /*long*/[] gc) {
+	lock.lock();
+	try {
+		_gtk_style_get_black_gc(style, gc);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_style_get_white_gc(int /*long*/ style, int /*long*/[] gc);
+public static final void gtk_style_get_white_gc(int /*long*/ style, int /*long*/[] gc) {
+	lock.lock();
+	try {
+		_gtk_style_get_white_gc(style, gc);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_style_get_font_desc(int /*long*/ style);
+public static final int /*long*/ gtk_style_get_font_desc(int /*long*/ style) {
+	lock.lock();
+	try {
+		return _gtk_style_get_font_desc(style);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_style_get_light(int /*long*/ style, int index, GdkColor color);
+public static final void gtk_style_get_light(int /*long*/ style, int index, GdkColor color) {
+	lock.lock();
+	try {
+		_gtk_style_get_light(style, index, color);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_style_get_text(int /*long*/ style, int index, GdkColor color);
+public static final void gtk_style_get_text(int /*long*/ style, int index, GdkColor color) {
+	lock.lock();
+	try {
+		_gtk_style_get_text(style, index, color);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _gtk_style_get_xthickness(int /*long*/ style);
+public static final int gtk_style_get_xthickness(int /*long*/ style) {
+	lock.lock();
+	try {
+		return _gtk_style_get_xthickness(style);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _gtk_style_get_ythickness(int /*long*/ style);
+public static final int gtk_style_get_ythickness(int /*long*/ style) {
+	lock.lock();
+	try {
+		return _gtk_style_get_ythickness(style);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_style_render_icon(int /*long*/ style, int /*long*/ source, int direction, int state, int size, int /*long*/ widget, byte[] detail);
+public static final int /*long*/ gtk_style_render_icon(int /*long*/ style, int /*long*/ source, int direction, int state, int size, int /*long*/ widget, byte[] detail) {
+	lock.lock();
+	try {
+		return _gtk_style_render_icon(style, source, direction, state, size, widget, detail);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_target_list_new(int /*long*/ targets, int ntargets);
+public static final int /*long*/ gtk_target_list_new(int /*long*/ targets, int ntargets) {
+	lock.lock();
+	try {
+		return _gtk_target_list_new(targets, ntargets);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_target_list_unref(int /*long*/ list);
+public static final void gtk_target_list_unref(int /*long*/ list) {
+	lock.lock();
+	try {
+		_gtk_target_list_unref(list);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_text_buffer_copy_clipboard(int /*long*/ buffer, int /*long*/ clipboard);
+public static final void gtk_text_buffer_copy_clipboard(int /*long*/ buffer, int /*long*/ clipboard) {
+	lock.lock();
+	try {
+		_gtk_text_buffer_copy_clipboard(buffer, clipboard);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_text_buffer_cut_clipboard(int /*long*/ buffer, int /*long*/ clipboard, boolean default_editable);
+public static final void gtk_text_buffer_cut_clipboard(int /*long*/ buffer, int /*long*/ clipboard, boolean default_editable) {
+	lock.lock();
+	try {
+		_gtk_text_buffer_cut_clipboard(buffer, clipboard, default_editable);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_text_buffer_delete(int /*long*/ buffer, byte[] start, byte[] end);
+public static final void gtk_text_buffer_delete(int /*long*/ buffer, byte[] start, byte[] end) {
+	lock.lock();
+	try {
+		_gtk_text_buffer_delete(buffer, start, end);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_text_buffer_get_bounds(int /*long*/ buffer, byte[] start, byte[] end);
+public static final void gtk_text_buffer_get_bounds(int /*long*/ buffer, byte[] start, byte[] end) {
+	lock.lock();
+	try {
+		_gtk_text_buffer_get_bounds(buffer, start, end);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _gtk_text_buffer_get_char_count(int /*long*/ buffer);
+public static final int gtk_text_buffer_get_char_count(int /*long*/ buffer) {
+	lock.lock();
+	try {
+		return _gtk_text_buffer_get_char_count(buffer);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_text_buffer_get_end_iter(int /*long*/ buffer, byte[] iter);
+public static final void gtk_text_buffer_get_end_iter(int /*long*/ buffer, byte[] iter) {
+	lock.lock();
+	try {
+		_gtk_text_buffer_get_end_iter(buffer, iter);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_text_buffer_get_insert(int /*long*/ buffer);
+public static final int /*long*/ gtk_text_buffer_get_insert(int /*long*/ buffer) {
+	lock.lock();
+	try {
+		return _gtk_text_buffer_get_insert(buffer);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_text_buffer_get_iter_at_line(int /*long*/ buffer, byte[] iter, int line_number);
+public static final void gtk_text_buffer_get_iter_at_line(int /*long*/ buffer, byte[] iter, int line_number) {
+	lock.lock();
+	try {
+		_gtk_text_buffer_get_iter_at_line(buffer, iter, line_number);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_text_buffer_get_iter_at_mark(int /*long*/ buffer, byte[] iter, int /*long*/ mark);
+public static final void gtk_text_buffer_get_iter_at_mark(int /*long*/ buffer, byte[] iter, int /*long*/ mark) {
+	lock.lock();
+	try {
+		_gtk_text_buffer_get_iter_at_mark(buffer, iter, mark);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_text_buffer_get_iter_at_offset(int /*long*/ buffer, byte[] iter, int char_offset);
+public static final void gtk_text_buffer_get_iter_at_offset(int /*long*/ buffer, byte[] iter, int char_offset) {
+	lock.lock();
+	try {
+		_gtk_text_buffer_get_iter_at_offset(buffer, iter, char_offset);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _gtk_text_buffer_get_line_count(int /*long*/ buffer);
+public static final int gtk_text_buffer_get_line_count(int /*long*/ buffer) {
+	lock.lock();
+	try {
+		return _gtk_text_buffer_get_line_count(buffer);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_text_buffer_get_selection_bound(int /*long*/ buffer);
+public static final int /*long*/ gtk_text_buffer_get_selection_bound(int /*long*/ buffer) {
+	lock.lock();
+	try {
+		return _gtk_text_buffer_get_selection_bound(buffer);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _gtk_text_buffer_get_selection_bounds(int /*long*/ buffer, byte[] start, byte[] end);
+public static final boolean gtk_text_buffer_get_selection_bounds(int /*long*/ buffer, byte[] start, byte[] end) {
+	lock.lock();
+	try {
+		return _gtk_text_buffer_get_selection_bounds(buffer, start, end);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_text_buffer_get_text(int /*long*/ buffer, byte[] start, byte[] end, boolean include_hidden_chars);
+public static final int /*long*/ gtk_text_buffer_get_text(int /*long*/ buffer, byte[] start, byte[] end, boolean include_hidden_chars) {
+	lock.lock();
+	try {
+		return _gtk_text_buffer_get_text(buffer, start, end, include_hidden_chars);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_text_buffer_insert(int /*long*/ buffer, byte[] iter, byte[] text, int len);
+public static final void gtk_text_buffer_insert(int /*long*/ buffer, byte[] iter, byte[] text, int len) {
+	lock.lock();
+	try {
+		_gtk_text_buffer_insert(buffer, iter, text, len);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_text_buffer_insert(int /*long*/ buffer, int /*long*/ iter, byte[] text, int len);
+public static final void gtk_text_buffer_insert(int /*long*/ buffer, int /*long*/ iter, byte[] text, int len) {
+	lock.lock();
+	try {
+		_gtk_text_buffer_insert(buffer, iter, text, len);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_text_buffer_move_mark(int /*long*/ buffer, int /*long*/ mark, byte[] where);
+public static final void gtk_text_buffer_move_mark(int /*long*/ buffer, int /*long*/ mark, byte[] where) {
+	lock.lock();
+	try {
+		_gtk_text_buffer_move_mark(buffer, mark, where);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_text_buffer_paste_clipboard(int /*long*/ buffer, int /*long*/ clipboard, byte[] override_location, boolean default_editable);
+public static final void gtk_text_buffer_paste_clipboard(int /*long*/ buffer, int /*long*/ clipboard, byte[] override_location, boolean default_editable) {
+	lock.lock();
+	try {
+		_gtk_text_buffer_paste_clipboard(buffer, clipboard, override_location, default_editable);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_text_buffer_place_cursor(int /*long*/ buffer, byte[] where);
+public static final void gtk_text_buffer_place_cursor(int /*long*/ buffer, byte[] where) {
+	lock.lock();
+	try {
+		_gtk_text_buffer_place_cursor(buffer, where);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_text_buffer_set_text(int /*long*/ buffer, byte[] text, int len);
+public static final void gtk_text_buffer_set_text(int /*long*/ buffer, byte[] text, int len) {
+	lock.lock();
+	try {
+		_gtk_text_buffer_set_text(buffer, text, len);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _gtk_text_iter_get_line(byte[] iter);
+public static final int gtk_text_iter_get_line(byte[] iter) {
+	lock.lock();
+	try {
+		return _gtk_text_iter_get_line(iter);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _gtk_text_iter_get_offset(byte[] iter);
+public static final int gtk_text_iter_get_offset(byte[] iter) {
+	lock.lock();
+	try {
+		return _gtk_text_iter_get_offset(iter);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_text_view_buffer_to_window_coords(int /*long*/ text_view, int win, int buffer_x, int buffer_y, int[] window_x, int[] window_y);
+public static final void gtk_text_view_buffer_to_window_coords(int /*long*/ text_view, int win, int buffer_x, int buffer_y, int[] window_x, int[] window_y) {
+	lock.lock();
+	try {
+		_gtk_text_view_buffer_to_window_coords(text_view, win, buffer_x, buffer_y, window_x, window_y);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_text_view_get_buffer(int /*long*/ text_view);
+public static final int /*long*/ gtk_text_view_get_buffer(int /*long*/ text_view) {
+	lock.lock();
+	try {
+		return _gtk_text_view_get_buffer(text_view);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _gtk_text_view_get_editable(int /*long*/ text_view);
+public static final boolean gtk_text_view_get_editable(int /*long*/ text_view) {
+	lock.lock();
+	try {
+		return _gtk_text_view_get_editable(text_view);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_text_view_get_iter_at_location(int /*long*/ text_view, byte[] iter, int x, int y);
+public static final void gtk_text_view_get_iter_at_location(int /*long*/ text_view, byte[] iter, int x, int y) {
+	lock.lock();
+	try {
+		_gtk_text_view_get_iter_at_location(text_view, iter, x, y);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_text_view_get_iter_location(int /*long*/ text_view, byte[] iter, GdkRectangle location);
+public static final void gtk_text_view_get_iter_location(int /*long*/ text_view, byte[] iter, GdkRectangle location) {
+	lock.lock();
+	try {
+		_gtk_text_view_get_iter_location(text_view, iter, location);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_text_view_get_line_at_y(int /*long*/ text_view, byte[] target_iter, int y, int[] line_top);
+public static final void gtk_text_view_get_line_at_y(int /*long*/ text_view, byte[] target_iter, int y, int[] line_top) {
+	lock.lock();
+	try {
+		_gtk_text_view_get_line_at_y(text_view, target_iter, y, line_top);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_text_view_get_visible_rect(int /*long*/ text_view, GdkRectangle visible_rect);
+public static final void gtk_text_view_get_visible_rect(int /*long*/ text_view, GdkRectangle visible_rect) {
+	lock.lock();
+	try {
+		_gtk_text_view_get_visible_rect(text_view, visible_rect);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_text_view_get_window(int /*long*/ text_view, int win);
+public static final int /*long*/ gtk_text_view_get_window(int /*long*/ text_view, int win) {
+	lock.lock();
+	try {
+		return _gtk_text_view_get_window(text_view, win);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_text_view_new();
+public static final int /*long*/ gtk_text_view_new() {
+	lock.lock();
+	try {
+		return _gtk_text_view_new();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_text_view_scroll_mark_onscreen(int /*long*/ text_view, int /*long*/ mark);
+public static final void gtk_text_view_scroll_mark_onscreen(int /*long*/ text_view, int /*long*/ mark) {
+	lock.lock();
+	try {
+		_gtk_text_view_scroll_mark_onscreen(text_view, mark);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _gtk_text_view_scroll_to_iter(int /*long*/ text_view, byte[] iter, double within_margin, boolean use_align, double xalign, double yalign);
+public static final boolean gtk_text_view_scroll_to_iter(int /*long*/ text_view, byte[] iter, double within_margin, boolean use_align, double xalign, double yalign) {
+	lock.lock();
+	try {
+		return _gtk_text_view_scroll_to_iter(text_view, iter, within_margin, use_align, xalign, yalign);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_text_view_set_editable(int /*long*/ text_view, boolean setting);
+public static final void gtk_text_view_set_editable(int /*long*/ text_view, boolean setting) {
+	lock.lock();
+	try {
+		_gtk_text_view_set_editable(text_view, setting);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_text_view_set_justification(int /*long*/ text_view, int justification);
+public static final void gtk_text_view_set_justification(int /*long*/ text_view, int justification) {
+	lock.lock();
+	try {
+		_gtk_text_view_set_justification(text_view, justification);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_text_view_set_tabs(int /*long*/ text_view, int /*long*/ tabs);
+public static final void gtk_text_view_set_tabs(int /*long*/ text_view, int /*long*/ tabs) {
+	lock.lock();
+	try {
+		_gtk_text_view_set_tabs(text_view, tabs);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_text_view_set_wrap_mode(int /*long*/ text_view, int wrap_mode);
+public static final void gtk_text_view_set_wrap_mode(int /*long*/ text_view, int wrap_mode) {
+	lock.lock();
+	try {
+		_gtk_text_view_set_wrap_mode(text_view, wrap_mode);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_text_view_window_to_buffer_coords(int /*long*/ text_view, int win, int window_x, int window_y, int[] buffer_x, int[] buffer_y);
+public static final void gtk_text_view_window_to_buffer_coords(int /*long*/ text_view,  int win, int window_x, int window_y, int[] buffer_x, int[] buffer_y) {
+	lock.lock();
+	try {
+		_gtk_text_view_window_to_buffer_coords(text_view, win, window_x, window_y, buffer_x, buffer_y);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _gtk_timeout_add(int interval, int /*long*/ function, int /*long*/ data);
+public static final int gtk_timeout_add(int interval, int /*long*/ function, int /*long*/ data) {
+	lock.lock();
+	try {
+		return _gtk_timeout_add(interval, function, data);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_timeout_remove(int timeout_handler_id);
+public static final void gtk_timeout_remove(int timeout_handler_id) {
+	lock.lock();
+	try {
+		_gtk_timeout_remove(timeout_handler_id);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _gtk_toggle_button_get_active(int /*long*/ toggle_button);
+public static final boolean gtk_toggle_button_get_active(int /*long*/ toggle_button) {
+	lock.lock();
+	try {
+		return _gtk_toggle_button_get_active(toggle_button);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_toggle_button_new();
+public static final int /*long*/ gtk_toggle_button_new() {
+	lock.lock();
+	try {
+		return _gtk_toggle_button_new();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _gtk_toggle_button_get_inconsistent(int /*long*/ toggle_button);
+public static final boolean gtk_toggle_button_get_inconsistent(int /*long*/ toggle_button) {
+	lock.lock();
+	try {
+		return _gtk_toggle_button_get_inconsistent(toggle_button);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_toggle_button_set_active(int /*long*/ toggle_button, boolean is_active);
+public static final void gtk_toggle_button_set_active(int /*long*/ toggle_button, boolean is_active) {
+	lock.lock();
+	try {
+		_gtk_toggle_button_set_active(toggle_button, is_active);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_toggle_button_set_inconsistent(int /*long*/ toggle_button, boolean setting);
+public static final void gtk_toggle_button_set_inconsistent(int /*long*/ toggle_button, boolean setting) {
+	lock.lock();
+	try {
+		_gtk_toggle_button_set_inconsistent(toggle_button, setting);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_toggle_button_set_mode(int /*long*/ toggle_button, boolean draw_indicator);
+public static final void gtk_toggle_button_set_mode(int /*long*/ toggle_button, boolean draw_indicator) {
+	lock.lock();
+	try {
+		_gtk_toggle_button_set_mode(toggle_button, draw_indicator);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_toolbar_insert_widget(int /*long*/ toolbar, int /*long*/ widget, byte[] tooltip_text, byte[] tooltip_private_text, int position);
+public static final void gtk_toolbar_insert_widget(int /*long*/ toolbar, int /*long*/ widget, byte[] tooltip_text, byte[] tooltip_private_text, int position) {
+	lock.lock();
+	try {
+		_gtk_toolbar_insert_widget(toolbar, widget, tooltip_text, tooltip_private_text, position);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_toolbar_new();
+public static final int /*long*/ gtk_toolbar_new() {
+	lock.lock();
+	try {
+		return _gtk_toolbar_new();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_toolbar_set_orientation(int /*long*/ toolbar, int orientation);
+public static final void gtk_toolbar_set_orientation(int /*long*/ toolbar, int orientation) {
+	lock.lock();
+	try {
+		_gtk_toolbar_set_orientation(toolbar, orientation);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_tooltips_data_get(int /*long*/ widget);
+public static final int /*long*/ gtk_tooltips_data_get(int /*long*/ widget) {
+	lock.lock();
+	try {
+		return _gtk_tooltips_data_get(widget);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_tooltips_disable(int /*long*/ tooltips);
+public static final void gtk_tooltips_disable(int /*long*/ tooltips) {
+	lock.lock();
+	try {
+		_gtk_tooltips_disable(tooltips);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_tooltips_enable(int /*long*/ tooltips);
+public static final void gtk_tooltips_enable(int /*long*/ tooltips) {
+	lock.lock();
+	try {
+		_gtk_tooltips_enable(tooltips);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_tooltips_new();
+public static final int /*long*/ gtk_tooltips_new() {
+	lock.lock();
+	try {
+		return _gtk_tooltips_new();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_tooltips_force_window(int /*long*/ tooltips);
+public static final void gtk_tooltips_force_window(int /*long*/ tooltips) {
+	lock.lock();
+	try {
+		_gtk_tooltips_force_window(tooltips);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_tooltips_set_tip(int /*long*/ tooltips, int /*long*/ widget, byte[] tip_text, byte[] tip_private);
+public static final void gtk_tooltips_set_tip(int /*long*/ tooltips, int /*long*/ widget, byte[] tip_text, byte[] tip_private) {
+	lock.lock();
+	try {
+		_gtk_tooltips_set_tip(tooltips, widget, tip_text, tip_private);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_tree_model_get(int /*long*/ tree_model, int /*long*/ iter, int column, int[] value, int /*long*/ terminator);
+public static final void gtk_tree_model_get(int /*long*/ tree_model, int /*long*/ iter, int column, int[] value, int /*long*/ terminator) {
+	lock.lock();
+	try {
+		_gtk_tree_model_get(tree_model, iter, column, value, terminator);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_tree_model_get(int /*long*/ tree_model, int /*long*/ iter, int column, long[] value, int /*long*/ terminator);
+public static final void gtk_tree_model_get(int /*long*/ tree_model, int /*long*/ iter, int column, long[] value, int /*long*/ terminator) {
+	lock.lock();
+	try {
+		_gtk_tree_model_get(tree_model, iter, column, value, terminator);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _gtk_tree_model_get_iter(int /*long*/ tree_model, int /*long*/ iter, int /*long*/ path);
+public static final boolean gtk_tree_model_get_iter(int /*long*/ tree_model, int /*long*/ iter, int /*long*/ path) {
+	lock.lock();
+	try {
+		return _gtk_tree_model_get_iter(tree_model, iter, path);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _gtk_tree_model_get_iter_first(int /*long*/ tree_model, int /*long*/ iter);
+public static final boolean gtk_tree_model_get_iter_first(int /*long*/ tree_model, int /*long*/ iter) {
+	lock.lock();
+	try {
+		return _gtk_tree_model_get_iter_first(tree_model, iter);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _gtk_tree_model_get_n_columns(int /*long*/ tree_model);
+public static final int gtk_tree_model_get_n_columns(int /*long*/ tree_model) {
+	lock.lock();
+	try {
+		return _gtk_tree_model_get_n_columns(tree_model);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_tree_model_get_path(int /*long*/ tree_model, int /*long*/ iter);
+public static final int /*long*/ gtk_tree_model_get_path(int /*long*/ tree_model, int /*long*/ iter) {
+	lock.lock();
+	try {
+		return _gtk_tree_model_get_path(tree_model, iter);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_tree_model_get_type();
+public static final int /*long*/ gtk_tree_model_get_type() {
+	lock.lock();
+	try {
+		return _gtk_tree_model_get_type();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _gtk_tree_model_iter_children(int /*long*/ model, int /*long*/ iter, int /*long*/ parent);
+public static final boolean gtk_tree_model_iter_children(int /*long*/ model, int /*long*/ iter, int /*long*/ parent) {
+	lock.lock();
+	try {
+		return _gtk_tree_model_iter_children(model, iter, parent);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _gtk_tree_model_iter_n_children(int /*long*/ model, int /*long*/ iter);
+public static final int gtk_tree_model_iter_n_children(int /*long*/ model, int /*long*/ iter) {
+	lock.lock();
+	try {
+		return _gtk_tree_model_iter_n_children(model, iter);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _gtk_tree_model_iter_next(int /*long*/ model, int /*long*/ iter);
+public static final boolean gtk_tree_model_iter_next(int /*long*/ model, int /*long*/ iter) {
+	lock.lock();
+	try {
+		return _gtk_tree_model_iter_next(model, iter);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _gtk_tree_model_iter_nth_child(int /*long*/ tree_model, int /*long*/ iter, int /*long*/ parent, int n);
+public static final boolean gtk_tree_model_iter_nth_child(int /*long*/ tree_model, int /*long*/ iter, int /*long*/ parent, int n) {
+	lock.lock();
+	try {
+		return _gtk_tree_model_iter_nth_child(tree_model, iter, parent, n);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_tree_path_append_index(int /*long*/ path, int index);
+public static final void gtk_tree_path_append_index(int /*long*/ path, int index) {
+	lock.lock();
+	try {
+		_gtk_tree_path_append_index(path, index);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_tree_path_compare(int /*long*/ a, int /*long*/ b);
+public static final int /*long*/ gtk_tree_path_compare(int /*long*/ a, int /*long*/ b) {
+	lock.lock();
+	try {
+		 return _gtk_tree_path_compare(a, b);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_tree_path_down(int /*long*/ path);
+public static final void gtk_tree_path_down(int /*long*/ path) {
+	lock.lock();
+	try {
+		 _gtk_tree_path_down(path);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_tree_path_free(int /*long*/ path);
+public static final void gtk_tree_path_free(int /*long*/ path) {
+	lock.lock();
+	try {
+		_gtk_tree_path_free(path);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _gtk_tree_path_get_depth(int /*long*/ path);
+public static final int gtk_tree_path_get_depth(int /*long*/ path) {
+	lock.lock();
+	try {
+		return _gtk_tree_path_get_depth(path);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_tree_path_get_indices(int /*long*/ path);
+public static final int /*long*/ gtk_tree_path_get_indices(int /*long*/ path) {
+	lock.lock();
+	try {
+		return _gtk_tree_path_get_indices(path);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_tree_path_new();
+public static final int /*long*/ gtk_tree_path_new() {
+	lock.lock();
+	try {
+		return _gtk_tree_path_new();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_tree_path_new_first();
+public static final int /*long*/ gtk_tree_path_new_first() {
+	lock.lock();
+	try {
+		return _gtk_tree_path_new_first();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_tree_path_new_from_string(byte[] path);
+public static final int /*long*/ gtk_tree_path_new_from_string(byte[] path) {
+	lock.lock();
+	try {
+		return _gtk_tree_path_new_from_string(path);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_tree_path_new_from_string(int /*long*/ path);
+public static final int /*long*/ gtk_tree_path_new_from_string(int /*long*/ path) {
+	lock.lock();
+	try {
+		return _gtk_tree_path_new_from_string(path);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_tree_path_next(int /*long*/ path);
+public static final void gtk_tree_path_next(int /*long*/ path) {
+	lock.lock();
+	try {
+		_gtk_tree_path_next(path);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _gtk_tree_path_prev(int /*long*/ path);
+public static final boolean gtk_tree_path_prev(int /*long*/ path) {
+	lock.lock();
+	try {
+		return _gtk_tree_path_prev(path);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _gtk_tree_path_up(int /*long*/ path);
+public static final boolean gtk_tree_path_up(int /*long*/ path) {
+	lock.lock();
+	try {
+		return _gtk_tree_path_up(path);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _gtk_tree_selection_count_selected_rows(int /*long*/ selection);
+public static final int gtk_tree_selection_count_selected_rows(int /*long*/ selection) {
+	lock.lock();
+	try {
+		return _gtk_tree_selection_count_selected_rows(selection);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _gtk_tree_selection_get_selected(int /*long*/ selection, int /*long*/[] model, int /*long*/ iter);
+public static final boolean gtk_tree_selection_get_selected(int /*long*/ selection, int /*long*/[] model, int /*long*/ iter) {
+	lock.lock();
+	try {
+		return _gtk_tree_selection_get_selected(selection, model, iter);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_tree_selection_get_selected_rows(int /*long*/ selection, int /*long*/[] model);
+public static final int /*long*/ gtk_tree_selection_get_selected_rows(int /*long*/ selection, int /*long*/[] model) {
+	lock.lock();
+	try {
+		return _gtk_tree_selection_get_selected_rows(selection, model);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _gtk_tree_selection_path_is_selected(int /*long*/ selection, int /*long*/ path);
+public static final boolean gtk_tree_selection_path_is_selected(int /*long*/ selection, int /*long*/ path) {
+	lock.lock();
+	try {
+		return _gtk_tree_selection_path_is_selected(selection, path);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_tree_selection_select_all(int /*long*/ selection);
+public static final void gtk_tree_selection_select_all(int /*long*/ selection) {
+	lock.lock();
+	try {
+		_gtk_tree_selection_select_all(selection);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_tree_selection_select_iter(int /*long*/ selection, int /*long*/ iter);
+public static final void gtk_tree_selection_select_iter(int /*long*/ selection, int /*long*/ iter) {
+	lock.lock();
+	try {
+		_gtk_tree_selection_select_iter(selection, iter);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_tree_selection_selected_foreach(int /*long*/ selection, int /*long*/ func, int /*long*/ data);
+public static final void gtk_tree_selection_selected_foreach(int /*long*/ selection, int /*long*/ func, int /*long*/ data) {
+	lock.lock();
+	try {
+		_gtk_tree_selection_selected_foreach(selection, func, data);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_tree_selection_set_mode(int /*long*/ selection, int mode);
+public static final void gtk_tree_selection_set_mode(int /*long*/ selection, int mode) {
+	lock.lock();
+	try {
+		_gtk_tree_selection_set_mode(selection, mode);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_tree_selection_unselect_all(int /*long*/ selection);
+public static final void gtk_tree_selection_unselect_all(int /*long*/ selection) {
+	lock.lock();
+	try {
+		_gtk_tree_selection_unselect_all(selection);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_tree_selection_unselect_iter(int /*long*/ selection, int /*long*/ iter);
+public static final void gtk_tree_selection_unselect_iter(int /*long*/ selection, int /*long*/ iter) {
+	lock.lock();
+	try {
+		_gtk_tree_selection_unselect_iter(selection, iter);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_tree_store_append(int /*long*/ store, int /*long*/ iter, int /*long*/ parent);
+public static final void gtk_tree_store_append(int /*long*/ store, int /*long*/ iter, int /*long*/ parent) {
+	lock.lock();
+	try {
+		_gtk_tree_store_append(store, iter, parent);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_tree_store_clear(int /*long*/ store);
+public static final void gtk_tree_store_clear(int /*long*/ store) {
+	lock.lock();
+	try {
+		_gtk_tree_store_clear(store);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_tree_store_insert(int /*long*/ store, int /*long*/ iter, int /*long*/ parent, int position);
+public static final void gtk_tree_store_insert(int /*long*/ store, int /*long*/ iter, int /*long*/ parent, int position) {
+	lock.lock();
+	try {
+		_gtk_tree_store_insert(store, iter, parent, position);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_tree_store_newv(int numColumns, int /*long*/[] types);
+public static final int /*long*/ gtk_tree_store_newv(int numColumns, int /*long*/[] types) {
+	lock.lock();
+	try {
+		return _gtk_tree_store_newv(numColumns, types);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_tree_store_remove(int /*long*/ store, int /*long*/ iter);
+public static final void gtk_tree_store_remove(int /*long*/ store, int /*long*/ iter) {
+	lock.lock();
+	try {
+		_gtk_tree_store_remove(store, iter);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_tree_store_set(int /*long*/ store, int /*long*/ iter, int column, byte[] value, int /*long*/ terminator);
+public static final void gtk_tree_store_set(int /*long*/ store, int /*long*/ iter, int column, byte[] value, int /*long*/ terminator) {
+	lock.lock();
+	try {
+		_gtk_tree_store_set(store, iter, column, value, terminator);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_tree_store_set(int /*long*/ store, int /*long*/ iter, int column, int value, int /*long*/ terminator);
+public static final void gtk_tree_store_set(int /*long*/ store, int /*long*/ iter, int column, int value, int /*long*/ terminator) {
+	lock.lock();
+	try {
+		_gtk_tree_store_set(store, iter, column, value, terminator);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_tree_store_set(int /*long*/ store, int /*long*/ iter, int column, long value, int /*long*/ terminator);
+public static final void gtk_tree_store_set(int /*long*/ store, int /*long*/ iter, int column, long value, int /*long*/ terminator) {
+	lock.lock();
+	try {
+		_gtk_tree_store_set(store, iter, column, value, terminator);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_tree_store_set(int /*long*/ store, int /*long*/ iter, int column, GdkColor value, int /*long*/ terminator);
+public static final void gtk_tree_store_set(int /*long*/ store, int /*long*/ iter, int column, GdkColor value, int /*long*/ terminator) {
+	lock.lock();
+	try {
+		_gtk_tree_store_set(store, iter, column, value, terminator);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_tree_store_set(int /*long*/ store, int /*long*/ iter, int column, boolean value, int /*long*/ terminator);
+public static final void gtk_tree_store_set(int /*long*/ store, int /*long*/ iter, int column, boolean value, int /*long*/ terminator) {
+	lock.lock();
+	try {
+		_gtk_tree_store_set(store, iter, column, value, terminator);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_tree_view_create_row_drag_icon(int /*long*/ view, int /*long*/ path);
+public static final int /*long*/ gtk_tree_view_create_row_drag_icon(int /*long*/ view, int /*long*/ path) {
+	lock.lock();
+	try {
+		return _gtk_tree_view_create_row_drag_icon(view, path);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _gtk_tree_view_collapse_row(int /*long*/ view, int /*long*/ path);
+public static final boolean gtk_tree_view_collapse_row(int /*long*/ view, int /*long*/ path) {
+	lock.lock();
+	try {
+		return _gtk_tree_view_collapse_row(view, path);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_tree_view_column_add_attribute(int /*long*/ treeColumn, int /*long*/ cellRenderer, byte[] attribute, int column);
+public static final void gtk_tree_view_column_add_attribute(int /*long*/ treeColumn, int /*long*/ cellRenderer, byte[] attribute, int column) {
+	lock.lock();
+	try {
+		_gtk_tree_view_column_add_attribute(treeColumn, cellRenderer, attribute, column);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _gtk_tree_view_column_cell_get_position(int /*long*/ tree_column, int /*long*/ cell_renderer, int[] start_pos, int[] width);
+public static final boolean gtk_tree_view_column_cell_get_position(int /*long*/ tree_column, int /*long*/ cell_renderer, int[] start_pos, int[] width) {
+	lock.lock();
+	try {
+		return _gtk_tree_view_column_cell_get_position(tree_column, cell_renderer, start_pos, width);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_tree_view_column_cell_get_size(int /*long*/ tree_column, GdkRectangle cell_area, int[] x_offset, int[] y_offset, int[] width, int[] height);
+public static final void gtk_tree_view_column_cell_get_size(int /*long*/ tree_column, GdkRectangle cell_area, int[] x_offset, int[] y_offset, int[] width, int[] height) {
+	lock.lock();
+	try {
+		_gtk_tree_view_column_cell_get_size(tree_column, cell_area, x_offset, y_offset, width, height);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_tree_view_column_cell_set_cell_data(int /*long*/ tree_column, int /*long*/ tree_model, int /*long*/ iter, boolean is_expander, boolean is_expanded);
+public static final void gtk_tree_view_column_cell_set_cell_data(int /*long*/ tree_column, int /*long*/ tree_model, int /*long*/ iter, boolean is_expander, boolean is_expanded) {
+	lock.lock();
+	try {
+		_gtk_tree_view_column_cell_set_cell_data(tree_column, tree_model, iter, is_expander, is_expanded);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_tree_view_column_clear(int /*long*/ tree_column);
+public static final void gtk_tree_view_column_clear(int /*long*/ tree_column) {
+	lock.lock();
+	try {
+		_gtk_tree_view_column_clear(tree_column);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_tree_view_column_get_cell_renderers(int /*long*/ tree_column);
+public static final int /*long*/ gtk_tree_view_column_get_cell_renderers(int /*long*/ tree_column) {
+	lock.lock();
+	try {
+		return _gtk_tree_view_column_get_cell_renderers(tree_column);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _gtk_tree_view_column_get_fixed_width(int /*long*/ column);
+public static final int gtk_tree_view_column_get_fixed_width(int /*long*/ column) {
+	lock.lock();
+	try {
+		return _gtk_tree_view_column_get_fixed_width(column);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _gtk_tree_view_column_get_reorderable(int /*long*/ column);
+public static final boolean gtk_tree_view_column_get_reorderable(int /*long*/ column) {
+	lock.lock();
+	try {
+		return _gtk_tree_view_column_get_reorderable(column);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _gtk_tree_view_column_get_resizable(int /*long*/ column);
+public static final boolean gtk_tree_view_column_get_resizable(int /*long*/ column) {
+	lock.lock();
+	try {
+		return _gtk_tree_view_column_get_resizable(column);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _gtk_tree_view_column_get_sizing(int /*long*/ tree_column);
+public static final int gtk_tree_view_column_get_sizing(int /*long*/ tree_column) {
+	lock.lock();
+	try {
+		return _gtk_tree_view_column_get_sizing(tree_column);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _gtk_tree_view_column_get_spacing(int /*long*/ tree_column);
+public static final int gtk_tree_view_column_get_spacing(int /*long*/ tree_column) {
+	lock.lock();
+	try {
+		return _gtk_tree_view_column_get_spacing(tree_column);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _gtk_tree_view_column_get_visible(int /*long*/ column);
+public static final boolean gtk_tree_view_column_get_visible(int /*long*/ column) {
+	lock.lock();
+	try {
+		return _gtk_tree_view_column_get_visible(column);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _gtk_tree_view_column_get_sort_indicator(int /*long*/ tree_column);
+public static final boolean gtk_tree_view_column_get_sort_indicator(int /*long*/ tree_column) {
+	lock.lock();
+	try {
+		return _gtk_tree_view_column_get_sort_indicator(tree_column);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _gtk_tree_view_column_get_sort_order(int /*long*/ tree_column);
+public static final int gtk_tree_view_column_get_sort_order(int /*long*/ tree_column) {
+	lock.lock();
+	try {
+		return _gtk_tree_view_column_get_sort_order(tree_column);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _gtk_tree_view_column_get_width(int /*long*/ column);
+public static final int gtk_tree_view_column_get_width(int /*long*/ column) {
+	lock.lock();
+	try {
+		return _gtk_tree_view_column_get_width(column);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_tree_view_column_new();
+public static final int /*long*/ gtk_tree_view_column_new() {
+	lock.lock();
+	try {
+		return _gtk_tree_view_column_new();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_tree_view_column_pack_start(int /*long*/ tree_column, int /*long*/ cell_renderer, boolean expand);
+public static final void gtk_tree_view_column_pack_start(int /*long*/ tree_column, int /*long*/ cell_renderer, boolean expand) {
+	lock.lock();
+	try {
+		_gtk_tree_view_column_pack_start(tree_column, cell_renderer, expand);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_tree_view_column_pack_end(int /*long*/ tree_column, int /*long*/ cell_renderer, boolean expand);
+public static final void gtk_tree_view_column_pack_end(int /*long*/ tree_column, int /*long*/ cell_renderer, boolean expand) {
+	lock.lock();
+	try {
+		_gtk_tree_view_column_pack_end(tree_column, cell_renderer, expand);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_tree_view_column_set_alignment(int /*long*/ tree_column, float xalign);
+public static final void gtk_tree_view_column_set_alignment(int /*long*/ tree_column, float xalign) {
+	lock.lock();
+	try {
+		_gtk_tree_view_column_set_alignment(tree_column, xalign);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_tree_view_column_set_cell_data_func(int /*long*/ tree_column, int /*long*/ cell_renderer, int /*long*/ func, int /*long*/ func_data, int /*long*/ destroy);
+public static final void gtk_tree_view_column_set_cell_data_func(int /*long*/ tree_column, int /*long*/ cell_renderer, int /*long*/ func, int /*long*/ func_data, int /*long*/ destroy) {
+	lock.lock();
+	try {
+		_gtk_tree_view_column_set_cell_data_func(tree_column, cell_renderer, func, func_data, destroy);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_tree_view_column_set_clickable(int /*long*/ column, boolean clickable);
+public static final void gtk_tree_view_column_set_clickable(int /*long*/ column, boolean clickable) {
+	lock.lock();
+	try {
+		_gtk_tree_view_column_set_clickable(column, clickable);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_tree_view_column_set_fixed_width(int /*long*/ column, int fixed_width);
+public static final void gtk_tree_view_column_set_fixed_width(int /*long*/ column, int fixed_width) {
+	lock.lock();
+	try {
+		_gtk_tree_view_column_set_fixed_width(column, fixed_width);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_tree_view_column_set_min_width(int /*long*/ tree_column, int min_width);
+public static final void gtk_tree_view_column_set_min_width(int /*long*/ tree_column, int min_width) {
+	lock.lock();
+	try {
+		_gtk_tree_view_column_set_min_width(tree_column, min_width);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_tree_view_column_set_reorderable(int /*long*/ column, boolean reorderable);
+public static final void gtk_tree_view_column_set_reorderable(int /*long*/ column, boolean reorderable) {
+	lock.lock();
+	try {
+		_gtk_tree_view_column_set_reorderable(column, reorderable);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_tree_view_column_set_resizable(int /*long*/ column, boolean resizable);
+public static final void gtk_tree_view_column_set_resizable(int /*long*/ column, boolean resizable) {
+	lock.lock();
+	try {
+		_gtk_tree_view_column_set_resizable(column, resizable);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_tree_view_column_set_sizing(int /*long*/ column, int type);
+public static final void gtk_tree_view_column_set_sizing(int /*long*/ column, int type) {
+	lock.lock();
+	try {
+		_gtk_tree_view_column_set_sizing(column, type);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_tree_view_column_set_sort_indicator(int /*long*/ tree_column, boolean setting);
+public static final void gtk_tree_view_column_set_sort_indicator(int /*long*/ tree_column, boolean setting) {
+	lock.lock();
+	try {
+		_gtk_tree_view_column_set_sort_indicator(tree_column, setting);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_tree_view_column_set_sort_order(int /*long*/ tree_column, int order);
+public static final void gtk_tree_view_column_set_sort_order(int /*long*/ tree_column, int order) {
+	lock.lock();
+	try {
+		_gtk_tree_view_column_set_sort_order(tree_column, order);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_tree_view_column_set_title(int /*long*/ tree_column, byte[] title);
+public static final void gtk_tree_view_column_set_title(int /*long*/ tree_column, byte[] title) {
+	lock.lock();
+	try {
+		_gtk_tree_view_column_set_title(tree_column, title);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_tree_view_column_set_visible (int /*long*/ tree_column, boolean visible);
+public static final void gtk_tree_view_column_set_visible (int /*long*/ tree_column, boolean visible) {
+	lock.lock();
+	try {
+		_gtk_tree_view_column_set_visible(tree_column, visible);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_tree_view_column_set_widget(int /*long*/ tree_column, int /*long*/ widget);
+public static final void gtk_tree_view_column_set_widget(int /*long*/ tree_column, int /*long*/ widget) {
+	lock.lock();
+	try {
+		_gtk_tree_view_column_set_widget(tree_column, widget);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_tree_view_set_drag_dest_row(int /*long*/ view, int /*long*/ path, int pos);
+public static final void gtk_tree_view_set_drag_dest_row(int /*long*/ view, int /*long*/ path, int pos) {
+	lock.lock();
+	try {
+		_gtk_tree_view_set_drag_dest_row(view, path, pos);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_tree_view_set_enable_search (int /*long*/ view, boolean enable_search);
+public static final void gtk_tree_view_set_enable_search (int /*long*/ view, boolean enable_search) {
+	lock.lock();
+	try {
+		_gtk_tree_view_set_enable_search(view, enable_search);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _gtk_tree_view_expand_row(int /*long*/ view, int /*long*/ path, boolean open_all);
+public static final boolean gtk_tree_view_expand_row(int /*long*/ view, int /*long*/ path, boolean open_all) {
+	lock.lock();
+	try {
+		return _gtk_tree_view_expand_row(view, path, open_all);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_tree_view_get_background_area(int /*long*/ tree_view, int /*long*/ path, int /*long*/ column, GdkRectangle rect);
+public static final void gtk_tree_view_get_background_area(int /*long*/ tree_view, int /*long*/ path, int /*long*/ column, GdkRectangle rect) {
+	lock.lock();
+	try {
+		_gtk_tree_view_get_background_area(tree_view, path, column, rect);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_tree_view_get_bin_window(int /*long*/ tree_view);
+public static final int /*long*/ gtk_tree_view_get_bin_window(int /*long*/ tree_view) {
+	lock.lock();
+	try {
+		return _gtk_tree_view_get_bin_window(tree_view);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_tree_view_get_cell_area(int /*long*/ tree_view, int /*long*/ path, int /*long*/ column, GdkRectangle rect);
+public static final void gtk_tree_view_get_cell_area(int /*long*/ tree_view, int /*long*/ path, int /*long*/ column, GdkRectangle rect) {
+	lock.lock();
+	try {
+		_gtk_tree_view_get_cell_area(tree_view, path, column, rect);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/_gtk_tree_view_get_expander_column(int /*long*/ tree_view);
+public static final int /*long*/gtk_tree_view_get_expander_column(int /*long*/ tree_view) {
+	lock.lock();
+	try {
+		return _gtk_tree_view_get_expander_column(tree_view);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_tree_view_get_column(int /*long*/ tree_view, int n);
+public static final int /*long*/ gtk_tree_view_get_column(int /*long*/ tree_view, int n) {
+	lock.lock();
+	try {
+		return _gtk_tree_view_get_column(tree_view, n);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_tree_view_get_columns(int /*long*/ tree_view);
+public static final int /*long*/ gtk_tree_view_get_columns(int /*long*/ tree_view) {
+	lock.lock();
+	try {
+		return _gtk_tree_view_get_columns(tree_view);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_tree_view_get_cursor(int /*long*/ tree_view, int /*long*/[] path, int /*long*/[] focus_column);
+public static final void gtk_tree_view_get_cursor(int /*long*/ tree_view, int /*long*/[] path, int /*long*/[] focus_column) {
+	lock.lock();
+	try {
+		_gtk_tree_view_get_cursor(tree_view, path, focus_column);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _gtk_tree_view_get_headers_visible(int /*long*/ tree_view);
+public static final boolean gtk_tree_view_get_headers_visible(int /*long*/ tree_view) {
+	lock.lock();
+	try {
+		return _gtk_tree_view_get_headers_visible(tree_view);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _gtk_tree_view_get_path_at_pos(int /*long*/ tree_view, int x, int y, int /*long*/[] path, int /*long*/[] column, int[] cell_x, int[] cell_y);
+public static final boolean gtk_tree_view_get_path_at_pos(int /*long*/ tree_view, int x, int y, int /*long*/[] path, int /*long*/[] column, int[] cell_x, int[] cell_y) {
+	lock.lock();
+	try {
+		return _gtk_tree_view_get_path_at_pos(tree_view, x, y, path, column, cell_x, cell_y);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _gtk_tree_view_get_rules_hint(int /*long*/ tree_view);
+public static final boolean gtk_tree_view_get_rules_hint(int /*long*/ tree_view) {
+	lock.lock();
+	try {
+		return _gtk_tree_view_get_rules_hint(tree_view);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_tree_view_get_selection(int /*long*/ tree_view);
+public static final int /*long*/ gtk_tree_view_get_selection(int /*long*/ tree_view) {
+	lock.lock();
+	try {
+		return _gtk_tree_view_get_selection(tree_view);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_tree_view_get_visible_rect(int /*long*/ tree_view, GdkRectangle visible_rect);
+public static final void gtk_tree_view_get_visible_rect(int /*long*/ tree_view, GdkRectangle visible_rect) {
+	lock.lock();
+	try {
+		_gtk_tree_view_get_visible_rect(tree_view, visible_rect);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _gtk_tree_view_insert_column(int /*long*/ tree_view, int /*long*/ column, int position);
+public static final int gtk_tree_view_insert_column(int /*long*/ tree_view, int /*long*/ column, int position) {
+	lock.lock();
+	try {
+		return _gtk_tree_view_insert_column(tree_view, column, position);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_tree_view_move_column_after(int /*long*/ tree_view, int /*long*/ column, int /*long*/ base_column);
+public static final void gtk_tree_view_move_column_after(int /*long*/ tree_view, int /*long*/ column, int /*long*/base_column) {
+	lock.lock();
+	try {
+		_gtk_tree_view_move_column_after(tree_view, column, base_column);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_tree_view_new_with_model(int /*long*/ model);
+public static final int /*long*/ gtk_tree_view_new_with_model(int /*long*/ model) {
+	lock.lock();
+	try {
+		return _gtk_tree_view_new_with_model(model);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_tree_view_remove_column(int /*long*/ tree_view, int /*long*/ column);
+public static final void gtk_tree_view_remove_column(int /*long*/ tree_view, int /*long*/ column) {
+	lock.lock();
+	try {
+		_gtk_tree_view_remove_column(tree_view, column);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _gtk_tree_view_row_expanded(int /*long*/ view, int /*long*/ path);
+public static final boolean gtk_tree_view_row_expanded(int /*long*/ view, int /*long*/ path) {
+	lock.lock();
+	try {
+		return _gtk_tree_view_row_expanded(view, path);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_tree_view_scroll_to_cell(int /*long*/ tree_view, int /*long*/ path, int /*long*/ column, boolean use_align, float row_aligh, float column_align);
+public static final void gtk_tree_view_scroll_to_cell(int /*long*/ tree_view, int /*long*/ path, int /*long*/ column, boolean use_align, float row_aligh, float column_align) {
+	lock.lock();
+	try {
+		_gtk_tree_view_scroll_to_cell(tree_view, path, column, use_align, row_aligh, column_align);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_tree_view_scroll_to_point (int /*long*/ tree_view, int tree_x, int tree_y);
+public static final void gtk_tree_view_scroll_to_point (int /*long*/ tree_view, int tree_x, int tree_y) {
+	lock.lock();
+	try {
+		_gtk_tree_view_scroll_to_point(tree_view, tree_x, tree_y);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_tree_view_set_cursor(int /*long*/ tree_view, int /*long*/ path, int /*long*/ focus_column, boolean start_editing);
+public static final void gtk_tree_view_set_cursor(int /*long*/ tree_view, int /*long*/ path, int /*long*/ focus_column, boolean start_editing) {
+	lock.lock();
+	try {
+		_gtk_tree_view_set_cursor(tree_view, path, focus_column, start_editing);
+	} finally {
+		lock.unlock();
+	}
+} 
+public static final native void _gtk_tree_view_set_headers_visible(int /*long*/ tree_view, boolean visible);
+public static final void gtk_tree_view_set_headers_visible(int /*long*/ tree_view, boolean visible) {
+	lock.lock();
+	try {
+		_gtk_tree_view_set_headers_visible(tree_view, visible);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_tree_view_set_model(int /*long*/ tree_view, int /*long*/ model);
+public static final void gtk_tree_view_set_model(int /*long*/ tree_view, int /*long*/ model) {
+	lock.lock();
+	try {
+		_gtk_tree_view_set_model(tree_view, model);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_tree_view_set_rules_hint(int /*long*/ tree_view, boolean setting);
+public static final void gtk_tree_view_set_rules_hint(int /*long*/ tree_view, boolean setting) {
+	lock.lock();
+	try {
+		_gtk_tree_view_set_rules_hint(tree_view, setting);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_tree_view_set_search_column(int /*long*/ tree_view, int column);
+public static final void gtk_tree_view_set_search_column(int /*long*/ tree_view, int column) {
+	lock.lock();
+	try {
+		_gtk_tree_view_set_search_column(tree_view, column);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_tree_view_tree_to_widget_coords(int /*long*/ tree_view, int tx, int ty, int[] wx, int[] wy);
+public static final void gtk_tree_view_tree_to_widget_coords(int /*long*/ tree_view, int tx, int ty, int[] wx, int[] wy) {
+	lock.lock();
+	try {
+		_gtk_tree_view_tree_to_widget_coords(tree_view, tx, ty, wx, wy);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_tree_view_unset_rows_drag_dest(int /*long*/ tree_view);
+public static final void gtk_tree_view_unset_rows_drag_dest(int /*long*/ tree_view) {
+	lock.lock();
+	try {
+		_gtk_tree_view_unset_rows_drag_dest(tree_view);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_tree_view_widget_to_tree_coords(int /*long*/ tree_view, int wx, int wy, int[] tx, int[] ty);
+public static final void gtk_tree_view_widget_to_tree_coords(int /*long*/ tree_view, int wx, int wy, int[] tx, int[] ty) {
+	lock.lock();
+	try {
+		_gtk_tree_view_widget_to_tree_coords(tree_view, wx, wy, tx, ty);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_vbox_new(boolean homogeneous, int spacing);
+public static final int /*long*/ gtk_vbox_new(boolean homogeneous, int spacing) {
+	lock.lock();
+	try {
+		return _gtk_vbox_new(homogeneous, spacing);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_vscale_new(int /*long*/ adjustment);
+public static final int /*long*/ gtk_vscale_new(int /*long*/ adjustment) {
+	lock.lock();
+	try {
+		return _gtk_vscale_new(adjustment);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_vscrollbar_new(int /*long*/ adjustment);
+public static final int /*long*/ gtk_vscrollbar_new(int /*long*/ adjustment) {
+	lock.lock();
+	try {
+		return _gtk_vscrollbar_new(adjustment);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_vseparator_new();
+public static final int /*long*/ gtk_vseparator_new() {
+	lock.lock();
+	try {
+		return _gtk_vseparator_new();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_widget_add_accelerator(int /*long*/ widget, byte[] accel_signal, int /*long*/ accel_group, int accel_key, int accel_mods, int accel_flags);
+public static final void gtk_widget_add_accelerator(int /*long*/ widget, byte[] accel_signal, int /*long*/ accel_group, int accel_key, int accel_mods, int accel_flags) {
+	lock.lock();
+	try {
+		_gtk_widget_add_accelerator(widget, accel_signal, accel_group, accel_key, accel_mods, accel_flags);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_widget_add_events(int /*long*/ widget, int events);
+public static final void gtk_widget_add_events(int /*long*/ widget, int events) {
+	lock.lock();
+	try {
+		_gtk_widget_add_events(widget, events);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _gtk_widget_child_focus(int /*long*/ widget, int direction);
+public static final boolean gtk_widget_child_focus(int /*long*/ widget, int direction) {
+	lock.lock();
+	try {
+		return _gtk_widget_child_focus(widget, direction);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_widget_create_pango_layout(int /*long*/ widget, byte[] text);
+public static final int /*long*/ gtk_widget_create_pango_layout(int /*long*/ widget, byte[] text) {
+	lock.lock();
+	try {
+		return _gtk_widget_create_pango_layout(widget, text);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_widget_create_pango_layout(int /*long*/ widget, int /*long*/ text);
+public static final int /*long*/ gtk_widget_create_pango_layout(int /*long*/ widget, int /*long*/ text) {
+	lock.lock();
+	try {
+		return _gtk_widget_create_pango_layout(widget, text);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_widget_destroy(int /*long*/ widget);
+public static final void gtk_widget_destroy(int /*long*/ widget) {
+	lock.lock();
+	try {
+		_gtk_widget_destroy(widget);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _gtk_widget_event(int /*long*/ widget, int /*long*/ event);
+public static final boolean gtk_widget_event(int /*long*/ widget, int /*long*/ event) {
+	lock.lock();
+	try {
+		return _gtk_widget_event(widget, event);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_widget_get_accessible (int /*long*/ widget);
+public static final int /*long*/ gtk_widget_get_accessible (int /*long*/ widget) {
+	lock.lock();
+	try {
+		return _gtk_widget_get_accessible(widget);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _gtk_widget_get_child_visible (int /*long*/ widget);
+public static final boolean gtk_widget_get_child_visible (int /*long*/ widget) {
+	lock.lock();
+	try {
+		return _gtk_widget_get_child_visible(widget);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _gtk_widget_get_default_direction();
+public static final int gtk_widget_get_default_direction() {
+	lock.lock();
+	try {
+		return _gtk_widget_get_default_direction();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_widget_get_default_style();
+public static final int /*long*/ gtk_widget_get_default_style() {
+	lock.lock();
+	try {
+		return _gtk_widget_get_default_style();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _gtk_widget_get_direction(int /*long*/ widget);
+public static final int gtk_widget_get_direction(int /*long*/ widget) {
+	lock.lock();
+	try {
+		return _gtk_widget_get_direction(widget);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _gtk_widget_get_events(int /*long*/ widget);
+public static final int gtk_widget_get_events(int /*long*/ widget) {
+	lock.lock();
+	try {
+		return _gtk_widget_get_events(widget);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_widget_get_modifier_style(int /*long*/ widget);
+public static final int /*long*/ gtk_widget_get_modifier_style(int /*long*/ widget) {
+	lock.lock();
+	try {
+		return _gtk_widget_get_modifier_style(widget);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_widget_get_pango_context(int /*long*/ widget);
+public static final int /*long*/ gtk_widget_get_pango_context(int /*long*/ widget) {
+	lock.lock();
+	try {
+		return _gtk_widget_get_pango_context(widget);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_widget_get_parent(int /*long*/ widget);
+public static final int /*long*/ gtk_widget_get_parent(int /*long*/ widget) {
+	lock.lock();
+	try {
+		return _gtk_widget_get_parent(widget);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_widget_get_style(int /*long*/ widget);
+public static final int /*long*/ gtk_widget_get_style(int /*long*/ widget) {
+	lock.lock();
+	try {
+		return _gtk_widget_get_style(widget);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_widget_get_size_request(int /*long*/ widget, int [] width, int [] height);
+public static final void gtk_widget_get_size_request(int /*long*/ widget, int [] width, int [] height) {
+	lock.lock();
+	try {
+		_gtk_widget_get_size_request(widget, width, height);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_widget_get_toplevel (int /*long*/ widget);
+public static final int /*long*/ gtk_widget_get_toplevel (int /*long*/ widget) {
+	lock.lock();
+	try {
+		return _gtk_widget_get_toplevel(widget);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_widget_grab_focus(int /*long*/ widget);
+public static final void gtk_widget_grab_focus(int /*long*/ widget) {
+	lock.lock();
+	try {
+		_gtk_widget_grab_focus(widget);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_widget_hide(int /*long*/ widget);
+public static final void gtk_widget_hide(int /*long*/ widget) {
+	lock.lock();
+	try {
+		_gtk_widget_hide(widget);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _gtk_widget_is_composited(int /*long*/ widget);
+public static final boolean gtk_widget_is_composited(int /*long*/ widget) {
+	lock.lock();
+	try {
+		return _gtk_widget_is_composited(widget);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _gtk_widget_is_focus(int /*long*/ widget);
+public static final boolean gtk_widget_is_focus(int /*long*/ widget) {
+	lock.lock();
+	try {
+		return _gtk_widget_is_focus(widget);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_widget_map(int /*long*/ widget);
+public static final void gtk_widget_map(int /*long*/ widget) {
+	lock.lock();
+	try {
+		_gtk_widget_map(widget);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _gtk_widget_mnemonic_activate(int /*long*/ widget, boolean group_cycling);
+public static final boolean gtk_widget_mnemonic_activate(int /*long*/ widget, boolean group_cycling) {
+	lock.lock();
+	try {
+		return _gtk_widget_mnemonic_activate(widget, group_cycling);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_widget_modify_base(int /*long*/ widget, int state, GdkColor color);
+public static final void gtk_widget_modify_base(int /*long*/ widget, int state, GdkColor color) {
+	lock.lock();
+	try {
+		_gtk_widget_modify_base(widget, state, color);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_widget_modify_bg(int /*long*/ widget, int state, GdkColor color);
+public static final void gtk_widget_modify_bg(int /*long*/ widget, int state, GdkColor color) {
+	lock.lock();
+	try {
+		_gtk_widget_modify_bg(widget, state, color);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_widget_modify_fg(int /*long*/ widget, int state, GdkColor color);
+public static final void gtk_widget_modify_fg(int /*long*/ widget, int state, GdkColor color) {
+	lock.lock();
+	try {
+		_gtk_widget_modify_fg(widget, state, color);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_widget_modify_font(int /*long*/ widget, int /*long*/ pango_font_descr);
+public static final void gtk_widget_modify_font(int /*long*/ widget, int /*long*/ pango_font_descr) {
+	lock.lock();
+	try {
+		_gtk_widget_modify_font(widget, pango_font_descr);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_widget_modify_style(int /*long*/ widget, int /*long*/ style);
+public static final void gtk_widget_modify_style(int /*long*/ widget, int /*long*/ style) {
+	lock.lock();
+	try {
+		_gtk_widget_modify_style(widget, style);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_widget_modify_text(int /*long*/ widget, int state, GdkColor color);
+public static final void gtk_widget_modify_text(int /*long*/ widget, int state, GdkColor color) {
+	lock.lock();
+	try {
+		_gtk_widget_modify_text(widget, state, color);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_widget_queue_resize(int /*long*/ widget);
+public static final void gtk_widget_queue_resize(int /*long*/ widget) {
+	lock.lock();
+	try {
+		_gtk_widget_queue_resize(widget);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_widget_realize(int /*long*/ widget);
+public static final void gtk_widget_realize(int /*long*/ widget) {
+	lock.lock();
+	try {
+		_gtk_widget_realize(widget);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_widget_remove_accelerator(int /*long*/ widget, int /*long*/ accel_group, int accel_key, int accel_mods);
+public static final void gtk_widget_remove_accelerator(int /*long*/ widget, int /*long*/ accel_group, int accel_key, int accel_mods) {
+	lock.lock();
+	try {
+		_gtk_widget_remove_accelerator(widget, accel_group, accel_key, accel_mods);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_widget_reparent(int /*long*/ widget, int /*long*/ new_parent);
+public static final void gtk_widget_reparent(int /*long*/ widget, int /*long*/ new_parent) {
+	lock.lock();
+	try {
+		_gtk_widget_reparent(widget, new_parent);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _gtk_widget_send_expose(int /*long*/ widget, int /*long*/ event);
+public static final int gtk_widget_send_expose(int /*long*/ widget, int /*long*/ event) {
+	lock.lock();
+	try {
+		return _gtk_widget_send_expose(widget, event);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_widget_set_app_paintable(int /*long*/ widget, boolean app_paintable);
+public static final void gtk_widget_set_app_paintable(int /*long*/ widget, boolean app_paintable) {
+	lock.lock();
+	try {
+		_gtk_widget_set_app_paintable(widget, app_paintable);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_widget_set_default_direction(int dir);
+public static final void gtk_widget_set_default_direction(int dir) {
+	lock.lock();
+	try {
+		_gtk_widget_set_default_direction(dir);
+	} finally {
+		lock.unlock();
+	}
+} 
+public static final native void _gtk_widget_set_direction(int /*long*/ widget, int dir);
+public static final void gtk_widget_set_direction(int /*long*/ widget, int dir) {
+	lock.lock();
+	try {
+		_gtk_widget_set_direction(widget, dir);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_widget_set_double_buffered(int /*long*/ widget, boolean double_buffered);
+public static final void gtk_widget_set_double_buffered(int /*long*/ widget, boolean double_buffered) {
+	lock.lock();
+	try {
+		_gtk_widget_set_double_buffered(widget, double_buffered);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_widget_set_name(int /*long*/ widget, byte[] name);
+public static final void gtk_widget_set_name(int /*long*/ widget, byte[] name) {
+	lock.lock();
+	try {
+		_gtk_widget_set_name(widget, name);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_widget_set_redraw_on_allocate(int /*long*/ widget, boolean redraw);
+public static final void gtk_widget_set_redraw_on_allocate(int /*long*/ widget, boolean redraw) {
+	lock.lock();
+	try {
+		_gtk_widget_set_redraw_on_allocate(widget, redraw);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_widget_set_sensitive(int /*long*/ widget, boolean sensitive);
+public static final void gtk_widget_set_sensitive(int /*long*/ widget, boolean sensitive) {
+	lock.lock();
+	try {
+		_gtk_widget_set_sensitive(widget, sensitive);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_widget_set_size_request(int /*long*/ widget, int width, int height);
+public static final void gtk_widget_set_size_request(int /*long*/ widget, int width, int height) {
+	lock.lock();
+	try {
+		_gtk_widget_set_size_request(widget, width, height);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_widget_set_state(int /*long*/ widget, int state);
+public static final void gtk_widget_set_state(int /*long*/ widget, int state) {
+	lock.lock();
+	try {
+		_gtk_widget_set_state(widget, state);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_widget_set_style(int /*long*/ widget, int /*long*/ style);
+public static final void gtk_widget_set_style(int /*long*/ widget, int /*long*/ style) {
+	lock.lock();
+	try {
+		_gtk_widget_set_style(widget, style);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_widget_shape_combine_mask(int /*long*/ widget, int /*long*/ shape_mask, int offset_x, int offset_y);
+public static final void gtk_widget_shape_combine_mask(int /*long*/ widget, int /*long*/ shape_mask, int offset_x, int offset_y) {
+	lock.lock();
+	try {
+		_gtk_widget_shape_combine_mask(widget, shape_mask, offset_x, offset_y);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_widget_show(int /*long*/ widget);
+public static final void gtk_widget_show(int /*long*/ widget) {
+	lock.lock();
+	try {
+		_gtk_widget_show(widget);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_widget_show_now(int /*long*/ widget);
+public static final void gtk_widget_show_now(int /*long*/ widget) {
+	lock.lock();
+	try {
+		_gtk_widget_show_now(widget);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_widget_size_allocate(int /*long*/ widget, GtkAllocation allocation);
+public static final void gtk_widget_size_allocate(int /*long*/ widget, GtkAllocation allocation) {
+	lock.lock();
+	try {
+		_gtk_widget_size_allocate(widget, allocation);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_widget_size_request(int /*long*/ widget, GtkRequisition requisition);
+public static final void gtk_widget_size_request(int /*long*/ widget, GtkRequisition requisition) {
+	lock.lock();
+	try {
+		_gtk_widget_size_request(widget, requisition);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_widget_style_get(int /*long*/ widget, byte[] property_name, int[] value, int /*long*/ terminator);
+public static final void gtk_widget_style_get(int /*long*/ widget, byte[] property_name, int[] value, int /*long*/ terminator) {
+	lock.lock();
+	try {
+		_gtk_widget_style_get(widget, property_name, value, terminator);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_widget_style_get(int /*long*/ widget, byte[] property_name, long[] value, int /*long*/ terminator);
+public static final void gtk_widget_style_get(int /*long*/ widget, byte[] property_name, long[] value, int /*long*/ terminator) {
+	lock.lock();
+	try {
+		_gtk_widget_style_get(widget, property_name, value, terminator);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _gtk_widget_translate_coordinates(int /*long*/ src_widget, int /*long*/ dest_widget, int src_x, int src_y, int[] dest_x, int[] dest_y);
+public static final boolean gtk_widget_translate_coordinates(int /*long*/ src_widget, int /*long*/ dest_widget, int src_x, int src_y, int[] dest_x, int[] dest_y) {
+	lock.lock();
+	try {
+		return _gtk_widget_translate_coordinates(src_widget, dest_widget, src_x, src_y, dest_x, dest_y);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_widget_unrealize(int /*long*/ widget);
+public static final void gtk_widget_unrealize(int /*long*/ widget) {
+	lock.lock();
+	try {
+		_gtk_widget_unrealize(widget);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _gtk_window_activate_default(int /*long*/ window);
+public static final boolean gtk_window_activate_default(int /*long*/ window) {
+	lock.lock();
+	try {
+		return _gtk_window_activate_default(window);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_window_add_accel_group(int /*long*/ window, int /*long*/ accel_group);
+public static final void gtk_window_add_accel_group(int /*long*/ window, int /*long*/ accel_group) {
+	lock.lock();
+	try {
+		_gtk_window_add_accel_group(window, accel_group);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_window_deiconify(int /*long*/ handle);
+public static final void gtk_window_deiconify(int /*long*/ handle) {
+	lock.lock();
+	try {
+		_gtk_window_deiconify(handle);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_window_get_focus(int /*long*/ window);
+public static final int /*long*/ gtk_window_get_focus(int /*long*/ window) {
+	lock.lock();
+	try {
+		return _gtk_window_get_focus(window);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_window_get_group(int /*long*/ window);
+public static final int /*long*/ gtk_window_get_group(int /*long*/ window) {
+	lock.lock();
+	try {
+		return _gtk_window_get_group(window);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_window_get_icon_list(int /*long*/ window);
+public static final int /*long*/ gtk_window_get_icon_list(int /*long*/ window) {
+	lock.lock();
+	try {
+		return _gtk_window_get_icon_list(window);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _gtk_window_get_modal(int /*long*/ window);
+public static final boolean gtk_window_get_modal(int /*long*/ window) {
+	lock.lock();
+	try {
+		return _gtk_window_get_modal(window);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _gtk_window_get_mnemonic_modifier(int /*long*/ window);
+public static final int gtk_window_get_mnemonic_modifier(int /*long*/ window) {
+	lock.lock();
+	try {
+		return _gtk_window_get_mnemonic_modifier(window);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native double _gtk_window_get_opacity (int /*long*/ window);
+public static final double gtk_window_get_opacity (int /*long*/ window) {
+	lock.lock();
+	try {
+		return _gtk_window_get_opacity (window);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_window_get_position(int /*long*/ handle, int[] x, int[] y);
+public static final void gtk_window_get_position(int /*long*/ handle, int[] x, int[] y) {
+	lock.lock();
+	try {
+		_gtk_window_get_position(handle, x, y);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_window_get_size(int /*long*/ handle, int[] x, int[] y);
+public static final void gtk_window_get_size(int /*long*/ handle, int[] x, int[] y) {
+	lock.lock();
+	try {
+		_gtk_window_get_size(handle, x, y);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_window_group_add_window(int /*long*/ group, int /*long*/ window);
+public static final void gtk_window_group_add_window(int /*long*/ group, int /*long*/ window) {
+	lock.lock();
+	try {
+		_gtk_window_group_add_window(group, window);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_window_group_remove_window(int /*long*/ group, int /*long*/ window);
+public static final void gtk_window_group_remove_window(int /*long*/ group, int /*long*/ window) {
+	lock.lock();
+	try {
+		_gtk_window_group_remove_window(group, window);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_window_group_new();
+public static final int /*long*/ gtk_window_group_new() {
+	lock.lock();
+	try {
+		return _gtk_window_group_new();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_window_iconify(int /*long*/ handle);
+public static final void gtk_window_iconify(int /*long*/ handle) {
+	lock.lock();
+	try {
+		_gtk_window_iconify(handle);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_window_list_toplevels ();
+public static final int /*long*/ gtk_window_list_toplevels () {
+	lock.lock();
+	try {
+		return _gtk_window_list_toplevels ();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_window_maximize(int /*long*/ handle);
+public static final void gtk_window_maximize(int /*long*/ handle) {
+	lock.lock();
+	try {
+		_gtk_window_maximize(handle);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_window_fullscreen(int /*long*/ handle);
+public static final void gtk_window_fullscreen(int /*long*/ handle) {
+	lock.lock();
+	try {
+		_gtk_window_fullscreen(handle);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_window_unfullscreen(int /*long*/ handle);
+public static final void gtk_window_unfullscreen(int /*long*/ handle) {
+	lock.lock();
+	try {
+		_gtk_window_unfullscreen(handle);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_window_move(int /*long*/ handle, int x, int y);
+public static final void gtk_window_move(int /*long*/ handle, int x, int y) {
+	lock.lock();
+	try {
+		_gtk_window_move(handle, x, y);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _gtk_window_new(int type);
+public static final int /*long*/ gtk_window_new(int type) {
+	lock.lock();
+	try {
+		return _gtk_window_new(type);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_window_present(int /*long*/ window);
+public static final void gtk_window_present(int /*long*/ window) {
+	lock.lock();
+	try {
+		_gtk_window_present(window);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_window_remove_accel_group(int /*long*/ window, int /*long*/ accel_group);
+public static final void gtk_window_remove_accel_group(int /*long*/ window, int /*long*/ accel_group) {
+	lock.lock();
+	try {
+		_gtk_window_remove_accel_group(window, accel_group);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_window_resize(int /*long*/ handle, int x, int y);
+public static final void gtk_window_resize(int /*long*/ handle, int x, int y) {
+	lock.lock();
+	try {
+		_gtk_window_resize(handle, x, y);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_window_set_default(int /*long*/ window, int /*long*/ widget);
+public static final void gtk_window_set_default(int /*long*/ window, int /*long*/ widget) {
+	lock.lock();
+	try {
+		_gtk_window_set_default(window, widget);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_window_set_destroy_with_parent(int /*long*/ window, boolean setting);
+public static final void gtk_window_set_destroy_with_parent(int /*long*/ window, boolean setting) {
+	lock.lock();
+	try {
+		_gtk_window_set_destroy_with_parent(window, setting);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_window_set_keep_below(int /*long*/ window, boolean setting);
+public static final void gtk_window_set_keep_below(int /*long*/ window,  boolean setting) {
+	lock.lock();
+	try {
+		_gtk_window_set_keep_below(window, setting);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_window_set_geometry_hints(int /*long*/ window, int /*long*/ geometry_widget, GdkGeometry geometry, int geom_mask);
+public static final void gtk_window_set_geometry_hints(int /*long*/ window, int /*long*/ geometry_widget, GdkGeometry geometry, int geom_mask) {
+	lock.lock();
+	try {
+		_gtk_window_set_geometry_hints(window, geometry_widget, geometry, geom_mask);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_window_set_icon_list(int /*long*/ window, int /*long*/ list);
+public static final void gtk_window_set_icon_list(int /*long*/ window, int /*long*/ list) {	
+	lock.lock();
+	try {
+		_gtk_window_set_icon_list(window, list);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_window_set_modal(int /*long*/ window, boolean modal);
+public static final void gtk_window_set_modal(int /*long*/ window, boolean modal) {
+	lock.lock();
+	try {
+		_gtk_window_set_modal(window, modal);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_window_set_opacity(int /*long*/ window, double opacity);
+public static final void gtk_window_set_opacity(int /*long*/ window, double opacity) {
+	lock.lock();
+	try {
+		 _gtk_window_set_opacity(window, opacity);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_widget_set_tooltip_text(int /*long*/ widget, byte[] tip_text);
+public static final void gtk_widget_set_tooltip_text(int /*long*/ widget, byte[] tip_text) {
+	lock.lock();
+	try {
+		_gtk_widget_set_tooltip_text(widget, tip_text);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_widget_set_parent_window(int /*long*/ widget, int /*long*/ parent_window);
+public static final void gtk_widget_set_parent_window(int /*long*/ widget, int /*long*/ parent_window) {	
+	lock.lock();
+	try {
+		_gtk_widget_set_parent_window(widget, parent_window);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_window_set_resizable(int /*long*/ window, boolean resizable);
+public static final void gtk_window_set_resizable(int /*long*/ window, boolean resizable) {
+	lock.lock();
+	try {
+		_gtk_window_set_resizable(window, resizable);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_window_set_title(int /*long*/ window, byte[] title);
+public static final void gtk_window_set_title(int /*long*/ window, byte[] title) {
+	lock.lock();
+	try {
+		_gtk_window_set_title(window, title);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_window_set_skip_taskbar_hint(int /*long*/ window, boolean skips_taskbar);
+public static final void gtk_window_set_skip_taskbar_hint(int /*long*/ window, boolean skips_taskbar) {
+	lock.lock();
+	try {
+		_gtk_window_set_skip_taskbar_hint(window, skips_taskbar);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_window_set_type_hint(int /*long*/ window, int hint);
+public static final void gtk_window_set_type_hint(int /*long*/ window, int hint) {
+	lock.lock();
+	try {
+		_gtk_window_set_type_hint(window, hint);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_window_set_transient_for(int /*long*/ window, int /*long*/ parent);
+public static final void gtk_window_set_transient_for(int /*long*/ window, int /*long*/ parent) {
+	lock.lock();
+	try {
+		_gtk_window_set_transient_for(window, parent);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _gtk_window_unmaximize(int /*long*/ handle);
+public static final void gtk_window_unmaximize(int /*long*/ handle) {
+	lock.lock();
+	try {
+		_gtk_window_unmaximize(handle);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void memmove(int /*long*/ dest, GInterfaceInfo src, int size);
+public static final native void memmove(int /*long*/ dest, GObjectClass src);
+public static final native void memmove(int /*long*/ dest, GTypeInfo src, int size);
+public static final native void memmove(int /*long*/ dest, GtkTargetEntry src, int /*long*/ size);
+public static final native void memmove(int /*long*/ dest, GtkAdjustment src);
+public static final native void memmove(int /*long*/ dest, GdkEventButton src, int /*long*/ size);
+public static final native void memmove(int /*long*/ dest, GdkEventExpose src, int /*long*/ size);
+public static final native void memmove(int /*long*/ dest, GdkEventMotion src, int /*long*/ size);
+public static final native void memmove(int /*long*/ dest, GtkWidgetClass src);
+public static final native void memmove(int /*long*/ dest, PangoAttribute src, int /*long*/ size);
+public static final native void memmove(GObjectClass  dest, int /*long*/ src);
+public static final native void memmove(GTypeQuery dest, int /*long*/ src, int /*long*/ size);
+public static final native void memmove(GtkColorSelectionDialog dest, int /*long*/ src);
+public static final native void memmove(GtkFileSelection dest, int /*long*/ src);
+public static final native void memmove(GdkDragContext dest, int /*long*/ src, int /*long*/ size);
+public static final native void memmove(GtkSelectionData dest, int /*long*/ src, int /*long*/ size);
+public static final native void memmove(GtkWidgetClass dest, int /*long*/ src);
+public static final native void memmove(GtkTargetPair dest, int /*long*/ src, int /*long*/ size);
+public static final native void memmove(GtkCombo dest, int /*long*/ src);
+public static final native void memmove(GtkAdjustment dest, int /*long*/ src);
+public static final native void memmove(GtkBorder dest, int /*long*/ src, int /*long*/ size);
+public static final native void memmove(GdkColor dest, int /*long*/ src, int /*long*/ size);
+public static final native void memmove(GdkEvent dest, int /*long*/ src, int /*long*/ size);
+public static final native void memmove(GdkEventAny dest, int /*long*/ src, int /*long*/ size);
+public static final native void memmove(GdkEventButton dest, int /*long*/ src, int /*long*/ size);
+public static final native void memmove(GdkEventCrossing dest, int /*long*/ src, int /*long*/ size);
+public static final native void memmove(GdkEventExpose dest, int /*long*/ src, int /*long*/ size);
+public static final native void memmove(GdkEventFocus dest, int /*long*/ src, int /*long*/ size);
+public static final native void memmove(GdkEventKey dest, int /*long*/ src, int /*long*/ size);
+public static final native void memmove(GdkEventMotion dest, int /*long*/ src, int /*long*/ size);
+public static final native void memmove(GdkEventScroll dest, int /*long*/ src, int /*long*/ size);
+public static final native void memmove(GdkEventVisibility dest, int /*long*/ src, int /*long*/ size);
+public static final native void memmove(GdkEventWindowState dest, int /*long*/ src, int /*long*/ size);
+public static final native void memmove(int /*long*/ dest, GtkCellRendererClass src);
+public static final native void memmove(GtkCellRendererClass dest, int /*long*/ src);
+public static final native void memmove(GtkFixed dest, int /*long*/ src);
+public static final native void memmove(int /*long*/ dest, GtkFixed src);
+public static final native void memmove(GdkVisual dest, int /*long*/ src);
+public static final native void memmove(GdkImage dest, int /*long*/ src);
+public static final native void memmove(GdkRectangle dest, int /*long*/ src, int /*long*/ size);
+public static final native void memmove(PangoAttribute dest, int /*long*/ src, int /*long*/ size);
+public static final native void memmove(PangoAttrColor dest, int /*long*/ src, int /*long*/ size);
+public static final native void memmove(PangoAttrInt dest, int /*long*/ src, int /*long*/ size);
+public static final native void memmove(PangoItem dest, int /*long*/ src, int /*long*/ size);
+public static final native void memmove(PangoLayoutLine dest, int /*long*/ src, int /*long*/ size);
+public static final native void memmove(PangoLayoutRun dest, int /*long*/ src, int /*long*/ size);
+public static final native void memmove(PangoLogAttr dest, int /*long*/ src, int /*long*/ size);
+public static final native int /*long*/ _pango_attr_background_new (short red, short green, short blue);
+public static final int /*long*/ pango_attr_background_new (short red, short green, short blue) {
+	lock.lock();
+	try {
+		return _pango_attr_background_new(red, green, blue);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _pango_attr_font_desc_new(int /*long*/ desc);
+public static final int /*long*/ pango_attr_font_desc_new(int /*long*/ desc) {
+	lock.lock();
+	try {
+		return _pango_attr_font_desc_new(desc);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _pango_attr_foreground_new (short red, short green, short blue);
+public static final int /*long*/ pango_attr_foreground_new (short red, short green, short blue) {
+	lock.lock();
+	try {
+		return _pango_attr_foreground_new(red, green, blue);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _pango_attr_rise_new(int rise);
+public static final int /*long*/ pango_attr_rise_new(int rise) {
+	lock.lock();
+	try {
+		return _pango_attr_rise_new(rise);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _pango_attr_shape_new(PangoRectangle ink_rect, PangoRectangle logical_rect);
+public static final int /*long*/ pango_attr_shape_new(PangoRectangle ink_rect, PangoRectangle logical_rect) {
+	lock.lock();
+	try {
+		return _pango_attr_shape_new(ink_rect, logical_rect);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _pango_attr_list_insert(int /*long*/ list, int /*long*/ attr);
+public static final void pango_attr_list_insert(int /*long*/ list, int /*long*/ attr) {
+	lock.lock();
+	try {
+		_pango_attr_list_insert(list, attr);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _pango_attr_list_change(int /*long*/ list, int /*long*/ attr);
+public static final void pango_attr_list_change(int /*long*/ list, int /*long*/ attr) {
+	lock.lock();
+	try {
+		_pango_attr_list_change(list, attr);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _pango_attr_list_get_iterator(int /*long*/ list);
+public static final int /*long*/ pango_attr_list_get_iterator(int /*long*/ list) {
+	lock.lock();
+	try {
+		return _pango_attr_list_get_iterator(list);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _pango_attr_iterator_next(int /*long*/ iterator);
+public static final boolean pango_attr_iterator_next(int /*long*/ iterator) {
+	lock.lock();
+	try {
+		return _pango_attr_iterator_next(iterator);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _pango_attr_iterator_range(int /*long*/ iterator, int[] start, int[] end);
+public static final void pango_attr_iterator_range(int /*long*/ iterator, int[] start, int[] end) {
+	lock.lock();
+	try {
+		_pango_attr_iterator_range(iterator, start, end);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _pango_attr_iterator_get(int /*long*/ iterator, int type);
+public static final int /*long*/ pango_attr_iterator_get(int /*long*/ iterator, int type) {
+	lock.lock();
+	try {
+		return _pango_attr_iterator_get(iterator, type);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _pango_attr_iterator_get_attrs(int /*long*/ iterator);
+public static final int /*long*/ pango_attr_iterator_get_attrs(int /*long*/ iterator) {
+	lock.lock();
+	try {
+		return _pango_attr_iterator_get_attrs(iterator);
+	} finally {
+		lock.unlock();
+	}
+}
+
+public static final native void _pango_attr_iterator_destroy(int /*long*/ iterator);
+public static final void pango_attr_iterator_destroy(int /*long*/ iterator) {
+	lock.lock();
+	try {
+		_pango_attr_iterator_destroy(iterator);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _pango_attr_list_new();
+public static final int /*long*/ pango_attr_list_new() {
+	lock.lock();
+	try {
+		return _pango_attr_list_new();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _pango_attr_list_unref(int /*long*/ list);
+public static final void pango_attr_list_unref(int /*long*/ list) {
+	lock.lock();
+	try {
+		_pango_attr_list_unref(list);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _pango_attr_strikethrough_color_new(short red, short green, short blue);
+public static final int /*long*/ pango_attr_strikethrough_color_new(short red, short green, short blue) {
+	lock.lock();
+	try {
+		return _pango_attr_strikethrough_color_new(red, green, blue);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _pango_attr_strikethrough_new(boolean strikethrough);
+public static final int /*long*/ pango_attr_strikethrough_new(boolean strikethrough) {
+	lock.lock();
+	try {
+		return _pango_attr_strikethrough_new(strikethrough);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _pango_attr_underline_color_new(short red, short green, short blue);
+public static final int /*long*/ pango_attr_underline_color_new(short red, short green, short blue) {
+	lock.lock();
+	try {
+		return _pango_attr_underline_color_new(red, green, blue);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _pango_attr_underline_new(int underline);
+public static final int /*long*/ pango_attr_underline_new(int underline) {
+	lock.lock();
+	try {
+		return _pango_attr_underline_new(underline);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _pango_attr_weight_new(int weight);
+public static final int /*long*/ pango_attr_weight_new(int weight) {
+	lock.lock();
+	try {
+		return _pango_attr_weight_new(weight);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _pango_cairo_font_map_get_default();
+public static final int /*long*/ pango_cairo_font_map_get_default() {
+	lock.lock();
+	try {
+		return _pango_cairo_font_map_get_default();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _pango_cairo_font_map_new();
+public static final int /*long*/ pango_cairo_font_map_new() {
+	lock.lock();
+	try {
+		return _pango_cairo_font_map_new();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _pango_cairo_font_map_create_context(int /*long*/ fontmap);
+public static final int /*long*/ pango_cairo_font_map_create_context(int /*long*/ fontmap) {
+	lock.lock();
+	try {
+		return _pango_cairo_font_map_create_context(fontmap);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _pango_cairo_create_layout(int /*long*/ cairo);
+public static final int /*long*/ pango_cairo_create_layout(int /*long*/ cairo) {
+	lock.lock();
+	try {
+		return _pango_cairo_create_layout(cairo);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _pango_cairo_context_get_font_options(int /*long*/ context);
+public static final int /*long*/ pango_cairo_context_get_font_options(int /*long*/ context) {
+	lock.lock();
+	try {
+		return _pango_cairo_context_get_font_options(context);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _pango_cairo_context_set_font_options(int /*long*/ context, int /*long*/ options);
+public static final void pango_cairo_context_set_font_options(int /*long*/ context, int /*long*/ options) {
+	lock.lock();
+	try {
+		_pango_cairo_context_set_font_options(context, options);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _pango_cairo_font_map_set_resolution(int /*long*/ fontmap, double dpi);
+public static final void pango_cairo_font_map_set_resolution(int /*long*/ fontmap, double dpi) {
+	lock.lock();
+	try {
+		_pango_cairo_font_map_set_resolution(fontmap, dpi);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _pango_cairo_layout_path(int /*long*/ cairo, int /*long*/ layout);
+public static final void pango_cairo_layout_path(int /*long*/ cairo, int /*long*/ layout) {
+	lock.lock();
+	try {
+		_pango_cairo_layout_path(cairo, layout);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _pango_cairo_show_layout(int /*long*/ cairo, int /*long*/ layout);
+public static final void pango_cairo_show_layout(int /*long*/ cairo, int /*long*/ layout) {
+	lock.lock();
+	try {
+		_pango_cairo_show_layout(cairo, layout);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _pango_context_get_base_dir(int /*long*/ context);
+public static final int pango_context_get_base_dir(int /*long*/ context) {
+	lock.lock();
+	try {
+		return _pango_context_get_base_dir(context);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _pango_context_get_language(int /*long*/ context);
+public static final int /*long*/ pango_context_get_language(int /*long*/ context) {
+	lock.lock();
+	try {
+		return _pango_context_get_language(context);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _pango_context_get_metrics(int /*long*/ context, int /*long*/ desc, int /*long*/ language);
+public static final int /*long*/ pango_context_get_metrics(int /*long*/ context, int /*long*/ desc, int /*long*/ language) {
+	lock.lock();
+	try {
+		return _pango_context_get_metrics(context, desc, language);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _pango_context_list_families(int /*long*/ context, int /*long*/[] families, int[] n_families);
+public static final void pango_context_list_families(int /*long*/ context, int /*long*/[] families, int[] n_families) {
+	lock.lock();
+	try {
+		_pango_context_list_families(context, families, n_families);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _pango_context_set_base_dir(int /*long*/ context, int direction);
+public static final void pango_context_set_base_dir(int /*long*/ context, int direction) {
+	lock.lock();
+	try {
+		_pango_context_set_base_dir(context, direction);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _pango_context_set_language(int /*long*/ context, int /*long*/ language);
+public static final void pango_context_set_language(int /*long*/ context, int /*long*/ language) {
+	lock.lock();
+	try {
+		_pango_context_set_language(context, language);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _pango_font_description_copy(int /*long*/ desc);
+public static final int /*long*/ pango_font_description_copy(int /*long*/ desc) {
+	lock.lock();
+	try {
+		return _pango_font_description_copy(desc);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _pango_font_description_free(int /*long*/ desc);
+public static final void pango_font_description_free(int /*long*/ desc) {
+	lock.lock();
+	try {
+		_pango_font_description_free(desc);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _pango_font_description_from_string(byte[] str);
+public static final int /*long*/ pango_font_description_from_string(byte[] str) {
+	lock.lock();
+	try {
+		return _pango_font_description_from_string(str);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _pango_font_description_get_family(int /*long*/ desc);
+public static final int /*long*/ pango_font_description_get_family(int /*long*/ desc) {
+	lock.lock();
+	try {
+		return _pango_font_description_get_family(desc);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _pango_font_description_get_size(int /*long*/ desc);
+public static final int pango_font_description_get_size(int /*long*/ desc) {
+	lock.lock();
+	try {
+		return _pango_font_description_get_size(desc);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _pango_font_description_get_style(int /*long*/ desc);
+public static final int pango_font_description_get_style(int /*long*/ desc) {
+	lock.lock();
+	try {
+		return _pango_font_description_get_style(desc);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _pango_font_description_get_weight(int /*long*/ desc);
+public static final int pango_font_description_get_weight(int /*long*/ desc) {
+	lock.lock();
+	try {
+		return _pango_font_description_get_weight(desc);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _pango_font_description_new();
+public static final int /*long*/ pango_font_description_new() {
+	lock.lock();
+	try {
+		return _pango_font_description_new();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _pango_font_description_set_family(int /*long*/ desc, byte[] family);
+public static final void pango_font_description_set_family(int /*long*/ desc, byte[] family) {
+	lock.lock();
+	try {
+		_pango_font_description_set_family(desc, family);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _pango_font_description_set_size(int /*long*/ desc, int size);
+public static final void pango_font_description_set_size(int /*long*/ desc, int size) {
+	lock.lock();
+	try {
+		_pango_font_description_set_size(desc, size);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _pango_font_description_set_stretch(int /*long*/ desc, int stretch);
+public static final void pango_font_description_set_stretch(int /*long*/ desc, int stretch) {
+	lock.lock();
+	try {
+		_pango_font_description_set_stretch(desc, stretch);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _pango_font_description_set_style(int /*long*/ desc, int weight);
+public static final void pango_font_description_set_style(int /*long*/ desc, int weight) {
+	lock.lock();
+	try {
+		_pango_font_description_set_style(desc, weight);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _pango_font_description_set_weight(int /*long*/ desc, int weight);
+public static final void pango_font_description_set_weight(int /*long*/ desc, int weight) {
+	lock.lock();
+	try {
+		_pango_font_description_set_weight(desc, weight);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _pango_font_description_to_string(int /*long*/ desc);
+public static final int /*long*/ pango_font_description_to_string(int /*long*/ desc) {
+	lock.lock();
+	try {
+		return _pango_font_description_to_string(desc);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _pango_font_face_describe(int /*long*/ face);
+public static final int /*long*/ pango_font_face_describe(int /*long*/ face) {
+	lock.lock();
+	try {
+		return _pango_font_face_describe(face);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _pango_font_family_get_name(int /*long*/ family);
+public static final int /*long*/ pango_font_family_get_name(int /*long*/ family) {
+	lock.lock();
+	try {
+		return _pango_font_family_get_name(family);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _pango_font_family_list_faces(int /*long*/ family, int /*long*/[] faces, int[] n_faces);
+public static final void pango_font_family_list_faces(int /*long*/ family, int /*long*/[] faces, int[] n_faces) {
+	lock.lock();
+	try {
+		_pango_font_family_list_faces(family, faces, n_faces);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _pango_font_get_metrics(int /*long*/ font, int /*long*/ language);
+public static final int /*long*/ pango_font_get_metrics(int /*long*/ font, int /*long*/ language) {
+	lock.lock();
+	try {
+		return _pango_font_get_metrics(font, language);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _pango_font_metrics_get_approximate_char_width(int /*long*/ metrics);
+public static final int pango_font_metrics_get_approximate_char_width(int /*long*/ metrics) {
+	lock.lock();
+	try {
+		return _pango_font_metrics_get_approximate_char_width(metrics);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _pango_font_metrics_get_ascent(int /*long*/ metrics);
+public static final int pango_font_metrics_get_ascent(int /*long*/ metrics) {
+	lock.lock();
+	try {
+		return _pango_font_metrics_get_ascent(metrics);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _pango_font_metrics_get_descent(int /*long*/ metrics);
+public static final int pango_font_metrics_get_descent(int /*long*/ metrics) {
+	lock.lock();
+	try {
+		return _pango_font_metrics_get_descent(metrics);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _pango_font_metrics_get_underline_thickness(int /*long*/ metrics);
+public static final int pango_font_metrics_get_underline_thickness(int /*long*/ metrics) {
+	lock.lock();
+	try {
+		return _pango_font_metrics_get_underline_thickness(metrics);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _pango_font_metrics_get_underline_position(int /*long*/ metrics);
+public static final int pango_font_metrics_get_underline_position(int /*long*/ metrics) {
+	lock.lock();
+	try {
+		return _pango_font_metrics_get_underline_position(metrics);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _pango_font_metrics_get_strikethrough_thickness(int /*long*/ metrics);
+public static final int pango_font_metrics_get_strikethrough_thickness(int /*long*/ metrics) {
+	lock.lock();
+	try {
+		return _pango_font_metrics_get_strikethrough_thickness(metrics);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _pango_font_metrics_get_strikethrough_position(int /*long*/ metrics);
+public static final int pango_font_metrics_get_strikethrough_position(int /*long*/ metrics) {
+	lock.lock();
+	try {
+		return _pango_font_metrics_get_strikethrough_position(metrics);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _pango_font_metrics_unref(int /*long*/ metrics);
+public static final void pango_font_metrics_unref(int /*long*/ metrics) {
+	lock.lock();
+	try {
+		_pango_font_metrics_unref(metrics);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _pango_language_from_string(byte[] language);
+public static final int /*long*/ pango_language_from_string(byte[] language) {
+	lock.lock();
+	try {
+		return _pango_language_from_string(language);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _pango_layout_context_changed(int /*long*/ layout);
+public static final void pango_layout_context_changed(int /*long*/ layout) {
+	lock.lock();
+	try {
+		_pango_layout_context_changed(layout);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _pango_layout_get_alignment(int /*long*/ layout);
+public static final int pango_layout_get_alignment(int /*long*/ layout) {
+	lock.lock();
+	try {
+		return _pango_layout_get_alignment(layout);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _pango_layout_get_context(int /*long*/ layout);
+public static final int /*long*/ pango_layout_get_context(int /*long*/ layout) {
+	lock.lock();
+	try {
+		return _pango_layout_get_context(layout);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _pango_layout_get_attributes(int /*long*/ layout);
+public static final int /*long*/ pango_layout_get_attributes(int /*long*/ layout) {
+	lock.lock();
+	try {
+		return _pango_layout_get_attributes(layout);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _pango_layout_get_indent(int /*long*/ layout);
+public static final int pango_layout_get_indent(int /*long*/ layout) {
+	lock.lock();
+	try {
+		return _pango_layout_get_indent(layout);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _pango_layout_get_iter(int /*long*/ layout);
+public static final int /*long*/ pango_layout_get_iter(int /*long*/ layout) {
+	lock.lock();
+	try {
+		return _pango_layout_get_iter(layout);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _pango_layout_get_justify(int /*long*/ layout);
+public static final boolean pango_layout_get_justify(int /*long*/ layout) {
+	lock.lock();
+	try {
+		return _pango_layout_get_justify(layout);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _pango_layout_get_line(int /*long*/ layout, int line);
+public static final int /*long*/ pango_layout_get_line(int /*long*/ layout, int line) {
+	lock.lock();
+	try {
+		return _pango_layout_get_line(layout, line);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _pango_layout_get_line_count(int /*long*/ layout);
+public static final int pango_layout_get_line_count(int /*long*/ layout) {
+	lock.lock();
+	try {
+		return _pango_layout_get_line_count(layout);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _pango_layout_get_log_attrs(int /*long*/ layout, int /*long*/[] attrs, int[] n_attrs);
+public static final void pango_layout_get_log_attrs(int /*long*/ layout, int /*long*/[] attrs, int[] n_attrs) {
+	lock.lock();
+	try {
+		_pango_layout_get_log_attrs(layout, attrs, n_attrs);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _pango_layout_get_size(int /*long*/ layout, int[] width, int[] height);
+public static final void pango_layout_get_size(int /*long*/ layout, int[] width, int[] height) {
+	lock.lock();
+	try {
+		_pango_layout_get_size(layout, width, height);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _pango_layout_get_spacing(int /*long*/ layout);
+public static final int pango_layout_get_spacing(int /*long*/ layout) {
+	lock.lock();
+	try {
+		return _pango_layout_get_spacing(layout);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _pango_layout_get_tabs(int /*long*/ layout);
+public static final int /*long*/ pango_layout_get_tabs(int /*long*/ layout) {
+	lock.lock();
+	try {
+		return _pango_layout_get_tabs(layout);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _pango_layout_get_text(int /*long*/ layout);
+public static final int /*long*/ pango_layout_get_text(int /*long*/ layout) {
+	lock.lock();
+	try {
+		return _pango_layout_get_text(layout);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _pango_layout_get_width(int /*long*/ layout);
+public static final int pango_layout_get_width(int /*long*/ layout) {
+	lock.lock();
+	try {
+		return _pango_layout_get_width(layout);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _pango_layout_index_to_pos(int /*long*/ layout, int index, PangoRectangle pos);
+public static final void pango_layout_index_to_pos(int /*long*/ layout, int index, PangoRectangle pos) {
+	lock.lock();
+	try {
+		_pango_layout_index_to_pos(layout, index, pos);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _pango_layout_iter_free(int /*long*/ iter);
+public static final void pango_layout_iter_free(int /*long*/ iter) {
+	lock.lock();
+	try {
+		_pango_layout_iter_free(iter);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _pango_layout_iter_get_line_extents(int /*long*/ iter, PangoRectangle ink_rect, PangoRectangle logical_rect);
+public static final void pango_layout_iter_get_line_extents(int /*long*/ iter, PangoRectangle ink_rect, PangoRectangle logical_rect) {
+	lock.lock();
+	try {
+		_pango_layout_iter_get_line_extents(iter, ink_rect, logical_rect);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _pango_layout_iter_get_index(int /*long*/ iter);
+public static final int pango_layout_iter_get_index(int /*long*/ iter) {
+	lock.lock();
+	try {
+		return _pango_layout_iter_get_index(iter);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _pango_layout_iter_get_run(int /*long*/ iter);
+public static final int /*long*/ pango_layout_iter_get_run(int /*long*/ iter) {
+	lock.lock();
+	try {
+		return _pango_layout_iter_get_run(iter);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _pango_layout_iter_next_line(int /*long*/ iter);
+public static final boolean pango_layout_iter_next_line(int /*long*/ iter) {
+	lock.lock();
+	try {
+		return _pango_layout_iter_next_line(iter);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _pango_layout_iter_next_run(int /*long*/ iter);
+public static final boolean pango_layout_iter_next_run(int /*long*/ iter) {
+	lock.lock();
+	try {
+		return _pango_layout_iter_next_run(iter);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _pango_layout_line_get_extents(int /*long*/ line, PangoRectangle ink_rect, PangoRectangle logical_rect);
+public static final void pango_layout_line_get_extents(int /*long*/ line, PangoRectangle ink_rect, PangoRectangle logical_rect) {
+	lock.lock();
+	try {
+		_pango_layout_line_get_extents(line, ink_rect, logical_rect);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _pango_layout_line_x_to_index(int /*long*/ line, int x_pos, int[] index_, int[] trailing);
+public static final boolean pango_layout_line_x_to_index(int /*long*/ line, int x_pos, int[] index_, int[] trailing) {
+	lock.lock();
+	try {
+		return _pango_layout_line_x_to_index(line, x_pos, index_, trailing);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _pango_layout_line_get_resolved_dir(int /*long*/ line);
+public static final int pango_layout_line_get_resolved_dir(int /*long*/ line) {
+	lock.lock();
+	try {
+		return _pango_layout_line_get_resolved_dir(line);
+	} finally {
+		lock.unlock();
+	}
+}
+
+public static final native int /*long*/ _pango_layout_new(int /*long*/ context);
+public static final int /*long*/ pango_layout_new(int /*long*/ context) {
+	lock.lock();
+	try {
+		return _pango_layout_new(context);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _pango_layout_set_alignment (int /*long*/ layout, int alignment);
+public static final void pango_layout_set_alignment (int /*long*/ layout, int alignment) {
+	lock.lock();
+	try {
+		_pango_layout_set_alignment(layout, alignment);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _pango_layout_set_attributes(int /*long*/ layout, int /*long*/ attrs);
+public static final void pango_layout_set_attributes(int /*long*/ layout, int /*long*/ attrs) {
+	lock.lock();
+	try {
+		_pango_layout_set_attributes(layout, attrs);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _pango_layout_set_auto_dir(int /*long*/ layout, boolean auto_dir);
+public static final void pango_layout_set_auto_dir(int /*long*/ layout, boolean auto_dir) {
+	lock.lock();
+	try {
+		_pango_layout_set_auto_dir(layout, auto_dir);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _pango_layout_set_font_description(int /*long*/ context, int /*long*/ descr);
+public static final void pango_layout_set_font_description(int /*long*/ context, int /*long*/ descr) {
+	lock.lock();
+	try {
+		_pango_layout_set_font_description(context, descr);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _pango_layout_set_indent(int /*long*/ layout, int indent);
+public static final void pango_layout_set_indent(int /*long*/ layout, int indent) {
+	lock.lock();
+	try {
+		_pango_layout_set_indent(layout, indent);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _pango_layout_set_justify(int /*long*/ layout, boolean justify);
+public static final void pango_layout_set_justify(int /*long*/ layout, boolean justify) {
+	lock.lock();
+	try {
+		_pango_layout_set_justify(layout, justify);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _pango_layout_set_single_paragraph_mode(int /*long*/ context, boolean setting);
+public static final void pango_layout_set_single_paragraph_mode(int /*long*/ context, boolean setting) {
+	lock.lock();
+	try {
+		_pango_layout_set_single_paragraph_mode(context, setting);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _pango_layout_set_spacing(int /*long*/ layout, int spacing);
+public static final void pango_layout_set_spacing(int /*long*/ layout, int spacing) {
+	lock.lock();
+	try {
+		_pango_layout_set_spacing(layout, spacing);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _pango_layout_set_tabs(int /*long*/ layout, int /*long*/ tabs);
+public static final void pango_layout_set_tabs(int /*long*/ layout, int /*long*/ tabs) {
+	lock.lock();
+	try {
+		_pango_layout_set_tabs(layout, tabs);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _pango_layout_set_text(int /*long*/ layout, byte[] text, int length);
+public static final void pango_layout_set_text(int /*long*/ layout, byte[] text, int length) {
+	lock.lock();
+	try {
+		_pango_layout_set_text(layout, text, length);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _pango_layout_set_width(int /*long*/ layout, int width);
+public static final void pango_layout_set_width(int /*long*/ layout, int width) {
+	lock.lock();
+	try {
+		_pango_layout_set_width(layout, width);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _pango_layout_set_wrap (int /*long*/ layout, int wrap);
+public static final void pango_layout_set_wrap (int /*long*/ layout, int wrap) {
+	lock.lock();
+	try {
+		_pango_layout_set_wrap(layout, wrap);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _pango_layout_xy_to_index(int /*long*/ layout, int x, int y, int[] index, int[] trailing);
+public static final boolean pango_layout_xy_to_index(int /*long*/ layout, int x, int y, int[] index, int[] trailing) {
+	lock.lock();
+	try {
+		return _pango_layout_xy_to_index(layout, x, y, index, trailing);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _pango_tab_array_get_size(int /*long*/ tab_array);
+public static final int pango_tab_array_get_size(int /*long*/ tab_array) {
+	lock.lock();
+	try {
+		return _pango_tab_array_get_size(tab_array);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _pango_tab_array_get_tabs(int /*long*/ tab_array, int /*long*/[] alignments, int /*long*/[] locations);
+public static final void pango_tab_array_get_tabs(int /*long*/ tab_array, int /*long*/[] alignments, int /*long*/[] locations) {
+	lock.lock();
+	try {
+		_pango_tab_array_get_tabs(tab_array, alignments, locations);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _pango_tab_array_free(int /*long*/ tab_array);
+public static final void pango_tab_array_free(int /*long*/ tab_array) {
+	lock.lock();
+	try {
+		_pango_tab_array_free(tab_array);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _pango_tab_array_new(int initial_size, boolean positions_in_pixels);
+public static final int /*long*/ pango_tab_array_new(int initial_size, boolean positions_in_pixels) {
+	lock.lock();
+	try {
+		return _pango_tab_array_new(initial_size, positions_in_pixels);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _pango_tab_array_set_tab(int /*long*/ tab_array, int tab_index, int /*long*/ alignment, int location);
+public static final void pango_tab_array_set_tab(int /*long*/ tab_array, int tab_index, int /*long*/ alignment, int location) {
+	lock.lock();
+	try {
+		_pango_tab_array_set_tab(tab_array, tab_index, alignment, location);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _atk_object_add_relationship (int /*long*/ object, int relationship, int /*long*/ target);
+public static final boolean atk_object_add_relationship (int /*long*/ object, int relationship, int /*long*/ target) {
+	lock.lock();
+	try {
+		return _atk_object_add_relationship(object, relationship, target);
+	} finally {
+		lock.unlock();
+	}
+}
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/OS.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/PangoAttrColor.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/PangoAttrColor.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/PangoAttrColor.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 IBM Corporation and others. All rights reserved.
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt).  The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html.  If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.gtk;
+
+
+public class PangoAttrColor extends PangoAttribute {
+	public short color_red;
+	public short color_green;
+	public short color_blue;
+	public static final int sizeof = OS.PangoAttrColor_sizeof();
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/PangoAttrColor.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/PangoAttrInt.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/PangoAttrInt.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/PangoAttrInt.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 IBM Corporation and others. All rights reserved.
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt).  The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html.  If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.gtk;
+
+
+public class PangoAttrInt extends PangoAttribute {
+	public int value;
+	public static final int sizeof = OS.PangoAttrInt_sizeof();
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/PangoAttrInt.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/PangoAttribute.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/PangoAttribute.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/PangoAttribute.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others. All rights reserved.
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt).  The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html.  If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.gtk;
+
+
+public class PangoAttribute {
+	public int /*long*/ klass;
+	public int start_index;
+	public int end_index;
+	public static final int sizeof = OS.PangoAttribute_sizeof();
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/PangoAttribute.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/PangoItem.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/PangoItem.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/PangoItem.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others. All rights reserved.
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt).  The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html.  If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.gtk;
+
+public class PangoItem {
+	public int offset;
+	public int length;
+	public int num_chars;
+	public int /*long*/ analysis_shape_engine;
+	public int /*long*/ analysis_lang_engine;
+	public int /*long*/ analysis_font;
+	public byte analysis_level;
+	public int /*long*/ analysis_language;
+	public int /*long*/ analysis_extra_attrs;
+	public static final int sizeof = OS.PangoItem_sizeof();
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/PangoItem.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/PangoLayoutLine.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/PangoLayoutLine.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/PangoLayoutLine.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others. All rights reserved.
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt).  The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html.  If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.gtk;
+
+public class PangoLayoutLine {
+	public int /*long*/ layout;
+	public int start_index;
+	public int length;
+	public int /*long*/ runs;
+//	public boolean is_paragraph_start;
+//	public byte resolved_dir;
+	public static final int sizeof = OS.PangoLayoutLine_sizeof();
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/PangoLayoutLine.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/PangoLayoutRun.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/PangoLayoutRun.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/PangoLayoutRun.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others. All rights reserved.
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt).  The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html.  If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.gtk;
+
+public class PangoLayoutRun {
+	public int /*long*/ item;
+	public int /*long*/ glyphs;
+	public static final int sizeof = OS.PangoLayoutRun_sizeof();
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/PangoLayoutRun.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/PangoLogAttr.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/PangoLogAttr.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/PangoLogAttr.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others. All rights reserved.
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt).  The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html.  If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.gtk;
+
+
+public class PangoLogAttr {
+	public boolean is_line_break;
+	public boolean is_mandatory_break;
+	public boolean is_char_break;
+	public boolean is_white;
+	public boolean is_cursor_position;
+	public boolean is_word_start;
+	public boolean is_word_end;
+	public boolean is_sentence_boundary;
+	public boolean is_sentence_start;
+	public boolean is_sentence_end;
+	public static final int sizeof = OS.PangoLogAttr_sizeof();
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/PangoLogAttr.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/PangoRectangle.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/PangoRectangle.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/PangoRectangle.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others. All rights reserved.
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt).  The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html.  If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.gtk;
+
+
+public class PangoRectangle {
+	public int x;
+	public int y;
+	public int width;
+	public int height;
+	public static final int sizeof = OS.PangoRectangle_sizeof();
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/PangoRectangle.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/XAnyEvent.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/XAnyEvent.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/XAnyEvent.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,20 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.gtk;
+
+ 
+public abstract class XAnyEvent extends XEvent {
+	public int /*long*/ serial;
+	public int send_event;
+	public int /*long*/ display;
+	public int /*long*/ window;
+	public static final int sizeof = OS.XAnyEvent_sizeof();
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/XAnyEvent.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/XButtonEvent.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/XButtonEvent.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/XButtonEvent.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.gtk;
+
+ 
+public class XButtonEvent extends XAnyEvent {
+	public int root;
+	public int subwindow;
+	public int time;
+	public int x;
+	public int y;
+	public int x_root;
+	public int y_root;
+	public int state;
+	public int button;
+	public int same_screen;
+	public static final int sizeof = OS.XButtonEvent_sizeof();
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/XButtonEvent.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/XClientMessageEvent.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/XClientMessageEvent.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/XClientMessageEvent.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.gtk;
+
+ 
+public class XClientMessageEvent {
+	public int type;
+	public int /*long*/ serial;
+	public boolean send_event;
+	public int /*long*/ display;
+	public int /*long*/ window;
+	public int /*long*/ message_type;
+	public int format;
+	public int /*long*/[] data = new int /*long*/[5];
+	public static final int sizeof = OS.XClientMessageEvent_sizeof();
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/XClientMessageEvent.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/XCrossingEvent.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/XCrossingEvent.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/XCrossingEvent.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.gtk;
+
+ 
+public class XCrossingEvent extends XAnyEvent {
+	public int /*long*/ root;
+	public int /*long*/ subwindow;
+	public int time;
+	public int x;
+	public int y;
+	public int x_root;
+	public int y_root;
+	public int mode;
+	public int detail;
+	public boolean same_screen;
+	public boolean focus;
+	public int state;
+	public static final int sizeof =  OS.XCrossingEvent_sizeof();
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/XCrossingEvent.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/XEvent.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/XEvent.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/XEvent.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,17 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.gtk;
+
+ 
+public class XEvent {
+	public int type;
+	public static final int sizeof = OS.XEvent_sizeof();
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/XEvent.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/XExposeEvent.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/XExposeEvent.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/XExposeEvent.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.gtk;
+
+ 
+public class XExposeEvent extends XAnyEvent {
+	public int x;
+	public int y;
+	public int width;
+	public int height;
+	public int count;
+	public static final int sizeof = OS.XExposeEvent_sizeof();
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/XExposeEvent.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/XFocusChangeEvent.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/XFocusChangeEvent.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/XFocusChangeEvent.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,18 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.gtk;
+
+ 
+public class XFocusChangeEvent extends XAnyEvent {
+	public int mode;
+	public int detail;
+	public static final int sizeof = OS.XFocusChangeEvent_sizeof();
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/XFocusChangeEvent.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/XRenderPictureAttributes.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/XRenderPictureAttributes.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/XRenderPictureAttributes.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.gtk;
+
+ 
+public class XRenderPictureAttributes {
+	public boolean repeat;
+	public int /*long*/ alpha_map;
+	public int alpha_x_origin;
+	public int alpha_y_origin;
+	public int clip_x_origin;
+	public int clip_y_origin;
+	public int /*long*/ clip_mask;
+	public boolean graphics_exposures;
+	public int subwindow_mode;
+	public int poly_edge;
+	public int poly_mode;
+	public int /*long*/ dither;
+	public boolean component_alpha;
+	public static final int sizeof = OS.XRenderPictureAttributes_sizeof();
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/XRenderPictureAttributes.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/XVisibilityEvent.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/XVisibilityEvent.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/XVisibilityEvent.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,17 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.gtk;
+
+ 
+public class XVisibilityEvent extends XAnyEvent {
+	public int state;
+	public static final int sizeof = OS.XVisibilityEvent_sizeof();
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/XVisibilityEvent.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/XWindowChanges.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/XWindowChanges.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/XWindowChanges.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.gtk;
+
+ 
+public class XWindowChanges {
+	public int x;
+	public int y;
+	public int width;
+	public int height;
+	public int border_width;
+	public int /*long*/ sibling;
+	public int stack_mode;
+	public static final int sizeof = OS.XWindowChanges_sizeof();
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/gtk/XWindowChanges.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/FileFormat.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/FileFormat.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/FileFormat.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,129 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.image;
+
+
+import java.io.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
+/**
+ * Abstract factory class for loading/unloading images from files or streams
+ * in various image file formats.
+ *
+ */
+public abstract class FileFormat {
+	static final String FORMAT_PACKAGE = "org.eclipse.swt.internal.image"; //$NON-NLS-1$
+	static final String FORMAT_SUFFIX = "FileFormat"; //$NON-NLS-1$
+	static final String[] FORMATS = {"WinBMP", "WinBMP", "GIF", "WinICO", "JPEG", "PNG", "TIFF", "OS2BMP"}; //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$//$NON-NLS-5$ //$NON-NLS-6$//$NON-NLS-7$//$NON-NLS-8$
+	
+	LEDataInputStream inputStream;
+	LEDataOutputStream outputStream;
+	ImageLoader loader;
+	int compression;
+
+/**
+ * Return whether or not the specified input stream
+ * represents a supported file format.
+ */
+abstract boolean isFileFormat(LEDataInputStream stream);
+
+abstract ImageData[] loadFromByteStream();
+
+/**
+ * Read the specified input stream, and return the
+ * device independent image array represented by the stream.
+ */	
+public ImageData[] loadFromStream(LEDataInputStream stream) {
+	try {
+		inputStream = stream;
+		return loadFromByteStream();
+	} catch (Exception e) {
+		if (e instanceof IOException) {
+			SWT.error(SWT.ERROR_IO, e);
+		} else {
+			SWT.error(SWT.ERROR_INVALID_IMAGE, e);
+		}
+		return null;
+	}
+}
+
+/**
+ * Read the specified input stream using the specified loader, and
+ * return the device independent image array represented by the stream.
+ */	
+public static ImageData[] load(InputStream is, ImageLoader loader) {
+	FileFormat fileFormat = null;
+	LEDataInputStream stream = new LEDataInputStream(is);
+	boolean isSupported = false;	
+	for (int i = 1; i < FORMATS.length; i++) {
+		if (FORMATS[i] != null) {
+			try {
+				Class clazz = Class.forName(FORMAT_PACKAGE + '.' + FORMATS[i] + FORMAT_SUFFIX);
+				fileFormat = (FileFormat) clazz.newInstance();
+				if (fileFormat.isFileFormat(stream)) {
+					isSupported = true;
+					break;
+				}
+			} catch (ClassNotFoundException e) {
+				FORMATS[i] = null;
+			} catch (Exception e) {
+			}
+		}
+	}
+	if (!isSupported) SWT.error(SWT.ERROR_UNSUPPORTED_FORMAT);
+	fileFormat.loader = loader;
+	return fileFormat.loadFromStream(stream);
+}
+
+/**
+ * Write the device independent image array stored in the specified loader
+ * to the specified output stream using the specified file format.
+ */	
+public static void save(OutputStream os, int format, ImageLoader loader) {
+	if (format < 0 || format >= FORMATS.length) SWT.error(SWT.ERROR_UNSUPPORTED_FORMAT);
+	if (FORMATS[format] == null) SWT.error(SWT.ERROR_UNSUPPORTED_FORMAT);
+	if (loader.data == null || loader.data.length < 1) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+
+	LEDataOutputStream stream = new LEDataOutputStream(os);
+	FileFormat fileFormat = null;
+	try {
+		Class clazz = Class.forName(FORMAT_PACKAGE + '.' + FORMATS[format] + FORMAT_SUFFIX);
+		fileFormat = (FileFormat) clazz.newInstance();
+	} catch (Exception e) {
+		SWT.error(SWT.ERROR_UNSUPPORTED_FORMAT);
+	}
+	if (format == SWT.IMAGE_BMP_RLE) {
+		switch (loader.data[0].depth) {
+			case 8: fileFormat.compression = 1; break;
+			case 4: fileFormat.compression = 2; break;
+		}
+	}
+	fileFormat.unloadIntoStream(loader, stream);
+}
+
+abstract void unloadIntoByteStream(ImageLoader loader);
+
+/**
+ * Write the device independent image array stored in the specified loader
+ * to the specified output stream.
+ */	
+public void unloadIntoStream(ImageLoader loader, LEDataOutputStream stream) {
+	try {
+		outputStream = stream;
+		unloadIntoByteStream(loader);
+		outputStream.flush();
+	} catch (Exception e) {
+		try {outputStream.flush();} catch (Exception f) {}
+		SWT.error(SWT.ERROR_IO, e);
+	}
+}
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/FileFormat.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/GIFFileFormat.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/GIFFileFormat.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/GIFFileFormat.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,614 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.image;
+
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import java.io.*;
+
+public final class GIFFileFormat extends FileFormat {
+	String signature;
+	int screenWidth, screenHeight, backgroundPixel, bitsPerPixel, defaultDepth;
+	int disposalMethod = 0;
+	int delayTime = 0;
+	int transparentPixel = -1;
+	int repeatCount = 1;
+	
+	static final int GIF_APPLICATION_EXTENSION_BLOCK_ID = 0xFF;
+	static final int GIF_GRAPHICS_CONTROL_BLOCK_ID = 0xF9;
+	static final int GIF_PLAIN_TEXT_BLOCK_ID = 0x01;
+	static final int GIF_COMMENT_BLOCK_ID = 0xFE;
+	static final int GIF_EXTENSION_BLOCK_ID = 0x21;
+	static final int GIF_IMAGE_BLOCK_ID = 0x2C;
+	static final int GIF_TRAILER_ID = 0x3B;
+	static final byte [] GIF89a = new byte[] { (byte)'G', (byte)'I', (byte)'F', (byte)'8', (byte)'9', (byte)'a' };
+	static final byte [] NETSCAPE2_0 = new byte[] { (byte)'N', (byte)'E', (byte)'T', (byte)'S', (byte)'C', (byte)'A', (byte)'P', (byte)'E', (byte)'2', (byte)'.', (byte)'0' };
+	
+	/**
+	 * Answer a palette containing numGrays
+	 * shades of gray, ranging from black to white.
+	 */
+	static PaletteData grayRamp(int numGrays) {
+		int n = numGrays - 1;
+		RGB[] colors = new RGB[numGrays];
+		for (int i = 0; i < numGrays; i++) {
+			int intensity = (byte)((i * 3) * 256 / n);
+			colors[i] = new RGB(intensity, intensity, intensity);
+		}
+		return new PaletteData(colors);
+	}
+
+	boolean isFileFormat(LEDataInputStream stream) {
+		try {
+			byte[] signature = new byte[3];
+			stream.read(signature);
+			stream.unread(signature);
+			return signature[0] == 'G' && signature[1] == 'I' && signature[2] == 'F';
+		} catch (Exception e) {
+			return false;
+		}
+	}
+
+	/**
+	 * Load the GIF image(s) stored in the input stream.
+	 * Return an array of ImageData representing the image(s).
+	 */
+	ImageData[] loadFromByteStream() {
+		byte[] signature = new byte[3];
+		byte[] versionBytes = new byte[3];
+		byte[] block = new byte[7];
+		try {
+			inputStream.read(signature);
+			if (!(signature[0] == 'G' && signature[1] == 'I' && signature[2] == 'F'))
+				SWT.error(SWT.ERROR_INVALID_IMAGE);
+
+			inputStream.read(versionBytes);
+
+			inputStream.read(block);
+		} catch (IOException e) {
+			SWT.error(SWT.ERROR_IO, e);
+		}
+		screenWidth = (block[0] & 0xFF) | ((block[1] & 0xFF) << 8);
+		loader.logicalScreenWidth = screenWidth;
+		screenHeight = (block[2] & 0xFF) | ((block[3] & 0xFF) << 8);
+		loader.logicalScreenHeight = screenHeight;
+		byte bitField = block[4];
+		backgroundPixel = block[5] & 0xFF;
+		//aspect = block[6] & 0xFF;
+		bitsPerPixel = ((bitField >> 4) & 0x07) + 1;
+		defaultDepth = (bitField & 0x7) + 1;
+		PaletteData palette = null;
+		if ((bitField & 0x80) != 0) {
+			// Global palette.
+			//sorted = (bitField & 0x8) != 0;
+			palette = readPalette(1 << defaultDepth);
+		} else {
+			// No global palette.
+			//sorted = false;
+			backgroundPixel = -1;
+			defaultDepth = bitsPerPixel;
+		}
+		loader.backgroundPixel = backgroundPixel;
+
+		getExtensions();
+		int id = readID();
+		ImageData[] images = new ImageData[0];
+		while (id == GIF_IMAGE_BLOCK_ID) {
+			ImageData image = readImageBlock(palette);
+			if (loader.hasListeners()) {
+				loader.notifyListeners(new ImageLoaderEvent(loader, image, 3, true));
+			}
+			ImageData[] oldImages = images;
+			images = new ImageData[oldImages.length + 1];
+			System.arraycopy(oldImages, 0, images, 0, oldImages.length);
+			images[images.length - 1] = image;
+			try {
+				/* Read the 0-byte terminator at the end of the image. */
+				id = inputStream.read();
+				if (id > 0) {
+					/* We read the terminator earlier. */
+					inputStream.unread(new byte[] {(byte)id});
+				}
+			} catch (IOException e) {
+				SWT.error(SWT.ERROR_IO, e);
+			}
+			getExtensions();
+			id = readID();
+		}
+		return images;
+	}
+
+	/**
+	 * Read and return the next block or extension identifier from the file.
+	 */
+	int readID() {
+		try {
+			return inputStream.read();
+		} catch (IOException e) {
+			SWT.error(SWT.ERROR_IO, e);
+		}
+		return -1;
+	}
+
+	/**
+	 * Read extensions until an image descriptor appears.
+	 * In the future, if we care about the extensions, they
+	 * should be properly grouped with the image data before
+	 * which they appeared. Right now, the interesting parts
+	 * of some extensions are kept, but the rest is discarded.
+	 * Throw an error if an error occurs.
+	 */
+	void getExtensions() {
+		int id = readID();
+		while (id != GIF_IMAGE_BLOCK_ID && id != GIF_TRAILER_ID && id > 0) {
+			if (id == GIF_EXTENSION_BLOCK_ID) {
+				readExtension();
+			} else {
+				SWT.error(SWT.ERROR_INVALID_IMAGE);
+			}
+			id = readID();
+		}
+		if (id == GIF_IMAGE_BLOCK_ID || id == GIF_TRAILER_ID) {
+			try {
+				inputStream.unread(new byte[] {(byte)id});
+			} catch (IOException e) {
+				SWT.error(SWT.ERROR_IO, e);
+			}
+		}
+	}
+
+	/**
+	 * Read a control extension.
+	 * Return the extension block data.
+	 */
+	byte[] readExtension() {
+		int extensionID = readID();
+		if (extensionID == GIF_COMMENT_BLOCK_ID)
+			return readCommentExtension();
+		if (extensionID == GIF_PLAIN_TEXT_BLOCK_ID)
+			return readPlainTextExtension();
+		if (extensionID == GIF_GRAPHICS_CONTROL_BLOCK_ID)
+			return readGraphicsControlExtension();
+		if (extensionID == GIF_APPLICATION_EXTENSION_BLOCK_ID)
+			return readApplicationExtension();
+		// Otherwise, we don't recognize the block. If the
+		// field size is correct, we can just skip over
+		// the block contents.
+		try {
+			int extSize = inputStream.read();
+			if (extSize < 0) {
+				SWT.error(SWT.ERROR_INVALID_IMAGE);
+			}
+			byte[] ext = new byte[extSize];
+			inputStream.read(ext, 0, extSize);
+			return ext;
+		} catch (IOException e) {
+			SWT.error(SWT.ERROR_IO, e);
+			return null;
+		}
+	}
+
+	/**
+	 * We have just read the Comment extension identifier
+	 * from the input stream. Read in the rest of the comment
+	 * and return it. GIF comment blocks are variable size.
+	 */
+	byte[] readCommentExtension() {
+		try {
+			byte[] comment = new byte[0];
+			byte[] block = new byte[255];
+			int size = inputStream.read();
+			while ((size > 0) && (inputStream.read(block, 0, size) != -1)) {
+				byte[] oldComment = comment;
+				comment = new byte[oldComment.length + size];
+				System.arraycopy(oldComment, 0, comment, 0, oldComment.length);
+				System.arraycopy(block, 0, comment, oldComment.length, size);
+				size = inputStream.read();
+			}
+			return comment;
+		} catch (Exception e) {
+			SWT.error(SWT.ERROR_IO, e);
+			return null;
+		}
+	}
+
+	/**
+	 * We have just read the PlainText extension identifier
+	 * from the input stream. Read in the plain text info and text,
+	 * and return the text. GIF plain text blocks are variable size.
+	 */
+	byte[] readPlainTextExtension() {
+		try {
+			// Read size of block = 0x0C.
+			inputStream.read();
+			// Read the text information (x, y, width, height, colors).
+			byte[] info = new byte[12];
+			inputStream.read(info);
+			// Read the text.
+			byte[] text = new byte[0];
+			byte[] block = new byte[255];
+			int size = inputStream.read();
+			while ((size > 0) && (inputStream.read(block, 0, size) != -1)) {
+				byte[] oldText = text;
+				text = new byte[oldText.length + size];
+				System.arraycopy(oldText, 0, text, 0, oldText.length);
+				System.arraycopy(block, 0, text, oldText.length, size);
+				size = inputStream.read();
+			}
+			return text;
+		} catch (Exception e) {
+			SWT.error(SWT.ERROR_IO, e);
+			return null;
+		}
+	}
+
+	/**
+	 * We have just read the GraphicsControl extension identifier
+	 * from the input stream. Read in the control information, store
+	 * it, and return it.
+	 */
+	byte[] readGraphicsControlExtension() {
+		try {
+			// Read size of block = 0x04.
+			inputStream.read();
+			// Read the control block.
+			byte[] controlBlock = new byte[4];
+			inputStream.read(controlBlock);
+			byte bitField = controlBlock[0];
+			// Store the user input field.
+			//userInput = (bitField & 0x02) != 0;
+			// Store the disposal method.
+			disposalMethod = (bitField >> 2) & 0x07;
+			// Store the delay time.
+			delayTime = (controlBlock[1] & 0xFF) | ((controlBlock[2] & 0xFF) << 8);
+			// Store the transparent color.
+			if ((bitField & 0x01) != 0) {
+				transparentPixel = controlBlock[3] & 0xFF;
+			} else {
+				transparentPixel = -1;
+			}
+			// Read block terminator.
+			inputStream.read();
+			return controlBlock;
+		} catch (Exception e) {
+			SWT.error(SWT.ERROR_IO, e);
+			return null;
+		}
+	}
+
+	/**
+	 * We have just read the Application extension identifier
+	 * from the input stream.  Read in the rest of the extension,
+	 * look for and store 'number of repeats', and return the data.
+	 */
+	byte[] readApplicationExtension() {
+		try {
+			// Read size of block = 0x0B.
+			inputStream.read();
+			// Read application identifier.
+			byte[] application = new byte[8];
+			inputStream.read(application);
+			// Read authentication code.
+			byte[] authentication = new byte[3];
+			inputStream.read(authentication);
+			// Read application data.
+			byte[] data = new byte[0];
+			byte[] block = new byte[255];
+			int size = inputStream.read();
+			while ((size > 0) && (inputStream.read(block, 0, size) != -1)) {
+				byte[] oldData = data;
+				data = new byte[oldData.length + size];
+				System.arraycopy(oldData, 0, data, 0, oldData.length);
+				System.arraycopy(block, 0, data, oldData.length, size);
+				size = inputStream.read();
+			}
+			// Look for the NETSCAPE 'repeat count' field for an animated GIF.
+			boolean netscape =
+				application[0] == 'N' &&
+				application[1] == 'E' &&
+				application[2] == 'T' &&
+				application[3] == 'S' &&
+				application[4] == 'C' &&
+				application[5] == 'A' &&
+				application[6] == 'P' &&
+				application[7] == 'E';
+			boolean authentic =
+				authentication[0] == '2' &&
+				authentication[1] == '.' &&
+				authentication[2] == '0';
+			if (netscape && authentic && data[0] == 01) { //$NON-NLS-1$ //$NON-NLS-2$
+				repeatCount = (data[1] & 0xFF) | ((data[2] & 0xFF) << 8);
+				loader.repeatCount = repeatCount;
+			}
+			return data;
+		} catch (Exception e) {
+			SWT.error(SWT.ERROR_IO, e);
+			return null;
+		}
+	}
+
+	/**
+	 * Return a DeviceIndependentImage representing the
+	 * image block at the current position in the input stream.
+	 * Throw an error if an error occurs.
+	 */
+	ImageData readImageBlock(PaletteData defaultPalette) {
+		int depth;
+		PaletteData palette;
+		byte[] block = new byte[9];
+		try {
+			inputStream.read(block);
+		} catch (IOException e) {
+			SWT.error(SWT.ERROR_IO, e);
+		}
+		int left = (block[0] & 0xFF) | ((block[1] & 0xFF) << 8);
+		int top = (block[2] & 0xFF) | ((block[3] & 0xFF) << 8);
+		int width = (block[4] & 0xFF) | ((block[5] & 0xFF) << 8);
+		int height = (block[6] & 0xFF) | ((block[7] & 0xFF) << 8);
+		byte bitField = block[8];
+		boolean interlaced = (bitField & 0x40) != 0;
+		//boolean sorted = (bitField & 0x20) != 0;
+		if ((bitField & 0x80) != 0) {
+			// Local palette.
+			depth = (bitField & 0x7) + 1;
+			palette = readPalette(1 << depth);
+		} else {
+			// No local palette.
+			depth = defaultDepth;
+			palette = defaultPalette;
+		}
+		/* Work around: Ignore the case where a GIF specifies an
+		 * invalid index for the transparent pixel that is larger
+		 * than the number of entries in the palette. */
+		if (transparentPixel > 1 << depth) {
+			transparentPixel = -1;
+		}
+		// Promote depth to next highest supported value.
+		if (!(depth == 1 || depth == 4 || depth == 8)) {
+			if (depth < 4)
+				depth = 4;
+			else
+				depth = 8;
+		}
+		if (palette == null) {
+			palette = grayRamp(1 << depth);
+		}
+		int initialCodeSize = -1;
+		try {
+			initialCodeSize = inputStream.read();
+		} catch (IOException e) {
+			SWT.error(SWT.ERROR_IO, e);
+		}
+		if (initialCodeSize < 0) {
+			SWT.error(SWT.ERROR_INVALID_IMAGE);
+		}
+		ImageData image = ImageData.internal_new(
+			width,
+			height,
+			depth,
+			palette,
+			4,
+			null,
+			0,
+			null,
+			null,
+			-1,
+			transparentPixel,
+			SWT.IMAGE_GIF,
+			left,
+			top,
+			disposalMethod,
+			delayTime);	
+		LZWCodec codec = new LZWCodec();
+		codec.decode(inputStream, loader, image, interlaced, initialCodeSize);
+		return image;
+	}
+
+	/**
+	 * Read a palette from the input stream.
+	 */
+	PaletteData readPalette(int numColors) {
+		byte[] bytes = new byte[numColors * 3];
+		try {
+			if (inputStream.read(bytes) != bytes.length)
+				SWT.error(SWT.ERROR_INVALID_IMAGE);
+		} catch (IOException e) {
+			SWT.error(SWT.ERROR_IO, e);
+		}
+		RGB[] colors = new RGB[numColors];
+		for (int i = 0; i < numColors; i++)
+			colors[i] = new RGB(bytes[i*3] & 0xFF, 
+				bytes[i*3+1] & 0xFF, bytes[i*3+2] & 0xFF);
+		return new PaletteData(colors);
+	}
+
+	void unloadIntoByteStream(ImageLoader loader) {
+		
+ 		/* Step 1: Acquire GIF parameters. */
+		ImageData[] data = loader.data;
+		int frameCount = data.length;
+		boolean multi = frameCount > 1;
+		ImageData firstImage = data[0];
+		int logicalScreenWidth = multi ? loader.logicalScreenWidth : firstImage.width;
+		int logicalScreenHeight = multi ? loader.logicalScreenHeight : firstImage.height;
+		int backgroundPixel = loader.backgroundPixel;
+		int depth = firstImage.depth;
+		PaletteData palette = firstImage.palette;
+		RGB[] colors = palette.getRGBs();
+		short globalTable = 1;
+				
+		/* Step 2: Check for validity and global/local color map. */
+		if (!(depth == 1 || depth == 4 || depth == 8)) {
+			SWT.error(SWT.ERROR_UNSUPPORTED_DEPTH);
+		}
+		for (int i=0; i<frameCount; i++) {
+			if (data[i].palette.isDirect) {
+				SWT.error(SWT.ERROR_INVALID_IMAGE);
+			}
+			if (multi) {
+				if (!(data[i].height <= logicalScreenHeight && data[i].width <= logicalScreenWidth && data[i].depth == depth)) {
+					SWT.error(SWT.ERROR_INVALID_IMAGE);
+				}
+				if (globalTable == 1) {
+					RGB rgbs[] = data[i].palette.getRGBs();
+					if (rgbs.length != colors.length) {
+						globalTable = 0;
+					} else { 
+						for (int j=0; j<colors.length; j++) {
+							if (!(rgbs[j].red == colors[j].red &&
+								rgbs[j].green == colors[j].green &&
+								rgbs[j].blue == colors[j].blue))
+									globalTable = 0;
+						}
+					}
+				}
+			}
+		}
+		
+		try {
+ 			/* Step 3: Write the GIF89a Header and Logical Screen Descriptor. */
+			outputStream.write(GIF89a);
+			int bitField = globalTable*128 + (depth-1)*16 + depth-1;
+			outputStream.writeShort((short)logicalScreenWidth);
+			outputStream.writeShort((short)logicalScreenHeight);
+			outputStream.write(bitField);
+			outputStream.write(backgroundPixel);
+			outputStream.write(0); // Aspect ratio is 1:1
+		} catch (IOException e) {
+			SWT.error(SWT.ERROR_IO, e);
+		}
+		
+		/* Step 4: Write Global Color Table if applicable. */
+		if (globalTable == 1) {
+			writePalette(palette, depth);
+		}
+
+		/* Step 5: Write Application Extension if applicable. */
+		if (multi) {
+			int repeatCount = loader.repeatCount;
+			try {
+				outputStream.write(GIF_EXTENSION_BLOCK_ID);
+				outputStream.write(GIF_APPLICATION_EXTENSION_BLOCK_ID);
+				outputStream.write(NETSCAPE2_0.length);
+				outputStream.write(NETSCAPE2_0);
+				outputStream.write(3); // Three bytes follow
+				outputStream.write(1); // Extension type
+				outputStream.writeShort((short) repeatCount);
+				outputStream.write(0); // Block terminator
+			} catch (IOException e) {
+				SWT.error(SWT.ERROR_IO, e);
+			}
+		}
+		
+		for (int frame=0; frame<frameCount; frame++) {
+			
+			/* Step 6: Write Graphics Control Block for each frame if applicable. */
+			if (multi || data[frame].transparentPixel != -1) {
+				writeGraphicsControlBlock(data[frame]);
+			}
+			
+			/* Step 7: Write Image Header for each frame. */
+			int x = data[frame].x;
+			int y = data[frame].y;
+			int width = data[frame].width;
+			int height = data[frame].height;
+			try {
+				outputStream.write(GIF_IMAGE_BLOCK_ID);
+				byte[] block = new byte[9];
+				block[0] = (byte)(x & 0xFF);
+				block[1] = (byte)((x >> 8) & 0xFF);
+				block[2] = (byte)(y & 0xFF);
+				block[3] = (byte)((y >> 8) & 0xFF);
+				block[4] = (byte)(width & 0xFF);
+				block[5] = (byte)((width >> 8) & 0xFF);
+				block[6] = (byte)(height & 0xFF);
+				block[7] = (byte)((height >> 8) & 0xFF); 
+				block[8] = (byte)(globalTable == 0 ? (depth-1) | 0x80 : 0x00);
+				outputStream.write(block);
+			} catch (IOException e) {
+				SWT.error(SWT.ERROR_IO, e);
+			}
+			
+			/* Step 8: Write Local Color Table for each frame if applicable. */
+			if (globalTable == 0) {
+				writePalette(data[frame].palette, depth);
+			}
+			
+			/* Step 9: Write the actual data for each frame. */
+			try {
+				outputStream.write(depth); // Minimum LZW Code size
+			} catch (IOException e) {
+				SWT.error(SWT.ERROR_IO, e);
+			}
+			new LZWCodec().encode(outputStream, data[frame]);
+		}
+
+		/* Step 10: Write GIF terminator. */
+		try {
+			outputStream.write(0x3B);
+		} catch (IOException e) {
+			SWT.error(SWT.ERROR_IO, e);
+		}
+	}
+
+	/**
+	 * Write out a GraphicsControlBlock to describe
+	 * the specified device independent image.
+	 */
+	void writeGraphicsControlBlock(ImageData image) {
+		try {
+			outputStream.write(GIF_EXTENSION_BLOCK_ID);
+			outputStream.write(GIF_GRAPHICS_CONTROL_BLOCK_ID);
+			byte[] gcBlock = new byte[4];
+			gcBlock[0] = 0;
+			gcBlock[1] = 0;
+			gcBlock[2] = 0;
+			gcBlock[3] = 0;
+			if (image.transparentPixel != -1) {
+				gcBlock[0] = (byte)0x01;
+				gcBlock[3] = (byte)image.transparentPixel;
+			}
+			if (image.disposalMethod != 0) {
+				gcBlock[0] |= (byte)((image.disposalMethod & 0x07) << 2);
+			}
+			if (image.delayTime != 0) {
+				gcBlock[1] = (byte)(image.delayTime & 0xFF);
+				gcBlock[2] = (byte)((image.delayTime >> 8) & 0xFF);
+			}
+			outputStream.write((byte)gcBlock.length);
+			outputStream.write(gcBlock);
+			outputStream.write(0); // Block terminator
+		} catch (IOException e) {
+			SWT.error(SWT.ERROR_IO, e);
+		}
+	}
+
+	/**
+	 * Write the specified palette to the output stream.
+	 */
+	void writePalette(PaletteData palette, int depth) {
+		byte[] bytes = new byte[(1 << depth) * 3];
+		int offset = 0;
+		for (int i = 0; i < palette.colors.length; i++) {
+			RGB color = palette.colors[i];
+			bytes[offset] = (byte)color.red;
+			bytes[offset + 1] = (byte)color.green;
+			bytes[offset + 2] = (byte)color.blue;
+			offset += 3;
+		}
+		try {
+			outputStream.write(bytes);
+		} catch (IOException e) {
+			SWT.error(SWT.ERROR_IO, e);
+		}
+	}
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/GIFFileFormat.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/JPEGAppn.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/JPEGAppn.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/JPEGAppn.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.image;
+
+
+final class JPEGAppn extends JPEGVariableSizeSegment {
+
+	public JPEGAppn(byte[] reference) {
+		super(reference);
+	}
+	
+	public JPEGAppn(LEDataInputStream byteStream) {
+		super(byteStream);
+	}
+	
+	public boolean verify() {
+		int marker = getSegmentMarker();
+		return marker >= JPEGFileFormat.APP0 && marker <= JPEGFileFormat.APP15;
+	}
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/JPEGAppn.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/JPEGArithmeticConditioningTable.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/JPEGArithmeticConditioningTable.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/JPEGArithmeticConditioningTable.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.image;
+
+
+final class JPEGArithmeticConditioningTable extends JPEGVariableSizeSegment {
+
+	public JPEGArithmeticConditioningTable(LEDataInputStream byteStream) {
+		super(byteStream);
+	}
+	
+	public int signature() {
+		return JPEGFileFormat.DAC;
+	}
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/JPEGArithmeticConditioningTable.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/JPEGComment.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/JPEGComment.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/JPEGComment.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.image;
+
+
+final class JPEGComment extends JPEGVariableSizeSegment {
+
+	public JPEGComment(byte[] reference) {
+		super(reference);
+	}
+	
+	public JPEGComment(LEDataInputStream byteStream) {
+		super(byteStream);
+	}
+	
+	public int signature() {
+		return JPEGFileFormat.COM;
+	}
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/JPEGComment.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/JPEGDecoder.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/JPEGDecoder.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/JPEGDecoder.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,6360 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.image;
+
+import java.io.*;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
+public class JPEGDecoder {
+	
+	static final int DCTSIZE = 8;
+	static final int DCTSIZE2 = 64;
+	static final int NUM_QUANT_TBLS = 4;
+	static final int NUM_HUFF_TBLS = 4;
+	static final int NUM_ARITH_TBLS = 16;
+	static final int MAX_COMPS_IN_SCAN = 4;
+	static final int MAX_COMPONENTS = 10;
+	static final int MAX_SAMP_FACTOR = 4;
+	static final int D_MAX_BLOCKS_IN_MCU = 10;
+	static final int HUFF_LOOKAHEAD = 8;
+	static final int MAX_Q_COMPS = 4;
+	static final int IFAST_SCALE_BITS = 2;
+	static final int MAXJSAMPLE = 255;
+	static final int CENTERJSAMPLE = 128;
+	static final int MIN_GET_BITS = 32-7;
+	static final int INPUT_BUFFER_SIZE = 4096;
+
+	static final int SCALEBITS = 16;	/* speediest right-shift on some machines */
+	static final int ONE_HALF = 1 << (SCALEBITS-1);
+	
+	static final int RGB_RED = 2;	/* Offset of Red in an RGB scanline element */
+	static final int RGB_GREEN = 1;	/* Offset of Green */
+	static final int RGB_BLUE = 0;	/* Offset of Blue */
+	static final int RGB_PIXELSIZE = 3;
+	
+	static final int JBUF_PASS_THRU = 0;
+	static final int JBUF_SAVE_SOURCE = 1;	/* Run source subobject only, save output */
+	static final int JBUF_CRANK_DEST = 2;	/* Run dest subobject only, using saved data */
+	static final int JBUF_SAVE_AND_PASS = 3;	
+	
+	static final int JPEG_MAX_DIMENSION = 65500;
+	static final int BITS_IN_JSAMPLE = 8;
+	
+	static final int JDITHER_NONE = 0;		/* no dithering */
+	static final int JDITHER_ORDERED = 1;	/* simple ordered dither */
+	static final int JDITHER_FS = 2;	
+	
+	static final int JDCT_ISLOW = 0;	/* slow but accurate integer algorithm */
+	static final int JDCT_IFAST = 1;	/* faster, less accurate integer method */
+	static final int JDCT_FLOAT = 2;	/* floating-point: accurate, fast on fast HW */
+	static final int JDCT_DEFAULT = JDCT_ISLOW;
+
+	static final int JCS_UNKNOWN = 0;		/* error/unspecified */
+	static final int JCS_GRAYSCALE = 1;		/* monochrome */
+	static final int JCS_RGB = 2;		/* red/green/blue */
+	static final int JCS_YCbCr = 3;		/* Y/Cb/Cr (also known as YUV) */
+	static final int JCS_CMYK = 4;		/* C/M/Y/K */
+	static final int JCS_YCCK = 5;		/* Y/Cb/Cr/K */
+
+	static final int SAVED_COEFS = 6;
+	static final int Q01_POS = 1;
+	static final int Q10_POS = 8;
+	static final int Q20_POS = 16;
+	static final int Q11_POS = 9;
+	static final int Q02_POS = 2;
+	
+	static final int CTX_PREPARE_FOR_IMCU = 0;	/* need to prepare for MCU row */
+	static final int CTX_PROCESS_IMCU = 1;	/* feeding iMCU to postprocessor */
+	static final int CTX_POSTPONED_ROW = 2;	/* feeding postponed row group */
+	
+	static final int APP0_DATA_LEN = 14;	/* Length of interesting data in APP0 */
+	static final int APP14_DATA_LEN = 12;	/* Length of interesting data in APP14 */
+	static final int APPN_DATA_LEN = 14;	/* Must be the largest of the above!! */
+
+	/* markers */
+	static final int M_SOF0 = 0xc0;
+	static final int M_SOF1 = 0xc1;
+	static final int M_SOF2 = 0xc2;
+	static final int M_SOF3 = 0xc3;
+	static final int M_SOF5 = 0xc5;
+	static final int M_SOF6 = 0xc6;
+	static final int M_SOF7 = 0xc7;
+	static final int M_JPG = 0xc8;
+	static final int M_SOF9 = 0xc9;
+	static final int M_SOF10 = 0xca;
+	static final int M_SOF11 = 0xcb;
+	static final int M_SOF13 = 0xcd;
+	static final int M_SOF14 = 0xce;
+	static final int M_SOF15 = 0xcf;
+	static final int M_DHT = 0xc4;
+	static final int M_DAC = 0xcc;
+	static final int M_RST0 = 0xd0;
+	static final int M_RST1 = 0xd1;
+	static final int M_RST2	= 0xd2;
+	static final int M_RST3 = 0xd3;
+	static final int M_RST4 = 0xd4;
+	static final int M_RST5 = 0xd5;
+	static final int M_RST6 = 0xd6;
+	static final int M_RST7 = 0xd7;
+	static final int M_SOI = 0xd8;
+	static final int M_EOI = 0xd9;
+	static final int M_SOS = 0xda;
+	static final int M_DQT = 0xdb;
+	static final int M_DNL = 0xdc;
+	static final int M_DRI = 0xdd;
+	static final int M_DHP = 0xde;
+	static final int M_EXP = 0xdf;
+	static final int M_APP0 = 0xe0;
+	static final int M_APP1 = 0xe1;
+	static final int M_APP2 = 0xe2;
+	static final int M_APP3 = 0xe3;
+	static final int M_APP4 = 0xe4;
+	static final int M_APP5 = 0xe5;
+	static final int M_APP6 = 0xe6;
+	static final int M_APP7 = 0xe7;
+	static final int M_APP8 = 0xe8;
+	static final int M_APP9 = 0xe9;
+	static final int M_APP10 = 0xea;
+	static final int M_APP11 = 0xeb;
+	static final int M_APP12 = 0xec;
+	static final int M_APP13 = 0xed;
+	static final int M_APP14 = 0xee;
+	static final int M_APP15 = 0xef;
+ 	static final int M_JPG0 = 0xf0;
+	static final int M_JPG13 = 0xfd;
+	static final int M_COM = 0xfe;
+	static final int M_TEM = 0x01;
+	static final int M_ERROR = 0x100;
+	
+	/* Values of global_state field (jdapi.c has some dependencies on ordering!) */
+	static final int CSTATE_START = 100;	/* after create_compress */
+	static final int CSTATE_SCANNING = 101;	/* start_compress done, write_scanlines OK */
+	static final int CSTATE_RAW_OK = 102;	/* start_compress done, write_raw_data OK */
+	static final int CSTATE_WRCOEFS = 103;	/* jpeg_write_coefficients done */
+	static final int DSTATE_START = 200;	/* after create_decompress */
+	static final int DSTATE_INHEADER = 201;	/* reading header markers, no SOS yet */
+	static final int DSTATE_READY = 202;	/* found SOS, ready for start_decompress */
+	static final int DSTATE_PRELOAD = 203;	/* reading multiscan file in start_decompress*/
+	static final int DSTATE_PRESCAN = 204;	/* performing dummy pass for 2-pass quant */
+	static final int DSTATE_SCANNING = 205;	/* start_decompress done, read_scanlines OK */
+	static final int DSTATE_RAW_OK = 206;	/* start_decompress done, read_raw_data OK */
+	static final int DSTATE_BUFIMAGE = 207;	/* expecting jpeg_start_output */
+	static final int DSTATE_BUFPOST = 208;	/* looking for SOS/EOI in jpeg_finish_output */
+	static final int DSTATE_RDCOEFS = 209;	/* reading file in jpeg_read_coefficients */
+	static final int DSTATE_STOPPING = 210;	/* looking for EOI in jpeg_finish_decompress */
+
+	static final int JPEG_REACHED_SOS = 1; /* Reached start of new scan */
+	static final int JPEG_REACHED_EOI = 2; /* Reached end of image */
+	static final int JPEG_ROW_COMPLETED = 3; /* Completed one iMCU row */
+	static final int JPEG_SCAN_COMPLETED = 4; /* Completed last iMCU row of a scan */
+	
+	static final int JPEG_SUSPENDED = 0; /* Suspended due to lack of input data */
+	static final int JPEG_HEADER_OK = 1; /* Found valid image datastream */
+	static final int JPEG_HEADER_TABLES_ONLY = 2; /* Found valid table-specs-only datastream */
+
+	/* Function pointers */
+	static final int DECOMPRESS_DATA = 0;
+	static final int DECOMPRESS_SMOOTH_DATA = 1;
+	static final int DECOMPRESS_ONEPASS = 2;
+	
+	static final int CONSUME_DATA = 0;
+	static final int DUMMY_CONSUME_DATA = 1;
+	
+	static final int PROCESS_DATA_SIMPLE_MAIN = 0;
+	static final int PROCESS_DATA_CONTEXT_MAIN = 1;
+	static final int PROCESS_DATA_CRANK_POST = 2;
+	
+	static final int POST_PROCESS_1PASS = 0;
+	static final int POST_PROCESS_DATA_UPSAMPLE = 1;
+	
+	static final int NULL_CONVERT = 0;
+	static final int GRAYSCALE_CONVERT = 1;
+	static final int YCC_RGB_CONVERT = 2;
+	static final int GRAY_RGB_CONVERT = 3;
+	static final int YCCK_CMYK_CONVERT = 4;
+	
+	static final int NOOP_UPSAMPLE = 0;
+	static final int FULLSIZE_UPSAMPLE = 1;
+	static final int H2V1_FANCY_UPSAMPLE = 2;
+	static final int H2V1_UPSAMPLE = 3;
+	static final int H2V2_FANCY_UPSAMPLE = 4;
+	static final int H2V2_UPSAMPLE = 5;
+	static final int INT_UPSAMPLE = 6;
+	
+	static final int INPUT_CONSUME_INPUT = 0;
+	static final int COEF_CONSUME_INPUT = 1;
+	
+	static int extend_test[] =	 /* entry n is 2**(n-1) */
+	{
+		0, 0x0001, 0x0002, 0x0004, 0x0008, 0x0010, 0x0020, 0x0040, 0x0080,
+		0x0100, 0x0200, 0x0400, 0x0800, 0x1000, 0x2000, 0x4000
+	};
+
+	static int extend_offset[] = /* entry n is (-1 << n) + 1 */
+	{
+		0, ((-1)<<1) + 1, ((-1)<<2) + 1, ((-1)<<3) + 1, ((-1)<<4) + 1,
+		((-1)<<5) + 1, ((-1)<<6) + 1, ((-1)<<7) + 1, ((-1)<<8) + 1,
+		((-1)<<9) + 1, ((-1)<<10) + 1, ((-1)<<11) + 1, ((-1)<<12) + 1,
+		((-1)<<13) + 1, ((-1)<<14) + 1, ((-1)<<15) + 1
+	};
+	
+	static int jpeg_natural_order[] = {
+		0,	1,	8, 16,	9,	2,	3, 10,
+		17, 24, 32, 25, 18, 11,	4,	5,
+		12, 19, 26, 33, 40, 48, 41, 34,
+		27, 20, 13,	6,	7, 14, 21, 28,
+		35, 42, 49, 56, 57, 50, 43, 36,
+		29, 22, 15, 23, 30, 37, 44, 51,
+		58, 59, 52, 45, 38, 31, 39, 46,
+		53, 60, 61, 54, 47, 55, 62, 63,
+		63, 63, 63, 63, 63, 63, 63, 63, /* extra entries for safety in decoder */
+		63, 63, 63, 63, 63, 63, 63, 63
+	};
+	
+	static final class JQUANT_TBL {
+		/* This array gives the coefficient quantizers in natural array order
+		 * (not the zigzag order in which they are stored in a JPEG DQT marker).
+		 * CAUTION: IJG versions prior to v6a kept this array in zigzag order.
+		 */
+		short[] quantval = new short[DCTSIZE2];	/* quantization step for each coefficient */
+		/* This field is used only during compression.	It's initialized false when
+		 * the table is created, and set true when it's been output to the file.
+		 * You could suppress output of a table by setting this to true.
+		 * (See jpeg_suppress_tables for an example.)
+		 */
+		boolean sent_table;		/* true when table has been output */
+	}
+	
+	static final class JHUFF_TBL {
+		/* These two fields directly represent the contents of a JPEG DHT marker */
+		byte[] bits = new byte[17]; /* bits[k] = # of symbols with codes of */
+									/* length k bits; bits[0] is unused */
+		byte[] huffval = new byte[256];		/* The symbols, in order of incr code length */
+		/* This field is used only during compression.	It's initialized false when
+		 * the table is created, and set true when it's been output to the file.
+		 * You could suppress output of a table by setting this to true.
+		 * (See jpeg_suppress_tables for an example.)
+		 */
+		boolean sent_table;		/* true when table has been output */
+	}
+	
+	static final class bitread_perm_state {		/* Bitreading state saved across MCUs */
+		int get_buffer;	/* current bit-extraction buffer */
+		int bits_left;		/* # of unused bits in it */
+	}
+	
+	static final class bitread_working_state {		/* Bitreading working state within an MCU */
+		/* Current data source location */
+		/* We need a copy, rather than munging the original, in case of suspension */
+		byte[] buffer; /* => next byte to read from source */
+		int bytes_offset;
+		int bytes_in_buffer;	/* # of bytes remaining in source buffer */
+		/* Bit input buffer --- note these values are kept in register variables,
+		 * not in this struct, inside the inner loops.
+		 */
+		int get_buffer;	/* current bit-extraction buffer */
+		int bits_left;		/* # of unused bits in it */
+		/* Pointer needed by jpeg_fill_bit_buffer. */
+		jpeg_decompress_struct cinfo;	/* back link to decompress master record */
+	} 
+	
+	static final class savable_state {
+		int EOBRUN; //Note that this is only used in the progressive case
+		int[] last_dc_val = new int[MAX_COMPS_IN_SCAN]; /* last DC coef for each component */
+	}
+	
+	static final class d_derived_tbl {
+		/* Basic tables: (element [0] of each array is unused) */
+		int[] maxcode = new int[18];		/* largest code of length k (-1 if none) */
+		/* (maxcode[17] is a sentinel to ensure jpeg_huff_decode terminates) */
+		int[] valoffset = new int[17];		/* huffval[] offset for codes of length k */
+		/* valoffset[k] = huffval[] index of 1st symbol of code length k, less
+		 * the smallest code of length k; so given a code of length k, the
+		 * corresponding symbol is huffval[code + valoffset[k]]
+		 */
+
+		/* Link to public Huffman table (needed only in jpeg_huff_decode) */
+		JHUFF_TBL pub;
+
+		/* Lookahead tables: indexed by the next HUFF_LOOKAHEAD bits of
+		 * the input data stream.	If the next Huffman code is no more
+		 * than HUFF_LOOKAHEAD bits long, we can obtain its length and
+		 * the corresponding symbol directly from these tables.
+		 */
+		int[] look_nbits = new int[1<<HUFF_LOOKAHEAD]; /* # bits, or 0 if too long */
+		byte[] look_sym = new byte[1<<HUFF_LOOKAHEAD]; /* symbol, or unused */
+	} 
+	
+	static final class jpeg_d_coef_controller {
+		int consume_data;
+		int decompress_data;
+
+		/* Pointer to array of coefficient virtual arrays, or null if none */
+		short[][][] coef_arrays;
+	
+		/* These variables keep track of the current location of the input side. */
+		/* cinfo.input_iMCU_row is also used for this. */
+		int MCU_ctr;		/* counts MCUs processed in current row */
+		int MCU_vert_offset;		/* counts MCU rows within iMCU row */
+		int MCU_rows_per_iMCU_row;	/* number of such rows needed */
+
+		/* The output side's location is represented by cinfo.output_iMCU_row. */
+
+		/* In single-pass modes, it's sufficient to buffer just one MCU.
+		 * We allocate a workspace of D_MAX_BLOCKS_IN_MCU coefficient blocks,
+		 * and let the entropy decoder write into that workspace each time.
+		 * (On 80x86, the workspace is FAR even though it's not really very big;
+		 * this is to keep the module interfaces unchanged when a large coefficient
+		 * buffer is necessary.)
+		 * In multi-pass modes, this array points to the current MCU's blocks
+		 * within the virtual arrays; it is used only by the input side.
+		 */
+		short[][] MCU_buffer = new short[D_MAX_BLOCKS_IN_MCU][];
+
+		/* In multi-pass modes, we need a virtual block array for each component. */
+		short[][][][] whole_image = new short[MAX_COMPONENTS][][][];
+
+		/* When doing block smoothing, we latch coefficient Al values here */
+		int[] coef_bits_latch;
+		
+		short[] workspace;
+
+		void start_input_pass (jpeg_decompress_struct cinfo) {
+			cinfo.input_iMCU_row = 0;
+			start_iMCU_row(cinfo);
+		}
+		
+		/* Reset within-iMCU-row counters for a new row (input side) */
+		void start_iMCU_row (jpeg_decompress_struct cinfo) {
+			jpeg_d_coef_controller coef = cinfo.coef;
+
+			/* In an interleaved scan, an MCU row is the same as an iMCU row.
+			 * In a noninterleaved scan, an iMCU row has v_samp_factor MCU rows.
+			 * But at the bottom of the image, process only what's left.
+			 */
+			if (cinfo.comps_in_scan > 1) {
+				coef.MCU_rows_per_iMCU_row = 1;
+			} else {
+				if (cinfo.input_iMCU_row < (cinfo.total_iMCU_rows-1))
+					coef.MCU_rows_per_iMCU_row = cinfo.cur_comp_info[0].v_samp_factor;
+				else
+					coef.MCU_rows_per_iMCU_row = cinfo.cur_comp_info[0].last_row_height;
+			}
+
+			coef.MCU_ctr = 0;
+			coef.MCU_vert_offset = 0;
+		}
+		
+	}
+	
+	static abstract class jpeg_entropy_decoder {
+		abstract void start_pass (jpeg_decompress_struct cinfo);
+		abstract boolean decode_mcu (jpeg_decompress_struct cinfo, short[][] MCU_data);
+
+		/* This is here to share code between baseline and progressive decoders; */
+		/* other modules probably should not use it */
+		boolean insufficient_data;	/* set true after emitting warning */
+		
+		bitread_working_state br_state_local = new bitread_working_state();
+		savable_state state_local = new savable_state();
+	}	
+
+	static final class huff_entropy_decoder extends jpeg_entropy_decoder {
+		bitread_perm_state bitstate = new bitread_perm_state();	/* Bit buffer at start of MCU */
+		savable_state saved = new savable_state();		/* Other state at start of MCU */
+
+		/* These fields are NOT loaded into local working state. */
+		int restarts_to_go;	/* MCUs left in this restart interval */
+
+		/* Pointers to derived tables (these workspaces have image lifespan) */
+		d_derived_tbl[] dc_derived_tbls = new d_derived_tbl[NUM_HUFF_TBLS];
+		d_derived_tbl[] ac_derived_tbls = new d_derived_tbl[NUM_HUFF_TBLS];
+
+		/* Precalculated info set up by start_pass for use in decode_mcu: */
+
+		/* Pointers to derived tables to be used for each block within an MCU */
+		d_derived_tbl[] dc_cur_tbls = new d_derived_tbl[D_MAX_BLOCKS_IN_MCU];
+		d_derived_tbl[] ac_cur_tbls = new d_derived_tbl[D_MAX_BLOCKS_IN_MCU];
+		/* Whether we care about the DC and AC coefficient values for each block */
+		boolean[] dc_needed = new boolean[D_MAX_BLOCKS_IN_MCU];
+		boolean[] ac_needed = new boolean[D_MAX_BLOCKS_IN_MCU];
+		
+		void start_pass (jpeg_decompress_struct cinfo) {
+			start_pass_huff_decoder(cinfo);
+		}
+
+		boolean decode_mcu (jpeg_decompress_struct cinfo, short[][] MCU_data) {
+			huff_entropy_decoder entropy = this;
+			int blkn;
+//			BITREAD_STATE_VARS;
+			int get_buffer;
+			int bits_left;
+//			bitread_working_state br_state = new bitread_working_state();
+//			savable_state state = new savable_state();
+			bitread_working_state br_state = br_state_local;
+			savable_state state = state_local;
+
+				/* Process restart marker if needed; may have to suspend */
+			if (cinfo.restart_interval != 0) {
+				if (entropy.restarts_to_go == 0)
+					if (! process_restart(cinfo))
+						return false;
+			}
+
+			/* If we've run out of data, just leave the MCU set to zeroes.
+			 * This way, we return uniform gray for the remainder of the segment.
+			 */
+			if (! entropy.insufficient_data) {
+
+				/* Load up working state */
+//				BITREAD_LOAD_STATE(cinfo,entropy.bitstate);
+				br_state.cinfo = cinfo;
+				br_state.buffer = cinfo.buffer; 
+				br_state.bytes_in_buffer = cinfo.bytes_in_buffer;
+				br_state.bytes_offset = cinfo.bytes_offset;
+				get_buffer = entropy.bitstate.get_buffer;
+				bits_left = entropy.bitstate.bits_left;
+					
+//				ASSIGN_STATE(state, entropy.saved);
+				state.last_dc_val[0] = entropy.saved.last_dc_val[0];
+				state.last_dc_val[1] = entropy.saved.last_dc_val[1];
+				state.last_dc_val[2] = entropy.saved.last_dc_val[2];
+				state.last_dc_val[3] = entropy.saved.last_dc_val[3];
+
+				/* Outer loop handles each block in the MCU */
+
+				for (blkn = 0; blkn < cinfo.blocks_in_MCU; blkn++) {
+					short[] block = MCU_data[blkn];
+					d_derived_tbl dctbl = entropy.dc_cur_tbls[blkn];
+					d_derived_tbl actbl = entropy.ac_cur_tbls[blkn];
+					int s = 0, k, r;
+
+					/* Decode a single block's worth of coefficients */
+
+					/* Section F.2.2.1: decode the DC coefficient difference */
+//					HUFF_DECODE(s, br_state, dctbl, return FALSE, label1);
+					{
+					int nb = 0, look;
+					if (bits_left < HUFF_LOOKAHEAD) {
+						if (!jpeg_fill_bit_buffer(br_state,get_buffer,bits_left, 0)) {
+							return false;
+						}
+						get_buffer = br_state.get_buffer; bits_left = br_state.bits_left;
+						if (bits_left < HUFF_LOOKAHEAD) {
+							nb = 1;
+//							goto slowlabel;
+							if ((s=jpeg_huff_decode(br_state,get_buffer,bits_left,dctbl,nb)) < 0) {
+								return false;
+							}
+							get_buffer = br_state.get_buffer; bits_left = br_state.bits_left;
+						}
+					}
+//					look = PEEK_BITS(HUFF_LOOKAHEAD);
+					if (nb != 1) {
+						look = (( (get_buffer >> (bits_left -	(HUFF_LOOKAHEAD)))) & ((1<<(HUFF_LOOKAHEAD))-1));
+						if ((nb = dctbl.look_nbits[look]) != 0) {
+//							DROP_BITS(nb);
+							bits_left -= nb;
+							s = dctbl.look_sym[look] & 0xFF;
+						} else {
+							nb = HUFF_LOOKAHEAD+1;
+//							slowlabel:
+							if ((s=jpeg_huff_decode(br_state,get_buffer,bits_left,dctbl,nb)) < 0) {
+								return false;
+							}
+							get_buffer = br_state.get_buffer; bits_left = br_state.bits_left;
+						}
+					}
+					}
+
+					if (s != 0) {
+//						CHECK_BIT_BUFFER(br_state, s, return FALSE);
+						{
+						if (bits_left < (s)) {
+							if (!jpeg_fill_bit_buffer(br_state,get_buffer,bits_left,s)) {
+								return false;
+							}
+							get_buffer = (br_state).get_buffer; bits_left = (br_state).bits_left;
+						}
+						}
+//						r = GET_BITS(s);
+						r = (( (get_buffer >> (bits_left -= (s)))) & ((1<<(s))-1));
+//						s = HUFF_EXTEND(r, s);
+						s = ((r) < extend_test[s] ? (r) + extend_offset[s] : (r));
+					}
+
+					if (entropy.dc_needed[blkn]) {
+						/* Convert DC difference to actual value, update last_dc_val */
+						int ci = cinfo.MCU_membership[blkn];
+						s += state.last_dc_val[ci];
+						state.last_dc_val[ci] = s;
+						/* Output the DC coefficient (assumes jpeg_natural_order[0] = 0) */
+						block[0] = (short) s;
+					}
+
+					if (entropy.ac_needed[blkn]) {
+
+						/* Section F.2.2.2: decode the AC coefficients */
+						/* Since zeroes are skipped, output area must be cleared beforehand */
+						for (k = 1; k < DCTSIZE2; k++) {
+//							HUFF_DECODE(s, br_state, actbl, return FALSE, label2);	
+							{
+							int nb = 0, look;
+							if (bits_left < HUFF_LOOKAHEAD) {
+								if (!jpeg_fill_bit_buffer(br_state,get_buffer,bits_left, 0)) {
+									return false;
+								}
+								get_buffer = br_state.get_buffer; bits_left = br_state.bits_left;
+								if (bits_left < HUFF_LOOKAHEAD) {
+									nb = 1; 
+//									goto slowlabel;
+									if ((s=jpeg_huff_decode(br_state,get_buffer,bits_left,actbl,nb)) < 0) {
+										return false;
+									}
+									get_buffer = br_state.get_buffer; bits_left = br_state.bits_left;
+								}
+							}
+							if (nb != 1) {
+//								look = PEEK_BITS(HUFF_LOOKAHEAD);
+								look = (( (get_buffer >> (bits_left -	(HUFF_LOOKAHEAD)))) & ((1<<(HUFF_LOOKAHEAD))-1));
+								if ((nb = actbl.look_nbits[look]) != 0) {
+//									DROP_BITS(nb);
+									bits_left -= (nb);
+									s = actbl.look_sym[look] & 0xFF;
+								} else {
+									nb = HUFF_LOOKAHEAD+1;
+//									slowlabel:
+									if ((s=jpeg_huff_decode(br_state,get_buffer,bits_left,actbl,nb)) < 0) {
+										return false;
+									}
+									get_buffer = br_state.get_buffer; bits_left = br_state.bits_left;
+								}
+							}
+							}			
+							r = s >> 4;
+							s &= 15;
+						
+							if (s != 0) {
+								k += r;
+//								CHECK_BIT_BUFFER(br_state, s, return FALSE);
+								{
+								if (bits_left < (s)) {
+									if (!jpeg_fill_bit_buffer(br_state, get_buffer, bits_left, s)) {
+										return false;
+									}
+									get_buffer = (br_state).get_buffer;
+									bits_left = (br_state).bits_left;
+								}
+								}
+//								r = GET_BITS(s);
+								r = (((get_buffer >> (bits_left -= (s)))) & ((1 << (s)) - 1));
+//								s = HUFF_EXTEND(r, s);
+								s = ((r) < extend_test[s] ? (r) + extend_offset[s] : (r));
+								/*
+								 * Output coefficient in natural (dezigzagged)
+								 * order. Note: the extra entries in
+								 * jpeg_natural_order[] will save us if k >=
+								 * DCTSIZE2, which could happen if the data is
+								 * corrupted.
+								 */
+								block[jpeg_natural_order[k]] = (short) s;
+							} else {
+								if (r != 15)
+									break;
+								k += 15;
+							}
+						}
+
+					} else {
+
+						/* Section F.2.2.2: decode the AC coefficients */
+						/* In this path we just discard the values */
+						for (k = 1; k < DCTSIZE2; k++) {
+//							HUFF_DECODE(s, br_state, actbl, return FALSE, label3);
+							{
+							int nb = 0, look;
+							if (bits_left < HUFF_LOOKAHEAD) {
+								if (!jpeg_fill_bit_buffer(br_state,get_buffer,bits_left, 0)) {
+									return false;
+								}
+								get_buffer = br_state.get_buffer; bits_left = br_state.bits_left;
+								if (bits_left < HUFF_LOOKAHEAD) {
+									nb = 1;
+//									goto slowlabel;
+									if ((s=jpeg_huff_decode(br_state,get_buffer,bits_left,actbl,nb)) < 0) {
+										return false;
+									}
+									get_buffer = br_state.get_buffer; bits_left = br_state.bits_left;
+								}
+							}
+							if (nb != 1) {
+//								look = PEEK_BITS(HUFF_LOOKAHEAD);
+								look = (( (get_buffer >> (bits_left -	(HUFF_LOOKAHEAD)))) & ((1<<(HUFF_LOOKAHEAD))-1));
+								if ((nb = actbl.look_nbits[look]) != 0) {
+//									DROP_BITS(nb);
+									bits_left -= (nb);
+									s = actbl.look_sym[look] & 0xFF;
+								} else {
+									nb = HUFF_LOOKAHEAD+1;
+//									slowlabel:
+									if ((s=jpeg_huff_decode(br_state,get_buffer,bits_left,actbl,nb)) < 0) {
+										return false;
+									}
+									get_buffer = br_state.get_buffer; bits_left = br_state.bits_left;
+								}
+							}
+							}			
+							r = s >> 4;
+							s &= 15;
+						
+							if (s != 0) {
+								k += r;
+//								CHECK_BIT_BUFFER(br_state, s, return FALSE);
+								{
+								if (bits_left < (s)) {
+									if (!jpeg_fill_bit_buffer((br_state),get_buffer,bits_left,s)) {
+										return false;
+									}
+									get_buffer = (br_state).get_buffer; bits_left = (br_state).bits_left;
+									}
+								}
+//								DROP_BITS(s);
+								bits_left -= s;
+							} else {
+								if (r != 15)
+									break;
+								k += 15;
+							}
+						}
+
+					}
+				}
+
+				/* Completed MCU, so update state */
+//				BITREAD_SAVE_STATE(cinfo,entropy.bitstate);
+				cinfo.buffer = br_state.buffer;
+				cinfo.bytes_in_buffer = br_state.bytes_in_buffer;
+				cinfo.bytes_offset = br_state.bytes_offset;
+				entropy.bitstate.get_buffer = get_buffer;
+				entropy.bitstate.bits_left = bits_left;
+//				ASSIGN_STATE(entropy.saved, state);
+				entropy.saved.last_dc_val[0] = state.last_dc_val[0];
+				entropy.saved.last_dc_val[1] = state.last_dc_val[1];
+				entropy.saved.last_dc_val[2] = state.last_dc_val[2];
+				entropy.saved.last_dc_val[3] = state.last_dc_val[3];
+			}
+
+			/* Account for restart interval (no-op if not using restarts) */
+			entropy.restarts_to_go--;
+
+			return true;
+		}
+
+		void start_pass_huff_decoder (jpeg_decompress_struct cinfo) {
+			huff_entropy_decoder entropy = this;
+			int ci, blkn, dctbl, actbl;
+			jpeg_component_info compptr;
+
+			/* Check that the scan parameters Ss, Se, Ah/Al are OK for sequential JPEG.
+			 * This ought to be an error condition, but we make it a warning because
+			 * there are some baseline files out there with all zeroes in these bytes.
+			 */
+			if (cinfo.Ss != 0 || cinfo.Se != DCTSIZE2-1 || cinfo.Ah != 0 || cinfo.Al != 0) {
+//				WARNMS(cinfo, JWRN_NOT_SEQUENTIAL);
+			}
+
+			for (ci = 0; ci < cinfo.comps_in_scan; ci++) {
+				compptr = cinfo.cur_comp_info[ci];
+				dctbl = compptr.dc_tbl_no;
+				actbl = compptr.ac_tbl_no;
+				/* Compute derived values for Huffman tables */
+				/* We may do this more than once for a table, but it's not expensive */
+				jpeg_make_d_derived_tbl(cinfo, true, dctbl, entropy.dc_derived_tbls[dctbl] = new d_derived_tbl());
+				jpeg_make_d_derived_tbl(cinfo, false, actbl, entropy.ac_derived_tbls[actbl] = new d_derived_tbl());
+				/* Initialize DC predictions to 0 */
+				entropy.saved.last_dc_val[ci] = 0;
+			}
+
+			/* Precalculate decoding info for each block in an MCU of this scan */
+			for (blkn = 0; blkn < cinfo.blocks_in_MCU; blkn++) {
+				ci = cinfo.MCU_membership[blkn];
+				compptr = cinfo.cur_comp_info[ci];
+				/* Precalculate which table to use for each block */
+				entropy.dc_cur_tbls[blkn] = entropy.dc_derived_tbls[compptr.dc_tbl_no];
+				entropy.ac_cur_tbls[blkn] = entropy.ac_derived_tbls[compptr.ac_tbl_no];
+				/* Decide whether we really care about the coefficient values */
+				if (compptr.component_needed) {
+					entropy.dc_needed[blkn] = true;
+					/* we don't need the ACs if producing a 1/8th-size image */
+					entropy.ac_needed[blkn] = (compptr.DCT_scaled_size > 1);
+				} else {
+					entropy.dc_needed[blkn] = entropy.ac_needed[blkn] = false;
+				}
+			}
+
+			/* Initialize bitread state variables */
+			entropy.bitstate.bits_left = 0;
+			entropy.bitstate.get_buffer = 0; /* unnecessary, but keeps Purify quiet */
+			entropy.insufficient_data = false;
+
+			/* Initialize restart counter */
+			entropy.restarts_to_go = cinfo.restart_interval;
+		}
+	
+		boolean process_restart (jpeg_decompress_struct cinfo) {
+			huff_entropy_decoder entropy = this;
+			int ci;
+
+			/* Throw away any unused bits remaining in bit buffer; */
+			/* include any full bytes in next_marker's count of discarded bytes */
+			cinfo.marker.discarded_bytes += entropy.bitstate.bits_left / 8;
+			entropy.bitstate.bits_left = 0;
+
+			/* Advance past the RSTn marker */
+			if (! read_restart_marker (cinfo))
+				return false;
+
+			/* Re-initialize DC predictions to 0 */
+			for (ci = 0; ci < cinfo.comps_in_scan; ci++)
+				entropy.saved.last_dc_val[ci] = 0;
+
+			/* Reset restart counter */
+			entropy.restarts_to_go = cinfo.restart_interval;
+
+			/* Reset out-of-data flag, unless read_restart_marker left us smack up
+			 * against a marker.	In that case we will end up treating the next data
+			 * segment as empty, and we can avoid producing bogus output pixels by
+			 * leaving the flag set.
+			 */
+			if (cinfo.unread_marker == 0)
+				entropy.insufficient_data = false;
+
+			return true;
+		}
+	}
+	
+	static final class phuff_entropy_decoder extends jpeg_entropy_decoder {
+
+		/* These fields are loaded into local variables at start of each MCU.
+		 * In case of suspension, we exit WITHOUT updating them.
+		 */
+		bitread_perm_state bitstate = new bitread_perm_state();	/* Bit buffer at start of MCU */
+		savable_state saved = new savable_state();		/* Other state at start of MCU */
+
+		/* These fields are NOT loaded into local working state. */
+		int restarts_to_go;	/* MCUs left in this restart interval */
+
+		/* Pointers to derived tables (these workspaces have image lifespan) */
+		d_derived_tbl[] derived_tbls = new d_derived_tbl[NUM_HUFF_TBLS];
+
+		d_derived_tbl ac_derived_tbl; /* active table during an AC scan */
+		
+		int[] newnz_pos = new int[DCTSIZE2];
+			
+		void start_pass (jpeg_decompress_struct cinfo) {
+			start_pass_phuff_decoder(cinfo);
+		}
+			
+		boolean decode_mcu (jpeg_decompress_struct cinfo, short[][] MCU_data) {
+			boolean is_DC_band = (cinfo.Ss == 0);
+			if (cinfo.Ah == 0) {
+				if (is_DC_band)
+					return decode_mcu_DC_first(cinfo, MCU_data);
+				else
+					return decode_mcu_AC_first(cinfo, MCU_data);
+			} else {
+				if (is_DC_band)
+					return decode_mcu_DC_refine(cinfo, MCU_data);
+				else
+					return decode_mcu_AC_refine(cinfo, MCU_data);
+			}
+		}
+			
+		boolean decode_mcu_DC_refine (jpeg_decompress_struct cinfo, short[][] MCU_data) {
+			phuff_entropy_decoder entropy = this;
+			int p1 = 1 << cinfo.Al;	/* 1 in the bit position being coded */
+			int blkn;
+			short[] block;
+//			BITREAD_STATE_VARS;
+			int get_buffer;
+			int bits_left;
+//			bitread_working_state br_state = new bitread_working_state();
+			bitread_working_state br_state = br_state_local;
+					
+			/* Process restart marker if needed; may have to suspend */
+			if (cinfo.restart_interval != 0) {
+				if (entropy.restarts_to_go == 0)
+					if (! process_restart(cinfo))
+						return false;
+			}
+
+			/* Not worth the cycles to check insufficient_data here,
+			 * since we will not change the data anyway if we read zeroes.
+			 */
+
+			/* Load up working state */
+//			BITREAD_LOAD_STATE(cinfo,entropy.bitstate);
+			br_state.cinfo = cinfo;
+			br_state.buffer = cinfo.buffer; 
+			br_state.bytes_in_buffer = cinfo.bytes_in_buffer;
+			br_state.bytes_offset = cinfo.bytes_offset;
+			get_buffer = entropy.bitstate.get_buffer;
+			bits_left = entropy.bitstate.bits_left;
+					
+			/* Outer loop handles each block in the MCU */
+
+			for (blkn = 0; blkn < cinfo.blocks_in_MCU; blkn++) {
+				block = MCU_data[blkn];
+
+				/* Encoded data is simply the next bit of the two's-complement DC value */
+//				CHECK_BIT_BUFFER(br_state, 1, return FALSE);
+				{
+				if (bits_left < (1)) {
+					if (!jpeg_fill_bit_buffer(br_state,get_buffer,bits_left,1)) {
+						 return false;
+					}
+					get_buffer = (br_state).get_buffer; bits_left = (br_state).bits_left;
+				}
+				}
+//				if (GET_BITS(1))
+				if ((( (get_buffer >> (bits_left -= (1)))) & ((1<<(1))-1)) != 0)
+					block[0] |= p1;
+					/* Note: since we use |=, repeating the assignment later is safe */
+			}
+
+			/* Completed MCU, so update state */
+//			BITREAD_SAVE_STATE(cinfo,entropy.bitstate);
+			cinfo.buffer = br_state.buffer;
+			cinfo.bytes_in_buffer = br_state.bytes_in_buffer;
+			cinfo.bytes_offset = br_state.bytes_offset;
+			entropy.bitstate.get_buffer = get_buffer;
+			entropy.bitstate.bits_left = bits_left;
+					
+			/* Account for restart interval (no-op if not using restarts) */
+			entropy.restarts_to_go--;
+
+			return true;
+
+		}
+			
+		boolean decode_mcu_AC_refine (jpeg_decompress_struct cinfo, short[][] MCU_data) {
+			phuff_entropy_decoder entropy = this;
+			int Se = cinfo.Se;
+			int p1 = 1 << cinfo.Al;	/* 1 in the bit position being coded */
+			int m1 = (-1) << cinfo.Al;	/* -1 in the bit position being coded */
+			int s = 0, k, r;
+			int EOBRUN;
+			short[] block;
+			short[] thiscoef;
+//			BITREAD_STATE_VARS;
+			int get_buffer;
+			int bits_left;
+//			bitread_working_state br_state = new bitread_working_state();
+			bitread_working_state br_state = br_state_local;
+				
+			d_derived_tbl tbl;
+			int num_newnz;
+			int[] newnz_pos = entropy.newnz_pos;
+
+				/* Process restart marker if needed; may have to suspend */
+			if (cinfo.restart_interval != 0) {
+				if (entropy.restarts_to_go == 0)
+					if (! process_restart(cinfo))
+						return false;
+			}
+
+			/* If we've run out of data, don't modify the MCU.
+			 */
+			if (! entropy.insufficient_data) {
+
+				/* Load up working state */
+//				BITREAD_LOAD_STATE(cinfo,entropy.bitstate);
+				br_state.cinfo = cinfo;
+				br_state.buffer = cinfo.buffer; 
+				br_state.bytes_in_buffer = cinfo.bytes_in_buffer;
+				br_state.bytes_offset = cinfo.bytes_offset;
+				get_buffer = entropy.bitstate.get_buffer;
+				bits_left = entropy.bitstate.bits_left;
+					
+				EOBRUN = entropy.saved.EOBRUN; /* only part of saved state we need */
+
+				/* There is always only one block per MCU */
+				block = MCU_data[0];
+				tbl = entropy.ac_derived_tbl;
+
+				/* If we are forced to suspend, we must undo the assignments to any newly
+				 * nonzero coefficients in the block, because otherwise we'd get confused
+				 * next time about which coefficients were already nonzero.
+				 * But we need not undo addition of bits to already-nonzero coefficients;
+				 * instead, we can test the current bit to see if we already did it.
+				 */
+				num_newnz = 0;
+
+				/* initialize coefficient loop counter to start of band */
+				k = cinfo.Ss;
+
+				if (EOBRUN == 0) {
+					for (; k <= Se; k++) {
+//						HUFF_DECODE(s, br_state, tbl, goto undoit, label3);
+						{
+						int nb = 0, look;
+						if (bits_left < HUFF_LOOKAHEAD) {
+							if (! jpeg_fill_bit_buffer(br_state,get_buffer,bits_left, 0)) {
+//								failaction;
+								while (num_newnz > 0)
+									block[newnz_pos[--num_newnz]] = 0;
+
+								return false;
+							}
+							get_buffer = br_state.get_buffer; bits_left = br_state.bits_left;
+							if (bits_left < HUFF_LOOKAHEAD) {
+								nb = 1; 
+//								goto slowlabel;
+								if ((s=jpeg_huff_decode(br_state,get_buffer,bits_left,tbl,nb)) < 0) {
+//									failaction;
+									while (num_newnz > 0)
+										block[newnz_pos[--num_newnz]] = 0;
+
+									return false;
+								}
+								get_buffer = br_state.get_buffer; bits_left = br_state.bits_left;
+							}
+						}
+						if (nb != 1) {
+//							look = PEEK_BITS(HUFF_LOOKAHEAD);
+							look = (( (get_buffer >> (bits_left -	(HUFF_LOOKAHEAD)))) & ((1<<(HUFF_LOOKAHEAD))-1));
+							if ((nb = tbl.look_nbits[look]) != 0) {
+//								DROP_BITS(nb);
+								bits_left -= nb;
+								s = tbl.look_sym[look] & 0xFF;
+							} else {
+								nb = HUFF_LOOKAHEAD+1;
+//								slowlabel:
+								if ((s=jpeg_huff_decode(br_state,get_buffer,bits_left,tbl,nb)) < 0) { 
+//									failaction;
+									while (num_newnz > 0)
+										block[newnz_pos[--num_newnz]] = 0;
+
+									return false;
+								}
+								get_buffer = br_state.get_buffer; bits_left = br_state.bits_left;
+							}
+						}
+						}
+						r = s >> 4;
+						s &= 15;
+						if (s != 0) {
+							if (s != 1) {		/* size of new coef should always be 1 */
+//								WARNMS(cinfo, JWRN_HUFF_BAD_CODE);
+							}
+//							CHECK_BIT_BUFFER(br_state, 1, goto undoit);
+							{
+							if (bits_left < (1)) {
+								if (! jpeg_fill_bit_buffer(br_state,get_buffer,bits_left,1)) {
+//									failaction;
+									while (num_newnz > 0)
+										block[newnz_pos[--num_newnz]] = 0;
+
+									return false;
+								}
+								get_buffer = (br_state).get_buffer; bits_left = (br_state).bits_left;
+								}
+							}
+//							if (GET_BITS(1))
+							if ((( (get_buffer >> (bits_left -= (1)))) & ((1<<(1))-1)) != 0)
+								s = p1;		/* newly nonzero coef is positive */
+							else
+								s = m1;		/* newly nonzero coef is negative */
+						} else {
+							if (r != 15) {
+								EOBRUN = 1 << r;	/* EOBr, run length is 2^r + appended bits */
+								if (r != 0) {
+//									CHECK_BIT_BUFFER(br_state, r, goto undoit);
+									{
+									if (bits_left < (r)) {
+										if (!jpeg_fill_bit_buffer(br_state,get_buffer,bits_left,r)) {
+//											failaction;
+											while (num_newnz > 0)
+												block[newnz_pos[--num_newnz]] = 0;
+
+											return false;
+										}
+										get_buffer = (br_state).get_buffer; bits_left = (br_state).bits_left;
+									}
+									}
+//									r = GET_BITS(r);
+									r = (( (get_buffer >> (bits_left -= (r)))) & ((1<<(r))-1));
+									EOBRUN += r;
+								}
+								break;		/* rest of block is handled by EOB logic */
+							}
+							/* note s = 0 for processing ZRL */
+						}
+						/* Advance over already-nonzero coefs and r still-zero coefs,
+						 * appending correction bits to the nonzeroes.	A correction bit is 1
+						 * if the absolute value of the coefficient must be increased.
+						 */
+						do {
+							thiscoef = block;
+							int thiscoef_offset = jpeg_natural_order[k];
+							if (thiscoef[thiscoef_offset] != 0) {
+//								CHECK_BIT_BUFFER(br_state, 1, goto undoit);
+								{
+								if (bits_left < (1)) {
+									if (!jpeg_fill_bit_buffer(br_state,get_buffer,bits_left,1)) {
+//										failaction;
+										while (num_newnz > 0)
+											block[newnz_pos[--num_newnz]] = 0;
+
+										return false;
+									}
+									get_buffer = (br_state).get_buffer; bits_left = (br_state).bits_left;
+								}
+								}
+//								if (GET_BITS(1)) {
+								if ((( (get_buffer >> (bits_left -= (1)))) & ((1<<(1))-1)) != 0) {
+									if ((thiscoef[thiscoef_offset] & p1) == 0) { /* do nothing if already set it */
+										if (thiscoef[thiscoef_offset] >= 0)
+											thiscoef[thiscoef_offset] += p1;
+										else
+											thiscoef[thiscoef_offset] += m1;
+									}
+								}
+							} else {
+								if (--r < 0)
+									break;		/* reached target zero coefficient */
+							}
+							k++;
+						} while (k <= Se);
+						if (s != 0) {
+							int pos = jpeg_natural_order[k];
+							/* Output newly nonzero coefficient */
+							block[pos] = (short) s;
+							/* Remember its position in case we have to suspend */
+							newnz_pos[num_newnz++] = pos;
+						}
+					}
+				}
+
+				if (EOBRUN > 0) {
+					/* Scan any remaining coefficient positions after the end-of-band
+					 * (the last newly nonzero coefficient, if any).	Append a correction
+					 * bit to each already-nonzero coefficient.	A correction bit is 1
+					 * if the absolute value of the coefficient must be increased.
+					 */
+					for (; k <= Se; k++) {
+						thiscoef = block;
+						int thiscoef_offset = jpeg_natural_order[k];
+						if (thiscoef[thiscoef_offset] != 0) {
+//							CHECK_BIT_BUFFER(br_state, 1, goto undoit);
+							{
+							if (bits_left < (1)) {
+								if (! jpeg_fill_bit_buffer(br_state,get_buffer,bits_left,1)) {
+//									failaction;
+									while (num_newnz > 0)
+										block[newnz_pos[--num_newnz]] = 0;
+	
+									return false;
+								}
+								get_buffer = (br_state).get_buffer; bits_left = (br_state).bits_left;
+							}
+							}
+//							if (GET_BITS(1)) {
+							if ((( (get_buffer >> (bits_left -= (1)))) & ((1<<(1))-1)) != 0) {
+								if ((thiscoef[thiscoef_offset] & p1) == 0) { /* do nothing if already changed it */
+									if (thiscoef[thiscoef_offset] >= 0)
+										thiscoef[thiscoef_offset] += p1;
+									else
+										thiscoef[thiscoef_offset] += m1;
+								}
+							}
+						}
+					}
+						/* Count one block completed in EOB run */
+					EOBRUN--;
+				}
+
+				/* Completed MCU, so update state */
+//				BITREAD_SAVE_STATE(cinfo,entropy.bitstate);
+				cinfo.buffer = br_state.buffer;
+				cinfo.bytes_in_buffer = br_state.bytes_in_buffer;
+				cinfo.bytes_offset = br_state.bytes_offset;
+				entropy.bitstate.get_buffer = get_buffer;
+				entropy.bitstate.bits_left = bits_left;
+						
+				entropy.saved.EOBRUN = EOBRUN; /* only part of saved state we need */
+			}
+
+			/* Account for restart interval (no-op if not using restarts) */
+			entropy.restarts_to_go--;
+
+			return true;
+
+//			undoit:
+//				/* Re-zero any output coefficients that we made newly nonzero */
+//				while (num_newnz > 0)
+//					(*block)[newnz_pos[--num_newnz]] = 0;
+//
+//				return false;
+
+		}			
+			
+		boolean decode_mcu_AC_first (jpeg_decompress_struct cinfo, short[][] MCU_data) {
+			phuff_entropy_decoder entropy = this;
+			int Se = cinfo.Se;
+			int Al = cinfo.Al;
+			int s = 0, k, r;
+			int EOBRUN;
+			short[] block;
+//			BITREAD_STATE_VARS;
+			int get_buffer;
+			int bits_left;
+//			bitread_working_state br_state = new bitread_working_state();
+			bitread_working_state br_state = br_state_local;
+					
+			d_derived_tbl tbl;
+
+			/* Process restart marker if needed; may have to suspend */
+			if (cinfo.restart_interval != 0) {
+				if (entropy.restarts_to_go == 0)
+					if (! process_restart(cinfo))
+						return false;
+			}
+
+			/* If we've run out of data, just leave the MCU set to zeroes.
+			 * This way, we return uniform gray for the remainder of the segment.
+			 */
+			if (! entropy.insufficient_data) {
+
+				/* Load up working state.
+				 * We can avoid loading/saving bitread state if in an EOB run.
+				 */
+				EOBRUN = entropy.saved.EOBRUN;	/* only part of saved state we need */
+
+				/* There is always only one block per MCU */
+
+				if (EOBRUN > 0)		/* if it's a band of zeroes... */
+					EOBRUN--;			/* ...process it now (we do nothing) */
+				else {
+//					BITREAD_LOAD_STATE(cinfo,entropy.bitstate);
+					br_state.cinfo = cinfo;
+					br_state.buffer = cinfo.buffer; 
+					br_state.bytes_in_buffer = cinfo.bytes_in_buffer;
+					br_state.bytes_offset = cinfo.bytes_offset;
+					get_buffer = entropy.bitstate.get_buffer;
+					bits_left = entropy.bitstate.bits_left;
+						
+					block = MCU_data[0];
+					tbl = entropy.ac_derived_tbl;
+
+					for (k = cinfo.Ss; k <= Se; k++) {
+//						HUFF_DECODE(s, br_state, tbl, return FALSE, label2);
+						{
+						int nb = 0, look;
+						if (bits_left < HUFF_LOOKAHEAD) {
+							if (! jpeg_fill_bit_buffer(br_state,get_buffer,bits_left, 0)) {
+								return false;
+							}
+							get_buffer = br_state.get_buffer; bits_left = br_state.bits_left;
+							if (bits_left < HUFF_LOOKAHEAD) {
+								nb = 1;
+//								goto slowlabel;
+								if ((s=jpeg_huff_decode(br_state,get_buffer,bits_left,tbl,nb)) < 0) {
+									return false;
+								}
+								get_buffer = br_state.get_buffer; bits_left = br_state.bits_left;
+							}
+						}
+						if (nb != 1) {
+//							look = PEEK_BITS(HUFF_LOOKAHEAD);
+							look = (( (get_buffer >> (bits_left -	(HUFF_LOOKAHEAD)))) & ((1<<(HUFF_LOOKAHEAD))-1));
+
+							if ((nb = tbl.look_nbits[look]) != 0) {
+//								DROP_BITS(nb);
+								bits_left -= nb;
+								s = tbl.look_sym[look] & 0xFF;
+							} else {
+								nb = HUFF_LOOKAHEAD+1;
+//								slowlabel:
+								if ((s=jpeg_huff_decode(br_state,get_buffer,bits_left,tbl,nb)) < 0) {
+									return false;
+								}
+								get_buffer = br_state.get_buffer; bits_left = br_state.bits_left;
+							}
+						}
+						}
+						r = s >> 4;
+						s &= 15;
+						if (s != 0) {
+							k += r;
+//							CHECK_BIT_BUFFER(br_state, s, return FALSE);
+							{
+							if (bits_left < (s)) {
+								if (! jpeg_fill_bit_buffer(br_state,get_buffer,bits_left,s)) {
+									return false;
+								}
+								get_buffer = (br_state).get_buffer; bits_left = (br_state).bits_left;
+							}
+							}
+//							r = GET_BITS(s);
+							r = (( (get_buffer >> (bits_left -= (s)))) & ((1<<(s))-1));
+//							s = HUFF_EXTEND(r, s);
+							s = ((r) < extend_test[s] ? (r) + extend_offset[s] : (r));
+							/* Scale and output coefficient in natural (dezigzagged) order */
+							block[jpeg_natural_order[k]] = (short) (s << Al);
+						} else {
+							if (r == 15) {	/* ZRL */
+								k += 15;		/* skip 15 zeroes in band */
+							} else {		/* EOBr, run length is 2^r + appended bits */
+								EOBRUN = 1 << r;
+								if (r != 0) {		/* EOBr, r > 0 */
+//									CHECK_BIT_BUFFER(br_state, r, return FALSE);
+									{
+									if (bits_left < (r)) {
+										if (! jpeg_fill_bit_buffer(br_state,get_buffer,bits_left,r)) {
+											return false;
+										}
+										get_buffer = (br_state).get_buffer; bits_left = (br_state).bits_left;
+									}
+									}
+//									r = GET_BITS(r);
+									r = (( (get_buffer >> (bits_left -= (r)))) & ((1<<(r))-1));
+									EOBRUN += r;
+								}
+								EOBRUN--;		/* this band is processed at this moment */
+								break;		/* force end-of-band */
+							}
+						}
+					}
+
+//					BITREAD_SAVE_STATE(cinfo,entropy.bitstate);
+					cinfo.buffer = br_state.buffer;
+					cinfo.bytes_in_buffer = br_state.bytes_in_buffer;
+					cinfo.bytes_offset = br_state.bytes_offset;
+					entropy.bitstate.get_buffer = get_buffer;
+					entropy.bitstate.bits_left = bits_left;
+				}
+
+				/* Completed MCU, so update state */
+				entropy.saved.EOBRUN = EOBRUN;	/* only part of saved state we need */
+			}
+
+			/* Account for restart interval (no-op if not using restarts) */
+			entropy.restarts_to_go--;
+
+			return true;
+		}
+			
+		boolean decode_mcu_DC_first (jpeg_decompress_struct cinfo, short[][] MCU_data) {	 
+			phuff_entropy_decoder entropy = this;
+			int Al = cinfo.Al;
+			int s = 0, r;
+			int blkn, ci;
+			short[] block;
+//			BITREAD_STATE_VARS;
+			int get_buffer;
+			int bits_left;
+//			bitread_working_state br_state = new bitread_working_state();
+			bitread_working_state br_state = br_state_local;
+				
+//			savable_state state = new savable_state();
+			savable_state state = state_local;
+			d_derived_tbl tbl;
+			jpeg_component_info compptr;
+
+			/* Process restart marker if needed; may have to suspend */
+			if (cinfo.restart_interval != 0) {
+				if (entropy.restarts_to_go == 0)
+					if (! process_restart(cinfo))
+						return false;
+			}
+
+			/* If we've run out of data, just leave the MCU set to zeroes.
+			 * This way, we return uniform gray for the remainder of the segment.
+			 */
+			if (! entropy.insufficient_data) {
+
+				/* Load up working state */
+//				BITREAD_LOAD_STATE(cinfo,entropy.bitstate);
+				br_state.cinfo = cinfo;
+				br_state.buffer = cinfo.buffer; 
+				br_state.bytes_in_buffer = cinfo.bytes_in_buffer;
+				br_state.bytes_offset = cinfo.bytes_offset;
+				get_buffer = entropy.bitstate.get_buffer;
+				bits_left = entropy.bitstate.bits_left;
+					
+//				ASSIGN_STATE(state, entropy.saved);
+				state.EOBRUN = entropy.saved.EOBRUN;
+				state.last_dc_val[0] = entropy.saved.last_dc_val[0];
+				state.last_dc_val[1] = entropy.saved.last_dc_val[1];
+				state.last_dc_val[2] = entropy.saved.last_dc_val[2];
+				state.last_dc_val[3] = entropy.saved.last_dc_val[3];
+					
+				/* Outer loop handles each block in the MCU */
+
+				for (blkn = 0; blkn < cinfo.blocks_in_MCU; blkn++) {
+					block = MCU_data[blkn];
+					ci = cinfo.MCU_membership[blkn];
+					compptr = cinfo.cur_comp_info[ci];
+					tbl = entropy.derived_tbls[compptr.dc_tbl_no];
+
+					/* Decode a single block's worth of coefficients */
+
+					/* Section F.2.2.1: decode the DC coefficient difference */
+//					HUFF_DECODE(s, br_state, tbl, return FALSE, label1);
+					{
+					int nb = 0, look;
+					if (bits_left < HUFF_LOOKAHEAD) {
+						if (! jpeg_fill_bit_buffer(br_state,get_buffer,bits_left, 0)) {
+							return false;
+						}
+						get_buffer = br_state.get_buffer; bits_left = br_state.bits_left;
+						if (bits_left < HUFF_LOOKAHEAD) {
+							nb = 1;
+//							goto slowlabel;
+							if ((s=jpeg_huff_decode(br_state,get_buffer,bits_left,tbl,nb)) < 0) {
+								return false;
+							}
+							get_buffer = br_state.get_buffer; bits_left = br_state.bits_left;
+						}
+					}
+					if (nb != 1) {
+//						look = PEEK_BITS(HUFF_LOOKAHEAD);
+						look = (( (get_buffer >> (bits_left -	(HUFF_LOOKAHEAD)))) & ((1<<(HUFF_LOOKAHEAD))-1));
+
+						if ((nb = tbl.look_nbits[look]) != 0) {
+//							DROP_BITS(nb);
+							bits_left -= nb;
+							s = tbl.look_sym[look] & 0xFF;
+						} else {
+							nb = HUFF_LOOKAHEAD+1;
+//							slowlabel:
+							if ((s=jpeg_huff_decode(br_state,get_buffer,bits_left,tbl,nb)) < 0) {
+								return false;
+							}
+							get_buffer = br_state.get_buffer; bits_left = br_state.bits_left;
+						}
+					}
+					}
+					if (s != 0) {
+//						CHECK_BIT_BUFFER(br_state, s, return FALSE);
+						{
+						if (bits_left < (s)) {
+							if (! jpeg_fill_bit_buffer(br_state,get_buffer,bits_left,s)) {
+								return false;
+							}
+							get_buffer = (br_state).get_buffer; bits_left = (br_state).bits_left;
+						}
+						}
+//						r = GET_BITS(s);
+						r = (( (get_buffer >> (bits_left -= (s)))) & ((1<<(s))-1));
+//						s = HUFF_EXTEND(r, s);
+						s = ((r) < extend_test[s] ? (r) + extend_offset[s] : (r));
+					}
+
+						/* Convert DC difference to actual value, update last_dc_val */
+					s += state.last_dc_val[ci];
+					state.last_dc_val[ci] = s;
+					/* Scale and output the coefficient (assumes jpeg_natural_order[0]=0) */
+					block[0] = (short) (s << Al);
+				}
+
+				/* Completed MCU, so update state */
+//				BITREAD_SAVE_STATE(cinfo,entropy.bitstate);
+				cinfo.buffer = br_state.buffer;
+				cinfo.bytes_in_buffer = br_state.bytes_in_buffer;
+				cinfo.bytes_offset = br_state.bytes_offset;
+				entropy.bitstate.get_buffer = get_buffer;
+				entropy.bitstate.bits_left = bits_left;
+//				ASSIGN_STATE(entropy.saved, state);
+				entropy.saved.EOBRUN = state.EOBRUN;
+				entropy.saved.last_dc_val[0] = state.last_dc_val[0];
+				entropy.saved.last_dc_val[1] = state.last_dc_val[1];
+				entropy.saved.last_dc_val[2] = state.last_dc_val[2];
+				entropy.saved.last_dc_val[3] = state.last_dc_val[3];
+			}
+
+			/* Account for restart interval (no-op if not using restarts) */
+			entropy.restarts_to_go--;
+
+			return true;
+		}
+			
+		boolean process_restart (jpeg_decompress_struct cinfo) {
+			phuff_entropy_decoder entropy = this;
+			int ci;
+
+			/* Throw away any unused bits remaining in bit buffer; */
+			/* include any full bytes in next_marker's count of discarded bytes */
+			cinfo.marker.discarded_bytes += entropy.bitstate.bits_left / 8;
+			entropy.bitstate.bits_left = 0;
+
+			/* Advance past the RSTn marker */
+			if (! read_restart_marker (cinfo))
+				return false;
+
+			/* Re-initialize DC predictions to 0 */
+			for (ci = 0; ci < cinfo.comps_in_scan; ci++)
+				entropy.saved.last_dc_val[ci] = 0;
+				/* Re-init EOB run count, too */
+			entropy.saved.EOBRUN = 0;
+
+			/* Reset restart counter */
+			entropy.restarts_to_go = cinfo.restart_interval;
+
+			/* Reset out-of-data flag, unless read_restart_marker left us smack up
+			 * against a marker.	In that case we will end up treating the next data
+			 * segment as empty, and we can avoid producing bogus output pixels by
+			 * leaving the flag set.
+			 */
+			if (cinfo.unread_marker == 0)
+				entropy.insufficient_data = false;
+
+			return true;
+		}
+
+		void start_pass_phuff_decoder (jpeg_decompress_struct cinfo) {
+			phuff_entropy_decoder entropy = this;
+			boolean is_DC_band, bad;
+			int ci, coefi, tbl;
+			int[] coef_bit_ptr;
+			jpeg_component_info compptr;
+
+			is_DC_band = (cinfo.Ss == 0);
+
+			/* Validate scan parameters */
+			bad = false;
+			if (is_DC_band) {
+				if (cinfo.Se != 0)
+					bad = true;
+			} else {
+				/* need not check Ss/Se < 0 since they came from unsigned bytes */
+				if (cinfo.Ss > cinfo.Se || cinfo.Se >= DCTSIZE2)
+					bad = true;
+				/* AC scans may have only one component */
+				if (cinfo.comps_in_scan != 1)
+					bad = true;
+			}
+			if (cinfo.Ah != 0) {
+				/* Successive approximation refinement scan: must have Al = Ah-1. */
+				if (cinfo.Al != cinfo.Ah-1)
+					bad = true;
+			}
+			if (cinfo.Al > 13)		/* need not check for < 0 */
+				bad = true;
+			/* Arguably the maximum Al value should be less than 13 for 8-bit precision,
+			 * but the spec doesn't say so, and we try to be liberal about what we
+			 * accept.	Note: large Al values could result in out-of-range DC
+			 * coefficients during early scans, leading to bizarre displays due to
+			 * overflows in the IDCT math.	But we won't crash.
+			 */
+			if (bad)
+				error();
+//				ERREXIT4(cinfo, JERR_BAD_PROGRESSION, cinfo.Ss, cinfo.Se, cinfo.Ah, cinfo.Al);
+			/* Update progression status, and verify that scan order is legal.
+			 * Note that inter-scan inconsistencies are treated as warnings
+			 * not fatal errors ... not clear if this is right way to behave.
+			 */
+			for (ci = 0; ci < cinfo.comps_in_scan; ci++) {
+				int cindex = cinfo.cur_comp_info[ci].component_index;
+				coef_bit_ptr = cinfo.coef_bits[cindex];
+				if (!is_DC_band && coef_bit_ptr[0] < 0) {/* AC without prior DC scan */
+//					WARNMS2(cinfo, JWRN_BOGUS_PROGRESSION, cindex, 0);
+				}
+				for (coefi = cinfo.Ss; coefi <= cinfo.Se; coefi++) {
+					int expected = (coef_bit_ptr[coefi] < 0) ? 0 : coef_bit_ptr[coefi];
+					if (cinfo.Ah != expected) {
+//						WARNMS2(cinfo, JWRN_BOGUS_PROGRESSION, cindex, coefi);
+					}
+					coef_bit_ptr[coefi] = cinfo.Al;
+				}
+			}
+
+			/* Select MCU decoding routine */
+//			if (cinfo.Ah == 0) {
+//				if (is_DC_band)
+//					entropy.pub.decode_mcu = decode_mcu_DC_first;
+//				else
+//					entropy.pub.decode_mcu = decode_mcu_AC_first;
+//			} else {
+//				if (is_DC_band)
+//					entropy.pub.decode_mcu = decode_mcu_DC_refine;
+//				else
+//					entropy.pub.decode_mcu = decode_mcu_AC_refine;
+//			}
+
+			for (ci = 0; ci < cinfo.comps_in_scan; ci++) {
+				compptr = cinfo.cur_comp_info[ci];
+				/* Make sure requested tables are present, and compute derived tables.
+				 * We may build same derived table more than once, but it's not expensive.
+				 */
+				if (is_DC_band) {
+					if (cinfo.Ah == 0) {	/* DC refinement needs no table */
+						tbl = compptr.dc_tbl_no;
+						jpeg_make_d_derived_tbl(cinfo, true, tbl, entropy.derived_tbls[tbl] = new d_derived_tbl());
+					}
+				} else {
+					tbl = compptr.ac_tbl_no;
+					jpeg_make_d_derived_tbl(cinfo, false, tbl, entropy.derived_tbls[tbl] = new d_derived_tbl());
+					/* remember the single active table */
+					entropy.ac_derived_tbl = entropy.derived_tbls[tbl];
+				}
+				/* Initialize DC predictions to 0 */
+				entropy.saved.last_dc_val[ci] = 0;
+			}
+
+			/* Initialize bitread state variables */
+			entropy.bitstate.bits_left = 0;
+			entropy.bitstate.get_buffer = 0; /* unnecessary, but keeps Purify quiet */
+			entropy.insufficient_data = false;
+
+			/* Initialize private state variables */
+			entropy.saved.EOBRUN = 0;
+
+			/* Initialize restart counter */
+			entropy.restarts_to_go = cinfo.restart_interval;
+		}
+
+	}
+	
+	static final class jpeg_component_info {
+		/* These values are fixed over the whole image. */
+		/* For compression, they must be supplied by parameter setup; */
+		/* for decompression, they are read from the SOF marker. */
+		int component_id;		/* identifier for this component (0..255) */
+		int component_index;		/* its index in SOF or cinfo.comp_info[] */
+		int h_samp_factor;		/* horizontal sampling factor (1..4) */
+		int v_samp_factor;		/* vertical sampling factor (1..4) */
+		int quant_tbl_no;		/* quantization table selector (0..3) */
+		/* These values may vary between scans. */
+		/* For compression, they must be supplied by parameter setup; */
+		/* for decompression, they are read from the SOS marker. */
+		/* The decompressor output side may not use these variables. */
+		int dc_tbl_no;		/* DC entropy table selector (0..3) */
+		int ac_tbl_no;		/* AC entropy table selector (0..3) */
+		
+		/* Remaining fields should be treated as private by applications. */
+		
+		/* These values are computed during compression or decompression startup: */
+		/* Component's size in DCT blocks.
+		 * Any dummy blocks added to complete an MCU are not counted; therefore
+		 * these values do not depend on whether a scan is interleaved or not.
+		 */
+		int width_in_blocks;
+		int height_in_blocks;
+		/* Size of a DCT block in samples.	Always DCTSIZE for compression.
+		 * For decompression this is the size of the output from one DCT block,
+		 * reflecting any scaling we choose to apply during the IDCT step.
+		 * Values of 1,2,4,8 are likely to be supported.	Note that different
+		 * components may receive different IDCT scalings.
+		 */
+		int DCT_scaled_size;
+		/* The downsampled dimensions are the component's actual, unpadded number
+		 * of samples at the main buffer (preprocessing/compression interface), thus
+		 * downsampled_width = ceil(image_width * Hi/Hmax)
+		 * and similarly for height.	For decompression, IDCT scaling is included, so
+		 * downsampled_width = ceil(image_width * Hi/Hmax * DCT_scaled_size/DCTSIZE)
+		 */
+		int downsampled_width;	 /* actual width in samples */
+		int downsampled_height; /* actual height in samples */
+		/* This flag is used only for decompression.	In cases where some of the
+		 * components will be ignored (eg grayscale output from YCbCr image),
+		 * we can skip most computations for the unused components.
+		 */
+		boolean component_needed;	/* do we need the value of this component? */
+
+		/* These values are computed before starting a scan of the component. */
+		/* The decompressor output side may not use these variables. */
+		int MCU_width;		/* number of blocks per MCU, horizontally */
+		int MCU_height;		/* number of blocks per MCU, vertically */
+		int MCU_blocks;		/* MCU_width * MCU_height */
+		int MCU_sample_width;		/* MCU width in samples, MCU_width*DCT_scaled_size */
+		int last_col_width;		/* # of non-dummy blocks across in last MCU */
+		int last_row_height;		/* # of non-dummy blocks down in last MCU */
+
+		/* Saved quantization table for component; null if none yet saved.
+		 * See jdinput.c comments about the need for this information.
+		 * This field is currently used only for decompression.
+		 */
+		JQUANT_TBL quant_table;
+
+		/* Private per-component storage for DCT or IDCT subsystem. */
+		int[] dct_table;
+	}
+	
+	static final class jpeg_color_quantizer {
+//		JMETHOD(void, start_pass, (j_decompress_ptr cinfo, boolean is_pre_scan));
+//		JMETHOD(void, color_quantize, (j_decompress_ptr cinfo,
+//					 JSAMPARRAY input_buf, JSAMPARRAY output_buf,
+//					 int num_rows));
+//		JMETHOD(void, finish_pass, (j_decompress_ptr cinfo));
+//		JMETHOD(void, new_color_map, (j_decompress_ptr cinfo));
+		
+		/* Initially allocated colormap is saved here */
+		int[][] sv_colormap;	/* The color map as a 2-D pixel array */
+		int sv_actual;		/* number of entries in use */
+
+		int[][] colorindex;	/* Precomputed mapping for speed */
+		/* colorindex[i][j] = index of color closest to pixel value j in component i,
+		 * premultiplied as described above.	Since colormap indexes must fit into
+		 * JSAMPLEs, the entries of this array will too.
+		 */
+		boolean is_padded;		/* is the colorindex padded for odither? */
+
+		int[] Ncolors = new int [MAX_Q_COMPS];	/* # of values alloced to each component */
+
+		/* Variables for ordered dithering */
+		int row_index;		/* cur row's vertical index in dither matrix */
+//			ODITHER_MATRIX_PTR odither[MAX_Q_COMPS]; /* one dither array per component */
+
+		/* Variables for Floyd-Steinberg dithering */
+//			FSERRPTR fserrors[MAX_Q_COMPS]; /* accumulated errors */
+		boolean on_odd_row;	
+			
+		void start_pass (jpeg_decompress_struct cinfo, boolean is_pre_scan) {
+			error();
+		}
+	}
+	
+	static final class jpeg_upsampler {
+//		JMETHOD(void, start_pass, (j_decompress_ptr cinfo));
+//		JMETHOD(void, upsample, (j_decompress_ptr cinfo,
+//					 JSAMPIMAGE input_buf,
+//					 JDIMENSION *in_row_group_ctr,
+//					 JDIMENSION in_row_groups_avail,
+//					 JSAMPARRAY output_buf,
+//					 JDIMENSION *out_row_ctr,
+//					 JDIMENSION out_rows_avail));
+
+		boolean need_context_rows;	/* TRUE if need rows above & below */
+			
+		/* Color conversion buffer.	When using separate upsampling and color
+		 * conversion steps, this buffer holds one upsampled row group until it
+		 * has been color converted and output.
+		 * Note: we do not allocate any storage for component(s) which are full-size,
+		 * ie do not need rescaling.	The corresponding entry of color_buf[] is
+		 * simply set to point to the input data array, thereby avoiding copying.
+		 */
+		byte[][][] color_buf = new byte[MAX_COMPONENTS][][];
+		int[] color_buf_offset = new int[MAX_COMPONENTS];
+
+		/* Per-component upsampling method pointers */
+		int[] methods = new int[MAX_COMPONENTS];
+
+		int next_row_out;		/* counts rows emitted from color_buf */
+		int rows_to_go;	/* counts rows remaining in image */
+
+		/* Height of an input row group for each component. */
+		int[] rowgroup_height = new int[MAX_COMPONENTS];
+
+		/* These arrays save pixel expansion factors so that int_expand need not
+		 * recompute them each time.	They are unused for other upsampling methods.
+		 */
+		byte[] h_expand = new byte[MAX_COMPONENTS];
+		byte[] v_expand = new byte[MAX_COMPONENTS];
+			
+		void start_pass (jpeg_decompress_struct cinfo) {
+			jpeg_upsampler upsample = cinfo.upsample;
+
+			/* Mark the conversion buffer empty */
+			upsample.next_row_out = cinfo.max_v_samp_factor;
+			/* Initialize total-height counter for detecting bottom of image */
+			upsample.rows_to_go = cinfo.output_height;
+		}
+			
+	}
+	
+	static final class jpeg_marker_reader {
+		/* Read a restart marker --- exported for use by entropy decoder only */
+//		jpeg_marker_parser_method read_restart_marker;
+
+		/* State of marker reader --- nominally internal, but applications
+		 * supplying COM or APPn handlers might like to know the state.
+		 */
+		boolean saw_SOI;		/* found SOI? */
+		boolean saw_SOF;		/* found SOF? */
+		int next_restart_num;		/* next restart number expected (0-7) */
+		int discarded_bytes;	/* # of bytes skipped looking for a marker */
+		
+		/* Application-overridable marker processing methods */
+//		jpeg_marker_parser_method process_COM;
+//		jpeg_marker_parser_method process_APPn[16];
+
+		/* Limit on marker data length to save for each marker type */
+		int length_limit_COM;
+		int[] length_limit_APPn = new int[16];
+
+		/* Status of COM/APPn marker saving */
+//		jpeg_marker_reader cur_marker;	/* null if not processing a marker */
+//		int bytes_read;		/* data bytes read so far in marker */
+		/* Note: cur_marker is not linked into marker_list until it's all read. */
+	}
+	
+	
+	static final class jpeg_d_main_controller {
+//		JMETHOD(void, start_pass, (j_decompress_ptr cinfo, J_BUF_MODE pass_mode));
+		int process_data;
+				
+		 /* Pointer to allocated workspace (M or M+2 row groups). */
+		byte[][][] buffer = new byte[MAX_COMPONENTS][][];
+		int[] buffer_offset = new int[MAX_COMPONENTS];
+
+		boolean buffer_full;		/* Have we gotten an iMCU row from decoder? */
+		int[] rowgroup_ctr = new int[1];	/* counts row groups output to postprocessor */
+
+		/* Remaining fields are only used in the context case. */
+
+		/* These are the master pointers to the funny-order pointer lists. */
+		byte[][][][] xbuffer = new byte[2][][][];	/* pointers to weird pointer lists */
+		int[][] xbuffer_offset = new int[2][];
+
+		int whichptr;			/* indicates which pointer set is now in use */
+		int context_state;		/* process_data state machine status */
+		int rowgroups_avail;	/* row groups available to postprocessor */
+		int iMCU_row_ctr;	/* counts iMCU rows to detect image top/bot */
+					
+		void start_pass (jpeg_decompress_struct cinfo, int pass_mode) {
+			jpeg_d_main_controller main = cinfo.main;
+
+			switch (pass_mode) {
+				case JBUF_PASS_THRU:
+					if (cinfo.upsample.need_context_rows) {
+						main.process_data = PROCESS_DATA_CONTEXT_MAIN;
+						make_funny_pointers(cinfo); /* Create the xbuffer[] lists */
+						main.whichptr = 0;	/* Read first iMCU row into xbuffer[0] */
+						main.context_state = CTX_PREPARE_FOR_IMCU;
+						main.iMCU_row_ctr = 0;
+					} else {
+						/* Simple case with no context needed */
+						main.process_data = PROCESS_DATA_SIMPLE_MAIN;
+					}
+					main.buffer_full = false;	/* Mark buffer empty */
+					main.rowgroup_ctr[0] = 0;
+					break;
+//				#ifdef QUANT_2PASS_SUPPORTED
+//				case JBUF_CRANK_DEST:
+//					/* For last pass of 2-pass quantization, just crank the postprocessor */
+//					main.process_data = PROCESS_DATA_CRANK_POST;
+//					break;
+//				#endif
+				default:
+					error();
+//					ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
+					break;
+			}
+		}
+					
+	}
+
+	static final class jpeg_decomp_master {
+//		JMETHOD(void, prepare_for_output_pass, (j_decompress_ptr cinfo));
+//		JMETHOD(void, finish_output_pass, (j_decompress_ptr cinfo));
+
+		/* State variables made visible to other modules */
+		boolean is_dummy_pass;
+
+		int pass_number;		/* # of passes completed */
+
+		boolean using_merged_upsample; /* true if using merged upsample/cconvert */
+
+		/* Saved references to initialized quantizer modules,
+		 * in case we need to switch modes.
+		 */
+		jpeg_color_quantizer quantizer_1pass;
+		jpeg_color_quantizer quantizer_2pass;
+	}
+	
+	static final class jpeg_inverse_dct {
+//		JMETHOD(void, start_pass, (j_decompress_ptr cinfo));
+//		/* It is useful to allow each component to have a separate IDCT method. */
+//		inverse_DCT_method_ptr inverse_DCT[MAX_COMPONENTS];
+		int[] cur_method = new int[MAX_COMPONENTS];
+			
+		void start_pass (jpeg_decompress_struct cinfo) {
+			jpeg_inverse_dct idct = cinfo.idct;
+			int ci, i;
+			jpeg_component_info compptr;
+			int method = 0;
+//			inverse_DCT_method_ptr method_ptr = NULL;
+			JQUANT_TBL qtbl;
+
+			for (ci = 0; ci < cinfo.num_components; ci++) {
+				compptr = cinfo.comp_info[ci];
+				/* Select the proper IDCT routine for this component's scaling */
+				switch (compptr.DCT_scaled_size) {
+//					#ifdef IDCT_SCALING_SUPPORTED
+//					case 1:
+//						method_ptr = jpeg_idct_1x1;
+//						method = JDCT_ISLOW;	/* jidctred uses islow-style table */
+//						break;
+//					case 2:
+//						method_ptr = jpeg_idct_2x2;
+//						method = JDCT_ISLOW;	/* jidctred uses islow-style table */
+//						break;
+//					case 4:
+//						method_ptr = jpeg_idct_4x4;
+//						method = JDCT_ISLOW;	/* jidctred uses islow-style table */
+//						break;
+//					#endif
+					case DCTSIZE:
+						switch (cinfo.dct_method) {
+//							#ifdef DCT_ISLOW_SUPPORTED
+							case JDCT_ISLOW:
+//								method_ptr = jpeg_idct_islow;
+								method = JDCT_ISLOW;
+								break;
+//							#endif
+//							#ifdef DCT_IFAST_SUPPORTED
+//							case JDCT_IFAST:
+//								method_ptr = jpeg_idct_ifast;
+//								method = JDCT_IFAST;
+//								break;
+//							#endif
+//							#ifdef DCT_FLOAT_SUPPORTED
+//							case JDCT_FLOAT:
+//								method_ptr = jpeg_idct_float;
+//								method = JDCT_FLOAT;
+//								break;
+//							#endif
+							default:
+								error();
+//								ERREXIT(cinfo, JERR_NOT_COMPILED);
+								break;
+						}
+						break;
+					default:
+						error();
+//						ERREXIT1(cinfo, JERR_BAD_DCTSIZE, compptr.DCT_scaled_size);
+						break;
+					}
+//					idct.inverse_DCT[ci] = method_ptr;
+					/* Create multiplier table from quant table.
+					 * However, we can skip this if the component is uninteresting
+					 * or if we already built the table.	Also, if no quant table
+					 * has yet been saved for the component, we leave the
+					 * multiplier table all-zero; we'll be reading zeroes from the
+					 * coefficient controller's buffer anyway.
+					 */
+					if (! compptr.component_needed || idct.cur_method[ci] == method)
+						continue;
+					qtbl = compptr.quant_table;
+					if (qtbl == null)		/* happens if no data yet for component */
+						continue;
+					idct.cur_method[ci] = method;
+					switch (method) {
+//						#ifdef PROVIDE_ISLOW_TABLES
+						case JDCT_ISLOW:
+						{
+							/* For LL&M IDCT method, multipliers are equal to raw quantization
+							 * coefficients, but are stored as ints to ensure access efficiency.
+							 */
+							int[] ismtbl = compptr.dct_table;
+							for (i = 0; i < DCTSIZE2; i++) {
+								ismtbl[i] = qtbl.quantval[i];
+							}
+						}
+						break;
+//						#endif
+//						#ifdef DCT_IFAST_SUPPORTED
+//						case JDCT_IFAST:
+//						{
+//							/* For AA&N IDCT method, multipliers are equal to quantization
+//							 * coefficients scaled by scalefactor[row]*scalefactor[col], where
+//							 *	 scalefactor[0] = 1
+//							 *	 scalefactor[k] = cos(k*PI/16) * sqrt(2)		for k=1..7
+//							 * For integer operation, the multiplier table is to be scaled by
+//							 * IFAST_SCALE_BITS.
+//							 */
+//							int[] ifmtbl = compptr.dct_table;
+//							short aanscales[] = {
+//								/* precomputed values scaled up by 14 bits */
+//								16384, 22725, 21407, 19266, 16384, 12873,	8867,	4520,
+//								22725, 31521, 29692, 26722, 22725, 17855, 12299,	6270,
+//								21407, 29692, 27969, 25172, 21407, 16819, 11585,	5906,
+//								19266, 26722, 25172, 22654, 19266, 15137, 10426,	5315,
+//								16384, 22725, 21407, 19266, 16384, 12873,	8867,	4520,
+//								12873, 17855, 16819, 15137, 12873, 10114,	6967,	3552,
+//								8867, 12299, 11585, 10426,	8867,	6967,	4799,	2446,
+//								4520,	6270,	5906,	5315,	4520,	3552,	2446,	1247
+//							};
+//							SHIFT_TEMPS
+//							
+//							for (i = 0; i < DCTSIZE2; i++) {
+//								ifmtbl[i] = DESCALE(MULTIPLY16V16( qtbl.quantval[i], aanscales[i]), CONST_BITS-IFAST_SCALE_BITS);
+//							}
+//						}
+//						break;
+//						#endif
+//						#ifdef DCT_FLOAT_SUPPORTED
+//						case JDCT_FLOAT:
+//						{
+//							/* For float AA&N IDCT method, multipliers are equal to quantization
+//							 * coefficients scaled by scalefactor[row]*scalefactor[col], where
+//							 *	 scalefactor[0] = 1
+//							 *	 scalefactor[k] = cos(k*PI/16) * sqrt(2)		for k=1..7
+//							 */
+//							FLOAT_MULT_TYPE * fmtbl = (FLOAT_MULT_TYPE *) compptr.dct_table;
+//							int row, col;
+//							static const double aanscalefactor[DCTSIZE] = {
+//								1.0, 1.387039845, 1.306562965, 1.175875602,
+//								1.0, 0.785694958, 0.541196100, 0.275899379
+//							};
+//
+//							i = 0;
+//							for (row = 0; row < DCTSIZE; row++) {
+//								for (col = 0; col < DCTSIZE; col++) {
+//									fmtbl[i] = (FLOAT_MULT_TYPE)
+//										((double) qtbl.quantval[i] *
+//									 aanscalefactor[row] * aanscalefactor[col]);
+//									i++;
+//								}
+//							}
+//						}
+//						break;
+//						#endif
+					default:
+						error();
+//						ERREXIT(cinfo, JERR_NOT_COMPILED);
+						break;
+				}
+			}
+		}
+	}
+			
+	static final class jpeg_input_controller {
+		int consume_input;
+		boolean has_multiple_scans;	/* True if file has multiple scans */
+		boolean eoi_reached;
+
+		boolean inheaders;		/* true until first SOS is reached */
+	}
+	
+	static final class	jpeg_color_deconverter {
+//		JMETHOD(void, start_pass, (j_decompress_ptr cinfo));
+		int color_convert;
+		
+		/* Private state for YCC.RGB conversion */
+		int[] Cr_r_tab;		/* => table for Cr to R conversion */
+		int[] Cb_b_tab;		/* => table for Cb to B conversion */
+		int[] Cr_g_tab;		/* => table for Cr to G conversion */
+		int[] Cb_g_tab;		/* => table for Cb to G conversion */
+			
+		void start_pass (jpeg_decompress_struct cinfo) {
+			/* no work needed */
+		}
+
+	}
+		
+	static final class jpeg_d_post_controller {
+//		JMETHOD(void, start_pass, (j_decompress_ptr cinfo, J_BUF_MODE pass_mode));
+		int post_process_data;
+			
+		/* Color quantization source buffer: this holds output data from
+		 * the upsample/color conversion step to be passed to the quantizer.
+		 * For two-pass color quantization, we need a full-image buffer;
+		 * for one-pass operation, a strip buffer is sufficient.
+		 */
+		int[] whole_image;	/* virtual array, or NULL if one-pass */
+		int[][] buffer;		/* strip buffer, or current strip of virtual */
+		int strip_height;	/* buffer size in rows */
+		/* for two-pass mode only: */
+		int starting_row;	/* row # of first row in current strip */
+		int next_row;		/* index of next row to fill/empty in strip */
+				
+		void start_pass (jpeg_decompress_struct cinfo, int pass_mode) {
+			jpeg_d_post_controller post = cinfo.post;
+
+			switch (pass_mode) {
+				case JBUF_PASS_THRU:
+					if (cinfo.quantize_colors) {
+						error(SWT.ERROR_NOT_IMPLEMENTED);
+//						/* Single-pass processing with color quantization. */
+//						post.post_process_data = POST_PROCESS_1PASS;
+//						/* We could be doing buffered-image output before starting a 2-pass
+//						 * color quantization; in that case, jinit_d_post_controller did not
+//						 * allocate a strip buffer.	Use the virtual-array buffer as workspace.
+//						 */
+//						if (post.buffer == null) {
+//							post.buffer = (*cinfo.mem.access_virt_sarray)
+//								((j_common_ptr) cinfo, post.whole_image,
+//						 		(JDIMENSION) 0, post.strip_height, TRUE);
+//						}
+					} else {
+						/* For single-pass processing without color quantization,
+						 * I have no work to do; just call the upsampler directly.
+						 */
+						post.post_process_data = POST_PROCESS_DATA_UPSAMPLE;
+					}
+					break;
+//				#ifdef QUANT_2PASS_SUPPORTED
+//				case JBUF_SAVE_AND_PASS:
+//					/* First pass of 2-pass quantization */
+//					if (post.whole_image == NULL)
+//						ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
+//					post.pub.post_process_data = post_process_prepass;
+//					break;
+//				case JBUF_CRANK_DEST:
+//					/* Second pass of 2-pass quantization */
+//					if (post.whole_image == NULL)
+//						ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
+//					post.pub.post_process_data = post_process_2pass;
+//					break;
+//				#endif /* QUANT_2PASS_SUPPORTED */
+					default:
+						error();
+//						ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
+						break;
+			}
+			post.starting_row = post.next_row = 0;
+		}
+
+	}
+	
+	static final class jpeg_decompress_struct {
+//		jpeg_error_mgr * err;	/* Error handler module */\
+//		struct jpeg_memory_mgr * mem;	/* Memory manager module */\
+//		struct jpeg_progress_mgr * progress; /* Progress monitor, or null if none */\
+//		void * client_data;		/* Available for use by application */\
+		boolean is_decompressor;	/* So common code can tell which is which */
+		int global_state;		/* For checking call sequence validity */
+
+//		/* Source of compressed data */
+//		struct jpeg_source_mgr * src;
+		InputStream inputStream;
+		byte[] buffer;
+		int bytes_in_buffer;
+		int bytes_offset;
+		boolean start_of_file;
+
+		/* Basic description of image --- filled in by jpeg_read_header(). */
+		/* Application may inspect these values to decide how to process image. */
+
+		int image_width;	/* nominal image width (from SOF marker) */
+		int image_height;	/* nominal image height */
+		int num_components;		/* # of color components in JPEG image */
+		int jpeg_color_space; /* colorspace of JPEG image */
+
+		/* Decompression processing parameters --- these fields must be set before
+		 * calling jpeg_start_decompress().	Note that jpeg_read_header() initializes
+		 * them to default values.
+		 */
+
+		int out_color_space; /* colorspace for output */
+
+		int scale_num, scale_denom; /* fraction by which to scale image */
+
+		double output_gamma;		/* image gamma wanted in output */
+
+		boolean buffered_image;	/* true=multiple output passes */
+		boolean raw_data_out;		/* true=downsampled data wanted */
+
+		int dct_method;	/* IDCT algorithm selector */
+		boolean do_fancy_upsampling;	/* true=apply fancy upsampling */
+		boolean do_block_smoothing;	/* true=apply interblock smoothing */
+
+		boolean quantize_colors;	/* true=colormapped output wanted */
+		/* the following are ignored if not quantize_colors: */
+		int dither_mode;	/* type of color dithering to use */
+		boolean two_pass_quantize;	/* true=use two-pass color quantization */
+		int desired_number_of_colors;	/* max # colors to use in created colormap */
+		/* these are significant only in buffered-image mode: */
+		boolean enable_1pass_quant;	/* enable future use of 1-pass quantizer */
+		boolean enable_external_quant;/* enable future use of external colormap */
+		boolean enable_2pass_quant;	/* enable future use of 2-pass quantizer */
+
+		/* Description of actual output image that will be returned to application.
+		 * These fields are computed by jpeg_start_decompress().
+		 * You can also use jpeg_calc_output_dimensions() to determine these values
+		 * in advance of calling jpeg_start_decompress().
+		 */
+
+		int output_width;	/* scaled image width */
+		int output_height;	/* scaled image height */
+		int out_color_components;	/* # of color components in out_color_space */
+		int output_components;	/* # of color components returned */
+		/* output_components is 1 (a colormap index) when quantizing colors;
+		 * otherwise it equals out_color_components.
+		 */
+		int rec_outbuf_height;	/* min recommended height of scanline buffer */
+		/* If the buffer passed to jpeg_read_scanlines() is less than this many rows
+		 * high, space and time will be wasted due to unnecessary data copying.
+		 * Usually rec_outbuf_height will be 1 or 2, at most 4.
+		 */
+
+		/* When quantizing colors, the output colormap is described by these fields.
+		 * The application can supply a colormap by setting colormap non-null before
+		 * calling jpeg_start_decompress; otherwise a colormap is created during
+		 * jpeg_start_decompress or jpeg_start_output.
+		 * The map has out_color_components rows and actual_number_of_colors columns.
+		 */
+		int actual_number_of_colors;	/* number of entries in use */
+		int[] colormap;		/* The color map as a 2-D pixel array */
+
+		/* State variables: these variables indicate the progress of decompression.
+		 * The application may examine these but must not modify them.
+		 */
+
+		/* Row index of next scanline to be read from jpeg_read_scanlines().
+		 * Application may use this to control its processing loop, e.g.,
+		 * "while (output_scanline < output_height)".
+		 */
+		int output_scanline;	/* 0 .. output_height-1	*/
+
+		/* Current input scan number and number of iMCU rows completed in scan.
+		 * These indicate the progress of the decompressor input side.
+		 */
+		int input_scan_number;	/* Number of SOS markers seen so far */
+		int input_iMCU_row;	/* Number of iMCU rows completed */
+
+		/* The "output scan number" is the notional scan being displayed by the
+		 * output side.	The decompressor will not allow output scan/row number
+		 * to get ahead of input scan/row, but it can fall arbitrarily far behind.
+		 */
+		int output_scan_number;	/* Nominal scan number being displayed */
+		int output_iMCU_row;	/* Number of iMCU rows read */
+
+		/* Current progression status.	coef_bits[c][i] indicates the precision
+		 * with which component c's DCT coefficient i (in zigzag order) is known.
+		 * It is -1 when no data has yet been received, otherwise it is the point
+		 * transform (shift) value for the most recent scan of the coefficient
+		 * (thus, 0 at completion of the progression).
+		 * This pointer is null when reading a non-progressive file.
+		 */
+		int[][] coef_bits;	/* -1 or current Al value for each coef */
+
+		/* Internal JPEG parameters --- the application usually need not look at
+		 * these fields.	Note that the decompressor output side may not use
+		 * any parameters that can change between scans.
+		 */
+
+		/* Quantization and Huffman tables are carried forward across input
+		 * datastreams when processing abbreviated JPEG datastreams.
+		 */
+
+		JQUANT_TBL[] quant_tbl_ptrs = new JQUANT_TBL[NUM_QUANT_TBLS];
+		/* ptrs to coefficient quantization tables, or null if not defined */
+
+		JHUFF_TBL[] dc_huff_tbl_ptrs = new JHUFF_TBL[NUM_HUFF_TBLS];
+		JHUFF_TBL[] ac_huff_tbl_ptrs = new JHUFF_TBL[NUM_HUFF_TBLS];
+		/* ptrs to Huffman coding tables, or null if not defined */
+
+		/* These parameters are never carried across datastreams, since they
+		 * are given in SOF/SOS markers or defined to be reset by SOI.
+		 */
+
+		int data_precision;		/* bits of precision in image data */
+
+		jpeg_component_info[] comp_info;
+		/* comp_info[i] describes component that appears i'th in SOF */
+
+		boolean progressive_mode;	/* true if SOFn specifies progressive mode */
+		boolean arith_code;		/* true=arithmetic coding, false=Huffman */
+
+		byte[] arith_dc_L = new byte[NUM_ARITH_TBLS]; /* L values for DC arith-coding tables */
+		byte[] arith_dc_U = new byte[NUM_ARITH_TBLS]; /* U values for DC arith-coding tables */
+		byte[] arith_ac_K = new byte[NUM_ARITH_TBLS]; /* Kx values for AC arith-coding tables */
+
+		int restart_interval; /* MCUs per restart interval, or 0 for no restart */
+
+		/* These fields record data obtained from optional markers recognized by
+		 * the JPEG library.
+		 */
+		boolean saw_JFIF_marker;	/* true iff a JFIF APP0 marker was found */
+		/* Data copied from JFIF marker; only valid if saw_JFIF_marker is true: */
+		byte JFIF_major_version;	/* JFIF version number */
+		byte JFIF_minor_version;
+		byte density_unit;		/* JFIF code for pixel size units */
+		short X_density;		/* Horizontal pixel density */
+		short Y_density;		/* Vertical pixel density */
+		boolean saw_Adobe_marker;	/* true iff an Adobe APP14 marker was found */
+		byte Adobe_transform;	/* Color transform code from Adobe marker */
+
+		boolean CCIR601_sampling;	/* true=first samples are cosited */
+
+		/* Aside from the specific data retained from APPn markers known to the
+		 * library, the uninterpreted contents of any or all APPn and COM markers
+		 * can be saved in a list for examination by the application.
+		 */
+		jpeg_marker_reader marker_list; /* Head of list of saved markers */
+
+		/* Remaining fields are known throughout decompressor, but generally
+		 * should not be touched by a surrounding application.
+		 */
+
+		/*
+		 * These fields are computed during decompression startup
+		 */
+		int max_h_samp_factor;	/* largest h_samp_factor */
+		int max_v_samp_factor;	/* largest v_samp_factor */
+
+		int min_DCT_scaled_size;	/* smallest DCT_scaled_size of any component */
+
+		int total_iMCU_rows;	/* # of iMCU rows in image */
+		/* The coefficient controller's input and output progress is measured in
+		 * units of "iMCU" (interleaved MCU) rows.	These are the same as MCU rows
+		 * in fully interleaved JPEG scans, but are used whether the scan is
+		 * interleaved or not.	We define an iMCU row as v_samp_factor DCT block
+		 * rows of each component.	Therefore, the IDCT output contains
+		 * v_samp_factor*DCT_scaled_size sample rows of a component per iMCU row.
+		 */
+
+		byte[] sample_range_limit; /* table for fast range-limiting */
+		int sample_range_limit_offset;
+
+		/*
+		 * These fields are valid during any one scan.
+		 * They describe the components and MCUs actually appearing in the scan.
+		 * Note that the decompressor output side must not use these fields.
+		 */
+		int comps_in_scan;		/* # of JPEG components in this scan */
+		jpeg_component_info[] cur_comp_info = new jpeg_component_info[MAX_COMPS_IN_SCAN];
+		/* *cur_comp_info[i] describes component that appears i'th in SOS */
+
+		int MCUs_per_row;	/* # of MCUs across the image */
+		int MCU_rows_in_scan;	/* # of MCU rows in the image */
+
+		int blocks_in_MCU;		/* # of DCT blocks per MCU */
+		int[] MCU_membership = new int[D_MAX_BLOCKS_IN_MCU];
+		/* MCU_membership[i] is index in cur_comp_info of component owning */
+		/* i'th block in an MCU */
+
+		int Ss, Se, Ah, Al;		/* progressive JPEG parameters for scan */
+
+		/* This field is shared between entropy decoder and marker parser.
+		 * It is either zero or the code of a JPEG marker that has been
+		 * read from the data source, but has not yet been processed.
+		 */
+		int unread_marker;
+		
+		int[] workspace = new int[DCTSIZE2];
+		int[] row_ctr = new int[1];
+
+		/*
+		 * Links to decompression subobjects (methods, private variables of modules)
+		 */
+		jpeg_decomp_master master;
+		jpeg_d_main_controller main;
+		jpeg_d_coef_controller coef;
+		jpeg_d_post_controller post;
+		jpeg_input_controller inputctl;
+		jpeg_marker_reader marker;
+		jpeg_entropy_decoder entropy;
+		jpeg_inverse_dct idct;
+		jpeg_upsampler upsample;
+		jpeg_color_deconverter cconvert;
+		jpeg_color_quantizer cquantize;
+	}
+
+static void error() {
+	SWT.error(SWT.ERROR_INVALID_IMAGE);
+}
+
+static void error(int code) {
+	SWT.error(code);
+}
+
+static void error(String msg) {
+	SWT.error(SWT.ERROR_INVALID_IMAGE, null, msg);
+}
+
+static void jinit_marker_reader (jpeg_decompress_struct cinfo) {
+	jpeg_marker_reader marker = cinfo.marker = new jpeg_marker_reader();
+//	int i;
+
+	/* Initialize COM/APPn processing.
+	 * By default, we examine and then discard APP0 and APP14,
+	 * but simply discard COM and all other APPn.
+	 */
+//	marker.process_COM = skip_variable;
+	marker.length_limit_COM = 0;
+//	for (i = 0; i < 16; i++) {
+//		marker.process_APPn[i] = skip_variable;
+//		marker.length_limit_APPn[i] = 0;
+//	}
+//	marker.process_APPn[0] = get_interesting_appn;
+//	marker.process_APPn[14] = get_interesting_appn;
+	/* Reset marker processing state */
+	reset_marker_reader(cinfo);
+}
+
+static void jinit_d_coef_controller (jpeg_decompress_struct cinfo, boolean need_full_buffer) {
+	jpeg_d_coef_controller coef = new jpeg_d_coef_controller();
+	cinfo.coef = coef;
+//	coef.pub.start_input_pass = start_input_pass;
+//	coef.pub.start_output_pass = start_output_pass;
+	coef.coef_bits_latch = null;
+
+	/* Create the coefficient buffer. */
+	if (need_full_buffer) {
+//#ifdef D_MULTISCAN_FILES_SUPPORTED
+		/* Allocate a full-image virtual array for each component, */
+		/* padded to a multiple of samp_factor DCT blocks in each direction. */
+		/* Note we ask for a pre-zeroed array. */
+		int ci, access_rows;
+		jpeg_component_info compptr;
+
+		for (ci = 0; ci < cinfo.num_components; ci++) {
+			compptr = cinfo.comp_info[ci];
+			access_rows = compptr.v_samp_factor;
+//#ifdef BLOCK_SMOOTHING_SUPPORTED
+			/* If block smoothing could be used, need a bigger window */
+			if (cinfo.progressive_mode)
+				access_rows *= 3;
+//#endif
+			coef.whole_image[ci] = 
+				new short
+					[(int)jround_up( compptr.height_in_blocks, compptr.v_samp_factor)]
+				    [(int)jround_up( compptr.width_in_blocks, compptr.h_samp_factor)]
+				    [DCTSIZE2];
+		}
+//		coef.consume_data = consume_data;
+		coef.decompress_data = DECOMPRESS_DATA;
+		coef.coef_arrays = coef.whole_image[0]; /* link to virtual arrays */
+//		#else
+//				ERREXIT(cinfo, JERR_NOT_COMPILED);
+//		#endif
+	} else {
+		/* We only need a single-MCU buffer. */
+		coef.MCU_buffer = new short[D_MAX_BLOCKS_IN_MCU][DCTSIZE2];
+//		coef.consume_data = dummy_consume_data;
+		coef.decompress_data = DECOMPRESS_ONEPASS;
+		coef.coef_arrays = null; /* flag for no virtual arrays */
+	}
+}
+
+static void start_output_pass (jpeg_decompress_struct cinfo) {
+//#ifdef BLOCK_SMOOTHING_SUPPORTED
+	jpeg_d_coef_controller coef = cinfo.coef;
+
+	/* If multipass, check to see whether to use block smoothing on this pass */
+	if (coef.coef_arrays != null) {
+		if (cinfo.do_block_smoothing && smoothing_ok(cinfo))
+			coef.decompress_data = DECOMPRESS_SMOOTH_DATA;
+		else
+			coef.decompress_data = DECOMPRESS_DATA;
+	}
+//#endif
+	cinfo.output_iMCU_row = 0;
+}
+
+static void jpeg_create_decompress(jpeg_decompress_struct cinfo) {
+	cinfo.is_decompressor = true;
+
+
+	/* Initialize marker processor so application can override methods
+	 * for COM, APPn markers before calling jpeg_read_header.
+	 */
+	cinfo.marker_list = null;
+	jinit_marker_reader(cinfo);
+
+	/* And initialize the overall input controller. */
+	jinit_input_controller(cinfo);
+
+	/* OK, I'm ready */
+	cinfo.global_state = DSTATE_START;
+}
+
+static void jpeg_calc_output_dimensions (jpeg_decompress_struct cinfo)
+/* Do computations that are needed before master selection phase */
+{
+//#ifdef IDCT_SCALING_SUPPORTED
+//	int ci;
+//	jpeg_component_info compptr;
+//#endif
+
+	/* Prevent application from calling me at wrong times */
+	if (cinfo.global_state != DSTATE_READY)
+		error();
+//		ERREXIT1(cinfo, JERR_BAD_STATE, cinfo.global_state);
+
+//#ifdef IDCT_SCALING_SUPPORTED
+//
+//	/* Compute actual output image dimensions and DCT scaling choices. */
+//	if (cinfo.scale_num * 8 <= cinfo.scale_denom) {
+//		/* Provide 1/8 scaling */
+//		cinfo.output_width = (int)
+//			jdiv_round_up(cinfo.image_width, 8L);
+//		cinfo.output_height = (int)
+//			jdiv_round_up(cinfo.image_height, 8L);
+//		cinfo.min_DCT_scaled_size = 1;
+//	} else if (cinfo.scale_num * 4 <= cinfo.scale_denom) {
+//		/* Provide 1/4 scaling */
+//		cinfo.output_width = (int)
+//			jdiv_round_up(cinfo.image_width, 4L);
+//		cinfo.output_height = (int)
+//			jdiv_round_up(cinfo.image_height, 4L);
+//		cinfo.min_DCT_scaled_size = 2;
+//	} else if (cinfo.scale_num * 2 <= cinfo.scale_denom) {
+//		/* Provide 1/2 scaling */
+//		cinfo.output_width = (int)
+//			jdiv_round_up(cinfo.image_width, 2L);
+//		cinfo.output_height = (int)
+//			jdiv_round_up(cinfo.image_height, 2L);
+//		cinfo.min_DCT_scaled_size = 4;
+//	} else {
+//		/* Provide 1/1 scaling */
+//		cinfo.output_width = cinfo.image_width;
+//		cinfo.output_height = cinfo.image_height;
+//		cinfo.min_DCT_scaled_size = DCTSIZE;
+//	}
+//	/* In selecting the actual DCT scaling for each component, we try to
+//	 * scale up the chroma components via IDCT scaling rather than upsampling.
+//	 * This saves time if the upsampler gets to use 1:1 scaling.
+//	 * Note this code assumes that the supported DCT scalings are powers of 2.
+//	 */
+//	for (ci = 0; ci < cinfo.num_components; ci++) {
+//		compptr = cinfo.comp_info[ci];
+//		int ssize = cinfo.min_DCT_scaled_size;
+//		while (ssize < DCTSIZE &&
+//			(compptr.h_samp_factor * ssize * 2 <= cinfo.max_h_samp_factor * cinfo.min_DCT_scaled_size) &&
+//			(compptr.v_samp_factor * ssize * 2 <= cinfo.max_v_samp_factor * cinfo.min_DCT_scaled_size))
+//		{
+//			ssize = ssize * 2;
+//		}
+//		compptr.DCT_scaled_size = ssize;
+//	}
+//
+//	/* Recompute downsampled dimensions of components;
+//	 * application needs to know these if using raw downsampled data.
+//	 */
+//	for (ci = 0; ci < cinfo.num_components; ci++) {
+//		compptr = cinfo.comp_info[ci];
+//		/* Size in samples, after IDCT scaling */
+//		compptr.downsampled_width = (int)
+//			jdiv_round_up((long) cinfo.image_width * (long) (compptr.h_samp_factor * compptr.DCT_scaled_size),
+//				(cinfo.max_h_samp_factor * DCTSIZE));
+//		compptr.downsampled_height = (int)
+//			jdiv_round_up((long) cinfo.image_height * (long) (compptr.v_samp_factor * compptr.DCT_scaled_size),
+//				(cinfo.max_v_samp_factor * DCTSIZE));
+//	}
+//
+//#else /* !IDCT_SCALING_SUPPORTED */
+
+	/* Hardwire it to "no scaling" */
+	cinfo.output_width = cinfo.image_width;
+	cinfo.output_height = cinfo.image_height;
+	/* jdinput.c has already initialized DCT_scaled_size to DCTSIZE,
+	 * and has computed unscaled downsampled_width and downsampled_height.
+	 */
+
+//#endif /* IDCT_SCALING_SUPPORTED */
+
+	/* Report number of components in selected colorspace. */
+	/* Probably this should be in the color conversion module... */
+	switch (cinfo.out_color_space) {
+		case JCS_GRAYSCALE:
+			cinfo.out_color_components = 1;
+			break;
+		case JCS_RGB:
+			if (RGB_PIXELSIZE != 3) {
+				cinfo.out_color_components = RGB_PIXELSIZE;
+				break;
+			}
+			//FALLTHROUGH
+		case JCS_YCbCr:
+			cinfo.out_color_components = 3;
+			break;
+		case JCS_CMYK:
+		case JCS_YCCK:
+			cinfo.out_color_components = 4;
+			break;
+		default:			/* else must be same colorspace as in file */
+			cinfo.out_color_components = cinfo.num_components;
+			break;
+	}
+	cinfo.output_components = (cinfo.quantize_colors ? 1 : cinfo.out_color_components);
+
+	/* See if upsampler will want to emit more than one row at a time */
+	if (use_merged_upsample(cinfo))
+		cinfo.rec_outbuf_height = cinfo.max_v_samp_factor;
+	else
+		cinfo.rec_outbuf_height = 1;
+}
+
+static boolean use_merged_upsample (jpeg_decompress_struct cinfo) {
+//#ifdef UPSAMPLE_MERGING_SUPPORTED
+	/* Merging is the equivalent of plain box-filter upsampling */
+	if (cinfo.do_fancy_upsampling || cinfo.CCIR601_sampling)
+		return false;
+	/* jdmerge.c only supports YCC=>RGB color conversion */
+	if (cinfo.jpeg_color_space != JCS_YCbCr || cinfo.num_components != 3 ||
+			cinfo.out_color_space != JCS_RGB ||
+			cinfo.out_color_components != RGB_PIXELSIZE)
+		return false;
+	/* and it only handles 2h1v or 2h2v sampling ratios */
+	if (cinfo.comp_info[0].h_samp_factor != 2 ||
+			cinfo.comp_info[1].h_samp_factor != 1 ||
+			cinfo.comp_info[2].h_samp_factor != 1 ||
+			cinfo.comp_info[0].v_samp_factor >	2 ||
+			cinfo.comp_info[1].v_samp_factor != 1 ||
+			cinfo.comp_info[2].v_samp_factor != 1)
+		return false;
+	/* furthermore, it doesn't work if we've scaled the IDCTs differently */
+	if (cinfo.comp_info[0].DCT_scaled_size != cinfo.min_DCT_scaled_size ||
+			cinfo.comp_info[1].DCT_scaled_size != cinfo.min_DCT_scaled_size ||
+			cinfo.comp_info[2].DCT_scaled_size != cinfo.min_DCT_scaled_size)
+		return false;
+	/* ??? also need to test for upsample-time rescaling, when & if supported */
+	return true;			/* by golly, it'll work... */
+//#else
+//	return false;
+//#endif
+}
+
+static void prepare_range_limit_table (jpeg_decompress_struct cinfo)
+/* Allocate and fill in the sample_range_limit table */
+{
+	byte[] table;
+	int i;
+
+	table = new byte[5 * (MAXJSAMPLE+1) + CENTERJSAMPLE];
+	int offset = (MAXJSAMPLE+1);	/* allow negative subscripts of simple table */
+	cinfo.sample_range_limit_offset = offset;
+	cinfo.sample_range_limit = table;
+	/* First segment of "simple" table: limit[x] = 0 for x < 0 */
+	/* Main part of "simple" table: limit[x] = x */
+	for (i = 0; i <= MAXJSAMPLE; i++)
+		table[i + offset] = (byte)i;
+	offset += CENTERJSAMPLE;	/* Point to where post-IDCT table starts */
+	/* End of simple table, rest of first half of post-IDCT table */
+	for (i = CENTERJSAMPLE; i < 2*(MAXJSAMPLE+1); i++)
+		table[i+offset] = (byte)MAXJSAMPLE;
+	/* Second half of post-IDCT table */
+	System.arraycopy(cinfo.sample_range_limit, cinfo.sample_range_limit_offset, table, offset + (4 * (MAXJSAMPLE+1) - CENTERJSAMPLE), CENTERJSAMPLE);
+}
+
+static void build_ycc_rgb_table (jpeg_decompress_struct cinfo) {
+	jpeg_color_deconverter cconvert = cinfo.cconvert;
+	int i;
+	int x;
+//	SHIFT_TEMPS
+
+	cconvert.Cr_r_tab = new int[MAXJSAMPLE+1];
+	cconvert.Cb_b_tab = new int[MAXJSAMPLE+1];
+	cconvert.Cr_g_tab = new int[MAXJSAMPLE+1];
+	cconvert.Cb_g_tab = new int[MAXJSAMPLE+1];
+
+	for (i = 0, x = -CENTERJSAMPLE; i <= MAXJSAMPLE; i++, x++) {
+		/* i is the actual input pixel value, in the range 0..MAXJSAMPLE */
+		/* The Cb or Cr value we are thinking of is x = i - CENTERJSAMPLE */
+		/* Cr=>R value is nearest int to 1.40200 * x */
+		cconvert.Cr_r_tab[i] = ((int)(1.40200f * (1<<SCALEBITS) + 0.5f) * x + ONE_HALF) >> SCALEBITS;
+		/* Cb=>B value is nearest int to 1.77200 * x */
+		cconvert.Cb_b_tab[i] = ((int)(1.77200f * (1<<SCALEBITS) + 0.5f) * x + ONE_HALF) >> SCALEBITS;
+		/* Cr=>G value is scaled-up -0.71414 * x */
+		cconvert.Cr_g_tab[i] = ((int)(- (0.71414f * (1<<SCALEBITS) + 0.5f)) * x);
+		/* Cb=>G value is scaled-up -0.34414 * x */
+		/* We also add in ONE_HALF so that need not do it in inner loop */
+		cconvert.Cb_g_tab[i] = ((int)(- (0.34414f* (1<<SCALEBITS) + 0.5f)) * x + ONE_HALF);
+	}
+}
+
+static void jinit_color_deconverter (jpeg_decompress_struct cinfo) {
+	jpeg_color_deconverter cconvert = cinfo.cconvert = new jpeg_color_deconverter();
+//	cconvert.start_pass = start_pass_dcolor;
+
+	/* Make sure num_components agrees with jpeg_color_space */
+	switch (cinfo.jpeg_color_space) {
+		case JCS_GRAYSCALE:
+			if (cinfo.num_components != 1)
+				error();
+//				ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);
+			break;
+
+		case JCS_RGB:
+		case JCS_YCbCr:
+			if (cinfo.num_components != 3)
+				error();
+//				ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);
+			break;
+
+		case JCS_CMYK:
+		case JCS_YCCK:
+			if (cinfo.num_components != 4)
+				error();
+//				ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);
+			break;
+
+		default:			/* JCS_UNKNOWN can be anything */
+			if (cinfo.num_components < 1)
+				error();
+//				ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);
+			break;
+	}
+
+	/* Set out_color_components and conversion method based on requested space.
+	 * Also clear the component_needed flags for any unused components,
+	 * so that earlier pipeline stages can avoid useless computation.
+	 */
+
+	int ci;
+	switch (cinfo.out_color_space) {
+		case JCS_GRAYSCALE:
+			cinfo.out_color_components = 1;
+			if (cinfo.jpeg_color_space == JCS_GRAYSCALE || cinfo.jpeg_color_space == JCS_YCbCr) {
+				cconvert.color_convert = GRAYSCALE_CONVERT;
+				/* For color.grayscale conversion, only the Y (0) component is needed */
+				for (ci = 1; ci < cinfo.num_components; ci++)
+					cinfo.comp_info[ci].component_needed = false;
+			} else
+				error();
+//				ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
+			break;
+
+		case JCS_RGB:
+			cinfo.out_color_components = RGB_PIXELSIZE;
+			if (cinfo.jpeg_color_space == JCS_YCbCr) {
+				cconvert.color_convert = YCC_RGB_CONVERT;
+				build_ycc_rgb_table(cinfo);
+			} else if (cinfo.jpeg_color_space == JCS_GRAYSCALE) {
+				cconvert.color_convert = GRAY_RGB_CONVERT;
+			} else if (cinfo.jpeg_color_space == JCS_RGB && RGB_PIXELSIZE == 3) {
+				cconvert.color_convert = NULL_CONVERT;
+			} else
+				error();
+//				ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
+				break;
+
+		case JCS_CMYK:
+			cinfo.out_color_components = 4;
+			if (cinfo.jpeg_color_space == JCS_YCCK) {
+				cconvert.color_convert = YCCK_CMYK_CONVERT;
+				build_ycc_rgb_table(cinfo);
+			} else if (cinfo.jpeg_color_space == JCS_CMYK) {
+				cconvert.color_convert = NULL_CONVERT;
+			} else
+				error();
+//				ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
+			break;
+
+		default:
+			/* Permit null conversion to same output space */
+			if (cinfo.out_color_space == cinfo.jpeg_color_space) {
+				cinfo.out_color_components = cinfo.num_components;
+				cconvert.color_convert = NULL_CONVERT;
+			} else	/* unsupported non-null conversion */
+				error();
+//				ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
+			break;
+	}
+
+	if (cinfo.quantize_colors)
+		cinfo.output_components = 1; /* single colormapped output component */
+	else
+		cinfo.output_components = cinfo.out_color_components;
+}
+
+static void jinit_d_post_controller (jpeg_decompress_struct cinfo, boolean need_full_buffer) {
+	jpeg_d_post_controller post = cinfo.post = new jpeg_d_post_controller();
+//	post.pub.start_pass = start_pass_dpost;
+	post.whole_image = null;	/* flag for no virtual arrays */
+	post.buffer = null;		/* flag for no strip buffer */
+
+	/* Create the quantization buffer, if needed */
+	if (cinfo.quantize_colors) {
+		error(SWT.ERROR_NOT_IMPLEMENTED);
+//		/* The buffer strip height is max_v_samp_factor, which is typically
+//		 * an efficient number of rows for upsampling to return.
+//		 * (In the presence of output rescaling, we might want to be smarter?)
+//		 */
+//		post.strip_height = cinfo.max_v_samp_factor;
+//		if (need_full_buffer) {
+//			/* Two-pass color quantization: need full-image storage. */
+//			/* We round up the number of rows to a multiple of the strip height. */
+//#ifdef QUANT_2PASS_SUPPORTED
+//			post.whole_image = (*cinfo.mem.request_virt_sarray)
+//				((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE,
+//	 			cinfo.output_width * cinfo.out_color_components,
+//	 			(JDIMENSION) jround_up((long) cinfo.output_height,
+//				(long) post.strip_height),
+//	 post.strip_height);
+//#else
+//			ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
+//#endif /* QUANT_2PASS_SUPPORTED */
+//		} else {
+//			/* One-pass color quantization: just make a strip buffer. */
+//			post.buffer = (*cinfo.mem.alloc_sarray)
+//				((j_common_ptr) cinfo, JPOOL_IMAGE,
+//	 			cinfo.output_width * cinfo.out_color_components,
+//	 			post.strip_height);
+//		}
+	}
+}
+
+static void make_funny_pointers (jpeg_decompress_struct cinfo)
+/* Create the funny pointer lists discussed in the comments above.
+ * The actual workspace is already allocated (in main.buffer),
+ * and the space for the pointer lists is allocated too.
+ * This routine just fills in the curiously ordered lists.
+ * This will be repeated at the beginning of each pass.
+ */
+{
+	jpeg_d_main_controller main = cinfo.main;
+	int ci, i, rgroup;
+	int M = cinfo.min_DCT_scaled_size;
+	jpeg_component_info compptr;
+	byte[][] buf, xbuf0, xbuf1;
+	
+	for (ci = 0; ci < cinfo.num_components; ci++) {
+		compptr = cinfo.comp_info[ci];
+		rgroup = (compptr.v_samp_factor * compptr.DCT_scaled_size) /
+			cinfo.min_DCT_scaled_size; /* height of a row group of component */
+		xbuf0 = main.xbuffer[0][ci];
+		int xbuf0_offset = main.xbuffer_offset[0][ci];
+		xbuf1 = main.xbuffer[1][ci];
+		int xbuf1_offset = main.xbuffer_offset[1][ci];
+		/* First copy the workspace pointers as-is */
+		buf = main.buffer[ci];
+		for (i = 0; i < rgroup * (M + 2); i++) {
+			xbuf0[i + xbuf0_offset] = xbuf1[i + xbuf1_offset] = buf[i];
+		}
+		/* In the second list, put the last four row groups in swapped order */
+		for (i = 0; i < rgroup * 2; i++) {
+			xbuf1[rgroup*(M-2) + i + xbuf1_offset] = buf[rgroup*M + i];
+			xbuf1[rgroup*M + i + xbuf1_offset] = buf[rgroup*(M-2) + i];
+		}
+		/* The wraparound pointers at top and bottom will be filled later
+		 * (see set_wraparound_pointers, below).	Initially we want the "above"
+		 * pointers to duplicate the first actual data line.	This only needs
+		 * to happen in xbuffer[0].
+		 */
+		for (i = 0; i < rgroup; i++) {
+			xbuf0[i - rgroup + xbuf0_offset] = xbuf0[0 + xbuf0_offset];
+		}
+	}
+}
+
+static void alloc_funny_pointers (jpeg_decompress_struct cinfo)
+/* Allocate space for the funny pointer lists.
+ * This is done only once, not once per pass.
+ */
+{
+	jpeg_d_main_controller main = cinfo.main;
+	int ci, rgroup;
+	int M = cinfo.min_DCT_scaled_size;
+	jpeg_component_info compptr;
+	byte[][] xbuf;
+
+	/* Get top-level space for component array pointers.
+	 * We alloc both arrays with one call to save a few cycles.
+	 */
+	main.xbuffer[0] = new byte[cinfo.num_components][][];
+	main.xbuffer[1] = new byte[cinfo.num_components][][];
+	main.xbuffer_offset[0] = new int[cinfo.num_components];
+	main.xbuffer_offset[1] = new int[cinfo.num_components];
+
+	for (ci = 0; ci < cinfo.num_components; ci++) {
+		compptr = cinfo.comp_info[ci];
+		rgroup = (compptr.v_samp_factor * compptr.DCT_scaled_size) / cinfo.min_DCT_scaled_size; /* height of a row group of component */
+		/* Get space for pointer lists --- M+4 row groups in each list.
+		 * We alloc both pointer lists with one call to save a few cycles.
+		 */
+		xbuf = new byte[2 * (rgroup * (M + 4))][];
+		int offset = rgroup;
+		main.xbuffer_offset[0][ci] = offset;
+		main.xbuffer[0][ci] = xbuf;
+		offset += rgroup * (M + 4);
+		main.xbuffer_offset[1][ci] = offset;
+		main.xbuffer[1][ci] = xbuf;
+	}
+}
+
+
+static void jinit_d_main_controller (jpeg_decompress_struct cinfo, boolean need_full_buffer) {
+	int ci, rgroup, ngroups;
+	jpeg_component_info compptr;
+
+	jpeg_d_main_controller main = cinfo.main = new jpeg_d_main_controller();
+//	main.pub.start_pass = start_pass_main;
+
+	if (need_full_buffer)		/* shouldn't happen */
+		error();
+//		ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
+
+	/* Allocate the workspace.
+	 * ngroups is the number of row groups we need.
+	 */
+	if (cinfo.upsample.need_context_rows) {
+		if (cinfo.min_DCT_scaled_size < 2) /* unsupported, see comments above */
+			error();
+//			ERREXIT(cinfo, JERR_NOTIMPL);
+		alloc_funny_pointers(cinfo); /* Alloc space for xbuffer[] lists */
+		ngroups = cinfo.min_DCT_scaled_size + 2;
+	} else {
+		ngroups = cinfo.min_DCT_scaled_size;
+	}
+
+	for (ci = 0; ci < cinfo.num_components; ci++) {
+		compptr = cinfo.comp_info[ci];
+		rgroup = (compptr.v_samp_factor * compptr.DCT_scaled_size) / cinfo.min_DCT_scaled_size; /* height of a row group of component */
+		main.buffer[ci] = new byte[rgroup * ngroups][compptr.width_in_blocks * compptr.DCT_scaled_size];
+	}
+}
+
+static long jround_up (long a, long b)
+/* Compute a rounded up to next multiple of b, ie, ceil(a/b)*b */
+/* Assumes a >= 0, b > 0 */
+{
+	a += b - 1L;
+	return a - (a % b);
+}
+
+static void jinit_upsampler (jpeg_decompress_struct cinfo) {
+	int ci;
+	jpeg_component_info compptr;
+	boolean need_buffer, do_fancy;
+	int h_in_group, v_in_group, h_out_group, v_out_group;
+
+	jpeg_upsampler upsample = new jpeg_upsampler();
+	cinfo.upsample = upsample;
+//	upsample.start_pass = start_pass_upsample;
+//	upsample.upsample = sep_upsample;
+	upsample.need_context_rows = false; /* until we find out differently */
+
+	if (cinfo.CCIR601_sampling)	/* this isn't supported */
+		error();
+//		ERREXIT(cinfo, JERR_CCIR601_NOTIMPL);
+
+	/* jdmainct.c doesn't support context rows when min_DCT_scaled_size = 1,
+	 * so don't ask for it.
+	 */
+	do_fancy = cinfo.do_fancy_upsampling && cinfo.min_DCT_scaled_size > 1;
+
+	/* Verify we can handle the sampling factors, select per-component methods,
+	 * and create storage as needed.
+	 */
+	for (ci = 0; ci < cinfo.num_components; ci++) {
+		compptr = cinfo.comp_info[ci];
+		/* Compute size of an "input group" after IDCT scaling.	This many samples
+		 * are to be converted to max_h_samp_factor * max_v_samp_factor pixels.
+		 */
+		h_in_group = (compptr.h_samp_factor * compptr.DCT_scaled_size) /
+		 cinfo.min_DCT_scaled_size;
+		v_in_group = (compptr.v_samp_factor * compptr.DCT_scaled_size) /
+		 cinfo.min_DCT_scaled_size;
+		h_out_group = cinfo.max_h_samp_factor;
+		v_out_group = cinfo.max_v_samp_factor;
+		upsample.rowgroup_height[ci] = v_in_group; /* save for use later */
+		need_buffer = true;
+		if (! compptr.component_needed) {
+			/* Don't bother to upsample an uninteresting component. */
+			upsample.methods[ci] = NOOP_UPSAMPLE;
+			need_buffer = false;
+		} else if (h_in_group == h_out_group && v_in_group == v_out_group) {
+			/* Fullsize components can be processed without any work. */
+			upsample.methods[ci] = FULLSIZE_UPSAMPLE;
+			need_buffer = false;
+		} else if (h_in_group * 2 == h_out_group && v_in_group == v_out_group) {
+			/* Special cases for 2h1v upsampling */
+			if (do_fancy && compptr.downsampled_width > 2)
+				upsample.methods[ci] = H2V1_FANCY_UPSAMPLE;
+			else
+				upsample.methods[ci] = H2V1_UPSAMPLE;
+		} else if (h_in_group * 2 == h_out_group && v_in_group * 2 == v_out_group) {
+			/* Special cases for 2h2v upsampling */
+			if (do_fancy && compptr.downsampled_width > 2) {
+				upsample.methods[ci] = H2V2_FANCY_UPSAMPLE;
+				upsample.need_context_rows = true;
+			} else
+				upsample.methods[ci] = H2V2_UPSAMPLE;
+		} else if ((h_out_group % h_in_group) == 0 && (v_out_group % v_in_group) == 0) {
+			/* Generic integral-factors upsampling method */
+			upsample.methods[ci] = INT_UPSAMPLE;
+			upsample.h_expand[ci] = (byte) (h_out_group / h_in_group);
+			upsample.v_expand[ci] = (byte) (v_out_group / v_in_group);
+		} else
+			error();
+//			ERREXIT(cinfo, JERR_FRACT_SAMPLE_NOTIMPL);
+		if (need_buffer) {
+			upsample.color_buf[ci] = new byte[cinfo.max_v_samp_factor]
+						 [(int) jround_up(cinfo.output_width, cinfo.max_h_samp_factor)];
+		}
+	}
+}
+
+static void jinit_phuff_decoder (jpeg_decompress_struct cinfo) {
+	int[][] coef_bit_ptr;
+	int ci, i;
+
+	cinfo.entropy = new phuff_entropy_decoder();
+//	entropy.pub.start_pass = start_pass_phuff_decoder;
+
+	/* Create progression status table */
+	cinfo.coef_bits = new int[cinfo.num_components][DCTSIZE2];
+	coef_bit_ptr = cinfo.coef_bits;
+	for (ci = 0; ci < cinfo.num_components; ci++) 
+		for (i = 0; i < DCTSIZE2; i++)
+			coef_bit_ptr[ci][i] = -1;
+}
+
+
+static void jinit_huff_decoder (jpeg_decompress_struct cinfo) {
+
+	cinfo.entropy = new huff_entropy_decoder();
+//	entropy.pub.start_pass = start_pass_huff_decoder;
+//	entropy.pub.decode_mcu = decode_mcu;
+
+}
+
+static void jinit_inverse_dct (jpeg_decompress_struct cinfo) {
+	int ci;
+	jpeg_component_info compptr;
+
+	jpeg_inverse_dct idct = cinfo.idct = new jpeg_inverse_dct();
+//	idct.pub.start_pass = start_pass;
+
+	for (ci = 0; ci < cinfo.num_components; ci++) {
+		compptr = cinfo.comp_info[ci];
+		/* Allocate and pre-zero a multiplier table for each component */
+		compptr.dct_table = new int[DCTSIZE2];
+		/* Mark multiplier table not yet set up for any method */
+		idct.cur_method[ci] = -1;
+	}
+}
+
+static final int CONST_BITS = 13;
+static final int PASS1_BITS = 2;
+static final int RANGE_MASK =(MAXJSAMPLE * 4 + 3);
+static void jpeg_idct_islow (jpeg_decompress_struct cinfo, jpeg_component_info compptr,
+	short[] coef_block,
+	byte[][] output_buf, int output_buf_offset, int output_col)
+{
+	int tmp0, tmp1, tmp2, tmp3;
+	int tmp10, tmp11, tmp12, tmp13;
+	int z1, z2, z3, z4, z5;
+	short[] inptr;
+	int[] quantptr;
+	int[] wsptr;
+	byte[] outptr;
+	byte[] range_limit = cinfo.sample_range_limit;
+	int range_limit_offset = cinfo.sample_range_limit_offset + CENTERJSAMPLE;
+	int ctr;
+	int[] workspace = cinfo.workspace;	/* buffers data between passes */
+//	SHIFT_TEMPS
+	
+	/* Pass 1: process columns from input, store into work array. */
+	/* Note results are scaled up by sqrt(8) compared to a true IDCT; */
+	/* furthermore, we scale the results by 2**PASS1_BITS. */
+	
+	inptr = coef_block;
+	quantptr = compptr.dct_table;
+	wsptr = workspace;
+	int inptr_offset = 0, quantptr_offset = 0, wsptr_offset = 0;
+	for (ctr = DCTSIZE; ctr > 0; ctr--) {
+		/* Due to quantization, we will usually find that many of the input
+		 * coefficients are zero, especially the AC terms.	We can exploit this
+		 * by short-circuiting the IDCT calculation for any column in which all
+		 * the AC terms are zero.	In that case each output is equal to the
+		 * DC coefficient (with scale factor as needed).
+		 * With typical images and quantization tables, half or more of the
+		 * column DCT calculations can be simplified this way.
+		 */
+		
+		if (inptr[DCTSIZE*1+inptr_offset] == 0 && inptr[DCTSIZE*2+inptr_offset] == 0 &&
+			inptr[DCTSIZE*3+inptr_offset] == 0 && inptr[DCTSIZE*4+inptr_offset] == 0 &&
+			inptr[DCTSIZE*5+inptr_offset] == 0 && inptr[DCTSIZE*6+inptr_offset] == 0 &&
+			inptr[DCTSIZE*7+inptr_offset] == 0)
+		{
+			/* AC terms all zero */
+			int dcval = ((inptr[DCTSIZE*0+inptr_offset]) * quantptr[DCTSIZE*0+quantptr_offset]) << PASS1_BITS;
+			
+			wsptr[DCTSIZE*0+wsptr_offset] = dcval;
+			wsptr[DCTSIZE*1+wsptr_offset] = dcval;
+			wsptr[DCTSIZE*2+wsptr_offset] = dcval;
+			wsptr[DCTSIZE*3+wsptr_offset] = dcval;
+			wsptr[DCTSIZE*4+wsptr_offset] = dcval;
+			wsptr[DCTSIZE*5+wsptr_offset] = dcval;
+			wsptr[DCTSIZE*6+wsptr_offset] = dcval;
+			wsptr[DCTSIZE*7+wsptr_offset] = dcval;
+			
+			inptr_offset++;			/* advance pointers to next column */
+			quantptr_offset++;
+			wsptr_offset++;
+			continue;
+		}
+		
+		/* Even part: reverse the even part of the forward DCT. */
+		/* The rotator is sqrt(2)*c(-6). */
+		
+		z2 = ((inptr[DCTSIZE*2+inptr_offset]) * quantptr[DCTSIZE*2+quantptr_offset]);
+		z3 = ((inptr[DCTSIZE*6+inptr_offset]) * quantptr[DCTSIZE*6+quantptr_offset]);
+		
+		z1 = ((z2 + z3) * 4433/*FIX_0_541196100*/);
+		tmp2 = z1 + (z3 * - 15137/*FIX_1_847759065*/);
+		tmp3 = z1 + (z2 * 6270/*FIX_0_765366865*/);
+		
+		z2 = ((inptr[DCTSIZE*0+inptr_offset]) * quantptr[DCTSIZE*0+quantptr_offset]);
+		z3 = ((inptr[DCTSIZE*4+inptr_offset]) * quantptr[DCTSIZE*4+quantptr_offset]);
+
+		tmp0 = (z2 + z3) << CONST_BITS;
+		tmp1 = (z2 - z3) << CONST_BITS;
+		
+		tmp10 = tmp0 + tmp3;
+		tmp13 = tmp0 - tmp3;
+		tmp11 = tmp1 + tmp2;
+		tmp12 = tmp1 - tmp2;
+		
+		/* Odd part per figure 8; the matrix is unitary and hence its
+		 * transpose is its inverse.	i0..i3 are y7,y5,y3,y1 respectively.
+		 */
+		
+		tmp0 = ((inptr[DCTSIZE*7+inptr_offset]) * quantptr[DCTSIZE*7+quantptr_offset]);
+		tmp1 = ((inptr[DCTSIZE*5+inptr_offset]) * quantptr[DCTSIZE*5+quantptr_offset]);
+		tmp2 = ((inptr[DCTSIZE*3+inptr_offset]) * quantptr[DCTSIZE*3+quantptr_offset]);
+		tmp3 = ((inptr[DCTSIZE*1+inptr_offset]) * quantptr[DCTSIZE*1+quantptr_offset]);
+		
+		z1 = tmp0 + tmp3;
+		z2 = tmp1 + tmp2;
+		z3 = tmp0 + tmp2;
+		z4 = tmp1 + tmp3;
+		z5 = ((z3 + z4) * 9633/*FIX_1_175875602*/); /* sqrt(2) * c3 */
+		
+		tmp0 = (tmp0 * 2446/*FIX_0_298631336*/); /* sqrt(2) * (-c1+c3+c5-c7) */
+		tmp1 = (tmp1 * 16819/*FIX_2_053119869*/); /* sqrt(2) * ( c1+c3-c5+c7) */
+		tmp2 = (tmp2 * 25172/*FIX_3_072711026*/); /* sqrt(2) * ( c1+c3+c5-c7) */
+		tmp3 = (tmp3 * 12299/*FIX_1_501321110*/); /* sqrt(2) * ( c1+c3-c5-c7) */
+		z1 = (z1 * - 7373/*FIX_0_899976223*/); /* sqrt(2) * (c7-c3) */
+		z2 = (z2 * - 20995/*FIX_2_562915447*/); /* sqrt(2) * (-c1-c3) */
+		z3 = (z3 * - 16069/*FIX_1_961570560*/); /* sqrt(2) * (-c3-c5) */
+		z4 = (z4 * - 3196/*FIX_0_390180644*/); /* sqrt(2) * (c5-c3) */
+		
+		z3 += z5;
+		z4 += z5;
+		
+		tmp0 += z1 + z3;
+		tmp1 += z2 + z4;
+		tmp2 += z2 + z3;
+		tmp3 += z1 + z4;
+		
+		/* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */
+		
+//		#define DESCALE(x,n)	RIGHT_SHIFT((x) + (ONE << ((n)-1)), n)
+		wsptr[DCTSIZE*0+wsptr_offset] = (((tmp10 + tmp3) + (1 << ((CONST_BITS-PASS1_BITS)-1))) >> (CONST_BITS-PASS1_BITS));
+		wsptr[DCTSIZE*7+wsptr_offset] = (((tmp10 - tmp3) + (1 << ((CONST_BITS-PASS1_BITS)-1))) >> (CONST_BITS-PASS1_BITS));
+		wsptr[DCTSIZE*1+wsptr_offset] = (((tmp11 + tmp2) + (1 << ((CONST_BITS-PASS1_BITS)-1))) >> (CONST_BITS-PASS1_BITS));
+		wsptr[DCTSIZE*6+wsptr_offset] = (((tmp11 - tmp2) + (1 << ((CONST_BITS-PASS1_BITS)-1))) >> (CONST_BITS-PASS1_BITS));
+		wsptr[DCTSIZE*2+wsptr_offset] = (((tmp12 + tmp1) + (1 << ((CONST_BITS-PASS1_BITS)-1))) >> (CONST_BITS-PASS1_BITS));
+		wsptr[DCTSIZE*5+wsptr_offset] = (((tmp12 - tmp1) + (1 << ((CONST_BITS-PASS1_BITS)-1))) >> (CONST_BITS-PASS1_BITS));
+		wsptr[DCTSIZE*3+wsptr_offset] = (((tmp13 + tmp0) + (1 << ((CONST_BITS-PASS1_BITS)-1))) >> (CONST_BITS-PASS1_BITS));
+		wsptr[DCTSIZE*4+wsptr_offset] = (((tmp13 - tmp0) + (1 << ((CONST_BITS-PASS1_BITS)-1))) >> (CONST_BITS-PASS1_BITS));
+		
+		inptr_offset++;			/* advance pointers to next column */
+		quantptr_offset++;
+		wsptr_offset++;
+	}
+
+	
+	/* Pass 2: process rows from work array, store into output array. */
+	/* Note that we must descale the results by a factor of 8 == 2**3, */
+	/* and also undo the PASS1_BITS scaling. */
+
+	int outptr_offset = 0;
+	wsptr = workspace;
+	wsptr_offset =0;
+	for (ctr = 0; ctr < DCTSIZE; ctr++) {
+		outptr = output_buf[ctr+output_buf_offset];
+		outptr_offset = output_col;
+		/* Rows of zeroes can be exploited in the same way as we did with columns.
+		 * However, the column calculation has created many nonzero AC terms, so
+		 * the simplification applies less often (typically 5% to 10% of the time).
+		 * On machines with very fast multiplication, it's possible that the
+		 * test takes more time than it's worth.	In that case this section
+		 * may be commented out.
+		 */
+		
+//#ifndef NO_ZERO_ROW_TEST
+		if (wsptr[1+wsptr_offset] == 0 && wsptr[2+wsptr_offset] == 0 && wsptr[3+wsptr_offset] == 0 && wsptr[4+wsptr_offset] == 0 &&
+			wsptr[5+wsptr_offset] == 0 && wsptr[6+wsptr_offset] == 0 && wsptr[7+wsptr_offset] == 0)
+		{
+			/* AC terms all zero */
+//			#define DESCALE(x,n)	RIGHT_SHIFT((x) + (ONE << ((n)-1)), n)
+			byte dcval = range_limit[range_limit_offset + ((((wsptr[0+wsptr_offset]) + (1 << ((PASS1_BITS+3)-1))) >> PASS1_BITS+3)
+					& RANGE_MASK)];
+			
+			outptr[0+outptr_offset] = dcval;
+			outptr[1+outptr_offset] = dcval;
+			outptr[2+outptr_offset] = dcval;
+			outptr[3+outptr_offset] = dcval;
+			outptr[4+outptr_offset] = dcval;
+			outptr[5+outptr_offset] = dcval;
+			outptr[6+outptr_offset] = dcval;
+			outptr[7+outptr_offset] = dcval;
+
+			wsptr_offset += DCTSIZE;		/* advance pointer to next row */
+			continue;
+		}
+//#endif
+		
+		/* Even part: reverse the even part of the forward DCT. */
+		/* The rotator is sqrt(2)*c(-6). */
+		
+		z2 = wsptr[2+wsptr_offset];
+		z3 = wsptr[6+wsptr_offset];
+		
+		z1 = ((z2 + z3) * 4433/*FIX_0_541196100*/);
+		tmp2 = z1 + (z3 * - 15137/*FIX_1_847759065*/);
+		tmp3 = z1 + (z2 * 6270/*FIX_0_765366865*/);
+		
+		tmp0 = (wsptr[0+wsptr_offset] + wsptr[4+wsptr_offset]) << CONST_BITS;
+		tmp1 = (wsptr[0+wsptr_offset] - wsptr[4+wsptr_offset]) << CONST_BITS;
+		
+		tmp10 = tmp0 + tmp3;
+		tmp13 = tmp0 - tmp3;
+		tmp11 = tmp1 + tmp2;
+		tmp12 = tmp1 - tmp2;
+		
+		/* Odd part per figure 8; the matrix is unitary and hence its
+		 * transpose is its inverse.	i0..i3 are y7,y5,y3,y1 respectively.
+		 */
+		
+		tmp0 = wsptr[7+wsptr_offset];
+		tmp1 = wsptr[5+wsptr_offset];
+		tmp2 = wsptr[3+wsptr_offset];
+		tmp3 = wsptr[1+wsptr_offset];
+		
+		z1 = tmp0 + tmp3;
+		z2 = tmp1 + tmp2;
+		z3 = tmp0 + tmp2;
+		z4 = tmp1 + tmp3;
+		z5 = ((z3 + z4) * 9633/*FIX_1_175875602*/); /* sqrt(2) * c3 */
+		
+		tmp0 = (tmp0 * 2446/*FIX_0_298631336*/); /* sqrt(2) * (-c1+c3+c5-c7) */
+		tmp1 = (tmp1 * 16819/*FIX_2_053119869*/); /* sqrt(2) * ( c1+c3-c5+c7) */
+		tmp2 = (tmp2 * 25172/*FIX_3_072711026*/); /* sqrt(2) * ( c1+c3+c5-c7) */
+		tmp3 = (tmp3 * 12299/*FIX_1_501321110*/); /* sqrt(2) * ( c1+c3-c5-c7) */
+		z1 = (z1 * - 7373/*FIX_0_899976223*/); /* sqrt(2) * (c7-c3) */
+		z2 = (z2 * - 20995/*FIX_2_562915447*/); /* sqrt(2) * (-c1-c3) */
+		z3 = (z3 * - 16069/*FIX_1_961570560*/); /* sqrt(2) * (-c3-c5) */
+		z4 = (z4 * - 3196/*FIX_0_390180644*/); /* sqrt(2) * (c5-c3) */
+		
+		z3 += z5;
+		z4 += z5;
+		
+		tmp0 += z1 + z3;
+		tmp1 += z2 + z4;
+		tmp2 += z2 + z3;
+		tmp3 += z1 + z4;
+		
+		/* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */
+		
+
+//		#define DESCALE(x,n)	RIGHT_SHIFT((x) + (ONE << ((n)-1)), n)
+		outptr[0+outptr_offset] = range_limit[range_limit_offset + ((((tmp10 + tmp3) + (1 << ((CONST_BITS+PASS1_BITS+3)-1))) >>
+						CONST_BITS+PASS1_BITS+3)
+					& RANGE_MASK)];
+		outptr[7+outptr_offset] = range_limit[range_limit_offset + ((((tmp10 - tmp3) + (1 << ((CONST_BITS+PASS1_BITS+3)-1))) >>
+									CONST_BITS+PASS1_BITS+3)
+					& RANGE_MASK)];
+		outptr[1+outptr_offset] = range_limit[range_limit_offset + ((((tmp11 + tmp2) + (1 << ((CONST_BITS+PASS1_BITS+3)-1))) >>
+									CONST_BITS+PASS1_BITS+3)
+					& RANGE_MASK)];
+		outptr[6+outptr_offset] = range_limit[range_limit_offset + ((((tmp11 - tmp2) + (1 << ((CONST_BITS+PASS1_BITS+3)-1))) >>
+									CONST_BITS+PASS1_BITS+3)
+					& RANGE_MASK)];
+		outptr[2+outptr_offset] = range_limit[range_limit_offset + ((((tmp12 + tmp1) + (1 << ((CONST_BITS+PASS1_BITS+3)-1))) >>
+									CONST_BITS+PASS1_BITS+3)
+					& RANGE_MASK)];
+		outptr[5+outptr_offset] = range_limit[range_limit_offset + ((((tmp12 - tmp1) + (1 << ((CONST_BITS+PASS1_BITS+3)-1))) >>
+									CONST_BITS+PASS1_BITS+3)
+					& RANGE_MASK)];
+		outptr[3+outptr_offset] = range_limit[range_limit_offset + ((((tmp13 + tmp0) + (1 << ((CONST_BITS+PASS1_BITS+3)-1))) >>
+									CONST_BITS+PASS1_BITS+3)
+					& RANGE_MASK)];
+		outptr[4+outptr_offset] = range_limit[range_limit_offset + ((((tmp13 - tmp0) + (1 << ((CONST_BITS+PASS1_BITS+3)-1))) >>
+									CONST_BITS+PASS1_BITS+3)
+					& RANGE_MASK)];
+
+		wsptr_offset += DCTSIZE;		/* advance pointer to next row */
+	}
+}
+
+static void upsample (jpeg_decompress_struct cinfo,
+	byte[][][] input_buf, int[] input_buf_offset, int[] in_row_group_ctr,
+	int in_row_groups_avail,
+	byte[][] output_buf, int[] out_row_ctr,
+	int out_rows_avail)
+{
+	sep_upsample(cinfo, input_buf, input_buf_offset, in_row_group_ctr, in_row_groups_avail, output_buf, out_row_ctr, out_rows_avail);
+}
+
+static boolean smoothing_ok (jpeg_decompress_struct cinfo) {
+	jpeg_d_coef_controller coef = cinfo.coef;
+	boolean smoothing_useful = false;
+	int ci, coefi;
+	jpeg_component_info compptr;
+	JQUANT_TBL qtable;
+	int[] coef_bits;
+	int[] coef_bits_latch;
+
+	if (! cinfo.progressive_mode || cinfo.coef_bits == null)
+		return false;
+
+	/* Allocate latch area if not already done */
+	if (coef.coef_bits_latch == null)
+		coef.coef_bits_latch = new int[cinfo.num_components * SAVED_COEFS];
+	coef_bits_latch = coef.coef_bits_latch;
+	int coef_bits_latch_offset = 0;
+
+	for (ci = 0; ci < cinfo.num_components; ci++) {
+		compptr = cinfo.comp_info[ci];
+		/* All components' quantization values must already be latched. */
+		if ((qtable = compptr.quant_table) == null)
+			return false;
+		/* Verify DC & first 5 AC quantizers are nonzero to avoid zero-divide. */
+		if (qtable.quantval[0] == 0 ||
+			qtable.quantval[Q01_POS] == 0 ||
+			qtable.quantval[Q10_POS] == 0 ||
+			qtable.quantval[Q20_POS] == 0 ||
+			qtable.quantval[Q11_POS] == 0 ||
+			qtable.quantval[Q02_POS] == 0)
+				return false;
+		/* DC values must be at least partly known for all components. */
+		coef_bits = cinfo.coef_bits[ci];
+		if (coef_bits[0] < 0)
+			return false;
+		/* Block smoothing is helpful if some AC coefficients remain inaccurate. */
+		for (coefi = 1; coefi <= 5; coefi++) {
+			coef_bits_latch[coefi+coef_bits_latch_offset] = coef_bits[coefi];
+			if (coef_bits[coefi] != 0)
+				smoothing_useful = true;
+		}
+		coef_bits_latch_offset += SAVED_COEFS;
+	}
+
+	return smoothing_useful;
+}
+
+static void master_selection (jpeg_decompress_struct cinfo) {
+	jpeg_decomp_master master = cinfo.master;
+	boolean use_c_buffer;
+	long samplesperrow;
+	int jd_samplesperrow;
+
+	/* Initialize dimensions and other stuff */
+	jpeg_calc_output_dimensions(cinfo);
+	prepare_range_limit_table(cinfo);
+
+	/* Width of an output scanline must be representable as JDIMENSION. */
+	samplesperrow = (long) cinfo.output_width * (long) cinfo.out_color_components;
+	jd_samplesperrow = (int) samplesperrow;
+	if ( jd_samplesperrow != samplesperrow)
+		error();
+//		ERREXIT(cinfo, JERR_WIDTH_OVERFLOW);
+
+	/* Initialize my private state */
+	master.pass_number = 0;
+	master.using_merged_upsample = use_merged_upsample(cinfo);
+
+	/* Color quantizer selection */
+	master.quantizer_1pass = null;
+	master.quantizer_2pass = null;
+	/* No mode changes if not using buffered-image mode. */
+	if (! cinfo.quantize_colors || ! cinfo.buffered_image) {
+		cinfo.enable_1pass_quant = false;
+		cinfo.enable_external_quant = false;
+		cinfo.enable_2pass_quant = false;
+	}
+	if (cinfo.quantize_colors) {
+		error(SWT.ERROR_NOT_IMPLEMENTED);
+//		if (cinfo.raw_data_out)
+//			ERREXIT(cinfo, JERR_NOTIMPL);
+//		/* 2-pass quantizer only works in 3-component color space. */
+//		if (cinfo.out_color_components != 3) {
+//			cinfo.enable_1pass_quant = true;
+//			cinfo.enable_external_quant = false;
+//			cinfo.enable_2pass_quant = false;
+//			cinfo.colormap = null;
+//		} else if (cinfo.colormap != null) {
+//			cinfo.enable_external_quant = true;
+//		} else if (cinfo.two_pass_quantize) {
+//			cinfo.enable_2pass_quant = true;
+//		} else {
+//			cinfo.enable_1pass_quant = true;
+//		}
+//
+//		if (cinfo.enable_1pass_quant) {
+//#ifdef QUANT_1PASS_SUPPORTED
+//			jinit_1pass_quantizer(cinfo);
+//			master.quantizer_1pass = cinfo.cquantize;
+//#else
+//			ERREXIT(cinfo, JERR_NOT_COMPILED);
+//#endif
+//		}
+//
+//		/* We use the 2-pass code to map to external colormaps. */
+//		if (cinfo.enable_2pass_quant || cinfo.enable_external_quant) {
+//#ifdef QUANT_2PASS_SUPPORTED
+//			jinit_2pass_quantizer(cinfo);
+//			master.quantizer_2pass = cinfo.cquantize;
+//#else
+//			ERREXIT(cinfo, JERR_NOT_COMPILED);
+//#endif
+//		}
+//		/* If both quantizers are initialized, the 2-pass one is left active;
+//		 * this is necessary for starting with quantization to an external map.
+//		 */
+	}
+
+	/* Post-processing: in particular, color conversion first */
+	if (! cinfo.raw_data_out) {
+		if (master.using_merged_upsample) {
+//#ifdef UPSAMPLE_MERGING_SUPPORTED
+//			jinit_merged_upsampler(cinfo); /* does color conversion too */
+//#else
+			error();
+//			ERREXIT(cinfo, JERR_NOT_COMPILED);
+//#endif
+		} else {
+			jinit_color_deconverter(cinfo);
+			jinit_upsampler(cinfo);
+		}
+		jinit_d_post_controller(cinfo, cinfo.enable_2pass_quant);
+	}
+	/* Inverse DCT */
+	jinit_inverse_dct(cinfo);
+	/* Entropy decoding: either Huffman or arithmetic coding. */
+	if (cinfo.arith_code) {
+		error();
+//		ERREXIT(cinfo, JERR_ARITH_NOTIMPL);
+	} else {
+		if (cinfo.progressive_mode) {
+//#ifdef D_PROGRESSIVE_SUPPORTED
+			jinit_phuff_decoder(cinfo);
+//#else
+//			ERREXIT(cinfo, JERR_NOT_COMPILED);
+//#endif
+		} else
+			jinit_huff_decoder(cinfo);
+	}
+
+	/* Initialize principal buffer controllers. */
+	use_c_buffer = cinfo.inputctl.has_multiple_scans || cinfo.buffered_image;
+	jinit_d_coef_controller(cinfo, use_c_buffer);
+
+	if (! cinfo.raw_data_out)
+		jinit_d_main_controller(cinfo, false /* never need full buffer here */);
+
+	/* Initialize input side of decompressor to consume first scan. */
+	start_input_pass (cinfo);
+
+//#ifdef D_MULTISCAN_FILES_SUPPORTED
+	/* If jpeg_start_decompress will read the whole file, initialize
+	 * progress monitoring appropriately.	The input step is counted
+	 * as one pass.
+	 */
+//	if (cinfo.progress != null && ! cinfo.buffered_image &&
+//			cinfo.inputctl.has_multiple_scans) {
+//		int nscans;
+//		/* Estimate number of scans to set pass_limit. */
+//		if (cinfo.progressive_mode) {
+//			/* Arbitrarily estimate 2 interleaved DC scans + 3 AC scans/component. */
+//			nscans = 2 + 3 * cinfo.num_components;
+//		} else {
+//			/* For a nonprogressive multiscan file, estimate 1 scan per component. */
+//			nscans = cinfo.num_components;
+//		}
+//		cinfo.progress.pass_counter = 0L;
+//		cinfo.progress.pass_limit = (long) cinfo.total_iMCU_rows * nscans;
+//		cinfo.progress.completed_passes = 0;
+//		cinfo.progress.total_passes = (cinfo.enable_2pass_quant ? 3 : 2);
+//		/* Count the input pass as done */
+//		master.pass_number++;
+//	}
+//#endif /* D_MULTISCAN_FILES_SUPPORTED */
+}
+
+static void jinit_master_decompress (jpeg_decompress_struct cinfo) {
+	jpeg_decomp_master master = new jpeg_decomp_master();
+	cinfo.master = master;
+//	master.prepare_for_output_pass = prepare_for_output_pass;
+//	master.finish_output_pass = finish_output_pass;
+
+	master.is_dummy_pass = false;
+
+	master_selection(cinfo);
+}
+
+static void
+jcopy_sample_rows (byte[][] input_array, int source_row,
+		   byte[][] output_array, int dest_row,
+		   int num_rows, int num_cols)
+/* Copy some rows of samples from one place to another.
+ * num_rows rows are copied from input_array[source_row++]
+ * to output_array[dest_row++]; these areas may overlap for duplication.
+ * The source and destination arrays must be at least as wide as num_cols.
+ */
+{
+  byte[] inptr, outptr;
+  int count = num_cols;
+  int row;
+
+  int input_array_offset = source_row;
+  int output_array_offset = dest_row;
+
+  for (row = num_rows; row > 0; row--) {
+    inptr = input_array[input_array_offset++];
+    outptr = output_array[output_array_offset++];
+    System.arraycopy(inptr, 0, outptr, 0, count);
+  }
+}
+
+static boolean jpeg_start_decompress (jpeg_decompress_struct cinfo) {
+	if (cinfo.global_state == DSTATE_READY) {
+		/* First call: initialize master control, select active modules */
+		jinit_master_decompress(cinfo);
+		if (cinfo.buffered_image) {
+			/* No more work here; expecting jpeg_start_output next */
+			cinfo.global_state = DSTATE_BUFIMAGE;
+			return true;
+		}
+		cinfo.global_state = DSTATE_PRELOAD;
+	}
+	if (cinfo.global_state == DSTATE_PRELOAD) {
+		/* If file has multiple scans, absorb them all into the coef buffer */
+		if (cinfo.inputctl.has_multiple_scans) {
+//#ifdef D_MULTISCAN_FILES_SUPPORTED
+			for (;;) {
+				int retcode;
+				/* Call progress monitor hook if present */
+//				if (cinfo.progress != null)
+//					(*cinfo.progress.progress_monitor) ((j_common_ptr) cinfo);
+				/* Absorb some more input */
+				retcode = consume_input (cinfo);
+				if (retcode == JPEG_SUSPENDED)
+					return false;
+				if (retcode == JPEG_REACHED_EOI)
+					break;
+				/* Advance progress counter if appropriate */
+//				if (cinfo.progress != null && (retcode == JPEG_ROW_COMPLETED || retcode == JPEG_REACHED_SOS)) {
+//					if (++cinfo.progress.pass_counter >= cinfo.progress.pass_limit) {
+//						/* jdmaster underestimated number of scans; ratchet up one scan */
+//						cinfo.progress.pass_limit += (long) cinfo.total_iMCU_rows;
+//					}
+//				}
+			}
+//#else
+//			ERREXIT(cinfo, JERR_NOT_COMPILED);
+//#endif /* D_MULTISCAN_FILES_SUPPORTED */
+		}
+		cinfo.output_scan_number = cinfo.input_scan_number;
+	} else if (cinfo.global_state != DSTATE_PRESCAN)
+		error();
+//		ERREXIT1(cinfo, JERR_BAD_STATE, cinfo.global_state);
+	/* Perform any dummy output passes, and set up for the final pass */
+	return output_pass_setup(cinfo);
+}
+
+static void prepare_for_output_pass (jpeg_decompress_struct cinfo) {
+	jpeg_decomp_master master = cinfo.master;
+
+	if (master.is_dummy_pass) {
+//#ifdef QUANT_2PASS_SUPPORTED
+//		/* Final pass of 2-pass quantization */
+//		master.pub.is_dummy_pass = FALSE;
+//		(*cinfo.cquantize.start_pass) (cinfo, FALSE);
+//		(*cinfo.post.start_pass) (cinfo, JBUF_CRANK_DEST);
+//		(*cinfo.main.start_pass) (cinfo, JBUF_CRANK_DEST);
+//#else
+		error(SWT.ERROR_NOT_IMPLEMENTED);
+//		ERREXIT(cinfo, JERR_NOT_COMPILED);
+//#endif /* QUANT_2PASS_SUPPORTED */
+	} else {
+		if (cinfo.quantize_colors && cinfo.colormap == null) {
+			/* Select new quantization method */
+			if (cinfo.two_pass_quantize && cinfo.enable_2pass_quant) {
+				cinfo.cquantize = master.quantizer_2pass;
+				master.is_dummy_pass = true;
+			} else if (cinfo.enable_1pass_quant) {
+				cinfo.cquantize = master.quantizer_1pass;
+			} else {
+				error();
+//	ERREXIT(cinfo, JERR_MODE_CHANGE);
+			}
+		}
+		cinfo.idct.start_pass (cinfo);
+		start_output_pass (cinfo);
+		if (! cinfo.raw_data_out) {
+			if (! master.using_merged_upsample)
+				cinfo.cconvert.start_pass (cinfo);
+			cinfo.upsample.start_pass (cinfo);
+			if (cinfo.quantize_colors) 
+				cinfo.cquantize.start_pass (cinfo, master.is_dummy_pass);
+			cinfo.post.start_pass (cinfo, (master.is_dummy_pass ? JBUF_SAVE_AND_PASS : JBUF_PASS_THRU));
+			cinfo.main.start_pass (cinfo, JBUF_PASS_THRU);
+		}
+	}
+
+//	/* Set up progress monitor's pass info if present */
+//	if (cinfo.progress != NULL) {
+//		cinfo.progress.completed_passes = master.pass_number;
+//		cinfo.progress.total_passes = master.pass_number +
+//						(master.pub.is_dummy_pass ? 2 : 1);
+//		/* In buffered-image mode, we assume one more output pass if EOI not
+//		 * yet reached, but no more passes if EOI has been reached.
+//		 */
+//		if (cinfo.buffered_image && ! cinfo.inputctl.eoi_reached) {
+//			cinfo.progress.total_passes += (cinfo.enable_2pass_quant ? 2 : 1);
+//		}
+//	}
+}
+
+
+static boolean jpeg_resync_to_restart (jpeg_decompress_struct cinfo, int desired) {
+	int marker = cinfo.unread_marker;
+	int action = 1;
+	
+	/* Always put up a warning. */
+//	WARNMS2(cinfo, JWRN_MUST_RESYNC, marker, desired);
+	
+	/* Outer loop handles repeated decision after scanning forward. */
+	for (;;) {
+		if (marker < M_SOF0)
+			action = 2;		/* invalid marker */
+		else if (marker < M_RST0 || marker > M_RST7)
+			action = 3;		/* valid non-restart marker */
+		else {
+			if (marker == (M_RST0 + ((desired+1) & 7)) || marker == ( M_RST0 + ((desired+2) & 7)))
+				action = 3;		/* one of the next two expected restarts */
+			else if (marker == (M_RST0 + ((desired-1) & 7)) || marker == ( M_RST0 + ((desired-2) & 7)))
+				action = 2;		/* a prior restart, so advance */
+			else
+				action = 1;		/* desired restart or too far away */
+		}
+//		TRACEMS2(cinfo, 4, JTRC_RECOVERY_ACTION, marker, action);
+		switch (action) {
+			case 1:
+				/* Discard marker and let entropy decoder resume processing. */
+				cinfo.unread_marker = 0;
+				return true;
+			case 2:
+				/* Scan to the next marker, and repeat the decision loop. */
+				if (! next_marker(cinfo))
+					return false;
+				marker = cinfo.unread_marker;
+				break;
+			case 3:
+				/* Return without advancing past this marker. */
+				/* Entropy decoder will be forced to process an empty segment. */
+				return true;
+		}
+	} /* end loop */
+}
+
+static boolean read_restart_marker (jpeg_decompress_struct cinfo) {
+	/* Obtain a marker unless we already did. */
+	/* Note that next_marker will complain if it skips any data. */
+	if (cinfo.unread_marker == 0) {
+		if (! next_marker(cinfo))
+			return false;
+	}
+
+	if (cinfo.unread_marker == (M_RST0 + cinfo.marker.next_restart_num)) {
+		/* Normal case --- swallow the marker and let entropy decoder continue */
+//		TRACEMS1(cinfo, 3, JTRC_RST, cinfo.marker.next_restart_num);
+		cinfo.unread_marker = 0;
+	} else {
+		/* Uh-oh, the restart markers have been messed up. */
+		/* Let the data source manager determine how to resync. */
+		if (! jpeg_resync_to_restart (cinfo, cinfo.marker.next_restart_num))
+			return false;
+	}
+
+	/* Update next-restart state */
+	cinfo.marker.next_restart_num = (cinfo.marker.next_restart_num + 1) & 7;
+
+	return true;
+}
+
+static boolean jpeg_fill_bit_buffer (bitread_working_state state, int get_buffer, int bits_left, int nbits)
+/* Load up the bit buffer to a depth of at least nbits */
+{
+	/* Copy heavily used state fields into locals (hopefully registers) */
+	byte[] buffer = state.buffer;
+	int bytes_in_buffer = state.bytes_in_buffer;
+	int bytes_offset = state.bytes_offset;
+	jpeg_decompress_struct cinfo = state.cinfo;
+
+	/* Attempt to load at least MIN_GET_BITS bits into get_buffer. */
+	/* (It is assumed that no request will be for more than that many bits.) */
+	/* We fail to do so only if we hit a marker or are forced to suspend. */
+
+	if (cinfo.unread_marker == 0) {	/* cannot advance past a marker */
+		while (bits_left < MIN_GET_BITS) {
+			int c;
+
+			/* Attempt to read a byte */
+			if (bytes_offset == bytes_in_buffer) {
+				if (! fill_input_buffer (cinfo))
+					return false;
+				buffer = cinfo.buffer;
+				bytes_in_buffer = cinfo.bytes_in_buffer;
+				bytes_offset = cinfo.bytes_offset;
+			}
+			c = buffer[bytes_offset++] & 0xFF;
+
+			/* If it's 0xFF, check and discard stuffed zero byte */
+			if (c == 0xFF) {
+				/* Loop here to discard any padding FF's on terminating marker,
+				 * so that we can save a valid unread_marker value.	NOTE: we will
+				 * accept multiple FF's followed by a 0 as meaning a single FF data
+				 * byte.	This data pattern is not valid according to the standard.
+				 */
+				do {
+					if (bytes_offset == bytes_in_buffer) {
+						if (! fill_input_buffer (cinfo))
+							return false;
+						buffer = cinfo.buffer;
+						bytes_in_buffer = cinfo.bytes_in_buffer;
+						bytes_offset = cinfo.bytes_offset;
+					}
+					c = buffer[bytes_offset++] & 0xFF;
+				} while (c == 0xFF);
+
+				if (c == 0) {
+					/* Found FF/00, which represents an FF data byte */
+					c = 0xFF;
+				} else {
+					/* Oops, it's actually a marker indicating end of compressed data.
+					 * Save the marker code for later use.
+					 * Fine point: it might appear that we should save the marker into
+					 * bitread working state, not straight into permanent state.	But
+					 * once we have hit a marker, we cannot need to suspend within the
+					 * current MCU, because we will read no more bytes from the data
+					 * source.	So it is OK to update permanent state right away.
+					 */
+					cinfo.unread_marker = c;
+					/* See if we need to insert some fake zero bits. */
+//					goto no_more_bytes;
+					if (nbits > bits_left) {
+						/* Uh-oh.	Report corrupted data to user and stuff zeroes into
+						 * the data stream, so that we can produce some kind of image.
+						 * We use a nonvolatile flag to ensure that only one warning message
+						 * appears per data segment.
+						 */
+						if (! cinfo.entropy.insufficient_data) {
+//							WARNMS(cinfo, JWRN_HIT_MARKER);
+							cinfo.entropy.insufficient_data = true;
+						}
+					/* Fill the buffer with zero bits */
+						get_buffer <<= MIN_GET_BITS - bits_left;
+						bits_left = MIN_GET_BITS;
+					}
+
+					/* Unload the local registers */
+					state.buffer = buffer;
+					state.bytes_in_buffer = bytes_in_buffer;
+					state.bytes_offset = bytes_offset;
+					state.get_buffer = get_buffer;
+					state.bits_left = bits_left;
+
+					return true;
+		
+				}
+			}
+
+			/* OK, load c into get_buffer */
+			get_buffer = (get_buffer << 8) | c;
+			bits_left += 8;
+		} /* end while */
+	} else {
+//		no_more_bytes:
+		/* We get here if we've read the marker that terminates the compressed
+		 * data segment.	There should be enough bits in the buffer register
+		 * to satisfy the request; if so, no problem.
+		 */
+		if (nbits > bits_left) {
+			/* Uh-oh.	Report corrupted data to user and stuff zeroes into
+			 * the data stream, so that we can produce some kind of image.
+			 * We use a nonvolatile flag to ensure that only one warning message
+			 * appears per data segment.
+			 */
+			if (! cinfo.entropy.insufficient_data) {
+//				WARNMS(cinfo, JWRN_HIT_MARKER);
+				cinfo.entropy.insufficient_data = true;
+			}
+			/* Fill the buffer with zero bits */
+			get_buffer <<= MIN_GET_BITS - bits_left;
+			bits_left = MIN_GET_BITS;
+		}
+	}
+
+	/* Unload the local registers */
+	state.buffer = buffer;
+	state.bytes_in_buffer = bytes_in_buffer;
+	state.bytes_offset = bytes_offset;
+	state.get_buffer = get_buffer;
+	state.bits_left = bits_left;
+
+	return true;
+}
+
+static int jpeg_huff_decode (bitread_working_state state, int get_buffer, int bits_left, d_derived_tbl htbl, int min_bits) {
+	int l = min_bits;
+	int code;
+
+	/* HUFF_DECODE has determined that the code is at least min_bits */
+	/* bits long, so fetch that many bits in one swoop. */
+
+//	CHECK_BIT_BUFFER(*state, l, return -1);
+	{
+	if (bits_left < (l)) {
+		if (! jpeg_fill_bit_buffer(state,get_buffer,bits_left,l)) { 
+			return -1;
+		}
+		get_buffer = (state).get_buffer; bits_left = (state).bits_left;
+	}
+	}
+//	code = GET_BITS(l);
+	code = (( (get_buffer >> (bits_left -= (l)))) & ((1<<(l))-1));
+
+	/* Collect the rest of the Huffman code one bit at a time. */
+	/* This is per Figure F.16 in the JPEG spec. */
+
+	while (code > htbl.maxcode[l]) {
+		code <<= 1;
+//		CHECK_BIT_BUFFER(*state, 1, return -1);
+		{
+		if (bits_left < (1)) {
+			if (! jpeg_fill_bit_buffer(state,get_buffer,bits_left,1)) { 
+				return -1;
+			}
+			get_buffer = (state).get_buffer; bits_left = (state).bits_left;
+		}
+		}
+//		code |= GET_BITS(1);
+		code |= (( (get_buffer >> (bits_left -= (1)))) & ((1<<(1))-1));
+		l++;
+	}
+
+	/* Unload the local registers */
+	state.get_buffer = get_buffer;
+	state.bits_left = bits_left;
+
+	/* With garbage input we may reach the sentinel value l = 17. */
+
+	if (l > 16) {
+//		WARNMS(state.cinfo, JWRN_HUFF_BAD_CODE);
+		return 0;			/* fake a zero as the safest result */
+	}
+
+	return htbl.pub.huffval[ (code + htbl.valoffset[l]) ] & 0xFF;
+}
+
+static int decompress_onepass (jpeg_decompress_struct cinfo, byte[][][] output_buf, int[] output_buf_offset) {
+	jpeg_d_coef_controller coef = cinfo.coef;
+	int MCU_col_num;	/* index of current MCU within row */
+	int last_MCU_col = cinfo.MCUs_per_row - 1;
+	int last_iMCU_row = cinfo.total_iMCU_rows - 1;
+	int blkn, ci, xindex, yindex, yoffset, useful_width;
+	byte[][] output_ptr;
+	int start_col, output_col;
+	jpeg_component_info compptr;
+//	inverse_DCT_method_ptr inverse_DCT;
+
+	/* Loop to process as much as one whole iMCU row */
+	for (yoffset = coef.MCU_vert_offset; yoffset < coef.MCU_rows_per_iMCU_row; yoffset++) {
+		for (MCU_col_num = coef.MCU_ctr; MCU_col_num <= last_MCU_col; MCU_col_num++) {
+			/* Try to fetch an MCU.	Entropy decoder expects buffer to be zeroed. */
+			for (int i = 0; i < cinfo.blocks_in_MCU; i++) {
+				short[] blk = coef.MCU_buffer[i];
+				for (int j = 0; j < blk.length; j++) {
+					blk[j] = 0;
+				}
+			}
+			if (! cinfo.entropy.decode_mcu (cinfo, coef.MCU_buffer)) {
+				/* Suspension forced; update state counters and exit */
+				coef.MCU_vert_offset = yoffset;
+				coef.MCU_ctr = MCU_col_num;
+				return JPEG_SUSPENDED;
+			}
+			/* Determine where data should go in output_buf and do the IDCT thing.
+			 * We skip dummy blocks at the right and bottom edges (but blkn gets
+			 * incremented past them!).	Note the inner loop relies on having
+			 * allocated the MCU_buffer[] blocks sequentially.
+			 */
+			blkn = 0;			/* index of current DCT block within MCU */
+			for (ci = 0; ci < cinfo.comps_in_scan; ci++) {
+				compptr = cinfo.cur_comp_info[ci];
+				/* Don't bother to IDCT an uninteresting component. */
+				if (! compptr.component_needed) {
+					blkn += compptr.MCU_blocks;
+					continue;
+				}
+//				inverse_DCT = cinfo.idct.inverse_DCT[compptr.component_index];
+				useful_width = (MCU_col_num < last_MCU_col) ? compptr.MCU_width	: compptr.last_col_width;
+				output_ptr = output_buf[compptr.component_index];
+				int output_ptr_offset = output_buf_offset[compptr.component_index] + yoffset * compptr.DCT_scaled_size;
+				start_col = MCU_col_num * compptr.MCU_sample_width;
+				for (yindex = 0; yindex < compptr.MCU_height; yindex++) {
+					if (cinfo.input_iMCU_row < last_iMCU_row ||	yoffset+yindex < compptr.last_row_height) {
+						output_col = start_col;
+						for (xindex = 0; xindex < useful_width; xindex++) {
+							jpeg_idct_islow(cinfo, compptr, coef.MCU_buffer[blkn+xindex], output_ptr, output_ptr_offset, output_col);
+							output_col += compptr.DCT_scaled_size;
+						}
+					}
+					blkn += compptr.MCU_width;
+					output_ptr_offset += compptr.DCT_scaled_size;
+				}
+			}
+		}
+		/* Completed an MCU row, but perhaps not an iMCU row */
+		coef.MCU_ctr = 0;
+	}
+	/* Completed the iMCU row, advance counters for next one */
+	cinfo.output_iMCU_row++;
+	if (++(cinfo.input_iMCU_row) < cinfo.total_iMCU_rows) {
+		coef.start_iMCU_row(cinfo);
+		return JPEG_ROW_COMPLETED;
+	}
+	/* Completed the scan */
+	finish_input_pass (cinfo);
+	return JPEG_SCAN_COMPLETED;
+}
+
+static int decompress_smooth_data (jpeg_decompress_struct cinfo, byte[][][] output_buf, int[] output_buf_offset) {
+	jpeg_d_coef_controller coef = cinfo.coef;
+	int last_iMCU_row = cinfo.total_iMCU_rows - 1;
+	int block_num, last_block_column;
+	int ci, block_row, block_rows, access_rows;
+	short[][][] buffer;
+	short[][] buffer_ptr, prev_block_row, next_block_row;
+	byte[][] output_ptr;
+	int output_col;
+	jpeg_component_info compptr;
+//	inverse_DCT_method_ptr inverse_DCT;
+	boolean first_row, last_row;
+	short[] workspace = coef.workspace;
+	if (workspace == null) workspace = coef.workspace = new short[DCTSIZE2];
+	int[] coef_bits;
+	JQUANT_TBL quanttbl;
+	int Q00,Q01,Q02,Q10,Q11,Q20, num;
+	int DC1,DC2,DC3,DC4,DC5,DC6,DC7,DC8,DC9;
+	int Al, pred;
+
+	/* Force some input to be done if we are getting ahead of the input. */
+	while (cinfo.input_scan_number <= cinfo.output_scan_number && ! cinfo.inputctl.eoi_reached) {
+		if (cinfo.input_scan_number == cinfo.output_scan_number) {
+			/* If input is working on current scan, we ordinarily want it to
+			 * have completed the current row.	But if input scan is DC,
+			 * we want it to keep one row ahead so that next block row's DC
+			 * values are up to date.
+			 */
+			int delta = (cinfo.Ss == 0) ? 1 : 0;
+			if (cinfo.input_iMCU_row > cinfo.output_iMCU_row+delta)
+				break;
+		}
+		if (consume_input(cinfo) == JPEG_SUSPENDED)
+			return JPEG_SUSPENDED;
+	}
+
+	/* OK, output from the virtual arrays. */
+	for (ci = 0; ci < cinfo.num_components; ci++) {
+		compptr = cinfo.comp_info[ci];
+		/* Don't bother to IDCT an uninteresting component. */
+		if (! compptr.component_needed)
+			continue;
+		/* Count non-dummy DCT block rows in this iMCU row. */
+		if (cinfo.output_iMCU_row < last_iMCU_row) {
+			block_rows = compptr.v_samp_factor;
+			access_rows = block_rows * 2; /* this and next iMCU row */
+			last_row = false;
+		} else {
+			/* NB: can't use last_row_height here; it is input-side-dependent! */
+			block_rows = (compptr.height_in_blocks % compptr.v_samp_factor);
+			if (block_rows == 0) block_rows = compptr.v_samp_factor;
+			access_rows = block_rows; /* this iMCU row only */
+			last_row = true;
+		}
+		/* Align the virtual buffer for this component. */
+		int buffer_offset;
+		if (cinfo.output_iMCU_row > 0) {
+			access_rows += compptr.v_samp_factor; /* prior iMCU row too */
+			buffer = coef.whole_image[ci];
+			buffer_offset = (cinfo.output_iMCU_row - 1) * compptr.v_samp_factor;
+			buffer_offset += compptr.v_samp_factor;	/* point to current iMCU row */
+			first_row = false;
+		} else {
+			buffer = coef.whole_image[ci];
+			buffer_offset = 0;
+			first_row = true;
+		}
+		/* Fetch component-dependent info */
+		coef_bits = coef.coef_bits_latch;
+		int coef_offset = (ci * SAVED_COEFS);
+		quanttbl = compptr.quant_table;
+		Q00 = quanttbl.quantval[0];
+		Q01 = quanttbl.quantval[Q01_POS];
+		Q10 = quanttbl.quantval[Q10_POS];
+		Q20 = quanttbl.quantval[Q20_POS];
+		Q11 = quanttbl.quantval[Q11_POS];
+		Q02 = quanttbl.quantval[Q02_POS];
+//		inverse_DCT = cinfo.idct.inverse_DCT[ci];
+		output_ptr = output_buf[ci];
+		int output_ptr_offset = output_buf_offset[ci];
+		/* Loop over all DCT blocks to be processed. */
+		for (block_row = 0; block_row < block_rows; block_row++) {
+			buffer_ptr = buffer[block_row+buffer_offset];
+			int buffer_ptr_offset = 0, prev_block_row_offset = 0, next_block_row_offset = 0;
+			if (first_row && block_row == 0) {
+				prev_block_row = buffer_ptr;
+				prev_block_row_offset = buffer_ptr_offset;
+			} else {
+				prev_block_row = buffer[block_row-1+buffer_offset];
+				prev_block_row_offset = 0;
+			}
+			if (last_row && block_row == block_rows-1) {
+				next_block_row = buffer_ptr;
+				next_block_row_offset = buffer_ptr_offset;
+			} else {
+				next_block_row = buffer[block_row+1+buffer_offset];
+				next_block_row_offset = 0;
+			}
+			/* We fetch the surrounding DC values using a sliding-register approach.
+			 * Initialize all nine here so as to do the right thing on narrow pics.
+			 */
+			DC1 = DC2 = DC3 = prev_block_row[0+prev_block_row_offset][0];
+			DC4 = DC5 = DC6 = buffer_ptr[0+buffer_ptr_offset][0];
+			DC7 = DC8 = DC9 = next_block_row[0+next_block_row_offset][0];
+			output_col = 0;
+			last_block_column = compptr.width_in_blocks - 1;
+			for (block_num = 0; block_num <= last_block_column; block_num++) {
+				/* Fetch current DCT block into workspace so we can modify it. */
+//				jcopy_block_row(buffer_ptr, workspace, 1);
+				System.arraycopy(buffer_ptr[buffer_ptr_offset], 0, workspace, 0, workspace.length);
+				/* Update DC values */
+				if (block_num < last_block_column) {
+					DC3 = prev_block_row[1+prev_block_row_offset][0];
+					DC6 = buffer_ptr[1+buffer_ptr_offset][0];
+					DC9 = next_block_row[1+next_block_row_offset][0];
+				}
+				/* Compute coefficient estimates per K.8.
+				 * An estimate is applied only if coefficient is still zero,
+				 * and is not known to be fully accurate.
+				 */
+				/* AC01 */
+				if ((Al=coef_bits[1+coef_offset]) != 0 && workspace[1] == 0) {
+					num = 36 * Q00 * (DC4 - DC6);
+					if (num >= 0) {
+						pred = (((Q01<<7) + num) / (Q01<<8));
+						if (Al > 0 && pred >= (1<<Al))
+							pred = (1<<Al)-1;
+					} else {
+						pred = (((Q01<<7) - num) / (Q01<<8));
+						if (Al > 0 && pred >= (1<<Al))
+							pred = (1<<Al)-1;
+						pred = -pred;
+					}
+					workspace[1] = (short) pred;
+				}
+				/* AC10 */
+				if ((Al=coef_bits[2+coef_offset]) != 0 && workspace[8] == 0) {
+					num = 36 * Q00 * (DC2 - DC8);
+					if (num >= 0) {
+						pred = (((Q10<<7) + num) / (Q10<<8));
+						if (Al > 0 && pred >= (1<<Al))
+							pred = (1<<Al)-1;
+					} else {
+						pred = (((Q10<<7) - num) / (Q10<<8));
+						if (Al > 0 && pred >= (1<<Al))
+							pred = (1<<Al)-1;
+						pred = -pred;
+					}
+					workspace[8] = (short) pred;
+				}
+				/* AC20 */
+				if ((Al=coef_bits[3+coef_offset]) != 0 && workspace[16] == 0) {
+					num = 9 * Q00 * (DC2 + DC8 - 2*DC5);
+					if (num >= 0) {
+						pred = (((Q20<<7) + num) / (Q20<<8));
+						if (Al > 0 && pred >= (1<<Al))
+							pred = (1<<Al)-1;
+					} else {
+						pred = (((Q20<<7) - num) / (Q20<<8));
+						if (Al > 0 && pred >= (1<<Al))
+							pred = (1<<Al)-1;
+						pred = -pred;
+					}
+					workspace[16] = (short) pred;
+				}
+				/* AC11 */
+				if ((Al=coef_bits[4+coef_offset]) != 0 && workspace[9] == 0) {
+					num = 5 * Q00 * (DC1 - DC3 - DC7 + DC9);
+					if (num >= 0) {
+						pred = (((Q11<<7) + num) / (Q11<<8));
+						if (Al > 0 && pred >= (1<<Al))
+							pred = (1<<Al)-1;
+					} else {
+						pred = (((Q11<<7) - num) / (Q11<<8));
+						if (Al > 0 && pred >= (1<<Al))
+							pred = (1<<Al)-1;
+						pred = -pred;
+					}
+					workspace[9] = (short) pred;
+				}
+				/* AC02 */
+				if ((Al=coef_bits[5+coef_offset]) != 0 && workspace[2] == 0) {
+					num = 9 * Q00 * (DC4 + DC6 - 2*DC5);
+					if (num >= 0) {
+						pred = (((Q02<<7) + num) / (Q02<<8));
+						if (Al > 0 && pred >= (1<<Al))
+							pred = (1<<Al)-1;
+					} else {
+						pred = (((Q02<<7) - num) / (Q02<<8));
+						if (Al > 0 && pred >= (1<<Al))
+							pred = (1<<Al)-1;
+						pred = -pred;
+					}
+					workspace[2] = (short) pred;
+				}
+				/* OK, do the IDCT */
+				jpeg_idct_islow(cinfo, compptr, workspace, output_ptr, output_ptr_offset, output_col);
+				/* Advance for next column */
+				DC1 = DC2; DC2 = DC3;
+				DC4 = DC5; DC5 = DC6;
+				DC7 = DC8; DC8 = DC9;
+				buffer_ptr_offset++; prev_block_row_offset++; next_block_row_offset++;
+				output_col += compptr.DCT_scaled_size;
+			}
+			output_ptr_offset += compptr.DCT_scaled_size;
+		}
+	}
+
+	if (++(cinfo.output_iMCU_row) < cinfo.total_iMCU_rows)
+		return JPEG_ROW_COMPLETED;
+	return JPEG_SCAN_COMPLETED;
+}
+
+static int decompress_data (jpeg_decompress_struct cinfo, byte[][][] output_buf, int[] output_buf_offset) {
+	jpeg_d_coef_controller coef = cinfo.coef;
+	int last_iMCU_row = cinfo.total_iMCU_rows - 1;
+	int block_num;
+	int ci, block_row, block_rows;
+	short[][][] buffer;
+	short[][] buffer_ptr;
+	byte[][] output_ptr;
+	int output_col;
+	jpeg_component_info compptr;
+//	inverse_DCT_method_ptr inverse_DCT;
+
+	/* Force some input to be done if we are getting ahead of the input. */
+	while (cinfo.input_scan_number < cinfo.output_scan_number ||
+	 (cinfo.input_scan_number == cinfo.output_scan_number &&
+		cinfo.input_iMCU_row <= cinfo.output_iMCU_row))
+	{
+		if (consume_input(cinfo) == JPEG_SUSPENDED)
+			return JPEG_SUSPENDED;
+	}
+
+	/* OK, output from the virtual arrays. */
+	for (ci = 0; ci < cinfo.num_components; ci++) {
+		compptr = cinfo.comp_info[ci];
+		/* Don't bother to IDCT an uninteresting component. */
+		if (! compptr.component_needed)
+			continue;
+		/* Align the virtual buffer for this component. */
+		buffer = coef.whole_image[ci];
+		int buffer_offset = cinfo.output_iMCU_row * compptr.v_samp_factor;
+		/* Count non-dummy DCT block rows in this iMCU row. */
+		if (cinfo.output_iMCU_row < last_iMCU_row)
+			block_rows = compptr.v_samp_factor;
+		else {
+			/* NB: can't use last_row_height here; it is input-side-dependent! */
+			block_rows = (compptr.height_in_blocks % compptr.v_samp_factor);
+			if (block_rows == 0) block_rows = compptr.v_samp_factor;
+		}
+//		inverse_DCT = cinfo.idct.inverse_DCT[ci];
+		output_ptr = output_buf[ci];
+		int output_ptr_offset = output_buf_offset[ci];
+		/* Loop over all DCT blocks to be processed. */
+		for (block_row = 0; block_row < block_rows; block_row++) {
+			buffer_ptr = buffer[block_row+buffer_offset];
+			int buffer_ptr_offset = 0;
+			output_col = 0;
+			for (block_num = 0; block_num < compptr.width_in_blocks; block_num++) {
+				jpeg_idct_islow(cinfo, compptr, buffer_ptr[buffer_ptr_offset], output_ptr, output_ptr_offset, output_col);
+
+				buffer_ptr_offset++;
+				output_col += compptr.DCT_scaled_size;
+			}
+			output_ptr_offset += compptr.DCT_scaled_size;
+		}
+	}
+
+	if (++(cinfo.output_iMCU_row) < cinfo.total_iMCU_rows)
+		return JPEG_ROW_COMPLETED;
+	return JPEG_SCAN_COMPLETED;
+}
+
+static void post_process_data (jpeg_decompress_struct cinfo,
+				byte[][][] input_buf, int[] input_buf_offset, int[] in_row_group_ctr,
+				int in_row_groups_avail,
+				byte[][] output_buf, int[] out_row_ctr,
+				int out_rows_avail)
+{
+	upsample(cinfo, input_buf, input_buf_offset, in_row_group_ctr, in_row_groups_avail, output_buf, out_row_ctr, out_rows_avail);
+}
+
+static void set_bottom_pointers (jpeg_decompress_struct cinfo)
+/* Change the pointer lists to duplicate the last sample row at the bottom
+ * of the image.	whichptr indicates which xbuffer holds the final iMCU row.
+ * Also sets rowgroups_avail to indicate number of nondummy row groups in row.
+ */
+{
+	jpeg_d_main_controller main = cinfo.main;
+	int ci, i, rgroup, iMCUheight, rows_left;
+	jpeg_component_info compptr;
+	byte[][] xbuf;
+
+	for (ci = 0; ci < cinfo.num_components; ci++) {
+		compptr = cinfo.comp_info[ci];
+		/* Count sample rows in one iMCU row and in one row group */
+		iMCUheight = compptr.v_samp_factor * compptr.DCT_scaled_size;
+		rgroup = iMCUheight / cinfo.min_DCT_scaled_size;
+		/* Count nondummy sample rows remaining for this component */
+		rows_left = (compptr.downsampled_height % iMCUheight);
+		if (rows_left == 0) rows_left = iMCUheight;
+		/* Count nondummy row groups.	Should get same answer for each component,
+		 * so we need only do it once.
+		 */
+		if (ci == 0) {
+			main.rowgroups_avail = ((rows_left-1) / rgroup + 1);
+		}
+		/* Duplicate the last real sample row rgroup*2 times; this pads out the
+		 * last partial rowgroup and ensures at least one full rowgroup of context.
+		 */
+		xbuf = main.xbuffer[main.whichptr][ci];
+		int xbuf_offset = main.xbuffer_offset[main.whichptr][ci];
+		for (i = 0; i < rgroup * 2; i++) {
+			xbuf[rows_left + i + xbuf_offset] = xbuf[rows_left-1 + xbuf_offset];
+		}
+	}
+}
+
+static void set_wraparound_pointers (jpeg_decompress_struct cinfo)
+/* Set up the "wraparound" pointers at top and bottom of the pointer lists.
+ * This changes the pointer list state from top-of-image to the normal state.
+ */
+{
+	jpeg_d_main_controller main = cinfo.main;
+	int ci, i, rgroup;
+	int M = cinfo.min_DCT_scaled_size;
+	jpeg_component_info compptr;
+	byte[][] xbuf0, xbuf1;
+
+	for (ci = 0; ci < cinfo.num_components; ci++) {
+		compptr = cinfo.comp_info[ci];
+		rgroup = (compptr.v_samp_factor * compptr.DCT_scaled_size) / cinfo.min_DCT_scaled_size; /* height of a row group of component */
+		xbuf0 = main.xbuffer[0][ci];
+		int xbuf0_offset = main.xbuffer_offset[0][ci];
+		xbuf1 = main.xbuffer[1][ci];
+		int xbuf1_offset = main.xbuffer_offset[1][ci];
+		for (i = 0; i < rgroup; i++) {
+			xbuf0[i - rgroup + xbuf0_offset] = xbuf0[rgroup*(M+1) + i + xbuf0_offset];
+			xbuf1[i - rgroup + xbuf1_offset] = xbuf1[rgroup*(M+1) + i + xbuf1_offset];
+			xbuf0[rgroup*(M+2) + i + xbuf0_offset] = xbuf0[i + xbuf0_offset];
+			xbuf1[rgroup*(M+2) + i + xbuf1_offset] = xbuf1[i + xbuf1_offset];
+		}
+	}
+}
+
+static void process_data_crank_post (jpeg_decompress_struct cinfo,
+	byte[][] output_buf, int[] out_row_ctr,
+	int out_rows_avail)
+{
+	error();
+}
+
+static void process_data_context_main (jpeg_decompress_struct cinfo,
+	byte[][] output_buf, int[] out_row_ctr,
+	int out_rows_avail)
+{
+	jpeg_d_main_controller main = cinfo.main;
+
+	/* Read input data if we haven't filled the main buffer yet */
+	if (! main.buffer_full) {
+		int result;
+		switch (cinfo.coef.decompress_data) {
+			case DECOMPRESS_DATA:
+				result = decompress_data(cinfo, main.xbuffer[main.whichptr], main.xbuffer_offset[main.whichptr]);
+				break;
+			case DECOMPRESS_SMOOTH_DATA:
+				result = decompress_smooth_data(cinfo, main.xbuffer[main.whichptr], main.xbuffer_offset[main.whichptr]);
+				break;
+			case DECOMPRESS_ONEPASS:
+				result = decompress_onepass(cinfo, main.xbuffer[main.whichptr], main.xbuffer_offset[main.whichptr]);
+				break;
+			default: result = 0;
+		}
+		if (result == 0)
+			return;			/* suspension forced, can do nothing more */
+		main.buffer_full = true;	/* OK, we have an iMCU row to work with */
+		main.iMCU_row_ctr++;	/* count rows received */
+	}
+
+	/* Postprocessor typically will not swallow all the input data it is handed
+	 * in one call (due to filling the output buffer first).	Must be prepared
+	 * to exit and restart.	This switch lets us keep track of how far we got.
+	 * Note that each case falls through to the next on successful completion.
+	 */
+	switch (main.context_state) {
+		case CTX_POSTPONED_ROW:
+			/* Call postprocessor using previously set pointers for postponed row */
+			post_process_data (cinfo, main.xbuffer[main.whichptr], main.xbuffer_offset[main.whichptr], main.rowgroup_ctr, main.rowgroups_avail, output_buf, out_row_ctr, out_rows_avail);
+			if (main.rowgroup_ctr[0] < main.rowgroups_avail)
+				return;			/* Need to suspend */
+			main.context_state = CTX_PREPARE_FOR_IMCU;
+			if (out_row_ctr[0] >= out_rows_avail)
+				return;			/* Postprocessor exactly filled output buf */
+			/*FALLTHROUGH*/
+		case CTX_PREPARE_FOR_IMCU:
+			/* Prepare to process first M-1 row groups of this iMCU row */
+			main.rowgroup_ctr[0] = 0;
+			main.rowgroups_avail = (cinfo.min_DCT_scaled_size - 1);
+			/* Check for bottom of image: if so, tweak pointers to "duplicate"
+			 * the last sample row, and adjust rowgroups_avail to ignore padding rows.
+			 */
+			if (main.iMCU_row_ctr == cinfo.total_iMCU_rows)
+				set_bottom_pointers(cinfo);
+			main.context_state = CTX_PROCESS_IMCU;
+			/*FALLTHROUGH*/
+		case CTX_PROCESS_IMCU:
+			/* Call postprocessor using previously set pointers */
+			post_process_data (cinfo, main.xbuffer[main.whichptr], main.xbuffer_offset[main.whichptr], main.rowgroup_ctr, main.rowgroups_avail, output_buf, out_row_ctr, out_rows_avail);
+			if (main.rowgroup_ctr[0] < main.rowgroups_avail)
+				return;			/* Need to suspend */
+			/* After the first iMCU, change wraparound pointers to normal state */
+			if (main.iMCU_row_ctr == 1)
+				set_wraparound_pointers(cinfo);
+			/* Prepare to load new iMCU row using other xbuffer list */
+			main.whichptr ^= 1;	/* 0=>1 or 1=>0 */
+			main.buffer_full = false;
+			/* Still need to process last row group of this iMCU row, */
+			/* which is saved at index M+1 of the other xbuffer */
+			main.rowgroup_ctr[0] = (cinfo.min_DCT_scaled_size + 1);
+			main.rowgroups_avail =	(cinfo.min_DCT_scaled_size + 2);
+			main.context_state = CTX_POSTPONED_ROW;
+	}
+}
+
+static void process_data_simple_main (jpeg_decompress_struct cinfo, byte[][] output_buf, int[] out_row_ctr, int out_rows_avail) {
+	jpeg_d_main_controller main = cinfo.main;
+	int rowgroups_avail;
+
+	/* Read input data if we haven't filled the main buffer yet */
+	if (! main.buffer_full) {
+		int result;
+		switch (cinfo.coef.decompress_data) {
+			case DECOMPRESS_DATA:
+				result = decompress_data(cinfo, main.buffer, main.buffer_offset);
+				break;
+			case DECOMPRESS_SMOOTH_DATA:
+				result = decompress_smooth_data(cinfo, main.buffer, main.buffer_offset);
+				break;
+			case DECOMPRESS_ONEPASS: 
+				result = decompress_onepass(cinfo, main.buffer, main.buffer_offset);
+				break;
+			default: result = 0;
+		}
+		if (result == 0)
+			return;			/* suspension forced, can do nothing more */
+		main.buffer_full = true;	/* OK, we have an iMCU row to work with */
+	}
+
+	/* There are always min_DCT_scaled_size row groups in an iMCU row. */
+	rowgroups_avail = cinfo.min_DCT_scaled_size;
+	/* Note: at the bottom of the image, we may pass extra garbage row groups
+	 * to the postprocessor.	The postprocessor has to check for bottom
+	 * of image anyway (at row resolution), so no point in us doing it too.
+	 */
+
+	/* Feed the postprocessor */
+	post_process_data (cinfo, main.buffer, main.buffer_offset, main.rowgroup_ctr, rowgroups_avail, output_buf, out_row_ctr, out_rows_avail);
+
+	/* Has postprocessor consumed all the data yet? If so, mark buffer empty */
+	if (main.rowgroup_ctr[0] >= rowgroups_avail) {
+		main.buffer_full = false;
+		main.rowgroup_ctr[0] = 0;
+	}
+}
+
+static int jpeg_read_scanlines (jpeg_decompress_struct cinfo, byte[][] scanlines, int max_lines) {
+
+	if (cinfo.global_state != DSTATE_SCANNING)
+		error();
+//		ERREXIT1(cinfo, JERR_BAD_STATE, cinfo.global_state);
+	if (cinfo.output_scanline >= cinfo.output_height) {
+//		WARNMS(cinfo, JWRN_TOO_MUCH_DATA);
+		return 0;
+	}
+
+	/* Call progress monitor hook if present */
+//	if (cinfo.progress != NULL) {
+//		cinfo.progress.pass_counter = (long) cinfo.output_scanline;
+//		cinfo.progress.pass_limit = (long) cinfo.output_height;
+//		(*cinfo.progress.progress_monitor) ((j_common_ptr) cinfo);
+//	}
+
+	/* Process some data */
+	cinfo.row_ctr[0] = 0;
+	switch (cinfo.main.process_data) {
+		case PROCESS_DATA_SIMPLE_MAIN:
+			process_data_simple_main (cinfo, scanlines, cinfo.row_ctr, max_lines);
+			break;
+		case PROCESS_DATA_CONTEXT_MAIN:
+			process_data_context_main (cinfo, scanlines, cinfo.row_ctr, max_lines);
+			break;
+		case PROCESS_DATA_CRANK_POST:
+			process_data_crank_post (cinfo, scanlines, cinfo.row_ctr, max_lines);
+			break;
+		default: error();
+	}
+	cinfo.output_scanline += cinfo.row_ctr[0];
+	return cinfo.row_ctr[0];
+}
+
+
+static boolean output_pass_setup (jpeg_decompress_struct cinfo) {
+	if (cinfo.global_state != DSTATE_PRESCAN) {
+		/* First call: do pass setup */
+		prepare_for_output_pass (cinfo);
+		cinfo.output_scanline = 0;
+		cinfo.global_state = DSTATE_PRESCAN;
+	}
+	/* Loop over any required dummy passes */
+	while (cinfo.master.is_dummy_pass) {
+		error();
+//#ifdef QUANT_2PASS_SUPPORTED
+//		/* Crank through the dummy pass */
+//		while (cinfo.output_scanline < cinfo.output_height) {
+//			JDIMENSION last_scanline;
+//			/* Call progress monitor hook if present */
+//			if (cinfo.progress != NULL) {
+//	cinfo.progress.pass_counter = (long) cinfo.output_scanline;
+//	cinfo.progress.pass_limit = (long) cinfo.output_height;
+//	(*cinfo.progress.progress_monitor) ((j_common_ptr) cinfo);
+//			}
+//			/* Process some data */
+//			last_scanline = cinfo.output_scanline;
+//			(*cinfo.main.process_data) (cinfo, (JSAMPARRAY) NULL,
+//						&cinfo.output_scanline, (JDIMENSION) 0);
+//			if (cinfo.output_scanline == last_scanline)
+//	return FALSE;		/* No progress made, must suspend */
+//		}
+//		/* Finish up dummy pass, and set up for another one */
+//		(*cinfo.master.finish_output_pass) (cinfo);
+//		(*cinfo.master.prepare_for_output_pass) (cinfo);
+//		cinfo.output_scanline = 0;
+//#else
+//		ERREXIT(cinfo, JERR_NOT_COMPILED);
+//#endif /* QUANT_2PASS_SUPPORTED */
+	}
+	/* Ready for application to drive output pass through
+	 * jpeg_read_scanlines or jpeg_read_raw_data.
+	 */
+	cinfo.global_state = cinfo.raw_data_out ? DSTATE_RAW_OK : DSTATE_SCANNING;
+	return true;
+}
+
+static boolean get_dht (jpeg_decompress_struct cinfo)
+/* Process a DHT marker */
+{
+	int length;
+	byte[] bits = new byte[17];
+	byte[] huffval = new byte[256];
+	int i, index, count;
+	JHUFF_TBL htblptr;
+
+	if (cinfo.bytes_offset == cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+	length = (cinfo.buffer[cinfo.bytes_offset++] & 0xFF) << 8;
+	if (cinfo.bytes_offset == cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+	length |= cinfo.buffer[cinfo.bytes_offset++] & 0xFF;
+	length -= 2;
+	
+	while (length > 16) {
+		if (cinfo.bytes_offset == cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+		index = cinfo.buffer[cinfo.bytes_offset++] & 0xFF;
+
+//		TRACEMS1(cinfo, 1, JTRC_DHT, index);
+			
+		bits[0] = 0;
+		count = 0;
+		for (i = 1; i <= 16; i++) {
+			if (cinfo.bytes_offset == cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+		bits[i] = cinfo.buffer[cinfo.bytes_offset++];
+			count += bits[i] & 0xFF;
+		}
+
+		length -= 1 + 16;
+
+//		TRACEMS8(cinfo, 2, JTRC_HUFFBITS,
+//			 bits[1], bits[2], bits[3], bits[4],
+//			 bits[5], bits[6], bits[7], bits[8]);
+//		TRACEMS8(cinfo, 2, JTRC_HUFFBITS,
+//			 bits[9], bits[10], bits[11], bits[12],
+//			 bits[13], bits[14], bits[15], bits[16]);
+
+		/* Here we just do minimal validation of the counts to avoid walking
+		 * off the end of our table space.	jdhuff.c will check more carefully.
+		 */
+		if (count > 256 || (count) > length)
+			error();
+//			ERREXIT(cinfo, JERR_BAD_HUFF_TABLE);
+
+		for (i = 0; i < count; i++) {
+	 		if (cinfo.bytes_offset == cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+	 		huffval[i] = cinfo.buffer[cinfo.bytes_offset++];
+		}
+
+		length -= count;
+
+		if ((index & 0x10) != 0) {		/* AC table definition */
+			index -= 0x10;
+			htblptr = cinfo.ac_huff_tbl_ptrs[index] = new JHUFF_TBL();
+		} else {			/* DC table definition */
+			htblptr = cinfo.dc_huff_tbl_ptrs[index] = new JHUFF_TBL();
+		}
+
+		if (index < 0 || index >= NUM_HUFF_TBLS)
+			error();
+//			ERREXIT1(cinfo, JERR_DHT_INDEX, index);
+
+		System.arraycopy(bits, 0, htblptr.bits, 0, bits.length);
+		System.arraycopy(huffval, 0, htblptr.huffval, 0, huffval.length);
+	}
+
+	if (length != 0)
+		error();
+//		ERREXIT(cinfo, JERR_BAD_LENGTH);
+
+	return true;
+}
+
+
+static boolean get_dqt (jpeg_decompress_struct cinfo)
+/* Process a DQT marker */
+{
+	int length;
+	int n, i, prec;
+	int tmp;
+	JQUANT_TBL quant_ptr;
+
+	if (cinfo.bytes_offset == cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+	length = (cinfo.buffer[cinfo.bytes_offset++] & 0xFF) << 8;
+	if (cinfo.bytes_offset == cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+	length |= cinfo.buffer[cinfo.bytes_offset++] & 0xFF;
+	length -= 2;
+
+	while (length > 0) {
+		if (cinfo.bytes_offset == cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+	n = cinfo.buffer[cinfo.bytes_offset++] & 0xFF;
+		prec = n >> 4;
+		n &= 0x0F;
+
+//		TRACEMS2(cinfo, 1, JTRC_DQT, n, prec);
+
+		if (n >= NUM_QUANT_TBLS)
+			error();
+//			ERREXIT1(cinfo, JERR_DQT_INDEX, n);
+			
+		if (cinfo.quant_tbl_ptrs[n] == null)
+			cinfo.quant_tbl_ptrs[n] = new JQUANT_TBL();
+		quant_ptr = cinfo.quant_tbl_ptrs[n];
+
+		for (i = 0; i < DCTSIZE2; i++) {
+			if (prec != 0) {
+				if (cinfo.bytes_offset == cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+				tmp = (cinfo.buffer[cinfo.bytes_offset++] & 0xFF) << 8;
+				if (cinfo.bytes_offset == cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+				tmp |= cinfo.buffer[cinfo.bytes_offset++] & 0xFF;
+			} else {
+					if (cinfo.bytes_offset == cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+				tmp = cinfo.buffer[cinfo.bytes_offset++] & 0xFF;
+			}
+			/* We convert the zigzag-order table to natural array order. */
+			quant_ptr.quantval[jpeg_natural_order[i]] = (short) tmp;
+		}
+
+//		if (cinfo.err.trace_level >= 2) {
+//			for (i = 0; i < DCTSIZE2; i += 8) {
+//				TRACEMS8(cinfo, 2, JTRC_QUANTVALS,
+//		 			quant_ptr.quantval[i],	 quant_ptr.quantval[i+1],
+//					 quant_ptr.quantval[i+2], quant_ptr.quantval[i+3],
+//					 quant_ptr.quantval[i+4], quant_ptr.quantval[i+5],
+//					 quant_ptr.quantval[i+6], quant_ptr.quantval[i+7]);
+//			}
+//		}
+
+		length -= (DCTSIZE2+1);
+		if (prec != 0) length -= DCTSIZE2;
+	}
+
+	if (length != 0)
+		error();
+//		ERREXIT(cinfo, JERR_BAD_LENGTH);
+
+	return true;
+}
+
+static boolean get_dri (jpeg_decompress_struct cinfo)
+/* Process a DRI marker */
+{
+	int length;
+	int tmp;
+
+	if (cinfo.bytes_offset == cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+	length = (cinfo.buffer[cinfo.bytes_offset++] & 0xFF) << 8;
+	if (cinfo.bytes_offset == cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+	length |= cinfo.buffer[cinfo.bytes_offset++] & 0xFF;
+	
+	if (length != 4)
+	error();
+//		ERREXIT(cinfo, JERR_BAD_LENGTH);
+
+	if (cinfo.bytes_offset == cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+	tmp = (cinfo.buffer[cinfo.bytes_offset++] & 0xFF) << 8;
+	if (cinfo.bytes_offset == cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+	tmp |= cinfo.buffer[cinfo.bytes_offset++] & 0xFF;
+
+//	TRACEMS1(cinfo, 1, JTRC_DRI, tmp);
+
+	cinfo.restart_interval = tmp;
+
+	return true;
+}
+
+static boolean get_dac (jpeg_decompress_struct cinfo)
+/* Process a DAC marker */
+{
+	int length;
+	int index, val;
+	if (cinfo.bytes_offset == cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+	length = (cinfo.buffer[cinfo.bytes_offset++] & 0xFF) << 8;
+	if (cinfo.bytes_offset == cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+	length |= cinfo.buffer[cinfo.bytes_offset++] & 0xFF;
+	length -= 2;
+	
+	while (length > 0) {
+		if (cinfo.bytes_offset == cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+		index = cinfo.buffer[cinfo.bytes_offset++] & 0xFF;
+		if (cinfo.bytes_offset == cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+		val = cinfo.buffer[cinfo.bytes_offset++] & 0xFF;
+
+		length -= 2;
+
+//		TRACEMS2(cinfo, 1, JTRC_DAC, index, val);
+
+		if (index < 0 || index >= (2*NUM_ARITH_TBLS))
+			error();
+//			ERREXIT1(cinfo, JERR_DAC_INDEX, index);
+
+		if (index >= NUM_ARITH_TBLS) { /* define AC table */
+			cinfo.arith_ac_K[index-NUM_ARITH_TBLS] = (byte) val;
+		} else {			/* define DC table */
+			cinfo.arith_dc_L[index] = (byte) (val & 0x0F);
+			cinfo.arith_dc_U[index] = (byte) (val >> 4);
+			if (cinfo.arith_dc_L[index] > cinfo.arith_dc_U[index])
+				error();
+//	ERREXIT1(cinfo, JERR_DAC_VALUE, val);
+		}
+	}
+
+	if (length != 0)
+		error();
+//		ERREXIT(cinfo, JERR_BAD_LENGTH);
+
+	return true;
+}
+
+
+static boolean get_sos (jpeg_decompress_struct cinfo)
+/* Process a SOS marker */
+{
+	int length;
+	int i, ci, n, c, cc;
+	jpeg_component_info compptr = null;
+
+	if (! cinfo.marker.saw_SOF)
+		error();
+//		ERREXIT(cinfo, JERR_SOS_NO_SOF);
+
+	if (cinfo.bytes_offset == cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+	length = (cinfo.buffer[cinfo.bytes_offset++] & 0xFF) << 8;
+	if (cinfo.bytes_offset == cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+	length |= cinfo.buffer[cinfo.bytes_offset++] & 0xFF;
+
+	if (cinfo.bytes_offset == cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+	n = cinfo.buffer[cinfo.bytes_offset++] & 0xFF;
+
+//	TRACEMS1(cinfo, 1, JTRC_SOS, n);
+
+	if (length != (n * 2 + 6) || n < 1 || n > MAX_COMPS_IN_SCAN)
+		error();
+//		ERREXIT(cinfo, JERR_BAD_LENGTH);
+
+	cinfo.comps_in_scan = n;
+
+	/* Collect the component-spec parameters */
+
+	for (i = 0; i < n; i++) {
+		if (cinfo.bytes_offset == cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+		cc = cinfo.buffer[cinfo.bytes_offset++] & 0xFF;
+		if (cinfo.bytes_offset == cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+		c = cinfo.buffer[cinfo.bytes_offset++] & 0xFF;
+		
+		for (ci = 0; ci < cinfo.num_components; ci++) {
+			compptr = cinfo.comp_info[ci];
+			if (cc == compptr.component_id)
+				break;
+		}
+
+		if (ci == cinfo.num_components)
+			error();
+//			ERREXIT1(cinfo, JERR_BAD_COMPONENT_ID, cc);
+
+		cinfo.cur_comp_info[i] = compptr;
+		compptr.dc_tbl_no = (c >> 4) & 15;
+		compptr.ac_tbl_no = (c		 ) & 15;
+		
+//		TRACEMS3(cinfo, 1, JTRC_SOS_COMPONENT, cc, compptr.dc_tbl_no, compptr.ac_tbl_no);
+	}
+
+	/* Collect the additional scan parameters Ss, Se, Ah/Al. */
+	if (cinfo.bytes_offset == cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+	c = cinfo.buffer[cinfo.bytes_offset++] & 0xFF;
+	cinfo.Ss = c;
+	if (cinfo.bytes_offset == cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+	c = cinfo.buffer[cinfo.bytes_offset++] & 0xFF;
+	cinfo.Se = c;
+	if (cinfo.bytes_offset == cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+	c = cinfo.buffer[cinfo.bytes_offset++] & 0xFF;
+	cinfo.Ah = (c >> 4) & 15;
+	cinfo.Al = (c		 ) & 15;
+
+//	TRACEMS4(cinfo, 1, JTRC_SOS_PARAMS, cinfo.Ss, cinfo.Se, cinfo.Ah, cinfo.Al);
+
+	/* Prepare to scan data & restart markers */
+	cinfo.marker.next_restart_num = 0;
+
+	/* Count another SOS marker */
+	cinfo.input_scan_number++;
+
+	return true;
+}
+
+static boolean get_sof (jpeg_decompress_struct cinfo, boolean is_prog, boolean is_arith) {
+	int length;
+	int c, ci;
+
+	cinfo.progressive_mode = is_prog;
+	cinfo.arith_code = is_arith;
+
+	if (cinfo.bytes_offset == cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+	length = (cinfo.buffer[cinfo.bytes_offset++] & 0xFF) << 8;
+	if (cinfo.bytes_offset == cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+	length |= cinfo.buffer[cinfo.bytes_offset++] & 0xFF;
+
+	if (cinfo.bytes_offset == cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+	cinfo.data_precision = cinfo.buffer[cinfo.bytes_offset++] & 0xFF;
+
+	if (cinfo.bytes_offset == cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+	cinfo.image_height = (cinfo.buffer[cinfo.bytes_offset++] & 0xFF) << 8;
+	if (cinfo.bytes_offset == cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+	cinfo.image_height |= cinfo.buffer[cinfo.bytes_offset++] & 0xFF;
+
+	if (cinfo.bytes_offset == cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+	cinfo.image_width = (cinfo.buffer[cinfo.bytes_offset++] & 0xFF) << 8;
+	if (cinfo.bytes_offset == cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+	cinfo.image_width |= cinfo.buffer[cinfo.bytes_offset++] & 0xFF;
+	
+	if (cinfo.bytes_offset == cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+	cinfo.num_components = cinfo.buffer[cinfo.bytes_offset++] & 0xFF;
+
+	length -= 8;
+
+//	TRACEMS4(cinfo, 1, JTRC_SOF, cinfo.unread_marker,
+//		 (int) cinfo.image_width, (int) cinfo.image_height,
+//		 cinfo.num_components);
+
+	if (cinfo.marker.saw_SOF)
+		error();
+//		ERREXIT(cinfo, JERR_SOF_DUPLICATE);
+
+	/* We don't support files in which the image height is initially specified */
+	/* as 0 and is later redefined by DNL.	As long as we have to check that,	*/
+	/* might as well have a general sanity check. */
+	if (cinfo.image_height <= 0 || cinfo.image_width <= 0 || cinfo.num_components <= 0)
+		error();
+//		ERREXIT(cinfo, JERR_EMPTY_IMAGE);
+
+	if (length != (cinfo.num_components * 3))
+		error();
+//		ERREXIT(cinfo, JERR_BAD_LENGTH);
+
+	if (cinfo.comp_info == null)	/* do only once, even if suspend */
+		cinfo.comp_info = new jpeg_component_info[cinfo.num_components];
+	
+	for (ci = 0; ci < cinfo.num_components; ci++) {
+		jpeg_component_info compptr = cinfo.comp_info[ci] = new jpeg_component_info();
+		compptr.component_index = ci;
+		if (cinfo.bytes_offset == cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+		compptr.component_id = cinfo.buffer[cinfo.bytes_offset++] & 0xFF;
+		if (cinfo.bytes_offset == cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+		c = cinfo.buffer[cinfo.bytes_offset++] & 0xFF;
+		compptr.h_samp_factor = (c >> 4) & 15;
+		compptr.v_samp_factor = (c		 ) & 15;
+		if (cinfo.bytes_offset == cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+		compptr.quant_tbl_no = cinfo.buffer[cinfo.bytes_offset++] & 0xFF;
+
+//		TRACEMS4(cinfo, 1, JTRC_SOF_COMPONENT,
+//			 compptr.component_id, compptr.h_samp_factor,
+//			 compptr.v_samp_factor, compptr.quant_tbl_no);
+	}
+
+	cinfo.marker.saw_SOF = true;
+
+	return true;
+}
+
+static void sep_upsample (jpeg_decompress_struct cinfo, byte[][][] input_buf, int[] input_buf_offset,
+		int[] in_row_group_ctr, int in_row_groups_avail,
+		byte[][] output_buf, int[] out_row_ctr,	int out_rows_avail)
+{
+	jpeg_upsampler upsample = cinfo.upsample;
+	int ci;
+	jpeg_component_info compptr;
+	int num_rows;
+
+	/* Fill the conversion buffer, if it's empty */
+	if (upsample.next_row_out >= cinfo.max_v_samp_factor) {
+		for (ci = 0; ci < cinfo.num_components; ci++) {
+			compptr = cinfo.comp_info[ci];
+			/* Invoke per-component upsample method.	Notice we pass a POINTER
+			 * to color_buf[ci], so that fullsize_upsample can change it.
+			 */
+			int offset = input_buf_offset[ci] + (in_row_group_ctr[0] * upsample.rowgroup_height[ci]);
+			switch (upsample.methods[ci]) {
+				case NOOP_UPSAMPLE: noop_upsample(cinfo, compptr, input_buf[ci], offset, upsample.color_buf, upsample.color_buf_offset, ci); break;
+				case FULLSIZE_UPSAMPLE: fullsize_upsample(cinfo, compptr, input_buf[ci], offset, upsample.color_buf, upsample.color_buf_offset, ci); break;
+				case H2V1_FANCY_UPSAMPLE: h2v1_fancy_upsample(cinfo, compptr, input_buf[ci], offset, upsample.color_buf, upsample.color_buf_offset, ci); break;
+				case H2V1_UPSAMPLE: h2v1_upsample(cinfo, compptr, input_buf[ci], offset, upsample.color_buf, upsample.color_buf_offset, ci); break;
+				case H2V2_FANCY_UPSAMPLE: h2v2_fancy_upsample(cinfo, compptr, input_buf[ci], offset, upsample.color_buf, upsample.color_buf_offset, ci); break;
+				case H2V2_UPSAMPLE: h2v2_upsample(cinfo, compptr, input_buf[ci], offset, upsample.color_buf, upsample.color_buf_offset, ci); break;
+				case INT_UPSAMPLE: int_upsample(cinfo, compptr, input_buf[ci], offset, upsample.color_buf, upsample.color_buf_offset, ci); break;
+			}
+		}
+		upsample.next_row_out = 0;
+	}
+
+	/* Color-convert and emit rows */
+
+	/* How many we have in the buffer: */
+	num_rows =	(cinfo.max_v_samp_factor - upsample.next_row_out);
+	/* Not more than the distance to the end of the image.	Need this test
+	 * in case the image height is not a multiple of max_v_samp_factor:
+	 */
+	if (num_rows > upsample.rows_to_go) 
+		num_rows = upsample.rows_to_go;
+	/* And not more than what the client can accept: */
+	out_rows_avail -= out_row_ctr[0];
+	if (num_rows > out_rows_avail)
+		num_rows = out_rows_avail;
+
+	switch (cinfo.cconvert.color_convert) {
+		case NULL_CONVERT: null_convert (cinfo, upsample.color_buf, upsample.color_buf_offset, upsample.next_row_out, output_buf, out_row_ctr[0], num_rows); break;
+		case GRAYSCALE_CONVERT: grayscale_convert (cinfo, upsample.color_buf, upsample.color_buf_offset, upsample.next_row_out, output_buf, out_row_ctr[0], num_rows); break;
+		case YCC_RGB_CONVERT: ycc_rgb_convert (cinfo, upsample.color_buf, upsample.color_buf_offset, upsample.next_row_out, output_buf, out_row_ctr[0], num_rows); break;
+		case GRAY_RGB_CONVERT: gray_rgb_convert (cinfo, upsample.color_buf, upsample.color_buf_offset, upsample.next_row_out, output_buf, out_row_ctr[0], num_rows); break;
+		case YCCK_CMYK_CONVERT: error(); break;
+	}
+
+	/* Adjust counts */
+	out_row_ctr[0] += num_rows;
+	upsample.rows_to_go -= num_rows;
+	upsample.next_row_out += num_rows;
+	/* When the buffer is emptied, declare this input row group consumed */
+	if (upsample.next_row_out >= cinfo.max_v_samp_factor) {
+		in_row_group_ctr[0]++;
+	}
+}
+	
+static void noop_upsample (jpeg_decompress_struct cinfo, jpeg_component_info compptr,
+	 byte[][] input_data, int input_data_offset, byte[][][] output_data_ptr, int[] output_data_offset, int output_data_index)
+{
+	output_data_ptr[output_data_index] = null;	/* safety check */
+}
+	
+static void fullsize_upsample (jpeg_decompress_struct cinfo, jpeg_component_info compptr,
+	 byte[][] input_data, int input_data_offset, byte[][][] output_data_ptr, int[] output_data_offset, int output_data_index)
+{
+	output_data_ptr[output_data_index] = input_data;
+	output_data_offset[output_data_index] = input_data_offset;
+}
+	
+static void h2v1_upsample (jpeg_decompress_struct cinfo, jpeg_component_info compptr,
+	 byte[][] input_data, int input_data_offset, byte[][][] output_data_ptr, int[] output_data_offset, int output_data_index)
+{
+	byte[][] output_data = output_data_ptr[output_data_index];
+	byte[] inptr, outptr;
+	byte invalue;
+	int outend;
+	int inrow;
+	output_data_offset[output_data_index] = 0;
+
+	for (inrow = 0; inrow < cinfo.max_v_samp_factor; inrow++) {
+		inptr = input_data[inrow+input_data_offset];
+		outptr = output_data[inrow];
+		int inptr_offset = 0, outptr_offset = 0;
+		outend = outptr_offset + cinfo.output_width;
+		while (outptr_offset < outend) {
+			invalue = inptr[inptr_offset++];	/* don't need GETJSAMPLE() here */
+			outptr[outptr_offset++] = invalue;
+			outptr[outptr_offset++] = invalue;
+		}
+	}
+}
+	
+static void h2v2_upsample (jpeg_decompress_struct cinfo, jpeg_component_info compptr,
+	byte[][] input_data, int input_data_offset, byte[][][] output_data_ptr, int[] output_data_offset, int output_data_index)
+{
+	byte[][] output_data = output_data_ptr[output_data_index];
+	byte[] inptr, outptr;
+	byte invalue;
+	int outend;
+	int inrow, outrow;
+	output_data_offset[output_data_index] = 0;
+
+	inrow = outrow = 0;
+	while (outrow < cinfo.max_v_samp_factor) {
+		inptr = input_data[inrow+input_data_offset];
+		outptr = output_data[outrow];
+		int inptr_offset = 0, outptr_offset = 0;
+		outend = outptr_offset + cinfo.output_width;
+		while (outptr_offset < outend) {
+			invalue = inptr[inptr_offset++];	/* don't need GETJSAMPLE() here */
+			outptr[outptr_offset++] = invalue;
+			outptr[outptr_offset++] = invalue;
+		}
+		jcopy_sample_rows(output_data, outrow, output_data, outrow+1, 1, cinfo.output_width);
+		inrow++;
+		outrow += 2;
+	}
+}
+	
+static void h2v1_fancy_upsample (jpeg_decompress_struct cinfo, jpeg_component_info compptr,
+	 byte[][] input_data, int input_data_offset, byte[][][] output_data_ptr, int[] output_data_offset, int output_data_index)
+{
+	byte[][] output_data = output_data_ptr[output_data_index];
+	byte[] inptr, outptr;
+	int invalue;
+	int colctr;
+	int inrow;					
+	output_data_offset[output_data_index] = 0;
+
+	for (inrow = 0; inrow < cinfo.max_v_samp_factor; inrow++) {
+		inptr = input_data[inrow+input_data_offset];
+		outptr = output_data[inrow];
+		int inptr_offset = 0, outptr_offset = 0;
+		/* Special case for first column */
+		invalue = inptr[inptr_offset++] & 0xFF;
+		outptr[outptr_offset++] = (byte) invalue;
+		outptr[outptr_offset++] = (byte) ((invalue * 3 + (inptr[inptr_offset] & 0xFF) + 2) >> 2);
+
+		for (colctr = compptr.downsampled_width - 2; colctr > 0; colctr--) {
+			/* General case: 3/4 * nearer pixel + 1/4 * further pixel */
+			invalue = (inptr[inptr_offset++] & 0xFF) * 3;
+			outptr[outptr_offset++] = (byte) ((invalue + (inptr[inptr_offset-2] & 0xFF) + 1) >> 2);
+			outptr[outptr_offset++] = (byte) ((invalue + (inptr[inptr_offset] & 0xFF) + 2) >> 2);
+		}
+
+		/* Special case for last column */
+		invalue = (inptr[inptr_offset] & 0xFF);
+		outptr[outptr_offset++] = (byte) ((invalue * 3 + (inptr[inptr_offset-1] & 0xFF) + 1) >> 2);
+		outptr[outptr_offset++] = (byte) invalue;
+	}
+}
+	
+static void h2v2_fancy_upsample (jpeg_decompress_struct cinfo, jpeg_component_info compptr,
+	byte[][] input_data, int input_data_offset, byte[][][] output_data_ptr, int[] output_data_offset, int output_data_index)
+{
+	byte[][] output_data = output_data_ptr[output_data_index];
+	byte[] inptr0, inptr1, outptr;
+	int thiscolsum, lastcolsum, nextcolsum;
+	int colctr;
+	int inrow, outrow, v;
+	output_data_offset[output_data_index] = 0;
+
+	inrow = outrow = 0;
+	while (outrow < cinfo.max_v_samp_factor) {
+		for (v = 0; v < 2; v++) {
+			/* inptr0 points to nearest input row, inptr1 points to next nearest */
+			inptr0 = input_data[inrow+input_data_offset];
+			if (v == 0)		/* next nearest is row above */
+				inptr1 = input_data[inrow-1+input_data_offset];
+			else			/* next nearest is row below */
+				inptr1 = input_data[inrow+1+input_data_offset];
+			outptr = output_data[outrow++];
+				
+			int inptr0_offset = 0, inptr1_offset = 0, outptr_offset = 0;
+
+			/* Special case for first column */
+			thiscolsum = (inptr0[inptr0_offset++] & 0xFF) * 3 + (inptr1[inptr1_offset++] & 0xFF);
+			nextcolsum = (inptr0[inptr0_offset++] & 0xFF) * 3 + (inptr1[inptr1_offset++] & 0xFF);
+			outptr[outptr_offset++] = (byte) ((thiscolsum * 4 + 8) >> 4);
+			outptr[outptr_offset++] = (byte) ((thiscolsum * 3 + nextcolsum + 7) >> 4);
+			lastcolsum = thiscolsum; thiscolsum = nextcolsum;
+
+			for (colctr = compptr.downsampled_width - 2; colctr > 0; colctr--) {
+				/* General case: 3/4 * nearer pixel + 1/4 * further pixel in each */
+				/* dimension, thus 9/16, 3/16, 3/16, 1/16 overall */
+				nextcolsum = (inptr0[inptr0_offset++] & 0xFF) * 3 + (inptr1[inptr1_offset++] & 0xFF);
+				outptr[outptr_offset++] = (byte) ((thiscolsum * 3 + lastcolsum + 8) >> 4);
+				outptr[outptr_offset++] = (byte) ((thiscolsum * 3 + nextcolsum + 7) >> 4);
+				lastcolsum = thiscolsum; thiscolsum = nextcolsum;
+			}
+
+			/* Special case for last column */
+			outptr[outptr_offset++] = (byte) ((thiscolsum * 3 + lastcolsum + 8) >> 4);
+			outptr[outptr_offset++] = (byte) ((thiscolsum * 4 + 7) >> 4);
+		}
+		inrow++;
+	}
+}
+	
+static void int_upsample (jpeg_decompress_struct cinfo, jpeg_component_info compptr,
+	 byte[][] input_data, int input_data_offset, byte[][][] output_data_ptr, int[] output_data_offset, int output_data_index)
+{
+	jpeg_upsampler upsample = cinfo.upsample;
+	byte[][] output_data = output_data_ptr[output_data_index];
+	byte[] inptr, outptr;
+	byte invalue;
+	int h;
+	int outend;
+	int h_expand, v_expand;
+	int inrow, outrow;
+	output_data_offset[output_data_index] = 0;
+		
+	h_expand = upsample.h_expand[compptr.component_index];
+	v_expand = upsample.v_expand[compptr.component_index];
+
+	inrow = outrow = 0;
+	while (outrow < cinfo.max_v_samp_factor) {
+		/* Generate one output row with proper horizontal expansion */
+		inptr = input_data[inrow+input_data_offset];
+		int inptr_offset = 0;
+		outptr = output_data[outrow];
+		int outptr_offset = 0;
+		outend = outptr_offset + cinfo.output_width;
+		while (outptr_offset < outend) {
+			invalue = inptr[inptr_offset++];	/* don't need GETJSAMPLE() here */
+			for (h = h_expand; h > 0; h--) {
+				outptr[outptr_offset++] = invalue;
+			}
+		}
+		/* Generate any additional output rows by duplicating the first one */
+		if (v_expand > 1) {
+			jcopy_sample_rows(output_data, outrow, output_data, outrow+1, v_expand-1, cinfo.output_width);
+		}
+		inrow++;
+		outrow += v_expand;
+	}
+}
+
+static void null_convert (jpeg_decompress_struct cinfo,
+	byte[][][] input_buf, int[] input_buf_offset, int input_row,
+	byte[][] output_buf, int output_buf_offset, int num_rows)
+{
+	byte[] inptr, outptr;
+	int count;
+	int num_components = cinfo.num_components;
+	int num_cols = cinfo.output_width;
+	int ci;
+
+	while (--num_rows >= 0) {
+		for (ci = 0; ci < num_components; ci++) {
+			inptr = input_buf[ci][input_row+input_buf_offset[0]];
+			outptr = output_buf[output_buf_offset];
+			/* BGR instead of RGB */
+			int offset = 0;
+			switch (ci) {
+				case 2: offset = RGB_BLUE; break;
+				case 1: offset = RGB_GREEN; break;
+				case 0: offset = RGB_RED; break;
+			}
+			int outptr_offset = offset, inptr_offset = 0;
+			for (count = num_cols; count > 0; count--) {
+				outptr[outptr_offset] = inptr[inptr_offset++];	/* needn't bother with GETJSAMPLE() here */
+				outptr_offset += num_components;
+			}
+		}
+		input_row++;
+		output_buf_offset++;
+	}
+}
+	
+static void grayscale_convert (jpeg_decompress_struct cinfo,
+	byte[][][] input_buf, int[] input_buf_offset, int input_row,
+	byte[][] output_buf, int output_buf_offset, int num_rows)
+{
+  jcopy_sample_rows(input_buf[0], input_row+input_buf_offset[0], output_buf, output_buf_offset,
+		    num_rows, cinfo.output_width);
+}
+
+static void gray_rgb_convert (jpeg_decompress_struct cinfo,
+	byte[][][] input_buf, int[] input_buf_offset, int input_row,
+	byte[][] output_buf, int output_buf_offset, int num_rows)
+{
+	byte[] inptr, outptr;
+	int col;
+	int num_cols = cinfo.output_width;
+
+	while (--num_rows >= 0) {
+		inptr = input_buf[0][input_row+++input_buf_offset[0]];
+		outptr = output_buf[output_buf_offset++];
+		int outptr_offset = 0;
+		for (col = 0; col < num_cols; col++) {
+			/* We can dispense with GETJSAMPLE() here */
+			outptr[RGB_RED+outptr_offset] = outptr[RGB_GREEN+outptr_offset] = outptr[RGB_BLUE+outptr_offset] = inptr[col];
+			outptr_offset += RGB_PIXELSIZE;
+		}
+	}
+}
+	
+static void ycc_rgb_convert (jpeg_decompress_struct cinfo,
+	byte[][][] input_buf, int[] input_buf_offset, int input_row,
+	byte[][] output_buf, int output_buf_offset, int num_rows)
+{
+	jpeg_color_deconverter cconvert = cinfo.cconvert;
+	int y, cb, cr;
+	byte[] outptr;
+	byte[] inptr0, inptr1, inptr2;
+	int col;
+	int num_cols = cinfo.output_width;
+	/* copy these pointers into registers if possible */
+	byte[] range_limit = cinfo.sample_range_limit;
+	int range_limit_offset = cinfo.sample_range_limit_offset;
+	int[] Crrtab = cconvert.Cr_r_tab;
+	int[] Cbbtab = cconvert.Cb_b_tab;
+	int[] Crgtab = cconvert.Cr_g_tab;
+	int[] Cbgtab = cconvert.Cb_g_tab;
+//		SHIFT_TEMPS
+
+	while (--num_rows >= 0) {
+		inptr0 = input_buf[0][input_row+input_buf_offset[0]];
+		inptr1 = input_buf[1][input_row+input_buf_offset[1]];
+		inptr2 = input_buf[2][input_row+input_buf_offset[2]];
+		input_row++;
+		outptr = output_buf[output_buf_offset++];
+		int outptr_offset = 0;
+		for (col = 0; col < num_cols; col++) {
+			y = (inptr0[col] & 0xFF);
+			cb = (inptr1[col] & 0xFF);
+			cr = (inptr2[col] & 0xFF);
+			/* Range-limiting is essential due to noise introduced by DCT losses. */
+			outptr[outptr_offset + RGB_RED] =	range_limit[y + Crrtab[cr] + range_limit_offset];
+			outptr[outptr_offset + RGB_GREEN] = range_limit[y + ((Cbgtab[cb] + Crgtab[cr]>>SCALEBITS)) + range_limit_offset];
+			outptr[outptr_offset + RGB_BLUE] =	range_limit[y + Cbbtab[cb] + range_limit_offset];
+			outptr_offset += RGB_PIXELSIZE;
+		}
+	}
+}
+
+static boolean process_APPn(int n, jpeg_decompress_struct cinfo) {
+	if (n == 0 || n == 14) {
+		return get_interesting_appn(cinfo);
+	}
+	return skip_variable(cinfo);
+}
+
+static boolean process_COM(jpeg_decompress_struct cinfo) {
+	return skip_variable(cinfo);
+}
+
+static void skip_input_data (jpeg_decompress_struct cinfo, int num_bytes) {
+	if (num_bytes > 0) {
+		while (num_bytes > cinfo.bytes_in_buffer - cinfo.bytes_offset) {
+			num_bytes -= cinfo.bytes_in_buffer - cinfo.bytes_offset;
+			if (!fill_input_buffer(cinfo)) error();
+			/* note we assume that fill_input_buffer will never return FALSE,
+			 * so suspension need not be handled.
+			 */
+		}
+		cinfo.bytes_offset += num_bytes;
+	}
+}
+
+static boolean skip_variable (jpeg_decompress_struct cinfo)
+/* Skip over an unknown or uninteresting variable-length marker */
+{
+	int length;
+
+	if (cinfo.bytes_offset == cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+	length = (cinfo.buffer[cinfo.bytes_offset++] & 0xFF) << 8;
+	if (cinfo.bytes_offset == cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+	length |= cinfo.buffer[cinfo.bytes_offset++] & 0xFF;
+
+	length -= 2;
+	
+//	TRACEMS2(cinfo, 1, JTRC_MISC_MARKER, cinfo.unread_marker, (int) length);
+
+	if (length > 0) {
+		skip_input_data (cinfo, length);
+	}
+	
+	return true;
+}
+
+static boolean get_interesting_appn (jpeg_decompress_struct cinfo)
+/* Process an APP0 or APP14 marker without saving it */
+{
+	int length;
+	byte[] b = new byte[APPN_DATA_LEN];
+	int i, numtoread;
+
+	if (cinfo.bytes_offset == cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+	length = (cinfo.buffer[cinfo.bytes_offset++] & 0xFF) << 8;
+	if (cinfo.bytes_offset == cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+	length |= cinfo.buffer[cinfo.bytes_offset++] & 0xFF;
+	length -= 2;
+
+	/* get the interesting part of the marker data */
+	if (length >= APPN_DATA_LEN)
+		numtoread = APPN_DATA_LEN;
+	else if (length > 0)
+		numtoread = length;
+	else
+		numtoread = 0;
+	for (i = 0; i < numtoread; i++) {
+		if (cinfo.bytes_offset == cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+		b[i] = cinfo.buffer[cinfo.bytes_offset++];
+	}
+	length -= numtoread;
+
+	/* process it */
+	switch (cinfo.unread_marker) {
+		case M_APP0:
+			examine_app0(cinfo, b, numtoread, length);
+			break;
+		case M_APP14:
+			examine_app14(cinfo, b, numtoread, length);
+			break;
+		default:
+			/* can't get here unless jpeg_save_markers chooses wrong processor */
+			error();
+//			ERREXIT1(cinfo, JERR_UNKNOWN_MARKER, cinfo.unread_marker);
+			break;
+	}
+
+	/* skip any remaining data -- could be lots */
+	if (length > 0)
+		skip_input_data (cinfo, length);
+
+	return true;
+}
+
+static void examine_app0 (jpeg_decompress_struct cinfo, byte[] data, int datalen, int remaining)
+/* Examine first few bytes from an APP0.
+ * Take appropriate action if it is a JFIF marker.
+ * datalen is # of bytes at data[], remaining is length of rest of marker data.
+ */
+{
+	int totallen = datalen + remaining;
+
+	if (datalen >= APP0_DATA_LEN &&
+			(data[0] & 0xFF) == 0x4A &&
+			(data[1] & 0xFF) == 0x46 &&
+			(data[2] & 0xFF) == 0x49 &&
+			(data[3] & 0xFF) == 0x46 &&
+			(data[4] & 0xFF) == 0)
+	{
+		/* Found JFIF APP0 marker: save info */
+		cinfo.saw_JFIF_marker = true;
+		cinfo.JFIF_major_version = (data[5]);
+		cinfo.JFIF_minor_version = (byte)(data[6] & 0xFF);
+		cinfo.density_unit = (byte)(data[7] & 0xFF);
+		cinfo.X_density = (short)(((data[8] & 0xFF) << 8) + (data[9] & 0xFF));
+		cinfo.Y_density = (short)(((data[10] & 0xFF) << 8) + (data[11] & 0xFF));
+		/* Check version.
+		 * Major version must be 1, anything else signals an incompatible change.
+		 * (We used to treat this as an error, but now it's a nonfatal warning,
+		 * because some bozo at Hijaak couldn't read the spec.)
+		 * Minor version should be 0..2, but process anyway if newer.
+		 */
+		if (cinfo.JFIF_major_version != 1) {
+//			WARNMS2(cinfo, JWRN_JFIF_MAJOR,
+//				cinfo.JFIF_major_version, cinfo.JFIF_minor_version);
+		}
+		/* Generate trace messages */
+//		TRACEMS5(cinfo, 1, JTRC_JFIF,
+//			 cinfo.JFIF_major_version, cinfo.JFIF_minor_version,
+//			 cinfo.X_density, cinfo.Y_density, cinfo.density_unit);
+		/* Validate thumbnail dimensions and issue appropriate messages */
+		if (((data[12] & 0xFF) | (data[13]) & 0xFF) != 0) {
+//			TRACEMS2(cinfo, 1, JTRC_JFIF_THUMBNAIL,
+//				 GETJOCTET(data[12]), GETJOCTET(data[13]));
+		}
+		totallen -= APP0_DATA_LEN;
+		if (totallen !=	((data[12] & 0xFF) * (data[13] & 0xFF) * 3)) {
+//			TRACEMS1(cinfo, 1, JTRC_JFIF_BADTHUMBNAILSIZE, (int) totallen);
+		}
+	} else if (datalen >= 6 &&
+			(data[0] & 0xFF) == 0x4A &&
+			(data[1] & 0xFF) == 0x46 &&
+			(data[2] & 0xFF) == 0x58 &&
+			(data[3] & 0xFF) == 0x58 &&
+			(data[4] & 0xFF) == 0)
+	{
+		/* Found JFIF "JFXX" extension APP0 marker */
+		/* The library doesn't actually do anything with these,
+		 * but we try to produce a helpful trace message.
+		 */
+		switch ((data[5]) & 0xFF) {
+			case 0x10:
+//				TRACEMS1(cinfo, 1, JTRC_THUMB_JPEG, (int) totallen);
+				break;
+			case 0x11:
+//				TRACEMS1(cinfo, 1, JTRC_THUMB_PALETTE, (int) totallen);
+				break;
+			case 0x13:
+//				TRACEMS1(cinfo, 1, JTRC_THUMB_RGB, (int) totallen);
+				break;
+			default:
+//				TRACEMS2(cinfo, 1, JTRC_JFIF_EXTENSION, GETJOCTET(data[5]), (int) totallen);
+			break;
+		}
+	} else {
+		/* Start of APP0 does not match "JFIF" or "JFXX", or too short */
+//		TRACEMS1(cinfo, 1, JTRC_APP0, (int) totallen);
+	}
+}
+
+static void examine_app14 (jpeg_decompress_struct cinfo, byte[] data, int datalen, int remaining)
+/* Examine first few bytes from an APP14.
+ * Take appropriate action if it is an Adobe marker.
+ * datalen is # of bytes at data[], remaining is length of rest of marker data.
+ */
+{
+	int /*version, flags0, flags1, */transform;
+
+	if (datalen >= APP14_DATA_LEN &&
+			(data[0] & 0xFF) == 0x41 &&
+			(data[1] & 0xFF) == 0x64 &&
+			(data[2] & 0xFF) == 0x6F &&
+			(data[3] & 0xFF) == 0x62 &&
+			(data[4] & 0xFF) == 0x65)
+	{
+		/* Found Adobe APP14 marker */
+//		version = ((data[5] & 0xFF) << 8) + (data[6] & 0xFF);
+//		flags0 = ((data[7] & 0xFF) << 8) + (data[8] & 0xFF);
+//		flags1 = ((data[9] & 0xFF) << 8) + (data[10] & 0xFF);
+		transform = (data[11] & 0xFF);
+//		TRACEMS4(cinfo, 1, JTRC_ADOBE, version, flags0, flags1, transform);
+		cinfo.saw_Adobe_marker = true;
+		cinfo.Adobe_transform = (byte) transform;
+	} else {
+		/* Start of APP14 does not match "Adobe", or too short */
+//		TRACEMS1(cinfo, 1, JTRC_APP14, (int) (datalen + remaining));
+	}
+}
+
+static boolean get_soi (jpeg_decompress_struct cinfo) /* Process an SOI marker */ {
+	int i;
+	
+//	TRACEMS(cinfo, 1, JTRC_SOI);
+
+	if (cinfo.marker.saw_SOI)
+		error();
+//		ERREXIT(cinfo, JERR_SOI_DUPLICATE);
+
+	/* Reset all parameters that are defined to be reset by SOI */
+
+	for (i = 0; i < NUM_ARITH_TBLS; i++) {
+		cinfo.arith_dc_L[i] = 0;
+		cinfo.arith_dc_U[i] = 1;
+		cinfo.arith_ac_K[i] = 5;
+	}
+	cinfo.restart_interval = 0;
+
+	/* Set initial assumptions for colorspace etc */
+
+	cinfo.jpeg_color_space = JCS_UNKNOWN;
+	cinfo.CCIR601_sampling = false; /* Assume non-CCIR sampling??? */
+
+	cinfo.saw_JFIF_marker = false;
+	cinfo.JFIF_major_version = 1; /* set default JFIF APP0 values */
+	cinfo.JFIF_minor_version = 1;
+	cinfo.density_unit = 0;
+	cinfo.X_density = 1;
+	cinfo.Y_density = 1;
+	cinfo.saw_Adobe_marker = false;
+	cinfo.Adobe_transform = 0;
+
+	cinfo.marker.saw_SOI = true;
+
+	return true;
+}
+
+static void jinit_input_controller (jpeg_decompress_struct cinfo)
+{
+	/* Initialize state: can't use reset_input_controller since we don't
+	 * want to try to reset other modules yet.
+	 */
+	jpeg_input_controller inputctl = cinfo.inputctl = new jpeg_input_controller();
+	inputctl.has_multiple_scans = false; /* "unknown" would be better */
+	inputctl.eoi_reached = false;
+	inputctl.inheaders = true;
+}
+
+static void reset_marker_reader (jpeg_decompress_struct cinfo) {
+	jpeg_marker_reader marker = cinfo.marker;
+
+	cinfo.comp_info = null;		/* until allocated by get_sof */
+	cinfo.input_scan_number = 0;		/* no SOS seen yet */
+	cinfo.unread_marker = 0;		/* no pending marker */
+	marker.saw_SOI = false;		/* set internal state too */
+	marker.saw_SOF = false;
+	marker.discarded_bytes = 0;
+//	marker.cur_marker = null;
+}
+
+static void reset_input_controller (jpeg_decompress_struct cinfo) {
+	jpeg_input_controller inputctl = cinfo.inputctl;
+
+	inputctl.has_multiple_scans = false; /* "unknown" would be better */
+	inputctl.eoi_reached = false;
+	inputctl.inheaders = true;
+	/* Reset other modules */
+	reset_marker_reader (cinfo);
+	/* Reset progression state -- would be cleaner if entropy decoder did this */
+	cinfo.coef_bits = null;
+}
+
+static void finish_output_pass (jpeg_decompress_struct cinfo) {
+	jpeg_decomp_master master = cinfo.master;
+
+	if (cinfo.quantize_colors) {
+		error(SWT.ERROR_NOT_IMPLEMENTED);
+//		(*cinfo.cquantize.finish_pass) (cinfo);
+	}
+	master.pass_number++;
+}
+
+static void jpeg_destroy (jpeg_decompress_struct cinfo) {
+	/* We need only tell the memory manager to release everything. */
+	/* NB: mem pointer is NULL if memory mgr failed to initialize. */
+//	if (cinfo.mem != NULL)
+//		(*cinfo.mem.self_destruct) (cinfo);
+//	cinfo.mem = NULL;		/* be safe if jpeg_destroy is called twice */
+	cinfo.global_state = 0;	/* mark it destroyed */
+}
+
+static void jpeg_destroy_decompress (jpeg_decompress_struct cinfo) {
+	jpeg_destroy(cinfo); /* use common routine */
+}
+
+static boolean jpeg_input_complete (jpeg_decompress_struct cinfo) {
+	/* Check for valid jpeg object */
+	if (cinfo.global_state < DSTATE_START || cinfo.global_state > DSTATE_STOPPING)
+		error();
+//		ERREXIT1(cinfo, JERR_BAD_STATE, cinfo.global_state);
+	return cinfo.inputctl.eoi_reached;
+}
+
+static boolean jpeg_start_output (jpeg_decompress_struct cinfo, int scan_number) {
+	if (cinfo.global_state != DSTATE_BUFIMAGE && cinfo.global_state != DSTATE_PRESCAN)
+		error();
+//		ERREXIT1(cinfo, JERR_BAD_STATE, cinfo.global_state);
+	/* Limit scan number to valid range */
+	if (scan_number <= 0)
+		scan_number = 1;
+	if (cinfo.inputctl.eoi_reached && scan_number > cinfo.input_scan_number)
+		scan_number = cinfo.input_scan_number;
+	cinfo.output_scan_number = scan_number;
+	/* Perform any dummy output passes, and set up for the real pass */
+	return output_pass_setup(cinfo);
+}
+
+static boolean jpeg_finish_output (jpeg_decompress_struct cinfo) {
+	if ((cinfo.global_state == DSTATE_SCANNING || cinfo.global_state == DSTATE_RAW_OK) && cinfo.buffered_image) {
+		/* Terminate this pass. */
+		/* We do not require the whole pass to have been completed. */
+		finish_output_pass (cinfo);
+		cinfo.global_state = DSTATE_BUFPOST;
+	} else if (cinfo.global_state != DSTATE_BUFPOST) {
+		/* BUFPOST = repeat call after a suspension, anything else is error */
+		error();
+//		ERREXIT1(cinfo, JERR_BAD_STATE, cinfo.global_state);
+	}
+	/* Read markers looking for SOS or EOI */
+	while (cinfo.input_scan_number <= cinfo.output_scan_number && !cinfo.inputctl.eoi_reached) {
+		if (consume_input (cinfo) == JPEG_SUSPENDED)
+			return false;		/* Suspend, come back later */
+	}
+	cinfo.global_state = DSTATE_BUFIMAGE;
+	return true;
+}
+
+static boolean jpeg_finish_decompress (jpeg_decompress_struct cinfo) {
+	if ((cinfo.global_state == DSTATE_SCANNING || cinfo.global_state == DSTATE_RAW_OK) && ! cinfo.buffered_image) {
+		/* Terminate final pass of non-buffered mode */
+		if (cinfo.output_scanline < cinfo.output_height)
+			error();
+//			ERREXIT(cinfo, JERR_TOO_LITTLE_DATA);
+		finish_output_pass (cinfo);
+		cinfo.global_state = DSTATE_STOPPING;
+	} else if (cinfo.global_state == DSTATE_BUFIMAGE) {
+		/* Finishing after a buffered-image operation */
+		cinfo.global_state = DSTATE_STOPPING;
+	} else if (cinfo.global_state != DSTATE_STOPPING) {
+		/* STOPPING = repeat call after a suspension, anything else is error */
+		error();
+//		ERREXIT1(cinfo, JERR_BAD_STATE, cinfo.global_state);
+	}
+	/* Read until EOI */
+	while (! cinfo.inputctl.eoi_reached) {
+		if (consume_input (cinfo) == JPEG_SUSPENDED)
+			return false;		/* Suspend, come back later */
+	}
+	/* Do final cleanup */
+//	(*cinfo.src.term_source) (cinfo);
+	/* We can use jpeg_abort to release memory and reset global_state */
+	jpeg_abort(cinfo);
+	return true;
+}
+
+
+static int jpeg_read_header (jpeg_decompress_struct cinfo, boolean require_image) {
+	int retcode;
+
+	if (cinfo.global_state != DSTATE_START && cinfo.global_state != DSTATE_INHEADER)
+		error();
+//		ERREXIT1(cinfo, JERR_BAD_STATE, cinfo.global_state);
+
+	retcode = jpeg_consume_input(cinfo);
+
+	switch (retcode) {
+		case JPEG_REACHED_SOS:
+			retcode = JPEG_HEADER_OK;
+			break;
+		case JPEG_REACHED_EOI:
+			if (require_image)		/* Complain if application wanted an image */
+				error();
+//				ERREXIT(cinfo, JERR_NO_IMAGE);
+			/* Reset to start state; it would be safer to require the application to
+			 * call jpeg_abort, but we can't change it now for compatibility reasons.
+			 * A side effect is to free any temporary memory (there shouldn't be any).
+			 */
+			jpeg_abort(cinfo); /* sets state = DSTATE_START */
+			retcode = JPEG_HEADER_TABLES_ONLY;
+			break;
+		case JPEG_SUSPENDED:
+			/* no work */
+			break;
+	}
+
+	return retcode;
+}
+
+static int dummy_consume_data (jpeg_decompress_struct cinfo) {
+	return JPEG_SUSPENDED;	/* Always indicate nothing was done */
+}
+
+static int consume_data (jpeg_decompress_struct cinfo) {
+	jpeg_d_coef_controller coef = cinfo.coef;
+	int MCU_col_num;	/* index of current MCU within row */
+	int blkn, ci, xindex, yindex, yoffset;
+	int start_col;
+//	short[][][][] buffer = new short[MAX_COMPS_IN_SCAN][][][];
+	short[][] buffer_ptr;
+	jpeg_component_info compptr;
+
+//	/* Align the virtual buffers for the components used in this scan. */
+//	for (ci = 0; ci < cinfo.comps_in_scan; ci++) {
+//		compptr = cinfo.cur_comp_info[ci];
+//		buffer[ci] = coef.whole_image[compptr.component_index];
+//		/* Note: entropy decoder expects buffer to be zeroed,
+//		 * but this is handled automatically by the memory manager
+//		 * because we requested a pre-zeroed array.
+//		 */
+//	}
+
+	/* Loop to process one whole iMCU row */
+	for (yoffset = coef.MCU_vert_offset; yoffset < coef.MCU_rows_per_iMCU_row; yoffset++) {
+		for (MCU_col_num = coef.MCU_ctr; MCU_col_num < cinfo.MCUs_per_row; MCU_col_num++) {
+			/* Construct list of pointers to DCT blocks belonging to this MCU */
+			blkn = 0; /* index of current DCT block within MCU */
+			for (ci = 0; ci < cinfo.comps_in_scan; ci++) {
+				compptr = cinfo.cur_comp_info[ci];
+				start_col = MCU_col_num * compptr.MCU_width;
+				for (yindex = 0; yindex < compptr.MCU_height; yindex++) {
+//					buffer_ptr = buffer[ci][yindex+yoffset] + start_col;
+					buffer_ptr = coef.whole_image[compptr.component_index][yindex+yoffset+cinfo.input_iMCU_row*compptr.v_samp_factor];
+					int buffer_ptr_offset = start_col;
+					for (xindex = 0; xindex < compptr.MCU_width; xindex++) {
+						coef.MCU_buffer[blkn++] = buffer_ptr[buffer_ptr_offset++];
+					}
+				}
+			}
+			/* Try to fetch the MCU. */
+			if (! cinfo.entropy.decode_mcu (cinfo, coef.MCU_buffer)) {
+				/* Suspension forced; update state counters and exit */
+				coef.MCU_vert_offset = yoffset;
+				coef.MCU_ctr = MCU_col_num;
+				return JPEG_SUSPENDED;
+			}
+		}
+		/* Completed an MCU row, but perhaps not an iMCU row */
+		coef.MCU_ctr = 0;
+	}
+	/* Completed the iMCU row, advance counters for next one */
+	if (++(cinfo.input_iMCU_row) < cinfo.total_iMCU_rows) {
+		coef.start_iMCU_row(cinfo);
+		return JPEG_ROW_COMPLETED;
+	}
+	/* Completed the scan */
+	finish_input_pass (cinfo);
+	return JPEG_SCAN_COMPLETED;
+}
+
+static int consume_input (jpeg_decompress_struct cinfo) {
+	switch (cinfo.inputctl.consume_input) {
+		case COEF_CONSUME_INPUT:
+			 switch (cinfo.coef.consume_data) {
+				case CONSUME_DATA: return consume_data(cinfo);
+				case DUMMY_CONSUME_DATA: return dummy_consume_data(cinfo);
+				default: error();
+			 }
+			 break;
+		case INPUT_CONSUME_INPUT:
+			return consume_markers(cinfo);
+		default:
+			error();
+	}
+	return 0;	
+}
+
+static boolean fill_input_buffer(jpeg_decompress_struct cinfo) {
+	try {
+		InputStream inputStream = cinfo.inputStream;
+		int nbytes = inputStream.read(cinfo.buffer);
+		if (nbytes <= 0) {
+			if (cinfo.start_of_file)	/* Treat empty input file as fatal error */
+				error();
+//				ERREXIT(cinfo, JERR_INPUT_EMPTY);
+//			WARNMS(cinfo, JWRN_JPEG_EOF);
+			/* Insert a fake EOI marker */
+			cinfo.buffer[0] = (byte)0xFF;
+			cinfo.buffer[1] = (byte)M_EOI;
+			nbytes = 2;
+		}
+		cinfo.bytes_in_buffer = nbytes;
+		cinfo.bytes_offset = 0;
+		cinfo.start_of_file = false;
+	} catch (IOException e) {
+		error(SWT.ERROR_IO);
+		return false;
+	}
+	return true;
+}
+
+static boolean first_marker (jpeg_decompress_struct cinfo) {
+	/* Like next_marker, but used to obtain the initial SOI marker. */
+	/* For this marker, we do not allow preceding garbage or fill; otherwise,
+	 * we might well scan an entire input file before realizing it ain't JPEG.
+	 * If an application wants to process non-JFIF files, it must seek to the
+	 * SOI before calling the JPEG library.
+	 */
+	int c, c2;
+
+	if (cinfo.bytes_offset == cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+	c = cinfo.buffer[cinfo.bytes_offset++] & 0xFF;
+	if (cinfo.bytes_offset == cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+	c2 = cinfo.buffer[cinfo.bytes_offset++] & 0xFF;
+	if (c != 0xFF || c2 != M_SOI)
+		error();
+//		ERREXIT2(cinfo, JERR_NO_SOI, c, c2);
+
+	cinfo.unread_marker = c2;
+
+	return true;
+}
+
+static boolean next_marker (jpeg_decompress_struct cinfo) {
+	int c;
+
+	for (;;) {
+		if (cinfo.bytes_offset == cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+		c = cinfo.buffer[cinfo.bytes_offset++] & 0xFF;
+		/* Skip any non-FF bytes.
+		 * This may look a bit inefficient, but it will not occur in a valid file.
+		 * We sync after each discarded byte so that a suspending data source
+		 * can discard the byte from its buffer.
+		 */
+		while (c != 0xFF) {
+			cinfo.marker.discarded_bytes++;
+			if (cinfo.bytes_offset == cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+			c = cinfo.buffer[cinfo.bytes_offset++] & 0xFF;
+		}
+		/* This loop swallows any duplicate FF bytes.	Extra FFs are legal as
+		 * pad bytes, so don't count them in discarded_bytes.	We assume there
+		 * will not be so many consecutive FF bytes as to overflow a suspending
+		 * data source's input buffer.
+		 */
+		do {
+			 if (cinfo.bytes_offset == cinfo.bytes_in_buffer) fill_input_buffer(cinfo);
+				c = cinfo.buffer[cinfo.bytes_offset++] & 0xFF;
+		} while (c == 0xFF);
+		if (c != 0)
+			break;			/* found a valid marker, exit loop */
+		/* Reach here if we found a stuffed-zero data sequence (FF/00).
+		 * Discard it and loop back to try again.
+		 */
+		cinfo.marker.discarded_bytes += 2;
+	}
+
+	if (cinfo.marker.discarded_bytes != 0) {
+//		WARNMS2(cinfo, JWRN_EXTRANEOUS_DATA, cinfo.marker.discarded_bytes, c);
+		cinfo.marker.discarded_bytes = 0;
+	}
+
+	cinfo.unread_marker = c;
+
+	return true;
+}
+
+static int read_markers (jpeg_decompress_struct cinfo) {
+	/* Outer loop repeats once for each marker. */
+	for (;;) {
+		/* Collect the marker proper, unless we already did. */
+		/* NB: first_marker() enforces the requirement that SOI appear first. */
+		if (cinfo.unread_marker == 0) {
+			if (! cinfo.marker.saw_SOI) {
+				if (! first_marker(cinfo))
+					return JPEG_SUSPENDED;
+				} else {
+					if (! next_marker(cinfo))
+						return JPEG_SUSPENDED;
+				}
+		}
+		/* At this point cinfo.unread_marker contains the marker code and the
+		 * input point is just past the marker proper, but before any parameters.
+		 * A suspension will cause us to return with this state still true.
+		 */
+		switch (cinfo.unread_marker) {
+			case M_SOI:
+				if (! get_soi(cinfo))
+					return JPEG_SUSPENDED;
+				break;
+
+			case M_SOF0:		/* Baseline */
+			case M_SOF1:		/* Extended sequential, Huffman */
+				if (! get_sof(cinfo, false, false))
+					return JPEG_SUSPENDED;
+				break;
+
+			case M_SOF2:		/* Progressive, Huffman */
+				if (! get_sof(cinfo, true, false))
+					return JPEG_SUSPENDED;
+				break;
+
+			case M_SOF9:		/* Extended sequential, arithmetic */
+				if (! get_sof(cinfo, false, true))
+					return JPEG_SUSPENDED;
+				break;
+
+			case M_SOF10:		/* Progressive, arithmetic */
+				if (! get_sof(cinfo, true, true))
+					return JPEG_SUSPENDED;
+				break;
+
+			/* Currently unsupported SOFn types */
+			case M_SOF3:		/* Lossless, Huffman */
+			case M_SOF5:		/* Differential sequential, Huffman */
+			case M_SOF6:		/* Differential progressive, Huffman */
+			case M_SOF7:		/* Differential lossless, Huffman */
+			case M_JPG:			/* Reserved for JPEG extensions */
+			case M_SOF11:		/* Lossless, arithmetic */
+			case M_SOF13:		/* Differential sequential, arithmetic */
+			case M_SOF14:		/* Differential progressive, arithmetic */
+			case M_SOF15:		/* Differential lossless, arithmetic */
+				error();
+//				ERREXIT1(cinfo, JERR_SOF_UNSUPPORTED, cinfo.unread_marker);
+				break;
+
+			case M_SOS:
+				if (! get_sos(cinfo))
+					return JPEG_SUSPENDED;
+				cinfo.unread_marker = 0;	/* processed the marker */
+				return JPEG_REACHED_SOS;
+	
+			case M_EOI:
+//				TRACEMS(cinfo, 1, JTRC_EOI);
+				cinfo.unread_marker = 0;	/* processed the marker */
+				return JPEG_REACHED_EOI;
+		
+			case M_DAC:
+				if (! get_dac(cinfo))
+					return JPEG_SUSPENDED;
+				break;
+		
+			case M_DHT:
+				if (! get_dht(cinfo))
+					return JPEG_SUSPENDED;
+				break;
+		
+			case M_DQT:
+				if (! get_dqt(cinfo))
+					return JPEG_SUSPENDED;
+				break;
+		
+			case M_DRI:
+				if (! get_dri(cinfo))
+					return JPEG_SUSPENDED;
+				break;
+		
+			case M_APP0:
+			case M_APP1:
+			case M_APP2:
+			case M_APP3:
+			case M_APP4:
+			case M_APP5:
+			case M_APP6:
+			case M_APP7:
+			case M_APP8:
+			case M_APP9:
+			case M_APP10:
+			case M_APP11:
+			case M_APP12:
+			case M_APP13:
+			case M_APP14:
+			case M_APP15:
+				if (! process_APPn(cinfo.unread_marker - M_APP0, cinfo))
+					return JPEG_SUSPENDED;
+				break;
+		
+			case M_COM:
+				if (! process_COM(cinfo))
+					return JPEG_SUSPENDED;
+				break;
+
+			case M_RST0:		/* these are all parameterless */
+			case M_RST1:
+			case M_RST2:
+			case M_RST3:
+			case M_RST4:
+			case M_RST5:
+			case M_RST6:
+			case M_RST7:
+			case M_TEM:
+//				TRACEMS1(cinfo, 1, JTRC_PARMLESS_MARKER, cinfo.unread_marker);
+				break;
+
+			case M_DNL:			/* Ignore DNL ... perhaps the wrong thing */
+				if (! skip_variable(cinfo))
+					return JPEG_SUSPENDED;
+				break;
+
+			default:			/* must be DHP, EXP, JPGn, or RESn */
+				/* For now, we treat the reserved markers as fatal errors since they are
+				 * likely to be used to signal incompatible JPEG Part 3 extensions.
+				 * Once the JPEG 3 version-number marker is well defined, this code
+				 * ought to change!
+				 */
+				error();
+ //		 		ERREXIT1(cinfo, JERR_UNKNOWN_MARKER, cinfo.unread_marker);
+				break;
+		}
+		/* Successfully processed marker, so reset state variable */
+		cinfo.unread_marker = 0;
+	} /* end loop */
+}
+
+static long jdiv_round_up (long a, long b)
+/* Compute a/b rounded up to next integer, ie, ceil(a/b) */
+/* Assumes a >= 0, b > 0 */
+{
+	return (a + b - 1) / b;
+}
+
+static void initial_setup (jpeg_decompress_struct cinfo)
+/* Called once, when first SOS marker is reached */
+{
+	int ci;
+	jpeg_component_info compptr;
+
+	/* Make sure image isn't bigger than I can handle */
+	if (cinfo.image_height >	JPEG_MAX_DIMENSION || cinfo.image_width > JPEG_MAX_DIMENSION)
+		error();
+//		ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, (unsigned int) JPEG_MAX_DIMENSION);
+
+	/* For now, precision must match compiled-in value... */
+	if (cinfo.data_precision != BITS_IN_JSAMPLE)
+		error(" [data precision=" + cinfo.data_precision + "]");
+//		ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo.data_precision);
+
+	/* Check that number of components won't exceed internal array sizes */
+	if (cinfo.num_components > MAX_COMPONENTS)
+		error();
+//		ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo.num_components, MAX_COMPONENTS);
+
+	/* Compute maximum sampling factors; check factor validity */
+	cinfo.max_h_samp_factor = 1;
+	cinfo.max_v_samp_factor = 1;
+	for (ci = 0; ci < cinfo.num_components; ci++) {
+		compptr = cinfo.comp_info[ci];
+		if (compptr.h_samp_factor<=0 || compptr.h_samp_factor>MAX_SAMP_FACTOR || compptr.v_samp_factor<=0 || compptr.v_samp_factor>MAX_SAMP_FACTOR)
+			error();
+//			ERREXIT(cinfo, JERR_BAD_SAMPLING);
+		cinfo.max_h_samp_factor = Math.max(cinfo.max_h_samp_factor, compptr.h_samp_factor);
+		cinfo.max_v_samp_factor = Math.max(cinfo.max_v_samp_factor, compptr.v_samp_factor);
+	}
+
+	/* We initialize DCT_scaled_size and min_DCT_scaled_size to DCTSIZE.
+	 * In the full decompressor, this will be overridden by jdmaster.c;
+	 * but in the transcoder, jdmaster.c is not used, so we must do it here.
+	 */
+	cinfo.min_DCT_scaled_size = DCTSIZE;
+
+	/* Compute dimensions of components */
+	for (ci = 0; ci < cinfo.num_components; ci++) {
+		compptr = cinfo.comp_info[ci];
+		compptr.DCT_scaled_size = DCTSIZE;
+		/* Size in DCT blocks */
+		compptr.width_in_blocks = (int)jdiv_round_up((long) cinfo.image_width * (long) compptr.h_samp_factor, (cinfo.max_h_samp_factor * DCTSIZE));
+		compptr.height_in_blocks = (int)jdiv_round_up((long) cinfo.image_height * (long) compptr.v_samp_factor, (cinfo.max_v_samp_factor * DCTSIZE));
+		/* downsampled_width and downsampled_height will also be overridden by
+		 * jdmaster.c if we are doing full decompression.	The transcoder library
+		 * doesn't use these values, but the calling application might.
+		 */
+		/* Size in samples */
+		compptr.downsampled_width = (int)jdiv_round_up((long) cinfo.image_width * (long) compptr.h_samp_factor,	cinfo.max_h_samp_factor);
+		compptr.downsampled_height = (int)jdiv_round_up((long) cinfo.image_height * (long) compptr.v_samp_factor, cinfo.max_v_samp_factor);
+		/* Mark component needed, until color conversion says otherwise */
+		compptr.component_needed = true;
+		/* Mark no quantization table yet saved for component */
+		compptr.quant_table = null;
+	}
+
+	/* Compute number of fully interleaved MCU rows. */
+	cinfo.total_iMCU_rows = (int)jdiv_round_up( cinfo.image_height, (cinfo.max_v_samp_factor*DCTSIZE));
+
+	/* Decide whether file contains multiple scans */
+	if (cinfo.comps_in_scan < cinfo.num_components || cinfo.progressive_mode)
+		cinfo.inputctl.has_multiple_scans = true;
+	else
+		cinfo.inputctl.has_multiple_scans = false;
+}
+
+
+static void per_scan_setup (jpeg_decompress_struct cinfo)
+/* Do computations that are needed before processing a JPEG scan */
+/* cinfo.comps_in_scan and cinfo.cur_comp_info[] were set from SOS marker */
+{
+	int ci, mcublks, tmp = 0;
+	jpeg_component_info compptr;
+	
+	if (cinfo.comps_in_scan == 1) {
+		
+		/* Noninterleaved (single-component) scan */
+		compptr = cinfo.cur_comp_info[0];
+		
+		/* Overall image size in MCUs */
+		cinfo.MCUs_per_row = compptr.width_in_blocks;
+		cinfo.MCU_rows_in_scan = compptr.height_in_blocks;
+		
+		/* For noninterleaved scan, always one block per MCU */
+		compptr.MCU_width = 1;
+		compptr.MCU_height = 1;
+		compptr.MCU_blocks = 1;
+		compptr.MCU_sample_width = compptr.DCT_scaled_size;
+		compptr.last_col_width = 1;
+		/* For noninterleaved scans, it is convenient to define last_row_height
+		 * as the number of block rows present in the last iMCU row.
+		 */
+		tmp = (compptr.height_in_blocks % compptr.v_samp_factor);
+		if (tmp == 0) tmp = compptr.v_samp_factor;
+		compptr.last_row_height = tmp;
+		
+		/* Prepare array describing MCU composition */
+		cinfo.blocks_in_MCU = 1;
+		cinfo.MCU_membership[0] = 0;
+		
+	} else {
+		
+		/* Interleaved (multi-component) scan */
+		if (cinfo.comps_in_scan <= 0 || cinfo.comps_in_scan > MAX_COMPS_IN_SCAN)
+			error();
+//			ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo.comps_in_scan, MAX_COMPS_IN_SCAN);
+		
+		/* Overall image size in MCUs */
+		cinfo.MCUs_per_row = (int)jdiv_round_up( cinfo.image_width, (cinfo.max_h_samp_factor*DCTSIZE));
+		cinfo.MCU_rows_in_scan = (int)jdiv_round_up( cinfo.image_height, (cinfo.max_v_samp_factor*DCTSIZE));
+		
+		cinfo.blocks_in_MCU = 0;
+		
+		for (ci = 0; ci < cinfo.comps_in_scan; ci++) {
+			compptr = cinfo.cur_comp_info[ci];
+			/* Sampling factors give # of blocks of component in each MCU */
+			compptr.MCU_width = compptr.h_samp_factor;
+			compptr.MCU_height = compptr.v_samp_factor;
+			compptr.MCU_blocks = compptr.MCU_width * compptr.MCU_height;
+			compptr.MCU_sample_width = compptr.MCU_width * compptr.DCT_scaled_size;
+			/* Figure number of non-dummy blocks in last MCU column & row */
+			tmp = (compptr.width_in_blocks % compptr.MCU_width);
+			if (tmp == 0) tmp = compptr.MCU_width;
+			compptr.last_col_width = tmp;
+			tmp = (compptr.height_in_blocks % compptr.MCU_height);
+			if (tmp == 0) tmp = compptr.MCU_height;
+			compptr.last_row_height = tmp;
+			/* Prepare array describing MCU composition */
+			mcublks = compptr.MCU_blocks;
+			if (cinfo.blocks_in_MCU + mcublks > D_MAX_BLOCKS_IN_MCU)
+				error();
+//	ERREXIT(cinfo, JERR_BAD_MCU_SIZE);
+			while (mcublks-- > 0) {
+				cinfo.MCU_membership[cinfo.blocks_in_MCU++] = ci;
+			}
+		}
+		
+	}
+}
+
+static void latch_quant_tables (jpeg_decompress_struct cinfo) {
+	int ci, qtblno;
+	jpeg_component_info compptr;
+	JQUANT_TBL qtbl;
+
+	for (ci = 0; ci < cinfo.comps_in_scan; ci++) {
+		compptr = cinfo.cur_comp_info[ci];
+		/* No work if we already saved Q-table for this component */
+		if (compptr.quant_table != null)
+			continue;
+		/* Make sure specified quantization table is present */
+		qtblno = compptr.quant_tbl_no;
+		if (qtblno < 0 || qtblno >= NUM_QUANT_TBLS || cinfo.quant_tbl_ptrs[qtblno] == null)
+			error();
+//			ERREXIT1(cinfo, JERR_NO_QUANT_TABLE, qtblno);
+		/* OK, save away the quantization table */
+		qtbl = new JQUANT_TBL();
+		System.arraycopy(cinfo.quant_tbl_ptrs[qtblno].quantval, 0, qtbl.quantval, 0, qtbl.quantval.length);
+		qtbl.sent_table = cinfo.quant_tbl_ptrs[qtblno].sent_table;
+		compptr.quant_table = qtbl;
+	}
+}
+
+static void jpeg_make_d_derived_tbl (jpeg_decompress_struct cinfo, boolean isDC, int tblno, d_derived_tbl dtbl) {
+	JHUFF_TBL htbl;
+	int p, i = 0, l, si, numsymbols;
+	int lookbits, ctr;
+	byte[] huffsize = new byte[257];
+	int[] huffcode = new int[257];
+	int code;
+
+	/* Note that huffsize[] and huffcode[] are filled in code-length order,
+	 * paralleling the order of the symbols themselves in htbl.huffval[].
+	 */
+
+	/* Find the input Huffman table */
+	if (tblno < 0 || tblno >= NUM_HUFF_TBLS)
+		error();
+//		ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, tblno);
+	htbl = isDC ? cinfo.dc_huff_tbl_ptrs[tblno] : cinfo.ac_huff_tbl_ptrs[tblno];
+	if (htbl == null)
+		error();
+//		ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, tblno);
+
+	/* Allocate a workspace if we haven't already done so. */
+	dtbl.pub = htbl;		/* fill in back link */
+	
+	/* Figure C.1: make table of Huffman code length for each symbol */
+
+	p = 0;
+	for (l = 1; l <= 16; l++) {
+		i = htbl.bits[l] & 0xFF;
+		if (i < 0 || p + i > 256)	/* protect against table overrun */
+			error();
+//			ERREXIT(cinfo, JERR_BAD_HUFF_TABLE);
+		while (i-- != 0)
+			huffsize[p++] = (byte) l;
+	}
+	huffsize[p] = 0;
+	numsymbols = p;
+	
+	/* Figure C.2: generate the codes themselves */
+	/* We also validate that the counts represent a legal Huffman code tree. */
+	
+	code = 0;
+	si = huffsize[0];
+	p = 0;
+	while ((huffsize[p]) != 0) {
+		while (( huffsize[p]) == si) {
+			huffcode[p++] = code;
+			code++;
+		}
+		/* code is now 1 more than the last code used for codelength si; but
+		 * it must still fit in si bits, since no code is allowed to be all ones.
+		 */
+		if (( code) >= (( 1) << si))
+			error();
+//			ERREXIT(cinfo, JERR_BAD_HUFF_TABLE);
+		code <<= 1;
+		si++;
+	}
+
+	/* Figure F.15: generate decoding tables for bit-sequential decoding */
+
+	p = 0;
+	for (l = 1; l <= 16; l++) {
+		if ((htbl.bits[l] & 0xFF) != 0) {
+			/* valoffset[l] = huffval[] index of 1st symbol of code length l,
+			 * minus the minimum code of length l
+			 */
+			dtbl.valoffset[l] =	p -	huffcode[p];
+			p += (htbl.bits[l] & 0xFF);
+			dtbl.maxcode[l] = huffcode[p-1]; /* maximum code of length l */
+		} else {
+			dtbl.maxcode[l] = -1;	/* -1 if no codes of this length */
+		}
+	}
+	dtbl.maxcode[17] = 0xFFFFF; /* ensures jpeg_huff_decode terminates */
+
+	/* Compute lookahead tables to speed up decoding.
+	 * First we set all the table entries to 0, indicating "too long";
+	 * then we iterate through the Huffman codes that are short enough and
+	 * fill in all the entries that correspond to bit sequences starting
+	 * with that code.
+	 */
+
+	for (int j = 0; j < dtbl.look_nbits.length; j++) {
+		dtbl.look_nbits[j] = 0;
+	}
+
+	p = 0;
+	for (l = 1; l <= HUFF_LOOKAHEAD; l++) {
+		for (i = 1; i <= (htbl.bits[l] & 0xFF); i++, p++) {
+			/* l = current code's length, p = its index in huffcode[] & huffval[]. */
+			/* Generate left-justified code followed by all possible bit sequences */
+			lookbits = huffcode[p] << (HUFF_LOOKAHEAD-l);
+			for (ctr = 1 << (HUFF_LOOKAHEAD-l); ctr > 0; ctr--) {
+				dtbl.look_nbits[lookbits] = l;
+				dtbl.look_sym[lookbits] = htbl.huffval[p];
+				lookbits++;
+			}
+		}
+	}
+
+	/* Validate symbols as being reasonable.
+	 * For AC tables, we make no check, but accept all byte values 0..255.
+	 * For DC tables, we require the symbols to be in range 0..15.
+	 * (Tighter bounds could be applied depending on the data depth and mode,
+	 * but this is sufficient to ensure safe decoding.)
+	 */
+	if (isDC) {
+		for (i = 0; i < numsymbols; i++) {
+			int sym = htbl.huffval[i] & 0xFF;
+			if (sym < 0 || sym > 15)
+				error();
+//				ERREXIT(cinfo, JERR_BAD_HUFF_TABLE);
+		}
+	}
+}
+
+static void start_input_pass (jpeg_decompress_struct cinfo) {
+	per_scan_setup(cinfo);
+	latch_quant_tables(cinfo);
+	cinfo.entropy.start_pass(cinfo);
+	cinfo.coef.start_input_pass (cinfo);
+	cinfo.inputctl.consume_input = COEF_CONSUME_INPUT;
+}
+
+static void finish_input_pass (jpeg_decompress_struct cinfo) {
+	cinfo.inputctl.consume_input = INPUT_CONSUME_INPUT;
+}
+
+static int consume_markers (jpeg_decompress_struct cinfo) {
+	jpeg_input_controller inputctl = cinfo.inputctl;
+	int val;
+
+	if (inputctl.eoi_reached) /* After hitting EOI, read no further */
+		return JPEG_REACHED_EOI;
+
+	val = read_markers (cinfo);
+
+	switch (val) {
+	case JPEG_REACHED_SOS:	/* Found SOS */
+		if (inputctl.inheaders) {	/* 1st SOS */
+			initial_setup(cinfo);
+			inputctl.inheaders = false;
+			/* Note: start_input_pass must be called by jdmaster.c
+			 * before any more input can be consumed.	jdapimin.c is
+			 * responsible for enforcing this sequencing.
+			 */
+		} else {			/* 2nd or later SOS marker */
+			if (! inputctl.has_multiple_scans)
+				error();
+//				ERREXIT(cinfo, JERR_EOI_EXPECTED); /* Oops, I wasn't expecting this! */
+			start_input_pass(cinfo);
+		}
+		break;
+	case JPEG_REACHED_EOI:	/* Found EOI */
+		inputctl.eoi_reached = true;
+		if (inputctl.inheaders) {	/* Tables-only datastream, apparently */
+			if (cinfo.marker.saw_SOF)
+				error();
+//				ERREXIT(cinfo, JERR_SOF_NO_SOS);
+		} else {
+			/* Prevent infinite loop in coef ctlr's decompress_data routine
+			 * if user set output_scan_number larger than number of scans.
+			 */
+			if (cinfo.output_scan_number > cinfo.input_scan_number)
+				cinfo.output_scan_number = cinfo.input_scan_number;
+		}
+		break;
+	case JPEG_SUSPENDED:
+		break;
+	}
+
+	return val;
+}
+
+static void default_decompress_parms (jpeg_decompress_struct cinfo) {
+	/* Guess the input colorspace, and set output colorspace accordingly. */
+	/* (Wish JPEG committee had provided a real way to specify this...) */
+	/* Note application may override our guesses. */
+	switch (cinfo.num_components) {
+		case 1:
+			cinfo.jpeg_color_space = JCS_GRAYSCALE;
+			cinfo.out_color_space = JCS_GRAYSCALE;
+			break;
+			
+		case 3:
+			if (cinfo.saw_JFIF_marker) {
+				cinfo.jpeg_color_space = JCS_YCbCr; /* JFIF implies YCbCr */
+			} else if (cinfo.saw_Adobe_marker) {
+				switch (cinfo.Adobe_transform) {
+					case 0:
+						cinfo.jpeg_color_space = JCS_RGB;
+						break;
+					case 1:
+						cinfo.jpeg_color_space = JCS_YCbCr;
+						break;
+					default:	
+//						WARNMS1(cinfo, JWRN_ADOBE_XFORM, cinfo.Adobe_transform);
+						cinfo.jpeg_color_space = JCS_YCbCr; /* assume it's YCbCr */
+					break;
+				}
+			} else {
+				/* Saw no special markers, try to guess from the component IDs */
+				int cid0 = cinfo.comp_info[0].component_id;
+				int cid1 = cinfo.comp_info[1].component_id;
+				int cid2 = cinfo.comp_info[2].component_id;
+	
+				if (cid0 == 1 && cid1 == 2 && cid2 == 3)
+					cinfo.jpeg_color_space = JCS_YCbCr; /* assume JFIF w/out marker */
+				else if (cid0 == 82 && cid1 == 71 && cid2 == 66)
+					cinfo.jpeg_color_space = JCS_RGB; /* ASCII 'R', 'G', 'B' */
+				else {
+//					TRACEMS3(cinfo, 1, JTRC_UNKNOWN_IDS, cid0, cid1, cid2);
+					cinfo.jpeg_color_space = JCS_YCbCr; /* assume it's YCbCr */
+				}
+			}
+			/* Always guess RGB is proper output colorspace. */
+			cinfo.out_color_space = JCS_RGB;
+			break;
+			
+		case 4:
+			if (cinfo.saw_Adobe_marker) {
+				switch (cinfo.Adobe_transform) {
+					case 0:
+						cinfo.jpeg_color_space = JCS_CMYK;
+						break;
+					case 2:
+						cinfo.jpeg_color_space = JCS_YCCK;
+						break;
+					default:
+//						WARNMS1(cinfo, JWRN_ADOBE_XFORM, cinfo.Adobe_transform);
+						cinfo.jpeg_color_space = JCS_YCCK; /* assume it's YCCK */
+						break;
+				}
+			} else {
+				/* No special markers, assume straight CMYK. */
+				cinfo.jpeg_color_space = JCS_CMYK;
+			}
+			cinfo.out_color_space = JCS_CMYK;
+			break;
+			
+		default:
+			cinfo.jpeg_color_space = JCS_UNKNOWN;
+			cinfo.out_color_space = JCS_UNKNOWN;
+			break;
+	}
+
+	/* Set defaults for other decompression parameters. */
+	cinfo.scale_num = 1;		/* 1:1 scaling */
+	cinfo.scale_denom = 1;
+	cinfo.output_gamma = 1.0;
+	cinfo.buffered_image = false;
+	cinfo.raw_data_out = false;
+	cinfo.dct_method = JDCT_DEFAULT;
+	cinfo.do_fancy_upsampling = true;
+	cinfo.do_block_smoothing = true;
+	cinfo.quantize_colors = false;
+	/* We set these in case application only sets quantize_colors. */
+	cinfo.dither_mode = JDITHER_FS;
+	cinfo.two_pass_quantize = true;
+	cinfo.desired_number_of_colors = 256;
+	cinfo.colormap = null;
+	/* Initialize for no mode change in buffered-image mode. */
+	cinfo.enable_1pass_quant = false;
+	cinfo.enable_external_quant = false;
+	cinfo.enable_2pass_quant = false;
+}
+
+static void init_source(jpeg_decompress_struct cinfo) {
+	cinfo.buffer = new byte[INPUT_BUFFER_SIZE];
+	cinfo.bytes_in_buffer = 0;
+	cinfo.bytes_offset = 0;
+	cinfo.start_of_file = true;
+}
+
+static int jpeg_consume_input (jpeg_decompress_struct cinfo) {
+	int retcode = JPEG_SUSPENDED;
+
+	/* NB: every possible DSTATE value should be listed in this switch */
+	switch (cinfo.global_state) {
+	case DSTATE_START:
+		/* Start-of-datastream actions: reset appropriate modules */
+		reset_input_controller(cinfo);
+		/* Initialize application's data source module */
+		init_source (cinfo);
+		cinfo.global_state = DSTATE_INHEADER;
+		/*FALLTHROUGH*/
+	case DSTATE_INHEADER:
+		retcode = consume_input(cinfo);
+		if (retcode == JPEG_REACHED_SOS) { /* Found SOS, prepare to decompress */
+			/* Set up default parameters based on header data */
+			default_decompress_parms(cinfo);
+			/* Set global state: ready for start_decompress */
+			cinfo.global_state = DSTATE_READY;
+		}
+		break;
+	case DSTATE_READY:
+		/* Can't advance past first SOS until start_decompress is called */
+		retcode = JPEG_REACHED_SOS;
+		break;
+	case DSTATE_PRELOAD:
+	case DSTATE_PRESCAN:
+	case DSTATE_SCANNING:
+	case DSTATE_RAW_OK:
+	case DSTATE_BUFIMAGE:
+	case DSTATE_BUFPOST:
+	case DSTATE_STOPPING:
+		retcode = consume_input (cinfo);
+		break;
+	default:
+		error();
+//		ERREXIT1(cinfo, JERR_BAD_STATE, cinfo.global_state);
+	}
+	return retcode;
+}
+
+
+static void jpeg_abort (jpeg_decompress_struct cinfo) {
+//	int pool;
+//
+//	/* Releasing pools in reverse order might help avoid fragmentation
+//	 * with some (brain-damaged) malloc libraries.
+//	 */
+//	for (pool = JPOOL_NUMPOOLS-1; pool > JPOOL_PERMANENT; pool--) {
+//		(*cinfo.mem.free_pool) (cinfo, pool);
+//	}
+
+	/* Reset overall state for possible reuse of object */
+	if (cinfo.is_decompressor) {
+		cinfo.global_state = DSTATE_START;
+		/* Try to keep application from accessing now-deleted marker list.
+		 * A bit kludgy to do it here, but this is the most central place.
+		 */
+//		((j_decompress_ptr) cinfo).marker_list = null;
+	} else {
+		cinfo.global_state = CSTATE_START;
+	}
+}
+
+
+static boolean isFileFormat(LEDataInputStream stream) {
+	try {
+		byte[] buffer = new byte[2];
+		stream.read(buffer);
+		stream.unread(buffer);
+		return (buffer[0] & 0xFF) == 0xFF && (buffer[1] & 0xFF) == M_SOI;
+	} catch (Exception e) {
+		return false;
+	}
+}
+	
+static ImageData[] loadFromByteStream(InputStream inputStream, ImageLoader loader) {
+	jpeg_decompress_struct cinfo = new jpeg_decompress_struct();
+	cinfo.inputStream = inputStream;
+	jpeg_create_decompress(cinfo);
+	jpeg_read_header(cinfo, true);
+	cinfo.buffered_image = cinfo.progressive_mode && loader.hasListeners();
+	jpeg_start_decompress(cinfo);
+	PaletteData palette = null;
+	switch (cinfo.out_color_space) {
+		case JCS_RGB:
+			palette = new PaletteData(0xFF, 0xFF00, 0xFF0000);
+			break;
+		case JCS_GRAYSCALE:
+			RGB[] colors = new RGB[256];
+			for (int i = 0; i < colors.length; i++) {
+				colors[i] = new RGB(i, i, i);
+			}
+			palette = new PaletteData(colors);
+			break;
+		default:
+			error();
+	}
+	int scanlinePad = 4;
+	int row_stride = (((cinfo.output_width * cinfo.out_color_components * 8 + 7) / 8) + (scanlinePad - 1)) / scanlinePad * scanlinePad;
+	byte[][] buffer = new byte[1][row_stride];
+	byte[] data = new byte[row_stride * cinfo.output_height];
+	ImageData imageData = ImageData.internal_new(
+			cinfo.output_width, cinfo.output_height, palette.isDirect ? 24 : 8, palette, scanlinePad, data,
+			0, null, null, -1, -1, SWT.IMAGE_JPEG, 0, 0, 0, 0);
+	if (cinfo.buffered_image) {
+		boolean done;
+		do {
+			int incrementCount = cinfo.input_scan_number - 1;
+			jpeg_start_output(cinfo, cinfo.input_scan_number);
+			while (cinfo.output_scanline < cinfo.output_height) {
+				int offset = row_stride * cinfo.output_scanline;
+				jpeg_read_scanlines(cinfo, buffer, 1);
+				System.arraycopy(buffer[0], 0, data, offset, row_stride);
+			}
+			jpeg_finish_output(cinfo);
+			loader.notifyListeners(new ImageLoaderEvent(loader, (ImageData)imageData.clone(), incrementCount, done = jpeg_input_complete(cinfo)));
+		} while (!done);
+	} else {
+		while (cinfo.output_scanline < cinfo.output_height) {
+			int offset = row_stride * cinfo.output_scanline;
+			jpeg_read_scanlines(cinfo, buffer, 1);
+			System.arraycopy(buffer[0], 0, data, offset, row_stride);
+		}
+	}
+	jpeg_finish_decompress(cinfo);
+	jpeg_destroy_decompress(cinfo);
+	return new ImageData[]{imageData};
+}
+
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/JPEGDecoder.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/JPEGEndOfImage.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/JPEGEndOfImage.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/JPEGEndOfImage.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.image;
+
+
+final class JPEGEndOfImage extends JPEGFixedSizeSegment {
+
+	public JPEGEndOfImage() {
+		super();
+	}
+	
+	public JPEGEndOfImage(byte[] reference) {
+		super(reference);
+	}
+	
+	public int signature() {
+		return JPEGFileFormat.EOI;
+	}
+	
+	public int fixedSize() {
+		return 2;
+	}
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/JPEGEndOfImage.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/JPEGFileFormat.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/JPEGFileFormat.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/JPEGFileFormat.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,1882 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved.  This source file is made available under the terms contained in the README file
+ * accompanying this program.  The README file should be located in the about_files directory of the
+ * plug-in that contains this source file.
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.image;
+
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import java.io.*;
+
+public final class JPEGFileFormat extends FileFormat {
+	int restartInterval;
+	JPEGFrameHeader frameHeader;
+	int imageWidth, imageHeight;
+	int interleavedMcuCols, interleavedMcuRows;
+	int maxV, maxH;
+	boolean progressive;
+	int samplePrecision;
+	int nComponents;
+	int[][] frameComponents;
+	int[] componentIds;
+	byte[][] imageComponents;
+	int[] dataUnit;
+	int[][][] dataUnits;
+	int[] precedingDCs;
+	JPEGScanHeader scanHeader;
+	byte[] dataBuffer;
+	int currentBitCount;
+	int bufferCurrentPosition;
+	int restartsToGo;
+	int nextRestartNumber;
+	JPEGHuffmanTable[] acHuffmanTables;
+	JPEGHuffmanTable[] dcHuffmanTables;
+	int[][] quantizationTables;
+	int currentByte;
+	int encoderQFactor = 75;
+	int eobrun = 0;
+	/* JPEGConstants */
+	public static final int DCTSIZE = 8;
+	public static final int DCTSIZESQR = 64;
+	/* JPEGFixedPointConstants */
+	public static final int FIX_0_899976223 = 7373;
+	public static final int FIX_1_961570560 = 16069;
+	public static final int FIX_2_053119869 = 16819;
+	public static final int FIX_0_298631336 = 2446;
+	public static final int FIX_1_847759065 = 15137;
+	public static final int FIX_1_175875602 = 9633;
+	public static final int FIX_3_072711026 = 25172;
+	public static final int FIX_0_765366865 = 6270;
+	public static final int FIX_2_562915447 = 20995;
+	public static final int FIX_0_541196100 = 4433;
+	public static final int FIX_0_390180644 = 3196;
+	public static final int FIX_1_501321110 = 12299;
+	/* JPEGMarkerCodes */
+	public static final int APP0  = 0xFFE0;
+	public static final int APP15 = 0xFFEF;
+	public static final int COM   = 0xFFFE;
+	public static final int DAC   = 0xFFCC;
+	public static final int DHP   = 0xFFDE;
+	public static final int DHT   = 0xFFC4;
+	public static final int DNL   = 0xFFDC;
+	public static final int DRI   = 0xFFDD;
+	public static final int DQT   = 0xFFDB;
+	public static final int EOI   = 0xFFD9;
+	public static final int EXP   = 0xFFDF;
+	public static final int JPG   = 0xFFC8;
+	public static final int JPG0  = 0xFFF0;
+	public static final int JPG13 = 0xFFFD;
+	public static final int RST0  = 0xFFD0;
+	public static final int RST1  = 0xFFD1;
+	public static final int RST2  = 0xFFD2;
+	public static final int RST3  = 0xFFD3;
+	public static final int RST4  = 0xFFD4;
+	public static final int RST5  = 0xFFD5;
+	public static final int RST6  = 0xFFD6;
+	public static final int RST7  = 0xFFD7;
+	public static final int SOF0  = 0xFFC0;
+	public static final int SOF1  = 0xFFC1;
+	public static final int SOF2  = 0xFFC2;
+	public static final int SOF3  = 0xFFC3;
+	public static final int SOF5  = 0xFFC5;
+	public static final int SOF6  = 0xFFC6;
+	public static final int SOF7  = 0xFFC7;
+	public static final int SOF9  = 0xFFC9;
+	public static final int SOF10 = 0xFFCA;
+	public static final int SOF11 = 0xFFCB;
+	public static final int SOF13 = 0xFFCD;
+	public static final int SOF14 = 0xFFCE;
+	public static final int SOF15 = 0xFFCF;
+	public static final int SOI   = 0xFFD8;
+	public static final int SOS   = 0xFFDA;
+	public static final int TEM   = 0xFF01;
+	/* JPEGFrameComponentParameterConstants */
+	public static final int TQI	= 0;
+	public static final int HI	= 1;
+	public static final int VI	= 2;
+	public static final int CW	= 3;
+	public static final int CH	= 4;
+	/* JPEGScanComponentParameterConstants */
+	public static final int DC	= 0;
+	public static final int AC	= 1;
+	/* JFIF Component Constants */
+	public static final int ID_Y		= 1 - 1;
+	public static final int ID_CB	= 2 - 1;
+	public static final int ID_CR	= 3 - 1;
+	public static final RGB[] RGB16 = new RGB[] {
+		new RGB(0,0,0),
+		new RGB(0x80,0,0),
+		new RGB(0,0x80,0),
+		new RGB(0x80,0x80,0),
+		new RGB(0,0,0x80),
+		new RGB(0x80,0,0x80),
+		new RGB(0,0x80,0x80),
+		new RGB(0xC0,0xC0,0xC0),
+		new RGB(0x80,0x80,0x80),
+		new RGB(0xFF,0,0),
+		new RGB(0,0xFF,0),
+		new RGB(0xFF,0xFF,0),
+		new RGB(0,0,0xFF),
+		new RGB(0xFF,0,0xFF),
+		new RGB(0,0xFF,0xFF),
+		new RGB(0xFF,0xFF,0xFF),
+	};
+	public static final int[] ExtendTest = {
+		0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 
+		4096, 8192, 16384, 32768, 65536, 131072, 262144
+	};
+	public static final int[] ExtendOffset = new int[] {
+		0, -1, -3, -7, -15, -31, -63, -127, -255, -511, -1023, -2047, 
+		-4095, -8191, -16383, -32767, -65535, -131071, -262143
+	};
+	public static final int[] ZigZag8x8 = {
+		0, 1, 8, 16, 9, 2, 3, 10,
+		17, 24, 32, 25, 18, 11, 4, 5,
+		12, 19, 26, 33, 40, 48, 41, 34,
+		27, 20, 13, 6, 7, 14, 21, 28,
+		35, 42, 49, 56, 57, 50, 43, 36,
+		29, 22, 15, 23, 30, 37, 44, 51,
+		58, 59, 52, 45, 38, 31, 39, 46,
+		53, 60, 61, 54, 47, 55, 62, 63
+	};
+
+	public static final int[] CrRTable, CbBTable, CrGTable, CbGTable;
+	public static final int[] RYTable, GYTable, BYTable,
+		RCbTable, GCbTable, BCbTable, RCrTable, GCrTable, BCrTable, NBitsTable;
+	static {
+		/* Initialize RGB-YCbCr Tables */
+		int [] rYTable = new int[256];
+		int [] gYTable = new int[256];
+		int [] bYTable = new int[256];
+		int [] rCbTable = new int[256];
+		int [] gCbTable = new int[256];
+		int [] bCbTable = new int[256];
+		int [] gCrTable = new int[256];
+		int [] bCrTable = new int[256];
+		for (int i = 0; i < 256; i++) {
+			rYTable[i] = i * 19595;
+			gYTable[i] = i * 38470;
+			bYTable[i] = i * 7471 + 32768;
+			rCbTable[i] = i * -11059;
+			gCbTable[i] = i * -21709;
+			bCbTable[i] = i * 32768 + 8388608;
+			gCrTable[i] = i * -27439;
+			bCrTable[i] = i * -5329;
+		}
+		RYTable = rYTable;
+		GYTable = gYTable;
+		BYTable = bYTable;
+		RCbTable = rCbTable;
+		GCbTable = gCbTable;
+		BCbTable = bCbTable;
+		RCrTable = bCbTable;
+		GCrTable = gCrTable;
+		BCrTable = bCrTable;
+
+		/* Initialize YCbCr-RGB Tables */
+		int [] crRTable = new int[256];
+		int [] cbBTable = new int[256];
+		int [] crGTable = new int[256];
+		int [] cbGTable = new int[256];
+		for (int i = 0; i < 256; i++) {
+			int x2 = 2 * i - 255;
+			crRTable[i] = (45941 * x2 + 32768) >> 16;
+			cbBTable[i] = (58065 * x2 + 32768) >> 16;
+			crGTable[i] = -23401 * x2;
+			cbGTable[i] = -11277 * x2 + 32768;
+		}
+		CrRTable = crRTable;
+		CbBTable = cbBTable;
+		CrGTable = crGTable;
+		CbGTable = cbGTable;
+
+		/* Initialize BitCount Table */
+		int nBits = 1;
+		int power2 = 2;
+		int [] nBitsTable = new int[2048];
+		nBitsTable[0] = 0;
+		for (int i = 1; i < nBitsTable.length; i++) {
+			if (!(i < power2)) {
+				nBits++;
+				power2 *= 2;
+			}
+			nBitsTable[i] = nBits;
+		}
+		NBitsTable = nBitsTable;
+	}
+void compress(ImageData image, byte[] dataYComp, byte[] dataCbComp, byte[] dataCrComp) {
+	int srcWidth = image.width;
+	int srcHeight = image.height;
+	int vhFactor = maxV * maxH;
+	int[] frameComponent;
+	imageComponents = new byte[nComponents][];
+	for (int i = 0; i < nComponents; i++) {
+		frameComponent = frameComponents[componentIds[i]];
+		imageComponents[i] = new byte[frameComponent[CW] * frameComponent[CH]];
+	}
+	frameComponent = frameComponents[componentIds[ID_Y]];
+	for (int yPos = 0; yPos < srcHeight; yPos++) {
+		int srcOfs = yPos * srcWidth;
+		int dstOfs = yPos * frameComponent[CW];
+		System.arraycopy(dataYComp, srcOfs, imageComponents[ID_Y], dstOfs, srcWidth);
+	}
+	frameComponent = frameComponents[componentIds[ID_CB]];
+	for (int yPos = 0; yPos < srcHeight / maxV; yPos++) {
+		int destRowIndex = yPos * frameComponent[CW];
+		for (int xPos = 0; xPos < srcWidth / maxH; xPos++) {
+			int sum = 0;
+			for (int iv = 0; iv < maxV; iv++) {
+				int srcIndex = (yPos * maxV + iv) * srcWidth + (xPos * maxH);
+				for (int ih = 0; ih < maxH; ih++) {
+					sum += dataCbComp[srcIndex + ih] & 0xFF;
+				}
+			}
+			imageComponents[ID_CB][destRowIndex + xPos] = (byte)(sum / vhFactor);
+		}
+	}
+	frameComponent = frameComponents[componentIds[ID_CR]];
+	for (int yPos = 0; yPos < srcHeight / maxV; yPos++) {
+		int destRowIndex = yPos * frameComponent[CW];
+		for (int xPos = 0; xPos < srcWidth / maxH; xPos++) {
+			int sum = 0;
+			for (int iv = 0; iv < maxV; iv++) {
+				int srcIndex = (yPos * maxV + iv) * srcWidth + (xPos * maxH);
+				for (int ih = 0; ih < maxH; ih++) {
+					sum += dataCrComp[srcIndex + ih] & 0xFF;
+				}
+			}
+			imageComponents[ID_CR][destRowIndex + xPos] = (byte)(sum / vhFactor);
+		}
+	}
+	for (int iComp = 0; iComp < nComponents; iComp++) {
+		byte[] imageComponent = imageComponents[iComp];
+		frameComponent = frameComponents[componentIds[iComp]];
+		int hFactor = frameComponent[HI];
+		int vFactor = frameComponent[VI];
+		int componentWidth = frameComponent[CW];
+		int componentHeight = frameComponent[CH];
+		int compressedWidth = srcWidth / (maxH / hFactor);
+		int compressedHeight = srcHeight / (maxV / vFactor);
+		if (compressedWidth < componentWidth) {
+			int delta = componentWidth - compressedWidth;
+			for (int yPos = 0; yPos < compressedHeight; yPos++) {
+				int dstOfs = ((yPos + 1) * componentWidth - delta);
+				int dataValue = imageComponent[(dstOfs > 0) ? dstOfs - 1 : 0] & 0xFF;
+				for (int i = 0; i < delta; i++) {
+					imageComponent[dstOfs + i] = (byte)dataValue;
+				}
+			}
+		}
+		if (compressedHeight < componentHeight) {
+			int srcOfs = (compressedHeight > 0) ? (compressedHeight - 1) * componentWidth : 1;
+			for (int yPos = (compressedHeight > 0) ? compressedHeight : 1; yPos <= componentHeight; yPos++) {
+				int dstOfs = (yPos - 1) * componentWidth;
+				System.arraycopy(imageComponent, srcOfs, imageComponent, dstOfs, componentWidth);
+			}
+		}
+	}
+}
+void convert4BitRGBToYCbCr(ImageData image) {
+	RGB[] rgbs = image.getRGBs();
+	int paletteSize = rgbs.length;
+	byte[] yComp = new byte[paletteSize];
+	byte[] cbComp = new byte[paletteSize];
+	byte[] crComp = new byte[paletteSize];
+	int srcWidth = image.width;
+	int srcHeight = image.height;
+	for (int i = 0; i < paletteSize; i++) {
+		RGB color = rgbs[i];
+		int r = color.red;
+		int g = color.green;
+		int b = color.blue;
+		int n = RYTable[r] + GYTable[g] + BYTable[b];
+		yComp[i] = (byte)(n >> 16);
+		if ((n < 0) && ((n & 0xFFFF) != 0)) yComp[i]--;
+		n = RCbTable[r] + GCbTable[g] + BCbTable[b];
+		cbComp[i] = (byte)(n >> 16);
+		if ((n < 0) && ((n & 0xFFFF) != 0)) cbComp[i]--;
+		n = RCrTable[r] + GCrTable[g] + BCrTable[b];
+		crComp[i] = (byte)(n >> 16);
+		if ((n < 0) && ((n & 0xFFFF) != 0)) crComp[i]--;
+	}
+	int bSize = srcWidth * srcHeight;
+	byte[] dataYComp = new byte[bSize];
+	byte[] dataCbComp = new byte[bSize];
+	byte[] dataCrComp = new byte[bSize];
+	byte[] origData = image.data;
+	int bytesPerLine = image.bytesPerLine;
+	int maxScanlineByte = srcWidth >> 1;
+	for (int yPos = 0; yPos < srcHeight; yPos++) {
+		for (int xPos = 0; xPos < maxScanlineByte; xPos++) {
+			int srcIndex = yPos * bytesPerLine + xPos;
+			int dstIndex = yPos * srcWidth + (xPos * 2);
+			int value2 = origData[srcIndex] & 0xFF;
+			int value1 = value2 >> 4;
+			value2 &= 0x0F;
+			dataYComp[dstIndex] = yComp[value1];
+			dataCbComp[dstIndex] = cbComp[value1];
+			dataCrComp[dstIndex] = crComp[value1];
+			dataYComp[dstIndex + 1] = yComp[value2];
+			dataCbComp[dstIndex + 1] = cbComp[value2];
+			dataCrComp[dstIndex + 1] = crComp[value2];
+		}
+	}
+	compress(image, dataYComp, dataCbComp, dataCrComp);
+}
+void convert8BitRGBToYCbCr(ImageData image) {
+	RGB[] rgbs = image.getRGBs();
+	int paletteSize = rgbs.length;
+	byte[] yComp = new byte[paletteSize];
+	byte[] cbComp = new byte[paletteSize];
+	byte[] crComp = new byte[paletteSize];
+	int srcWidth = image.width;
+	int srcHeight = image.height;
+	for (int i = 0; i < paletteSize; i++) {
+		RGB color = rgbs[i];
+		int r = color.red;
+		int g = color.green;
+		int b = color.blue;
+		int n = RYTable[r] + GYTable[g] + BYTable[b];
+		yComp[i] = (byte)(n >> 16);
+		if ((n < 0) && ((n & 0xFFFF) != 0)) yComp[i]--;
+		n = RCbTable[r] + GCbTable[g] + BCbTable[b];
+		cbComp[i] = (byte)(n >> 16);
+		if ((n < 0) && ((n & 0xFFFF) != 0)) cbComp[i]--;
+		n = RCrTable[r] + GCrTable[g] + BCrTable[b];
+		crComp[i] = (byte)(n >> 16);
+		if ((n < 0) && ((n & 0xFFFF) != 0)) crComp[i]--;
+	}
+	int dstWidth = image.width;
+	int dstHeight = srcHeight;
+	int stride = ((srcWidth + 3) >> 2) << 2;
+	int bSize = dstWidth * dstHeight;
+	byte[] dataYComp = new byte[bSize];
+	byte[] dataCbComp = new byte[bSize];
+	byte[] dataCrComp = new byte[bSize];
+	byte[] origData = image.data;
+	for (int yPos = 0; yPos < srcHeight; yPos++) {
+		int srcRowIndex = yPos * stride;
+		int dstRowIndex = yPos * dstWidth;
+		for (int xPos = 0; xPos < srcWidth; xPos++) {
+			int value = origData[srcRowIndex + xPos] & 0xFF;
+			int dstIndex = dstRowIndex + xPos;
+			dataYComp[dstIndex] = yComp[value];
+			dataCbComp[dstIndex] = cbComp[value];
+			dataCrComp[dstIndex] = crComp[value];
+		}
+	}
+	compress(image, dataYComp, dataCbComp, dataCrComp);
+}
+byte[] convertCMYKToRGB() {
+	/* Unsupported CMYK format. Answer an empty byte array. */
+	return new byte[0];
+}
+void convertImageToYCbCr(ImageData image) {
+	switch (image.depth) {
+		case 4:
+			convert4BitRGBToYCbCr(image);
+			return;
+		case 8:
+			convert8BitRGBToYCbCr(image);
+			return;
+		case 16:
+		case 24:
+		case 32:
+			convertMultiRGBToYCbCr(image);
+			return;
+		default:
+			SWT.error(SWT.ERROR_UNSUPPORTED_DEPTH);
+	}
+	return;
+}
+void convertMultiRGBToYCbCr(ImageData image) {
+	int srcWidth = image.width;
+	int srcHeight = image.height;
+	int bSize = srcWidth * srcHeight;
+	byte[] dataYComp = new byte[bSize];
+	byte[] dataCbComp = new byte[bSize];
+	byte[] dataCrComp = new byte[bSize];
+	PaletteData palette = image.palette;
+	int[] buffer = new int[srcWidth];
+	if (palette.isDirect) {
+		int redMask = palette.redMask;
+		int greenMask = palette.greenMask;
+		int blueMask = palette.blueMask;
+		int redShift = palette.redShift;
+		int greenShift = palette.greenShift;
+		int blueShift = palette.blueShift;
+		for (int yPos = 0; yPos < srcHeight; yPos++) {
+			image.getPixels(0, yPos, srcWidth, buffer, 0);
+			int dstRowIndex = yPos * srcWidth;
+			for (int xPos = 0; xPos < srcWidth; xPos++) {
+				int pixel = buffer[xPos];
+				int dstDataIndex = dstRowIndex + xPos;
+				int r = pixel & redMask;
+				r = (redShift < 0) ? r >>> -redShift : r << redShift;
+				int g = pixel & greenMask;
+				g = (greenShift < 0) ? g >>> -greenShift : g << greenShift;
+				int b = pixel & blueMask;
+				b = (blueShift < 0) ? b >>> -blueShift : b << blueShift;				
+				dataYComp[dstDataIndex] = (byte)((RYTable[r] + GYTable[g] + BYTable[b]) >> 16);
+				dataCbComp[dstDataIndex] = (byte)((RCbTable[r] + GCbTable[g] + BCbTable[b]) >> 16);
+				dataCrComp[dstDataIndex] = (byte)((RCrTable[r] + GCrTable[g] + BCrTable[b]) >> 16);
+			}
+		}
+	} else {
+		for (int yPos = 0; yPos < srcHeight; yPos++) {
+			image.getPixels(0, yPos, srcWidth, buffer, 0);
+			int dstRowIndex = yPos * srcWidth;
+			for (int xPos = 0; xPos < srcWidth; xPos++) {
+				int pixel = buffer[xPos];
+				int dstDataIndex = dstRowIndex + xPos;
+				RGB rgb = palette.getRGB(pixel);
+				int r = rgb.red;
+				int g = rgb.green;
+				int b = rgb.blue;
+				dataYComp[dstDataIndex] = (byte)((RYTable[r] + GYTable[g] + BYTable[b]) >> 16);
+				dataCbComp[dstDataIndex] = (byte)((RCbTable[r] + GCbTable[g] + BCbTable[b]) >> 16);
+				dataCrComp[dstDataIndex] = (byte)((RCrTable[r] + GCrTable[g] + BCrTable[b]) >> 16);
+			}
+		}
+	}
+	compress(image, dataYComp, dataCbComp, dataCrComp);
+}
+byte[] convertYToRGB() {
+	int compWidth = frameComponents[componentIds[ID_Y]][CW];
+	int bytesPerLine = (((imageWidth * 8 + 7) / 8) + 3) / 4 * 4;
+	byte[] data = new byte[bytesPerLine * imageHeight];
+	byte[] yComp = imageComponents[ID_Y];
+	int destIndex = 0;
+	for (int i = 0; i < imageHeight; i++) {
+		int srcIndex = i * compWidth;
+		for (int j = 0; j < bytesPerLine; j++) {
+			int y = yComp[srcIndex] & 0xFF;
+			if (y < 0) {
+				y = 0;
+			} else {
+				if (y > 255) y = 255;
+			}
+			if (j >= imageWidth) {
+				y = 0;
+			}
+			data[destIndex] = (byte)y;
+			srcIndex++;
+			destIndex++;
+		}
+	}
+	return data;
+}
+byte[] convertYCbCrToRGB() {
+	/**
+	 * Convert existing image components into an RGB format.
+	 * YCbCr is defined per CCIR 601-1, except that Cb and Cr are
+	 * normalized to the range 0..MAXJSAMPLE rather than -0.5 .. 0.5.
+	 * The conversion equations to be implemented are therefore
+	 * 	R = Y                + 1.40200 * Cr
+	 * 	G = Y - 0.34414 * Cb - 0.71414 * Cr
+	 * 	B = Y + 1.77200 * Cb
+	 * where Cb and Cr represent the incoming values less MAXJSAMPLE/2.
+	 * (These numbers are derived from TIFF 6.0 section 21, dated 3-June-92.)
+	 * 
+	 * To avoid floating-point arithmetic, we represent the fractional constants
+	 * as integers scaled up by 2^16 (about 4 digits precision); we have to divide
+	 * the products by 2^16, with appropriate rounding, to get the correct answer.
+	 * Notice that Y, being an integral input, does not contribute any fraction
+	 * so it need not participate in the rounding.
+	 * 
+	 * For even more speed, we avoid doing any multiplications in the inner loop
+	 * by precalculating the constants times Cb and Cr for all possible values.
+	 * For 8-bit JSAMPLEs this is very reasonable (only 256 entries per table);
+	 * for 12-bit samples it is still acceptable.  It's not very reasonable for
+	 * 16-bit samples, but if you want lossless storage you shouldn't be changing
+	 * colorspace anyway.
+	 * The Cr=>R and Cb=>B values can be rounded to integers in advance; the
+	 * values for the G calculation are left scaled up, since we must add them
+	 * together before rounding.
+	 */
+	int bSize = imageWidth * imageHeight * nComponents;
+	byte[] rgbData = new byte[bSize];
+	int destIndex = 0;
+	expandImageComponents();
+	byte[] yComp = imageComponents[ID_Y];
+	byte[] cbComp = imageComponents[ID_CB];
+	byte[] crComp = imageComponents[ID_CR];
+	int compWidth = frameComponents[componentIds[ID_Y]][CW];
+	for (int v = 0; v < imageHeight; v++) {
+		int srcIndex = v * compWidth;
+		for (int i = 0; i < imageWidth; i++) {
+			int y = yComp[srcIndex] & 0xFF;
+			int cb = cbComp[srcIndex] & 0xFF;
+			int cr = crComp[srcIndex] & 0xFF;
+			int r = y + CrRTable[cr];
+			int g = y + ((CbGTable[cb] + CrGTable[cr]) >> 16);
+			int b = y + CbBTable[cb];
+			if (r < 0) {
+				r = 0;
+			} else {
+				if (r > 255) r = 255;
+			}
+			if (g < 0) {
+				g = 0;
+			} else {
+				if (g > 255) g = 255;
+			}
+			if (b < 0) {
+				b = 0;
+			} else {
+				if (b > 255) b = 255;
+			}
+			rgbData[destIndex] = (byte)b;
+			rgbData[destIndex + 1] = (byte)g;
+			rgbData[destIndex + 2] = (byte)r;
+			destIndex += 3;
+			srcIndex++;
+		}
+	}
+	return rgbData;
+}
+void decodeACCoefficients(int[] dataUnit, int iComp) {
+	int[] sParams = scanHeader.componentParameters[componentIds[iComp]];
+	JPEGHuffmanTable acTable = acHuffmanTables[sParams[AC]];
+	int k = 1;
+	while (k < 64) {
+		int rs = decodeUsingTable(acTable);
+		int r = rs >> 4;
+		int s = rs & 0xF;
+		if (s == 0) {
+			if (r == 15) {
+				k += 16;
+			} else {
+				break;
+			}
+		} else {
+			k += r;
+			int bits = receive(s);
+			dataUnit[ZigZag8x8[k]] = extendBy(bits, s);
+			k++;
+		}
+	}
+}
+void decodeACFirstCoefficients(int[] dataUnit, int iComp, int start, int end, int approxBit) {
+	if (eobrun > 0) {
+		eobrun--;
+		return;
+	}
+	int[] sParams = scanHeader.componentParameters[componentIds[iComp]];
+	JPEGHuffmanTable acTable = acHuffmanTables[sParams[AC]];
+	int k = start;
+	while (k <= end) {
+		int rs = decodeUsingTable(acTable);
+		int r = rs >> 4;
+		int s = rs & 0xF;
+		if (s == 0) {
+			if (r == 15) {
+				k += 16;
+			} else {
+				eobrun = (1 << r) + receive(r) - 1;
+				break;
+			}
+		} else {
+			k += r;
+			int bits = receive(s);
+			dataUnit[ZigZag8x8[k]] = extendBy(bits, s) << approxBit;
+			k++;
+		}
+	}
+}
+void decodeACRefineCoefficients(int[] dataUnit, int iComp, int start, int end, int approxBit) {
+	int[] sParams = scanHeader.componentParameters[componentIds[iComp]];
+	JPEGHuffmanTable acTable = acHuffmanTables[sParams[AC]];
+	int k = start;
+	while (k <= end) {
+		if (eobrun > 0) {
+			while (k <= end) {
+				int zzIndex = ZigZag8x8[k];
+				if (dataUnit[zzIndex] != 0) {
+					dataUnit[zzIndex] = refineAC(dataUnit[zzIndex], approxBit);
+				}
+				k++;
+			}
+			eobrun--;
+		} else {
+			int rs = decodeUsingTable(acTable);
+			int r = rs >> 4;
+			int s = rs & 0xF;
+			if (s == 0) {
+				if (r == 15) {
+					int zeros = 0;
+					while (zeros < 16 && k <= end) {
+						int zzIndex = ZigZag8x8[k];
+						if (dataUnit[zzIndex] != 0) {
+							dataUnit[zzIndex] = refineAC(dataUnit[zzIndex], approxBit);
+						} else {
+							zeros++;
+						}
+						k++;
+					}
+				} else {
+					eobrun = (1 << r) + receive(r);
+				}
+			} else {
+				int bit = receive(s);
+				int zeros = 0;
+				int zzIndex = ZigZag8x8[k];
+				while ((zeros < r || dataUnit[zzIndex] != 0) && k <= end) {
+					if (dataUnit[zzIndex] != 0) {
+						dataUnit[zzIndex] = refineAC(dataUnit[zzIndex], approxBit);
+					} else {
+						zeros++;
+					}
+					k++;
+					zzIndex = ZigZag8x8[k];
+				}
+				if (bit != 0) {
+					dataUnit[zzIndex] = 1 << approxBit;
+				} else {
+					dataUnit[zzIndex] = -1 << approxBit;
+				}
+				k++;
+			}
+		}
+	}
+}
+int refineAC(int ac, int approxBit) {
+	if (ac > 0) {
+		int bit = nextBit();
+		if (bit != 0) {
+			ac += 1 << approxBit;
+		}
+	} else if (ac < 0) {
+		int bit = nextBit();
+		if (bit != 0) {
+			ac += -1 << approxBit;
+		}
+	}
+	return ac;
+}
+void decodeDCCoefficient(int[] dataUnit, int iComp, boolean first, int approxBit) {
+	int[] sParams = scanHeader.componentParameters[componentIds[iComp]];
+	JPEGHuffmanTable dcTable = dcHuffmanTables[sParams[DC]];
+	int lastDC = 0;
+	if (progressive && !first) {
+		int bit = nextBit();
+		lastDC = dataUnit[0] + (bit << approxBit);
+	} else {
+		lastDC = precedingDCs[iComp];
+		int nBits = decodeUsingTable(dcTable);
+		if (nBits != 0) {
+			int bits = receive(nBits);
+			int diff = extendBy(bits, nBits);
+			lastDC += diff;
+			precedingDCs[iComp] = lastDC;
+		}
+		if (progressive) {
+			lastDC = lastDC << approxBit;
+		}
+	}
+	dataUnit[0] = lastDC;
+}
+void dequantize(int[] dataUnit, int iComp) {
+	int[] qTable = quantizationTables[frameComponents[componentIds[iComp]][TQI]];
+	for (int i = 0; i < dataUnit.length; i++) {
+		int zzIndex = ZigZag8x8[i];
+		dataUnit[zzIndex] = dataUnit[zzIndex] * qTable[i];
+	}
+}
+byte[] decodeImageComponents() {
+	if (nComponents == 3) { // compIds 1, 2, 3
+		return convertYCbCrToRGB();
+	}
+//	if (nComponents == 3) { // compIds 1, 4, 5
+//		Unsupported CMYK format.
+//		return convertYIQToRGB();
+//	}
+	if (nComponents == 4) {
+		return convertCMYKToRGB();
+	}
+	return convertYToRGB();
+}
+void decodeMCUAtXAndY(int xmcu, int ymcu, int nComponentsInScan, boolean first, int start, int end, int approxBit) {
+	for (int iComp = 0; iComp < nComponentsInScan; iComp++) {
+		int scanComponent = iComp;
+		while (scanHeader.componentParameters[componentIds[scanComponent]] == null) {
+			scanComponent++;
+		}
+		int[] frameComponent = frameComponents[componentIds[scanComponent]];
+		int hi = frameComponent[HI];
+		int vi = frameComponent[VI];
+		if (nComponentsInScan == 1) {
+			hi = 1;
+			vi = 1;
+		}
+		int compWidth = frameComponent[CW];
+		for (int ivi = 0; ivi < vi; ivi++) {
+			for (int ihi = 0; ihi < hi; ihi++) {
+				if (progressive) {
+					// Progressive: First scan - create a new data unit.
+					// Subsequent scans - refine the existing data unit.
+					int index = (ymcu * vi + ivi) * compWidth + xmcu * hi + ihi;
+					dataUnit = dataUnits[scanComponent][index];
+					if (dataUnit == null) {
+						dataUnit = new int[64];
+						dataUnits[scanComponent][index] = dataUnit;
+					}
+				} else {
+					// Sequential: Clear and reuse the data unit buffer.
+					for (int i = 0; i < dataUnit.length; i++) {
+						dataUnit[i] = 0;
+					}
+				}
+				if (!progressive || scanHeader.isDCProgressiveScan()) {
+					decodeDCCoefficient(dataUnit, scanComponent, first, approxBit);
+				}
+				if (!progressive) {
+					decodeACCoefficients(dataUnit, scanComponent);
+				} else {
+					if (scanHeader.isACProgressiveScan()) {
+						if (first) {
+							decodeACFirstCoefficients(dataUnit, scanComponent, start, end, approxBit);
+						} else {
+							decodeACRefineCoefficients(dataUnit, scanComponent, start, end, approxBit);
+						}
+					}
+					if (loader.hasListeners()) {
+						// Dequantization, IDCT, up-sampling and color conversion
+						// are done on a copy of the coefficient data in order to
+						// display the image incrementally.
+						int[] temp = dataUnit;
+						dataUnit = new int[64];
+						System.arraycopy(temp, 0, dataUnit, 0, 64);
+					}
+				}
+				if (!progressive || (progressive && loader.hasListeners())) {
+					dequantize(dataUnit, scanComponent);
+					inverseDCT(dataUnit);
+					storeData(dataUnit, scanComponent, xmcu, ymcu, hi, ihi, vi, ivi);
+				}
+			}
+		}
+	}
+}
+void decodeScan() {
+	if (progressive && !scanHeader.verifyProgressiveScan()) {
+		SWT.error(SWT.ERROR_INVALID_IMAGE);
+	}
+	int nComponentsInScan = scanHeader.getNumberOfImageComponents();
+	int mcuRowsInScan = interleavedMcuRows;
+	int mcusPerRow = interleavedMcuCols;
+	if (nComponentsInScan == 1) {
+		// Non-interleaved.
+		int scanComponent = 0;
+		while (scanHeader.componentParameters[componentIds[scanComponent]] == null) {
+			scanComponent++;
+		}
+		int[] frameComponent = frameComponents[componentIds[scanComponent]];
+		int hi = frameComponent[HI];
+		int vi = frameComponent[VI];
+		int mcuWidth = DCTSIZE * maxH / hi;
+		int mcuHeight = DCTSIZE * maxV / vi;
+		mcusPerRow = (imageWidth + mcuWidth - 1) / mcuWidth;
+		mcuRowsInScan = (imageHeight + mcuHeight - 1) / mcuHeight;
+	}
+	boolean first = scanHeader.isFirstScan();
+	int start = scanHeader.getStartOfSpectralSelection();
+	int end = scanHeader.getEndOfSpectralSelection();
+	int approxBit = scanHeader.getApproxBitPositionLow();
+	restartsToGo = restartInterval;
+	nextRestartNumber = 0;
+	for (int ymcu = 0; ymcu < mcuRowsInScan; ymcu++) {
+		for (int xmcu = 0; xmcu < mcusPerRow; xmcu++) {
+			if (restartInterval != 0) {
+				if (restartsToGo == 0) processRestartInterval();
+				restartsToGo--;
+			}
+			decodeMCUAtXAndY(xmcu, ymcu, nComponentsInScan, first, start, end, approxBit);
+		}
+	}
+}
+int decodeUsingTable(JPEGHuffmanTable huffmanTable) {
+	int i = 0;
+	int[] maxCodes = huffmanTable.getDhMaxCodes();
+	int[] minCodes = huffmanTable.getDhMinCodes();
+	int[] valPtrs = huffmanTable.getDhValPtrs();
+	int[] huffVals = huffmanTable.getDhValues();
+	int code = nextBit();
+	while (code > maxCodes[i]) {
+		code = code * 2 + nextBit();
+		i++;
+	}
+	int j = valPtrs[i] + code - minCodes[i];
+	return huffVals[j];
+}
+void emit(int huffCode, int nBits) {
+	if (nBits == 0) {
+		SWT.error(SWT.ERROR_INVALID_IMAGE);
+	}
+	int[] power2m1 = new int[] {
+		1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 
+		16383, 32767, 65535, 131125
+	};
+	int code = (huffCode & power2m1[nBits - 1]) << (24 - nBits - currentBitCount);
+	byte[] codeBuffer = new byte[4];
+	codeBuffer[0] = (byte)(code & 0xFF);
+	codeBuffer[1] = (byte)((code >> 8) & 0xFF);
+	codeBuffer[2] = (byte)((code >> 16) & 0xFF);
+	codeBuffer[3] = (byte)((code >> 24) & 0xFF);
+	int abs = nBits - (8 - currentBitCount);
+	if (abs < 0) abs = -abs;
+	if ((abs >> 3) > 0) {
+		currentByte += codeBuffer[2];
+		emitByte((byte)currentByte);
+		emitByte(codeBuffer[1]);
+		currentByte = codeBuffer[0];
+		currentBitCount += nBits - 16;
+	} else {
+		currentBitCount += nBits;
+		if (currentBitCount >= 8) {
+			currentByte += codeBuffer[2];
+			emitByte((byte)currentByte);
+			currentByte = codeBuffer[1];
+			currentBitCount -= 8;
+		} else {
+			currentByte += codeBuffer[2];
+		}
+	}
+}
+void emitByte(byte byteValue) {
+	if (bufferCurrentPosition >= 512) {
+		resetOutputBuffer();
+	}
+	dataBuffer[bufferCurrentPosition] = byteValue;
+	bufferCurrentPosition++;
+	if (byteValue == -1) {
+		emitByte((byte)0);
+	}
+}
+void encodeACCoefficients(int[] dataUnit, int iComp) {
+	int[] sParams = scanHeader.componentParameters[iComp];
+	JPEGHuffmanTable acTable = acHuffmanTables[sParams[AC]];
+	int[] ehCodes = acTable.ehCodes;
+	byte[] ehSizes = acTable.ehCodeLengths;
+	int r = 0;
+	int k = 1;
+	while (k < 64) {
+		k++;
+		int acValue = dataUnit[ZigZag8x8[k - 1]];
+		if (acValue == 0) {
+			if (k == 64) {
+				emit(ehCodes[0], ehSizes[0] & 0xFF);
+			} else {
+				r++;
+			}
+		} else {
+			while (r > 15) {
+				emit(ehCodes[0xF0], ehSizes[0xF0] & 0xFF);
+				r -= 16;
+			}
+			if (acValue < 0) {
+				int absACValue = acValue;
+				if (absACValue < 0) absACValue = -absACValue;
+				int nBits = NBitsTable[absACValue];
+				int rs = r * 16 + nBits;
+				emit(ehCodes[rs], ehSizes[rs] & 0xFF);
+				emit(0xFFFFFF - absACValue, nBits);
+			} else {
+				int nBits = NBitsTable[acValue];
+				int rs = r * 16 + nBits;
+				emit(ehCodes[rs], ehSizes[rs] & 0xFF);
+				emit(acValue, nBits);
+			}
+			r = 0;
+		}
+	}
+}
+void encodeDCCoefficients(int[] dataUnit, int iComp) {
+	int[] sParams = scanHeader.componentParameters[iComp];
+	JPEGHuffmanTable dcTable = dcHuffmanTables[sParams[DC]];
+	int lastDC = precedingDCs[iComp];
+	int dcValue = dataUnit[0];
+	int diff = dcValue - lastDC;
+	precedingDCs[iComp] = dcValue;
+	if (diff < 0) {
+		int absDiff = 0 - diff;
+		int nBits = NBitsTable[absDiff];
+		emit(dcTable.ehCodes[nBits], dcTable.ehCodeLengths[nBits]);
+		emit(0xFFFFFF - absDiff, nBits);
+	} else {
+		int nBits = NBitsTable[diff];
+		emit(dcTable.ehCodes[nBits], dcTable.ehCodeLengths[nBits]);
+		if (nBits != 0) {
+			emit(diff, nBits);
+		}
+	}
+}
+void encodeMCUAtXAndY(int xmcu, int ymcu) {
+	int nComponentsInScan = scanHeader.getNumberOfImageComponents();
+	dataUnit = new int[64];
+	for (int iComp = 0; iComp < nComponentsInScan; iComp++) {
+		int[] frameComponent = frameComponents[componentIds[iComp]];
+		int hi = frameComponent[HI];
+		int vi = frameComponent[VI];
+		for (int ivi = 0; ivi < vi; ivi++) {
+			for (int ihi = 0; ihi < hi; ihi++) {
+				extractData(dataUnit, iComp, xmcu, ymcu, ihi, ivi);
+				forwardDCT(dataUnit);
+				quantizeData(dataUnit, iComp);
+				encodeDCCoefficients(dataUnit, iComp);
+				encodeACCoefficients(dataUnit, iComp);
+			}
+		}
+	}
+}
+void encodeScan() {
+	for (int ymcu = 0; ymcu < interleavedMcuRows; ymcu++) {
+		for (int xmcu = 0; xmcu < interleavedMcuCols; xmcu++) {
+			encodeMCUAtXAndY(xmcu, ymcu);
+		}
+	}
+	if (currentBitCount != 0) {
+		emitByte((byte)currentByte);
+	}
+	resetOutputBuffer();
+}
+void expandImageComponents() {
+	for (int iComp = 0; iComp < nComponents; iComp++) {
+		int[] frameComponent = frameComponents[componentIds[iComp]];
+		int hi = frameComponent[HI];
+		int vi = frameComponent[VI];
+		int upH = maxH / hi;
+		int upV = maxV / vi;
+		if ((upH * upV) > 1) {
+			byte[] component = imageComponents[iComp];
+			int compWidth = frameComponent[CW];
+			int compHeight = frameComponent[CH];
+			int upCompWidth = compWidth * upH;
+			int upCompHeight = compHeight * upV;
+			ImageData src = new ImageData(compWidth, compHeight, 8, new PaletteData(RGB16), 4, component);
+			ImageData dest = src.scaledTo(upCompWidth, upCompHeight);
+			imageComponents[iComp] = dest.data;
+		}
+	}
+}
+int extendBy(int diff, int t) {
+	if (diff < ExtendTest[t]) {
+		return diff + ExtendOffset[t];
+	} else {
+		return diff;
+	}
+}
+void extractData(int[] dataUnit, int iComp, int xmcu, int ymcu, int ihi, int ivi) {
+	byte[] compImage = imageComponents[iComp];
+	int[] frameComponent = frameComponents[componentIds[iComp]];
+	int hi = frameComponent[HI];
+	int vi = frameComponent[VI];
+	int compWidth = frameComponent[CW];
+	int srcIndex = ((ymcu * vi + ivi) * compWidth * DCTSIZE) + ((xmcu * hi + ihi) * DCTSIZE);
+	int destIndex = 0;
+	for (int i = 0; i < DCTSIZE; i++) {
+		for (int col = 0; col < DCTSIZE; col++) {
+			dataUnit[destIndex] = (compImage[srcIndex + col] & 0xFF) - 128;
+			destIndex++;
+		}
+		srcIndex += compWidth;
+	}
+}
+void forwardDCT(int[] dataUnit) {
+	for (int row = 0; row < 8; row++) {
+		int rIndex = row * DCTSIZE;
+		int tmp0 = dataUnit[rIndex] + dataUnit[rIndex + 7];
+		int tmp7 = dataUnit[rIndex] - dataUnit[rIndex + 7];
+		int tmp1 = dataUnit[rIndex + 1] + dataUnit[rIndex + 6];
+		int tmp6 = dataUnit[rIndex + 1] - dataUnit[rIndex + 6];
+		int tmp2 = dataUnit[rIndex + 2] + dataUnit[rIndex + 5];
+		int tmp5 = dataUnit[rIndex + 2] - dataUnit[rIndex + 5];
+		int tmp3 = dataUnit[rIndex + 3] + dataUnit[rIndex + 4];
+		int tmp4 = dataUnit[rIndex + 3] - dataUnit[rIndex + 4];
+
+		/**
+		 * Even part per LL&M figure 1 --- note that published figure 
+		 * is faulty; rotator 'sqrt(2)*c1' should be 'sqrt(2)*c6'.
+		 */
+		int tmp10 = tmp0 + tmp3;
+		int tmp13 = tmp0 - tmp3;
+		int tmp11 = tmp1 + tmp2;
+		int tmp12 = tmp1 - tmp2;
+
+		dataUnit[rIndex] = (tmp10 + tmp11) * 4;
+		dataUnit[rIndex + 4]  = (tmp10 - tmp11) * 4;
+
+		int z1 = (tmp12 + tmp13) * FIX_0_541196100;
+		int n = z1 + (tmp13 * FIX_0_765366865) + 1024;
+		dataUnit[rIndex + 2] = n >> 11;
+		if ((n < 0) && ((n & 0x07FF) != 0)) dataUnit[rIndex + 2]--;
+		n = z1 + (tmp12 * (0 - FIX_1_847759065)) + 1024;
+ 		dataUnit[rIndex + 6] = n >> 11;
+		if ((n < 0) && ((n & 0x07FF) != 0)) dataUnit[rIndex + 6]--;
+
+		/**
+		 * Odd part per figure 8 --- note paper omits factor of sqrt(2).
+		 * cK represents cos(K*pi/16).
+		 * i0..i3 in the paper are tmp4..tmp7 here.
+		 */
+		z1 = tmp4 + tmp7;
+		int z2 = tmp5 + tmp6;
+		int z3 = tmp4 + tmp6;
+		int z4 = tmp5 + tmp7;
+		int z5 = (z3 + z4) * FIX_1_175875602;	// sqrt(2) * c3
+
+		tmp4 *= FIX_0_298631336;	// sqrt(2) * (-c1+c3+c5-c7)
+		tmp5 *= FIX_2_053119869;	// sqrt(2) * ( c1+c3-c5+c7)
+		tmp6 *= FIX_3_072711026;	// sqrt(2) * ( c1+c3+c5-c7)
+		tmp7 *= FIX_1_501321110;	// sqrt(2) * ( c1+c3-c5-c7)
+		z1 *= 0 - FIX_0_899976223;	// sqrt(2) * (c7-c3)
+		z2 *= 0 - FIX_2_562915447;	// sqrt(2) * (-c1-c3)
+		z3 *= 0 - FIX_1_961570560;	// sqrt(2) * (-c3-c5)
+		z4 *= 0 - FIX_0_390180644;	// sqrt(2) * (c5-c3)
+
+		z3 += z5;
+		z4 += z5;
+
+		n = tmp4 + z1 + z3 + 1024;
+		dataUnit[rIndex + 7] = n >> 11;
+		if ((n < 0) && ((n & 0x07FF) != 0)) dataUnit[rIndex + 7]--;
+		n = tmp5 + z2 + z4 + 1024;
+		dataUnit[rIndex + 5] = n >> 11;
+		if ((n < 0) && ((n & 0x07FF) != 0)) dataUnit[rIndex + 5]--;
+		n = tmp6 + z2 + z3 + 1024;
+		dataUnit[rIndex + 3] = n >> 11;
+		if ((n < 0) && ((n & 0x07FF) != 0)) dataUnit[rIndex + 3]--;
+		n = tmp7 + z1 + z4 + 1024;
+		dataUnit[rIndex + 1] = n >> 11;
+		if ((n < 0) && ((n & 0x07FF) != 0)) dataUnit[rIndex + 1]--;
+	}
+
+	/**
+	 * Pass 2: process columns.
+	 * Note that we must descale the results by a factor of 8 == 2**3,
+	 * and also undo the PASS1_BITS scaling.
+	 */
+	for (int col = 0; col < 8; col++) {
+		int c0 = col;
+		int c1 = col + 8;
+		int c2 = col + 16;
+		int c3 = col + 24;
+		int c4 = col + 32;
+		int c5 = col + 40;
+		int c6 = col + 48;
+		int c7 = col + 56;
+		int tmp0 = dataUnit[c0] + dataUnit[c7];
+		int tmp7 = dataUnit[c0] - dataUnit[c7];
+		int tmp1 = dataUnit[c1] + dataUnit[c6];
+		int tmp6 = dataUnit[c1] - dataUnit[c6];
+		int tmp2 = dataUnit[c2] + dataUnit[c5];
+		int tmp5 = dataUnit[c2] - dataUnit[c5];
+		int tmp3 = dataUnit[c3] + dataUnit[c4];
+		int tmp4 = dataUnit[c3] - dataUnit[c4];
+
+		/**
+		 * Even part per LL&M figure 1 --- note that published figure 
+		 * is faulty; rotator 'sqrt(2)*c1' should be 'sqrt(2)*c6'.
+		 */
+		int tmp10 = tmp0 + tmp3;
+		int tmp13 = tmp0 - tmp3;
+		int tmp11 = tmp1 + tmp2;
+		int tmp12 = tmp1 - tmp2;
+
+		int n = tmp10 + tmp11 + 16;
+		dataUnit[c0] = n >> 5;
+		if ((n < 0) && ((n & 0x1F) != 0)) dataUnit[c0]--;
+		n = tmp10 - tmp11 + 16;
+		dataUnit[c4] = n >> 5;
+		if ((n < 0) && ((n & 0x1F) != 0)) dataUnit[c4]--;
+
+		int z1 = (tmp12 + tmp13) * FIX_0_541196100;
+		n = z1 + (tmp13 * FIX_0_765366865) + 131072;
+		dataUnit[c2] = n >> 18;
+		if ((n < 0) && ((n & 0x3FFFF) != 0)) dataUnit[c2]--;
+		n = z1 + (tmp12 * (0 - FIX_1_847759065)) + 131072;
+		dataUnit[c6] = n >> 18;
+		if ((n < 0) && ((n & 0x3FFFF) != 0)) dataUnit[c6]--;
+
+		/**
+		 * Odd part per figure 8 --- note paper omits factor of sqrt(2).
+		 * cK represents cos(K*pi/16).
+		 * i0..i3 in the paper are tmp4..tmp7 here.
+		 */
+		z1 = tmp4 + tmp7;
+		int z2 = tmp5 + tmp6;
+		int z3 = tmp4 + tmp6;
+		int z4 = tmp5 + tmp7;
+		int z5 = (z3 + z4) * FIX_1_175875602;	// sqrt(2) * c3
+
+		tmp4 *= FIX_0_298631336;	// sqrt(2) * (-c1+c3+c5-c7)
+		tmp5 *= FIX_2_053119869;	// sqrt(2) * ( c1+c3-c5+c7)
+		tmp6 *= FIX_3_072711026;	// sqrt(2) * ( c1+c3+c5-c7)
+		tmp7 *= FIX_1_501321110;	// sqrt(2) * ( c1+c3-c5-c7)
+		z1 *= 0 - FIX_0_899976223;	// sqrt(2) * (c7-c3)
+		z2 *= 0 - FIX_2_562915447;	// sqrt(2) * (-c1-c3)
+		z3 *= 0 - FIX_1_961570560;	// sqrt(2) * (-c3-c5)
+		z4 *= 0 - FIX_0_390180644;	// sqrt(2) * (c5-c3)
+
+		z3 += z5;
+		z4 += z5;
+
+		n = tmp4 + z1 + z3 + 131072;
+		dataUnit[c7] = n >> 18;
+		if ((n < 0) && ((n & 0x3FFFF) != 0)) dataUnit[c7]--;
+		n = tmp5 + z2 + z4 + 131072;
+		dataUnit[c5] = n >> 18;
+		if ((n < 0) && ((n & 0x3FFFF) != 0)) dataUnit[c5]--;
+		n = tmp6 + z2 + z3 + 131072;
+		dataUnit[c3] = n >> 18;
+		if ((n < 0) && ((n & 0x3FFFF) != 0)) dataUnit[c3]--;
+		n = tmp7 + z1 + z4 + 131072;
+		dataUnit[c1] = n >> 18;
+		if ((n < 0) && ((n & 0x3FFFF) != 0)) dataUnit[c1]--;
+	}
+}
+void getAPP0() {
+	JPEGAppn appn = new JPEGAppn(inputStream);
+	if (!appn.verify()) {
+		SWT.error(SWT.ERROR_INVALID_IMAGE);
+	}
+}
+void getCOM() {
+	new JPEGComment(inputStream);
+}
+void getDAC() {
+	new JPEGArithmeticConditioningTable(inputStream);
+}
+void getDHT() {
+	JPEGHuffmanTable dht = new JPEGHuffmanTable(inputStream);
+	if (!dht.verify()) {
+		SWT.error(SWT.ERROR_INVALID_IMAGE);
+	}
+	if (acHuffmanTables == null) {
+		acHuffmanTables = new JPEGHuffmanTable[4];
+	}
+	if (dcHuffmanTables == null) {
+		dcHuffmanTables = new JPEGHuffmanTable[4];
+	}
+	JPEGHuffmanTable[] dhtTables = dht.getAllTables();
+	for (int i = 0; i < dhtTables.length; i++) {
+		JPEGHuffmanTable dhtTable = dhtTables[i];
+		if (dhtTable.getTableClass() == 0) {
+			dcHuffmanTables[dhtTable.getTableIdentifier()] = dhtTable;
+		} else {
+			acHuffmanTables[dhtTable.getTableIdentifier()] = dhtTable;
+		}
+	}
+}
+void getDNL() {
+	new JPEGRestartInterval(inputStream);
+}
+void getDQT() {
+	JPEGQuantizationTable dqt = new JPEGQuantizationTable(inputStream);
+	int[][] currentTables = quantizationTables;
+	if (currentTables == null) {
+		currentTables = new int[4][];
+	}
+	int[] dqtTablesKeys = dqt.getQuantizationTablesKeys();
+	int[][] dqtTablesValues = dqt.getQuantizationTablesValues();
+	for (int i = 0; i < dqtTablesKeys.length; i++) {
+		int index = dqtTablesKeys[i];
+		currentTables[index] = dqtTablesValues[i];
+	}
+	quantizationTables = currentTables;
+}
+void getDRI() {
+	JPEGRestartInterval dri = new JPEGRestartInterval(inputStream);
+	if (!dri.verify()) {
+		SWT.error(SWT.ERROR_INVALID_IMAGE);
+	}
+	restartInterval = dri.getRestartInterval();
+}
+void inverseDCT(int[] dataUnit) {
+	for (int row = 0; row < 8; row++) {
+		int rIndex = row * DCTSIZE;
+		/**
+		 * Due to quantization, we will usually find that many of the input
+		 * coefficients are zero, especially the AC terms.  We can exploit this
+		 * by short-circuiting the IDCT calculation for any row in which all
+		 * the AC terms are zero.  In that case each output is equal to the
+		 * DC coefficient (with scale factor as needed).
+		 * With typical images and quantization tables, half or more of the
+		 * row DCT calculations can be simplified this way.
+		 */
+		if (isZeroInRow(dataUnit, rIndex)) {
+			int dcVal = dataUnit[rIndex] << 2;
+			for (int i = rIndex + 7; i >= rIndex; i--) {
+				dataUnit[i] = dcVal;
+			}
+		} else {
+			/**
+			 * Even part: reverse the even part of the forward DCT.
+			 * The rotator is sqrt(2)*c(-6).
+			 */
+			int z2 = dataUnit[rIndex + 2];
+			int z3 = dataUnit[rIndex + 6];
+			int z1 = (z2 + z3) * FIX_0_541196100;
+			int tmp2 = z1 + (z3 * (0 - FIX_1_847759065));
+			int tmp3 = z1 + (z2 * FIX_0_765366865);
+			int tmp0 = (dataUnit[rIndex] + dataUnit[rIndex + 4]) << 13;
+			int tmp1 = (dataUnit[rIndex] - dataUnit[rIndex + 4]) << 13;
+			int tmp10 = tmp0 + tmp3;
+			int tmp13 = tmp0 - tmp3;
+			int tmp11 = tmp1 + tmp2;
+			int tmp12 = tmp1 - tmp2;
+			/**
+			 * Odd part per figure 8; the matrix is unitary and hence its
+			 * transpose is its inverse. i0..i3 are y7,y5,y3,y1 respectively.
+			 */
+			tmp0 = dataUnit[rIndex + 7];
+			tmp1 = dataUnit[rIndex + 5];
+			tmp2 = dataUnit[rIndex + 3];
+			tmp3 = dataUnit[rIndex + 1];
+			z1 = tmp0 + tmp3;
+			z2 = tmp1 + tmp2;
+			z3 = tmp0 + tmp2;
+			int z4 = tmp1 + tmp3;
+			int z5 = (z3 + z4) * FIX_1_175875602; /* sqrt(2) * c3 */
+			  
+			tmp0 *= FIX_0_298631336;		/* sqrt(2) * (-c1+c3+c5-c7) */
+			tmp1 *= FIX_2_053119869;		/* sqrt(2) * ( c1+c3-c5+c7) */
+			tmp2 *= FIX_3_072711026;		/* sqrt(2) * ( c1+c3+c5-c7) */
+			tmp3 *= FIX_1_501321110;		/* sqrt(2) * ( c1+c3-c5-c7) */
+			z1 *= 0 - FIX_0_899976223;	/* sqrt(2) * (c7-c3) */
+			z2 *= 0 - FIX_2_562915447;	/* sqrt(2) * (-c1-c3) */
+			z3 *= 0 - FIX_1_961570560;	/* sqrt(2) * (-c3-c5) */
+			z4 *= 0 - FIX_0_390180644;	/* sqrt(2) * (c5-c3) */
+
+			z3 += z5;
+			z4 += z5;
+			tmp0 += z1 + z3;
+			tmp1 += z2 + z4;
+			tmp2 += z2 + z3;
+			tmp3 += z1 + z4;
+
+			dataUnit[rIndex] = (tmp10 + tmp3 + 1024) >> 11;
+			dataUnit[rIndex + 7] = (tmp10 - tmp3 + 1024) >> 11;
+			dataUnit[rIndex + 1] = (tmp11 + tmp2 + 1024) >> 11;
+			dataUnit[rIndex + 6] = (tmp11 - tmp2 + 1024) >> 11;
+			dataUnit[rIndex + 2] = (tmp12 + tmp1 + 1024) >> 11;
+			dataUnit[rIndex + 5] = (tmp12 - tmp1 + 1024) >> 11;
+			dataUnit[rIndex + 3] = (tmp13 + tmp0 + 1024) >> 11;
+			dataUnit[rIndex + 4] = (tmp13 - tmp0 + 1024) >> 11;
+		 }
+	}
+	/**
+	 * Pass 2: process columns.
+	 * Note that we must descale the results by a factor of 8 == 2**3,
+	 * and also undo the PASS1_BITS scaling.
+	 */
+	for (int col = 0; col < 8; col++) {
+		int c0 = col;
+		int c1 = col + 8;
+		int c2 = col + 16;
+		int c3 = col + 24;
+		int c4 = col + 32;
+		int c5 = col + 40;
+		int c6 = col + 48;
+		int c7 = col + 56;
+		if (isZeroInColumn(dataUnit, col)) {
+			int dcVal = (dataUnit[c0] + 16) >> 5;
+			dataUnit[c0] = dcVal;
+			dataUnit[c1] = dcVal;
+			dataUnit[c2] = dcVal;
+			dataUnit[c3] = dcVal;
+			dataUnit[c4] = dcVal;
+			dataUnit[c5] = dcVal;
+			dataUnit[c6] = dcVal;
+			dataUnit[c7] = dcVal;
+		} else {
+			/**
+			 * Even part: reverse the even part of the forward DCT.
+			 * The rotator is sqrt(2)*c(-6).
+			 */
+			int z0 = dataUnit[c0];
+			int z2 = dataUnit[c2];
+			int z3 = dataUnit[c6];
+			int z4 = dataUnit[c4];
+			int z1 = (z2 + z3) * FIX_0_541196100;
+			int tmp2 = z1 + (z3 * (0 - FIX_1_847759065));
+			int tmp3 = z1 + (z2 * FIX_0_765366865);
+			int tmp0 = (z0 + z4) << 13;
+			int tmp1 = (z0 - z4) << 13;
+			int tmp10 = tmp0 + tmp3;
+			int tmp13 = tmp0 - tmp3;
+			int tmp11 = tmp1 + tmp2;
+			int tmp12 = tmp1 - tmp2;
+			/**
+			 * Odd part per figure 8; the matrix is unitary and hence its
+			 * transpose is its inverse. i0..i3 are y7,y5,y3,y1 respectively.
+			 */
+			tmp0 = dataUnit[c7];
+			tmp1 = dataUnit[c5];
+			tmp2 = dataUnit[c3];
+			tmp3 = dataUnit[c1];
+			z1 = tmp0 + tmp3;
+			z2 = tmp1 + tmp2;
+			z3 = tmp0 + tmp2;
+			z4 = tmp1 + tmp3;
+			z0 = (z3 + z4) * FIX_1_175875602;	/* sqrt(2) * c3 */
+			
+			tmp0 *= FIX_0_298631336;		/* sqrt(2) * (-c1+c3+c5-c7) */
+			tmp1 *= FIX_2_053119869;		/* sqrt(2) * ( c1+c3-c5+c7) */
+			tmp2 *= FIX_3_072711026;		/* sqrt(2) * ( c1+c3+c5-c7) */
+			tmp3 *= FIX_1_501321110;		/* sqrt(2) * ( c1+c3-c5-c7) */
+			z1 *= 0 - FIX_0_899976223;	/* sqrt(2) * (c7-c3) */
+			z2 *= 0 - FIX_2_562915447;	/* sqrt(2) * (-c1-c3) */
+			z3 *= 0 - FIX_1_961570560;	/* sqrt(2) * (-c3-c5) */
+			z4 *= 0 - FIX_0_390180644;	/* sqrt(2) * (c5-c3) */
+			
+			z3 += z0;
+			z4 += z0;
+			
+			tmp0 += z1 + z3;
+			tmp1 += z2 + z4;
+			tmp2 += z2 + z3;
+			tmp3 += z1 + z4;
+
+			/* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */
+			dataUnit[c0] = (tmp10 + tmp3 + 131072) >> 18;
+			dataUnit[c7] = (tmp10 - tmp3 + 131072) >> 18;
+			dataUnit[c1] = (tmp11 + tmp2 + 131072) >> 18;
+			dataUnit[c6] = (tmp11 - tmp2 + 131072) >> 18;
+			dataUnit[c2] = (tmp12 + tmp1 + 131072) >> 18;
+			dataUnit[c5] = (tmp12 - tmp1 + 131072) >> 18;
+			dataUnit[c3] = (tmp13 + tmp0 + 131072) >> 18;
+			dataUnit[c4] = (tmp13 - tmp0 + 131072) >> 18;
+		}
+	}
+}
+boolean isFileFormat(LEDataInputStream stream) {
+	try {
+		JPEGStartOfImage soi = new JPEGStartOfImage(stream);
+		stream.unread(soi.reference);
+		return soi.verify();  // we no longer check for appN
+	} catch (Exception e) {
+		return false;
+	}
+}
+boolean isZeroInColumn(int[] dataUnit, int col) {
+	return dataUnit[col + 8] == 0 && dataUnit[col + 16] == 0
+			&& dataUnit[col + 24] == 0 && dataUnit[col + 32] == 0
+			&& dataUnit[col + 40] == 0 && dataUnit[col + 48] == 0
+			&& dataUnit[col + 56] == 0;
+}
+boolean isZeroInRow(int[] dataUnit, int rIndex) {
+	return dataUnit[rIndex + 1] == 0 && dataUnit[rIndex + 2] == 0
+			&& dataUnit[rIndex + 3] == 0 && dataUnit[rIndex + 4] == 0
+			&& dataUnit[rIndex + 5] == 0 && dataUnit[rIndex + 6] == 0
+			&& dataUnit[rIndex + 7] == 0;
+}
+ImageData[] loadFromByteStream() {
+	//TEMPORARY CODE
+	if (System.getProperty("org.eclipse.swt.internal.image.JPEGFileFormat_3.2") == null) {
+		return JPEGDecoder.loadFromByteStream(inputStream, loader);
+	}
+	JPEGStartOfImage soi = new JPEGStartOfImage(inputStream);
+	if (!soi.verify()) SWT.error(SWT.ERROR_INVALID_IMAGE);
+	restartInterval = 0;
+
+	/* Process the tables preceding the frame header. */
+	processTables();
+	
+	/* Start of Frame. */
+	frameHeader = new JPEGFrameHeader(inputStream);
+	if (!frameHeader.verify()) SWT.error(SWT.ERROR_INVALID_IMAGE);
+	imageWidth = frameHeader.getSamplesPerLine();
+	imageHeight = frameHeader.getNumberOfLines();
+	maxH = frameHeader.getMaxHFactor();
+	maxV = frameHeader.getMaxVFactor();
+	int mcuWidth = maxH * DCTSIZE;
+	int mcuHeight = maxV * DCTSIZE;
+	interleavedMcuCols = (imageWidth + mcuWidth - 1) / mcuWidth;
+	interleavedMcuRows = (imageHeight + mcuHeight - 1) / mcuHeight;
+	progressive = frameHeader.isProgressive();
+	samplePrecision = frameHeader.getSamplePrecision();
+	nComponents = frameHeader.getNumberOfImageComponents();
+	frameComponents = frameHeader.componentParameters;
+	componentIds = frameHeader.componentIdentifiers;
+	imageComponents = new byte[nComponents][];
+	if (progressive) {
+		// Progressive jpeg: need to keep all of the data units.
+		dataUnits = new int[nComponents][][];
+	} else {
+		// Sequential jpeg: only need one data unit.
+		dataUnit = new int[8 * 8];
+	}
+	for (int i = 0; i < nComponents; i++) {
+		int[] frameComponent = frameComponents[componentIds[i]];
+		int bufferSize = frameComponent[CW] * frameComponent[CH];
+		imageComponents[i] = new byte[bufferSize];
+		if (progressive) {
+			dataUnits[i] = new int[bufferSize][];
+		}
+	}
+
+	/* Process the tables preceding the scan header. */
+	processTables();
+	
+	/* Start of Scan. */
+	scanHeader = new JPEGScanHeader(inputStream);
+	if (!scanHeader.verify()) SWT.error(SWT.ERROR_INVALID_IMAGE);
+	
+	/* Process scan(s) and further tables until EOI. */
+	int progressiveScanCount = 0;
+	boolean done = false;
+	while(!done) {
+		resetInputBuffer();
+		precedingDCs = new int[4];
+		decodeScan();
+		if (progressive && loader.hasListeners()) {
+			ImageData imageData = createImageData();
+			loader.notifyListeners(new ImageLoaderEvent(loader, imageData, progressiveScanCount, false));
+			progressiveScanCount++;
+		}
+
+		/* Unread any buffered data before looking for tables again. */
+		int delta = 512 - bufferCurrentPosition - 1;
+		if (delta > 0) {
+			byte[] unreadBuffer = new byte[delta];
+			System.arraycopy(dataBuffer, bufferCurrentPosition + 1, unreadBuffer, 0, delta);
+			try {
+				inputStream.unread(unreadBuffer);
+			} catch (IOException e) {
+				SWT.error(SWT.ERROR_IO, e);
+			}
+		}
+		
+		/* Process the tables preceding the next scan header. */
+		JPEGSegment jpegSegment = processTables();
+		if (jpegSegment == null || jpegSegment.getSegmentMarker() == EOI) {
+			done = true;
+		} else {
+			scanHeader = new JPEGScanHeader(inputStream);
+			if (!scanHeader.verify()) SWT.error(SWT.ERROR_INVALID_IMAGE);
+		}
+	}
+	
+	if (progressive) {
+		for (int ymcu = 0; ymcu < interleavedMcuRows; ymcu++) {
+			for (int xmcu = 0; xmcu < interleavedMcuCols; xmcu++) {
+				for (int iComp = 0; iComp < nComponents; iComp++) {
+					int[] frameComponent = frameComponents[componentIds[iComp]];
+					int hi = frameComponent[HI];
+					int vi = frameComponent[VI];
+					int compWidth = frameComponent[CW];
+					for (int ivi = 0; ivi < vi; ivi++) {
+						for (int ihi = 0; ihi < hi; ihi++) {
+							int index = (ymcu * vi + ivi) * compWidth + xmcu * hi + ihi;
+							dataUnit = dataUnits[iComp][index];
+							dequantize(dataUnit, iComp);
+							inverseDCT(dataUnit);
+							storeData(dataUnit, iComp, xmcu, ymcu, hi, ihi, vi, ivi);
+						}
+					}
+				}
+			}
+		}
+		dataUnits = null; // release memory
+	}
+	ImageData imageData = createImageData();
+	if (progressive && loader.hasListeners()) {
+		loader.notifyListeners(new ImageLoaderEvent(loader, imageData, progressiveScanCount, true));
+	}
+	return new ImageData[] {imageData};
+}
+ImageData createImageData() {
+	return ImageData.internal_new(
+		imageWidth,
+		imageHeight, 
+		nComponents * samplePrecision,
+		setUpPalette(),
+		nComponents == 1 ? 4 : 1,
+		decodeImageComponents(),
+		0,
+		null,
+		null,
+		-1,
+		-1,
+		SWT.IMAGE_JPEG,
+		0,
+		0,
+		0,
+		0);
+}
+int nextBit() {
+	if (currentBitCount != 0) {
+		currentBitCount--;
+		currentByte *= 2;
+		if (currentByte > 255) {
+			currentByte -= 256;
+			return 1;
+		} else {
+			return 0;
+		}
+	}
+	bufferCurrentPosition++;
+	if (bufferCurrentPosition >= 512) {
+		resetInputBuffer();
+		bufferCurrentPosition = 0;
+	}
+	currentByte = dataBuffer[bufferCurrentPosition] & 0xFF;
+	currentBitCount = 8;
+	byte nextByte;
+	if (bufferCurrentPosition == 511) {
+		resetInputBuffer();
+		currentBitCount = 8;
+		nextByte = dataBuffer[0];
+	} else {
+		nextByte = dataBuffer[bufferCurrentPosition + 1];
+	}
+	if (currentByte == 0xFF) {
+		if (nextByte == 0) {
+			bufferCurrentPosition ++;
+			currentBitCount--;
+			currentByte *= 2;
+			if (currentByte > 255) {
+				currentByte -= 256;
+				return 1;
+			} else {
+				return 0;
+			}
+		} else {
+			if ((nextByte & 0xFF) + 0xFF00 == DNL) {
+				getDNL();
+				return 0;
+			} else {
+				SWT.error(SWT.ERROR_INVALID_IMAGE);
+				return 0;
+			}
+		}
+	} else {
+		currentBitCount--;
+		currentByte *= 2;
+		if (currentByte > 255) {
+			currentByte -= 256;
+			return 1;
+		} else {
+			return 0;
+		}
+	}
+}
+void processRestartInterval() {
+	do {
+		bufferCurrentPosition++;
+		if (bufferCurrentPosition > 511) {
+			resetInputBuffer();
+			bufferCurrentPosition = 0;
+		}
+		currentByte = dataBuffer[bufferCurrentPosition] & 0xFF;
+	} while (currentByte != 0xFF);
+	while (currentByte == 0xFF) {
+		bufferCurrentPosition++;
+		if (bufferCurrentPosition > 511) {
+			resetInputBuffer();
+			bufferCurrentPosition = 0;
+		}
+		currentByte = dataBuffer[bufferCurrentPosition] & 0xFF;
+	}
+	if (currentByte != ((RST0 + nextRestartNumber) & 0xFF)) {
+		SWT.error(SWT.ERROR_INVALID_IMAGE);
+	}
+	bufferCurrentPosition++;
+	if (bufferCurrentPosition > 511) {
+		resetInputBuffer();
+		bufferCurrentPosition = 0;
+	}
+	currentByte = dataBuffer[bufferCurrentPosition] & 0xFF;
+	currentBitCount = 8;
+	restartsToGo = restartInterval;
+	nextRestartNumber = (nextRestartNumber + 1) & 0x7;
+	precedingDCs = new int[4];
+	eobrun = 0;
+}
+/* Process all markers until a frame header, scan header, or EOI is found. */
+JPEGSegment processTables() {
+	while (true) {
+		JPEGSegment jpegSegment = seekUnspecifiedMarker(inputStream);
+		if (jpegSegment == null) return null;
+		JPEGFrameHeader sof = new JPEGFrameHeader(jpegSegment.reference);
+		if (sof.verify()) {
+			return jpegSegment;
+		}
+		int marker = jpegSegment.getSegmentMarker();
+		switch (marker) {
+			case SOI: // there should only be one SOI per file
+				SWT.error(SWT.ERROR_INVALID_IMAGE);
+			case EOI:
+			case SOS:
+				return jpegSegment;
+			case DQT:
+				getDQT();
+				break;
+			case DHT:
+				getDHT();
+				break;
+			case DAC:
+				getDAC();
+				break;
+			case DRI:
+				getDRI();
+				break;
+			case APP0:
+				getAPP0();
+				break;
+			case COM:
+				getCOM();
+				break;
+			default:
+				skipSegmentFrom(inputStream);
+			
+		}
+	}
+}
+void quantizeData(int[] dataUnit, int iComp) {
+	int[] qTable = quantizationTables[frameComponents[componentIds[iComp]][TQI]];
+	for (int i = 0; i < dataUnit.length; i++) {
+		int zzIndex = ZigZag8x8[i];
+		int data = dataUnit[zzIndex];
+		int absData = data < 0 ? 0 - data : data;
+		int qValue = qTable[i];
+		int q2 = qValue >> 1;
+		absData += q2;
+		if (absData < qValue) {
+			dataUnit[zzIndex] = 0;
+		} else {
+			absData /= qValue;
+			if (data >= 0) {
+				dataUnit[zzIndex] = absData;
+			} else {
+				dataUnit[zzIndex] = 0 - absData;
+			}
+		}
+	}
+}
+int receive(int nBits) {
+	int v = 0;
+	for (int i = 0; i < nBits; i++) {
+		v = v * 2 + nextBit();
+	}
+	return v;
+}
+void resetInputBuffer() {
+	if (dataBuffer == null) {
+		dataBuffer = new byte[512];
+	}
+	try {
+		inputStream.read(dataBuffer);
+	} catch (IOException e) {
+		SWT.error(SWT.ERROR_IO, e);
+	}
+	currentBitCount = 0;
+	bufferCurrentPosition = -1;
+}
+void resetOutputBuffer() {
+	if (dataBuffer == null) {
+		dataBuffer = new byte[512];
+	} else {
+		try {
+			outputStream.write(dataBuffer, 0, bufferCurrentPosition);
+		} catch (IOException e) {
+			SWT.error(SWT.ERROR_IO, e);
+		}
+	}
+	bufferCurrentPosition = 0;
+}
+static JPEGSegment seekUnspecifiedMarker(LEDataInputStream byteStream) {
+	byte[] byteArray = new byte[2];
+	try {
+		while (true) {
+			if (byteStream.read(byteArray, 0, 1) != 1) return null;
+			if (byteArray[0] == (byte) 0xFF) {
+				if (byteStream.read(byteArray, 1, 1) != 1) return null;
+				if (byteArray[1] != (byte) 0xFF && byteArray[1] != 0) {
+					byteStream.unread(byteArray);
+					return new JPEGSegment(byteArray);
+				}
+			}
+		}
+	} catch (IOException e) {
+		SWT.error(SWT.ERROR_IO, e);
+	}
+	return null;
+}
+PaletteData setUpPalette() {
+	if (nComponents == 1) {
+		RGB[] entries = new RGB[256];
+		for (int i = 0; i < 256; i++) {
+			entries[i] = new RGB(i, i, i);
+		}
+		return new PaletteData(entries);
+	}
+	return new PaletteData(0xFF, 0xFF00, 0xFF0000);
+}
+static void skipSegmentFrom(LEDataInputStream byteStream) {
+	try {
+		byte[] byteArray = new byte[4];
+		JPEGSegment jpegSegment = new JPEGSegment(byteArray);
+	
+		if (byteStream.read(byteArray) != byteArray.length) {
+			SWT.error(SWT.ERROR_INVALID_IMAGE);
+		}
+		if (!(byteArray[0] == -1 && byteArray[1] != 0 && byteArray[1] != -1)) {
+			SWT.error(SWT.ERROR_INVALID_IMAGE);
+		}
+		int delta = jpegSegment.getSegmentLength() - 2;
+		byteStream.skip(delta);
+	} catch (Exception e) {
+		SWT.error(SWT.ERROR_IO, e);
+	}
+}
+void storeData(int[] dataUnit, int iComp, int xmcu, int ymcu, int hi, int ihi, int vi, int ivi) {
+	byte[] compImage = imageComponents[iComp];
+	int[] frameComponent = frameComponents[componentIds[iComp]];
+	int compWidth = frameComponent[CW];
+	int destIndex = ((ymcu * vi + ivi) * compWidth * DCTSIZE) + ((xmcu * hi + ihi) * DCTSIZE);
+	int srcIndex = 0;
+	for (int i = 0; i < DCTSIZE; i++) {
+		for (int col = 0; col < DCTSIZE; col++) {
+			int x = dataUnit[srcIndex] + 128;
+			if (x < 0) {
+				x = 0;
+			} else {
+				if (x > 255) x = 255;
+			}
+			compImage[destIndex + col] = (byte)x;
+			srcIndex++;
+		}
+		destIndex += compWidth;
+	}
+}
+void unloadIntoByteStream(ImageLoader loader) {
+	ImageData image = loader.data[0];
+	if (!new JPEGStartOfImage().writeToStream(outputStream)) {
+		SWT.error(SWT.ERROR_IO);
+	}
+	JPEGAppn appn = new JPEGAppn(new byte[] {(byte)0xFF, (byte)0xE0, 0, 0x10, 0x4A, 0x46, 0x49, 0x46, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0});
+	if (!appn.writeToStream(outputStream)) {
+		SWT.error(SWT.ERROR_IO);
+	}
+	quantizationTables = new int[4][];
+	JPEGQuantizationTable chromDQT = JPEGQuantizationTable.defaultChrominanceTable();
+	chromDQT.scaleBy(encoderQFactor);
+	int[] jpegDQTKeys = chromDQT.getQuantizationTablesKeys();
+	int[][] jpegDQTValues = chromDQT.getQuantizationTablesValues();
+	for (int i = 0; i < jpegDQTKeys.length; i++) {
+		quantizationTables[jpegDQTKeys[i]] = jpegDQTValues[i];
+	}
+	JPEGQuantizationTable lumDQT = JPEGQuantizationTable.defaultLuminanceTable();
+	lumDQT.scaleBy(encoderQFactor);
+	jpegDQTKeys = lumDQT.getQuantizationTablesKeys();
+	jpegDQTValues = lumDQT.getQuantizationTablesValues();
+	for (int i = 0; i < jpegDQTKeys.length; i++) {
+		quantizationTables[jpegDQTKeys[i]] = jpegDQTValues[i];
+	}
+	if (!lumDQT.writeToStream(outputStream)) {
+		SWT.error(SWT.ERROR_IO);
+	}
+	if (!chromDQT.writeToStream(outputStream)) {
+		SWT.error(SWT.ERROR_IO);
+	}
+	int frameLength, scanLength, precision;
+	int[][] frameParams, scanParams;
+	if (image.depth == 1) {
+		frameLength = 11;
+		frameParams = new int[1][];
+		frameParams[0] = new int[] {1, 1, 1, 0, 0};
+		scanParams = new int[1][];
+		scanParams[0] = new int[] {0, 0};
+		scanLength = 8;
+		nComponents = 1;
+		precision = 1;
+	} else {
+		frameLength = 17;
+		frameParams = new int[3][];
+		frameParams[0] = new int[] {0, 2, 2, 0, 0};
+		frameParams[1] = new int[] {1, 1, 1, 0, 0};
+		frameParams[2] = new int[] {1, 1, 1, 0, 0};
+		scanParams = new int[3][];
+		scanParams[0] = new int[] {0, 0};
+		scanParams[1] = new int[] {1, 1};
+		scanParams[2] = new int[] {1, 1};
+		scanLength = 12;
+		nComponents = 3;
+		precision = 8;
+	}
+	imageWidth = image.width;
+	imageHeight = image.height;
+	frameHeader = new JPEGFrameHeader(new byte[19]);
+	frameHeader.setSegmentMarker(SOF0);
+	frameHeader.setSegmentLength(frameLength);
+	frameHeader.setSamplePrecision(precision);
+	frameHeader.setSamplesPerLine(imageWidth);
+	frameHeader.setNumberOfLines(imageHeight);
+	frameHeader.setNumberOfImageComponents(nComponents);
+	frameHeader.componentParameters = frameParams;
+	frameHeader.componentIdentifiers = new int[] {0, 1, 2};
+	frameHeader.initializeContents();
+	if (!frameHeader.writeToStream(outputStream)) {
+		SWT.error(SWT.ERROR_IO);
+	}
+	frameComponents = frameParams;
+	componentIds = frameHeader.componentIdentifiers;
+	maxH = frameHeader.getMaxHFactor();
+	maxV = frameHeader.getMaxVFactor();
+	int mcuWidth = maxH * DCTSIZE;
+	int mcuHeight = maxV * DCTSIZE;
+	interleavedMcuCols = (imageWidth + mcuWidth - 1) / mcuWidth;
+	interleavedMcuRows = (imageHeight + mcuHeight - 1) / mcuHeight;
+	acHuffmanTables = new JPEGHuffmanTable[4];
+	dcHuffmanTables = new JPEGHuffmanTable[4];
+	JPEGHuffmanTable[] dhtTables = new JPEGHuffmanTable[] {
+		JPEGHuffmanTable.getDefaultDCLuminanceTable(),
+		JPEGHuffmanTable.getDefaultDCChrominanceTable(),
+		JPEGHuffmanTable.getDefaultACLuminanceTable(),
+		JPEGHuffmanTable.getDefaultACChrominanceTable()
+	};
+	for (int i = 0; i < dhtTables.length; i++) {
+		JPEGHuffmanTable dhtTable = dhtTables[i];
+		if (!dhtTable.writeToStream(outputStream)) {
+			SWT.error(SWT.ERROR_IO);
+		}
+		JPEGHuffmanTable[] allTables = dhtTable.getAllTables();
+		for (int j = 0; j < allTables.length; j++) {
+			JPEGHuffmanTable huffmanTable = allTables[j];
+			if (huffmanTable.getTableClass() == 0) {
+				dcHuffmanTables[huffmanTable.getTableIdentifier()] = huffmanTable;
+			} else {
+				acHuffmanTables[huffmanTable.getTableIdentifier()] = huffmanTable;
+			}
+		}
+	}
+	precedingDCs = new int[4];
+	scanHeader = new JPEGScanHeader(new byte[14]);
+	scanHeader.setSegmentMarker(SOS);
+	scanHeader.setSegmentLength(scanLength);
+	scanHeader.setNumberOfImageComponents(nComponents);
+	scanHeader.setStartOfSpectralSelection(0);
+	scanHeader.setEndOfSpectralSelection(63);
+	scanHeader.componentParameters = scanParams;
+	scanHeader.initializeContents();
+	if (!scanHeader.writeToStream(outputStream)) {
+		SWT.error(SWT.ERROR_IO);
+	}
+	convertImageToYCbCr(image);
+	resetOutputBuffer();
+	currentByte = 0;
+	currentBitCount = 0;
+	encodeScan();
+	if (!new JPEGEndOfImage().writeToStream(outputStream)) {
+		SWT.error(SWT.ERROR_IO);
+	}
+}
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/JPEGFileFormat.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/JPEGFixedSizeSegment.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/JPEGFixedSizeSegment.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/JPEGFixedSizeSegment.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.image;
+
+ 
+import org.eclipse.swt.*;
+
+abstract class JPEGFixedSizeSegment extends JPEGSegment {
+
+	public JPEGFixedSizeSegment() {
+		reference = new byte[fixedSize()];
+		setSegmentMarker(signature());
+	}
+	
+	public JPEGFixedSizeSegment(byte[] reference) {
+		super(reference);
+	}
+	
+	public JPEGFixedSizeSegment(LEDataInputStream byteStream) {
+		reference = new byte[fixedSize()];
+		try {
+			byteStream.read(reference);
+		} catch (Exception e) { 
+			SWT.error(SWT.ERROR_IO, e);
+		}
+	}
+	
+	abstract public int fixedSize();
+
+	public int getSegmentLength() {
+		return fixedSize() - 2;
+	}
+	
+	public void setSegmentLength(int length) {
+	}
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/JPEGFixedSizeSegment.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/JPEGFrameHeader.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/JPEGFrameHeader.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/JPEGFrameHeader.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,214 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.image;
+
+
+import org.eclipse.swt.*;
+
+final class JPEGFrameHeader extends JPEGVariableSizeSegment {
+	int maxVFactor;
+	int maxHFactor;
+	public int[] componentIdentifiers;
+	public int[][] componentParameters;
+
+	public JPEGFrameHeader(byte[] reference) {
+		super(reference);
+	}
+	
+	public JPEGFrameHeader(LEDataInputStream byteStream) {
+		super(byteStream);
+		initializeComponentParameters();
+	}
+	
+	public int getSamplePrecision() {
+		return reference[4] & 0xFF;
+	}
+	
+	public int getNumberOfLines() {
+		return (reference[5] & 0xFF) << 8 | (reference[6] & 0xFF);
+	}
+	
+	public int getSamplesPerLine() {
+		return (reference[7] & 0xFF) << 8 | (reference[8] & 0xFF);
+	}
+	
+	public int getNumberOfImageComponents() {
+		return reference[9] & 0xFF;
+	}
+	
+	public void setSamplePrecision(int precision) {
+		reference[4] = (byte)(precision & 0xFF);
+	}
+	
+	public void setNumberOfLines(int anInteger) {
+		reference[5] = (byte)((anInteger & 0xFF00) >> 8);
+		reference[6] = (byte)(anInteger & 0xFF);
+	}
+	
+	public void setSamplesPerLine(int samples) {
+		reference[7] = (byte)((samples & 0xFF00) >> 8);
+		reference[8] = (byte)(samples & 0xFF);
+	}
+	
+	public void setNumberOfImageComponents(int anInteger) {
+		reference[9] = (byte)(anInteger & 0xFF);
+	}
+	
+	public int getMaxHFactor() {
+		return maxHFactor;
+	}
+	
+	public int getMaxVFactor() {
+		return maxVFactor;
+	}
+	
+	public void setMaxHFactor(int anInteger) {
+		maxHFactor = anInteger;
+	}
+	
+	public void setMaxVFactor(int anInteger) {
+		maxVFactor = anInteger;
+	}
+	
+	/* Used when decoding. */
+	void initializeComponentParameters() {
+		int nf = getNumberOfImageComponents();
+		componentIdentifiers = new int[nf];
+		int[][] compSpecParams = new int[0][];
+		int hmax = 1;
+		int vmax = 1;
+		for (int i = 0; i < nf; i++) {
+			int ofs = i * 3 + 10;
+			int ci = reference[ofs] & 0xFF;
+			componentIdentifiers[i] = ci;
+			int hi = (reference[ofs + 1] & 0xFF) >> 4;
+			int vi = reference[ofs + 1] & 0xF;
+			int tqi = reference[ofs + 2] & 0xFF;
+			if (hi > hmax) {
+				hmax = hi;
+			}
+			if (vi > vmax) {
+				vmax = vi;
+			}
+			int[] compParam = new int[5];
+			compParam[0] = tqi;
+			compParam[1] = hi;
+			compParam[2] = vi;
+			if (compSpecParams.length <= ci) {
+				int[][] newParams = new int[ci + 1][];
+				System.arraycopy(compSpecParams, 0, newParams, 0, compSpecParams.length);
+				compSpecParams = newParams;
+			}
+			compSpecParams[ci] = compParam;
+		}
+		int x = getSamplesPerLine();
+		int y = getNumberOfLines();
+		int[] multiples = new int[] { 8, 16, 24, 32 };
+		for (int i = 0; i < nf; i++) {
+			int[] compParam = compSpecParams[componentIdentifiers[i]];
+			int hi = compParam[1];
+			int vi = compParam[2];
+			int compWidth = (x * hi + hmax - 1) / hmax;
+			int compHeight = (y * vi + vmax - 1) / vmax;
+			int dsWidth = roundUpToMultiple(compWidth, multiples[hi - 1]);
+			int dsHeight = roundUpToMultiple(compHeight, multiples[vi - 1]);
+			compParam[3] = dsWidth;
+			compParam[4] = dsHeight;
+		}
+		setMaxHFactor(hmax);
+		setMaxVFactor(vmax);
+		componentParameters = compSpecParams;
+	}
+	
+	/* Used when encoding. */
+	public void initializeContents() {
+		int nf = getNumberOfImageComponents();
+		if (nf == 0 || nf != componentParameters.length) {
+			SWT.error(SWT.ERROR_INVALID_IMAGE);
+		}
+		int hmax = 0;
+		int vmax = 0;
+		int[][] compSpecParams = componentParameters;
+		for (int i = 0; i < nf; i++) {
+			int ofs = i * 3 + 10;
+			int[] compParam = compSpecParams[componentIdentifiers[i]];
+			int hi = compParam[1];
+			int vi = compParam[2];
+			if (hi * vi > 4) {
+				SWT.error(SWT.ERROR_INVALID_IMAGE);
+			}
+			reference[ofs] = (byte)(i + 1);
+			reference[ofs + 1] = (byte)(hi * 16 + vi);
+			reference[ofs + 2] = (byte)(compParam[0]);
+			if (hi > hmax) hmax = hi;
+			if (vi > vmax) vmax = vi;
+		}
+		int x = getSamplesPerLine();
+		int y = getNumberOfLines();
+		int[] multiples = new int[] {8, 16, 24, 32};
+		for (int i = 0; i < nf; i++) {
+			int[] compParam = compSpecParams[componentIdentifiers[i]];
+			int hi = compParam[1];
+			int vi = compParam[2];
+			int compWidth = (x * hi + hmax - 1) / hmax;
+			int compHeight = (y * vi + vmax - 1) / vmax;
+			int dsWidth = roundUpToMultiple(compWidth, multiples[hi - 1]);
+			int dsHeight = roundUpToMultiple(compHeight, multiples[vi - 1]);
+			compParam[3] = dsWidth;
+			compParam[4] = dsHeight;
+		}
+		setMaxHFactor(hmax);
+		setMaxVFactor(vmax);
+	}
+	
+	int roundUpToMultiple(int anInteger, int mInteger) {
+		int a = anInteger + mInteger - 1;
+		return a - (a % mInteger);
+	}
+	
+	/*
+	 * Verify the information contained in the receiver is correct.
+	 * Answer true if the header contains a valid marker. Otherwise,
+	 * answer false. Valid Start Of Frame markers are:
+	 *	SOF_0  - Baseline DCT, Huffman coding
+	 *	SOF_1  - Extended sequential DCT, Huffman coding
+	 *	SOF_2  - Progressive DCT, Huffman coding
+	 *	SOF_3  - Lossless (sequential), Huffman coding
+	 *	SOF_5  - Differential sequential, Huffman coding
+	 *	SOF_6  - Differential progressive, Huffman coding
+	 *	SOF_7  - Differential lossless, Huffman coding
+	 *	SOF_9  - Extended sequential DCT, arithmetic coding
+	 *	SOF_10 - Progressive DCT, arithmetic coding
+	 *	SOF_11 - Lossless (sequential), arithmetic coding
+	 *	SOF_13 - Differential sequential, arithmetic coding
+	 *	SOF_14 - Differential progressive, arithmetic coding
+	 *	SOF_15 - Differential lossless, arithmetic coding
+	 */
+	public boolean verify() {
+		int marker = getSegmentMarker();
+		return (marker >= JPEGFileFormat.SOF0 && marker <= JPEGFileFormat.SOF3) ||
+			(marker >= JPEGFileFormat.SOF5 && marker <= JPEGFileFormat.SOF7) ||
+			(marker >= JPEGFileFormat.SOF9 && marker <= JPEGFileFormat.SOF11) ||
+			(marker >= JPEGFileFormat.SOF13 && marker <= JPEGFileFormat.SOF15);
+	}
+
+	public boolean isProgressive() {
+		int marker = getSegmentMarker();
+		return marker == JPEGFileFormat.SOF2
+			|| marker == JPEGFileFormat.SOF6
+			|| marker == JPEGFileFormat.SOF10
+			|| marker == JPEGFileFormat.SOF14;
+	}
+	
+	public boolean isArithmeticCoding() {
+		return getSegmentMarker() >= JPEGFileFormat.SOF9;
+	}
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/JPEGFrameHeader.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/JPEGHuffmanTable.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/JPEGHuffmanTable.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/JPEGHuffmanTable.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,264 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.image;
+
+
+/**
+ * JPEGHuffmanTable class actually represents two types of object:
+ * 1) A DHT (Define Huffman Tables) segment, which may represent
+ *	as many as 4 Huffman tables. In this case, the tables are
+ *	stored in the allTables array.
+ * 2) A single Huffman table. In this case, the allTables array
+ *	will be null.
+ * The 'reference' field is stored in both types of object, but
+ * 'initialize' is only called if the object represents a DHT.
+ */
+final class JPEGHuffmanTable extends JPEGVariableSizeSegment {
+	JPEGHuffmanTable[] allTables;
+	int tableClass;
+	int tableIdentifier;
+	int[] dhMaxCodes;
+	int[] dhMinCodes;
+	int[] dhValPtrs;
+	int[] dhValues;
+	int[] ehCodes;
+	byte[] ehCodeLengths;
+	static byte[] DCLuminanceTable = {
+		(byte)255, (byte)196, 0, 31, 0, 0, 1, 5, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0,
+		0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11
+	};
+	static byte[] DCChrominanceTable = {
+		(byte)255, (byte)196, 0, 31, 1, 0, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0,
+		0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11
+	};
+	static byte[] ACLuminanceTable = {
+		(byte)255, (byte)196, 0, (byte)181, 16, 0, 2, 1, 3, 3, 2, 4, 3, 5, 5, 4, 4, 0, 0, 1, 125, 
+		1, 2, 3, 0, 4, 17, 5, 18, 33, 49, 65, 6, 19, 81, 97, 7, 34, 113, 20, 
+		50, (byte)129, (byte)145, (byte)161, 8, 35, 66, (byte)177, (byte)193, 21, 82, (byte)209, (byte)240, 36, 51, 98, 
+		114, (byte)130, 9, 10, 22, 23, 24, 25, 26, 37, 38, 39, 40, 41, 42, 52, 53, 
+		54, 55, 56, 57, 58, 67, 68, 69, 70, 71, 72, 73, 74, 83, 84, 85, 86, 87, 
+		88, 89, 90, 99, 100, 101, 102, 103, 104, 105, 106, 115, 116, 117, 118, 
+		119, 120, 121, 122, (byte)131, (byte)132, (byte)133, (byte)134, (byte)135, (byte)136, (byte)137, (byte)138, (byte)146, (byte)147, (byte)148, 
+		(byte)149, (byte)150, (byte)151, (byte)152, (byte)153, (byte)154, (byte)162, (byte)163, (byte)164, (byte)165, (byte)166, (byte)167, (byte)168, (byte)169, (byte)170, 
+		(byte)178, (byte)179, (byte)180, (byte)181, (byte)182, (byte)183, (byte)184, (byte)185, (byte)186, (byte)194, (byte)195, (byte)196, (byte)197, (byte)198, (byte)199, 
+		(byte)200, (byte)201, (byte)202, (byte)210, (byte)211, (byte)212, (byte)213, (byte)214, (byte)215, (byte)216, (byte)217, (byte)218, (byte)225, (byte)226, (byte)227, 
+		(byte)228, (byte)229, (byte)230, (byte)231, (byte)232, (byte)233, (byte)234, (byte)241, (byte)242, (byte)243, (byte)244, (byte)245, (byte)246, (byte)247, (byte)248, 
+		(byte)249, (byte)250
+	};
+	static byte[] ACChrominanceTable = {
+		(byte)255, (byte)196, 0, (byte)181, 17, 0, 2, 1, 2, 4, 4, 3, 4, 7, 5, 4, 4, 0, 
+		1, 2, 119, 0, 1, 2, 3, 17, 4, 5, 33, 49, 6, 18, 65, 81, 7, 97, 113, 19, 34, 
+		50, (byte)129, 8, 20, 66, (byte)145, (byte)161, (byte)177, (byte)193, 9, 35, 
+		51, 82, (byte)240, 21, 98, 114, (byte)209, 10, 22, 36, 52, (byte)225, 37, 
+		(byte)241, 23, 24, 25, 26, 38, 39, 40, 41, 42, 53, 54, 55, 56, 57, 58, 67, 
+		68, 69, 70, 71, 72, 73, 74, 83, 84, 85, 86, 87, 88, 89, 90, 99, 100, 101, 102, 
+		103, 104, 105, 106, 115, 116, 117, 118, 119, 120, 121, 122, (byte)130, 
+		(byte)131, (byte)132, (byte)133, (byte)134, (byte)135, (byte)136, (byte)137, 
+		(byte)138, (byte)146, (byte)147, (byte)148, (byte)149, (byte)150, (byte)151, 
+		(byte)152, (byte)153, (byte)154, (byte)162, (byte)163, (byte)164, (byte)165, 
+		(byte)166, (byte)167, (byte)168, (byte)169, (byte)170, (byte)178, (byte)179, 
+		(byte)180, (byte)181, (byte)182, (byte)183, (byte)184, (byte)185, (byte)186, 
+		(byte)194, (byte)195, (byte)196, (byte)197, (byte)198, (byte)199, (byte)200, 
+		(byte)201, (byte)202, (byte)210, (byte)211, (byte)212, (byte)213, (byte)214, 
+		(byte)215, (byte)216, (byte)217, (byte)218, (byte)226, (byte)227, (byte)228, 
+		(byte)229, (byte)230, (byte)231, (byte)232, (byte)233, (byte)234, (byte)242, 
+		(byte)243, (byte)244, (byte)245, (byte)246, (byte)247, (byte)248, (byte)249, 
+		(byte)250
+	};
+	
+public JPEGHuffmanTable(byte[] reference) {
+	super(reference);
+}
+
+public JPEGHuffmanTable(LEDataInputStream byteStream) {
+	super(byteStream);
+	initialize();
+}
+
+public JPEGHuffmanTable[] getAllTables() {
+	return allTables;
+}
+
+public static JPEGHuffmanTable getDefaultACChrominanceTable() {
+	JPEGHuffmanTable result = new JPEGHuffmanTable(ACChrominanceTable);
+	result.initialize();
+	return result;
+}
+
+public static JPEGHuffmanTable getDefaultACLuminanceTable() {
+	JPEGHuffmanTable result = new JPEGHuffmanTable(ACLuminanceTable);
+	result.initialize();
+	return result;
+}
+
+public static JPEGHuffmanTable getDefaultDCChrominanceTable() {
+	JPEGHuffmanTable result = new JPEGHuffmanTable(DCChrominanceTable);
+	result.initialize();
+	return result;
+}
+
+public static JPEGHuffmanTable getDefaultDCLuminanceTable() {
+	JPEGHuffmanTable result = new JPEGHuffmanTable(DCLuminanceTable);
+	result.initialize();
+	return result;
+}
+
+public int[] getDhMaxCodes() {
+	return dhMaxCodes;
+}
+
+public int[] getDhMinCodes() {
+	return dhMinCodes;
+}
+
+public int[] getDhValPtrs() {
+	return dhValPtrs;
+}
+
+public int[] getDhValues() {
+	return dhValues;
+}
+
+public int getTableClass() {
+	return tableClass;
+}
+
+public int getTableIdentifier() {
+	return tableIdentifier;
+}
+
+void initialize() {
+	int totalLength = getSegmentLength() - 2;
+	int ofs = 4;
+	int[] bits = new int[16];
+	JPEGHuffmanTable[] huffTables = new JPEGHuffmanTable[8]; // maximum is 4 AC + 4 DC
+	int huffTableCount = 0;
+	while (totalLength > 0) {
+		int tc = (reference[ofs] & 0xFF) >> 4; // table class: AC (1) or DC (0)
+		int tid = reference[ofs] & 0xF; // table id: 0-1 baseline, 0-3 prog/ext
+		ofs++;
+		
+		/* Read the 16 count bytes and add them together to get the table size. */
+		int count = 0;
+		for (int i = 0; i < bits.length; i++) {
+			int bCount = reference[ofs + i] & 0xFF;
+			bits[i] = bCount;
+			count += bCount;
+		}
+		ofs += 16;
+		totalLength -= 17;
+		
+		/* Read the table. */
+		int[] huffVals = new int[count];
+		for (int i = 0; i < count; i++) {
+			huffVals[i] = reference[ofs + i] & 0xFF;
+		}
+		ofs += count;
+		totalLength -= count;
+		
+		/* Calculate the lengths. */
+		int[] huffCodeLengths = new int[50]; // start with 50 and increment as needed
+		int huffCodeLengthsIndex = 0;
+		for (int i = 0; i < 16; i++) {
+			for (int j = 0; j < bits[i]; j++) {
+				if (huffCodeLengthsIndex >= huffCodeLengths.length) {
+					int[] newHuffCodeLengths = new int[huffCodeLengths.length + 50];
+					System.arraycopy(huffCodeLengths, 0, newHuffCodeLengths, 0, huffCodeLengths.length);
+					huffCodeLengths = newHuffCodeLengths;
+				}
+				huffCodeLengths[huffCodeLengthsIndex] = i + 1;
+				huffCodeLengthsIndex++;
+			}
+		}
+		
+		/* Truncate huffCodeLengths to the correct size. */
+		if (huffCodeLengthsIndex < huffCodeLengths.length) {
+			int[] newHuffCodeLengths = new int[huffCodeLengthsIndex];
+			System.arraycopy(huffCodeLengths, 0, newHuffCodeLengths, 0, huffCodeLengthsIndex);
+			huffCodeLengths = newHuffCodeLengths;
+		}
+		
+		/* Calculate the Huffman codes. */
+		int[] huffCodes = new int[50]; // start with 50 and increment as needed
+		int huffCodesIndex = 0;
+		int k = 1;
+		int code = 0;
+		int si = huffCodeLengths[0];
+		int p = 0;
+		while (p < huffCodeLengthsIndex) {
+			while ((p < huffCodeLengthsIndex) && (huffCodeLengths[p] == si)) {
+				if (huffCodesIndex >= huffCodes.length) {
+					int[] newHuffCodes = new int[huffCodes.length + 50];
+					System.arraycopy(huffCodes, 0, newHuffCodes, 0, huffCodes.length);
+					huffCodes = newHuffCodes;
+				}
+				huffCodes[huffCodesIndex] = code;
+				huffCodesIndex++;
+				code++;
+				p++;
+			}
+			code *= 2;
+			si++;
+		}
+		
+		/* Truncate huffCodes to the correct size. */
+		if (huffCodesIndex < huffCodes.length) {
+			int[] newHuffCodes = new int[huffCodesIndex];
+			System.arraycopy(huffCodes, 0, newHuffCodes, 0, huffCodesIndex);
+			huffCodes = newHuffCodes;
+		}
+		
+		/* Calculate the maximum and minimum codes */
+		k = 0;
+		int[] maxCodes = new int[16];
+		int[] minCodes = new int[16];
+		int[] valPtrs = new int[16];
+		for (int i = 0; i < 16; i++) {
+			int bSize = bits[i];
+			if (bSize == 0) {
+				maxCodes[i] = -1;
+			} else {
+				valPtrs[i] = k;
+				minCodes[i] = huffCodes[k];
+				k += bSize;
+				maxCodes[i] = huffCodes[k - 1];
+			}
+		}
+		
+		/* Calculate the eHuffman codes and lengths. */
+		int[] eHuffCodes = new int[256];
+		byte[] eHuffSize = new byte[256];
+		for (int i = 0; i < huffCodesIndex; i++) {
+			eHuffCodes[huffVals[i]] = huffCodes[i];
+			eHuffSize[huffVals[i]] = (byte)huffCodeLengths[i];
+		}
+		
+		/* Create the new JPEGHuffmanTable and add it to the allTables array. */
+		JPEGHuffmanTable dhtTable = new JPEGHuffmanTable(reference);
+		dhtTable.tableClass = tc;
+		dhtTable.tableIdentifier = tid;
+		dhtTable.dhValues = huffVals;
+		dhtTable.dhMinCodes = minCodes;
+		dhtTable.dhMaxCodes = maxCodes;
+		dhtTable.dhValPtrs = valPtrs;
+		dhtTable.ehCodes = eHuffCodes;
+		dhtTable.ehCodeLengths = eHuffSize;
+		huffTables[huffTableCount] = dhtTable;
+		huffTableCount++;
+	}
+	allTables = new JPEGHuffmanTable[huffTableCount];
+	System.arraycopy(huffTables, 0, allTables, 0, huffTableCount);
+}
+
+public int signature() {
+	return JPEGFileFormat.DHT;
+}
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/JPEGHuffmanTable.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/JPEGQuantizationTable.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/JPEGQuantizationTable.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/JPEGQuantizationTable.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,165 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.image;
+
+
+final class JPEGQuantizationTable extends JPEGVariableSizeSegment {
+	public static byte[] DefaultLuminanceQTable = {
+		(byte)255, (byte)219, 0, 67, 0,
+		16, 11, 10, 16, 24, 40, 51, 61,
+		12, 12, 14, 19, 26, 58, 60, 55,
+		14, 13, 16, 24, 40, 57, 69, 56,
+		14, 17, 22, 29, 51, 87, 80, 62,
+		18, 22, 37, 56, 68, 109, 103, 77,
+		24, 35, 55, 64, 81, 104, 113, 92,
+		49, 64, 78, 87, 103, 121, 120, 101,
+		72, 92, 95, 98, 112, 100, 103, 99
+	};
+	public static byte[] DefaultChrominanceQTable = {
+		(byte)255, (byte)219, 0, 67, 1,
+		17, 18, 24, 47, 99, 99, 99, 99,
+		18, 21, 26, 66, 99, 99, 99, 99,
+		24, 26, 56, 99, 99, 99, 99, 99,
+		47, 66, 99, 99, 99, 99, 99, 99,
+		99, 99, 99, 99, 99, 99, 99, 99,
+		99, 99, 99, 99, 99, 99, 99, 99,
+		99, 99, 99, 99, 99, 99, 99, 99,
+		99, 99, 99, 99, 99, 99, 99, 99
+	};
+	
+public JPEGQuantizationTable(byte[] reference) {
+	super(reference);
+}
+
+public JPEGQuantizationTable(LEDataInputStream byteStream) {
+	super(byteStream);
+}
+
+public static JPEGQuantizationTable defaultChrominanceTable() {
+	byte[] data = new byte[DefaultChrominanceQTable.length];
+	System.arraycopy(DefaultChrominanceQTable, 0, data, 0, data.length);
+	return new JPEGQuantizationTable(data);
+}
+
+public static JPEGQuantizationTable defaultLuminanceTable() {
+	byte[] data = new byte[DefaultLuminanceQTable.length];
+	System.arraycopy(DefaultLuminanceQTable, 0, data, 0, data.length);
+	return new JPEGQuantizationTable(data);
+}
+
+public int[] getQuantizationTablesKeys() {
+	int[] keys = new int[4];
+	int keysIndex = 0;
+	int totalLength = getSegmentLength() - 2;
+	int ofs = 4;
+	while (totalLength > 64) {
+		int tq = reference[ofs] & 0xF;
+		int pq = (reference[ofs] & 0xFF) >> 4;
+		if (pq == 0) {
+			ofs += 65;
+			totalLength -= 65;
+		} else {
+			ofs += 129;
+			totalLength -= 129;
+		}
+		if (keysIndex >= keys.length) {
+			int[] newKeys = new int[keys.length + 4];
+			System.arraycopy(keys, 0, newKeys, 0, keys.length);
+			keys = newKeys;
+		}
+		keys[keysIndex] = tq;
+		keysIndex++;
+	}
+	int[] newKeys = new int[keysIndex];
+	System.arraycopy(keys, 0, newKeys, 0, keysIndex);
+	return newKeys;
+}
+
+public int[][] getQuantizationTablesValues() {
+	int[][] values = new int[4][];
+	int valuesIndex = 0;
+	int totalLength = getSegmentLength() - 2;
+	int ofs = 4;
+	while (totalLength > 64) {
+		int[] qk = new int[64];
+		int pq = (reference[ofs] & 0xFF) >> 4;
+		if (pq == 0) {
+			for (int i = 0; i < qk.length; i++) {
+				qk[i] = reference[ofs + i + 1] & 0xFF;
+			}
+			ofs += 65;
+			totalLength -= 65;
+		} else {
+			for (int i = 0; i < qk.length; i++) {
+				int idx = (i - 1) * 2 ;
+				qk[i] = (reference[ofs + idx + 1] & 0xFF) * 256 + (reference[ofs + idx + 2] & 0xFF);
+			}
+			ofs += 129;
+			totalLength -= 129;
+		}
+		if (valuesIndex >= values.length) {
+			int[][] newValues = new int[values.length + 4][];
+			System.arraycopy(values, 0, newValues, 0, values.length);
+			values = newValues;
+		}
+		values[valuesIndex] = qk;
+		valuesIndex++;
+	}
+	int[][] newValues = new int[valuesIndex][];
+	System.arraycopy(values, 0, newValues, 0, valuesIndex);
+	return newValues;
+}
+
+public void scaleBy(int qualityFactor) {
+	int qFactor = qualityFactor;
+	if (qFactor <= 0) {
+		qFactor = 1;
+	}
+	if (qFactor > 100) {
+		qFactor = 100;
+	}
+	if (qFactor < 50) {
+		qFactor = 5000 / qFactor;
+	} else {
+		qFactor = 200 - (qFactor * 2);
+	}
+	int totalLength = getSegmentLength() - 2;
+	int ofs = 4;
+	while (totalLength > 64) {
+//		int tq = reference[ofs] & 0xFF;
+		int pq = (reference[ofs] & 0xFF) >> 4;
+		if (pq == 0) {
+			for (int i = ofs + 1; i <= ofs + 64; i++) {
+				int temp = ((reference[i] & 0xFF) * qFactor + 50) / 100;
+				if (temp <= 0) temp = 1;
+				if (temp > 255) temp = 255;
+				reference[i] = (byte)temp;
+			}
+			ofs += 65;
+			totalLength -= 65;
+		} else {
+			for (int i = ofs + 1; i <= ofs + 128; i += 2) {
+				int temp = (((reference[i] & 0xFF) * 256 + (reference[i + 1] & 0xFF)) * qFactor + 50) / 100;
+				if (temp <= 0) temp = 1;
+				if (temp > 32767) temp = 32767;
+				reference[i] = (byte)(temp >> 8);
+				reference[i + 1] = (byte)(temp & 0xFF);
+			}
+			ofs += 129;
+			totalLength -= 129;
+		}
+	}
+}
+
+public int signature() {
+	return JPEGFileFormat.DQT;
+}
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/JPEGQuantizationTable.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/JPEGRestartInterval.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/JPEGRestartInterval.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/JPEGRestartInterval.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.image;
+
+
+final class JPEGRestartInterval extends JPEGFixedSizeSegment {
+
+	public JPEGRestartInterval(LEDataInputStream byteStream) {
+		super(byteStream);
+	}
+	
+	public int signature() {
+		return JPEGFileFormat.DRI;
+	}
+	
+	public int getRestartInterval() {
+		return ((reference[4] & 0xFF) << 8 | (reference[5] & 0xFF));
+	}
+
+	public int fixedSize() {
+		return 6;
+	}
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/JPEGRestartInterval.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/JPEGScanHeader.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/JPEGScanHeader.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/JPEGScanHeader.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,123 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.image;
+
+
+import org.eclipse.swt.*;
+
+final class JPEGScanHeader extends JPEGVariableSizeSegment {
+	public int[][] componentParameters;
+
+public JPEGScanHeader(byte[] reference) {
+	super(reference);
+}
+
+public JPEGScanHeader(LEDataInputStream byteStream) {
+	super(byteStream);
+	initializeComponentParameters();
+}
+
+public int getApproxBitPositionHigh() {
+	return reference[(2 * getNumberOfImageComponents()) + 7] >> 4;
+}
+
+public int getApproxBitPositionLow() {
+	return reference[(2 * getNumberOfImageComponents()) + 7] & 0xF;
+}
+
+public int getEndOfSpectralSelection() {
+	return reference[(2 * getNumberOfImageComponents()) + 6];
+}
+
+public int getNumberOfImageComponents() {
+	return reference[4];
+}
+
+public int getStartOfSpectralSelection() {
+	return reference[(2 * getNumberOfImageComponents()) + 5];
+}
+
+/* Used when decoding. */
+void initializeComponentParameters() {
+	int compCount = getNumberOfImageComponents();
+	componentParameters = new int[0][];
+	for (int i = 0; i < compCount; i++) {
+		int ofs = 5 + i * 2;
+		int cid = reference[ofs] & 0xFF;
+		int dc = (reference[ofs + 1] & 0xFF) >> 4;
+		int ac = reference[ofs + 1] & 0xF;
+		if (componentParameters.length <= cid) {
+			int[][] newParams = new int[cid + 1][];
+			System.arraycopy(componentParameters, 0, newParams, 0, componentParameters.length);
+			componentParameters = newParams;
+		}
+		componentParameters[cid] = new int[] { dc, ac };
+	}
+}
+
+/* Used when encoding. */
+public void initializeContents() {
+	int compCount = getNumberOfImageComponents();
+	int[][] compSpecParams = componentParameters;
+	if (compCount == 0 || compCount != compSpecParams.length) {
+		SWT.error(SWT.ERROR_INVALID_IMAGE);
+	}
+	for (int i = 0; i < compCount; i++) {
+		int ofs = i * 2 + 5;
+		int[] compParams = compSpecParams[i];
+		reference[ofs] = (byte)(i + 1);
+		reference[ofs + 1] = (byte)(compParams[0] * 16 + compParams[1]);
+	}
+}
+
+public void setEndOfSpectralSelection(int anInteger) {
+	reference[(2 * getNumberOfImageComponents()) + 6] = (byte)anInteger;
+}
+
+public void setNumberOfImageComponents(int anInteger) {
+	reference[4] = (byte)(anInteger & 0xFF);
+}
+
+public void setStartOfSpectralSelection(int anInteger) {
+	reference[(2 * getNumberOfImageComponents()) + 5] = (byte)anInteger;
+}
+
+public int signature() {
+	return JPEGFileFormat.SOS;
+}
+
+public boolean verifyProgressiveScan() {
+	int start = getStartOfSpectralSelection();
+	int end = getEndOfSpectralSelection();
+	int low = getApproxBitPositionLow();
+	int high = getApproxBitPositionHigh();
+	int count = getNumberOfImageComponents();
+	if ((start == 0 && end == 00) || (start <= end && end <= 63)) {
+		if (low <= 13 && high <= 13 && (high == 0 || high == low + 1)) {
+			return start == 0 || (start > 0 && count == 1);
+		}
+	}
+	return false;
+}
+
+public boolean isACProgressiveScan() {
+	return getStartOfSpectralSelection() != 0 && getEndOfSpectralSelection() != 0;
+}
+
+public boolean isDCProgressiveScan() {
+	return getStartOfSpectralSelection() == 0 && getEndOfSpectralSelection() == 0;
+}
+
+public boolean isFirstScan() {
+	return getApproxBitPositionHigh() == 0;
+}
+
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/JPEGScanHeader.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/JPEGSegment.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/JPEGSegment.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/JPEGSegment.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.image;
+
+
+class JPEGSegment {
+	public byte[] reference;
+
+	JPEGSegment() {
+	}
+	
+	public JPEGSegment(byte[] reference) {
+		this.reference = reference;
+	}
+	
+	public int signature() {
+		return 0;
+	}
+	
+	public boolean verify() {
+		return getSegmentMarker() == signature();
+	}
+	
+	public int getSegmentMarker() {
+		return ((reference[0] & 0xFF) << 8 | (reference[1] & 0xFF));
+	}
+	
+	public void setSegmentMarker(int marker) {
+		reference[0] = (byte)((marker & 0xFF00) >> 8);
+		reference[1] = (byte)(marker & 0xFF);
+	}
+	
+	public int getSegmentLength() {
+		return ((reference[2] & 0xFF) << 8 | (reference[3] & 0xFF));
+	}
+	
+	public void setSegmentLength(int length) {
+		reference[2] = (byte)((length & 0xFF00) >> 8);
+		reference[3] = (byte)(length & 0xFF);
+	}
+	
+	public boolean writeToStream(LEDataOutputStream byteStream) {
+		try {
+			byteStream.write(reference);
+			return true;
+		} catch (Exception e) {
+			return false;
+		}
+	}
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/JPEGSegment.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/JPEGStartOfImage.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/JPEGStartOfImage.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/JPEGStartOfImage.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.image;
+
+
+final class JPEGStartOfImage extends JPEGFixedSizeSegment {
+
+	public JPEGStartOfImage() {
+		super();
+	}
+	
+	public JPEGStartOfImage(byte[] reference) {
+		super(reference);
+	}
+	
+	public JPEGStartOfImage(LEDataInputStream byteStream) {
+		super(byteStream);
+	}
+	
+	public int signature() {
+		return JPEGFileFormat.SOI;
+	}
+	
+	public int fixedSize() {
+		return 2;
+	}
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/JPEGStartOfImage.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/JPEGVariableSizeSegment.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/JPEGVariableSizeSegment.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/JPEGVariableSizeSegment.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.image;
+
+
+import org.eclipse.swt.*;
+
+abstract class JPEGVariableSizeSegment extends JPEGSegment {
+
+	public JPEGVariableSizeSegment(byte[] reference) {
+		super(reference);
+	}
+	
+	public JPEGVariableSizeSegment(LEDataInputStream byteStream) {
+		try {
+			byte[] header = new byte[4];
+			byteStream.read(header);
+			reference = header; // to use getSegmentLength()
+			byte[] contents = new byte[getSegmentLength() + 2];
+			contents[0] = header[0];
+			contents[1] = header[1];
+			contents[2] = header[2];
+			contents[3] = header[3];
+			byteStream.read(contents, 4, contents.length - 4);
+			reference = contents;
+		} catch (Exception e) {
+			SWT.error(SWT.ERROR_IO, e);
+		}
+	}
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/JPEGVariableSizeSegment.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/LEDataInputStream.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/LEDataInputStream.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/LEDataInputStream.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,186 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.image;
+
+
+import java.io.*;
+
+final class LEDataInputStream extends InputStream {
+	int position;
+	InputStream in;
+
+	/**
+	 * The byte array containing the bytes to read.
+	 */
+	protected byte[] buf;
+	
+	/**
+	 * The current position within the byte array <code>buf</code>. A value
+	 * equal to buf.length indicates no bytes available.  A value of
+	 * 0 indicates the buffer is full.
+	 */
+	protected int pos;
+	
+
+	public LEDataInputStream(InputStream input) {
+		this(input, 512);
+	}
+	
+	public LEDataInputStream(InputStream input, int bufferSize) {
+		this.in = input;
+		if (bufferSize > 0) {
+			buf = new byte[bufferSize];
+			pos = bufferSize;
+		} 
+		else throw new IllegalArgumentException();
+	}
+	
+	public void close() throws IOException {
+		buf = null;
+		if (in != null) {
+			in.close();
+			in = null;
+		}
+	}
+	
+	/**
+	 * Answer how many bytes were read.
+	 */
+	public int getPosition() {
+		return position;
+	}
+	
+	/**
+	 * Answers how many bytes are available for reading without blocking
+	 */
+	public int available() throws IOException {
+		if (buf == null) throw new IOException();
+		return (buf.length - pos) + in.available();
+	}
+	
+	/**
+	 * Answer the next byte of the input stream.
+	 */
+	public int read() throws IOException {
+		if (buf == null) throw new IOException();
+		if (pos < buf.length) {
+			position++;
+			return (buf[pos++] & 0xFF);
+		}
+		int c = in.read();
+		if (c != -1) position++;
+		return c;
+	}
+	
+	/**
+	 * Don't imitate the JDK behaviour of reading a random number
+	 * of bytes when you can actually read them all.
+	 */
+	public int read(byte b[], int off, int len) throws IOException {
+		int read = 0, count;
+		while (read != len && (count = readData(b, off, len - read)) != -1) {
+			off += count;
+			read += count;
+		}
+		position += read;
+		if (read == 0 && read != len) return -1;
+		return read;
+	}
+	
+	/**
+ 	 * Reads at most <code>length</code> bytes from this LEDataInputStream and 
+ 	 * stores them in byte array <code>buffer</code> starting at <code>offset</code>.
+ 	 * <p>
+ 	 * Answer the number of bytes actually read or -1 if no bytes were read and 
+ 	 * end of stream was encountered.  This implementation reads bytes from 
+ 	 * the pushback buffer first, then the target stream if more bytes are required
+ 	 * to satisfy <code>count</code>.
+	 * </p>
+	 * @param buffer the byte array in which to store the read bytes.
+	 * @param offset the offset in <code>buffer</code> to store the read bytes.
+	 * @param length the maximum number of bytes to store in <code>buffer</code>.
+	 *
+	 * @return int the number of bytes actually read or -1 if end of stream.
+	 *
+	 * @exception java.io.IOException if an IOException occurs.
+	 */
+	private int readData(byte[] buffer, int offset, int length) throws IOException {
+		if (buf == null) throw new IOException();
+		if (offset < 0 || offset > buffer.length ||
+  		 	length < 0 || (length > buffer.length - offset)) {
+	 		throw new ArrayIndexOutOfBoundsException();
+		 	}
+				
+		int cacheCopied = 0;
+		int newOffset = offset;
+	
+		// Are there pushback bytes available?
+		int available = buf.length - pos;
+		if (available > 0) {
+			cacheCopied = (available >= length) ? length : available;
+			System.arraycopy(buf, pos, buffer, newOffset, cacheCopied);
+			newOffset += cacheCopied;
+			pos += cacheCopied;
+		}
+	
+		// Have we copied enough?
+		if (cacheCopied == length) return length;
+
+		int inCopied = in.read(buffer, newOffset, length - cacheCopied);
+
+		if (inCopied > 0) return inCopied + cacheCopied;
+		if (cacheCopied == 0) return inCopied;
+		return cacheCopied;
+	}
+	
+	/**
+	 * Answer an integer comprised of the next
+	 * four bytes of the input stream.
+	 */
+	public int readInt() throws IOException {
+		byte[] buf = new byte[4];
+		read(buf);
+		return ((buf[3] & 0xFF) << 24) | 
+			((buf[2] & 0xFF) << 16) | 
+			((buf[1] & 0xFF) << 8) | 
+			(buf[0] & 0xFF);
+	}
+	
+	/**
+	 * Answer a short comprised of the next
+	 * two bytes of the input stream.
+	 */
+	public short readShort() throws IOException {
+		byte[] buf = new byte[2];
+		read(buf);
+		return (short)(((buf[1] & 0xFF) << 8) | (buf[0] & 0xFF));
+	}
+	
+	/**
+	 * Push back the entire content of the given buffer <code>b</code>.
+	 * <p>
+	 * The bytes are pushed so that they would be read back b[0], b[1], etc. 
+	 * If the push back buffer cannot handle the bytes copied from <code>b</code>, 
+	 * an IOException will be thrown and no byte will be pushed back.
+	 * </p>
+	 * 
+	 * @param b the byte array containing bytes to push back into the stream
+	 *
+	 * @exception 	java.io.IOException if the pushback buffer is too small
+	 */
+	public void unread(byte[] b) throws IOException {
+		int length = b.length;
+		if (length > pos) throw new IOException();
+		position -= length;
+		pos -= length;
+		System.arraycopy(b, 0, buf, pos, length);
+	}
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/LEDataInputStream.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/LEDataOutputStream.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/LEDataOutputStream.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/LEDataOutputStream.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.image;
+
+
+import java.io.*;
+
+final class LEDataOutputStream extends OutputStream {
+	OutputStream out;
+public LEDataOutputStream(OutputStream output) {
+	this.out = output;
+}
+/**
+ * Write the specified number of bytes of the given byte array,
+ * starting at the specified offset, to the output stream.
+ */
+public void write(byte b[], int off, int len) throws IOException {
+	out.write(b, off, len);
+}
+/**
+ * Write the given byte to the output stream.
+ */
+public void write(int b) throws IOException {
+	out.write(b);
+}
+/**
+ * Write the given byte to the output stream.
+ */
+public void writeByte(byte b) throws IOException {
+	out.write(b & 0xFF);
+}
+/**
+ * Write the four bytes of the given integer
+ * to the output stream.
+ */
+public void writeInt(int theInt) throws IOException {
+	out.write(theInt & 0xFF);
+	out.write((theInt >> 8) & 0xFF);
+	out.write((theInt >> 16) & 0xFF);
+	out.write((theInt >> 24) & 0xFF);
+}
+/**
+ * Write the two bytes of the given short
+ * to the output stream.
+ */
+public void writeShort(int theShort) throws IOException {
+	out.write(theShort & 0xFF);
+	out.write((theShort >> 8) & 0xFF);
+}
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/LEDataOutputStream.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/LZWCodec.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/LZWCodec.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/LZWCodec.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,477 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.image;
+
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
+final class LZWCodec {
+	int bitsPerPixel, blockSize, blockIndex, currentByte, bitsLeft,
+		codeSize, clearCode, endCode, newCodes, topSlot, currentSlot,
+		imageWidth, imageHeight, imageX, imageY, pass, line, codeMask;
+	byte[] block, lineArray;
+	int[] stack, suffix, prefix;
+	LZWNode[] nodeStack;
+	LEDataInputStream inputStream;
+	LEDataOutputStream outputStream;
+	ImageData image;
+	ImageLoader loader;
+	boolean interlaced;
+	static final int[] MASK_TABLE = new int[] {
+		0x1, 0x3, 0x7, 0xF, 0x1F, 0x3F, 0x7F,
+		0xFF, 0x1FF, 0x3FF, 0x7FF, 0xFFF
+	};
+
+/**
+ * Decode the input.
+ */
+void decode() {
+	int code;
+	int oc = 0;
+	int fc = 0;
+	byte[] buf = new byte[imageWidth];
+	int stackIndex = 0;
+	int bufIndex = 0;
+	int c;
+	while ((c = nextCode()) != endCode) {
+		if (c == clearCode) {
+			codeSize = bitsPerPixel + 1;
+			codeMask = MASK_TABLE[bitsPerPixel];
+			currentSlot = newCodes;
+			topSlot = 1 << codeSize;
+			while ((c = nextCode()) == clearCode) {}
+			if (c != endCode) {
+				oc = fc = c;
+				buf[bufIndex] = (byte)c;
+				bufIndex++;
+				if (bufIndex == imageWidth) {
+					nextPutPixels(buf);
+					bufIndex = 0;
+				}
+			}
+		} else {
+			code = c;
+			if (code >= currentSlot) {
+				code = oc;
+				stack[stackIndex] = fc;
+				stackIndex++;
+			}
+			while (code >= newCodes) {
+				stack[stackIndex] = suffix[code];
+				stackIndex++;
+				code = prefix[code];
+			}
+			stack[stackIndex] = code;
+			stackIndex++;
+			if (currentSlot < topSlot) {
+				fc = code;
+				suffix[currentSlot] = fc;
+				prefix[currentSlot] = oc;
+				currentSlot++;
+				oc = c;
+			}
+			if (currentSlot >= topSlot) {
+				if (codeSize < 12) {
+					codeMask = MASK_TABLE[codeSize];
+					codeSize++;
+					topSlot = topSlot + topSlot;
+				}
+			}
+			while (stackIndex > 0) {
+				stackIndex--;
+				buf[bufIndex] = (byte)stack[stackIndex];
+				bufIndex++;
+				if (bufIndex == imageWidth) {
+					nextPutPixels(buf);
+					bufIndex = 0;
+				}
+			}
+		}
+	}
+	if (bufIndex != 0 && line < imageHeight) {
+		nextPutPixels(buf);
+	}
+}
+/**
+ * Decode the LZW-encoded bytes in the given byte stream
+ * into the given DeviceIndependentImage.
+ */
+public void decode(LEDataInputStream inputStream, ImageLoader loader, ImageData image, boolean interlaced, int depth) {
+	this.inputStream = inputStream;
+	this.loader = loader;
+	this.image = image;
+	this.interlaced = interlaced;
+	this.bitsPerPixel = depth;
+	initializeForDecoding();
+	decode();
+}
+/**
+ * Encode the image.
+ */
+void encode() {
+	nextPutCode(clearCode);
+	int lastPrefix = encodeLoop();
+	nextPutCode(lastPrefix);
+	nextPutCode(endCode);
+
+	// Write out last partial block
+	if (bitsLeft == 8) {
+		block[0] = (byte)(blockIndex - 1); // Nothing in last byte
+	} else {
+		block[0] = (byte)(blockIndex); // Last byte has data
+	}
+	writeBlock();
+
+	// Write out empty block to indicate the end (if needed)
+	if (block[0] != 0) {
+		block[0] = 0;
+		writeBlock();
+	}
+}
+/**
+ * Encode the bytes into the given byte stream
+ * from the given DeviceIndependentImage.
+ */
+public void encode(LEDataOutputStream byteStream, ImageData image) {
+	this.outputStream = byteStream;
+	this.image = image;
+	initializeForEncoding();
+	encode();
+}
+/**
+ * Encoding loop broken out to allow early return.
+ */
+int encodeLoop() {
+	int pixel = nextPixel();
+	boolean found;
+	LZWNode node;
+	while (true) {
+		int currentPrefix = pixel;
+		node = nodeStack[currentPrefix];
+		found = true;
+		pixel = nextPixel();
+		if (pixel < 0)
+			return currentPrefix;
+		while (found && (node.children != null)) {
+			node = node.children;
+			while (found && (node.suffix != pixel)) {
+				if (pixel < node.suffix) {
+					if (node.left == null) {
+						node.left = new LZWNode();
+						found = false;
+					}
+					node = node.left;
+				} else {
+					if (node.right == null) {
+						node.right = new LZWNode();
+						found = false;
+					}
+					node = node.right;
+				}
+			}
+			if (found) {
+				currentPrefix = node.code;
+				pixel = nextPixel();
+				if (pixel < 0)
+					return currentPrefix;
+			}
+		}
+		if (found) {
+			node.children = new LZWNode();
+			node = node.children;
+		}
+		node.children = null;
+		node.left = null;
+		node.right = null;
+		node.code = currentSlot;
+		node.prefix = currentPrefix;
+		node.suffix = pixel;
+		nextPutCode(currentPrefix);
+		currentSlot++;
+		// Off by one?
+		if (currentSlot < 4096) {
+			if (currentSlot > topSlot) {
+				codeSize++;
+				codeMask = MASK_TABLE[codeSize - 1];
+				topSlot *= 2;
+			}
+		} else {
+			nextPutCode(clearCode);
+			for (int i = 0; i < nodeStack.length; i++)
+				nodeStack[i].children = null;
+			codeSize = bitsPerPixel + 1;
+			codeMask = MASK_TABLE[codeSize - 1];
+			currentSlot = newCodes;
+			topSlot = 1 << codeSize;
+		}
+	}
+}
+/**
+ * Initialize the receiver for decoding the given
+ * byte array.
+ */
+void initializeForDecoding() {
+	pass = 1;
+	line = 0;
+	codeSize = bitsPerPixel + 1;
+	topSlot = 1 << codeSize;
+	clearCode = 1 << bitsPerPixel;
+	endCode = clearCode + 1;
+	newCodes = currentSlot = endCode + 1;
+	currentByte = -1;
+	blockSize = bitsLeft = 0;
+	blockIndex = 0;
+	codeMask = MASK_TABLE[codeSize - 1];
+	stack = new int[4096];
+	suffix = new int[4096];
+	prefix = new int[4096];
+	block = new byte[256];
+	imageWidth = image.width;
+	imageHeight = image.height;
+}
+/**
+ * Initialize the receiver for encoding the given
+ * byte array.
+ */
+void initializeForEncoding() {
+	interlaced = false;
+	bitsPerPixel = image.depth;
+	codeSize = bitsPerPixel + 1;
+	topSlot = 1 << codeSize;
+	clearCode = 1 << bitsPerPixel;
+	endCode = clearCode + 1;
+	newCodes = currentSlot = endCode + 1;
+	bitsLeft = 8;
+	currentByte = 0;
+	blockIndex = 1;
+	blockSize = 255;
+	block = new byte[blockSize];
+	block[0] = (byte)(blockSize - 1);
+	nodeStack = new LZWNode[1 << bitsPerPixel];
+	for (int i = 0; i < nodeStack.length; i++) {
+		LZWNode node = new LZWNode();
+		node.code = i + 1;
+		node.prefix = -1;
+		node.suffix = i + 1;
+		nodeStack[i] = node;
+	}
+	imageWidth = image.width;
+	imageHeight = image.height;
+	imageY = -1;
+	lineArray = new byte[imageWidth];
+	imageX = imageWidth + 1; // Force a read
+}
+/**
+ * Answer the next code from the input byte array.
+ */
+int nextCode() {
+	int code;
+	if (bitsLeft == 0) {
+		if (blockIndex >= blockSize) {
+			blockSize = readBlock();
+			blockIndex = 0;
+			if (blockSize == 0) return endCode;
+		}
+		blockIndex++;
+		currentByte = block[blockIndex] & 0xFF;
+		bitsLeft = 8;
+		code = currentByte;
+	} else {
+		int shift = bitsLeft - 8;
+		if (shift < 0)
+			code = currentByte >> (0 - shift);
+		else
+			code = currentByte << shift;
+	}
+	while (codeSize > bitsLeft) {
+		if (blockIndex >= blockSize) {
+			blockSize = readBlock();
+			blockIndex = 0;
+			if (blockSize == 0) return endCode;
+		}
+		blockIndex++;
+		currentByte = block[blockIndex] & 0xFF;
+		code += currentByte << bitsLeft;
+		bitsLeft += 8;
+	}
+	bitsLeft -= codeSize;
+	return code & codeMask;
+}
+/**
+ * Answer the next pixel to encode in the image
+ */
+int nextPixel() {
+	imageX++;
+	if (imageX > imageWidth) {
+		imageY++;
+		if (imageY >= imageHeight) {
+			return -1;
+		} else {
+			nextPixels(lineArray, imageWidth);
+		}
+		imageX = 1;
+	}
+	return this.lineArray[imageX - 1] & 0xFF;
+}
+/**
+ * Copy a row of pixel values from the image.
+ */
+void nextPixels(byte[] buf, int lineWidth) {
+	if (image.depth == 8) {
+		System.arraycopy(image.data, imageY * image.bytesPerLine, buf, 0, lineWidth);
+	} else {
+		image.getPixels(0, imageY, lineWidth, buf, 0);
+	}
+}
+/**
+ * Output aCode to the output stream.
+ */
+void nextPutCode(int aCode) {
+	int codeToDo = aCode;
+	int codeBitsToDo = codeSize;
+	// Fill in the remainder of the current byte with the
+	// *high-order* bits of the code.
+	int c = codeToDo & MASK_TABLE[bitsLeft - 1];
+	currentByte = currentByte | (c << (8 - bitsLeft));
+	block[blockIndex] = (byte)currentByte;
+	codeBitsToDo -= bitsLeft;
+	if (codeBitsToDo < 1) {
+		// The whole code fit in the first byte, so we are done.
+		bitsLeft -= codeSize;
+		if (bitsLeft == 0) {
+			// We used the whole last byte, so get ready
+			// for the next one.
+			bitsLeft = 8;
+			blockIndex++;
+			if (blockIndex >= blockSize) {
+				writeBlock();
+				blockIndex = 1;
+			}
+			currentByte = 0;
+		}
+		return;
+	}
+	codeToDo = codeToDo >> bitsLeft;
+
+	// Fill in any remaining whole bytes (i.e. not the last one!)
+	blockIndex++;
+	if (blockIndex >= blockSize) {
+		writeBlock();
+		blockIndex = 1;
+	}
+	while (codeBitsToDo >= 8) {
+		currentByte = codeToDo & 0xFF;
+		block[blockIndex] = (byte)currentByte;
+		codeToDo = codeToDo >> 8;
+		codeBitsToDo -= 8;
+		blockIndex++;
+		if (blockIndex >= blockSize) {
+			writeBlock();
+			blockIndex = 1;
+		}
+	}
+	// Fill the *low-order* bits of the last byte with the remainder
+	bitsLeft = 8 - codeBitsToDo;
+	currentByte = codeToDo;
+	block[blockIndex] = (byte)currentByte;
+}
+/**
+ * Copy a row of pixel values to the image.
+ */
+void nextPutPixels(byte[] buf) {
+	if (image.depth == 8) {
+		// Slight optimization for depth = 8.
+		int start = line * image.bytesPerLine;
+		for (int i = 0; i < imageWidth; i++)
+			image.data[start + i] = buf[i];
+	} else {
+		image.setPixels(0, line, imageWidth, buf, 0);
+	}
+	if (interlaced) {
+		if (pass == 1) {
+			copyRow(buf, 7);
+			line += 8;
+		} else if (pass == 2) {
+			copyRow(buf, 3);
+			line += 8;
+		} else if (pass == 3) {
+			copyRow(buf, 1);
+			line += 4;
+		} else if (pass == 4) {
+			line += 2;
+		} else if (pass == 5) {
+			line += 0;
+		}
+		if (line >= imageHeight) {
+			pass++;
+			if (pass == 2) line = 4;
+			else if (pass == 3) line = 2;
+			else if (pass == 4) line = 1;
+			else if (pass == 5) line = 0;
+			if (pass < 5) {
+				if (loader.hasListeners()) {
+					ImageData imageCopy = (ImageData) image.clone();
+					loader.notifyListeners(
+						new ImageLoaderEvent(loader, imageCopy, pass - 2, false));
+				}
+			}
+		}
+		if (line >= imageHeight) line = 0;
+	} else {
+		line++;
+	}
+}
+/**
+ * Copy duplicate rows of pixel values to the image.
+ * This is to fill in rows if the image is interlaced.
+ */
+void copyRow(byte[] buf, int copies) {
+	for (int i = 1; i <= copies; i++) {
+		if (line + i < imageHeight) {
+			image.setPixels(0, line + i, imageWidth, buf, 0);
+		}
+	}
+}
+/**
+ * Read a block from the byte stream.
+ * Return the number of bytes read.
+ * Throw an exception if the block could not be read.
+ */
+int readBlock() {
+	int size = -1;
+	try {
+		size = inputStream.read();
+		if (size == -1) {
+			SWT.error(SWT.ERROR_INVALID_IMAGE);
+		}
+		block[0] = (byte)size;
+		size = inputStream.read(block, 1, size);
+		if (size == -1) {
+			SWT.error(SWT.ERROR_INVALID_IMAGE);
+		}
+	} catch (Exception e) {
+		SWT.error(SWT.ERROR_IO, e);
+	}
+	return size;
+}
+/**
+ * Write a block to the byte stream.
+ * Throw an exception if the block could not be written.
+ */
+void writeBlock() {
+	try {
+		outputStream.write(block, 0, (block[0] & 0xFF) + 1);
+	} catch (Exception e) {
+		SWT.error(SWT.ERROR_IO, e);
+	}
+}
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/LZWCodec.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/LZWNode.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/LZWNode.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/LZWNode.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,17 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.image;
+
+
+final class LZWNode {
+	public LZWNode left, right, children;
+	public int code, prefix, suffix;
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/LZWNode.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/OS2BMPFileFormat.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/OS2BMPFileFormat.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/OS2BMPFileFormat.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,294 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.image;
+
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import java.io.*;
+
+public final class OS2BMPFileFormat extends FileFormat {
+	static final int BMPFileHeaderSize = 14;
+	static final int BMPHeaderFixedSize = 12;
+	int width, height, bitCount;
+
+boolean isFileFormat(LEDataInputStream stream) {
+	try {
+		byte[] header = new byte[18];
+		stream.read(header);
+		stream.unread(header);
+		int infoHeaderSize = (header[14] & 0xFF) | ((header[15] & 0xFF) << 8) | ((header[16] & 0xFF) << 16) | ((header[17] & 0xFF) << 24);
+		return header[0] == 0x42 && header[1] == 0x4D && infoHeaderSize == BMPHeaderFixedSize;
+	} catch (Exception e) {
+		return false;
+	}
+}
+byte[] loadData(byte[] infoHeader) {
+	int stride = (width * bitCount + 7) / 8;
+	stride = (stride + 3) / 4 * 4; // Round up to 4 byte multiple
+	byte[] data = loadData(infoHeader, stride);
+	flipScanLines(data, stride, height);
+	return data;
+}
+byte[] loadData(byte[] infoHeader, int stride) {
+	int dataSize = height * stride;
+	byte[] data = new byte[dataSize];
+	try {
+		if (inputStream.read(data) != dataSize)
+			SWT.error(SWT.ERROR_INVALID_IMAGE);
+	} catch (IOException e) {
+		SWT.error(SWT.ERROR_IO, e);
+	}
+	return data;
+}
+int[] loadFileHeader() {
+	int[] header = new int[5];
+	try {
+		header[0] = inputStream.readShort();
+		header[1] = inputStream.readInt();
+		header[2] = inputStream.readShort();
+		header[3] = inputStream.readShort();
+		header[4] = inputStream.readInt();
+	} catch (IOException e) {
+		SWT.error(SWT.ERROR_IO, e);
+	}
+	if (header[0] != 0x4D42)
+		SWT.error(SWT.ERROR_INVALID_IMAGE);
+	return header;
+}
+ImageData[] loadFromByteStream() {
+	int[] fileHeader = loadFileHeader();
+	byte[] infoHeader = new byte[BMPHeaderFixedSize];
+	try {
+		inputStream.read(infoHeader);
+	} catch (Exception e) {
+		SWT.error(SWT.ERROR_IO, e);
+	}
+	width = (infoHeader[4] & 0xFF) | ((infoHeader[5] & 0xFF) << 8);
+	height = (infoHeader[6] & 0xFF) | ((infoHeader[7] & 0xFF) << 8);
+	bitCount = (infoHeader[10] & 0xFF) | ((infoHeader[11] & 0xFF) << 8);
+	PaletteData palette = loadPalette(infoHeader);
+	if (inputStream.getPosition() < fileHeader[4]) {
+		// Seek to the specified offset
+		try {
+			inputStream.skip(fileHeader[4] - inputStream.getPosition());
+		} catch (IOException e) {
+			SWT.error(SWT.ERROR_IO, e);
+		}
+	}
+	byte[] data = loadData(infoHeader);
+	int type = SWT.IMAGE_OS2_BMP;
+	return new ImageData[] {
+		ImageData.internal_new(
+			width,
+			height,
+			bitCount,
+			palette,
+			4,
+			data,
+			0,
+			null,
+			null,
+			-1,
+			-1,
+			type,
+			0,
+			0,
+			0,
+			0)
+	};
+}
+PaletteData loadPalette(byte[] infoHeader) {
+	if (bitCount <= 8) {
+		int numColors = 1 << bitCount;
+		byte[] buf = new byte[numColors * 3];
+		try {
+			if (inputStream.read(buf) != buf.length)
+				SWT.error(SWT.ERROR_INVALID_IMAGE);
+		} catch (IOException e) {
+			SWT.error(SWT.ERROR_IO, e);
+		}
+		return paletteFromBytes(buf, numColors);
+	}
+	if (bitCount == 16) return new PaletteData(0x7C00, 0x3E0, 0x1F);
+	if (bitCount == 24) return new PaletteData(0xFF, 0xFF00, 0xFF0000);
+	return new PaletteData(0xFF00, 0xFF0000, 0xFF000000);
+}
+PaletteData paletteFromBytes(byte[] bytes, int numColors) {
+	int bytesOffset = 0;
+	RGB[] colors = new RGB[numColors];
+	for (int i = 0; i < numColors; i++) {
+		colors[i] = new RGB(bytes[bytesOffset + 2] & 0xFF,
+			bytes[bytesOffset + 1] & 0xFF,
+			bytes[bytesOffset] & 0xFF);
+		bytesOffset += 3;
+	}
+	return new PaletteData(colors);
+}
+/**
+ * Answer a byte array containing the BMP representation of
+ * the given device independent palette.
+ */
+static byte[] paletteToBytes(PaletteData pal) {
+	int n = pal.colors == null ? 0 : (pal.colors.length < 256 ? pal.colors.length : 256);
+	byte[] bytes = new byte[n * 3];
+	int offset = 0;
+	for (int i = 0; i < n; i++) {
+		RGB col = pal.colors[i];
+		bytes[offset] = (byte)col.blue;
+		bytes[offset + 1] = (byte)col.green;
+		bytes[offset + 2] = (byte)col.red;
+		offset += 3;
+	}
+	return bytes;
+}
+/**
+ * Unload the given image's data into the given byte stream. 
+ * Answer the number of bytes written.
+ */
+int unloadData(ImageData image, OutputStream out) {
+	int bmpBpl = 0;
+	try {
+		int bpl = (image.width * image.depth + 7) / 8;
+		bmpBpl = (bpl + 3) / 4 * 4; // BMP pads scanlines to multiples of 4 bytes
+		int linesPerBuf = 32678 / bmpBpl;
+		byte[] buf = new byte[linesPerBuf * bmpBpl];
+		byte[] data = image.data;
+		int imageBpl = image.bytesPerLine;
+		int dataIndex = imageBpl * (image.height - 1); // Start at last line
+		if (image.depth == 16) {
+			for (int y = 0; y < image.height; y += linesPerBuf) {
+				int count = image.height - y;
+				if (linesPerBuf < count) count = linesPerBuf;
+				int bufOffset = 0;
+				for (int i = 0; i < count; i++) {
+					for (int wIndex = 0; wIndex < bpl; wIndex += 2) {
+						buf[bufOffset + wIndex + 1] = data[dataIndex + wIndex + 1];
+						buf[bufOffset + wIndex] = data[dataIndex + wIndex];
+					}
+					bufOffset += bmpBpl;
+					dataIndex -= imageBpl;
+				}
+				out.write(buf, 0, bufOffset);
+			}
+		} else {
+			for (int y = 0; y < image.height; y += linesPerBuf) {
+				int tmp = image.height - y;
+				int count = tmp < linesPerBuf ? tmp : linesPerBuf;
+				int bufOffset = 0;
+				for (int i = 0; i < count; i++) {
+					System.arraycopy(data, dataIndex, buf, bufOffset, bpl);
+					bufOffset += bmpBpl;
+					dataIndex -= imageBpl;
+				}
+				out.write(buf, 0, bufOffset);
+			}
+		}
+	} catch (IOException e) {
+		SWT.error(SWT.ERROR_IO, e);
+	}
+	return bmpBpl * image.height;
+}
+/**
+ * Unload a DeviceIndependentImage using Windows .BMP format into the given
+ * byte stream.
+ */
+void unloadIntoByteStream(ImageLoader loader) {
+	ImageData image = loader.data[0];
+	byte[] rgbs;
+	int numCols;
+	if (!((image.depth == 1) || (image.depth == 4) || (image.depth == 8) ||
+		  (image.depth == 16) || (image.depth == 24) || (image.depth == 32)))
+			SWT.error(SWT.ERROR_UNSUPPORTED_DEPTH);
+	PaletteData pal = image.palette;
+	if ((image.depth == 16) || (image.depth == 24) || (image.depth == 32)) {
+		if (!pal.isDirect)
+			SWT.error(SWT.ERROR_INVALID_IMAGE);
+		numCols = 0;
+		rgbs = null;
+	} else {
+		if (pal.isDirect)
+			SWT.error(SWT.ERROR_INVALID_IMAGE);
+		numCols = pal.colors.length;
+		rgbs = paletteToBytes(pal);
+	}
+	// Fill in file header, except for bfsize, which is done later.
+	int headersSize = BMPFileHeaderSize + BMPHeaderFixedSize;
+	int[] fileHeader = new int[5];
+	fileHeader[0] = 0x4D42;	// Signature
+	fileHeader[1] = 0; // File size - filled in later
+	fileHeader[2] = 0; // Reserved 1
+	fileHeader[3] = 0; // Reserved 2
+	fileHeader[4] = headersSize; // Offset to data
+	if (rgbs != null) {
+		fileHeader[4] += rgbs.length;
+	}
+
+	// Prepare data. This is done first so we don't have to try to rewind
+	// the stream and fill in the details later.
+	ByteArrayOutputStream out = new ByteArrayOutputStream();
+	unloadData(image, out);
+	byte[] data = out.toByteArray();
+	
+	// Calculate file size
+	fileHeader[1] = fileHeader[4] + data.length;
+
+	// Write the headers
+	try {
+		outputStream.writeShort(fileHeader[0]);
+		outputStream.writeInt(fileHeader[1]);
+		outputStream.writeShort(fileHeader[2]);
+		outputStream.writeShort(fileHeader[3]);
+		outputStream.writeInt(fileHeader[4]);
+	} catch (IOException e) {
+		SWT.error(SWT.ERROR_IO, e);
+	}
+	try {
+		outputStream.writeInt(BMPHeaderFixedSize);
+		outputStream.writeShort(image.width);
+		outputStream.writeShort(image.height);
+		outputStream.writeShort(1);
+		outputStream.writeShort((short)image.depth);
+	} catch (IOException e) {
+		SWT.error(SWT.ERROR_IO, e);
+	}
+	
+	// Unload palette
+	if (numCols > 0) {
+		try {
+			outputStream.write(rgbs);
+		} catch (IOException e) {
+			SWT.error(SWT.ERROR_IO, e);
+		}
+	}
+
+	// Unload the data
+	try {
+		outputStream.write(data);
+	} catch (IOException e) {
+		SWT.error(SWT.ERROR_IO, e);
+	}
+}
+void flipScanLines(byte[] data, int stride, int height) {
+	int i1 = 0;
+	int i2 = (height - 1) * stride;
+	for (int i = 0; i < height / 2; i++) {
+		for (int index = 0; index < stride; index++) {
+			byte b = data[index + i1];
+			data[index + i1] = data[index + i2];
+			data[index + i2] = b;
+		}
+		i1 += stride;
+		i2 -= stride;
+	}
+}
+
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/OS2BMPFileFormat.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/PNGFileFormat.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/PNGFileFormat.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/PNGFileFormat.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,574 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.image;
+
+
+import java.io.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.*;
+
+public final class PNGFileFormat extends FileFormat {
+	static final int SIGNATURE_LENGTH = 8;
+	static final int PRIME = 65521;
+	PngIhdrChunk headerChunk;
+	PngPlteChunk paletteChunk;
+	ImageData imageData;
+	byte[] data;
+	byte[] alphaPalette;
+	byte headerByte1;
+	byte headerByte2;
+	int adler;
+
+/**
+ * Skip over signature data. This has already been
+ * verified in isFileFormat(). 
+ */
+void readSignature() throws IOException {
+	byte[] signature = new byte[SIGNATURE_LENGTH];
+	inputStream.read(signature);
+}
+/**
+ * Load the PNG image from the byte stream.
+ */
+ImageData[] loadFromByteStream() {
+	try {
+		readSignature();
+		PngChunkReader chunkReader = new PngChunkReader(inputStream);
+		headerChunk = chunkReader.getIhdrChunk();
+		int width = headerChunk.getWidth(), height = headerChunk.getHeight();
+		if (width <= 0 || height <= 0) SWT.error(SWT.ERROR_INVALID_IMAGE);
+		int imageSize = getAlignedBytesPerRow() * height;
+		data = new byte[imageSize];		
+		imageData = ImageData.internal_new(
+			width,
+			height,
+			headerChunk.getSwtBitsPerPixel(),
+			new PaletteData(0, 0, 0),
+			4,
+			data,
+			0,
+			null,
+			null,
+			-1,
+			-1,
+			SWT.IMAGE_PNG,
+			0,
+			0,
+			0,
+			0);		
+			
+		if (headerChunk.usesDirectColor()) {
+			imageData.palette = headerChunk.getPaletteData();
+		}
+		
+		// Read and process chunks until the IEND chunk is encountered.
+		while (chunkReader.hasMoreChunks()) {
+			readNextChunk(chunkReader);
+		}
+						
+		return new ImageData[] {imageData};
+	} catch (IOException e) {
+		SWT.error(SWT.ERROR_INVALID_IMAGE);
+		return null;
+	}
+}
+/**
+ * Read and handle the next chunk of data from the 
+ * PNG file.
+ */
+void readNextChunk(PngChunkReader chunkReader) throws IOException {
+	PngChunk chunk = chunkReader.readNextChunk();
+	switch (chunk.getChunkType()) {
+		case PngChunk.CHUNK_IEND:
+			break;
+		case PngChunk.CHUNK_PLTE:
+			if (!headerChunk.usesDirectColor()) {
+				paletteChunk = (PngPlteChunk) chunk;
+				imageData.palette = paletteChunk.getPaletteData();						
+			}			
+			break;
+		case PngChunk.CHUNK_tRNS:
+			PngTrnsChunk trnsChunk = (PngTrnsChunk) chunk;
+			if (trnsChunk.getTransparencyType(headerChunk) == 
+				PngTrnsChunk.TRANSPARENCY_TYPE_PIXEL) 
+			{
+				imageData.transparentPixel = 
+					trnsChunk.getSwtTransparentPixel(headerChunk);
+			} else {
+				alphaPalette = trnsChunk.getAlphaValues(headerChunk, paletteChunk);
+				int transparentCount = 0, transparentPixel = -1;
+				for (int i = 0; i < alphaPalette.length; i++) {
+					if ((alphaPalette[i] & 0xFF) != 255) {
+						transparentCount++;
+						transparentPixel = i;
+					}
+				}
+				if (transparentCount == 0) {
+					alphaPalette = null;
+				} else if (transparentCount == 1 && alphaPalette[transparentPixel] == 0) {
+					alphaPalette = null;
+					imageData.transparentPixel = transparentPixel;
+				}
+			}
+			break;
+		case PngChunk.CHUNK_IDAT:
+			if (chunkReader.readPixelData()) {
+				// All IDAT chunks in an image file must be
+				// sequential. If the pixel data has already
+				// been read and another IDAT block is encountered,
+				// then this is an invalid image.
+				SWT.error(SWT.ERROR_INVALID_IMAGE);
+			} else {
+				// Read in the pixel data for the image. This should
+				// go through all the image's IDAT chunks. 	
+				PngIdatChunk dataChunk = (PngIdatChunk) chunk;
+				readPixelData(dataChunk, chunkReader);				
+			}
+			break;
+		default:
+			if (chunk.isCritical()) {
+				// All critical chunks must be supported.
+				SWT.error(SWT.ERROR_NOT_IMPLEMENTED);
+			}
+	}
+}
+void unloadIntoByteStream(ImageLoader loader) {
+	PngEncoder encoder = new PngEncoder(loader);
+	encoder.encode(outputStream);
+}
+boolean isFileFormat(LEDataInputStream stream) {
+	try {
+		byte[] signature = new byte[SIGNATURE_LENGTH];
+		stream.read(signature);
+		stream.unread(signature);
+		if ((signature[0] & 0xFF) != 137) return false; //137
+		if ((signature[1] & 0xFF) != 80) return false; //P
+		if ((signature[2] & 0xFF) != 78) return false; //N
+		if ((signature[3] & 0xFF) != 71) return false; //G
+		if ((signature[4] & 0xFF) != 13) return false; //<RETURN>
+		if ((signature[5] & 0xFF) != 10) return false; //<LINEFEED>
+		if ((signature[6] & 0xFF) != 26) return false; //<CTRL/Z>
+		if ((signature[7] & 0xFF) != 10) return false; //<LINEFEED>		
+		return true;
+	} catch (Exception e) {
+		return false;
+	}
+}
+/**
+ * SWT does not support 16-bit depths. If this image uses
+ * 16-bit depths, convert the data to an 8-bit depth.
+ */
+byte[] validateBitDepth(byte[] data) {
+	if (headerChunk.getBitDepth() > 8) {
+		byte[] result = new byte[data.length / 2];
+		compress16BitDepthTo8BitDepth(data, 0, result, 0, result.length);
+		return result;
+	} else {
+		return data;
+	}
+}
+/**
+ * SWT does not support greyscale as a color type. For
+ * plain grayscale, we create a palette. For Grayscale
+ * with Alpha, however, we need to convert the pixels
+ * to use RGB values.
+ * Note: This method assumes that the bit depth of the
+ * data has already been restricted to 8 or less.
+ */
+void setPixelData(byte[] data, ImageData imageData) {
+	switch (headerChunk.getColorType()) {
+		case PngIhdrChunk.COLOR_TYPE_GRAYSCALE_WITH_ALPHA:
+		{
+			int width = imageData.width;
+			int height = imageData.height;
+			int destBytesPerLine = imageData.bytesPerLine;
+			/*
+			* If the image uses 16-bit depth, it is converted
+			* to an 8-bit depth image.
+			*/
+			int srcBytesPerLine = getAlignedBytesPerRow();
+			if (headerChunk.getBitDepth() > 8) srcBytesPerLine /= 2;
+
+			byte[] rgbData = new byte[destBytesPerLine * height];
+			byte[] alphaData = new byte[width * height];
+			for (int y = 0; y < height; y++) {
+				int srcIndex = srcBytesPerLine * y;
+				int destIndex = destBytesPerLine * y;
+				int destAlphaIndex = width * y;
+				for (int x = 0; x < width; x++) {
+					byte grey = data[srcIndex];
+					byte alpha = data[srcIndex + 1];
+					rgbData[destIndex + 0] = grey;
+					rgbData[destIndex + 1] = grey;
+					rgbData[destIndex + 2] = grey;
+					alphaData[destAlphaIndex] = alpha;
+					srcIndex += 2;
+					destIndex += 3;
+					destAlphaIndex++;
+				}
+			}
+			imageData.data = rgbData;
+			imageData.alphaData = alphaData;
+			break;
+		}
+		case PngIhdrChunk.COLOR_TYPE_RGB_WITH_ALPHA:
+		{
+			int width = imageData.width;
+			int height = imageData.height;
+			int destBytesPerLine = imageData.bytesPerLine;
+			int srcBytesPerLine = getAlignedBytesPerRow();
+			/*
+			* If the image uses 16-bit depth, it is converted
+			* to an 8-bit depth image.
+			*/
+			if (headerChunk.getBitDepth() > 8) srcBytesPerLine /= 2;
+
+			byte[] rgbData = new byte[destBytesPerLine * height];
+			byte[] alphaData = new byte[width * height];
+			for (int y = 0; y < height; y++) {
+				int srcIndex = srcBytesPerLine * y;
+				int destIndex = destBytesPerLine * y;
+				int destAlphaIndex = width * y;
+				for (int x = 0; x < width; x++) {
+					rgbData[destIndex + 0] = data[srcIndex + 0];
+					rgbData[destIndex + 1] = data[srcIndex + 1];
+					rgbData[destIndex + 2] = data[srcIndex + 2];
+					alphaData[destAlphaIndex] = data[srcIndex + 3];
+					srcIndex += 4;
+					destIndex += 3;
+					destAlphaIndex++;
+				}
+			}
+			imageData.data = rgbData;
+			imageData.alphaData = alphaData;
+			break;
+		}		
+		case PngIhdrChunk.COLOR_TYPE_RGB:
+			imageData.data = data;
+			break;
+		case PngIhdrChunk.COLOR_TYPE_PALETTE:
+			imageData.data = data;
+			if (alphaPalette != null) {
+				int size = imageData.width * imageData.height;
+				byte[] alphaData = new byte[size];
+				byte[] pixelData = new byte[size];
+				imageData.getPixels(0, 0, size, pixelData, 0);
+				for (int i = 0; i < pixelData.length; i++) {
+					alphaData[i] = alphaPalette[pixelData[i] & 0xFF];
+				}
+				imageData.alphaData = alphaData;
+			}
+			break;
+		default:
+			imageData.data = data;
+			break;
+	}
+}
+/**
+ * PNG supports some color types and bit depths that are 
+ * unsupported by SWT. If the image uses an unsupported
+ * color type (either of the gray scale types) or bit
+ * depth (16), convert the data to an SWT-supported
+ * format. Then assign the data into the ImageData given.
+ */
+void setImageDataValues(byte[] data, ImageData imageData) {
+	byte[] result = validateBitDepth(data);
+	setPixelData(result, imageData);
+}
+/**
+ * Read the image data from the data stream. This must handle
+ * decoding the data, filtering, and interlacing.
+ */
+void readPixelData(PngIdatChunk chunk, PngChunkReader chunkReader) throws IOException {
+	InputStream stream = new PngInputStream(chunk, chunkReader);
+	//TEMPORARY CODE
+	boolean use3_2 = System.getProperty("org.eclipse.swt.internal.image.PNGFileFormat_3.2") != null;
+	InputStream inflaterStream = use3_2 ? null : Compatibility.newInflaterInputStream(stream);
+	if (inflaterStream != null) {
+		stream = inflaterStream;
+	} else {
+		stream = new PngDecodingDataStream(stream);
+	}
+	int interlaceMethod = headerChunk.getInterlaceMethod();
+	if (interlaceMethod == PngIhdrChunk.INTERLACE_METHOD_NONE) {
+		readNonInterlacedImage(stream);
+	} else {
+		readInterlacedImage(stream);
+	}
+	/*
+	* InflaterInputStream does not consume all bytes in the stream
+	* when it is closed. This may leave unread IDAT chunks. The fix
+	* is to read all available bytes before closing it.
+	*/
+	while (stream.available() > 0) stream.read();
+	stream.close();
+}
+/**
+ * Answer the number of bytes in a word-aligned row of pixel data.
+ */
+int getAlignedBytesPerRow() {
+	return ((getBytesPerRow(headerChunk.getWidth()) + 3) / 4) * 4;
+}
+/**
+ * Answer the number of bytes in each row of the image
+ * data. Each PNG row is byte-aligned, so images with bit
+ * depths less than a byte may have unused bits at the
+ * end of each row. The value of these bits is undefined.
+ */
+int getBytesPerRow() {
+	return getBytesPerRow(headerChunk.getWidth());
+}
+/**
+ * Answer the number of bytes needed to represent a pixel.
+ * This value depends on the image's color type and bit
+ * depth. 
+ * Note that this method rounds up if an image's pixel size
+ * isn't byte-aligned.
+ */
+int getBytesPerPixel() {
+	int bitsPerPixel = headerChunk.getBitsPerPixel();
+	return (bitsPerPixel + 7) / 8;	
+}
+/**
+ * Answer the number of bytes in a row of the given pixel
+ * width. Each row is byte-aligned, so images with bit
+ * depths less than a byte may have unused bits at the
+ * end of each row. The value of these bits is undefined.
+ */
+int getBytesPerRow(int rowWidthInPixels) {
+	int bitsPerPixel = headerChunk.getBitsPerPixel();
+	int bitsPerRow = bitsPerPixel * rowWidthInPixels;
+	int bitsPerByte = 8;
+	return (bitsPerRow + (bitsPerByte - 1)) / bitsPerByte;
+}
+/**
+ * 1. Read one of the seven frames of interlaced data.
+ * 2. Update the imageData.
+ * 3. Notify the image loader's listeners of the frame load.
+ */
+void readInterlaceFrame(
+	InputStream inputStream,
+	int rowInterval,
+	int columnInterval,
+	int startRow,
+	int startColumn,
+	int frameCount) throws IOException 
+{
+	int width = headerChunk.getWidth();
+	int alignedBytesPerRow = getAlignedBytesPerRow();
+	int height = headerChunk.getHeight();
+	if (startRow >= height || startColumn >= width) return;
+	
+	int pixelsPerRow = (width - startColumn + columnInterval - 1) / columnInterval;
+	int bytesPerRow = getBytesPerRow(pixelsPerRow);
+	byte[] row1 = new byte[bytesPerRow];
+	byte[] row2 = new byte[bytesPerRow];
+	byte[] currentRow = row1;	
+	byte[] lastRow = row2;	
+	for (int row = startRow; row < height; row += rowInterval) {
+		byte filterType = (byte)inputStream.read();
+		int read = 0;
+		while (read != bytesPerRow) {
+			read += inputStream.read(currentRow, read, bytesPerRow - read);
+		}
+		filterRow(currentRow, lastRow, filterType);
+		if (headerChunk.getBitDepth() >= 8) {
+			int bytesPerPixel = getBytesPerPixel();
+			int dataOffset = (row * alignedBytesPerRow) + (startColumn * bytesPerPixel);
+			for (int rowOffset = 0; rowOffset < currentRow.length; rowOffset += bytesPerPixel) {
+				for (int byteOffset = 0; byteOffset < bytesPerPixel; byteOffset++) {
+					data[dataOffset + byteOffset] = currentRow[rowOffset + byteOffset];
+				}
+				dataOffset += (columnInterval * bytesPerPixel);
+			}
+		} else {
+			int bitsPerPixel = headerChunk.getBitDepth();
+			int pixelsPerByte = 8 / bitsPerPixel;
+			int column = startColumn;
+			int rowBase = row * alignedBytesPerRow;
+			int valueMask = 0;
+			for (int i = 0; i < bitsPerPixel; i++) {
+				valueMask <<= 1;
+				valueMask |= 1;
+			}
+			int maxShift = 8 - bitsPerPixel;
+			for (int byteOffset = 0; byteOffset < currentRow.length; byteOffset++) {
+				for (int bitOffset = maxShift; bitOffset >= 0; bitOffset -= bitsPerPixel) {
+					if (column < width) {
+						int dataOffset = rowBase + (column * bitsPerPixel / 8);							
+						int value = (currentRow[byteOffset] >> bitOffset) & valueMask;
+						int dataShift = maxShift - (bitsPerPixel * (column % pixelsPerByte));
+						data[dataOffset] |= value << dataShift;
+					}
+					column += columnInterval;
+				}
+			}
+		}
+		currentRow = (currentRow == row1) ? row2 : row1;
+		lastRow = (lastRow == row1) ? row2 : row1;
+	}
+	setImageDataValues(data, imageData);
+	fireInterlacedFrameEvent(frameCount);
+}
+/**
+ * Read the pixel data for an interlaced image from the
+ * data stream.
+ */
+void readInterlacedImage(InputStream inputStream) throws IOException {
+	readInterlaceFrame(inputStream, 8, 8, 0, 0, 0);
+	readInterlaceFrame(inputStream, 8, 8, 0, 4, 1);	
+	readInterlaceFrame(inputStream, 8, 4, 4, 0, 2);	
+	readInterlaceFrame(inputStream, 4, 4, 0, 2, 3);
+	readInterlaceFrame(inputStream, 4, 2, 2, 0, 4);
+	readInterlaceFrame(inputStream, 2, 2, 0, 1, 5);	
+	readInterlaceFrame(inputStream, 2, 1, 1, 0, 6);
+}
+/**
+ * Fire an event to let listeners know that an interlaced
+ * frame has been loaded.
+ * finalFrame should be true if the image has finished
+ * loading, false if there are more frames to come.
+ */
+void fireInterlacedFrameEvent(int frameCount) {
+	if (loader.hasListeners()) {
+		ImageData image = (ImageData) imageData.clone();
+		boolean finalFrame = frameCount == 6;
+		loader.notifyListeners(new ImageLoaderEvent(loader, image, frameCount, finalFrame));
+	}
+}
+/**
+ * Read the pixel data for a non-interlaced image from the
+ * data stream.
+ * Update the imageData to reflect the new data.
+ */
+void readNonInterlacedImage(InputStream inputStream) throws IOException {
+	int dataOffset = 0;
+	int alignedBytesPerRow = getAlignedBytesPerRow();
+	int bytesPerRow = getBytesPerRow();
+	byte[] row1 = new byte[bytesPerRow];
+	byte[] row2 = new byte[bytesPerRow];
+	byte[] currentRow = row1;	
+	byte[] lastRow = row2;
+	int height = headerChunk.getHeight();
+	for (int row = 0; row < height; row++) {
+		byte filterType = (byte)inputStream.read();
+		int read = 0;
+		while (read != bytesPerRow) {
+			read += inputStream.read(currentRow, read, bytesPerRow - read);
+		}
+		filterRow(currentRow, lastRow, filterType);
+		System.arraycopy(currentRow, 0, data, dataOffset, bytesPerRow);
+		dataOffset += alignedBytesPerRow;
+		currentRow = (currentRow == row1) ? row2 : row1;
+		lastRow = (lastRow == row1) ? row2 : row1;
+	}
+	setImageDataValues(data, imageData);
+}
+/**
+ * SWT does not support 16-bit depth color formats.
+ * Convert the 16-bit data to 8-bit data.
+ * The correct way to do this is to multiply each
+ * 16 bit value by the value:
+ * (2^8 - 1) / (2^16 - 1).
+ * The fast way to do this is just to drop the low
+ * byte of the 16-bit value.
+ */
+static void compress16BitDepthTo8BitDepth(
+	byte[] source,
+	int sourceOffset,
+	byte[] destination, 
+	int destinationOffset,
+	int numberOfValues) 
+{
+	//double multiplier = (Compatibility.pow2(8) - 1) / (Compatibility.pow2(16) - 1);
+	for (int i = 0; i < numberOfValues; i++) {
+		int sourceIndex = sourceOffset + (2 * i);
+		int destinationIndex = destinationOffset + i;
+		//int value = (source[sourceIndex] << 8) | source[sourceIndex + 1];
+		//byte compressedValue = (byte)(value * multiplier);
+		byte compressedValue = source[sourceIndex];
+		destination[destinationIndex] = compressedValue;
+	}
+}
+/**
+ * SWT does not support 16-bit depth color formats.
+ * Convert the 16-bit data to 8-bit data.
+ * The correct way to do this is to multiply each
+ * 16 bit value by the value:
+ * (2^8 - 1) / (2^16 - 1).
+ * The fast way to do this is just to drop the low
+ * byte of the 16-bit value.
+ */
+static int compress16BitDepthTo8BitDepth(int value) {
+	//double multiplier = (Compatibility.pow2(8) - 1) / (Compatibility.pow2(16) - 1);
+	//byte compressedValue = (byte)(value * multiplier);
+	return value >> 8;
+}
+/**
+ * PNG supports four filtering types. These types are applied
+ * per row of image data. This method unfilters the given row
+ * based on the filterType.
+ */
+void filterRow(byte[] row, byte[] previousRow, int filterType) {
+	int byteOffset = headerChunk.getFilterByteOffset();
+	switch (filterType) {
+		case PngIhdrChunk.FILTER_NONE:
+			break;
+		case PngIhdrChunk.FILTER_SUB:
+			for (int i = byteOffset; i < row.length; i++) {
+				int current = row[i] & 0xFF;
+				int left = row[i - byteOffset] & 0xFF;
+				row[i] = (byte)((current + left) & 0xFF);
+			}
+			break;
+		case PngIhdrChunk.FILTER_UP:
+			for (int i = 0; i < row.length; i++) {
+				int current = row[i] & 0xFF;
+				int above = previousRow[i] & 0xFF;				
+				row[i] = (byte)((current + above) & 0xFF);
+			}
+			break;
+		case PngIhdrChunk.FILTER_AVERAGE:
+			for (int i = 0; i < row.length; i++) {
+				int left = (i < byteOffset) ? 0 : row[i - byteOffset] & 0xFF;
+				int above = previousRow[i] & 0xFF;
+				int current = row[i] & 0xFF;
+				row[i] = (byte)((current + ((left + above) / 2)) & 0xFF);
+			}
+			break;
+		case PngIhdrChunk.FILTER_PAETH:
+			for (int i = 0; i < row.length; i++) {
+				int left = (i < byteOffset) ? 0 : row[i - byteOffset] & 0xFF;
+				int aboveLeft = (i < byteOffset) ? 0 : previousRow[i - byteOffset] & 0xFF;
+				int above = previousRow[i] & 0xFF;
+				
+				int a = Math.abs(above - aboveLeft);
+				int b = Math.abs(left - aboveLeft);
+				int c = Math.abs(left - aboveLeft + above - aboveLeft);
+				
+				int preductor = 0;
+				if (a <= b && a <= c) {
+					preductor = left;
+				} else if (b <= c) {
+					preductor = above;
+				} else {
+					preductor = aboveLeft;
+				}
+				
+				int currentValue = row[i] & 0xFF;
+				row[i] = (byte) ((currentValue + preductor) & 0xFF);
+			}
+			break;
+	}
+}
+
+}
\ No newline at end of file


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/PNGFileFormat.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/PngChunk.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/PngChunk.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/PngChunk.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,381 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.image;
+
+
+import org.eclipse.swt.*;
+import java.io.*;
+
+class PngChunk extends Object {
+	byte[] reference;
+
+	static final int LENGTH_OFFSET = 0;
+	static final int TYPE_OFFSET = 4;
+	static final int DATA_OFFSET = 8;
+
+	static final int TYPE_FIELD_LENGTH = 4;
+	static final int LENGTH_FIELD_LENGTH = 4;
+	static final int MIN_LENGTH = 12;
+
+	static final int CHUNK_UNKNOWN = -1;
+	// Critical chunks.
+	static final int CHUNK_IHDR = 0;
+	static final int CHUNK_PLTE = 1;
+	static final int CHUNK_IDAT = 2;
+	static final int CHUNK_IEND = 3;
+	// Non-critical chunks.
+	static final int CHUNK_tRNS = 5;
+	
+	static final byte[] TYPE_IHDR = {(byte) 'I', (byte) 'H', (byte) 'D', (byte) 'R'};
+	static final byte[] TYPE_PLTE = {(byte) 'P', (byte) 'L', (byte) 'T', (byte) 'E'};
+	static final byte[] TYPE_IDAT = {(byte) 'I', (byte) 'D', (byte) 'A', (byte) 'T'};
+	static final byte[] TYPE_IEND = {(byte) 'I', (byte) 'E', (byte) 'N', (byte) 'D'};
+	static final byte[] TYPE_tRNS = {(byte) 't', (byte) 'R', (byte) 'N', (byte) 'S'};
+	
+	static final int[] CRC_TABLE;
+	static {
+		CRC_TABLE = new int[256];
+		for (int i = 0; i < 256; i++) {
+			CRC_TABLE[i] = i;
+			for (int j = 0; j < 8; j++) {
+				if ((CRC_TABLE[i] & 0x1) == 0) {
+					CRC_TABLE[i] = (CRC_TABLE[i] >> 1) & 0x7FFFFFFF;
+				} else {
+					CRC_TABLE[i] = 0xEDB88320 ^ ((CRC_TABLE[i] >> 1) & 0x7FFFFFFF);
+				}
+			}
+		}	
+	}
+	
+	int length;
+	
+/**
+ * Construct a PngChunk using the reference bytes
+ * given.
+ */	
+PngChunk(byte[] reference) {
+	super();
+	setReference(reference);
+	if (reference.length < LENGTH_OFFSET + LENGTH_FIELD_LENGTH) SWT.error(SWT.ERROR_INVALID_IMAGE);
+	length = getInt32(LENGTH_OFFSET);
+}
+
+/**
+ * Construct a PngChunk with the specified number of
+ * data bytes.
+ */	
+PngChunk(int dataLength) {
+	this(new byte[MIN_LENGTH + dataLength]);
+	setLength(dataLength);
+}
+
+/**
+ * Get the PngChunk's reference byteArray;
+ */	
+byte[] getReference() {
+	return reference;
+}
+
+/**
+ * Set the PngChunk's reference byteArray;
+ */	
+void setReference(byte[] reference) {
+	this.reference = reference;
+}
+
+/**
+ * Get the 16-bit integer from the reference byte
+ * array at the given offset.
+ */	
+int getInt16(int offset) {
+	int answer = 0;
+	answer |= (reference[offset] & 0xFF) << 8;
+	answer |= (reference[offset + 1] & 0xFF);
+	return answer;	
+}
+
+/**
+ * Set the 16-bit integer in the reference byte
+ * array at the given offset.
+ */	
+void setInt16(int offset, int value) {
+	reference[offset] = (byte) ((value >> 8) & 0xFF);
+	reference[offset + 1] = (byte) (value & 0xFF);
+}
+
+/**
+ * Get the 32-bit integer from the reference byte
+ * array at the given offset.
+ */	
+int getInt32(int offset) {
+	int answer = 0;
+	answer |= (reference[offset] & 0xFF) << 24;
+	answer |= (reference[offset + 1] & 0xFF) << 16;
+	answer |= (reference[offset + 2] & 0xFF) << 8;
+	answer |= (reference[offset + 3] & 0xFF);
+	return answer;	
+}
+
+/**
+ * Set the 32-bit integer in the reference byte
+ * array at the given offset.
+ */	
+void setInt32(int offset, int value) {
+	reference[offset] = (byte) ((value >> 24) & 0xFF);
+	reference[offset + 1] = (byte) ((value >> 16) & 0xFF);
+	reference[offset + 2] = (byte) ((value >> 8) & 0xFF);
+	reference[offset + 3] = (byte) (value & 0xFF);
+}
+
+/**
+ * Get the length of the data component of this chunk.
+ * This is not the length of the entire chunk.
+ */	
+int getLength() {
+	return length;
+}
+
+/**
+ * Set the length of the data component of this chunk.
+ * This is not the length of the entire chunk.
+ */	
+void setLength(int value) {
+	setInt32(LENGTH_OFFSET, value);
+	length = value;
+}
+
+/**
+ * Get the chunk type. This is a four byte value.
+ * Each byte should be an ASCII character.
+ * The first byte is upper case if the chunk is critical.
+ * The second byte is upper case if the chunk is publicly defined.
+ * The third byte must be upper case.
+ * The fourth byte is upper case if the chunk is unsafe to copy. 
+ * Public chunk types are defined by the PNG Development Group.
+ */	
+byte[] getTypeBytes() {
+	byte[] type = new byte[4];
+	System.arraycopy(reference, TYPE_OFFSET, type, 0, TYPE_FIELD_LENGTH);
+	return type;
+}	
+
+/**
+ * Set the chunk type. This is a four byte value.
+ * Each byte should be an ASCII character.
+ * The first byte is upper case if the chunk is critical.
+ * The second byte is upper case if the chunk is publicly defined.
+ * The third byte must be upper case.
+ * The fourth byte is upper case if the chunk is unsafe to copy. 
+ * Public chunk types are defined by the PNG Development Group.
+ */	
+void setType(byte[] value) {
+	if (value.length != TYPE_FIELD_LENGTH) {
+		SWT.error (SWT.ERROR_INVALID_ARGUMENT);
+	}
+	System.arraycopy(value, 0, reference, TYPE_OFFSET, TYPE_FIELD_LENGTH);
+}
+
+/**
+ * Get the chunk's data.
+ */
+byte[] getData() {
+	int dataLength = getLength();
+	if (reference.length < MIN_LENGTH + dataLength) {
+		SWT.error (SWT.ERROR_INVALID_RANGE);
+	}
+	byte[] data = new byte[dataLength];
+	System.arraycopy(reference, DATA_OFFSET, data, 0, dataLength);
+	return data;
+}
+
+/**
+ * Set the chunk's data.
+ * This method has two side-effects.
+ * 1. It will set the length field to be the length
+ *    of the data array given.
+ * 2. It will set the CRC field to the computed CRC
+ *    value of the data array given.
+ */
+void setData(byte[] data) {
+	setLength(data.length);
+	System.arraycopy(data, 0, reference, DATA_OFFSET, data.length);
+	setCRC(computeCRC());
+}
+
+/**
+ * Get the CRC value for the chunk's data.
+ * Ensure that the length field has a good
+ * value before making this call.
+ */
+int getCRC() {
+	int crcOffset = DATA_OFFSET + getLength();
+	return getInt32(crcOffset);
+}
+
+/**
+ * Set the CRC value for the chunk's data.
+ * Ensure that the length field has a good
+ * value before making this call.
+ */
+void setCRC(int value) {
+	int crcOffset = DATA_OFFSET + getLength();
+	setInt32(crcOffset, value);
+}
+
+/**
+ * Get the chunk's total size including the length, type, and crc fields.
+ */
+int getSize() {
+	return MIN_LENGTH + getLength();
+}
+
+/**
+ * Compute the CRC value for the chunk's data. Answer
+ * whether this value matches the value stored in the
+ * chunk.
+ */
+boolean checkCRC() {
+	int crc = computeCRC();
+	int storedCRC = getCRC();
+	return crc == storedCRC;
+}
+
+/**
+ * Answer the CRC value of chunk's data.
+ */
+int computeCRC() {
+	int crc = 0xFFFFFFFF;
+	int start = TYPE_OFFSET;
+	int stop = DATA_OFFSET + getLength();
+	for (int i = start; i < stop; i++) {
+		int index = (crc ^ reference[i]) & 0xFF;
+		crc =  CRC_TABLE[index] ^ ((crc >> 8) & 0x00FFFFFF);
+	}
+	return ~crc;
+}
+
+boolean typeMatchesArray(byte[] array) {
+	for (int i = 0; i < TYPE_FIELD_LENGTH; i++) {
+		if (reference[TYPE_OFFSET + i] != array[i]){
+			return false;
+		}
+	}	
+	return true;
+}
+
+boolean isCritical() {
+	char c = (char) getTypeBytes()[0]; 
+	return 'A' <= c && c <= 'Z';
+}
+
+int getChunkType() {
+	if (typeMatchesArray(TYPE_IHDR)) return CHUNK_IHDR;
+	if (typeMatchesArray(TYPE_PLTE)) return CHUNK_PLTE;
+	if (typeMatchesArray(TYPE_IDAT)) return CHUNK_IDAT;
+	if (typeMatchesArray(TYPE_IEND)) return CHUNK_IEND;
+	if (typeMatchesArray(TYPE_tRNS)) return CHUNK_tRNS;	
+	return CHUNK_UNKNOWN;
+}
+
+/**
+ * Read the next PNG chunk from the input stream given.
+ * If unable to read a chunk, return null.
+ */
+static PngChunk readNextFromStream(LEDataInputStream stream) {
+	try {
+		int headerLength = LENGTH_FIELD_LENGTH + TYPE_FIELD_LENGTH;
+		byte[] headerBytes = new byte[headerLength];
+		int result = stream.read(headerBytes, 0, headerLength);
+		stream.unread(headerBytes);
+		if (result != headerLength) return null;
+		
+		PngChunk tempChunk = new PngChunk(headerBytes);
+		
+		int chunkLength = tempChunk.getSize();
+		byte[] chunk = new byte[chunkLength];
+		result = stream.read(chunk, 0, chunkLength);
+		if (result != chunkLength) return null;
+	
+		switch (tempChunk.getChunkType()) {
+			case CHUNK_IHDR:
+				return new PngIhdrChunk(chunk);
+			case CHUNK_PLTE:
+				return new PngPlteChunk(chunk);
+			case CHUNK_IDAT:
+				return new PngIdatChunk(chunk);
+			case CHUNK_IEND:
+				return new PngIendChunk(chunk);
+			case CHUNK_tRNS:
+				return new PngTrnsChunk(chunk);
+			default:
+				return new PngChunk(chunk);
+		}		
+	} catch (IOException e) {
+		return null;
+	}
+}
+
+/**
+ * Answer whether the chunk is a valid PNG chunk.
+ */
+void validate(PngFileReadState readState, PngIhdrChunk headerChunk) {
+	if (reference.length < MIN_LENGTH) SWT.error(SWT.ERROR_INVALID_IMAGE);
+	
+	byte[] type = getTypeBytes();
+	
+	// The third character MUST be upper case.
+	char c = (char) type[2];
+	if (!('A' <= c && c <= 'Z')) SWT.error(SWT.ERROR_INVALID_IMAGE);
+	
+	// All characters must be letters.
+	for (int i = 0; i < TYPE_FIELD_LENGTH; i++) {
+		c = (char) type[i];
+		if (!(('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z'))) {
+			SWT.error(SWT.ERROR_INVALID_IMAGE);
+		}
+	}
+	
+	// The stored CRC must match the data's computed CRC.
+	if (!checkCRC()) SWT.error(SWT.ERROR_INVALID_IMAGE);
+}
+
+/**
+ * Provided so that subclasses can override and add
+ * data to the toString() call.
+ */
+void contributeToString(StringBuffer buffer) {}
+
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the event
+ */
+public String toString() {
+	StringBuffer buffer = new StringBuffer();
+	buffer.append("{");
+	buffer.append("\n\tLength: ");
+	buffer.append(getLength());
+	buffer.append("\n\tType: ");
+	byte[] type = getTypeBytes();
+	for(int i = 0; i < type.length; i++) {
+		buffer.append((char) type[i]);
+	}
+	
+	contributeToString(buffer);
+	
+	buffer.append("\n\tCRC: ");
+	buffer.append(Integer.toHexString(getCRC()));
+	buffer.append("\n}");
+	return buffer.toString();
+}
+
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/PngChunk.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/PngChunkReader.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/PngChunkReader.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/PngChunkReader.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.image;
+
+
+import org.eclipse.swt.*;
+
+public class PngChunkReader {
+	LEDataInputStream inputStream;
+	PngFileReadState readState;
+	PngIhdrChunk headerChunk;
+	PngPlteChunk paletteChunk;
+	
+PngChunkReader(LEDataInputStream inputStream) {
+	this.inputStream = inputStream;
+	readState = new PngFileReadState();
+	headerChunk = null;
+}
+
+PngIhdrChunk getIhdrChunk() {
+	if (headerChunk == null) {
+		try { 
+			PngChunk chunk = PngChunk.readNextFromStream(inputStream);
+			if (chunk == null) SWT.error(SWT.ERROR_INVALID_IMAGE);
+			headerChunk = (PngIhdrChunk) chunk;
+			headerChunk.validate(readState, null);
+		} catch (ClassCastException e) {
+			SWT.error(SWT.ERROR_INVALID_IMAGE);
+		}
+	}
+	return headerChunk;
+}
+
+PngChunk readNextChunk() {
+	if (headerChunk == null) return getIhdrChunk();
+	
+	PngChunk chunk = PngChunk.readNextFromStream(inputStream);
+	if (chunk == null) SWT.error(SWT.ERROR_INVALID_IMAGE);
+	switch (chunk.getChunkType()) {
+		case PngChunk.CHUNK_tRNS:
+			((PngTrnsChunk) chunk).validate(readState, headerChunk, paletteChunk);
+			break;
+		case PngChunk.CHUNK_PLTE:
+			chunk.validate(readState, headerChunk);
+			paletteChunk = (PngPlteChunk) chunk;
+			break;
+		default:
+			chunk.validate(readState, headerChunk);
+	}
+	if (readState.readIDAT && !(chunk.getChunkType() == PngChunk.CHUNK_IDAT)) {
+		readState.readPixelData = true;
+	}
+	return chunk;
+}
+
+boolean readPixelData() {
+	return readState.readPixelData;
+}
+
+boolean hasMoreChunks() {
+	return !readState.readIEND;
+}
+
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/PngChunkReader.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/PngDecodingDataStream.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/PngDecodingDataStream.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/PngDecodingDataStream.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,134 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.image;
+
+
+import java.io.*;
+
+import org.eclipse.swt.*;
+
+public class PngDecodingDataStream extends InputStream {
+	InputStream stream;
+	byte currentByte;
+	int nextBitIndex;
+	
+	PngLzBlockReader lzBlockReader;
+	int adlerValue;
+	
+	static final int PRIME = 65521;
+	static final int MAX_BIT = 7;		
+	
+PngDecodingDataStream(InputStream stream) throws IOException {
+	super();
+	this.stream = stream;
+	nextBitIndex = MAX_BIT + 1;
+	adlerValue = 1;
+	lzBlockReader = new PngLzBlockReader(this);
+	readCompressedDataHeader();
+	lzBlockReader.readNextBlockHeader();
+}
+
+/**
+ * This method should be called when the image decoder thinks
+ * that all of the compressed image data has been read. This
+ * method will ensure that the next data value is an end of 
+ * block marker. If there are more blocks after this one,
+ * the method will read them and ensure that they are empty.
+ */
+void assertImageDataAtEnd() throws IOException {
+	lzBlockReader.assertCompressedDataAtEnd();
+}
+
+public void close() throws IOException {
+	assertImageDataAtEnd();
+	checkAdler();
+}
+
+int getNextIdatBits(int length) throws IOException {
+	int value = 0;
+	for (int i = 0; i < length; i++) {
+		value |= (getNextIdatBit() << i);
+	}
+	return value;
+}
+
+int getNextIdatBit() throws IOException {
+	if (nextBitIndex > MAX_BIT) {
+		currentByte = getNextIdatByte();
+		nextBitIndex = 0;
+	}
+	return (currentByte & (1 << nextBitIndex)) >> nextBitIndex++;
+}
+
+byte getNextIdatByte() throws IOException {	
+	byte nextByte = (byte)stream.read();
+	nextBitIndex = MAX_BIT + 1;
+	return nextByte;
+}
+
+void updateAdler(byte value) {
+	int low = adlerValue & 0xFFFF;
+	int high = (adlerValue >> 16) & 0xFFFF;
+	int valueInt = value & 0xFF;
+	low = (low + valueInt) % PRIME;
+	high = (low + high) % PRIME;
+	adlerValue = (high << 16) | low;
+}
+
+public int read() throws IOException {
+	byte nextDecodedByte = lzBlockReader.getNextByte();
+	updateAdler(nextDecodedByte);
+	return nextDecodedByte & 0xFF;
+}
+
+public int read(byte[] buffer, int off, int len) throws IOException {
+	for (int i = 0; i < len; i++) {
+		int b = read();
+		if (b == -1) return i;
+		buffer[off + i] = (byte)b;
+	}
+	return len;
+}
+
+void error() {
+	SWT.error(SWT.ERROR_INVALID_IMAGE);
+}
+
+private void readCompressedDataHeader() throws IOException {
+	byte headerByte1 = getNextIdatByte();
+	byte headerByte2 = getNextIdatByte();
+	
+	int number = ((headerByte1 & 0xFF) << 8) | (headerByte2 & 0xFF);
+	if (number % 31 != 0) error();
+	
+	int compressionMethod = headerByte1 & 0x0F;
+	if (compressionMethod != 8) error();
+	
+	int windowSizeHint = (headerByte1 & 0xF0) >> 4;
+	if (windowSizeHint > 7) error();
+	int windowSize = (1 << (windowSizeHint + 8));
+	lzBlockReader.setWindowSize(windowSize);
+	
+	int dictionary = (headerByte2 & (1 << 5));
+	if (dictionary != 0) error();
+	
+//	int compressionLevel = (headerByte2 & 0xC0) >> 6;
+}
+
+void checkAdler() throws IOException {
+	int storedAdler = ((getNextIdatByte() & 0xFF) << 24)
+		| ((getNextIdatByte() & 0xFF) << 16)
+		| ((getNextIdatByte() & 0xFF) << 8)
+		| (getNextIdatByte() & 0xFF);
+	if (storedAdler != adlerValue) error();
+}
+
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/PngDecodingDataStream.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/PngDeflater.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/PngDeflater.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/PngDeflater.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,618 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.image;
+
+import java.io.ByteArrayOutputStream;
+
+public class PngDeflater {
+
+	static final int BASE = 65521;
+	static final int WINDOW = 32768;
+	static final int MIN_LENGTH = 3;
+	static final int MAX_MATCHES = 32;
+	static final int HASH = 8209;
+	
+	byte[] in;
+	int inLength;
+	
+	ByteArrayOutputStream bytes = new ByteArrayOutputStream(1024);
+	
+	int adler32 = 1;
+	
+	int buffer, bitCount;
+	
+	Link[] hashtable = new Link[HASH];
+	Link[] window = new Link[WINDOW];
+	int nextWindow;
+
+static class Link {
+
+	int hash, value;
+	Link previous, next;
+	
+	Link() {
+	
+		this.hash = 0;
+		this.value = 0;
+		this.previous = null;
+		this.next = null;
+	
+	}
+
+}
+
+static class Match {
+
+	int length, distance;
+	
+	Match(int length, int distance) {
+	
+		this.length = length;
+		this.distance = distance;
+	
+	}
+
+}
+
+static final short mirrorBytes[] = {
+
+    0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0,
+    0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0,
+    0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8,
+    0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8,
+    0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4,
+    0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4,
+    0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec,
+    0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc,
+    0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2,
+    0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2,
+    0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea,
+    0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa,
+    0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6,
+    0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6,
+    0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee,
+    0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe,
+    0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1,
+    0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1,
+    0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9,
+    0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9,
+    0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5,
+    0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5,
+    0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed,
+    0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd,
+    0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3,
+    0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3,
+    0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb,
+    0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb,
+    0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7,
+    0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7,
+    0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef,
+    0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff,
+
+};
+
+static class Code {
+
+	int code, extraBits, min, max;
+	
+	Code(int code, int extraBits, int min, int max) {
+	
+		this.code = code;
+		this.extraBits = extraBits;
+		this.min = min;
+		this.max = max;
+    
+    }
+
+}
+
+static final Code lengthCodes[] = {
+
+	new Code(257, 0, 3, 3),
+	new Code(258, 0, 4, 4),
+	new Code(259, 0, 5, 5),
+	new Code(260, 0, 6, 6),
+	new Code(261, 0, 7, 7),
+	new Code(262, 0, 8, 8),
+	new Code(263, 0, 9, 9),
+	new Code(264, 0, 10, 10),
+	new Code(265, 1, 11, 12),
+	new Code(266, 1, 13, 14),
+	new Code(267, 1, 15, 16),
+	new Code(268, 1, 17, 18),
+	new Code(269, 2, 19, 22),
+	new Code(270, 2, 23, 26),
+	new Code(271, 2, 27, 30),
+	new Code(272, 2, 31, 34),
+	new Code(273, 3, 35, 42),
+	new Code(274, 3, 43, 50),
+	new Code(275, 3, 51, 58),
+	new Code(276, 3, 59, 66),
+	new Code(277, 4, 67, 82),
+	new Code(278, 4, 83, 98),
+	new Code(279, 4, 99, 114),
+	new Code(280, 4, 115, 130),
+	new Code(281, 5, 131, 162),
+	new Code(282, 5, 163, 194),
+	new Code(283, 5, 195, 226),
+	new Code(284, 5, 227, 257),
+	new Code(285, 0, 258, 258)
+
+};
+
+static final Code distanceCodes[] = {
+
+	new Code(0, 0, 1, 1),
+	new Code(1, 0, 2, 2),
+	new Code(2, 0, 3, 3),
+	new Code(3, 0, 4, 4),
+	new Code(4, 1, 5, 6),
+	new Code(5, 1, 7, 8),
+	new Code(6, 2, 9, 12),
+	new Code(7, 2, 13, 16),
+	new Code(8, 3, 17, 24),
+	new Code(9, 3, 25, 32),
+	new Code(10, 4, 33, 48),
+	new Code(11, 4, 49, 64),
+	new Code(12, 5, 65, 96),
+	new Code(13, 5, 97, 128),
+	new Code(14, 6, 129, 192),
+	new Code(15, 6, 193, 256),
+	new Code(16, 7, 257, 384),
+	new Code(17, 7, 385, 512),
+	new Code(18, 8, 513, 768),
+	new Code(19, 8, 769, 1024),
+	new Code(20, 9, 1025, 1536),
+	new Code(21, 9, 1537, 2048),
+	new Code(22, 10, 2049, 3072),
+	new Code(23, 10, 3073, 4096),
+	new Code(24, 11, 4097, 6144),
+	new Code(25, 11, 6145, 8192),
+	new Code(26, 12, 8193, 12288),
+	new Code(27, 12, 12289, 16384),
+	new Code(28, 13, 16385, 24576),
+	new Code(29, 13, 24577, 32768)
+
+};
+
+void writeShortLSB(ByteArrayOutputStream baos, int theShort) {
+
+	byte byte1 = (byte) (theShort & 0xff);
+	byte byte2 = (byte) ((theShort >> 8) & 0xff);
+	byte[] temp = {byte1, byte2};
+	baos.write(temp, 0, 2);
+
+}
+
+void writeInt(ByteArrayOutputStream baos, int theInt) {
+
+	byte byte1 = (byte) ((theInt >> 24) & 0xff);
+	byte byte2 = (byte) ((theInt >> 16) & 0xff);
+	byte byte3 = (byte) ((theInt >> 8) & 0xff);
+	byte byte4 = (byte) (theInt & 0xff);
+	byte[] temp = {byte1, byte2, byte3, byte4};
+	baos.write(temp, 0, 4);
+
+}
+
+void updateAdler(byte value) {
+
+	int low = adler32 & 0xffff;
+	int high = (adler32 >> 16) & 0xffff;
+	int valueInt = value & 0xff;
+	low = (low + valueInt) % BASE;
+	high = (low + high) % BASE;
+	adler32 = (high << 16) | low;
+
+}
+
+int hash(byte[] bytes) {
+
+	int hash = ((bytes[0] & 0xff) << 24 | (bytes[1] & 0xff) << 16 | (bytes[2] & 0xff) << 8) % HASH;
+	if (hash < 0) {
+		hash = hash + HASH;
+	}
+	return hash;
+
+}
+
+void writeBits(int value, int count) {
+
+	buffer |= value << bitCount;
+	bitCount += count;
+	if (bitCount >= 16) {
+		bytes.write((byte) buffer);
+		bytes.write((byte) (buffer >>> 8));
+		buffer >>>= 16;
+		bitCount -= 16;
+	}
+
+}
+
+void alignToByte() {
+
+	if (bitCount > 0) {
+		bytes.write((byte) buffer);
+		if (bitCount > 8) bytes.write((byte) (buffer >>> 8));
+	}
+	buffer = 0;
+	bitCount = 0;
+
+}
+
+void outputLiteral(byte literal) {
+
+	int i = literal & 0xff;
+	
+	if (i <= 143) {
+		// 0 through 143 are 8 bits long starting at 00110000
+		writeBits(mirrorBytes[0x30 + i], 8);
+	}
+	else {
+		// 144 through 255 are 9 bits long starting at 110010000
+		writeBits(1 + 2 * mirrorBytes[0x90 - 144 + i], 9);
+	}
+
+}
+
+Code findCode(int value, Code[] codes) {
+
+	int i, j, k;
+	
+	i = -1;
+	j = codes.length;
+	while (true) {
+		k = (j + i) / 2;
+		if (value < codes[k].min) {
+			j = k;
+		}
+		else if (value > codes[k].max) {
+			i = k;
+		}
+		else {
+			return codes[k];
+		}
+	}
+
+}
+
+void outputMatch(int length, int distance) {
+
+	Code d, l;
+	int thisLength;
+	
+	while (length > 0) {
+
+		// we can transmit matches of lengths 3 through 258 inclusive
+		// so if length exceeds 258, we must transmit in several steps,
+		// with 258 or less in each step
+		
+		if (length > 260) {
+			thisLength = 258;
+		}
+		else if (length <= 258) {
+			thisLength = length;
+		}
+		else {
+			thisLength = length - 3;
+		}
+		
+		length = length - thisLength;
+				
+		// find length code
+		l = findCode(thisLength, lengthCodes);
+		
+		// transmit the length code
+		// 256 through 279 are 7 bits long starting at 0000000
+		// 280 through 287 are 8 bits long starting at 11000000
+		if (l.code <= 279) {
+			writeBits(mirrorBytes[(l.code - 256) * 2], 7);
+		}
+		else {
+			writeBits(mirrorBytes[0xc0 - 280 + l.code], 8);
+		}
+		
+		// transmit the extra bits
+		if (l.extraBits != 0) {
+			writeBits(thisLength - l.min, l.extraBits);
+		}
+		
+		// find distance code
+		d = findCode(distance, distanceCodes);
+		
+		// transmit the distance code
+		// 5 bits long starting at 00000
+		writeBits(mirrorBytes[d.code * 8], 5);
+		
+		// transmit the extra bits
+		if (d.extraBits != 0) {
+			writeBits(distance - d.min, d.extraBits);
+		}
+	
+	}
+
+}
+
+Match findLongestMatch(int position, Link firstPosition) {
+
+	Link link = firstPosition;
+	int numberOfMatches = 0;
+	Match bestMatch = new Match(-1, -1);
+	
+	while (true) {
+	
+		int matchPosition = link.value;
+		
+		if (position - matchPosition < WINDOW && matchPosition != 0) {
+
+			int i;
+			
+			for (i = 1; position + i < inLength; i++) {
+				if (in[position + i] != in[matchPosition + i]) {
+					break;
+				}
+			}
+			
+			if (i >= MIN_LENGTH) {
+			
+				if (i > bestMatch.length) {
+					bestMatch.length = i;
+					bestMatch.distance = position - matchPosition;
+				}
+				
+				numberOfMatches = numberOfMatches + 1;
+				
+				if (numberOfMatches == MAX_MATCHES) {
+					break;
+				}
+			
+			}
+						
+		}
+		
+		link = link.next;
+		if (link == null) {
+			break;
+		}
+	
+	}
+	
+	if (bestMatch.length < MIN_LENGTH || bestMatch.distance < 1 || bestMatch.distance > WINDOW) {
+		return null;
+	}
+	
+	return bestMatch;	
+
+}
+
+void updateHashtable(int to, int from) {
+
+	byte[] data = new byte[3];
+	int hash;
+	Link temp;
+	
+	for (int i = to; i < from; i++) {
+		
+		if (i + MIN_LENGTH > inLength) {
+			break;
+		}
+		
+		data[0] = in[i];
+		data[1] = in[i + 1];
+		data[2] = in[i + 2];
+		
+		hash = hash(data);
+		
+		if (window[nextWindow].previous != null) {
+			window[nextWindow].previous.next = null;
+		}
+		else if (window[nextWindow].hash != 0) {
+			hashtable[window[nextWindow].hash].next = null;
+		}
+		
+		window[nextWindow].hash = hash;
+		window[nextWindow].value = i;
+		window[nextWindow].previous = null;
+		temp = window[nextWindow].next = hashtable[hash].next;
+		hashtable[hash].next = window[nextWindow];
+		if (temp != null) {
+			temp.previous = window[nextWindow];
+		}
+		
+		nextWindow = nextWindow + 1;
+		if (nextWindow == WINDOW) {
+			nextWindow = 0;
+		}
+			
+	}
+
+}
+
+void compress() {
+
+	int position, newPosition;
+	byte[] data = new byte[3];
+	int hash;
+	for (int i = 0; i < HASH; i++) {
+		hashtable[i] = new Link();
+	}
+	for (int i = 0; i < WINDOW; i++) {
+		window[i] = new Link();
+	}
+	nextWindow = 0;
+	Link firstPosition;
+	Match match;
+	int deferredPosition = -1;
+	Match deferredMatch = null;
+	
+	writeBits(0x01, 1); // BFINAL = 0x01 (final block)
+	writeBits(0x01, 2); // BTYPE = 0x01 (compression with fixed Huffman codes)
+	
+	// just output first byte so we never match at zero
+	outputLiteral(in[0]);
+	position = 1;
+	
+	while (position < inLength) {
+	
+		if (inLength - position < MIN_LENGTH) {
+			outputLiteral(in[position]);
+			position = position + 1;
+			continue;
+		}
+		
+		data[0] = in[position];
+		data[1] = in[position + 1];
+		data[2] = in[position + 2];
+		
+		hash = hash(data);
+		firstPosition = hashtable[hash];
+		
+		match = findLongestMatch(position, firstPosition);
+		
+		updateHashtable(position, position + 1);
+		
+		if (match != null) {
+		
+			if (deferredMatch != null) {
+				if (match.length > deferredMatch.length + 1) {
+					// output literal at deferredPosition
+					outputLiteral(in[deferredPosition]);
+					// defer this match
+					deferredPosition = position;
+					deferredMatch = match;
+					position = position + 1;
+				}
+				else {
+					// output deferredMatch
+					outputMatch(deferredMatch.length, deferredMatch.distance);
+					newPosition = deferredPosition + deferredMatch.length;
+					deferredPosition = -1;
+					deferredMatch = null;
+					updateHashtable(position + 1, newPosition);
+					position = newPosition;
+				}
+			}
+			else {
+				// defer this match
+				deferredPosition = position;
+				deferredMatch = match;
+				position = position + 1;
+			}
+		
+		}
+		
+		else {
+		
+			// no match found
+			if (deferredMatch != null) {
+				outputMatch(deferredMatch.length, deferredMatch.distance);
+				newPosition = deferredPosition + deferredMatch.length;
+				deferredPosition = -1;
+				deferredMatch = null;
+				updateHashtable(position + 1, newPosition);
+				position = newPosition;
+			}
+			else {
+				outputLiteral(in[position]);
+				position = position + 1;
+			}
+		
+		}
+	
+	}
+	
+	writeBits(0, 7); // end of block code
+	alignToByte();
+
+}
+
+void compressHuffmanOnly() {
+
+	int position;
+	
+	writeBits(0x01, 1); // BFINAL = 0x01 (final block)
+	writeBits(0x01, 2); // BTYPE = 0x01 (compression with fixed Huffman codes)
+	
+	for (position = 0; position < inLength;) {
+	
+		outputLiteral(in[position]);
+		position = position + 1;
+	
+	}
+	
+	writeBits(0, 7); // end of block code
+	alignToByte();
+
+}
+
+void store() {
+
+	// stored blocks are limited to 0xffff bytes
+	
+	int start = 0;
+	int length = inLength;
+	int blockLength;
+	int BFINAL = 0x00; // BFINAL = 0x00 or 0x01 (if final block), BTYPE = 0x00 (no compression)
+	
+	while (length > 0) {
+	
+		if (length < 65535) {
+			blockLength = length;
+			BFINAL = 0x01;
+		}
+		else {
+			blockLength = 65535;
+			BFINAL = 0x00;
+		}
+		
+		// write data header
+		bytes.write((byte) BFINAL);
+		writeShortLSB(bytes, blockLength); // LEN
+		writeShortLSB(bytes, blockLength ^ 0xffff); // NLEN (one's complement of LEN)
+	
+		// write actual data
+		bytes.write(in, start, blockLength);
+		
+		length = length - blockLength;
+		start = start + blockLength;
+	
+	}
+
+}
+
+public byte[] deflate(byte[] input) {
+
+	in = input;
+	inLength = input.length;
+	
+	// write zlib header
+	bytes.write((byte) 0x78); // window size = 0x70 (32768), compression method = 0x08
+	bytes.write((byte) 0x9C); // compression level = 0x80 (default), check bits = 0x1C
+	
+	// compute checksum
+	for (int i = 0; i < inLength; i++) {
+		updateAdler(in[i]);
+	}
+	
+	//store();
+	
+	//compressHuffmanOnly();
+	
+	compress();
+	
+	// write checksum
+	writeInt(bytes, adler32);
+	
+	return bytes.toByteArray();
+
+}
+
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/PngDeflater.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/PngEncoder.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/PngEncoder.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/PngEncoder.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,364 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.image;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.ImageData;
+import org.eclipse.swt.graphics.ImageLoader;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.internal.Compatibility;
+
+final class PngEncoder extends Object {
+
+	static final byte SIGNATURE[] = {(byte) '\211', (byte) 'P', (byte) 'N', (byte) 'G', (byte) '\r', (byte) '\n', (byte) '\032', (byte) '\n'};
+	static final byte TAG_IHDR[] = {(byte) 'I', (byte) 'H', (byte) 'D', (byte) 'R'};
+	static final byte TAG_PLTE[] = {(byte) 'P', (byte) 'L', (byte) 'T', (byte) 'E'};
+	static final byte TAG_TRNS[] = {(byte) 't', (byte) 'R', (byte) 'N', (byte) 'S'};
+	static final byte TAG_IDAT[] = {(byte) 'I', (byte) 'D', (byte) 'A', (byte) 'T'};
+	static final byte TAG_IEND[] = {(byte) 'I', (byte) 'E', (byte) 'N', (byte) 'D'};
+	
+	ByteArrayOutputStream bytes = new ByteArrayOutputStream(1024);
+	PngChunk chunk;
+	
+	ImageLoader loader;
+	ImageData data;
+	int transparencyType;
+	
+	int width, height, bitDepth, colorType;
+	
+	int compressionMethod = 0;
+	int filterMethod = 0;
+	int interlaceMethod = 0;
+	
+public PngEncoder(ImageLoader loader) {
+
+	this.loader = loader;
+	this.data = loader.data[0];
+	this.transparencyType = data.getTransparencyType();
+	
+	this.width = data.width;
+	this.height = data.height;
+	
+	this.bitDepth = 8;
+	
+	this.colorType = 2;
+	
+	if (data.palette.isDirect) {
+		if (transparencyType == SWT.TRANSPARENCY_ALPHA) {
+			this.colorType = 6;
+		}
+	}
+	else {
+		this.colorType = 3;
+	}
+	
+	if (!(colorType == 2 || colorType == 3 || colorType == 6)) SWT.error(SWT.ERROR_INVALID_IMAGE);
+
+}
+
+void writeShort(ByteArrayOutputStream baos, int theShort) {
+
+	byte byte1 = (byte) ((theShort >> 8) & 0xff);
+	byte byte2 = (byte) (theShort & 0xff);
+	byte[] temp = {byte1, byte2};
+	baos.write(temp, 0, 2);
+
+}
+
+void writeInt(ByteArrayOutputStream baos, int theInt) {
+
+	byte byte1 = (byte) ((theInt >> 24) & 0xff);
+	byte byte2 = (byte) ((theInt >> 16) & 0xff);
+	byte byte3 = (byte) ((theInt >> 8) & 0xff);
+	byte byte4 = (byte) (theInt & 0xff);
+	byte[] temp = {byte1, byte2, byte3, byte4};
+	baos.write(temp, 0, 4);
+
+}
+
+void writeChunk(byte[] tag, byte[] buffer) {
+
+	int bufferLength = (buffer != null) ? buffer.length : 0;
+	
+	chunk = new PngChunk(bufferLength);
+	
+	writeInt(bytes, bufferLength);
+	bytes.write(tag, 0, 4);
+	chunk.setType(tag);
+	if (bufferLength != 0) {
+		bytes.write(buffer, 0, bufferLength);
+		chunk.setData(buffer);
+	}
+	else {
+		chunk.setCRC(chunk.computeCRC());
+	}
+	writeInt(bytes, chunk.getCRC());
+
+}
+
+void writeSignature() {
+
+	bytes.write(SIGNATURE, 0, 8);
+
+}
+
+void writeHeader() {
+
+	ByteArrayOutputStream baos = new ByteArrayOutputStream(13);
+	
+	writeInt(baos, width);
+	writeInt(baos, height);
+	baos.write(bitDepth);
+	baos.write(colorType);
+	baos.write(compressionMethod);
+	baos.write(filterMethod);
+	baos.write(interlaceMethod);
+	
+	writeChunk(TAG_IHDR, baos.toByteArray());
+
+}
+
+void writePalette() {
+
+	RGB[] RGBs = data.palette.getRGBs();
+	
+	if (RGBs.length > 256) SWT.error(SWT.ERROR_INVALID_IMAGE);
+	
+	ByteArrayOutputStream baos = new ByteArrayOutputStream(RGBs.length);
+	
+	for (int i = 0; i < RGBs.length; i++) {
+	
+		baos.write((byte) RGBs[i].red);
+		baos.write((byte) RGBs[i].green);
+		baos.write((byte) RGBs[i].blue);
+	
+	}
+	
+	writeChunk(TAG_PLTE, baos.toByteArray());
+
+}
+
+void writeTransparency() {
+
+	ByteArrayOutputStream baos = new ByteArrayOutputStream();
+	
+	switch (transparencyType) {
+	
+		case SWT.TRANSPARENCY_ALPHA:
+			
+			int pixelValue, alphaValue;
+			
+			byte[] alphas = new byte[data.palette.getRGBs().length];
+			
+			for (int y = 0; y < height; y++) {
+			
+				for (int x = 0; x < width; x++) {
+				
+					pixelValue = data.getPixel(x, y);
+					alphaValue = data.getAlpha(x, y);
+					
+					alphas[pixelValue] = (byte) alphaValue;
+				
+				}
+			
+			}
+			
+			baos.write(alphas, 0, alphas.length);
+			
+			break;
+		
+		case SWT.TRANSPARENCY_PIXEL:
+			
+			int pixel = data.transparentPixel;
+			
+			if (colorType == 2) {
+			
+				int redMask = data.palette.redMask;
+				int redShift = data.palette.redShift;
+				int greenMask = data.palette.greenMask;
+				int greenShift = data.palette.greenShift;
+				int blueShift = data.palette.blueShift;
+				int blueMask = data.palette.blueMask;
+				
+				int r = pixel & redMask;
+				r = (redShift < 0) ? r >>> -redShift : r << redShift;
+				int g = pixel & greenMask;
+				g = (greenShift < 0) ? g >>> -greenShift : g << greenShift;
+				int b = pixel & blueMask;
+				b = (blueShift < 0) ? b >>> -blueShift : b << blueShift;
+				
+				writeShort(baos, r);
+				writeShort(baos, g);
+				writeShort(baos, b);
+			
+			}
+			
+			if (colorType == 3) {
+			
+				byte[] padding = new byte[pixel + 1];
+				
+				for (int i = 0; i < pixel; i++) {
+				
+					padding[i] = (byte) 255;
+				
+				}
+				
+				padding[pixel] = (byte) 0;
+				
+				baos.write(padding, 0, padding.length);
+			
+			}
+			
+			break;
+	
+	}
+	
+	writeChunk(TAG_TRNS, baos.toByteArray());
+
+}
+
+void writeImageData() throws IOException {
+
+	ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
+	OutputStream os = Compatibility.newDeflaterOutputStream(baos);
+	if (os == null) os = baos;
+	
+	if (colorType == 3) {
+	
+		byte[] lineData = new byte[width];
+		
+		for (int y = 0; y < height; y++) {
+			
+			int filter = 0;
+			os.write(filter);
+			
+			data.getPixels(0, y, width, lineData, 0);
+			
+			for (int x = 0; x < lineData.length; x++) {
+			
+				os.write(lineData[x]);
+			
+			}
+		
+		}
+	
+	}
+	
+	else {
+	
+		int[] lineData = new int[width];
+		byte[] alphaData = null;
+		if (colorType == 6) {
+			alphaData = new byte[width];
+		}
+		
+		int redMask = data.palette.redMask;
+		int redShift = data.palette.redShift;
+		int greenMask = data.palette.greenMask;
+		int greenShift = data.palette.greenShift;
+		int blueShift = data.palette.blueShift;
+		int blueMask = data.palette.blueMask;
+		
+		for (int y = 0; y < height; y++) {
+		
+			int filter = 0;
+			os.write(filter);
+			
+			data.getPixels(0, y, width, lineData, 0);
+			
+			if (colorType == 6) {
+				data.getAlphas(0, y, width, alphaData, 0);
+			}
+			
+			for (int x = 0; x < lineData.length; x++) {
+			
+				int pixel = lineData[x];
+				
+				int r = pixel & redMask;
+				r = (redShift < 0) ? r >>> -redShift : r << redShift;
+				int g = pixel & greenMask;
+				g = (greenShift < 0) ? g >>> -greenShift : g << greenShift;
+				int b = pixel & blueMask;
+				b = (blueShift < 0) ? b >>> -blueShift : b << blueShift;
+				
+				os.write(r);
+				os.write(g);
+				os.write(b);
+				
+				if (colorType == 6) {
+					os.write(alphaData[x]);
+				}
+			
+			}
+		
+		}
+	
+	}
+	
+	os.flush();
+	os.close();
+	
+	byte[] compressed = baos.toByteArray();
+	if (os == baos) {
+		PngDeflater deflater = new PngDeflater();
+		compressed = deflater.deflate(compressed);
+	}
+	
+	writeChunk(TAG_IDAT, compressed);
+
+}
+
+void writeEnd() {
+
+	writeChunk(TAG_IEND, null);
+
+}
+
+public void encode(LEDataOutputStream outputStream) {
+
+	try {
+	
+		writeSignature();
+		writeHeader();
+		
+		if (colorType == 3) {
+			writePalette();
+		}
+		
+		boolean transparencyAlpha = (transparencyType == SWT.TRANSPARENCY_ALPHA);
+		boolean transparencyPixel = (transparencyType == SWT.TRANSPARENCY_PIXEL);
+		boolean type2Transparency = (colorType == 2 && transparencyPixel);
+		boolean type3Transparency = (colorType == 3 && (transparencyAlpha || transparencyPixel));
+		
+		if (type2Transparency || type3Transparency) {
+			writeTransparency();
+		}
+		
+		writeImageData();
+		writeEnd();
+		
+		outputStream.write(bytes.toByteArray());
+	
+	}
+	
+	catch (IOException e) {
+	
+		SWT.error(SWT.ERROR_IO, e);
+	
+	}
+
+}
+
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/PngEncoder.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/PngFileReadState.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/PngFileReadState.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/PngFileReadState.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.image;
+
+
+class PngFileReadState extends Object {
+	boolean readIHDR;
+	boolean readPLTE;
+	boolean readIDAT;
+	boolean readIEND;
+	
+	// Non - critical chunks
+	boolean readTRNS;
+	
+	// Set to true after IDATs have been read.
+	boolean readPixelData;
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/PngFileReadState.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/PngHuffmanTable.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/PngHuffmanTable.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/PngHuffmanTable.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,125 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.image;
+
+import java.io.*;
+
+public class PngHuffmanTable {
+	CodeLengthInfo[] codeLengthInfo;
+	int[] codeValues;
+	
+	static final int MAX_CODE_LENGTH = 15;
+	static final int BAD_CODE = 0xFFFFFFF;
+	static final int incs[] = {1391376, 463792, 198768, 86961, 33936, 13776, 4592, 1968, 861, 336, 112, 48, 21, 7, 3, 1};
+
+PngHuffmanTable (int[] lengths) {
+	super();
+	initialize(lengths);
+	generateTable(lengths);
+}
+
+private void initialize(int[] lengths) {
+	codeValues = new int[lengths.length];
+	for (int i = 0; i < codeValues.length; i++) {
+		codeValues[i] = i;
+	}
+	
+	// minCodesByLength[n] : The smallest Huffman code of length n + 1.
+	// maxCodesByLength[n] : The largest Huffman code of length n + 1.
+	// indexesByLength[n] : Index into the values array. First value with a code of length n + 1.
+	codeLengthInfo = new CodeLengthInfo[MAX_CODE_LENGTH];
+	for (int i = 0; i < MAX_CODE_LENGTH; i++) {
+		codeLengthInfo[i] = new CodeLengthInfo();
+		codeLengthInfo[i].length = i;
+		codeLengthInfo[i].baseIndex = 0;
+		codeLengthInfo[i].min = BAD_CODE;
+		codeLengthInfo[i].max = -1;
+	}
+}
+	
+private void generateTable(int[] lengths) {
+	// Sort the values using shellsort. Primary key is code size. Secondary key is value.
+	int codeValuesTemp;
+	for (int k = 0; k < 16; k++) {
+		for (int h = incs[k], i = h; i < lengths.length; i++) {
+			int v = lengths[i];
+			codeValuesTemp = codeValues[i];
+			int j = i;
+			while (j >= h && (lengths[j - h] > v || (lengths[j - h] == v && codeValues[j - h] > codeValuesTemp))) {
+				lengths[j] = lengths[j - h];
+				codeValues[j] = codeValues[j - h];
+				j -= h;
+			}
+			lengths[j] = v;
+			codeValues[j] = codeValuesTemp;
+		}
+	}
+
+	// These values in these arrays correspond to the elements of the
+	// "values" array. The Huffman code for codeValues[N] is codes[N]
+	// and the length of the code is lengths[N].
+	int[] codes = new int[lengths.length];
+	int lastLength = 0;
+	int code = 0;
+	for (int i = 0; i < lengths.length; i++) {
+		while (lastLength != lengths[i]) {
+			lastLength++;
+			code <<= 1;
+		}
+		if (lastLength != 0) {
+			codes[i] = code;
+			code++;
+		}
+	}
+	
+	int last = 0;
+	for (int i = 0; i < lengths.length; i++) {
+		if (last != lengths[i]) {
+			last = lengths[i];
+			codeLengthInfo[last - 1].baseIndex = i;
+			codeLengthInfo[last - 1].min = codes[i];
+		}
+		if (last != 0) codeLengthInfo[last - 1].max = codes[i];
+	}
+}
+
+int getNextValue(PngDecodingDataStream stream) throws IOException {
+	int code = stream.getNextIdatBit();
+	int codelength = 0;
+
+	// Here we are taking advantage of the fact that 1 bits are used as
+	// a prefix to the longer codeValues.
+	while (codelength < MAX_CODE_LENGTH && code > codeLengthInfo[codelength].max) {
+		code = ((code << 1) | stream.getNextIdatBit());
+        codelength++;
+	}
+	if (codelength >= MAX_CODE_LENGTH) stream.error();
+
+	// Now we have a Huffman code of length (codelength + 1) that
+	// is somewhere in the range
+	// minCodesByLength[codelength]..maxCodesByLength[codelength].
+	// This code is the (offset + 1)'th code of (codelength + 1);
+	int offset = code - codeLengthInfo[codelength].min;
+
+	// indexesByLength[codelength] is the first code of length (codelength + 1)
+	// so now we can look up the value for the Huffman code in the table.
+	int index = codeLengthInfo[codelength].baseIndex + offset;
+	return codeValues[index];
+}	
+	
+static class CodeLengthInfo {
+	int length;
+	int max;
+	int min;
+	int baseIndex;
+}
+
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/PngHuffmanTable.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/PngHuffmanTables.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/PngHuffmanTables.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/PngHuffmanTables.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,160 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.image;
+
+import java.io.*;
+
+public class PngHuffmanTables {
+	PngHuffmanTable literalTable;
+	PngHuffmanTable distanceTable;
+	
+	static PngHuffmanTable FixedLiteralTable;
+	static PngHuffmanTable FixedDistanceTable;
+	
+	static final int LiteralTableSize = 288;
+	static final int[] FixedLiteralLengths = {
+        8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
+        8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
+        8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
+        8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
+        8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
+        8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
+        9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
+        9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
+        9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
+        9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
+        9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 7, 7, 7, 7, 7, 7, 7, 7,
+        7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8,
+	};
+
+	static final int DistanceTableSize = 32;
+	static final int[] FixedDistanceLengths = {
+		5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
+		5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
+	};
+	
+	static final int LengthCodeTableSize = 19;
+	static final int[] LengthCodeOrder = {
+		16, 17, 18, 0, 8, 7, 9, 6, 10, 5,
+		11, 4, 12, 3, 13, 2, 14, 1, 15
+	};
+	
+static PngHuffmanTables getDynamicTables(PngDecodingDataStream stream) throws IOException {
+	return new PngHuffmanTables(stream);
+}
+static PngHuffmanTables getFixedTables() {
+	return new PngHuffmanTables();
+}
+
+private PngHuffmanTable getFixedLiteralTable() {
+	if (FixedLiteralTable == null) {
+		FixedLiteralTable = new PngHuffmanTable(FixedLiteralLengths);
+	}
+	return FixedLiteralTable;
+}
+
+private PngHuffmanTable getFixedDistanceTable() {
+	if (FixedDistanceTable == null) {
+		FixedDistanceTable = new PngHuffmanTable(FixedDistanceLengths);
+	}
+	return FixedDistanceTable;
+}
+
+private PngHuffmanTables () {
+	literalTable = getFixedLiteralTable();
+	distanceTable = getFixedDistanceTable();
+}
+
+private PngHuffmanTables (PngDecodingDataStream stream) throws IOException {
+	int literals = PngLzBlockReader.FIRST_LENGTH_CODE 
+		+ stream.getNextIdatBits(5);
+	int distances = PngLzBlockReader.FIRST_DISTANCE_CODE 
+		+ stream.getNextIdatBits(5);
+	int codeLengthCodes = PngLzBlockReader.FIRST_CODE_LENGTH_CODE 
+		+ stream.getNextIdatBits(4);
+
+	if (codeLengthCodes > PngLzBlockReader.LAST_CODE_LENGTH_CODE) {
+		stream.error();
+	}
+	
+	/* Tricky, tricky, tricky. The length codes are stored in
+	 * a very odd order. (For the order, see the definition of
+	 * the static field lengthCodeOrder.) Also, the data may 
+	 * not contain values for all the codes. It may just contain 
+	 * values for the first X number of codes. The table should
+	 * be of size <LengthCodeTableSize> regardless of the number
+	 * of values actually given in the table.
+	 */	
+	int[] lengthCodes = new int[LengthCodeTableSize];
+	for (int i = 0; i < codeLengthCodes; i++) {
+		lengthCodes[LengthCodeOrder[i]] = stream.getNextIdatBits(3);
+	}
+	PngHuffmanTable codeLengthsTable = new PngHuffmanTable(lengthCodes);
+	
+	int[] literalLengths = readLengths(
+		stream, literals, codeLengthsTable, LiteralTableSize);
+	int[] distanceLengths = readLengths(
+		stream, distances, codeLengthsTable, DistanceTableSize);
+	
+	literalTable = new PngHuffmanTable(literalLengths);
+	distanceTable = new PngHuffmanTable(distanceLengths);
+}
+
+private int [] readLengths (PngDecodingDataStream stream, 
+	int numLengths, 
+	PngHuffmanTable lengthsTable,
+	int tableSize) throws IOException
+{
+	int[] lengths = new int[tableSize];
+	
+	for (int index = 0; index < numLengths;) {
+		int value = lengthsTable.getNextValue(stream);
+		if (value < 16) {
+			// Literal value
+			lengths[index] = value;
+			index++;
+		} else if (value == 16) {
+			// Repeat the previous code 3-6 times.
+			int count = stream.getNextIdatBits(2) + 3;
+			for (int i = 0; i < count; i++) {
+				lengths[index] = lengths [index - 1];
+				index++;
+			}
+		} else if (value == 17) {
+			// Repeat 0 3-10 times.
+			int count = stream.getNextIdatBits(3) + 3;
+			for (int i = 0; i < count; i++) {
+				lengths[index] = 0;
+				index++;
+			}
+		} else if (value == 18) {
+			// Repeat 0 11-138 times.
+			int count = stream.getNextIdatBits(7) + 11;
+			for (int i = 0; i < count; i++) {
+				lengths[index] = 0;
+				index++;
+			}
+		} else {
+			stream.error();
+		}
+	}
+	return lengths;
+}
+
+int getNextLiteralValue(PngDecodingDataStream stream) throws IOException {
+	return literalTable.getNextValue(stream);
+}
+
+int getNextDistanceValue(PngDecodingDataStream stream) throws IOException {
+	return distanceTable.getNextValue(stream);
+}
+
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/PngHuffmanTables.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/PngIdatChunk.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/PngIdatChunk.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/PngIdatChunk.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.image;
+
+
+import org.eclipse.swt.*;
+
+class PngIdatChunk extends PngChunk {
+
+	static final int HEADER_BYTES_LENGTH = 2;
+	static final int ADLER_FIELD_LENGTH = 4;
+	static final int HEADER_BYTE1_DATA_OFFSET = DATA_OFFSET + 0;
+	static final int HEADER_BYTE2_DATA_OFFSET = DATA_OFFSET + 1;
+	static final int ADLER_DATA_OFFSET = DATA_OFFSET + 2; // plus variable compressed data length
+
+PngIdatChunk(byte headerByte1, byte headerByte2, byte[] data, int adler) {
+	super(data.length + HEADER_BYTES_LENGTH + ADLER_FIELD_LENGTH);
+	setType(TYPE_IDAT);
+	reference[HEADER_BYTE1_DATA_OFFSET] = headerByte1;
+	reference[HEADER_BYTE2_DATA_OFFSET] = headerByte2;
+	System.arraycopy(data, 0, reference, DATA_OFFSET, data.length);
+	setInt32(ADLER_DATA_OFFSET, adler);
+	setCRC(computeCRC());
+}
+		
+PngIdatChunk(byte[] reference) {
+	super(reference);
+}
+
+int getChunkType() {
+	return CHUNK_IDAT;
+}
+
+/**
+ * Answer whether the chunk is a valid IDAT chunk.
+ */
+void validate(PngFileReadState readState, PngIhdrChunk headerChunk) {
+	if (!readState.readIHDR
+		|| (headerChunk.getMustHavePalette() && !readState.readPLTE)
+		|| readState.readIEND) 
+	{
+		SWT.error(SWT.ERROR_INVALID_IMAGE);
+	} else {
+		readState.readIDAT = true;
+	}
+	
+	super.validate(readState, headerChunk);
+}
+
+byte getDataByteAtOffset(int offset) {
+	return reference[DATA_OFFSET + offset];
+}
+
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/PngIdatChunk.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/PngIendChunk.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/PngIendChunk.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/PngIendChunk.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.image;
+
+
+import org.eclipse.swt.*;
+
+class PngIendChunk extends PngChunk {
+
+PngIendChunk() {
+	super(0);
+	setType(TYPE_IEND);
+	setCRC(computeCRC());
+}
+
+PngIendChunk(byte[] reference){
+	super(reference);
+}
+
+int getChunkType() {
+	return CHUNK_IEND;
+}
+
+/**
+ * Answer whether the chunk is a valid IEND chunk.
+ */
+void validate(PngFileReadState readState, PngIhdrChunk headerChunk) {
+	// An IEND chunk is invalid if no IHDR has been read.
+	// Or if a palette is required and has not been read.
+	// Or if no IDAT chunk has been read.
+	if (!readState.readIHDR
+		|| (headerChunk.getMustHavePalette() && !readState.readPLTE)
+		|| !readState.readIDAT
+		|| readState.readIEND) 
+	{
+		SWT.error(SWT.ERROR_INVALID_IMAGE);
+	} else {
+		readState.readIEND = true;
+	}
+	
+	super.validate(readState, headerChunk);
+	
+	// IEND chunks are not allowed to have any data.
+	if (getLength() > 0) SWT.error(SWT.ERROR_INVALID_IMAGE);
+}
+
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/PngIendChunk.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/PngIhdrChunk.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/PngIhdrChunk.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/PngIhdrChunk.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,408 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.image;
+
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
+class PngIhdrChunk extends PngChunk {
+	static final int IHDR_DATA_LENGTH = 13;
+	
+	static final int WIDTH_DATA_OFFSET = DATA_OFFSET + 0;
+	static final int HEIGHT_DATA_OFFSET = DATA_OFFSET + 4;
+	static final int BIT_DEPTH_OFFSET = DATA_OFFSET + 8;
+	static final int COLOR_TYPE_OFFSET = DATA_OFFSET + 9;
+	static final int COMPRESSION_METHOD_OFFSET = DATA_OFFSET + 10;
+	static final int FILTER_METHOD_OFFSET = DATA_OFFSET + 11;
+	static final int INTERLACE_METHOD_OFFSET = DATA_OFFSET + 12;
+	
+	static final byte COLOR_TYPE_GRAYSCALE = 0;
+	static final byte COLOR_TYPE_RGB = 2;
+	static final byte COLOR_TYPE_PALETTE = 3;
+	static final byte COLOR_TYPE_GRAYSCALE_WITH_ALPHA = 4;
+	static final byte COLOR_TYPE_RGB_WITH_ALPHA = 6;
+	
+	static final int INTERLACE_METHOD_NONE = 0;
+	static final int INTERLACE_METHOD_ADAM7 = 1;
+	
+	static final int FILTER_NONE = 0;
+	static final int FILTER_SUB = 1;
+	static final int FILTER_UP = 2;
+	static final int FILTER_AVERAGE = 3;
+	static final int FILTER_PAETH = 4;
+	
+	static final byte[] ValidBitDepths = {1, 2, 4, 8, 16};
+	static final byte[] ValidColorTypes = {0, 2, 3, 4, 6};
+	
+	int width, height;
+	byte bitDepth, colorType, compressionMethod, filterMethod, interlaceMethod;
+	
+PngIhdrChunk(int width, int height, byte bitDepth, byte colorType, byte compressionMethod, byte filterMethod, byte interlaceMethod) {
+	super(IHDR_DATA_LENGTH);
+	setType(TYPE_IHDR);
+	setWidth(width);
+	setHeight(height);
+	setBitDepth(bitDepth);
+	setColorType(colorType);
+	setCompressionMethod(compressionMethod);
+	setFilterMethod(filterMethod);
+	setInterlaceMethod(interlaceMethod);
+	setCRC(computeCRC());
+}
+
+/**
+ * Construct a PNGChunk using the reference bytes
+ * given.
+ */	
+PngIhdrChunk(byte[] reference) {
+	super(reference);
+	if (reference.length <= IHDR_DATA_LENGTH) SWT.error(SWT.ERROR_INVALID_IMAGE);
+	width = getInt32(WIDTH_DATA_OFFSET);
+	height = getInt32(HEIGHT_DATA_OFFSET);
+	bitDepth = reference[BIT_DEPTH_OFFSET];
+	colorType = reference[COLOR_TYPE_OFFSET];
+	compressionMethod = reference[COMPRESSION_METHOD_OFFSET];
+	filterMethod = reference[FILTER_METHOD_OFFSET];
+	interlaceMethod = reference[INTERLACE_METHOD_OFFSET];
+}
+
+int getChunkType() {
+	return CHUNK_IHDR;
+}
+
+/**
+ * Get the image's width in pixels.
+ */
+int getWidth() {
+	return width;
+}
+
+/**
+ * Set the image's width in pixels.
+ */
+void setWidth(int value) {
+	setInt32(WIDTH_DATA_OFFSET, value);
+	width = value;
+}
+
+/**
+ * Get the image's height in pixels.
+ */
+int getHeight() {
+	return height;
+}
+
+/**
+ * Set the image's height in pixels.
+ */
+void setHeight(int value) {
+	setInt32(HEIGHT_DATA_OFFSET, value);
+	height = value;
+}
+
+/**
+ * Get the image's bit depth.
+ * This is limited to the values 1, 2, 4, 8, or 16.
+ */
+byte getBitDepth() {
+	return bitDepth;
+}
+
+/**
+ * Set the image's bit depth.
+ * This is limited to the values 1, 2, 4, 8, or 16.
+ */
+void setBitDepth(byte value) {
+	reference[BIT_DEPTH_OFFSET] = value;
+	bitDepth = value;
+}
+
+/**
+ * Get the image's color type.
+ * This is limited to the values:
+ * 0 - Grayscale image.
+ * 2 - RGB triple.
+ * 3 - Palette.
+ * 4 - Grayscale with Alpha channel.
+ * 6 - RGB with Alpha channel.
+ */
+byte getColorType() {
+	return colorType;
+}
+
+/**
+ * Set the image's color type.
+ * This is limited to the values:
+ * 0 - Grayscale image.
+ * 2 - RGB triple.
+ * 3 - Palette.
+ * 4 - Grayscale with Alpha channel.
+ * 6 - RGB with Alpha channel.
+ */
+void setColorType(byte value) {
+	reference[COLOR_TYPE_OFFSET] = value;
+	colorType = value;
+}
+
+/**
+ * Get the image's compression method.
+ * This value must be 0.
+ */
+byte getCompressionMethod() {
+	return compressionMethod;
+}
+
+/**
+ * Set the image's compression method.
+ * This value must be 0.
+ */
+void setCompressionMethod(byte value) {
+	reference[COMPRESSION_METHOD_OFFSET] = value;
+	compressionMethod = value;
+}
+
+/**
+ * Get the image's filter method.
+ * This value must be 0.
+ */
+byte getFilterMethod() {
+	return filterMethod;
+}
+
+/**
+ * Set the image's filter method.
+ * This value must be 0.
+ */
+void setFilterMethod(byte value) {
+	reference[FILTER_METHOD_OFFSET] = value;
+	filterMethod = value;
+}
+
+/**
+ * Get the image's interlace method.
+ * This value is limited to:
+ * 0 - No interlacing used.
+ * 1 - Adam7 interlacing used.
+ */
+byte getInterlaceMethod() {
+	return interlaceMethod;
+}
+
+/**
+ * Set the image's interlace method.
+ * This value is limited to:
+ * 0 - No interlacing used.
+ * 1 - Adam7 interlacing used.
+ */
+void setInterlaceMethod(byte value) {
+	reference[INTERLACE_METHOD_OFFSET] = value;
+	interlaceMethod = value;
+}
+
+/**
+ * Answer whether the chunk is a valid IHDR chunk.
+ */
+void validate(PngFileReadState readState, PngIhdrChunk headerChunk) {
+	// An IHDR chunk is invalid if any other chunk has
+	// been read.
+	if (readState.readIHDR 
+		|| readState.readPLTE
+		|| readState.readIDAT
+		|| readState.readIEND) 
+	{
+		SWT.error(SWT.ERROR_INVALID_IMAGE);
+	} else {
+		readState.readIHDR = true;
+	}
+	
+	super.validate(readState, headerChunk);
+	
+	if (length != IHDR_DATA_LENGTH) SWT.error(SWT.ERROR_INVALID_IMAGE);
+	if (compressionMethod != 0) SWT.error(SWT.ERROR_INVALID_IMAGE);
+	if (interlaceMethod != INTERLACE_METHOD_NONE &&
+		interlaceMethod != INTERLACE_METHOD_ADAM7) {
+			SWT.error(SWT.ERROR_INVALID_IMAGE);
+	}
+	
+	boolean colorTypeIsValid = false;
+	for (int i = 0; i < ValidColorTypes.length; i++) {
+		if (ValidColorTypes[i] == colorType) {
+			colorTypeIsValid = true;
+			break;
+		}
+	}
+	if (!colorTypeIsValid) SWT.error(SWT.ERROR_INVALID_IMAGE);
+
+	boolean bitDepthIsValid = false;
+	for (int i = 0; i < ValidBitDepths.length; i++) {
+		if (ValidBitDepths[i] == bitDepth) {
+			bitDepthIsValid = true;
+			break;
+		}
+	}
+	if (!bitDepthIsValid) SWT.error(SWT.ERROR_INVALID_IMAGE);
+	
+	if ((colorType == COLOR_TYPE_RGB 
+		|| colorType == COLOR_TYPE_RGB_WITH_ALPHA
+		|| colorType == COLOR_TYPE_GRAYSCALE_WITH_ALPHA)
+		&& bitDepth < 8) 
+	{
+			SWT.error(SWT.ERROR_INVALID_IMAGE);
+	}
+	
+	if (colorType == COLOR_TYPE_PALETTE && bitDepth > 8) {
+		SWT.error(SWT.ERROR_INVALID_IMAGE);
+	}
+}
+
+String getColorTypeString() {
+	switch (colorType) {
+		case COLOR_TYPE_GRAYSCALE: 				return "Grayscale";
+		case COLOR_TYPE_RGB: 					return "RGB";		
+		case COLOR_TYPE_PALETTE:				return "Palette";
+		case COLOR_TYPE_GRAYSCALE_WITH_ALPHA:	return "Grayscale with Alpha";
+		case COLOR_TYPE_RGB_WITH_ALPHA:			return "RGB with Alpha";
+		default:								return "Unknown - " + colorType;
+	}
+}
+
+String getFilterMethodString() {
+	switch (filterMethod) {
+		case FILTER_NONE:		return "None";
+		case FILTER_SUB:		return "Sub";
+		case FILTER_UP:			return "Up";
+		case FILTER_AVERAGE:	return "Average";
+		case FILTER_PAETH:		return "Paeth";
+		default:				return "Unknown";
+	}
+}
+
+String getInterlaceMethodString() {
+	switch (interlaceMethod) {
+		case INTERLACE_METHOD_NONE: 	return "Not Interlaced";
+		case INTERLACE_METHOD_ADAM7:	return "Interlaced - ADAM7";
+		default:				return "Unknown";
+	}
+}
+
+void contributeToString(StringBuffer buffer) {
+	buffer.append("\n\tWidth: ");
+	buffer.append(width);
+	buffer.append("\n\tHeight: ");
+	buffer.append(height);
+	buffer.append("\n\tBit Depth: ");
+	buffer.append(bitDepth);
+	buffer.append("\n\tColor Type: ");
+	buffer.append(getColorTypeString());
+	buffer.append("\n\tCompression Method: ");
+	buffer.append(compressionMethod);
+	buffer.append("\n\tFilter Method: ");
+	buffer.append(getFilterMethodString());
+	buffer.append("\n\tInterlace Method: ");
+	buffer.append(getInterlaceMethodString());
+}
+
+boolean getMustHavePalette() {
+	return colorType == COLOR_TYPE_PALETTE;
+}
+
+boolean getCanHavePalette() {
+	return colorType != COLOR_TYPE_GRAYSCALE && 
+		colorType != COLOR_TYPE_GRAYSCALE_WITH_ALPHA;
+}
+
+/**
+ * Answer the pixel size in bits based on the color type
+ * and bit depth.
+ */
+int getBitsPerPixel() {
+	switch (colorType) {
+		case COLOR_TYPE_RGB_WITH_ALPHA:
+			return 4 * bitDepth;
+		case COLOR_TYPE_RGB:
+			return 3 * bitDepth;
+		case COLOR_TYPE_GRAYSCALE_WITH_ALPHA:
+			return 2 * bitDepth;
+		case COLOR_TYPE_GRAYSCALE:
+		case COLOR_TYPE_PALETTE:
+			return bitDepth;
+		default:
+			SWT.error(SWT.ERROR_INVALID_IMAGE);
+			return 0;
+	}
+}
+
+/**
+ * Answer the pixel size in bits based on the color type
+ * and bit depth.
+ */
+int getSwtBitsPerPixel() {
+	switch (colorType) {
+		case COLOR_TYPE_RGB_WITH_ALPHA:
+		case COLOR_TYPE_RGB:
+		case COLOR_TYPE_GRAYSCALE_WITH_ALPHA:
+			return 24;
+		case COLOR_TYPE_GRAYSCALE:
+		case COLOR_TYPE_PALETTE:
+			return Math.min(bitDepth, 8);
+		default:
+			SWT.error(SWT.ERROR_INVALID_IMAGE);
+			return 0;
+	}
+}
+
+int getFilterByteOffset() {
+	if (bitDepth < 8) return 1;
+	return getBitsPerPixel() / 8;
+}
+
+boolean usesDirectColor() {
+	switch (colorType) {
+		case COLOR_TYPE_GRAYSCALE:
+		case COLOR_TYPE_GRAYSCALE_WITH_ALPHA:
+		case COLOR_TYPE_RGB:
+		case COLOR_TYPE_RGB_WITH_ALPHA:
+			return true;
+		default:
+			return false;
+	}
+}
+
+PaletteData createGrayscalePalette() {
+	int depth = Math.min(bitDepth, 8);
+	int max = (1 << depth) - 1;
+	int delta = 255 / max;
+	int gray = 0;
+	RGB[] rgbs = new RGB[max + 1]; 
+	for (int i = 0; i <= max; i++) {
+		rgbs[i] = new RGB(gray, gray, gray);
+		gray += delta;
+	}
+	return new PaletteData(rgbs);
+}
+
+PaletteData getPaletteData() {
+	switch (colorType) {
+		case COLOR_TYPE_GRAYSCALE:
+			return createGrayscalePalette();
+		case COLOR_TYPE_GRAYSCALE_WITH_ALPHA:
+		case COLOR_TYPE_RGB:
+		case COLOR_TYPE_RGB_WITH_ALPHA:
+			return new PaletteData(0xFF0000, 0xFF00, 0xFF);
+		default:
+			return null;
+	}	
+}
+
+
+
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/PngIhdrChunk.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/PngInputStream.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/PngInputStream.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/PngInputStream.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.image;
+
+import java.io.*;
+
+public class PngInputStream extends InputStream {
+	PngChunkReader reader;
+	PngChunk chunk;
+	int offset, length;
+	
+	final static int DATA_OFFSET = 8; 
+	
+public PngInputStream(PngIdatChunk chunk, PngChunkReader reader) {
+	this.chunk = chunk;
+	this.reader = reader;
+	length = chunk.getLength();
+	offset = 0;
+}
+
+private boolean checkChunk() throws IOException {
+	while (offset == length) {
+		chunk = reader.readNextChunk();
+		if (chunk == null) throw new IOException();
+		if (chunk.getChunkType() == PngChunk.CHUNK_IEND) return false;
+		if (chunk.getChunkType() != PngChunk.CHUNK_IDAT) throw new IOException();
+		length = chunk.getLength();
+		offset = 0;
+	}
+	return true;
+}
+
+public void close() throws IOException {
+	chunk = null;
+}
+
+public int read() throws IOException {
+	if (chunk == null) throw new IOException();
+	if (offset == length && !checkChunk()) return -1;
+	int b = chunk.reference[DATA_OFFSET + offset] & 0xFF;
+	offset++;
+	return b;
+}
+
+public int read(byte[] b, int off, int len) throws IOException {
+	if (chunk == null) throw new IOException();
+	if (offset == length && !checkChunk()) return -1;
+	len = Math.min(len, length - offset);
+	System.arraycopy(chunk.reference, DATA_OFFSET + offset, b, off, len);
+	offset += len;
+	return len;
+}
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/PngInputStream.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/PngLzBlockReader.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/PngLzBlockReader.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/PngLzBlockReader.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,172 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.image;
+
+import java.io.*;
+
+public class PngLzBlockReader {
+	boolean isLastBlock;
+	byte compressionType;
+	int uncompressedBytesRemaining;
+	PngDecodingDataStream stream;
+	PngHuffmanTables huffmanTables;
+	
+	byte[] window;
+	int windowIndex;
+	int copyIndex;
+	int copyBytesRemaining;
+	
+	static final int UNCOMPRESSED = 0;
+	static final int COMPRESSED_FIXED = 1;
+	static final int COMPRESSED_DYNAMIC = 2;
+
+	static final int END_OF_COMPRESSED_BLOCK = 256;
+	static final int FIRST_LENGTH_CODE = 257;
+	static final int LAST_LENGTH_CODE = 285;
+	static final int FIRST_DISTANCE_CODE = 1;
+	static final int LAST_DISTANCE_CODE = 29;
+	static final int FIRST_CODE_LENGTH_CODE = 4;
+	static final int LAST_CODE_LENGTH_CODE = 19;
+
+	static final int[] lengthBases = {
+		3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 
+		31, 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258
+	} ;	
+	static final int[] extraLengthBits = {
+		0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 
+		3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0,
+	};
+	static final int[] distanceBases = {
+		1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129,
+		193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097,
+		6145, 8193, 12289, 16385, 24577,
+	};
+	static final int[] extraDistanceBits = {
+		0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7,  7,
+		8,  8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13,
+	};	
+
+
+PngLzBlockReader(PngDecodingDataStream stream) {
+	this.stream = stream;
+	isLastBlock = false;
+}
+
+void setWindowSize(int windowSize) {
+	window = new byte[windowSize];
+}	
+
+void readNextBlockHeader() throws IOException {
+	isLastBlock = stream.getNextIdatBit() != 0;
+	compressionType = (byte)(stream.getNextIdatBits(2) & 0xFF);
+	if (compressionType > 2) stream.error();	
+	
+	if (compressionType == UNCOMPRESSED) {
+		byte b1 = stream.getNextIdatByte();
+		byte b2 = stream.getNextIdatByte();
+		byte b3 = stream.getNextIdatByte();
+		byte b4 = stream.getNextIdatByte();
+		if (b1 != ~b3 || b2 != ~b4) stream.error();
+		uncompressedBytesRemaining = (b1 & 0xFF) | ((b2 & 0xFF) << 8);
+	} else if (compressionType == COMPRESSED_DYNAMIC) {
+		huffmanTables = PngHuffmanTables.getDynamicTables(stream);
+	} else {
+		huffmanTables = PngHuffmanTables.getFixedTables();
+	}
+}
+
+byte getNextByte() throws IOException {
+	if (compressionType == UNCOMPRESSED) {
+		if (uncompressedBytesRemaining == 0) {
+			readNextBlockHeader();
+			return getNextByte();
+		}
+		uncompressedBytesRemaining--;
+		return stream.getNextIdatByte();
+	} else {
+		byte value = getNextCompressedByte();
+		if (value == END_OF_COMPRESSED_BLOCK) {
+			if (isLastBlock) stream.error();
+			readNextBlockHeader();
+			return getNextByte();
+		} else {
+			return value;
+		}
+	}
+}
+
+private void assertBlockAtEnd() throws IOException {
+	if (compressionType == UNCOMPRESSED) {
+		if (uncompressedBytesRemaining > 0) stream.error();
+	} else if (copyBytesRemaining > 0 ||
+		(huffmanTables.getNextLiteralValue(stream) != END_OF_COMPRESSED_BLOCK)) 
+	{
+		stream.error();		
+	}
+}
+void assertCompressedDataAtEnd() throws IOException {
+	assertBlockAtEnd();		
+	while (!isLastBlock) {
+		readNextBlockHeader();
+		assertBlockAtEnd();
+	}	
+}
+
+private byte getNextCompressedByte() throws IOException {
+	if (copyBytesRemaining > 0) {
+		byte value = window[copyIndex];
+		window[windowIndex] = value;
+		copyBytesRemaining--;
+		
+		copyIndex++;
+		windowIndex++;		
+		if (copyIndex == window.length) copyIndex = 0;
+		if (windowIndex == window.length) windowIndex = 0;
+
+		return value;		
+	}
+	
+	int value = huffmanTables.getNextLiteralValue(stream);
+	if (value < END_OF_COMPRESSED_BLOCK) {
+		window[windowIndex] = (byte) (value & 0xFF);
+		windowIndex++;
+		if (windowIndex >= window.length) windowIndex = 0;
+		return (byte) (value & 0xFF);		
+	} else if (value == END_OF_COMPRESSED_BLOCK) {
+		readNextBlockHeader();
+		return getNextByte();
+	} else if (value <= LAST_LENGTH_CODE) {
+		int extraBits = extraLengthBits[value - FIRST_LENGTH_CODE];
+		int length = lengthBases[value - FIRST_LENGTH_CODE];
+		if (extraBits > 0) {
+			length += stream.getNextIdatBits(extraBits);
+		}
+		
+		value = huffmanTables.getNextDistanceValue(stream);
+		if (value > LAST_DISTANCE_CODE) stream.error();
+		extraBits = extraDistanceBits[value];
+		int distance = distanceBases[value];
+		if (extraBits > 0) {
+			distance += stream.getNextIdatBits(extraBits);
+		}
+		
+		copyIndex = windowIndex - distance;
+		if (copyIndex < 0) copyIndex += window.length;
+
+		copyBytesRemaining = length;
+		return getNextCompressedByte();
+	} else {
+		stream.error();
+		return 0;
+	}
+}
+	
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/PngLzBlockReader.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/PngPlteChunk.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/PngPlteChunk.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/PngPlteChunk.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,123 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.image;
+
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
+class PngPlteChunk extends PngChunk {
+	
+	int paletteSize;
+
+PngPlteChunk(PaletteData palette) {
+	super(palette.getRGBs().length * 3);
+	paletteSize = length / 3;
+	setType(TYPE_PLTE);
+	setPaletteData(palette);
+	setCRC(computeCRC());
+}		
+
+PngPlteChunk(byte[] reference){
+	super(reference);
+	paletteSize = length / 3;
+}
+
+int getChunkType() {
+	return CHUNK_PLTE;
+}
+
+/**
+ * Get the number of colors in this palette.
+ */
+int getPaletteSize() {
+	return paletteSize;
+}
+
+/**
+ * Get a PaletteData object representing the colors
+ * stored in this PLTE chunk.
+ * The result should be cached as the PLTE chunk
+ * does not store the palette data created.
+ */
+PaletteData getPaletteData() {
+	RGB[] rgbs = new RGB[paletteSize];
+//	int start = DATA_OFFSET;
+//	int end = DATA_OFFSET + length;
+	for (int i = 0; i < rgbs.length; i++) {
+		int offset = DATA_OFFSET + (i * 3);
+		int red = reference[offset] & 0xFF;
+		int green = reference[offset + 1] & 0xFF;
+		int blue = reference[offset + 2] & 0xFF;
+		rgbs[i] = new RGB(red, green, blue);		
+	}
+	return new PaletteData(rgbs);
+}
+
+/**
+ * Set the data of a PLTE chunk to the colors
+ * stored in the specified PaletteData object.
+ */
+void setPaletteData(PaletteData palette) {
+	RGB[] rgbs = palette.getRGBs();
+	for (int i = 0; i < rgbs.length; i++) {
+		int offset = DATA_OFFSET + (i * 3);
+		reference[offset] = (byte) rgbs[i].red;
+		reference[offset + 1] = (byte) rgbs[i].green;
+		reference[offset + 2] = (byte) rgbs[i].blue;
+	}
+}
+
+/**
+ * Answer whether the chunk is a valid PLTE chunk.
+ */
+void validate(PngFileReadState readState, PngIhdrChunk headerChunk) {
+	// A PLTE chunk is invalid if no IHDR has been read or if any PLTE,
+	// IDAT, or IEND chunk has been read.
+	if (!readState.readIHDR
+		|| readState.readPLTE
+		|| readState.readTRNS
+		|| readState.readIDAT
+		|| readState.readIEND) 
+	{
+		SWT.error(SWT.ERROR_INVALID_IMAGE);
+	} else {
+		readState.readPLTE = true;
+	}
+	
+	super.validate(readState, headerChunk);
+	
+	// Palettes cannot be included in grayscale images.
+	// 
+	// Note: just ignore the palette.
+//	if (!headerChunk.getCanHavePalette()) SWT.error(SWT.ERROR_INVALID_IMAGE);
+	
+	// Palette chunks' data fields must be event multiples
+	// of 3. Each 3-byte group represents an RGB value.
+	if (getLength() % 3 != 0) SWT.error(SWT.ERROR_INVALID_IMAGE);	
+	
+	// Palettes cannot have more entries than 2^bitDepth
+	// where bitDepth is the bit depth of the image given
+	// in the IHDR chunk.
+	if (1 << headerChunk.getBitDepth() < paletteSize) {
+		SWT.error(SWT.ERROR_INVALID_IMAGE);
+	}
+	
+	// Palettes cannot have more than 256 entries.
+	if (256 < paletteSize) SWT.error(SWT.ERROR_INVALID_IMAGE);
+}
+
+void contributeToString(StringBuffer buffer) {
+	buffer.append("\n\tPalette size:");
+	buffer.append(paletteSize);
+}
+
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/PngPlteChunk.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/PngTrnsChunk.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/PngTrnsChunk.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/PngTrnsChunk.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,154 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.image;
+
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
+public class PngTrnsChunk extends PngChunk {
+	static final int TRANSPARENCY_TYPE_PIXEL = 0;
+	static final int TRANSPARENCY_TYPE_ALPHAS = 1;
+	static final int RGB_DATA_LENGTH = 6;
+	
+PngTrnsChunk(RGB rgb) {
+	super(RGB_DATA_LENGTH);
+	setType(TYPE_tRNS);
+	setInt16(DATA_OFFSET, rgb.red);
+	setInt16(DATA_OFFSET + 2, rgb.green);
+	setInt16(DATA_OFFSET + 4, rgb.blue);	
+	setCRC(computeCRC());
+}
+
+PngTrnsChunk(byte[] reference){
+	super(reference);
+}
+
+int getChunkType() {
+	return CHUNK_tRNS;
+}
+
+void validateLength(PngIhdrChunk header, PngPlteChunk paletteChunk) {
+	boolean valid;
+	switch (header.getColorType()) {
+		case PngIhdrChunk.COLOR_TYPE_RGB:
+			// Three 2-byte values (RGB)
+			valid = getLength() == 6;
+			break;
+		case PngIhdrChunk.COLOR_TYPE_PALETTE:
+			// Three 2-byte values (RGB)
+			valid = getLength() <= paletteChunk.getLength();
+			break;
+		case PngIhdrChunk.COLOR_TYPE_GRAYSCALE:
+			// One 2-byte value
+			valid = getLength() == 2;
+			break;
+		// Cannot use both Alpha and tRNS
+		case PngIhdrChunk.COLOR_TYPE_RGB_WITH_ALPHA:
+		case PngIhdrChunk.COLOR_TYPE_GRAYSCALE_WITH_ALPHA:
+		default:
+			valid = false;
+	}
+	if (!valid) {
+		SWT.error(SWT.ERROR_INVALID_IMAGE);
+	}
+}
+
+/**
+ * Answer whether the chunk is a valid tRNS chunk.
+ */
+void validate(PngFileReadState readState, PngIhdrChunk headerChunk, PngPlteChunk paletteChunk) {
+	if (!readState.readIHDR
+		|| (headerChunk.getMustHavePalette() && !readState.readPLTE)
+		|| readState.readIDAT
+		|| readState.readIEND) 
+	{
+		SWT.error(SWT.ERROR_INVALID_IMAGE);
+	} else {
+		readState.readTRNS = true;
+	}
+	
+	validateLength(headerChunk, paletteChunk);
+	
+	super.validate(readState, headerChunk);
+}
+
+
+int getTransparencyType(PngIhdrChunk header) {
+	if (header.getColorType() == PngIhdrChunk.COLOR_TYPE_PALETTE) {
+		return TRANSPARENCY_TYPE_ALPHAS;
+	}
+	return TRANSPARENCY_TYPE_PIXEL;
+}
+
+/**
+ * Answer the transparent pixel RGB value.
+ * This is not valid for palette color types.
+ * This is not valid for alpha color types.
+ * This will convert a grayscale value into
+ * a palette index.
+ * It will compress a 6 byte RGB into a 3 byte
+ * RGB.
+ */
+int getSwtTransparentPixel(PngIhdrChunk header) {
+	switch (header.getColorType()) {
+		case PngIhdrChunk.COLOR_TYPE_GRAYSCALE:
+			int gray = ((reference[DATA_OFFSET] & 0xFF) << 8)
+				+ (reference[DATA_OFFSET + 1] & 0xFF);
+			if (header.getBitDepth() > 8) {
+				return PNGFileFormat.compress16BitDepthTo8BitDepth(gray);
+			}
+			return gray & 0xFF;
+		case PngIhdrChunk.COLOR_TYPE_RGB:
+			int red = ((reference[DATA_OFFSET] & 0xFF) << 8)
+				| (reference[DATA_OFFSET + 1] & 0xFF);
+			int green = ((reference[DATA_OFFSET + 2] & 0xFF) << 8)
+				| (reference[DATA_OFFSET + 3] & 0xFF);
+			int blue = ((reference[DATA_OFFSET + 4] & 0xFF) << 8)
+				| (reference[DATA_OFFSET + 5] & 0xFF);			
+			if (header.getBitDepth() > 8) {
+				red = PNGFileFormat.compress16BitDepthTo8BitDepth(red);
+				green = PNGFileFormat.compress16BitDepthTo8BitDepth(green);
+				blue = PNGFileFormat.compress16BitDepthTo8BitDepth(blue);			
+			}
+			return (red << 16) | (green << 8) | blue;	
+		default:
+			SWT.error(SWT.ERROR_INVALID_IMAGE);
+			return -1;
+	}
+}
+
+/**
+ * Answer an array of Alpha values that correspond to the 
+ * colors in the palette.
+ * This is only valid for the COLOR_TYPE_PALETTE color type.
+ */
+byte[] getAlphaValues(PngIhdrChunk header, PngPlteChunk paletteChunk) {
+	if (header.getColorType() != PngIhdrChunk.COLOR_TYPE_PALETTE) {
+		SWT.error(SWT.ERROR_INVALID_IMAGE);
+	}
+	byte[] alphas = new byte[paletteChunk.getPaletteSize()];
+	int dataLength = getLength();
+	int i = 0;
+	for (i = 0; i < dataLength; i++) {
+		alphas[i] = reference[DATA_OFFSET + i];
+	}
+	/**
+	 * Any palette entries which do not have a corresponding
+	 * alpha value in the tRNS chunk are spec'd to have an 
+	 * alpha of 255.
+	 */
+	for (int j = i; j < alphas.length; j++) {
+		alphas[j] = (byte) 255;
+	}
+	return alphas;
+}
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/PngTrnsChunk.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/TIFFDirectory.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/TIFFDirectory.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/TIFFDirectory.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,625 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.image;
+
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import java.io.*;
+
+final class TIFFDirectory {
+
+	TIFFRandomFileAccess file;
+	boolean isLittleEndian;
+	ImageLoader loader;
+	int depth;
+	
+	/* Directory fields */
+	int imageWidth;
+	int imageLength;
+	int[] bitsPerSample;
+	int compression;
+	int photometricInterpretation;
+	int[] stripOffsets;
+	int samplesPerPixel;
+	int rowsPerStrip;
+	int[] stripByteCounts;
+	int t4Options;
+	int colorMapOffset;
+	
+	/* Encoder fields */
+	ImageData image;
+	LEDataOutputStream out;
+	
+	static final int NO_VALUE = -1;
+	
+	static final short TAG_ImageWidth = 256;
+	static final short TAG_ImageLength = 257;
+	static final short TAG_BitsPerSample = 258;
+	static final short TAG_Compression = 259;
+	static final short TAG_PhotometricInterpretation = 262;
+	static final short TAG_StripOffsets = 273;
+	static final short TAG_SamplesPerPixel = 277;
+	static final short TAG_RowsPerStrip = 278;
+	static final short TAG_StripByteCounts = 279;
+	static final short TAG_XResolution = 282;
+	static final short TAG_YResolution = 283;
+	static final short TAG_T4Options = 292;
+	static final short TAG_ResolutionUnit = 296;
+	static final short TAG_ColorMap = 320;
+	
+	static final int TYPE_BYTE = 1;
+	static final int TYPE_ASCII = 2;
+	static final int TYPE_SHORT = 3;
+	static final int TYPE_LONG = 4;
+	static final int TYPE_RATIONAL = 5;
+	
+	/* Different compression schemes */
+	static final int COMPRESSION_NONE = 1;
+	static final int COMPRESSION_CCITT_3_1 = 2;
+	static final int COMPRESSION_PACKBITS = 32773;
+	
+	static final int IFD_ENTRY_SIZE = 12;
+	
+public TIFFDirectory(TIFFRandomFileAccess file, boolean isLittleEndian, ImageLoader loader) {
+	this.file = file;
+	this.isLittleEndian = isLittleEndian;
+	this.loader = loader;
+}
+
+public TIFFDirectory(ImageData image) {
+	this.image = image;
+}
+
+/* PackBits decoder */
+int decodePackBits(byte[] src, byte[] dest, int offsetDest) {
+	int destIndex = offsetDest;
+	int srcIndex = 0;
+	while (srcIndex < src.length) {
+		byte n = src[srcIndex];
+		if (0 <= n && n <= 127) {
+			/* Copy next n+1 bytes literally */
+			System.arraycopy(src, ++srcIndex, dest, destIndex, n + 1);
+			srcIndex += n + 1;		
+			destIndex += n + 1;	
+		} else if (-127 <= n && n <= -1) {
+			/* Copy next byte -n+1 times */
+			byte value = src[++srcIndex];
+			for (int j = 0; j < -n + 1; j++) {
+				dest[destIndex++] = value;
+			}
+			srcIndex++;
+		} else {
+			/* Noop when n == -128 */
+			srcIndex++;
+		}
+	}
+	/* Number of bytes copied */
+	return destIndex - offsetDest;
+}
+
+int getEntryValue(int type, byte[] buffer, int index) {
+	return toInt(buffer, index + 8, type);
+}
+
+void getEntryValue(int type, byte[] buffer, int index, int[] values) throws IOException {
+	int start = index + 8;
+	int size;
+	int offset = toInt(buffer, start, TYPE_LONG);
+	switch (type) {
+		case TYPE_SHORT: size = 2; break;
+		case TYPE_LONG: size = 4; break; 
+		case TYPE_RATIONAL: size = 8; break;
+		case TYPE_ASCII:
+		case TYPE_BYTE: size = 1; break;
+		default: SWT.error(SWT.ERROR_UNSUPPORTED_FORMAT); return;
+	}
+	if (values.length * size > 4) {
+		buffer = new byte[values.length * size]; 
+		file.seek(offset);
+		file.read(buffer);
+		start = 0;
+	}
+	for (int i = 0; i < values.length; i++) {
+		values[i] = toInt(buffer, start + i * size, type);
+	}
+}
+
+void decodePixels(ImageData image) throws IOException {
+	/* Each row is byte aligned */ 
+	byte[] imageData = new byte[(imageWidth * depth + 7) / 8 * imageLength];
+	image.data = imageData;
+	int destIndex = 0;
+	int length = stripOffsets.length;
+	for (int i = 0; i < length; i++) {
+		/* Read a strip */
+		byte[] data = new byte[stripByteCounts[i]];
+		file.seek(stripOffsets[i]);
+		file.read(data);
+		if (compression == COMPRESSION_NONE) {
+			System.arraycopy(data, 0, imageData, destIndex, data.length);
+			destIndex += data.length;
+		} else if (compression == COMPRESSION_PACKBITS) {
+			destIndex += decodePackBits(data, imageData, destIndex);
+		} else if (compression == COMPRESSION_CCITT_3_1 || compression == 3) {
+			TIFFModifiedHuffmanCodec codec = new TIFFModifiedHuffmanCodec();
+			int nRows = rowsPerStrip;
+			if (i == length -1) {
+				int n = imageLength % rowsPerStrip;
+				if (n != 0) nRows = n;
+			}
+			destIndex += codec.decode(data, imageData, destIndex, imageWidth, nRows);
+		}
+		if (loader.hasListeners()) {
+			loader.notifyListeners(new ImageLoaderEvent(loader, image, i, i == length - 1));
+		}
+	}
+}
+
+PaletteData getColorMap() throws IOException {
+	int numColors = 1 << bitsPerSample[0];
+	/* R, G, B entries are 16 bit wide (2 bytes) */
+	int numBytes = 3 * 2 * numColors;
+	byte[] buffer = new byte[numBytes];
+	file.seek(colorMapOffset);
+	file.read(buffer);
+	RGB[] colors = new RGB[numColors];
+	/**
+	 * SWT does not support 16-bit depth color formats.
+	 * Convert the 16-bit data to 8-bit data.
+	 * The correct way to do this is to multiply each
+	 * 16 bit value by the value:
+	 * (2^8 - 1) / (2^16 - 1).
+	 * The fast way to do this is just to drop the low
+	 * byte of the 16-bit value.
+	 */
+	int offset = isLittleEndian ? 1 : 0;
+	int startG = 2 * numColors;
+	int startB = startG + 2 * numColors;
+	for (int i = 0; i < numColors; i++) {
+		int r = buffer[offset] & 0xFF;
+		int g = buffer[startG + offset] & 0xFF;
+		int b = buffer[startB + offset] & 0xFF;
+		colors[i] = new RGB(r, g, b);
+		offset += 2;
+	}
+	return new PaletteData(colors);
+}
+
+PaletteData getGrayPalette() {
+	int numColors = 1 << bitsPerSample[0];
+	RGB[] rgbs = new RGB[numColors];
+	for (int i = 0; i < numColors; i++) {
+		int value = i * 0xFF / (numColors - 1);
+		if (photometricInterpretation == 0) value = 0xFF - value;
+		rgbs[i] = new RGB(value, value, value);
+	}
+	return new PaletteData(rgbs);
+}
+
+PaletteData getRGBPalette(int bitsR, int bitsG, int bitsB) {	
+	int blueMask = 0;
+	for (int i = 0; i < bitsB; i++) {
+		blueMask |= 1 << i;
+	}
+	int greenMask = 0;
+	for (int i = bitsB; i < bitsB + bitsG; i++) {
+		greenMask |= 1 << i;
+	}
+	int redMask = 0;
+	for (int i = bitsB + bitsG; i < bitsB + bitsG + bitsR; i++) {
+		redMask |= 1 << i;
+	}	
+	return new PaletteData(redMask, greenMask, blueMask);
+}
+
+int formatStrips(int rowByteSize, int nbrRows, byte[] data, int maxStripByteSize, int offsetPostIFD, int extraBytes, int[][] strips) {
+	/* 
+	* Calculate the nbr of required strips given the following requirements: 
+	* - each strip should, if possible, not be greater than maxStripByteSize
+	* - each strip should contain 1 or more entire rows
+	* 
+	* Format the strip fields arrays so that the image data is stored in one
+	* contiguous block. This block is stored after the IFD and after any tag
+	* info described in the IFD.
+	*/
+	int n, nbrRowsPerStrip;
+	if (rowByteSize > maxStripByteSize) {
+		/* Each strip contains 1 row */
+		n = data.length / rowByteSize;
+		nbrRowsPerStrip = 1;
+	} else {
+		int nbr = (data.length + maxStripByteSize - 1) / maxStripByteSize;
+		nbrRowsPerStrip = nbrRows / nbr;
+		n = (nbrRows + nbrRowsPerStrip - 1) / nbrRowsPerStrip;	
+	}
+	int stripByteSize = rowByteSize * nbrRowsPerStrip;
+
+	int[] offsets = new int[n];
+	int[] counts = new int[n];
+	/* 
+	* Nbr of bytes between the end of the IFD directory and the start of
+	* the image data. Keep space for at least the offsets and counts
+	* data, each field being TYPE_LONG (4 bytes). If other tags require
+	* space between the IFD and the image block, use the extraBytes
+	* parameter.
+	* If there is only one strip, the offsets and counts data is stored
+	* directly in the IFD and we need not reserve space for it.
+	*/
+	int postIFDData = n == 1 ? 0 : n * 2 * 4;
+	int startOffset = offsetPostIFD + extraBytes + postIFDData; /* offset of image data */
+	
+	int offset = startOffset;
+	for (int i = 0; i < n; i++) {
+		/* 
+		* Store all strips sequentially to allow us
+		* to copy all pixels in one contiguous area.
+		*/
+		offsets[i] = offset;
+		counts[i] = stripByteSize;
+		offset += stripByteSize;
+	}
+	/* The last strip may contain fewer rows */
+	int mod = data.length % stripByteSize;
+	if (mod != 0) counts[counts.length - 1] = mod;
+	
+	strips[0] = offsets;
+	strips[1] = counts;
+	return nbrRowsPerStrip;
+}
+
+int[] formatColorMap(RGB[] rgbs) {
+	/* 
+	* In a TIFF ColorMap, all red come first, followed by
+	* green and blue. All values must be converted from
+	* 8 bit to 16 bit. 
+	*/
+	int[] colorMap = new int[rgbs.length * 3];
+	int offsetGreen = rgbs.length;
+	int offsetBlue = rgbs.length * 2;
+	for (int i = 0; i < rgbs.length; i++) {
+		colorMap[i] = rgbs[i].red << 8 | rgbs[i].red;
+		colorMap[i + offsetGreen] = rgbs[i].green << 8 | rgbs[i].green;
+		colorMap[i + offsetBlue] = rgbs[i].blue << 8 | rgbs[i].blue;
+	}
+	return colorMap;
+}
+
+void parseEntries(byte[] buffer) throws IOException {
+	for (int offset = 0; offset < buffer.length; offset += IFD_ENTRY_SIZE) {
+		int tag = toInt(buffer, offset, TYPE_SHORT);
+		int type = toInt(buffer, offset + 2, TYPE_SHORT);
+		int count = toInt(buffer, offset + 4, TYPE_LONG);
+		switch (tag) {
+			case TAG_ImageWidth: {
+				imageWidth = getEntryValue(type, buffer, offset);
+				break;
+			}
+			case TAG_ImageLength: {
+				imageLength = getEntryValue(type, buffer, offset);
+				break;
+			}
+			case TAG_BitsPerSample: {
+				if (type != TYPE_SHORT) SWT.error(SWT.ERROR_INVALID_IMAGE);
+				bitsPerSample = new int[count];
+				getEntryValue(type, buffer, offset, bitsPerSample);
+				break;
+			}
+			case TAG_Compression: {
+				compression = getEntryValue(type, buffer, offset);
+				break;
+			}
+			case TAG_PhotometricInterpretation: {
+				photometricInterpretation = getEntryValue(type, buffer, offset);
+				break;
+			}
+			case TAG_StripOffsets: {
+				if (type != TYPE_LONG && type != TYPE_SHORT) SWT.error(SWT.ERROR_INVALID_IMAGE);
+				stripOffsets = new int[count];
+				getEntryValue(type, buffer, offset, stripOffsets);
+				break;
+			}
+			case TAG_SamplesPerPixel: {
+				if (type != TYPE_SHORT) SWT.error(SWT.ERROR_INVALID_IMAGE);
+				samplesPerPixel = getEntryValue(type, buffer, offset);
+				/* Only the basic 1 and 3 values are supported */
+				if (samplesPerPixel != 1 && samplesPerPixel != 3) SWT.error(SWT.ERROR_UNSUPPORTED_DEPTH);
+				break;
+			}
+			case TAG_RowsPerStrip: {
+				rowsPerStrip = getEntryValue(type, buffer, offset);
+				break;
+			}
+			case TAG_StripByteCounts: {
+				stripByteCounts = new int[count];
+				getEntryValue(type, buffer, offset, stripByteCounts);
+				break;
+			}
+			case TAG_XResolution: {
+				/* Ignored */
+				break;
+			}
+			case TAG_YResolution: {
+				/* Ignored */
+				break;
+			}
+			case TAG_T4Options: {
+				if (type != TYPE_LONG) SWT.error(SWT.ERROR_INVALID_IMAGE);
+				t4Options = getEntryValue(type, buffer, offset);
+				if ((t4Options & 0x1) == 1) {
+					/* 2-dimensional coding is not supported */
+					SWT.error(SWT.ERROR_UNSUPPORTED_FORMAT);
+				}
+				break;
+			}
+			case TAG_ResolutionUnit: {
+				/* Ignored */
+				break;
+			}
+			case TAG_ColorMap: {
+				if (type != TYPE_SHORT) SWT.error(SWT.ERROR_INVALID_IMAGE);
+				/* Get the offset of the colorMap (use TYPE_LONG) */
+				colorMapOffset = getEntryValue(TYPE_LONG, buffer, offset);
+				break;
+			}
+		}
+	}
+}
+
+public ImageData read() throws IOException {
+	/* Set TIFF default values */
+	bitsPerSample = new int[] {1};
+	colorMapOffset = NO_VALUE;
+	compression = 1;
+	imageLength = NO_VALUE;
+	imageWidth = NO_VALUE;
+	photometricInterpretation = NO_VALUE;
+	rowsPerStrip = Integer.MAX_VALUE;
+	samplesPerPixel = 1;
+	stripByteCounts = null;
+	stripOffsets = null;
+	
+	byte[] buffer = new byte[2];
+	file.read(buffer);
+	int numberEntries = toInt(buffer, 0, TYPE_SHORT);
+	buffer = new byte[IFD_ENTRY_SIZE * numberEntries];
+	file.read(buffer);
+	parseEntries(buffer);
+	
+	PaletteData palette = null;
+	depth = 0;
+	switch (photometricInterpretation) {
+		case 0:
+		case 1: {
+			/* Bilevel or Grayscale image */
+			palette = getGrayPalette();
+			depth = bitsPerSample[0];
+			break;
+		}
+		case 2: {
+			/* RGB image */
+			if (colorMapOffset != NO_VALUE) SWT.error(SWT.ERROR_INVALID_IMAGE);
+			/* SamplesPerPixel 3 is the only value supported */
+			palette = getRGBPalette(bitsPerSample[0], bitsPerSample[1], bitsPerSample[2]);
+			depth = bitsPerSample[0] + bitsPerSample[1] + bitsPerSample[2];
+			break;		
+		}
+		case 3: {
+			/* Palette Color image */
+			if (colorMapOffset == NO_VALUE) SWT.error(SWT.ERROR_INVALID_IMAGE);
+			palette = getColorMap();
+			depth = bitsPerSample[0];
+			break;
+		}
+		default: {
+			SWT.error(SWT.ERROR_INVALID_IMAGE);
+		}
+	}
+
+	ImageData image = ImageData.internal_new(
+			imageWidth,
+			imageLength, 
+			depth,
+			palette,
+			1,
+			null,
+			0,
+			null,
+			null,
+			-1,
+			-1,
+			SWT.IMAGE_TIFF,
+			0,
+			0,
+			0,
+			0);
+	decodePixels(image);
+	return image;
+}
+
+int toInt(byte[] buffer, int i, int type) {
+	if (type == TYPE_LONG) {
+		return isLittleEndian ? 
+		(buffer[i] & 0xFF) | ((buffer[i + 1] & 0xFF) << 8) | ((buffer[i + 2] & 0xFF) << 16) | ((buffer[i + 3] & 0xFF) << 24) :
+		(buffer[i + 3] & 0xFF) | ((buffer[i + 2] & 0xFF) << 8) | ((buffer[i + 1] & 0xFF) << 16) | ((buffer[i] & 0xFF) << 24);
+	}
+	if (type == TYPE_SHORT) {
+		return isLittleEndian ? 
+		(buffer[i] & 0xFF) | ((buffer[i + 1] & 0xFF) << 8) :
+		(buffer[i + 1] & 0xFF) | ((buffer[i] & 0xFF) << 8);		
+	}
+	/* Invalid type */
+	SWT.error(SWT.ERROR_INVALID_IMAGE);
+	return -1;
+}
+
+void write(int photometricInterpretation) throws IOException {
+	boolean isRGB = photometricInterpretation == 2;
+	boolean isColorMap = photometricInterpretation == 3;
+	boolean isBiLevel = photometricInterpretation == 0 || photometricInterpretation == 1;
+
+	int imageWidth = image.width;
+	int imageLength = image.height;
+	int rowByteSize = image.bytesPerLine;
+	
+	int numberEntries = isBiLevel ? 9 : 11;
+	int lengthDirectory = 2 + 12 * numberEntries + 4;
+	/* Offset following the header and the directory */
+	int nextOffset = 8 + lengthDirectory;
+
+	/* Extra space used by XResolution and YResolution values */
+	int extraBytes = 16;
+
+	int[] colorMap = null;
+	if (isColorMap) {	
+		PaletteData palette = image.palette;
+		RGB[] rgbs = palette.getRGBs();
+		colorMap = formatColorMap(rgbs);
+		/* The number of entries of the Color Map must match the bitsPerSample field */
+		if (colorMap.length != 3 * 1 << image.depth) SWT.error(SWT.ERROR_UNSUPPORTED_FORMAT);
+		/* Extra space used by ColorMap values */
+		extraBytes += colorMap.length * 2;
+	}
+	if (isRGB) {
+		/* Extra space used by BitsPerSample values */
+		extraBytes += 6;
+	} 
+	/* TIFF recommends storing the data in strips of no more than 8 Ko */
+	byte[] data = image.data;
+	int[][] strips = new int[2][];
+	int nbrRowsPerStrip = formatStrips(rowByteSize, imageLength, data, 8192, nextOffset, extraBytes, strips);
+	int[] stripOffsets = strips[0];
+	int[] stripByteCounts = strips[1];
+
+	int bitsPerSampleOffset = NO_VALUE;
+	if (isRGB) {
+		bitsPerSampleOffset = nextOffset;
+		nextOffset += 6;
+	}
+	int stripOffsetsOffset = NO_VALUE, stripByteCountsOffset = NO_VALUE;
+	int xResolutionOffset, yResolutionOffset, colorMapOffset = NO_VALUE;
+	int cnt = stripOffsets.length;
+	if (cnt > 1) {
+		stripOffsetsOffset = nextOffset;
+		nextOffset += 4 * cnt;
+		stripByteCountsOffset = nextOffset;
+		nextOffset += 4 * cnt;
+	}
+	xResolutionOffset = nextOffset;
+	nextOffset += 8;
+	yResolutionOffset = nextOffset;
+	nextOffset += 8;
+	if (isColorMap) {
+		colorMapOffset = nextOffset;
+		nextOffset += colorMap.length * 2;
+	}
+	/* TIFF header */
+	writeHeader();
+	
+	/* Image File Directory */
+	out.writeShort(numberEntries);	
+	writeEntry(TAG_ImageWidth, TYPE_LONG, 1, imageWidth);	
+	writeEntry(TAG_ImageLength, TYPE_LONG, 1, imageLength);
+	if (isColorMap) writeEntry(TAG_BitsPerSample, TYPE_SHORT, 1, image.depth);
+	if (isRGB) writeEntry(TAG_BitsPerSample, TYPE_SHORT, 3, bitsPerSampleOffset);
+	writeEntry(TAG_Compression, TYPE_SHORT, 1, COMPRESSION_NONE);
+	writeEntry(TAG_PhotometricInterpretation, TYPE_SHORT, 1, photometricInterpretation);
+	writeEntry(TAG_StripOffsets, TYPE_LONG, cnt, cnt > 1 ? stripOffsetsOffset : stripOffsets[0]);
+	if (isRGB) writeEntry(TAG_SamplesPerPixel, TYPE_SHORT, 1, 3);
+	writeEntry(TAG_RowsPerStrip, TYPE_LONG, 1, nbrRowsPerStrip);
+	writeEntry(TAG_StripByteCounts, TYPE_LONG, cnt, cnt > 1 ? stripByteCountsOffset : stripByteCounts[0]);
+	writeEntry(TAG_XResolution, TYPE_RATIONAL, 1, xResolutionOffset);
+	writeEntry(TAG_YResolution, TYPE_RATIONAL, 1, yResolutionOffset);
+	if (isColorMap) writeEntry(TAG_ColorMap, TYPE_SHORT, colorMap.length, colorMapOffset);
+	/* Offset of next IFD (0 for last IFD) */
+	out.writeInt(0);
+	
+	/* Values longer than 4 bytes Section */
+	
+	/* BitsPerSample 8,8,8 */
+	if (isRGB) for (int i = 0; i < 3; i++) out.writeShort(8);
+	if (cnt > 1) {
+		for (int i = 0; i < cnt; i++) out.writeInt(stripOffsets[i]);
+		for (int i = 0; i < cnt; i++) out.writeInt(stripByteCounts[i]);
+	}
+	/* XResolution and YResolution set to 300 dpi */
+	for (int i = 0; i < 2; i++) {
+		out.writeInt(300);
+		out.writeInt(1);
+	}
+	/* ColorMap */
+	if (isColorMap) for (int i = 0; i < colorMap.length; i++) out.writeShort(colorMap[i]);
+	
+	/* Image Data */
+	out.write(data);
+}
+
+void writeEntry(short tag, int type, int count, int value) throws IOException {
+	out.writeShort(tag);
+	out.writeShort(type);
+	out.writeInt(count);
+	out.writeInt(value);
+}
+
+void writeHeader() throws IOException {
+	/* little endian */
+	out.write(0x49);
+	out.write(0x49);
+
+	/* TIFF identifier */
+	out.writeShort(42);
+	/* 
+	* Offset of the first IFD is chosen to be 8.
+	* It is word aligned and immediately after this header.
+	*/
+	out.writeInt(8);
+}
+
+void writeToStream(LEDataOutputStream byteStream) throws IOException {
+	out = byteStream;
+	int photometricInterpretation = -1;
+	
+	/* Scanline pad must be 1 */
+	if (image.scanlinePad != 1) SWT.error(SWT.ERROR_UNSUPPORTED_FORMAT);
+	switch (image.depth) {
+		case 1: {
+			/* Palette must be black and white or white and black */
+			PaletteData palette = image.palette;
+			RGB[] rgbs = palette.colors;
+			if (palette.isDirect || rgbs == null || rgbs.length != 2) SWT.error(SWT.ERROR_UNSUPPORTED_FORMAT);
+			RGB rgb0 = rgbs[0];
+			RGB rgb1 = rgbs[1];
+			if (!(rgb0.red == rgb0.green && rgb0.green == rgb0.blue &&
+				rgb1.red == rgb1.green && rgb1.green == rgb1.blue &&
+				((rgb0.red == 0x0 && rgb1.red == 0xFF) || (rgb0.red == 0xFF && rgb1.red == 0x0)))) {
+				SWT.error(SWT.ERROR_UNSUPPORTED_FORMAT); 
+			}
+			/* 0 means a color index of 0 is imaged as white */
+			photometricInterpretation = image.palette.colors[0].red == 0xFF ? 0 : 1;
+			break;
+		}
+		case 4:
+		case 8: {
+			photometricInterpretation = 3;
+			break;
+		}
+		case 24: {
+			photometricInterpretation = 2;
+			break;
+		}
+		default: {
+			SWT.error(SWT.ERROR_UNSUPPORTED_FORMAT);
+		}
+	}
+	write(photometricInterpretation);
+}
+
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/TIFFDirectory.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/TIFFFileFormat.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/TIFFFileFormat.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/TIFFFileFormat.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,79 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.image;
+
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import java.io.*;
+
+/**
+ * Baseline TIFF decoder revision 6.0
+ * Extension T4-encoding CCITT T.4 1D
+ */
+public final class TIFFFileFormat extends FileFormat {
+
+boolean isFileFormat(LEDataInputStream stream) {
+	try {
+		byte[] header = new byte[4];
+		stream.read(header);
+		stream.unread(header);
+		if (header[0] != header[1]) return false;
+		if (!(header[0] == 0x49 && header[2] == 42 && header[3] == 0) &&
+			!(header[0] == 0x4d && header[2] == 0 && header[3] == 42)) {
+			return false;
+		} 	
+		return true;
+	} catch (Exception e) {
+		return false;
+	}
+}
+
+ImageData[] loadFromByteStream() {	
+	byte[] header = new byte[8];
+	boolean isLittleEndian;
+	ImageData[] images = new ImageData[0];
+	TIFFRandomFileAccess file = new TIFFRandomFileAccess(inputStream);
+	try {
+		file.read(header);
+		if (header[0] != header[1]) SWT.error(SWT.ERROR_INVALID_IMAGE);
+		if (!(header[0] == 0x49 && header[2] == 42 && header[3] == 0) &&
+			!(header[0] == 0x4d && header[2] == 0 && header[3] == 42)) {
+			SWT.error(SWT.ERROR_INVALID_IMAGE);
+		} 
+		isLittleEndian = header[0] == 0x49;	
+		int offset = isLittleEndian ? 
+			(header[4] & 0xFF) | ((header[5] & 0xFF) << 8) | ((header[6] & 0xFF) << 16) | ((header[7] & 0xFF) << 24) :
+			(header[7] & 0xFF) | ((header[6] & 0xFF) << 8) | ((header[5] & 0xFF) << 16) | ((header[4] & 0xFF) << 24);
+		file.seek(offset);
+		TIFFDirectory directory = new TIFFDirectory(file, isLittleEndian, loader);
+		ImageData image = directory.read();
+		/* A baseline reader is only expected to read the first directory */
+		images = new ImageData[] {image};
+	} catch (IOException e) {
+		SWT.error(SWT.ERROR_IO, e);
+	}
+	return images;
+}
+
+void unloadIntoByteStream(ImageLoader loader) {
+	/* We do not currently support writing multi-page tiff,
+	 * so we use the first image data in the loader's array. */
+	ImageData image = loader.data[0];
+	TIFFDirectory directory = new TIFFDirectory(image);
+	try {
+		directory.writeToStream(outputStream);
+	} catch (IOException e) {
+		SWT.error(SWT.ERROR_IO, e);
+	}
+}
+
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/TIFFFileFormat.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/TIFFModifiedHuffmanCodec.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/TIFFModifiedHuffmanCodec.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/TIFFModifiedHuffmanCodec.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,217 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.image;
+
+import org.eclipse.swt.*;
+
+/*
+* Decoder for 
+* - CCITT Group 3 1-Dimensional Modified Huffman run length encoding
+*   (TIFF compression type 2)
+* - CCITT T.4 bi-level encoding 1D
+*   (TIFF compression type 3 option 1D) 
+*/
+final class TIFFModifiedHuffmanCodec {
+	static final short[][][] BLACK_CODE = {
+		/* 2 bits  */
+		{{2, 3}, {3, 2}},
+		/* 3 bits  */
+		{{2, 1}, {3, 4}},
+		/* 4 bits  */
+		{{2, 6}, {3, 5}},
+		/* 5 bits  */
+		{{3, 7}},
+		/* 6 bits  */
+		{{4, 9}, {5, 8}},
+		/* 7 bits  */
+		{{4, 10}, {5, 11}, {7, 12}},
+		/* 8 bits  */
+		{{4, 13}, {7, 14}},
+		/* 9 bits  */
+		{{24, 15}},
+		/* 10 bits */
+		{{8, 18}, {15, 64}, {23, 16}, {24, 17}, {55, 0}},
+		/* 11 bits */
+		{/* EOL */{0, -1}, {8, 1792}, {23, 24}, {24, 25}, {40, 23}, {55, 22}, {103, 19},
+		{104, 20}, {108, 21}, {12, 1856}, {13, 1920}},
+		/* 12 bits */
+		{{18, 1984}, {19, 2048}, {20, 2112}, {21, 2176}, {22, 2240}, {23, 2304},
+		{28, 2368}, {29, 2432}, {30, 2496}, {31, 2560}, {36, 52}, {39, 55}, {40, 56},
+		{43, 59}, {44, 60}, {51, 320}, {52, 384}, {53, 448}, {55, 53}, {56, 54}, {82, 50},
+		{83, 51}, {84, 44}, {85, 45}, {86, 46}, {87, 47}, {88, 57}, {89, 58}, {90, 61},
+		{91, 256}, {100, 48}, {101, 49}, {102, 62}, {103, 63}, {104, 30}, {105, 31},
+		{106, 32}, {107, 33}, {108, 40}, {109, 41}, {200, 128}, {201, 192}, {202, 26},
+		{203, 27}, {204, 28}, {205, 29}, {210, 34}, {211, 35}, {212, 36}, {213, 37},
+		{214, 38}, {215, 39}, {218, 42}, {219, 43}},
+		/* 13 bits */
+		{{74, 640}, {75, 704}, {76, 768}, {77, 832}, {82, 1280}, {83, 1344}, {84, 1408},
+		{85, 1472}, {90, 1536}, {91, 1600}, {100, 1664}, {101, 1728}, {108, 512},
+		{109, 576}, {114, 896}, {115, 960}, {116, 1024}, {117, 1088}, {118, 1152},
+		{119, 1216}}
+	};
+
+	static final short[][][] WHITE_CODE = {
+		/* 4 bits */
+		{{7, 2}, {8, 3}, {11, 4}, {12, 5}, {14, 6}, {15, 7}},
+		/* 5 bits */
+		{{7, 10}, {8, 11}, {18, 128}, {19, 8}, {20, 9}, {27, 64}},
+		/* 6 bits */
+		{{3, 13}, {7, 1}, {8, 12}, {23, 192}, {24, 1664}, {42, 16}, {43, 17}, {52, 14},
+		{53, 15}},
+		/* 7 bits */
+		{{3, 22}, {4, 23}, {8, 20}, {12, 19}, {19, 26}, {23, 21}, {24, 28}, {36, 27},
+		{39, 18}, {40, 24}, {43, 25}, {55, 256}},
+		/* 8 bits */
+		{{2, 29}, {3, 30}, {4, 45}, {5, 46}, {10, 47}, {11, 48}, {18, 33}, {19, 34},
+		{20, 35}, {21, 36}, {22, 37}, {23, 38}, {26, 31}, {27, 32}, {36, 53}, {37, 54},
+		{40, 39}, {41, 40}, {42, 41}, {43, 42}, {44, 43}, {45, 44}, {50, 61}, {51, 62},
+		{52, 63}, {53, 0}, {54, 320}, {55, 384}, {74, 59}, {75, 60}, {82, 49}, {83, 50},
+		{84, 51}, {85, 52}, {88, 55}, {89, 56}, {90, 57}, {91, 58}, {100, 448},
+		{101, 512}, {103, 640}, {104, 576}},
+		/* 9 bits */
+		{{152, 1472}, {153, 1536}, {154, 1600}, {155, 1728}, {204, 704}, {205, 768},
+		{210, 832}, {211, 896}, {212, 960}, {213, 1024}, {214, 1088}, {215, 1152},
+		{216, 1216}, {217, 1280}, {218, 1344}, {219, 1408}},
+		/* 10 bits */
+		{},
+		/* 11 bits */
+		{{8, 1792}, {12, 1856}, {13, 1920}},
+		/* 12 bits */
+		{/* EOL */{1, -1}, {18, 1984}, {19, 2048}, {20, 2112}, {21, 2176}, {22, 2240}, {23, 2304},
+		{28, 2368}, {29, 2432}, {30, 2496}, {31, 2560}}
+	};
+	
+	static final int BLACK_MIN_BITS = 2;
+	static final int WHITE_MIN_BITS = 4;
+
+	boolean isWhite;
+	int whiteValue = 0;
+	int blackValue = 1;
+	byte[] src;
+	byte[] dest;
+	int byteOffsetSrc = 0;
+	int bitOffsetSrc = 0;
+	int byteOffsetDest = 0;
+	int bitOffsetDest = 0;
+	int code = 0;
+	int nbrBits = 0;
+	/* nbr of bytes per row */
+	int rowSize;
+
+public int decode(byte[] src, byte[] dest, int offsetDest, int rowSize, int nRows) {
+	this.src = src;
+	this.dest = dest;
+	this.rowSize = rowSize;
+	byteOffsetSrc = 0;
+	bitOffsetSrc = 0;
+	byteOffsetDest = offsetDest;
+	bitOffsetDest = 0;
+	int cnt = 0;
+	while (cnt < nRows && decodeRow()) {
+		cnt++;
+		/* byte aligned */
+		if (bitOffsetDest > 0) {
+			byteOffsetDest++;
+			bitOffsetDest = 0; 
+		}
+	}
+	return byteOffsetDest - offsetDest;
+}
+
+boolean decodeRow() {
+	isWhite = true;
+	int n = 0;
+	while (n < rowSize) {
+		int runLength = decodeRunLength();
+		if (runLength < 0) return false;
+		n += runLength;
+		setNextBits(isWhite ? whiteValue : blackValue, runLength);
+		isWhite = !isWhite;
+	}
+	return true;
+}
+
+int decodeRunLength() {
+	int runLength = 0;
+	int partialRun = 0;
+	short[][][] huffmanCode = isWhite ? WHITE_CODE : BLACK_CODE;
+	while (true) {
+		boolean found = false;
+		nbrBits = isWhite ? WHITE_MIN_BITS : BLACK_MIN_BITS;
+		code = getNextBits(nbrBits);
+		for (int i = 0; i < huffmanCode.length; i++) {
+			for (int j = 0; j < huffmanCode[i].length; j++) {
+				if (huffmanCode[i][j][0] == code) {
+					found = true;
+					partialRun = huffmanCode[i][j][1];
+					if (partialRun == -1) {
+						/* Stop when reaching final EOL on last byte */
+						if (byteOffsetSrc == src.length - 1) return -1;
+						/* Group 3 starts each row with an EOL - ignore it */
+					} else {
+						runLength += partialRun;
+						if (partialRun < 64) return runLength;
+					}
+					break;
+				}
+			}
+			if (found) break;
+			code = code << 1 | getNextBit();
+		}
+		if (!found) SWT.error(SWT.ERROR_INVALID_IMAGE);			 
+	}
+}
+
+int getNextBit() {
+	int value = (src[byteOffsetSrc] >>> (7 - bitOffsetSrc)) & 0x1;
+	bitOffsetSrc++;
+	if (bitOffsetSrc > 7) {
+		byteOffsetSrc++;
+		bitOffsetSrc = 0;
+	}
+	return value;
+}
+
+int getNextBits(int cnt) {
+	int value = 0;
+	for (int i = 0; i < cnt; i++) {
+		value = value << 1 | getNextBit();
+	}
+	return value;
+}
+
+void setNextBits(int value, int cnt) {
+	int n = cnt;
+	while (bitOffsetDest > 0 && bitOffsetDest <= 7 && n > 0) {
+		dest[byteOffsetDest] = value == 1 ?
+			(byte)(dest[byteOffsetDest] | (1 << (7 - bitOffsetDest))) :
+			(byte)(dest[byteOffsetDest] & ~(1 << (7 - bitOffsetDest)));
+		n--;
+		bitOffsetDest++; 
+	}
+	if (bitOffsetDest == 8) {
+		byteOffsetDest++;
+		bitOffsetDest = 0;
+	}
+	while (n >= 8) {
+		dest[byteOffsetDest++] = (byte) (value == 1 ? 0xFF : 0);
+		n -= 8;
+	}
+	while (n > 0) {
+		dest[byteOffsetDest] = value == 1 ?
+			(byte)(dest[byteOffsetDest] | (1 << (7 - bitOffsetDest))) :
+			(byte)(dest[byteOffsetDest] & ~(1 << (7 - bitOffsetDest)));
+		n--;
+		bitOffsetDest++;		
+	}	
+}
+
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/TIFFModifiedHuffmanCodec.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/TIFFRandomFileAccess.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/TIFFRandomFileAccess.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/TIFFRandomFileAccess.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,96 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.image;
+
+import java.io.*;
+
+final class TIFFRandomFileAccess {
+
+	LEDataInputStream inputStream;
+	int start, current, next;
+	byte[][] buffers;
+
+	static final int CHUNK_SIZE = 8192;
+	static final int LIST_SIZE = 128;
+
+public TIFFRandomFileAccess(LEDataInputStream stream) {
+	inputStream = stream;
+	start = current = next = inputStream.getPosition();
+	buffers = new byte[LIST_SIZE][];
+}
+
+void seek(int pos) throws IOException {
+	if (pos == current) return;
+	if (pos < start) throw new IOException();
+	current = pos;	
+	if (current > next) {
+		int n = current - next;
+		/* store required bytes */
+		int index = next / CHUNK_SIZE;
+		int offset = next % CHUNK_SIZE;
+		while (n > 0) {
+			if (index >= buffers.length) {
+				byte[][] oldBuffers = buffers;
+				buffers = new byte[Math.max(index + 1, oldBuffers.length + LIST_SIZE)][];
+				System.arraycopy(oldBuffers, 0, buffers, 0, oldBuffers.length);
+			}
+			if (buffers[index] == null) buffers[index] = new byte[CHUNK_SIZE];
+			int cnt = inputStream.read(buffers[index], offset, Math.min(n, CHUNK_SIZE - offset));
+			n -= cnt;
+			next += cnt;
+			index++;
+			offset = 0;
+		}
+	}
+}
+
+void read(byte b[]) throws IOException {
+	int size = b.length;
+	int nCached = Math.min(size, next - current);
+	int nMissing = size - next + current;
+	int destNext = 0;
+	if (nCached > 0) {
+		/* Get cached bytes */
+		int index = current / CHUNK_SIZE;
+		int offset = current % CHUNK_SIZE;		
+		while (nCached > 0) {
+			int cnt = Math.min(nCached, CHUNK_SIZE - offset);
+			System.arraycopy(buffers[index], offset, b, destNext, cnt);
+			nCached -= cnt; 
+			destNext += cnt;
+			index++;
+			offset = 0;
+		}
+	}
+	if (nMissing > 0) {
+		/* Read required bytes */
+		int index = next / CHUNK_SIZE;
+		int offset = next % CHUNK_SIZE;
+		while (nMissing > 0) {
+			if (index >= buffers.length) {
+				byte[][] oldBuffers = buffers;
+				buffers = new byte[Math.max(index, oldBuffers.length + LIST_SIZE)][];
+				System.arraycopy(oldBuffers, 0, buffers, 0, oldBuffers.length);
+			}
+			if (buffers[index] == null) buffers[index] = new byte[CHUNK_SIZE];
+			int cnt = inputStream.read(buffers[index], offset, Math.min(nMissing, CHUNK_SIZE - offset));
+			System.arraycopy(buffers[index], offset, b, destNext, cnt);
+			nMissing -= cnt;
+			next += cnt;
+			destNext += cnt;
+			index++;
+			offset = 0;
+		}
+	}
+	current += size;
+}
+
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/TIFFRandomFileAccess.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/WinBMPFileFormat.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/WinBMPFileFormat.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/WinBMPFileFormat.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,690 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.image;
+
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import java.io.*;
+
+public final class WinBMPFileFormat extends FileFormat {
+	static final int BMPFileHeaderSize = 14;
+	static final int BMPHeaderFixedSize = 40;
+	int importantColors;
+	Point pelsPerMeter = new Point(0, 0);
+
+/**
+ * Compress numBytes bytes of image data from src, storing in dest
+ * (starting at 0), using the technique specified by comp.
+ * If last is true, this indicates the last line of the image.
+ * Answer the size of the compressed data.
+ */
+int compress(int comp, byte[] src, int srcOffset, int numBytes, byte[] dest, boolean last) {
+	if (comp == 1) { // BMP_RLE8_COMPRESSION
+		return compressRLE8Data(src, srcOffset, numBytes, dest, last);
+	}
+	if (comp == 2) { // BMP_RLE4_COMPRESSION
+		return compressRLE4Data(src, srcOffset, numBytes, dest, last);
+	}
+	SWT.error(SWT.ERROR_INVALID_IMAGE);
+	return 0;
+}
+int compressRLE4Data(byte[] src, int srcOffset, int numBytes, byte[] dest, boolean last) {
+	int sp = srcOffset, end = srcOffset + numBytes, dp = 0;
+	int size = 0, left, i, n;
+	byte theByte;
+	while (sp < end) {
+		/* find two consecutive bytes that are the same in the next 128 */
+		left = end - sp - 1;
+		if (left > 127)
+			left = 127;
+		for (n = 0; n < left; n++) {
+			if (src[sp + n] == src[sp + n + 1])
+				break;
+		}
+		/* if there is only one more byte in the scan line, include it */
+		if (n < 127 && n == left)
+			n++;
+		/* store the intervening data */
+		switch (n) {
+			case 0:
+				break;
+			case 1: /* handled separately because 0,2 is a command */
+				dest[dp] = 2; dp++; /* 1 byte == 2 pixels */
+				dest[dp] = src[sp];
+				dp++; sp++;
+				size += 2;
+				break;
+			default:
+				dest[dp] = 0; dp++;
+				dest[dp] = (byte)(n + n); dp++; /* n bytes = n*2 pixels */
+				for (i = n; i > 0; i--) {
+					dest[dp] = src[sp];
+					dp++; sp++;
+				}
+				size += 2 + n;
+				if ((n & 1) != 0) { /* pad to word */
+					dest[dp] = 0;
+					dp++;
+					size++;
+				}
+				break;
+		}
+		/* find the length of the next run (up to 127) and store it */
+		left = end - sp;
+		if (left > 0) {
+			if (left > 127)
+				left = 127;
+			theByte = src[sp];
+			for (n = 1; n < left; n++) {
+				if (src[sp + n] != theByte)
+					break;
+			}
+			dest[dp] = (byte)(n + n); dp++; /* n bytes = n*2 pixels */
+			dest[dp] = theByte; dp++;
+			sp += n;
+			size += 2;
+		}
+	}
+
+	/* store the end of line or end of bitmap codes */
+	dest[dp] = 0; dp++;
+	if (last) {
+		dest[dp] = 1; dp++;
+	} else {
+		dest[dp] = 0; dp++;
+	}
+	size += 2;
+	
+	return size;
+}
+int compressRLE8Data(byte[] src, int srcOffset, int numBytes, byte[] dest, boolean last) {
+	int sp = srcOffset, end = srcOffset + numBytes, dp = 0;
+	int size = 0, left, i, n;
+	byte theByte;
+	while (sp < end) {
+		/* find two consecutive bytes that are the same in the next 256 */
+		left = end - sp - 1;
+		if (left > 254)
+			left = 254;
+		for (n = 0; n < left; n++) {
+			if (src[sp + n] == src[sp + n + 1])
+				break;
+		}
+		/* if there is only one more byte in the scan line, include it */
+		if (n == left)
+			n++;
+		/* store the intervening data */
+		switch (n) {
+			case 0:
+				break;
+			case 2: /* handled separately because 0,2 is a command */
+				dest[dp] = 1; dp++;
+				dest[dp] = src[sp];
+				dp++; sp++;
+				size += 2;
+				/* don't break, fall through */
+			case 1: /* handled separately because 0,1 is a command */
+				dest[dp] = 1; dp++;
+				dest[dp] = src[sp];
+				dp++; sp++;
+				size += 2;
+				break;
+			default:
+				dest[dp] = 0; dp++;
+				dest[dp] = (byte)n; dp++;
+				for (i = n; i > 0; i--) {
+					dest[dp] = src[sp];
+					dp++; sp++;
+				}
+				size += 2 + n;
+				if ((n & 1) != 0) { /* pad to word */
+					dest[dp] = 0;
+					dp++;
+					size++;
+				}
+				break;
+		}
+		/* find the length of the next run (up to 255) and store it */
+		left = end - sp;
+		if (left > 0) {
+			if (left > 255)
+				left = 255;
+			theByte = src[sp];
+			for (n = 1; n < left; n++) {
+				if (src[sp + n] != theByte)
+					break;
+			}
+			dest[dp] = (byte)n; dp++;
+			dest[dp] = theByte; dp++;
+			sp += n;
+			size += 2;
+		}
+	}
+
+	/* store the end of line or end of bitmap codes */
+	dest[dp] = 0; dp++;
+	if (last) {
+		dest[dp] = 1; dp++;
+	} else {
+		dest[dp] = 0; dp++;
+	}
+	size += 2;
+	
+	return size;
+}
+void decompressData(byte[] src, byte[] dest, int stride, int cmp) {
+	if (cmp == 1) { // BMP_RLE8_COMPRESSION
+		if (decompressRLE8Data(src, src.length, stride, dest, dest.length) <= 0)
+			SWT.error(SWT.ERROR_INVALID_IMAGE);
+		return;
+	}
+	if (cmp == 2) { // BMP_RLE4_COMPRESSION
+		if (decompressRLE4Data(src, src.length, stride, dest, dest.length) <= 0)
+			SWT.error(SWT.ERROR_INVALID_IMAGE);
+		return;
+	}
+	SWT.error(SWT.ERROR_INVALID_IMAGE);
+}
+int decompressRLE4Data(byte[] src, int numBytes, int stride, byte[] dest, int destSize) {
+	int sp = 0;
+	int se = numBytes;
+	int dp = 0;
+	int de = destSize;
+	int x = 0, y = 0;
+	while (sp < se) {
+		int len = src[sp] & 0xFF;
+		sp++;
+		if (len == 0) {
+			len = src[sp] & 0xFF;
+			sp++;
+			switch (len) {
+				case 0: /* end of line */
+					y++;
+					x = 0;
+					dp = y * stride;
+					if (dp > de)
+						return -1;
+					break;
+				case 1: /* end of bitmap */
+					return 1;
+				case 2: /* delta */
+					x += src[sp] & 0xFF;
+					sp++;
+					y += src[sp] & 0xFF;
+					sp++;
+					dp = y * stride + x / 2;
+					if (dp > de)
+						return -1;
+					break;
+				default: /* absolute mode run */
+					if ((len & 1) != 0) /* odd run lengths not currently supported */
+						return -1;
+					x += len;
+					len = len / 2;
+					if (len > (se - sp))
+						return -1;
+					if (len > (de - dp))
+						return -1;
+					for (int i = 0; i < len; i++) {
+						dest[dp] = src[sp];
+						dp++;
+						sp++;
+					}
+					if ((sp & 1) != 0)
+						sp++; /* word align sp? */
+					break;
+			}
+		} else {
+			if ((len & 1) != 0)
+				return -1;
+			x += len;
+			len = len / 2;
+			byte theByte = src[sp];
+			sp++;
+			if (len > (de - dp))
+				return -1;
+			for (int i = 0; i < len; i++) {
+				dest[dp] = theByte;
+				dp++;
+			}
+		}
+	}
+	return 1;
+}
+int decompressRLE8Data(byte[] src, int numBytes, int stride, byte[] dest, int destSize) {
+	int sp = 0;
+	int se = numBytes;
+	int dp = 0;
+	int de = destSize;
+	int x = 0, y = 0;
+	while (sp < se) {
+		int len = src[sp] & 0xFF;
+		sp++;
+		if (len == 0) {
+			len = src[sp] & 0xFF;
+			sp++;
+			switch (len) {
+				case 0: /* end of line */
+					y++;
+					x = 0;
+					dp = y * stride;
+					if (dp > de)
+						return -1;
+					break;
+				case 1: /* end of bitmap */
+					return 1;
+				case 2: /* delta */
+					x += src[sp] & 0xFF;
+					sp++;
+					y += src[sp] & 0xFF;
+					sp++;
+					dp = y * stride + x;
+					if (dp > de)
+						return -1;
+					break;
+				default: /* absolute mode run */
+					if (len > (se - sp))
+						return -1;
+					if (len > (de - dp))
+						return -1;
+					for (int i = 0; i < len; i++) {
+						dest[dp] = src[sp];
+						dp++;
+						sp++;
+					}
+					if ((sp & 1) != 0)
+						sp++; /* word align sp? */
+					x += len;
+					break;
+			}
+		} else {
+			byte theByte = src[sp];
+			sp++;
+			if (len > (de - dp))
+				return -1;
+			for (int i = 0; i < len; i++) {
+				dest[dp] = theByte;
+				dp++;
+			}
+			x += len;
+		}
+	}
+	return 1;
+}
+boolean isFileFormat(LEDataInputStream stream) {
+	try {
+		byte[] header = new byte[18];
+		stream.read(header);
+		stream.unread(header);
+		int infoHeaderSize = (header[14] & 0xFF) | ((header[15] & 0xFF) << 8) | ((header[16] & 0xFF) << 16) | ((header[17] & 0xFF) << 24);
+		return header[0] == 0x42 && header[1] == 0x4D && infoHeaderSize >= BMPHeaderFixedSize;
+	} catch (Exception e) {
+		return false;
+	}
+}
+byte[] loadData(byte[] infoHeader) {
+	int width = (infoHeader[4] & 0xFF) | ((infoHeader[5] & 0xFF) << 8) | ((infoHeader[6] & 0xFF) << 16) | ((infoHeader[7] & 0xFF) << 24);
+	int height = (infoHeader[8] & 0xFF) | ((infoHeader[9] & 0xFF) << 8) | ((infoHeader[10] & 0xFF) << 16) | ((infoHeader[11] & 0xFF) << 24);
+	int bitCount = (infoHeader[14] & 0xFF) | ((infoHeader[15] & 0xFF) << 8);
+	int stride = (width * bitCount + 7) / 8;
+	stride = (stride + 3) / 4 * 4; // Round up to 4 byte multiple
+	byte[] data = loadData(infoHeader, stride);
+	flipScanLines(data, stride, height);
+	return data;
+}
+byte[] loadData(byte[] infoHeader, int stride) {
+	int height = (infoHeader[8] & 0xFF) | ((infoHeader[9] & 0xFF) << 8) | ((infoHeader[10] & 0xFF) << 16) | ((infoHeader[11] & 0xFF) << 24);
+	if (height < 0) height = -height;
+	int dataSize = height * stride;
+	byte[] data = new byte[dataSize];
+	int cmp = (infoHeader[16] & 0xFF) | ((infoHeader[17] & 0xFF) << 8) | ((infoHeader[18] & 0xFF) << 16) | ((infoHeader[19] & 0xFF) << 24);
+	if (cmp == 0 || cmp == 3) { // BMP_NO_COMPRESSION
+		try {
+			if (inputStream.read(data) != dataSize)
+				SWT.error(SWT.ERROR_INVALID_IMAGE);
+		} catch (IOException e) {
+			SWT.error(SWT.ERROR_IO, e);
+		}
+	} else {
+		int compressedSize = (infoHeader[20] & 0xFF) | ((infoHeader[21] & 0xFF) << 8) | ((infoHeader[22] & 0xFF) << 16) | ((infoHeader[23] & 0xFF) << 24);
+		byte[] compressed = new byte[compressedSize];
+		try {
+			if (inputStream.read(compressed) != compressedSize)
+				SWT.error(SWT.ERROR_INVALID_IMAGE);
+		} catch (IOException e) {
+			SWT.error(SWT.ERROR_IO, e);
+		}
+		decompressData(compressed, data, stride, cmp);
+	}
+	return data;
+}
+int[] loadFileHeader() {
+	int[] header = new int[5];
+	try {
+		header[0] = inputStream.readShort();
+		header[1] = inputStream.readInt();
+		header[2] = inputStream.readShort();
+		header[3] = inputStream.readShort();
+		header[4] = inputStream.readInt();
+	} catch (IOException e) {
+		SWT.error(SWT.ERROR_IO, e);
+	}
+	if (header[0] != 0x4D42)
+		SWT.error(SWT.ERROR_INVALID_IMAGE);
+	return header;
+}
+ImageData[] loadFromByteStream() {
+	int[] fileHeader = loadFileHeader();
+	byte[] infoHeader = new byte[BMPHeaderFixedSize];
+	try {
+		inputStream.read(infoHeader);
+	} catch (Exception e) {
+		SWT.error(SWT.ERROR_IO, e);
+	}
+	int width = (infoHeader[4] & 0xFF) | ((infoHeader[5] & 0xFF) << 8) | ((infoHeader[6] & 0xFF) << 16) | ((infoHeader[7] & 0xFF) << 24);
+	int height = (infoHeader[8] & 0xFF) | ((infoHeader[9] & 0xFF) << 8) | ((infoHeader[10] & 0xFF) << 16) | ((infoHeader[11] & 0xFF) << 24);
+	if (height < 0) height = -height;
+	int bitCount = (infoHeader[14] & 0xFF) | ((infoHeader[15] & 0xFF) << 8);
+	this.compression = (infoHeader[16] & 0xFF) | ((infoHeader[17] & 0xFF) << 8) | ((infoHeader[18] & 0xFF) << 16) | ((infoHeader[19] & 0xFF) << 24);
+	PaletteData palette = loadPalette(infoHeader);
+	if (inputStream.getPosition() < fileHeader[4]) {
+		// Seek to the specified offset
+		try {
+			inputStream.skip(fileHeader[4] - inputStream.getPosition());
+		} catch (IOException e) {
+			SWT.error(SWT.ERROR_IO, e);
+		}
+	}
+	byte[] data = loadData(infoHeader);
+	this.importantColors = (infoHeader[36] & 0xFF) | ((infoHeader[37] & 0xFF) << 8) | ((infoHeader[38] & 0xFF) << 16) | ((infoHeader[39] & 0xFF) << 24);
+	int xPelsPerMeter = (infoHeader[24] & 0xFF) | ((infoHeader[25] & 0xFF) << 8) | ((infoHeader[26] & 0xFF) << 16) | ((infoHeader[27] & 0xFF) << 24);
+	int yPelsPerMeter = (infoHeader[28] & 0xFF) | ((infoHeader[29] & 0xFF) << 8) | ((infoHeader[30] & 0xFF) << 16) | ((infoHeader[31] & 0xFF) << 24);
+	this.pelsPerMeter = new Point(xPelsPerMeter, yPelsPerMeter);
+	int type = (this.compression == 1 /*BMP_RLE8_COMPRESSION*/) || (this.compression == 2 /*BMP_RLE4_COMPRESSION*/) ? SWT.IMAGE_BMP_RLE : SWT.IMAGE_BMP;
+	return new ImageData[] {
+		ImageData.internal_new(
+			width,
+			height,
+			bitCount,
+			palette,
+			4,
+			data,
+			0,
+			null,
+			null,
+			-1,
+			-1,
+			type,
+			0,
+			0,
+			0,
+			0)
+	};
+}
+PaletteData loadPalette(byte[] infoHeader) {
+	int depth = (infoHeader[14] & 0xFF) | ((infoHeader[15] & 0xFF) << 8);
+	if (depth <= 8) {
+		int numColors = (infoHeader[32] & 0xFF) | ((infoHeader[33] & 0xFF) << 8) | ((infoHeader[34] & 0xFF) << 16) | ((infoHeader[35] & 0xFF) << 24);
+		if (numColors == 0) {
+			numColors = 1 << depth;
+		} else {
+			if (numColors > 256)
+				numColors = 256;
+		}
+		byte[] buf = new byte[numColors * 4];
+		try {
+			if (inputStream.read(buf) != buf.length)
+				SWT.error(SWT.ERROR_INVALID_IMAGE);
+		} catch (IOException e) {
+			SWT.error(SWT.ERROR_IO, e);
+		}
+		return paletteFromBytes(buf, numColors);
+	}
+	if (depth == 16) {
+		if (this.compression == 3) {
+			try {
+				return new PaletteData(inputStream.readInt(), inputStream.readInt(), inputStream.readInt());
+			} catch (IOException e) {
+				SWT.error(SWT.ERROR_IO, e);
+			}
+		}
+		return new PaletteData(0x7C00, 0x3E0, 0x1F);
+	}
+	if (depth == 24) return new PaletteData(0xFF, 0xFF00, 0xFF0000);
+	if (this.compression == 3) {
+		try {
+			return new PaletteData(inputStream.readInt(), inputStream.readInt(), inputStream.readInt());
+		} catch (IOException e) {
+			SWT.error(SWT.ERROR_IO, e);
+		}
+	}
+	return new PaletteData(0xFF00, 0xFF0000, 0xFF000000);
+}
+PaletteData paletteFromBytes(byte[] bytes, int numColors) {
+	int bytesOffset = 0;
+	RGB[] colors = new RGB[numColors];
+	for (int i = 0; i < numColors; i++) {
+		colors[i] = new RGB(bytes[bytesOffset + 2] & 0xFF,
+			bytes[bytesOffset + 1] & 0xFF,
+			bytes[bytesOffset] & 0xFF);
+		bytesOffset += 4;
+	}
+	return new PaletteData(colors);
+}
+/**
+ * Answer a byte array containing the BMP representation of
+ * the given device independent palette.
+ */
+static byte[] paletteToBytes(PaletteData pal) {
+	int n = pal.colors == null ? 0 : (pal.colors.length < 256 ? pal.colors.length : 256);
+	byte[] bytes = new byte[n * 4];
+	int offset = 0;
+	for (int i = 0; i < n; i++) {
+		RGB col = pal.colors[i];
+		bytes[offset] = (byte)col.blue;
+		bytes[offset + 1] = (byte)col.green;
+		bytes[offset + 2] = (byte)col.red;
+		offset += 4;
+	}
+	return bytes;
+}
+/**
+ * Unload the given image's data into the given byte stream
+ * using the given compression strategy. 
+ * Answer the number of bytes written.
+ */
+int unloadData(ImageData image, OutputStream out, int comp) {
+	int totalSize = 0;
+	try {
+		if (comp == 0)
+			return unloadDataNoCompression(image, out);
+		int bpl = (image.width * image.depth + 7) / 8;
+		int bmpBpl = (bpl + 3) / 4 * 4; // BMP pads scanlines to multiples of 4 bytes
+		int imageBpl = image.bytesPerLine;
+		// Compression can actually take twice as much space, in worst case
+		byte[] buf = new byte[bmpBpl * 2];
+		int srcOffset = imageBpl * (image.height - 1); // Start at last line
+		byte[] data = image.data;
+		totalSize = 0;
+		byte[] buf2 = new byte[32768];
+		int buf2Offset = 0;
+		for (int y = image.height - 1; y >= 0; y--) {
+			int lineSize = compress(comp, data, srcOffset, bpl, buf, y == 0);
+			if (buf2Offset + lineSize > buf2.length) {
+				out.write(buf2, 0, buf2Offset);
+				buf2Offset = 0;
+			}
+			System.arraycopy(buf, 0, buf2, buf2Offset, lineSize);
+			buf2Offset += lineSize;
+			totalSize += lineSize;
+			srcOffset -= imageBpl;
+		}
+		if (buf2Offset > 0)
+			out.write(buf2, 0, buf2Offset);
+	} catch (IOException e) {
+		SWT.error(SWT.ERROR_IO, e);
+	}
+	return totalSize;
+}
+/**
+ * Prepare the given image's data for unloading into a byte stream
+ * using no compression strategy.
+ * Answer the number of bytes written.
+ */
+int unloadDataNoCompression(ImageData image, OutputStream out) {
+	int bmpBpl = 0;
+	try {
+		int bpl = (image.width * image.depth + 7) / 8;
+		bmpBpl = (bpl + 3) / 4 * 4; // BMP pads scanlines to multiples of 4 bytes
+		int linesPerBuf = 32678 / bmpBpl;
+		byte[] buf = new byte[linesPerBuf * bmpBpl];
+		byte[] data = image.data;
+		int imageBpl = image.bytesPerLine;
+		int dataIndex = imageBpl * (image.height - 1); // Start at last line
+		if (image.depth == 16) {
+			for (int y = 0; y < image.height; y += linesPerBuf) {
+				int count = image.height - y;
+				if (linesPerBuf < count) count = linesPerBuf;
+				int bufOffset = 0;
+				for (int i = 0; i < count; i++) {
+					for (int wIndex = 0; wIndex < bpl; wIndex += 2) {
+						buf[bufOffset + wIndex + 1] = data[dataIndex + wIndex + 1];
+						buf[bufOffset + wIndex] = data[dataIndex + wIndex];
+					}
+					bufOffset += bmpBpl;
+					dataIndex -= imageBpl;
+				}
+				out.write(buf, 0, bufOffset);
+			}
+		} else {
+			for (int y = 0; y < image.height; y += linesPerBuf) {
+				int tmp = image.height - y;
+				int count = tmp < linesPerBuf ? tmp : linesPerBuf;
+				int bufOffset = 0;
+				for (int i = 0; i < count; i++) {
+					System.arraycopy(data, dataIndex, buf, bufOffset, bpl);
+					bufOffset += bmpBpl;
+					dataIndex -= imageBpl;
+				}
+				out.write(buf, 0, bufOffset);
+			}
+		}
+	} catch (IOException e) {
+		SWT.error(SWT.ERROR_IO, e);
+	}
+	return bmpBpl * image.height;
+}
+/**
+ * Unload a DeviceIndependentImage using Windows .BMP format into the given
+ * byte stream.
+ */
+void unloadIntoByteStream(ImageLoader loader) {
+	ImageData image = loader.data[0];
+	byte[] rgbs;
+	int numCols;
+	if (!((image.depth == 1) || (image.depth == 4) || (image.depth == 8) ||
+		  (image.depth == 16) || (image.depth == 24) || (image.depth == 32)))
+			SWT.error(SWT.ERROR_UNSUPPORTED_DEPTH);
+	int comp = this.compression;
+	if (!((comp == 0) || ((comp == 1) && (image.depth == 8)) ||
+		  ((comp == 2) && (image.depth == 4))))
+			SWT.error(SWT.ERROR_INVALID_IMAGE);
+	PaletteData pal = image.palette;
+	if ((image.depth == 16) || (image.depth == 24) || (image.depth == 32)) {
+		if (!pal.isDirect)
+			SWT.error(SWT.ERROR_INVALID_IMAGE);
+		numCols = 0;
+		rgbs = null;
+	} else {
+		if (pal.isDirect)
+			SWT.error(SWT.ERROR_INVALID_IMAGE);
+		numCols = pal.colors.length;
+		rgbs = paletteToBytes(pal);
+	}
+	// Fill in file header, except for bfsize, which is done later.
+	int headersSize = BMPFileHeaderSize + BMPHeaderFixedSize;
+	int[] fileHeader = new int[5];
+	fileHeader[0] = 0x4D42;	// Signature
+	fileHeader[1] = 0; // File size - filled in later
+	fileHeader[2] = 0; // Reserved 1
+	fileHeader[3] = 0; // Reserved 2
+	fileHeader[4] = headersSize; // Offset to data
+	if (rgbs != null) {
+		fileHeader[4] += rgbs.length;
+	}
+
+	// Prepare data. This is done first so we don't have to try to rewind
+	// the stream and fill in the details later.
+	ByteArrayOutputStream out = new ByteArrayOutputStream();
+	unloadData(image, out, comp);
+	byte[] data = out.toByteArray();
+	
+	// Calculate file size
+	fileHeader[1] = fileHeader[4] + data.length;
+
+	// Write the headers
+	try {
+		outputStream.writeShort(fileHeader[0]);
+		outputStream.writeInt(fileHeader[1]);
+		outputStream.writeShort(fileHeader[2]);
+		outputStream.writeShort(fileHeader[3]);
+		outputStream.writeInt(fileHeader[4]);
+	} catch (IOException e) {
+		SWT.error(SWT.ERROR_IO, e);
+	}
+	try {
+		outputStream.writeInt(BMPHeaderFixedSize);
+		outputStream.writeInt(image.width);
+		outputStream.writeInt(image.height);
+		outputStream.writeShort(1);
+		outputStream.writeShort((short)image.depth);
+		outputStream.writeInt(comp);
+		outputStream.writeInt(data.length);
+		outputStream.writeInt(pelsPerMeter.x);
+		outputStream.writeInt(pelsPerMeter.y);
+		outputStream.writeInt(numCols);
+		outputStream.writeInt(importantColors);
+	} catch (IOException e) {
+		SWT.error(SWT.ERROR_IO, e);
+	}
+	
+	// Unload palette
+	if (numCols > 0) {
+		try {
+			outputStream.write(rgbs);
+		} catch (IOException e) {
+			SWT.error(SWT.ERROR_IO, e);
+		}
+	}
+
+	// Unload the data
+	try {
+		outputStream.write(data);
+	} catch (IOException e) {
+		SWT.error(SWT.ERROR_IO, e);
+	}
+}
+void flipScanLines(byte[] data, int stride, int height) {
+	int i1 = 0;
+	int i2 = (height - 1) * stride;
+	for (int i = 0; i < height / 2; i++) {
+		for (int index = 0; index < stride; index++) {
+			byte b = data[index + i1];
+			data[index + i1] = data[index + i2];
+			data[index + i2] = b;
+		}
+		i1 += stride;
+		i2 -= stride;
+	}
+}
+
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/WinBMPFileFormat.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/WinICOFileFormat.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/WinICOFileFormat.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/WinICOFileFormat.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,325 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.image;
+
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import java.io.*;
+
+public final class WinICOFileFormat extends FileFormat {
+	
+byte[] bitInvertData(byte[] data, int startIndex, int endIndex) {
+	// Destructively bit invert data in the given byte array.
+	for (int i = startIndex; i < endIndex; i++) {
+		data[i] = (byte)(255 - data[i - startIndex]);
+	}
+	return data;
+}
+
+static final byte[] convertPad(byte[] data, int width, int height, int depth, int pad, int newPad) {
+	if (pad == newPad) return data;
+	int stride = (width * depth + 7) / 8;
+	int bpl = (stride + (pad - 1)) / pad * pad;
+	int newBpl = (stride + (newPad - 1)) / newPad * newPad;
+	byte[] newData = new byte[height * newBpl];
+	int srcIndex = 0, destIndex = 0;
+	for (int y = 0; y < height; y++) {
+		System.arraycopy(data, srcIndex, newData, destIndex, newBpl);
+		srcIndex += bpl;
+		destIndex += newBpl;
+	}
+	return newData;
+}
+/**
+ * Answer the size in bytes of the file representation of the given
+ * icon
+ */
+int iconSize(ImageData i) {
+	int shapeDataStride = (i.width * i.depth + 31) / 32 * 4;
+	int maskDataStride = (i.width + 31) / 32 * 4;
+	int dataSize = (shapeDataStride + maskDataStride) * i.height;
+	int paletteSize = i.palette.colors != null ? i.palette.colors.length * 4 : 0;
+	return WinBMPFileFormat.BMPHeaderFixedSize + paletteSize + dataSize;
+}
+boolean isFileFormat(LEDataInputStream stream) {
+	try {
+		byte[] header = new byte[4];
+		stream.read(header);
+		stream.unread(header);
+		return header[0] == 0 && header[1] == 0 && header[2] == 1 && header[3] == 0;
+	} catch (Exception e) {
+		return false;
+	}
+}
+boolean isValidIcon(ImageData i) {
+	switch (i.depth) {
+		case 1:
+		case 4:
+		case 8:
+			if (i.palette.isDirect) return false;
+			int size = i.palette.colors.length;
+			return size == 2 || size == 16 || size == 32 || size == 256;
+		case 24:
+		case 32:
+			return i.palette.isDirect;
+	}
+	return false;
+}
+int loadFileHeader(LEDataInputStream byteStream) {
+	int[] fileHeader = new int[3];
+	try {
+		fileHeader[0] = byteStream.readShort();
+		fileHeader[1] = byteStream.readShort();
+		fileHeader[2] = byteStream.readShort();
+	} catch (IOException e) {
+		SWT.error(SWT.ERROR_IO, e);
+	}
+	if ((fileHeader[0] != 0) || (fileHeader[1] != 1))
+		SWT.error(SWT.ERROR_INVALID_IMAGE);
+	int numIcons = fileHeader[2];
+	if (numIcons <= 0)
+		SWT.error(SWT.ERROR_INVALID_IMAGE);
+	return numIcons;
+}
+int loadFileHeader(LEDataInputStream byteStream, boolean hasHeader) {
+	int[] fileHeader = new int[3];
+	try {
+		if (hasHeader) {
+			fileHeader[0] = byteStream.readShort();
+			fileHeader[1] = byteStream.readShort();
+		} else {
+			fileHeader[0] = 0;
+			fileHeader[1] = 1;
+		}
+		fileHeader[2] = byteStream.readShort();
+	} catch (IOException e) {
+		SWT.error(SWT.ERROR_IO, e);
+	}
+	if ((fileHeader[0] != 0) || (fileHeader[1] != 1))
+		SWT.error(SWT.ERROR_INVALID_IMAGE);
+	int numIcons = fileHeader[2];
+	if (numIcons <= 0)
+		SWT.error(SWT.ERROR_INVALID_IMAGE);
+	return numIcons;
+}
+ImageData[] loadFromByteStream() {
+	int numIcons = loadFileHeader(inputStream);
+	int[][] headers = loadIconHeaders(numIcons);
+	ImageData[] icons = new ImageData[headers.length];
+	for (int i = 0; i < icons.length; i++) {
+		icons[i] = loadIcon(headers[i]);
+	}
+	return icons;
+}
+/**
+ * Load one icon from the byte stream.
+ */
+ImageData loadIcon(int[] iconHeader) {
+	byte[] infoHeader = loadInfoHeader(iconHeader);
+	WinBMPFileFormat bmpFormat = new WinBMPFileFormat();
+	bmpFormat.inputStream = inputStream;
+	PaletteData palette = bmpFormat.loadPalette(infoHeader);
+	byte[] shapeData = bmpFormat.loadData(infoHeader);
+	int width = (infoHeader[4] & 0xFF) | ((infoHeader[5] & 0xFF) << 8) | ((infoHeader[6] & 0xFF) << 16) | ((infoHeader[7] & 0xFF) << 24);
+	int height = (infoHeader[8] & 0xFF) | ((infoHeader[9] & 0xFF) << 8) | ((infoHeader[10] & 0xFF) << 16) | ((infoHeader[11] & 0xFF) << 24);
+	if (height < 0) height = -height;
+	int depth = (infoHeader[14] & 0xFF) | ((infoHeader[15] & 0xFF) << 8);
+	infoHeader[14] = 1;
+	infoHeader[15] = 0;
+	byte[] maskData = bmpFormat.loadData(infoHeader);
+	maskData = convertPad(maskData, width, height, 1, 4, 2);
+	bitInvertData(maskData, 0, maskData.length);
+	return ImageData.internal_new(
+		width,
+		height,
+		depth,
+		palette,
+		4,
+		shapeData,
+		2,
+		maskData,
+		null,
+		-1,
+		-1,
+		SWT.IMAGE_ICO,
+		0,
+		0,
+		0,
+		0);
+}
+int[][] loadIconHeaders(int numIcons) {
+	int[][] headers = new int[numIcons][7];
+	try {
+		for (int i = 0; i < numIcons; i++) {
+			headers[i][0] = inputStream.read();
+			headers[i][1] = inputStream.read();
+			headers[i][2] = inputStream.readShort();
+			headers[i][3] = inputStream.readShort();
+			headers[i][4] = inputStream.readShort();
+			headers[i][5] = inputStream.readInt();
+			headers[i][6] = inputStream.readInt();
+		}
+	} catch (IOException e) {
+		SWT.error(SWT.ERROR_IO, e);
+	}
+	return headers;
+}
+byte[] loadInfoHeader(int[] iconHeader) {
+	int width = iconHeader[0];
+	int height = iconHeader[1];
+	int numColors = iconHeader[2]; // the number of colors is in the low byte, but the high byte must be 0
+	if (numColors == 0) numColors = 256; // this is specified: '00' represents '256' (0x100) colors
+	if ((numColors != 2) && (numColors != 8) && (numColors != 16) &&
+		(numColors != 32) && (numColors != 256))
+		SWT.error(SWT.ERROR_INVALID_IMAGE);
+	if (inputStream.getPosition() < iconHeader[6]) {
+		// Seek to the specified offset
+		try {
+			inputStream.skip(iconHeader[6] - inputStream.getPosition());
+		} catch (IOException e) {
+			SWT.error(SWT.ERROR_IO, e);
+			return null;
+		}
+	}
+	byte[] infoHeader = new byte[WinBMPFileFormat.BMPHeaderFixedSize];
+	try {
+		inputStream.read(infoHeader);
+	} catch (IOException e) {
+		SWT.error(SWT.ERROR_IO, e);
+	}
+	if (((infoHeader[12] & 0xFF) | ((infoHeader[13] & 0xFF) << 8)) != 1)
+		SWT.error(SWT.ERROR_INVALID_IMAGE);
+	int infoWidth = (infoHeader[4] & 0xFF) | ((infoHeader[5] & 0xFF) << 8) | ((infoHeader[6] & 0xFF) << 16) | ((infoHeader[7] & 0xFF) << 24);
+	int infoHeight = (infoHeader[8] & 0xFF) | ((infoHeader[9] & 0xFF) << 8) | ((infoHeader[10] & 0xFF) << 16) | ((infoHeader[11] & 0xFF) << 24);
+	int bitCount = (infoHeader[14] & 0xFF) | ((infoHeader[15] & 0xFF) << 8);
+	if (height == infoHeight && bitCount == 1) height /= 2;
+	if (!((width == infoWidth) && (height * 2 == infoHeight) &&
+		(bitCount == 1 || bitCount == 4 || bitCount == 8 || bitCount == 24 || bitCount == 32)))
+			SWT.error(SWT.ERROR_INVALID_IMAGE);
+	infoHeader[8] = (byte)(height & 0xFF);
+	infoHeader[9] = (byte)((height >> 8) & 0xFF);
+	infoHeader[10] = (byte)((height >> 16) & 0xFF);
+	infoHeader[11] = (byte)((height >> 24) & 0xFF);
+	return infoHeader;
+}
+/**
+ * Unload a single icon
+ */
+void unloadIcon(ImageData icon) {
+	int sizeImage = (((icon.width * icon.depth + 31) / 32 * 4) +
+		((icon.width + 31) / 32 * 4)) * icon.height;
+	try {
+		outputStream.writeInt(WinBMPFileFormat.BMPHeaderFixedSize);
+		outputStream.writeInt(icon.width);
+		outputStream.writeInt(icon.height * 2);
+		outputStream.writeShort(1);
+		outputStream.writeShort((short)icon.depth);
+		outputStream.writeInt(0);
+		outputStream.writeInt(sizeImage);
+		outputStream.writeInt(0);
+		outputStream.writeInt(0);
+		outputStream.writeInt(icon.palette.colors != null ? icon.palette.colors.length : 0);
+		outputStream.writeInt(0);
+	} catch (IOException e) {
+		SWT.error(SWT.ERROR_IO, e);
+	}
+	
+	byte[] rgbs = WinBMPFileFormat.paletteToBytes(icon.palette);
+	try {
+		outputStream.write(rgbs);
+	} catch (IOException e) {
+		SWT.error(SWT.ERROR_IO, e);
+	}
+	unloadShapeData(icon);
+	unloadMaskData(icon);
+}
+/**
+ * Unload the icon header for the given icon, calculating the offset.
+ */
+void unloadIconHeader(ImageData i) {
+	int headerSize = 16;
+	int offset = headerSize + 6;
+	int iconSize = iconSize(i);
+	try {
+		outputStream.write(i.width);
+		outputStream.write(i.height);
+		outputStream.writeShort(i.palette.colors != null ? i.palette.colors.length : 0);
+		outputStream.writeShort(0);
+		outputStream.writeShort(0);
+		outputStream.writeInt(iconSize);
+		outputStream.writeInt(offset);
+	} catch (IOException e) {
+		SWT.error(SWT.ERROR_IO, e);
+	}
+}
+void unloadIntoByteStream(ImageLoader loader) {
+	/* We do not currently support writing multi-image ico,
+	 * so we use the first image data in the loader's array. */
+	ImageData image = loader.data[0];
+	if (!isValidIcon(image))
+		SWT.error(SWT.ERROR_INVALID_IMAGE);
+	try {
+		outputStream.writeShort(0);
+		outputStream.writeShort(1);
+		outputStream.writeShort(1);
+	} catch (IOException e) {
+		SWT.error(SWT.ERROR_IO, e);
+	}
+	unloadIconHeader(image);
+	unloadIcon(image);
+}
+/**
+ * Unload the mask data for an icon. The data is flipped vertically
+ * and inverted.
+ */
+void unloadMaskData(ImageData icon) {
+	ImageData mask = icon.getTransparencyMask();
+	int bpl = (icon.width + 7) / 8;
+	int pad = mask.scanlinePad;
+	int srcBpl = (bpl + pad - 1) / pad * pad;
+	int destBpl = (bpl + 3) / 4 * 4;
+	byte[] buf = new byte[destBpl];
+	int offset = (icon.height - 1) * srcBpl;
+	byte[] data = mask.data;
+	try {
+		for (int i = 0; i < icon.height; i++) {
+			System.arraycopy(data, offset, buf, 0, bpl);
+			bitInvertData(buf, 0, bpl);
+			outputStream.write(buf, 0, destBpl);
+			offset -= srcBpl;
+		}
+	} catch (IOException e) {
+		SWT.error(SWT.ERROR_IO, e);
+	}
+}
+/**
+ * Unload the shape data for an icon. The data is flipped vertically.
+ */
+void unloadShapeData(ImageData icon) {
+	int bpl = (icon.width * icon.depth + 7) / 8;
+	int pad = icon.scanlinePad;
+	int srcBpl = (bpl + pad - 1) / pad * pad;
+	int destBpl = (bpl + 3) / 4 * 4;
+	byte[] buf = new byte[destBpl];
+	int offset = (icon.height - 1) * srcBpl;
+	byte[] data = icon.data;
+	try {
+		for (int i = 0; i < icon.height; i++) {
+			System.arraycopy(data, offset, buf, 0, bpl);
+			outputStream.write(buf, 0, destBpl);
+			offset -= srcBpl;
+		}
+	} catch (IOException e) {
+		SWT.error(SWT.ERROR_IO, e);
+	}
+}
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/image/WinICOFileFormat.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/GREVersionRange.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/GREVersionRange.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/GREVersionRange.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,19 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.mozilla;
+
+public class GREVersionRange {
+    public int /*long*/ lower;
+    public boolean lowerInclusive;
+    public int /*long*/ upper;
+    public boolean upperInclusive;
+    public static final int sizeof = XPCOMInit.GREVersionRange_sizeof();
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/GREVersionRange.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/XPCOM.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/XPCOM.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/XPCOM.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,306 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by Netscape are Copyright (C) 1998-1999
+ * Netscape Communications Corporation.  All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * -  Binding to permit interfacing between Mozilla and SWT
+ * -  Copyright (C) 2003, 2006 IBM Corp.  All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package org.eclipse.swt.internal.mozilla;
+
+import org.eclipse.swt.internal.*;
+
+public class XPCOM extends C {
+	public static final String MOZILLA_FIVE_HOME = "MOZILLA_FIVE_HOME"; //$NON-NLS-1$
+	public static final String MOZILLA_PLUGIN_PATH = "MOZ_PLUGIN_PATH"; //$NON-NLS-1$
+	public static final String CONTENT_MAYBETEXT = "application/x-vnd.mozilla.maybe-text"; //$NON-NLS-1$
+	public static final String CONTENT_MULTIPART = "multipart/x-mixed-replace"; //$NON-NLS-1$
+	public static final String DOMEVENT_FOCUS = "focus"; //$NON-NLS-1$
+	public static final String DOMEVENT_UNLOAD = "unload"; //$NON-NLS-1$
+	public static final String DOMEVENT_MOUSEDOWN = "mousedown"; //$NON-NLS-1$
+	public static final String DOMEVENT_MOUSEUP = "mouseup"; //$NON-NLS-1$
+	public static final String DOMEVENT_MOUSEMOVE = "mousemove"; //$NON-NLS-1$
+	public static final String DOMEVENT_MOUSEDRAG = "draggesture"; //$NON-NLS-1$
+	public static final String DOMEVENT_MOUSEWHEEL = "DOMMouseScroll"; //$NON-NLS-1$
+	public static final String DOMEVENT_MOUSEOVER = "mouseover"; //$NON-NLS-1$
+	public static final String DOMEVENT_MOUSEOUT = "mouseout"; //$NON-NLS-1$
+	public static final String DOMEVENT_KEYUP = "keyup"; //$NON-NLS-1$
+	public static final String DOMEVENT_KEYDOWN = "keydown"; //$NON-NLS-1$
+	public static final String DOMEVENT_KEYPRESS = "keypress"; //$NON-NLS-1$
+	
+	/* CID constants */
+	public static final nsID NS_APPSHELL_CID =	new nsID("2d96b3df-c051-11d1-a827-0040959a28c9"); //$NON-NLS-1$
+	public static final nsID NS_CATEGORYMANAGER_CID = new nsID("16d222a6-1dd2-11b2-b693-f38b02c021b2"); //$NON-NLS-1$
+	public static final nsID NS_DOWNLOAD_CID = new nsID("e3fa9D0a-1dd1-11b2-bdef-8c720b597445"); //$NON-NLS-1$
+	public static final nsID NS_FILEPICKER_CID = new nsID("54ae32f8-1dd2-11b2-a209-df7c505370f8"); //$NON-NLS-1$
+	public static final nsID NS_HELPERAPPLAUNCHERDIALOG_CID = new nsID("f68578eb-6ec2-4169-ae19-8c6243f0abe1"); //$NON-NLS-1$
+	public static final nsID NS_INPUTSTREAMCHANNEL_CID = new nsID("6ddb050c-0d04-11d4-986e-00c04fa0cf4a"); //$NON-NLS-1$
+	public static final nsID NS_IOSERVICE_CID =	new nsID("9ac9e770-18bc-11d3-9337-00104ba0fd40"); //$NON-NLS-1$
+	public static final nsID NS_LOADGROUP_CID = new nsID("e1c61582-2a84-11d3-8cce-0060b0fc14a3"); //$NON-NLS-1$
+	public static final nsID NS_PROMPTSERVICE_CID = new nsID("a2112d6a-0e28-421f-b46a-25c0b308cbd0"); //$NON-NLS-1$
+
+	public static final String NS_CONTEXTSTACK_CONTRACTID = "@mozilla.org/js/xpc/ContextStack;1"; //$NON-NLS-1$
+	public static final String NS_COOKIEMANAGER_CONTRACTID = "@mozilla.org/cookiemanager;1"; //$NON-NLS-1$
+	public static final String NS_DIRECTORYSERVICE_CONTRACTID = "@mozilla.org/file/directory_service;1"; //$NON-NLS-1$
+	public static final String NS_DOMSERIALIZER_CONTRACTID = "@mozilla.org/xmlextras/xmlserializer;1"; //$NON-NLS-1$
+	public static final String NS_DOWNLOAD_CONTRACTID = "@mozilla.org/download;1"; //$NON-NLS-1$
+	public static final String NS_FILEPICKER_CONTRACTID = "@mozilla.org/filepicker;1"; //$NON-NLS-1$
+	public static final String NS_HELPERAPPLAUNCHERDIALOG_CONTRACTID = "@mozilla.org/helperapplauncherdialog;1"; //$NON-NLS-1$
+	public static final String NS_MEMORY_CONTRACTID = "@mozilla.org/xpcom/memory-service;1"; //$NON-NLS-1$
+	public static final String NS_OBSERVER_CONTRACTID = "@mozilla.org/observer-service;1"; //$NON-NLS-1$
+	public static final String NS_PREFLOCALIZEDSTRING_CONTRACTID = "@mozilla.org/pref-localizedstring;1"; //$NON-NLS-1$
+	public static final String NS_PREFSERVICE_CONTRACTID = "@mozilla.org/preferences-service;1"; //$NON-NLS-1$
+	public static final String NS_PROMPTSERVICE_CONTRACTID = "@mozilla.org/embedcomp/prompt-service;1"; //$NON-NLS-1$
+	public static final String NS_TRANSFER_CONTRACTID = "@mozilla.org/transfer;1"; //$NON-NLS-1$
+	public static final String NS_WEBNAVIGATIONINFO_CONTRACTID = "@mozilla.org/webnavigation-info;1"; //$NON-NLS-1$
+	public static final String NS_WINDOWWATCHER_CONTRACTID = "@mozilla.org/embedcomp/window-watcher;1"; //$NON-NLS-1$
+
+	/* directory service constants */
+	public static final String NS_APP_APPLICATION_REGISTRY_DIR = "AppRegD"; //$NON-NLS-1$
+	public static final String NS_APP_CACHE_PARENT_DIR = "cachePDir"; //$NON-NLS-1$
+	public static final String NS_APP_HISTORY_50_FILE = "UHist"; //$NON-NLS-1$
+	public static final String NS_APP_LOCALSTORE_50_FILE = "LclSt"; //$NON-NLS-1$
+	public static final String NS_APP_PLUGINS_DIR_LIST = "APluginsDL"; //$NON-NLS-1$
+	public static final String NS_APP_PREF_DEFAULTS_50_DIR = "PrfDef"; //$NON-NLS-1$
+	public static final String NS_APP_PREFS_50_DIR = "PrefD"; //$NON-NLS-1$
+	public static final String NS_APP_PREFS_50_FILE = "PrefF"; //$NON-NLS-1$
+	public static final String NS_APP_USER_CHROME_DIR = "UChrm"; //$NON-NLS-1$
+	public static final String NS_APP_USER_MIMETYPES_50_FILE = "UMimTyp"; //$NON-NLS-1$
+	public static final String NS_APP_USER_PROFILE_50_DIR = "ProfD"; //$NON-NLS-1$
+	public static final String NS_GRE_COMPONENT_DIR = "GreComsD"; //$NON-NLS-1$
+	public static final String NS_GRE_DIR = "GreD"; //$NON-NLS-1$
+	public static final String NS_OS_CURRENT_PROCESS_DIR = "CurProcD"; //$NON-NLS-1$
+	public static final String NS_OS_HOME_DIR = "Home"; //$NON-NLS-1$
+	public static final String NS_OS_TEMP_DIR = "TmpD"; //$NON-NLS-1$
+	public static final String NS_XPCOM_COMPONENT_DIR = "ComsD"; //$NON-NLS-1$
+	public static final String NS_XPCOM_CURRENT_PROCESS_DIR = "XCurProcD"; //$NON-NLS-1$
+	public static final String NS_XPCOM_INIT_CURRENT_PROCESS_DIR = "MozBinD"; //$NON-NLS-1$
+
+	/* XPCOM constants */
+	public static final int NS_OK =  0;
+	public static final int NS_COMFALSE = 1;
+	public static final int NS_BINDING_ABORTED = 0x804B0002;
+	public static final int NS_ERROR_BASE = 0xc1f30000;
+	public static final int NS_ERROR_NOT_INITIALIZED =  NS_ERROR_BASE + 1;
+	public static final int NS_ERROR_ALREADY_INITIALIZED = NS_ERROR_BASE + 2;
+	public static final int NS_ERROR_NOT_IMPLEMENTED =  0x80004001;
+	public static final int NS_NOINTERFACE =  0x80004002;
+	public static final int NS_ERROR_NO_INTERFACE =  NS_NOINTERFACE;
+	public static final int NS_ERROR_INVALID_POINTER =  0x80004003;
+	public static final int NS_ERROR_NULL_POINTER = NS_ERROR_INVALID_POINTER;
+	public static final int NS_ERROR_ABORT = 0x80004004;
+	public static final int NS_ERROR_FAILURE = 0x80004005;
+	public static final int NS_ERROR_UNEXPECTED = 0x8000ffff;
+	public static final int NS_ERROR_OUT_OF_MEMORY = 0x8007000e;
+	public static final int NS_ERROR_ILLEGAL_VALUE = 0x80070057;
+	public static final int NS_ERROR_INVALID_ARG = NS_ERROR_ILLEGAL_VALUE;
+	public static final int NS_ERROR_NO_AGGREGATION = 0x80040110;
+	public static final int NS_ERROR_NOT_AVAILABLE = 0x80040111;
+	public static final int NS_ERROR_FACTORY_NOT_REGISTERED = 0x80040154;
+	public static final int NS_ERROR_FACTORY_REGISTER_AGAIN = 0x80040155;
+	public static final int NS_ERROR_FACTORY_NOT_LOADED = 0x800401f8;
+	public static final int NS_ERROR_FACTORY_NO_SIGNATURE_SUPPORT = NS_ERROR_BASE + 0x101;
+	public static final int NS_ERROR_FACTORY_EXISTS = NS_ERROR_BASE + 0x100;
+	public static final int NS_ERROR_HTMLPARSER_UNRESOLVEDDTD = 0x804e03f3;
+	public static final int NS_ERROR_FILE_NOT_FOUND = 0x80520012;
+	public static final int NS_ERROR_FILE_UNRECOGNIZED_PATH = 0x80520001;
+
+public static final native void memmove(nsID dest, int /*long*/ src, int nbytes);
+public static final native void memmove(int /*long*/ dest, nsID src, int nbytes);
+public static final native int NS_GetComponentManager(int /*long*/[] result);
+public static final native int NS_GetServiceManager(int /*long*/[] result);
+public static final native int NS_InitXPCOM2(int /*long*/ result, int /*long*/ binDirectory, int /*long*/ appFileLocationProvider);
+public static final native int NS_NewLocalFile(int /*long*/ path, int followLinks, int /*long*/[] result);
+public static final native int strlen_PRUnichar(int /*long*/ s);
+public static final native int /*long*/ nsEmbedCString_new();
+public static final native int /*long*/ nsEmbedCString_new(byte[] aString, int length);
+public static final native int /*long*/ nsEmbedCString_new(int aString, int length);
+public static final native void nsEmbedCString_delete(int /*long*/ ptr);
+public static final native int nsEmbedCString_Length(int /*long*/ ptr);
+public static final native int /*long*/ nsEmbedCString_get(int /*long*/ ptr);
+public static final native void nsID_delete(int /*long*/ ptr);
+public static final native int /*long*/ nsID_new();
+public static final native int nsID_Equals(int /*long*/ ptr, int /*long*/ other);
+public static final native int /*long*/ nsEmbedString_new();
+public static final native int /*long*/ nsEmbedString_new(char[] aString);
+public static final native void nsEmbedString_delete(int /*long*/ ptr);
+public static final native int nsEmbedString_Length(int /*long*/ ptr);
+public static final native int /*long*/ nsEmbedString_get(int /*long*/ ptr);
+public static final native int XPCOMGlueStartup(byte[] place);
+public static final native int XPCOMGlueShutdown();
+
+public static final native int /*long*/ Call(int /*long*/ ptr, int /*long*/ aInStream, int /*long*/ aClosure, byte[] aFromSegment, int aToOffset, int aCount, int[] aWriteCount);
+
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, byte[] arg0);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, char[] arg0);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, float arg0);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, float[] arg0);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, int arg0);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, int[] arg0);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, long arg0);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, long[] arg0);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, short[] arg0);
+
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, int arg0, int arg1);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, long arg0, int arg1);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, long arg0, long arg1);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, int arg0, int[] arg1);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, long arg0, long [] arg1);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, long arg0, int[] arg1);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, byte[] arg0, int[] arg1);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, byte[] arg0, long[] arg1);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, byte[] arg0, long arg1);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, byte[] arg0, int arg1);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, int arg0, nsID arg1);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, long arg0, nsID arg1);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, int arg0, char[] arg1);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, int[] arg0, int[] arg1);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, int[] arg0, long[] arg1);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, nsID arg0, int arg1);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, nsID arg0, long arg1);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, nsID arg0, int[] arg1);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, nsID arg0, long[] arg1);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, char[] arg0, char[] arg1);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, byte[] arg0, byte[] arg1);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, int arg0, byte[] arg1);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, long arg0, byte[] arg1);
+
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, int arg0, char[] arg1, int arg2);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, long arg0, char[] arg1, int arg2);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, int[] arg0, int[] arg1, int[] arg2);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, long [] arg0, long [] arg1, long [] arg2);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, int[] arg0, long[] arg1, int[] arg2);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, int[] arg0, long[] arg1, long [] arg2);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, byte[] arg0, int arg1, int[] arg2);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, byte[] arg0, nsID arg1, long [] arg2);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, byte[] arg0, nsID arg1, int[] arg2);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, char[] arg0, int arg1, int[] arg2);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, char[] arg0, long arg1, long [] arg2);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, int arg0, char[] arg1, char[] arg2);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, long arg0, char[] arg1, char[] arg2);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, long arg0, long arg1, long arg2);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, long arg0, long arg1, int arg2);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, int arg0, long arg1, long arg2);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, int arg0, int arg1, int arg2);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, int arg0, int arg1, long[] arg2);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, int arg0, int arg1, int[] arg2);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, long arg0, int arg1, long [] arg2);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, long arg0, long arg1, int[] arg2);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, int arg0, nsID arg1, int[] arg2);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, long arg0, nsID arg1, long [] arg2);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, int arg0, int arg1, char[] arg2);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, nsID arg0, nsID arg1, long[] arg2);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, nsID arg0, nsID arg1, int[] arg2);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, byte[] arg0, byte[] arg1, int[] arg2);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, byte[] arg0, byte[] arg1, long[] arg2);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, byte[] arg0, int[] arg1, int[] arg2);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, byte[] arg0, int[] arg1, long[] arg2);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, byte[] arg0, long[] arg1, int[] arg2);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, byte[] arg0, nsID arg1, int arg2);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, byte[] arg0, nsID arg1, long arg2);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, int arg0, byte[] arg1, char[] arg2);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, long arg0, byte[] arg1, char[] arg2);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, int arg0, int arg1, byte[] arg2);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, long arg0, long arg1, byte[] arg2);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, byte[] arg0, byte[] arg1, int arg2);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, int arg0, byte[] arg1, int[] arg2);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, int arg0, byte[] arg1, int arg2);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, long arg0, byte[] arg1, int arg2);
+
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, byte[] arg0, int arg1, nsID arg2, int[] arg3);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, byte[] arg0, long arg1, nsID arg2, long[] arg3);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, int arg0, byte[] arg1, int arg2, int[] arg3);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, long arg0, byte[] arg1, long arg2, long[] arg3);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, int arg0, char[] arg1, char[] arg2, int[] arg3);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, long arg0, char[] arg1, char[] arg2, long [] arg3);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, long arg0, char[] arg1, char[] arg2, int[] arg3);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, int arg0, int arg1, int arg2, char[] arg3);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, long arg0, long arg1, int arg2, char[] arg3);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, int arg0, int arg1, int arg2, int arg3);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, long arg0, long arg1, int arg2, int arg3);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, long arg0, long arg1, long arg2, int arg3);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, int arg0, int arg1, int arg2, int[] arg3);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, long arg0, long arg1, int arg2, int[] arg3);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, int[] arg0, int[] arg1, int[] arg2, int[] arg3);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, nsID arg0, byte[] arg1, byte[] arg2, int arg3);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, nsID arg0, byte[] arg1, byte[] arg2, long arg3);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, nsID arg0, int arg1, nsID arg2, int[] arg3);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, nsID arg0, long arg1, nsID arg2, long [] arg3);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, byte[] arg0, int arg1, int[] arg2, int[] arg3);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, byte[] arg0, int arg1, long [] arg2, int[] arg3);
+
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, char[] arg0, int arg1, int arg2, int arg3, int arg4);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, char[] arg0, int arg1, long arg2, long arg3, long arg4);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, long arg0, long arg1, long arg2, long arg3, long arg4);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, int arg0, int arg1, int arg2, int arg3, int arg4);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, int arg0, int[] arg1, int[] arg2, int[] arg3, int[] arg4);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, int arg0, char[] arg1, char[] arg2, char[] arg3, int[] arg4);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, long arg0, char[] arg1, char[] arg2, char[] arg3, int[] arg4);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, byte[] arg0, int arg1, int arg2, int[] arg3, int[] arg4);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, byte[] arg0, int arg1, long arg2, long [] arg3, int[] arg4);
+
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, int arg0, byte[] arg1, byte[] arg2, byte[] arg3, int arg4, int[] arg5);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, long arg0, byte[] arg1, byte[] arg2, byte[] arg3, long arg4, long [] arg5);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, int arg0, int arg1, char[] arg2, int arg3, long arg4, int arg5);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, long arg0, long arg1, char[] arg2, int arg3, long arg4, int arg5);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, int arg0, int arg1, char[] arg2, long arg3, long arg4, long arg5);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, long arg0, long arg1, char[] arg2, long arg3, long arg4, long arg5);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, int arg0, int arg1, int arg2, int arg3, int arg4, int arg5);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, long arg0, long arg1, int arg2, int arg3, int arg4, int arg5);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, nsID arg0, byte[] arg1, byte[] arg2, int arg3, byte[] arg4, byte[] arg5);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, nsID arg0, byte[] arg1, byte[] arg2, long arg3, byte[] arg4, byte[] arg5);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, int arg0, int arg1, long arg2, long arg3, long arg4, long arg5);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, long arg0, long arg1, long arg2, long arg3, long arg4, long arg5);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, int arg0, char[] arg1, char[] arg2, char[] arg3, int[] arg4, int[] arg5);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, long arg0, char[] arg1, char[] arg2, char[] arg3, int[] arg4, int[] arg5);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, byte[] arg0, byte[] arg1, byte[] arg2, int arg3, int arg4, int[] arg5);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, byte[] arg0, byte[] arg1, byte[] arg2, int arg3, int arg4, long[] arg5);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, int arg0, int arg1, int arg2, int arg3, int[] arg4, int[] arg5);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, long arg0, int arg1, int arg2, long arg3, int[] arg4, long [] arg5);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, int arg0, int arg1, char[] arg2, char[] arg3, int arg4, int [] arg5);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, long arg0, long arg1, char[] arg2, char[] arg3, int arg4, long[] arg5);
+
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, int arg0, char[] arg1, char[] arg2, int arg3, int[] arg4, int[] arg5, int[] arg6);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, long arg0, char[] arg1, char[] arg2, int arg3, long[] arg4, int[] arg5, int[] arg6);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, int arg0, char[] arg1, char[] arg2, int[] arg3, char[] arg4, int[] arg5, int[] arg6);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, long arg0, char[] arg1, char[] arg2, long[] arg3, char[] arg4, int[] arg5, int[] arg6);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, int arg0, int arg1, int arg2, int arg3, char[] arg4, int[] arg5, int[] arg6);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, long arg0, long arg1, int arg2, long arg3, char[] arg4, int[] arg5, int[] arg6);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, int arg0, int arg1, int arg2, int arg3, long arg4, int arg5, int arg6);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, long arg0, long arg1, long arg2, long arg3, long arg4, long arg5, long arg6);
+
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, int arg0, char[] arg1, char[] arg2, int[] arg3, int[] arg4, char[] arg5, int[] arg6, int[] arg7);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, long arg0, char[] arg1, char[] arg2, long[] arg3, long [] arg4, char[] arg5, int[] arg6, int[] arg7);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, int arg0, int arg1, int arg2, int arg3, int arg4, int arg5, char[] arg6, int[] arg7, int[] arg8);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, long arg0, long arg1, long arg2, long arg3, int arg4, long arg5, char[] arg6, int[] arg7, long [] arg8);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, int arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, int arg8, int arg9);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, long arg0, int arg1, int arg2, long arg3, int arg4, int arg5, int arg6, int arg7, int arg8, int arg9);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, int arg0, char[] arg1, char[] arg2, int arg3, char[] arg4, char[] arg5, char[] arg6, char[] arg7, int[] arg8, int[] arg9);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, long arg0, char[] arg1, char[] arg2, int arg3, char[] arg4, char[] arg5, char[] arg6, char[] arg7, int[] arg8, int[] arg9);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, int arg0, int arg1, int arg2, int arg3, char[] arg4, int arg5, int arg6, int arg7, int arg8, int arg9, int[] arg10, int[] arg11);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, long arg0, long arg1, long arg2, int arg3, char[] arg4, long arg5, long arg6, int arg7, long arg8, int arg9, long [] arg10, long [] arg11);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, int arg0, int arg1, int arg2, int arg3, char[] arg4, byte[] arg5, int arg6, int arg7, int arg8, int arg9, int arg10, int[] arg11, int[] arg12);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, long arg0, long arg1, long arg2, int arg3, char[] arg4, byte[] arg5, long arg6, long arg7, int arg8, long arg9, int arg10, long [] arg11, long [] arg12);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, int arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, int arg8, int arg9, int arg10, int arg11, int arg12, short arg13, int arg14);
+static final native int VtblCall(int fnNumber, int /*long*/ ppVtbl, long arg0, int arg1, int arg2, long arg3, int arg4, int arg5, int arg6, int arg7, int arg8, int arg9, int arg10, int arg11, int arg12, short arg13, long arg14);
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/XPCOM.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/XPCOMInit.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/XPCOMInit.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/XPCOMInit.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,39 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by Netscape are Copyright (C) 1998-1999
+ * Netscape Communications Corporation.  All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * -  Binding to permit interfacing between Mozilla and SWT
+ * -  Copyright (C) 2003, 2006 IBM Corp.  All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package org.eclipse.swt.internal.mozilla;
+
+import org.eclipse.swt.internal.Platform;
+
+public class XPCOMInit extends Platform {
+	public static final int PATH_MAX = 4096;
+	
+public static final native int GREVersionRange_sizeof ();
+public static final native int GRE_GetGREPathWithProperties (GREVersionRange versions, int versionsLength, int /*long*/ properties, int propertiesLength, int /*long*/ buffer, int buflen);
+public static final native int XPCOMGlueStartup (byte[] place);
+public static final native int XPCOMGlueShutdown ();
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/XPCOMInit.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/XPCOMObject.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/XPCOMObject.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/XPCOMObject.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,1024 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.mozilla;
+
+import java.util.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.*;
+
+public class XPCOMObject {
+
+	private int /*long*/ ppVtable;
+	
+	static private final int MAX_ARG_COUNT = 12;
+	static private final int MAX_VTABLE_LENGTH = 80;
+	static private Callback[][] Callbacks = new Callback[MAX_VTABLE_LENGTH][MAX_ARG_COUNT];
+	static private Hashtable ObjectMap = new Hashtable ();
+	
+public XPCOMObject (int[] argCounts) {
+	int /*long*/[] callbackAddresses = new int /*long*/[argCounts.length];
+	synchronized (Callbacks) {
+		for (int i = 0, length = argCounts.length; i < length; i++){
+			if ((Callbacks[i][argCounts[i]]) == null) {
+				Callbacks[i][argCounts[i]] = new Callback (getClass (), "callback"+i, argCounts[i] + 1, true, XPCOM.NS_ERROR_FAILURE); //$NON-NLS-1$
+			}
+			callbackAddresses[i] = Callbacks[i][argCounts[i]].getAddress ();
+			if (callbackAddresses[i] == 0) SWT.error (SWT.ERROR_NO_MORE_CALLBACKS);
+		}
+	}
+
+	int /*long*/ pVtable = C.malloc (C.PTR_SIZEOF * argCounts.length);
+	XPCOM.memmove (pVtable, callbackAddresses, C.PTR_SIZEOF * argCounts.length);
+	ppVtable = C.malloc (C.PTR_SIZEOF);
+	XPCOM.memmove (ppVtable, new int /*long*/[] {pVtable}, C.PTR_SIZEOF);
+	ObjectMap.put (new LONG (ppVtable), this);
+}
+	
+static int /*long*/ callback0 (int /*long*/[] callbackArgs) {
+	// find the object on which this call was invoked
+	int /*long*/ address = callbackArgs[0];
+	Object object = ObjectMap.get (new LONG (address));
+	if (object == null) return XPCOM.NS_ERROR_FAILURE;
+	int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
+	System.arraycopy (callbackArgs, 1, args, 0, args.length);
+	return ((XPCOMObject) object).method0 (args);
+}
+static int /*long*/ callback1 (int /*long*/[] callbackArgs) {
+	// find the object on which this call was invoked
+	int /*long*/ address = callbackArgs[0];
+	Object object = ObjectMap.get (new LONG (address));
+	if (object == null) return XPCOM.NS_ERROR_FAILURE;
+	int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
+	System.arraycopy (callbackArgs, 1, args, 0, args.length);
+	return ((XPCOMObject) object).method1 (args);
+}
+static int /*long*/ callback10 (int /*long*/[] callbackArgs) {
+	// find the object on which this call was invoked
+	int /*long*/ address = callbackArgs[0];
+	Object object = ObjectMap.get (new LONG (address));
+	if (object == null) return XPCOM.NS_ERROR_FAILURE;
+	int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
+	System.arraycopy (callbackArgs, 1, args, 0, args.length);
+	return ((XPCOMObject) object).method10 (args);
+}
+static int /*long*/ callback11 (int /*long*/[] callbackArgs) {
+	// find the object on which this call was invoked
+	int /*long*/ address = callbackArgs[0];
+	Object object = ObjectMap.get (new LONG (address));
+	if (object == null) return XPCOM.NS_ERROR_FAILURE;
+	int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
+	System.arraycopy (callbackArgs, 1, args, 0, args.length);
+	return ((XPCOMObject) object).method11 (args);
+}
+static int /*long*/ callback12 (int /*long*/[] callbackArgs) {
+	// find the object on which this call was invoked
+	int /*long*/ address = callbackArgs[0];
+	Object object = ObjectMap.get (new LONG (address));
+	if (object == null) return XPCOM.NS_ERROR_FAILURE;
+	int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
+	System.arraycopy (callbackArgs, 1, args, 0, args.length);
+	return ((XPCOMObject) object).method12 (args);
+}
+static int /*long*/ callback13 (int /*long*/[] callbackArgs) {
+	// find the object on which this call was invoked
+	int /*long*/ address = callbackArgs[0];
+	Object object = ObjectMap.get (new LONG (address));
+	if (object == null) return XPCOM.NS_ERROR_FAILURE;
+	int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
+	System.arraycopy (callbackArgs, 1, args, 0, args.length);
+	return ((XPCOMObject) object).method13 (args);
+}
+static int /*long*/ callback14 (int /*long*/[] callbackArgs) {
+	// find the object on which this call was invoked
+	int /*long*/ address = callbackArgs[0];
+	Object object = ObjectMap.get (new LONG (address));
+	if (object == null) return XPCOM.NS_ERROR_FAILURE;
+	int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
+	System.arraycopy (callbackArgs, 1, args, 0, args.length);
+	return ((XPCOMObject) object).method14 (args);
+}
+static int /*long*/ callback15 (int /*long*/[] callbackArgs) {
+	// find the object on which this call was invoked
+	int /*long*/ address = callbackArgs[0];
+	Object object = ObjectMap.get (new LONG (address));
+	if (object == null) return XPCOM.NS_ERROR_FAILURE;
+	int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
+	System.arraycopy (callbackArgs, 1, args, 0, args.length);
+	return ((XPCOMObject) object).method15 (args);
+}
+static int /*long*/ callback16 (int /*long*/[] callbackArgs) {
+	// find the object on which this call was invoked
+	int /*long*/ address = callbackArgs[0];
+	Object object = ObjectMap.get (new LONG (address));
+	if (object == null) return XPCOM.NS_ERROR_FAILURE;
+	int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
+	System.arraycopy (callbackArgs, 1, args, 0, args.length);
+	return ((XPCOMObject) object).method16 (args);
+}
+static int /*long*/ callback17 (int /*long*/[] callbackArgs) {
+	// find the object on which this call was invoked
+	int /*long*/ address = callbackArgs[0];
+	Object object = ObjectMap.get (new LONG (address));
+	if (object == null) return XPCOM.NS_ERROR_FAILURE;
+	int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
+	System.arraycopy (callbackArgs, 1, args, 0, args.length);
+	return ((XPCOMObject) object).method17 (args);
+}
+static int /*long*/ callback18 (int /*long*/[] callbackArgs) {
+	// find the object on which this call was invoked
+	int /*long*/ address = callbackArgs[0];
+	Object object = ObjectMap.get (new LONG (address));
+	if (object == null) return XPCOM.NS_ERROR_FAILURE;
+	int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
+	System.arraycopy (callbackArgs, 1, args, 0, args.length);
+	return ((XPCOMObject) object).method18 (args);
+}
+static int /*long*/ callback19 (int /*long*/[] callbackArgs) {
+	// find the object on which this call was invoked
+	int /*long*/ address = callbackArgs[0];
+	Object object = ObjectMap.get (new LONG (address));
+	if (object == null) return XPCOM.NS_ERROR_FAILURE;
+	int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
+	System.arraycopy (callbackArgs, 1, args, 0, args.length);
+	return ((XPCOMObject) object).method19 (args);
+}
+static int /*long*/ callback2 (int /*long*/[] callbackArgs) {
+	// find the object on which this call was invoked
+	int /*long*/ address = callbackArgs[0];
+	Object object = ObjectMap.get (new LONG (address));
+	if (object == null) return XPCOM.NS_ERROR_FAILURE;
+	int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
+	System.arraycopy (callbackArgs, 1, args, 0, args.length);
+	return ((XPCOMObject) object).method2 (args);
+}
+static int /*long*/ callback20 (int /*long*/[] callbackArgs) {
+	// find the object on which this call was invoked
+	int /*long*/ address = callbackArgs[0];
+	Object object = ObjectMap.get (new LONG (address));
+	if (object == null) return XPCOM.NS_ERROR_FAILURE;
+	int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
+	System.arraycopy (callbackArgs, 1, args, 0, args.length);
+	return ((XPCOMObject) object).method20 (args);
+}
+static int /*long*/ callback21 (int /*long*/[] callbackArgs) {
+	// find the object on which this call was invoked
+	int /*long*/ address = callbackArgs[0];
+	Object object = ObjectMap.get (new LONG (address));
+	if (object == null) return XPCOM.NS_ERROR_FAILURE;
+	int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
+	System.arraycopy (callbackArgs, 1, args, 0, args.length);
+	return ((XPCOMObject) object).method21 (args);
+}
+static int /*long*/ callback22 (int /*long*/[] callbackArgs) {
+	// find the object on which this call was invoked
+	int /*long*/ address = callbackArgs[0];
+	Object object = ObjectMap.get (new LONG (address));
+	if (object == null) return XPCOM.NS_ERROR_FAILURE;
+	int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
+	System.arraycopy (callbackArgs, 1, args, 0, args.length);
+	return ((XPCOMObject) object).method22 (args);
+}
+static int /*long*/ callback23 (int /*long*/[] callbackArgs) {
+	// find the object on which this call was invoked
+	int /*long*/ address = callbackArgs[0];
+	Object object = ObjectMap.get (new LONG (address));
+	if (object == null) return XPCOM.NS_ERROR_FAILURE;
+	int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
+	System.arraycopy (callbackArgs, 1, args, 0, args.length);
+	return ((XPCOMObject) object).method23 (args);
+}
+static int /*long*/ callback24 (int /*long*/[] callbackArgs) {
+	// find the object on which this call was invoked
+	int /*long*/ address = callbackArgs[0];
+	Object object = ObjectMap.get (new LONG (address));
+	if (object == null) return XPCOM.NS_ERROR_FAILURE;
+	int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
+	System.arraycopy (callbackArgs, 1, args, 0, args.length);
+	return ((XPCOMObject) object).method24 (args);
+}
+static int /*long*/ callback25 (int /*long*/[] callbackArgs) {
+	// find the object on which this call was invoked
+	int /*long*/ address = callbackArgs[0];
+	Object object = ObjectMap.get (new LONG (address));
+	if (object == null) return XPCOM.NS_ERROR_FAILURE;
+	int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
+	System.arraycopy (callbackArgs, 1, args, 0, args.length);
+	return ((XPCOMObject) object).method25 (args);
+}
+static int /*long*/ callback26 (int /*long*/[] callbackArgs) {
+	// find the object on which this call was invoked
+	int /*long*/ address = callbackArgs[0];
+	Object object = ObjectMap.get (new LONG (address));
+	if (object == null) return XPCOM.NS_ERROR_FAILURE;
+	int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
+	System.arraycopy (callbackArgs, 1, args, 0, args.length);
+	return ((XPCOMObject) object).method26 (args);
+}
+static int /*long*/ callback27 (int /*long*/[] callbackArgs) {
+	// find the object on which this call was invoked
+	int /*long*/ address = callbackArgs[0];
+	Object object = ObjectMap.get (new LONG (address));
+	if (object == null) return XPCOM.NS_ERROR_FAILURE;
+	int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
+	System.arraycopy (callbackArgs, 1, args, 0, args.length);
+	return ((XPCOMObject) object).method27 (args);
+}
+static int /*long*/ callback28 (int /*long*/[] callbackArgs) {
+	// find the object on which this call was invoked
+	int /*long*/ address = callbackArgs[0];
+	Object object = ObjectMap.get (new LONG (address));
+	if (object == null) return XPCOM.NS_ERROR_FAILURE;
+	int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
+	System.arraycopy (callbackArgs, 1, args, 0, args.length);
+	return ((XPCOMObject) object).method28 (args);
+}
+static int /*long*/ callback29 (int /*long*/[] callbackArgs) {
+	// find the object on which this call was invoked
+	int /*long*/ address = callbackArgs[0];
+	Object object = ObjectMap.get (new LONG (address));
+	if (object == null) return XPCOM.NS_ERROR_FAILURE;
+	int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
+	System.arraycopy (callbackArgs, 1, args, 0, args.length);
+	return ((XPCOMObject) object).method29 (args);
+}
+static int /*long*/ callback3 (int /*long*/[] callbackArgs) {
+	// find the object on which this call was invoked
+	int /*long*/ address = callbackArgs[0];
+	Object object = ObjectMap.get (new LONG (address));
+	if (object == null) return XPCOM.NS_ERROR_FAILURE;
+	int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
+	System.arraycopy (callbackArgs, 1, args, 0, args.length);
+	return ((XPCOMObject) object).method3 (args);
+}
+static int /*long*/ callback30 (int /*long*/[] callbackArgs) {
+	// find the object on which this call was invoked
+	int /*long*/ address = callbackArgs[0];
+	Object object = ObjectMap.get (new LONG (address));
+	if (object == null) return XPCOM.NS_ERROR_FAILURE;
+	int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
+	System.arraycopy (callbackArgs, 1, args, 0, args.length);
+	return ((XPCOMObject) object).method30 (args);
+}
+static int /*long*/ callback31 (int /*long*/[] callbackArgs) {
+	// find the object on which this call was invoked
+	int /*long*/ address = callbackArgs[0];
+	Object object = ObjectMap.get (new LONG (address));
+	if (object == null) return XPCOM.NS_ERROR_FAILURE;
+	int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
+	System.arraycopy (callbackArgs, 1, args, 0, args.length);
+	return ((XPCOMObject) object).method31 (args);
+}
+static int /*long*/ callback32 (int /*long*/[] callbackArgs) {
+	// find the object on which this call was invoked
+	int /*long*/ address = callbackArgs[0];
+	Object object = ObjectMap.get (new LONG (address));
+	if (object == null) return XPCOM.NS_ERROR_FAILURE;
+	int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
+	System.arraycopy (callbackArgs, 1, args, 0, args.length);
+	return ((XPCOMObject) object).method32 (args);
+}
+static int /*long*/ callback33 (int /*long*/[] callbackArgs) {
+	// find the object on which this call was invoked
+	int /*long*/ address = callbackArgs[0];
+	Object object = ObjectMap.get (new LONG (address));
+	if (object == null) return XPCOM.NS_ERROR_FAILURE;
+	int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
+	System.arraycopy (callbackArgs, 1, args, 0, args.length);
+	return ((XPCOMObject) object).method33 (args);
+}
+static int /*long*/ callback34 (int /*long*/[] callbackArgs) {
+	// find the object on which this call was invoked
+	int /*long*/ address = callbackArgs[0];
+	Object object = ObjectMap.get (new LONG (address));
+	if (object == null) return XPCOM.NS_ERROR_FAILURE;
+	int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
+	System.arraycopy (callbackArgs, 1, args, 0, args.length);
+	return ((XPCOMObject) object).method34 (args);
+}
+static int /*long*/ callback35 (int /*long*/[] callbackArgs) {
+	// find the object on which this call was invoked
+	int /*long*/ address = callbackArgs[0];
+	Object object = ObjectMap.get (new LONG (address));
+	if (object == null) return XPCOM.NS_ERROR_FAILURE;
+	int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
+	System.arraycopy (callbackArgs, 1, args, 0, args.length);
+	return ((XPCOMObject) object).method35 (args);
+}
+static int /*long*/ callback36 (int /*long*/[] callbackArgs) {
+	// find the object on which this call was invoked
+	int /*long*/ address = callbackArgs[0];
+	Object object = ObjectMap.get (new LONG (address));
+	if (object == null) return XPCOM.NS_ERROR_FAILURE;
+	int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
+	System.arraycopy (callbackArgs, 1, args, 0, args.length);
+	return ((XPCOMObject) object).method36 (args);
+}
+static int /*long*/ callback37 (int /*long*/[] callbackArgs) {
+	// find the object on which this call was invoked
+	int /*long*/ address = callbackArgs[0];
+	Object object = ObjectMap.get (new LONG (address));
+	if (object == null) return XPCOM.NS_ERROR_FAILURE;
+	int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
+	System.arraycopy (callbackArgs, 1, args, 0, args.length);
+	return ((XPCOMObject) object).method37 (args);
+}
+static int /*long*/ callback38 (int /*long*/[] callbackArgs) {
+	// find the object on which this call was invoked
+	int /*long*/ address = callbackArgs[0];
+	Object object = ObjectMap.get (new LONG (address));
+	if (object == null) return XPCOM.NS_ERROR_FAILURE;
+	int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
+	System.arraycopy (callbackArgs, 1, args, 0, args.length);
+	return ((XPCOMObject) object).method38 (args);
+}
+static int /*long*/ callback39 (int /*long*/[] callbackArgs) {
+	// find the object on which this call was invoked
+	int /*long*/ address = callbackArgs[0];
+	Object object = ObjectMap.get (new LONG (address));
+	if (object == null) return XPCOM.NS_ERROR_FAILURE;
+	int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
+	System.arraycopy (callbackArgs, 1, args, 0, args.length);
+	return ((XPCOMObject) object).method39 (args);
+}
+static int /*long*/ callback4 (int /*long*/[] callbackArgs) {
+	// find the object on which this call was invoked
+	int /*long*/ address = callbackArgs[0];
+	Object object = ObjectMap.get (new LONG (address));
+	if (object == null) return XPCOM.NS_ERROR_FAILURE;
+	int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
+	System.arraycopy (callbackArgs, 1, args, 0, args.length);
+	return ((XPCOMObject) object).method4 (args);
+}
+static int /*long*/ callback40 (int /*long*/[] callbackArgs) {
+	// find the object on which this call was invoked
+	int /*long*/ address = callbackArgs[0];
+	Object object = ObjectMap.get (new LONG (address));
+	if (object == null) return XPCOM.NS_ERROR_FAILURE;
+	int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
+	System.arraycopy (callbackArgs, 1, args, 0, args.length);
+	return ((XPCOMObject) object).method40 (args);
+}
+static int /*long*/ callback41 (int /*long*/[] callbackArgs) {
+	// find the object on which this call was invoked
+	int /*long*/ address = callbackArgs[0];
+	Object object = ObjectMap.get (new LONG (address));
+	if (object == null) return XPCOM.NS_ERROR_FAILURE;
+	int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
+	System.arraycopy (callbackArgs, 1, args, 0, args.length);
+	return ((XPCOMObject) object).method41 (args);
+}
+static int /*long*/ callback42 (int /*long*/[] callbackArgs) {
+	// find the object on which this call was invoked
+	int /*long*/ address = callbackArgs[0];
+	Object object = ObjectMap.get (new LONG (address));
+	if (object == null) return XPCOM.NS_ERROR_FAILURE;
+	int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
+	System.arraycopy (callbackArgs, 1, args, 0, args.length);
+	return ((XPCOMObject) object).method42 (args);
+}
+static int /*long*/ callback43 (int /*long*/[] callbackArgs) {
+	// find the object on which this call was invoked
+	int /*long*/ address = callbackArgs[0];
+	Object object = ObjectMap.get (new LONG (address));
+	if (object == null) return XPCOM.NS_ERROR_FAILURE;
+	int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
+	System.arraycopy (callbackArgs, 1, args, 0, args.length);
+	return ((XPCOMObject) object).method43 (args);
+}
+static int /*long*/ callback44 (int /*long*/[] callbackArgs) {
+	// find the object on which this call was invoked
+	int /*long*/ address = callbackArgs[0];
+	Object object = ObjectMap.get (new LONG (address));
+	if (object == null) return XPCOM.NS_ERROR_FAILURE;
+	int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
+	System.arraycopy (callbackArgs, 1, args, 0, args.length);
+	return ((XPCOMObject) object).method44 (args);
+}
+static int /*long*/ callback45 (int /*long*/[] callbackArgs) {
+	// find the object on which this call was invoked
+	int /*long*/ address = callbackArgs[0];
+	Object object = ObjectMap.get (new LONG (address));
+	if (object == null) return XPCOM.NS_ERROR_FAILURE;
+	int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
+	System.arraycopy (callbackArgs, 1, args, 0, args.length);
+	return ((XPCOMObject) object).method45 (args);
+}
+static int /*long*/ callback46 (int /*long*/[] callbackArgs) {
+	// find the object on which this call was invoked
+	int /*long*/ address = callbackArgs[0];
+	Object object = ObjectMap.get (new LONG (address));
+	if (object == null) return XPCOM.NS_ERROR_FAILURE;
+	int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
+	System.arraycopy (callbackArgs, 1, args, 0, args.length);
+	return ((XPCOMObject) object).method46 (args);
+}
+static int /*long*/ callback47 (int /*long*/[] callbackArgs) {
+	// find the object on which this call was invoked
+	int /*long*/ address = callbackArgs[0];
+	Object object = ObjectMap.get (new LONG (address));
+	if (object == null) return XPCOM.NS_ERROR_FAILURE;
+	int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
+	System.arraycopy (callbackArgs, 1, args, 0, args.length);
+	return ((XPCOMObject) object).method47 (args);
+}
+static int /*long*/ callback48 (int /*long*/[] callbackArgs) {
+	// find the object on which this call was invoked
+	int /*long*/ address = callbackArgs[0];
+	Object object = ObjectMap.get (new LONG (address));
+	if (object == null) return XPCOM.NS_ERROR_FAILURE;
+	int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
+	System.arraycopy (callbackArgs, 1, args, 0, args.length);
+	return ((XPCOMObject) object).method48 (args);
+}
+static int /*long*/ callback49 (int /*long*/[] callbackArgs) {
+	// find the object on which this call was invoked
+	int /*long*/ address = callbackArgs[0];
+	Object object = ObjectMap.get (new LONG (address));
+	if (object == null) return XPCOM.NS_ERROR_FAILURE;
+	int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
+	System.arraycopy (callbackArgs, 1, args, 0, args.length);
+	return ((XPCOMObject) object).method49 (args);
+}
+static int /*long*/ callback5 (int /*long*/[] callbackArgs) {
+	// find the object on which this call was invoked
+	int /*long*/ address = callbackArgs[0];
+	Object object = ObjectMap.get (new LONG (address));
+	if (object == null) return XPCOM.NS_ERROR_FAILURE;
+	int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
+	System.arraycopy (callbackArgs, 1, args, 0, args.length);
+	return ((XPCOMObject) object).method5 (args);
+}
+static int /*long*/ callback50 (int /*long*/[] callbackArgs) {
+	// find the object on which this call was invoked
+	int /*long*/ address = callbackArgs[0];
+	Object object = ObjectMap.get (new LONG (address));
+	if (object == null) return XPCOM.NS_ERROR_FAILURE;
+	int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
+	System.arraycopy (callbackArgs, 1, args, 0, args.length);
+	return ((XPCOMObject) object).method50 (args);
+}
+static int /*long*/ callback51 (int /*long*/[] callbackArgs) {
+	// find the object on which this call was invoked
+	int /*long*/ address = callbackArgs[0];
+	Object object = ObjectMap.get (new LONG (address));
+	if (object == null) return XPCOM.NS_ERROR_FAILURE;
+	int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
+	System.arraycopy (callbackArgs, 1, args, 0, args.length);
+	return ((XPCOMObject) object).method51 (args);
+}
+static int /*long*/ callback52 (int /*long*/[] callbackArgs) {
+	// find the object on which this call was invoked
+	int /*long*/ address = callbackArgs[0];
+	Object object = ObjectMap.get (new LONG (address));
+	if (object == null) return XPCOM.NS_ERROR_FAILURE;
+	int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
+	System.arraycopy (callbackArgs, 1, args, 0, args.length);
+	return ((XPCOMObject) object).method52 (args);
+}
+static int /*long*/ callback53 (int /*long*/[] callbackArgs) {
+	// find the object on which this call was invoked
+	int /*long*/ address = callbackArgs[0];
+	Object object = ObjectMap.get (new LONG (address));
+	if (object == null) return XPCOM.NS_ERROR_FAILURE;
+	int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
+	System.arraycopy (callbackArgs, 1, args, 0, args.length);
+	return ((XPCOMObject) object).method53 (args);
+}
+static int /*long*/ callback54 (int /*long*/[] callbackArgs) {
+	// find the object on which this call was invoked
+	int /*long*/ address = callbackArgs[0];
+	Object object = ObjectMap.get (new LONG (address));
+	if (object == null) return XPCOM.NS_ERROR_FAILURE;
+	int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
+	System.arraycopy (callbackArgs, 1, args, 0, args.length);
+	return ((XPCOMObject) object).method54 (args);
+}
+static int /*long*/ callback55 (int /*long*/[] callbackArgs) {
+	// find the object on which this call was invoked
+	int /*long*/ address = callbackArgs[0];
+	Object object = ObjectMap.get (new LONG (address));
+	if (object == null) return XPCOM.NS_ERROR_FAILURE;
+	int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
+	System.arraycopy (callbackArgs, 1, args, 0, args.length);
+	return ((XPCOMObject) object).method55 (args);
+}
+static int /*long*/ callback56 (int /*long*/[] callbackArgs) {
+	// find the object on which this call was invoked
+	int /*long*/ address = callbackArgs[0];
+	Object object = ObjectMap.get (new LONG (address));
+	if (object == null) return XPCOM.NS_ERROR_FAILURE;
+	int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
+	System.arraycopy (callbackArgs, 1, args, 0, args.length);
+	return ((XPCOMObject) object).method56 (args);
+}
+static int /*long*/ callback57 (int /*long*/[] callbackArgs) {
+	// find the object on which this call was invoked
+	int /*long*/ address = callbackArgs[0];
+	Object object = ObjectMap.get (new LONG (address));
+	if (object == null) return XPCOM.NS_ERROR_FAILURE;
+	int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
+	System.arraycopy (callbackArgs, 1, args, 0, args.length);
+	return ((XPCOMObject) object).method57 (args);
+}
+static int /*long*/ callback58 (int /*long*/[] callbackArgs) {
+	// find the object on which this call was invoked
+	int /*long*/ address = callbackArgs[0];
+	Object object = ObjectMap.get (new LONG (address));
+	if (object == null) return XPCOM.NS_ERROR_FAILURE;
+	int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
+	System.arraycopy (callbackArgs, 1, args, 0, args.length);
+	return ((XPCOMObject) object).method58 (args);
+}
+static int /*long*/ callback59 (int /*long*/[] callbackArgs) {
+	// find the object on which this call was invoked
+	int /*long*/ address = callbackArgs[0];
+	Object object = ObjectMap.get (new LONG (address));
+	if (object == null) return XPCOM.NS_ERROR_FAILURE;
+	int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
+	System.arraycopy (callbackArgs, 1, args, 0, args.length);
+	return ((XPCOMObject) object).method59 (args);
+}
+static int /*long*/ callback6 (int /*long*/[] callbackArgs) {
+	// find the object on which this call was invoked
+	int /*long*/ address = callbackArgs[0];
+	Object object = ObjectMap.get (new LONG (address));
+	if (object == null) return XPCOM.NS_ERROR_FAILURE;
+	int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
+	System.arraycopy (callbackArgs, 1, args, 0, args.length);
+	return ((XPCOMObject) object).method6 (args);
+}
+static int /*long*/ callback60 (int /*long*/[] callbackArgs) {
+	// find the object on which this call was invoked
+	int /*long*/ address = callbackArgs[0];
+	Object object = ObjectMap.get (new LONG (address));
+	if (object == null) return XPCOM.NS_ERROR_FAILURE;
+	int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
+	System.arraycopy (callbackArgs, 1, args, 0, args.length);
+	return ((XPCOMObject) object).method60 (args);
+}
+static int /*long*/ callback61 (int /*long*/[] callbackArgs) {
+	// find the object on which this call was invoked
+	int /*long*/ address = callbackArgs[0];
+	Object object = ObjectMap.get (new LONG (address));
+	if (object == null) return XPCOM.NS_ERROR_FAILURE;
+	int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
+	System.arraycopy (callbackArgs, 1, args, 0, args.length);
+	return ((XPCOMObject) object).method61 (args);
+}
+static int /*long*/ callback62 (int /*long*/[] callbackArgs) {
+	// find the object on which this call was invoked
+	int /*long*/ address = callbackArgs[0];
+	Object object = ObjectMap.get (new LONG (address));
+	if (object == null) return XPCOM.NS_ERROR_FAILURE;
+	int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
+	System.arraycopy (callbackArgs, 1, args, 0, args.length);
+	return ((XPCOMObject) object).method62 (args);
+}
+static int /*long*/ callback63 (int /*long*/[] callbackArgs) {
+	// find the object on which this call was invoked
+	int /*long*/ address = callbackArgs[0];
+	Object object = ObjectMap.get (new LONG (address));
+	if (object == null) return XPCOM.NS_ERROR_FAILURE;
+	int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
+	System.arraycopy (callbackArgs, 1, args, 0, args.length);
+	return ((XPCOMObject) object).method63 (args);
+}
+static int /*long*/ callback64 (int /*long*/[] callbackArgs) {
+	// find the object on which this call was invoked
+	int /*long*/ address = callbackArgs[0];
+	Object object = ObjectMap.get (new LONG (address));
+	if (object == null) return XPCOM.NS_ERROR_FAILURE;
+	int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
+	System.arraycopy (callbackArgs, 1, args, 0, args.length);
+	return ((XPCOMObject) object).method64 (args);
+}
+static int /*long*/ callback65 (int /*long*/[] callbackArgs) {
+	// find the object on which this call was invoked
+	int /*long*/ address = callbackArgs[0];
+	Object object = ObjectMap.get (new LONG (address));
+	if (object == null) return XPCOM.NS_ERROR_FAILURE;
+	int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
+	System.arraycopy (callbackArgs, 1, args, 0, args.length);
+	return ((XPCOMObject) object).method65 (args);
+}
+static int /*long*/ callback66 (int /*long*/[] callbackArgs) {
+	// find the object on which this call was invoked
+	int /*long*/ address = callbackArgs[0];
+	Object object = ObjectMap.get (new LONG (address));
+	if (object == null) return XPCOM.NS_ERROR_FAILURE;
+	int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
+	System.arraycopy (callbackArgs, 1, args, 0, args.length);
+	return ((XPCOMObject) object).method66 (args);
+}
+static int /*long*/ callback67 (int /*long*/[] callbackArgs) {
+	// find the object on which this call was invoked
+	int /*long*/ address = callbackArgs[0];
+	Object object = ObjectMap.get (new LONG (address));
+	if (object == null) return XPCOM.NS_ERROR_FAILURE;
+	int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
+	System.arraycopy (callbackArgs, 1, args, 0, args.length);
+	return ((XPCOMObject) object).method67 (args);
+}
+static int /*long*/ callback68 (int /*long*/[] callbackArgs) {
+	// find the object on which this call was invoked
+	int /*long*/ address = callbackArgs[0];
+	Object object = ObjectMap.get (new LONG (address));
+	if (object == null) return XPCOM.NS_ERROR_FAILURE;
+	int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
+	System.arraycopy (callbackArgs, 1, args, 0, args.length);
+	return ((XPCOMObject) object).method68 (args);
+}
+static int /*long*/ callback69 (int /*long*/[] callbackArgs) {
+	// find the object on which this call was invoked
+	int /*long*/ address = callbackArgs[0];
+	Object object = ObjectMap.get (new LONG (address));
+	if (object == null) return XPCOM.NS_ERROR_FAILURE;
+	int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
+	System.arraycopy (callbackArgs, 1, args, 0, args.length);
+	return ((XPCOMObject) object).method69 (args);
+}
+static int /*long*/ callback7 (int /*long*/[] callbackArgs) {
+	// find the object on which this call was invoked
+	int /*long*/ address = callbackArgs[0];
+	Object object = ObjectMap.get (new LONG (address));
+	if (object == null) return XPCOM.NS_ERROR_FAILURE;
+	int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
+	System.arraycopy (callbackArgs, 1, args, 0, args.length);
+	return ((XPCOMObject) object).method7 (args);
+}
+static int /*long*/ callback70 (int /*long*/[] callbackArgs) {
+	// find the object on which this call was invoked
+	int /*long*/ address = callbackArgs[0];
+	Object object = ObjectMap.get (new LONG (address));
+	if (object == null) return XPCOM.NS_ERROR_FAILURE;
+	int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
+	System.arraycopy (callbackArgs, 1, args, 0, args.length);
+	return ((XPCOMObject) object).method70 (args);
+}
+static int /*long*/ callback71 (int /*long*/[] callbackArgs) {
+	// find the object on which this call was invoked
+	int /*long*/ address = callbackArgs[0];
+	Object object = ObjectMap.get (new LONG (address));
+	if (object == null) return XPCOM.NS_ERROR_FAILURE;
+	int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
+	System.arraycopy (callbackArgs, 1, args, 0, args.length);
+	return ((XPCOMObject) object).method71 (args);
+}
+static int /*long*/ callback72 (int /*long*/[] callbackArgs) {
+	// find the object on which this call was invoked
+	int /*long*/ address = callbackArgs[0];
+	Object object = ObjectMap.get (new LONG (address));
+	if (object == null) return XPCOM.NS_ERROR_FAILURE;
+	int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
+	System.arraycopy (callbackArgs, 1, args, 0, args.length);
+	return ((XPCOMObject) object).method72 (args);
+}
+static int /*long*/ callback73 (int /*long*/[] callbackArgs) {
+	// find the object on which this call was invoked
+	int /*long*/ address = callbackArgs[0];
+	Object object = ObjectMap.get (new LONG (address));
+	if (object == null) return XPCOM.NS_ERROR_FAILURE;
+	int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
+	System.arraycopy (callbackArgs, 1, args, 0, args.length);
+	return ((XPCOMObject) object).method73 (args);
+}
+static int /*long*/ callback74 (int /*long*/[] callbackArgs) {
+	// find the object on which this call was invoked
+	int /*long*/ address = callbackArgs[0];
+	Object object = ObjectMap.get (new LONG (address));
+	if (object == null) return XPCOM.NS_ERROR_FAILURE;
+	int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
+	System.arraycopy (callbackArgs, 1, args, 0, args.length);
+	return ((XPCOMObject) object).method74 (args);
+}
+static int /*long*/ callback75 (int /*long*/[] callbackArgs) {
+	// find the object on which this call was invoked
+	int /*long*/ address = callbackArgs[0];
+	Object object = ObjectMap.get (new LONG (address));
+	if (object == null) return XPCOM.NS_ERROR_FAILURE;
+	int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
+	System.arraycopy (callbackArgs, 1, args, 0, args.length);
+	return ((XPCOMObject) object).method75 (args);
+}
+static int /*long*/ callback76 (int /*long*/[] callbackArgs) {
+	// find the object on which this call was invoked
+	int /*long*/ address = callbackArgs[0];
+	Object object = ObjectMap.get (new LONG (address));
+	if (object == null) return XPCOM.NS_ERROR_FAILURE;
+	int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
+	System.arraycopy (callbackArgs, 1, args, 0, args.length);
+	return ((XPCOMObject) object).method76 (args);
+}
+static int /*long*/ callback77 (int /*long*/[] callbackArgs) {
+	// find the object on which this call was invoked
+	int /*long*/ address = callbackArgs[0];
+	Object object = ObjectMap.get (new LONG (address));
+	if (object == null) return XPCOM.NS_ERROR_FAILURE;
+	int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
+	System.arraycopy (callbackArgs, 1, args, 0, args.length);
+	return ((XPCOMObject) object).method77 (args);
+}
+static int /*long*/ callback78 (int /*long*/[] callbackArgs) {
+	// find the object on which this call was invoked
+	int /*long*/ address = callbackArgs[0];
+	Object object = ObjectMap.get (new LONG (address));
+	if (object == null) return XPCOM.NS_ERROR_FAILURE;
+	int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
+	System.arraycopy (callbackArgs, 1, args, 0, args.length);
+	return ((XPCOMObject) object).method78 (args);
+}
+static int /*long*/ callback79 (int /*long*/[] callbackArgs) {
+	// find the object on which this call was invoked
+	int /*long*/ address = callbackArgs[0];
+	Object object = ObjectMap.get (new LONG (address));
+	if (object == null) return XPCOM.NS_ERROR_FAILURE;
+	int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
+	System.arraycopy (callbackArgs, 1, args, 0, args.length);
+	return ((XPCOMObject) object).method79 (args);
+}
+static int /*long*/ callback8 (int /*long*/[] callbackArgs) {
+	// find the object on which this call was invoked
+	int /*long*/ address = callbackArgs[0];
+	Object object = ObjectMap.get (new LONG (address));
+	if (object == null) return XPCOM.NS_ERROR_FAILURE;
+	int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
+	System.arraycopy (callbackArgs, 1, args, 0, args.length);
+	return ((XPCOMObject) object).method8 (args);
+}
+static int /*long*/ callback9 (int /*long*/[] callbackArgs) {
+	// find the object on which this call was invoked
+	int /*long*/ address = callbackArgs[0];
+	Object object = ObjectMap.get (new LONG (address));
+	if (object == null) return XPCOM.NS_ERROR_FAILURE;
+	int /*long*/[] args = new int /*long*/[callbackArgs.length - 1];
+	System.arraycopy (callbackArgs, 1, args, 0, args.length);
+	return ((XPCOMObject) object).method9 (args);
+}
+
+public void dispose() {
+	// free the memory for this reference
+	int /*long*/[] pVtable = new int /*long*/[1];
+	XPCOM.memmove (pVtable, ppVtable, C.PTR_SIZEOF);
+	C.free (pVtable[0]);
+	C.free (ppVtable);	
+
+	// remove this ppVtable from the list
+	ObjectMap.remove (new LONG (ppVtable));	
+
+	ppVtable = 0;
+}
+	
+public int /*long*/ getAddress () {
+	return ppVtable;
+}
+
+public int /*long*/ method0 (int /*long*/[] args) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+public int /*long*/ method1 (int /*long*/[] args) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+public int /*long*/ method10 (int /*long*/[] args) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+public int /*long*/ method11 (int /*long*/[] args) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+public int /*long*/ method12 (int /*long*/[] args) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+public int /*long*/ method13 (int /*long*/[] args) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+public int /*long*/ method14 (int /*long*/[] args) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+public int /*long*/ method15 (int /*long*/[] args) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+public int /*long*/ method16 (int /*long*/[] args) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+public int /*long*/ method17 (int /*long*/[] args) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+public int /*long*/ method18 (int /*long*/[] args) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+public int /*long*/ method19 (int /*long*/[] args) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+public int /*long*/ method2 (int /*long*/[] args) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+public int /*long*/ method20 (int /*long*/[] args) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+public int /*long*/ method21 (int /*long*/[] args) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+public int /*long*/ method22 (int /*long*/[] args) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+public int /*long*/ method23 (int /*long*/[] args) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+public int /*long*/ method24 (int /*long*/[] args) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+public int /*long*/ method25 (int /*long*/[] args) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+public int /*long*/ method26 (int /*long*/[] args) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+public int /*long*/ method27 (int /*long*/[] args) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+public int /*long*/ method28 (int /*long*/[] args) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+public int /*long*/ method29 (int /*long*/[] args) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+public int /*long*/ method3 (int /*long*/[] args) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+public int /*long*/ method30 (int /*long*/[] args) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+public int /*long*/ method31 (int /*long*/[] args) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+public int /*long*/ method32 (int /*long*/[] args) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+public int /*long*/ method33 (int /*long*/[] args) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+public int /*long*/ method34 (int /*long*/[] args) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+public int /*long*/ method35 (int /*long*/[] args) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+public int /*long*/ method36 (int /*long*/[] args) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+public int /*long*/ method37 (int /*long*/[] args) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+public int /*long*/ method38 (int /*long*/[] args) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+public int /*long*/ method39 (int /*long*/[] args) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+public int /*long*/ method4 (int /*long*/[] args) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+public int /*long*/ method40 (int /*long*/[] args) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+public int /*long*/ method41 (int /*long*/[] args) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+public int /*long*/ method42 (int /*long*/[] args) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+public int /*long*/ method43 (int /*long*/[] args) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+public int /*long*/ method44 (int /*long*/[] args) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+public int /*long*/ method45 (int /*long*/[] args) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+public int /*long*/ method46 (int /*long*/[] args) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+public int /*long*/ method47 (int /*long*/[] args) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+public int /*long*/ method48 (int /*long*/[] args) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+public int /*long*/ method49 (int /*long*/[] args) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+public int /*long*/ method5 (int /*long*/[] args) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+public int /*long*/ method50 (int /*long*/[] args) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+public int /*long*/ method51 (int /*long*/[] args) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+public int /*long*/ method52 (int /*long*/[] args) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+public int /*long*/ method53 (int /*long*/[] args) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+public int /*long*/ method54 (int /*long*/[] args) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+public int /*long*/ method55 (int /*long*/[] args) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+public int /*long*/ method56 (int /*long*/[] args) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+public int /*long*/ method57 (int /*long*/[] args) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+public int /*long*/ method58 (int /*long*/[] args) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+public int /*long*/ method59 (int /*long*/[] args) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+public int /*long*/ method6 (int /*long*/[] args) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+public int /*long*/ method60 (int /*long*/[] args) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+public int /*long*/ method61 (int /*long*/[] args) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+public int /*long*/ method62 (int /*long*/[] args) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+public int /*long*/ method63 (int /*long*/[] args) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+public int /*long*/ method64 (int /*long*/[] args) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+public int /*long*/ method65 (int /*long*/[] args) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+public int /*long*/ method66 (int /*long*/[] args) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+public int /*long*/ method67 (int /*long*/[] args) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+public int /*long*/ method68 (int /*long*/[] args) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+public int /*long*/ method69 (int /*long*/[] args) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+public int /*long*/ method7 (int /*long*/[] args) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+public int /*long*/ method70 (int /*long*/[] args) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+public int /*long*/ method71 (int /*long*/[] args) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+public int /*long*/ method72 (int /*long*/[] args) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+public int /*long*/ method73 (int /*long*/[] args) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+public int /*long*/ method74 (int /*long*/[] args) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+public int /*long*/ method75 (int /*long*/[] args) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+public int /*long*/ method76 (int /*long*/[] args) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+public int /*long*/ method77 (int /*long*/[] args) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+public int /*long*/ method78 (int /*long*/[] args) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+public int /*long*/ method79 (int /*long*/[] args) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+public int /*long*/ method8 (int /*long*/[] args) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+public int /*long*/ method9 (int /*long*/[] args) {
+	return XPCOM.NS_ERROR_NOT_IMPLEMENTED;
+}
+}
+


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/XPCOMObject.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsEmbedString.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsEmbedString.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsEmbedString.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,63 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by Netscape are Copyright (C) 1998-1999
+ * Netscape Communications Corporation.  All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * -  Binding to permit interfacing between Mozilla and SWT
+ * -  Copyright (C) 2004 IBM Corp.  All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package org.eclipse.swt.internal.mozilla;
+
+public class nsEmbedString {
+	int /*long*/ handle;
+	
+public nsEmbedString() {
+	handle = XPCOM.nsEmbedString_new();
+}
+
+public nsEmbedString(String string) {
+	if (string != null) {
+	   char[] aString = new char[string.length() + 1];
+	   string.getChars(0, string.length(), aString, 0);
+	   handle = XPCOM.nsEmbedString_new(aString);
+	}   
+}
+
+public int /*long*/ getAddress() {
+	return handle;
+}	
+	
+public String toString() {
+	if (handle == 0) return null;
+	int length = XPCOM.nsEmbedString_Length(handle);
+	int /*long*/ buffer = XPCOM.nsEmbedString_get(handle);
+	char[] dest = new char[length];
+	XPCOM.memmove(dest, buffer, length * 2);
+	return new String(dest);
+}	
+	
+public void dispose() {
+	if (handle == 0) return;			
+	XPCOM.nsEmbedString_delete(handle);
+	handle = 0; 	
+}	
+}
\ No newline at end of file


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsEmbedString.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIAppShell.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIAppShell.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIAppShell.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,75 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by Netscape are Copyright (C) 1998-1999
+ * Netscape Communications Corporation.  All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * -  Binding to permit interfacing between Mozilla and SWT
+ * -  Copyright (C) 2003, 2008 IBM Corp.  All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package org.eclipse.swt.internal.mozilla;
+
+public class nsIAppShell extends nsISupports {
+
+	static final int LAST_METHOD_ID = nsISupports.LAST_METHOD_ID + 8;
+
+	public static final String NS_IAPPSHELL_IID_STR =
+		"a0757c31-eeac-11d1-9ec1-00aa002fb821";
+
+	public static final nsID NS_IAPPSHELL_IID =
+		new nsID(NS_IAPPSHELL_IID_STR);
+
+	public nsIAppShell(int /*long*/ address) {
+		super(address);
+	}
+
+	public int Create(int /*long*/ argc, int /*long*/[] argv) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 1, getAddress(), argc, argv);
+	}
+
+	public int Run() {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 2, getAddress());
+	}
+
+	public int Spinup() {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 3, getAddress());
+	}
+
+	public int Spindown() {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 4, getAddress());
+	}
+
+	public int ListenToEventQueue(int /*long*/ aQueue, int aListen) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 5, getAddress(), aQueue, aListen);
+	}
+
+	public int GetNativeEvent(int /*long*/ aRealEvent, int /*long*/[] aEvent) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 6, getAddress(), aRealEvent, aEvent);
+	}
+
+	public int DispatchNativeEvent(int aRealEvent, int /*long*/ aEvent) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 7, getAddress(), aRealEvent, aEvent);
+	}
+
+	public int Exit() {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 8, getAddress());
+	}
+}
\ No newline at end of file


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIAppShell.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIAuthInformation.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIAuthInformation.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIAuthInformation.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,87 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by Netscape are Copyright (C) 1998-1999
+ * Netscape Communications Corporation.  All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * -  Binding to permit interfacing between Mozilla and SWT
+ * -  Copyright (C) 2003, 2008 IBM Corp.  All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package org.eclipse.swt.internal.mozilla;
+
+public class nsIAuthInformation extends nsISupports {
+
+	static final int LAST_METHOD_ID = nsISupports.LAST_METHOD_ID + 9;
+
+	public static final String NS_IAUTHINFORMATION_IID_STR =
+		"0d73639c-2a92-4518-9f92-28f71fea5f20";
+
+	public static final nsID NS_IAUTHINFORMATION_IID =
+		new nsID(NS_IAUTHINFORMATION_IID_STR);
+
+	public nsIAuthInformation(int /*long*/ address) {
+		super(address);
+	}
+
+	public static final int AUTH_HOST = 1;
+
+	public static final int AUTH_PROXY = 2;
+
+	public static final int NEED_DOMAIN = 4;
+
+	public static final int ONLY_PASSWORD = 8;
+
+	public int GetFlags(int[] aFlags) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 1, getAddress(), aFlags);
+	}
+
+	public int GetRealm(int /*long*/ aRealm) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 2, getAddress(), aRealm);
+	}
+
+	public int GetAuthenticationScheme(int /*long*/ aAuthenticationScheme) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 3, getAddress(), aAuthenticationScheme);
+	}
+
+	public int GetUsername(int /*long*/ aUsername) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 4, getAddress(), aUsername);
+	}
+
+	public int SetUsername(int /*long*/ aUsername) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 5, getAddress(), aUsername);
+	}
+
+	public int GetPassword(int /*long*/ aPassword) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 6, getAddress(), aPassword);
+	}
+
+	public int SetPassword(int /*long*/ aPassword) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 7, getAddress(), aPassword);
+	}
+
+	public int GetDomain(int /*long*/ aDomain) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 8, getAddress(), aDomain);
+	}
+
+	public int SetDomain(int /*long*/ aDomain) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 9, getAddress(), aDomain);
+	}
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIAuthInformation.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIBaseWindow.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIBaseWindow.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIBaseWindow.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,139 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by Netscape are Copyright (C) 1998-1999
+ * Netscape Communications Corporation.  All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * -  Binding to permit interfacing between Mozilla and SWT
+ * -  Copyright (C) 2003, 2008 IBM Corp.  All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package org.eclipse.swt.internal.mozilla;
+
+public class nsIBaseWindow extends nsISupports {
+
+	static final int LAST_METHOD_ID = nsISupports.LAST_METHOD_ID + 24;
+
+	public static final String NS_IBASEWINDOW_IID_STR =
+		"046bc8a0-8015-11d3-af70-00a024ffc08c";
+
+	public static final nsID NS_IBASEWINDOW_IID =
+		new nsID(NS_IBASEWINDOW_IID_STR);
+
+	public nsIBaseWindow(int /*long*/ address) {
+		super(address);
+	}
+
+	public int InitWindow(int /*long*/ parentNativeWindow, int /*long*/ parentWidget, int x, int y, int cx, int cy) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 1, getAddress(), parentNativeWindow, parentWidget, x, y, cx, cy);
+	}
+
+	public int Create() {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 2, getAddress());
+	}
+
+	public int Destroy() {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 3, getAddress());
+	}
+
+	public int SetPosition(int x, int y) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 4, getAddress(), x, y);
+	}
+
+	public int GetPosition(int[] x, int[] y) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 5, getAddress(), x, y);
+	}
+
+	public int SetSize(int cx, int cy, int fRepaint) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 6, getAddress(), cx, cy, fRepaint);
+	}
+
+	public int GetSize(int[] cx, int[] cy) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 7, getAddress(), cx, cy);
+	}
+
+	public int SetPositionAndSize(int x, int y, int cx, int cy, int fRepaint) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 8, getAddress(), x, y, cx, cy, fRepaint);
+	}
+
+	public int GetPositionAndSize(int[] x, int[] y, int[] cx, int[] cy) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 9, getAddress(), x, y, cx, cy);
+	}
+
+	public int Repaint(int force) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 10, getAddress(), force);
+	}
+
+	public int GetParentWidget(int /*long*/[] aParentWidget) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 11, getAddress(), aParentWidget);
+	}
+
+	public int SetParentWidget(int /*long*/ aParentWidget) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 12, getAddress(), aParentWidget);
+	}
+
+	public int GetParentNativeWindow(int /*long*/[] aParentNativeWindow) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 13, getAddress(), aParentNativeWindow);
+	}
+
+	public int SetParentNativeWindow(int /*long*/ aParentNativeWindow) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 14, getAddress(), aParentNativeWindow);
+	}
+
+	public int GetVisibility(int[] aVisibility) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 15, getAddress(), aVisibility);
+	}
+
+	public int SetVisibility(int aVisibility) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 16, getAddress(), aVisibility);
+	}
+
+	public int GetEnabled(int[] aEnabled) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 17, getAddress(), aEnabled);
+	}
+
+	public int SetEnabled(int aEnabled) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 18, getAddress(), aEnabled);
+	}
+
+	public int GetBlurSuppression(int[] aBlurSuppression) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 19, getAddress(), aBlurSuppression);
+	}
+
+	public int SetBlurSuppression(int aBlurSuppression) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 20, getAddress(), aBlurSuppression);
+	}
+
+	public int GetMainWidget(int /*long*/[] aMainWidget) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 21, getAddress(), aMainWidget);
+	}
+
+	public int SetFocus() {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 22, getAddress());
+	}
+
+	public int GetTitle(int /*long*/[] aTitle) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 23, getAddress(), aTitle);
+	}
+
+	public int SetTitle(char[] aTitle) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 24, getAddress(), aTitle);
+	}
+}
\ No newline at end of file


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIBaseWindow.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsICancelable.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsICancelable.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsICancelable.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,47 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by Netscape are Copyright (C) 1998-1999
+ * Netscape Communications Corporation.  All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * -  Binding to permit interfacing between Mozilla and SWT
+ * -  Copyright (C) 2003 IBM Corp.  All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package org.eclipse.swt.internal.mozilla;
+
+public class nsICancelable extends nsISupports {
+
+	static final int LAST_METHOD_ID = nsISupports.LAST_METHOD_ID + 1;
+
+	public static final String NS_ICANCELABLE_IID_STR =
+		"d94ac0a0-bb18-46b8-844e-84159064b0bd";
+
+	public static final nsID NS_ICANCELABLE_IID =
+		new nsID(NS_ICANCELABLE_IID_STR);
+
+	public nsICancelable(int /*long*/ address) {
+		super(address);
+	}
+
+	public int Cancel(int aReason) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 1, getAddress(), aReason);
+	}
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsICancelable.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsICategoryManager.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsICategoryManager.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsICategoryManager.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,67 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by Netscape are Copyright (C) 1998-1999
+ * Netscape Communications Corporation.  All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * -  Binding to permit interfacing between Mozilla and SWT
+ * -  Copyright (C) 2003, 2008 IBM Corp.  All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package org.eclipse.swt.internal.mozilla;
+
+public class nsICategoryManager extends nsISupports {
+
+	static final int LAST_METHOD_ID = nsISupports.LAST_METHOD_ID + 6;
+
+	public static final String NS_ICATEGORYMANAGER_IID_STR =
+		"3275b2cd-af6d-429a-80d7-f0c5120342ac";
+
+	public static final nsID NS_ICATEGORYMANAGER_IID =
+		new nsID(NS_ICATEGORYMANAGER_IID_STR);
+
+	public nsICategoryManager(int /*long*/ address) {
+		super(address);
+	}
+
+	public int GetCategoryEntry(byte[] aCategory, byte[] aEntry, int /*long*/[] _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 1, getAddress(), aCategory, aEntry, _retval);
+	}
+
+	public int AddCategoryEntry(byte[] aCategory, byte[] aEntry, byte[] aValue, int aPersist, int aReplace, int /*long*/[] _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 2, getAddress(), aCategory, aEntry, aValue, aPersist, aReplace, _retval);
+	}
+
+	public int DeleteCategoryEntry(byte[] aCategory, byte[] aEntry, int aPersist) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 3, getAddress(), aCategory, aEntry, aPersist);
+	}
+
+	public int DeleteCategory(byte[] aCategory) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 4, getAddress(), aCategory);
+	}
+
+	public int EnumerateCategory(byte[] aCategory, int /*long*/[] _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 5, getAddress(), aCategory, _retval);
+	}
+
+	public int EnumerateCategories(int /*long*/[] _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 6, getAddress(), _retval);
+	}
+}
\ No newline at end of file


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsICategoryManager.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIChannel.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIChannel.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIChannel.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,119 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by Netscape are Copyright (C) 1998-1999
+ * Netscape Communications Corporation.  All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * -  Binding to permit interfacing between Mozilla and SWT
+ * -  Copyright (C) 2003, 2008 IBM Corp.  All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package org.eclipse.swt.internal.mozilla;
+
+public class nsIChannel extends nsIRequest {
+
+	static final int LAST_METHOD_ID = nsIRequest.LAST_METHOD_ID + 16;
+
+	public static final String NS_ICHANNEL_IID_STR =
+		"c63a055a-a676-4e71-bf3c-6cfa11082018";
+
+	public static final nsID NS_ICHANNEL_IID =
+		new nsID(NS_ICHANNEL_IID_STR);
+
+	public nsIChannel(int /*long*/ address) {
+		super(address);
+	}
+
+	public int GetOriginalURI(int /*long*/[] aOriginalURI) {
+		return XPCOM.VtblCall(nsIRequest.LAST_METHOD_ID + 1, getAddress(), aOriginalURI);
+	}
+
+	public int SetOriginalURI(int /*long*/ aOriginalURI) {
+		return XPCOM.VtblCall(nsIRequest.LAST_METHOD_ID + 2, getAddress(), aOriginalURI);
+	}
+
+	public int GetURI(int /*long*/[] aURI) {
+		return XPCOM.VtblCall(nsIRequest.LAST_METHOD_ID + 3, getAddress(), aURI);
+	}
+
+	public int GetOwner(int /*long*/[] aOwner) {
+		return XPCOM.VtblCall(nsIRequest.LAST_METHOD_ID + 4, getAddress(), aOwner);
+	}
+
+	public int SetOwner(int /*long*/ aOwner) {
+		return XPCOM.VtblCall(nsIRequest.LAST_METHOD_ID + 5, getAddress(), aOwner);
+	}
+
+	public int GetNotificationCallbacks(int /*long*/[] aNotificationCallbacks) {
+		return XPCOM.VtblCall(nsIRequest.LAST_METHOD_ID + 6, getAddress(), aNotificationCallbacks);
+	}
+
+	public int SetNotificationCallbacks(int /*long*/ aNotificationCallbacks) {
+		return XPCOM.VtblCall(nsIRequest.LAST_METHOD_ID + 7, getAddress(), aNotificationCallbacks);
+	}
+
+	public int GetSecurityInfo(int /*long*/[] aSecurityInfo) {
+		return XPCOM.VtblCall(nsIRequest.LAST_METHOD_ID + 8, getAddress(), aSecurityInfo);
+	}
+
+	public int GetContentType(int /*long*/ aContentType) {
+		return XPCOM.VtblCall(nsIRequest.LAST_METHOD_ID + 9, getAddress(), aContentType);
+	}
+
+	public int SetContentType(int /*long*/ aContentType) {
+		return XPCOM.VtblCall(nsIRequest.LAST_METHOD_ID + 10, getAddress(), aContentType);
+	}
+
+	public int GetContentCharset(int /*long*/ aContentCharset) {
+		return XPCOM.VtblCall(nsIRequest.LAST_METHOD_ID + 11, getAddress(), aContentCharset);
+	}
+
+	public int SetContentCharset(int /*long*/ aContentCharset) {
+		return XPCOM.VtblCall(nsIRequest.LAST_METHOD_ID + 12, getAddress(), aContentCharset);
+	}
+
+	public int GetContentLength(int[] aContentLength) {
+		return XPCOM.VtblCall(nsIRequest.LAST_METHOD_ID + 13, getAddress(), aContentLength);
+	}
+
+	public int SetContentLength(int aContentLength) {
+		return XPCOM.VtblCall(nsIRequest.LAST_METHOD_ID + 14, getAddress(), aContentLength);
+	}
+
+	public int Open(int /*long*/[] _retval) {
+		return XPCOM.VtblCall(nsIRequest.LAST_METHOD_ID + 15, getAddress(), _retval);
+	}
+
+	public int AsyncOpen(int /*long*/ aListener, int /*long*/ aContext) {
+		return XPCOM.VtblCall(nsIRequest.LAST_METHOD_ID + 16, getAddress(), aListener, aContext);
+	}
+
+	public static final int LOAD_DOCUMENT_URI = 65536;
+
+	public static final int LOAD_RETARGETED_DOCUMENT_URI = 131072;
+
+	public static final int LOAD_REPLACE = 262144;
+
+	public static final int LOAD_INITIAL_DOCUMENT_URI = 524288;
+
+	public static final int LOAD_TARGETED = 1048576;
+
+	public static final int LOAD_CALL_CONTENT_SNIFFERS = 2097152;
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIChannel.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIComponentManager.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIComponentManager.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIComponentManager.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,59 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by Netscape are Copyright (C) 1998-1999
+ * Netscape Communications Corporation.  All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * -  Binding to permit interfacing between Mozilla and SWT
+ * -  Copyright (C) 2003, 2005 IBM Corp.  All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package org.eclipse.swt.internal.mozilla;
+
+public class nsIComponentManager extends nsISupports {
+
+	static final int LAST_METHOD_ID = nsISupports.LAST_METHOD_ID + 4;
+
+	public static final String NS_ICOMPONENTMANAGER_IID_STR =
+		"a88e5a60-205a-4bb1-94e1-2628daf51eae";
+
+	public static final nsID NS_ICOMPONENTMANAGER_IID =
+		new nsID(NS_ICOMPONENTMANAGER_IID_STR);
+
+	public nsIComponentManager(int /*long*/ address) {
+		super(address);
+	}
+
+	public int GetClassObject(nsID aClass, nsID aIID, int /*long*/[] result) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 1, getAddress(), aClass, aIID, result);
+	}
+
+	public int GetClassObjectByContractID(byte[] aContractID, nsID aIID, int /*long*/[] result) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 2, getAddress(), aContractID, aIID, result);
+	}
+
+	public int CreateInstance(nsID aClass, int /*long*/ aDelegate, nsID aIID, int /*long*/[] result) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 3, getAddress(), aClass, aDelegate, aIID, result);
+	}
+
+	public int CreateInstanceByContractID(byte[] aContractID, int /*long*/ aDelegate, nsID aIID, int /*long*/[] result) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 4, getAddress(), aContractID, aDelegate, aIID, result);
+	}
+}
\ No newline at end of file


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIComponentManager.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIComponentRegistrar.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIComponentRegistrar.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIComponentRegistrar.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,91 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by Netscape are Copyright (C) 1998-1999
+ * Netscape Communications Corporation.  All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * -  Binding to permit interfacing between Mozilla and SWT
+ * -  Copyright (C) 2003, 2008 IBM Corp.  All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package org.eclipse.swt.internal.mozilla;
+
+public class nsIComponentRegistrar extends nsISupports {
+
+	static final int LAST_METHOD_ID = nsISupports.LAST_METHOD_ID + 12;
+
+	public static final String NS_ICOMPONENTREGISTRAR_IID_STR =
+		"2417cbfe-65ad-48a6-b4b6-eb84db174392";
+
+	public static final nsID NS_ICOMPONENTREGISTRAR_IID =
+		new nsID(NS_ICOMPONENTREGISTRAR_IID_STR);
+
+	public nsIComponentRegistrar(int /*long*/ address) {
+		super(address);
+	}
+
+	public int AutoRegister(int /*long*/ aSpec) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 1, getAddress(), aSpec);
+	}
+
+	public int AutoUnregister(int /*long*/ aSpec) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 2, getAddress(), aSpec);
+	}
+
+	public int RegisterFactory(nsID aClass, byte[] aClassName, byte[] aContractID, int /*long*/ aFactory) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 3, getAddress(), aClass, aClassName, aContractID, aFactory);
+	}
+
+	public int UnregisterFactory(nsID aClass, int /*long*/ aFactory) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 4, getAddress(), aClass, aFactory);
+	}
+
+	public int RegisterFactoryLocation(nsID aClass, byte[] aClassName, byte[] aContractID, int /*long*/ aFile, byte[] aLoaderStr, byte[] aType) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 5, getAddress(), aClass, aClassName, aContractID, aFile, aLoaderStr, aType);
+	}
+
+	public int UnregisterFactoryLocation(nsID aClass, int /*long*/ aFile) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 6, getAddress(), aClass, aFile);
+	}
+
+	public int IsCIDRegistered(nsID aClass, int[] _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 7, getAddress(), aClass, _retval);
+	}
+
+	public int IsContractIDRegistered(byte[] aContractID, int[] _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 8, getAddress(), aContractID, _retval);
+	}
+
+	public int EnumerateCIDs(int /*long*/[] _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 9, getAddress(), _retval);
+	}
+
+	public int EnumerateContractIDs(int /*long*/[] _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 10, getAddress(), _retval);
+	}
+
+	public int CIDToContractID(nsID aClass, int /*long*/[] _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 11, getAddress(), aClass, _retval);
+	}
+
+	public int ContractIDToCID(byte[] aContractID, int /*long*/ _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 12, getAddress(), aContractID, _retval);
+	}
+}
\ No newline at end of file


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIComponentRegistrar.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIContextMenuListener.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIContextMenuListener.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIContextMenuListener.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,59 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by Netscape are Copyright (C) 1998-1999
+ * Netscape Communications Corporation.  All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * -  Binding to permit interfacing between Mozilla and SWT
+ * -  Copyright (C) 2003, 2005 IBM Corp.  All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package org.eclipse.swt.internal.mozilla;
+
+public class nsIContextMenuListener extends nsISupports {
+
+	static final int LAST_METHOD_ID = nsISupports.LAST_METHOD_ID + 1;
+
+	public static final String NS_ICONTEXTMENULISTENER_IID_STR =
+		"3478b6b0-3875-11d4-94ef-0020183bf181";
+
+	public static final nsID NS_ICONTEXTMENULISTENER_IID =
+		new nsID(NS_ICONTEXTMENULISTENER_IID_STR);
+
+	public nsIContextMenuListener(int /*long*/ address) {
+		super(address);
+	}
+
+	public static final int CONTEXT_NONE = 0;
+
+	public static final int CONTEXT_LINK = 1;
+
+	public static final int CONTEXT_IMAGE = 2;
+
+	public static final int CONTEXT_DOCUMENT = 4;
+
+	public static final int CONTEXT_TEXT = 8;
+
+	public static final int CONTEXT_INPUT = 16;
+
+	public int OnShowContextMenu(int aContextFlags, int /*long*/ aEvent, int /*long*/ aNode) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 1, getAddress(), aContextFlags, aEvent, aNode);
+	}
+}
\ No newline at end of file


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIContextMenuListener.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsICookie.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsICookie.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsICookie.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,101 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by Netscape are Copyright (C) 1998-1999
+ * Netscape Communications Corporation.  All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * -  Binding to permit interfacing between Mozilla and SWT
+ * -  Copyright (C) 2003, 2008 IBM Corp.  All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package org.eclipse.swt.internal.mozilla;
+
+public class nsICookie extends nsISupports {
+
+	static final int LAST_METHOD_ID = nsISupports.LAST_METHOD_ID + 9;
+
+	public static final String NS_ICOOKIE_IID_STR =
+		"e9fcb9a4-d376-458f-b720-e65e7df593bc";
+
+	public static final nsID NS_ICOOKIE_IID =
+		new nsID(NS_ICOOKIE_IID_STR);
+
+	public nsICookie(int /*long*/ address) {
+		super(address);
+	}
+
+	public int GetName(int /*long*/ aName) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 1, getAddress(), aName);
+	}
+
+	public int GetValue(int /*long*/ aValue) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 2, getAddress(), aValue);
+	}
+
+	public int GetIsDomain(int[] aIsDomain) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 3, getAddress(), aIsDomain);
+	}
+
+	public int GetHost(int /*long*/ aHost) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 4, getAddress(), aHost);
+	}
+
+	public int GetPath(int /*long*/ aPath) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 5, getAddress(), aPath);
+	}
+
+	public int GetIsSecure(int[] aIsSecure) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 6, getAddress(), aIsSecure);
+	}
+
+	public int GetExpires(long[] aExpires) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 7, getAddress(), aExpires);
+	}
+
+	public static final int STATUS_UNKNOWN = 0;
+
+	public static final int STATUS_ACCEPTED = 1;
+
+	public static final int STATUS_DOWNGRADED = 2;
+
+	public static final int STATUS_FLAGGED = 3;
+
+	public static final int STATUS_REJECTED = 4;
+
+	public int GetStatus(int /*long*/ aStatus) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 8, getAddress(), aStatus);
+	}
+
+	public static final int POLICY_UNKNOWN = 0;
+
+	public static final int POLICY_NONE = 1;
+
+	public static final int POLICY_NO_CONSENT = 2;
+
+	public static final int POLICY_IMPLICIT_CONSENT = 3;
+
+	public static final int POLICY_EXPLICIT_CONSENT = 4;
+
+	public static final int POLICY_NO_II = 5;
+
+	public int GetPolicy(int /*long*/ aPolicy) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 9, getAddress(), aPolicy);
+	}
+}
\ No newline at end of file


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsICookie.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsICookieManager.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsICookieManager.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsICookieManager.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,55 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by Netscape are Copyright (C) 1998-1999
+ * Netscape Communications Corporation.  All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * -  Binding to permit interfacing between Mozilla and SWT
+ * -  Copyright (C) 2003, 2008 IBM Corp.  All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package org.eclipse.swt.internal.mozilla;
+
+public class nsICookieManager extends nsISupports {
+
+	static final int LAST_METHOD_ID = nsISupports.LAST_METHOD_ID + 3;
+
+	public static final String NS_ICOOKIEMANAGER_IID_STR =
+		"aaab6710-0f2c-11d5-a53b-0010a401eb10";
+
+	public static final nsID NS_ICOOKIEMANAGER_IID =
+		new nsID(NS_ICOOKIEMANAGER_IID_STR);
+
+	public nsICookieManager(int /*long*/ address) {
+		super(address);
+	}
+
+	public int RemoveAll() {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 1, getAddress());
+	}
+
+	public int GetEnumerator(int /*long*/[] aEnumerator) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 2, getAddress(), aEnumerator);
+	}
+
+	public int Remove(int /*long*/ aDomain, int /*long*/ aName, int /*long*/ aPath, int aBlocked) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 3, getAddress(), aDomain, aName, aPath, aBlocked);
+	}
+}
\ No newline at end of file


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsICookieManager.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsID.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsID.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsID.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,76 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by Netscape are Copyright (C) 1998-1999
+ * Netscape Communications Corporation.  All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * -  Binding to permit interfacing between Mozilla and SWT
+ * -  Copyright (C) 2003, 2004 IBM Corp.  All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package org.eclipse.swt.internal.mozilla;
+
+public class nsID {
+	
+	public int m0;
+	public short m1;
+	public short m2;
+	public byte[] m3 = new byte[8];
+	public static final int sizeof = 16;
+
+public nsID() {
+}
+
+public nsID(String id) {
+	Parse(id);
+}
+
+public boolean Equals(nsID other) {
+	int /*long*/ ptr = XPCOM.nsID_new();
+	XPCOM.memmove(ptr, this, nsID.sizeof);
+	int /*long*/ otherPtr = XPCOM.nsID_new();
+	XPCOM.memmove(otherPtr, other, nsID.sizeof);
+	boolean result = XPCOM.nsID_Equals(ptr, otherPtr) != 0;
+	XPCOM.nsID_delete(ptr);
+	XPCOM.nsID_delete(otherPtr);
+	return result;
+}
+
+public void Parse (String aIDStr) {
+	if(aIDStr == null) throw new Error ();
+	int i = 0;
+	for (; i < 8; i++) m0 = (m0 << 4) + Integer.parseInt (aIDStr.substring (i, i + 1), 16);
+	if (aIDStr.charAt (i++) != '-') throw new Error ();
+	for (; i < 13; i++) m1 = (short)((m1 << 4) + Integer.parseInt (aIDStr.substring (i, i + 1), 16));
+	if (aIDStr.charAt (i++) != '-') throw new Error ();
+	for (; i < 18; i++) m2 = (short)((m2 << 4) + Integer.parseInt (aIDStr.substring (i, i + 1), 16));
+	if (aIDStr.charAt (i++) != '-') throw new Error ();
+	for (; i < 21; i++) m3[0] = (byte)((m3[0] << 4) + Integer.parseInt (aIDStr.substring (i, i + 1), 16));
+	for (; i < 23; i++) m3[1] = (byte)((m3[1] << 4) + Integer.parseInt (aIDStr.substring (i, i + 1), 16));
+	if (aIDStr.charAt (i++) != '-') throw new Error ();
+	for (; i < 26; i++) m3[2] = (byte)((m3[2] << 4) + Integer.parseInt (aIDStr.substring (i, i + 1), 16));
+	for (; i < 28; i++) m3[3] = (byte)((m3[3] << 4) + Integer.parseInt (aIDStr.substring (i, i + 1), 16));
+	for (; i < 30; i++) m3[4] = (byte)((m3[4] << 4) + Integer.parseInt (aIDStr.substring (i, i + 1), 16));
+	for (; i < 32; i++) m3[5] = (byte)((m3[5] << 4) + Integer.parseInt (aIDStr.substring (i, i + 1), 16));
+	for (; i < 34; i++) m3[6] = (byte)((m3[6] << 4) + Integer.parseInt (aIDStr.substring (i, i + 1), 16));
+	for (; i < 36; i++) m3[7] = (byte)((m3[7] << 4) + Integer.parseInt (aIDStr.substring (i, i + 1), 16));
+}
+
+}
\ No newline at end of file


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsID.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIDOMEvent.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIDOMEvent.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIDOMEvent.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,89 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by Netscape are Copyright (C) 1998-1999
+ * Netscape Communications Corporation.  All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * -  Binding to permit interfacing between Mozilla and SWT
+ * -  Copyright (C) 2003, 2008 IBM Corp.  All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package org.eclipse.swt.internal.mozilla;
+
+public class nsIDOMEvent extends nsISupports {
+
+	static final int LAST_METHOD_ID = nsISupports.LAST_METHOD_ID + 10;
+
+	public static final String NS_IDOMEVENT_IID_STR =
+		"a66b7b80-ff46-bd97-0080-5f8ae38add32";
+
+	public static final nsID NS_IDOMEVENT_IID =
+		new nsID(NS_IDOMEVENT_IID_STR);
+
+	public nsIDOMEvent(int /*long*/ address) {
+		super(address);
+	}
+
+	public static final int CAPTURING_PHASE = 1;
+
+	public static final int AT_TARGET = 2;
+
+	public static final int BUBBLING_PHASE = 3;
+
+	public int GetType(int /*long*/ aType) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 1, getAddress(), aType);
+	}
+
+	public int GetTarget(int /*long*/[] aTarget) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 2, getAddress(), aTarget);
+	}
+
+	public int GetCurrentTarget(int /*long*/[] aCurrentTarget) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 3, getAddress(), aCurrentTarget);
+	}
+
+	public int GetEventPhase(short[] aEventPhase) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 4, getAddress(), aEventPhase);
+	}
+
+	public int GetBubbles(int[] aBubbles) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 5, getAddress(), aBubbles);
+	}
+
+	public int GetCancelable(int[] aCancelable) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 6, getAddress(), aCancelable);
+	}
+
+	public int GetTimeStamp(int /*long*/[] aTimeStamp) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 7, getAddress(), aTimeStamp);
+	}
+
+	public int StopPropagation() {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 8, getAddress());
+	}
+
+	public int PreventDefault() {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 9, getAddress());
+	}
+
+	public int InitEvent(int /*long*/ eventTypeArg, int canBubbleArg, int cancelableArg) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 10, getAddress(), eventTypeArg, canBubbleArg, cancelableArg);
+	}
+}
\ No newline at end of file


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIDOMEvent.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIDOMEventTarget.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIDOMEventTarget.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIDOMEventTarget.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,55 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by Netscape are Copyright (C) 1998-1999
+ * Netscape Communications Corporation.  All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * -  Binding to permit interfacing between Mozilla and SWT
+ * -  Copyright (C) 2003, 2008 IBM Corp.  All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package org.eclipse.swt.internal.mozilla;
+
+public class nsIDOMEventTarget extends nsISupports {
+
+	static final int LAST_METHOD_ID = nsISupports.LAST_METHOD_ID + 3;
+
+	public static final String NS_IDOMEVENTTARGET_IID_STR =
+		"1c773b30-d1cf-11d2-bd95-00805f8ae3f4";
+
+	public static final nsID NS_IDOMEVENTTARGET_IID =
+		new nsID(NS_IDOMEVENTTARGET_IID_STR);
+
+	public nsIDOMEventTarget(int /*long*/ address) {
+		super(address);
+	}
+
+	public int AddEventListener(int /*long*/ type, int /*long*/ listener, int useCapture) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 1, getAddress(), type, listener, useCapture);
+	}
+
+	public int RemoveEventListener(int /*long*/ type, int /*long*/ listener, int useCapture) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 2, getAddress(), type, listener, useCapture);
+	}
+
+	public int DispatchEvent(int /*long*/ evt, int[] _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 3, getAddress(), evt, _retval);
+	}
+}
\ No newline at end of file


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIDOMEventTarget.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIDOMKeyEvent.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIDOMKeyEvent.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIDOMKeyEvent.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,299 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by Netscape are Copyright (C) 1998-1999
+ * Netscape Communications Corporation.  All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * -  Binding to permit interfacing between Mozilla and SWT
+ * -  Copyright (C) 2003, 2008 IBM Corp.  All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package org.eclipse.swt.internal.mozilla;
+
+public class nsIDOMKeyEvent extends nsIDOMUIEvent {
+
+	static final int LAST_METHOD_ID = nsIDOMUIEvent.LAST_METHOD_ID + 7;
+
+	public static final String NS_IDOMKEYEVENT_IID_STR =
+		"028e0e6e-8b01-11d3-aae7-0010838a3123";
+
+	public static final nsID NS_IDOMKEYEVENT_IID =
+		new nsID(NS_IDOMKEYEVENT_IID_STR);
+
+	public nsIDOMKeyEvent(int /*long*/ address) {
+		super(address);
+	}
+
+	public static final int DOM_VK_CANCEL = 3;
+
+	public static final int DOM_VK_HELP = 6;
+
+	public static final int DOM_VK_BACK_SPACE = 8;
+
+	public static final int DOM_VK_TAB = 9;
+
+	public static final int DOM_VK_CLEAR = 12;
+
+	public static final int DOM_VK_RETURN = 13;
+
+	public static final int DOM_VK_ENTER = 14;
+
+	public static final int DOM_VK_SHIFT = 16;
+
+	public static final int DOM_VK_CONTROL = 17;
+
+	public static final int DOM_VK_ALT = 18;
+
+	public static final int DOM_VK_PAUSE = 19;
+
+	public static final int DOM_VK_CAPS_LOCK = 20;
+
+	public static final int DOM_VK_ESCAPE = 27;
+
+	public static final int DOM_VK_SPACE = 32;
+
+	public static final int DOM_VK_PAGE_UP = 33;
+
+	public static final int DOM_VK_PAGE_DOWN = 34;
+
+	public static final int DOM_VK_END = 35;
+
+	public static final int DOM_VK_HOME = 36;
+
+	public static final int DOM_VK_LEFT = 37;
+
+	public static final int DOM_VK_UP = 38;
+
+	public static final int DOM_VK_RIGHT = 39;
+
+	public static final int DOM_VK_DOWN = 40;
+
+	public static final int DOM_VK_PRINTSCREEN = 44;
+
+	public static final int DOM_VK_INSERT = 45;
+
+	public static final int DOM_VK_DELETE = 46;
+
+	public static final int DOM_VK_0 = 48;
+
+	public static final int DOM_VK_1 = 49;
+
+	public static final int DOM_VK_2 = 50;
+
+	public static final int DOM_VK_3 = 51;
+
+	public static final int DOM_VK_4 = 52;
+
+	public static final int DOM_VK_5 = 53;
+
+	public static final int DOM_VK_6 = 54;
+
+	public static final int DOM_VK_7 = 55;
+
+	public static final int DOM_VK_8 = 56;
+
+	public static final int DOM_VK_9 = 57;
+
+	public static final int DOM_VK_SEMICOLON = 59;
+
+	public static final int DOM_VK_EQUALS = 61;
+
+	public static final int DOM_VK_A = 65;
+
+	public static final int DOM_VK_B = 66;
+
+	public static final int DOM_VK_C = 67;
+
+	public static final int DOM_VK_D = 68;
+
+	public static final int DOM_VK_E = 69;
+
+	public static final int DOM_VK_F = 70;
+
+	public static final int DOM_VK_G = 71;
+
+	public static final int DOM_VK_H = 72;
+
+	public static final int DOM_VK_I = 73;
+
+	public static final int DOM_VK_J = 74;
+
+	public static final int DOM_VK_K = 75;
+
+	public static final int DOM_VK_L = 76;
+
+	public static final int DOM_VK_M = 77;
+
+	public static final int DOM_VK_N = 78;
+
+	public static final int DOM_VK_O = 79;
+
+	public static final int DOM_VK_P = 80;
+
+	public static final int DOM_VK_Q = 81;
+
+	public static final int DOM_VK_R = 82;
+
+	public static final int DOM_VK_S = 83;
+
+	public static final int DOM_VK_T = 84;
+
+	public static final int DOM_VK_U = 85;
+
+	public static final int DOM_VK_V = 86;
+
+	public static final int DOM_VK_W = 87;
+
+	public static final int DOM_VK_X = 88;
+
+	public static final int DOM_VK_Y = 89;
+
+	public static final int DOM_VK_Z = 90;
+
+	public static final int DOM_VK_NUMPAD0 = 96;
+
+	public static final int DOM_VK_NUMPAD1 = 97;
+
+	public static final int DOM_VK_NUMPAD2 = 98;
+
+	public static final int DOM_VK_NUMPAD3 = 99;
+
+	public static final int DOM_VK_NUMPAD4 = 100;
+
+	public static final int DOM_VK_NUMPAD5 = 101;
+
+	public static final int DOM_VK_NUMPAD6 = 102;
+
+	public static final int DOM_VK_NUMPAD7 = 103;
+
+	public static final int DOM_VK_NUMPAD8 = 104;
+
+	public static final int DOM_VK_NUMPAD9 = 105;
+
+	public static final int DOM_VK_MULTIPLY = 106;
+
+	public static final int DOM_VK_ADD = 107;
+
+	public static final int DOM_VK_SEPARATOR = 108;
+
+	public static final int DOM_VK_SUBTRACT = 109;
+
+	public static final int DOM_VK_DECIMAL = 110;
+
+	public static final int DOM_VK_DIVIDE = 111;
+
+	public static final int DOM_VK_F1 = 112;
+
+	public static final int DOM_VK_F2 = 113;
+
+	public static final int DOM_VK_F3 = 114;
+
+	public static final int DOM_VK_F4 = 115;
+
+	public static final int DOM_VK_F5 = 116;
+
+	public static final int DOM_VK_F6 = 117;
+
+	public static final int DOM_VK_F7 = 118;
+
+	public static final int DOM_VK_F8 = 119;
+
+	public static final int DOM_VK_F9 = 120;
+
+	public static final int DOM_VK_F10 = 121;
+
+	public static final int DOM_VK_F11 = 122;
+
+	public static final int DOM_VK_F12 = 123;
+
+	public static final int DOM_VK_F13 = 124;
+
+	public static final int DOM_VK_F14 = 125;
+
+	public static final int DOM_VK_F15 = 126;
+
+	public static final int DOM_VK_F16 = 127;
+
+	public static final int DOM_VK_F17 = 128;
+
+	public static final int DOM_VK_F18 = 129;
+
+	public static final int DOM_VK_F19 = 130;
+
+	public static final int DOM_VK_F20 = 131;
+
+	public static final int DOM_VK_F21 = 132;
+
+	public static final int DOM_VK_F22 = 133;
+
+	public static final int DOM_VK_F23 = 134;
+
+	public static final int DOM_VK_F24 = 135;
+
+	public static final int DOM_VK_NUM_LOCK = 144;
+
+	public static final int DOM_VK_SCROLL_LOCK = 145;
+
+	public static final int DOM_VK_COMMA = 188;
+
+	public static final int DOM_VK_PERIOD = 190;
+
+	public static final int DOM_VK_SLASH = 191;
+
+	public static final int DOM_VK_BACK_QUOTE = 192;
+
+	public static final int DOM_VK_OPEN_BRACKET = 219;
+
+	public static final int DOM_VK_BACK_SLASH = 220;
+
+	public static final int DOM_VK_CLOSE_BRACKET = 221;
+
+	public static final int DOM_VK_QUOTE = 222;
+
+	public static final int DOM_VK_META = 224;
+
+	public int GetCharCode(int[] aCharCode) {
+		return XPCOM.VtblCall(nsIDOMUIEvent.LAST_METHOD_ID + 1, getAddress(), aCharCode);
+	}
+
+	public int GetKeyCode(int[] aKeyCode) {
+		return XPCOM.VtblCall(nsIDOMUIEvent.LAST_METHOD_ID + 2, getAddress(), aKeyCode);
+	}
+
+	public int GetAltKey(int[] aAltKey) {
+		return XPCOM.VtblCall(nsIDOMUIEvent.LAST_METHOD_ID + 3, getAddress(), aAltKey);
+	}
+
+	public int GetCtrlKey(int[] aCtrlKey) {
+		return XPCOM.VtblCall(nsIDOMUIEvent.LAST_METHOD_ID + 4, getAddress(), aCtrlKey);
+	}
+
+	public int GetShiftKey(int[] aShiftKey) {
+		return XPCOM.VtblCall(nsIDOMUIEvent.LAST_METHOD_ID + 5, getAddress(), aShiftKey);
+	}
+
+	public int GetMetaKey(int[] aMetaKey) {
+		return XPCOM.VtblCall(nsIDOMUIEvent.LAST_METHOD_ID + 6, getAddress(), aMetaKey);
+	}
+
+	public int InitKeyEvent(int /*long*/ typeArg, int canBubbleArg, int cancelableArg, int /*long*/ viewArg, int ctrlKeyArg, int altKeyArg, int shiftKeyArg, int metaKeyArg, int keyCodeArg, int charCodeArg) {
+		return XPCOM.VtblCall(nsIDOMUIEvent.LAST_METHOD_ID + 7, getAddress(), typeArg, canBubbleArg, cancelableArg, viewArg, ctrlKeyArg, altKeyArg, shiftKeyArg, metaKeyArg, keyCodeArg, charCodeArg);
+	}
+}
\ No newline at end of file


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIDOMKeyEvent.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIDOMMouseEvent.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIDOMMouseEvent.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIDOMMouseEvent.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,87 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by Netscape are Copyright (C) 1998-1999
+ * Netscape Communications Corporation.  All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * -  Binding to permit interfacing between Mozilla and SWT
+ * -  Copyright (C) 2003, 2008 IBM Corp.  All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package org.eclipse.swt.internal.mozilla;
+
+public class nsIDOMMouseEvent extends nsIDOMUIEvent {
+
+	static final int LAST_METHOD_ID = nsIDOMUIEvent.LAST_METHOD_ID + 11;
+
+	public static final String NS_IDOMMOUSEEVENT_IID_STR =
+		"ff751edc-8b02-aae7-0010-8301838a3123";
+
+	public static final nsID NS_IDOMMOUSEEVENT_IID =
+		new nsID(NS_IDOMMOUSEEVENT_IID_STR);
+
+	public nsIDOMMouseEvent(int /*long*/ address) {
+		super(address);
+	}
+
+	public int GetScreenX(int[] aScreenX) {
+		return XPCOM.VtblCall(nsIDOMUIEvent.LAST_METHOD_ID + 1, getAddress(), aScreenX);
+	}
+
+	public int GetScreenY(int[] aScreenY) {
+		return XPCOM.VtblCall(nsIDOMUIEvent.LAST_METHOD_ID + 2, getAddress(), aScreenY);
+	}
+
+	public int GetClientX(int[] aClientX) {
+		return XPCOM.VtblCall(nsIDOMUIEvent.LAST_METHOD_ID + 3, getAddress(), aClientX);
+	}
+
+	public int GetClientY(int[] aClientY) {
+		return XPCOM.VtblCall(nsIDOMUIEvent.LAST_METHOD_ID + 4, getAddress(), aClientY);
+	}
+
+	public int GetCtrlKey(int[] aCtrlKey) {
+		return XPCOM.VtblCall(nsIDOMUIEvent.LAST_METHOD_ID + 5, getAddress(), aCtrlKey);
+	}
+
+	public int GetShiftKey(int[] aShiftKey) {
+		return XPCOM.VtblCall(nsIDOMUIEvent.LAST_METHOD_ID + 6, getAddress(), aShiftKey);
+	}
+
+	public int GetAltKey(int[] aAltKey) {
+		return XPCOM.VtblCall(nsIDOMUIEvent.LAST_METHOD_ID + 7, getAddress(), aAltKey);
+	}
+
+	public int GetMetaKey(int[] aMetaKey) {
+		return XPCOM.VtblCall(nsIDOMUIEvent.LAST_METHOD_ID + 8, getAddress(), aMetaKey);
+	}
+
+	public int GetButton(short[] aButton) {
+		return XPCOM.VtblCall(nsIDOMUIEvent.LAST_METHOD_ID + 9, getAddress(), aButton);
+	}
+
+	public int GetRelatedTarget(int /*long*/[] aRelatedTarget) {
+		return XPCOM.VtblCall(nsIDOMUIEvent.LAST_METHOD_ID + 10, getAddress(), aRelatedTarget);
+	}
+
+	public int InitMouseEvent(int /*long*/ typeArg, int canBubbleArg, int cancelableArg, int /*long*/ viewArg, int detailArg, int screenXArg, int screenYArg, int clientXArg, int clientYArg, int ctrlKeyArg, int altKeyArg, int shiftKeyArg, int metaKeyArg, short buttonArg, int /*long*/ relatedTargetArg) {
+		return XPCOM.VtblCall(nsIDOMUIEvent.LAST_METHOD_ID + 11, getAddress(), typeArg, canBubbleArg, cancelableArg, viewArg, detailArg, screenXArg, screenYArg, clientXArg, clientYArg, ctrlKeyArg, altKeyArg, shiftKeyArg, metaKeyArg, buttonArg, relatedTargetArg);
+	}
+}
\ No newline at end of file


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIDOMMouseEvent.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIDOMSerializer.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIDOMSerializer.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIDOMSerializer.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,51 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by Netscape are Copyright (C) 1998-1999
+ * Netscape Communications Corporation.  All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * -  Binding to permit interfacing between Mozilla and SWT
+ * -  Copyright (C) 2003 IBM Corp.  All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package org.eclipse.swt.internal.mozilla;
+
+public class nsIDOMSerializer extends nsISupports {
+
+	static final int LAST_METHOD_ID = nsISupports.LAST_METHOD_ID + 2;
+
+	public static final String NS_IDOMSERIALIZER_IID_STR =
+		"a6cf9123-15b3-11d2-932e-00805f8add32";
+
+	public static final nsID NS_IDOMSERIALIZER_IID =
+		new nsID(NS_IDOMSERIALIZER_IID_STR);
+
+	public nsIDOMSerializer(int /*long*/ address) {
+		super(address);
+	}
+
+	public int SerializeToString(int /*long*/ root, int /*long*/[] _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 1, getAddress(), root, _retval);
+	}
+
+	public int SerializeToStream(int /*long*/ root, int /*long*/ stream, byte[] charset) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 2, getAddress(), root, stream, charset);
+	}
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIDOMSerializer.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIDOMSerializer_1_7.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIDOMSerializer_1_7.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIDOMSerializer_1_7.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,51 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by Netscape are Copyright (C) 1998-1999
+ * Netscape Communications Corporation.  All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * -  Binding to permit interfacing between Mozilla and SWT
+ * -  Copyright (C) 2003 IBM Corp.  All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package org.eclipse.swt.internal.mozilla;
+
+public class nsIDOMSerializer_1_7 extends nsISupports {
+
+	static final int LAST_METHOD_ID = nsISupports.LAST_METHOD_ID + 2;
+
+	public static final String NS_IDOMSERIALIZER_IID_STR =
+		"9fd4ba15-e67c-4c98-b52c-7715f62c9196";
+
+	public static final nsID NS_IDOMSERIALIZER_IID =
+		new nsID(NS_IDOMSERIALIZER_IID_STR);
+
+	public nsIDOMSerializer_1_7(int /*long*/ address) {
+		super(address);
+	}
+
+	public int SerializeToString(int /*long*/ root, int /*long*/ _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 1, getAddress(), root, _retval);
+	}
+
+	public int SerializeToStream(int /*long*/ root, int /*long*/ stream, int /*long*/ charset) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 2, getAddress(), root, stream, charset);
+	}
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIDOMSerializer_1_7.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIDOMUIEvent.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIDOMUIEvent.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIDOMUIEvent.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,55 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by Netscape are Copyright (C) 1998-1999
+ * Netscape Communications Corporation.  All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * -  Binding to permit interfacing between Mozilla and SWT
+ * -  Copyright (C) 2003, 2008 IBM Corp.  All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package org.eclipse.swt.internal.mozilla;
+
+public class nsIDOMUIEvent extends nsIDOMEvent {
+
+	static final int LAST_METHOD_ID = nsIDOMEvent.LAST_METHOD_ID + 3;
+
+	public static final String NS_IDOMUIEVENT_IID_STR =
+		"a6cf90c3-15b3-11d2-932e-00805f8add32";
+
+	public static final nsID NS_IDOMUIEVENT_IID =
+		new nsID(NS_IDOMUIEVENT_IID_STR);
+
+	public nsIDOMUIEvent(int /*long*/ address) {
+		super(address);
+	}
+
+	public int GetView(int /*long*/[] aView) {
+		return XPCOM.VtblCall(nsIDOMEvent.LAST_METHOD_ID + 1, getAddress(), aView);
+	}
+
+	public int GetDetail(int[] aDetail) {
+		return XPCOM.VtblCall(nsIDOMEvent.LAST_METHOD_ID + 2, getAddress(), aDetail);
+	}
+
+	public int InitUIEvent(int /*long*/ typeArg, int canBubbleArg, int cancelableArg, int /*long*/ viewArg, int detailArg) {
+		return XPCOM.VtblCall(nsIDOMEvent.LAST_METHOD_ID + 3, getAddress(), typeArg, canBubbleArg, cancelableArg, viewArg, detailArg);
+	}
+}
\ No newline at end of file


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIDOMUIEvent.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIDOMWindow.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIDOMWindow.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIDOMWindow.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,111 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by Netscape are Copyright (C) 1998-1999
+ * Netscape Communications Corporation.  All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * -  Binding to permit interfacing between Mozilla and SWT
+ * -  Copyright (C) 2003, 2005 IBM Corp.  All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package org.eclipse.swt.internal.mozilla;
+
+public class nsIDOMWindow extends nsISupports {
+
+	static final int LAST_METHOD_ID = nsISupports.LAST_METHOD_ID + 17;
+
+	public static final String NS_IDOMWINDOW_IID_STR =
+		"a6cf906b-15b3-11d2-932e-00805f8add32";
+
+	public static final nsID NS_IDOMWINDOW_IID =
+		new nsID(NS_IDOMWINDOW_IID_STR);
+
+	public nsIDOMWindow(int /*long*/ address) {
+		super(address);
+	}
+
+	public int GetDocument(int /*long*/[] aDocument) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 1, getAddress(), aDocument);
+	}
+
+	public int GetParent(int /*long*/[] aParent) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 2, getAddress(), aParent);
+	}
+
+	public int GetTop(int /*long*/[] aTop) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 3, getAddress(), aTop);
+	}
+
+	public int GetScrollbars(int /*long*/[] aScrollbars) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 4, getAddress(), aScrollbars);
+	}
+
+	public int GetFrames(int /*long*/[] aFrames) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 5, getAddress(), aFrames);
+	}
+
+	public int GetName(int /*long*/ aName) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 6, getAddress(), aName);
+	}
+
+	public int SetName(int /*long*/ aName) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 7, getAddress(), aName);
+	}
+
+	public int GetTextZoom(float[] aTextZoom) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 8, getAddress(), aTextZoom);
+	}
+
+	public int SetTextZoom(float aTextZoom) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 9, getAddress(), aTextZoom);
+	}
+
+	public int GetScrollX(int[] aScrollX) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 10, getAddress(), aScrollX);
+	}
+
+	public int GetScrollY(int[] aScrollY) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 11, getAddress(), aScrollY);
+	}
+
+	public int ScrollTo(int xScroll, int yScroll) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 12, getAddress(), xScroll, yScroll);
+	}
+
+	public int ScrollBy(int xScrollDif, int yScrollDif) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 13, getAddress(), xScrollDif, yScrollDif);
+	}
+
+	public int GetSelection(int /*long*/[] _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 14, getAddress(), _retval);
+	}
+
+	public int ScrollByLines(int numLines) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 15, getAddress(), numLines);
+	}
+
+	public int ScrollByPages(int numPages) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 16, getAddress(), numPages);
+	}
+
+	public int SizeToContent() {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 17, getAddress());
+	}
+}
\ No newline at end of file


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIDOMWindow.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIDOMWindowCollection.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIDOMWindowCollection.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIDOMWindowCollection.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,55 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by Netscape are Copyright (C) 1998-1999
+ * Netscape Communications Corporation.  All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * -  Binding to permit interfacing between Mozilla and SWT
+ * -  Copyright (C) 2003 IBM Corp.  All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package org.eclipse.swt.internal.mozilla;
+
+public class nsIDOMWindowCollection extends nsISupports {
+
+	static final int LAST_METHOD_ID = nsISupports.LAST_METHOD_ID + 3;
+
+	public static final String NS_IDOMWINDOWCOLLECTION_IID_STR =
+		"a6cf906f-15b3-11d2-932e-00805f8add32";
+
+	public static final nsID NS_IDOMWINDOWCOLLECTION_IID =
+		new nsID(NS_IDOMWINDOWCOLLECTION_IID_STR);
+
+	public nsIDOMWindowCollection(int /*long*/ address) {
+		super(address);
+	}
+
+	public int GetLength(int[] aLength) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 1, getAddress(), aLength);
+	}
+
+	public int Item(int index, int /*long*/[] _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 2, getAddress(), index, _retval);
+	}
+
+	public int NamedItem(int /*long*/ name, int /*long*/[] _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 3, getAddress(), name, _retval);
+	}
+}
\ No newline at end of file


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIDOMWindowCollection.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIDirectoryService.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIDirectoryService.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIDirectoryService.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,55 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by Netscape are Copyright (C) 1998-1999
+ * Netscape Communications Corporation.  All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * -  Binding to permit interfacing between Mozilla and SWT
+ * -  Copyright (C) 2003 IBM Corp.  All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package org.eclipse.swt.internal.mozilla;
+
+public class nsIDirectoryService extends nsISupports {
+
+	static final int LAST_METHOD_ID = nsISupports.LAST_METHOD_ID + 3;
+
+	public static final String NS_IDIRECTORYSERVICE_IID_STR =
+		"57a66a60-d43a-11d3-8cc2-00609792278c";
+
+	public static final nsID NS_IDIRECTORYSERVICE_IID =
+		new nsID(NS_IDIRECTORYSERVICE_IID_STR);
+
+	public nsIDirectoryService(int /*long*/ address) {
+		super(address);
+	}
+
+	public int Init() {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 1, getAddress());
+	}
+
+	public int RegisterProvider(int /*long*/ prov) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 2, getAddress(), prov);
+	}
+
+	public int UnregisterProvider(int /*long*/ prov) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 3, getAddress(), prov);
+	}
+}
\ No newline at end of file


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIDirectoryService.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIDirectoryServiceProvider.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIDirectoryServiceProvider.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIDirectoryServiceProvider.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,47 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by Netscape are Copyright (C) 1998-1999
+ * Netscape Communications Corporation.  All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * -  Binding to permit interfacing between Mozilla and SWT
+ * -  Copyright (C) 2003, 2008 IBM Corp.  All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package org.eclipse.swt.internal.mozilla;
+
+public class nsIDirectoryServiceProvider extends nsISupports {
+
+	static final int LAST_METHOD_ID = nsISupports.LAST_METHOD_ID + 1;
+
+	public static final String NS_IDIRECTORYSERVICEPROVIDER_IID_STR =
+		"bbf8cab0-d43a-11d3-8cc2-00609792278c";
+
+	public static final nsID NS_IDIRECTORYSERVICEPROVIDER_IID =
+		new nsID(NS_IDIRECTORYSERVICEPROVIDER_IID_STR);
+
+	public nsIDirectoryServiceProvider(int /*long*/ address) {
+		super(address);
+	}
+
+	public int GetFile(byte[] prop, int[] persistent, int /*long*/[] _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 1, getAddress(), prop, persistent, _retval);
+	}
+}
\ No newline at end of file


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIDirectoryServiceProvider.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIDirectoryServiceProvider2.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIDirectoryServiceProvider2.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIDirectoryServiceProvider2.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,47 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by Netscape are Copyright (C) 1998-1999
+ * Netscape Communications Corporation.  All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * -  Binding to permit interfacing between Mozilla and SWT
+ * -  Copyright (C) 2003 IBM Corp.  All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package org.eclipse.swt.internal.mozilla;
+
+public class nsIDirectoryServiceProvider2 extends nsIDirectoryServiceProvider {
+
+	static final int LAST_METHOD_ID = nsIDirectoryServiceProvider.LAST_METHOD_ID + 1;
+
+	public static final String NS_IDIRECTORYSERVICEPROVIDER2_IID_STRING =
+		"2f977d4b-5485-11d4-87e2-0010a4e75ef2";
+
+	public static final nsID NS_IDIRECTORYSERVICEPROVIDER2_IID =
+		new nsID(NS_IDIRECTORYSERVICEPROVIDER2_IID_STRING);
+
+	public nsIDirectoryServiceProvider2(int /*long*/ address) {
+		super(address);
+	}
+
+	public int GetFiles(byte[] prop, int /*long*/[] _retval) {
+		return XPCOM.VtblCall(nsIDirectoryServiceProvider.LAST_METHOD_ID + 1, getAddress(), prop, _retval);
+	}
+}
\ No newline at end of file


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIDirectoryServiceProvider2.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIDocShell.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIDocShell.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIDocShell.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,269 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by Netscape are Copyright (C) 1998-1999
+ * Netscape Communications Corporation.  All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * -  Binding to permit interfacing between Mozilla and SWT
+ * -  Copyright (C) 2003, 2008 IBM Corp.  All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package org.eclipse.swt.internal.mozilla;
+
+public class nsIDocShell extends nsISupports {
+
+	static final int LAST_METHOD_ID = nsISupports.LAST_METHOD_ID + 51;
+
+	public static final String NS_IDOCSHELL_IID_STR =
+		"69e5de00-7b8b-11d3-af61-00a024ffc08c";
+
+	public static final nsID NS_IDOCSHELL_IID =
+		new nsID(NS_IDOCSHELL_IID_STR);
+
+	public nsIDocShell(int /*long*/ address) {
+		super(address);
+	}
+
+	public int LoadURI(int /*long*/ uri, int /*long*/ loadInfo, int aLoadFlags, int firstParty) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 1, getAddress(), uri, loadInfo, aLoadFlags, firstParty);
+	}
+
+	public int LoadStream(int /*long*/ aStream, int /*long*/ aURI, int /*long*/ aContentType, int /*long*/ aContentCharset, int /*long*/ aLoadInfo) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 2, getAddress(), aStream, aURI, aContentType, aContentCharset, aLoadInfo);
+	}
+
+	public int InternalLoad(int /*long*/ aURI, int /*long*/ aReferrer, int /*long*/ aOwner, int aInheritOwner, char[] aWindowTarget, int /*long*/ aPostDataStream, int /*long*/ aHeadersStream, int aLoadFlags, int /*long*/ aSHEntry, int firstParty, int /*long*/[] aDocShell, int /*long*/[] aRequest) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 3, getAddress(), aURI, aReferrer, aOwner, aInheritOwner, aWindowTarget, aPostDataStream, aHeadersStream, aLoadFlags, aSHEntry, firstParty, aDocShell, aRequest);
+	}
+
+	public int CreateLoadInfo(int /*long*/[] loadInfo) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 4, getAddress(), loadInfo);
+	}
+
+	public int PrepareForNewContentModel() {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 5, getAddress());
+	}
+
+	public int SetCurrentURI(int /*long*/ aURI) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 6, getAddress(), aURI);
+	}
+
+	public int FireUnloadNotification() {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 7, getAddress());
+	}
+
+	public int GetPresContext(int /*long*/[] aPresContext) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 8, getAddress(), aPresContext);
+	}
+
+	public int GetPresShell(int /*long*/[] aPresShell) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 9, getAddress(), aPresShell);
+	}
+
+	public int GetEldestPresShell(int /*long*/[] aEldestPresShell) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 10, getAddress(), aEldestPresShell);
+	}
+
+	public int GetContentViewer(int /*long*/[] aContentViewer) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 11, getAddress(), aContentViewer);
+	}
+
+	public int GetChromeEventHandler(int /*long*/[] aChromeEventHandler) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 12, getAddress(), aChromeEventHandler);
+	}
+
+	public int SetChromeEventHandler(int /*long*/ aChromeEventHandler) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 13, getAddress(), aChromeEventHandler);
+	}
+
+	public int GetParentURIContentListener(int /*long*/[] aParentURIContentListener) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 14, getAddress(), aParentURIContentListener);
+	}
+
+	public int SetParentURIContentListener(int /*long*/ aParentURIContentListener) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 15, getAddress(), aParentURIContentListener);
+	}
+
+	public int GetDocumentCharsetInfo(int /*long*/[] aDocumentCharsetInfo) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 16, getAddress(), aDocumentCharsetInfo);
+	}
+
+	public int SetDocumentCharsetInfo(int /*long*/ aDocumentCharsetInfo) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 17, getAddress(), aDocumentCharsetInfo);
+	}
+
+	public int GetAllowPlugins(int[] aAllowPlugins) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 18, getAddress(), aAllowPlugins);
+	}
+
+	public int SetAllowPlugins(int aAllowPlugins) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 19, getAddress(), aAllowPlugins);
+	}
+
+	public int GetAllowJavascript(int[] aAllowJavascript) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 20, getAddress(), aAllowJavascript);
+	}
+
+	public int SetAllowJavascript(int aAllowJavascript) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 21, getAddress(), aAllowJavascript);
+	}
+
+	public int GetAllowMetaRedirects(int[] aAllowMetaRedirects) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 22, getAddress(), aAllowMetaRedirects);
+	}
+
+	public int SetAllowMetaRedirects(int aAllowMetaRedirects) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 23, getAddress(), aAllowMetaRedirects);
+	}
+
+	public int GetAllowSubframes(int[] aAllowSubframes) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 24, getAddress(), aAllowSubframes);
+	}
+
+	public int SetAllowSubframes(int aAllowSubframes) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 25, getAddress(), aAllowSubframes);
+	}
+
+	public int GetAllowImages(int[] aAllowImages) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 26, getAddress(), aAllowImages);
+	}
+
+	public int SetAllowImages(int aAllowImages) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 27, getAddress(), aAllowImages);
+	}
+
+	public static final int ENUMERATE_FORWARDS = 0;
+
+	public static final int ENUMERATE_BACKWARDS = 1;
+
+	public int GetDocShellEnumerator(int aItemType, int aDirection, int /*long*/[] _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 28, getAddress(), aItemType, aDirection, _retval);
+	}
+
+	public static final int APP_TYPE_UNKNOWN = 0;
+
+	public static final int APP_TYPE_MAIL = 1;
+
+	public int GetAppType(int[] aAppType) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 29, getAddress(), aAppType);
+	}
+
+	public int SetAppType(int aAppType) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 30, getAddress(), aAppType);
+	}
+
+	public int GetAllowAuth(int[] aAllowAuth) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 31, getAddress(), aAllowAuth);
+	}
+
+	public int SetAllowAuth(int aAllowAuth) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 32, getAddress(), aAllowAuth);
+	}
+
+	public int GetZoom(float[] aZoom) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 33, getAddress(), aZoom);
+	}
+
+	public int SetZoom(float aZoom) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 34, getAddress(), aZoom);
+	}
+
+	public int GetMarginWidth(int[] aMarginWidth) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 35, getAddress(), aMarginWidth);
+	}
+
+	public int SetMarginWidth(int aMarginWidth) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 36, getAddress(), aMarginWidth);
+	}
+
+	public int GetMarginHeight(int[] aMarginHeight) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 37, getAddress(), aMarginHeight);
+	}
+
+	public int SetMarginHeight(int aMarginHeight) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 38, getAddress(), aMarginHeight);
+	}
+
+	public int GetHasFocus(int[] aHasFocus) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 39, getAddress(), aHasFocus);
+	}
+
+	public int SetHasFocus(int aHasFocus) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 40, getAddress(), aHasFocus);
+	}
+
+	public int GetCanvasHasFocus(int[] aCanvasHasFocus) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 41, getAddress(), aCanvasHasFocus);
+	}
+
+	public int SetCanvasHasFocus(int aCanvasHasFocus) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 42, getAddress(), aCanvasHasFocus);
+	}
+
+	public int TabToTreeOwner(int forward, int[] tookFocus) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 43, getAddress(), forward, tookFocus);
+	}
+
+	public static final int BUSY_FLAGS_NONE = 0;
+
+	public static final int BUSY_FLAGS_BUSY = 1;
+
+	public static final int BUSY_FLAGS_BEFORE_PAGE_LOAD = 2;
+
+	public static final int BUSY_FLAGS_PAGE_LOADING = 4;
+
+	public static final int LOAD_CMD_NORMAL = 1;
+
+	public static final int LOAD_CMD_RELOAD = 2;
+
+	public static final int LOAD_CMD_HISTORY = 4;
+
+	public int GetBusyFlags(int[] aBusyFlags) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 44, getAddress(), aBusyFlags);
+	}
+
+	public int GetLoadType(int[] aLoadType) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 45, getAddress(), aLoadType);
+	}
+
+	public int SetLoadType(int aLoadType) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 46, getAddress(), aLoadType);
+	}
+
+	public int IsBeingDestroyed(int[] _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 47, getAddress(), _retval);
+	}
+
+	public int GetIsExecutingOnLoadHandler(int[] aIsExecutingOnLoadHandler) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 48, getAddress(), aIsExecutingOnLoadHandler);
+	}
+
+	public int GetLayoutHistoryState(int /*long*/[] aLayoutHistoryState) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 49, getAddress(), aLayoutHistoryState);
+	}
+
+	public int SetLayoutHistoryState(int /*long*/ aLayoutHistoryState) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 50, getAddress(), aLayoutHistoryState);
+	}
+
+	public int GetShouldSaveLayoutState(int[] aShouldSaveLayoutState) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 51, getAddress(), aShouldSaveLayoutState);
+	}
+}
\ No newline at end of file


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIDocShell.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIDocShell_1_8.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIDocShell_1_8.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIDocShell_1_8.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,317 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by Netscape are Copyright (C) 1998-1999
+ * Netscape Communications Corporation.  All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * -  Binding to permit interfacing between Mozilla and SWT
+ * -  Copyright (C) 2003, 2008 IBM Corp.  All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package org.eclipse.swt.internal.mozilla;
+
+public class nsIDocShell_1_8 extends nsISupports {
+
+	static final int LAST_METHOD_ID = nsISupports.LAST_METHOD_ID + 61;
+
+	public static final String NS_IDOCSHELL_IID_STR =
+		"9f0c7461-b9a4-47f6-b88c-421dce1bce66";
+
+	public static final nsID NS_IDOCSHELL_IID =
+		new nsID(NS_IDOCSHELL_IID_STR);
+
+	public nsIDocShell_1_8(int /*long*/ address) {
+		super(address);
+	}
+
+	public int LoadURI(int /*long*/ uri, int /*long*/ loadInfo, int aLoadFlags, int firstParty) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 1, getAddress(), uri, loadInfo, aLoadFlags, firstParty);
+	}
+
+	public int LoadStream(int /*long*/ aStream, int /*long*/ aURI, int /*long*/ aContentType, int /*long*/ aContentCharset, int /*long*/ aLoadInfo) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 2, getAddress(), aStream, aURI, aContentType, aContentCharset, aLoadInfo);
+	}
+
+	public static final int INTERNAL_LOAD_FLAGS_NONE = 0;
+
+	public static final int INTERNAL_LOAD_FLAGS_INHERIT_OWNER = 1;
+
+	public static final int INTERNAL_LOAD_FLAGS_DONT_SEND_REFERRER = 2;
+
+	public int InternalLoad(int /*long*/ aURI, int /*long*/ aReferrer, int /*long*/ aOwner, int aFlags, char[] aWindowTarget, byte[] aTypeHint, int /*long*/ aPostDataStream, int /*long*/ aHeadersStream, int aLoadFlags, int /*long*/ aSHEntry, int firstParty, int /*long*/[] aDocShell, int /*long*/[] aRequest) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 3, getAddress(), aURI, aReferrer, aOwner, aFlags, aWindowTarget, aTypeHint, aPostDataStream, aHeadersStream, aLoadFlags, aSHEntry, firstParty, aDocShell, aRequest);
+	}
+
+	public int CreateLoadInfo(int /*long*/[] loadInfo) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 4, getAddress(), loadInfo);
+	}
+
+	public int PrepareForNewContentModel() {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 5, getAddress());
+	}
+
+	public int SetCurrentURI(int /*long*/ aURI) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 6, getAddress(), aURI);
+	}
+
+	public int FirePageHideNotification(int isUnload) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 7, getAddress(), isUnload);
+	}
+
+	public int GetPresContext(int /*long*/[] aPresContext) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 8, getAddress(), aPresContext);
+	}
+
+	public int GetPresShell(int /*long*/[] aPresShell) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 9, getAddress(), aPresShell);
+	}
+
+	public int GetEldestPresShell(int /*long*/[] aEldestPresShell) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 10, getAddress(), aEldestPresShell);
+	}
+
+	public int GetContentViewer(int /*long*/[] aContentViewer) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 11, getAddress(), aContentViewer);
+	}
+
+	public int GetChromeEventHandler(int /*long*/[] aChromeEventHandler) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 12, getAddress(), aChromeEventHandler);
+	}
+
+	public int SetChromeEventHandler(int /*long*/ aChromeEventHandler) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 13, getAddress(), aChromeEventHandler);
+	}
+
+	public int GetDocumentCharsetInfo(int /*long*/[] aDocumentCharsetInfo) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 14, getAddress(), aDocumentCharsetInfo);
+	}
+
+	public int SetDocumentCharsetInfo(int /*long*/ aDocumentCharsetInfo) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 15, getAddress(), aDocumentCharsetInfo);
+	}
+
+	public int GetAllowPlugins(int[] aAllowPlugins) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 16, getAddress(), aAllowPlugins);
+	}
+
+	public int SetAllowPlugins(int aAllowPlugins) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 17, getAddress(), aAllowPlugins);
+	}
+
+	public int GetAllowJavascript(int[] aAllowJavascript) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 18, getAddress(), aAllowJavascript);
+	}
+
+	public int SetAllowJavascript(int aAllowJavascript) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 19, getAddress(), aAllowJavascript);
+	}
+
+	public int GetAllowMetaRedirects(int[] aAllowMetaRedirects) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 20, getAddress(), aAllowMetaRedirects);
+	}
+
+	public int SetAllowMetaRedirects(int aAllowMetaRedirects) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 21, getAddress(), aAllowMetaRedirects);
+	}
+
+	public int GetAllowSubframes(int[] aAllowSubframes) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 22, getAddress(), aAllowSubframes);
+	}
+
+	public int SetAllowSubframes(int aAllowSubframes) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 23, getAddress(), aAllowSubframes);
+	}
+
+	public int GetAllowImages(int[] aAllowImages) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 24, getAddress(), aAllowImages);
+	}
+
+	public int SetAllowImages(int aAllowImages) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 25, getAddress(), aAllowImages);
+	}
+
+	public static final int ENUMERATE_FORWARDS = 0;
+
+	public static final int ENUMERATE_BACKWARDS = 1;
+
+	public int GetDocShellEnumerator(int aItemType, int aDirection, int /*long*/[] _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 26, getAddress(), aItemType, aDirection, _retval);
+	}
+
+	public static final int APP_TYPE_UNKNOWN = 0;
+
+	public static final int APP_TYPE_MAIL = 1;
+
+	public static final int APP_TYPE_EDITOR = 2;
+
+	public int GetAppType(int[] aAppType) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 27, getAddress(), aAppType);
+	}
+
+	public int SetAppType(int aAppType) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 28, getAddress(), aAppType);
+	}
+
+	public int GetAllowAuth(int[] aAllowAuth) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 29, getAddress(), aAllowAuth);
+	}
+
+	public int SetAllowAuth(int aAllowAuth) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 30, getAddress(), aAllowAuth);
+	}
+
+	public int GetZoom(float[] aZoom) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 31, getAddress(), aZoom);
+	}
+
+	public int SetZoom(float aZoom) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 32, getAddress(), aZoom);
+	}
+
+	public int GetMarginWidth(int[] aMarginWidth) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 33, getAddress(), aMarginWidth);
+	}
+
+	public int SetMarginWidth(int aMarginWidth) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 34, getAddress(), aMarginWidth);
+	}
+
+	public int GetMarginHeight(int[] aMarginHeight) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 35, getAddress(), aMarginHeight);
+	}
+
+	public int SetMarginHeight(int aMarginHeight) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 36, getAddress(), aMarginHeight);
+	}
+
+	public int GetHasFocus(int[] aHasFocus) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 37, getAddress(), aHasFocus);
+	}
+
+	public int SetHasFocus(int aHasFocus) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 38, getAddress(), aHasFocus);
+	}
+
+	public int GetCanvasHasFocus(int[] aCanvasHasFocus) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 39, getAddress(), aCanvasHasFocus);
+	}
+
+	public int SetCanvasHasFocus(int aCanvasHasFocus) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 40, getAddress(), aCanvasHasFocus);
+	}
+
+	public int TabToTreeOwner(int forward, int[] tookFocus) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 41, getAddress(), forward, tookFocus);
+	}
+
+	public static final int BUSY_FLAGS_NONE = 0;
+
+	public static final int BUSY_FLAGS_BUSY = 1;
+
+	public static final int BUSY_FLAGS_BEFORE_PAGE_LOAD = 2;
+
+	public static final int BUSY_FLAGS_PAGE_LOADING = 4;
+
+	public static final int LOAD_CMD_NORMAL = 1;
+
+	public static final int LOAD_CMD_RELOAD = 2;
+
+	public static final int LOAD_CMD_HISTORY = 4;
+
+	public int GetBusyFlags(int[] aBusyFlags) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 42, getAddress(), aBusyFlags);
+	}
+
+	public int GetLoadType(int[] aLoadType) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 43, getAddress(), aLoadType);
+	}
+
+	public int SetLoadType(int aLoadType) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 44, getAddress(), aLoadType);
+	}
+
+	public int IsBeingDestroyed(int[] _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 45, getAddress(), _retval);
+	}
+
+	public int GetIsExecutingOnLoadHandler(int[] aIsExecutingOnLoadHandler) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 46, getAddress(), aIsExecutingOnLoadHandler);
+	}
+
+	public int GetLayoutHistoryState(int /*long*/[] aLayoutHistoryState) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 47, getAddress(), aLayoutHistoryState);
+	}
+
+	public int SetLayoutHistoryState(int /*long*/ aLayoutHistoryState) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 48, getAddress(), aLayoutHistoryState);
+	}
+
+	public int GetShouldSaveLayoutState(int[] aShouldSaveLayoutState) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 49, getAddress(), aShouldSaveLayoutState);
+	}
+
+	public int GetSecurityUI(int /*long*/[] aSecurityUI) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 50, getAddress(), aSecurityUI);
+	}
+
+	public int SetSecurityUI(int /*long*/ aSecurityUI) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 51, getAddress(), aSecurityUI);
+	}
+
+	public int SuspendRefreshURIs() {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 52, getAddress());
+	}
+
+	public int ResumeRefreshURIs() {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 53, getAddress());
+	}
+
+	public int BeginRestore(int /*long*/ viewer, int top) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 54, getAddress(), viewer, top);
+	}
+
+	public int FinishRestore() {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 55, getAddress());
+	}
+
+	public int GetRestoringDocument(int[] aRestoringDocument) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 56, getAddress(), aRestoringDocument);
+	}
+
+	public int GetUseErrorPages(int[] aUseErrorPages) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 57, getAddress(), aUseErrorPages);
+	}
+
+	public int SetUseErrorPages(int aUseErrorPages) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 58, getAddress(), aUseErrorPages);
+	}
+
+	public int GetPreviousTransIndex(int[] aPreviousTransIndex) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 59, getAddress(), aPreviousTransIndex);
+	}
+
+	public int GetLoadedTransIndex(int[] aLoadedTransIndex) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 60, getAddress(), aLoadedTransIndex);
+	}
+
+	public int HistoryPurged(int numEntries) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 61, getAddress(), numEntries);
+	}
+}
\ No newline at end of file


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIDocShell_1_8.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIDocShell_1_9.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIDocShell_1_9.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIDocShell_1_9.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,347 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by Netscape are Copyright (C) 1998-1999
+ * Netscape Communications Corporation.  All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * -  Binding to permit interfacing between Mozilla and SWT
+ * -  Copyright (C) 2003, 2008 IBM Corp.  All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package org.eclipse.swt.internal.mozilla;
+
+public class nsIDocShell_1_9 extends nsISupports {
+
+	static final int LAST_METHOD_ID = nsISupports.LAST_METHOD_ID + 67;
+
+	public static final String NS_IDOCSHELL_IID_STR =
+		"7d1cf6b9-daa3-476d-8f9f-9eb2a971a95c";
+
+	public static final nsID NS_IDOCSHELL_IID =
+		new nsID(NS_IDOCSHELL_IID_STR);
+
+	public nsIDocShell_1_9(int /*long*/ address) {
+		super(address);
+	}
+
+	public int LoadURI(int /*long*/ uri, int /*long*/ loadInfo, int aLoadFlags, int firstParty) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 1, getAddress(), uri, loadInfo, aLoadFlags, firstParty);
+	}
+
+	public int LoadStream(int /*long*/ aStream, int /*long*/ aURI, int /*long*/ aContentType, int /*long*/ aContentCharset, int /*long*/ aLoadInfo) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 2, getAddress(), aStream, aURI, aContentType, aContentCharset, aLoadInfo);
+	}
+
+	public static final int INTERNAL_LOAD_FLAGS_NONE = 0;
+
+	public static final int INTERNAL_LOAD_FLAGS_INHERIT_OWNER = 1;
+
+	public static final int INTERNAL_LOAD_FLAGS_DONT_SEND_REFERRER = 2;
+
+	public static final int INTERNAL_LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP = 4;
+
+	public static final int INTERNAL_LOAD_FLAGS_FIRST_LOAD = 8;
+
+	public static final int INTERNAL_LOAD_FLAGS_BYPASS_CLASSIFIER = 16;
+
+	public int InternalLoad(int /*long*/ aURI, int /*long*/ aReferrer, int /*long*/ aOwner, int aFlags, char[] aWindowTarget, byte[] aTypeHint, int /*long*/ aPostDataStream, int /*long*/ aHeadersStream, int aLoadFlags, int /*long*/ aSHEntry, int firstParty, int /*long*/[] aDocShell, int /*long*/[] aRequest) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 3, getAddress(), aURI, aReferrer, aOwner, aFlags, aWindowTarget, aTypeHint, aPostDataStream, aHeadersStream, aLoadFlags, aSHEntry, firstParty, aDocShell, aRequest);
+	}
+
+	public int CreateLoadInfo(int /*long*/[] loadInfo) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 4, getAddress(), loadInfo);
+	}
+
+	public int PrepareForNewContentModel() {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 5, getAddress());
+	}
+
+	public int SetCurrentURI(int /*long*/ aURI) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 6, getAddress(), aURI);
+	}
+
+	public int FirePageHideNotification(int isUnload) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 7, getAddress(), isUnload);
+	}
+
+	public int GetPresContext(int /*long*/[] aPresContext) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 8, getAddress(), aPresContext);
+	}
+
+	public int GetPresShell(int /*long*/[] aPresShell) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 9, getAddress(), aPresShell);
+	}
+
+	public int GetEldestPresShell(int /*long*/[] aEldestPresShell) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 10, getAddress(), aEldestPresShell);
+	}
+
+	public int GetContentViewer(int /*long*/[] aContentViewer) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 11, getAddress(), aContentViewer);
+	}
+
+	public int GetChromeEventHandler(int /*long*/[] aChromeEventHandler) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 12, getAddress(), aChromeEventHandler);
+	}
+
+	public int SetChromeEventHandler(int /*long*/ aChromeEventHandler) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 13, getAddress(), aChromeEventHandler);
+	}
+
+	public int GetDocumentCharsetInfo(int /*long*/[] aDocumentCharsetInfo) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 14, getAddress(), aDocumentCharsetInfo);
+	}
+
+	public int SetDocumentCharsetInfo(int /*long*/ aDocumentCharsetInfo) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 15, getAddress(), aDocumentCharsetInfo);
+	}
+
+	public int GetAllowPlugins(int[] aAllowPlugins) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 16, getAddress(), aAllowPlugins);
+	}
+
+	public int SetAllowPlugins(int aAllowPlugins) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 17, getAddress(), aAllowPlugins);
+	}
+
+	public int GetAllowJavascript(int[] aAllowJavascript) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 18, getAddress(), aAllowJavascript);
+	}
+
+	public int SetAllowJavascript(int aAllowJavascript) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 19, getAddress(), aAllowJavascript);
+	}
+
+	public int GetAllowMetaRedirects(int[] aAllowMetaRedirects) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 20, getAddress(), aAllowMetaRedirects);
+	}
+
+	public int SetAllowMetaRedirects(int aAllowMetaRedirects) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 21, getAddress(), aAllowMetaRedirects);
+	}
+
+	public int GetAllowSubframes(int[] aAllowSubframes) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 22, getAddress(), aAllowSubframes);
+	}
+
+	public int SetAllowSubframes(int aAllowSubframes) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 23, getAddress(), aAllowSubframes);
+	}
+
+	public int GetAllowImages(int[] aAllowImages) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 24, getAddress(), aAllowImages);
+	}
+
+	public int SetAllowImages(int aAllowImages) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 25, getAddress(), aAllowImages);
+	}
+
+	public static final int ENUMERATE_FORWARDS = 0;
+
+	public static final int ENUMERATE_BACKWARDS = 1;
+
+	public int GetDocShellEnumerator(int aItemType, int aDirection, int /*long*/[] _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 26, getAddress(), aItemType, aDirection, _retval);
+	}
+
+	public static final int APP_TYPE_UNKNOWN = 0;
+
+	public static final int APP_TYPE_MAIL = 1;
+
+	public static final int APP_TYPE_EDITOR = 2;
+
+	public int GetAppType(int[] aAppType) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 27, getAddress(), aAppType);
+	}
+
+	public int SetAppType(int aAppType) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 28, getAddress(), aAppType);
+	}
+
+	public int GetAllowAuth(int[] aAllowAuth) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 29, getAddress(), aAllowAuth);
+	}
+
+	public int SetAllowAuth(int aAllowAuth) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 30, getAddress(), aAllowAuth);
+	}
+
+	public int GetZoom(float[] aZoom) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 31, getAddress(), aZoom);
+	}
+
+	public int SetZoom(float aZoom) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 32, getAddress(), aZoom);
+	}
+
+	public int GetMarginWidth(int[] aMarginWidth) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 33, getAddress(), aMarginWidth);
+	}
+
+	public int SetMarginWidth(int aMarginWidth) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 34, getAddress(), aMarginWidth);
+	}
+
+	public int GetMarginHeight(int[] aMarginHeight) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 35, getAddress(), aMarginHeight);
+	}
+
+	public int SetMarginHeight(int aMarginHeight) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 36, getAddress(), aMarginHeight);
+	}
+
+	public int GetHasFocus(int[] aHasFocus) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 37, getAddress(), aHasFocus);
+	}
+
+	public int SetHasFocus(int aHasFocus) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 38, getAddress(), aHasFocus);
+	}
+
+	public int GetCanvasHasFocus(int[] aCanvasHasFocus) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 39, getAddress(), aCanvasHasFocus);
+	}
+
+	public int SetCanvasHasFocus(int aCanvasHasFocus) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 40, getAddress(), aCanvasHasFocus);
+	}
+
+	public int TabToTreeOwner(int forward, int[] tookFocus) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 41, getAddress(), forward, tookFocus);
+	}
+
+	public static final int BUSY_FLAGS_NONE = 0;
+
+	public static final int BUSY_FLAGS_BUSY = 1;
+
+	public static final int BUSY_FLAGS_BEFORE_PAGE_LOAD = 2;
+
+	public static final int BUSY_FLAGS_PAGE_LOADING = 4;
+
+	public static final int LOAD_CMD_NORMAL = 1;
+
+	public static final int LOAD_CMD_RELOAD = 2;
+
+	public static final int LOAD_CMD_HISTORY = 4;
+
+	public int GetBusyFlags(int[] aBusyFlags) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 42, getAddress(), aBusyFlags);
+	}
+
+	public int GetLoadType(int[] aLoadType) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 43, getAddress(), aLoadType);
+	}
+
+	public int SetLoadType(int aLoadType) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 44, getAddress(), aLoadType);
+	}
+
+	public int IsBeingDestroyed(int[] _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 45, getAddress(), _retval);
+	}
+
+	public int GetIsExecutingOnLoadHandler(int[] aIsExecutingOnLoadHandler) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 46, getAddress(), aIsExecutingOnLoadHandler);
+	}
+
+	public int GetLayoutHistoryState(int /*long*/[] aLayoutHistoryState) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 47, getAddress(), aLayoutHistoryState);
+	}
+
+	public int SetLayoutHistoryState(int /*long*/ aLayoutHistoryState) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 48, getAddress(), aLayoutHistoryState);
+	}
+
+	public int GetShouldSaveLayoutState(int[] aShouldSaveLayoutState) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 49, getAddress(), aShouldSaveLayoutState);
+	}
+
+	public int GetSecurityUI(int /*long*/[] aSecurityUI) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 50, getAddress(), aSecurityUI);
+	}
+
+	public int SetSecurityUI(int /*long*/ aSecurityUI) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 51, getAddress(), aSecurityUI);
+	}
+
+	public int SuspendRefreshURIs() {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 52, getAddress());
+	}
+
+	public int ResumeRefreshURIs() {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 53, getAddress());
+	}
+
+	public int BeginRestore(int /*long*/ viewer, int top) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 54, getAddress(), viewer, top);
+	}
+
+	public int FinishRestore() {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 55, getAddress());
+	}
+
+	public int GetRestoringDocument(int[] aRestoringDocument) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 56, getAddress(), aRestoringDocument);
+	}
+
+	public int GetUseErrorPages(int[] aUseErrorPages) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 57, getAddress(), aUseErrorPages);
+	}
+
+	public int SetUseErrorPages(int aUseErrorPages) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 58, getAddress(), aUseErrorPages);
+	}
+
+	public int GetPreviousTransIndex(int[] aPreviousTransIndex) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 59, getAddress(), aPreviousTransIndex);
+	}
+
+	public int GetLoadedTransIndex(int[] aLoadedTransIndex) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 60, getAddress(), aLoadedTransIndex);
+	}
+
+	public int HistoryPurged(int numEntries) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 61, getAddress(), numEntries);
+	}
+
+	public int GetSessionStorageForURI(int /*long*/ uri, int /*long*/[] _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 62, getAddress(), uri, _retval);
+	}
+
+	public int AddSessionStorage(int /*long*/ aDomain, int /*long*/ storage) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 63, getAddress(), aDomain, storage);
+	}
+
+	public int GetCurrentDocumentChannel(int /*long*/[] aCurrentDocumentChannel) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 64, getAddress(), aCurrentDocumentChannel);
+	}
+
+	public int SetChildOffset(int offset) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 65, getAddress(), offset);
+	}
+
+	public int GetIsInUnload(int[] aIsInUnload) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 66, getAddress(), aIsInUnload);
+	}
+
+	public int GetChannelIsUnsafe(int[] aChannelIsUnsafe) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 67, getAddress(), aChannelIsUnsafe);
+	}
+}
\ No newline at end of file


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIDocShell_1_9.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIDownload.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIDownload.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIDownload.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,95 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by Netscape are Copyright (C) 1998-1999
+ * Netscape Communications Corporation.  All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * -  Binding to permit interfacing between Mozilla and SWT
+ * -  Copyright (C) 2004, 2005 IBM Corp.  All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package org.eclipse.swt.internal.mozilla;
+
+public class nsIDownload extends nsISupports {
+
+	static final int LAST_METHOD_ID = nsISupports.LAST_METHOD_ID + 13;
+
+	public static final String NS_IDOWNLOAD_IID_STR =
+		"06cb92f2-1dd2-11b2-95f2-96dfdfb804a1";
+
+	public static final nsID NS_IDOWNLOAD_IID =
+		new nsID(NS_IDOWNLOAD_IID_STR);
+
+	public nsIDownload(int /*long*/ address) {
+		super(address);
+	}
+
+	public int Init(int /*long*/ aSource, int /*long*/ aTarget, char[] aDisplayName, int /*long*/ aMIMEInfo, long startTime, int /*long*/ aPersist) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 1, getAddress(), aSource, aTarget, aDisplayName, aMIMEInfo, startTime, aPersist);
+	}
+
+	public int GetSource(int /*long*/[] aSource) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 2, getAddress(), aSource);
+	}
+
+	public int GetTarget(int /*long*/[] aTarget) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 3, getAddress(), aTarget);
+	}
+
+	public int GetPersist(int /*long*/[] aPersist) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 4, getAddress(), aPersist);
+	}
+
+	public int GetPercentComplete(int[] aPercentComplete) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 5, getAddress(), aPercentComplete);
+	}
+
+	public int GetDisplayName(int /*long*/[] aDisplayName) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 6, getAddress(), aDisplayName);
+	}
+
+	public int SetDisplayName(char[] aDisplayName) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 7, getAddress(), aDisplayName);
+	}
+
+	public int GetStartTime(long[] aStartTime) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 8, getAddress(), aStartTime);
+	}
+
+	public int GetMIMEInfo(int /*long*/[] aMIMEInfo) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 9, getAddress(), aMIMEInfo);
+	}
+
+	public int GetListener(int /*long*/[] aListener) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 10, getAddress(), aListener);
+	}
+
+	public int SetListener(int /*long*/ aListener) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 11, getAddress(), aListener);
+	}
+
+	public int GetObserver(int /*long*/[] aObserver) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 12, getAddress(), aObserver);
+	}
+
+	public int SetObserver(int /*long*/ aObserver) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 13, getAddress(), aObserver);
+	}
+}
\ No newline at end of file


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIDownload.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIDownload_1_8.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIDownload_1_8.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIDownload_1_8.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,83 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by Netscape are Copyright (C) 1998-1999
+ * Netscape Communications Corporation.  All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * -  Binding to permit interfacing between Mozilla and SWT
+ * -  Copyright (C) 2003 IBM Corp.  All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package org.eclipse.swt.internal.mozilla;
+
+public class nsIDownload_1_8 extends nsITransfer {
+
+	static final int LAST_METHOD_ID = nsITransfer.LAST_METHOD_ID + 10;
+
+	public static final String NS_IDOWNLOAD_IID_STR =
+		"9e1fd9f2-9727-4926-85cd-f16c375bba6d";
+
+	public static final nsID NS_IDOWNLOAD_IID =
+		new nsID(NS_IDOWNLOAD_IID_STR);
+
+	public nsIDownload_1_8(int /*long*/ address) {
+		super(address);
+	}
+
+	public int GetTargetFile(int /*long*/[] aTargetFile) {
+		return XPCOM.VtblCall(nsITransfer.LAST_METHOD_ID + 1, getAddress(), aTargetFile);
+	}
+
+	public int GetPercentComplete(int[] aPercentComplete) {
+		return XPCOM.VtblCall(nsITransfer.LAST_METHOD_ID + 2, getAddress(), aPercentComplete);
+	}
+
+	public int GetAmountTransferred(int /*long*/ aAmountTransferred) {
+		return XPCOM.VtblCall(nsITransfer.LAST_METHOD_ID + 3, getAddress(), aAmountTransferred);
+	}
+
+	public int GetSize(int /*long*/ aSize) {
+		return XPCOM.VtblCall(nsITransfer.LAST_METHOD_ID + 4, getAddress(), aSize);
+	}
+
+	public int GetSource(int /*long*/[] aSource) {
+		return XPCOM.VtblCall(nsITransfer.LAST_METHOD_ID + 5, getAddress(), aSource);
+	}
+
+	public int GetTarget(int /*long*/[] aTarget) {
+		return XPCOM.VtblCall(nsITransfer.LAST_METHOD_ID + 6, getAddress(), aTarget);
+	}
+
+	public int GetCancelable(int /*long*/[] aCancelable) {
+		return XPCOM.VtblCall(nsITransfer.LAST_METHOD_ID + 7, getAddress(), aCancelable);
+	}
+
+	public int GetDisplayName(int /*long*/[] aDisplayName) {
+		return XPCOM.VtblCall(nsITransfer.LAST_METHOD_ID + 8, getAddress(), aDisplayName);
+	}
+
+	public int GetStartTime(long[] aStartTime) {
+		return XPCOM.VtblCall(nsITransfer.LAST_METHOD_ID + 9, getAddress(), aStartTime);
+	}
+
+	public int GetMIMEInfo(int /*long*/[] aMIMEInfo) {
+		return XPCOM.VtblCall(nsITransfer.LAST_METHOD_ID + 10, getAddress(), aMIMEInfo);
+	}
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIDownload_1_8.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIEmbeddingSiteWindow.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIEmbeddingSiteWindow.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIEmbeddingSiteWindow.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,81 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by Netscape are Copyright (C) 1998-1999
+ * Netscape Communications Corporation.  All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * -  Binding to permit interfacing between Mozilla and SWT
+ * -  Copyright (C) 2003, 2008 IBM Corp.  All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package org.eclipse.swt.internal.mozilla;
+
+public class nsIEmbeddingSiteWindow extends nsISupports {
+
+	static final int LAST_METHOD_ID = nsISupports.LAST_METHOD_ID + 8;
+
+	public static final String NS_IEMBEDDINGSITEWINDOW_IID_STR =
+		"3e5432cd-9568-4bd1-8cbe-d50aba110743";
+
+	public static final nsID NS_IEMBEDDINGSITEWINDOW_IID =
+		new nsID(NS_IEMBEDDINGSITEWINDOW_IID_STR);
+
+	public nsIEmbeddingSiteWindow(int /*long*/ address) {
+		super(address);
+	}
+
+	public static final int DIM_FLAGS_POSITION = 1;
+
+	public static final int DIM_FLAGS_SIZE_INNER = 2;
+
+	public static final int DIM_FLAGS_SIZE_OUTER = 4;
+
+	public int SetDimensions(int flags, int x, int y, int cx, int cy) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 1, getAddress(), flags, x, y, cx, cy);
+	}
+
+	public int GetDimensions(int flags, int[] x, int[] y, int[] cx, int[] cy) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 2, getAddress(), flags, x, y, cx, cy);
+	}
+
+	public int SetFocus() {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 3, getAddress());
+	}
+
+	public int GetVisibility(int[] aVisibility) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 4, getAddress(), aVisibility);
+	}
+
+	public int SetVisibility(int aVisibility) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 5, getAddress(), aVisibility);
+	}
+
+	public int GetTitle(int /*long*/[] aTitle) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 6, getAddress(), aTitle);
+	}
+
+	public int SetTitle(char[] aTitle) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 7, getAddress(), aTitle);
+	}
+
+	public int GetSiteWindow(int /*long*/[] aSiteWindow) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 8, getAddress(), aSiteWindow);
+	}
+}
\ No newline at end of file


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIEmbeddingSiteWindow.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIFactory.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIFactory.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIFactory.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,51 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by Netscape are Copyright (C) 1998-1999
+ * Netscape Communications Corporation.  All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * -  Binding to permit interfacing between Mozilla and SWT
+ * -  Copyright (C) 2003, 2008 IBM Corp.  All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package org.eclipse.swt.internal.mozilla;
+
+public class nsIFactory extends nsISupports {
+
+	static final int LAST_METHOD_ID = nsISupports.LAST_METHOD_ID + 2;
+
+	public static final String NS_IFACTORY_IID_STR =
+		"00000001-0000-0000-c000-000000000046";
+
+	public static final nsID NS_IFACTORY_IID =
+		new nsID(NS_IFACTORY_IID_STR);
+
+	public nsIFactory(int /*long*/ address) {
+		super(address);
+	}
+
+	public int CreateInstance(int /*long*/ aOuter, nsID iid, int /*long*/[] result) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 1, getAddress(), aOuter, iid, result);
+	}
+
+	public int LockFactory(int lock) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 2, getAddress(), lock);
+	}
+}
\ No newline at end of file


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIFactory.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIFile.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIFile.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIFile.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,227 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by Netscape are Copyright (C) 1998-1999
+ * Netscape Communications Corporation.  All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * -  Binding to permit interfacing between Mozilla and SWT
+ * -  Copyright (C) 2003, 2008 IBM Corp.  All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package org.eclipse.swt.internal.mozilla;
+
+public class nsIFile extends nsISupports {
+
+	static final int LAST_METHOD_ID = nsISupports.LAST_METHOD_ID + 45;
+
+	public static final String NS_IFILE_IID_STR =
+		"c8c0a080-0868-11d3-915f-d9d889d48e3c";
+
+	public static final nsID NS_IFILE_IID =
+		new nsID(NS_IFILE_IID_STR);
+
+	public nsIFile(int /*long*/ address) {
+		super(address);
+	}
+
+	public static final int NORMAL_FILE_TYPE = 0;
+
+	public static final int DIRECTORY_TYPE = 1;
+
+	public int Append(int /*long*/ node) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 1, getAddress(), node);
+	}
+
+	public int AppendNative(int /*long*/ node) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 2, getAddress(), node);
+	}
+
+	public int Normalize() {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 3, getAddress());
+	}
+
+	public int Create(int type, int permissions) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 4, getAddress(), type, permissions);
+	}
+
+	public int GetLeafName(int /*long*/ aLeafName) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 5, getAddress(), aLeafName);
+	}
+
+	public int SetLeafName(int /*long*/ aLeafName) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 6, getAddress(), aLeafName);
+	}
+
+	public int GetNativeLeafName(int /*long*/ aNativeLeafName) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 7, getAddress(), aNativeLeafName);
+	}
+
+	public int SetNativeLeafName(int /*long*/ aNativeLeafName) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 8, getAddress(), aNativeLeafName);
+	}
+
+	public int CopyTo(int /*long*/ newParentDir, int /*long*/ newName) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 9, getAddress(), newParentDir, newName);
+	}
+
+	public int CopyToNative(int /*long*/ newParentDir, int /*long*/ newName) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 10, getAddress(), newParentDir, newName);
+	}
+
+	public int CopyToFollowingLinks(int /*long*/ newParentDir, int /*long*/ newName) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 11, getAddress(), newParentDir, newName);
+	}
+
+	public int CopyToFollowingLinksNative(int /*long*/ newParentDir, int /*long*/ newName) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 12, getAddress(), newParentDir, newName);
+	}
+
+	public int MoveTo(int /*long*/ newParentDir, int /*long*/ newName) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 13, getAddress(), newParentDir, newName);
+	}
+
+	public int MoveToNative(int /*long*/ newParentDir, int /*long*/ newName) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 14, getAddress(), newParentDir, newName);
+	}
+
+	public int Remove(int recursive) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 15, getAddress(), recursive);
+	}
+
+	public int GetPermissions(int[] aPermissions) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 16, getAddress(), aPermissions);
+	}
+
+	public int SetPermissions(int aPermissions) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 17, getAddress(), aPermissions);
+	}
+
+	public int GetPermissionsOfLink(int[] aPermissionsOfLink) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 18, getAddress(), aPermissionsOfLink);
+	}
+
+	public int SetPermissionsOfLink(int aPermissionsOfLink) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 19, getAddress(), aPermissionsOfLink);
+	}
+
+	public int GetLastModifiedTime(long[] aLastModifiedTime) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 20, getAddress(), aLastModifiedTime);
+	}
+
+	public int SetLastModifiedTime(long aLastModifiedTime) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 21, getAddress(), aLastModifiedTime);
+	}
+
+	public int GetLastModifiedTimeOfLink(long[] aLastModifiedTimeOfLink) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 22, getAddress(), aLastModifiedTimeOfLink);
+	}
+
+	public int SetLastModifiedTimeOfLink(long aLastModifiedTimeOfLink) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 23, getAddress(), aLastModifiedTimeOfLink);
+	}
+
+	public int GetFileSize(long[] aFileSize) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 24, getAddress(), aFileSize);
+	}
+
+	public int SetFileSize(long aFileSize) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 25, getAddress(), aFileSize);
+	}
+
+	public int GetFileSizeOfLink(long[] aFileSizeOfLink) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 26, getAddress(), aFileSizeOfLink);
+	}
+
+	public int GetTarget(int /*long*/ aTarget) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 27, getAddress(), aTarget);
+	}
+
+	public int GetNativeTarget(int /*long*/ aNativeTarget) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 28, getAddress(), aNativeTarget);
+	}
+
+	public int GetPath(int /*long*/ aPath) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 29, getAddress(), aPath);
+	}
+
+	public int GetNativePath(int /*long*/ aNativePath) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 30, getAddress(), aNativePath);
+	}
+
+	public int Exists(int[] _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 31, getAddress(), _retval);
+	}
+
+	public int IsWritable(int[] _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 32, getAddress(), _retval);
+	}
+
+	public int IsReadable(int[] _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 33, getAddress(), _retval);
+	}
+
+	public int IsExecutable(int[] _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 34, getAddress(), _retval);
+	}
+
+	public int IsHidden(int[] _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 35, getAddress(), _retval);
+	}
+
+	public int IsDirectory(int[] _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 36, getAddress(), _retval);
+	}
+
+	public int IsFile(int[] _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 37, getAddress(), _retval);
+	}
+
+	public int IsSymlink(int[] _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 38, getAddress(), _retval);
+	}
+
+	public int IsSpecial(int[] _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 39, getAddress(), _retval);
+	}
+
+	public int CreateUnique(int type, int permissions) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 40, getAddress(), type, permissions);
+	}
+
+	public int Clone(int /*long*/[] _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 41, getAddress(), _retval);
+	}
+
+	public int Equals(int /*long*/ inFile, int[] _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 42, getAddress(), inFile, _retval);
+	}
+
+	public int Contains(int /*long*/ inFile, int recur, int[] _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 43, getAddress(), inFile, recur, _retval);
+	}
+
+	public int GetParent(int /*long*/[] aParent) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 44, getAddress(), aParent);
+	}
+
+	public int GetDirectoryEntries(int /*long*/[] aDirectoryEntries) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 45, getAddress(), aDirectoryEntries);
+	}
+}
\ No newline at end of file


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIFile.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIFilePicker.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIFilePicker.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIFilePicker.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,118 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by Netscape are Copyright (C) 1998-1999
+ * Netscape Communications Corporation.  All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * -  Binding to permit interfacing between Mozilla and SWT
+ * -  Copyright (C) 2005 IBM Corp.  All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package org.eclipse.swt.internal.mozilla;
+
+public class nsIFilePicker extends nsISupports {
+
+	static final int LAST_METHOD_ID = nsISupports.LAST_METHOD_ID + 15;
+
+	public static final String NS_IFILEPICKER_IID_STR =
+		"c47de916-1dd1-11b2-8141-82507fa02b21";
+
+	public static final nsID NS_IFILEPICKER_IID =
+		new nsID(NS_IFILEPICKER_IID_STR);
+
+	public nsIFilePicker(int /*long*/ address) {
+		super(address);
+	}
+
+	public static final int modeOpen = 0;
+	public static final int modeSave = 1;
+	public static final int modeGetFolder = 2;
+	public static final int modeOpenMultiple = 3;
+	public static final int returnOK = 0;
+	public static final int returnCancel = 1;
+	public static final int returnReplace = 2;
+	public static final int filterAll = 1;
+	public static final int filterHTML = 2;
+	public static final int filterText = 4;
+	public static final int filterImages = 8;
+	public static final int filterXML = 16;
+	public static final int filterXUL = 32;
+	public static final int filterApps = 64;
+
+	public int Init(int /*long*/ parent, char[] title, int mode) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 1, getAddress(), parent, title, mode);
+	}
+
+	public int AppendFilters(int filterMask) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 2, getAddress(), filterMask);
+	}
+
+	public int AppendFilter(char[] title, char[] filter) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 3, getAddress(), title, filter);
+	}
+
+	public int GetDefaultString(int /*long*/[] aDefaultString) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 4, getAddress(), aDefaultString);
+	}
+
+	public int SetDefaultString(char[] aDefaultString) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 5, getAddress(), aDefaultString);
+	}
+
+	public int GetDefaultExtension(int /*long*/[] aDefaultExtension) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 6, getAddress(), aDefaultExtension);
+	}
+
+	public int SetDefaultExtension(char[] aDefaultExtension) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 7, getAddress(), aDefaultExtension);
+	}
+
+	public int GetFilterIndex(int[] aFilterIndex) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 8, getAddress(), aFilterIndex);
+	}
+
+	public int SetFilterIndex(int aFilterIndex) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 9, getAddress(), aFilterIndex);
+	}
+
+	public int GetDisplayDirectory(int /*long*/[] aDisplayDirectory) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 10, getAddress(), aDisplayDirectory);
+	}
+
+	public int SetDisplayDirectory(int /*long*/ aDisplayDirectory) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 11, getAddress(), aDisplayDirectory);
+	}
+
+	public int GetFile(int /*long*/[] aFile) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 12, getAddress(), aFile);
+	}
+
+	public int GetFileURL(int /*long*/[] aFileURL) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 13, getAddress(), aFileURL);
+	}
+
+	public int GetFiles(int /*long*/[] aFiles) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 14, getAddress(), aFiles);
+	}
+
+	public int Show(int /*long*/ _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 15, getAddress(), _retval);
+	}
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIFilePicker.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIFilePicker_1_8.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIFilePicker_1_8.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIFilePicker_1_8.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,118 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by Netscape are Copyright (C) 1998-1999
+ * Netscape Communications Corporation.  All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * -  Binding to permit interfacing between Mozilla and SWT
+ * -  Copyright (C) 2003 IBM Corp.  All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package org.eclipse.swt.internal.mozilla;
+
+public class nsIFilePicker_1_8 extends nsISupports {
+
+	static final int LAST_METHOD_ID = nsISupports.LAST_METHOD_ID + 15;
+
+	public static final String NS_IFILEPICKER_IID_STR =
+		"80faf095-c807-4558-a2cc-185ed70754ea";
+
+	public static final nsID NS_IFILEPICKER_IID =
+		new nsID(NS_IFILEPICKER_IID_STR);
+
+	public nsIFilePicker_1_8(int /*long*/ address) {
+		super(address);
+	}
+
+	public static final int modeOpen = 0;
+	public static final int modeSave = 1;
+	public static final int modeGetFolder = 2;
+	public static final int modeOpenMultiple = 3;
+	public static final int returnOK = 0;
+	public static final int returnCancel = 1;
+	public static final int returnReplace = 2;
+	public static final int filterAll = 1;
+	public static final int filterHTML = 2;
+	public static final int filterText = 4;
+	public static final int filterImages = 8;
+	public static final int filterXML = 16;
+	public static final int filterXUL = 32;
+	public static final int filterApps = 64;
+
+	public int Init(int /*long*/ parent, int /*long*/ title, int mode) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 1, getAddress(), parent, title, mode);
+	}
+
+	public int AppendFilters(int filterMask) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 2, getAddress(), filterMask);
+	}
+
+	public int AppendFilter(int /*long*/ title, int /*long*/ filter) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 3, getAddress(), title, filter);
+	}
+
+	public int GetDefaultString(int /*long*/ aDefaultString) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 4, getAddress(), aDefaultString);
+	}
+
+	public int SetDefaultString(int /*long*/ aDefaultString) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 5, getAddress(), aDefaultString);
+	}
+
+	public int GetDefaultExtension(int /*long*/ aDefaultExtension) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 6, getAddress(), aDefaultExtension);
+	}
+
+	public int SetDefaultExtension(int /*long*/ aDefaultExtension) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 7, getAddress(), aDefaultExtension);
+	}
+
+	public int GetFilterIndex(int[] aFilterIndex) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 8, getAddress(), aFilterIndex);
+	}
+
+	public int SetFilterIndex(int aFilterIndex) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 9, getAddress(), aFilterIndex);
+	}
+
+	public int GetDisplayDirectory(int /*long*/[] aDisplayDirectory) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 10, getAddress(), aDisplayDirectory);
+	}
+
+	public int SetDisplayDirectory(int /*long*/ aDisplayDirectory) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 11, getAddress(), aDisplayDirectory);
+	}
+
+	public int GetFile(int /*long*/[] aFile) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 12, getAddress(), aFile);
+	}
+
+	public int GetFileURL(int /*long*/[] aFileURL) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 13, getAddress(), aFileURL);
+	}
+
+	public int GetFiles(int /*long*/[] aFiles) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 14, getAddress(), aFiles);
+	}
+
+	public int Show(int /*long*/ _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 15, getAddress(), _retval);
+	}
+}
\ No newline at end of file


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIFilePicker_1_8.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIHelperAppLauncher.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIHelperAppLauncher.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIHelperAppLauncher.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,79 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by Netscape are Copyright (C) 1998-1999
+ * Netscape Communications Corporation.  All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * -  Binding to permit interfacing between Mozilla and SWT
+ * -  Copyright (C) 2003, 2008 IBM Corp.  All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package org.eclipse.swt.internal.mozilla;
+
+public class nsIHelperAppLauncher extends nsISupports {
+
+	static final int LAST_METHOD_ID = nsISupports.LAST_METHOD_ID + 9;
+
+	public static final String NS_IHELPERAPPLAUNCHER_IID_STR =
+		"9503d0fe-4c9d-11d4-98d0-001083010e9b";
+
+	public static final nsID NS_IHELPERAPPLAUNCHER_IID =
+		new nsID(NS_IHELPERAPPLAUNCHER_IID_STR);
+
+	public nsIHelperAppLauncher(int /*long*/ address) {
+		super(address);
+	}
+
+	public int GetMIMEInfo(int /*long*/[] aMIMEInfo) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 1, getAddress(), aMIMEInfo);
+	}
+
+	public int GetSource(int /*long*/[] aSource) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 2, getAddress(), aSource);
+	}
+
+	public int GetSuggestedFileName(int /*long*/[] aSuggestedFileName) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 3, getAddress(), aSuggestedFileName);
+	}
+
+	public int SaveToDisk(int /*long*/ aNewFileLocation, int aRememberThisPreference) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 4, getAddress(), aNewFileLocation, aRememberThisPreference);
+	}
+
+	public int LaunchWithApplication(int /*long*/ aApplication, int aRememberThisPreference) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 5, getAddress(), aApplication, aRememberThisPreference);
+	}
+
+	public int Cancel() {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 6, getAddress());
+	}
+
+	public int SetWebProgressListener(int /*long*/ aWebProgressListener) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 7, getAddress(), aWebProgressListener);
+	}
+
+	public int CloseProgressWindow() {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 8, getAddress());
+	}
+
+	public int GetDownloadInfo(int /*long*/[] aSourceUrl, long[] aTimeDownloadStarted, int /*long*/[] _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 9, getAddress(), aSourceUrl, aTimeDownloadStarted, _retval);
+	}
+}
\ No newline at end of file


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIHelperAppLauncher.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIHelperAppLauncherDialog.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIHelperAppLauncherDialog.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIHelperAppLauncherDialog.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,55 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by Netscape are Copyright (C) 1998-1999
+ * Netscape Communications Corporation.  All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * -  Binding to permit interfacing between Mozilla and SWT
+ * -  Copyright (C) 2004, 2005 IBM Corp.  All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package org.eclipse.swt.internal.mozilla;
+
+public class nsIHelperAppLauncherDialog extends nsISupports {
+
+	static final int LAST_METHOD_ID = nsISupports.LAST_METHOD_ID + 3;
+
+	public static final String NS_IHELPERAPPLAUNCHERDIALOG_IID_STR =
+		"d7ebddf0-4c84-11d4-807a-00600811a9c3";
+
+	public static final nsID NS_IHELPERAPPLAUNCHERDIALOG_IID =
+		new nsID(NS_IHELPERAPPLAUNCHERDIALOG_IID_STR);
+
+	public nsIHelperAppLauncherDialog(int /*long*/ address) {
+		super(address);
+	}
+
+	public int Show(int /*long*/ aLauncher, int /*long*/ aContext) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 1, getAddress(), aLauncher, aContext);
+	}
+
+	public int PromptForSaveToFile(int /*long*/ aWindowContext, char[] aDefaultFile, char[] aSuggestedFileExtension, int /*long*/[] _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 2, getAddress(), aWindowContext, aDefaultFile, aSuggestedFileExtension, _retval);
+	}
+
+	public int ShowProgressDialog(int /*long*/ aLauncher, int /*long*/ aContext) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 3, getAddress(), aLauncher, aContext);
+	}
+}
\ No newline at end of file


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIHelperAppLauncherDialog.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIHelperAppLauncherDialog_1_9.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIHelperAppLauncherDialog_1_9.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIHelperAppLauncherDialog_1_9.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,57 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by Netscape are Copyright (C) 1998-1999
+ * Netscape Communications Corporation.  All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * -  Binding to permit interfacing between Mozilla and SWT
+ * -  Copyright (C) 2003, 2008 IBM Corp.  All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package org.eclipse.swt.internal.mozilla;
+
+public class nsIHelperAppLauncherDialog_1_9 extends nsISupports {
+
+	static final int LAST_METHOD_ID = nsISupports.LAST_METHOD_ID + 2;
+
+	public static final String NS_IHELPERAPPLAUNCHERDIALOG_IID_STR =
+		"f3704fdc-8ae6-4eba-a3c3-f02958ac0649";
+
+	public static final nsID NS_IHELPERAPPLAUNCHERDIALOG_IID =
+		new nsID(NS_IHELPERAPPLAUNCHERDIALOG_IID_STR);
+
+	public nsIHelperAppLauncherDialog_1_9(int /*long*/ address) {
+		super(address);
+	}
+
+	public static final int REASON_CANTHANDLE = 0;
+
+	public static final int REASON_SERVERREQUEST = 1;
+
+	public static final int REASON_TYPESNIFFED = 2;
+
+	public int Show(int /*long*/ aLauncher, int /*long*/ aWindowContext, int aReason) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 1, getAddress(), aLauncher, aWindowContext, aReason);
+	}
+
+	public int PromptForSaveToFile(int /*long*/ aLauncher, int /*long*/ aWindowContext, char[] aDefaultFileName, char[] aSuggestedFileExtension, int aForcePrompt, int /*long*/[] _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 2, getAddress(), aLauncher, aWindowContext, aDefaultFileName, aSuggestedFileExtension, aForcePrompt, _retval);
+	}
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIHelperAppLauncherDialog_1_9.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIHelperAppLauncher_1_8.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIHelperAppLauncher_1_8.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIHelperAppLauncher_1_8.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,79 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by Netscape are Copyright (C) 1998-1999
+ * Netscape Communications Corporation.  All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * -  Binding to permit interfacing between Mozilla and SWT
+ * -  Copyright (C) 2003, 2008 IBM Corp.  All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package org.eclipse.swt.internal.mozilla;
+
+public class nsIHelperAppLauncher_1_8 extends nsICancelable {
+
+	static final int LAST_METHOD_ID = nsICancelable.LAST_METHOD_ID + 9;
+
+	public static final String NS_IHELPERAPPLAUNCHER_IID_STR =
+		"99a0882d-2ff9-4659-9952-9ac531ba5592";
+
+	public static final nsID NS_IHELPERAPPLAUNCHER_IID =
+		new nsID(NS_IHELPERAPPLAUNCHER_IID_STR);
+
+	public nsIHelperAppLauncher_1_8(int /*long*/ address) {
+		super(address);
+	}
+
+	public int GetMIMEInfo(int /*long*/[] aMIMEInfo) {
+		return XPCOM.VtblCall(nsICancelable.LAST_METHOD_ID + 1, getAddress(), aMIMEInfo);
+	}
+
+	public int GetSource(int /*long*/[] aSource) {
+		return XPCOM.VtblCall(nsICancelable.LAST_METHOD_ID + 2, getAddress(), aSource);
+	}
+
+	public int GetSuggestedFileName(int /*long*/ aSuggestedFileName) {
+		return XPCOM.VtblCall(nsICancelable.LAST_METHOD_ID + 3, getAddress(), aSuggestedFileName);
+	}
+
+	public int SaveToDisk(int /*long*/ aNewFileLocation, int aRememberThisPreference) {
+		return XPCOM.VtblCall(nsICancelable.LAST_METHOD_ID + 4, getAddress(), aNewFileLocation, aRememberThisPreference);
+	}
+
+	public int LaunchWithApplication(int /*long*/ aApplication, int aRememberThisPreference) {
+		return XPCOM.VtblCall(nsICancelable.LAST_METHOD_ID + 5, getAddress(), aApplication, aRememberThisPreference);
+	}
+
+	public int SetWebProgressListener(int /*long*/ aWebProgressListener) {
+		return XPCOM.VtblCall(nsICancelable.LAST_METHOD_ID + 6, getAddress(), aWebProgressListener);
+	}
+
+	public int CloseProgressWindow() {
+		return XPCOM.VtblCall(nsICancelable.LAST_METHOD_ID + 7, getAddress());
+	}
+
+	public int GetTargetFile(int /*long*/[] aTargetFile) {
+		return XPCOM.VtblCall(nsICancelable.LAST_METHOD_ID + 8, getAddress(), aTargetFile);
+	}
+
+	public int GetTimeDownloadStarted(int /*long*/ aTimeDownloadStarted) {
+		return XPCOM.VtblCall(nsICancelable.LAST_METHOD_ID + 9, getAddress(), aTimeDownloadStarted);
+	}
+}
\ No newline at end of file


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIHelperAppLauncher_1_8.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIHelperAppLauncher_1_9.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIHelperAppLauncher_1_9.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIHelperAppLauncher_1_9.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,83 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by Netscape are Copyright (C) 1998-1999
+ * Netscape Communications Corporation.  All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * -  Binding to permit interfacing between Mozilla and SWT
+ * -  Copyright (C) 2003, 2008 IBM Corp.  All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package org.eclipse.swt.internal.mozilla;
+
+public class nsIHelperAppLauncher_1_9 extends nsICancelable {
+
+	static final int LAST_METHOD_ID = nsICancelable.LAST_METHOD_ID + 10;
+
+	public static final String NS_IHELPERAPPLAUNCHER_IID_STR =
+		"cc75c21a-0a79-4f68-90e1-563253d0c555";
+
+	public static final nsID NS_IHELPERAPPLAUNCHER_IID =
+		new nsID(NS_IHELPERAPPLAUNCHER_IID_STR);
+
+	public nsIHelperAppLauncher_1_9(int /*long*/ address) {
+		super(address);
+	}
+
+	public int GetMIMEInfo(int /*long*/[] aMIMEInfo) {
+		return XPCOM.VtblCall(nsICancelable.LAST_METHOD_ID + 1, getAddress(), aMIMEInfo);
+	}
+
+	public int GetSource(int /*long*/[] aSource) {
+		return XPCOM.VtblCall(nsICancelable.LAST_METHOD_ID + 2, getAddress(), aSource);
+	}
+
+	public int GetSuggestedFileName(int /*long*/ aSuggestedFileName) {
+		return XPCOM.VtblCall(nsICancelable.LAST_METHOD_ID + 3, getAddress(), aSuggestedFileName);
+	}
+
+	public int SaveToDisk(int /*long*/ aNewFileLocation, int aRememberThisPreference) {
+		return XPCOM.VtblCall(nsICancelable.LAST_METHOD_ID + 4, getAddress(), aNewFileLocation, aRememberThisPreference);
+	}
+
+	public int LaunchWithApplication(int /*long*/ aApplication, int aRememberThisPreference) {
+		return XPCOM.VtblCall(nsICancelable.LAST_METHOD_ID + 5, getAddress(), aApplication, aRememberThisPreference);
+	}
+
+	public int SetWebProgressListener(int /*long*/ aWebProgressListener) {
+		return XPCOM.VtblCall(nsICancelable.LAST_METHOD_ID + 6, getAddress(), aWebProgressListener);
+	}
+
+	public int CloseProgressWindow() {
+		return XPCOM.VtblCall(nsICancelable.LAST_METHOD_ID + 7, getAddress());
+	}
+
+	public int GetTargetFile(int /*long*/[] aTargetFile) {
+		return XPCOM.VtblCall(nsICancelable.LAST_METHOD_ID + 8, getAddress(), aTargetFile);
+	}
+
+	public int GetTargetFileIsExecutable(int[] aTargetFileIsExecutable) {
+		return XPCOM.VtblCall(nsICancelable.LAST_METHOD_ID + 9, getAddress(), aTargetFileIsExecutable);
+	}
+
+	public int GetTimeDownloadStarted(int /*long*/ aTimeDownloadStarted) {
+		return XPCOM.VtblCall(nsICancelable.LAST_METHOD_ID + 10, getAddress(), aTimeDownloadStarted);
+	}
+}
\ No newline at end of file


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIHelperAppLauncher_1_9.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIIOService.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIIOService.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIIOService.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,83 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by Netscape are Copyright (C) 1998-1999
+ * Netscape Communications Corporation.  All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * -  Binding to permit interfacing between Mozilla and SWT
+ * -  Copyright (C) 2003, 2008 IBM Corp.  All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package org.eclipse.swt.internal.mozilla;
+
+public class nsIIOService extends nsISupports {
+
+	static final int LAST_METHOD_ID = nsISupports.LAST_METHOD_ID + 10;
+
+	public static final String NS_IIOSERVICE_IID_STR =
+		"bddeda3f-9020-4d12-8c70-984ee9f7935e";
+
+	public static final nsID NS_IIOSERVICE_IID =
+		new nsID(NS_IIOSERVICE_IID_STR);
+
+	public nsIIOService(int /*long*/ address) {
+		super(address);
+	}
+
+	public int GetProtocolHandler(byte[] aScheme, int /*long*/[] _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 1, getAddress(), aScheme, _retval);
+	}
+
+	public int GetProtocolFlags(byte[] aScheme, int[] _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 2, getAddress(), aScheme, _retval);
+	}
+
+	public int NewURI(int /*long*/ aSpec, byte[] aOriginCharset, int /*long*/ aBaseURI, int /*long*/[] _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 3, getAddress(), aSpec, aOriginCharset, aBaseURI, _retval);
+	}
+
+	public int NewFileURI(int /*long*/ aFile, int /*long*/[] _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 4, getAddress(), aFile, _retval);
+	}
+
+	public int NewChannelFromURI(int /*long*/ aURI, int /*long*/[] _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 5, getAddress(), aURI, _retval);
+	}
+
+	public int NewChannel(int /*long*/ aSpec, byte[] aOriginCharset, int /*long*/ aBaseURI, int /*long*/[] _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 6, getAddress(), aSpec, aOriginCharset, aBaseURI, _retval);
+	}
+
+	public int GetOffline(int[] aOffline) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 7, getAddress(), aOffline);
+	}
+
+	public int SetOffline(int aOffline) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 8, getAddress(), aOffline);
+	}
+
+	public int AllowPort(int aPort, byte[] aScheme, int[] _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 9, getAddress(), aPort, aScheme, _retval);
+	}
+
+	public int ExtractScheme(int /*long*/ urlString, int /*long*/ _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 10, getAddress(), urlString, _retval);
+	}
+}
\ No newline at end of file


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIIOService.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIInputStream.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIInputStream.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIInputStream.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,63 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by Netscape are Copyright (C) 1998-1999
+ * Netscape Communications Corporation.  All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * -  Binding to permit interfacing between Mozilla and SWT
+ * -  Copyright (C) 2003, 2008 IBM Corp.  All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package org.eclipse.swt.internal.mozilla;
+
+public class nsIInputStream extends nsISupports {
+
+	static final int LAST_METHOD_ID = nsISupports.LAST_METHOD_ID + 5;
+
+	public static final String NS_IINPUTSTREAM_IID_STR =
+		"fa9c7f6c-61b3-11d4-9877-00c04fa0cf4a";
+
+	public static final nsID NS_IINPUTSTREAM_IID =
+		new nsID(NS_IINPUTSTREAM_IID_STR);
+
+	public nsIInputStream(int /*long*/ address) {
+		super(address);
+	}
+
+	public int Close() {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 1, getAddress());
+	}
+
+	public int Available(int[] _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 2, getAddress(), _retval);
+	}
+
+	public int Read(byte[] aBuf, int aCount, int[] _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 3, getAddress(), aBuf, aCount, _retval);
+	}
+
+	public int ReadSegments(int /*long*/ aWriter, int /*long*/ aClosure, int aCount, int[] _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 4, getAddress(), aWriter, aClosure, aCount, _retval);
+	}
+
+	public int IsNonBlocking(int[] _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 5, getAddress(), _retval);
+	}
+}
\ No newline at end of file


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIInputStream.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIInterfaceRequestor.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIInterfaceRequestor.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIInterfaceRequestor.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,47 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by Netscape are Copyright (C) 1998-1999
+ * Netscape Communications Corporation.  All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * -  Binding to permit interfacing between Mozilla and SWT
+ * -  Copyright (C) 2003, 2005 IBM Corp.  All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package org.eclipse.swt.internal.mozilla;
+
+public class nsIInterfaceRequestor extends nsISupports {
+
+	static final int LAST_METHOD_ID = nsISupports.LAST_METHOD_ID + 1;
+
+	public static final String NS_IINTERFACEREQUESTOR_IID_STR =
+		"033a1470-8b2a-11d3-af88-00a024ffc08c";
+
+	public static final nsID NS_IINTERFACEREQUESTOR_IID =
+		new nsID(NS_IINTERFACEREQUESTOR_IID_STR);
+
+	public nsIInterfaceRequestor(int /*long*/ address) {
+		super(address);
+	}
+
+	public int GetInterface(nsID uuid, int /*long*/[] result) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 1, getAddress(), uuid, result);
+	}
+}
\ No newline at end of file


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIInterfaceRequestor.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIJSContextStack.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIJSContextStack.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIJSContextStack.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,59 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by Netscape are Copyright (C) 1998-1999
+ * Netscape Communications Corporation.  All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * -  Binding to permit interfacing between Mozilla and SWT
+ * -  Copyright (C) 2003 IBM Corp.  All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package org.eclipse.swt.internal.mozilla;
+
+public class nsIJSContextStack extends nsISupports {
+
+	static final int LAST_METHOD_ID = nsISupports.LAST_METHOD_ID + 4;
+
+	public static final String NS_IJSCONTEXTSTACK_IID_STR =
+		"c67d8270-3189-11d3-9885-006008962422";
+
+	public static final nsID NS_IJSCONTEXTSTACK_IID =
+		new nsID(NS_IJSCONTEXTSTACK_IID_STR);
+
+	public nsIJSContextStack(int /*long*/ address) {
+		super(address);
+	}
+
+	public int GetCount(int[] aCount) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 1, getAddress(), aCount);
+	}
+
+	public int Peek(int /*long*/[] _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 2, getAddress(), _retval);
+	}
+
+	public int Pop(int /*long*/[] _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 3, getAddress(), _retval);
+	}
+
+	public int Push(int /*long*/ cx) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 4, getAddress(), cx);
+	}
+}
\ No newline at end of file


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIJSContextStack.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsILocalFile.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsILocalFile.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsILocalFile.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,111 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by Netscape are Copyright (C) 1998-1999
+ * Netscape Communications Corporation.  All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * -  Binding to permit interfacing between Mozilla and SWT
+ * -  Copyright (C) 2003, 2008 IBM Corp.  All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package org.eclipse.swt.internal.mozilla;
+
+public class nsILocalFile extends nsIFile {
+
+	static final int LAST_METHOD_ID = nsIFile.LAST_METHOD_ID + 17;
+
+	public static final String NS_ILOCALFILE_IID_STR =
+		"aa610f20-a889-11d3-8c81-000064657374";
+
+	public static final nsID NS_ILOCALFILE_IID =
+		new nsID(NS_ILOCALFILE_IID_STR);
+
+	public nsILocalFile(int /*long*/ address) {
+		super(address);
+	}
+
+	public int InitWithPath(int /*long*/ filePath) {
+		return XPCOM.VtblCall(nsIFile.LAST_METHOD_ID + 1, getAddress(), filePath);
+	}
+
+	public int InitWithNativePath(int /*long*/ filePath) {
+		return XPCOM.VtblCall(nsIFile.LAST_METHOD_ID + 2, getAddress(), filePath);
+	}
+
+	public int InitWithFile(int /*long*/ aFile) {
+		return XPCOM.VtblCall(nsIFile.LAST_METHOD_ID + 3, getAddress(), aFile);
+	}
+
+	public int GetFollowLinks(int[] aFollowLinks) {
+		return XPCOM.VtblCall(nsIFile.LAST_METHOD_ID + 4, getAddress(), aFollowLinks);
+	}
+
+	public int SetFollowLinks(int aFollowLinks) {
+		return XPCOM.VtblCall(nsIFile.LAST_METHOD_ID + 5, getAddress(), aFollowLinks);
+	}
+
+	public int OpenNSPRFileDesc(int flags, int mode, int /*long*/[] _retval) {
+		return XPCOM.VtblCall(nsIFile.LAST_METHOD_ID + 6, getAddress(), flags, mode, _retval);
+	}
+
+	public int OpenANSIFileDesc(byte[] mode, int /*long*/[] _retval) {
+		return XPCOM.VtblCall(nsIFile.LAST_METHOD_ID + 7, getAddress(), mode, _retval);
+	}
+
+	public int Load(int /*long*/[] _retval) {
+		return XPCOM.VtblCall(nsIFile.LAST_METHOD_ID + 8, getAddress(), _retval);
+	}
+
+	public int GetDiskSpaceAvailable(long[] aDiskSpaceAvailable) {
+		return XPCOM.VtblCall(nsIFile.LAST_METHOD_ID + 9, getAddress(), aDiskSpaceAvailable);
+	}
+
+	public int AppendRelativePath(int /*long*/ relativeFilePath) {
+		return XPCOM.VtblCall(nsIFile.LAST_METHOD_ID + 10, getAddress(), relativeFilePath);
+	}
+
+	public int AppendRelativeNativePath(int /*long*/ relativeFilePath) {
+		return XPCOM.VtblCall(nsIFile.LAST_METHOD_ID + 11, getAddress(), relativeFilePath);
+	}
+
+	public int GetPersistentDescriptor(int /*long*/ aPersistentDescriptor) {
+		return XPCOM.VtblCall(nsIFile.LAST_METHOD_ID + 12, getAddress(), aPersistentDescriptor);
+	}
+
+	public int SetPersistentDescriptor(int /*long*/ aPersistentDescriptor) {
+		return XPCOM.VtblCall(nsIFile.LAST_METHOD_ID + 13, getAddress(), aPersistentDescriptor);
+	}
+
+	public int Reveal() {
+		return XPCOM.VtblCall(nsIFile.LAST_METHOD_ID + 14, getAddress());
+	}
+
+	public int Launch() {
+		return XPCOM.VtblCall(nsIFile.LAST_METHOD_ID + 15, getAddress());
+	}
+
+	public int GetRelativeDescriptor(int /*long*/ fromFile, int /*long*/ _retval) {
+		return XPCOM.VtblCall(nsIFile.LAST_METHOD_ID + 16, getAddress(), fromFile, _retval);
+	}
+
+	public int SetRelativeDescriptor(int /*long*/ fromFile, int /*long*/ relativeDesc) {
+		return XPCOM.VtblCall(nsIFile.LAST_METHOD_ID + 17, getAddress(), fromFile, relativeDesc);
+	}
+}
\ No newline at end of file


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsILocalFile.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIMemory.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIMemory.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIMemory.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,63 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by Netscape are Copyright (C) 1998-1999
+ * Netscape Communications Corporation.  All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * -  Binding to permit interfacing between Mozilla and SWT
+ * -  Copyright (C) 2003, 2008 IBM Corp.  All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package org.eclipse.swt.internal.mozilla;
+
+public class nsIMemory extends nsISupports {
+
+	static final int LAST_METHOD_ID = nsISupports.LAST_METHOD_ID + 5;
+
+	public static final String NS_IMEMORY_IID_STR =
+		"59e7e77a-38e4-11d4-8cf5-0060b0fc14a3";
+
+	public static final nsID NS_IMEMORY_IID =
+		new nsID(NS_IMEMORY_IID_STR);
+
+	public nsIMemory(int /*long*/ address) {
+		super(address);
+	}
+
+	public int Alloc(int size) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 1, getAddress(), size);
+	}
+
+	public int Realloc(int /*long*/ ptr, int newSize) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 2, getAddress(), ptr, newSize);
+	}
+
+	public int Free(int /*long*/ ptr) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 3, getAddress(), ptr);
+	}
+
+	public int HeapMinimize(int immediate) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 4, getAddress(), immediate);
+	}
+
+	public int IsLowMemory(int[] _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 5, getAddress(), _retval);
+	}
+}
\ No newline at end of file


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIMemory.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIObserverService.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIObserverService.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIObserverService.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,59 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by Netscape are Copyright (C) 1998-1999
+ * Netscape Communications Corporation.  All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * -  Binding to permit interfacing between Mozilla and SWT
+ * -  Copyright (C) 2003, 2008 IBM Corp.  All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package org.eclipse.swt.internal.mozilla;
+
+public class nsIObserverService extends nsISupports {
+
+	static final int LAST_METHOD_ID = nsISupports.LAST_METHOD_ID + 4;
+
+	public static final String NS_IOBSERVERSERVICE_IID_STR =
+		"d07f5192-e3d1-11d2-8acd-00105a1b8860";
+
+	public static final nsID NS_IOBSERVERSERVICE_IID =
+		new nsID(NS_IOBSERVERSERVICE_IID_STR);
+
+	public nsIObserverService(int /*long*/ address) {
+		super(address);
+	}
+
+	public int AddObserver(int /*long*/ anObserver, byte[] aTopic, int ownsWeak) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 1, getAddress(), anObserver, aTopic, ownsWeak);
+	}
+
+	public int RemoveObserver(int /*long*/ anObserver, byte[] aTopic) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 2, getAddress(), anObserver, aTopic);
+	}
+
+	public int NotifyObservers(int /*long*/ aSubject, byte[] aTopic, char[] someData) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 3, getAddress(), aSubject, aTopic, someData);
+	}
+
+	public int EnumerateObservers(byte[] aTopic, int /*long*/[] _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 4, getAddress(), aTopic, _retval);
+	}
+}
\ No newline at end of file


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIObserverService.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIPrefBranch.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIPrefBranch.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIPrefBranch.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,123 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by Netscape are Copyright (C) 1998-1999
+ * Netscape Communications Corporation.  All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * -  Binding to permit interfacing between Mozilla and SWT
+ * -  Copyright (C) 2003, 2008 IBM Corp.  All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package org.eclipse.swt.internal.mozilla;
+
+public class nsIPrefBranch extends nsISupports {
+
+	static final int LAST_METHOD_ID = nsISupports.LAST_METHOD_ID + 18;
+
+	public static final String NS_IPREFBRANCH_IID_STR =
+		"56c35506-f14b-11d3-99d3-ddbfac2ccf65";
+
+	public static final nsID NS_IPREFBRANCH_IID =
+		new nsID(NS_IPREFBRANCH_IID_STR);
+
+	public nsIPrefBranch(int /*long*/ address) {
+		super(address);
+	}
+
+	public static final int PREF_INVALID = 0;
+
+	public static final int PREF_STRING = 32;
+
+	public static final int PREF_INT = 64;
+
+	public static final int PREF_BOOL = 128;
+
+	public int GetRoot(int /*long*/[] aRoot) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 1, getAddress(), aRoot);
+	}
+
+	public int GetPrefType(byte[] aPrefName, int[] _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 2, getAddress(), aPrefName, _retval);
+	}
+
+	public int GetBoolPref(byte[] aPrefName, int[] _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 3, getAddress(), aPrefName, _retval);
+	}
+
+	public int SetBoolPref(byte[] aPrefName, int aValue) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 4, getAddress(), aPrefName, aValue);
+	}
+
+	public int GetCharPref(byte[] aPrefName, int /*long*/[] _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 5, getAddress(), aPrefName, _retval);
+	}
+
+	public int SetCharPref(byte[] aPrefName, byte[] aValue) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 6, getAddress(), aPrefName, aValue);
+	}
+
+	public int GetIntPref(byte[] aPrefName, int[] _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 7, getAddress(), aPrefName, _retval);
+	}
+
+	public int SetIntPref(byte[] aPrefName, int aValue) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 8, getAddress(), aPrefName, aValue);
+	}
+
+	public int GetComplexValue(byte[] aPrefName, nsID aType, int /*long*/[] aValue) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 9, getAddress(), aPrefName, aType, aValue);
+	}
+
+	public int SetComplexValue(byte[] aPrefName, nsID aType, int /*long*/ aValue) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 10, getAddress(), aPrefName, aType, aValue);
+	}
+
+	public int ClearUserPref(byte[] aPrefName) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 11, getAddress(), aPrefName);
+	}
+
+	public int LockPref(byte[] aPrefName) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 12, getAddress(), aPrefName);
+	}
+
+	public int PrefHasUserValue(byte[] aPrefName, int[] _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 13, getAddress(), aPrefName, _retval);
+	}
+
+	public int PrefIsLocked(byte[] aPrefName, int[] _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 14, getAddress(), aPrefName, _retval);
+	}
+
+	public int UnlockPref(byte[] aPrefName) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 15, getAddress(), aPrefName);
+	}
+
+	public int DeleteBranch(byte[] aStartingAt) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 16, getAddress(), aStartingAt);
+	}
+
+	public int GetChildList(byte[] aStartingAt, int[] aCount, int /*long*/[] aChildArray) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 17, getAddress(), aStartingAt, aCount, aChildArray);
+	}
+
+	public int ResetBranch(byte[] aStartingAt) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 18, getAddress(), aStartingAt);
+	}
+}
\ No newline at end of file


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIPrefBranch.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIPrefLocalizedString.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIPrefLocalizedString.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIPrefLocalizedString.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,59 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by Netscape are Copyright (C) 1998-1999
+ * Netscape Communications Corporation.  All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * -  Binding to permit interfacing between Mozilla and SWT
+ * -  Copyright (C) 2006 IBM Corp.  All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package org.eclipse.swt.internal.mozilla;
+
+public class nsIPrefLocalizedString extends nsISupports {
+
+	static final int LAST_METHOD_ID = nsISupports.LAST_METHOD_ID + 4;
+
+	public static final String NS_IPREFLOCALIZEDSTRING_IID_STR =
+		"ae419e24-1dd1-11b2-b39a-d3e5e7073802";
+
+	public static final nsID NS_IPREFLOCALIZEDSTRING_IID =
+		new nsID(NS_IPREFLOCALIZEDSTRING_IID_STR);
+
+	public nsIPrefLocalizedString(int /*long*/ address) {
+		super(address);
+	}
+
+	public int GetData(int /*long*/[] aData) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 1, getAddress(), aData);
+	}
+
+	public int SetData(char[] aData) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 2, getAddress(), aData);
+	}
+
+	public int ToString(int /*long*/[] _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 3, getAddress(), _retval);
+	}
+
+	public int SetDataWithLength(int length, char[] data) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 4, getAddress(), length, data);
+	}
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIPrefLocalizedString.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIPrefService.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIPrefService.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIPrefService.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,67 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by Netscape are Copyright (C) 1998-1999
+ * Netscape Communications Corporation.  All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * -  Binding to permit interfacing between Mozilla and SWT
+ * -  Copyright (C) 2006 IBM Corp.  All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package org.eclipse.swt.internal.mozilla;
+
+public class nsIPrefService extends nsISupports {
+
+	static final int LAST_METHOD_ID = nsISupports.LAST_METHOD_ID + 6;
+
+	public static final String NS_IPREFSERVICE_IID_STR =
+		"decb9cc7-c08f-4ea5-be91-a8fc637ce2d2";
+
+	public static final nsID NS_IPREFSERVICE_IID =
+		new nsID(NS_IPREFSERVICE_IID_STR);
+
+	public nsIPrefService(int /*long*/ address) {
+		super(address);
+	}
+
+	public int ReadUserPrefs(int /*long*/ aFile) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 1, getAddress(), aFile);
+	}
+
+	public int ResetPrefs() {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 2, getAddress());
+	}
+
+	public int ResetUserPrefs() {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 3, getAddress());
+	}
+
+	public int SavePrefFile(int /*long*/ aFile) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 4, getAddress(), aFile);
+	}
+
+	public int GetBranch(byte[] aPrefRoot, int /*long*/[] _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 5, getAddress(), aPrefRoot, _retval);
+	}
+
+	public int GetDefaultBranch(byte[] aPrefRoot, int /*long*/[] _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 6, getAddress(), aPrefRoot, _retval);
+	}
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIPrefService.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIProgressDialog.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIProgressDialog.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIProgressDialog.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,63 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by Netscape are Copyright (C) 1998-1999
+ * Netscape Communications Corporation.  All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * -  Binding to permit interfacing between Mozilla and SWT
+ * -  Copyright (C) 2003, 2008 IBM Corp.  All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package org.eclipse.swt.internal.mozilla;
+
+public class nsIProgressDialog extends nsIDownload {
+
+	static final int LAST_METHOD_ID = nsIDownload.LAST_METHOD_ID + 5;
+
+	public static final String NS_IPROGRESSDIALOG_IID_STR =
+		"88a478b3-af65-440a-94dc-ed9b154d2990";
+
+	public static final nsID NS_IPROGRESSDIALOG_IID =
+		new nsID(NS_IPROGRESSDIALOG_IID_STR);
+
+	public nsIProgressDialog(int /*long*/ address) {
+		super(address);
+	}
+
+	public int Open(int /*long*/ aParent) {
+		return XPCOM.VtblCall(nsIDownload.LAST_METHOD_ID + 1, getAddress(), aParent);
+	}
+
+	public int GetCancelDownloadOnClose(int[] aCancelDownloadOnClose) {
+		return XPCOM.VtblCall(nsIDownload.LAST_METHOD_ID + 2, getAddress(), aCancelDownloadOnClose);
+	}
+
+	public int SetCancelDownloadOnClose(int aCancelDownloadOnClose) {
+		return XPCOM.VtblCall(nsIDownload.LAST_METHOD_ID + 3, getAddress(), aCancelDownloadOnClose);
+	}
+
+	public int GetDialog(int /*long*/[] aDialog) {
+		return XPCOM.VtblCall(nsIDownload.LAST_METHOD_ID + 4, getAddress(), aDialog);
+	}
+
+	public int SetDialog(int /*long*/ aDialog) {
+		return XPCOM.VtblCall(nsIDownload.LAST_METHOD_ID + 5, getAddress(), aDialog);
+	}
+}
\ No newline at end of file


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIProgressDialog.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIProgressDialog_1_8.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIProgressDialog_1_8.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIProgressDialog_1_8.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,71 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by Netscape are Copyright (C) 1998-1999
+ * Netscape Communications Corporation.  All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * -  Binding to permit interfacing between Mozilla and SWT
+ * -  Copyright (C) 2003, 2008 IBM Corp.  All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package org.eclipse.swt.internal.mozilla;
+
+public class nsIProgressDialog_1_8 extends nsIDownload_1_8 {
+
+	static final int LAST_METHOD_ID = nsIDownload_1_8.LAST_METHOD_ID + 7;
+
+	public static final String NS_IPROGRESSDIALOG_IID_STR =
+		"20e790a2-76c6-462d-851a-22ab6cbbe48b";
+
+	public static final nsID NS_IPROGRESSDIALOG_IID =
+		new nsID(NS_IPROGRESSDIALOG_IID_STR);
+
+	public nsIProgressDialog_1_8(int /*long*/ address) {
+		super(address);
+	}
+
+	public int Open(int /*long*/ aParent) {
+		return XPCOM.VtblCall(nsIDownload_1_8.LAST_METHOD_ID + 1, getAddress(), aParent);
+	}
+
+	public int GetCancelDownloadOnClose(int[] aCancelDownloadOnClose) {
+		return XPCOM.VtblCall(nsIDownload_1_8.LAST_METHOD_ID + 2, getAddress(), aCancelDownloadOnClose);
+	}
+
+	public int SetCancelDownloadOnClose(int aCancelDownloadOnClose) {
+		return XPCOM.VtblCall(nsIDownload_1_8.LAST_METHOD_ID + 3, getAddress(), aCancelDownloadOnClose);
+	}
+
+	public int GetObserver(int /*long*/[] aObserver) {
+		return XPCOM.VtblCall(nsIDownload_1_8.LAST_METHOD_ID + 4, getAddress(), aObserver);
+	}
+
+	public int SetObserver(int /*long*/ aObserver) {
+		return XPCOM.VtblCall(nsIDownload_1_8.LAST_METHOD_ID + 5, getAddress(), aObserver);
+	}
+
+	public int GetDialog(int /*long*/[] aDialog) {
+		return XPCOM.VtblCall(nsIDownload_1_8.LAST_METHOD_ID + 6, getAddress(), aDialog);
+	}
+
+	public int SetDialog(int /*long*/ aDialog) {
+		return XPCOM.VtblCall(nsIDownload_1_8.LAST_METHOD_ID + 7, getAddress(), aDialog);
+	}
+}
\ No newline at end of file


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIProgressDialog_1_8.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIPromptService.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIPromptService.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIPromptService.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,113 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by Netscape are Copyright (C) 1998-1999
+ * Netscape Communications Corporation.  All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * -  Binding to permit interfacing between Mozilla and SWT
+ * -  Copyright (C) 2003, 2008 IBM Corp.  All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package org.eclipse.swt.internal.mozilla;
+
+public class nsIPromptService extends nsISupports {
+
+	static final int LAST_METHOD_ID = nsISupports.LAST_METHOD_ID + 9;
+
+	public static final String NS_IPROMPTSERVICE_IID_STR =
+		"1630c61a-325e-49ca-8759-a31b16c47aa5";
+
+	public static final nsID NS_IPROMPTSERVICE_IID =
+		new nsID(NS_IPROMPTSERVICE_IID_STR);
+
+	public nsIPromptService(int /*long*/ address) {
+		super(address);
+	}
+
+	public int Alert(int /*long*/ aParent, char[] aDialogTitle, char[] aText) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 1, getAddress(), aParent, aDialogTitle, aText);
+	}
+
+	public int AlertCheck(int /*long*/ aParent, char[] aDialogTitle, char[] aText, char[] aCheckMsg, int[] aCheckState) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 2, getAddress(), aParent, aDialogTitle, aText, aCheckMsg, aCheckState);
+	}
+
+	public int Confirm(int /*long*/ aParent, char[] aDialogTitle, char[] aText, int[] _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 3, getAddress(), aParent, aDialogTitle, aText, _retval);
+	}
+
+	public int ConfirmCheck(int /*long*/ aParent, char[] aDialogTitle, char[] aText, char[] aCheckMsg, int[] aCheckState, int[] _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 4, getAddress(), aParent, aDialogTitle, aText, aCheckMsg, aCheckState, _retval);
+	}
+
+	public static final int BUTTON_POS_0 = 1;
+
+	public static final int BUTTON_POS_1 = 256;
+
+	public static final int BUTTON_POS_2 = 65536;
+
+	public static final int BUTTON_TITLE_OK = 1;
+
+	public static final int BUTTON_TITLE_CANCEL = 2;
+
+	public static final int BUTTON_TITLE_YES = 3;
+
+	public static final int BUTTON_TITLE_NO = 4;
+
+	public static final int BUTTON_TITLE_SAVE = 5;
+
+	public static final int BUTTON_TITLE_DONT_SAVE = 6;
+
+	public static final int BUTTON_TITLE_REVERT = 7;
+
+	public static final int BUTTON_TITLE_IS_STRING = 127;
+
+	public static final int BUTTON_POS_0_DEFAULT = 0;
+
+	public static final int BUTTON_POS_1_DEFAULT = 16777216;
+
+	public static final int BUTTON_POS_2_DEFAULT = 33554432;
+
+	public static final int BUTTON_DELAY_ENABLE = 67108864;
+
+	public static final int STD_OK_CANCEL_BUTTONS = 513;
+
+	public static final int STD_YES_NO_BUTTONS = 1027;
+	
+	public int ConfirmEx(int /*long*/ aParent, char[] aDialogTitle, char[] aText, int aButtonFlags, char[] aButton0Title, char[] aButton1Title, char[] aButton2Title, char[] aCheckMsg, int[] aCheckState, int[] _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 5, getAddress(), aParent, aDialogTitle, aText, aButtonFlags, aButton0Title, aButton1Title, aButton2Title, aCheckMsg, aCheckState, _retval);
+	}
+
+	public int Prompt(int /*long*/ aParent, char[] aDialogTitle, char[] aText, int /*long*/[] aValue, char[] aCheckMsg, int[] aCheckState, int[] _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 6, getAddress(), aParent, aDialogTitle, aText, aValue, aCheckMsg, aCheckState, _retval);
+	}
+
+	public int PromptUsernameAndPassword(int /*long*/ aParent, char[] aDialogTitle, char[] aText, int /*long*/[] aUsername, int /*long*/[] aPassword, char[] aCheckMsg, int[] aCheckState, int[] _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 7, getAddress(), aParent, aDialogTitle, aText, aUsername, aPassword, aCheckMsg, aCheckState, _retval);
+	}
+
+	public int PromptPassword(int /*long*/ aParent, char[] aDialogTitle, char[] aText, int /*long*/[] aPassword, char[] aCheckMsg, int[] aCheckState, int[] _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 8, getAddress(), aParent, aDialogTitle, aText, aPassword, aCheckMsg, aCheckState, _retval);
+	}
+
+	public int Select(int /*long*/ aParent, char[] aDialogTitle, char[] aText, int aCount, int /*long*/[] aSelectList, int[] aOutSelection, int[] _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 9, getAddress(), aParent, aDialogTitle, aText, aCount, aSelectList, aOutSelection, _retval);
+	}
+}
\ No newline at end of file


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIPromptService.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIPromptService2.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIPromptService2.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIPromptService2.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,51 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by Netscape are Copyright (C) 1998-1999
+ * Netscape Communications Corporation.  All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * -  Binding to permit interfacing between Mozilla and SWT
+ * -  Copyright (C) 2003, 2008 IBM Corp.  All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package org.eclipse.swt.internal.mozilla;
+
+public class nsIPromptService2 extends nsIPromptService {
+
+	static final int LAST_METHOD_ID = nsIPromptService.LAST_METHOD_ID + 2;
+
+	public static final String NS_IPROMPTSERVICE2_IID_STR =
+		"cf86d196-dbee-4482-9dfa-3477aa128319";
+
+	public static final nsID NS_IPROMPTSERVICE2_IID =
+		new nsID(NS_IPROMPTSERVICE2_IID_STR);
+
+	public nsIPromptService2(int /*long*/ address) {
+		super(address);
+	}
+
+	public int PromptAuth(int /*long*/ aParent, int /*long*/ aChannel, int level, int /*long*/ authInfo, char[] checkboxLabel, int[] checkValue, int[] _retval) {
+		return XPCOM.VtblCall(nsIPromptService.LAST_METHOD_ID + 1, getAddress(), aParent, aChannel, level, authInfo, checkboxLabel, checkValue, _retval);
+	}
+
+	public int AsyncPromptAuth(int /*long*/ aParent, int /*long*/ aChannel, int /*long*/ aCallback, int /*long*/ aContext, int level, int /*long*/ authInfo, char[] checkboxLabel, int[] checkValue, int /*long*/[] _retval) {
+		return XPCOM.VtblCall(nsIPromptService.LAST_METHOD_ID + 2, getAddress(), aParent, aChannel, aCallback, aContext, level, authInfo, checkboxLabel, checkValue, _retval);
+	}
+}
\ No newline at end of file


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIPromptService2.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIProperties.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIProperties.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIProperties.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,63 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by Netscape are Copyright (C) 1998-1999
+ * Netscape Communications Corporation.  All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * -  Binding to permit interfacing between Mozilla and SWT
+ * -  Copyright (C) 2003, 2008 IBM Corp.  All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package org.eclipse.swt.internal.mozilla;
+
+public class nsIProperties extends nsISupports {
+
+	static final int LAST_METHOD_ID = nsISupports.LAST_METHOD_ID + 5;
+
+	public static final String NS_IPROPERTIES_IID_STR =
+		"78650582-4e93-4b60-8e85-26ebd3eb14ca";
+
+	public static final nsID NS_IPROPERTIES_IID =
+		new nsID(NS_IPROPERTIES_IID_STR);
+
+	public nsIProperties(int /*long*/ address) {
+		super(address);
+	}
+
+	public int Get(byte[] prop, nsID iid, int /*long*/[] result) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 1, getAddress(), prop, iid, result);
+	}
+
+	public int Set(byte[] prop, int /*long*/ value) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 2, getAddress(), prop, value);
+	}
+
+	public int Has(byte[] prop, int[] _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 3, getAddress(), prop, _retval);
+	}
+
+	public int Undefine(byte[] prop) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 4, getAddress(), prop);
+	}
+
+	public int GetKeys(int[] count, int /*long*/[] keys) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 5, getAddress(), count, keys);
+	}
+}
\ No newline at end of file


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIProperties.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIRequest.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIRequest.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIRequest.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,101 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by Netscape are Copyright (C) 1998-1999
+ * Netscape Communications Corporation.  All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * -  Binding to permit interfacing between Mozilla and SWT
+ * -  Copyright (C) 2003, 2008 IBM Corp.  All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package org.eclipse.swt.internal.mozilla;
+
+public class nsIRequest extends nsISupports {
+
+	static final int LAST_METHOD_ID = nsISupports.LAST_METHOD_ID + 10;
+
+	public static final String NS_IREQUEST_IID_STR =
+		"ef6bfbd2-fd46-48d8-96b7-9f8f0fd387fe";
+
+	public static final nsID NS_IREQUEST_IID =
+		new nsID(NS_IREQUEST_IID_STR);
+
+	public nsIRequest(int /*long*/ address) {
+		super(address);
+	}
+
+	public int GetName(int /*long*/ aName) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 1, getAddress(), aName);
+	}
+
+	public int IsPending(int[] _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 2, getAddress(), _retval);
+	}
+
+	public int GetStatus(int /*long*/[] aStatus) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 3, getAddress(), aStatus);
+	}
+
+	public int Cancel(int aStatus) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 4, getAddress(), aStatus);
+	}
+
+	public int Suspend() {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 5, getAddress());
+	}
+
+	public int Resume() {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 6, getAddress());
+	}
+
+	public int GetLoadGroup(int /*long*/[] aLoadGroup) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 7, getAddress(), aLoadGroup);
+	}
+
+	public int SetLoadGroup(int /*long*/ aLoadGroup) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 8, getAddress(), aLoadGroup);
+	}
+
+	public int GetLoadFlags(int /*long*/[] aLoadFlags) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 9, getAddress(), aLoadFlags);
+	}
+
+	public int SetLoadFlags(int aLoadFlags) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 10, getAddress(), aLoadFlags);
+	}
+
+	public static final int LOAD_NORMAL = 0;
+
+	public static final int LOAD_BACKGROUND = 1;
+
+	public static final int INHIBIT_CACHING = 128;
+
+	public static final int INHIBIT_PERSISTENT_CACHING = 256;
+
+	public static final int LOAD_BYPASS_CACHE = 512;
+
+	public static final int LOAD_FROM_CACHE = 1024;
+
+	public static final int VALIDATE_ALWAYS = 2048;
+
+	public static final int VALIDATE_NEVER = 4096;
+
+	public static final int VALIDATE_ONCE_PER_SESSION = 8192;
+}
\ No newline at end of file


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIRequest.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIServiceManager.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIServiceManager.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIServiceManager.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,59 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by Netscape are Copyright (C) 1998-1999
+ * Netscape Communications Corporation.  All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * -  Binding to permit interfacing between Mozilla and SWT
+ * -  Copyright (C) 2003, 2008 IBM Corp.  All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package org.eclipse.swt.internal.mozilla;
+
+public class nsIServiceManager extends nsISupports {
+
+	static final int LAST_METHOD_ID = nsISupports.LAST_METHOD_ID + 4;
+
+	public static final String NS_ISERVICEMANAGER_IID_STR =
+		"8bb35ed9-e332-462d-9155-4a002ab5c958";
+
+	public static final nsID NS_ISERVICEMANAGER_IID =
+		new nsID(NS_ISERVICEMANAGER_IID_STR);
+
+	public nsIServiceManager(int /*long*/ address) {
+		super(address);
+	}
+
+	public int GetService(nsID aClass, nsID aIID, int /*long*/[] result) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 1, getAddress(), aClass, aIID, result);
+	}
+
+	public int GetServiceByContractID(byte[] aContractID, nsID aIID, int /*long*/[] result) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 2, getAddress(), aContractID, aIID, result);
+	}
+
+	public int IsServiceInstantiated(nsID aClass, nsID aIID, int[] _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 3, getAddress(), aClass, aIID, _retval);
+	}
+
+	public int IsServiceInstantiatedByContractID(byte[] aContractID, nsID aIID, int[] _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 4, getAddress(), aContractID, aIID, _retval);
+	}
+}
\ No newline at end of file


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIServiceManager.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsISimpleEnumerator.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsISimpleEnumerator.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsISimpleEnumerator.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,51 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by Netscape are Copyright (C) 1998-1999
+ * Netscape Communications Corporation.  All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * -  Binding to permit interfacing between Mozilla and SWT
+ * -  Copyright (C) 2003, 2008 IBM Corp.  All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package org.eclipse.swt.internal.mozilla;
+
+public class nsISimpleEnumerator extends nsISupports {
+
+	static final int LAST_METHOD_ID = nsISupports.LAST_METHOD_ID + 2;
+
+	public static final String NS_ISIMPLEENUMERATOR_IID_STR =
+		"d1899240-f9d2-11d2-bdd6-000064657374";
+
+	public static final nsID NS_ISIMPLEENUMERATOR_IID =
+		new nsID(NS_ISIMPLEENUMERATOR_IID_STR);
+
+	public nsISimpleEnumerator(int /*long*/ address) {
+		super(address);
+	}
+
+	public int HasMoreElements(int[] _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 1, getAddress(), _retval);
+	}
+
+	public int GetNext(int /*long*/[] _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 2, getAddress(), _retval);
+	}
+}
\ No newline at end of file


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsISimpleEnumerator.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsISupports.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsISupports.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsISupports.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,61 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by Netscape are Copyright (C) 1998-1999
+ * Netscape Communications Corporation.  All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * -  Binding to permit interfacing between Mozilla and SWT
+ * -  Copyright (C) 2003, 2005 IBM Corp.  All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package org.eclipse.swt.internal.mozilla;
+
+public class nsISupports {
+
+	static final int LAST_METHOD_ID = 2;
+
+	public static final String NS_ISUPPORTS_IID_STR =
+		"00000000-0000-0000-c000-000000000046";
+
+	public static final nsID NS_ISUPPORTS_IID =
+		new nsID(NS_ISUPPORTS_IID_STR);
+
+	int /*long*/ address;
+
+	public nsISupports(int /*long*/ address) {
+		this.address = address;
+	}
+
+	public int /*long*/ getAddress() {
+		return this.address;
+	}
+
+	public int QueryInterface(nsID uuid, int /*long*/[] result) {
+		return XPCOM.VtblCall(0, getAddress(), uuid, result);
+	}
+
+	public int AddRef() {
+		return XPCOM.VtblCall(1, getAddress());
+	}
+
+	public int Release() {
+		return XPCOM.VtblCall(2, getAddress());
+	}
+}
\ No newline at end of file


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsISupports.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsISupportsWeakReference.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsISupportsWeakReference.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsISupportsWeakReference.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,47 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by Netscape are Copyright (C) 1998-1999
+ * Netscape Communications Corporation.  All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * -  Binding to permit interfacing between Mozilla and SWT
+ * -  Copyright (C) 2003, 2005 IBM Corp.  All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package org.eclipse.swt.internal.mozilla;
+
+public class nsISupportsWeakReference extends nsISupports {
+
+	static final int LAST_METHOD_ID = nsISupports.LAST_METHOD_ID + 1;
+
+	public static final String NS_ISUPPORTSWEAKREFERENCE_IID_STR =
+		"9188bc86-f92e-11d2-81ef-0060083a0bcf";
+
+	public static final nsID NS_ISUPPORTSWEAKREFERENCE_IID =
+		new nsID(NS_ISUPPORTSWEAKREFERENCE_IID_STR);
+
+	public nsISupportsWeakReference(int /*long*/ address) {
+		super(address);
+	}
+
+	public int GetWeakReference(int /*long*/[] _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 1, getAddress(), _retval);
+	}
+}
\ No newline at end of file


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsISupportsWeakReference.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsITooltipListener.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsITooltipListener.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsITooltipListener.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,51 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by Netscape are Copyright (C) 1998-1999
+ * Netscape Communications Corporation.  All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * -  Binding to permit interfacing between Mozilla and SWT
+ * -  Copyright (C) 2004, 2005 IBM Corp.  All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package org.eclipse.swt.internal.mozilla;
+
+public class nsITooltipListener extends nsISupports {
+
+	static final int LAST_METHOD_ID = nsISupports.LAST_METHOD_ID + 2;
+
+	public static final String NS_ITOOLTIPLISTENER_IID_STR =
+		"44b78386-1dd2-11b2-9ad2-e4eee2ca1916";
+
+	public static final nsID NS_ITOOLTIPLISTENER_IID =
+		new nsID(NS_ITOOLTIPLISTENER_IID_STR);
+
+	public nsITooltipListener(int /*long*/ address) {
+		super(address);
+	}
+
+	public int OnShowTooltip(int aXCoords, int aYCoords, char[] aTipText) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 1, getAddress(), aXCoords, aYCoords, aTipText);
+	}
+
+	public int OnHideTooltip() {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 2, getAddress());
+	}
+}
\ No newline at end of file


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsITooltipListener.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsITransfer.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsITransfer.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsITransfer.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,47 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by Netscape are Copyright (C) 1998-1999
+ * Netscape Communications Corporation.  All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * -  Binding to permit interfacing between Mozilla and SWT
+ * -  Copyright (C) 2003 IBM Corp.  All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package org.eclipse.swt.internal.mozilla;
+
+public class nsITransfer extends nsIWebProgressListener2 {
+
+	static final int LAST_METHOD_ID = nsIWebProgressListener2.LAST_METHOD_ID + 1;
+
+	public static final String NS_ITRANSFER_IID_STR =
+		"23c51569-e9a1-4a92-adeb-3723db82ef7c";
+
+	public static final nsID NS_ITRANSFER_IID =
+		new nsID(NS_ITRANSFER_IID_STR);
+
+	public nsITransfer(int /*long*/ address) {
+		super(address);
+	}
+
+	public int Init(int /*long*/ aSource, int /*long*/ aTarget, int /*long*/ aDisplayName, int /*long*/ aMIMEInfo, long startTime, int /*long*/ aTempFile, int /*long*/ aCancelable) {
+		return XPCOM.VtblCall(nsIWebProgressListener2.LAST_METHOD_ID + 1, getAddress(), aSource, aTarget, aDisplayName, aMIMEInfo, startTime, aTempFile, aCancelable);
+	}
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsITransfer.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIURI.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIURI.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIURI.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,147 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by Netscape are Copyright (C) 1998-1999
+ * Netscape Communications Corporation.  All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * -  Binding to permit interfacing between Mozilla and SWT
+ * -  Copyright (C) 2003, 2008 IBM Corp.  All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package org.eclipse.swt.internal.mozilla;
+
+public class nsIURI extends nsISupports {
+
+	static final int LAST_METHOD_ID = nsISupports.LAST_METHOD_ID + 26;
+
+	public static final String NS_IURI_IID_STR =
+		"07a22cc0-0ce5-11d3-9331-00104ba0fd40";
+
+	public static final nsID NS_IURI_IID =
+		new nsID(NS_IURI_IID_STR);
+
+	public nsIURI(int /*long*/ address) {
+		super(address);
+	}
+
+	public int GetSpec(int /*long*/ aSpec) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 1, getAddress(), aSpec);
+	}
+
+	public int SetSpec(int /*long*/ aSpec) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 2, getAddress(), aSpec);
+	}
+
+	public int GetPrePath(int /*long*/ aPrePath) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 3, getAddress(), aPrePath);
+	}
+
+	public int GetScheme(int /*long*/ aScheme) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 4, getAddress(), aScheme);
+	}
+
+	public int SetScheme(int /*long*/ aScheme) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 5, getAddress(), aScheme);
+	}
+
+	public int GetUserPass(int /*long*/ aUserPass) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 6, getAddress(), aUserPass);
+	}
+
+	public int SetUserPass(int /*long*/ aUserPass) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 7, getAddress(), aUserPass);
+	}
+
+	public int GetUsername(int /*long*/ aUsername) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 8, getAddress(), aUsername);
+	}
+
+	public int SetUsername(int /*long*/ aUsername) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 9, getAddress(), aUsername);
+	}
+
+	public int GetPassword(int /*long*/ aPassword) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 10, getAddress(), aPassword);
+	}
+
+	public int SetPassword(int /*long*/ aPassword) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 11, getAddress(), aPassword);
+	}
+
+	public int GetHostPort(int /*long*/ aHostPort) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 12, getAddress(), aHostPort);
+	}
+
+	public int SetHostPort(int /*long*/ aHostPort) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 13, getAddress(), aHostPort);
+	}
+
+	public int GetHost(int /*long*/ aHost) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 14, getAddress(), aHost);
+	}
+
+	public int SetHost(int /*long*/ aHost) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 15, getAddress(), aHost);
+	}
+
+	public int GetPort(int[] aPort) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 16, getAddress(), aPort);
+	}
+
+	public int SetPort(int aPort) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 17, getAddress(), aPort);
+	}
+
+	public int GetPath(int /*long*/ aPath) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 18, getAddress(), aPath);
+	}
+
+	public int SetPath(int /*long*/ aPath) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 19, getAddress(), aPath);
+	}
+
+	public int Equals(int /*long*/ other, int[] _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 20, getAddress(), other, _retval);
+	}
+
+	public int SchemeIs(byte[] scheme, int[] _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 21, getAddress(), scheme, _retval);
+	}
+
+	public int Clone(int /*long*/[] _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 22, getAddress(), _retval);
+	}
+
+	public int Resolve(int /*long*/ relativePath, int /*long*/ _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 23, getAddress(), relativePath, _retval);
+	}
+
+	public int GetAsciiSpec(int /*long*/ aAsciiSpec) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 24, getAddress(), aAsciiSpec);
+	}
+
+	public int GetAsciiHost(int /*long*/ aAsciiHost) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 25, getAddress(), aAsciiHost);
+	}
+
+	public int GetOriginCharset(int /*long*/ aOriginCharset) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 26, getAddress(), aOriginCharset);
+	}
+}
\ No newline at end of file


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIURI.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIURIContentListener.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIURIContentListener.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIURIContentListener.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,75 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by Netscape are Copyright (C) 1998-1999
+ * Netscape Communications Corporation.  All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * -  Binding to permit interfacing between Mozilla and SWT
+ * -  Copyright (C) 2003, 2008 IBM Corp.  All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package org.eclipse.swt.internal.mozilla;
+
+public class nsIURIContentListener extends nsISupports {
+
+	static final int LAST_METHOD_ID = nsISupports.LAST_METHOD_ID + 8;
+
+	public static final String NS_IURICONTENTLISTENER_IID_STR =
+		"94928ab3-8b63-11d3-989d-001083010e9b";
+
+	public static final nsID NS_IURICONTENTLISTENER_IID =
+		new nsID(NS_IURICONTENTLISTENER_IID_STR);
+
+	public nsIURIContentListener(int /*long*/ address) {
+		super(address);
+	}
+
+	public int OnStartURIOpen(int /*long*/ aURI, int[] _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 1, getAddress(), aURI, _retval);
+	}
+
+	public int DoContent(byte[] aContentType, int aIsContentPreferred, int /*long*/ aRequest, int /*long*/[] aContentHandler, int[] _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 2, getAddress(), aContentType, aIsContentPreferred, aRequest, aContentHandler, _retval);
+	}
+
+	public int IsPreferred(byte[] aContentType, int /*long*/[] aDesiredContentType, int[] _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 3, getAddress(), aContentType, aDesiredContentType, _retval);
+	}
+
+	public int CanHandleContent(byte[] aContentType, int aIsContentPreferred, int /*long*/[] aDesiredContentType, int[] _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 4, getAddress(), aContentType, aIsContentPreferred, aDesiredContentType, _retval);
+	}
+
+	public int GetLoadCookie(int /*long*/[] aLoadCookie) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 5, getAddress(), aLoadCookie);
+	}
+
+	public int SetLoadCookie(int /*long*/ aLoadCookie) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 6, getAddress(), aLoadCookie);
+	}
+
+	public int GetParentContentListener(int /*long*/[] aParentContentListener) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 7, getAddress(), aParentContentListener);
+	}
+
+	public int SetParentContentListener(int /*long*/ aParentContentListener) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 8, getAddress(), aParentContentListener);
+	}
+}
\ No newline at end of file


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIURIContentListener.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIWeakReference.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIWeakReference.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIWeakReference.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,47 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by Netscape are Copyright (C) 1998-1999
+ * Netscape Communications Corporation.  All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * -  Binding to permit interfacing between Mozilla and SWT
+ * -  Copyright (C) 2003, 2005 IBM Corp.  All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package org.eclipse.swt.internal.mozilla;
+
+public class nsIWeakReference extends nsISupports {
+
+	static final int LAST_METHOD_ID = nsISupports.LAST_METHOD_ID + 1;
+
+	public static final String NS_IWEAKREFERENCE_IID_STR =
+		"9188bc85-f92e-11d2-81ef-0060083a0bcf";
+
+	public static final nsID NS_IWEAKREFERENCE_IID =
+		new nsID(NS_IWEAKREFERENCE_IID_STR);
+
+	public nsIWeakReference(int /*long*/ address) {
+		super(address);
+	}
+
+	public int QueryReferent(nsID uuid, int /*long*/[] result) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 1, getAddress(), uuid, result);
+	}
+}
\ No newline at end of file


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIWeakReference.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIWebBrowser.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIWebBrowser.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIWebBrowser.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,71 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by Netscape are Copyright (C) 1998-1999
+ * Netscape Communications Corporation.  All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * -  Binding to permit interfacing between Mozilla and SWT
+ * -  Copyright (C) 2003, 2005 IBM Corp.  All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package org.eclipse.swt.internal.mozilla;
+
+public class nsIWebBrowser extends nsISupports {
+
+	static final int LAST_METHOD_ID = nsISupports.LAST_METHOD_ID + 7;
+
+	public static final String NS_IWEBBROWSER_IID_STR =
+		"69e5df00-7b8b-11d3-af61-00a024ffc08c";
+
+	public static final nsID NS_IWEBBROWSER_IID =
+		new nsID(NS_IWEBBROWSER_IID_STR);
+
+	public nsIWebBrowser(int /*long*/ address) {
+		super(address);
+	}
+
+	public int AddWebBrowserListener(int /*long*/ aListener, nsID aIID) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 1, getAddress(), aListener, aIID);
+	}
+
+	public int RemoveWebBrowserListener(int /*long*/ aListener, nsID aIID) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 2, getAddress(), aListener, aIID);
+	}
+
+	public int GetContainerWindow(int /*long*/[] aContainerWindow) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 3, getAddress(), aContainerWindow);
+	}
+
+	public int SetContainerWindow(int /*long*/ aContainerWindow) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 4, getAddress(), aContainerWindow);
+	}
+
+	public int GetParentURIContentListener(int /*long*/[] aParentURIContentListener) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 5, getAddress(), aParentURIContentListener);
+	}
+
+	public int SetParentURIContentListener(int /*long*/ aParentURIContentListener) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 6, getAddress(), aParentURIContentListener);
+	}
+
+	public int GetContentDOMWindow(int /*long*/[] aContentDOMWindow) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 7, getAddress(), aContentDOMWindow);
+	}
+}
\ No newline at end of file


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIWebBrowser.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIWebBrowserChrome.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIWebBrowserChrome.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIWebBrowserChrome.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,137 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by Netscape are Copyright (C) 1998-1999
+ * Netscape Communications Corporation.  All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * -  Binding to permit interfacing between Mozilla and SWT
+ * -  Copyright (C) 2003, 2008 IBM Corp.  All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package org.eclipse.swt.internal.mozilla;
+
+public class nsIWebBrowserChrome extends nsISupports {
+
+	static final int LAST_METHOD_ID = nsISupports.LAST_METHOD_ID + 10;
+
+	public static final String NS_IWEBBROWSERCHROME_IID_STR =
+		"ba434c60-9d52-11d3-afb0-00a024ffc08c";
+
+	public static final nsID NS_IWEBBROWSERCHROME_IID =
+		new nsID(NS_IWEBBROWSERCHROME_IID_STR);
+
+	public nsIWebBrowserChrome(int /*long*/ address) {
+		super(address);
+	}
+
+	public static final int STATUS_SCRIPT = 1;
+
+	public static final int STATUS_SCRIPT_DEFAULT = 2;
+
+	public static final int STATUS_LINK = 3;
+
+	public int SetStatus(int statusType, char[] status) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 1, getAddress(), statusType, status);
+	}
+
+	public int GetWebBrowser(int /*long*/[] aWebBrowser) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 2, getAddress(), aWebBrowser);
+	}
+
+	public int SetWebBrowser(int /*long*/ aWebBrowser) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 3, getAddress(), aWebBrowser);
+	}
+
+	public static final int CHROME_DEFAULT = 1;
+
+	public static final int CHROME_WINDOW_BORDERS = 2;
+
+	public static final int CHROME_WINDOW_CLOSE = 4;
+
+	public static final int CHROME_WINDOW_RESIZE = 8;
+
+	public static final int CHROME_MENUBAR = 16;
+
+	public static final int CHROME_TOOLBAR = 32;
+
+	public static final int CHROME_LOCATIONBAR = 64;
+
+	public static final int CHROME_STATUSBAR = 128;
+
+	public static final int CHROME_PERSONAL_TOOLBAR = 256;
+
+	public static final int CHROME_SCROLLBARS = 512;
+
+	public static final int CHROME_TITLEBAR = 1024;
+
+	public static final int CHROME_EXTRA = 2048;
+
+	public static final int CHROME_WITH_SIZE = 4096;
+
+	public static final int CHROME_WITH_POSITION = 8192;
+
+	public static final int CHROME_WINDOW_MIN = 16384;
+
+	public static final int CHROME_WINDOW_POPUP = 32768;
+
+	public static final int CHROME_WINDOW_RAISED = 33554432;
+
+	public static final int CHROME_WINDOW_LOWERED = 67108864;
+
+	public static final int CHROME_CENTER_SCREEN = 134217728;
+
+	public static final int CHROME_DEPENDENT = 268435456;
+
+	public static final int CHROME_MODAL = 536870912;
+
+	public static final int CHROME_OPENAS_DIALOG = 1073741824;
+
+	public static final int CHROME_OPENAS_CHROME = -2147483648;
+
+	public static final int CHROME_ALL = 4094;
+
+	public int GetChromeFlags(int[] aChromeFlags) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 4, getAddress(), aChromeFlags);
+	}
+
+	public int SetChromeFlags(int aChromeFlags) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 5, getAddress(), aChromeFlags);
+	}
+
+	public int DestroyBrowserWindow() {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 6, getAddress());
+	}
+
+	public int SizeBrowserTo(int aCX, int aCY) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 7, getAddress(), aCX, aCY);
+	}
+
+	public int ShowAsModal() {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 8, getAddress());
+	}
+
+	public int IsWindowModal(int[] _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 9, getAddress(), _retval);
+	}
+
+	public int ExitModalEventLoop(int aStatus) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 10, getAddress(), aStatus);
+	}
+}
\ No newline at end of file


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIWebBrowserChrome.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIWebBrowserChromeFocus.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIWebBrowserChromeFocus.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIWebBrowserChromeFocus.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,51 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by Netscape are Copyright (C) 1998-1999
+ * Netscape Communications Corporation.  All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * -  Binding to permit interfacing between Mozilla and SWT
+ * -  Copyright (C) 2003, 2005 IBM Corp.  All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package org.eclipse.swt.internal.mozilla;
+
+public class nsIWebBrowserChromeFocus extends nsISupports {
+
+	static final int LAST_METHOD_ID = nsISupports.LAST_METHOD_ID + 2;
+
+	public static final String NS_IWEBBROWSERCHROMEFOCUS_IID_STR =
+		"d2206418-1dd1-11b2-8e55-acddcd2bcfb8";
+
+	public static final nsID NS_IWEBBROWSERCHROMEFOCUS_IID =
+		new nsID(NS_IWEBBROWSERCHROMEFOCUS_IID_STR);
+
+	public nsIWebBrowserChromeFocus(int /*long*/ address) {
+		super(address);
+	}
+
+	public int FocusNextElement() {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 1, getAddress());
+	}
+
+	public int FocusPrevElement() {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 2, getAddress());
+	}
+}
\ No newline at end of file


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIWebBrowserChromeFocus.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIWebBrowserFocus.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIWebBrowserFocus.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIWebBrowserFocus.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,75 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by Netscape are Copyright (C) 1998-1999
+ * Netscape Communications Corporation.  All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * -  Binding to permit interfacing between Mozilla and SWT
+ * -  Copyright (C) 2003, 2005 IBM Corp.  All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package org.eclipse.swt.internal.mozilla;
+
+public class nsIWebBrowserFocus extends nsISupports {
+
+	static final int LAST_METHOD_ID = nsISupports.LAST_METHOD_ID + 8;
+
+	public static final String NS_IWEBBROWSERFOCUS_IID_STR =
+		"9c5d3c58-1dd1-11b2-a1c9-f3699284657a";
+
+	public static final nsID NS_IWEBBROWSERFOCUS_IID =
+		new nsID(NS_IWEBBROWSERFOCUS_IID_STR);
+
+	public nsIWebBrowserFocus(int /*long*/ address) {
+		super(address);
+	}
+
+	public int Activate() {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 1, getAddress());
+	}
+
+	public int Deactivate() {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 2, getAddress());
+	}
+
+	public int SetFocusAtFirstElement() {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 3, getAddress());
+	}
+
+	public int SetFocusAtLastElement() {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 4, getAddress());
+	}
+
+	public int GetFocusedWindow(int /*long*/[] aFocusedWindow) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 5, getAddress(), aFocusedWindow);
+	}
+
+	public int SetFocusedWindow(int /*long*/ aFocusedWindow) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 6, getAddress(), aFocusedWindow);
+	}
+
+	public int GetFocusedElement(int /*long*/[] aFocusedElement) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 7, getAddress(), aFocusedElement);
+	}
+
+	public int SetFocusedElement(int /*long*/ aFocusedElement) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 8, getAddress(), aFocusedElement);
+	}
+}
\ No newline at end of file


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIWebBrowserFocus.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIWebNavigation.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIWebNavigation.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIWebNavigation.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,119 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by Netscape are Copyright (C) 1998-1999
+ * Netscape Communications Corporation.  All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * -  Binding to permit interfacing between Mozilla and SWT
+ * -  Copyright (C) 2003, 2008 IBM Corp.  All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package org.eclipse.swt.internal.mozilla;
+
+public class nsIWebNavigation extends nsISupports {
+
+	static final int LAST_METHOD_ID = nsISupports.LAST_METHOD_ID + 13;
+
+	public static final String NS_IWEBNAVIGATION_IID_STR =
+		"f5d9e7b0-d930-11d3-b057-00a024ffc08c";
+
+	public static final nsID NS_IWEBNAVIGATION_IID =
+		new nsID(NS_IWEBNAVIGATION_IID_STR);
+
+	public nsIWebNavigation(int /*long*/ address) {
+		super(address);
+	}
+
+	public int GetCanGoBack(int[] aCanGoBack) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 1, getAddress(), aCanGoBack);
+	}
+
+	public int GetCanGoForward(int[] aCanGoForward) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 2, getAddress(), aCanGoForward);
+	}
+
+	public int GoBack() {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 3, getAddress());
+	}
+
+	public int GoForward() {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 4, getAddress());
+	}
+
+	public int GotoIndex(int index) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 5, getAddress(), index);
+	}
+
+	public static final int LOAD_FLAGS_MASK = 65535;
+
+	public static final int LOAD_FLAGS_NONE = 0;
+
+	public static final int LOAD_FLAGS_IS_REFRESH = 16;
+
+	public static final int LOAD_FLAGS_IS_LINK = 32;
+
+	public static final int LOAD_FLAGS_BYPASS_HISTORY = 64;
+
+	public static final int LOAD_FLAGS_REPLACE_HISTORY = 128;
+
+	public static final int LOAD_FLAGS_BYPASS_CACHE = 256;
+
+	public static final int LOAD_FLAGS_BYPASS_PROXY = 512;
+
+	public static final int LOAD_FLAGS_CHARSET_CHANGE = 1024;
+
+	public int LoadURI(char[] uri, int loadFlags, int /*long*/ referrer, int /*long*/ postData, int /*long*/ headers) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 6, getAddress(), uri, loadFlags, referrer, postData, headers);
+	}
+
+	public int Reload(int reloadFlags) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 7, getAddress(), reloadFlags);
+	}
+
+	public static final int STOP_NETWORK = 1;
+
+	public static final int STOP_CONTENT = 2;
+
+	public static final int STOP_ALL = 3;
+
+	public int Stop(int stopFlags) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 8, getAddress(), stopFlags);
+	}
+
+	public int GetDocument(int /*long*/[] aDocument) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 9, getAddress(), aDocument);
+	}
+
+	public int GetCurrentURI(int /*long*/[] aCurrentURI) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 10, getAddress(), aCurrentURI);
+	}
+
+	public int GetReferringURI(int /*long*/[] aReferringURI) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 11, getAddress(), aReferringURI);
+	}
+
+	public int GetSessionHistory(int /*long*/[] aSessionHistory) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 12, getAddress(), aSessionHistory);
+	}
+
+	public int SetSessionHistory(int /*long*/ aSessionHistory) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 13, getAddress(), aSessionHistory);
+	}
+}
\ No newline at end of file


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIWebNavigation.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIWebNavigationInfo.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIWebNavigationInfo.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIWebNavigationInfo.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,55 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by Netscape are Copyright (C) 1998-1999
+ * Netscape Communications Corporation.  All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * -  Binding to permit interfacing between Mozilla and SWT
+ * -  Copyright (C) 2003, 2005 IBM Corp.  All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package org.eclipse.swt.internal.mozilla;
+
+public class nsIWebNavigationInfo extends nsISupports {
+
+	static final int LAST_METHOD_ID = nsISupports.LAST_METHOD_ID + 1;
+
+	public static final String NS_IWEBNAVIGATIONINFO_IID_STR =
+		"62a93afb-93a1-465c-84c8-0432264229de";
+
+	public static final nsID NS_IWEBNAVIGATIONINFO_IID =
+		new nsID(NS_IWEBNAVIGATIONINFO_IID_STR);
+
+	public nsIWebNavigationInfo(int /*long*/ address) {
+		super(address);
+	}
+
+	public static final int UNSUPPORTED = 0;
+
+	public static final int IMAGE = 1;
+
+	public static final int PLUGIN = 2;
+
+	public static final int OTHER = 32768;
+
+	public int IsTypeSupported(int /*long*/ aType, int /*long*/ aWebNav, int[] _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 1, getAddress(), aType, aWebNav, _retval);
+	}
+}
\ No newline at end of file


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIWebNavigationInfo.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIWebProgress.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIWebProgress.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIWebProgress.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,79 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by Netscape are Copyright (C) 1998-1999
+ * Netscape Communications Corporation.  All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * -  Binding to permit interfacing between Mozilla and SWT
+ * -  Copyright (C) 2003, 2008 IBM Corp.  All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package org.eclipse.swt.internal.mozilla;
+
+public class nsIWebProgress extends nsISupports {
+
+	static final int LAST_METHOD_ID = nsISupports.LAST_METHOD_ID + 4;
+
+	public static final String NS_IWEBPROGRESS_IID_STR =
+		"570f39d0-efd0-11d3-b093-00a024ffc08c";
+
+	public static final nsID NS_IWEBPROGRESS_IID =
+		new nsID(NS_IWEBPROGRESS_IID_STR);
+
+	public nsIWebProgress(int /*long*/ address) {
+		super(address);
+	}
+
+	public static final int NOTIFY_STATE_REQUEST = 1;
+
+	public static final int NOTIFY_STATE_DOCUMENT = 2;
+
+	public static final int NOTIFY_STATE_NETWORK = 4;
+
+	public static final int NOTIFY_STATE_WINDOW = 8;
+
+	public static final int NOTIFY_STATE_ALL = 15;
+
+	public static final int NOTIFY_PROGRESS = 16;
+
+	public static final int NOTIFY_STATUS = 32;
+
+	public static final int NOTIFY_SECURITY = 64;
+
+	public static final int NOTIFY_LOCATION = 128;
+
+	public static final int NOTIFY_ALL = 255;
+
+	public int AddProgressListener(int /*long*/ listener, int aNotifyMask) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 1, getAddress(), listener, aNotifyMask);
+	}
+
+	public int RemoveProgressListener(int /*long*/ listener) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 2, getAddress(), listener);
+	}
+
+	public int GetDOMWindow(int /*long*/[] aDOMWindow) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 3, getAddress(), aDOMWindow);
+	}
+
+	public int GetIsLoadingDocument(int[] aIsLoadingDocument) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 4, getAddress(), aIsLoadingDocument);
+	}
+}
\ No newline at end of file


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIWebProgress.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIWebProgressListener.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIWebProgressListener.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIWebProgressListener.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,93 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by Netscape are Copyright (C) 1998-1999
+ * Netscape Communications Corporation.  All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * -  Binding to permit interfacing between Mozilla and SWT
+ * -  Copyright (C) 2003, 2005 IBM Corp.  All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package org.eclipse.swt.internal.mozilla;
+
+public class nsIWebProgressListener extends nsISupports {
+
+	static final int LAST_METHOD_ID = nsISupports.LAST_METHOD_ID + 5;
+
+	public static final String NS_IWEBPROGRESSLISTENER_IID_STR =
+		"570f39d1-efd0-11d3-b093-00a024ffc08c";
+
+	public static final nsID NS_IWEBPROGRESSLISTENER_IID =
+		new nsID(NS_IWEBPROGRESSLISTENER_IID_STR);
+
+	public nsIWebProgressListener(int /*long*/ address) {
+		super(address);
+	}
+
+	public static final int STATE_START = 1;
+
+	public static final int STATE_REDIRECTING = 2;
+
+	public static final int STATE_TRANSFERRING = 4;
+
+	public static final int STATE_NEGOTIATING = 8;
+
+	public static final int STATE_STOP = 16;
+
+	public static final int STATE_IS_REQUEST = 65536;
+
+	public static final int STATE_IS_DOCUMENT = 131072;
+
+	public static final int STATE_IS_NETWORK = 262144;
+
+	public static final int STATE_IS_WINDOW = 524288;
+
+	public static final int STATE_IS_INSECURE = 4;
+
+	public static final int STATE_IS_BROKEN = 1;
+
+	public static final int STATE_IS_SECURE = 2;
+
+	public static final int STATE_SECURE_HIGH = 262144;
+
+	public static final int STATE_SECURE_MED = 65536;
+
+	public static final int STATE_SECURE_LOW = 131072;
+
+	public int OnStateChange(int /*long*/ aWebProgress, int /*long*/ aRequest, int aStateFlags, int aStatus) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 1, getAddress(), aWebProgress, aRequest, aStateFlags, aStatus);
+	}
+
+	public int OnProgressChange(int /*long*/ aWebProgress, int /*long*/ aRequest, int aCurSelfProgress, int aMaxSelfProgress, int aCurTotalProgress, int aMaxTotalProgress) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 2, getAddress(), aWebProgress, aRequest, aCurSelfProgress, aMaxSelfProgress, aCurTotalProgress, aMaxTotalProgress);
+	}
+
+	public int OnLocationChange(int /*long*/ aWebProgress, int /*long*/ aRequest, int /*long*/ location) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 3, getAddress(), aWebProgress, aRequest, location);
+	}
+
+	public int OnStatusChange(int /*long*/ aWebProgress, int /*long*/ aRequest, int aStatus, char[] aMessage) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 4, getAddress(), aWebProgress, aRequest, aStatus, aMessage);
+	}
+
+	public int OnSecurityChange(int /*long*/ aWebProgress, int /*long*/ aRequest, int state) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 5, getAddress(), aWebProgress, aRequest, state);
+	}
+}
\ No newline at end of file


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIWebProgressListener.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIWebProgressListener2.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIWebProgressListener2.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIWebProgressListener2.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,47 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by Netscape are Copyright (C) 1998-1999
+ * Netscape Communications Corporation.  All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * -  Binding to permit interfacing between Mozilla and SWT
+ * -  Copyright (C) 2003 IBM Corp.  All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package org.eclipse.swt.internal.mozilla;
+
+public class nsIWebProgressListener2 extends nsIWebProgressListener {
+
+	static final int LAST_METHOD_ID = nsIWebProgressListener.LAST_METHOD_ID + 1;
+
+	public static final String NS_IWEBPROGRESSLISTENER2_IID_STR =
+		"3f24610d-1e1f-4151-9d2e-239884742324";
+
+	public static final nsID NS_IWEBPROGRESSLISTENER2_IID =
+		new nsID(NS_IWEBPROGRESSLISTENER2_IID_STR);
+
+	public nsIWebProgressListener2(int /*long*/ address) {
+		super(address);
+	}
+
+	public int OnProgressChange64(int /*long*/ aWebProgress, int /*long*/ aRequest, long aCurSelfProgress, long aMaxSelfProgress, long aCurTotalProgress, long aMaxTotalProgress) {
+		return XPCOM.VtblCall(nsIWebProgressListener.LAST_METHOD_ID + 1, getAddress(), aWebProgress, aRequest, aCurSelfProgress, aMaxSelfProgress, aCurTotalProgress, aMaxTotalProgress);
+	}
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIWebProgressListener2.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIWindowCreator.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIWindowCreator.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIWindowCreator.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,47 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by Netscape are Copyright (C) 1998-1999
+ * Netscape Communications Corporation.  All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * -  Binding to permit interfacing between Mozilla and SWT
+ * -  Copyright (C) 2003, 2005 IBM Corp.  All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package org.eclipse.swt.internal.mozilla;
+
+public class nsIWindowCreator extends nsISupports {
+
+	static final int LAST_METHOD_ID = nsISupports.LAST_METHOD_ID + 1;
+
+	public static final String NS_IWINDOWCREATOR_IID_STR =
+		"30465632-a777-44cc-90f9-8145475ef999";
+
+	public static final nsID NS_IWINDOWCREATOR_IID =
+		new nsID(NS_IWINDOWCREATOR_IID_STR);
+
+	public nsIWindowCreator(int /*long*/ address) {
+		super(address);
+	}
+
+	public int CreateChromeWindow(int /*long*/ parent, int chromeFlags, int /*long*/[] _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 1, getAddress(), parent, chromeFlags, _retval);
+	}
+}
\ No newline at end of file


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIWindowCreator.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIWindowCreator2.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIWindowCreator2.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIWindowCreator2.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,49 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by Netscape are Copyright (C) 1998-1999
+ * Netscape Communications Corporation.  All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * -  Binding to permit interfacing between Mozilla and SWT
+ * -  Copyright (C) 2003, 2008 IBM Corp.  All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package org.eclipse.swt.internal.mozilla;
+
+public class nsIWindowCreator2 extends nsIWindowCreator {
+
+	static final int LAST_METHOD_ID = nsIWindowCreator.LAST_METHOD_ID + 1;
+
+	public static final String NS_IWINDOWCREATOR2_IID_STR =
+		"f673ec81-a4b0-11d6-964b-eb5a2bf216fc";
+
+	public static final nsID NS_IWINDOWCREATOR2_IID =
+		new nsID(NS_IWINDOWCREATOR2_IID_STR);
+
+	public nsIWindowCreator2(int /*long*/ address) {
+		super(address);
+	}
+
+	public static final int PARENT_IS_LOADING_OR_RUNNING_TIMEOUT = 1;
+
+	public int CreateChromeWindow2(int /*long*/ parent, int chromeFlags, int contextFlags, int /*long*/ uri, int[] cancel, int /*long*/[] _retval) {
+		return XPCOM.VtblCall(nsIWindowCreator.LAST_METHOD_ID + 1, getAddress(), parent, chromeFlags, contextFlags, uri, cancel, _retval);
+	}
+}
\ No newline at end of file


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIWindowCreator2.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIWindowWatcher.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIWindowWatcher.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIWindowWatcher.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,87 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code, released March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by Netscape are Copyright (C) 1998-1999
+ * Netscape Communications Corporation.  All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * IBM
+ * -  Binding to permit interfacing between Mozilla and SWT
+ * -  Copyright (C) 2003, 2005 IBM Corp.  All Rights Reserved.
+ *
+ * ***** END LICENSE BLOCK ***** */
+package org.eclipse.swt.internal.mozilla;
+
+public class nsIWindowWatcher extends nsISupports {
+
+	static final int LAST_METHOD_ID = nsISupports.LAST_METHOD_ID + 11;
+
+	public static final String NS_IWINDOWWATCHER_IID_STR =
+		"002286a8-494b-43b3-8ddd-49e3fc50622b";
+
+	public static final nsID NS_IWINDOWWATCHER_IID =
+		new nsID(NS_IWINDOWWATCHER_IID_STR);
+
+	public nsIWindowWatcher(int /*long*/ address) {
+		super(address);
+	}
+
+	public int OpenWindow(int /*long*/ aParent, byte[] aUrl, byte[] aName, byte[] aFeatures, int /*long*/ aArguments, int /*long*/[] _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 1, getAddress(), aParent, aUrl, aName, aFeatures, aArguments, _retval);
+	}
+
+	public int RegisterNotification(int /*long*/ aObserver) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 2, getAddress(), aObserver);
+	}
+
+	public int UnregisterNotification(int /*long*/ aObserver) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 3, getAddress(), aObserver);
+	}
+
+	public int GetWindowEnumerator(int /*long*/[] _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 4, getAddress(), _retval);
+	}
+
+	public int GetNewPrompter(int /*long*/ aParent, int /*long*/[] _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 5, getAddress(), aParent, _retval);
+	}
+
+	public int GetNewAuthPrompter(int /*long*/ aParent, int /*long*/[] _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 6, getAddress(), aParent, _retval);
+	}
+
+	public int SetWindowCreator(int /*long*/ creator) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 7, getAddress(), creator);
+	}
+
+	public int GetChromeForWindow(int /*long*/ aWindow, int /*long*/[] _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 8, getAddress(), aWindow, _retval);
+	}
+
+	public int GetWindowByName(char[] aTargetName, int /*long*/ aCurrentWindow, int /*long*/[] _retval) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 9, getAddress(), aTargetName, aCurrentWindow, _retval);
+	}
+
+	public int GetActiveWindow(int /*long*/[] aActiveWindow) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 10, getAddress(), aActiveWindow);
+	}
+
+	public int SetActiveWindow(int /*long*/ aActiveWindow) {
+		return XPCOM.VtblCall(nsISupports.LAST_METHOD_ID + 11, getAddress(), aActiveWindow);
+	}
+}
\ No newline at end of file


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/mozilla/nsIWindowWatcher.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/opengl/glx/GLX.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/opengl/glx/GLX.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/opengl/glx/GLX.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,395 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.opengl.glx;
+
+import org.eclipse.swt.internal.*;
+
+public class GLX extends Platform {
+	static {
+		Library.loadLibrary("swt-glx");
+	}
+
+	/*
+	** Visual Config Attributes (glXGetConfig, glXGetFBConfigAttrib)
+	*/
+	public static final int GLX_USE_GL				= 1;	/* support GLX rendering */
+	public static final int GLX_BUFFER_SIZE			= 2;	/* depth of the color buffer */
+	public static final int GLX_LEVEL				= 3;	/* level in plane stacking */
+	public static final int GLX_RGBA				= 4;	/* true if RGBA mode */
+	public static final int GLX_DOUBLEBUFFER		= 5;	/* double buffering supported */
+	public static final int GLX_STEREO				= 6;	/* stereo buffering supported */
+	public static final int GLX_AUX_BUFFERS			= 7;	/* number of aux buffers */
+	public static final int GLX_RED_SIZE			= 8;	/* number of red component bits */
+	public static final int GLX_GREEN_SIZE			= 9;	/* number of green component bits */
+	public static final int GLX_BLUE_SIZE			= 10;	/* number of blue component bits */
+	public static final int GLX_ALPHA_SIZE			= 11;	/* number of alpha component bits */
+	public static final int GLX_DEPTH_SIZE			= 12;	/* number of depth bits */
+	public static final int GLX_STENCIL_SIZE		= 13;	/* number of stencil bits */
+	public static final int GLX_ACCUM_RED_SIZE		= 14;	/* number of red accum bits */
+	public static final int GLX_ACCUM_GREEN_SIZE	= 15;	/* number of green accum bits */
+	public static final int GLX_ACCUM_BLUE_SIZE		= 16;	/* number of blue accum bits */
+	public static final int GLX_ACCUM_ALPHA_SIZE	= 17;	/* number of alpha accum bits */
+	/*
+	** FBConfig-specific attributes
+	*/
+	public static final int GLX_X_VISUAL_TYPE		= 0x22;
+	public static final int GLX_CONFIG_CAVEAT		= 0x20;	/* Like visual_info VISUAL_CAVEAT_EXT */
+	public static final int GLX_TRANSPARENT_TYPE	= 0x23;
+	public static final int GLX_TRANSPARENT_INDEX_VALUE	= 0x24;
+	public static final int GLX_TRANSPARENT_RED_VALUE	= 0x25;
+	public static final int GLX_TRANSPARENT_GREEN_VALUE	= 0x26;
+	public static final int GLX_TRANSPARENT_BLUE_VALUE	= 0x27;
+	public static final int GLX_TRANSPARENT_ALPHA_VALUE	= 0x28;
+	public static final int GLX_DRAWABLE_TYPE		= 0x8010;
+	public static final int GLX_RENDER_TYPE			= 0x8011;
+	public static final int GLX_X_RENDERABLE		= 0x8012;
+	public static final int GLX_FBCONFIG_ID			= 0x8013;
+	public static final int GLX_MAX_PBUFFER_WIDTH	= 0x8016;
+	public static final int GLX_MAX_PBUFFER_HEIGHT	= 0x8017;
+	public static final int GLX_MAX_PBUFFER_PIXELS	= 0x8018;
+	public static final int GLX_VISUAL_ID			= 0x800B;
+	
+	/*
+	** Error return values from glXGetConfig.  Success is indicated by
+	** a value of 0.
+	*/
+	public static final int GLX_BAD_SCREEN		= 1;	/* screen # is bad */
+	public static final int GLX_BAD_ATTRIBUTE	= 2;	/* attribute to get is bad */
+	public static final int GLX_NO_EXTENSION	= 3;	/* no glx extension on server */
+	public static final int GLX_BAD_VISUAL		= 4;	/* visual # not known by GLX */
+	public static final int GLX_BAD_CONTEXT		= 5;	/* returned only by import_context EXT? */
+	public static final int GLX_BAD_VALUE		= 6;	/* returned only by glXSwapIntervalSGI? */
+	public static final int GLX_BAD_ENUM		= 7;	/* unused? */
+	
+	/* FBConfig attribute values */
+	
+	/*
+	** Generic "don't care" value for glX ChooseFBConfig attributes (except
+	** GLX_LEVEL)
+	*/
+	public static final int GLX_DONT_CARE			= 0xFFFFFFFF;
+	
+	/* GLX_RENDER_TYPE bits */
+	public static final int GLX_RGBA_BIT			= 0x00000001;
+	public static final int GLX_COLOR_INDEX_BIT		= 0x00000002;
+	
+	/* GLX_DRAWABLE_TYPE bits */
+	public static final int GLX_WINDOW_BIT			= 0x00000001;
+	public static final int GLX_PIXMAP_BIT			= 0x00000002;
+	public static final int GLX_PBUFFER_BIT			= 0x00000004;
+	
+	/* GLX_CONFIG_CAVEAT attribute values */
+	public static final int GLX_NONE				= 0x8000;
+	public static final int GLX_SLOW_CONFIG			= 0x8001;
+	public static final int GLX_NON_CONFORMANT_CONFIG	= 0x800D;
+	
+	/* GLX_X_VISUAL_TYPE attribute values */
+	public static final int GLX_TRUE_COLOR			= 0x8002;
+	public static final int GLX_DIRECT_COLOR		= 0x8003;
+	public static final int GLX_PSEUDO_COLOR		= 0x8004;
+	public static final int GLX_STATIC_COLOR		= 0x8005;
+	public static final int GLX_GRAY_SCALE			= 0x8006;
+	public static final int GLX_STATIC_GRAY			= 0x8007;
+	
+	/* GLX_TRANSPARENT_TYPE attribute values */
+	/* public static final int GLX_NONE			   0x8000 */
+	public static final int GLX_TRANSPARENT_RGB		= 0x8008;
+	public static final int GLX_TRANSPARENT_INDEX	= 0x8009;
+	
+	/* glXCreateGLXPbuffer attributes */
+	public static final int GLX_PRESERVED_CONTENTS	= 0x801B;
+	public static final int GLX_LARGEST_PBUFFER		= 0x801C;
+	public static final int GLX_PBUFFER_HEIGHT		= 0x8040;	/* New for GLX 1.3 */
+	public static final int GLX_PBUFFER_WIDTH		= 0x8041;	/* New for GLX 1.3 */
+	
+	/* glXQueryGLXPBuffer attributes */
+	public static final int GLX_WIDTH		= 0x801D;
+	public static final int GLX_HEIGHT		= 0x801E;
+	public static final int GLX_EVENT_MASK	= 0x801F;
+	
+	/* glXCreateNewContext render_type attribute values */
+	public static final int GLX_RGBA_TYPE			= 0x8014;
+	public static final int GLX_COLOR_INDEX_TYPE	= 0x8015;
+	
+	/* glXQueryContext attributes */
+	/* public static final int GLX_FBCONFIG_ID		  0x8013 */
+	/* public static final int GLX_RENDER_TYPE		  0x8011 */
+	public static final int GLX_SCREEN			= 0x800C;
+	
+	/* glXSelectEvent event mask bits */
+	public static final int GLX_PBUFFER_CLOBBER_MASK	= 0x08000000;
+	
+	/* GLXPbufferClobberEvent event_type values */
+	public static final int GLX_DAMAGED			= 0x8020;
+	public static final int GLX_SAVED			= 0x8021;
+	
+	/* GLXPbufferClobberEvent draw_type values */
+	public static final int GLX_WINDOW			= 0x8022;
+	public static final int GLX_PBUFFER			= 0x8023;
+	
+	/* GLXPbufferClobberEvent buffer_mask bits */
+	public static final int GLX_FRONT_LEFT_BUFFER_BIT	= 0x00000001;
+	public static final int GLX_FRONT_RIGHT_BUFFER_BIT	= 0x00000002;
+	public static final int GLX_BACK_LEFT_BUFFER_BIT	= 0x00000004;
+	public static final int GLX_BACK_RIGHT_BUFFER_BIT	= 0x00000008;
+	public static final int GLX_AUX_BUFFERS_BIT		= 0x00000010;
+	public static final int GLX_DEPTH_BUFFER_BIT		= 0x00000020;
+	public static final int GLX_STENCIL_BUFFER_BIT		= 0x00000040;
+	public static final int GLX_ACCUM_BUFFER_BIT		= 0x00000080;
+	
+	/*
+	** Extension return values from glXGetConfig.  These are also
+	** accepted as parameter values for glXChooseVisual.
+	*/
+	
+	public static final int GLX_X_VISUAL_TYPE_EXT = 0x22;	/* visual_info extension type */
+	public static final int GLX_TRANSPARENT_TYPE_EXT = 0x23;	/* visual_info extension */
+	public static final int GLX_TRANSPARENT_INDEX_VALUE_EXT = 0x24;	/* visual_info extension */
+	public static final int GLX_TRANSPARENT_RED_VALUE_EXT	= 0x25;	/* visual_info extension */
+	public static final int GLX_TRANSPARENT_GREEN_VALUE_EXT = 0x26;	/* visual_info extension */
+	public static final int GLX_TRANSPARENT_BLUE_VALUE_EXT	= 0x27;	/* visual_info extension */
+	public static final int GLX_TRANSPARENT_ALPHA_VALUE_EXT = 0x28;	/* visual_info extension */
+	
+	/* Property values for visual_type */
+	public static final int GLX_TRUE_COLOR_EXT	= 0x8002;
+	public static final int GLX_DIRECT_COLOR_EXT	= 0x8003;
+	public static final int GLX_PSEUDO_COLOR_EXT	= 0x8004;
+	public static final int GLX_STATIC_COLOR_EXT	= 0x8005;
+	public static final int GLX_GRAY_SCALE_EXT	= 0x8006;
+	public static final int GLX_STATIC_GRAY_EXT	= 0x8007;
+	
+	/* Property values for transparent pixel */
+	public static final int GLX_NONE_EXT		= 0x8000;
+	public static final int GLX_TRANSPARENT_RGB_EXT		= 0x8008;
+	public static final int GLX_TRANSPARENT_INDEX_EXT	= 0x8009;
+	
+	/* Property values for visual_rating */
+	public static final int GLX_VISUAL_CAVEAT_EXT		= 0x20;  /* visual_rating extension type */
+	public static final int GLX_SLOW_VISUAL_EXT		= 0x8001;
+	public static final int GLX_NON_CONFORMANT_VISUAL_EXT	= 0x800D;
+	
+	/*
+	** Names for attributes to glXGetClientString.
+	*/
+	public static final int GLX_VENDOR		= 0x1;
+	public static final int GLX_VERSION		= 0x2;
+	public static final int GLX_EXTENSIONS	= 0x3;
+	
+	/*
+	** Names for attributes to glXQueryContextInfoEXT.
+	*/
+	public static final int GLX_SHARE_CONTEXT_EXT = 0x800A;	/* id of share context */
+	public static final int GLX_VISUAL_ID_EXT = 0x800B;	/* id of context's visual */
+	public static final int GLX_SCREEN_EXT = 0x800C;	/* screen number */
+	
+	/*
+	* GLX 1.4 
+	*/
+	public static final int GLX_SAMPLE_BUFFERS = 100000;
+	public static final int GLX_SAMPLES = 100001;
+
+	/*
+	* GL bits 
+	*/
+	public static final int GL_VIEWPORT = 0x0BA2;
+	
+public static final native int XVisualInfo_sizeof();
+public static final native void _glGetIntegerv(int pname, int[] params);
+public static final void glGetIntegerv(int pname, int[] params) {
+	lock.lock();
+	try {
+		_glGetIntegerv(pname, params);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _glViewport(int x, int y, int width, int height);
+public static final void glViewport(int x, int y, int width, int height) {
+	lock.lock();
+	try {
+		_glViewport(x, y, width, height);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _glXChooseVisual(int /*long*/ dpy, int screen, int[] attribList);
+public static final int /*long*/ glXChooseVisual(int /*long*/ dpy, int screen, int[] attribList) {
+	lock.lock();
+	try {
+		return _glXChooseVisual(dpy, screen, attribList);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _glXCopyContext(int /*long*/ dpy, int /*long*/ src, int /*long*/ dst, int mask);
+public static final void glXCopyContext(int /*long*/ dpy, int /*long*/ src, int /*long*/ dst, int mask) {
+	lock.lock();
+	try {
+		_glXCopyContext(dpy, src, dst, mask);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _glXCreateContext(int /*long*/ dpy, XVisualInfo vis, int /*long*/ shareList, boolean direct);
+public static final int /*long*/ glXCreateContext(int /*long*/ dpy, XVisualInfo vis, int /*long*/ shareList, boolean direct) {
+	lock.lock();
+	try {
+		return _glXCreateContext(dpy, vis, shareList, direct);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _glXCreateGLXPixmap(int /*long*/ dpy, XVisualInfo vis, int /*long*/ pixmap);
+public static final int /*long*/ glXCreateGLXPixmap(int /*long*/ dpy, XVisualInfo vis, int /*long*/ pixmap) {
+	lock.lock();
+	try {
+		return _glXCreateGLXPixmap(dpy, vis, pixmap);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _glXDestroyContext(int /*long*/ dpy, int /*long*/ ctx);
+public static final void glXDestroyContext(int /*long*/ dpy, int /*long*/ ctx) {
+	lock.lock();
+	try {
+		_glXDestroyContext(dpy, ctx);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _glXDestroyGLXPixmap(int /*long*/ dpy, int /*long*/ pix);
+public static final void glXDestroyGLXPixmap(int /*long*/ dpy, int /*long*/ pix) {
+	lock.lock();
+	try {
+		_glXDestroyGLXPixmap(dpy, pix);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _glXGetClientString(int /*long*/ dpy, int name);
+public static final int /*long*/ glXGetClientString(int /*long*/ dpy, int name) {
+	lock.lock();
+	try {
+		return _glXGetClientString(dpy, name);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int _glXGetConfig(int /*long*/ dpy, XVisualInfo vis, int attrib, int[] value);
+public static final int glXGetConfig(int /*long*/ dpy, XVisualInfo vis, int attrib, int[] value) {
+	lock.lock();
+	try {
+		return _glXGetConfig(dpy, vis, attrib, value);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _glXGetCurrentContext();
+public static final int /*long*/ glXGetCurrentContext() {
+	lock.lock();
+	try {
+		return _glXGetCurrentContext();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _glXGetCurrentDrawable();
+public static final int /*long*/ glXGetCurrentDrawable() {
+	lock.lock();
+	try {
+		return _glXGetCurrentDrawable();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _glXIsDirect(int /*long*/ dpy, int /*long*/ ctx);
+public static final boolean glXIsDirect(int /*long*/ dpy, int /*long*/ ctx) {
+	lock.lock();
+	try {
+		return _glXIsDirect(dpy, ctx);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _glXMakeCurrent(int /*long*/ dpy, int /*long*/ drawable, int /*long*/ ctx);
+public static final boolean glXMakeCurrent(int /*long*/ dpy, int /*long*/ drawable, int /*long*/ ctx) {
+	lock.lock();
+	try {
+		return _glXMakeCurrent(dpy, drawable, ctx);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _glXQueryExtension(int /*long*/ dpy, int[] errorBase, int[] eventBase);
+public static final boolean glXQueryExtension(int /*long*/ dpy, int[] errorBase, int[] eventBase) {
+	lock.lock();
+	try {
+		return _glXQueryExtension(dpy, errorBase, eventBase);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _glXQueryExtensionsString(int /*long*/ dpy, int screen);
+public static final int /*long*/ glXQueryExtensionsString(int /*long*/ dpy, int screen) {
+	lock.lock();
+	try {
+		return _glXQueryExtensionsString(dpy, screen);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native int /*long*/ _glXQueryServerString(int /*long*/ dpy, int screen, int name);
+public static final int /*long*/ glXQueryServerString(int /*long*/ dpy, int screen, int name) {
+	lock.lock();
+	try {
+		return _glXQueryServerString(dpy, screen, name);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native boolean _glXQueryVersion(int /*long*/ dpy, int[] major, int[] minor);
+public static final boolean glXQueryVersion(int /*long*/ dpy, int[] major, int[] minor) {
+	lock.lock();
+	try {
+		return _glXQueryVersion(dpy, major, minor);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _glXSwapBuffers(int /*long*/ dpy, int /*long*/ drawable);
+public static final void glXSwapBuffers(int /*long*/ dpy, int /*long*/ drawable) {
+	lock.lock();
+	try {
+		_glXSwapBuffers(dpy, drawable);
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _glXWaitGL();
+public static final void glXWaitGL() {
+	lock.lock();
+	try {
+		_glXWaitGL();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void _glXWaitX();
+public static final void glXWaitX() {
+	lock.lock();
+	try {
+		_glXWaitX();
+	} finally {
+		lock.unlock();
+	}
+}
+public static final native void memmove(XVisualInfo dest, int /*long*/ src, int size);
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/opengl/glx/GLX.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/opengl/glx/XVisualInfo.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/opengl/glx/XVisualInfo.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/opengl/glx/XVisualInfo.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.opengl.glx;
+
+public class XVisualInfo {
+	public int /*long*/ visual;
+	public int visualid;
+	public int screen;
+	public int depth;
+	public int cclass;
+	public int red_mask, green_mask, blue_mask;
+	public int colormap_size;
+	public int bits_per_rgb;
+	public static final int sizeof = GLX.XVisualInfo_sizeof();
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/opengl/glx/XVisualInfo.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/theme/ButtonDrawData.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/theme/ButtonDrawData.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/theme/ButtonDrawData.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,220 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.theme;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.gtk.*;
+
+public class ButtonDrawData extends DrawData {
+	
+public ButtonDrawData() {
+	state = new int[1];
+}
+
+
+void draw(Theme theme, GC gc, Rectangle bounds) {
+	int state = this.state[DrawData.WIDGET_WHOLE];
+
+	int /*long*/ drawable = gc.getGCData().drawable;
+	if ((style & SWT.RADIO) != 0) {
+		int /*long*/ radioButtonHandle = theme.radioButtonHandle;
+		int /*long*/ gtkStyle = OS.gtk_widget_get_style (radioButtonHandle);
+		theme.transferClipping (gc, gtkStyle);
+		int indicator_size = theme.getWidgetProperty(radioButtonHandle, "indicator-size");
+		int indicator_spacing = theme.getWidgetProperty(radioButtonHandle, "indicator-spacing");
+		int interior_focus = theme.getWidgetProperty(radioButtonHandle, "interior-focus");
+		int focus_line_width = theme.getWidgetProperty(radioButtonHandle, "focus-line-width");
+		int focus_padding = theme.getWidgetProperty(radioButtonHandle, "focus-padding");
+		int border_width = OS.gtk_container_get_border_width(radioButtonHandle);
+		
+		int x = bounds.x + indicator_spacing + border_width;
+		int y = bounds.y + (bounds.height - indicator_size) / 2;
+		
+		if (interior_focus == 0) {
+			x += focus_line_width + focus_padding;
+		}
+		
+		int shadow_type;
+		if ((state & DrawData.GRAYED) != 0) {
+			shadow_type = OS.GTK_SHADOW_ETCHED_IN;
+		} else if ((state & DrawData.SELECTED) != 0) {
+			shadow_type = OS.GTK_SHADOW_IN;
+		} else {
+			shadow_type = OS.GTK_SHADOW_OUT;
+		}
+		
+		byte[] detail = Converter.wcsToMbcs(null, "radiobutton", true);
+		if ((state & DrawData.HOT) != 0) {
+			int prelight_x, prelight_y, prelight_width, prelight_height;
+			prelight_x = bounds.x + border_width;
+			prelight_y = bounds.y + border_width;
+			prelight_width = bounds.width - (2 * border_width);
+			prelight_height = bounds.height - (2 * border_width);
+			OS.gtk_paint_flat_box(gtkStyle, drawable, OS.GTK_STATE_PRELIGHT, OS.GTK_SHADOW_ETCHED_OUT, null, radioButtonHandle, detail, prelight_x, prelight_y, prelight_width, prelight_height);
+		}
+		int state_type = getStateType(DrawData.WIDGET_WHOLE);
+		OS.gtk_paint_option(gtkStyle, drawable, state_type, shadow_type, null, radioButtonHandle, detail, x, y, indicator_size, indicator_size);
+		if (clientArea != null) {
+			clientArea.x = bounds.x + 2 * indicator_spacing + border_width + indicator_size;
+			clientArea.y = bounds.y + border_width;
+			clientArea.width = bounds.width - (2 * indicator_spacing + 2 * border_width + indicator_size);
+			clientArea.height = bounds.height - 2 * border_width;
+		}
+		return;
+	}
+	
+	if ((style & SWT.CHECK) != 0) {
+		int /*long*/ checkButtonHandle = theme.checkButtonHandle;
+		int /*long*/ gtkStyle = OS.gtk_widget_get_style (checkButtonHandle);
+		theme.transferClipping (gc, gtkStyle);
+		int indicator_size = theme.getWidgetProperty(checkButtonHandle, "indicator-size");
+		int indicator_spacing = theme.getWidgetProperty(checkButtonHandle, "indicator-spacing");
+		int interior_focus = theme.getWidgetProperty(checkButtonHandle, "interior-focus");
+		int focus_line_width = theme.getWidgetProperty(checkButtonHandle, "focus-line-width");
+		int focus_padding = theme.getWidgetProperty(checkButtonHandle, "focus-padding");
+		int border_width = OS.gtk_container_get_border_width(checkButtonHandle);
+		
+		int x = bounds.x + indicator_spacing + border_width;
+		int y = bounds.y + (bounds.height - indicator_size) / 2;
+		
+		if (interior_focus == 0) {
+			x += focus_line_width + focus_padding;
+		}
+		
+		int shadow_type;
+		if ((state & DrawData.GRAYED) != 0) {
+			shadow_type = OS.GTK_SHADOW_ETCHED_IN;
+		} else if ((state & DrawData.SELECTED) != 0) {
+			shadow_type = OS.GTK_SHADOW_IN;
+		} else {
+			shadow_type = OS.GTK_SHADOW_OUT;
+		}
+		
+		byte[] detail = Converter.wcsToMbcs(null, "checkbutton", true);
+		if ((state & DrawData.HOT) != 0) {
+			int prelight_x, prelight_y, prelight_width, prelight_height;
+			prelight_x = bounds.x + border_width;
+			prelight_y = bounds.y + border_width;
+			prelight_width = bounds.width - (2 * border_width);
+			prelight_height = bounds.height - (2 * border_width);
+			OS.gtk_paint_flat_box(gtkStyle, drawable, OS.GTK_STATE_PRELIGHT, OS.GTK_SHADOW_ETCHED_OUT, null, checkButtonHandle, detail, prelight_x, prelight_y, prelight_width, prelight_height);
+		}
+		int state_type = getStateType(DrawData.WIDGET_WHOLE);
+		OS.gtk_paint_check(gtkStyle, drawable, state_type, shadow_type, null, checkButtonHandle, detail, x, y, indicator_size, indicator_size);
+		if (clientArea != null) {
+			clientArea.x = bounds.x + 2 * indicator_spacing + border_width + indicator_size;
+			clientArea.y = bounds.y + border_width;
+			clientArea.width = bounds.width - (2 * indicator_spacing + 2 * border_width + indicator_size);
+			clientArea.height = bounds.height - 2 * border_width;
+		}
+		return;
+	}
+	
+
+	if ((style & SWT.PUSH) != 0) {
+		int /*long*/ buttonHandle = theme.buttonHandle;
+		int /*long*/ gtkStyle = OS.gtk_widget_get_style (buttonHandle);
+		theme.transferClipping (gc, gtkStyle);		
+		int focus_line_width = theme.getWidgetProperty(buttonHandle, "focus-line-width");
+		int focus_padding = theme.getWidgetProperty(buttonHandle, "focus-padding");
+		int border_width = OS.gtk_container_get_border_width(buttonHandle);
+		
+		GtkBorder default_border = new GtkBorder();
+		int default_border_ptr = theme.getWidgetProperty(buttonHandle, "default-border");
+		if (default_border_ptr != 0) {
+			OS.memmove(default_border, default_border_ptr, GdkRectangle.sizeof);
+		} else {
+			default_border.left = default_border.right = default_border.top = default_border.bottom = 1;
+		}
+
+		GtkBorder default_outside_border = new GtkBorder();
+		int default_outside_border_ptr = theme.getWidgetProperty(buttonHandle, "default-outside-border");
+		if (default_outside_border_ptr != 0) {
+			OS.memmove(default_outside_border, default_outside_border_ptr, GdkRectangle.sizeof);
+		} else {
+			default_outside_border.left = default_outside_border.right = default_outside_border.top = default_outside_border.bottom = 0;
+		}
+		
+		int x = bounds.x + border_width;
+		int y = bounds.y + border_width;
+		int width = bounds.width - border_width * 2;
+		int height = bounds.height - border_width * 2;
+
+		int relief = OS.gtk_button_get_relief(buttonHandle);
+		byte[] detail = Converter.wcsToMbcs(null, (state & DrawData.DEFAULTED) != 0 ? "buttondefault" : "button", true);
+		if ((state & DrawData.DEFAULTED) != 0 && relief == OS.GTK_RELIEF_NORMAL) {
+            OS.gtk_paint_box(gtkStyle, drawable, OS.GTK_STATE_NORMAL, OS.GTK_SHADOW_IN, null, buttonHandle, detail, x, y, width, height);
+            x += default_border.left;
+            y += default_border.top;
+            width -= default_border.left + default_border.right;
+            height -= default_border.top + default_border.bottom;
+		} else if ((state & DrawData.DEFAULTED) != 0) {
+			x += default_outside_border.left;
+			y += default_outside_border.top;
+			width -= default_outside_border.left + default_outside_border.right;
+			height -= default_outside_border.top + default_outside_border.bottom;
+        }
+
+		int shadow_type = OS.GTK_SHADOW_OUT;
+		if ((state & (DrawData.SELECTED | DrawData.PRESSED)) != 0) shadow_type = OS.GTK_SHADOW_IN;
+		int state_type = getStateType(DrawData.WIDGET_WHOLE);
+
+		if (relief != OS.GTK_RELIEF_NONE || ((state & (DrawData.PRESSED | DrawData.HOT)) != 0)) {
+			OS.gtk_paint_box(gtkStyle, drawable, state_type, shadow_type, null, buttonHandle, detail, x, y, width, height);
+		}
+		
+	    if ((state & DrawData.FOCUSED) != 0) {
+	    	int child_displacement_y = theme.getWidgetProperty(buttonHandle, "child-displacement-y");
+	    	int child_displacement_x = theme.getWidgetProperty(buttonHandle, "child-displacement-x");
+	    	int displace_focus = 0;
+	    	if (OS.GTK_VERSION >= OS.VERSION (2, 6, 0)) {
+	    		displace_focus = theme.getWidgetProperty(buttonHandle, "displace-focus");		    	
+	    	}
+	    	int interior_focus = theme.getWidgetProperty(buttonHandle, "interior-focus");
+	    	
+	    	if (interior_focus != 0) {
+	    		int xthickness = OS.gtk_style_get_xthickness(gtkStyle);
+	    		int ythickness = OS.gtk_style_get_ythickness(gtkStyle);
+	    		x += xthickness + focus_padding;
+	            y += ythickness + focus_padding;
+	            width -= 2 * (xthickness + focus_padding);
+	            height -=  2 * (ythickness + focus_padding);
+	    	} else {
+	    		x -= focus_line_width + focus_padding;
+	    		y -= focus_line_width + focus_padding;
+	    		width += 2 * (focus_line_width + focus_padding);
+	    		height += 2 * (focus_line_width + focus_padding);
+	    	}
+	    	
+	    	if ((state & DrawData.PRESSED) != 0 && displace_focus != 0) {
+	              x += child_displacement_x;
+	              y += child_displacement_y;
+	    	}
+	    	
+	        OS.gtk_paint_focus(gtkStyle, drawable, state_type, null, buttonHandle, detail, x, y, width, height);
+	    }
+		if (clientArea != null) {
+			clientArea.x = bounds.x + border_width;
+			clientArea.y = bounds.y + border_width;
+			clientArea.width = bounds.width - 2 * border_width;
+			clientArea.height = bounds.height - 2 * border_width;
+		}
+	    return;
+	}
+}
+
+int hit(Theme theme, Point position, Rectangle bounds) {
+	return bounds.contains(position) ? DrawData.WIDGET_WHOLE : DrawData.WIDGET_NOWHERE;
+}
+
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/theme/ButtonDrawData.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/theme/ComboDrawData.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/theme/ComboDrawData.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/theme/ComboDrawData.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,124 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.theme;
+
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.gtk.*;
+
+public class ComboDrawData extends DrawData {
+
+	static final int ARROW_HEIGHT = 6;
+	static final int MIN_ARROW_SIZE = 15;
+
+public ComboDrawData() {
+	state = new int[2];
+}
+
+void draw(Theme theme, GC gc, Rectangle bounds) {
+	int /*long*/ buttonHandle = theme.buttonHandle;
+	int /*long*/ gtkStyle = OS.gtk_widget_get_style(buttonHandle);
+	int /*long*/ drawable = gc.getGCData().drawable;
+	theme.transferClipping(gc, gtkStyle);
+	
+	int x = bounds.x;
+	int y = bounds.y ;
+	int width = bounds.width;
+	int height = bounds.height;
+
+	int shadow_type = OS.GTK_SHADOW_OUT;
+	if ((state[DrawData.COMBO_ARROW] & DrawData.PRESSED) != 0) shadow_type = OS.GTK_SHADOW_IN;
+	int state_type = getStateType(DrawData.COMBO_ARROW);
+	
+	int relief = OS.gtk_button_get_relief(buttonHandle);
+	int interior_focus = theme.getWidgetProperty(buttonHandle, "interior-focus");
+	int focus_line_width = theme.getWidgetProperty(buttonHandle, "focus-line-width");
+	int focus_padding = theme.getWidgetProperty(buttonHandle, "focus-padding");
+	int xthickness = OS.gtk_style_get_xthickness(gtkStyle);
+	int ythickness = OS.gtk_style_get_xthickness(gtkStyle);
+	int arrow_width = MIN_ARROW_SIZE;
+	int arrow_height = ARROW_HEIGHT;
+	int x_border = xthickness + focus_padding;
+	int y_border = ythickness + focus_padding;
+	if (interior_focus == 0) {
+		x_border += focus_line_width;
+		y_border += focus_line_width;
+	}
+	int arrow_button_width = arrow_width + x_border * 2;		
+	int arrow_button_x = x + width - arrow_button_width;
+	int arrow_x = arrow_button_x + (arrow_button_width - arrow_width) / 2;
+	int arrow_y = y + (height - arrow_height) / 2 + 1;
+	if (relief != OS.GTK_RELIEF_NONE || ((state[DrawData.COMBO_ARROW] & (DrawData.PRESSED | DrawData.HOT)) != 0)) {
+		byte[] detail = Converter.wcsToMbcs(null, "button", true);
+		OS.gtk_paint_box(gtkStyle, drawable, state_type, shadow_type, null, buttonHandle, detail, arrow_button_x, y, arrow_button_width, height);
+	}		
+	byte[] arrow_detail = Converter.wcsToMbcs(null, "arrow", true);
+	int /*long*/ arrowHandle = theme.arrowHandle;
+	OS.gtk_paint_arrow(gtkStyle, drawable, state_type, OS.GTK_SHADOW_OUT, null, arrowHandle, arrow_detail, OS.GTK_ARROW_DOWN, true, arrow_x, arrow_y, arrow_width, arrow_height);
+	
+	int /*long*/ entryHandle = theme.entryHandle;
+	gtkStyle = OS.gtk_widget_get_style(entryHandle);
+	theme.transferClipping(gc, gtkStyle);
+	state_type = getStateType(DrawData.WIDGET_WHOLE);
+	byte[] detail = Converter.wcsToMbcs(null, "entry", true);
+	OS.gtk_paint_shadow(gtkStyle, drawable, OS.GTK_STATE_NORMAL, OS.GTK_SHADOW_IN, null, entryHandle, detail, x, y, width - arrow_button_width, height);
+	xthickness = OS.gtk_style_get_xthickness(gtkStyle);
+	ythickness = OS.gtk_style_get_xthickness(gtkStyle);
+	x += xthickness;
+	y += ythickness;
+	width -= 2 * xthickness;
+	height -= 2 * ythickness;
+	detail = Converter.wcsToMbcs(null, "entry_bg", true);
+	OS.gtk_paint_flat_box(gtkStyle, drawable, state_type, OS.GTK_SHADOW_NONE, null, entryHandle, detail, x, y, width - arrow_button_width, height);
+		
+	if (clientArea != null) {
+		clientArea.x = x;
+		clientArea.y = y;
+		clientArea.width = width - arrow_button_width;
+		clientArea.height = height;
+	}	
+}
+
+int getStateType(int part) {
+	if (part == DrawData.WIDGET_WHOLE) {
+		int state_type = OS.GTK_STATE_NORMAL;
+		if ((state[DrawData.WIDGET_WHOLE] & DrawData.DISABLED) != 0) {
+			state_type = OS.GTK_STATE_INSENSITIVE;
+		}
+		return state_type;
+	}
+	return super.getStateType(part);
+}
+
+int hit(Theme theme, Point position, Rectangle bounds) {
+	if (!bounds.contains(position)) return DrawData.WIDGET_NOWHERE;
+	int /*long*/ buttonHandle = theme.buttonHandle;
+	int /*long*/ gtkStyle = OS.gtk_widget_get_style(buttonHandle);
+	int interior_focus = theme.getWidgetProperty(buttonHandle, "interior-focus");
+	int focus_line_width = theme.getWidgetProperty(buttonHandle, "focus-line-width");
+	int focus_padding = theme.getWidgetProperty(buttonHandle, "focus-padding");
+	int xthickness = OS.gtk_style_get_xthickness(gtkStyle);
+	int ythickness = OS.gtk_style_get_xthickness(gtkStyle);
+	int arrow_width = MIN_ARROW_SIZE;
+	int x_border = xthickness + focus_padding;
+	int y_border = ythickness + focus_padding;
+	if (interior_focus == 0) {
+		x_border += focus_line_width;
+		y_border += focus_line_width;
+	}
+	int arrow_button_width = arrow_width + x_border * 2;		
+	int arrow_button_x = bounds.x + bounds.width - arrow_button_width;
+	Rectangle arrowRect = new Rectangle(arrow_button_x, bounds.y, arrow_button_width, bounds.height);
+	if (arrowRect.contains(position)) return DrawData.COMBO_ARROW;
+	return DrawData.WIDGET_WHOLE;
+}
+
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/theme/ComboDrawData.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/theme/DrawData.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/theme/DrawData.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/theme/DrawData.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,191 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.theme;
+
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.gtk.*;
+
+public class DrawData {
+	public int style;
+	public int[] state;
+	public Rectangle clientArea;
+
+	/** Part states */
+	public static final int SELECTED = 1 << 1;
+	public static final int FOCUSED = 1 << 2;
+	public static final int PRESSED = 1 << 3;
+	public static final int ACTIVE = 1 << 4;
+	public static final int DISABLED = 1 << 5;
+	public static final int HOT = 1 << 6;
+	public static final int DEFAULTED = 1 << 7;
+	public static final int GRAYED = 1 << 8;
+	
+	/** Text and Image drawing flags */
+	public static final int DRAW_LEFT = 1 << 4;
+	public static final int DRAW_TOP = 1 << 5;
+	public static final int DRAW_RIGHT = 1 << 6;
+	public static final int DRAW_BOTTOM = 1 << 7;
+	public static final int DRAW_HCENTER = 1 << 8;
+	public static final int DRAW_VCENTER = 1 << 9;
+
+	/** Widget parts */
+	public static final int WIDGET_NOWHERE = -1;
+	public static final int WIDGET_WHOLE = 0;
+
+	/** Scrollbar parts */
+	public static final int SCROLLBAR_UP_ARROW = 1;
+	public static final int SCROLLBAR_DOWN_ARROW = 2;
+	public static final int SCROLLBAR_LEFT_ARROW = SCROLLBAR_UP_ARROW;
+	public static final int SCROLLBAR_RIGHT_ARROW = SCROLLBAR_DOWN_ARROW;
+	public static final int SCROLLBAR_UP_TRACK = 3;
+	public static final int SCROLLBAR_DOWN_TRACK = 4;
+	public static final int SCROLLBAR_LEFT_TRACK = SCROLLBAR_UP_TRACK;
+	public static final int SCROLLBAR_RIGHT_TRACK = SCROLLBAR_DOWN_TRACK;
+	public static final int SCROLLBAR_THUMB = 5;
+	
+	/** Scale parts */
+	public static final int SCALE_UP_TRACK = 1;
+	public static final int SCALE_LEFT_TRACK = SCALE_UP_TRACK;
+	public static final int SCALE_DOWN_TRACK = 2;
+	public static final int SCALE_RIGHT_TRACK = SCALE_DOWN_TRACK;
+	public static final int SCALE_THUMB = 3;
+	
+	/** ToolItem parts */
+	public static final int TOOLITEM_ARROW = 1;
+	
+	/** Combo parts */
+	public static final int COMBO_ARROW = 1;
+	
+
+public DrawData() {
+	state = new int[1];
+}
+
+Rectangle computeTrim(Theme theme, GC gc) {
+	return new Rectangle(clientArea.x, clientArea.y, clientArea.width, clientArea.height);
+}
+
+void draw(Theme theme, GC gc, Rectangle bounds) {
+	
+}
+
+void drawImage(Theme theme, Image image, GC gc, Rectangle bounds) {
+	int /*long*/ drawable = gc.getGCData().drawable;
+	Rectangle rect = image.getBounds();
+	int state_type = getStateType(DrawData.WIDGET_WHOLE);
+	if (state_type == OS.GTK_STATE_NORMAL) {
+		gc.drawImage(image, 0, 0, rect.width, rect.height, bounds.x, bounds.y, bounds.width, bounds.height);
+	} else {
+		int /*long*/ pixbuf = Theme.createPixbuf(image);
+		int /*long*/ source = OS.gtk_icon_source_new();
+		if (source != 0) {
+			OS.gtk_icon_source_set_pixbuf(source, pixbuf);
+			//TODO - always uses buttonHandle
+			int /*long*/ buttonHandle = theme.buttonHandle;
+			int /*long*/ gtkStyle = OS.gtk_widget_get_style (buttonHandle);
+			theme.transferClipping(gc, gtkStyle);
+			int /*long*/ rendered = OS.gtk_style_render_icon(gtkStyle, source, OS.GTK_TEXT_DIR_NONE, state_type, -1, buttonHandle, null);
+			OS.g_object_unref(pixbuf);
+			//TODO - stretching
+			if (rendered != 0) {
+				OS.gdk_draw_pixbuf(drawable, gc.handle, rendered, 0, 0, bounds.x, bounds.y, bounds.width, bounds.height, OS.GDK_RGB_DITHER_NORMAL, 0, 0);
+				OS.g_object_unref(rendered);
+			}
+			OS.gtk_icon_source_free(source);
+		}
+	}
+}
+
+void drawText(Theme theme, String text, int flags, GC gc, Rectangle bounds) {
+	int /*long*/ widget = getTextHandle(theme);
+	int /*long*/ gtkStyle = OS.gtk_widget_get_style(widget);
+	int /*long*/ drawable = gc.getGCData().drawable;
+	theme.transferClipping (gc, gtkStyle);
+	byte[] buffer = Converter.wcsToMbcs(null, text, true);
+	int /*long*/ layout = OS.gtk_widget_create_pango_layout(widget, buffer);
+	int[] width = new int[1], height = new int[1];
+	OS.pango_layout_get_size(layout, width, height);
+	OS.pango_layout_set_width(layout, bounds.width * OS.PANGO_SCALE);
+	int x = bounds.x;
+	int y = bounds.y;
+	if ((flags & DrawData.DRAW_LEFT) != 0) {
+		OS.pango_layout_set_alignment(layout, OS.PANGO_ALIGN_LEFT);
+	}
+	if ((flags & DrawData.DRAW_HCENTER) != 0) {
+		OS.pango_layout_set_alignment(layout, OS.PANGO_ALIGN_CENTER);
+	}
+	if ((flags & DrawData.DRAW_RIGHT) != 0) {
+		OS.pango_layout_set_alignment(layout, OS.PANGO_ALIGN_RIGHT);
+	}
+	if ((flags & DrawData.DRAW_VCENTER) != 0) {
+		y += (bounds.height - OS.PANGO_PIXELS(height[0])) / 2;
+	}
+	if ((flags & DrawData.DRAW_BOTTOM) != 0) {
+		y += bounds.height - OS.PANGO_PIXELS(height[0]);
+	}
+	int state_type = getStateType(DrawData.WIDGET_WHOLE);
+	byte[] detail = Converter.wcsToMbcs(null, "label", true);
+	OS.gtk_paint_layout(gtkStyle, drawable, state_type, false, null, widget, detail, x, y, layout);
+	OS.g_object_unref(layout);
+}
+
+Rectangle getBounds(int part, Rectangle bounds) {
+	return new Rectangle(bounds.x, bounds.y, bounds.width, bounds.height);
+}
+
+int getStateType(int part) {
+	int state = this.state[part];
+	int state_type = OS.GTK_STATE_NORMAL;
+	if ((state & DrawData.DISABLED) != 0) {
+		state_type = OS.GTK_STATE_INSENSITIVE;
+	} else {
+		if ((state & DrawData.SELECTED) != 0) state_type = OS.GTK_STATE_ACTIVE;
+		if ((state & DrawData.HOT) != 0) {
+			if ((state & DrawData.PRESSED) != 0) { 
+				state_type = OS.GTK_STATE_ACTIVE;
+			} else {
+				state_type = OS.GTK_STATE_PRELIGHT;
+			}
+		}
+	}
+	return state_type;
+}
+
+int /*long*/ getTextHandle(Theme theme) {
+	return theme.labelHandle;
+}
+
+int hit(Theme theme, Point position, Rectangle bounds) {
+	return -1;
+}
+
+Rectangle measureText(Theme theme, String text, int flags, GC gc, Rectangle bounds) {
+	int /*long*/ widget = getTextHandle(theme);
+	byte[] buffer = Converter.wcsToMbcs(null, text, true);
+	int /*long*/ layout = OS.gtk_widget_create_pango_layout(widget, buffer);
+	if (bounds != null) OS.pango_layout_set_width(layout, bounds.width);
+	if ((flags & DrawData.DRAW_LEFT) != 0) {
+		OS.pango_layout_set_alignment(layout, OS.PANGO_ALIGN_LEFT);
+	}
+	if ((flags & DrawData.DRAW_HCENTER) != 0) {
+		OS.pango_layout_set_alignment(layout, OS.PANGO_ALIGN_CENTER);
+	}
+	if ((flags & DrawData.DRAW_RIGHT) != 0) {
+		OS.pango_layout_set_alignment(layout, OS.PANGO_ALIGN_RIGHT);
+	}
+	int[] width = new int[1], height = new int[1];
+	OS.pango_layout_get_size(layout, width, height);
+	OS.g_object_unref(layout);
+	return new Rectangle(0, 0, OS.PANGO_PIXELS(width[0]), OS.PANGO_PIXELS(height[0]));
+}
+
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/theme/DrawData.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/theme/ExpanderDrawData.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/theme/ExpanderDrawData.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/theme/ExpanderDrawData.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.theme;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.gtk.*;
+
+public class ExpanderDrawData extends DrawData {
+	
+public ExpanderDrawData() {
+	state = new int[1];
+}
+
+void draw(Theme theme, GC gc, Rectangle bounds) {
+	int /*long*/ treeHandle = theme.treeHandle;
+	int /*long*/ gtkStyle = OS.gtk_widget_get_style (treeHandle);
+	int /*long*/ drawable = gc.getGCData().drawable;
+	theme.transferClipping(gc, gtkStyle);
+	int state_type = getStateType(DrawData.WIDGET_WHOLE);
+	int expander_style = OS.GTK_EXPANDER_COLAPSED;
+	if ((this.style & SWT.DOWN) != 0) expander_style = OS.GTK_EXPANDER_EXPANDED;
+	byte[] detail = Converter.wcsToMbcs(null, "treeview", true);
+	int expander_size = theme.getWidgetProperty(treeHandle, "expander-size");
+	int x = bounds.x + expander_size / 2;
+	int y = bounds.y + expander_size / 2;
+	OS.gtk_paint_expander(gtkStyle, drawable, state_type, null, treeHandle, detail, x, y, expander_style);
+}
+
+int hit(Theme theme, Point position, Rectangle bounds) {
+	if (!bounds.contains(position)) return DrawData.WIDGET_NOWHERE;
+	int /*long*/ treeHandle = theme.treeHandle;
+	int expander_size = theme.getWidgetProperty(treeHandle, "expander-size");
+	if (new Rectangle(bounds.x, bounds.y, expander_size, expander_size).contains(position)) {
+		return DrawData.WIDGET_WHOLE;
+	}
+	return DrawData.WIDGET_NOWHERE;
+}
+
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/theme/ExpanderDrawData.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/theme/GroupDrawData.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/theme/GroupDrawData.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/theme/GroupDrawData.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.theme;
+
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.gtk.*;
+
+public class GroupDrawData extends DrawData {
+	public int headerWidth;
+	public int headerHeight;
+	public Rectangle headerArea;
+	
+	static final int GROUP_X = 2;
+	static final int GROUP_PAD = 1;
+	
+public GroupDrawData() {
+	state = new int[1];
+}
+
+static final int GROUP_HEADER_X = 9;
+static final int GROUP_HEADER_PAD = 2;
+void draw(Theme theme, GC gc, Rectangle bounds) {
+	int /*long*/ frameHandle = theme.frameHandle;
+	int /*long*/ gtkStyle = OS.gtk_widget_get_style (frameHandle);
+	int /*long*/ drawable = gc.getGCData().drawable;
+	theme.transferClipping(gc, gtkStyle);
+	int xthickness = OS.gtk_style_get_xthickness(gtkStyle);
+	int ythickness = OS.gtk_style_get_ythickness(gtkStyle);
+	int x = bounds.x, y = bounds.y + headerHeight / 2, width = bounds.width, height = bounds.height - headerHeight / 2;
+	byte[] detail = Converter.wcsToMbcs(null, "frame", true);
+	int gap_x = xthickness + GROUP_X, gap_width = headerWidth + GROUP_PAD * 2, gap_side = OS.GTK_POS_TOP;
+	int state_type = getStateType(DrawData.WIDGET_WHOLE);
+	OS.gtk_paint_shadow_gap(gtkStyle, drawable, state_type, OS.GTK_SHADOW_ETCHED_IN, null, frameHandle, detail, x, y, width, height, gap_side, gap_x, gap_width);
+	if (headerArea != null) {
+		headerArea.x = bounds.x + gap_x + GROUP_PAD;
+		headerArea.y = bounds.y;
+		headerArea.width = headerWidth;
+		headerArea.height = headerHeight;
+	}
+	if (clientArea != null) {
+		clientArea.x = bounds.x + xthickness;
+		clientArea.y = bounds.y + ythickness + headerHeight;
+		clientArea.width = bounds.width - 2 * xthickness;
+		clientArea.height = bounds.height - 2 * ythickness - headerHeight;
+	}
+}
+
+int getStateType(int part) {
+	int state = this.state[part];
+	int state_type = OS.GTK_STATE_NORMAL;
+	if ((state & DrawData.DISABLED) != 0) state_type = OS.GTK_STATE_INSENSITIVE;
+	return state_type;
+}
+
+int hit(Theme theme, Point position, Rectangle bounds) {
+   	return bounds.contains(position) ? DrawData.WIDGET_WHOLE : DrawData.WIDGET_NOWHERE;
+}
+
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/theme/GroupDrawData.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/theme/ProgressBarDrawData.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/theme/ProgressBarDrawData.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/theme/ProgressBarDrawData.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.theme;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.gtk.*;
+
+public class ProgressBarDrawData extends RangeDrawData {
+
+public ProgressBarDrawData() {
+	state = new int[1];
+}
+
+void draw(Theme theme, GC gc, Rectangle bounds) {
+	int /*long*/ progressHandle = theme.progressHandle;
+	int /*long*/ gtkStyle = OS.gtk_widget_get_style (progressHandle);
+	int /*long*/ drawable = gc.getGCData().drawable;
+	theme.transferClipping(gc, gtkStyle);
+	byte[] detail = Converter.wcsToMbcs(null, "trough", true);
+	int x = bounds.x, y = bounds.y, width = bounds.width, height = bounds.height;
+	OS.gtk_paint_box(gtkStyle, drawable, getStateType(DrawData.WIDGET_WHOLE), OS.GTK_SHADOW_IN, null, progressHandle, detail, x, y, width, height);
+	int xthichness = OS.gtk_style_get_xthickness(gtkStyle);
+	int ythichness = OS.gtk_style_get_ythickness(gtkStyle);
+	if ((style & SWT.VERTICAL) != 0) {
+		OS.gtk_progress_bar_set_orientation(progressHandle, OS.GTK_PROGRESS_BOTTOM_TO_TOP);
+		x += xthichness;
+		width -= xthichness * 2;
+		height -= ythichness * 2;
+		height *= selection / (float)Math.max(1, (maximum - minimum));
+		y += bounds.height - ythichness - height;
+	} else {
+		OS.gtk_progress_bar_set_orientation(progressHandle, OS.GTK_PROGRESS_LEFT_TO_RIGHT);
+		x += xthichness;
+		y += ythichness;
+		width -= xthichness * 2;
+		height -= ythichness * 2;
+		width *= selection / (float)Math.max(1, maximum - minimum);
+	}
+	detail = Converter.wcsToMbcs(null, "bar", true);
+	OS.gtk_paint_box(gtkStyle, drawable, OS.GTK_STATE_PRELIGHT, OS.GTK_SHADOW_OUT, null, progressHandle, detail, x, y, width, height);
+}
+
+int getStateType(int part) {
+	return OS.GTK_STATE_NORMAL;
+}
+
+int hit(Theme theme, Point position, Rectangle bounds) {
+	return bounds.contains(position) ? DrawData.WIDGET_WHOLE : DrawData.WIDGET_NOWHERE;
+}
+
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/theme/ProgressBarDrawData.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/theme/RangeDrawData.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/theme/RangeDrawData.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/theme/RangeDrawData.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.theme;
+
+import org.eclipse.swt.graphics.*;
+
+public class RangeDrawData extends DrawData {
+	public int selection;
+	public int minimum;
+	public int maximum;
+
+int getSelection(Point position, Rectangle bounds) {
+	return 0;
+}
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/theme/RangeDrawData.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/theme/ScaleDrawData.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/theme/ScaleDrawData.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/theme/ScaleDrawData.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.theme;
+
+import org.eclipse.swt.graphics.*;
+
+public class ScaleDrawData extends RangeDrawData {
+	public int increment;
+	public int pageIncrement;
+	
+public ScaleDrawData() {
+	state = new int[4];
+}
+
+void draw(Theme theme, GC gc, Rectangle bounds) {
+	
+}
+
+int hit(Theme theme, Point position, Rectangle bounds) {
+	return bounds.contains(position) ? DrawData.WIDGET_WHOLE : DrawData.WIDGET_NOWHERE;
+}
+
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/theme/ScaleDrawData.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/theme/ScrollBarDrawData.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/theme/ScrollBarDrawData.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/theme/ScrollBarDrawData.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.theme;
+
+import org.eclipse.swt.graphics.*;
+
+public class ScrollBarDrawData extends RangeDrawData {
+	public int thumb;
+	public int increment;
+	public int pageIncrement;
+	
+public ScrollBarDrawData() {
+	state = new int[6];
+}
+
+void draw(Theme theme, GC gc, Rectangle bounds) {
+}
+
+int hit(Theme theme, Point position, Rectangle bounds) {
+	return bounds.contains(position) ? DrawData.WIDGET_WHOLE : DrawData.WIDGET_NOWHERE;
+}
+
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/theme/ScrollBarDrawData.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/theme/TabFolderDrawData.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/theme/TabFolderDrawData.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/theme/TabFolderDrawData.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.theme;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.gtk.*;
+
+public class TabFolderDrawData extends DrawData {
+	public int tabsWidth;
+	public int tabsHeight;
+	public Rectangle tabsArea;
+	public int selectedX;
+	public int selectedWidth;
+	public int spacing;
+	
+public TabFolderDrawData() {
+	state = new int[1];
+	if (SWT.getPlatform().equals("gtk")) {
+		spacing = -2;
+	}
+}
+
+void draw(Theme theme, GC gc, Rectangle bounds) {
+	int /*long*/ notebookHandle = theme.notebookHandle;
+	int /*long*/ gtkStyle = OS.gtk_widget_get_style (notebookHandle);
+	int /*long*/ drawable = gc.getGCData().drawable;
+	theme.transferClipping(gc, gtkStyle);
+	int x = bounds.x, y = bounds.y, width = bounds.width, height = bounds.height;
+	height -= tabsHeight;
+	int gap_x = selectedX, gap_width = selectedWidth, gap_side = OS.GTK_POS_TOP;
+	if ((style & SWT.BOTTOM) != 0) {
+		gap_side = OS.GTK_POS_BOTTOM;
+	} else {
+		y += tabsHeight;
+	}
+	byte[] detail = Converter.wcsToMbcs(null, "notebook", true);
+	OS.gtk_paint_box_gap(gtkStyle, drawable, getStateType(DrawData.WIDGET_WHOLE), OS.GTK_SHADOW_OUT, null, notebookHandle, detail, x, y, width, height, gap_side, gap_x, gap_width);
+	if (tabsArea != null) {
+		tabsArea.x = bounds.x;
+		tabsArea.y = bounds.y;
+		tabsArea.width = bounds.width;
+		tabsArea.height = tabsHeight;
+		if ((style & SWT.BOTTOM) != 0) {
+			tabsArea.y += bounds.height - tabsHeight;
+		}
+	}
+}
+
+int getStateType(int part) {
+	return OS.GTK_STATE_NORMAL;
+}
+
+int hit(Theme theme, Point position, Rectangle bounds) {
+	return bounds.contains(position) ? DrawData.WIDGET_WHOLE : DrawData.WIDGET_NOWHERE;
+}
+
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/theme/TabFolderDrawData.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/theme/TabItemDrawData.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/theme/TabItemDrawData.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/theme/TabItemDrawData.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,103 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.theme;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.gtk.*;
+
+public class TabItemDrawData extends DrawData {
+	
+	public TabFolderDrawData parent;
+	public int position;
+
+	static final int TAB_CURVATURE = 1;
+
+public TabItemDrawData() {
+	state = new int[1];
+}
+
+Rectangle computeTrim(Theme theme, GC gc) {
+	int /*long*/ notebookHandle = theme.notebookHandle;
+	int /*long*/ gtkStyle = OS.gtk_widget_get_style(notebookHandle);
+	int hborder, vborder;
+	if (OS.GTK_VERSION >= OS.VERSION(2, 4, 0)) {
+		hborder = theme.getWidgetProperty(notebookHandle, "tab-hborder");
+		vborder = theme.getWidgetProperty(notebookHandle, "tab-vborder");
+	} else {
+		hborder = 2;
+		vborder = 2;
+	}
+	int focus_width = theme.getWidgetProperty(notebookHandle, "focus-line-width");
+	int xthickness = OS.gtk_style_get_xthickness(gtkStyle);
+	int ythickness = OS.gtk_style_get_ythickness(gtkStyle);
+	int borderX = xthickness + TAB_CURVATURE + focus_width + hborder;
+	int borderY = ythickness + TAB_CURVATURE + focus_width + vborder;
+	int x = clientArea.x - borderX;
+	int y = clientArea.y - borderY;
+	int width = clientArea.width + 2 * borderX;
+	int height = clientArea.height + 2 * borderY;
+	return new Rectangle(x, y, width, height);
+}
+
+void draw(Theme theme, GC gc, Rectangle bounds) {
+	int /*long*/ notebookHandle = theme.notebookHandle;
+	int /*long*/ gtkStyle = OS.gtk_widget_get_style (notebookHandle);
+	int /*long*/ drawable = gc.getGCData().drawable;
+	theme.transferClipping(gc, gtkStyle);
+	int x = bounds.x, y = bounds.y, width = bounds.width, height = bounds.height;
+	if ((state[DrawData.WIDGET_WHOLE] & DrawData.SELECTED) == 0) {
+		if ((parent.style & SWT.BOTTOM) == 0) {
+			y += TAB_CURVATURE;
+		}
+		height -= TAB_CURVATURE;
+	}
+	int gap_side = OS.GTK_POS_BOTTOM;
+	if ((parent.style & SWT.BOTTOM) != 0) {
+		gap_side = OS.GTK_POS_TOP;
+	}
+	int state_type = getStateType(DrawData.WIDGET_WHOLE);
+	byte[] detail = Converter.wcsToMbcs(null, "tab", true);
+	OS.gtk_paint_extension(gtkStyle, drawable, state_type, OS.GTK_SHADOW_OUT, null, notebookHandle, detail, x, y, width, height, gap_side);
+	if (clientArea != null) {
+		int hborder, vborder;
+		if (OS.GTK_VERSION >= OS.VERSION(2, 4, 0)) {
+			hborder = theme.getWidgetProperty(notebookHandle, "tab-hborder");
+			vborder = theme.getWidgetProperty(notebookHandle, "tab-vborder");
+		} else {
+			hborder = 2;
+			vborder = 2;
+		}
+		int focus_line_width = theme.getWidgetProperty(notebookHandle, "focus-line-width");
+		int xthickness = OS.gtk_style_get_xthickness(gtkStyle);
+		int ythickness = OS.gtk_style_get_ythickness(gtkStyle);
+		int borderX = xthickness + TAB_CURVATURE + focus_line_width + hborder;
+		int borderY = ythickness + TAB_CURVATURE + focus_line_width + vborder;
+		clientArea.x = bounds.x + borderX;
+		clientArea.y = bounds.y + borderY;
+		clientArea.width = bounds.width - 2 * borderX;
+		clientArea.height = bounds.height - 2 * borderY;
+	}
+}
+
+int getStateType(int part) {
+	int state = this.state[part];
+	int state_type = OS.GTK_STATE_ACTIVE;
+	if ((state & DrawData.SELECTED) != 0) state_type = OS.GTK_STATE_NORMAL;
+	return state_type;
+}
+
+int hit(Theme theme, Point position, Rectangle bounds) {
+	return bounds.contains(position) ? DrawData.WIDGET_WHOLE : DrawData.WIDGET_NOWHERE;
+}
+
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/theme/TabItemDrawData.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/theme/Theme.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/theme/Theme.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/theme/Theme.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,267 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.theme;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.gtk.*;
+
+public class Theme {
+	Device device;
+	
+	int /*long*/ shellHandle, fixedHandle, buttonHandle, arrowHandle,
+		frameHandle, entryHandle, checkButtonHandle, radioButtonHandle, 
+		notebookHandle, treeHandle, progressHandle, toolbarHandle,
+		labelHandle, separatorHandle;
+	
+public Theme(Device device) {
+	this.device = device;
+	shellHandle = OS.gtk_window_new (OS.GTK_WINDOW_TOPLEVEL);
+	fixedHandle = OS.gtk_fixed_new();
+	buttonHandle = OS.gtk_button_new();
+	arrowHandle = OS.gtk_arrow_new(OS.GTK_ARROW_DOWN, OS.GTK_SHADOW_NONE);
+	checkButtonHandle = OS.gtk_check_button_new();
+	frameHandle = OS.gtk_check_button_new();
+	entryHandle = OS.gtk_entry_new();
+	radioButtonHandle = OS.gtk_radio_button_new(0);
+	notebookHandle = OS.gtk_notebook_new();
+	progressHandle = OS.gtk_progress_bar_new();
+	toolbarHandle = OS.gtk_toolbar_new();
+	treeHandle = OS.gtk_tree_view_new_with_model(0);
+	separatorHandle = OS.gtk_vseparator_new();
+	labelHandle = OS.gtk_label_new(null);
+	OS.gtk_container_add (fixedHandle, labelHandle);
+	OS.gtk_container_add (fixedHandle, frameHandle);
+	OS.gtk_container_add (fixedHandle, entryHandle);
+	OS.gtk_container_add (fixedHandle, separatorHandle);
+	OS.gtk_container_add (fixedHandle, arrowHandle);
+	OS.gtk_container_add (fixedHandle, toolbarHandle);
+	OS.gtk_container_add (fixedHandle, progressHandle);
+	OS.gtk_container_add (fixedHandle, checkButtonHandle);
+	OS.gtk_container_add (fixedHandle, radioButtonHandle);
+	OS.gtk_container_add (fixedHandle, buttonHandle);
+	OS.gtk_container_add (fixedHandle, treeHandle);
+	OS.gtk_container_add (fixedHandle, notebookHandle);
+	OS.gtk_container_add (shellHandle, fixedHandle);
+	OS.gtk_widget_realize (separatorHandle);
+	OS.gtk_widget_realize (labelHandle);
+	OS.gtk_widget_realize (frameHandle);
+	OS.gtk_widget_realize (entryHandle);
+	OS.gtk_widget_realize (arrowHandle);
+	OS.gtk_widget_realize (buttonHandle);
+	OS.gtk_widget_realize (treeHandle);
+	OS.gtk_widget_realize (notebookHandle);
+	OS.gtk_widget_realize (checkButtonHandle);
+	OS.gtk_widget_realize (radioButtonHandle);
+	OS.gtk_widget_realize (progressHandle);
+	OS.gtk_widget_realize (toolbarHandle);
+	OS.gtk_widget_realize (shellHandle);
+}
+
+//TODO - share this code 
+static int /*long*/ createPixbuf(Image image) {
+	int [] w = new int [1], h = new int [1];
+ 	OS.gdk_drawable_get_size (image.pixmap, w, h);
+	int /*long*/ colormap = OS.gdk_colormap_get_system ();
+	int /*long*/ pixbuf;
+	boolean hasMask = image.mask != 0 && OS.gdk_drawable_get_depth (image.mask) == 1;
+	if (hasMask) {
+		pixbuf = OS.gdk_pixbuf_new (OS.GDK_COLORSPACE_RGB, true, 8, w [0], h [0]);
+		if (pixbuf == 0) SWT.error (SWT.ERROR_NO_HANDLES);
+		OS.gdk_pixbuf_get_from_drawable (pixbuf, image.pixmap, colormap, 0, 0, 0, 0, w [0], h [0]);
+		int /*long*/ maskPixbuf = OS.gdk_pixbuf_new(OS.GDK_COLORSPACE_RGB, false, 8, w [0], h [0]);
+		if (maskPixbuf == 0) SWT.error (SWT.ERROR_NO_HANDLES);
+		OS.gdk_pixbuf_get_from_drawable(maskPixbuf, image.mask, 0, 0, 0, 0, 0, w [0], h [0]);
+		int stride = OS.gdk_pixbuf_get_rowstride(pixbuf);
+		int /*long*/ pixels = OS.gdk_pixbuf_get_pixels(pixbuf);
+		byte[] line = new byte[stride];
+		int maskStride = OS.gdk_pixbuf_get_rowstride(maskPixbuf);
+		int /*long*/ maskPixels = OS.gdk_pixbuf_get_pixels(maskPixbuf);
+		byte[] maskLine = new byte[maskStride];
+		for (int y=0; y<h[0]; y++) {
+			int /*long*/ offset = pixels + (y * stride);
+			OS.memmove(line, offset, stride);
+			int /*long*/ maskOffset = maskPixels + (y * maskStride);
+			OS.memmove(maskLine, maskOffset, maskStride);
+			for (int x=0; x<w[0]; x++) {
+				if (maskLine[x * 3] == 0) {
+					line[x * 4 + 3] = 0;
+				}
+			}
+			OS.memmove(offset, line, stride);
+		}
+		OS.g_object_unref(maskPixbuf);
+	} else {
+		ImageData data = image.getImageData ();
+		boolean hasAlpha = data.getTransparencyType () == SWT.TRANSPARENCY_ALPHA;
+		pixbuf = OS.gdk_pixbuf_new (OS.GDK_COLORSPACE_RGB, hasAlpha, 8, w [0], h [0]);
+		if (pixbuf == 0) SWT.error (SWT.ERROR_NO_HANDLES);
+		OS.gdk_pixbuf_get_from_drawable (pixbuf, image.pixmap, colormap, 0, 0, 0, 0, w [0], h [0]);
+		if (hasAlpha) {
+			byte [] alpha = data.alphaData;
+			int stride = OS.gdk_pixbuf_get_rowstride (pixbuf);
+			int /*long*/ pixels = OS.gdk_pixbuf_get_pixels (pixbuf);
+			byte [] line = new byte [stride];
+			for (int y = 0; y < h [0]; y++) {
+				int /*long*/ offset = pixels + (y * stride);
+				OS.memmove (line, offset, stride);
+				for (int x = 0; x < w [0]; x++) {
+					line [x*4+3] = alpha [y*w [0]+x];
+				}
+				OS.memmove (offset, line, stride);
+			}
+		}
+	}
+	return pixbuf;
+}
+
+void checkTheme() {
+	if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
+}
+
+public Rectangle computeTrim(GC gc, DrawData data) {
+	if (gc == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	if (data == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	if (gc.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	return data.computeTrim(this, gc);
+}
+
+public void dispose () {
+	if (shellHandle == 0) return;
+	OS.gtk_widget_destroy(shellHandle);
+	shellHandle = fixedHandle = buttonHandle = arrowHandle =
+	frameHandle = entryHandle = checkButtonHandle = radioButtonHandle = 
+	notebookHandle = treeHandle = progressHandle = toolbarHandle = 
+	labelHandle = separatorHandle = 0;
+}
+	
+public void drawBackground(GC gc, Rectangle bounds, DrawData data) {
+	checkTheme();
+	if (gc == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	if (bounds == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	if (data == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	if (gc.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	data.draw(this, gc, bounds);
+}
+
+public void drawFocus(GC gc, Rectangle bounds, DrawData data) {
+	checkTheme();
+	if (gc == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	if (bounds == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	if (data == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	if (gc.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	gc.drawFocus(bounds.x, bounds.y, bounds.width, bounds.height);
+}
+
+public void drawImage(GC gc, Rectangle bounds, DrawData data, Image image, int flags) {
+	checkTheme();
+	if (gc == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	if (bounds == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	if (data == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	if (image == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	if (gc.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	data.drawImage(this, image, gc, bounds);
+}
+
+public void drawText(GC gc, Rectangle bounds, DrawData data, String text, int flags) {
+	checkTheme();
+	if (gc == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	if (bounds == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	if (data == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	if (text == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	if (gc.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	data.drawText(this, text, flags, gc, bounds);
+}
+
+public Rectangle getBounds(int part, Rectangle bounds, DrawData data) {
+	checkTheme();
+	if (bounds == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	if (data == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	return data.getBounds(part, bounds);
+}
+
+public int getSelection(Point offset, Rectangle bounds, RangeDrawData data) {
+	checkTheme();
+	if (offset == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	if (bounds == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	if (data == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	return data.getSelection(offset, bounds);
+}
+
+public int hitBackground(Point position, Rectangle bounds, DrawData data) {
+	checkTheme();
+	if (position == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	if (bounds == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	if (data == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	return data.hit(this, position, bounds);
+}
+
+public boolean isDisposed() {
+	return device == null;
+}
+
+public Rectangle measureText(GC gc, Rectangle bounds, DrawData data, String text, int flags) {
+	checkTheme();
+	if (gc == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	if (data == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	if (text == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	if (gc.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	return data.measureText(this, text, flags, gc, bounds);
+}
+
+int getWidgetProperty(int /*long*/ handle, String name) {
+	byte[] propertyName = Converter.wcsToMbcs(null, name, true);
+	int[] result = new int[1];
+	OS.gtk_widget_style_get(handle, propertyName, result, 0);
+	return result[0];
+}
+
+void transferClipping(GC gc, int /*long*/ style) {
+	GCData data = gc.getGCData();
+	int /*long*/ clipRgn = data.clipRgn;
+	int /*long*/ damageRgn = data.damageRgn;
+	int /*long*/ clipping = clipRgn;
+	if (damageRgn != 0) {
+		if (clipping != 0) {
+			clipping = OS.gdk_region_new();
+			OS.gdk_region_union(clipping, clipRgn);
+			OS.gdk_region_intersect(clipping, damageRgn);
+		} else {
+			clipping = damageRgn;
+		}
+	}
+	int /*long*/ [] curGC = new int /*long*/ [1];
+	for (int i = 0; i < 5; i++) {
+		OS.gtk_style_get_fg_gc (style, i, curGC);
+		if (curGC[0] != 0) OS.gdk_gc_set_clip_region (curGC[0], clipping);
+		OS.gtk_style_get_bg_gc (style, i, curGC);
+		if (curGC[0] != 0) OS.gdk_gc_set_clip_region (curGC[0], clipping);
+		OS.gtk_style_get_light_gc (style, i, curGC);
+		if (curGC[0] != 0) OS.gdk_gc_set_clip_region (curGC[0], clipping);
+		OS.gtk_style_get_dark_gc (style, i, curGC);
+		if (curGC[0] != 0) OS.gdk_gc_set_clip_region (curGC[0], clipping);
+		OS.gtk_style_get_mid_gc (style, i, curGC);
+		if (curGC[0] != 0) OS.gdk_gc_set_clip_region (curGC[0], clipping);
+		OS.gtk_style_get_text_gc (style, i, curGC);
+		if (curGC[0] != 0) OS.gdk_gc_set_clip_region (curGC[0], clipping);
+		OS.gtk_style_get_text_aa_gc (style, i, curGC);
+		if (curGC[0] != 0) OS.gdk_gc_set_clip_region (curGC[0], clipping);
+	}
+	OS.gtk_style_get_black_gc (style, curGC);
+	if (curGC[0] != 0) OS.gdk_gc_set_clip_region (curGC[0], clipping);
+	OS.gtk_style_get_white_gc (style, curGC);
+	if (curGC[0] != 0) OS.gdk_gc_set_clip_region (curGC[0], clipping);
+	if (clipping != clipRgn && clipping != damageRgn) {
+		OS.gdk_region_destroy(clipping);
+	}
+}
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/theme/Theme.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/theme/ToolBarDrawData.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/theme/ToolBarDrawData.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/theme/ToolBarDrawData.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.theme;
+
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.gtk.*;
+
+public class ToolBarDrawData extends DrawData {
+	
+public ToolBarDrawData() {
+	state = new int[1];
+}
+
+void draw(Theme theme, GC gc, Rectangle bounds) {
+	int /*long*/ toolbarHandle = theme.toolbarHandle;
+	int /*long*/ gtkStyle = OS.gtk_widget_get_style (toolbarHandle);
+	int /*long*/ drawable = gc.getGCData().drawable;
+	theme.transferClipping(gc, gtkStyle);
+	int x = bounds.x, y = bounds.y, width = bounds.width, height = bounds.height;
+	byte[] detail = Converter.wcsToMbcs(null, "toolbar", true);
+	OS.gtk_paint_box(gtkStyle, drawable, getStateType(DrawData.WIDGET_WHOLE), OS.GTK_SHADOW_NONE, null, toolbarHandle, detail, x, y, width, height);
+	if (clientArea != null) {
+		clientArea.x = bounds.x;
+		clientArea.y = bounds.y;
+		clientArea.width = bounds.width;
+		clientArea.height = bounds.height;
+	}
+}
+
+int getStateType(int part) {
+	return OS.GTK_STATE_NORMAL;
+}
+
+int hit(Theme theme, Point position, Rectangle bounds) {
+	return bounds.contains(position) ? DrawData.WIDGET_WHOLE : DrawData.WIDGET_NOWHERE;
+}
+
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/theme/ToolBarDrawData.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/theme/ToolItemDrawData.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/internal/theme/ToolItemDrawData.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/internal/theme/ToolItemDrawData.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,166 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.theme;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.gtk.*;
+
+public class ToolItemDrawData extends DrawData {
+
+	public ToolBarDrawData parent;
+
+	static final int ARROW_WIDTH = 8;
+	static final int ARROW_HEIGHT = 6;
+
+public ToolItemDrawData() {
+	state = new int[2];
+}
+
+Rectangle computeTrim(Theme theme, GC gc) {
+	int /*long*/ buttonHandle = theme.buttonHandle;
+	int /*long*/ gtkStyle = OS.gtk_widget_get_style(buttonHandle);
+	int focus_width = theme.getWidgetProperty(buttonHandle, "focus-line-width");
+	int focus_padding = theme.getWidgetProperty(buttonHandle, "focus-padding");
+	int xthickness = OS.gtk_style_get_xthickness(gtkStyle);
+	int ythickness = OS.gtk_style_get_ythickness(gtkStyle);
+	int borderX = xthickness + focus_width + focus_padding;
+	int borderY = ythickness + focus_width + focus_padding;
+	int x = clientArea.x - borderX;
+	int y = clientArea.y - borderY;
+	int width = clientArea.width + 2 * borderX;
+	int height = clientArea.height + 2 * borderY;
+	if ((style & SWT.DROP_DOWN) != 0) {
+		width += ARROW_WIDTH;
+	}
+	return new Rectangle(x, y, width, height);
+}
+
+void draw(Theme theme, GC gc, Rectangle bounds) {
+	int state = this.state[DrawData.WIDGET_WHOLE];
+	int /*long*/ drawable = gc.getGCData().drawable;
+
+	if ((style & SWT.SEPARATOR) != 0) {
+		int state_type = getStateType(DrawData.WIDGET_WHOLE);
+		int /*long*/ separatorHandle = theme.separatorHandle;
+		byte[] detail = Converter.wcsToMbcs(null, "vseparator", true);
+		int /*long*/ gtkStyle = OS.gtk_widget_get_style (separatorHandle);
+		theme.transferClipping(gc, gtkStyle);
+		if ((parent.style & SWT.VERTICAL) != 0) {
+			OS.gtk_paint_hline(gtkStyle, drawable, state_type, null, separatorHandle, detail, bounds.x, bounds.x + bounds.width, bounds.y + bounds.height / 2);
+		} else {
+			OS.gtk_paint_vline(gtkStyle, drawable, state_type, null, separatorHandle, detail, bounds.y, bounds.y + bounds.height, bounds.x + bounds.width / 2);
+		}
+		return;
+	}
+
+	int /*long*/ buttonHandle = theme.buttonHandle;
+	int /*long*/ gtkStyle = OS.gtk_widget_get_style (buttonHandle);
+	theme.transferClipping (gc, gtkStyle);
+	int focus_line_width = theme.getWidgetProperty(buttonHandle, "focus-line-width");
+	int focus_padding = theme.getWidgetProperty(buttonHandle, "focus-padding");
+	int border_width = OS.gtk_container_get_border_width(buttonHandle);
+
+	int x = bounds.x + border_width;
+	int y = bounds.y + border_width;
+	int width = bounds.width - border_width * 2;
+	int height = bounds.height - border_width * 2;
+
+	byte[] detail = null;
+	if ((style & (SWT.PUSH | SWT.DROP_DOWN)) != 0) {
+		detail = Converter.wcsToMbcs(null, "button", true);
+	} else if ((style & (SWT.CHECK | SWT.RADIO)) != 0) {
+		detail = Converter.wcsToMbcs(null, "togglebutton", true);
+	}
+	
+	int[] relief = new int[1];
+	int /*long*/ toolbarHandle = theme.toolbarHandle;
+	OS.gtk_widget_style_get(toolbarHandle, OS.button_relief, relief, 0);
+
+	int shadow_type = OS.GTK_SHADOW_OUT;
+	if ((state & (DrawData.SELECTED | DrawData.PRESSED)) != 0) shadow_type = OS.GTK_SHADOW_IN;
+	int state_type = getStateType(DrawData.WIDGET_WHOLE);
+		
+	if (relief[0] != OS.GTK_RELIEF_NONE || ((state & (DrawData.PRESSED | DrawData.HOT | DrawData.SELECTED)) != 0)) {
+		OS.gtk_paint_box(gtkStyle, drawable, state_type, shadow_type, null, buttonHandle, detail, x, y, width, height);
+	}
+
+	if (clientArea != null) {
+		clientArea.x = bounds.x + border_width;
+		clientArea.y = bounds.y + border_width;
+		clientArea.width = bounds.width - 2 * border_width;
+		clientArea.height = bounds.height - 2 * border_width;
+	}
+
+	int xthickness = OS.gtk_style_get_xthickness(gtkStyle);
+	int interior_focus = theme.getWidgetProperty(buttonHandle, "interior-focus");
+	if ((style & SWT.DROP_DOWN) != 0) {
+		int arrow_width = ARROW_WIDTH;
+		int arrow_height = ARROW_HEIGHT;
+		int arrow_x = x + width - arrow_width - xthickness - focus_padding;
+		if (interior_focus == 0) arrow_x -= focus_line_width;
+		int arrow_y = y + (height - arrow_height) / 2;
+		byte[] arrow_detail = Converter.wcsToMbcs(null, "arrow", true);
+		OS.gtk_paint_arrow(gtkStyle, drawable, state_type, OS.GTK_SHADOW_NONE, null, theme.arrowHandle, arrow_detail, OS.GTK_ARROW_DOWN, true, arrow_x, arrow_y, arrow_width, arrow_height);
+		if (clientArea != null) {
+			clientArea.width -= bounds.x + bounds.width - arrow_x;
+		}
+	}
+
+    if ((state & DrawData.FOCUSED) != 0) {
+    	int child_displacement_y = theme.getWidgetProperty(buttonHandle, "child-displacement-y");
+    	int child_displacement_x = theme.getWidgetProperty(buttonHandle, "child-displacement-x");
+    	int displace_focus = 0;
+    	if (OS.GTK_VERSION >= OS.VERSION (2, 6, 0)) {
+    		displace_focus = theme.getWidgetProperty(buttonHandle, "displace-focus");
+    	}
+    	
+    	if (interior_focus != 0) {
+    		int ythickness = OS.gtk_style_get_ythickness(gtkStyle);
+    		x += xthickness + focus_padding;
+            y += ythickness + focus_padding;
+            width -= 2 * (xthickness + focus_padding);
+            height -=  2 * (ythickness + focus_padding);
+    	} else {
+    		x -= focus_line_width + focus_padding;
+    		y -= focus_line_width + focus_padding;
+    		width += 2 * (focus_line_width + focus_padding);
+    		height += 2 * (focus_line_width + focus_padding);
+    	}
+    	
+    	if ((state & (DrawData.PRESSED | DrawData.SELECTED)) != 0 && displace_focus != 0) {
+              x += child_displacement_x;
+              y += child_displacement_y;
+    	}
+    	
+        OS.gtk_paint_focus(gtkStyle, drawable, state_type, null, buttonHandle, detail, x, y, width, height);
+    }
+}
+
+int hit(Theme theme, Point position, Rectangle bounds) {
+	if (!bounds.contains(position)) return DrawData.WIDGET_NOWHERE;
+	if ((style & SWT.DROP_DOWN) != 0) {
+		int /*long*/ buttonHandle = theme.buttonHandle;
+		int /*long*/ gtkStyle = OS.gtk_widget_get_style (buttonHandle);
+		int xthickness = OS.gtk_style_get_xthickness(gtkStyle);
+		int interior_focus = theme.getWidgetProperty(buttonHandle, "interior-focus");
+		int focus_line_width = theme.getWidgetProperty(buttonHandle, "focus-line-width");
+		int focus_padding = theme.getWidgetProperty(buttonHandle, "focus-padding");
+		int arrow_width = ARROW_WIDTH;
+		int arrow_x = bounds.x + bounds.width - arrow_width - xthickness - focus_padding;
+		if (interior_focus == 0) arrow_x -= focus_line_width;
+		if (arrow_x <= position.x) return DrawData.TOOLITEM_ARROW;
+	}
+	return DrawData.WIDGET_WHOLE; 
+}
+
+}


Property changes on: branches/upstream/swt-gtk/current/org/eclipse/swt/internal/theme/ToolItemDrawData.java
___________________________________________________________________
Added: svn:executable
   + 

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/layout/FillData.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/layout/FillData.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/layout/FillData.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.layout;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+
+class FillData {
+
+	int defaultWidth = -1, defaultHeight = -1;
+	int currentWhint, currentHhint, currentWidth = -1, currentHeight = -1;
+	
+Point computeSize (Control control, int wHint, int hHint, boolean flushCache) {
+	if (flushCache) flushCache();
+	if (wHint == SWT.DEFAULT && hHint == SWT.DEFAULT) {
+		if (defaultWidth == -1 || defaultHeight == -1) {
+			Point size = control.computeSize (wHint, hHint, flushCache);
+			defaultWidth = size.x;
+			defaultHeight = size.y;
+		}
+		return new Point(defaultWidth, defaultHeight);
+	}
+	if (currentWidth == -1 || currentHeight == -1 || wHint != currentWhint || hHint != currentHhint) {
+		Point size = control.computeSize (wHint, hHint, flushCache);
+		currentWhint = wHint;
+		currentHhint = hHint;
+		currentWidth = size.x;
+		currentHeight = size.y;
+	}
+	return new Point(currentWidth, currentHeight);
+}
+void flushCache () {
+	defaultWidth = defaultHeight = -1;
+	currentWidth = currentHeight = -1;
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/layout/FillLayout.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/layout/FillLayout.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/layout/FillLayout.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,238 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.layout;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+
+/**
+ * <code>FillLayout</code> is the simplest layout class. It lays out 
+ * controls in a single row or column, forcing them to be the same size. 
+ * <p>
+ * Initially, the controls will all be as tall as the tallest control, 
+ * and as wide as the widest. <code>FillLayout</code> does not wrap, 
+ * but you can specify margins and spacing. You might use it to 
+ * lay out buttons in a task bar or tool bar, or to stack checkboxes 
+ * in a <code>Group</code>. <code>FillLayout</code> can also be used 
+ * when a <code>Composite</code> only has one child. For example, 
+ * if a <code>Shell</code> has a single <code>Group</code> child, 
+ * <code>FillLayout</code> will cause the <code>Group</code> to 
+ * completely fill the <code>Shell</code> (if margins are 0).
+ * </p>
+ * <p>
+ * Example code: first a <code>FillLayout</code> is created and
+ * its type field is set, and then the layout is set into the 
+ * <code>Composite</code>. Note that in a <code>FillLayout</code>,
+ * children are always the same size, and they fill all available space.
+ * <pre>
+ * 		FillLayout fillLayout = new FillLayout();
+ * 		fillLayout.type = SWT.VERTICAL;
+ * 		shell.setLayout(fillLayout);
+ * </pre>
+ * </p>
+ *
+ * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: LayoutExample</a>
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public final class FillLayout extends Layout {
+	/**
+	 * type specifies how controls will be positioned 
+	 * within the layout.
+	 *
+	 * The default value is HORIZONTAL.
+	 *
+	 * Possible values are: <ul>
+	 *    <li>HORIZONTAL: Position the controls horizontally from left to right</li>
+	 *    <li>VERTICAL: Position the controls vertically from top to bottom</li>
+	 * </ul>
+	 */
+	public int type = SWT.HORIZONTAL;
+	
+	/**
+	 * marginWidth specifies the number of pixels of horizontal margin
+	 * that will be placed along the left and right edges of the layout.
+	 *
+	 * The default value is 0.
+	 * 
+	 * @since 3.0
+	 */
+ 	public int marginWidth = 0;
+ 	
+	/**
+	 * marginHeight specifies the number of pixels of vertical margin
+	 * that will be placed along the top and bottom edges of the layout.
+	 *
+	 * The default value is 0.
+	 * 
+	 * @since 3.0
+	 */
+ 	public int marginHeight = 0;
+ 	
+ 	/**
+	 * spacing specifies the number of pixels between the edge of one cell
+	 * and the edge of its neighbouring cell.
+	 *
+	 * The default value is 0.
+	 * 
+	 * @since 3.0
+	 */
+	public int spacing = 0;
+	
+/**
+ * Constructs a new instance of this class.
+ */
+public FillLayout () {
+}
+
+/**
+ * Constructs a new instance of this class given the type.
+ *
+ * @param type the type of fill layout
+ * 
+ * @since 2.0
+ */
+public FillLayout (int type) {
+	this.type = type;
+}
+
+protected Point computeSize (Composite composite, int wHint, int hHint, boolean flushCache) {
+	Control [] children = composite.getChildren ();
+	int count = children.length;
+	int maxWidth = 0, maxHeight = 0;
+	for (int i=0; i<count; i++) {
+		Control child = children [i];
+		int w = wHint, h = hHint;
+		if (count > 0) {
+			if (type == SWT.HORIZONTAL && wHint != SWT.DEFAULT) {
+				w = Math.max (0, (wHint - (count - 1) * spacing) / count);
+			}
+			if (type == SWT.VERTICAL && hHint != SWT.DEFAULT) {
+				h = Math.max (0, (hHint - (count - 1) * spacing) / count);
+			}
+		}
+		Point size = computeChildSize (child, w, h, flushCache);
+		maxWidth = Math.max (maxWidth, size.x);
+		maxHeight = Math.max (maxHeight, size.y);
+	}
+	int width = 0, height = 0;
+	if (type == SWT.HORIZONTAL) {
+		width = count * maxWidth;
+		if (count != 0) width += (count - 1) * spacing;
+		height = maxHeight;
+	} else {
+		width = maxWidth;
+		height = count * maxHeight;
+		if (count != 0) height += (count - 1) * spacing;
+	}
+	width += marginWidth * 2;
+	height += marginHeight * 2;
+	if (wHint != SWT.DEFAULT) width = wHint;
+	if (hHint != SWT.DEFAULT) height = hHint;
+	return new Point (width, height);
+}
+
+Point computeChildSize (Control control, int wHint, int hHint, boolean flushCache) {
+	FillData data = (FillData)control.getLayoutData ();
+	if (data == null) {
+		data = new FillData ();
+		control.setLayoutData (data);
+	}
+	Point size = null;
+	if (wHint == SWT.DEFAULT && hHint == SWT.DEFAULT) {
+		size = data.computeSize (control, wHint, hHint, flushCache);
+	} else {
+		// TEMPORARY CODE
+		int trimX, trimY;
+		if (control instanceof Scrollable) {
+			Rectangle rect = ((Scrollable) control).computeTrim (0, 0, 0, 0);
+			trimX = rect.width;
+			trimY = rect.height;
+		} else {
+			trimX = trimY = control.getBorderWidth () * 2;
+		}
+		int w = wHint == SWT.DEFAULT ? wHint : Math.max (0, wHint - trimX);
+		int h = hHint == SWT.DEFAULT ? hHint : Math.max (0, hHint - trimY);
+		size = data.computeSize (control, w, h, flushCache);
+	}
+	return size;
+}
+
+protected boolean flushCache (Control control) {
+	Object data = control.getLayoutData();
+	if (data != null) ((FillData)data).flushCache();
+	return true;
+}
+
+String getName () {
+	String string = getClass ().getName ();
+	int index = string.lastIndexOf ('.');
+	if (index == -1) return string;
+	return string.substring (index + 1, string.length ());
+}
+
+protected void layout (Composite composite, boolean flushCache) {
+	Rectangle rect = composite.getClientArea ();
+	Control [] children = composite.getChildren ();
+	int count = children.length;
+	if (count == 0) return;
+	int width = rect.width - marginWidth * 2;
+	int height = rect.height - marginHeight * 2;
+	if (type == SWT.HORIZONTAL) {
+		width -= (count - 1) * spacing;
+		int x = rect.x + marginWidth, extra = width % count;
+		int y = rect.y + marginHeight, cellWidth = width / count;
+		for (int i=0; i<count; i++) {
+			Control child = children [i];
+			int childWidth = cellWidth;
+			if (i == 0) {
+				childWidth += extra / 2;
+			} else {
+				if (i == count - 1) childWidth += (extra + 1) / 2;
+			}
+			child.setBounds (x, y, childWidth, height);
+			x += childWidth + spacing;
+		}
+	} else {
+		height -= (count - 1) * spacing;
+		int x = rect.x + marginWidth, cellHeight = height / count;
+		int y = rect.y + marginHeight, extra = height % count;
+		for (int i=0; i<count; i++) {
+			Control child = children [i];
+			int childHeight = cellHeight;
+			if (i == 0) {
+				childHeight += extra / 2;
+			} else {
+				if (i == count - 1) childHeight += (extra + 1) / 2;
+			}
+			child.setBounds (x, y, width, childHeight);
+			y += childHeight + spacing;
+		}
+	}
+}
+
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the layout
+ */
+public String toString () {
+ 	String string = getName ()+" {";
+ 	string += "type="+((type == SWT.VERTICAL) ? "SWT.VERTICAL" : "SWT.HORIZONTAL")+" ";
+ 	if (marginWidth != 0) string += "marginWidth="+marginWidth+" ";
+ 	if (marginHeight != 0) string += "marginHeight="+marginHeight+" ";
+ 	if (spacing != 0) string += "spacing="+spacing+" ";
+ 	string = string.trim();
+ 	string += "}";
+ 	return string;
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/layout/FormAttachment.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/layout/FormAttachment.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/layout/FormAttachment.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,316 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.layout;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.widgets.*;
+
+/**
+ * Instances of this class are used to define the edges of a control
+ * within a <code>FormLayout</code>. 
+ * <p>
+ * <code>FormAttachments</code> are set into the top, bottom, left,
+ * and right fields of the <code>FormData</code> for a control.
+ * For example:
+ * <pre>
+ * 		FormData data = new FormData();
+ * 		data.top = new FormAttachment(0,5);
+ * 		data.bottom = new FormAttachment(100,-5);
+ * 		data.left = new FormAttachment(0,5);
+ * 		data.right = new FormAttachment(100,-5);
+ * 		button.setLayoutData(data);
+ * </pre>
+ * </p>
+ * <p>
+ * A <code>FormAttachment</code> defines where to attach the side of
+ * a control by using the equation, y = ax + b. The "a" term represents 
+ * a fraction of the parent composite's width (from the left) or height
+ * (from the top). It can be defined using a numerator and denominator,
+ * or just a percentage value. If a percentage is used, the denominator 
+ * is set to 100. The "b" term in the equation represents an offset, in
+ * pixels, from the attachment position. For example:
+ * <pre>
+ * 		FormAttachment attach = new FormAttachment (20, -5);
+ * </pre>
+ * specifies that the side to which the <code>FormAttachment</code>
+ * object belongs will lie at 20% of the parent composite, minus 5 pixels.
+ * </p>
+ * <p>
+ * Control sides can also be attached to another control.
+ * For example:
+ * <pre>
+ * 		FormAttachment attach = new FormAttachment (button, 10);
+ * </pre>
+ * specifies that the side to which the <code>FormAttachment</code>
+ * object belongs will lie in the same position as the adjacent side of 
+ * the <code>button</code> control, plus 10 pixels. The control side can 
+ * also be attached to the opposite side of the specified control.
+ * For example:
+ * <pre>
+ * 		FormData data = new FormData ();
+ * 		data.left = new FormAttachment (button, 0, SWT.LEFT);
+ * </pre>
+ * specifies that the left side of the control will lie in the same position
+ * as the left side of the <code>button</code> control. The control can also 
+ * be attached in a position that will center the control on the specified 
+ * control. For example:
+ * <pre>
+ * 		data.left = new FormAttachment (button, 0, SWT.CENTER);
+ * </pre>
+ * specifies that the left side of the control will be positioned so that it is
+ * centered between the left and right sides of the <code>button</code> control.
+ * If the alignment is not specified, the default is to attach to the adjacent side.
+ * </p>
+ * 
+ * @see FormLayout
+ * @see FormData
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ * 
+ * @since 2.0
+ */
+public final class FormAttachment {
+	/**
+	 * numerator specifies the numerator of the "a" term in the
+	 * equation, y = ax + b, which defines the attachment.
+	 */
+	public int numerator;
+	
+	/**
+	 * denominator specifies the denominator of the "a" term in the
+	 * equation, y = ax + b, which defines the attachment.
+	 * 
+	 * The default value is 100.
+	 */
+	public int denominator = 100;
+	
+	/**
+	 * offset specifies the offset, in pixels, of the control side
+	 * from the attachment position.
+	 * If the offset is positive, then the control side is offset
+	 * to the right of or below the attachment position. If it is
+	 * negative, then the control side is offset to the left of or
+	 * above the attachment position.
+	 * 
+	 * This is equivalent to the "b" term in the equation y = ax + b.
+	 * The default value is 0.
+	 */
+	public int offset;
+	
+	/**
+	 * control specifies the control to which the control side is
+	 * attached.
+	 */
+	public Control control;
+	
+	/**
+	 * alignment specifies the alignment of the control side that is
+	 * attached to a control.
+	 * <p>
+	 * For top and bottom attachments, TOP, BOTTOM and CENTER are used. For left 
+	 * and right attachments, LEFT, RIGHT and CENTER are used. If any other case
+	 * occurs, the default will be used instead.
+	 * </p>
+	 * 
+	 * <br>Possible values are: <ul>
+	 *    <li>{@link SWT#TOP}: Attach the side to the top side of the specified control.</li>
+	 *    <li>{@link SWT#BOTTOM}: Attach the side to the bottom side of the specified control.</li>
+	 *    <li>{@link SWT#LEFT}: Attach the side to the left side of the specified control.</li>
+	 *    <li>{@link SWT#RIGHT}: Attach the side to the right side of the specified control.</li>
+	 *    <li>{@link SWT#CENTER}: Attach the side at a position which will center the control on the specified control.</li>
+	 *    <li>{@link SWT#DEFAULT}: Attach the side to the adjacent side of the specified control.</li>
+	 * </ul>
+	 */
+	public int alignment;
+
+/**
+ * Constructs a new instance of this class.
+ * Since no numerator, denominator or offset is specified,
+ * the attachment is treated as a percentage of the form.
+ * The numerator is zero, the denominator is 100 and the
+ * offset is zero.
+ * 
+ * @since 3.2
+ */
+public FormAttachment () {
+}
+
+/**
+ * Constructs a new instance of this class given a numerator
+ * Since no denominator or offset is specified, the default
+ * is to treat the numerator as a percentage of the form, with a 
+ * denominator of 100. The offset is zero.
+ * 
+ * @param numerator the percentage of the position
+ * 
+ * @since 3.0
+ */
+public FormAttachment (int numerator) {
+	this (numerator, 100, 0);
+}
+
+/**
+ * Constructs a new instance of this class given a numerator
+ * and an offset. Since no denominator is specified, the default
+ * is to treat the numerator as a percentage of the form, with a 
+ * denominator of 100.
+ * 
+ * @param numerator the percentage of the position
+ * @param offset the offset of the side from the position
+ */
+public FormAttachment (int numerator, int offset) {
+	this (numerator, 100, offset);
+}
+
+/**
+ * Constructs a new instance of this class given a numerator 
+ * and denominator and an offset. The position of the side is
+ * given by the fraction of the form defined by the numerator
+ * and denominator.
+ *
+ * @param numerator the numerator of the position
+ * @param denominator the denominator of the position
+ * @param offset the offset of the side from the position
+ */
+public FormAttachment (int numerator, int denominator, int offset) {
+	if (denominator == 0) SWT.error (SWT.ERROR_CANNOT_BE_ZERO);
+	this.numerator = numerator;
+	this.denominator = denominator;
+	this.offset = offset;
+}
+
+/**
+ * Constructs a new instance of this class given a control.
+ * Since no alignment is specified, the default alignment is
+ * to attach the side to the adjacent side of the specified 
+ * control. Since no offset is specified, an offset of 0 is
+ * used.
+ * 
+ * @param control the control the side is attached to
+ */
+public FormAttachment (Control control) {
+	this (control, 0, SWT.DEFAULT);
+}
+
+/**
+ * Constructs a new instance of this class given a control
+ * and an offset. Since no alignment is specified, the default
+ * alignment is to attach the side to the adjacent side of the 
+ * specified control.
+ * 
+ * @param control the control the side is attached to
+ * @param offset the offset of the side from the control
+ */
+public FormAttachment (Control control, int offset) {
+	this (control, offset, SWT.DEFAULT);
+}
+
+/**
+ * Constructs a new instance of this class given a control,
+ * an offset and an alignment.  The possible alignment values are:
+ * <dl>
+ * <dt><b>{@link SWT#TOP}</b></dt>
+ * <dd>the side will be attached to the top side of the specified control</dd>
+ * <dt><b>{@link SWT#BOTTOM}</b></dt>
+ * <dd>the side will be attached to the bottom side of the specified control</dd>
+ * <dt><b>{@link SWT#LEFT}</b></dt>
+ * <dd>the side will be attached to the left side of the specified control</dd>
+ * <dt><b>{@link SWT#RIGHT}</b></dt>
+ * <dd>the side will be attached to the right side of the specified control</dd>
+ * <dt><b>{@link SWT#CENTER}</b></dt>
+ * <dd>the side will be centered on the same side of the specified control</dd>
+ * <dt><b>{@link SWT#DEFAULT}</b></dt>
+ * <dd>the side will be attached to the adjacent side of the specified control</dd>
+ * </dl>
+ * 
+ * @param control the control the side is attached to
+ * @param offset the offset of the side from the control
+ * @param alignment the alignment of the side to the control it is attached to,
+ * 		one of TOP, BOTTOM, LEFT, RIGHT, CENTER, or DEFAULT
+ */
+public FormAttachment (Control control, int offset, int alignment) {
+	this.control = control;
+	this.offset = offset;
+	this.alignment = alignment;
+}
+
+FormAttachment divide (int value) {
+	return new FormAttachment (numerator, denominator * value, offset / value);
+}
+
+int gcd (int m, int n) {
+	int temp;
+	m = Math.abs (m);
+	n = Math.abs (n);
+	if (m < n) {
+		temp = m;
+		m = n;
+		n = temp;
+	}
+	while (n != 0){
+		temp = m;
+		m = n;
+		n = temp % n;
+	}
+	return m;
+}
+
+FormAttachment minus (FormAttachment attachment) {
+	FormAttachment solution = new FormAttachment ();
+	solution.numerator = numerator * attachment.denominator - denominator * attachment.numerator;
+	solution.denominator = denominator * attachment.denominator;
+	int gcd = gcd (solution.denominator, solution.numerator);
+	solution.numerator = solution.numerator / gcd;
+	solution.denominator = solution.denominator / gcd;
+	solution.offset = offset - attachment.offset;
+	return solution;
+}
+
+FormAttachment minus (int value) {
+	return new FormAttachment (numerator, denominator, offset - value);
+}
+
+FormAttachment plus (FormAttachment attachment) {
+	FormAttachment solution = new FormAttachment ();
+	solution.numerator = numerator * attachment.denominator + denominator * attachment.numerator;
+	solution.denominator = denominator * attachment.denominator;
+	int gcd = gcd (solution.denominator, solution.numerator);
+	solution.numerator = solution.numerator / gcd;
+	solution.denominator = solution.denominator / gcd;
+	solution.offset = offset + attachment.offset;
+	return solution;
+}
+
+FormAttachment plus (int value) {
+	return new FormAttachment (numerator, denominator, offset + value);
+}
+
+int solveX (int value) {
+	if (denominator == 0) SWT.error (SWT.ERROR_CANNOT_BE_ZERO);
+	return ((numerator * value) / denominator) + offset;
+}
+
+int solveY (int value) {
+	if (numerator == 0) SWT.error (SWT.ERROR_CANNOT_BE_ZERO);
+	return (value - offset) * denominator / numerator;
+}
+	
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the FormAttachment
+ */
+public String toString () {
+ 	String string = control != null ? control.toString () : numerator + "/" + denominator;
+	return "{y = (" + string + (offset >= 0 ? ")x + " + offset: ")x - " + (-offset))+"}";
+}
+
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/layout/FormData.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/layout/FormData.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/layout/FormData.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,344 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.layout;
+
+ 
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+
+/**
+ * Instances of this class are used to define the attachments 
+ * of a control in a <code>FormLayout</code>. 
+ * <p>
+ * To set a <code>FormData</code> object into a control, you use the 
+ * <code>setLayoutData ()</code> method. To define attachments for the 
+ * <code>FormData</code>, set the fields directly, like this:
+ * <pre>
+ * 		FormData data = new FormData();
+ * 		data.left = new FormAttachment(0,5);
+ * 		data.right = new FormAttachment(100,-5);
+ * 		button.setLayoutData(formData);
+ * </pre>
+ * </p>
+ * <p>
+ * <code>FormData</code> contains the <code>FormAttachments</code> for 
+ * each edge of the control that the <code>FormLayout</code> uses to
+ * determine the size and position of the control. <code>FormData</code>
+ * objects also allow you to set the width and height of controls within
+ * a <code>FormLayout</code>. 
+ * </p>
+ * 
+ * @see FormLayout
+ * @see FormAttachment
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ * 
+ * @since 2.0
+ */
+public final class FormData {
+	/**
+	 * width specifies the preferred width in pixels. This value
+	 * is the wHint passed into Control.computeSize(int, int, boolean) 
+	 * to determine the preferred size of the control.
+	 *
+	 * The default value is SWT.DEFAULT.
+	 *
+	 * @see Control#computeSize(int, int, boolean)
+	 */
+	public int width = SWT.DEFAULT;
+	/**
+	 * height specifies the preferred height in pixels. This value
+	 * is the hHint passed into Control.computeSize(int, int, boolean) 
+	 * to determine the preferred size of the control.
+	 *
+	 * The default value is SWT.DEFAULT.
+	 *
+	 * @see Control#computeSize(int, int, boolean)
+	 */
+	public int height = SWT.DEFAULT;
+	/**
+	 * left specifies the attachment of the left side of 
+	 * the control.
+	 */
+	public FormAttachment left;
+	/**
+	 * right specifies the attachment of the right side of
+	 * the control.
+	 */
+	public FormAttachment right;
+	/**
+	 * top specifies the attachment of the top of the control.
+	 */
+	public FormAttachment top;
+	/**
+	 * bottom specifies the attachment of the bottom of the
+	 * control.
+	 */
+	public FormAttachment bottom;
+	
+	int cacheWidth = -1, cacheHeight = -1;
+	int defaultWhint, defaultHhint, defaultWidth = -1, defaultHeight = -1;
+	int currentWhint, currentHhint, currentWidth = -1, currentHeight = -1;
+	FormAttachment cacheLeft, cacheRight, cacheTop, cacheBottom;
+	boolean isVisited, needed;
+	
+/**
+ * Constructs a new instance of FormData using
+ * default values.
+ */
+public FormData () {
+}
+	
+/**
+ * Constructs a new instance of FormData according to the parameters.
+ * A value of SWT.DEFAULT indicates that no minimum width or
+ * no minimum height is specified.
+ * 
+ * @param width a minimum width for the control
+ * @param height a minimum height for the control
+ */
+public FormData (int width, int height) {
+	this.width = width;
+	this.height = height;
+}
+
+void computeSize (Control control, int wHint, int hHint, boolean flushCache) {
+	if (cacheWidth != -1 && cacheHeight != -1) return;
+	if (wHint == this.width && hHint == this.height) {
+		if (defaultWidth == -1 || defaultHeight == -1 || wHint != defaultWhint || hHint != defaultHhint) {
+			Point size =  control.computeSize (wHint, hHint, flushCache);
+			defaultWhint = wHint;
+			defaultHhint = hHint;
+			defaultWidth = size.x;
+			defaultHeight = size.y;
+		}
+		cacheWidth = defaultWidth;
+		cacheHeight = defaultHeight;
+		return;
+	}
+	if (currentWidth == -1 || currentHeight == -1 || wHint != currentWhint || hHint != currentHhint) {
+		Point size =  control.computeSize (wHint, hHint, flushCache);
+		currentWhint = wHint;
+		currentHhint = hHint;
+		currentWidth = size.x;
+		currentHeight = size.y;
+	}
+	cacheWidth = currentWidth;
+	cacheHeight = currentHeight;
+}
+
+void flushCache () {
+	cacheWidth = cacheHeight = -1;
+	defaultHeight = defaultWidth = -1;
+	currentHeight = currentWidth = -1;
+}
+
+int getWidth (Control control, boolean flushCache) {
+	needed = true;
+	computeSize (control, width, height, flushCache);
+	return cacheWidth;
+}
+
+int getHeight (Control control, boolean flushCache) {
+	computeSize (control, width, height, flushCache);
+	return cacheHeight;
+}
+
+FormAttachment getBottomAttachment (Control control, int spacing, boolean flushCache) {
+	if (cacheBottom != null) return cacheBottom;
+	if (isVisited) return cacheBottom = new FormAttachment (0, getHeight (control, flushCache));
+	if (bottom == null) {
+		if (top == null) return cacheBottom = new FormAttachment (0, getHeight (control, flushCache));
+		return cacheBottom = getTopAttachment (control, spacing, flushCache).plus (getHeight (control, flushCache));
+	}
+	Control bottomControl = bottom.control;
+	if (bottomControl != null) {
+		if (bottomControl.isDisposed ()) {
+			bottom.control = bottomControl = null;
+		} else {
+			if (bottomControl.getParent () != control.getParent ()) {
+				bottomControl = null;
+			}
+		}
+	}
+	if (bottomControl == null) return cacheBottom = bottom;
+	isVisited = true;
+	FormData bottomData = (FormData) bottomControl.getLayoutData ();
+	FormAttachment bottomAttachment = bottomData.getBottomAttachment (bottomControl, spacing, flushCache);
+	switch (bottom.alignment) {
+		case SWT.BOTTOM: 
+			cacheBottom = bottomAttachment.plus (bottom.offset);
+			break;
+		case SWT.CENTER: {
+			FormAttachment topAttachment = bottomData.getTopAttachment (bottomControl, spacing, flushCache);
+			FormAttachment bottomHeight = bottomAttachment.minus (topAttachment);
+			cacheBottom = bottomAttachment.minus (bottomHeight.minus (getHeight (control, flushCache)).divide (2));
+			break;
+		}
+		default: {
+			FormAttachment topAttachment = bottomData.getTopAttachment (bottomControl, spacing, flushCache);
+			cacheBottom = topAttachment.plus (bottom.offset - spacing);	
+			break;
+		}
+	}
+	isVisited = false;
+	return cacheBottom;
+}
+
+FormAttachment getLeftAttachment (Control control, int spacing, boolean flushCache) {
+	if (cacheLeft != null) return cacheLeft;
+	if (isVisited) return cacheLeft = new FormAttachment (0, 0);
+	if (left == null) {
+		if (right == null) return cacheLeft = new FormAttachment (0, 0);
+		return cacheLeft = getRightAttachment (control, spacing, flushCache).minus (getWidth (control, flushCache));
+	}
+	Control leftControl = left.control;
+	if (leftControl != null) {
+		if (leftControl.isDisposed ()) {
+			left.control = leftControl = null;
+		} else {
+			if (leftControl.getParent () != control.getParent ()) {
+				leftControl = null;
+			}
+		}
+	}
+	if (leftControl == null) return cacheLeft = left;
+	isVisited = true;
+	FormData leftData = (FormData) leftControl.getLayoutData ();
+	FormAttachment leftAttachment = leftData.getLeftAttachment (leftControl, spacing, flushCache);
+	switch (left.alignment) {
+		case SWT.LEFT:
+			cacheLeft = leftAttachment.plus (left.offset);
+			break;
+		case SWT.CENTER: {
+			FormAttachment rightAttachment = leftData.getRightAttachment (leftControl, spacing, flushCache);
+			FormAttachment leftWidth = rightAttachment.minus (leftAttachment);
+			cacheLeft = leftAttachment.plus (leftWidth.minus (getWidth (control, flushCache)).divide (2));
+			break;
+		}
+		default: {
+			FormAttachment rightAttachment = leftData.getRightAttachment (leftControl, spacing, flushCache);
+			cacheLeft = rightAttachment.plus (left.offset + spacing); 
+		}
+	}
+	isVisited = false; 
+	return cacheLeft;
+}
+	
+String getName () {
+	String string = getClass ().getName ();
+	int index = string.lastIndexOf ('.');
+	if (index == -1) return string;
+	return string.substring (index + 1, string.length ());
+}
+
+FormAttachment getRightAttachment (Control control, int spacing, boolean flushCache) {
+	if (cacheRight != null) return cacheRight;
+	if (isVisited) return cacheRight = new FormAttachment (0, getWidth (control, flushCache));
+	if (right == null) {
+		if (left == null) return cacheRight = new FormAttachment (0, getWidth (control, flushCache));
+		return cacheRight = getLeftAttachment (control, spacing, flushCache).plus (getWidth (control, flushCache));
+	}
+	Control rightControl = right.control;
+	if (rightControl != null) {
+		if (rightControl.isDisposed ()) {
+			right.control = rightControl = null;
+		} else {
+			if (rightControl.getParent () != control.getParent ()) {
+				rightControl = null;
+			}
+		}
+	}
+	if (rightControl == null) return cacheRight = right;
+	isVisited = true;
+	FormData rightData = (FormData) rightControl.getLayoutData ();
+	FormAttachment rightAttachment = rightData.getRightAttachment (rightControl, spacing, flushCache);
+	switch (right.alignment) {
+		case SWT.RIGHT: 
+			cacheRight = rightAttachment.plus (right.offset);
+			break;
+		case SWT.CENTER: {
+			FormAttachment leftAttachment = rightData.getLeftAttachment (rightControl, spacing, flushCache);
+			FormAttachment rightWidth = rightAttachment.minus (leftAttachment);
+			cacheRight = rightAttachment.minus (rightWidth.minus (getWidth (control, flushCache)).divide (2));
+			break;
+		}
+		default: {
+			FormAttachment leftAttachment = rightData.getLeftAttachment (rightControl, spacing, flushCache);
+			cacheRight = leftAttachment.plus (right.offset - spacing);
+			break;
+		}
+	}
+	isVisited = false;
+	return cacheRight;
+}
+
+FormAttachment getTopAttachment (Control control, int spacing, boolean flushCache) {
+	if (cacheTop != null) return cacheTop;
+	if (isVisited) return cacheTop = new FormAttachment (0, 0);
+	if (top == null) {
+		if (bottom == null) return cacheTop = new FormAttachment (0, 0);
+		return cacheTop = getBottomAttachment (control, spacing, flushCache).minus (getHeight (control, flushCache));
+	}
+	Control topControl = top.control;
+	if (topControl != null) {
+		if (topControl.isDisposed ()) {
+			top.control = topControl = null;
+		} else {
+			if (topControl.getParent () != control.getParent ()) {
+				topControl = null;
+			}
+		}
+	}
+	if (topControl == null) return cacheTop = top;
+	isVisited = true;
+	FormData topData = (FormData) topControl.getLayoutData ();
+	FormAttachment topAttachment = topData.getTopAttachment (topControl, spacing, flushCache);
+	switch (top.alignment) {
+		case SWT.TOP:
+			cacheTop = topAttachment.plus (top.offset);
+			break;
+		case SWT.CENTER: {
+			FormAttachment bottomAttachment = topData.getBottomAttachment (topControl, spacing, flushCache);
+			FormAttachment topHeight = bottomAttachment.minus (topAttachment);
+			cacheTop = topAttachment.plus (topHeight.minus (getHeight (control, flushCache)).divide (2));
+			break;
+		}
+		default: {
+			FormAttachment bottomAttachment = topData.getBottomAttachment (topControl, spacing, flushCache);
+			cacheTop = bottomAttachment.plus (top.offset + spacing);
+			break;
+		}
+	}
+	isVisited = false;
+	return cacheTop;
+}
+
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the FormData object
+ */
+public String toString () {
+ 	String string = getName()+" {";
+ 	if (width != SWT.DEFAULT) string += "width="+width+" ";
+	if (height != SWT.DEFAULT) string += "height="+height+" ";
+ 	if (left != null) string += "left="+left+" ";
+ 	if (right != null) string += "right="+right+" ";
+ 	if (top != null) string += "top="+top+" ";
+ 	if (bottom != null) string += "bottom="+bottom+" ";
+ 	string = string.trim();
+ 	string += "}";
+	return string;
+}
+
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/layout/FormLayout.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/layout/FormLayout.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/layout/FormLayout.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,385 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.layout;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+
+/**
+ * Instances of this class control the position and size of the 
+ * children of a composite control by using <code>FormAttachments</code>
+ * to optionally configure the left, top, right and bottom edges of
+ * each child.
+ * <p>
+ * The following example code creates a <code>FormLayout</code> and then sets
+ * it into a <code>Shell</code>:
+ * <pre>
+ * 		Display display = new Display ();
+ *		Shell shell = new Shell(display);
+ *		FormLayout layout = new FormLayout();
+ *		layout.marginWidth = 3;
+ *		layout.marginHeight = 3;
+ *		shell.setLayout(layout);
+ * </pre>
+ * </p>
+ * <p>
+ * To use a <code>FormLayout</code>, create a <code>FormData</code> with
+ * <code>FormAttachment</code> for each child of <code>Composite</code>.
+ * The following example code attaches <code>button1</code> to the top
+ * and left edge of the composite and <code>button2</code> to the right
+ * edge of <code>button1</code> and the top and right edges of the
+ * composite:
+ * <pre>
+ *		FormData data1 = new FormData();
+ *		data1.left = new FormAttachment(0, 0);
+ *		data1.top = new FormAttachment(0, 0);
+ *		button1.setLayoutData(data1);
+ *		FormData data2 = new FormData();
+ *		data2.left = new FormAttachment(button1);
+ *		data2.top = new FormAttachment(0, 0);
+ *		data2.right = new FormAttachment(100, 0);
+ *		button2.setLayoutData(data2);
+ * </pre>
+ * </p>
+ * <p>
+ * Each side of a child control can be attached to a position in the parent 
+ * composite, or to other controls within the <code>Composite</code> by
+ * creating instances of <code>FormAttachment</code> and setting them into
+ * the top, bottom, left, and right fields of the child's <code>FormData</code>.
+ * </p>
+ * <p>
+ * If a side is not given an attachment, it is defined as not being attached
+ * to anything, causing the child to remain at its preferred size.  If a child
+ * is given no attachment on either the left or the right or top or bottom, it is
+ * automatically attached to the left and top of the composite respectively.
+ * The following code positions <code>button1</code> and <code>button2</code>
+ * but relies on default attachments:
+ * <pre>
+ *		FormData data2 = new FormData();
+ *		data2.left = new FormAttachment(button1);
+ *		data2.right = new FormAttachment(100, 0);
+ *		button2.setLayoutData(data2);
+ * </pre>
+ * </p>
+ * <p>
+ * IMPORTANT: Do not define circular attachments.  For example, do not attach
+ * the right edge of <code>button1</code> to the left edge of <code>button2</code>
+ * and then attach the left edge of <code>button2</code> to the right edge of
+ * <code>button1</code>.  This will over constrain the layout, causing undefined
+ * behavior.  The algorithm will terminate, but the results are undefined.
+ * </p>
+ * 
+ * @see FormData
+ * @see FormAttachment
+ * @see <a href="http://www.eclipse.org/swt/snippets/#formlayout">FormLayout snippets</a>
+ * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: LayoutExample</a>
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a> 
+ * 
+ * @since 2.0
+ */
+public final class FormLayout extends Layout {
+	
+	/**
+	 * marginWidth specifies the number of pixels of horizontal margin
+	 * that will be placed along the left and right edges of the layout.
+	 *
+	 * The default value is 0.
+	 */
+ 	public int marginWidth = 0;
+ 	
+	/**
+	 * marginHeight specifies the number of pixels of vertical margin
+	 * that will be placed along the top and bottom edges of the layout.
+	 *
+	 * The default value is 0.
+	 */
+ 	public int marginHeight = 0;
+ 
+
+ 	/**
+	 * marginLeft specifies the number of pixels of horizontal margin
+	 * that will be placed along the left edge of the layout.
+	 *
+	 * The default value is 0.
+	 * 
+	 * @since 3.1
+	 */
+	public int marginLeft = 0;
+
+	/**
+	 * marginTop specifies the number of pixels of vertical margin
+	 * that will be placed along the top edge of the layout.
+	 *
+	 * The default value is 0.
+	 * 
+	 * @since 3.1
+	 */
+	public int marginTop = 0;
+
+	/**
+	 * marginRight specifies the number of pixels of horizontal margin
+	 * that will be placed along the right edge of the layout.
+	 *
+	 * The default value is 0.
+	 * 
+	 * @since 3.1
+	 */
+	public int marginRight = 0;
+
+	/**
+	 * marginBottom specifies the number of pixels of vertical margin
+	 * that will be placed along the bottom edge of the layout.
+	 *
+	 * The default value is 0.
+	 * 
+	 * @since 3.1
+	 */
+	public int marginBottom = 0;
+
+	/**
+	 * spacing specifies the number of pixels between the edge of one control
+	 * and the edge of its neighbouring control.
+	 *
+	 * The default value is 0.
+	 * 
+	 * @since 3.0
+	 */
+	public int spacing = 0;
+	
+/**
+ * Constructs a new instance of this class.
+ */
+public FormLayout () {
+}
+
+/*
+ * Computes the preferred height of the form with
+ * respect to the preferred height of the control.
+ * 
+ * Given that the equations for top (T) and bottom (B)
+ * of the control in terms of the height of the form (X)
+ * are:
+ *		T = AX + B
+ *		B = CX + D
+ * 
+ * The equation for the height of the control (H)
+ * is bottom (B) minus top (T) or (H = B - T) or:
+ * 
+ *		H = (CX + D) - (AX + B)
+ * 
+ * Solving for (X), the height of the form, we get:
+ * 
+ *		X = (H + B - D) / (C - A)
+ * 
+ * When (A = C), (C - A = 0) and the equation has no
+ * solution for X.  This is a special case meaning that
+ * the control does not constrain the height of the
+ * form.  In this case, we need to arbitrarily define
+ * the height of the form (X):
+ * 
+ * Case 1: A = C, A = 0, C = 0
+ *
+ * 		Let X = D, the distance from the top of the form
+ * 		to the bottom edge of the control.  In this case,
+ * 		the control was attached to the top of the form
+ * 		and the form needs to be large enough to show the
+ * 		bottom edge of the control.
+ * 
+ * Case 2: A = C, A = 1, C = 1
+ * 
+ * 		Let X = -B, the distance from the bottom of the
+ *		form to the top edge of the control.  In this case,
+ * 		the control was attached to the bottom of the form
+ * 		and the only way that the control would be visible
+ * 		is if the offset is negative.  If the offset is
+ * 		positive, there is no possible height for the form
+ * 		that will show the control as it will always be
+ * 		below the bottom edge of the form.
+ * 
+ * Case 3: A = C, A != 0, C != 0 and A != 1, C != 0
+ * 
+ * 		Let X = D / (1 - C), the distance from the top of the 
+ * 		form to the bottom edge of the control.  In this case, 
+ * 		since C is not 0 or 1, it must be a fraction, U / V.  
+ * 		The offset D is the distance from CX to the bottom edge 
+ * 		of the control.  This represents a fraction of the form 
+ * 		(1 - C)X. Since the height of a fraction of the form is 
+ * 		known, the height of the entire form can be found by setting
+ * 		(1 - C)X = D.  We solve this equation for X in terms of U 
+ * 		and V, giving us X = (U * D) / (U - V). Similarly, if the 
+ * 		offset D is	negative, the control is positioned above CX.
+ * 		The offset -B is the distance from the top edge of the control
+ * 		to CX. We can find the height of the entire form by setting 
+ * 		CX = -B. Solving in terms of U and V gives us X = (-B * V) / U.
+ */
+int computeHeight (Control control, FormData data, boolean flushCache) {
+	FormAttachment top = data.getTopAttachment (control, spacing, flushCache);
+	FormAttachment bottom = data.getBottomAttachment (control, spacing, flushCache);
+	FormAttachment height = bottom.minus (top);
+	if (height.numerator == 0) {
+		if (bottom.numerator == 0) return bottom.offset;
+		if (bottom.numerator == bottom.denominator) return -top.offset;
+		if (bottom.offset <= 0) {
+			return -top.offset * top.denominator / bottom.numerator;
+		}
+		int divider = bottom.denominator - bottom.numerator; 
+		return bottom.denominator * bottom.offset / divider;
+	}
+	return height.solveY (data.getHeight (control, flushCache));
+}
+
+protected Point computeSize (Composite composite, int wHint, int hHint, boolean flushCache) {
+	Point size = layout (composite, false, 0, 0, wHint, hHint, flushCache);
+	if (wHint != SWT.DEFAULT) size.x = wHint;
+	if (hHint != SWT.DEFAULT) size.y = hHint;
+	return size;
+}
+
+protected boolean flushCache (Control control) {
+	Object data = control.getLayoutData ();
+	if (data != null) ((FormData) data).flushCache ();
+	return true;
+}
+
+String getName () {
+	String string = getClass ().getName ();
+	int index = string.lastIndexOf ('.');
+	if (index == -1) return string;
+	return string.substring (index + 1, string.length ());
+}
+
+/*
+ * Computes the preferred height of the form with
+ * respect to the preferred height of the control.
+ */
+int computeWidth (Control control, FormData data, boolean flushCache) {
+	FormAttachment left = data.getLeftAttachment (control, spacing, flushCache);
+	FormAttachment right = data.getRightAttachment (control, spacing, flushCache);
+	FormAttachment width = right.minus (left);
+	if (width.numerator == 0) {
+		if (right.numerator == 0) return right.offset;
+		if (right.numerator == right.denominator) return -left.offset;
+		if (right.offset <= 0) {
+			return -left.offset * left.denominator / left.numerator;
+		}
+		int divider = right.denominator - right.numerator; 
+		return right.denominator * right.offset / divider;
+	}
+	return width.solveY (data.getWidth (control, flushCache));
+}
+
+protected void layout (Composite composite, boolean flushCache) {
+	Rectangle rect = composite.getClientArea ();
+	int x = rect.x + marginLeft + marginWidth;
+	int y = rect.y + marginTop + marginHeight;
+	int width = Math.max (0, rect.width - marginLeft - 2 * marginWidth - marginRight);
+	int height = Math.max (0, rect.height - marginTop - 2 * marginHeight - marginBottom);
+	layout (composite, true, x, y, width, height, flushCache);
+}
+
+Point layout (Composite composite, boolean move, int x, int y, int width, int height, boolean flushCache) {
+	Control [] children = composite.getChildren ();
+	for (int i=0; i<children.length; i++) {
+		Control child = children [i];
+		FormData data = (FormData) child.getLayoutData ();
+		if (data == null) child.setLayoutData (data = new FormData ());
+		if (flushCache) data.flushCache ();
+		data.cacheLeft = data.cacheRight = data.cacheTop = data.cacheBottom = null;
+	}
+	boolean [] flush = null;
+	Rectangle [] bounds = null;
+	int w = 0, h = 0;
+	for (int i=0; i<children.length; i++) {
+		Control child = children [i];
+		FormData data = (FormData) child.getLayoutData ();
+		if (width != SWT.DEFAULT) {
+			data.needed = false;
+			FormAttachment left = data.getLeftAttachment (child, spacing, flushCache);
+			FormAttachment right = data.getRightAttachment (child, spacing, flushCache);
+			int x1 = left.solveX (width), x2 = right.solveX (width);
+			if (data.height == SWT.DEFAULT && !data.needed) {
+				int trim = 0;
+				//TEMPORARY CODE
+				if (child instanceof Scrollable) {
+					Rectangle rect = ((Scrollable) child).computeTrim (0, 0, 0, 0);
+					trim = rect.width;
+				} else {
+					trim = child.getBorderWidth () * 2;
+				}
+				data.cacheWidth = data.cacheHeight = -1;
+				int currentWidth = Math.max (0, x2 - x1 - trim);
+				data.computeSize (child, currentWidth, data.height, flushCache);
+				if (flush == null) flush = new boolean [children.length];
+				flush [i] = true;
+			}
+			w = Math.max (x2, w);
+			if (move) {
+				if (bounds == null) bounds = new Rectangle [children.length];
+				bounds [i] = new Rectangle (0, 0, 0, 0);
+				bounds [i].x = x + x1;
+				bounds [i].width = x2 - x1;
+			}
+		} else {
+			w = Math.max (computeWidth (child, data, flushCache), w);
+		}
+	}
+	for (int i=0; i<children.length; i++) {
+		Control child = children [i];
+		FormData data = (FormData) child.getLayoutData ();
+		if (height != SWT.DEFAULT) {
+			int y1 = data.getTopAttachment (child, spacing, flushCache).solveX (height);
+			int y2 = data.getBottomAttachment (child, spacing, flushCache).solveX (height);
+			h = Math.max (y2, h);
+			if (move) {
+				bounds [i].y = y + y1;
+				bounds [i].height = y2 - y1;
+			}
+		} else {
+			h = Math.max (computeHeight (child, data, flushCache), h);
+		}
+	}
+	for (int i=0; i<children.length; i++) {
+		Control child = children [i];
+		FormData data = (FormData) child.getLayoutData ();
+		if (flush != null && flush [i]) data.cacheWidth = data.cacheHeight = -1;
+		data.cacheLeft = data.cacheRight = data.cacheTop = data.cacheBottom = null;
+	}
+	if (move) {
+		for (int i=0; i<children.length; i++) {
+			children [i].setBounds (bounds [i]);
+		}
+	}
+	w += marginLeft + marginWidth * 2 + marginRight;
+	h += marginTop + marginHeight * 2 + marginBottom;
+	return new Point (w, h);
+}
+
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the layout
+ */
+public String toString () {
+ 	String string =  getName ()+" {";
+ 	if (marginWidth != 0) string += "marginWidth="+marginWidth+" ";
+ 	if (marginHeight != 0) string += "marginHeight="+marginHeight+" ";
+ 	if (marginLeft != 0) string += "marginLeft="+marginLeft+" ";
+ 	if (marginRight != 0) string += "marginRight="+marginRight+" ";
+ 	if (marginTop != 0) string += "marginTop="+marginTop+" ";
+ 	if (marginBottom != 0) string += "marginBottom="+marginBottom+" ";
+ 	if (spacing != 0) string += "spacing="+spacing+" ";
+ 	string = string.trim();
+ 	string += "}";
+ 	return string;
+}	
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/layout/GridData.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/layout/GridData.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/layout/GridData.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,566 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.layout;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+
+/**
+ * <code>GridData</code> is the layout data object associated with 
+ * <code>GridLayout</code>. To set a <code>GridData</code> object into a 
+ * control, you use the <code>Control.setLayoutData(Object)</code> method. 
+ * <p>
+ * There are two ways to create a <code>GridData</code> object with certain 
+ * fields set. The first is to set the fields directly, like this:
+ * <pre>
+ * 		GridData gridData = new GridData();
+ * 		gridData.horizontalAlignment = GridData.FILL;
+ * 		gridData.grabExcessHorizontalSpace = true;
+ * 		button1.setLayoutData(gridData);
+ * </pre>
+ * The second is to take advantage of convenience style bits defined 
+ * by <code>GridData</code>:
+ * <pre>
+ *      button1.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL));
+ * </pre>
+ * </p>
+ * <p>
+ * NOTE: Do not reuse <code>GridData</code> objects. Every control in a 
+ * <code>Composite</code> that is managed by a <code>GridLayout</code>
+ * must have a unique <code>GridData</code> object. If the layout data 
+ * for a control in a <code>GridLayout</code> is null at layout time, 
+ * a unique <code>GridData</code> object is created for it.
+ * </p>
+ * 
+ * @see GridLayout
+ * @see Control#setLayoutData
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public final class GridData {
+	/**
+	 * verticalAlignment specifies how controls will be positioned 
+	 * vertically within a cell. 
+	 *
+	 * The default value is CENTER.
+	 *
+	 * Possible values are: <ul>
+	 *    <li>SWT.BEGINNING (or SWT.TOP): Position the control at the top of the cell</li>
+	 *    <li>SWT.CENTER: Position the control in the vertical center of the cell</li>
+	 *    <li>SWT.END (or SWT.BOTTOM): Position the control at the bottom of the cell</li>
+	 *    <li>SWT.FILL: Resize the control to fill the cell vertically</li>
+	 * </ul>
+	 */
+	public int verticalAlignment = CENTER;
+	
+	/**
+	 * horizontalAlignment specifies how controls will be positioned 
+	 * horizontally within a cell. 
+	 *
+	 * The default value is BEGINNING.
+	 *
+	 * Possible values are: <ul>
+	 *    <li>SWT.BEGINNING (or SWT.LEFT): Position the control at the left of the cell</li>
+	 *    <li>SWT.CENTER: Position the control in the horizontal center of the cell</li>
+	 *    <li>SWT.END (or SWT.RIGHT): Position the control at the right of the cell</li>
+	 *    <li>SWT.FILL: Resize the control to fill the cell horizontally</li>
+	 * </ul>
+	 */
+	public int horizontalAlignment = BEGINNING;
+	
+	/**
+	 * widthHint specifies the preferred width in pixels. This value
+	 * is the wHint passed into Control.computeSize(int, int, boolean) 
+	 * to determine the preferred size of the control.
+	 *
+	 * The default value is SWT.DEFAULT.
+	 * 
+	 * @see Control#computeSize(int, int, boolean)
+	 */
+	public int widthHint = SWT.DEFAULT;
+	
+	/**
+	 * heightHint specifies the preferred height in pixels. This value
+	 * is the hHint passed into Control.computeSize(int, int, boolean) 
+	 * to determine the preferred size of the control.
+	 *
+	 * The default value is SWT.DEFAULT.
+	 * 
+	 * @see Control#computeSize(int, int, boolean)
+	 */
+	public int heightHint = SWT.DEFAULT;
+	
+	/**
+	 * horizontalIndent specifies the number of pixels of indentation
+	 * that will be placed along the left side of the cell.
+	 *
+	 * The default value is 0.
+	 */
+	public int horizontalIndent = 0;
+	
+	/**
+	 * verticalIndent specifies the number of pixels of indentation
+	 * that will be placed along the top side of the cell.
+	 *
+	 * The default value is 0.
+	 * 
+	 * @since 3.1
+	 */
+	public int verticalIndent = 0;
+	
+	/**
+	 * horizontalSpan specifies the number of column cells that the control
+	 * will take up.
+	 *
+	 * The default value is 1.
+	 */
+	public int horizontalSpan = 1;
+	
+	/**
+	 * verticalSpan specifies the number of row cells that the control
+	 * will take up.
+	 *
+	 * The default value is 1.
+	 */
+	public int verticalSpan = 1;
+	
+	/**
+	 * <p>grabExcessHorizontalSpace specifies whether the width of the cell 
+	 * changes depending on the size of the parent Composite.  If 
+	 * grabExcessHorizontalSpace is <code>true</code>, the following rules
+	 * apply to the width of the cell:</p>
+	 * <ul>
+	 * <li>If extra horizontal space is available in the parent, the cell will 
+	 * grow to be wider than its preferred width.  The new width 
+	 * will be "preferred width + delta" where delta is the extra 
+	 * horizontal space divided by the number of grabbing columns.</li>
+	 * <li>If there is not enough horizontal space available in the parent, the 
+	 * cell will shrink until it reaches its minimum width as specified by 
+	 * GridData.minimumWidth. The new width will be the maximum of 
+	 * "minimumWidth" and "preferred width - delta", where delta is 
+	 * the amount of space missing divided by the number of grabbing columns.</li>
+	 * <li>If the parent is packed, the cell will be its preferred width 
+	 * as specified by GridData.widthHint.</li>
+	 * <li>If the control spans multiple columns and there are no other grabbing 
+	 * controls in any of the spanned columns, the last column in the span will
+	 * grab the extra space.  If there is at least one other grabbing control
+	 * in the span, the grabbing will be spread over the columns already 
+	 * marked as grabExcessHorizontalSpace.</li>
+	 * </ul>
+	 * 
+	 * <p>The default value is false.</p>
+	 * 
+	 * @see GridData#minimumWidth
+	 * @see GridData#widthHint
+	 */	
+	public boolean grabExcessHorizontalSpace = false;
+	
+	/**
+	 * <p>grabExcessVerticalSpace specifies whether the height of the cell 
+	 * changes depending on the size of the parent Composite.  If 
+	 * grabExcessVerticalSpace is <code>true</code>, the following rules
+	 * apply to the height of the cell:</p>
+	 * <ul>
+	 * <li>If extra vertical space is available in the parent, the cell will 
+	 * grow to be taller than its preferred height.  The new height 
+	 * will be "preferred height + delta" where delta is the extra 
+	 * vertical space divided by the number of grabbing rows.</li>
+	 * <li>If there is not enough vertical space available in the parent, the 
+	 * cell will shrink until it reaches its minimum height as specified by 
+	 * GridData.minimumHeight. The new height will be the maximum of 
+	 * "minimumHeight" and "preferred height - delta", where delta is 
+	 * the amount of space missing divided by the number of grabbing rows.</li>
+	 * <li>If the parent is packed, the cell will be its preferred height 
+	 * as specified by GridData.heightHint.</li>
+	 * <li>If the control spans multiple rows and there are no other grabbing 
+	 * controls in any of the spanned rows, the last row in the span will
+	 * grab the extra space.  If there is at least one other grabbing control
+	 * in the span, the grabbing will be spread over the rows already 
+	 * marked as grabExcessVerticalSpace.</li>
+	 * </ul>
+	 * 
+	 * <p>The default value is false.</p>
+	 * 
+	 * @see GridData#minimumHeight
+	 * @see GridData#heightHint
+	 */	
+	public boolean grabExcessVerticalSpace = false;
+
+	/**
+	 * minimumWidth specifies the minimum width in pixels.  This value
+	 * applies only if grabExcessHorizontalSpace is true. A value of 
+	 * SWT.DEFAULT means that the minimum width will be the result
+	 * of Control.computeSize(int, int, boolean) where wHint is 
+	 * determined by GridData.widthHint.
+	 *
+	 * The default value is 0.
+	 *
+	 * @since 3.1
+	 * @see Control#computeSize(int, int, boolean)
+	 * @see GridData#widthHint
+	 */
+	public int minimumWidth = 0;
+	
+	/**
+	 * minimumHeight specifies the minimum height in pixels.  This value
+	 * applies only if grabExcessVerticalSpace is true.  A value of 
+	 * SWT.DEFAULT means that the minimum height will be the result
+	 * of Control.computeSize(int, int, boolean) where hHint is 
+	 * determined by GridData.heightHint.
+	 *
+	 * The default value is 0.
+	 *
+	 * @since 3.1
+	 * @see Control#computeSize(int, int, boolean)
+	 * @see GridData#heightHint
+	 */
+	public int minimumHeight = 0;
+	
+	/**
+	 * exclude informs the layout to ignore this control when sizing
+	 * and positioning controls.  If this value is <code>true</code>,
+	 * the size and position of the control will not be managed by the
+	 * layout.  If this	value is <code>false</code>, the size and 
+	 * position of the control will be computed and assigned.
+	 * 
+	 * The default value is <code>false</code>.
+	 * 
+	 * @since 3.1
+	 */
+	public boolean exclude = false;
+	
+	/**
+	 * Value for horizontalAlignment or verticalAlignment.
+	 * Position the control at the top or left of the cell.
+	 * Not recommended. Use SWT.BEGINNING, SWT.TOP or SWT.LEFT instead.
+	 */
+	public static final int BEGINNING = SWT.BEGINNING;
+	
+	/**
+	 * Value for horizontalAlignment or verticalAlignment.
+	 * Position the control in the vertical or horizontal center of the cell
+	 * Not recommended. Use SWT.CENTER instead.
+	 */
+	public static final int CENTER = 2;
+	
+	/**
+	 * Value for horizontalAlignment or verticalAlignment.
+	 * Position the control at the bottom or right of the cell
+	 * Not recommended. Use SWT.END, SWT.BOTTOM or SWT.RIGHT instead.
+	 */
+	public static final int END = 3;
+	
+	/**
+	 * Value for horizontalAlignment or verticalAlignment.
+	 * Resize the control to fill the cell horizontally or vertically.
+	 * Not recommended. Use SWT.FILL instead.
+	 */
+	public static final int FILL = SWT.FILL;
+
+	/**
+	 * Style bit for <code>new GridData(int)</code>.
+	 * Position the control at the top of the cell.
+	 * Not recommended. Use 
+	 * <code>new GridData(int, SWT.BEGINNING, boolean, boolean)</code>
+	 * instead.
+	 */
+	public static final int VERTICAL_ALIGN_BEGINNING =  1 << 1;
+	
+	/**
+	 * Style bit for <code>new GridData(int)</code> to position the 
+	 * control in the vertical center of the cell.
+	 * Not recommended. Use
+	 * <code>new GridData(int, SWT.CENTER, boolean, boolean)</code>
+	 * instead.
+	 */
+	public static final int VERTICAL_ALIGN_CENTER = 1 << 2;
+	
+	/**
+	 * Style bit for <code>new GridData(int)</code> to position the 
+	 * control at the bottom of the cell.
+	 * Not recommended. Use
+	 * <code>new GridData(int, SWT.END, boolean, boolean)</code>
+	 * instead.
+	 */
+	public static final int VERTICAL_ALIGN_END = 1 << 3;
+	
+	/**
+	 * Style bit for <code>new GridData(int)</code> to resize the 
+	 * control to fill the cell vertically.
+	 * Not recommended. Use
+	 * <code>new GridData(int, SWT.FILL, boolean, boolean)</code>
+	 * instead
+	 */
+	public static final int VERTICAL_ALIGN_FILL = 1 << 4;
+	
+	/**
+	 * Style bit for <code>new GridData(int)</code> to position the 
+	 * control at the left of the cell.
+	 * Not recommended. Use
+	 * <code>new GridData(SWT.BEGINNING, int, boolean, boolean)</code>
+	 * instead.
+	 */
+	public static final int HORIZONTAL_ALIGN_BEGINNING =  1 << 5;
+	
+	/**
+	 * Style bit for <code>new GridData(int)</code> to position the 
+	 * control in the horizontal center of the cell.
+	 * Not recommended. Use
+	 * <code>new GridData(SWT.CENTER, int, boolean, boolean)</code>
+	 * instead.
+	 */
+	public static final int HORIZONTAL_ALIGN_CENTER = 1 << 6;
+	
+	/**
+	 * Style bit for <code>new GridData(int)</code> to position the 
+	 * control at the right of the cell.
+	 * Not recommended. Use
+	 * <code>new GridData(SWT.END, int, boolean, boolean)</code>
+	 * instead.
+	 */
+	public static final int HORIZONTAL_ALIGN_END = 1 << 7;
+	
+	/**
+	 * Style bit for <code>new GridData(int)</code> to resize the 
+	 * control to fill the cell horizontally.
+	 * Not recommended. Use
+	 * <code>new GridData(SWT.FILL, int, boolean, boolean)</code>
+	 * instead.
+	 */
+	public static final int HORIZONTAL_ALIGN_FILL = 1 << 8;
+	
+	/**
+	 * Style bit for <code>new GridData(int)</code> to resize the 
+	 * control to fit the remaining horizontal space.
+	 * Not recommended. Use
+	 * <code>new GridData(int, int, true, boolean)</code>
+	 * instead.
+	 */
+	public static final int GRAB_HORIZONTAL = 1 << 9;
+	
+	/**
+	 * Style bit for <code>new GridData(int)</code> to resize the 
+	 * control to fit the remaining vertical space.
+	 * Not recommended. Use
+	 * <code>new GridData(int, int, boolean, true)</code>
+	 * instead.
+	 */
+	public static final int GRAB_VERTICAL = 1 << 10;
+	
+	/**
+	 * Style bit for <code>new GridData(int)</code> to resize the 
+	 * control to fill the cell vertically and to fit the remaining
+	 * vertical space.
+	 * FILL_VERTICAL = VERTICAL_ALIGN_FILL | GRAB_VERTICAL
+	 * Not recommended. Use
+	 * <code>new GridData(int, SWT.FILL, boolean, true)</code>
+	 * instead.
+	 */	
+	public static final int FILL_VERTICAL = VERTICAL_ALIGN_FILL | GRAB_VERTICAL;
+	
+	/**
+	 * Style bit for <code>new GridData(int)</code> to resize the 
+	 * control to fill the cell horizontally and to fit the remaining
+	 * horizontal space.
+	 * FILL_HORIZONTAL = HORIZONTAL_ALIGN_FILL | GRAB_HORIZONTAL
+	 * Not recommended. Use
+	 * <code>new GridData(SWT.FILL, int, true, boolean)</code>
+	 * instead.
+	 */	
+	public static final int FILL_HORIZONTAL = HORIZONTAL_ALIGN_FILL | GRAB_HORIZONTAL;
+	
+	/**
+	 * Style bit for <code>new GridData(int)</code> to resize the 
+	 * control to fill the cell horizontally and vertically and 
+	 * to fit the remaining horizontal and vertical space.
+	 * FILL_BOTH = FILL_VERTICAL | FILL_HORIZONTAL
+	 * Not recommended. Use
+	 * <code>new GridData(SWT.FILL, SWT.FILL, true, true)</code>
+	 * instead.
+	 */	
+	public static final int FILL_BOTH = FILL_VERTICAL | FILL_HORIZONTAL;
+
+	int cacheWidth = -1, cacheHeight = -1;
+	int defaultWhint, defaultHhint, defaultWidth = -1, defaultHeight = -1;
+	int currentWhint, currentHhint, currentWidth = -1, currentHeight = -1;
+
+/**
+ * Constructs a new instance of GridData using
+ * default values.
+ */
+public GridData () {
+	super ();
+}
+
+/**
+ * Constructs a new instance based on the GridData style.
+ * This constructor is not recommended.
+ * 
+ * @param style the GridData style
+ */
+public GridData (int style) {
+	super ();
+	if ((style & VERTICAL_ALIGN_BEGINNING) != 0) verticalAlignment = BEGINNING;
+	if ((style & VERTICAL_ALIGN_CENTER) != 0) verticalAlignment = CENTER;
+	if ((style & VERTICAL_ALIGN_FILL) != 0) verticalAlignment = FILL;
+	if ((style & VERTICAL_ALIGN_END) != 0) verticalAlignment = END;
+	if ((style & HORIZONTAL_ALIGN_BEGINNING) != 0) horizontalAlignment = BEGINNING;
+	if ((style & HORIZONTAL_ALIGN_CENTER) != 0) horizontalAlignment = CENTER;
+	if ((style & HORIZONTAL_ALIGN_FILL) != 0) horizontalAlignment = FILL;
+	if ((style & HORIZONTAL_ALIGN_END) != 0) horizontalAlignment = END;
+	grabExcessHorizontalSpace = (style & GRAB_HORIZONTAL) != 0;
+	grabExcessVerticalSpace = (style & GRAB_VERTICAL) != 0;
+}
+
+/**
+ * Constructs a new instance of GridData according to the parameters.
+ * 
+ * @param horizontalAlignment how control will be positioned horizontally within a cell,
+ * 		one of: SWT.BEGINNING (or SWT.LEFT), SWT.CENTER, SWT.END (or SWT.RIGHT), or SWT.FILL
+ * @param verticalAlignment how control will be positioned vertically within a cell,
+ * 		one of: SWT.BEGINNING (or SWT.TOP), SWT.CENTER, SWT.END (or SWT.BOTTOM), or SWT.FILL
+ * @param grabExcessHorizontalSpace whether cell will be made wide enough to fit the remaining horizontal space
+ * @param grabExcessVerticalSpace whether cell will be made high enough to fit the remaining vertical space
+ * 
+ * @since 3.0
+ */
+public GridData (int horizontalAlignment, int verticalAlignment, boolean grabExcessHorizontalSpace, boolean grabExcessVerticalSpace) {
+	this (horizontalAlignment, verticalAlignment, grabExcessHorizontalSpace, grabExcessVerticalSpace, 1, 1);
+}
+
+/**
+ * Constructs a new instance of GridData according to the parameters.
+ *  
+ * @param horizontalAlignment how control will be positioned horizontally within a cell,
+ * 		one of: SWT.BEGINNING (or SWT.LEFT), SWT.CENTER, SWT.END (or SWT.RIGHT), or SWT.FILL
+ * @param verticalAlignment how control will be positioned vertically within a cell,
+ * 		one of: SWT.BEGINNING (or SWT.TOP), SWT.CENTER, SWT.END (or SWT.BOTTOM), or SWT.FILL
+ * @param grabExcessHorizontalSpace whether cell will be made wide enough to fit the remaining horizontal space
+ * @param grabExcessVerticalSpace whether cell will be made high enough to fit the remaining vertical space
+ * @param horizontalSpan the number of column cells that the control will take up
+ * @param verticalSpan the number of row cells that the control will take up
+ * 
+ * @since 3.0
+ */
+public GridData (int horizontalAlignment, int verticalAlignment, boolean grabExcessHorizontalSpace, boolean grabExcessVerticalSpace, int horizontalSpan, int verticalSpan) {
+	super ();
+	this.horizontalAlignment = horizontalAlignment;
+	this.verticalAlignment = verticalAlignment;
+	this.grabExcessHorizontalSpace = grabExcessHorizontalSpace;
+	this.grabExcessVerticalSpace = grabExcessVerticalSpace;
+	this.horizontalSpan = horizontalSpan;
+	this.verticalSpan = verticalSpan;
+}
+
+/**
+ * Constructs a new instance of GridData according to the parameters.
+ * A value of SWT.DEFAULT indicates that no minimum width or
+ * no minimum height is specified.
+ * 
+ * @param width a minimum width for the column
+ * @param height a minimum height for the row
+ * 
+ * @since 3.0
+ */
+public GridData (int width, int height) {
+	super ();
+	this.widthHint = width;
+	this.heightHint = height;
+}
+
+void computeSize (Control control, int wHint, int hHint, boolean flushCache) {
+	if (cacheWidth != -1 && cacheHeight != -1) return;
+	if (wHint == this.widthHint && hHint == this.heightHint) {
+		if (defaultWidth == -1 || defaultHeight == -1 || wHint != defaultWhint || hHint != defaultHhint) {
+			Point size = control.computeSize (wHint, hHint, flushCache);
+			defaultWhint = wHint;
+			defaultHhint = hHint;
+			defaultWidth = size.x;
+			defaultHeight = size.y;
+		}
+		cacheWidth = defaultWidth;
+		cacheHeight = defaultHeight;
+		return;
+	}
+	if (currentWidth == -1 || currentHeight == -1 || wHint != currentWhint || hHint != currentHhint) {
+		Point size = control.computeSize (wHint, hHint, flushCache);
+		currentWhint = wHint;
+		currentHhint = hHint;
+		currentWidth = size.x;
+		currentHeight = size.y;
+	}
+	cacheWidth = currentWidth;
+	cacheHeight = currentHeight;
+}
+
+void flushCache () {
+	cacheWidth = cacheHeight = -1;
+	defaultWidth = defaultHeight = -1;
+	currentWidth = currentHeight = -1;
+}
+
+String getName () {
+	String string = getClass ().getName ();
+	int index = string.lastIndexOf ('.');
+	if (index == -1) return string;
+	return string.substring (index + 1, string.length ());
+}
+
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the GridData object
+ */
+public String toString () {
+	String hAlign = "";
+	switch (horizontalAlignment) {
+		case SWT.FILL: hAlign = "SWT.FILL"; break;
+		case SWT.BEGINNING: hAlign = "SWT.BEGINNING"; break;
+		case SWT.LEFT: hAlign = "SWT.LEFT"; break;
+		case SWT.END: hAlign = "SWT.END"; break;
+		case END: hAlign = "GridData.END"; break;
+		case SWT.RIGHT: hAlign = "SWT.RIGHT"; break;
+		case SWT.CENTER: hAlign = "SWT.CENTER"; break;
+		case CENTER: hAlign = "GridData.CENTER"; break;
+		default: hAlign = "Undefined "+horizontalAlignment; break;
+	}
+	String vAlign = "";
+	switch (verticalAlignment) {
+		case SWT.FILL: vAlign = "SWT.FILL"; break;
+		case SWT.BEGINNING: vAlign = "SWT.BEGINNING"; break;
+		case SWT.TOP: vAlign = "SWT.TOP"; break;
+		case SWT.END: vAlign = "SWT.END"; break;
+		case END: vAlign = "GridData.END"; break;
+		case SWT.BOTTOM: vAlign = "SWT.BOTTOM"; break;
+		case SWT.CENTER: vAlign = "SWT.CENTER"; break;
+		case CENTER: vAlign = "GridData.CENTER"; break;
+		default: vAlign = "Undefined "+verticalAlignment; break;
+	}
+ 	String string = getName()+" {";
+ 	string += "horizontalAlignment="+hAlign+" ";
+ 	if (horizontalIndent != 0) string += "horizontalIndent="+horizontalIndent+" ";
+ 	if (horizontalSpan != 1) string += "horizontalSpan="+horizontalSpan+" ";
+ 	if (grabExcessHorizontalSpace) string += "grabExcessHorizontalSpace="+grabExcessHorizontalSpace+" ";
+ 	if (widthHint != SWT.DEFAULT) string += "widthHint="+widthHint+" ";
+ 	if (minimumWidth != 0) string += "minimumWidth="+minimumWidth+" ";
+ 	string += "verticalAlignment="+vAlign+" ";
+ 	if (verticalIndent != 0) string += "verticalIndent="+verticalIndent+" ";
+	if (verticalSpan != 1) string += "verticalSpan="+verticalSpan+" ";
+ 	if (grabExcessVerticalSpace) string += "grabExcessVerticalSpace="+grabExcessVerticalSpace+" ";
+ 	if (heightHint != SWT.DEFAULT) string += "heightHint="+heightHint+" ";
+ 	if (minimumHeight != 0) string += "minimumHeight="+minimumHeight+" ";
+ 	if (exclude) string += "exclude="+exclude+" ";
+ 	string = string.trim();
+ 	string += "}";
+	return string;
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/layout/GridLayout.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/layout/GridLayout.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/layout/GridLayout.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,745 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.layout;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+
+/**
+ * Instances of this class lay out the control children of a 
+ * <code>Composite</code> in a grid. 
+ * <p>
+ * <code>GridLayout</code> has a number of configuration fields, and the 
+ * controls it lays out can have an associated layout data object, called 
+ * <code>GridData</code>. The power of <code>GridLayout</code> lies in the 
+ * ability to configure <code>GridData</code> for each control in the layout. 
+ * </p>
+ * <p>
+ * The following code creates a shell managed by a <code>GridLayout</code>
+ * with 3 columns:
+ * <pre>
+ * 		Display display = new Display();
+ * 		Shell shell = new Shell(display);
+ * 		GridLayout gridLayout = new GridLayout();
+ * 		gridLayout.numColumns = 3;
+ * 		shell.setLayout(gridLayout);
+ * </pre>
+ * The <code>numColumns</code> field is the most important field in a 
+ * <code>GridLayout</code>. Widgets are laid out in columns from left 
+ * to right, and a new row is created when <code>numColumns</code> + 1 
+ * controls are added to the <code>Composite<code>.
+ * </p>
+ * 
+ * @see GridData
+ * @see <a href="http://www.eclipse.org/swt/snippets/#gridlayout">GridLayout snippets</a>
+ * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: LayoutExample</a>
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public final class GridLayout extends Layout {
+ 
+ 	/**
+ 	 * numColumns specifies the number of cell columns in the layout.
+ 	 * If numColumns has a value less than 1, the layout will not
+ 	 * set the size and position of any controls.
+ 	 *
+ 	 * The default value is 1.
+ 	 */
+	public int numColumns = 1;
+
+	/**
+	 * makeColumnsEqualWidth specifies whether all columns in the layout
+	 * will be forced to have the same width.
+	 *
+	 * The default value is false.
+	 */
+	public boolean makeColumnsEqualWidth = false;
+	
+	/**
+	 * marginWidth specifies the number of pixels of horizontal margin
+	 * that will be placed along the left and right edges of the layout.
+	 *
+	 * The default value is 5.
+	 */
+ 	public int marginWidth = 5;
+ 	
+	/**
+	 * marginHeight specifies the number of pixels of vertical margin
+	 * that will be placed along the top and bottom edges of the layout.
+	 *
+	 * The default value is 5.
+	 */
+ 	public int marginHeight = 5;
+
+ 	/**
+	 * marginLeft specifies the number of pixels of horizontal margin
+	 * that will be placed along the left edge of the layout.
+	 *
+	 * The default value is 0.
+	 * 
+	 * @since 3.1
+	 */
+	public int marginLeft = 0;
+
+	/**
+	 * marginTop specifies the number of pixels of vertical margin
+	 * that will be placed along the top edge of the layout.
+	 *
+	 * The default value is 0.
+	 * 
+	 * @since 3.1
+	 */
+	public int marginTop = 0;
+
+	/**
+	 * marginRight specifies the number of pixels of horizontal margin
+	 * that will be placed along the right edge of the layout.
+	 *
+	 * The default value is 0.
+	 * 
+	 * @since 3.1
+	 */
+	public int marginRight = 0;
+
+	/**
+	 * marginBottom specifies the number of pixels of vertical margin
+	 * that will be placed along the bottom edge of the layout.
+	 *
+	 * The default value is 0.
+	 * 
+	 * @since 3.1
+	 */
+	public int marginBottom = 0;
+
+	/**
+	 * horizontalSpacing specifies the number of pixels between the right
+	 * edge of one cell and the left edge of its neighbouring cell to
+	 * the right.
+	 *
+	 * The default value is 5.
+	 */
+ 	public int horizontalSpacing = 5;
+
+	/**
+	 * verticalSpacing specifies the number of pixels between the bottom
+	 * edge of one cell and the top edge of its neighbouring cell underneath.
+	 *
+	 * The default value is 5.
+	 */
+ 	public int verticalSpacing = 5;
+ 
+/**
+ * Constructs a new instance of this class.
+ */
+public GridLayout () {}
+
+/**
+ * Constructs a new instance of this class given the
+ * number of columns, and whether or not the columns
+ * should be forced to have the same width.
+ * If numColumns has a value less than 1, the layout will not
+ * set the size and position of any controls.
+ *
+ * @param numColumns the number of columns in the grid
+ * @param makeColumnsEqualWidth whether or not the columns will have equal width
+ * 
+ * @since 2.0
+ */
+public GridLayout (int numColumns, boolean makeColumnsEqualWidth) {
+	this.numColumns = numColumns;
+	this.makeColumnsEqualWidth = makeColumnsEqualWidth;
+}
+
+protected Point computeSize (Composite composite, int wHint, int hHint, boolean flushCache) {
+	Point size = layout (composite, false, 0, 0, wHint, hHint, flushCache);
+	if (wHint != SWT.DEFAULT) size.x = wHint;
+	if (hHint != SWT.DEFAULT) size.y = hHint;
+	return size;
+}
+
+protected boolean flushCache (Control control) {
+	Object data = control.getLayoutData ();
+	if (data != null) ((GridData) data).flushCache ();
+	return true;
+}
+
+GridData getData (Control [][] grid, int row, int column, int rowCount, int columnCount, boolean first) {
+	Control control = grid [row] [column];
+	if (control != null) {
+		GridData data = (GridData) control.getLayoutData ();
+		int hSpan = Math.max (1, Math.min (data.horizontalSpan, columnCount));
+		int vSpan = Math.max (1, data.verticalSpan);
+		int i = first ? row + vSpan - 1 : row - vSpan + 1;
+		int j = first ? column + hSpan - 1 : column - hSpan + 1;
+		if (0 <= i && i < rowCount) {
+			if (0 <= j && j < columnCount) {
+				if (control == grid [i][j]) return data;
+			}
+		}
+	}
+	return null;
+}
+
+protected void layout (Composite composite, boolean flushCache) {
+	Rectangle rect = composite.getClientArea ();
+	layout (composite, true, rect.x, rect.y, rect.width, rect.height, flushCache);
+}
+
+Point layout (Composite composite, boolean move, int x, int y, int width, int height, boolean flushCache) {
+	if (numColumns < 1) {
+		return new Point (marginLeft + marginWidth * 2 + marginRight, marginTop + marginHeight * 2 + marginBottom);
+	}
+	Control [] children = composite.getChildren ();
+	int count = 0;
+	for (int i=0; i<children.length; i++) {
+		Control control = children [i];
+		GridData data = (GridData) control.getLayoutData ();
+		if (data == null || !data.exclude) {
+			children [count++] = children [i];
+		} 
+	}
+	if (count == 0) {
+		return new Point (marginLeft + marginWidth * 2 + marginRight, marginTop + marginHeight * 2 + marginBottom);
+	}
+	for (int i=0; i<count; i++) {
+		Control child = children [i];
+		GridData data = (GridData) child.getLayoutData ();
+		if (data == null) child.setLayoutData (data = new GridData ());
+		if (flushCache) data.flushCache ();
+		data.computeSize (child, data.widthHint, data.heightHint, flushCache);
+		if (data.grabExcessHorizontalSpace && data.minimumWidth > 0) {
+			if (data.cacheWidth < data.minimumWidth) {
+				int trim = 0;
+				//TEMPORARY CODE
+				if (child instanceof Scrollable) {
+					Rectangle rect = ((Scrollable) child).computeTrim (0, 0, 0, 0);
+					trim = rect.width;
+				} else {
+					trim = child.getBorderWidth () * 2;
+				}
+				data.cacheWidth = data.cacheHeight = SWT.DEFAULT;
+				data.computeSize (child, Math.max (0, data.minimumWidth - trim), data.heightHint, false);
+			}
+		}
+		if (data.grabExcessVerticalSpace && data.minimumHeight > 0) {
+			data.cacheHeight = Math.max (data.cacheHeight, data.minimumHeight);
+		}
+	}
+
+	/* Build the grid */
+	int row = 0, column = 0, rowCount = 0, columnCount = numColumns;
+	Control [][] grid = new Control [4] [columnCount];
+	for (int i=0; i<count; i++) {	
+		Control child = children [i];
+		GridData data = (GridData) child.getLayoutData ();
+		int hSpan = Math.max (1, Math.min (data.horizontalSpan, columnCount));
+		int vSpan = Math.max (1, data.verticalSpan);
+		while (true) {
+			int lastRow = row + vSpan;
+			if (lastRow >= grid.length) {
+				Control [][] newGrid = new Control [lastRow + 4] [columnCount];
+				System.arraycopy (grid, 0, newGrid, 0, grid.length);
+				grid = newGrid;
+			}
+			if (grid [row] == null) {
+				grid [row] = new Control [columnCount];
+			}
+			while (column < columnCount && grid [row] [column] != null) {
+				column++;
+			}
+			int endCount = column + hSpan;
+			if (endCount <= columnCount) {
+				int index = column;
+				while (index < endCount && grid [row] [index] == null) {
+					index++;
+				}
+				if (index == endCount) break;
+				column = index;
+			}
+			if (column + hSpan >= columnCount) {
+				column = 0;
+				row++;
+			}
+		}
+		for (int j=0; j<vSpan; j++) {
+			if (grid [row + j] == null) {
+				grid [row + j] = new Control [columnCount];
+			}
+			for (int k=0; k<hSpan; k++) {
+				grid [row + j] [column + k] = child;
+			}
+		}
+		rowCount = Math.max (rowCount, row + vSpan);
+		column += hSpan;
+	}
+
+	/* Column widths */
+	int availableWidth = width - horizontalSpacing * (columnCount - 1) - (marginLeft + marginWidth * 2 + marginRight);
+	int expandCount = 0;
+	int [] widths = new int [columnCount];
+	int [] minWidths = new int [columnCount];
+	boolean [] expandColumn = new boolean [columnCount];
+	for (int j=0; j<columnCount; j++) {
+		for (int i=0; i<rowCount; i++) {
+			GridData data = getData (grid, i, j, rowCount, columnCount, true);
+			if (data != null) {
+				int hSpan = Math.max (1, Math.min (data.horizontalSpan, columnCount));
+				if (hSpan == 1) {
+					int w = data.cacheWidth + data.horizontalIndent;
+					widths [j] = Math.max (widths [j], w);
+					if (data.grabExcessHorizontalSpace) {
+						if (!expandColumn [j]) expandCount++;
+						expandColumn [j] = true;
+					}
+					if (!data.grabExcessHorizontalSpace || data.minimumWidth != 0) {
+						w = !data.grabExcessHorizontalSpace || data.minimumWidth == SWT.DEFAULT ? data.cacheWidth : data.minimumWidth;
+						w += data.horizontalIndent;
+						minWidths [j] = Math.max (minWidths [j], w);
+					}
+				}
+			}
+		}
+		for (int i=0; i<rowCount; i++) {
+			GridData data = getData (grid, i, j, rowCount, columnCount, false);
+			if (data != null) {
+				int hSpan = Math.max (1, Math.min (data.horizontalSpan, columnCount));
+				if (hSpan > 1) {
+					int spanWidth = 0, spanMinWidth = 0, spanExpandCount = 0;
+					for (int k=0; k<hSpan; k++) {
+						spanWidth += widths [j-k];
+						spanMinWidth += minWidths [j-k];
+						if (expandColumn [j-k]) spanExpandCount++;
+					}
+					if (data.grabExcessHorizontalSpace && spanExpandCount == 0) {
+						expandCount++;
+						expandColumn [j] = true;
+					}
+					int w = data.cacheWidth + data.horizontalIndent - spanWidth - (hSpan - 1) * horizontalSpacing;
+					if (w > 0) {
+						if (makeColumnsEqualWidth) {
+							int equalWidth = (w + spanWidth) / hSpan;
+							int remainder = (w + spanWidth) % hSpan, last = -1;
+							for (int k = 0; k < hSpan; k++) {
+								widths [last=j-k] = Math.max (equalWidth, widths [j-k]);
+							}
+							if (last > -1) widths [last] += remainder;
+						} else {
+							if (spanExpandCount == 0) {
+								widths [j] += w;
+							} else {
+								int delta = w / spanExpandCount;
+								int remainder = w % spanExpandCount, last = -1;
+								for (int k = 0; k < hSpan; k++) {
+									if (expandColumn [j-k]) {
+										widths [last=j-k] += delta;
+									}
+								}
+								if (last > -1) widths [last] += remainder;
+							}
+						}
+					}
+					if (!data.grabExcessHorizontalSpace || data.minimumWidth != 0) {
+						w = !data.grabExcessHorizontalSpace || data.minimumWidth == SWT.DEFAULT ? data.cacheWidth : data.minimumWidth;
+						w += data.horizontalIndent - spanMinWidth - (hSpan - 1) * horizontalSpacing;
+						if (w > 0) {
+							if (spanExpandCount == 0) {
+								minWidths [j] += w;
+							} else {
+								int delta = w / spanExpandCount;
+								int remainder = w % spanExpandCount, last = -1;
+								for (int k = 0; k < hSpan; k++) {
+									if (expandColumn [j-k]) {
+										minWidths [last=j-k] += delta;
+									}
+								}
+								if (last > -1) minWidths [last] += remainder;
+							}
+						}
+					}
+				}
+			}
+		}
+	}
+	if (makeColumnsEqualWidth) {
+		int minColumnWidth = 0;
+		int columnWidth = 0;
+		for (int i=0; i<columnCount; i++) {
+			minColumnWidth = Math.max (minColumnWidth, minWidths [i]);
+			columnWidth = Math.max (columnWidth, widths [i]);
+		}
+		columnWidth = width == SWT.DEFAULT || expandCount == 0 ? columnWidth : Math.max (minColumnWidth, availableWidth / columnCount);
+		for (int i=0; i<columnCount; i++) {
+			expandColumn [i] = expandCount > 0;
+			widths [i] = columnWidth;
+		}
+	} else {
+		if (width != SWT.DEFAULT && expandCount > 0) {
+			int totalWidth = 0;
+			for (int i=0; i<columnCount; i++) {
+				totalWidth += widths [i];
+			}
+			int c = expandCount;
+			int delta = (availableWidth - totalWidth) / c;
+			int remainder = (availableWidth - totalWidth) % c;
+			int last = -1;
+			while (totalWidth != availableWidth) {
+				for (int j=0; j<columnCount; j++) {
+					if (expandColumn [j]) {
+						if (widths [j] + delta > minWidths [j]) {
+							widths [last = j] = widths [j] + delta;
+						} else {
+							widths [j] = minWidths [j];
+							expandColumn [j] = false;
+							c--;
+						}
+					}
+				}
+				if (last > -1) widths [last] += remainder;
+				
+				for (int j=0; j<columnCount; j++) {
+					for (int i=0; i<rowCount; i++) {
+						GridData data = getData (grid, i, j, rowCount, columnCount, false);
+						if (data != null) {
+							int hSpan = Math.max (1, Math.min (data.horizontalSpan, columnCount));
+							if (hSpan > 1) {
+								if (!data.grabExcessHorizontalSpace || data.minimumWidth != 0) {
+									int spanWidth = 0, spanExpandCount = 0;
+									for (int k=0; k<hSpan; k++) {
+										spanWidth += widths [j-k];
+										if (expandColumn [j-k]) spanExpandCount++;
+									}
+									int w = !data.grabExcessHorizontalSpace || data.minimumWidth == SWT.DEFAULT ? data.cacheWidth : data.minimumWidth;
+									w += data.horizontalIndent - spanWidth - (hSpan - 1) * horizontalSpacing;
+									if (w > 0) {
+										if (spanExpandCount == 0) {
+											widths [j] += w;
+										} else {
+											int delta2 = w / spanExpandCount;
+											int remainder2 = w % spanExpandCount, last2 = -1;
+											for (int k = 0; k < hSpan; k++) {
+												if (expandColumn [j-k]) {
+													widths [last2=j-k] += delta2;
+												}
+											}
+											if (last2 > -1) widths [last2] += remainder2;	
+										}
+									}
+								}
+							}
+						}
+					}
+				}
+				if (c == 0) break;
+				totalWidth = 0;
+				for (int i=0; i<columnCount; i++) {
+					totalWidth += widths [i];
+				}
+				delta = (availableWidth - totalWidth) / c;
+				remainder = (availableWidth - totalWidth) % c;
+				last = -1;
+			}
+		}
+	}
+
+	/* Wrapping */
+	GridData [] flush = null;
+	int flushLength = 0;
+	if (width != SWT.DEFAULT) {
+		for (int j=0; j<columnCount; j++) {
+			for (int i=0; i<rowCount; i++) {
+				GridData data = getData (grid, i, j, rowCount, columnCount, false);
+				if (data != null) {
+					if (data.heightHint == SWT.DEFAULT) {
+						Control child = grid [i][j];
+						//TEMPORARY CODE
+						int hSpan = Math.max (1, Math.min (data.horizontalSpan, columnCount));
+						int currentWidth = 0;
+						for (int k=0; k<hSpan; k++) {
+							currentWidth += widths [j-k];
+						}
+						currentWidth += (hSpan - 1) * horizontalSpacing - data.horizontalIndent;
+						if ((currentWidth != data.cacheWidth && data.horizontalAlignment == SWT.FILL) || (data.cacheWidth > currentWidth)) {
+							int trim = 0;
+							if (child instanceof Scrollable) {
+								Rectangle rect = ((Scrollable) child).computeTrim (0, 0, 0, 0);
+								trim = rect.width;
+							} else {
+								trim = child.getBorderWidth () * 2;
+							}
+							data.cacheWidth = data.cacheHeight = SWT.DEFAULT;
+							data.computeSize (child, Math.max (0, currentWidth - trim), data.heightHint, false);
+							if (data.grabExcessVerticalSpace && data.minimumHeight > 0) {
+								data.cacheHeight = Math.max (data.cacheHeight, data.minimumHeight);
+							}
+							if (flush == null) flush = new GridData [count];
+							flush [flushLength++] = data;
+						}
+					}
+				}
+			}
+		}
+	}
+
+	/* Row heights */
+	int availableHeight = height - verticalSpacing * (rowCount - 1) - (marginTop + marginHeight * 2 + marginBottom);
+	expandCount = 0;
+	int [] heights = new int [rowCount];
+	int [] minHeights = new int [rowCount];
+	boolean [] expandRow = new boolean [rowCount];
+	for (int i=0; i<rowCount; i++) {
+		for (int j=0; j<columnCount; j++) {
+			GridData data = getData (grid, i, j, rowCount, columnCount, true);
+			if (data != null) {
+				int vSpan = Math.max (1, Math.min (data.verticalSpan, rowCount));
+				if (vSpan == 1) {
+					int h = data.cacheHeight + data.verticalIndent;
+					heights [i] = Math.max (heights [i], h);
+					if (data.grabExcessVerticalSpace) {
+						if (!expandRow [i]) expandCount++;
+						expandRow [i] = true;
+					}
+					if (!data.grabExcessVerticalSpace || data.minimumHeight != 0) {
+						h = !data.grabExcessVerticalSpace || data.minimumHeight == SWT.DEFAULT ? data.cacheHeight : data.minimumHeight;
+						h += data.verticalIndent;
+						minHeights [i] = Math.max (minHeights [i], h);
+					}
+				}
+			}
+		}
+		for (int j=0; j<columnCount; j++) {
+			GridData data = getData (grid, i, j, rowCount, columnCount, false);
+			if (data != null) {
+				int vSpan = Math.max (1, Math.min (data.verticalSpan, rowCount));
+				if (vSpan > 1) {
+					int spanHeight = 0, spanMinHeight = 0, spanExpandCount = 0;
+					for (int k=0; k<vSpan; k++) {
+						spanHeight += heights [i-k];
+						spanMinHeight += minHeights [i-k];
+						if (expandRow [i-k]) spanExpandCount++;
+					}
+					if (data.grabExcessVerticalSpace && spanExpandCount == 0) {
+						expandCount++;
+						expandRow [i] = true;
+					}
+					int h = data.cacheHeight + data.verticalIndent - spanHeight - (vSpan - 1) * verticalSpacing;
+					if (h > 0) {
+						if (spanExpandCount == 0) {
+							heights [i] += h;
+						} else {
+							int delta = h / spanExpandCount;
+							int remainder = h % spanExpandCount, last = -1;
+							for (int k = 0; k < vSpan; k++) {
+								if (expandRow [i-k]) {
+									heights [last=i-k] += delta;
+								}
+							}
+							if (last > -1) heights [last] += remainder;	
+						}
+					}
+					if (!data.grabExcessVerticalSpace || data.minimumHeight != 0) {
+						h = !data.grabExcessVerticalSpace || data.minimumHeight == SWT.DEFAULT ? data.cacheHeight : data.minimumHeight;
+						h += data.verticalIndent - spanMinHeight - (vSpan - 1) * verticalSpacing;
+						if (h > 0) {
+							if (spanExpandCount == 0) {
+								minHeights [i] += h;
+							} else {
+								int delta = h / spanExpandCount;
+								int remainder = h % spanExpandCount, last = -1;
+								for (int k = 0; k < vSpan; k++) {
+									if (expandRow [i-k]) {
+										minHeights [last=i-k] += delta;
+									}
+								}
+								if (last > -1) minHeights [last] += remainder;	
+							}
+						}
+					}
+				}
+			}
+		}
+	}
+	if (height != SWT.DEFAULT && expandCount > 0) {
+		int totalHeight = 0;
+		for (int i=0; i<rowCount; i++) {
+			totalHeight += heights [i];
+		}
+		int c = expandCount;
+		int delta = (availableHeight - totalHeight) / c;
+		int remainder = (availableHeight - totalHeight) % c;
+		int last = -1;
+		while (totalHeight != availableHeight) {
+			for (int i=0; i<rowCount; i++) {
+				if (expandRow [i]) {
+					if (heights [i] + delta > minHeights [i]) {
+						heights [last = i] = heights [i] + delta;
+					} else {
+						heights [i] = minHeights [i];
+						expandRow [i] = false;
+						c--;
+					}
+				}
+			}
+			if (last > -1) heights [last] += remainder;
+			
+			for (int i=0; i<rowCount; i++) {
+				for (int j=0; j<columnCount; j++) {
+					GridData data = getData (grid, i, j, rowCount, columnCount, false);
+					if (data != null) {
+						int vSpan = Math.max (1, Math.min (data.verticalSpan, rowCount));
+						if (vSpan > 1) {
+							if (!data.grabExcessVerticalSpace || data.minimumHeight != 0) {
+								int spanHeight = 0, spanExpandCount = 0;
+								for (int k=0; k<vSpan; k++) {
+									spanHeight += heights [i-k];
+									if (expandRow [i-k]) spanExpandCount++;
+								}
+								int h = !data.grabExcessVerticalSpace || data.minimumHeight == SWT.DEFAULT ? data.cacheHeight : data.minimumHeight;
+								h += data.verticalIndent - spanHeight - (vSpan - 1) * verticalSpacing;
+								if (h > 0) {
+									if (spanExpandCount == 0) {
+										heights [i] += h;
+									} else {
+										int delta2 = h / spanExpandCount;
+										int remainder2 = h % spanExpandCount, last2 = -1;
+										for (int k = 0; k < vSpan; k++) {
+											if (expandRow [i-k]) {
+												heights [last2=i-k] += delta2;
+											}
+										}
+										if (last2 > -1) heights [last2] += remainder2;
+									}
+								}
+							}
+						}
+					}
+				}
+			}
+			if (c == 0) break;
+			totalHeight = 0;
+			for (int i=0; i<rowCount; i++) {
+				totalHeight += heights [i];
+			}
+			delta = (availableHeight - totalHeight) / c;
+			remainder = (availableHeight - totalHeight) % c;
+			last = -1;
+		}
+	}
+
+	/* Position the controls */
+	if (move) {
+		int gridY = y + marginTop + marginHeight;
+		for (int i=0; i<rowCount; i++) {
+			int gridX = x + marginLeft + marginWidth;
+			for (int j=0; j<columnCount; j++) {
+				GridData data = getData (grid, i, j, rowCount, columnCount, true);
+				if (data != null) {
+					int hSpan = Math.max (1, Math.min (data.horizontalSpan, columnCount));
+					int vSpan = Math.max (1, data.verticalSpan);
+					int cellWidth = 0, cellHeight = 0;
+					for (int k=0; k<hSpan; k++) {
+						cellWidth += widths [j+k];
+					}
+					for (int k=0; k<vSpan; k++) {
+						cellHeight += heights [i+k];
+					}
+					cellWidth += horizontalSpacing * (hSpan - 1);
+					int childX = gridX + data.horizontalIndent;
+					int childWidth = Math.min (data.cacheWidth, cellWidth);
+					switch (data.horizontalAlignment) {
+						case SWT.CENTER:
+						case GridData.CENTER:
+							childX += Math.max (0, (cellWidth - data.horizontalIndent - childWidth) / 2);
+							break;
+						case SWT.RIGHT:
+						case SWT.END:
+						case GridData.END:
+							childX += Math.max (0, cellWidth - data.horizontalIndent - childWidth);
+							break;
+						case SWT.FILL:
+							childWidth = cellWidth - data.horizontalIndent;
+							break;
+					}
+					cellHeight += verticalSpacing * (vSpan - 1);
+					int childY = gridY + data.verticalIndent;
+					int childHeight = Math.min (data.cacheHeight, cellHeight);
+					switch (data.verticalAlignment) {
+						case SWT.CENTER:
+						case GridData.CENTER:
+							childY += Math.max (0, (cellHeight - data.verticalIndent - childHeight) / 2);
+							break;
+						case SWT.BOTTOM:
+						case SWT.END:
+						case GridData.END:
+							childY += Math.max (0, cellHeight - data.verticalIndent - childHeight);
+							break;
+						case SWT.FILL:
+							childHeight = cellHeight - data.verticalIndent;
+							break;
+					}
+					Control child = grid [i][j];
+					if (child != null) {
+						child.setBounds (childX, childY, childWidth, childHeight);
+					}
+				}
+				gridX += widths [j] + horizontalSpacing;
+			}
+			gridY += heights [i] + verticalSpacing;
+		}
+	}
+
+	// clean up cache
+	for (int i = 0; i < flushLength; i++) {
+		flush [i].cacheWidth = flush [i].cacheHeight = -1;
+	}
+
+	int totalDefaultWidth = 0;
+	int totalDefaultHeight = 0;
+	for (int i=0; i<columnCount; i++) {
+		totalDefaultWidth += widths [i];
+	}
+	for (int i=0; i<rowCount; i++) {
+		totalDefaultHeight += heights [i];
+	}
+	totalDefaultWidth += horizontalSpacing * (columnCount - 1) + marginLeft + marginWidth * 2 + marginRight;
+	totalDefaultHeight += verticalSpacing * (rowCount - 1) + marginTop + marginHeight * 2 + marginBottom;
+	return new Point (totalDefaultWidth, totalDefaultHeight);
+}
+
+String getName () {
+	String string = getClass ().getName ();
+	int index = string.lastIndexOf ('.');
+	if (index == -1) return string;
+	return string.substring (index + 1, string.length ());
+}
+
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the layout
+ */
+public String toString () {
+ 	String string = getName ()+" {";
+ 	if (numColumns != 1) string += "numColumns="+numColumns+" ";
+ 	if (makeColumnsEqualWidth) string += "makeColumnsEqualWidth="+makeColumnsEqualWidth+" ";
+ 	if (marginWidth != 0) string += "marginWidth="+marginWidth+" ";
+ 	if (marginHeight != 0) string += "marginHeight="+marginHeight+" ";
+ 	if (marginLeft != 0) string += "marginLeft="+marginLeft+" ";
+ 	if (marginRight != 0) string += "marginRight="+marginRight+" ";
+ 	if (marginTop != 0) string += "marginTop="+marginTop+" ";
+ 	if (marginBottom != 0) string += "marginBottom="+marginBottom+" ";
+ 	if (horizontalSpacing != 0) string += "horizontalSpacing="+horizontalSpacing+" ";
+ 	if (verticalSpacing != 0) string += "verticalSpacing="+verticalSpacing+" ";
+ 	string = string.trim();
+ 	string += "}";
+ 	return string;
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/layout/RowData.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/layout/RowData.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/layout/RowData.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,125 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.layout;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
+/**
+ * Each control controlled by a <code>RowLayout</code> can have its initial 
+ * width and height specified by setting a <code>RowData</code> object 
+ * into the control.
+ * <p>
+ * The following code uses a <code>RowData</code> object to change the initial
+ * size of a <code>Button</code> in a <code>Shell</code>:
+ * <pre>
+ * 		Display display = new Display();
+ * 		Shell shell = new Shell(display);
+ * 		shell.setLayout(new RowLayout());
+ * 		Button button1 = new Button(shell, SWT.PUSH);
+ * 		button1.setText("Button 1");
+ * 		button1.setLayoutData(new RowData(50, 40));
+ * </pre>
+ * </p>
+ * 
+ * @see RowLayout
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public final class RowData {
+	/**
+	 * width specifies the desired width in pixels. This value
+	 * is the wHint passed into Control.computeSize(int, int, boolean) 
+	 * to determine the preferred size of the control.
+	 *
+	 * The default value is SWT.DEFAULT.
+	 *
+	 * @see org.eclipse.swt.widgets.Control#computeSize(int, int, boolean)
+	 */
+	public int width = SWT.DEFAULT;
+	/**
+	 * height specifies the preferred height in pixels. This value
+	 * is the hHint passed into Control.computeSize(int, int, boolean) 
+	 * to determine the preferred size of the control.
+	 *
+	 * The default value is SWT.DEFAULT.
+	 *
+	 * @see org.eclipse.swt.widgets.Control#computeSize(int, int, boolean)
+	 */
+	public int height = SWT.DEFAULT;
+	
+	/**
+	 * exclude informs the layout to ignore this control when sizing
+	 * and positioning controls.  If this value is <code>true</code>,
+	 * the size and position of the control will not be managed by the
+	 * layout.  If this	value is <code>false</code>, the size and 
+	 * position of the control will be computed and assigned.
+	 * 
+	 * The default value is <code>false</code>.
+	 * 
+	 * @since 3.1
+	 */
+	public boolean exclude = false;
+	
+/**
+ * Constructs a new instance of RowData using
+ * default values.
+ */
+public RowData () {
+}
+
+/**
+ * Constructs a new instance of RowData according to the parameters.
+ * A value of SWT.DEFAULT indicates that no minimum width or
+ * no minimum height is specified.
+ * 
+ * @param width a minimum width for the control
+ * @param height a minimum height for the control
+ */
+public RowData (int width, int height) {
+	this.width = width;
+	this.height = height;
+}
+
+/**
+ * Constructs a new instance of RowData according to the parameter.
+ * A value of SWT.DEFAULT indicates that no minimum width or
+ * no minimum height is specified.
+ * 
+ * @param point a point whose x coordinate specifies a minimum width for the control
+ * and y coordinate specifies a minimum height for the control
+ */
+public RowData (Point point) {
+	this (point.x, point.y);
+}
+
+String getName () {
+	String string = getClass ().getName ();
+	int index = string.lastIndexOf ('.');
+	if (index == -1) return string;
+	return string.substring (index + 1, string.length ());
+}
+
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the RowData object
+ */
+public String toString () {
+	String string = getName ()+" {";
+	if (width != SWT.DEFAULT) string += "width="+width+" ";
+	if (height != SWT.DEFAULT) string += "height="+height+" ";
+	if (exclude) string += "exclude="+exclude+" ";
+	string = string.trim();
+	string += "}";
+	return string;
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/layout/RowLayout.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/layout/RowLayout.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/layout/RowLayout.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,506 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.layout;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+
+/**
+ * Instances of this class determine the size and position of the 
+ * children of a <code>Composite</code> by placing them either in 
+ * horizontal rows or vertical columns within the parent <code>Composite</code>. 
+ * <p>
+ * <code>RowLayout</code> aligns all controls in one row if the
+ * <code>type</code> is set to horizontal, and one column if it is
+ * set to vertical. It has the ability to wrap, and provides configurable 
+ * margins and spacing. <code>RowLayout</code> has a number of configuration 
+ * fields. In addition, the height and width of each control in a 
+ * <code>RowLayout</code> can be specified by setting a <code>RowData</code>
+ * object into the control using <code>setLayoutData ()</code>.
+ * </p>
+ * <p>
+ * The following example code creates a <code>RowLayout</code>, sets all 
+ * of its fields to non-default values, and then sets it into a 
+ * <code>Shell</code>. 
+ * <pre>
+ * 		RowLayout rowLayout = new RowLayout();
+ * 		rowLayout.wrap = false;
+ * 		rowLayout.pack = false;
+ * 		rowLayout.justify = true;
+ * 		rowLayout.type = SWT.VERTICAL;
+ * 		rowLayout.marginLeft = 5;
+ * 		rowLayout.marginTop = 5;
+ * 		rowLayout.marginRight = 5;
+ * 		rowLayout.marginBottom = 5;
+ * 		rowLayout.spacing = 0;
+ * 		shell.setLayout(rowLayout);
+ * </pre>
+ * If you are using the default field values, you only need one line of code:
+ * <pre>
+ * 		shell.setLayout(new RowLayout());
+ * </pre>
+ * </p>
+ * 
+ * @see RowData
+ * @see <a href="http://www.eclipse.org/swt/snippets/#rowlayout">RowLayout snippets</a>
+ * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: LayoutExample</a>
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public final class RowLayout extends Layout {
+	
+	/**
+	 * type specifies whether the layout places controls in rows or 
+	 * columns.
+	 * 
+	 * The default value is HORIZONTAL.
+	 * 
+	 * Possible values are: <ul>
+	 *    <li>HORIZONTAL: Position the controls horizontally from left to right</li>
+	 *    <li>VERTICAL: Position the controls vertically from top to bottom</li>
+	 * </ul>
+	 * 
+	 * @since 2.0
+	 */
+	public int type = SWT.HORIZONTAL;
+	
+	/**
+	 * marginWidth specifies the number of pixels of horizontal margin
+	 * that will be placed along the left and right edges of the layout.
+	 *
+	 * The default value is 0.
+	 * 
+	 * @since 3.0
+	 */
+ 	public int marginWidth = 0;
+ 	
+	/**
+	 * marginHeight specifies the number of pixels of vertical margin
+	 * that will be placed along the top and bottom edges of the layout.
+	 *
+	 * The default value is 0.
+	 * 
+	 * @since 3.0
+	 */
+ 	public int marginHeight = 0;
+
+	/**
+	 * spacing specifies the number of pixels between the edge of one cell
+	 * and the edge of its neighbouring cell.
+	 *
+	 * The default value is 3.
+	 */
+	public int spacing = 3;
+	 		
+	/**
+	 * wrap specifies whether a control will be wrapped to the next
+	 * row if there is insufficient space on the current row.
+	 *
+	 * The default value is true.
+	 */
+	public boolean wrap = true;
+
+	/**
+	 * pack specifies whether all controls in the layout take
+	 * their preferred size.  If pack is false, all controls will 
+	 * have the same size which is the size required to accommodate the 
+	 * largest preferred height and the largest preferred width of all 
+	 * the controls in the layout.
+	 *
+	 * The default value is true.
+	 */
+	public boolean pack = true;
+	
+	/**
+	 * fill specifies whether the controls in a row should be
+	 * all the same height for horizontal layouts, or the same
+	 * width for vertical layouts.
+	 *
+	 * The default value is false.
+	 * 
+	 * @since 3.0
+	 */
+	public boolean fill = false;
+
+	/**
+	 * center specifies whether the controls in a row should be
+	 * centered vertically in each cell for horizontal layouts,
+	 * or centered horizontally in each cell for vertical layouts.
+	 *
+	 * The default value is false.
+	 * 
+	 * @since 3.4
+	 */
+	public boolean center = false;
+	
+	/**
+	 * justify specifies whether the controls in a row should be
+	 * fully justified, with any extra space placed between the controls.
+	 *
+	 * The default value is false.
+	 */
+	public boolean justify = false;
+
+	/**
+	 * marginLeft specifies the number of pixels of horizontal margin
+	 * that will be placed along the left edge of the layout.
+	 *
+	 * The default value is 3.
+	 */
+	public int marginLeft = 3;
+
+	/**
+	 * marginTop specifies the number of pixels of vertical margin
+	 * that will be placed along the top edge of the layout.
+	 *
+	 * The default value is 3.
+	 */
+	public int marginTop = 3;
+
+	/**
+	 * marginRight specifies the number of pixels of horizontal margin
+	 * that will be placed along the right edge of the layout.
+	 *
+	 * The default value is 3.
+	 */
+	public int marginRight = 3;
+
+	/**
+	 * marginBottom specifies the number of pixels of vertical margin
+	 * that will be placed along the bottom edge of the layout.
+	 *
+	 * The default value is 3.
+	 */
+	public int marginBottom = 3;
+
+/**
+ * Constructs a new instance of this class.
+ */
+public RowLayout () {
+}
+
+/**
+ * Constructs a new instance of this class given the type.
+ *
+ * @param type the type of row layout
+ * 
+ * @since 2.0
+ */
+public RowLayout (int type) {
+	this.type = type;
+}
+
+protected Point computeSize (Composite composite, int wHint, int hHint, boolean flushCache) {
+	Point extent;
+	if (type == SWT.HORIZONTAL) {
+		extent = layoutHorizontal (composite, false, (wHint != SWT.DEFAULT) && wrap, wHint, flushCache);
+	} else {
+		extent = layoutVertical (composite, false, (hHint != SWT.DEFAULT) && wrap, hHint, flushCache);
+	}
+	if (wHint != SWT.DEFAULT) extent.x = wHint;
+	if (hHint != SWT.DEFAULT) extent.y = hHint;
+	return extent;
+}
+
+Point computeSize (Control control, boolean flushCache) {
+	int wHint = SWT.DEFAULT, hHint = SWT.DEFAULT;
+	RowData data = (RowData) control.getLayoutData ();
+	if (data != null) {
+		wHint = data.width;
+		hHint = data.height;
+	}
+	return control.computeSize (wHint, hHint, flushCache);
+}
+
+protected boolean flushCache (Control control) {
+	return true;
+}
+
+String getName () {
+	String string = getClass ().getName ();
+	int index = string.lastIndexOf ('.');
+	if (index == -1) return string;
+	return string.substring (index + 1, string.length ());
+}
+
+protected void layout (Composite composite, boolean flushCache) {
+	Rectangle clientArea = composite.getClientArea ();
+	if (type == SWT.HORIZONTAL) {
+		layoutHorizontal (composite, true, wrap, clientArea.width, flushCache);
+	} else {
+		layoutVertical (composite, true, wrap, clientArea.height, flushCache);
+	}
+}
+
+Point layoutHorizontal (Composite composite, boolean move, boolean wrap, int width, boolean flushCache) {
+	Control [] children = composite.getChildren ();
+	int count = 0;
+	for (int i=0; i<children.length; i++) {
+		Control control = children [i];
+		RowData data = (RowData) control.getLayoutData ();
+		if (data == null || !data.exclude) {
+			children [count++] = children [i];
+		} 
+	}
+	if (count == 0) {
+		return new Point (marginLeft + marginWidth * 2 + marginRight, marginTop + marginHeight * 2 + marginBottom);
+	}
+	int childWidth = 0, childHeight = 0, maxHeight = 0;
+	if (!pack) {
+		for (int i=0; i<count; i++) {
+			Control child = children [i];
+			Point size = computeSize (child, flushCache);
+			childWidth = Math.max (childWidth, size.x);
+			childHeight = Math.max (childHeight, size.y);
+		}
+		maxHeight = childHeight;
+	}
+	int clientX = 0, clientY = 0;
+	if (move) {
+		Rectangle rect = composite.getClientArea ();
+		clientX = rect.x;
+		clientY = rect.y;
+	}
+	int [] wraps = null;
+	boolean wrapped = false;
+	Rectangle [] bounds = null;
+	if (move && (justify || fill || center)) {
+		bounds = new Rectangle [count];
+		wraps = new int [count];
+	}
+	int maxX = 0, x = marginLeft + marginWidth, y = marginTop + marginHeight;
+	for (int i=0; i<count; i++) {
+		Control child = children [i];
+		if (pack) {
+			Point size = computeSize (child, flushCache);
+			childWidth = size.x;
+			childHeight = size.y;
+		}
+		if (wrap && (i != 0) && (x + childWidth > width)) {
+			wrapped = true;
+			if (move && (justify || fill || center)) wraps [i - 1] = maxHeight;
+			x = marginLeft + marginWidth;
+			y += spacing + maxHeight;
+			if (pack) maxHeight = 0;
+		}
+		if (pack || fill || center) {
+			maxHeight = Math.max (maxHeight, childHeight);
+		}
+		if (move) {
+			int childX = x + clientX, childY = y + clientY;
+			if (justify || fill || center) {
+				bounds [i] = new Rectangle (childX, childY, childWidth, childHeight);
+			} else {
+				child.setBounds (childX, childY, childWidth, childHeight);
+			}
+		}
+		x += spacing + childWidth;
+		maxX = Math.max (maxX, x);
+	}
+	maxX = Math.max (clientX + marginLeft + marginWidth, maxX - spacing);
+	if (!wrapped) maxX += marginRight + marginWidth;
+	if (move && (justify || fill || center)) {
+		int space = 0, margin = 0;
+		if (!wrapped) {
+			space = Math.max (0, (width - maxX) / (count + 1));
+			margin = Math.max (0, ((width - maxX) % (count + 1)) / 2);
+		} else {
+			if (fill || justify || center) {
+				int last = 0;
+				if (count > 0) wraps [count - 1] = maxHeight;
+				for (int i=0; i<count; i++) {
+					if (wraps [i] != 0) {
+						int wrapCount = i - last + 1;
+						if (justify) {
+							int wrapX = 0;
+							for (int j=last; j<=i; j++) {
+								wrapX += bounds [j].width + spacing;
+							}
+							space = Math.max (0, (width - wrapX) / (wrapCount + 1));
+							margin = Math.max (0, ((width - wrapX) % (wrapCount + 1)) / 2);
+						}
+						for (int j=last; j<=i; j++) {
+							if (justify) bounds [j].x += (space * (j - last + 1)) + margin;
+							if (fill) {
+								bounds [j].height = wraps [i];
+							} else {
+								if (center) {
+									bounds [j].y += Math.max (0, (wraps [i] - bounds [j].height) / 2);
+								}
+							}
+						}
+						last = i + 1;
+					}
+				}
+			}
+		}
+		for (int i=0; i<count; i++) {
+			if (!wrapped) {
+				if (justify) bounds [i].x += (space * (i + 1)) + margin;
+				if (fill) {
+					bounds [i].height = maxHeight;
+				} else {
+					if (center) {
+						bounds [i].y += Math.max (0, (maxHeight - bounds [i].height) / 2);
+					}
+				}
+			}
+			children [i].setBounds (bounds [i]);
+		}
+	}
+	return new Point (maxX, y + maxHeight + marginBottom + marginHeight);
+}
+
+Point layoutVertical (Composite composite, boolean move, boolean wrap, int height, boolean flushCache) {
+	Control [] children = composite.getChildren ();
+	int count = 0;
+	for (int i=0; i<children.length; i++) {
+		Control control = children [i];
+		RowData data = (RowData) control.getLayoutData ();
+		if (data == null || !data.exclude) {
+			children [count++] = children [i];
+		} 
+	}
+	if (count == 0) {
+		return new Point (marginLeft + marginWidth * 2 + marginRight, marginTop + marginHeight * 2 + marginBottom);
+	}
+	int childWidth = 0, childHeight = 0, maxWidth = 0;
+	if (!pack) {
+		for (int i=0; i<count; i++) {
+			Control child = children [i];
+			Point size = computeSize (child, flushCache);
+			childWidth = Math.max (childWidth, size.x);
+			childHeight = Math.max (childHeight, size.y);
+		}
+		maxWidth = childWidth;
+	}
+	int clientX = 0, clientY = 0;
+	if (move) {
+		Rectangle rect = composite.getClientArea ();
+		clientX = rect.x;
+		clientY = rect.y;
+	}
+	int [] wraps = null;
+	boolean wrapped = false;
+	Rectangle [] bounds = null;
+	if (move && (justify || fill || center)) {
+		bounds = new Rectangle [count];
+		wraps = new int [count];
+	}
+	int maxY = 0, x = marginLeft + marginWidth, y = marginTop + marginHeight;
+	for (int i=0; i<count; i++) {
+		Control child = children [i];
+		if (pack) {
+			Point size = computeSize (child, flushCache);
+			childWidth = size.x;
+			childHeight = size.y;
+		}
+		if (wrap && (i != 0) && (y + childHeight > height)) {
+			wrapped = true;
+			if (move && (justify || fill || center)) wraps [i - 1] = maxWidth;
+			x += spacing + maxWidth;
+			y = marginTop + marginHeight;
+			if (pack) maxWidth = 0;
+		}
+		if (pack || fill || center) {
+			maxWidth = Math.max (maxWidth, childWidth);
+		}
+		if (move) {
+			int childX = x + clientX, childY = y + clientY;
+			if (justify || fill || center) {
+				bounds [i] = new Rectangle (childX, childY, childWidth, childHeight);
+			} else {
+				child.setBounds (childX, childY, childWidth, childHeight);
+			}
+		}
+		y += spacing + childHeight;
+		maxY = Math.max (maxY, y);
+	}
+	maxY = Math.max (clientY + marginTop + marginHeight, maxY - spacing);
+	if (!wrapped) maxY += marginBottom + marginHeight;
+	if (move && (justify || fill || center)) {
+		int space = 0, margin = 0;
+		if (!wrapped) {
+			space = Math.max (0, (height - maxY) / (count + 1));
+			margin = Math.max (0, ((height - maxY) % (count + 1)) / 2);
+		} else {
+			if (fill || justify || center) {
+				int last = 0;
+				if (count > 0) wraps [count - 1] = maxWidth;
+				for (int i=0; i<count; i++) {
+					if (wraps [i] != 0) {
+						int wrapCount = i - last + 1;
+						if (justify) {
+							int wrapY = 0;
+							for (int j=last; j<=i; j++) {
+								wrapY += bounds [j].height + spacing;
+							}
+							space = Math.max (0, (height - wrapY) / (wrapCount + 1));
+							margin = Math.max (0, ((height - wrapY) % (wrapCount + 1)) / 2);
+						}
+						for (int j=last; j<=i; j++) {
+							if (justify) bounds [j].y += (space * (j - last + 1)) + margin;
+							if (fill) {
+								bounds [j].width = wraps [i];
+							} else {
+								if (center) {
+									bounds [j].x += Math.max (0, (wraps [i] - bounds [j].width) / 2);
+								}
+							}
+						}
+						last = i + 1;
+					}
+				}
+			}
+		}
+		for (int i=0; i<count; i++) {
+			if (!wrapped) {
+				if (justify) bounds [i].y += (space * (i + 1)) + margin;
+				if (fill) {
+					bounds [i].width = maxWidth;
+				} else {
+					if (center) {
+						bounds [i].x += Math.max (0, (maxWidth - bounds [i].width) / 2);
+					}
+				}
+
+			}
+			children [i].setBounds (bounds [i]);
+		}
+	}
+	return new Point (x + maxWidth + marginRight + marginWidth, maxY);
+}
+
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the layout
+ */
+public String toString () {
+ 	String string = getName ()+" {";
+ 	string += "type="+((type != SWT.HORIZONTAL) ? "SWT.VERTICAL" : "SWT.HORIZONTAL")+" ";
+ 	if (marginWidth != 0) string += "marginWidth="+marginWidth+" ";
+ 	if (marginHeight != 0) string += "marginHeight="+marginHeight+" ";
+ 	if (marginLeft != 0) string += "marginLeft="+marginLeft+" ";
+ 	if (marginTop != 0) string += "marginTop="+marginTop+" ";
+ 	if (marginRight != 0) string += "marginRight="+marginRight+" ";
+ 	if (marginBottom != 0) string += "marginBottom="+marginBottom+" ";
+ 	if (spacing != 0) string += "spacing="+spacing+" ";
+ 	string += "wrap="+wrap+" ";
+	string += "pack="+pack+" ";
+	string += "fill="+fill+" ";
+	string += "justify="+justify+" ";
+	string = string.trim();
+	string += "}";
+ 	return string;
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/opengl/GLCanvas.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/opengl/GLCanvas.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/opengl/GLCanvas.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,275 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.opengl;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.gtk.*;
+import org.eclipse.swt.internal.opengl.glx.*;
+
+/**
+ * GLCanvas is a widget capable of displaying OpenGL content.
+ * 
+ * @see GLData
+ * @see <a href="http://www.eclipse.org/swt/snippets/#opengl">OpenGL snippets</a>
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ *
+ * @since 3.2
+ */
+
+public class GLCanvas extends Canvas {
+	int /*long*/ context;
+	int /*long*/ xWindow;
+	int /*long*/ glWindow;
+	XVisualInfo vinfo;
+	static final int MAX_ATTRIBUTES = 32;
+
+/**
+ * Create a GLCanvas widget using the attributes described in the GLData
+ * object provided.
+ *
+ * @param parent a composite widget
+ * @param style the bitwise OR'ing of widget styles
+ * @param data the requested attributes of the GLCanvas
+ *
+ * @exception IllegalArgumentException
+ * <ul><li>ERROR_NULL_ARGUMENT when the data is null
+ *     <li>ERROR_UNSUPPORTED_DEPTH when the requested attributes cannot be provided</ul> 
+ * </ul>
+ */
+public GLCanvas (Composite parent, int style, GLData data) {
+	super (parent, style);	
+	if (data == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+	int glxAttrib [] = new int [MAX_ATTRIBUTES];
+	int pos = 0;
+	glxAttrib [pos++] = GLX.GLX_RGBA;
+	if (data.doubleBuffer) glxAttrib [pos++] = GLX.GLX_DOUBLEBUFFER;
+	if (data.stereo) glxAttrib [pos++] = GLX.GLX_STEREO;
+	if (data.redSize > 0) {
+		glxAttrib [pos++] = GLX.GLX_RED_SIZE;
+		glxAttrib [pos++] = data.redSize;
+	}
+	if (data.greenSize > 0) {
+		glxAttrib [pos++] = GLX.GLX_GREEN_SIZE;
+		glxAttrib [pos++] = data.greenSize;
+	}
+	if (data.blueSize > 0) {
+		glxAttrib [pos++] = GLX.GLX_BLUE_SIZE;
+		glxAttrib [pos++] = data.blueSize;
+	}
+	if (data.alphaSize > 0) {
+		glxAttrib [pos++] = GLX.GLX_ALPHA_SIZE;
+		glxAttrib [pos++] = data.alphaSize;
+	}
+	if (data.depthSize > 0) {
+		glxAttrib [pos++] = GLX.GLX_DEPTH_SIZE;
+		glxAttrib [pos++] = data.depthSize;
+	}
+	if (data.stencilSize > 0) {
+		glxAttrib [pos++] = GLX.GLX_STENCIL_SIZE;
+		glxAttrib [pos++] = data.stencilSize;
+	}
+	if (data.accumRedSize > 0) {
+		glxAttrib [pos++] = GLX.GLX_ACCUM_RED_SIZE;
+		glxAttrib [pos++] = data.accumRedSize;
+	}
+	if (data.accumGreenSize > 0) {
+		glxAttrib [pos++] = GLX.GLX_ACCUM_GREEN_SIZE;
+		glxAttrib [pos++] = data.accumGreenSize;
+	}
+	if (data.accumBlueSize > 0) {
+		glxAttrib [pos++] = GLX.GLX_ACCUM_BLUE_SIZE;
+		glxAttrib [pos++] = data.accumBlueSize;
+	}
+	if (data.accumAlphaSize > 0) {
+		glxAttrib [pos++] = GLX.GLX_ACCUM_ALPHA_SIZE;
+		glxAttrib [pos++] = data.accumAlphaSize;
+	}
+	if (data.sampleBuffers > 0) {
+		glxAttrib [pos++] = GLX.GLX_SAMPLE_BUFFERS;
+		glxAttrib [pos++] = data.sampleBuffers;
+	}
+	if (data.samples > 0) {
+		glxAttrib [pos++] = GLX.GLX_SAMPLES;
+		glxAttrib [pos++] = data.samples;
+	}
+	glxAttrib [pos++] = 0;
+	OS.gtk_widget_realize (handle);
+	int /*long*/ window = OS.GTK_WIDGET_WINDOW (handle);
+	int /*long*/ xDisplay = OS.gdk_x11_drawable_get_xdisplay (window);
+	int /*long*/ infoPtr = GLX.glXChooseVisual (xDisplay, OS.XDefaultScreen (xDisplay), glxAttrib);
+	if (infoPtr == 0) {
+		dispose ();
+		SWT.error (SWT.ERROR_UNSUPPORTED_DEPTH);
+	}
+	vinfo = new XVisualInfo ();
+	GLX.memmove (vinfo, infoPtr, XVisualInfo.sizeof);
+	OS.XFree (infoPtr);
+	int /*long*/ screen = OS.gdk_screen_get_default ();
+	int /*long*/ gdkvisual = OS.gdk_x11_screen_lookup_visual (screen, vinfo.visualid);
+	//FIXME- share lists
+	//context = GLX.glXCreateContext (xDisplay, info, share == null ? 0 : share.context, true);
+	context = GLX.glXCreateContext (xDisplay, vinfo, 0, true);
+	if (context == 0) SWT.error (SWT.ERROR_NO_HANDLES);
+	GdkWindowAttr attrs = new GdkWindowAttr ();
+	attrs.width = 1;
+	attrs.height = 1;
+	attrs.event_mask = OS.GDK_KEY_PRESS_MASK | OS.GDK_KEY_RELEASE_MASK |
+		OS.GDK_FOCUS_CHANGE_MASK | OS.GDK_POINTER_MOTION_MASK |
+		OS.GDK_BUTTON_PRESS_MASK | OS.GDK_BUTTON_RELEASE_MASK |
+		OS.GDK_ENTER_NOTIFY_MASK | OS.GDK_LEAVE_NOTIFY_MASK |
+		OS.GDK_EXPOSURE_MASK | OS.GDK_VISIBILITY_NOTIFY_MASK |
+		OS.GDK_POINTER_MOTION_HINT_MASK;
+	attrs.window_type = OS.GDK_WINDOW_CHILD;
+	attrs.visual = gdkvisual;
+	glWindow = OS.gdk_window_new (window, attrs, OS.GDK_WA_VISUAL);
+	OS.gdk_window_set_user_data (glWindow, handle);
+	if ((style & SWT.NO_BACKGROUND) != 0) OS.gdk_window_set_back_pixmap (window, 0, false);
+	xWindow = OS.gdk_x11_drawable_get_xid (glWindow);
+	OS.gdk_window_show (glWindow);
+
+	Listener listener = new Listener () {
+		public void handleEvent (Event event) {
+			switch (event.type) {
+			case SWT.Paint:
+				/**
+				* Bug in MESA.  MESA does some nasty sort of polling to try
+				* and ensure that their buffer sizes match the current X state.
+				* This state can be updated using glViewport().
+				* FIXME: There has to be a better way of doing this.
+				*/
+				int [] viewport = new int [4];
+				GLX.glGetIntegerv (GLX.GL_VIEWPORT, viewport);
+				GLX.glViewport (viewport [0],viewport [1],viewport [2],viewport [3]);
+				break;
+			case SWT.Resize:
+				Rectangle clientArea = getClientArea();
+				OS.gdk_window_move (glWindow, clientArea.x, clientArea.y);
+				OS.gdk_window_resize (glWindow, clientArea.width, clientArea.height);
+				break;
+			case SWT.Dispose:
+				int /*long*/ window = OS.GTK_WIDGET_WINDOW (handle);
+				int /*long*/ xDisplay = OS.gdk_x11_drawable_get_xdisplay (window);
+				if (context != 0) {
+					if (GLX.glXGetCurrentContext () == context) {
+						GLX.glXMakeCurrent (xDisplay, 0, 0);
+					}
+					GLX.glXDestroyContext (xDisplay, context);
+					context = 0;
+				}
+				if (glWindow != 0) {
+					OS.gdk_window_destroy (glWindow);
+					glWindow = 0;
+				}
+				break;
+			}
+		}
+	};
+	addListener (SWT.Resize, listener);
+	addListener (SWT.Paint, listener);
+	addListener (SWT.Dispose, listener);
+}
+
+/**
+ * Returns a GLData object describing the created context.
+ *  
+ * @return GLData description of the OpenGL context attributes
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public GLData getGLData () {
+	checkWidget ();
+	int /*long*/ window = OS.GTK_WIDGET_WINDOW (handle);
+	int /*long*/ xDisplay = OS.gdk_x11_drawable_get_xdisplay (window);
+	GLData data = new GLData ();
+	int [] value = new int [1];
+	GLX.glXGetConfig (xDisplay, vinfo, GLX.GLX_DOUBLEBUFFER, value);
+	data.doubleBuffer = value [0] != 0;
+	GLX.glXGetConfig (xDisplay, vinfo, GLX.GLX_STEREO, value);
+	data.stereo = value [0] != 0;
+	GLX.glXGetConfig (xDisplay, vinfo, GLX.GLX_RED_SIZE, value);
+	data.redSize = value [0];
+	GLX.glXGetConfig (xDisplay, vinfo, GLX.GLX_GREEN_SIZE, value);
+	data.greenSize = value [0];
+	GLX.glXGetConfig (xDisplay, vinfo, GLX.GLX_BLUE_SIZE, value);
+	data.blueSize = value [0];
+	GLX.glXGetConfig (xDisplay, vinfo, GLX.GLX_ALPHA_SIZE, value);
+	data.alphaSize = value [0];
+	GLX.glXGetConfig (xDisplay, vinfo, GLX.GLX_DEPTH_SIZE, value);
+	data.depthSize = value [0];
+	GLX.glXGetConfig (xDisplay, vinfo, GLX.GLX_STENCIL_SIZE, value);
+	data.stencilSize = value [0];
+	GLX.glXGetConfig (xDisplay, vinfo, GLX.GLX_ACCUM_RED_SIZE, value);
+	data.accumRedSize = value [0];
+	GLX.glXGetConfig (xDisplay, vinfo, GLX.GLX_ACCUM_GREEN_SIZE, value);
+	data.accumGreenSize = value [0];
+	GLX.glXGetConfig (xDisplay, vinfo, GLX.GLX_ACCUM_BLUE_SIZE, value);
+	data.accumBlueSize = value [0];
+	GLX.glXGetConfig (xDisplay, vinfo, GLX.GLX_ACCUM_ALPHA_SIZE, value);
+	data.accumAlphaSize = value [0];
+	GLX.glXGetConfig (xDisplay, vinfo, GLX.GLX_SAMPLE_BUFFERS, value);
+	data.sampleBuffers = value [0];
+	GLX.glXGetConfig (xDisplay, vinfo, GLX.GLX_SAMPLES, value);
+	data.samples = value [0];
+	return data;
+}
+
+/**
+ * Returns a boolean indicating whether the receiver's OpenGL context
+ * is the current context.
+ *  
+ * @return true if the receiver holds the current OpenGL context,
+ * false otherwise
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public boolean isCurrent () {
+	checkWidget ();
+	return GLX.glXGetCurrentContext () == context;
+}
+
+/**
+ * Sets the OpenGL context associated with this GLCanvas to be the
+ * current GL context.
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setCurrent () {
+	checkWidget ();
+	if (GLX.glXGetCurrentContext () == context) return;
+	int /*long*/ window = OS.GTK_WIDGET_WINDOW (handle);
+	int /*long*/ xDisplay = OS.gdk_x11_drawable_get_xdisplay (window);
+	GLX.glXMakeCurrent (xDisplay, xWindow, context);
+}
+
+/**
+ * Swaps the front and back color buffers.
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void swapBuffers () {
+	checkWidget ();
+	int /*long*/ window = OS.GTK_WIDGET_WINDOW (handle);
+	int /*long*/ xDisplay = OS.gdk_x11_drawable_get_xdisplay (window);
+	GLX.glXSwapBuffers (xDisplay, xWindow);
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/opengl/GLData.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/opengl/GLData.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/opengl/GLData.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,139 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.opengl;
+
+/**
+ * The GLData class is a device-independent description
+ * of the pixel format attributes of a GL drawable.
+ *
+ * @see GLCanvas
+ * @see <a href="http://www.eclipse.org/swt/snippets/#opengl">OpenGL snippets</a>
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ * 
+ * @since 3.2
+ */
+
+public class GLData {
+	/**
+	 * Specifies a double-buffered surface.  During context
+	 * creation, only double-buffered formats are considered
+	 * when set to true. 
+	 */
+	public boolean doubleBuffer;
+
+	/**
+	 * Specifies a stereo surface.  During context creation,
+	 * only stereo formats are considered when set to true. 
+	 */
+	public boolean stereo;
+
+	/**
+	 * The size in bits of the color buffer's red channel.
+	 * During context creation, this specifies the minimum
+	 * required red bits.
+	 */
+	public int redSize;
+
+	/**
+	 * The size in bits of the color buffer's green channel.
+	 * During context creation, this specifies the minimum
+	 * required green bits.
+	 */
+	public int greenSize;
+
+	/**
+	 * The size in bits of the color buffer's blue channel.
+	 * During context creation, this specifies the minimum
+	 * required blue bits.
+	 */
+	public int blueSize;
+
+	/**
+	 * The size in bits of the color buffer's alpha channel.
+	 * During context creation, this specifies the minimum
+	 * required alpha bits.
+	 */
+	public int alphaSize;
+
+	/**
+	 * The size in bits of the depth buffer.  During context
+	 * creation, the smallest depth buffer of at least the
+	 * specified value is preferred, or zero for no depth
+	 * buffer.
+	 */
+	public int depthSize;
+
+	/**
+	 * The desired number of stencil bitplanes.  During
+	 * context creation, the smallest stencil buffer of at
+	 * least the specified value is preferred, or zero for
+	 * no stencil buffer.
+	 */
+	public int stencilSize;
+
+	/**
+	 * The size in bits of the accumulation buffer's red
+	 * channel. During context creation, this specifies the
+	 * minimum required red bits.
+	 */
+	public int accumRedSize;
+
+	/**
+	 * The size in bits of the accumulation buffer's green
+	 * channel. During context creation, this specifies the
+	 * minimum required green bits.
+	 */
+	public int accumGreenSize;
+
+	/**
+	 * The size in bits of the accumulation buffer's blue
+	 * channel. During context creation, this specifies the
+	 * minimum required blue bits.
+	 */
+	public int accumBlueSize;
+
+	/**
+	 * The size in bits of the accumulation buffer's alpha
+	 * channel. During context creation, this specifies the
+	 * minimum required alpha bits.
+	 */
+	public int accumAlphaSize;
+
+	/**
+	 * The number of multisample buffers used by this context.
+	 * During context creation, this specifies the minimum
+	 * number of multisample buffers requested.
+	 */
+	public int sampleBuffers;
+
+	/**
+	 * The number of samples accepted in the multisample buffer.
+	 * During creation, pixel formats with the smallest number of
+	 * samples that meets or exceeds the specified minimum number
+	 * are preferred.
+	 */
+	public int samples;
+	
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the data
+ */
+public String toString() {
+	return (doubleBuffer ? "doubleBuffer," : "") +
+		(stereo ? "stereo," : "") +
+		"r:" + redSize + " g:" + greenSize + " b:" + blueSize + " a:" + alphaSize + "," +
+		"depth:" + depthSize + ",stencil:" + stencilSize +
+		",accum r:" + accumRedSize + "g:" + accumGreenSize + "b:" + accumBlueSize + "a:" + accumAlphaSize +
+		",sampleBuffers:" + sampleBuffers + ",samples:" + samples;
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/printing/PrintDialog.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/printing/PrintDialog.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/printing/PrintDialog.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,482 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.printing;
+
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.gtk.*;
+import org.eclipse.swt.printing.PrinterData;
+import org.eclipse.swt.widgets.*;
+
+/**
+ * Instances of this class allow the user to select
+ * a printer and various print-related parameters
+ * prior to starting a print job.
+ * <p>
+ * IMPORTANT: This class is intended to be subclassed <em>only</em>
+ * within the SWT implementation.
+ * </p>
+ *
+ * @see <a href="http://www.eclipse.org/swt/snippets/#printing">Printing snippets</a>
+ * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: ControlExample, Dialog tab</a>
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public class PrintDialog extends Dialog {
+	PrinterData printerData;
+	int scope = PrinterData.ALL_PAGES;
+	int startPage = 1, endPage = 1;
+	boolean printToFile = false;
+
+	int /*long*/ handle;
+	int index;
+	byte [] settingsData;
+	
+	static final String GET_MODAL_DIALOG = "org.eclipse.swt.internal.gtk.getModalDialog";
+	static final String SET_MODAL_DIALOG = "org.eclipse.swt.internal.gtk.setModalDialog";
+	static final String ADD_IDLE_PROC_KEY = "org.eclipse.swt.internal.gtk.addIdleProc";
+	static final String REMOVE_IDLE_PROC_KEY = "org.eclipse.swt.internal.gtk.removeIdleProc";
+	static final String GET_EMISSION_PROC_KEY = "org.eclipse.swt.internal.gtk.getEmissionProc";
+/**
+ * Constructs a new instance of this class given only its parent.
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public PrintDialog (Shell parent) {
+	this (parent, SWT.PRIMARY_MODAL);
+}
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public PrintDialog (Shell parent, int style) {
+	super (parent, parent == null? style : checkStyleBit (parent, style));
+	checkSubclass ();
+}
+
+/**
+ * Sets the printer data that will be used when the dialog
+ * is opened.
+ * 
+ * @param data the data that will be used when the dialog is opened
+ * 
+ * @since 3.4
+ */
+public void setPrinterData(PrinterData data) {
+	this.printerData = data;
+}
+
+/**
+ * Returns the printer data that will be used when the dialog
+ * is opened.
+ * 
+ * @return the data that will be used when the dialog is opened
+ * 
+ * @since 3.4
+ */
+public PrinterData getPrinterData() {
+	return printerData;
+}
+
+static int checkBits (int style, int int0, int int1, int int2, int int3, int int4, int int5) {
+	int mask = int0 | int1 | int2 | int3 | int4 | int5;
+	if ((style & mask) == 0) style |= int0;
+	if ((style & int0) != 0) style = (style & ~mask) | int0;
+	if ((style & int1) != 0) style = (style & ~mask) | int1;
+	if ((style & int2) != 0) style = (style & ~mask) | int2;
+	if ((style & int3) != 0) style = (style & ~mask) | int3;
+	if ((style & int4) != 0) style = (style & ~mask) | int4;
+	if ((style & int5) != 0) style = (style & ~mask) | int5;
+	return style;
+}
+
+static int checkStyleBit (Shell parent, int style) {
+	style &= ~SWT.MIRRORED;
+	if ((style & (SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT)) == 0) {
+		if (parent != null) {
+			if ((parent.getStyle () & SWT.LEFT_TO_RIGHT) != 0) style |= SWT.LEFT_TO_RIGHT;
+			if ((parent.getStyle () & SWT.RIGHT_TO_LEFT) != 0) style |= SWT.RIGHT_TO_LEFT;
+		}
+	}
+	return checkBits (style, SWT.LEFT_TO_RIGHT, SWT.RIGHT_TO_LEFT, 0, 0, 0, 0);
+}
+
+protected void checkSubclass() {
+}
+
+/**
+ * Returns the print job scope that the user selected
+ * before pressing OK in the dialog. This will be one
+ * of the following values:
+ * <dl>
+ * <dt><code>PrinterData.ALL_PAGES</code></dt>
+ * <dd>Print all pages in the current document</dd>
+ * <dt><code>PrinterData.PAGE_RANGE</code></dt>
+ * <dd>Print the range of pages specified by startPage and endPage</dd>
+ * <dt><code>PrinterData.SELECTION</code></dt>
+ * <dd>Print the current selection</dd>
+ * </dl>
+ *
+ * @return the scope setting that the user selected
+ */
+public int getScope() {
+	return scope;
+}
+
+/**
+ * Sets the scope of the print job. The user will see this
+ * setting when the dialog is opened. This can have one of
+ * the following values:
+ * <dl>
+ * <dt><code>PrinterData.ALL_PAGES</code></dt>
+ * <dd>Print all pages in the current document</dd>
+ * <dt><code>PrinterData.PAGE_RANGE</code></dt>
+ * <dd>Print the range of pages specified by startPage and endPage</dd>
+ * <dt><code>PrinterData.SELECTION</code></dt>
+ * <dd>Print the current selection</dd>
+ * </dl>
+ *
+ * @param scope the scope setting when the dialog is opened
+ */
+public void setScope(int scope) {
+	this.scope = scope;
+}
+
+/**
+ * Returns the start page setting that the user selected
+ * before pressing OK in the dialog.
+ * <p>
+ * This value can be from 1 to the maximum number of pages for the platform.
+ * Note that it is only valid if the scope is <code>PrinterData.PAGE_RANGE</code>.
+ * </p>
+ *
+ * @return the start page setting that the user selected
+ */
+public int getStartPage() {
+	return startPage;
+}
+
+/**
+ * Sets the start page that the user will see when the dialog
+ * is opened.
+ * <p>
+ * This value can be from 1 to the maximum number of pages for the platform.
+ * Note that it is only valid if the scope is <code>PrinterData.PAGE_RANGE</code>.
+ * </p>
+ * 
+ * @param startPage the startPage setting when the dialog is opened
+ */
+public void setStartPage(int startPage) {
+	this.startPage = startPage;
+}
+
+/**
+ * Returns the end page setting that the user selected
+ * before pressing OK in the dialog.
+ * <p>
+ * This value can be from 1 to the maximum number of pages for the platform.
+ * Note that it is only valid if the scope is <code>PrinterData.PAGE_RANGE</code>.
+ * </p>
+ *
+ * @return the end page setting that the user selected
+ */
+public int getEndPage() {
+	return endPage;
+}
+
+/**
+ * Sets the end page that the user will see when the dialog
+ * is opened.
+ * <p>
+ * This value can be from 1 to the maximum number of pages for the platform.
+ * Note that it is only valid if the scope is <code>PrinterData.PAGE_RANGE</code>.
+ * </p>
+ * 
+ * @param endPage the end page setting when the dialog is opened
+ */
+public void setEndPage(int endPage) {
+	this.endPage = endPage;
+}
+
+/**
+ * Returns the 'Print to file' setting that the user selected
+ * before pressing OK in the dialog.
+ *
+ * @return the 'Print to file' setting that the user selected
+ */
+public boolean getPrintToFile() {
+	return printToFile;
+}
+
+/**
+ * Sets the 'Print to file' setting that the user will see
+ * when the dialog is opened.
+ *
+ * @param printToFile the 'Print to file' setting when the dialog is opened
+ */
+public void setPrintToFile(boolean printToFile) {
+	this.printToFile = printToFile;
+}
+
+/**
+ * Makes the receiver visible and brings it to the front
+ * of the display.
+ *
+ * @return a printer data object describing the desired print job parameters
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public PrinterData open() {
+	if (OS.GTK_VERSION < OS.VERSION (2, 10, 0)) {
+		return Printer.getDefaultPrinterData();
+	} else {
+		byte [] titleBytes = Converter.wcsToMbcs (null, getText(), true);
+		int /*long*/ topHandle = getParent().handle;
+		while (topHandle != 0 && !OS.GTK_IS_WINDOW(topHandle)) {
+			topHandle = OS.gtk_widget_get_parent(topHandle);
+		}
+		handle = OS.gtk_print_unix_dialog_new(titleBytes, topHandle);
+				
+		//TODO: Not currently implemented. May need new API. For now, disable 'Current' in the dialog. (see gtk bug 344519)
+		OS.gtk_print_unix_dialog_set_current_page(handle, -1);
+		
+		OS.gtk_print_unix_dialog_set_manual_capabilities(handle,
+			OS.GTK_PRINT_CAPABILITY_COLLATE | OS.GTK_PRINT_CAPABILITY_COPIES | OS.GTK_PRINT_CAPABILITY_PAGE_SET);
+		
+		/* Set state into print dialog settings. */
+		int /*long*/ settings = OS.gtk_print_settings_new();
+		int /*long*/ page_setup = OS.gtk_page_setup_new();
+		
+		if (printerData != null) {
+			if (printerData.otherData != null) {
+				Printer.restore(printerData.otherData, settings, page_setup);
+			}
+			/* Set values of settings from PrinterData. */
+			Printer.setScope(settings, printerData.scope, printerData.startPage, printerData.endPage);
+			//TODO: Should we look at printToFile, or driver/name for "Print to File", or both? (see gtk bug 345590)
+			if (printerData.printToFile) {
+				byte [] buffer = Converter.wcsToMbcs (null, printerData.fileName, true);
+				OS.gtk_print_settings_set(settings, OS.GTK_PRINT_SETTINGS_OUTPUT_URI, buffer);
+			}
+			if (printerData.driver.equals("GtkPrintBackendFile") && printerData.name.equals("Print to File")) { //$NON-NLS-1$ //$NON-NLS-2$
+				byte [] buffer = Converter.wcsToMbcs (null, printerData.fileName, true);
+				OS.gtk_print_settings_set(settings, OS.GTK_PRINT_SETTINGS_OUTPUT_URI, buffer);
+			}
+			OS.gtk_print_settings_set_n_copies(settings, printerData.copyCount);
+			OS.gtk_print_settings_set_collate(settings, printerData.collate);	
+		}
+		
+		Printer.setScope(settings, scope, startPage, endPage);
+		if (printToFile) {
+			byte [] buffer = Converter.wcsToMbcs (null, "Print to File", true); //$NON-NLS-1$
+			OS.gtk_print_settings_set_printer(settings, buffer);
+		}
+		OS.gtk_print_unix_dialog_set_settings(handle, settings);
+		OS.gtk_print_unix_dialog_set_page_setup(handle, page_setup);
+		OS.g_object_unref(settings);
+		OS.g_object_unref(page_setup);
+
+		PrinterData data = null;
+		//TODO: Handle 'Print Preview' (GTK_RESPONSE_APPLY).
+		Display display = getParent() != null ? getParent().getDisplay (): Display.getCurrent ();
+		
+		int signalId = 0;
+		int /*long*/ hookId = 0;
+		if ((getStyle () & SWT.RIGHT_TO_LEFT) != 0) {
+			signalId = OS.g_signal_lookup (OS.map, OS.GTK_TYPE_WIDGET());
+			hookId = OS.g_signal_add_emission_hook (signalId, 0, ((LONG) display.getData (GET_EMISSION_PROC_KEY)).value, handle, 0);
+		}	
+		display.setData (ADD_IDLE_PROC_KEY, null);
+		Object oldModal = null;
+		if (OS.gtk_window_get_modal (handle)) {
+			oldModal = display.getData (GET_MODAL_DIALOG);
+			display.setData (SET_MODAL_DIALOG, this);
+		}
+		int response = OS.gtk_dialog_run (handle);
+		if (OS.gtk_window_get_modal (handle)) {
+			display.setData (SET_MODAL_DIALOG, oldModal);
+		}
+		if ((getStyle () & SWT.RIGHT_TO_LEFT) != 0) {
+			OS.g_signal_remove_emission_hook (signalId, hookId);
+		}
+		if (response == OS.GTK_RESPONSE_OK) {
+			int /*long*/ printer = OS.gtk_print_unix_dialog_get_selected_printer(handle);
+			if (printer != 0) {
+				/* Get state from print dialog. */
+				settings = OS.gtk_print_unix_dialog_get_settings(handle); // must unref
+				page_setup = OS.gtk_print_unix_dialog_get_page_setup(handle); // do not unref
+				data = Printer.printerDataFromGtkPrinter(printer);
+				int print_pages = OS.gtk_print_settings_get_print_pages(settings);
+				switch (print_pages) {
+					case OS.GTK_PRINT_PAGES_ALL:
+						scope = PrinterData.ALL_PAGES;
+						break;
+					case OS.GTK_PRINT_PAGES_RANGES:
+						scope = PrinterData.PAGE_RANGE;
+						int[] num_ranges = new int[1];
+						int /*long*/ page_ranges = OS.gtk_print_settings_get_page_ranges(settings, num_ranges);
+						int [] pageRange = new int[2];
+						int length = num_ranges[0];
+						int min = Integer.MAX_VALUE, max = 0;
+						for (int i = 0; i < length; i++) {
+							OS.memmove(pageRange, page_ranges + i * pageRange.length * 4, pageRange.length * 4);
+							min = Math.min(min, pageRange[0] + 1);
+							max = Math.max(max, pageRange[1] + 1);
+						}
+						OS.g_free(page_ranges);
+						startPage = min == Integer.MAX_VALUE ? 1 : min;
+						endPage = max == 0 ? 1 : max;
+						break;
+					case OS.GTK_PRINT_PAGES_CURRENT:
+						//TODO: Disabled in dialog (see above). This code will not run. (see gtk bug 344519)
+						scope = PrinterData.SELECTION;
+						startPage = endPage = OS.gtk_print_unix_dialog_get_current_page(handle);
+						break;
+				}
+				
+				printToFile = data.name.equals("Print to File"); //$NON-NLS-1$
+				if (printToFile) {
+					int /*long*/ address = OS.gtk_print_settings_get(settings, OS.GTK_PRINT_SETTINGS_OUTPUT_URI);
+					int length = OS.strlen (address);
+					byte [] buffer = new byte [length];
+					OS.memmove (buffer, address, length);
+					data.fileName = new String (Converter.mbcsToWcs (null, buffer));
+				}
+
+				data.scope = scope;
+				data.startPage = startPage;
+				data.endPage = endPage;
+				data.printToFile = printToFile;
+				data.copyCount = OS.gtk_print_settings_get_n_copies(settings);
+				data.collate = OS.gtk_print_settings_get_collate(settings);
+
+				/* Save other print_settings data as key/value pairs in otherData. */
+				Callback printSettingsCallback = new Callback(this, "GtkPrintSettingsFunc", 3); //$NON-NLS-1$
+				int /*long*/ GtkPrintSettingsFunc = printSettingsCallback.getAddress();
+				if (GtkPrintSettingsFunc == 0) SWT.error (SWT.ERROR_NO_MORE_CALLBACKS);
+				index = 0;
+				settingsData = new byte[1024];
+				OS.gtk_print_settings_foreach (settings, GtkPrintSettingsFunc, 0);
+				printSettingsCallback.dispose ();
+				index++; // extra null terminator after print_settings and before page_setup
+
+				/* Save page_setup data as key/value pairs in otherData.
+				 * Note that page_setup properties must be stored and restored in the same order.
+				 */
+				store("orientation", OS.gtk_page_setup_get_orientation(page_setup)); //$NON-NLS-1$
+				store("top_margin", OS.gtk_page_setup_get_top_margin(page_setup, OS.GTK_UNIT_MM)); //$NON-NLS-1$
+				store("bottom_margin", OS.gtk_page_setup_get_bottom_margin(page_setup, OS.GTK_UNIT_MM)); //$NON-NLS-1$
+				store("left_margin", OS.gtk_page_setup_get_left_margin(page_setup, OS.GTK_UNIT_MM)); //$NON-NLS-1$
+				store("right_margin", OS.gtk_page_setup_get_right_margin(page_setup, OS.GTK_UNIT_MM)); //$NON-NLS-1$
+				int /*long*/ paper_size = OS.gtk_page_setup_get_paper_size(page_setup); //$NON-NLS-1$
+				storeBytes("paper_size_name", OS.gtk_paper_size_get_name(paper_size)); //$NON-NLS-1$
+				storeBytes("paper_size_display_name", OS.gtk_paper_size_get_display_name(paper_size)); //$NON-NLS-1$
+				storeBytes("paper_size_ppd_name", OS.gtk_paper_size_get_ppd_name(paper_size)); //$NON-NLS-1$
+				store("paper_size_width", OS.gtk_paper_size_get_width(paper_size, OS.GTK_UNIT_MM)); //$NON-NLS-1$
+				store("paper_size_height", OS.gtk_paper_size_get_height(paper_size, OS.GTK_UNIT_MM)); //$NON-NLS-1$
+				store("paper_size_is_custom", OS.gtk_paper_size_is_custom(paper_size)); //$NON-NLS-1$
+				data.otherData = settingsData;
+				OS.g_object_unref(settings);
+			}
+		}
+		display.setData (REMOVE_IDLE_PROC_KEY, null);
+		OS.gtk_widget_destroy (handle);
+		return data;
+	}
+}
+
+int /*long*/ GtkPrintSettingsFunc (int /*long*/ key, int /*long*/ value, int /*long*/ data) {
+	int length = OS.strlen (key);
+	byte [] keyBuffer = new byte [length];
+	OS.memmove (keyBuffer, key, length);
+	length = OS.strlen (value);
+	byte [] valueBuffer = new byte [length];
+	OS.memmove (valueBuffer, value, length);
+	store(keyBuffer, valueBuffer);
+	return 0;
+}
+
+void store(String key, int value) {
+	store(key, String.valueOf(value));
+}
+
+void store(String key, double value) {
+	store(key, String.valueOf(value));
+}
+
+void store(String key, boolean value) {
+	store(key, String.valueOf(value));
+}
+
+void storeBytes(String key, int /*long*/ value) {
+	int length = OS.strlen (value);
+	byte [] valueBuffer = new byte [length];
+	OS.memmove (valueBuffer, value, length);
+	store(key.getBytes(), valueBuffer);
+}
+
+void store(String key, String value) {
+	store(key.getBytes(), value.getBytes());
+}
+
+void store(byte [] key, byte [] value) {
+	int length = key.length + 1 + value.length + 1;
+	if (index + length + 1 > settingsData.length) {
+		byte [] newData = new byte[settingsData.length + Math.max(length + 1, 1024)];
+		System.arraycopy (settingsData, 0, newData, 0, settingsData.length);
+		settingsData = newData;
+	}
+	System.arraycopy (key, 0, settingsData, index, key.length);
+	index += key.length + 1; // null terminated
+	System.arraycopy (value, 0, settingsData, index, value.length);
+	index += value.length + 1; // null terminated
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/printing/Printer.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/printing/Printer.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/printing/Printer.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,762 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.printing;
+
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.Callback;
+import org.eclipse.swt.internal.Converter;
+import org.eclipse.swt.internal.gtk.OS;
+import org.eclipse.swt.internal.cairo.Cairo;
+
+/**
+ * Instances of this class are used to print to a printer.
+ * Applications create a GC on a printer using <code>new GC(printer)</code>
+ * and then draw on the printer GC using the usual graphics calls.
+ * <p>
+ * A <code>Printer</code> object may be constructed by providing
+ * a <code>PrinterData</code> object which identifies the printer.
+ * A <code>PrintDialog</code> presents a print dialog to the user
+ * and returns an initialized instance of <code>PrinterData</code>.
+ * Alternatively, calling <code>new Printer()</code> will construct a
+ * printer object for the user's default printer.
+ * </p><p>
+ * Application code must explicitly invoke the <code>Printer.dispose()</code> 
+ * method to release the operating system resources managed by each instance
+ * when those instances are no longer required.
+ * </p>
+ *
+ * @see PrinterData
+ * @see PrintDialog
+ * @see <a href="http://www.eclipse.org/swt/snippets/#printing">Printing snippets</a>
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public final class Printer extends Device {
+	static PrinterData [] printerList;
+	
+	PrinterData data;
+	int /*long*/ printer;
+	int /*long*/ printJob;
+	int /*long*/ settings;
+	int /*long*/ pageSetup;
+	int /*long*/ surface;
+	int /*long*/ cairo;
+	
+	/**
+	 * whether or not a GC was created for this printer
+	 */
+	boolean isGCCreated = false;
+	Font systemFont;
+
+	static byte [] settingsData;
+	static int start, end;
+
+	static final String GTK_LPR_BACKEND = "GtkPrintBackendLpr"; //$NON-NLS-1$
+
+	static boolean disablePrinting = System.getProperty("org.eclipse.swt.internal.gtk.disablePrinting") != null; //$NON-NLS-1$
+	
+/**
+ * Returns an array of <code>PrinterData</code> objects
+ * representing all available printers.
+ *
+ * @return the list of available printers
+ */
+public static PrinterData[] getPrinterList() {
+	printerList = new PrinterData [0];
+	if (OS.GTK_VERSION < OS.VERSION (2, 10, 0) || disablePrinting) {
+		return printerList;
+	}
+	if (!OS.g_thread_supported ()) {
+		OS.g_thread_init (0);
+	}
+	OS.gtk_set_locale();
+	if (!OS.gtk_init_check (new int /*long*/ [] {0}, null)) {
+		SWT.error (SWT.ERROR_NO_HANDLES, null, " [gtk_init_check() failed]");
+	}
+	Callback printerCallback = new Callback(Printer.class, "GtkPrinterFunc_List", 2); //$NON-NLS-1$
+	int /*long*/ GtkPrinterFunc_List = printerCallback.getAddress();
+	if (GtkPrinterFunc_List == 0) SWT.error (SWT.ERROR_NO_MORE_CALLBACKS);
+	OS.gtk_enumerate_printers(GtkPrinterFunc_List, 0, 0, true);
+	printerCallback.dispose ();
+	return printerList;
+}
+
+static int /*long*/ GtkPrinterFunc_List (int /*long*/ printer, int /*long*/ user_data) {
+	int length = printerList.length;
+	PrinterData [] newList = new PrinterData [length + 1];
+	System.arraycopy (printerList, 0, newList, 0, length);
+	printerList = newList;
+	printerList [length] = printerDataFromGtkPrinter(printer);
+	/*
+	* Bug in GTK. While performing a gtk_enumerate_printers(), GTK finds all of the 
+	* available printers from each backend and can hang. If a backend requires more 
+	* time to gather printer info, GTK will start an event loop waiting for a done 
+    * signal before continuing. For the Lpr backend, GTK does not send a done signal
+    * which means the event loop never ends. The fix is to check to see if the driver
+    * is of type Lpr, and stop the enumeration, which exits the event loop.
+	*/
+	if (printerList[length].driver.equals (GTK_LPR_BACKEND)) return 1;
+	return 0;
+}
+
+/**
+ * Returns a <code>PrinterData</code> object representing
+ * the default printer or <code>null</code> if there is no 
+ * printer available on the System.
+ *
+ * @return the default printer data or null
+ * 
+ * @since 2.1
+ */
+public static PrinterData getDefaultPrinterData() {
+	printerList = new PrinterData [1];
+	if (OS.GTK_VERSION < OS.VERSION (2, 10, 0) || disablePrinting) {
+		return null;
+	}
+	if (!OS.g_thread_supported ()) {
+		OS.g_thread_init (0);
+	}
+	OS.gtk_set_locale();
+	if (!OS.gtk_init_check (new int /*long*/ [] {0}, null)) {
+		SWT.error (SWT.ERROR_NO_HANDLES, null, " [gtk_init_check() failed]");
+	}
+	Callback printerCallback = new Callback(Printer.class, "GtkPrinterFunc_Default", 2); //$NON-NLS-1$
+	int /*long*/ GtkPrinterFunc_Default = printerCallback.getAddress();
+	if (GtkPrinterFunc_Default == 0) SWT.error (SWT.ERROR_NO_MORE_CALLBACKS);
+	OS.gtk_enumerate_printers(GtkPrinterFunc_Default, 0, 0, true);
+	printerCallback.dispose ();
+	return printerList[0];
+}
+
+static int /*long*/ GtkPrinterFunc_Default (int /*long*/ printer, int /*long*/ user_data) {
+	if (OS.gtk_printer_is_default(printer)) {
+		printerList[0] = printerDataFromGtkPrinter(printer);
+		return 1;
+	} else if (OS.GTK_VERSION < OS.VERSION(2, 10, 12) && printerDataFromGtkPrinter(printer).driver.equals (GTK_LPR_BACKEND)) { 
+		return 1;
+	}
+	return 0;
+}
+
+int /*long*/ gtkPrinterFromPrinterData() {
+	Callback printerCallback = new Callback(this, "GtkPrinterFunc_FindNamedPrinter", 2); //$NON-NLS-1$
+	int /*long*/ GtkPrinterFunc_FindNamedPrinter = printerCallback.getAddress();
+	if (GtkPrinterFunc_FindNamedPrinter == 0) SWT.error (SWT.ERROR_NO_MORE_CALLBACKS);
+	printer = 0;
+	OS.gtk_enumerate_printers(GtkPrinterFunc_FindNamedPrinter, 0, 0, true);
+	printerCallback.dispose ();
+	return printer;
+}
+
+int /*long*/ GtkPrinterFunc_FindNamedPrinter (int /*long*/ printer, int /*long*/ user_data) {
+	PrinterData pd = printerDataFromGtkPrinter(printer);
+	if (pd.driver.equals(data.driver) && pd.name.equals(data.name)) {
+		this.printer = printer;
+		OS.g_object_ref(printer);
+		return 1;
+	} else if (OS.GTK_VERSION < OS.VERSION (2, 10, 12) && pd.driver.equals(GTK_LPR_BACKEND)) {
+		return 1;
+	}
+	return 0;
+}
+
+static PrinterData printerDataFromGtkPrinter(int /*long*/ printer) {
+	int /*long*/ backend = OS.gtk_printer_get_backend(printer);
+	int /*long*/ address = OS.G_OBJECT_TYPE_NAME(backend);
+	int length = OS.strlen (address);
+	byte [] buffer = new byte [length];
+	OS.memmove (buffer, address, length);
+	String backendType = new String (Converter.mbcsToWcs (null, buffer));
+	
+	address = OS.gtk_printer_get_name (printer);
+	length = OS.strlen (address);
+	buffer = new byte [length];
+	OS.memmove (buffer, address, length);
+	String name = new String (Converter.mbcsToWcs (null, buffer));
+
+	return new PrinterData (backendType, name);
+}
+
+/* 
+* Restore printer settings and page_setup data from data.
+*/
+static void restore(byte [] data, int /*long*/ settings, int /*long*/ page_setup) {
+	settingsData = data;
+	start = end = 0;
+	while (end < settingsData.length && settingsData[end] != 0) {
+		start = end;
+		while (end < settingsData.length && settingsData[end] != 0) end++;
+		end++;
+		byte [] keyBuffer = new byte [end - start];
+		System.arraycopy (settingsData, start, keyBuffer, 0, keyBuffer.length);
+		start = end;
+		while (end < settingsData.length && settingsData[end] != 0) end++;
+		end++;
+		byte [] valueBuffer = new byte [end - start];
+		System.arraycopy (settingsData, start, valueBuffer, 0, valueBuffer.length);
+		OS.gtk_print_settings_set(settings, keyBuffer, valueBuffer);
+		if (DEBUG) System.out.println(new String (Converter.mbcsToWcs (null, keyBuffer))+": "+new String (Converter.mbcsToWcs (null, valueBuffer)));
+	}
+	end++; // skip extra null terminator
+	
+	/* Retrieve stored page_setup data.
+	 * Note that page_setup properties must be stored (in PrintDialog) and restored (here) in the same order.
+	 */
+	OS.gtk_page_setup_set_orientation(page_setup, restoreInt("orientation")); //$NON-NLS-1$
+	OS.gtk_page_setup_set_top_margin(page_setup, restoreDouble("top_margin"), OS.GTK_UNIT_MM); //$NON-NLS-1$
+	OS.gtk_page_setup_set_bottom_margin(page_setup, restoreDouble("bottom_margin"), OS.GTK_UNIT_MM); //$NON-NLS-1$
+	OS.gtk_page_setup_set_left_margin(page_setup, restoreDouble("left_margin"), OS.GTK_UNIT_MM); //$NON-NLS-1$
+	OS.gtk_page_setup_set_right_margin(page_setup, restoreDouble("right_margin"), OS.GTK_UNIT_MM); //$NON-NLS-1$
+	byte [] name = restoreBytes("paper_size_name", true); //$NON-NLS-1$
+	byte [] display_name = restoreBytes("paper_size_display_name", true); //$NON-NLS-1$
+	byte [] ppd_name = restoreBytes("paper_size_ppd_name", true); //$NON-NLS-1$
+	double width = restoreDouble("paper_size_width"); //$NON-NLS-1$
+	double height = restoreDouble("paper_size_height"); //$NON-NLS-1$
+	boolean custom = restoreBoolean("paper_size_is_custom"); //$NON-NLS-1$
+	int /*long*/ paper_size = 0;
+	if (custom) {
+		if (ppd_name.length > 0) {
+			paper_size = OS.gtk_paper_size_new_from_ppd(ppd_name, display_name, width, height);
+		} else {
+			paper_size = OS.gtk_paper_size_new_custom(name, display_name, width, height, OS.GTK_UNIT_MM);
+		}
+	} else {
+		paper_size = OS.gtk_paper_size_new(name);
+	}
+	OS.gtk_page_setup_set_paper_size(page_setup, paper_size);
+	OS.gtk_paper_size_free(paper_size);
+}
+
+static void setScope(int /*long*/ settings, int scope, int startPage, int endPage) {
+	switch (scope) {
+	case PrinterData.ALL_PAGES:
+		OS.gtk_print_settings_set_print_pages(settings, OS.GTK_PRINT_PAGES_ALL);
+		break;
+	case PrinterData.PAGE_RANGE:
+		OS.gtk_print_settings_set_print_pages(settings, OS.GTK_PRINT_PAGES_RANGES);
+		int [] pageRange = new int[2];
+		pageRange[0] = startPage - 1;
+		pageRange[1] = endPage - 1;
+		OS.gtk_print_settings_set_page_ranges(settings, pageRange, 1);
+		break;
+	case PrinterData.SELECTION:
+		//TODO: Not correctly implemented. May need new API. For now, set to ALL. (see gtk bug 344519)
+		OS.gtk_print_settings_set_print_pages(settings, OS.GTK_PRINT_PAGES_ALL);
+		break;
+	}
+}
+
+static DeviceData checkNull (PrinterData data) {
+	if (data == null) data = new PrinterData();
+	if (data.driver == null || data.name == null) {
+		PrinterData defaultPrinter = getDefaultPrinterData();
+		if (defaultPrinter == null) SWT.error(SWT.ERROR_NO_HANDLES);
+		data.driver = defaultPrinter.driver;
+		data.name = defaultPrinter.name;		
+	}
+	return data;
+}
+
+/**
+ * Constructs a new printer representing the default printer.
+ * <p>
+ * You must dispose the printer when it is no longer required. 
+ * </p>
+ *
+ * @exception SWTError <ul>
+ *    <li>ERROR_NO_HANDLES - if there are no valid printers
+ * </ul>
+ *
+ * @see Device#dispose
+ */
+public Printer() {
+	this(null);
+}
+
+/**
+ * Constructs a new printer given a <code>PrinterData</code>
+ * object representing the desired printer.
+ * <p>
+ * You must dispose the printer when it is no longer required. 
+ * </p>
+ *
+ * @param data the printer data for the specified printer
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the specified printer data does not represent a valid printer
+ * </ul>
+ * @exception SWTError <ul>
+ *    <li>ERROR_NO_HANDLES - if there are no valid printers
+ * </ul>
+ *
+ * @see Device#dispose
+ */
+public Printer(PrinterData data) {
+	super(checkNull(data));
+}
+
+static int restoreInt(String key) {
+	byte [] value = restoreBytes(key, false);
+	return Integer.parseInt(new String(value));
+}
+
+static double restoreDouble(String key) {
+	byte [] value = restoreBytes(key, false);
+	return Double.parseDouble(new String(value));
+}
+
+static boolean restoreBoolean(String key) {
+	byte [] value = restoreBytes(key, false);
+	return Boolean.valueOf(new String(value)).booleanValue();
+}
+
+static byte [] restoreBytes(String key, boolean nullTerminate) {
+	//get key
+	start = end;
+	while (end < settingsData.length && settingsData[end] != 0) end++;
+	end++;
+	byte [] keyBuffer = new byte [end - start];
+	System.arraycopy (settingsData, start, keyBuffer, 0, keyBuffer.length);
+	
+	//get value
+	start = end;
+	while (end < settingsData.length && settingsData[end] != 0) end++;
+	int length = end - start;
+	end++;
+	if (nullTerminate) length++;
+	byte [] valueBuffer = new byte [length];
+	System.arraycopy (settingsData, start, valueBuffer, 0, length);
+	
+	if (DEBUG) System.out.println(new String (Converter.mbcsToWcs (null, keyBuffer))+": "+new String (Converter.mbcsToWcs (null, valueBuffer)));
+
+	return valueBuffer;
+}
+
+/**
+ * Returns a reasonable font for applications to use.
+ * On some platforms, this will match the "default font"
+ * or "system font" if such can be found.  This font
+ * should not be free'd because it was allocated by the
+ * system, not the application.
+ * <p>
+ * Typically, applications which want the default look
+ * should simply not set the font on the widgets they
+ * create. Widgets are always created with the correct
+ * default font for the class of user-interface component
+ * they represent.
+ * </p>
+ *
+ * @return a font
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public Font getSystemFont () {
+	checkDevice ();
+	if (systemFont != null) return systemFont;
+	int /*long*/ style = OS.gtk_widget_get_default_style();	
+	int /*long*/ defaultFont = OS.pango_font_description_copy (OS.gtk_style_get_font_desc (style));
+	return systemFont = Font.gtk_new (this, defaultFont);
+}
+
+/**	 
+ * Invokes platform specific functionality to allocate a new GC handle.
+ * <p>
+ * <b>IMPORTANT:</b> This method is <em>not</em> part of the public
+ * API for <code>Printer</code>. It is marked public only so that it
+ * can be shared within the packages provided by SWT. It is not
+ * available on all platforms, and should never be called from
+ * application code.
+ * </p>
+ *
+ * @param data the platform specific GC data 
+ * @return the platform specific GC handle
+ */
+public int /*long*/ internal_new_GC(GCData data) {
+	int /*long*/ drawable = OS.gdk_pixmap_new(OS.GDK_ROOT_PARENT(), 1, 1, 1);
+	int /*long*/ gdkGC = OS.gdk_gc_new (drawable);
+	if (gdkGC == 0) SWT.error (SWT.ERROR_NO_HANDLES);
+	if (data != null) {
+		if (isGCCreated) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+		int mask = SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT;
+		if ((data.style & mask) == 0) {
+			data.style |= SWT.LEFT_TO_RIGHT;
+		}
+		data.device = this;
+		data.drawable = drawable;
+		data.background = getSystemColor (SWT.COLOR_WHITE).handle;
+		data.foreground = getSystemColor (SWT.COLOR_BLACK).handle;
+		data.font = getSystemFont ();
+		//TODO: We are supposed to return this in pixels, but GTK_UNIT_PIXELS is currently not implemented (gtk bug 346245)
+		data.width = (int)OS.gtk_page_setup_get_paper_width (pageSetup, OS.GTK_UNIT_POINTS);
+		data.height = (int)OS.gtk_page_setup_get_paper_height (pageSetup, OS.GTK_UNIT_POINTS);
+		if (cairo == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+		data.cairo = cairo;
+		isGCCreated = true;
+	}
+	return gdkGC;
+}
+
+/**	 
+ * Invokes platform specific functionality to dispose a GC handle.
+ * <p>
+ * <b>IMPORTANT:</b> This method is <em>not</em> part of the public
+ * API for <code>Printer</code>. It is marked public only so that it
+ * can be shared within the packages provided by SWT. It is not
+ * available on all platforms, and should never be called from
+ * application code.
+ * </p>
+ *
+ * @param hDC the platform specific GC handle
+ * @param data the platform specific GC data 
+ */
+public void internal_dispose_GC(int /*long*/ gdkGC, GCData data) {
+	if (data != null) isGCCreated = false;
+	OS.g_object_unref (gdkGC);
+	if (data != null) {
+		if (data.drawable != 0) OS.g_object_unref (data.drawable);
+		data.drawable = data.cairo = 0;
+	}
+}
+
+/**	 
+ * Releases any internal state prior to destroying this printer.
+ * This method is called internally by the dispose
+ * mechanism of the <code>Device</code> class.
+ */
+protected void release () {
+	super.release();
+	
+	/* Dispose the default font */
+	if (systemFont != null) systemFont.dispose ();
+	systemFont = null;
+}
+
+/**
+ * Starts a print job and returns true if the job started successfully
+ * and false otherwise.
+ * <p>
+ * This must be the first method called to initiate a print job,
+ * followed by any number of startPage/endPage calls, followed by
+ * endJob. Calling startPage, endPage, or endJob before startJob
+ * will result in undefined behavior.
+ * </p>
+ * 
+ * @param jobName the name of the print job to start
+ * @return true if the job started successfully and false otherwise.
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see #startPage
+ * @see #endPage
+ * @see #endJob
+ */
+public boolean startJob(String jobName) {
+	checkDevice();
+	byte [] buffer = Converter.wcsToMbcs (null, jobName, true);
+	printJob = OS.gtk_print_job_new (buffer, printer, settings, pageSetup);
+	if (printJob == 0) return false;
+	surface = OS.gtk_print_job_get_surface(printJob, null);
+	if (surface == 0) {
+		OS.g_object_unref(printJob);
+		printJob = 0;
+		return false;
+	}
+	cairo = Cairo.cairo_create(surface);
+	if (cairo == 0)  {
+		OS.g_object_unref(printJob);
+		printJob = 0;
+		return false;
+	}
+	return true;
+}
+
+/**	 
+ * Destroys the printer handle.
+ * This method is called internally by the dispose
+ * mechanism of the <code>Device</code> class.
+ */
+protected void destroy () {
+	if (printer != 0) OS.g_object_unref (printer);
+	if (settings != 0) OS.g_object_unref (settings);
+	if (pageSetup != 0) OS.g_object_unref (pageSetup);
+	if (cairo != 0) Cairo.cairo_destroy (cairo);
+	if (printJob != 0) OS.g_object_unref (printJob);
+	printer = settings = pageSetup = cairo = printJob = 0;
+}
+
+/**
+ * Ends the current print job.
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see #startJob
+ * @see #startPage
+ * @see #endPage
+ */
+public void endJob() {
+	checkDevice();
+	if (printJob == 0) return;
+	Cairo.cairo_surface_finish(surface);
+	OS.gtk_print_job_send(printJob, 0, 0, 0);
+}
+
+/**
+ * Cancels a print job in progress. 
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void cancelJob() {
+	checkDevice();
+	if (printJob == 0) return;
+	//TODO: Need to implement (waiting on gtk bug 339323) 
+	//OS.g_object_unref(printJob);
+	//printJob = 0;
+}
+
+/**
+ * Starts a page and returns true if the page started successfully
+ * and false otherwise.
+ * <p>
+ * After calling startJob, this method may be called any number of times
+ * along with a matching endPage.
+ * </p>
+ * 
+ * @return true if the page started successfully and false otherwise.
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see #endPage
+ * @see #startJob
+ * @see #endJob
+ */
+public boolean startPage() {
+	checkDevice();
+	if (printJob == 0) return false;
+	double width = OS.gtk_page_setup_get_paper_width (pageSetup, OS.GTK_UNIT_POINTS);
+	double height = OS.gtk_page_setup_get_paper_height (pageSetup, OS.GTK_UNIT_POINTS);
+	int type = Cairo.cairo_surface_get_type (surface);
+	switch (type) {
+		case Cairo.CAIRO_SURFACE_TYPE_PS:
+			Cairo.cairo_ps_surface_set_size (surface, width, height);
+			break;
+		case Cairo.CAIRO_SURFACE_TYPE_PDF:
+			Cairo.cairo_pdf_surface_set_size (surface, width, height);
+			break;
+	}
+	return true;
+}
+
+/**
+ * Ends the current page.
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see #startPage
+ * @see #startJob
+ * @see #endJob
+ */
+public void endPage() {
+	checkDevice();
+	if (cairo != 0) Cairo.cairo_show_page(cairo);
+}
+
+/**
+ * Returns a point whose x coordinate is the horizontal
+ * dots per inch of the printer, and whose y coordinate
+ * is the vertical dots per inch of the printer.
+ *
+ * @return the horizontal and vertical DPI
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public Point getDPI() {
+	checkDevice();
+	int resolution = OS.gtk_print_settings_get_resolution(settings);
+	if (DEBUG) System.out.println("print_settings.resolution=" + resolution);
+	//TODO: Return 72 (1/72 inch = 1 point) until gtk bug 346245 is fixed
+	//TODO: Fix this: gtk_print_settings_get_resolution returns 0? (see gtk bug 346252)
+	if (true || resolution == 0) return new Point(72, 72);
+	return new Point(resolution, resolution);
+}
+
+/**
+ * Returns a rectangle describing the receiver's size and location.
+ * <p>
+ * For a printer, this is the size of the physical page, in pixels.
+ * </p>
+ *
+ * @return the bounding rectangle
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see #getClientArea
+ * @see #computeTrim
+ */
+public Rectangle getBounds() {
+	checkDevice();
+	//TODO: We are supposed to return this in pixels, but GTK_UNIT_PIXELS is currently not implemented (gtk bug 346245)
+	double width = OS.gtk_page_setup_get_paper_width (pageSetup, OS.GTK_UNIT_POINTS);
+	double height = OS.gtk_page_setup_get_paper_height (pageSetup, OS.GTK_UNIT_POINTS);
+	return new Rectangle(0, 0, (int) width, (int) height);
+}
+
+/**
+ * Returns a rectangle which describes the area of the
+ * receiver which is capable of displaying data.
+ * <p>
+ * For a printer, this is the size of the printable area
+ * of the page, in pixels.
+ * </p>
+ * 
+ * @return the client area
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see #getBounds
+ * @see #computeTrim
+ */
+public Rectangle getClientArea() {
+	checkDevice();
+	//TODO: We are supposed to return this in pixels, but GTK_UNIT_PIXELS is currently not implemented (gtk bug 346245)
+	double width = OS.gtk_page_setup_get_page_width(pageSetup, OS.GTK_UNIT_POINTS);
+	double height = OS.gtk_page_setup_get_page_height(pageSetup, OS.GTK_UNIT_POINTS);
+	return new Rectangle(0, 0, (int) width, (int) height);
+}
+
+/**
+ * Given a <em>client area</em> (as described by the arguments),
+ * returns a rectangle, relative to the client area's coordinates,
+ * that is the client area expanded by the printer's trim (or minimum margins).
+ * <p>
+ * Most printers have a minimum margin on each edge of the paper where the
+ * printer device is unable to print.  This margin is known as the "trim."
+ * This method can be used to calculate the printer's minimum margins
+ * by passing in a client area of 0, 0, 0, 0 and then using the resulting
+ * x and y coordinates (which will be <= 0) to determine the minimum margins
+ * for the top and left edges of the paper, and the resulting width and height
+ * (offset by the resulting x and y) to determine the minimum margins for the
+ * bottom and right edges of the paper, as follows:
+ * <ul>
+ * 		<li>The left trim width is -x pixels</li>
+ * 		<li>The top trim height is -y pixels</li>
+ * 		<li>The right trim width is (x + width) pixels</li>
+ * 		<li>The bottom trim height is (y + height) pixels</li>
+ * </ul>
+ * </p>
+ * 
+ * @param x the x coordinate of the client area
+ * @param y the y coordinate of the client area
+ * @param width the width of the client area
+ * @param height the height of the client area
+ * @return a rectangle, relative to the client area's coordinates, that is
+ * 		the client area expanded by the printer's trim (or minimum margins)
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see #getBounds
+ * @see #getClientArea
+ */
+public Rectangle computeTrim(int x, int y, int width, int height) {
+	checkDevice();
+	//TODO: We are supposed to return this in pixels, but GTK_UNIT_PIXELS is currently not implemented (gtk bug 346245)
+	double printWidth = OS.gtk_page_setup_get_page_width(pageSetup, OS.GTK_UNIT_POINTS);
+	double printHeight = OS.gtk_page_setup_get_page_height(pageSetup, OS.GTK_UNIT_POINTS);
+	double paperWidth = OS.gtk_page_setup_get_paper_width (pageSetup, OS.GTK_UNIT_POINTS);
+	double paperHeight = OS.gtk_page_setup_get_paper_height (pageSetup, OS.GTK_UNIT_POINTS);
+	double printX = -OS.gtk_page_setup_get_left_margin(pageSetup, OS.GTK_UNIT_POINTS);
+	double printY = -OS.gtk_page_setup_get_top_margin(pageSetup, OS.GTK_UNIT_POINTS);
+	double hTrim = paperWidth - printWidth;
+	double vTrim = paperHeight - printHeight;
+	return new Rectangle(x + (int)printX, y + (int)printY, width + (int)hTrim, height + (int)vTrim);
+}
+
+/**	 
+ * Creates the printer handle.
+ * This method is called internally by the instance creation
+ * mechanism of the <code>Device</code> class.
+ * @param deviceData the device data
+ */
+protected void create(DeviceData deviceData) {
+	this.data = (PrinterData)deviceData;
+	if (OS.GTK_VERSION < OS.VERSION (2, 10, 0) || disablePrinting) SWT.error(SWT.ERROR_NO_HANDLES);
+	printer = gtkPrinterFromPrinterData();
+	if (printer == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+}
+
+/**
+ * Initializes any internal resources needed by the
+ * device.
+ * <p>
+ * This method is called after <code>create</code>.
+ * </p><p>
+ * If subclasses reimplement this method, they must
+ * call the <code>super</code> implementation.
+ * </p>
+ * 
+ * @see #create
+ */
+protected void init() {
+	super.init ();
+	settings = OS.gtk_print_settings_new();
+	pageSetup = OS.gtk_page_setup_new();
+	if (data.otherData != null) {
+		restore(data.otherData, settings, pageSetup);
+	}
+	
+	/* Set values of settings from PrinterData. */
+	setScope(settings, data.scope, data.startPage, data.endPage);
+	//TODO: Should we look at printToFile, or driver/name for "Print to File", or both? (see gtk bug 345590)
+	if (data.printToFile) {
+		byte [] buffer = Converter.wcsToMbcs (null, data.fileName, true);
+		OS.gtk_print_settings_set(settings, OS.GTK_PRINT_SETTINGS_OUTPUT_URI, buffer);
+	}
+	if (data.driver.equals("GtkPrintBackendFile") && data.name.equals("Print to File")) { //$NON-NLS-1$ //$NON-NLS-2$
+		byte [] buffer = Converter.wcsToMbcs (null, data.fileName, true);
+		OS.gtk_print_settings_set(settings, OS.GTK_PRINT_SETTINGS_OUTPUT_URI, buffer);
+	}
+	OS.gtk_print_settings_set_n_copies(settings, data.copyCount);
+	OS.gtk_print_settings_set_collate(settings, data.collate);
+}
+
+/**
+ * Returns a <code>PrinterData</code> object representing the
+ * target printer for this print job.
+ * 
+ * @return a PrinterData object describing the receiver
+ */
+public PrinterData getPrinterData() {
+	checkDevice();
+	return data;
+}
+
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/printing/PrinterData.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/printing/PrinterData.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/printing/PrinterData.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,171 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.printing;
+
+
+import org.eclipse.swt.graphics.*;
+
+/**
+ * Instances of this class are descriptions of a print job
+ * in terms of the printer, and the scope and type of printing
+ * that is desired. For example, the number of pages and copies
+ * can be specified, as well as whether or not the print job
+ * should go to a file.
+ * <p>
+ * Application code does <em>not</em> need to explicitly release the
+ * resources managed by each instance when those instances are no longer
+ * required, and thus no <code>dispose()</code> method is provided.
+ * </p>
+ *
+ * @see Printer
+ * @see Printer#getPrinterList
+ * @see PrintDialog#open
+ * @see <a href="http://www.eclipse.org/swt/snippets/#printing">Printing snippets</a>
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+
+public final class PrinterData extends DeviceData {
+	
+	/**
+	 * the printer driver
+	 * On Windows systems, this is the name of the driver (often "winspool").
+	 * On Mac OSX, this is the destination type ("Printer", "Fax", "File", or "Preview").
+	 * On X/Window systems, this is the name of a display connection to the
+	 * Xprt server (the default is ":1").
+	 * On GTK+, this is the backend type name (eg. GtkPrintBackendCups).
+	 */
+	// TODO: note that this api is not finalized for GTK+
+	public String driver;
+	
+	/**
+	 * the name of the printer
+	 * On Windows systems, this is the name of the 'device'.
+	 * On Mac OSX, X/Window systems, and GTK+, this is the printer's 'name'.
+	 */
+	public String name;
+	
+	/**
+	 * the scope of the print job, expressed as one of the following values:
+	 * <dl>
+	 * <dt><code>ALL_PAGES</code></dt>
+	 * <dd>Print all pages in the current document</dd>
+	 * <dt><code>PAGE_RANGE</code></dt>
+	 * <dd>Print the range of pages specified by startPage and endPage</dd>
+	 * <dt><code>SELECTION</code></dt>
+	 * <dd>Print the current selection</dd>
+	 * </dl>
+	 */
+	public int scope = ALL_PAGES;
+	
+	/**
+	 * the start page of a page range, used when scope is PAGE_RANGE.
+	 * This value can be from 1 to the maximum number of pages for the platform.
+	 */
+	public int startPage = 0;
+
+	/**
+	 * the end page of a page range, used when scope is PAGE_RANGE.
+	 * This value can be from 1 to the maximum number of pages for the platform.
+	 */
+	public int endPage = 0;
+	
+	/**
+	 * whether or not the print job should go to a file
+	 */
+	public boolean printToFile = false;
+	
+	/**
+	 * the name of the file to print to if printToFile is true.
+	 * Note that this field is ignored if printToFile is false.
+	 */
+	public String fileName;
+	
+	/**
+	 * the number of copies to print.
+	 * Note that this field may be controlled by the printer driver
+	 * In other words, the printer itself may be capable of printing
+	 * multiple copies, and if so, the value of this field will always be 1.
+	 */
+	public int copyCount = 1;
+	
+	/**
+	 * whether or not the printer should collate the printed paper
+	 * Note that this field may be controlled by the printer driver.
+	 * In other words, the printer itself may be capable of doing the
+	 * collation, and if so, the value of this field will always be false.
+	 */
+	public boolean collate = false;
+	
+	/**
+	 * <code>scope</code> field value indicating that
+	 * all pages should be printed
+	 */	
+	public static final int ALL_PAGES = 0;
+	
+	/**
+	 * <code>scope</code> field value indicating that
+	 * the range of pages specified by startPage and endPage
+	 * should be printed
+	 */	
+	public static final int PAGE_RANGE = 1;
+	
+	/**
+	 * <code>scope</code> field value indicating that
+	 * the current selection should be printed
+	 */	
+	public static final int SELECTION = 2;
+	
+	/**
+	 * private, platform-specific data
+	 * On Windows, this contains a copy of the DEVMODE struct
+	 * returned from the <code>PrintDialog</code>.
+	 * On GTK, this contains a copy of the print_settings and page_setup
+	 * returned from the <code>PrintDialog</code>.
+	 * On OS X Carbon, this contains a copy of the PrintSettings and PageFormat
+	 * returned from the <code>PrintDialog</code>.
+	 * This field is not currently used on the X/Window System.
+	 */	
+	byte [] otherData;
+
+	/**
+	 * Constructs an instance of this class that can be
+	 * used to print to the default printer.
+	 * 
+	 * @see Printer#getDefaultPrinterData
+	 */
+	public PrinterData() {
+	}
+
+	/**
+	 * Constructs an instance of this class with the given
+	 * printer driver and printer name.
+	 *
+	 * @param driver the printer driver for the printer
+	 * @param name the name of the printer
+	 *
+	 * @see #driver
+	 * @see #name
+	 */
+	public PrinterData(String driver, String name) {
+		this.driver = driver;
+		this.name = name;
+	}
+
+	/**
+	 * Returns a string containing a concise, human-readable
+	 * description of the receiver.
+	 *
+	 * @return a string representation of the receiver
+	 */
+	public String toString() {
+		return "PrinterData {" + "driver = " + driver + ", name = " + name + "}";  //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+	}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/program/Program.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/program/Program.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/program/Program.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,810 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.program;
+
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.gnome.*;
+import org.eclipse.swt.internal.cde.*;
+import org.eclipse.swt.internal.gtk.*;
+import org.eclipse.swt.widgets.*;
+
+import java.io.*;
+import java.util.*;
+
+/**
+ * Instances of this class represent programs and
+ * their associated file extensions in the operating
+ * system.
+ *
+ * @see <a href="http://www.eclipse.org/swt/snippets/#program">Program snippets</a>
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public final class Program {
+	String name;
+	String command;
+	String iconPath;
+	Display display;
+
+	/* Gnome specific
+	 * true if command expects a URI
+	 * false if expects a path
+	 */
+	boolean gnomeExpectUri;
+	
+	static int /*long*/ cdeShell;
+
+	static final String[] CDE_ICON_EXT = { ".m.pm",   ".l.pm",   ".s.pm",   ".t.pm" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+	static final String[] CDE_MASK_EXT = { ".m_m.bm", ".l_m.bm", ".s_m.bm", ".t_m.bm" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+	static final String DESKTOP_DATA = "Program_DESKTOP"; //$NON-NLS-1$
+	static final String ICON_THEME_DATA = "Program_GNOME_ICON_THEME"; //$NON-NLS-1$
+	static final String PREFIX_HTTP = "http://"; //$NON-NLS-1$
+	static final String PREFIX_HTTPS = "https://"; //$NON-NLS-1$
+	static final int DESKTOP_UNKNOWN = 0;
+	static final int DESKTOP_GNOME = 1;
+	static final int DESKTOP_GNOME_24 = 2;
+	static final int DESKTOP_CDE = 3;
+	static final int PREFERRED_ICON_SIZE = 16;
+	
+/**
+ * Prevents uninitialized instances from being created outside the package.
+ */
+Program() {
+}
+
+/* Determine the desktop for the given display. */
+static int getDesktop(final Display display) {
+	if (display == null) return DESKTOP_UNKNOWN;	
+	Integer desktopValue = (Integer)display.getData(DESKTOP_DATA);
+	if (desktopValue != null) return desktopValue.intValue();
+	int desktop = DESKTOP_UNKNOWN;
+
+	/* Get the list of properties on the root window. */
+	int /*long*/ xDisplay = OS.GDK_DISPLAY();
+	int /*long*/ rootWindow = OS.XDefaultRootWindow(xDisplay);
+	int[] numProp = new int[1];
+	int /*long*/ propList = OS.XListProperties(xDisplay, rootWindow, numProp);
+	int /*long*/ [] property = new int /*long*/ [numProp[0]];
+	if (propList != 0) {
+		OS.memmove(property, propList, (property.length * OS.PTR_SIZEOF));
+		OS.XFree(propList);
+	}
+
+	/*
+	 * Feature in Linux Desktop. There is currently no official way to
+	 * determine whether the Gnome window manager or gnome-vfs is
+	 * available. Earlier versions including Red Hat 9 and Suse 9 provide
+	 * a documented Gnome specific property on the root window 
+	 * WIN_SUPPORTING_WM_CHECK. This property is no longer supported in newer
+	 * versions such as Fedora Core 2.
+	 * The workaround is to simply check that the window manager is a 
+	 * compliant one (property _NET_SUPPORTING_WM_CHECK) and to attempt to load 
+	 * our native library that depends on gnome-vfs.
+	 */
+	if (desktop == DESKTOP_UNKNOWN) {
+		byte[] gnomeName = Converter.wcsToMbcs(null, "_NET_SUPPORTING_WM_CHECK", true);
+		int /*long*/ gnome = OS.XInternAtom(xDisplay, gnomeName, true);
+		if (gnome != OS.None && (OS.GTK_VERSION >= OS.VERSION (2, 2, 0)) && gnome_init()) {
+			desktop = DESKTOP_GNOME;
+			int /*long*/ icon_theme = GNOME.gnome_icon_theme_new();
+			display.setData(ICON_THEME_DATA, new LONG(icon_theme));
+			display.addListener(SWT.Dispose, new Listener() {
+				public void handleEvent(Event event) {
+					LONG gnomeIconTheme = (LONG)display.getData(ICON_THEME_DATA);
+					if (gnomeIconTheme == null) return;
+					display.setData(ICON_THEME_DATA, null);
+					/* 
+					 * Note.  gnome_icon_theme_new uses g_object_new to allocate the
+					 * data it returns. Use g_object_unref to free the pointer it returns.
+					 */
+					if (gnomeIconTheme.value != 0) GNOME.g_object_unref(gnomeIconTheme.value);
+				}
+			});
+			/* Check for libgnomevfs-2 version 2.4 */
+			byte[] buffer = Converter.wcsToMbcs(null, "libgnomevfs-2.so.0", true);
+			int /*long*/ libgnomevfs = OS.dlopen(buffer, OS.RTLD_LAZY);
+			if (libgnomevfs != 0) {
+				buffer = Converter.wcsToMbcs(null, "gnome_vfs_url_show", true);
+				int /*long*/ gnome_vfs_url_show = OS.dlsym(libgnomevfs, buffer);
+				if (gnome_vfs_url_show != 0) {
+					desktop = DESKTOP_GNOME_24;
+				}
+				OS.dlclose(libgnomevfs);
+			}
+		}
+	}
+
+	/*
+	* On CDE, the atom below may exist without DTWM running. If the atom 
+	* below is defined, the CDE database exists and the available
+	* applications can be queried.
+	*/
+	if (desktop == DESKTOP_UNKNOWN) {
+		byte[] cdeName = Converter.wcsToMbcs(null, "_DT_SM_PREFERENCES", true);
+		int /*long*/ cde = OS.XInternAtom(xDisplay, cdeName, true);
+		for (int index = 0; desktop == DESKTOP_UNKNOWN && index < property.length; index++) {
+			if (property[index] == OS.None) continue; /* do not match atoms that do not exist */
+			if (property[index] == cde && cde_init(display)) desktop = DESKTOP_CDE;
+		}
+	}
+
+	display.setData(DESKTOP_DATA, new Integer(desktop));
+	return desktop;
+}
+
+boolean cde_execute(String fileName) {
+	/* Use the character encoding for the default locale */
+	byte[] action = Converter.wcsToMbcs(null, command, true);
+	byte[] fileArg = Converter.wcsToMbcs(null, fileName, true);
+	int /*long*/ ptr = OS.g_malloc(fileArg.length);
+	OS.memmove(ptr, fileArg, fileArg.length);
+	DtActionArg args = new DtActionArg();
+	args.argClass = CDE.DtACTION_FILE;
+	args.name = ptr;
+	long actionID = CDE.DtActionInvoke(cdeShell, action, args, 1, null, null, null, 1, 0, 0);
+	OS.g_free(ptr);
+	return actionID != 0;
+}
+
+static String cde_getAction(String dataType) {
+	String action  = null;
+	String actions = cde_getAttribute(dataType, CDE.DtDTS_DA_ACTION_LIST);
+	if (actions != null) {
+		int index = actions.indexOf("Open");
+		if (index != -1) {
+			action = actions.substring(index, index + 4);
+		} else {
+			index = actions.indexOf(",");
+			action = index != -1 ? actions.substring(0, index) : actions;
+		}
+	}
+	return action;
+}
+
+static String cde_getAttribute(String dataType, String attrName) {
+	/* Use the character encoding for the default locale */
+	byte[] dataTypeBuf = Converter.wcsToMbcs(null, dataType, true);
+	byte[] attrNameBuf = Converter.wcsToMbcs(null, attrName, true);
+	byte[] optNameBuf = null;
+	int /*long*/ attrValue = CDE.DtDtsDataTypeToAttributeValue(dataTypeBuf, attrNameBuf, optNameBuf);
+	if (attrValue == 0) return null;
+	int length = OS.strlen(attrValue);
+	byte[] attrValueBuf = new byte[length];
+	OS.memmove(attrValueBuf, attrValue, length);
+	CDE.DtDtsFreeAttributeValue(attrValue);
+	/* Use the character encoding for the default locale */
+	return new String(Converter.mbcsToWcs(null, attrValueBuf));
+}
+
+static Hashtable cde_getDataTypeInfo() {
+	Hashtable dataTypeInfo = new Hashtable();
+	int index;
+	int /*long*/ dataTypeList = CDE.DtDtsDataTypeNames();
+	if (dataTypeList != 0) {
+		/* For each data type name in the list */
+		index = 0; 
+		int /*long*/ [] dataType = new int /*long*/ [1];
+		OS.memmove(dataType, dataTypeList + (index++ * 4), 4);
+		while (dataType[0] != 0) {
+			int length = OS.strlen(dataType[0]);
+			byte[] dataTypeBuf = new byte[length];
+			OS.memmove(dataTypeBuf, dataType[0], length);
+			/* Use the character encoding for the default locale */
+			String dataTypeName = new String(Converter.mbcsToWcs(null, dataTypeBuf));
+     		
+			/* The data type is valid if it is not an action, and it has an extension and an action. */
+			String extension = cde_getExtension(dataTypeName);
+			if (!CDE.DtDtsDataTypeIsAction(dataTypeBuf) &&
+				extension != null && cde_getAction(dataTypeName) != null) {
+				Vector exts = new Vector();
+				exts.addElement(extension);
+				dataTypeInfo.put(dataTypeName, exts);
+			}
+			OS.memmove(dataType, dataTypeList + (index++ * 4), 4);
+		}
+		CDE.DtDtsFreeDataTypeNames(dataTypeList);
+	}
+	
+	return dataTypeInfo;
+}
+
+static String cde_getExtension(String dataType) {
+	String fileExt = cde_getAttribute(dataType, CDE.DtDTS_DA_NAME_TEMPLATE);
+	if (fileExt == null || fileExt.indexOf("%s.") == -1) return null;
+	int dot = fileExt.indexOf(".");
+	return fileExt.substring(dot);
+}
+
+/**
+ * CDE - Get Image Data
+ * 
+ * This method returns the image data of the icon associated with
+ * the data type. Since CDE supports multiple sizes of icons, several
+ * attempts are made to locate an icon of the desired size and format.
+ * CDE supports the sizes: tiny, small, medium and large. The best
+ * search order is medium, large, small and then tiny. Althoug CDE supports
+ * colour and monochrome bitmaps, only colour icons are tried. (The order is
+ * defined by the  cdeIconExt and cdeMaskExt arrays above.)
+ */
+ImageData cde_getImageData() {
+	// TODO
+	return null;	
+}
+
+static String cde_getMimeType(String extension) {
+	String mimeType = null;
+	Hashtable mimeInfo = cde_getDataTypeInfo();
+	if (mimeInfo == null) return null;
+	Enumeration keys = mimeInfo.keys();
+	while (mimeType == null && keys.hasMoreElements()) {
+		String type = (String)keys.nextElement();
+		Vector mimeExts = (Vector)mimeInfo.get(type);
+		for (int index = 0; index < mimeExts.size(); index++){
+			if (extension.equals(mimeExts.elementAt(index))) {
+				mimeType = type;
+				break;
+			}
+		}
+	}
+	return mimeType;
+}
+
+static Program cde_getProgram(Display display, String mimeType) {
+	Program program = new Program();
+	program.display = display;
+	program.name = mimeType;
+	program.command = cde_getAction(mimeType);
+	program.iconPath = cde_getAttribute(program.name, CDE.DtDTS_DA_ICON);
+	return program;
+}
+
+static boolean cde_init(Display display) {
+	try {
+		Library.loadLibrary("swt-cde");
+	} catch (Throwable e) {
+		return false;
+	}
+
+	/* Use the character encoding for the default locale */
+	CDE.XtToolkitInitialize();
+	int /*long*/ xtContext = CDE.XtCreateApplicationContext ();
+	int /*long*/ xDisplay = OS.GDK_DISPLAY();
+	byte[] appName = Converter.wcsToMbcs(null, "CDE", true);
+	byte[] appClass = Converter.wcsToMbcs(null, "CDE", true);
+	int /*long*/ [] argc = new int /*long*/ [] {0};
+	CDE.XtDisplayInitialize(xtContext, xDisplay, appName, appClass, 0, 0, argc, 0);
+	int /*long*/ widgetClass = CDE.topLevelShellWidgetClass ();
+	cdeShell = CDE.XtAppCreateShell (appName, appClass, widgetClass, xDisplay, null, 0);
+	CDE.XtSetMappedWhenManaged (cdeShell, false);
+	CDE.XtResizeWidget (cdeShell, 10, 10, 0);
+	CDE.XtRealizeWidget (cdeShell);
+	boolean initOK = CDE.DtAppInitialize(xtContext, xDisplay, cdeShell, appName, appName);
+	if (initOK) CDE.DtDbLoad();
+	return initOK;
+}
+
+static String[] parseCommand(String cmd) {
+	Vector args = new Vector();
+	int sIndex = 0;
+	int eIndex;
+	while (sIndex < cmd.length()) {
+		/* Trim initial white space of argument. */
+		while (sIndex < cmd.length() && Compatibility.isWhitespace(cmd.charAt(sIndex))) {
+			sIndex++;
+		}
+		if (sIndex < cmd.length()) {
+			/* If the command is a quoted string */
+			if (cmd.charAt(sIndex) == '"' || cmd.charAt(sIndex) == '\'') {
+				/* Find the terminating quote (or end of line).
+				 * This code currently does not handle escaped characters (e.g., " a\"b").
+				 */
+				eIndex = sIndex + 1;
+				while (eIndex < cmd.length() && cmd.charAt(eIndex) != cmd.charAt(sIndex)) eIndex++;
+				if (eIndex >= cmd.length()) { 
+					/* The terminating quote was not found
+					 * Add the argument as is with only one initial quote.
+					 */
+					args.addElement(cmd.substring(sIndex, eIndex));
+				} else {
+					/* Add the argument, trimming off the quotes. */
+					args.addElement(cmd.substring(sIndex + 1, eIndex));
+				}
+				sIndex = eIndex + 1;
+			}
+			else {
+				/* Use white space for the delimiters. */
+				eIndex = sIndex;
+				while (eIndex < cmd.length() && !Compatibility.isWhitespace(cmd.charAt(eIndex))) eIndex++;
+				args.addElement(cmd.substring(sIndex, eIndex));
+				sIndex = eIndex + 1;
+			}
+		}
+	}
+	
+	String[] strings = new String[args.size()];
+	for (int index =0; index < args.size(); index++) {
+		strings[index] = (String)args.elementAt(index);
+	}
+	return strings;
+}
+
+/**
+ * GNOME 2.4 - Execute the program for the given file. 
+ */
+boolean gnome_24_execute(String fileName) {
+	byte[] mimeTypeBuffer = Converter.wcsToMbcs(null, name, true);
+	int /*long*/ ptr = GNOME.gnome_vfs_mime_get_default_application(mimeTypeBuffer);
+	byte[] fileNameBuffer = Converter.wcsToMbcs(null, fileName, true);
+	int /*long*/ uri = GNOME.gnome_vfs_make_uri_from_input_with_dirs(fileNameBuffer, GNOME.GNOME_VFS_MAKE_URI_DIR_CURRENT);
+	int /*long*/ list = GNOME.g_list_append(0, uri);
+	int result = GNOME.gnome_vfs_mime_application_launch(ptr, list);
+	GNOME.gnome_vfs_mime_application_free(ptr);
+	GNOME.g_free(uri);
+	GNOME.g_list_free(list);
+	return result == GNOME.GNOME_VFS_OK;
+}
+
+/**
+ * GNOME 2.4 - Launch the default program for the given file. 
+ */
+static boolean gnome_24_launch(String fileName) {
+	byte[] fileNameBuffer = Converter.wcsToMbcs(null, fileName, true);
+	int /*long*/ uri = GNOME.gnome_vfs_make_uri_from_input_with_dirs(fileNameBuffer, GNOME.GNOME_VFS_MAKE_URI_DIR_CURRENT);
+	int result = GNOME.gnome_vfs_url_show(uri);
+	GNOME.g_free(uri);
+	return (result == GNOME.GNOME_VFS_OK);
+}
+
+/**
+ * GNOME 2.2 - Execute the program for the given file. 
+ */
+boolean gnome_execute(String fileName) {
+	if (gnomeExpectUri) {
+		/* Convert the given path into a URL */
+		byte[] fileNameBuffer = Converter.wcsToMbcs(null, fileName, true);
+		int /*long*/ uri = GNOME.gnome_vfs_make_uri_from_input(fileNameBuffer);
+		if (uri != 0) {
+			int length = OS.strlen(uri);
+			if (length > 0) {
+				byte[] buffer = new byte[length];
+				OS.memmove(buffer, uri, length);
+				fileName = new String(Converter.mbcsToWcs(null, buffer));
+			}
+			GNOME.g_free(uri);
+		}
+	}
+
+	/* Parse the command into its individual arguments. */
+	String[] args = parseCommand(command);
+	int fileArg = -1;
+	int index;
+	for (index = 0; index < args.length; index++) {
+		int j = args[index].indexOf("%f");
+		if (j != -1) {
+			String value = args[index];
+			fileArg = index;
+			args[index] = value.substring(0, j) + fileName + value.substring(j + 2);
+		}
+	}
+
+	/* If a file name was given but the command did not have "%f" */
+	if ((fileName.length() > 0) && (fileArg < 0)) {
+		String[] newArgs = new String[args.length + 1];
+		for (index = 0; index < args.length; index++) newArgs[index] = args[index];
+		newArgs[args.length] = fileName;
+		args = newArgs;
+	}
+
+	/* Execute the command. */
+	try {
+		Compatibility.exec(args);
+	} catch (IOException e) {
+		return false;
+	}
+	return true;
+}
+
+/**
+ * GNOME - Get Image Data
+ * 
+ */ 
+ImageData gnome_getImageData() {
+	if (iconPath == null) return null;
+	try {
+		return new ImageData(iconPath);
+	} catch (Exception e) {}
+	return null;
+}
+
+/**
+ * GNOME - Get mime types
+ * 
+ * Obtain the registered mime type information and
+ * return it in a map. The key of each entry
+ * in the map is the mime type name. The value is
+ * a vector of the associated file extensions.
+ */
+static Hashtable gnome_getMimeInfo() {
+	Hashtable mimeInfo = new Hashtable();
+	int /*long*/[] mimeData = new int /*long*/[1];
+	int /*long*/[] extensionData = new int /*long*/[1];
+	int /*long*/ mimeList = GNOME.gnome_vfs_get_registered_mime_types();
+	int /*long*/ mimeElement = mimeList;
+	while (mimeElement != 0) {
+		OS.memmove (mimeData, mimeElement, OS.PTR_SIZEOF);
+		int /*long*/ mimePtr = mimeData[0];
+		int mimeLength = OS.strlen(mimePtr);
+		byte[] mimeTypeBuffer = new byte[mimeLength];
+		OS.memmove(mimeTypeBuffer, mimePtr, mimeLength);
+		String mimeType = new String(Converter.mbcsToWcs(null, mimeTypeBuffer));
+		int /*long*/ extensionList = GNOME.gnome_vfs_mime_get_extensions_list(mimePtr);
+		if (extensionList != 0) {
+			Vector extensions = new Vector();
+			int /*long*/ extensionElement = extensionList;
+			while (extensionElement != 0) {
+				OS.memmove(extensionData, extensionElement, OS.PTR_SIZEOF);
+				int /*long*/ extensionPtr = extensionData[0];
+				int extensionLength = OS.strlen(extensionPtr);
+				byte[] extensionBuffer = new byte[extensionLength];
+				OS.memmove(extensionBuffer, extensionPtr, extensionLength);
+				String extension = new String(Converter.mbcsToWcs(null, extensionBuffer));
+				extension = '.' + extension;
+				extensions.addElement(extension);
+				extensionElement = GNOME.g_list_next(extensionElement); 
+			}
+			GNOME.gnome_vfs_mime_extensions_list_free(extensionList);
+			if (extensions.size() > 0) mimeInfo.put(mimeType, extensions);
+		}
+		mimeElement = GNOME.g_list_next(mimeElement);
+	}
+	if (mimeList != 0) GNOME.gnome_vfs_mime_registered_mime_type_list_free(mimeList);
+	return mimeInfo;
+}
+
+static String gnome_getMimeType(String extension) {
+	String mimeType = null;
+	String fileName = "swt" + extension;
+	byte[] extensionBuffer = Converter.wcsToMbcs(null, fileName, true);
+	int /*long*/ typeName = GNOME.gnome_vfs_mime_type_from_name(extensionBuffer);
+	if (typeName != 0) {
+		int length = OS.strlen(typeName);
+		if (length > 0) {
+			byte [] buffer = new byte[length];
+			OS.memmove(buffer, typeName, length);
+			mimeType = new String(Converter.mbcsToWcs(null, buffer));
+		}
+	}
+	return mimeType;
+}
+
+static Program gnome_getProgram(Display display, String mimeType) {
+	Program program = null;
+	byte[] mimeTypeBuffer = Converter.wcsToMbcs(null, mimeType, true);
+	int /*long*/ ptr = GNOME.gnome_vfs_mime_get_default_application(mimeTypeBuffer);
+	if (ptr != 0) {
+		program = new Program();
+		program.display = display;
+		program.name = mimeType;
+		GnomeVFSMimeApplication application = new GnomeVFSMimeApplication();
+		GNOME.memmove(application, ptr, GnomeVFSMimeApplication.sizeof);
+		int length = OS.strlen(application.command);
+		byte[] buffer = new byte[length];
+		OS.memmove(buffer, application.command, length);		
+		program.command = new String(Converter.mbcsToWcs(null, buffer));
+		program.gnomeExpectUri = application.expects_uris == GNOME.GNOME_VFS_MIME_APPLICATION_ARGUMENT_TYPE_URIS;
+		
+		length = OS.strlen(application.id);
+		buffer = new byte[length + 1];
+		OS.memmove(buffer, application.id, length);
+		LONG gnomeIconTheme = (LONG)display.getData(ICON_THEME_DATA);
+		int /*long*/ icon_name = GNOME.gnome_icon_lookup(gnomeIconTheme.value, 0, null, buffer, 0, mimeTypeBuffer, 
+				GNOME.GNOME_ICON_LOOKUP_FLAGS_NONE, null);
+		int /*long*/ path = 0;
+		if (icon_name != 0) path = GNOME.gnome_icon_theme_lookup_icon(gnomeIconTheme.value, icon_name, PREFERRED_ICON_SIZE, null, null);
+		if (path != 0) {
+			length = OS.strlen(path);
+			if (length > 0) {
+				buffer = new byte[length];
+				OS.memmove(buffer, path, length);
+				program.iconPath = new String(Converter.mbcsToWcs(null, buffer));
+			}
+			GNOME.g_free(path);
+		}
+		if (icon_name != 0) GNOME.g_free(icon_name);
+		GNOME.gnome_vfs_mime_application_free(ptr);
+	}
+	return program;
+}
+
+static boolean gnome_init() {
+	try {
+		return GNOME.gnome_vfs_init();
+	} catch (Throwable e) {
+		return false;
+	}
+}
+
+/**
+ * Finds the program that is associated with an extension.
+ * The extension may or may not begin with a '.'.  Note that
+ * a <code>Display</code> must already exist to guarantee that
+ * this method returns an appropriate result.
+ *
+ * @param extension the program extension
+ * @return the program or <code>null</code>
+ *
+ * @exception IllegalArgumentException <ul>
+ *		<li>ERROR_NULL_ARGUMENT when extension is null</li>
+ *	</ul>
+ */
+public static Program findProgram(String extension) {
+	return findProgram(Display.getCurrent(), extension);
+}
+
+/*
+ *  API: When support for multiple displays is added, this method will
+ *       become public and the original method above can be deprecated.
+ */
+static Program findProgram(Display display, String extension) {
+	if (extension == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	if (extension.length() == 0) return null;
+	if (extension.charAt(0) != '.') extension = "." + extension;
+	int desktop = getDesktop(display);
+	String mimeType = null;
+	switch (desktop) {
+		case DESKTOP_GNOME_24:
+		case DESKTOP_GNOME: mimeType = gnome_getMimeType(extension); break;
+		case DESKTOP_CDE: mimeType = cde_getMimeType(extension); break;
+	}
+	if (mimeType == null) return null;
+	Program program = null;
+	switch (desktop) {
+		case DESKTOP_GNOME_24:
+		case DESKTOP_GNOME: program = gnome_getProgram(display, mimeType); break;
+		case DESKTOP_CDE: program = cde_getProgram(display, mimeType); break;
+	}
+	return program;
+}
+
+/**
+ * Answer all program extensions in the operating system.  Note
+ * that a <code>Display</code> must already exist to guarantee
+ * that this method returns an appropriate result.
+ *
+ * @return an array of extensions
+ */
+public static String[] getExtensions() {
+	return getExtensions(Display.getCurrent());
+}
+
+/*
+ *  API: When support for multiple displays is added, this method will
+ *       become public and the original method above can be deprecated.
+ */
+static String[] getExtensions(Display display) {
+	int desktop = getDesktop(display);
+	Hashtable mimeInfo = null;
+	switch (desktop) {
+		case DESKTOP_GNOME_24: break;
+		case DESKTOP_GNOME: mimeInfo = gnome_getMimeInfo(); break;
+		case DESKTOP_CDE: mimeInfo = cde_getDataTypeInfo(); break;
+	}
+	if (mimeInfo == null) return new String[0];
+
+	/* Create a unique set of the file extensions. */
+	Vector extensions = new Vector();
+	Enumeration keys = mimeInfo.keys();
+	while (keys.hasMoreElements()) {
+		String mimeType = (String)keys.nextElement();
+		Vector mimeExts = (Vector)mimeInfo.get(mimeType);
+		for (int index = 0; index < mimeExts.size(); index++){
+			if (!extensions.contains(mimeExts.elementAt(index))) {
+				extensions.addElement(mimeExts.elementAt(index));
+			}
+		}
+	}
+			
+	/* Return the list of extensions. */
+	String[] extStrings = new String[extensions.size()];
+	for (int index = 0; index < extensions.size(); index++) {
+		extStrings[index] = (String)extensions.elementAt(index);
+	}			
+	return extStrings;
+}
+
+/**
+ * Answers all available programs in the operating system.  Note
+ * that a <code>Display</code> must already exist to guarantee
+ * that this method returns an appropriate result.
+ *
+ * @return an array of programs
+ */
+public static Program[] getPrograms() {
+	return getPrograms(Display.getCurrent());
+}
+
+/*
+ *  API: When support for multiple displays is added, this method will
+ *       become public and the original method above can be deprecated.
+ */
+static Program[] getPrograms(Display display) {
+	int desktop = getDesktop(display);
+	Hashtable mimeInfo = null;
+	switch (desktop) {
+		case DESKTOP_GNOME_24: break;
+		case DESKTOP_GNOME: mimeInfo = gnome_getMimeInfo(); break;
+		case DESKTOP_CDE: mimeInfo = cde_getDataTypeInfo(); break;
+	}
+	if (mimeInfo == null) return new Program[0];
+	Vector programs = new Vector();
+	Enumeration keys = mimeInfo.keys();
+	while (keys.hasMoreElements()) {
+		String mimeType = (String)keys.nextElement();
+		Program program = null;
+		switch (desktop) {
+			case DESKTOP_GNOME: program = gnome_getProgram(display, mimeType); break;
+			case DESKTOP_CDE: program = cde_getProgram(display, mimeType); break;
+		}
+		if (program != null) programs.addElement(program);
+	}
+	Program[] programList = new Program[programs.size()];
+	for (int index = 0; index < programList.length; index++) {
+		programList[index] = (Program)programs.elementAt(index);
+	}
+	return programList;
+}
+
+/**
+ * Launches the operating system executable associated with the file or
+ * URL (http:// or https://).  If the file is an executable then the
+ * executable is launched.  Note that a <code>Display</code> must already
+ * exist to guarantee that this method returns an appropriate result.
+ *
+ * @param fileName the file or program name or URL (http:// or https://)
+ * @return <code>true</code> if the file is launched, otherwise <code>false</code>
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT when fileName is null</li>
+ * </ul>
+ */
+public static boolean launch(String fileName) {
+	return launch(Display.getCurrent(), fileName);
+}
+
+/*
+ *  API: When support for multiple displays is added, this method will
+ *       become public and the original method above can be deprecated.
+ */
+static boolean launch (Display display, String fileName) {
+	if (fileName == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+	switch (getDesktop (display)) {
+		case DESKTOP_GNOME_24:
+			if (gnome_24_launch (fileName)) return true;
+		default:
+			int index = fileName.lastIndexOf ('.');
+			if (index != -1) {
+				String extension = fileName.substring (index);
+				Program program = Program.findProgram (display, extension); 
+				if (program != null && program.execute (fileName)) return true;
+			}
+			String lowercaseName = fileName.toLowerCase ();
+			if (lowercaseName.startsWith (PREFIX_HTTP) || lowercaseName.startsWith (PREFIX_HTTPS)) {
+				Program program = Program.findProgram (display, ".html"); //$NON-NLS-1$
+				if (program == null) {
+					program = Program.findProgram (display, ".htm"); //$NON-NLS-1$
+				}
+				if (program != null && program.execute (fileName)) return true;
+			}
+			break;
+	}
+	try {
+		Compatibility.exec (fileName);
+		return true;
+	} catch (IOException e) {
+		return false;
+	}
+}
+
+/**
+ * Compares the argument to the receiver, and returns true
+ * if they represent the <em>same</em> object using a class
+ * specific comparison.
+ *
+ * @param other the object to compare with this object
+ * @return <code>true</code> if the object is the same as this object and <code>false</code> otherwise
+ *
+ * @see #hashCode()
+ */
+public boolean equals(Object other) {
+	if (this == other) return true;
+	if (!(other instanceof Program)) return false;
+	Program program = (Program)other;
+	return display == program.display && name.equals(program.name) && command.equals(program.command);
+}
+
+/**
+ * Executes the program with the file as the single argument
+ * in the operating system.  It is the responsibility of the
+ * programmer to ensure that the file contains valid data for 
+ * this program.
+ *
+ * @param fileName the file or program name
+ * @return <code>true</code> if the file is launched, otherwise <code>false</code>
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT when fileName is null</li>
+ * </ul>
+ */
+public boolean execute(String fileName) {
+	if (fileName == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+	int desktop = getDesktop(display);
+	switch (desktop) {
+		case DESKTOP_GNOME_24: return gnome_24_execute(fileName);
+		case DESKTOP_GNOME: return gnome_execute(fileName);
+		case DESKTOP_CDE: return cde_execute(fileName);
+	}
+	return false;
+}
+
+/**
+ * Returns the receiver's image data.  This is the icon
+ * that is associated with the receiver in the operating
+ * system.
+ *
+ * @return the image data for the program, may be null
+ */
+public ImageData getImageData() {
+	switch (getDesktop(display)) {
+		case DESKTOP_GNOME_24:
+		case DESKTOP_GNOME: return gnome_getImageData();
+		case DESKTOP_CDE: return cde_getImageData();
+	}
+	return null;
+}
+
+/**
+ * Returns the receiver's name.  This is as short and
+ * descriptive a name as possible for the program.  If
+ * the program has no descriptive name, this string may
+ * be the executable name, path or empty.
+ *
+ * @return the name of the program
+ */
+public String getName() {
+	return name;
+}
+
+/**
+ * Returns an integer hash code for the receiver. Any two 
+ * objects that return <code>true</code> when passed to 
+ * <code>equals</code> must return the same value for this
+ * method.
+ *
+ * @return the receiver's hash
+ *
+ * @see #equals(Object)
+ */
+public int hashCode() {
+	return name.hashCode() ^ command.hashCode() ^ display.hashCode();
+}
+
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the program
+ */
+public String toString() {
+	return "Program {" + name + "}";
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Button.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Button.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Button.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,833 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.widgets;
+
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.gtk.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.events.*;
+
+/**
+ * Instances of this class represent a selectable user interface object that
+ * issues notification when pressed and released. 
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>ARROW, CHECK, PUSH, RADIO, TOGGLE, FLAT</dd>
+ * <dd>UP, DOWN, LEFT, RIGHT, CENTER</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Selection</dd>
+ * </dl>
+ * <p>
+ * Note: Only one of the styles ARROW, CHECK, PUSH, RADIO, and TOGGLE 
+ * may be specified.
+ * </p><p>
+ * Note: Only one of the styles LEFT, RIGHT, and CENTER may be specified.
+ * </p><p>
+ * Note: Only one of the styles UP, DOWN, LEFT, and RIGHT may be specified
+ * when the ARROW style is specified.
+ * </p><p>
+ * IMPORTANT: This class is intended to be subclassed <em>only</em>
+ * within the SWT implementation.
+ * </p>
+ * 
+ * @see <a href="http://www.eclipse.org/swt/snippets/#button">Button snippets</a>
+ * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: ControlExample</a>
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public class Button extends Control {
+	int /*long*/ boxHandle, labelHandle, imageHandle, arrowHandle, groupHandle;
+	boolean selected, grayed;
+	ImageList imageList;
+	Image image;
+	String text;
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT#ARROW
+ * @see SWT#CHECK
+ * @see SWT#PUSH
+ * @see SWT#RADIO
+ * @see SWT#TOGGLE
+ * @see SWT#FLAT
+ * @see SWT#LEFT
+ * @see SWT#RIGHT
+ * @see SWT#CENTER
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public Button (Composite parent, int style) {
+	super (parent, checkStyle (style));
+}
+
+static int checkStyle (int style) {
+	style = checkBits (style, SWT.PUSH, SWT.ARROW, SWT.CHECK, SWT.RADIO, SWT.TOGGLE, 0);
+	if ((style & (SWT.PUSH | SWT.TOGGLE)) != 0) {
+		return checkBits (style, SWT.CENTER, SWT.LEFT, SWT.RIGHT, 0, 0, 0);
+	}
+	if ((style & (SWT.CHECK | SWT.RADIO)) != 0) {
+		return checkBits (style, SWT.LEFT, SWT.RIGHT, SWT.CENTER, 0, 0, 0);
+	}
+	if ((style & SWT.ARROW) != 0) {
+		style |= SWT.NO_FOCUS;
+		return checkBits (style, SWT.UP, SWT.DOWN, SWT.LEFT, SWT.RIGHT, 0, 0);
+	}
+	return style;
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the control is selected by the user, by sending
+ * it one of the messages defined in the <code>SelectionListener</code>
+ * interface.
+ * <p>
+ * <code>widgetSelected</code> is called when the control is selected by the user.
+ * <code>widgetDefaultSelected</code> is not called.
+ * </p>
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent
+ */
+public void addSelectionListener (SelectionListener listener) {
+	checkWidget ();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	TypedListener typedListener = new TypedListener (listener);
+	addListener (SWT.Selection,typedListener);
+	addListener (SWT.DefaultSelection,typedListener);
+}
+
+public Point computeSize (int wHint, int hHint, boolean changed) {
+	checkWidget ();
+	if (wHint != SWT.DEFAULT && wHint < 0) wHint = 0;
+	if (hHint != SWT.DEFAULT && hHint < 0) hHint = 0;
+	/*
+	* Feature in GTK, GtkCheckButton and GtkRadioButton allocate
+	* only the minimum size necessary for its child. This causes the child
+	* alignment to fail. The fix is to set the child size to the size
+	* of the button.
+	*/
+	forceResize ();
+	int [] reqWidth = null, reqHeight = null;
+	if ((style & (SWT.CHECK | SWT.RADIO)) != 0) {
+		reqWidth = new int [1];
+		reqHeight = new int [1];
+		OS.gtk_widget_get_size_request (boxHandle, reqWidth, reqHeight);
+		OS.gtk_widget_set_size_request (boxHandle, -1, -1);
+	}
+	Point size = computeNativeSize (handle, wHint, hHint, changed);
+	if ((style & (SWT.CHECK | SWT.RADIO)) != 0) {
+		OS.gtk_widget_set_size_request (boxHandle, reqWidth [0], reqHeight [0]);
+	}
+	if (wHint != SWT.DEFAULT || hHint != SWT.DEFAULT) {
+		if ((OS.GTK_WIDGET_FLAGS (handle) & OS.GTK_CAN_DEFAULT) != 0) {
+			int /*long*/ [] buffer = new int /*long*/ [1];
+			GtkBorder border = new GtkBorder ();
+			OS.gtk_widget_style_get (handle, OS.default_border, buffer, 0);
+			if (buffer[0] != 0) {
+				OS.memmove (border, buffer[0], GtkBorder.sizeof);
+			} else {
+				/* Use the GTK+ default value of 1 for each. */
+				border.left = border.right = border.top = border.bottom = 1;
+			}
+			if (wHint != SWT.DEFAULT) size.x += border.left + border.right;
+			if (hHint != SWT.DEFAULT) size.y += border.top + border.bottom;
+		}
+	}
+	return size;
+}
+
+void createHandle (int index) {
+	state |= HANDLE;
+	if ((style & (SWT.PUSH | SWT.TOGGLE)) == 0) state |= THEME_BACKGROUND; 	
+	int bits = SWT.ARROW | SWT.TOGGLE | SWT.CHECK | SWT.RADIO | SWT.PUSH;
+	fixedHandle = OS.g_object_new (display.gtk_fixed_get_type (), 0);
+	if (fixedHandle == 0) error (SWT.ERROR_NO_HANDLES);
+	OS.gtk_fixed_set_has_window (fixedHandle, true);
+	switch (style & bits) {
+		case SWT.ARROW:
+			int arrow_type = OS.GTK_ARROW_UP;
+			if ((style & SWT.UP) != 0) arrow_type = OS.GTK_ARROW_UP;
+			if ((style & SWT.DOWN) != 0) arrow_type = OS.GTK_ARROW_DOWN;
+            if ((style & SWT.LEFT) != 0) arrow_type = OS.GTK_ARROW_LEFT;
+            if ((style & SWT.RIGHT) != 0) arrow_type = OS.GTK_ARROW_RIGHT;
+			handle = OS.gtk_button_new ();
+			if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+			arrowHandle = OS.gtk_arrow_new (arrow_type, OS.GTK_SHADOW_OUT);
+			if (arrowHandle == 0) error (SWT.ERROR_NO_HANDLES);
+			break;
+		case SWT.TOGGLE:
+			handle = OS.gtk_toggle_button_new ();
+			if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+			break;
+		case SWT.CHECK:
+			handle = OS.gtk_check_button_new ();
+			if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+			break;
+		case SWT.RADIO:
+			/*
+			* Feature in GTK.  In GTK, radio button must always be part of
+			* a radio button group.  In a GTK radio group, one button is always
+			* selected.  This means that it is not possible to have a single
+			* radio button that is unselected.  This is necessary to allow
+			* applications to implement their own radio behavior or use radio
+			* buttons outside of radio groups.  The fix is to create a hidden
+			* radio button for each radio button we create and add them
+			* to the same group.  This allows the visible button to be
+			* unselected.
+			*/
+			groupHandle = OS.gtk_radio_button_new (0);
+			if (groupHandle == 0) error (SWT.ERROR_NO_HANDLES);
+			OS.g_object_ref (groupHandle);
+			OS.gtk_object_sink (groupHandle);
+			handle = OS.gtk_radio_button_new (OS.gtk_radio_button_get_group (groupHandle));
+			if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+			break;
+		case SWT.PUSH:
+		default:
+			handle = OS.gtk_button_new ();
+			if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+			OS.GTK_WIDGET_SET_FLAGS(handle, OS.GTK_CAN_DEFAULT);
+			break;
+	}
+	if ((style & SWT.ARROW) != 0) {
+		OS.gtk_container_add (handle, arrowHandle);
+	} else {
+		boxHandle = OS.gtk_hbox_new (false, 4);
+		if (boxHandle == 0) error (SWT.ERROR_NO_HANDLES);
+		labelHandle = OS.gtk_label_new_with_mnemonic (null);
+		if (labelHandle == 0) error (SWT.ERROR_NO_HANDLES);
+		imageHandle = OS.gtk_image_new ();
+		if (imageHandle == 0) error (SWT.ERROR_NO_HANDLES);
+		OS.gtk_container_add (handle, boxHandle);
+		OS.gtk_container_add (boxHandle, imageHandle);
+		OS.gtk_container_add (boxHandle, labelHandle);
+	}
+	OS.gtk_container_add (fixedHandle, handle);
+	
+	if ((style & SWT.ARROW) != 0) return;
+	_setAlignment (style & (SWT.LEFT | SWT.CENTER | SWT.RIGHT));
+}
+
+void createWidget (int index) {
+	super.createWidget (index);
+	text = "";
+}
+
+void deregister () {
+	super.deregister ();
+	if (boxHandle != 0) display.removeWidget (boxHandle);
+	if (labelHandle != 0) display.removeWidget (labelHandle);
+	if (imageHandle != 0) display.removeWidget (imageHandle);
+	if (arrowHandle != 0) display.removeWidget (arrowHandle);
+}
+
+int /*long*/ fontHandle () {
+	if (labelHandle != 0) return labelHandle;
+	return super.fontHandle ();
+}
+
+/**
+ * Returns a value which describes the position of the
+ * text or image in the receiver. The value will be one of
+ * <code>LEFT</code>, <code>RIGHT</code> or <code>CENTER</code>
+ * unless the receiver is an <code>ARROW</code> button, in 
+ * which case, the alignment will indicate the direction of
+ * the arrow (one of <code>LEFT</code>, <code>RIGHT</code>, 
+ * <code>UP</code> or <code>DOWN</code>).
+ *
+ * @return the alignment 
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getAlignment () {
+	checkWidget ();
+	if ((style & SWT.ARROW) != 0) {
+		if ((style & SWT.UP) != 0) return SWT.UP;
+		if ((style & SWT.DOWN) != 0) return SWT.DOWN;
+		if ((style & SWT.LEFT) != 0) return SWT.LEFT;
+		if ((style & SWT.RIGHT) != 0) return SWT.RIGHT;
+		return SWT.UP;
+	}
+	if ((style & SWT.LEFT) != 0) return SWT.LEFT;
+	if ((style & SWT.CENTER) != 0) return SWT.CENTER;
+	if ((style & SWT.RIGHT) != 0) return SWT.RIGHT;
+	return SWT.LEFT;
+}
+
+/**
+ * Returns <code>true</code> if the receiver is grayed,
+ * and false otherwise. When the widget does not have
+ * the <code>CHECK</code> style, return false.
+ *
+ * @return the grayed state of the checkbox
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.4
+ */
+public boolean getGrayed () {
+	checkWidget();
+	if ((style & SWT.CHECK) == 0) return false;
+	return grayed;
+}
+
+/**
+ * Returns the receiver's image if it has one, or null
+ * if it does not.
+ *
+ * @return the receiver's image
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Image getImage () {
+	checkWidget ();
+	return image;
+}
+
+String getNameText () {
+	return getText ();
+}
+
+/**
+ * Returns <code>true</code> if the receiver is selected,
+ * and false otherwise.
+ * <p>
+ * When the receiver is of type <code>CHECK</code> or <code>RADIO</code>,
+ * it is selected when it is checked. When it is of type <code>TOGGLE</code>,
+ * it is selected when it is pushed in. If the receiver is of any other type,
+ * this method returns false.
+ *
+ * @return the selection state
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public boolean getSelection () {
+	checkWidget ();
+	if ((style & (SWT.CHECK | SWT.RADIO | SWT.TOGGLE)) == 0) return false;
+	return OS.gtk_toggle_button_get_active (handle);
+}
+
+/**
+ * Returns the receiver's text, which will be an empty
+ * string if it has never been set or if the receiver is
+ * an <code>ARROW</code> button.
+ *
+ * @return the receiver's text
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public String getText () {
+	checkWidget();
+	if ((style & SWT.ARROW) != 0) return "";
+	return text;
+}
+
+int /*long*/ gtk_button_press_event (int /*long*/ widget, int /*long*/ event) {
+	int /*long*/ result = super.gtk_button_press_event (widget, event);
+	if (result != 0) return result;
+	if ((style & SWT.RADIO) != 0) selected  = getSelection ();
+	return result;
+}
+
+int /*long*/ gtk_clicked (int /*long*/ widget) {
+	if ((style & SWT.RADIO) != 0) {
+		if ((parent.getStyle () & SWT.NO_RADIO_GROUP) != 0) {
+			setSelection (!selected);
+		} else {
+			selectRadio ();
+		}
+	} else {
+		if ((style & SWT.CHECK) != 0) {
+			if (grayed) {
+				if (OS.gtk_toggle_button_get_active (handle)) {
+					OS.gtk_toggle_button_set_inconsistent (handle, true);
+				} else {
+					OS.gtk_toggle_button_set_inconsistent (handle, false);
+				}
+			}
+		}
+	}
+	postEvent (SWT.Selection);
+	return 0;
+}
+
+int /*long*/ gtk_focus_in_event (int /*long*/ widget, int /*long*/ event) {
+	int /*long*/ result = super.gtk_focus_in_event (widget, event);
+	// widget could be disposed at this point
+	if (handle == 0) return 0;
+	if ((style & SWT.PUSH) != 0 && OS.GTK_WIDGET_HAS_DEFAULT (handle)) {
+		Decorations menuShell = menuShell ();
+		menuShell.defaultButton = this;
+	}
+	return result;
+}
+
+int /*long*/ gtk_focus_out_event (int /*long*/ widget, int /*long*/ event) {
+	int /*long*/ result = super.gtk_focus_out_event (widget, event);
+	// widget could be disposed at this point
+	if (handle == 0) return 0;
+	if ((style & SWT.PUSH) != 0 && !OS.GTK_WIDGET_HAS_DEFAULT (handle)) {
+		Decorations menuShell = menuShell ();
+		if (menuShell.defaultButton == this) {
+			menuShell.defaultButton = null;
+		}
+	}
+	return result;
+}
+
+int /*long*/ gtk_key_press_event (int /*long*/ widget, int /*long*/ event) {
+	int /*long*/ result = super.gtk_key_press_event (widget, event);
+	if (result != 0) return result;
+	if ((style & SWT.RADIO) != 0) selected  = getSelection ();
+	return result;
+}
+
+void hookEvents () {
+	super.hookEvents();
+	OS.g_signal_connect_closure (handle, OS.clicked, display.closures [CLICKED], false);
+	if (labelHandle != 0) {
+		OS.g_signal_connect_closure_by_id (labelHandle, display.signalIds [MNEMONIC_ACTIVATE], 0, display.closures [MNEMONIC_ACTIVATE], false);
+	}
+}
+
+boolean isDescribedByLabel () {
+	return false;
+}
+
+boolean mnemonicHit (char key) {
+	if (labelHandle == 0) return false;
+	boolean result = super.mnemonicHit (labelHandle, key);
+	if (result) setFocus ();
+	return result;
+}
+
+boolean mnemonicMatch (char key) {
+	if (labelHandle == 0) return false;
+	return mnemonicMatch (labelHandle, key);
+}
+
+void register () {
+	super.register ();
+	if (boxHandle != 0) display.addWidget (boxHandle, this);
+	if (labelHandle != 0) display.addWidget (labelHandle, this);
+	if (imageHandle != 0) display.addWidget (imageHandle, this);
+	if (arrowHandle != 0) display.addWidget (arrowHandle, this);
+}
+
+void releaseHandle () {
+	super.releaseHandle ();
+	boxHandle = imageHandle = labelHandle = arrowHandle = 0;
+}
+
+void releaseWidget () {
+	super.releaseWidget ();
+	if (groupHandle != 0) OS.g_object_unref (groupHandle);
+	groupHandle = 0;
+	if (imageList != null) imageList.dispose ();
+	imageList = null;
+	image = null;
+	text = null;
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the control is selected by the user.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #addSelectionListener
+ */
+public void removeSelectionListener (SelectionListener listener) {
+	checkWidget();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if (eventTable == null) return;
+	eventTable.unhook (SWT.Selection, listener);
+	eventTable.unhook (SWT.DefaultSelection,listener);	
+}
+
+void resizeHandle (int width, int height) {
+	super.resizeHandle (width, height);
+	/*
+	* Feature in GTK, GtkCheckButton and GtkRadioButton allocate
+	* only the minimum size necessary for its child. This causes the child
+	* alignment to fail. The fix is to set the child size to the size
+	* of the button.
+	*/
+	if ((style & (SWT.CHECK | SWT.RADIO)) != 0) {
+		OS.gtk_widget_set_size_request (boxHandle, width, -1);
+	}
+}
+
+void selectRadio () {
+	/*
+	* This code is intentionally commented.  When two groups
+	* of radio buttons with the same parent are separated by
+	* another control, the correct behavior should be that
+	* the two groups act independently.  This is consistent
+	* with radio tool and menu items.  The commented code
+	* implements this behavior.
+	*/
+//	int index = 0;
+//	Control [] children = parent._getChildren ();
+//	while (index < children.length && children [index] != this) index++;
+//	int i = index - 1;
+//	while (i >= 0 && children [i].setRadioSelection (false)) --i;
+//	int j = index + 1;
+//	while (j < children.length && children [j].setRadioSelection (false)) j++;
+//	setSelection (true);
+	Control [] children = parent._getChildren ();
+	for (int i=0; i<children.length; i++) {
+		Control child = children [i];
+		if (this != child) child.setRadioSelection (false);
+	}
+	setSelection (true);
+}
+
+/**
+ * Controls how text, images and arrows will be displayed
+ * in the receiver. The argument should be one of
+ * <code>LEFT</code>, <code>RIGHT</code> or <code>CENTER</code>
+ * unless the receiver is an <code>ARROW</code> button, in 
+ * which case, the argument indicates the direction of
+ * the arrow (one of <code>LEFT</code>, <code>RIGHT</code>, 
+ * <code>UP</code> or <code>DOWN</code>).
+ *
+ * @param alignment the new alignment 
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setAlignment (int alignment) {
+	checkWidget ();
+	_setAlignment (alignment);
+}
+
+void _setAlignment (int alignment) {
+	if ((style & SWT.ARROW) != 0) {
+		if ((style & (SWT.UP | SWT.DOWN | SWT.LEFT | SWT.RIGHT)) == 0) return; 
+		style &= ~(SWT.UP | SWT.DOWN | SWT.LEFT | SWT.RIGHT);
+		style |= alignment & (SWT.UP | SWT.DOWN | SWT.LEFT | SWT.RIGHT);
+		int arrow_type = OS.GTK_ARROW_UP;
+		boolean isRTL = (style & SWT.RIGHT_TO_LEFT) != 0;
+		switch (alignment) {
+			case SWT.UP: arrow_type = OS.GTK_ARROW_UP; break;
+			case SWT.DOWN: arrow_type = OS.GTK_ARROW_DOWN; break;
+			case SWT.LEFT: arrow_type = isRTL ? OS.GTK_ARROW_RIGHT : OS.GTK_ARROW_LEFT; break;
+			case SWT.RIGHT: arrow_type = isRTL ? OS.GTK_ARROW_LEFT : OS.GTK_ARROW_RIGHT; break;
+		}
+		OS.gtk_arrow_set (arrowHandle, arrow_type, OS.GTK_SHADOW_OUT);
+		return;
+	}
+	if ((alignment & (SWT.LEFT | SWT.RIGHT | SWT.CENTER)) == 0) return;
+	style &= ~(SWT.LEFT | SWT.RIGHT | SWT.CENTER);
+	style |= alignment & (SWT.LEFT | SWT.RIGHT | SWT.CENTER);
+	/* Alignment not honoured when image and text are visible */
+	boolean bothVisible = OS.GTK_WIDGET_VISIBLE (labelHandle) && OS.GTK_WIDGET_VISIBLE (imageHandle);
+	if (bothVisible) {
+		if ((style & (SWT.RADIO | SWT.CHECK)) != 0) alignment = SWT.LEFT;
+		if ((style & (SWT.PUSH | SWT.TOGGLE)) != 0) alignment = SWT.CENTER;
+	}
+	if ((alignment & SWT.LEFT) != 0) {
+		if (bothVisible) {
+			OS.gtk_box_set_child_packing (boxHandle, labelHandle, false, false, 0, OS.GTK_PACK_START);
+			OS.gtk_box_set_child_packing (boxHandle, imageHandle, false, false, 0, OS.GTK_PACK_START);
+		}
+		OS.gtk_misc_set_alignment (labelHandle, 0.0f, 0.5f);
+		OS.gtk_label_set_justify (labelHandle, OS.GTK_JUSTIFY_LEFT);
+		OS.gtk_misc_set_alignment (imageHandle, 0.0f, 0.5f);
+		return;
+	}
+	if ((alignment & SWT.CENTER) != 0) {
+		if (bothVisible) {
+			OS.gtk_box_set_child_packing (boxHandle, labelHandle, true, true, 0, OS.GTK_PACK_END);
+			OS.gtk_box_set_child_packing (boxHandle, imageHandle, true, true, 0, OS.GTK_PACK_START);
+			OS.gtk_misc_set_alignment (labelHandle, 0f, 0.5f);
+			OS.gtk_misc_set_alignment (imageHandle, 1f, 0.5f);
+		} else {
+			OS.gtk_misc_set_alignment (labelHandle, 0.5f, 0.5f);
+			OS.gtk_label_set_justify (labelHandle, OS.GTK_JUSTIFY_CENTER);
+			OS.gtk_misc_set_alignment (imageHandle, 0.5f, 0.5f);
+		}
+		return;
+	}
+	if ((alignment & SWT.RIGHT) != 0) {
+		if (bothVisible) {
+			OS.gtk_box_set_child_packing (boxHandle, labelHandle, false, false, 0, OS.GTK_PACK_END);
+			OS.gtk_box_set_child_packing (boxHandle, imageHandle, false, false, 0, OS.GTK_PACK_END);
+		}
+		OS.gtk_misc_set_alignment (labelHandle, 1.0f, 0.5f);
+		OS.gtk_label_set_justify (labelHandle, OS.GTK_JUSTIFY_RIGHT);
+		OS.gtk_misc_set_alignment (imageHandle, 1.0f, 0.5f);
+		return;
+	}
+}
+
+void setBackgroundColor (GdkColor color) {
+	super.setBackgroundColor (color);
+	setBackgroundColor(fixedHandle, color);
+	if (labelHandle != 0) setBackgroundColor(labelHandle, color);
+	if (imageHandle != 0) setBackgroundColor(imageHandle, color);
+}
+
+void setFontDescription (int /*long*/ font) {
+	super.setFontDescription (font);
+	if (labelHandle != 0) OS.gtk_widget_modify_font (labelHandle, font);
+	if (imageHandle != 0) OS.gtk_widget_modify_font (imageHandle, font);
+}
+
+boolean setRadioSelection (boolean value) {
+	if ((style & SWT.RADIO) == 0) return false;
+	if (getSelection () != value) {
+		setSelection (value);
+		postEvent (SWT.Selection);
+	}
+	return true;
+}
+
+void setForegroundColor (GdkColor color) {
+	super.setForegroundColor (color);
+	setForegroundColor (fixedHandle, color);
+	if (labelHandle != 0) setForegroundColor (labelHandle, color);
+	if (imageHandle != 0) setForegroundColor (imageHandle, color);
+}
+
+/**
+ * Sets the grayed state of the receiver.  This state change 
+ * only applies if the control was created with the SWT.CHECK
+ * style.
+ *
+ * @param grayed the new grayed state
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.4
+ */
+public void setGrayed (boolean grayed) {
+	checkWidget();
+	if ((style & SWT.CHECK) == 0) return;
+	this.grayed = grayed;
+	if (grayed && OS.gtk_toggle_button_get_active (handle)) {
+		OS.gtk_toggle_button_set_inconsistent (handle, true);
+	} else {
+		OS.gtk_toggle_button_set_inconsistent (handle, false);
+	}
+}
+
+/**
+ * Sets the receiver's image to the argument, which may be
+ * <code>null</code> indicating that no image should be displayed.
+ * <p>
+ * Note that a Button can display an image and text simultaneously
+ * on Windows (starting with XP), GTK+ and OSX.  On other platforms,
+ * a Button that has an image and text set into it will display the
+ * image or text that was set most recently.
+ * </p>
+ * @param image the image to display on the receiver (may be <code>null</code>)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
+ * </ul> 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setImage (Image image) {
+	checkWidget ();
+	if ((style & SWT.ARROW) != 0) return;
+	if (imageList != null) imageList.dispose ();
+	imageList = null;
+	if (image != null) {
+		if (image.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);
+		imageList = new ImageList ();
+		int imageIndex = imageList.add (image);
+		int /*long*/ pixbuf = imageList.getPixbuf (imageIndex);
+		OS.gtk_image_set_from_pixbuf (imageHandle, pixbuf);
+		if (text.length () == 0) OS.gtk_widget_hide (labelHandle);
+		OS.gtk_widget_show (imageHandle);
+	} else {
+		OS.gtk_image_set_from_pixbuf (imageHandle, 0);
+		OS.gtk_widget_show (labelHandle);
+		OS.gtk_widget_hide (imageHandle);
+	}
+	this.image = image;
+	_setAlignment (style);
+}
+
+void setOrientation () {
+	super.setOrientation ();
+	if ((style & SWT.RIGHT_TO_LEFT) != 0) {
+		if (boxHandle != 0) OS.gtk_widget_set_direction (boxHandle, OS.GTK_TEXT_DIR_RTL);
+		if (labelHandle != 0) OS.gtk_widget_set_direction (labelHandle, OS.GTK_TEXT_DIR_RTL);
+		if (imageHandle != 0) OS.gtk_widget_set_direction (imageHandle, OS.GTK_TEXT_DIR_RTL);
+		if (arrowHandle != 0) {
+			switch (style & (SWT.LEFT | SWT.RIGHT)) {
+				case SWT.LEFT: OS.gtk_arrow_set (arrowHandle, OS.GTK_ARROW_RIGHT, OS.GTK_SHADOW_OUT); break;
+				case SWT.RIGHT: OS.gtk_arrow_set (arrowHandle, OS.GTK_ARROW_LEFT, OS.GTK_SHADOW_OUT); break;
+			}
+		}
+	}
+}
+
+/**
+ * Sets the selection state of the receiver, if it is of type <code>CHECK</code>, 
+ * <code>RADIO</code>, or <code>TOGGLE</code>.
+ *
+ * <p>
+ * When the receiver is of type <code>CHECK</code> or <code>RADIO</code>,
+ * it is selected when it is checked. When it is of type <code>TOGGLE</code>,
+ * it is selected when it is pushed in.
+ *
+ * @param selected the new selection state
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setSelection (boolean selected) {
+	checkWidget();
+	if ((style & (SWT.CHECK | SWT.RADIO | SWT.TOGGLE)) == 0) return;
+	OS.g_signal_handlers_block_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CLICKED);
+	OS.gtk_toggle_button_set_active (handle, selected);
+	if ((style & SWT.CHECK) != 0) {
+		if (selected && grayed) {
+			OS.gtk_toggle_button_set_inconsistent (handle, true);
+		} else {
+			OS.gtk_toggle_button_set_inconsistent (handle, false);
+		}
+	}
+	if ((style & SWT.RADIO) != 0) OS.gtk_toggle_button_set_active (groupHandle, !selected);
+	OS.g_signal_handlers_unblock_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CLICKED);
+}
+
+/**
+ * Sets the receiver's text.
+ * <p>
+ * This method sets the button label.  The label may include
+ * the mnemonic character but must not contain line delimiters.
+ * </p>
+ * <p>
+ * Mnemonics are indicated by an '&amp;' that causes the next
+ * character to be the mnemonic.  When the user presses a
+ * key sequence that matches the mnemonic, a selection
+ * event occurs. On most platforms, the mnemonic appears
+ * underlined but may be emphasized in a platform specific
+ * manner.  The mnemonic indicator character '&amp;' can be
+ * escaped by doubling it in the string, causing a single
+ * '&amp;' to be displayed.
+ * </p><p>
+ * Note that a Button can display an image and text simultaneously
+ * on Windows (starting with XP), GTK+ and OSX.  On other platforms,
+ * a Button that has an image and text set into it will display the
+ * image or text that was set most recently.
+ * </p>
+ * @param string the new text
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the text is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setText (String string) {
+	checkWidget ();
+	if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if ((style & SWT.ARROW) != 0) return;
+	text = string;
+	char [] chars = fixMnemonic (string);
+	byte [] buffer = Converter.wcsToMbcs (null, chars, true);
+	OS.gtk_label_set_text_with_mnemonic (labelHandle, buffer);
+	if (image == null) OS.gtk_widget_hide (imageHandle);
+	OS.gtk_widget_show (labelHandle);
+	_setAlignment (style);
+}
+
+void showWidget () {
+	super.showWidget ();
+	if (boxHandle != 0) OS.gtk_widget_show (boxHandle);
+	if (labelHandle != 0) OS.gtk_widget_show (labelHandle);
+	if (arrowHandle != 0) OS.gtk_widget_show (arrowHandle);
+}
+
+int traversalCode (int key, GdkEventKey event) {
+	int code = super.traversalCode (key, event);
+	if ((style & SWT.ARROW) != 0) code &= ~(SWT.TRAVERSE_TAB_NEXT | SWT.TRAVERSE_TAB_PREVIOUS);
+	if ((style & SWT.RADIO) != 0) code |= SWT.TRAVERSE_ARROW_NEXT | SWT.TRAVERSE_ARROW_PREVIOUS;
+	return code;
+}
+
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Canvas.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Canvas.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Canvas.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,407 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.widgets;
+
+
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.gtk.*;
+import org.eclipse.swt.*;
+
+/**
+ * Instances of this class provide a surface for drawing
+ * arbitrary graphics.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>(none)</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>(none)</dd>
+ * </dl>
+ * <p>
+ * This class may be subclassed by custom control implementors
+ * who are building controls that are <em>not</em> constructed
+ * from aggregates of other controls. That is, they are either
+ * painted using SWT graphics calls or are handled by native
+ * methods.
+ * </p>
+ *
+ * @see Composite
+ * @see <a href="http://www.eclipse.org/swt/snippets/#canvas">Canvas snippets</a>
+ * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: ControlExample</a>
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public class Canvas extends Composite {
+	Caret caret;
+	IME ime;
+
+Canvas () {}
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * </ul>
+ *
+ * @see SWT
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public Canvas (Composite parent, int style) {
+	super (parent, checkStyle (style));
+}
+
+/** 
+ * Fills the interior of the rectangle specified by the arguments,
+ * with the receiver's background. 
+ *
+ * @param gc the gc where the rectangle is to be filled
+ * @param x the x coordinate of the rectangle to be filled
+ * @param y the y coordinate of the rectangle to be filled
+ * @param width the width of the rectangle to be filled
+ * @param height the height of the rectangle to be filled
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the gc is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the gc has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.2
+ */
+public void drawBackground (GC gc, int x, int y, int width, int height) {
+	checkWidget ();
+	if (gc == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if (gc.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT);
+	super.drawBackground (gc, x, y, width, height);
+}
+
+/**
+ * Returns the caret.
+ * <p>
+ * The caret for the control is automatically hidden
+ * and shown when the control is painted or resized,
+ * when focus is gained or lost and when an the control
+ * is scrolled.  To avoid drawing on top of the caret,
+ * the programmer must hide and show the caret when
+ * drawing in the window any other time.
+ * </p>
+ *
+ * @return the caret for the receiver, may be null
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Caret getCaret () {
+	checkWidget();
+	return caret;
+}
+
+Point getIMCaretPos () {
+	if (caret == null) return super.getIMCaretPos ();
+	return new Point (caret.x, caret.y);
+}
+
+/**
+ * Returns the IME.
+ *
+ * @return the IME
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.4
+ */
+public IME getIME () {
+	checkWidget ();
+	return ime;
+}
+
+int /*long*/ gtk_button_press_event (int /*long*/ widget, int /*long*/ event) {
+	if (ime != null) {
+		int /*long*/ result = ime.gtk_button_press_event (widget, event);
+		if (result != 0) return result;
+	}
+	return  super.gtk_button_press_event (widget, event);
+}
+
+int /*long*/ gtk_commit (int /*long*/ imcontext, int /*long*/ text) {
+	if (ime != null) {
+		int /*long*/ result = ime.gtk_commit (imcontext, text);
+		if (result != 0) return result;
+	}
+	return super.gtk_commit (imcontext, text);
+}
+
+int /*long*/ gtk_expose_event (int /*long*/ widget, int /*long*/ event) {
+	if ((state & OBSCURED) != 0) return 0;
+	boolean isFocus = caret != null && caret.isFocusCaret ();
+	if (isFocus) caret.killFocus ();
+	int /*long*/ result = super.gtk_expose_event (widget, event);
+	if (isFocus) caret.setFocus ();
+	return result;
+}
+
+int /*long*/ gtk_focus_in_event (int /*long*/ widget, int /*long*/ event) {
+	int /*long*/ result = super.gtk_focus_in_event (widget, event);
+	if (caret != null) caret.setFocus ();
+	return result;
+}
+
+int /*long*/ gtk_focus_out_event (int /*long*/ widget, int /*long*/ event) {
+	int /*long*/ result = super.gtk_focus_out_event (widget, event);
+	if (caret != null) caret.killFocus ();
+	return result;
+}
+
+int /*long*/ gtk_preedit_changed (int /*long*/ imcontext) {
+	if (ime != null) {
+		int /*long*/ result = ime.gtk_preedit_changed (imcontext);
+		if (result != 0) return result;
+	}
+	return super.gtk_preedit_changed (imcontext);
+}
+
+void redrawWidget (int x, int y, int width, int height, boolean redrawAll, boolean all, boolean trim) {
+	boolean isFocus = caret != null && caret.isFocusCaret ();
+	if (isFocus) caret.killFocus ();
+	super.redrawWidget (x, y, width, height, redrawAll, all, trim);
+	if (isFocus) caret.setFocus ();
+}
+
+void releaseChildren (boolean destroy) {
+	if (caret != null) {
+		caret.release (false);
+		caret = null;
+	}
+	if (ime != null) {
+		ime.release (false);
+		ime = null;
+	}
+	super.releaseChildren (destroy);
+}
+
+/**
+ * Scrolls a rectangular area of the receiver by first copying 
+ * the source area to the destination and then causing the area
+ * of the source which is not covered by the destination to
+ * be repainted. Children that intersect the rectangle are
+ * optionally moved during the operation. In addition, outstanding
+ * paint events are flushed before the source area is copied to
+ * ensure that the contents of the canvas are drawn correctly.
+ *
+ * @param destX the x coordinate of the destination
+ * @param destY the y coordinate of the destination
+ * @param x the x coordinate of the source
+ * @param y the y coordinate of the source
+ * @param width the width of the area
+ * @param height the height of the area
+ * @param all <code>true</code>if children should be scrolled, and <code>false</code> otherwise
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void scroll (int destX, int destY, int x, int y, int width, int height, boolean all) {
+	checkWidget();
+	if (width <= 0 || height <= 0) return;
+	if ((style & SWT.MIRRORED) != 0) {
+		int clientWidth = getClientWidth ();
+		x = clientWidth - width - x;
+		destX = clientWidth - width - destX;
+	}
+	int deltaX = destX - x, deltaY = destY - y;
+	if (deltaX == 0 && deltaY == 0) return;
+	if (!isVisible ()) return;
+	boolean isFocus = caret != null && caret.isFocusCaret ();
+	if (isFocus) caret.killFocus ();
+	int /*long*/ window = paintWindow ();
+	int /*long*/ visibleRegion = OS.gdk_drawable_get_visible_region (window);
+	GdkRectangle srcRect = new GdkRectangle ();
+	srcRect.x = x;
+	srcRect.y = y;
+	srcRect.width = width;
+	srcRect.height = height;
+	int /*long*/ copyRegion = OS.gdk_region_rectangle (srcRect);
+	OS.gdk_region_intersect(copyRegion, visibleRegion);
+	int /*long*/ invalidateRegion = OS.gdk_region_rectangle (srcRect);	
+	OS.gdk_region_subtract (invalidateRegion, visibleRegion);
+	OS.gdk_region_offset (invalidateRegion, deltaX, deltaY);
+	GdkRectangle copyRect = new GdkRectangle();
+	OS.gdk_region_get_clipbox (copyRegion, copyRect);
+	if (copyRect.width != 0 && copyRect.height != 0) {
+		update ();
+	}
+	Control control = findBackgroundControl ();
+	if (control == null) control = this;
+	if (control.backgroundImage != null) {
+		redrawWidget (x, y, width, height, false, false, false);
+		redrawWidget (destX, destY, width, height, false, false, false);
+	} else {
+//		GC gc = new GC (this);
+//		gc.copyArea (x, y, width, height, destX, destY);
+//		gc.dispose ();
+		int /*long*/ gdkGC = OS.gdk_gc_new (window);
+		OS.gdk_gc_set_exposures (gdkGC, true);
+		OS.gdk_draw_drawable (window, gdkGC, window, copyRect.x, copyRect.y, copyRect.x + deltaX, copyRect.y + deltaY, copyRect.width, copyRect.height);
+		OS.g_object_unref (gdkGC);
+		boolean disjoint = (destX + width < x) || (x + width < destX) || (destY + height < y) || (y + height < destY);
+		if (disjoint) {
+			GdkRectangle rect = new GdkRectangle ();
+			rect.x = x;
+			rect.y = y;
+			rect.width = width;
+			rect.height = height;
+			OS.gdk_region_union_with_rect (invalidateRegion, rect);
+		} else {
+			GdkRectangle rect = new GdkRectangle ();
+			if (deltaX != 0) {
+				int newX = destX - deltaX;
+				if (deltaX < 0) newX = destX + width;
+				rect.x = newX;
+				rect.y = y;
+				rect.width = Math.abs(deltaX);
+				rect.height = height;
+				OS.gdk_region_union_with_rect (invalidateRegion, rect);
+			}
+			if (deltaY != 0) {
+				int newY = destY - deltaY;
+				if (deltaY < 0) newY = destY + height;
+				rect.x = x;
+				rect.y = newY;
+				rect.width = width;
+				rect.height = Math.abs(deltaY);
+				OS.gdk_region_union_with_rect (invalidateRegion, rect);
+			}
+		}	
+		OS.gdk_window_invalidate_region(window, invalidateRegion, all);
+		OS.gdk_region_destroy (visibleRegion);
+		OS.gdk_region_destroy (copyRegion);
+		OS.gdk_region_destroy (invalidateRegion);
+	}
+	if (all) {
+		Control [] children = _getChildren ();
+		for (int i=0; i<children.length; i++) {
+			Control child = children [i];
+			Rectangle rect = child.getBounds ();
+			if (Math.min(x + width, rect.x + rect.width) >= Math.max (x, rect.x) && 
+				Math.min(y + height, rect.y + rect.height) >= Math.max (y, rect.y)) {
+					child.setLocation (rect.x + deltaX, rect.y + deltaY);					
+			}
+		}
+	}	
+	if (isFocus) caret.setFocus ();
+}
+
+int setBounds (int x, int y, int width, int height, boolean move, boolean resize) {
+	boolean isFocus = caret != null && caret.isFocusCaret ();
+	if (isFocus) caret.killFocus ();
+	int result = super.setBounds (x, y, width, height, move, resize);
+	if (isFocus) caret.setFocus ();
+	return result;
+}
+
+/**
+ * Sets the receiver's caret.
+ * <p>
+ * The caret for the control is automatically hidden
+ * and shown when the control is painted or resized,
+ * when focus is gained or lost and when an the control
+ * is scrolled.  To avoid drawing on top of the caret,
+ * the programmer must hide and show the caret when
+ * drawing in the window any other time.
+ * </p>
+ * @param caret the new caret for the receiver, may be null
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the caret has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setCaret (Caret caret) {
+	checkWidget();
+	Caret newCaret = caret;
+	Caret oldCaret = this.caret;
+	this.caret = newCaret;
+	if (hasFocus ()) {
+		if (oldCaret != null) oldCaret.killFocus ();
+		if (newCaret != null) {
+			if (newCaret.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
+			newCaret.setFocus ();
+		}
+	}
+}
+
+public void setFont (Font font) {
+	checkWidget();
+	if (caret != null) caret.setFont (font);
+	super.setFont (font);
+}
+
+/**
+ * Sets the receiver's IME.
+ * 
+ * @param ime the new IME for the receiver, may be null
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the IME has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.4
+ */
+public void setIME (IME ime) {
+	checkWidget ();
+	if (ime != null && ime.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
+	this.ime = ime;
+}
+	
+void updateCaret () {
+	int /*long*/ imHandle = imHandle ();
+	if (imHandle == 0) return;
+	GdkRectangle rect = new GdkRectangle ();
+	rect.x = caret.x;
+	rect.y = caret.y;
+	rect.width = caret.width;
+	rect.height = caret.height;
+	OS.gtk_im_context_set_cursor_location (imHandle, rect);
+}
+
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Caret.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Caret.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Caret.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,514 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.widgets;
+
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.gtk.*;
+import org.eclipse.swt.graphics.*;
+
+/**
+ * Instances of this class provide an i-beam that is typically used
+ * as the insertion point for text.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>(none)</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>(none)</dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is intended to be subclassed <em>only</em>
+ * within the SWT implementation.
+ * </p>
+ * 
+ * @see <a href="http://www.eclipse.org/swt/snippets/#caret">Caret snippets</a>
+ * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: ControlExample, Canvas tab</a>
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public class Caret extends Widget {
+	Canvas parent;
+	int x, y, width, height;
+	boolean isVisible, isShowing;
+	int blinkRate;
+	Image image;
+	Font font;
+	
+	static final int DEFAULT_WIDTH = 1;
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public Caret (Canvas parent, int style) {
+	super (parent, style);
+	this.parent = parent;
+	createWidget (0);
+}
+
+boolean blinkCaret () {
+	if (!isVisible) return true;
+	if (!isShowing) return showCaret ();
+	if (blinkRate == 0) return true;
+	return hideCaret ();
+}
+
+void createWidget (int index) {
+	super.createWidget (index);
+	blinkRate = display.getCaretBlinkTime ();
+	isVisible = true;
+	if (parent.getCaret () == null) {
+		parent.setCaret (this);
+	}
+}
+
+boolean drawCaret () {
+	if (parent == null) return false;
+	if (parent.isDisposed ()) return false;
+	int /*long*/ window = parent.paintWindow ();
+	int /*long*/ gc = OS.gdk_gc_new (window);
+	GdkColor color = new GdkColor ();
+	color.red = (short) 0xffff;
+	color.green = (short) 0xffff;
+	color.blue = (short) 0xffff;
+	int /*long*/ colormap = OS.gdk_colormap_get_system ();
+	OS.gdk_colormap_alloc_color (colormap, color, true, true);
+	OS.gdk_gc_set_foreground (gc, color);
+	OS.gdk_gc_set_function (gc, OS.GDK_XOR);
+	if (image != null && !image.isDisposed() && image.mask == 0) {
+		int[] width = new int[1]; int[] height = new int[1];
+	 	OS.gdk_drawable_get_size(image.pixmap, width, height);
+	 	int nX = x;
+		if ((parent.style & SWT.MIRRORED) != 0) nX = parent.getClientWidth () - width[0] - nX;
+	 	OS.gdk_draw_drawable(window, gc, image.pixmap, 0, 0, nX, y, width[0], height[0]);
+	} else {
+		int nWidth = width, nHeight = height;
+		if (nWidth <= 0) nWidth = DEFAULT_WIDTH;
+		int nX = x;
+		if ((parent.style & SWT.MIRRORED) != 0) nX = parent.getClientWidth () - nWidth - nX;
+		OS.gdk_draw_rectangle (window, gc, 1, nX, y, nWidth, nHeight);
+	}
+	OS.g_object_unref (gc);
+	OS.gdk_colormap_free_colors (colormap, color, 1);
+	return true;
+}
+
+/**
+ * Returns a rectangle describing the receiver's size and location
+ * relative to its parent (or its display if its parent is null).
+ *
+ * @return the receiver's bounding rectangle
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Rectangle getBounds () {
+	checkWidget();
+	if (image != null) {
+		Rectangle rect = image.getBounds ();
+		return new Rectangle (x, y, rect.width, rect.height);
+	} else {
+		if (width == 0) {
+			return new Rectangle (x, y, DEFAULT_WIDTH, height);
+		}
+	}
+	return new Rectangle (x, y, width, height);
+}
+
+/**
+ * Returns the font that the receiver will use to paint textual information.
+ *
+ * @return the receiver's font
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Font getFont () {
+	checkWidget();
+	if (font != null) return font;
+	return parent.getFont ();
+}
+
+/**
+ * Returns the image that the receiver will use to paint the caret.
+ *
+ * @return the receiver's image
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Image getImage () {
+	checkWidget();
+	return image;
+}
+
+/**
+ * Returns a point describing the receiver's location relative
+ * to its parent (or its display if its parent is null).
+ *
+ * @return the receiver's location
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Point getLocation () {
+	checkWidget();
+	return new Point (x, y);
+}
+
+/**
+ * Returns the receiver's parent, which must be a <code>Canvas</code>.
+ *
+ * @return the receiver's parent
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Canvas getParent () {
+	checkWidget();
+	return parent;
+}
+
+/**
+ * Returns a point describing the receiver's size.
+ *
+ * @return the receiver's size
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Point getSize () {
+	checkWidget();
+	if (image != null) {
+		Rectangle rect = image.getBounds ();
+		return new Point (rect.width, rect.height);
+	} else {
+		if (width == 0) {
+			return new Point (DEFAULT_WIDTH, height);
+		}
+	}
+	return new Point (width, height);
+}
+
+/**
+ * Returns <code>true</code> if the receiver is visible, and
+ * <code>false</code> otherwise.
+ * <p>
+ * If one of the receiver's ancestors is not visible or some
+ * other condition makes the receiver not visible, this method
+ * may still indicate that it is considered visible even though
+ * it may not actually be showing.
+ * </p>
+ *
+ * @return the receiver's visibility state
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public boolean getVisible () {
+	checkWidget();
+	return isVisible;
+}
+
+boolean hideCaret () {
+	if (!isShowing) return true;
+	isShowing = false;
+	return drawCaret ();
+}
+
+/**
+ * Returns <code>true</code> if the receiver is visible and all
+ * of the receiver's ancestors are visible and <code>false</code>
+ * otherwise.
+ *
+ * @return the receiver's visibility state
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #getVisible
+ */
+public boolean isVisible () {
+	checkWidget();
+	return isVisible && parent.isVisible () && parent.hasFocus ();
+}
+
+boolean isFocusCaret () {
+	return this == display.currentCaret;
+}
+
+void killFocus () {
+	if (display.currentCaret != this) return;
+	display.setCurrentCaret (null);
+	if (isVisible) hideCaret ();
+}
+
+void releaseParent () {
+	super.releaseParent ();
+	if (this == parent.getCaret ()) parent.setCaret (null);
+}
+
+void releaseWidget () {
+	super.releaseWidget ();
+	if (display.currentCaret == this) {
+		hideCaret ();
+		display.setCurrentCaret (null);
+	}
+	parent = null;
+	image = null;
+}
+
+/**
+ * Sets the receiver's size and location to the rectangular
+ * area specified by the arguments. The <code>x</code> and 
+ * <code>y</code> arguments are relative to the receiver's
+ * parent (or its display if its parent is null).
+ *
+ * @param x the new x coordinate for the receiver
+ * @param y the new y coordinate for the receiver
+ * @param width the new width for the receiver
+ * @param height the new height for the receiver
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setBounds (int x, int y, int width, int height) {
+	checkWidget();
+	if (this.x == x && this.y == y && this.width == width && this.height == height) return;
+	boolean isFocus = isFocusCaret ();
+	if (isFocus && isVisible) hideCaret ();
+	this.x = x; this.y = y;
+	this.width = width; this.height = height;
+	parent.updateCaret ();
+	if (isFocus && isVisible) showCaret ();
+}
+
+/**
+ * Sets the receiver's size and location to the rectangular
+ * area specified by the argument. The <code>x</code> and 
+ * <code>y</code> fields of the rectangle are relative to
+ * the receiver's parent (or its display if its parent is null).
+ *
+ * @param rect the new bounds for the receiver
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setBounds (Rectangle rect) {
+	checkWidget();
+	if (rect == null) error (SWT.ERROR_NULL_ARGUMENT);
+	setBounds (rect.x, rect.y, rect.width, rect.height);
+}
+
+void setFocus () {
+	if (display.currentCaret == this) return;
+	display.setCurrentCaret (this);
+	if (isVisible) showCaret ();
+}
+
+/**
+ * Sets the font that the receiver will use to paint textual information
+ * to the font specified by the argument, or to the default font for that
+ * kind of control if the argument is null.
+ *
+ * @param font the new font (or null)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the font has been disposed</li>
+ * </ul> 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setFont (Font font) {
+	checkWidget();
+	if (font != null && font.isDisposed ()) {
+		error (SWT.ERROR_INVALID_ARGUMENT);
+	}
+	this.font = font;
+}
+
+/**
+ * Sets the image that the receiver will use to paint the caret
+ * to the image specified by the argument, or to the default
+ * which is a filled rectangle if the argument is null
+ *
+ * @param image the new image (or null)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
+ * </ul> 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setImage (Image image) {
+	checkWidget();
+	if (image != null && image.isDisposed ()) {
+		error (SWT.ERROR_INVALID_ARGUMENT);
+	}
+	boolean isFocus = isFocusCaret ();
+	if (isFocus && isVisible) hideCaret ();
+	this.image = image;
+	if (isFocus && isVisible) showCaret ();
+}
+
+/**
+ * Sets the receiver's location to the point specified by
+ * the arguments which are relative to the receiver's
+ * parent (or its display if its parent is null).
+ *
+ * @param x the new x coordinate for the receiver
+ * @param y the new y coordinate for the receiver
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setLocation (int x, int y) {
+	checkWidget();
+	setBounds (x, y, width, height);
+}
+
+/**
+ * Sets the receiver's location to the point specified by
+ * the argument which is relative to the receiver's
+ * parent (or its display if its parent is null).
+ *
+ * @param location the new location for the receiver
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setLocation (Point location) {
+	checkWidget();
+	if (location == null) error (SWT.ERROR_NULL_ARGUMENT);
+	setLocation (location.x, location.y);
+}
+
+/**
+ * Sets the receiver's size to the point specified by the arguments.
+ *
+ * @param width the new width for the receiver
+ * @param height the new height for the receiver
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setSize (int width, int height) {
+	checkWidget();
+	setBounds (x, y, width, height);
+}
+
+/**
+ * Sets the receiver's size to the point specified by the argument.
+ *
+ * @param size the new extent for the receiver
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the point is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setSize (Point size) {
+	checkWidget();
+	if (size == null) error (SWT.ERROR_NULL_ARGUMENT);
+	setSize (size.x, size.y);
+}
+
+/**
+ * Marks the receiver as visible if the argument is <code>true</code>,
+ * and marks it invisible otherwise. 
+ * <p>
+ * If one of the receiver's ancestors is not visible or some
+ * other condition makes the receiver not visible, marking
+ * it visible may not actually cause it to be displayed.
+ * </p>
+ *
+ * @param visible the new visibility state
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setVisible (boolean visible) {
+	checkWidget();
+	if (visible == isVisible) return;
+	isVisible = visible;
+	if (!isFocusCaret ()) return;
+	if (isVisible) {
+		showCaret ();
+	} else {
+		hideCaret ();
+	}
+}
+
+boolean showCaret () {
+	if (isShowing) return true;
+	isShowing = true;
+	return drawCaret ();
+}
+
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/ColorDialog.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/ColorDialog.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/ColorDialog.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,180 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.widgets;
+
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.gtk.*;
+import org.eclipse.swt.graphics.*;
+
+/**
+ * Instances of this class allow the user to select a color
+ * from a predefined set of available colors.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>(none)</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>(none)</dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is intended to be subclassed <em>only</em>
+ * within the SWT implementation.
+ * </p>
+ * 
+ * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: ControlExample, Dialog tab</a>
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public class ColorDialog extends Dialog {
+	RGB rgb;
+/**
+ * Constructs a new instance of this class given only its parent.
+ *
+ * @param parent a composite control which will be the parent of the new instance
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public ColorDialog (Shell parent) {
+	this (parent, SWT.APPLICATION_MODAL);
+}
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public ColorDialog (Shell parent, int style) {
+	super (parent, checkStyle (parent, style));
+	checkSubclass ();
+}
+
+/**
+ * Returns the currently selected color in the receiver.
+ *
+ * @return the RGB value for the selected color, may be null
+ *
+ * @see PaletteData#getRGBs
+ */
+public RGB getRGB () {
+	return rgb;
+}
+/**
+ * Makes the receiver visible and brings it to the front
+ * of the display.
+ *
+ * @return the selected color, or null if the dialog was
+ *         cancelled, no color was selected, or an error
+ *         occurred
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public RGB open () {
+	byte [] buffer = Converter.wcsToMbcs (null, title, true);
+	int /*long*/ handle = OS.gtk_color_selection_dialog_new (buffer);
+	Display display = parent != null ? parent.getDisplay (): Display.getCurrent ();
+	if (parent != null) {
+		int /*long*/ shellHandle = parent.topHandle ();
+		OS.gtk_window_set_transient_for (handle, shellHandle);
+		int /*long*/ pixbufs = OS.gtk_window_get_icon_list (shellHandle);
+		if (pixbufs != 0) {
+			OS.gtk_window_set_icon_list (handle, pixbufs);
+			OS.g_list_free (pixbufs);
+		}
+	}
+	GtkColorSelectionDialog dialog = new GtkColorSelectionDialog ();
+	OS.memmove (dialog, handle);
+	GdkColor color = new GdkColor();
+	if (rgb != null) {
+		color.red = (short)((rgb.red & 0xFF) | ((rgb.red & 0xFF) << 8));
+		color.green = (short)((rgb.green & 0xFF) | ((rgb.green & 0xFF) << 8));
+		color.blue = (short)((rgb.blue & 0xFF) | ((rgb.blue & 0xFF) << 8));
+		OS.gtk_color_selection_set_current_color (dialog.colorsel, color);
+	}
+	OS.gtk_color_selection_set_has_palette (dialog.colorsel, true);
+	display.addIdleProc ();
+	Dialog oldModal = null;
+	if (OS.gtk_window_get_modal (handle)) {
+		oldModal = display.getModalDialog ();
+		display.setModalDialog (this);
+	}
+	int signalId = 0;
+	int /*long*/ hookId = 0;
+	if ((style & SWT.RIGHT_TO_LEFT) != 0) {
+		signalId = OS.g_signal_lookup (OS.map, OS.GTK_TYPE_WIDGET());
+		hookId = OS.g_signal_add_emission_hook (signalId, 0, display.emissionProc, handle, 0);
+	}	
+	int response = OS.gtk_dialog_run (handle);
+	if ((style & SWT.RIGHT_TO_LEFT) != 0) {
+		OS.g_signal_remove_emission_hook (signalId, hookId);
+	}
+	if (OS.gtk_window_get_modal (handle)) {
+		display.setModalDialog (oldModal);
+	}
+	boolean success = response == OS.GTK_RESPONSE_OK; 
+	if (success) {
+		OS.gtk_color_selection_get_current_color (dialog.colorsel, color);
+		int red = (color.red >> 8) & 0xFF;
+		int green = (color.green >> 8) & 0xFF;
+		int blue = (color.blue >> 8) & 0xFF;
+		rgb = new RGB (red, green, blue);
+	}
+	display.removeIdleProc ();
+	OS.gtk_widget_destroy (handle);
+	if (!success) return null;
+	return rgb;
+}
+/**
+ * Sets the receiver's selected color to be the argument.
+ *
+ * @param rgb the new RGB value for the selected color, may be
+ *        null to let the platform select a default when
+ *        open() is called
+ * @see PaletteData#getRGBs
+ */
+public void setRGB (RGB rgb) {
+	this.rgb = rgb;
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Combo.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Combo.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Combo.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,2236 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.widgets;
+
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.gtk.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.events.*;
+
+/**
+ * Instances of this class are controls that allow the user
+ * to choose an item from a list of items, or optionally 
+ * enter a new value by typing it into an editable text
+ * field. Often, <code>Combo</code>s are used in the same place
+ * where a single selection <code>List</code> widget could
+ * be used but space is limited. A <code>Combo</code> takes
+ * less space than a <code>List</code> widget and shows
+ * similar information.
+ * <p>
+ * Note: Since <code>Combo</code>s can contain both a list
+ * and an editable text field, it is possible to confuse methods
+ * which access one versus the other (compare for example,
+ * <code>clearSelection()</code> and <code>deselectAll()</code>).
+ * The API documentation is careful to indicate either "the
+ * receiver's list" or the "the receiver's text field" to 
+ * distinguish between the two cases.
+ * </p><p>
+ * Note that although this class is a subclass of <code>Composite</code>,
+ * it does not make sense to add children to it, or set a layout on it.
+ * </p>
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>DROP_DOWN, READ_ONLY, SIMPLE</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>DefaultSelection, Modify, Selection, Verify</dd>
+ * </dl>
+ * <p>
+ * Note: Only one of the styles DROP_DOWN and SIMPLE may be specified.
+ * </p><p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ *
+ * @see List
+ * @see <a href="http://www.eclipse.org/swt/snippets/#combo">Combo snippets</a>
+ * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: ControlExample</a>
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public class Combo extends Composite {
+	int /*long*/ buttonHandle, entryHandle, listHandle, textRenderer, cellHandle, popupHandle;
+	int lastEventTime, visibleCount = 5;
+	int /*long*/ gdkEventKey = 0;
+	int fixStart = -1, fixEnd = -1;
+	String [] items = new String [0];
+	boolean ignoreSelect, lockText;
+
+	static final int INNER_BORDER = 2;
+
+	/**
+	 * the operating system limit for the number of characters
+	 * that the text field in an instance of this class can hold
+	 */
+	public final static int LIMIT;
+	
+	/*
+	* These values can be different on different platforms.
+	* Therefore they are not initialized in the declaration
+	* to stop the compiler from inlining.
+	*/
+	static {
+		LIMIT = 0xFFFF;
+	}
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT#DROP_DOWN
+ * @see SWT#READ_ONLY
+ * @see SWT#SIMPLE
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public Combo (Composite parent, int style) {
+	super (parent, checkStyle (style));
+}
+
+/**
+ * Adds the argument to the end of the receiver's list.
+ *
+ * @param string the new item
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #add(String,int)
+ */
+public void add (String string) {
+	checkWidget();
+	if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+	add (string, items.length);
+}
+
+/**
+ * Adds the argument to the receiver's list at the given
+ * zero-relative index.
+ * <p>
+ * Note: To add an item at the end of the list, use the
+ * result of calling <code>getItemCount()</code> as the
+ * index or use <code>add(String)</code>.
+ * </p>
+ *
+ * @param string the new item
+ * @param index the index for the item
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list (inclusive)</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #add(String)
+ */
+public void add (String string, int index) {
+	checkWidget();
+	if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if (!(0 <= index && index <= items.length)) {
+		error (SWT.ERROR_INVALID_RANGE);
+	}
+	String [] newItems = new String [items.length + 1];
+	System.arraycopy (items, 0, newItems, 0, index);
+	newItems [index] = string;
+	System.arraycopy (items, index, newItems, index + 1, items.length - index);
+	items = newItems;
+	byte [] buffer = Converter.wcsToMbcs (null, string, true);
+	if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
+		OS.gtk_combo_box_insert_text (handle, index, buffer);
+		if ((style & SWT.RIGHT_TO_LEFT) != 0 && popupHandle != 0) {
+			OS.gtk_container_forall (popupHandle, display.setDirectionProc, OS.GTK_TEXT_DIR_RTL);    
+		}
+	} else {
+		/*
+		* Feature in GTK. When the list is empty and the first item
+		* is added, the combo box selects that item replacing the
+		* text in the entry field.  The fix is to avoid this by
+		* stopping the "delete" and "insert_text" signal emission. 
+		*/
+		ignoreSelect = lockText = true;
+		int /*long*/ item = OS.gtk_list_item_new_with_label (buffer);
+		int /*long*/ label = OS.gtk_bin_get_child (item); 
+		setForegroundColor (label, getForegroundColor ());
+		OS.gtk_widget_modify_font (label, getFontDescription ());
+		OS.gtk_widget_set_direction (label, OS.gtk_widget_get_direction (handle));
+		OS.gtk_widget_show (item);
+		int /*long*/ items = OS.g_list_append (0, item);
+		OS.gtk_list_insert_items (listHandle, items, index);
+		ignoreSelect = lockText = false;
+	}
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the receiver's text is modified, by sending
+ * it one of the messages defined in the <code>ModifyListener</code>
+ * interface.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see ModifyListener
+ * @see #removeModifyListener
+ */
+public void addModifyListener (ModifyListener listener) {
+	checkWidget();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	TypedListener typedListener = new TypedListener (listener);
+	addListener (SWT.Modify, typedListener);
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the user changes the receiver's selection, by sending
+ * it one of the messages defined in the <code>SelectionListener</code>
+ * interface.
+ * <p>
+ * <code>widgetSelected</code> is called when the user changes the combo's list selection.
+ * <code>widgetDefaultSelected</code> is typically called when ENTER is pressed the combo's text area.
+ * </p>
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent
+ */
+public void addSelectionListener(SelectionListener listener) {
+	checkWidget();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	TypedListener typedListener = new TypedListener (listener);
+	addListener (SWT.Selection,typedListener);
+	addListener (SWT.DefaultSelection,typedListener);
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the receiver's text is verified, by sending
+ * it one of the messages defined in the <code>VerifyListener</code>
+ * interface.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see VerifyListener
+ * @see #removeVerifyListener
+ * 
+ * @since 3.1
+ */
+public void addVerifyListener (VerifyListener listener) {
+	checkWidget ();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	TypedListener typedListener = new TypedListener (listener);
+	addListener (SWT.Verify, typedListener);
+}
+
+static int checkStyle (int style) {
+	/*
+	* Feature in Windows.  It is not possible to create
+	* a combo box that has a border using Windows style
+	* bits.  All combo boxes draw their own border and
+	* do not use the standard Windows border styles.
+	* Therefore, no matter what style bits are specified,
+	* clear the BORDER bits so that the SWT style will
+	* match the Windows widget.
+	*
+	* The Windows behavior is currently implemented on
+	* all platforms.
+	*/
+	style &= ~SWT.BORDER;
+	
+	/*
+	* Even though it is legal to create this widget
+	* with scroll bars, they serve no useful purpose
+	* because they do not automatically scroll the
+	* widget's client area.  The fix is to clear
+	* the SWT style.
+	*/
+	style &= ~(SWT.H_SCROLL | SWT.V_SCROLL);
+	style = checkBits (style, SWT.DROP_DOWN, SWT.SIMPLE, 0, 0, 0, 0);
+	if ((style & SWT.SIMPLE) != 0) return style & ~SWT.READ_ONLY;
+	return style;
+}
+
+protected void checkSubclass () {
+	if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
+}
+
+/**
+ * Sets the selection in the receiver's text field to an empty
+ * selection starting just before the first character. If the
+ * text field is editable, this has the effect of placing the
+ * i-beam at the start of the text.
+ * <p>
+ * Note: To clear the selected items in the receiver's list, 
+ * use <code>deselectAll()</code>.
+ * </p>
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #deselectAll
+ */
+public void clearSelection () {
+	checkWidget();
+	if (entryHandle != 0) {
+		int position = OS.gtk_editable_get_position (entryHandle);
+		OS.gtk_editable_select_region (entryHandle, position, position);
+	}
+}
+
+void clearText () {
+	if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
+		OS.g_signal_handlers_block_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+		if ((style & SWT.READ_ONLY) != 0) {
+			int index = OS.gtk_combo_box_get_active (handle);
+			if (index != -1) {
+				int /*long*/ modelHandle = OS.gtk_combo_box_get_model (handle);
+				int /*long*/ [] ptr = new int /*long*/ [1];
+				int /*long*/ iter = OS.g_malloc (OS.GtkTreeIter_sizeof ());
+				OS.gtk_tree_model_iter_nth_child (modelHandle, iter, 0, index);
+				OS.gtk_tree_model_get (modelHandle, iter, 0, ptr, -1);
+				OS.g_free (iter);
+				if (ptr [0] != 0 && OS.strlen (ptr [0]) > 0) postEvent (SWT.Modify);
+				OS.g_free (ptr [0]);
+			}
+		} else {
+			OS.gtk_entry_set_text (entryHandle, new byte[1]);
+		}
+		OS.gtk_combo_box_set_active (handle, -1);
+ 		OS.g_signal_handlers_unblock_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+	}
+}
+
+public Point computeSize (int wHint, int hHint, boolean changed) {
+	checkWidget ();
+	if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
+		return computeNativeSize (handle, wHint, hHint, changed);
+	}
+	if (wHint != SWT.DEFAULT && wHint < 0) wHint = 0;
+	if (hHint != SWT.DEFAULT && hHint < 0) hHint = 0;
+	int[] w = new int [1], h = new int [1];
+	OS.gtk_widget_realize (entryHandle);
+	int /*long*/ layout = OS.gtk_entry_get_layout (entryHandle);
+	OS.pango_layout_get_size (layout, w, h);
+	int xborder = INNER_BORDER, yborder = INNER_BORDER;
+	int /*long*/ style = OS.gtk_widget_get_style (entryHandle);
+	xborder += OS.gtk_style_get_xthickness (style);
+	yborder += OS.gtk_style_get_ythickness (style);
+	int [] property = new int [1];
+	OS.gtk_widget_style_get (entryHandle, OS.interior_focus, property, 0);
+	if (property [0] == 0) {
+		OS.gtk_widget_style_get (entryHandle, OS.focus_line_width, property, 0);
+		xborder += property [0];
+		yborder += property [0];
+	}
+	int width = OS.PANGO_PIXELS (w [0]) + xborder  * 2;
+	int height = OS.PANGO_PIXELS (h [0]) + yborder  * 2;
+
+	GtkRequisition arrowRequesition = new GtkRequisition ();
+	OS.gtk_widget_size_request (buttonHandle, arrowRequesition);
+	GtkRequisition listRequesition = new GtkRequisition ();
+	int /*long*/ listParent = OS.gtk_widget_get_parent (listHandle);
+	OS.gtk_widget_size_request (listParent != 0 ? listParent : listHandle, listRequesition);
+	
+	width = Math.max (listRequesition.width, width) + arrowRequesition.width + 4;
+	width = wHint == SWT.DEFAULT ? width : wHint;
+	height = hHint == SWT.DEFAULT ? height : hHint;
+	return new Point (width, height);
+}
+
+/**
+ * Copies the selected text.
+ * <p>
+ * The current selection is copied to the clipboard.
+ * </p>
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 2.1
+ */
+public void copy () {
+	checkWidget ();
+	if (entryHandle != 0) OS.gtk_editable_copy_clipboard (entryHandle);
+}
+
+void createHandle (int index) {
+	state |= HANDLE | MENU;
+	fixedHandle = OS.g_object_new (display.gtk_fixed_get_type (), 0);
+	if (fixedHandle == 0) error (SWT.ERROR_NO_HANDLES);
+	OS.gtk_fixed_set_has_window (fixedHandle, true);
+	if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
+		int /*long*/ oldList = OS.gtk_window_list_toplevels ();  
+		if ((style & SWT.READ_ONLY) != 0) {
+			handle = OS.gtk_combo_box_new_text ();
+			if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+			cellHandle = OS.gtk_bin_get_child (handle);
+			if (cellHandle == 0) error (SWT.ERROR_NO_HANDLES);
+		} else {
+			handle = OS.gtk_combo_box_entry_new_text ();
+			if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+			entryHandle = OS.gtk_bin_get_child (handle);
+			if (entryHandle == 0) error (SWT.ERROR_NO_HANDLES);
+		}
+		popupHandle = findPopupHandle (oldList);    
+		OS.gtk_container_add (fixedHandle, handle);
+		textRenderer = OS.gtk_cell_renderer_text_new ();
+		if (textRenderer == 0) error (SWT.ERROR_NO_HANDLES);
+		/*
+		* Feature in GTK. In order to make a read only combo box the same
+		* height as an editable combo box the ypad must be set to 0. In 
+		* versions 2.4.x of GTK, a pad of 0 will clip some letters. The
+		* fix is to set the pad to 1.
+		*/
+		int pad = 0;
+		if (OS.GTK_VERSION < OS.VERSION(2, 6, 0)) pad = 1;
+		OS.g_object_set (textRenderer, OS.ypad, pad, 0);
+		/*
+		* Feature in GTK.  In version 2.4.9 of GTK, a warning is issued
+		* when a call to gtk_cell_layout_clear() is made. The fix is to hide
+		* the warning.
+		*/
+		boolean warnings = display.getWarnings ();
+		display.setWarnings (false);
+		OS.gtk_cell_layout_clear (handle);
+		display.setWarnings (warnings);
+		OS.gtk_cell_layout_pack_start (handle, textRenderer, true);
+		OS.gtk_cell_layout_set_attributes (handle, textRenderer, OS.text, 0, 0);
+
+		/*
+		* Feature in GTK.  There is no API to query the button
+		* handle from a combo box although it is possible to get the
+		* text field.  The button handle is needed to hook events.  The
+		* fix is to walk the combo tree and find the first child that is 
+		* an instance of button.
+		*/
+		OS.gtk_container_forall (handle, display.allChildrenProc, 0);
+		if (display.allChildren != 0) {
+			int /*long*/ list = display.allChildren;
+			while (list != 0) {
+				int /*long*/ widget = OS.g_list_data (list);
+				if (OS.GTK_IS_BUTTON (widget)) {
+					buttonHandle = widget;
+					break;
+				}
+				list = OS.g_list_next (list);
+			}
+			OS.g_list_free (display.allChildren);
+			display.allChildren = 0;
+		}
+		/*
+		* Feature in GTK. By default, read only combo boxes 
+		* process the RETURN key rather than allowing the 
+		* default button to process the key. The fix is to
+		* clear the GTK_RECEIVES_DEFAULT flag.
+		*/
+		if ((style & SWT.READ_ONLY) != 0 && buttonHandle != 0) {
+			OS.GTK_WIDGET_UNSET_FLAGS (buttonHandle, OS.GTK_RECEIVES_DEFAULT);
+		}
+	} else {
+		handle = OS.gtk_combo_new ();
+		if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+		OS.gtk_container_add (fixedHandle, handle);
+		GtkCombo combo = new GtkCombo ();
+		OS.memmove (combo, handle);
+		entryHandle = combo.entry;
+		listHandle = combo.list;
+		
+		if (OS.GTK_VERSION < OS.VERSION (2, 4, 0)) {
+			int /*long*/ parentHandle = 0;
+			int /*long*/ temp = listHandle;
+			while ((temp = OS.gtk_widget_get_parent(temp)) != 0) {
+				parentHandle = temp;
+			}
+			popupHandle = parentHandle;
+			if (popupHandle != 0) {
+				int /*long*/ modalGroup = getShell().modalGroup;
+				if (modalGroup != 0) {
+					OS.gtk_window_group_add_window (modalGroup, popupHandle);
+				}
+			}
+		}
+		/*
+		* Feature in GTK.  There is no API to query the arrow
+		* handle from a combo box although it is possible to
+		* get the list and text field.  The arrow handle is needed
+		* to hook events.  The fix is to find the first child that is
+		* not the entry or list and assume this is the arrow handle.
+		*/
+		int /*long*/ list = OS.gtk_container_get_children (handle);
+		if (list != 0) {
+			int i = 0, count = OS.g_list_length (list);
+			while (i<count) {
+				int /*long*/ childHandle = OS.g_list_nth_data (list, i);
+				if (childHandle != entryHandle && childHandle != listHandle) {
+					buttonHandle = childHandle;
+					break;
+				}
+				i++;
+			}
+			OS.g_list_free (list);
+		}
+		
+		boolean editable = (style & SWT.READ_ONLY) == 0;
+		OS.gtk_editable_set_editable (entryHandle, editable);
+		OS.gtk_combo_disable_activate (handle);
+		OS.gtk_combo_set_case_sensitive (handle, true);
+	}
+}
+
+/**
+ * Cuts the selected text.
+ * <p>
+ * The current selection is first copied to the
+ * clipboard and then deleted from the widget.
+ * </p>
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 2.1
+ */
+public void cut () {
+	checkWidget ();
+	if (entryHandle != 0) OS.gtk_editable_cut_clipboard (entryHandle);
+}
+
+void deregister () {
+	super.deregister ();
+	if (buttonHandle != 0) display.removeWidget (buttonHandle);
+	if (entryHandle != 0) display.removeWidget (entryHandle);
+	if (listHandle != 0) display.removeWidget (listHandle);
+	int /*long*/ imContext = imContext ();
+	if (imContext != 0) display.removeWidget (imContext);
+}
+
+boolean filterKey (int keyval, int /*long*/ event) {
+	int time = OS.gdk_event_get_time (event);
+	if (time != lastEventTime) {
+		lastEventTime = time;
+		int /*long*/ imContext = imContext ();
+		if (imContext != 0) {
+			return OS.gtk_im_context_filter_keypress (imContext, event);
+		}
+	}
+	gdkEventKey = event;
+	return false;
+}
+
+int /*long*/ findPopupHandle (int /*long*/ oldList) {
+	int /*long*/ hdl = 0;
+	int /*long*/ currentList = OS.gtk_window_list_toplevels();
+	int /*long*/ oldFromList = oldList;
+	int /*long*/ newFromList = currentList;
+	boolean isFound;
+	while (newFromList != 0) {
+		int /*long*/ newToplevel = OS.g_list_data(newFromList);
+		isFound = false;
+		oldFromList = oldList;
+		while (oldFromList != 0) {
+			int /*long*/ oldToplevel = OS.g_list_data(oldFromList);
+			if (newToplevel == oldToplevel) {
+				isFound = true;
+				break;
+			}
+			oldFromList = OS.g_list_next(oldFromList);
+		}
+		if (!isFound) {
+			hdl = newToplevel;
+			break;
+		}
+		newFromList = OS.g_list_next(newFromList);
+	}
+	OS.g_list_free(oldList);
+	OS.g_list_free(currentList);
+	return hdl;
+}
+
+void fixModal (int /*long*/ group, int /*long*/ modalGroup) {
+	if (popupHandle != 0) {
+		if (group != 0) {
+			OS.gtk_window_group_add_window (group, popupHandle);
+		} else {
+			if (modalGroup != 0) {
+				OS.gtk_window_group_remove_window (modalGroup, popupHandle);
+			}
+		}
+	}
+}
+
+void fixIM () {
+	/*
+	*  The IM filter has to be called one time for each key press event.
+	*  When the IM is open the key events are duplicated. The first event
+	*  is filtered by SWT and the second event is filtered by GTK.  In some 
+	*  cases the GTK handler does not run (the widget is destroyed, the 
+	*  application code consumes the event, etc), for these cases the IM
+	*  filter has to be called by SWT.
+	*/	
+	if (gdkEventKey != 0 && gdkEventKey != -1) {
+		int /*long*/ imContext = imContext ();
+		if (imContext != 0) {
+			OS.gtk_im_context_filter_keypress (imContext, gdkEventKey);
+			gdkEventKey = -1;
+			return;
+		}
+	}
+	gdkEventKey = 0;
+}
+
+int /*long*/ fontHandle () {
+	if (entryHandle != 0) return entryHandle;
+	return super.fontHandle ();
+}
+
+int /*long*/ focusHandle () {
+	if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
+		if ((style & SWT.READ_ONLY) != 0 && buttonHandle != 0) return buttonHandle;
+	}
+	if (entryHandle != 0) return entryHandle;
+	return super.focusHandle ();
+}
+
+boolean hasFocus () {
+	if (super.hasFocus ()) return true;
+	if (entryHandle != 0 && OS.GTK_WIDGET_HAS_FOCUS (entryHandle)) return true;
+	if (listHandle != 0 && OS.GTK_WIDGET_HAS_FOCUS (listHandle)) return true;
+	return false;
+}
+
+void hookEvents () {
+	super.hookEvents ();
+	if (OS.GTK_VERSION >= OS.VERSION(2, 4, 0)) {
+		OS.g_signal_connect_closure (handle, OS.changed, display.closures [CHANGED], true);
+	}
+
+	if (entryHandle != 0) {
+		OS.g_signal_connect_closure (entryHandle, OS.changed, display.closures [CHANGED], true);
+		OS.g_signal_connect_closure (entryHandle, OS.insert_text, display.closures [INSERT_TEXT], false);
+		OS.g_signal_connect_closure (entryHandle, OS.delete_text, display.closures [DELETE_TEXT], false);
+		OS.g_signal_connect_closure (entryHandle, OS.activate, display.closures [ACTIVATE], false);
+		OS.g_signal_connect_closure (entryHandle, OS.populate_popup, display.closures [POPULATE_POPUP], false);
+	}
+	int eventMask =	OS.GDK_POINTER_MOTION_MASK | OS.GDK_BUTTON_PRESS_MASK | 
+		OS.GDK_BUTTON_RELEASE_MASK;
+ 	int /*long*/ [] handles = new int /*long*/ [] {buttonHandle, entryHandle, listHandle};
+	for (int i=0; i<handles.length; i++) {
+		int /*long*/ eventHandle = handles [i];
+		if (eventHandle != 0) {
+			/* Connect the mouse signals */
+			OS.gtk_widget_add_events (eventHandle, eventMask);
+			OS.g_signal_connect_closure_by_id (eventHandle, display.signalIds [BUTTON_PRESS_EVENT], 0, display.closures [BUTTON_PRESS_EVENT], false);
+			OS.g_signal_connect_closure_by_id (eventHandle, display.signalIds [BUTTON_RELEASE_EVENT], 0, display.closures [BUTTON_RELEASE_EVENT], false);
+			OS.g_signal_connect_closure_by_id (eventHandle, display.signalIds [MOTION_NOTIFY_EVENT], 0, display.closures [MOTION_NOTIFY_EVENT], false);
+			/*
+			* Feature in GTK.  Events such as mouse move are propagated up
+			* the widget hierarchy and are seen by the parent.  This is the
+			* correct GTK behavior but not correct for SWT.  The fix is to
+			* hook a signal after and stop the propagation using a negative
+			* event number to distinguish this case.
+			*/
+			OS.g_signal_connect_closure_by_id (eventHandle, display.signalIds [BUTTON_PRESS_EVENT], 0, display.closures [BUTTON_PRESS_EVENT_INVERSE], true);
+			OS.g_signal_connect_closure_by_id (eventHandle, display.signalIds [BUTTON_RELEASE_EVENT], 0, display.closures [BUTTON_RELEASE_EVENT_INVERSE], true);
+			OS.g_signal_connect_closure_by_id (eventHandle, display.signalIds [MOTION_NOTIFY_EVENT], 0, display.closures [MOTION_NOTIFY_EVENT_INVERSE], true);
+
+			/* Connect the event_after signal for both key and mouse */
+			if (eventHandle != focusHandle ()) {
+				OS.g_signal_connect_closure_by_id (eventHandle, display.signalIds [EVENT_AFTER], 0, display.closures [EVENT_AFTER], false);
+			}
+		}
+	}
+	int /*long*/ imContext = imContext ();
+	if (imContext != 0) {
+		OS.g_signal_connect_closure (imContext, OS.commit, display.closures [COMMIT], false);
+		int id = OS.g_signal_lookup (OS.commit, OS.gtk_im_context_get_type ());
+		int blockMask =  OS.G_SIGNAL_MATCH_DATA | OS.G_SIGNAL_MATCH_ID;
+		OS.g_signal_handlers_block_matched (imContext, blockMask, id, 0, 0, 0, entryHandle);
+	}
+}
+
+int /*long*/ imContext () {
+	return entryHandle != 0 ? OS.GTK_ENTRY_IM_CONTEXT (entryHandle) : 0;
+}
+
+/**
+ * Deselects the item at the given zero-relative index in the receiver's 
+ * list.  If the item at the index was already deselected, it remains
+ * deselected. Indices that are out of range are ignored.
+ *
+ * @param index the index of the item to deselect
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void deselect (int index) {
+	checkWidget();
+	if (index < 0 || index >= items.length) return;
+	if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
+		if (OS.gtk_combo_box_get_active (handle) == index) {
+			clearText ();
+		}
+	} else {
+		ignoreSelect = true;
+		int /*long*/ children = OS.gtk_container_get_children (listHandle);
+		int /*long*/ item = OS.g_list_nth_data (children, index);
+		boolean selected = OS.GTK_WIDGET_STATE (item) == OS.GTK_STATE_SELECTED;
+		if (selected) {
+			OS.gtk_list_unselect_all (listHandle);
+			OS.gtk_entry_set_text (entryHandle, new byte[1]);
+		}
+		OS.g_list_free (children);
+		ignoreSelect = false;
+	}
+}
+
+/**
+ * Deselects all selected items in the receiver's list.
+ * <p>
+ * Note: To clear the selection in the receiver's text field,
+ * use <code>clearSelection()</code>.
+ * </p>
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #clearSelection
+ */
+public void deselectAll () {
+	checkWidget();
+	if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
+		clearText ();
+	} else {
+		ignoreSelect = true;
+		OS.gtk_list_unselect_all (listHandle);
+		OS.gtk_entry_set_text (entryHandle, new byte[1]);
+		ignoreSelect = false;
+	}
+}
+
+boolean dragDetect(int x, int y, boolean filter, boolean[] consume) {
+	if (filter && entryHandle != 0) {
+		int [] index = new int [1];
+		int [] trailing = new int [1];
+		int /*long*/ layout = OS.gtk_entry_get_layout (entryHandle);
+		OS.pango_layout_xy_to_index (layout, x * OS.PANGO_SCALE, y * OS.PANGO_SCALE, index, trailing);
+		int /*long*/ ptr = OS.pango_layout_get_text (layout);
+		int position = (int)/*64*/OS.g_utf8_pointer_to_offset (ptr, ptr + index[0]) + trailing[0];
+		Point selection = getSelection ();
+		if (selection.x <= position && position < selection.y) {
+			if (super.dragDetect (x, y, filter, consume)) {
+				if (consume != null) consume [0] = true;
+				return true;
+			}
+		}
+		return false;
+	}
+	return super.dragDetect (x, y, filter, consume);
+}
+
+int /*long*/ enterExitHandle () {
+	return fixedHandle;
+}
+
+int /*long*/ eventWindow () {
+	return paintWindow ();
+}
+
+GdkColor getBackgroundColor () {
+	return getBaseColor ();
+}
+
+GdkColor getForegroundColor () {
+	return getTextColor ();
+}
+
+/**
+ * Returns the item at the given, zero-relative index in the
+ * receiver's list. Throws an exception if the index is out
+ * of range.
+ *
+ * @param index the index of the item to return
+ * @return the item at the given index
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public String getItem (int index) {
+	checkWidget();
+	if (!(0 <= index && index < items.length)) {
+		error (SWT.ERROR_INVALID_RANGE);
+	}
+	return items [index];
+}
+
+/**
+ * Returns the number of items contained in the receiver's list.
+ *
+ * @return the number of items
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getItemCount () {
+	checkWidget();
+	return items.length;
+}
+
+/**
+ * Returns the height of the area which would be used to
+ * display <em>one</em> of the items in the receiver's list.
+ *
+ * @return the height of one item
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getItemHeight () {
+	checkWidget();
+	return fontHeight (getFontDescription (), listHandle != 0 ? listHandle : handle);
+}
+
+/**
+ * Returns a (possibly empty) array of <code>String</code>s which are
+ * the items in the receiver's list. 
+ * <p>
+ * Note: This is not the actual structure used by the receiver
+ * to maintain its list of items, so modifying the array will
+ * not affect the receiver. 
+ * </p>
+ *
+ * @return the items in the receiver's list
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public String [] getItems () {
+	checkWidget();
+	String [] result = new String [items.length];
+	System.arraycopy (items, 0, result, 0, items.length);
+	return result;
+}
+
+/**
+ * Returns <code>true</code> if the receiver's list is visible,
+ * and <code>false</code> otherwise.
+ * <p>
+ * If one of the receiver's ancestors is not visible or some
+ * other condition makes the receiver not visible, this method
+ * may still indicate that it is considered visible even though
+ * it may not actually be showing.
+ * </p>
+ *
+ * @return the receiver's list's visibility state
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.4
+ */
+public boolean getListVisible () {
+	checkWidget ();
+	if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
+		return popupHandle != 0 && OS.GTK_WIDGET_VISIBLE (popupHandle); 
+	}
+	return false;
+}
+
+String getNameText () {
+	return getText ();
+}
+
+/**
+ * Returns the orientation of the receiver.
+ *
+ * @return the orientation style
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 2.1.2
+ */
+public int getOrientation () {
+	checkWidget();
+	return style & (SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT);
+}
+
+/**
+ * Returns a <code>Point</code> whose x coordinate is the
+ * character position representing the start of the selection
+ * in the receiver's text field, and whose y coordinate is the
+ * character position representing the end of the selection.
+ * An "empty" selection is indicated by the x and y coordinates
+ * having the same value.
+ * <p>
+ * Indexing is zero based.  The range of a selection is from
+ * 0..N where N is the number of characters in the widget.
+ * </p>
+ *
+ * @return a point representing the selection start and end
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Point getSelection () {
+	checkWidget ();
+	if ((style & SWT.READ_ONLY) != 0) {
+		int length = 0;
+		if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
+			int index = OS.gtk_combo_box_get_active (handle);
+			if (index != -1) length = getItem (index).length ();
+		} else {
+			int /*long*/ str = OS.gtk_entry_get_text (entryHandle);
+			if (str != 0) length = (int)/*64*/OS.g_utf8_strlen (str, -1);
+		}
+		return new Point (0, length);
+	}
+	int [] start = new int [1];
+	int [] end = new int [1];
+	if (entryHandle != 0) {
+		OS.gtk_editable_get_selection_bounds (entryHandle, start, end);
+	}
+	return new Point(start [0], end [0]);
+}
+
+/**
+ * Returns the zero-relative index of the item which is currently
+ * selected in the receiver's list, or -1 if no item is selected.
+ *
+ * @return the index of the selected item
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getSelectionIndex () {
+	checkWidget();
+	if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
+		return OS.gtk_combo_box_get_active (handle);
+	}
+	int index = 0, result = -1;
+	int /*long*/ children = OS.gtk_container_get_children (listHandle);
+	int /*long*/ temp = children;
+	while (temp != 0) {
+		int /*long*/ item = OS.g_list_data (temp);
+		if (OS.GTK_WIDGET_STATE (item) == OS.GTK_STATE_SELECTED) {
+			result = index;
+			break;
+		}
+		index++;
+		temp = OS.g_list_next (temp);
+	}	
+	OS.g_list_free (children);
+	return result;
+}
+
+/**
+ * Returns a string containing a copy of the contents of the
+ * receiver's text field, or an empty string if there are no
+ * contents.
+ *
+ * @return the receiver's text
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public String getText () {
+	checkWidget();
+	if (entryHandle != 0) {
+		int /*long*/ str = OS.gtk_entry_get_text (entryHandle);
+		if (str == 0) return "";
+		int length = OS.strlen (str);
+		byte [] buffer = new byte [length];
+		OS.memmove (buffer, str, length);
+		return new String (Converter.mbcsToWcs (null, buffer));
+	} else {
+		int index = OS.gtk_combo_box_get_active (handle);		  
+		return index != -1 ? getItem (index) : "";
+	}
+}
+
+String getText (int start, int stop) {
+	/*
+	* NOTE: The current implementation uses substring ()
+	* which can reference a potentially large character
+	* array.
+	*/
+	return getText ().substring (start, stop - 1);
+}
+
+/**
+ * Returns the height of the receivers's text field.
+ *
+ * @return the text height
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getTextHeight () {
+	checkWidget();
+	GtkRequisition requisition = new GtkRequisition ();
+	gtk_widget_size_request (handle, requisition);
+	return OS.GTK_WIDGET_REQUISITION_HEIGHT (handle);
+}
+
+/**
+ * Returns the maximum number of characters that the receiver's
+ * text field is capable of holding. If this has not been changed
+ * by <code>setTextLimit()</code>, it will be the constant
+ * <code>Combo.LIMIT</code>.
+ * 
+ * @return the text limit
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #LIMIT
+ */
+public int getTextLimit () {
+	checkWidget();
+	int limit = entryHandle != 0 ? OS.gtk_entry_get_max_length (entryHandle) : 0;
+	return limit == 0 ? LIMIT : limit;
+}
+
+/**
+ * Gets the number of items that are visible in the drop
+ * down portion of the receiver's list.
+ * <p>
+ * Note: This operation is a hint and is not supported on
+ * platforms that do not have this concept.
+ * </p>
+ *
+ * @return the number of items that are visible
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.0
+ */
+public int getVisibleItemCount () {
+	checkWidget ();
+	return visibleCount;
+}
+
+int /*long*/ gtk_activate (int /*long*/ widget) {
+	postEvent (SWT.DefaultSelection);
+	return 0;
+}
+
+int /*long*/ gtk_button_press_event (int /*long*/ widget, int /*long*/ event) {
+	/*
+	* Feature in GTK. Depending on where the user clicks, GTK prevents 
+	* the left mouse button event from being propagated. The fix is to
+	* send the mouse event from the event_after handler.
+	*/
+	if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
+		GdkEventButton gdkEvent = new GdkEventButton ();
+		OS.memmove (gdkEvent, event, GdkEventButton.sizeof);
+		if (gdkEvent.type == OS.GDK_BUTTON_PRESS && gdkEvent.button == 1 && (style & SWT.READ_ONLY) != 0) {
+			return gtk_button_press_event(widget, event, false);
+		}
+	}
+	return super.gtk_button_press_event (widget, event);
+}
+
+int /*long*/ gtk_changed (int /*long*/ widget) {
+	if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
+		if (widget == handle) {
+			if (entryHandle == 0) {
+				sendEvent(SWT.Modify);
+				if (isDisposed ()) return 0;
+			}
+			/*
+			* Feature in GTK.  GTK emits a changed signal whenever
+			* the contents of a combo box are altered by typing or
+			* by selecting an item in the list, but the event should
+			* only be sent when the list is selected. The fix is to
+			* only send out a selection event when there is a selected
+			* item. 
+			* 
+			* NOTE: This code relies on GTK clearing the selected
+			* item and not matching the item as the user types.
+			*/
+			int index = OS.gtk_combo_box_get_active (handle);
+			if (index != -1) postEvent (SWT.Selection);
+			return 0;
+		}
+	} else {
+		if (!ignoreSelect) {
+			int /*long*/ ptr = OS.gtk_entry_get_text (entryHandle);
+			int length = OS.strlen (ptr);
+			byte [] buffer = new byte [length];
+			OS.memmove (buffer, ptr, length);
+			String text = new String (Converter.mbcsToWcs (null, buffer));
+			for (int i = 0; i < items.length; i++) {
+				if (items [i].equals (text)) {
+					postEvent (SWT.Selection);
+					break;
+				}
+			}
+		}
+	}
+	/*
+	* Feature in GTK.  When the user types, GTK positions
+	* the caret after sending the changed signal.  This
+	* means that application code that attempts to position
+	* the caret during a changed signal will fail.  The fix
+	* is to post the modify event when the user is typing.
+	*/
+	boolean keyPress = false;
+	int /*long*/ eventPtr = OS.gtk_get_current_event ();
+	if (eventPtr != 0) {
+		GdkEventKey gdkEvent = new GdkEventKey ();
+		OS.memmove (gdkEvent, eventPtr, GdkEventKey.sizeof);
+		switch (gdkEvent.type) {
+			case OS.GDK_KEY_PRESS:
+				keyPress = true;
+				break;
+		}
+		OS.gdk_event_free (eventPtr);
+	}
+	if (keyPress) {
+		postEvent (SWT.Modify);
+	} else {
+		sendEvent (SWT.Modify);
+	}
+	return 0;
+}
+
+int /*long*/ gtk_commit (int /*long*/ imContext, int /*long*/ text) {
+	if (text == 0) return 0;
+	if (!OS.gtk_editable_get_editable (entryHandle)) return 0;
+	int length = OS.strlen (text);
+	if (length == 0) return 0;
+	byte [] buffer = new byte [length];
+	OS.memmove (buffer, text, length);
+	char [] chars = Converter.mbcsToWcs (null, buffer);
+	char [] newChars = sendIMKeyEvent (SWT.KeyDown, null, chars);
+	if (newChars == null) return 0;
+	/*
+	* Feature in GTK.  For a GtkEntry, during the insert-text signal,
+	* GTK allows the programmer to change only the caret location,
+	* not the selection.  If the programmer changes the selection,
+	* the new selection is lost.  The fix is to detect a selection
+	* change and set it after the insert-text signal has completed.
+	*/
+	fixStart = fixEnd = -1;
+	OS.g_signal_handlers_block_matched (imContext, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, COMMIT);
+	int id = OS.g_signal_lookup (OS.commit, OS.gtk_im_context_get_type ());
+	int mask =  OS.G_SIGNAL_MATCH_DATA | OS.G_SIGNAL_MATCH_ID;
+	OS.g_signal_handlers_unblock_matched (imContext, mask, id, 0, 0, 0, entryHandle);
+	if (newChars == chars) {
+		OS.g_signal_emit_by_name (imContext, OS.commit, text);
+	} else {
+		buffer = Converter.wcsToMbcs (null, newChars, true);
+		OS.g_signal_emit_by_name (imContext, OS.commit, buffer);
+	}
+	OS.g_signal_handlers_unblock_matched (imContext, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, COMMIT);
+	OS.g_signal_handlers_block_matched (imContext, mask, id, 0, 0, 0, entryHandle);
+	if (fixStart != -1 && fixEnd != -1) {
+		OS.gtk_editable_set_position (entryHandle, fixStart);
+		OS.gtk_editable_select_region (entryHandle, fixStart, fixEnd);
+	}
+	fixStart = fixEnd = -1;
+	return 0;
+}
+
+int /*long*/ gtk_delete_text (int /*long*/ widget, int /*long*/ start_pos, int /*long*/ end_pos) {
+	if (lockText) {
+		OS.gtk_list_unselect_item (listHandle, 0);
+		OS.g_signal_stop_emission_by_name (entryHandle, OS.delete_text);
+		return 0;
+	}
+	if (!hooks (SWT.Verify) && !filters (SWT.Verify)) return 0;
+	String newText = verifyText ("", (int)/*64*/start_pos, (int)/*64*/end_pos);
+	if (newText == null) {
+		OS.g_signal_stop_emission_by_name (entryHandle, OS.delete_text);
+	} else {
+		if (newText.length () > 0) {
+			int [] pos = new int [1];
+			pos [0] = (int)/*64*/end_pos;
+			byte [] buffer = Converter.wcsToMbcs (null, newText, false);
+			OS.g_signal_handlers_block_matched (entryHandle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+			OS.g_signal_handlers_block_matched (entryHandle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, INSERT_TEXT);
+			OS.gtk_editable_insert_text (entryHandle, buffer, buffer.length, pos);
+			OS.g_signal_handlers_unblock_matched (entryHandle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, INSERT_TEXT);
+			OS.g_signal_handlers_unblock_matched (entryHandle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+			OS.gtk_editable_set_position (entryHandle, pos [0]);
+		}
+	}
+	return 0;
+}
+
+int /*long*/ gtk_event_after (int /*long*/ widget, int /*long*/ gdkEvent)  {
+	/*
+	* Feature in GTK. Depending on where the user clicks, GTK prevents 
+	* the left mouse button event from being propagated. The fix is to
+	* send the mouse event from the event_after handler.
+	* 
+	* Feature in GTK. When the user clicks anywhere in an editable 
+	* combo box, a single focus event should be issued, despite the 
+	* fact that focus might switch between the drop down button and
+	* the text field. The fix is to use gtk_combo_box_set_focus_on_click ()
+	* to eat all focus events while focus is in the combo box. When the 
+	* user clicks on the drop down button focus is assigned to the text 
+	* field.
+	*/
+	if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
+		GdkEvent event = new GdkEvent ();
+		OS.memmove (event, gdkEvent, GdkEvent.sizeof);
+		switch (event.type) {
+			case OS.GDK_BUTTON_PRESS: {
+				GdkEventButton gdkEventButton = new GdkEventButton ();
+				OS.memmove (gdkEventButton, gdkEvent, GdkEventButton.sizeof);
+				if (gdkEventButton.button == 1) {
+					if ((style & SWT.READ_ONLY) != 0 && !sendMouseEvent (SWT.MouseDown, gdkEventButton.button, display.clickCount, 0, false, gdkEventButton.time, gdkEventButton.x_root, gdkEventButton.y_root, false, gdkEventButton.state)) {
+						return 1;
+					}
+					if (OS.GTK_VERSION >= OS.VERSION (2, 6, 0)) {
+						if ((style & SWT.READ_ONLY) == 0 && widget == buttonHandle) {
+							OS.gtk_widget_grab_focus (entryHandle);
+						}
+					}
+				}
+				break;
+			}
+			case OS.GDK_FOCUS_CHANGE: {
+				if (OS.GTK_VERSION >= OS.VERSION (2, 6, 0)) {
+					if ((style & SWT.READ_ONLY) == 0) {
+						GdkEventFocus gdkEventFocus = new GdkEventFocus ();
+						OS.memmove (gdkEventFocus, gdkEvent, GdkEventFocus.sizeof);
+						if (gdkEventFocus.in != 0) {
+							OS.gtk_combo_box_set_focus_on_click (handle, false);
+						} else {
+							OS.gtk_combo_box_set_focus_on_click (handle, true);
+						}
+					}
+				}
+				break;
+			}
+		}
+	}
+	return super.gtk_event_after(widget, gdkEvent);
+}
+
+int /*long*/ gtk_focus_out_event (int /*long*/ widget, int /*long*/ event) {
+	fixIM ();
+	return super.gtk_focus_out_event (widget, event);
+}
+
+int /*long*/ gtk_insert_text (int /*long*/ widget, int /*long*/ new_text, int /*long*/ new_text_length, int /*long*/ position) {
+	if (lockText) {
+		OS.gtk_list_unselect_item (listHandle, 0);
+		OS.g_signal_stop_emission_by_name (entryHandle, OS.insert_text);
+		return 0;
+	}
+	if (!hooks (SWT.Verify) && !filters (SWT.Verify)) return 0;	
+	if (new_text == 0 || new_text_length == 0) return 0;
+	byte [] buffer = new byte [(int)/*64*/new_text_length];
+	OS.memmove (buffer, new_text, buffer.length);
+	String oldText = new String (Converter.mbcsToWcs (null, buffer));
+	int [] pos = new int [1];
+	OS.memmove (pos, position, 4);
+	if (pos [0] == -1) {
+		int /*long*/ ptr = OS.gtk_entry_get_text (entryHandle);
+		pos [0] = (int)/*64*/OS.g_utf8_strlen (ptr, -1);
+	}
+	String newText = verifyText (oldText, pos [0], pos [0]);
+	if (newText != oldText) {
+		int [] newStart = new int [1], newEnd = new int [1];
+		OS.gtk_editable_get_selection_bounds (entryHandle, newStart, newEnd);
+		if (newText != null) {
+			if (newStart [0] != newEnd [0]) {
+				OS.g_signal_handlers_block_matched (entryHandle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, DELETE_TEXT);
+				OS.g_signal_handlers_block_matched (entryHandle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+				OS.gtk_editable_delete_selection (entryHandle);
+				OS.g_signal_handlers_unblock_matched (entryHandle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, DELETE_TEXT);
+				OS.g_signal_handlers_unblock_matched (entryHandle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+			}
+			byte [] buffer3 = Converter.wcsToMbcs (null, newText, false);
+			OS.g_signal_handlers_block_matched (entryHandle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, INSERT_TEXT);
+			OS.gtk_editable_insert_text (entryHandle, buffer3, buffer3.length, pos);
+			OS.g_signal_handlers_unblock_matched (entryHandle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, INSERT_TEXT);
+			newStart [0] = newEnd [0] = pos [0];
+		}
+		pos [0] = newEnd [0];
+		if (newStart [0] != newEnd [0]) {
+			fixStart = newStart [0];
+			fixEnd = newEnd [0];
+		}
+		OS.memmove (position, pos, 4);
+		OS.g_signal_stop_emission_by_name (entryHandle, OS.insert_text);
+	}
+	return 0;
+}
+
+int /*long*/ gtk_key_press_event (int /*long*/ widget, int /*long*/ event) {
+	int /*long*/ result = super.gtk_key_press_event (widget, event);
+	if (result != 0) fixIM ();
+	if (gdkEventKey == -1) result = 1;
+	gdkEventKey = 0;
+	if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0) && (style & SWT.READ_ONLY) == 0) {
+		GdkEventKey keyEvent = new GdkEventKey ();
+		OS.memmove (keyEvent, event, GdkEventKey.sizeof);
+		int oldIndex = OS.gtk_combo_box_get_active (handle);
+		int newIndex = oldIndex;
+		int key = keyEvent.keyval;
+		switch (key) {
+			case OS.GDK_Down:
+			case OS.GDK_KP_Down: 
+				 if (oldIndex != (items.length - 1)) {
+					newIndex = oldIndex + 1;
+				 }
+				 break;
+			case OS.GDK_Up:
+			case OS.GDK_KP_Up: 
+				if (oldIndex != -1 && oldIndex != 0) {
+					newIndex = oldIndex - 1;
+				}
+				break;
+			/*
+			* Feature in GTK. In gtk_combo_box, the PageUp and PageDown keys
+			* go the first and last items in the list rather than scrolling
+			* a page at a time. The fix is to emulate this behavior for
+			* gtk_combo_box_entry.
+			*/
+			case OS.GDK_Page_Up:
+		    case OS.GDK_KP_Page_Up:
+		    	newIndex = 0;
+		    	break;
+		    case OS.GDK_Page_Down:
+		    case OS.GDK_KP_Page_Down:
+		    	newIndex = items.length - 1;
+		    	break;  
+		}
+		if (newIndex != oldIndex) {
+			OS.g_signal_handlers_block_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+			OS.gtk_combo_box_set_active (handle, newIndex);
+			OS.g_signal_handlers_unblock_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+			return 1;
+		}
+	}
+	return result;
+}
+
+int /*long*/ gtk_populate_popup (int /*long*/ widget, int /*long*/ menu) {
+	if ((style & SWT.RIGHT_TO_LEFT) != 0) {
+		OS.gtk_widget_set_direction (menu, OS.GTK_TEXT_DIR_RTL);
+		OS.gtk_container_forall (menu, display.setDirectionProc, OS.GTK_TEXT_DIR_RTL);
+	}
+	return 0;
+}
+
+/**
+ * Searches the receiver's list starting at the first item
+ * (index 0) until an item is found that is equal to the 
+ * argument, and returns the index of that item. If no item
+ * is found, returns -1.
+ *
+ * @param string the search item
+ * @return the index of the item
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int indexOf (String string) {
+	checkWidget();
+	return indexOf (string, 0);
+}
+
+/**
+ * Searches the receiver's list starting at the given, 
+ * zero-relative index until an item is found that is equal
+ * to the argument, and returns the index of that item. If
+ * no item is found or the starting index is out of range,
+ * returns -1.
+ *
+ * @param string the search item
+ * @param start the zero-relative index at which to begin the search
+ * @return the index of the item
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int indexOf (String string, int start) {
+	checkWidget();
+	if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if (!(0 <= start && start < items.length)) return -1;
+	for (int i=start; i<items.length; i++) {
+		if (string.equals(items [i])) return i;
+	}
+	return -1;
+}
+
+boolean isFocusHandle(int widget) {
+	if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
+		if (buttonHandle != 0 && widget == buttonHandle) return true;
+		if (entryHandle != 0 && widget == entryHandle) return true;
+	}
+	return super.isFocusHandle (widget);
+}
+
+int /*long*/ paintWindow () {
+	int /*long*/ childHandle =  entryHandle != 0 ? entryHandle : handle;	
+	OS.gtk_widget_realize (childHandle);
+	int /*long*/ window = OS.GTK_WIDGET_WINDOW (childHandle);
+	if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
+		if ((style & SWT.READ_ONLY) != 0) return window;
+	}
+	int /*long*/ children = OS.gdk_window_get_children (window);
+	if (children != 0) window = OS.g_list_data (children);
+	OS.g_list_free (children);
+	return window;
+}
+
+/**
+ * Pastes text from clipboard.
+ * <p>
+ * The selected text is deleted from the widget
+ * and new text inserted from the clipboard.
+ * </p>
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 2.1
+ */
+public void paste () {
+	checkWidget ();
+	if (entryHandle != 0) OS.gtk_editable_paste_clipboard (entryHandle);
+}
+
+int /*long*/ parentingHandle() {
+	return fixedHandle;
+}
+
+void register () {
+	super.register ();
+	if (buttonHandle != 0) display.addWidget (buttonHandle, this);
+	if (entryHandle != 0) display.addWidget (entryHandle, this);
+	if (listHandle != 0) display.addWidget (listHandle, this);
+	int /*long*/ imContext = imContext ();
+	if (imContext != 0) display.addWidget (imContext, this);
+}
+
+void releaseHandle () {
+	super.releaseHandle ();
+	buttonHandle = entryHandle = listHandle = 0;
+}
+
+void releaseWidget () {
+	super.releaseWidget ();
+	textRenderer = 0;
+	fixIM ();
+}
+
+/**
+ * Removes the item from the receiver's list at the given
+ * zero-relative index.
+ *
+ * @param index the index for the item
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void remove (int index) {
+	checkWidget();
+	if (!(0 <= index && index < items.length)) {
+		error (SWT.ERROR_INVALID_RANGE);
+	}
+	String [] oldItems = items;
+	String [] newItems = new String [oldItems.length - 1];
+	System.arraycopy (oldItems, 0, newItems, 0, index);
+	System.arraycopy (oldItems, index + 1, newItems, index, oldItems.length - index - 1);
+	items = newItems;
+	if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
+		if (OS.gtk_combo_box_get_active (handle) == index) clearText ();
+		OS.gtk_combo_box_remove_text (handle, index);
+	} else {
+		ignoreSelect = true;
+		int /*long*/ children = OS.gtk_container_get_children (listHandle);
+		int /*long*/ item = OS.g_list_nth_data (children, index);
+		boolean selected = OS.GTK_WIDGET_STATE (item) == OS.GTK_STATE_SELECTED;
+		int /*long*/ items = OS.g_list_append (0, item);
+		OS.gtk_list_remove_items (listHandle, items);
+		OS.g_list_free (items);
+		OS.g_list_free (children);
+		if (selected) {
+			OS.gtk_entry_set_text (entryHandle, new byte[1]);
+		}
+		ignoreSelect = false;
+	}
+}
+
+/**
+ * Removes the items from the receiver's list which are
+ * between the given zero-relative start and end 
+ * indices (inclusive).
+ *
+ * @param start the start of the range
+ * @param end the end of the range
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_RANGE - if either the start or end are not between 0 and the number of elements in the list minus 1 (inclusive)</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void remove (int start, int end) {
+	checkWidget();
+	if (start > end) return;
+	if (!(0 <= start && start <= end && end < items.length)) {
+		error (SWT.ERROR_INVALID_RANGE);
+	}
+	String [] oldItems = items;
+	String [] newItems = new String [oldItems.length - (end - start + 1)];
+	System.arraycopy (oldItems, 0, newItems, 0, start);
+	System.arraycopy (oldItems, end + 1, newItems, start, oldItems.length - end - 1);
+	items = newItems;
+	if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
+		int index = OS.gtk_combo_box_get_active (handle);
+		if (start <= index && index <= end) clearText();
+		for (int i = end; i >= start; i--) {
+			OS.gtk_combo_box_remove_text (handle, i);
+		}
+	} else {
+		boolean selected = false;
+		ignoreSelect = true;
+		int /*long*/ items = 0;
+		int /*long*/ children = OS.gtk_container_get_children (listHandle);
+		for (int i = start; i <= end; i++) {
+			int /*long*/ item = OS.g_list_nth_data (children, i);
+			selected |= OS.GTK_WIDGET_STATE (item) == OS.GTK_STATE_SELECTED;
+			items = OS.g_list_append (items, item);
+		}
+		OS.gtk_list_remove_items (listHandle, items);
+		OS.g_list_free (items);
+		OS.g_list_free (children);
+		if (selected) {
+			OS.gtk_entry_set_text (entryHandle, new byte[1]);
+		}
+		ignoreSelect = false;
+	}
+}
+
+/**
+ * Searches the receiver's list starting at the first item
+ * until an item is found that is equal to the argument, 
+ * and removes that item from the list.
+ *
+ * @param string the item to remove
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the string is not found in the list</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void remove (String string) {
+	checkWidget();
+	if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+	int index = indexOf (string, 0);
+	if (index == -1) error (SWT.ERROR_INVALID_ARGUMENT);
+	remove (index);
+}
+
+/**
+ * Removes all of the items from the receiver's list and clear the
+ * contents of receiver's text field.
+ * <p>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void removeAll () {
+	checkWidget();
+	int count = items.length;
+	items = new String[0];
+	if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
+		clearText ();
+		for (int i = count - 1; i >= 0; i--) {
+			OS.gtk_combo_box_remove_text (handle, i);
+		}
+	} else {
+		ignoreSelect = true;
+		OS.gtk_list_clear_items (listHandle, 0, -1);
+		OS.gtk_entry_set_text (entryHandle, new byte[1]);
+		ignoreSelect = false;
+	}
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the receiver's text is modified.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see ModifyListener
+ * @see #addModifyListener
+ */
+public void removeModifyListener (ModifyListener listener) {
+	checkWidget();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if (eventTable == null) return;
+	eventTable.unhook (SWT.Modify, listener);	
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the user changes the receiver's selection.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #addSelectionListener
+ */
+public void removeSelectionListener (SelectionListener listener) {
+	checkWidget();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if (eventTable == null) return;
+	eventTable.unhook (SWT.Selection, listener);
+	eventTable.unhook (SWT.DefaultSelection,listener);	
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the control is verified.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see VerifyListener
+ * @see #addVerifyListener
+ * 
+ * @since 3.1
+ */
+public void removeVerifyListener (VerifyListener listener) {
+	checkWidget ();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if (eventTable == null) return;
+	eventTable.unhook (SWT.Verify, listener);	
+}
+
+/**
+ * Selects the item at the given zero-relative index in the receiver's 
+ * list.  If the item at the index was already selected, it remains
+ * selected. Indices that are out of range are ignored.
+ *
+ * @param index the index of the item to select
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void select (int index) {
+	checkWidget();
+	if (index < 0 || index >= items.length) return;
+	if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
+		OS.g_signal_handlers_block_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+		OS.gtk_combo_box_set_active (handle, index);
+		OS.g_signal_handlers_unblock_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+		if ((style & SWT.READ_ONLY) != 0) {
+			/*
+			* Feature in GTK. Read Only combo boxes do not get a chance to send out a 
+			* Modify event in the gtk_changed callback. The fix is to send a Modify event 
+			* here.
+			*/
+			sendEvent (SWT.Modify);
+		}
+	} else {
+		ignoreSelect = true;
+		OS.gtk_list_select_item (listHandle, index);
+		ignoreSelect = false;
+	}
+}
+
+void setBackgroundColor (GdkColor color) {
+	super.setBackgroundColor (color);
+	if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
+		if (entryHandle != 0) OS.gtk_widget_modify_base (entryHandle, 0, color);
+		OS.g_object_set (textRenderer, OS.background_gdk, color, 0);
+	} else {
+		OS.gtk_widget_modify_base (entryHandle, 0, color);
+		if (listHandle != 0) OS.gtk_widget_modify_base (listHandle, 0, color);
+	}
+}
+
+int setBounds (int x, int y, int width, int height, boolean move, boolean resize) {
+	int newHeight = height;
+	if (resize) newHeight = Math.max (getTextHeight (), height);
+	return super.setBounds (x, y, width, newHeight, move, resize);
+}
+
+void setFontDescription (int /*long*/ font) {
+	super.setFontDescription (font);
+	if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
+		if (entryHandle != 0) OS.gtk_widget_modify_font (entryHandle, font);
+		OS.g_object_set (textRenderer, OS.font_desc, font, 0);
+		if ((style & SWT.READ_ONLY) != 0) {
+			/*
+			* Bug in GTK.  Setting the font can leave the combo box with an
+			* invalid minimum size.  The fix is to temporarily change the
+			* selected item to force the combo box to resize.
+			*/
+			int index = OS.gtk_combo_box_get_active (handle);
+			OS.g_signal_handlers_block_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+			OS.gtk_combo_box_set_active (handle, -1);
+			OS.gtk_combo_box_set_active (handle, index);
+			OS.g_signal_handlers_unblock_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+		}
+	} else {
+		OS.gtk_widget_modify_font (entryHandle, font);
+		if (listHandle != 0) {
+			OS.gtk_widget_modify_font (listHandle, font);
+			int /*long*/ itemsList = OS.gtk_container_get_children (listHandle);
+			if (itemsList != 0) {
+				int count = OS.g_list_length (itemsList);
+				for (int i=count - 1; i>=0; i--) {
+					int /*long*/ widget = OS.gtk_bin_get_child (OS.g_list_nth_data (itemsList, i));
+					OS.gtk_widget_modify_font (widget, font);
+				}
+				OS.g_list_free (itemsList);
+			}
+		}
+	}
+}
+
+void setForegroundColor (GdkColor color) {
+	super.setForegroundColor (color);
+	if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
+		if (entryHandle != 0) setForegroundColor (entryHandle, color);
+		OS.g_object_set (textRenderer, OS.foreground_gdk, color, 0);
+	} else {
+		setForegroundColor (entryHandle, color);
+		if (listHandle != 0) {
+			setForegroundColor (listHandle, color);
+			int /*long*/ itemsList = OS.gtk_container_get_children (listHandle);
+			if (itemsList != 0) {
+				int count = OS.g_list_length (itemsList);
+				for (int i=count - 1; i>=0; i--) {
+					int /*long*/ widget = OS.gtk_bin_get_child (OS.g_list_nth_data (itemsList, i));
+					setForegroundColor (widget, color);
+				}
+				OS.g_list_free (itemsList);
+			}
+		}
+	}
+}
+
+/**
+ * Sets the text of the item in the receiver's list at the given
+ * zero-relative index to the string argument.
+ *
+ * @param index the index for the item
+ * @param string the new text for the item
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
+ *    <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setItem (int index, String string) {
+	checkWidget();
+	if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if (!(0 <= index && index < items.length)) {
+		error (SWT.ERROR_INVALID_ARGUMENT);
+	}
+	items [index] = string;
+	byte [] buffer = Converter.wcsToMbcs (null, string, true);
+	if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
+		OS.gtk_combo_box_remove_text (handle, index);
+		OS.gtk_combo_box_insert_text (handle, index, buffer);
+		if ((style & SWT.RIGHT_TO_LEFT) != 0 && popupHandle != 0) {
+			OS.gtk_container_forall (popupHandle, display.setDirectionProc, OS.GTK_TEXT_DIR_RTL);    
+		}
+	} else {
+		ignoreSelect = true;
+		int /*long*/ children = OS.gtk_container_get_children (listHandle);
+		int /*long*/ item = OS.g_list_nth_data (children, index);
+		int /*long*/ label = OS.gtk_bin_get_child (item);
+		OS.gtk_label_set_text (label, buffer);
+		OS.g_list_free (children);
+		ignoreSelect = false;
+	}
+}
+
+/**
+ * Sets the receiver's list to be the given array of items.
+ *
+ * @param items the array of items
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the items array is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if an item in the items array is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setItems (String [] items) {
+	checkWidget();
+	if (items == null) error (SWT.ERROR_NULL_ARGUMENT);
+	for (int i=0; i<items.length; i++) {
+		if (items [i] == null) error (SWT.ERROR_INVALID_ARGUMENT);
+	}
+	int count = this.items.length;
+	this.items = new String [items.length];
+	System.arraycopy (items, 0, this.items, 0, items.length);
+	if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
+		clearText ();
+		for (int i = count - 1; i >= 0; i--) {
+			OS.gtk_combo_box_remove_text (handle, i);
+		}
+		for (int i = 0; i < items.length; i++) {
+			String string = items [i];
+			byte [] buffer = Converter.wcsToMbcs (null, string, true);
+			OS.gtk_combo_box_insert_text (handle, i, buffer);
+			if ((style & SWT.RIGHT_TO_LEFT) != 0 && popupHandle != 0) {
+				OS.gtk_container_forall (popupHandle, display.setDirectionProc, OS.GTK_TEXT_DIR_RTL);    
+			}
+		}
+	} else {
+		lockText = ignoreSelect = true;
+		OS.gtk_list_clear_items (listHandle, 0, -1);
+		int /*long*/ font = getFontDescription ();
+		GdkColor color = getForegroundColor ();
+		int direction = OS.gtk_widget_get_direction (handle);
+		int i = 0;
+		while (i < items.length) {
+			String string = items [i];
+			byte [] buffer = Converter.wcsToMbcs (null, string, true);
+			int /*long*/ item = OS.gtk_list_item_new_with_label (buffer);
+			int /*long*/ label = OS.gtk_bin_get_child (item); 
+			setForegroundColor (label, color);
+			OS.gtk_widget_modify_font (label, font);
+			OS.gtk_widget_set_direction (label, direction);
+			OS.gtk_container_add (listHandle, item);
+			OS.gtk_widget_show (item);
+			i++;
+		}
+		lockText = ignoreSelect = false;
+		OS.gtk_entry_set_text (entryHandle, new byte[1]);
+	}
+}
+
+/**
+ * Marks the receiver's list as visible if the argument is <code>true</code>,
+ * and marks it invisible otherwise.
+ * <p>
+ * If one of the receiver's ancestors is not visible or some
+ * other condition makes the receiver not visible, marking
+ * it visible may not actually cause it to be displayed.
+ * </p>
+ *
+ * @param visible the new visibility state
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.4
+ */
+public void setListVisible (boolean visible) {
+	checkWidget ();
+	if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
+		if (visible) {
+			OS.gtk_combo_box_popup (handle);
+		} else {
+			OS.gtk_combo_box_popdown (handle);
+		}
+	}
+}
+
+void setOrientation() {
+	super.setOrientation();
+	if ((style & SWT.RIGHT_TO_LEFT) != 0) {
+		if (listHandle != 0) OS.gtk_widget_set_direction (listHandle, OS.GTK_TEXT_DIR_RTL);
+		if (entryHandle != 0) OS.gtk_widget_set_direction (entryHandle, OS.GTK_TEXT_DIR_RTL);
+		if (cellHandle != 0) OS.gtk_widget_set_direction (cellHandle, OS.GTK_TEXT_DIR_RTL);
+	}
+}
+
+/**
+ * Sets the orientation of the receiver, which must be one
+ * of the constants <code>SWT.LEFT_TO_RIGHT</code> or <code>SWT.RIGHT_TO_LEFT</code>.
+ * <p>
+ *
+ * @param orientation new orientation style
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 2.1.2
+ */
+public void setOrientation (int orientation) {
+	if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
+		checkWidget();
+		int flags = SWT.RIGHT_TO_LEFT | SWT.LEFT_TO_RIGHT;
+		if ((orientation & flags) == 0 || (orientation & flags) == flags) return;
+		style &= ~flags;
+		style |= orientation & flags;
+		int dir = (orientation & SWT.RIGHT_TO_LEFT) != 0 ? OS.GTK_TEXT_DIR_RTL : OS.GTK_TEXT_DIR_LTR;
+		OS.gtk_widget_set_direction (fixedHandle, dir);
+		OS.gtk_widget_set_direction (handle, dir);
+		if (entryHandle != 0) OS.gtk_widget_set_direction (entryHandle, dir);
+		if (listHandle != 0) {
+			OS.gtk_widget_set_direction (listHandle, dir);
+			int /*long*/ itemsList = OS.gtk_container_get_children (listHandle);
+			if (itemsList != 0) {
+				int count = OS.g_list_length (itemsList);
+				for (int i=count - 1; i>=0; i--) {
+					int /*long*/ widget = OS.gtk_bin_get_child (OS.g_list_nth_data (itemsList, i));
+					OS.gtk_widget_set_direction (widget, dir);
+				}
+				OS.g_list_free (itemsList);
+			}
+		}
+		if (cellHandle != 0) OS.gtk_widget_set_direction (cellHandle, dir);
+		if (popupHandle != 0) OS.gtk_container_forall (popupHandle, display.setDirectionProc, dir);
+	}
+}
+
+/**
+ * Sets the selection in the receiver's text field to the
+ * range specified by the argument whose x coordinate is the
+ * start of the selection and whose y coordinate is the end
+ * of the selection. 
+ *
+ * @param selection a point representing the new selection start and end
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the point is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setSelection (Point selection) {
+	checkWidget();
+	if (selection == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if ((style & SWT.READ_ONLY) != 0) return;
+	if (entryHandle != 0) {
+		OS.gtk_editable_set_position (entryHandle, selection.x);
+		OS.gtk_editable_select_region (entryHandle, selection.x, selection.y);
+	}
+}
+
+/**
+ * Sets the contents of the receiver's text field to the
+ * given string.
+ * <p>
+ * Note: The text field in a <code>Combo</code> is typically
+ * only capable of displaying a single line of text. Thus,
+ * setting the text to a string containing line breaks or
+ * other special characters will probably cause it to 
+ * display incorrectly.
+ * </p>
+ *
+ * @param string the new text
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setText (String string) {
+	checkWidget();
+	if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if ((style & SWT.READ_ONLY) != 0) {
+		int index = indexOf (string);
+		if (index == -1) return;
+		if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
+			OS.g_signal_handlers_block_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+			OS.gtk_combo_box_set_active (handle, index);
+			OS.g_signal_handlers_unblock_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+			/*
+			* Feature in GTK. Read Only combo boxes do not get a chance to send out a 
+			* Modify event in the gtk_changed callback. The fix is to send a Modify event 
+			* here.
+			*/
+			sendEvent (SWT.Modify);
+			return;
+		}
+	}
+	/*
+	* Feature in gtk.  When text is set in gtk, separate events are fired for the deletion and 
+	* insertion of the text.  This is not wrong, but is inconsistent with other platforms.  The
+	* fix is to block the firing of these events and fire them ourselves in a consistent manner. 
+	*/
+	if (hooks (SWT.Verify) || filters (SWT.Verify)) {
+		int /*long*/ ptr = OS.gtk_entry_get_text (entryHandle);
+		string = verifyText (string, 0, (int)/*64*/OS.g_utf8_strlen (ptr, -1));
+		if (string == null) return;
+	}
+	byte [] buffer = Converter.wcsToMbcs (null, string, true);
+	if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
+		OS.g_signal_handlers_block_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+	}
+	OS.g_signal_handlers_block_matched (entryHandle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+	OS.g_signal_handlers_block_matched (entryHandle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, DELETE_TEXT);
+	OS.g_signal_handlers_block_matched (entryHandle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, INSERT_TEXT);
+	OS.gtk_entry_set_text (entryHandle, buffer);
+	if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
+		OS.g_signal_handlers_unblock_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+	}
+	OS.g_signal_handlers_unblock_matched (entryHandle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+	OS.g_signal_handlers_unblock_matched (entryHandle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, DELETE_TEXT);
+	OS.g_signal_handlers_unblock_matched (entryHandle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, INSERT_TEXT);
+	sendEvent (SWT.Modify);
+}
+
+/**
+ * Sets the maximum number of characters that the receiver's
+ * text field is capable of holding to be the argument.
+ * <p>
+ * To reset this value to the default, use <code>setTextLimit(Combo.LIMIT)</code>.
+ * Specifying a limit value larger than <code>Combo.LIMIT</code> sets the
+ * receiver's limit to <code>Combo.LIMIT</code>.
+ * </p>
+ * @param limit new text limit
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_CANNOT_BE_ZERO - if the limit is zero</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see #LIMIT
+ */
+public void setTextLimit (int limit) {
+	checkWidget();
+	if (limit == 0) error (SWT.ERROR_CANNOT_BE_ZERO);
+	if (entryHandle != 0) OS.gtk_entry_set_max_length (entryHandle, limit);
+}
+
+void setToolTipText (Shell shell, String newString) {
+	if (entryHandle != 0) shell.setToolTipText (entryHandle, newString);
+	if (buttonHandle != 0) shell.setToolTipText (buttonHandle, newString);
+}
+
+/**
+ * Sets the number of items that are visible in the drop
+ * down portion of the receiver's list.
+ * <p>
+ * Note: This operation is a hint and is not supported on
+ * platforms that do not have this concept.
+ * </p>
+ *
+ * @param count the new number of items to be visible
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.0
+ */
+public void setVisibleItemCount (int count) {
+	checkWidget ();
+	if (count < 0) return;
+	visibleCount = count;
+}
+
+boolean translateTraversal (GdkEventKey keyEvent) {
+	int key = keyEvent.keyval;
+	switch (key) {
+		case OS.GDK_KP_Enter:
+		case OS.GDK_Return: {
+			int /*long*/ imContext = imContext (); 
+			if (imContext != 0) {
+				int /*long*/ [] preeditString = new int /*long*/ [1];
+				OS.gtk_im_context_get_preedit_string (imContext, preeditString, null, null);
+				if (preeditString [0] != 0) {
+					int length = OS.strlen (preeditString [0]);
+					OS.g_free (preeditString [0]);
+					if (length != 0) return false;
+				}
+			}
+		}
+	}
+	return super.translateTraversal (keyEvent);
+}
+
+String verifyText (String string, int start, int end) {
+	if (string.length () == 0 && start == end) return null;
+	Event event = new Event ();
+	event.text = string;
+	event.start = start;
+	event.end = end;
+	int /*long*/ eventPtr = OS.gtk_get_current_event ();
+	if (eventPtr != 0) {
+		GdkEventKey gdkEvent = new GdkEventKey ();
+		OS.memmove (gdkEvent, eventPtr, GdkEventKey.sizeof);
+		switch (gdkEvent.type) {
+			case OS.GDK_KEY_PRESS:
+				setKeyState (event, gdkEvent);
+				break;
+		}
+		OS.gdk_event_free (eventPtr);
+	}
+	/*
+	 * It is possible (but unlikely), that application
+	 * code could have disposed the widget in the verify
+	 * event.  If this happens, answer null to cancel
+	 * the operation.
+	 */
+	sendEvent (SWT.Verify, event);
+	if (!event.doit || isDisposed ()) return null;
+	return event.text;
+}
+
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Composite.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Composite.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Composite.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,1433 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.widgets;
+
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.cairo.*;
+import org.eclipse.swt.internal.gtk.*;
+import org.eclipse.swt.graphics.*;
+
+/**
+ * Instances of this class are controls which are capable
+ * of containing other controls.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>NO_BACKGROUND, NO_FOCUS, NO_MERGE_PAINTS, NO_REDRAW_RESIZE, NO_RADIO_GROUP, EMBEDDED, DOUBLE_BUFFERED</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>(none)</dd>
+ * </dl>
+ * <p>
+ * Note: The <code>NO_BACKGROUND</code>, <code>NO_FOCUS</code>, <code>NO_MERGE_PAINTS</code>,
+ * and <code>NO_REDRAW_RESIZE</code> styles are intended for use with <code>Canvas</code>.
+ * They can be used with <code>Composite</code> if you are drawing your own, but their
+ * behavior is undefined if they are used with subclasses of <code>Composite</code> other
+ * than <code>Canvas</code>.
+ * </p><p>
+ * Note: The <code>CENTER</code> style, although undefined for composites, has the
+ * same value as <code>EMBEDDED</code> (which is used to embed widgets from other
+ * widget toolkits into SWT).  On some operating systems (GTK, Motif), this may cause
+ * the children of this composite to be obscured.  The <code>EMBEDDED</code> style
+ * is for use by other widget toolkits and should normally never be used.
+ * </p><p>
+ * This class may be subclassed by custom control implementors
+ * who are building controls that are constructed from aggregates
+ * of other controls.
+ * </p>
+ *
+ * @see Canvas
+ * @see <a href="http://www.eclipse.org/swt/snippets/#composite">Composite snippets</a>
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public class Composite extends Scrollable {
+	public int /*long*/  embeddedHandle;
+	int /*long*/ imHandle, socketHandle;
+	Layout layout;
+	Control[] tabList;
+	int layoutCount, backgroundMode;
+
+	static final String NO_INPUT_METHOD = "org.eclipse.swt.internal.gtk.noInputMethod"; //$NON-NLS-1$
+
+Composite () {
+	/* Do nothing */
+}
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a widget which will be the parent of the new instance (cannot be null)
+ * @param style the style of widget to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * </ul>
+ *
+ * @see SWT#NO_BACKGROUND
+ * @see SWT#NO_FOCUS
+ * @see SWT#NO_MERGE_PAINTS
+ * @see SWT#NO_REDRAW_RESIZE
+ * @see SWT#NO_RADIO_GROUP
+ * @see Widget#getStyle
+ */
+public Composite (Composite parent, int style) {
+	super (parent, checkStyle (style));
+}
+
+static int checkStyle (int style) {
+	style &= ~SWT.TRANSPARENT;
+	return style;
+}
+
+Control [] _getChildren () {
+	int /*long*/ parentHandle = parentingHandle ();
+	int /*long*/ list = OS.gtk_container_get_children (parentHandle);
+	if (list == 0) return new Control [0];
+	int count = OS.g_list_length (list);
+	Control [] children = new Control [count];
+	int i = 0;
+	int /*long*/ temp = list;
+	while (temp != 0) {
+		int /*long*/ handle = OS.g_list_data (temp);
+		if (handle != 0) {
+			Widget widget = display.getWidget (handle);
+			if (widget != null && widget != this) {
+				if (widget instanceof Control) {
+					children [i++] = (Control) widget;
+				}
+			}
+		}
+		temp = OS.g_list_next (temp);
+	}
+	OS.g_list_free (list);
+	if (i == count) return children;
+	Control [] newChildren = new Control [i];
+	System.arraycopy (children, 0, newChildren, 0, i);
+	return newChildren;
+}
+
+Control [] _getTabList () {
+	if (tabList == null) return tabList;
+	int count = 0;
+	for (int i=0; i<tabList.length; i++) {
+		if (!tabList [i].isDisposed ()) count++;
+	}
+	if (count == tabList.length) return tabList;
+	Control [] newList = new Control [count];
+	int index = 0;
+	for (int i=0; i<tabList.length; i++) {
+		if (!tabList [i].isDisposed ()) {
+			newList [index++] = tabList [i];
+		}
+	}
+	tabList = newList;
+	return tabList;
+}
+
+/**
+ * Clears any data that has been cached by a Layout for all widgets that 
+ * are in the parent hierarchy of the changed control up to and including the 
+ * receiver.  If an ancestor does not have a layout, it is skipped.
+ * 
+ * @param changed an array of controls that changed state and require a recalculation of size
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the changed array is null any of its controls are null or have been disposed</li> 
+ *    <li>ERROR_INVALID_PARENT - if any control in changed is not in the widget tree of the receiver</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 3.1
+ */
+public void changed (Control[] changed) {
+	checkWidget ();
+	if (changed == null) error (SWT.ERROR_INVALID_ARGUMENT);
+	for (int i=0; i<changed.length; i++) {
+		Control control = changed [i];
+		if (control == null) error (SWT.ERROR_INVALID_ARGUMENT);
+		if (control.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT);
+		boolean ancestor = false;
+		Composite composite = control.parent;
+		while (composite != null) {
+			ancestor = composite == this;
+			if (ancestor) break;
+			composite = composite.parent;
+		}
+		if (!ancestor) error (SWT.ERROR_INVALID_PARENT);
+	}
+	for (int i=0; i<changed.length; i++) {
+		Control child = changed [i];
+		Composite composite = child.parent;
+		while (child != this) {
+			if (composite.layout == null || !composite.layout.flushCache (child)) {
+				composite.state |= LAYOUT_CHANGED;
+			}
+			child = composite;
+			composite = child.parent;
+		}
+	}
+}
+
+void checkBuffered () {
+	if ((style & SWT.DOUBLE_BUFFERED) == 0 && (style & SWT.NO_BACKGROUND) != 0) {
+		return;
+	}
+	super.checkBuffered();
+}
+
+protected void checkSubclass () {
+	/* Do nothing - Subclassing is allowed */
+}
+
+int /*long*/ childStyle () {
+	if (scrolledHandle != 0) return 0;
+	return super.childStyle ();
+}
+
+public Point computeSize (int wHint, int hHint, boolean changed) {
+	checkWidget ();
+	if (wHint != SWT.DEFAULT && wHint < 0) wHint = 0;
+	if (hHint != SWT.DEFAULT && hHint < 0) hHint = 0;
+	Point size;
+	if (layout != null) {
+		if (wHint == SWT.DEFAULT || hHint == SWT.DEFAULT) {
+			changed |= (state & LAYOUT_CHANGED) != 0;
+			size = layout.computeSize (this, wHint, hHint, changed);
+			state &= ~LAYOUT_CHANGED;
+		} else {
+			size = new Point (wHint, hHint);
+		}
+	} else {
+		size = minimumSize (wHint, hHint, changed);
+	}
+	if (size.x == 0) size.x = DEFAULT_WIDTH;
+	if (size.y == 0) size.y = DEFAULT_HEIGHT;
+	if (wHint != SWT.DEFAULT) size.x = wHint;
+	if (hHint != SWT.DEFAULT) size.y = hHint;
+	Rectangle trim = computeTrim (0, 0, size.x, size.y);
+	return new Point (trim.width, trim.height);
+}
+
+Control [] computeTabList () {
+	Control result [] = super.computeTabList ();
+	if (result.length == 0) return result;
+	Control [] list = tabList != null ? _getTabList () : _getChildren ();
+	for (int i=0; i<list.length; i++) {
+		Control child = list [i];
+		Control [] childList = child.computeTabList ();
+		if (childList.length != 0) {
+			Control [] newResult = new Control [result.length + childList.length];
+			System.arraycopy (result, 0, newResult, 0, result.length);
+			System.arraycopy (childList, 0, newResult, result.length, childList.length);
+			result = newResult;
+		}
+	}
+	return result;
+}
+
+void createHandle (int index) {
+	state |= HANDLE | CANVAS;
+	boolean scrolled = (style & (SWT.H_SCROLL | SWT.V_SCROLL)) != 0;
+	if (!scrolled) state |= THEME_BACKGROUND;
+	createHandle (index, true, scrolled || (style & SWT.BORDER) != 0);
+}
+
+void createHandle (int index, boolean fixed, boolean scrolled) {
+	if (scrolled) {
+		if (fixed) {
+			fixedHandle = OS.g_object_new (display.gtk_fixed_get_type (), 0);
+			if (fixedHandle == 0) error (SWT.ERROR_NO_HANDLES);
+			OS.gtk_fixed_set_has_window (fixedHandle, true);
+		}
+		int /*long*/ vadj = OS.gtk_adjustment_new (0, 0, 100, 1, 10, 10);
+		if (vadj == 0) error (SWT.ERROR_NO_HANDLES);
+		int /*long*/ hadj = OS.gtk_adjustment_new (0, 0, 100, 1, 10, 10);
+		if (hadj == 0) error (SWT.ERROR_NO_HANDLES);
+		scrolledHandle = OS.gtk_scrolled_window_new (hadj, vadj);
+		if (scrolledHandle == 0) SWT.error (SWT.ERROR_NO_HANDLES);
+	}
+	handle = OS.g_object_new (display.gtk_fixed_get_type (), 0);
+	if (handle == 0) SWT.error (SWT.ERROR_NO_HANDLES);
+	OS.gtk_fixed_set_has_window (handle, true);
+	OS.GTK_WIDGET_SET_FLAGS(handle, OS.GTK_CAN_FOCUS);
+	if ((style & SWT.EMBEDDED) == 0) {
+		if ((state & CANVAS) != 0) {
+			/* Prevent an input method context from being created for the Browser widget */
+			if (display.getData (NO_INPUT_METHOD) == null) {
+				imHandle = OS.gtk_im_multicontext_new ();
+				if (imHandle == 0) error (SWT.ERROR_NO_HANDLES);
+			}
+		}
+	}
+	if (scrolled) {
+		if (fixed) OS.gtk_container_add (fixedHandle, scrolledHandle);
+		/*
+		* Force the scrolledWindow to have a single child that is
+		* not scrolled automatically.  Calling gtk_container_add()
+		* seems to add the child correctly but cause a warning.
+		*/
+		boolean warnings = display.getWarnings ();
+		display.setWarnings (false);
+		OS.gtk_container_add (scrolledHandle, handle);
+		display.setWarnings (warnings);
+		
+		int hsp = (style & SWT.H_SCROLL) != 0 ? OS.GTK_POLICY_ALWAYS : OS.GTK_POLICY_NEVER;
+		int vsp = (style & SWT.V_SCROLL) != 0 ? OS.GTK_POLICY_ALWAYS : OS.GTK_POLICY_NEVER;
+		OS.gtk_scrolled_window_set_policy (scrolledHandle, hsp, vsp);
+		if (hasBorder ()) {
+			OS.gtk_scrolled_window_set_shadow_type (scrolledHandle, OS.GTK_SHADOW_ETCHED_IN);
+		}
+	}
+	if ((style & SWT.EMBEDDED) != 0) {
+		socketHandle = OS.gtk_socket_new ();
+		if (socketHandle == 0) SWT.error (SWT.ERROR_NO_HANDLES);
+		OS.gtk_container_add (handle, socketHandle);
+	}
+	if ((style & SWT.NO_REDRAW_RESIZE) != 0 && (style & SWT.RIGHT_TO_LEFT) == 0) {
+		OS.gtk_widget_set_redraw_on_allocate (handle, false);
+	}
+	/*
+	* Bug in GTK.  When a widget is double buffered and the back
+	* pixmap is null, the double buffer pixmap is filled with the
+	* background of the widget rather than the current contents of
+	* the screen.  If nothing is drawn during an expose event,
+	* the pixels are altered.  The fix is to clear double buffering
+	* when NO_BACKGROUND is set and DOUBLE_BUFFERED
+	* is not explicitly set.
+	*/
+	if ((style & SWT.DOUBLE_BUFFERED) == 0 && (style & SWT.NO_BACKGROUND) != 0) {
+		OS.gtk_widget_set_double_buffered (handle, false);
+	}
+}
+
+void deregister () {
+	super.deregister ();
+	if (socketHandle != 0) display.removeWidget (socketHandle);
+}
+
+void drawBackground (GC gc, int x, int y, int width, int height) {
+	Control control = findBackgroundControl ();
+	if (control != null) {
+		GCData data = gc.getGCData ();
+		int /*long*/ cairo = data.cairo;
+		if (cairo != 0) {
+			Cairo.cairo_save (cairo);
+			if (control.backgroundImage != null) {
+				Point pt = display.map (this, control, 0, 0);
+				Cairo.cairo_translate (cairo, -pt.x, -pt.y);
+				x += pt.x;
+				y += pt.y;
+				int /*long*/ xDisplay = OS.GDK_DISPLAY ();
+				int /*long*/ xVisual = OS.gdk_x11_visual_get_xvisual (OS.gdk_visual_get_system());
+				int /*long*/ drawable = control.backgroundImage.pixmap;
+				int /*long*/ xDrawable = OS.GDK_PIXMAP_XID (drawable);				
+				int [] w = new int [1], h = new int [1];
+				OS.gdk_drawable_get_size (drawable, w, h);
+				int /*long*/ surface = Cairo.cairo_xlib_surface_create (xDisplay, xDrawable, xVisual, w [0], h [0]);
+				if (surface == 0) error (SWT.ERROR_NO_HANDLES);
+				int /*long*/ pattern = Cairo.cairo_pattern_create_for_surface (surface);
+				if (pattern == 0) error (SWT.ERROR_NO_HANDLES);
+				Cairo.cairo_pattern_set_extend (pattern, Cairo.CAIRO_EXTEND_REPEAT);
+				if ((data.style & SWT.MIRRORED) != 0) {
+					double[] matrix = {-1, 0, 0, 1, 0, 0};
+					Cairo.cairo_pattern_set_matrix(pattern, matrix);
+				}
+				Cairo.cairo_set_source (cairo, pattern);
+				Cairo.cairo_surface_destroy (surface);
+				Cairo.cairo_pattern_destroy (pattern);
+			} else {
+				GdkColor color = control.getBackgroundColor ();
+				Cairo.cairo_set_source_rgba (cairo, (color.red & 0xFFFF) / (float)0xFFFF, (color.green & 0xFFFF) / (float)0xFFFF, (color.blue & 0xFFFF) / (float)0xFFFF, data.alpha / (float)0xFF);
+			}			
+			Cairo.cairo_rectangle (cairo, x, y, width, height);
+			Cairo.cairo_fill (cairo);
+			Cairo.cairo_restore (cairo);
+		} else {
+			int /*long*/ gdkGC = gc.handle;
+			GdkGCValues values = new GdkGCValues ();
+			OS.gdk_gc_get_values (gdkGC, values);
+			if (control.backgroundImage != null) {
+				Point pt = display.map (this, control, 0, 0);
+				OS.gdk_gc_set_fill (gdkGC, OS.GDK_TILED);
+				OS.gdk_gc_set_ts_origin (gdkGC, -pt.x, -pt.y);
+				OS.gdk_gc_set_tile (gdkGC, control.backgroundImage.pixmap);
+				OS.gdk_draw_rectangle (data.drawable, gdkGC, 1, x, y, width, height);
+				OS.gdk_gc_set_fill (gdkGC, values.fill);
+				OS.gdk_gc_set_ts_origin (gdkGC, values.ts_x_origin, values.ts_y_origin);
+			} else {
+				GdkColor color = control.getBackgroundColor ();
+				OS.gdk_gc_set_foreground (gdkGC, color);
+				OS.gdk_draw_rectangle (data.drawable, gdkGC, 1, x, y, width, height);
+				color.pixel = values.foreground_pixel;
+				OS.gdk_gc_set_foreground (gdkGC, color);
+			}
+		}
+	} else {
+		gc.fillRectangle (x, y, width, height);
+	}
+}
+
+void enableWidget (boolean enabled) {
+	if ((state & CANVAS) != 0) return;
+	super.enableWidget (enabled);
+}
+
+Composite findDeferredControl () {
+	return layoutCount > 0 ? this : parent.findDeferredControl ();
+}
+
+Menu [] findMenus (Control control) {
+	if (control == this) return new Menu [0];
+	Menu result [] = super.findMenus (control);
+	Control [] children = _getChildren ();
+	for (int i=0; i<children.length; i++) {
+		Control child = children [i];
+		Menu [] menuList = child.findMenus (control);
+		if (menuList.length != 0) {
+			Menu [] newResult = new Menu [result.length + menuList.length];
+			System.arraycopy (result, 0, newResult, 0, result.length);
+			System.arraycopy (menuList, 0, newResult, result.length, menuList.length);
+			result = newResult;
+		}
+	}
+	return result;
+}
+
+void fixChildren (Shell newShell, Shell oldShell, Decorations newDecorations, Decorations oldDecorations, Menu [] menus) {
+	super.fixChildren (newShell, oldShell, newDecorations, oldDecorations, menus);
+	Control [] children = _getChildren ();
+	for (int i=0; i<children.length; i++) {
+		children [i].fixChildren (newShell, oldShell, newDecorations, oldDecorations, menus);
+	}
+}
+
+void fixModal(int /*long*/ group, int /*long*/ modalGroup)  {
+	Control[] controls = _getChildren ();
+	for (int i = 0; i < controls.length; i++) {
+		controls[i].fixModal (group, modalGroup);
+	}
+}
+
+void fixStyle () {
+	super.fixStyle ();
+	if (scrolledHandle == 0) fixStyle (handle);
+	Control[] children = _getChildren ();
+	for (int i = 0; i < children.length; i++) {
+		children [i].fixStyle ();
+	}
+}
+
+void fixTabList (Control control) {
+	if (tabList == null) return;
+	int count = 0;
+	for (int i=0; i<tabList.length; i++) {
+		if (tabList [i] == control) count++;
+	}
+	if (count == 0) return;
+	Control [] newList = null;
+	int length = tabList.length - count;
+	if (length != 0) {
+		newList = new Control [length];
+		int index = 0;
+		for (int i=0; i<tabList.length; i++) {
+			if (tabList [i] != control) {
+				newList [index++] = tabList [i];
+			}
+		}
+	}
+	tabList = newList;
+}
+
+void fixZOrder () {
+	if ((state & CANVAS) != 0) return;
+	int /*long*/ parentHandle = parentingHandle ();
+	int /*long*/ parentWindow = OS.GTK_WIDGET_WINDOW (parentHandle);
+	if (parentWindow == 0) return;
+	int /*long*/ [] userData = new int /*long*/ [1];
+	int /*long*/ windowList = OS.gdk_window_get_children (parentWindow);
+	if (windowList != 0) {
+		int /*long*/ windows = windowList;
+		while (windows != 0) {
+			int /*long*/ window = OS.g_list_data (windows);
+			if (window != redrawWindow) {
+				OS.gdk_window_get_user_data (window, userData);
+				if (userData [0] == 0 || OS.G_OBJECT_TYPE (userData [0]) != display.gtk_fixed_get_type ()) {
+					OS.gdk_window_lower (window);
+				}
+			}
+			windows = OS.g_list_next (windows);
+		}
+		OS.g_list_free (windowList);
+	}
+}
+
+int /*long*/ focusHandle () {
+	if (socketHandle != 0) return socketHandle;
+	return super.focusHandle ();
+}
+
+boolean forceFocus (int /*long*/ focusHandle) {
+	if (socketHandle != 0) OS.GTK_WIDGET_SET_FLAGS (focusHandle, OS.GTK_CAN_FOCUS);
+	boolean result = super.forceFocus (focusHandle);
+	if (socketHandle != 0) OS.GTK_WIDGET_UNSET_FLAGS (focusHandle, OS.GTK_CAN_FOCUS);
+	return result;
+}
+
+/**
+ * Returns the receiver's background drawing mode. This
+ * will be one of the following constants defined in class
+ * <code>SWT</code>:
+ * <code>INHERIT_NONE</code>, <code>INHERIT_DEFAULT</code>,
+ * <code>INHERTIT_FORCE</code>.
+ *
+ * @return the background mode
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SWT
+ * 
+ * @since 3.2
+ */
+public int getBackgroundMode () {
+	checkWidget ();
+	return backgroundMode;
+}
+
+/**
+ * Returns a (possibly empty) array containing the receiver's children.
+ * Children are returned in the order that they are drawn.  The topmost
+ * control appears at the beginning of the array.  Subsequent controls
+ * draw beneath this control and appear later in the array.
+ * <p>
+ * Note: This is not the actual structure used by the receiver
+ * to maintain its list of children, so modifying the array will
+ * not affect the receiver. 
+ * </p>
+ *
+ * @return an array of children
+ * 
+ * @see Control#moveAbove
+ * @see Control#moveBelow
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Control [] getChildren () {
+	checkWidget();
+	return _getChildren ();
+}
+
+int getChildrenCount () {
+	/*
+	* NOTE: The current implementation will count
+	* non-registered children.
+	*/
+	int /*long*/ list = OS.gtk_container_get_children (handle);
+	if (list == 0) return 0;
+	int count = OS.g_list_length (list);
+	OS.g_list_free (list);
+	return count;
+}
+
+public Rectangle getClientArea () {
+	checkWidget();
+	if ((state & CANVAS) != 0) {
+		if ((state & ZERO_WIDTH) != 0 && (state & ZERO_HEIGHT) != 0) {
+			return new Rectangle (0, 0, 0, 0);
+		}
+		forceResize ();
+		int /*long*/ clientHandle = clientHandle ();
+		int width = (state & ZERO_WIDTH) != 0 ? 0 : OS.GTK_WIDGET_WIDTH (clientHandle);
+		int height = (state & ZERO_HEIGHT) != 0 ? 0 : OS.GTK_WIDGET_HEIGHT (clientHandle);
+		return new Rectangle (0, 0, width, height);
+	}
+	return super.getClientArea();
+}
+
+int getClientWidth() {
+	return (state & ZERO_WIDTH) != 0 ? 0 : OS.GTK_WIDGET_WIDTH (clientHandle ());
+}
+
+/**
+ * Returns layout which is associated with the receiver, or
+ * null if one has not been set.
+ *
+ * @return the receiver's layout or null
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Layout getLayout () {
+	checkWidget();
+	return layout;
+}
+
+/**
+ * Returns <code>true</code> if the receiver has deferred
+ * the performing of layout, and <code>false</code> otherwise.
+ *
+ * @return the receiver's deferred layout state
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see #setLayoutDeferred(boolean)
+ * @see #isLayoutDeferred()
+ *
+ * @since 3.1
+ */
+public boolean getLayoutDeferred () {
+	checkWidget ();
+	return layoutCount > 0 ;
+}
+
+/**
+ * Gets the (possibly empty) tabbing order for the control.
+ *
+ * @return tabList the ordered list of controls representing the tab order
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see #setTabList
+ */
+public Control [] getTabList () {
+	checkWidget ();
+	Control [] tabList = _getTabList ();
+	if (tabList == null) {
+		int count = 0;
+		Control [] list =_getChildren ();
+		for (int i=0; i<list.length; i++) {
+			if (list [i].isTabGroup ()) count++;
+		}
+		tabList = new Control [count];
+		int index = 0;
+		for (int i=0; i<list.length; i++) {
+			if (list [i].isTabGroup ()) {
+				tabList [index++] = list [i];
+			}
+		}
+	}
+	return tabList;
+}
+
+int /*long*/ gtk_button_press_event (int /*long*/ widget, int /*long*/ event) {
+	int /*long*/ result = super.gtk_button_press_event (widget, event);
+	if (result != 0) return result;
+	if ((state & CANVAS) != 0) {
+		if ((style & SWT.NO_FOCUS) == 0 && hooksKeys ()) {
+			GdkEventButton gdkEvent = new GdkEventButton ();
+			OS.memmove (gdkEvent, event, GdkEventButton.sizeof);
+			if (gdkEvent.button == 1) {
+				if (getChildrenCount () == 0) setFocus ();
+			}
+		}
+	}
+	return result;
+}
+
+int /*long*/ gtk_expose_event (int /*long*/ widget, int /*long*/ eventPtr) {
+	if ((state & OBSCURED) != 0) return 0;
+	if ((state & CANVAS) == 0) {
+		return super.gtk_expose_event (widget, eventPtr);
+	}
+	if ((style & SWT.NO_MERGE_PAINTS) == 0) {
+		return super.gtk_expose_event (widget, eventPtr);
+	}
+	if (!hooks (SWT.Paint) && !filters (SWT.Paint)) return 0;
+	GdkEventExpose gdkEvent = new GdkEventExpose ();
+	OS.memmove(gdkEvent, eventPtr, GdkEventExpose.sizeof);
+	int /*long*/ [] rectangles = new int /*long*/ [1];
+	int [] n_rectangles = new int [1];
+	OS.gdk_region_get_rectangles (gdkEvent.region, rectangles, n_rectangles);
+	GdkRectangle rect = new GdkRectangle ();
+	for (int i=0; i<n_rectangles[0]; i++) {
+		Event event = new Event ();
+		OS.memmove (rect, rectangles [0] + i * GdkRectangle.sizeof, GdkRectangle.sizeof);
+		event.x = rect.x;
+		event.y = rect.y;
+		event.width = rect.width;
+		event.height = rect.height;
+		if ((style & SWT.MIRRORED) != 0) event.x = getClientWidth () - event.width - event.x;
+		int /*long*/ damageRgn = OS.gdk_region_new ();
+		OS.gdk_region_union_with_rect (damageRgn, rect);
+		GCData data = new GCData ();
+		data.damageRgn = damageRgn;
+		GC gc = event.gc = GC.gtk_new (this, data);
+		OS.gdk_gc_set_clip_region (gc.handle, damageRgn);
+		sendEvent (SWT.Paint, event);
+		gc.dispose ();
+		OS.gdk_region_destroy (damageRgn);
+		event.gc = null;
+	}
+	OS.g_free (rectangles [0]);
+	return 0;
+}
+
+int /*long*/ gtk_key_press_event (int /*long*/ widget, int /*long*/ event) {
+	int /*long*/ result = super.gtk_key_press_event (widget, event);
+	if (result != 0) return result;
+	/*
+	* Feature in GTK.  The default behavior when the return key
+	* is pressed is to select the default button.  This is not the
+	* expected behavior for Composite and its subclasses.  The
+	* fix is to avoid calling the default handler.
+	*/
+	if ((state & CANVAS) != 0 && socketHandle == 0) {
+		GdkEventKey keyEvent = new GdkEventKey ();
+		OS.memmove (keyEvent, event, GdkEventKey.sizeof);
+		int key = keyEvent.keyval;
+		switch (key) {
+			case OS.GDK_Return:
+			case OS.GDK_KP_Enter: return 1;
+		}
+	}
+	return result;
+}
+
+int /*long*/ gtk_focus (int /*long*/ widget, int /*long*/ directionType) {
+	if (widget == socketHandle) return 0;
+	return super.gtk_focus (widget, directionType);
+}
+
+int /*long*/ gtk_focus_in_event (int /*long*/ widget, int /*long*/ event) {
+	int /*long*/ result = super.gtk_focus_in_event (widget, event);
+	return (state & CANVAS) != 0 ? 1 : result;
+}
+
+int /*long*/ gtk_focus_out_event (int /*long*/ widget, int /*long*/ event) {
+	int /*long*/ result = super.gtk_focus_out_event (widget, event);
+	return (state & CANVAS) != 0 ? 1 : result;
+}
+
+int /*long*/ gtk_map (int /*long*/ widget) {
+	fixZOrder ();
+	return 0;	
+}
+
+int /*long*/ gtk_realize (int /*long*/ widget) {
+	int /*long*/ result = super.gtk_realize (widget);
+	if ((style & SWT.NO_BACKGROUND) != 0) {
+		int /*long*/ window = OS.GTK_WIDGET_WINDOW (paintHandle ());
+		if (window != 0) OS.gdk_window_set_back_pixmap (window, 0, false);
+	}
+	if (socketHandle != 0) {
+		embeddedHandle = OS.gtk_socket_get_id (socketHandle);
+	}
+	return result;
+}
+
+int /*long*/ gtk_scroll_child (int /*long*/ widget, int /*long*/ scrollType, int /*long*/ horizontal) {
+	/* Stop GTK scroll child signal for canvas */
+	OS.g_signal_stop_emission_by_name (widget, OS.scroll_child);
+	return 1;
+}
+
+int /*long*/ gtk_style_set (int /*long*/ widget, int /*long*/ previousStyle) {
+	int /*long*/ result = super.gtk_style_set (widget, previousStyle);
+	if ((style & SWT.NO_BACKGROUND) != 0) {
+		int /*long*/ window = OS.GTK_WIDGET_WINDOW (paintHandle ());
+		if (window != 0) OS.gdk_window_set_back_pixmap (window, 0, false);
+	}
+	return result;
+}
+
+boolean hasBorder () {
+	return (style & SWT.BORDER) != 0;
+}
+
+void hookEvents () {
+	super.hookEvents ();
+	if ((state & CANVAS) != 0) {
+		OS.gtk_widget_add_events (handle, OS.GDK_POINTER_MOTION_HINT_MASK);
+		if (scrolledHandle != 0) {
+			OS.g_signal_connect_closure (scrolledHandle, OS.scroll_child, display.closures [SCROLL_CHILD], false);
+		}
+	}
+}
+
+boolean hooksKeys () {
+	return hooks (SWT.KeyDown) || hooks (SWT.KeyUp);
+}
+
+int /*long*/ imHandle () {
+	return imHandle;
+}
+
+/**
+ * Returns <code>true</code> if the receiver or any ancestor 
+ * up to and including the receiver's nearest ancestor shell
+ * has deferred the performing of layouts.  Otherwise, <code>false</code>
+ * is returned.
+ *
+ * @return the receiver's deferred layout state
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see #setLayoutDeferred(boolean)
+ * @see #getLayoutDeferred()
+ * 
+ * @since 3.1
+ */
+public boolean isLayoutDeferred () {
+	checkWidget ();
+	return findDeferredControl () != null;
+}
+
+boolean isTabGroup() {
+	if ((state & CANVAS) != 0) return true;
+	return super.isTabGroup();
+}
+
+/**
+ * If the receiver has a layout, asks the layout to <em>lay out</em>
+ * (that is, set the size and location of) the receiver's children. 
+ * If the receiver does not have a layout, do nothing.
+ * <p>
+ * This is equivalent to calling <code>layout(true)</code>.
+ * </p>
+ * <p>
+ * Note: Layout is different from painting. If a child is
+ * moved or resized such that an area in the parent is
+ * exposed, then the parent will paint. If no child is
+ * affected, the parent will not paint.
+ * </p>
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void layout () {
+	checkWidget ();
+	layout (true);
+}
+
+/**
+ * If the receiver has a layout, asks the layout to <em>lay out</em>
+ * (that is, set the size and location of) the receiver's children. 
+ * If the argument is <code>true</code> the layout must not rely
+ * on any information it has cached about the immediate children. If it
+ * is <code>false</code> the layout may (potentially) optimize the
+ * work it is doing by assuming that none of the receiver's 
+ * children has changed state since the last layout.
+ * If the receiver does not have a layout, do nothing.
+ * <p>
+ * If a child is resized as a result of a call to layout, the 
+ * resize event will invoke the layout of the child.  The layout
+ * will cascade down through all child widgets in the receiver's widget 
+ * tree until a child is encountered that does not resize.  Note that 
+ * a layout due to a resize will not flush any cached information 
+ * (same as <code>layout(false)</code>).
+ * </p>
+ * <p>
+ * Note: Layout is different from painting. If a child is
+ * moved or resized such that an area in the parent is
+ * exposed, then the parent will paint. If no child is
+ * affected, the parent will not paint.
+ * </p>
+ *
+ * @param changed <code>true</code> if the layout must flush its caches, and <code>false</code> otherwise
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void layout (boolean changed) {
+	checkWidget ();
+	if (layout == null) return;
+	layout (changed, false);
+}
+
+/**
+ * If the receiver has a layout, asks the layout to <em>lay out</em>
+ * (that is, set the size and location of) the receiver's children. 
+ * If the changed argument is <code>true</code> the layout must not rely
+ * on any information it has cached about its children. If it
+ * is <code>false</code> the layout may (potentially) optimize the
+ * work it is doing by assuming that none of the receiver's 
+ * children has changed state since the last layout.
+ * If the all argument is <code>true</code> the layout will cascade down
+ * through all child widgets in the receiver's widget tree, regardless of
+ * whether the child has changed size.  The changed argument is applied to 
+ * all layouts.  If the all argument is <code>false</code>, the layout will
+ * <em>not</em> cascade down through all child widgets in the receiver's widget 
+ * tree.  However, if a child is resized as a result of a call to layout, the 
+ * resize event will invoke the layout of the child.  Note that 
+ * a layout due to a resize will not flush any cached information 
+ * (same as <code>layout(false)</code>).
+ * </p>
+ * <p>
+ * Note: Layout is different from painting. If a child is
+ * moved or resized such that an area in the parent is
+ * exposed, then the parent will paint. If no child is
+ * affected, the parent will not paint.
+ * </p>
+ *
+ * @param changed <code>true</code> if the layout must flush its caches, and <code>false</code> otherwise
+ * @param all <code>true</code> if all children in the receiver's widget tree should be laid out, and <code>false</code> otherwise
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 3.1
+ */
+public void layout (boolean changed, boolean all) {
+	checkWidget ();
+	if (layout == null && !all) return;
+	markLayout (changed, all);
+	updateLayout (all);
+}
+
+/**
+ * Forces a lay out (that is, sets the size and location) of all widgets that 
+ * are in the parent hierarchy of the changed control up to and including the 
+ * receiver.  The layouts in the hierarchy must not rely on any information 
+ * cached about the changed control or any of its ancestors.  The layout may 
+ * (potentially) optimize the work it is doing by assuming that none of the 
+ * peers of the changed control have changed state since the last layout.
+ * If an ancestor does not have a layout, skip it.
+ * <p>
+ * Note: Layout is different from painting. If a child is
+ * moved or resized such that an area in the parent is
+ * exposed, then the parent will paint. If no child is
+ * affected, the parent will not paint.
+ * </p>
+ * 
+ * @param changed a control that has had a state change which requires a recalculation of its size
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the changed array is null any of its controls are null or have been disposed</li> 
+ *    <li>ERROR_INVALID_PARENT - if any control in changed is not in the widget tree of the receiver</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 3.1
+ */
+public void layout (Control [] changed) {
+	checkWidget ();
+	if (changed == null) error (SWT.ERROR_INVALID_ARGUMENT);
+	for (int i=0; i<changed.length; i++) {
+		Control control = changed [i];
+		if (control == null) error (SWT.ERROR_INVALID_ARGUMENT);
+		if (control.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT);
+		boolean ancestor = false;
+		Composite composite = control.parent;
+		while (composite != null) {
+			ancestor = composite == this;
+			if (ancestor) break;
+			composite = composite.parent;
+		}
+		if (!ancestor) error (SWT.ERROR_INVALID_PARENT);
+	}
+	int updateCount = 0;
+	Composite [] update = new Composite [16];
+	for (int i=0; i<changed.length; i++) {
+		Control child = changed [i];
+		Composite composite = child.parent;
+		while (child != this) {
+			if (composite.layout != null) {
+				composite.state |= LAYOUT_NEEDED;
+				if (!composite.layout.flushCache (child)) {
+					composite.state |= LAYOUT_CHANGED;
+				}
+			}
+			if (updateCount == update.length) {
+				Composite [] newUpdate = new Composite [update.length + 16];
+				System.arraycopy (update, 0, newUpdate, 0, update.length);
+				update = newUpdate;
+			}
+			child = update [updateCount++] = composite;
+			composite = child.parent;
+		}
+	}
+	for (int i=updateCount-1; i>=0; i--) {
+		update [i].updateLayout (false);
+	}
+}
+
+void markLayout (boolean changed, boolean all) {
+	if (layout != null) {
+		state |= LAYOUT_NEEDED;
+		if (changed) state |= LAYOUT_CHANGED;
+	}
+	if (all) {
+		Control [] children = _getChildren ();
+		for (int i=0; i<children.length; i++) {
+			children [i].markLayout (changed, all);
+		}
+	}
+}
+
+void moveAbove (int /*long*/ child, int /*long*/ sibling) {
+	if (child == sibling) return;
+	int /*long*/ parentHandle = parentingHandle ();
+	GtkFixed fixed = new GtkFixed ();
+	OS.memmove (fixed, parentHandle);
+	int /*long*/ children = fixed.children;
+	if (children == 0) return;
+	int /*long*/ [] data = new int /*long*/ [1];
+	int /*long*/ [] widget = new int /*long*/ [1];
+	int /*long*/ childData = 0, childLink = 0, siblingLink = 0, temp = children;
+	while (temp != 0) {
+		OS.memmove (data, temp, OS.PTR_SIZEOF);
+		OS.memmove (widget, data [0], OS.PTR_SIZEOF);
+		if (child == widget [0]) {
+			childLink = temp;
+			childData = data [0];
+		} else if (sibling == widget [0]) {
+			siblingLink = temp;
+		}
+		if (childData != 0 && (sibling == 0 || siblingLink != 0)) break;
+		temp = OS.g_list_next (temp);
+	}
+	children = OS.g_list_remove_link (children, childLink);
+	if (siblingLink == 0 || OS.g_list_previous (siblingLink) == 0) {
+		OS.g_list_free_1 (childLink);
+		children = OS.g_list_prepend (children, childData);
+	} else {
+		temp = OS.g_list_previous (siblingLink);
+		OS.g_list_set_previous (childLink, temp);
+		OS.g_list_set_next (temp, childLink);
+		OS.g_list_set_next (childLink, siblingLink);
+		OS.g_list_set_previous (siblingLink, childLink);
+	}
+	fixed.children = children;
+	OS.memmove (parentHandle, fixed);
+}
+
+void moveBelow (int /*long*/ child, int /*long*/ sibling) {
+	if (child == sibling) return;
+	int /*long*/ parentHandle = parentingHandle ();
+	if (sibling == 0 && parentHandle == fixedHandle) {
+		moveAbove (child, scrolledHandle != 0  ? scrolledHandle : handle);
+		return;
+	}
+	GtkFixed fixed = new GtkFixed ();
+	OS.memmove (fixed, parentHandle);
+	int /*long*/ children = fixed.children;
+	if (children == 0) return;
+	int /*long*/ [] data = new int /*long*/ [1];
+	int /*long*/ [] widget = new int /*long*/ [1];
+	int /*long*/ childData = 0, childLink = 0, siblingLink = 0, temp = children;
+	while (temp != 0) {
+		OS.memmove (data, temp, OS.PTR_SIZEOF);
+		OS.memmove (widget, data [0], OS.PTR_SIZEOF);
+		if (child == widget [0]) {
+			childLink = temp;
+			childData = data [0];
+		} else if (sibling == widget [0]) {
+			siblingLink = temp;
+		}
+		if (childData != 0 && (sibling == 0 || siblingLink != 0)) break;
+		temp = OS.g_list_next (temp);
+	}
+	children = OS.g_list_remove_link (children, childLink);
+	if (siblingLink == 0 || OS.g_list_next (siblingLink) == 0) {
+		OS.g_list_free_1 (childLink);
+		children = OS.g_list_append (children, childData);
+	} else {
+		temp = OS.g_list_next (siblingLink);
+		OS.g_list_set_next (childLink, temp);
+		OS.g_list_set_previous (temp, childLink);
+		OS.g_list_set_previous (childLink, siblingLink);
+		OS.g_list_set_next (siblingLink, childLink);
+	}
+	fixed.children = children;
+	OS.memmove (parentHandle, fixed);
+}
+
+void moveChildren(int oldWidth) {
+	Control[] children = _getChildren ();
+	for (int i = 0; i < children.length; i++) {
+		Control child = children[i];
+		int /*long*/ topHandle = child.topHandle ();
+		int x = OS.GTK_WIDGET_X (topHandle);
+		int y = OS.GTK_WIDGET_Y (topHandle);
+		int controlWidth = (child.state & ZERO_WIDTH) != 0 ? 0 : OS.GTK_WIDGET_WIDTH (topHandle);
+		x = oldWidth - controlWidth - x; 
+		int clientWidth = getClientWidth ();
+		x = clientWidth - controlWidth - x;
+		if (child.enableWindow != 0) {
+			OS.gdk_window_move (child.enableWindow, x, y);
+		}
+		child.moveHandle (x, y);
+		/*
+		* Cause a size allocation this widget's topHandle.  Note that
+		* all calls to gtk_widget_size_allocate() must be preceded by
+		* a call to gtk_widget_size_request().
+		*/
+		GtkRequisition requisition = new GtkRequisition ();
+		gtk_widget_size_request (topHandle, requisition);
+		GtkAllocation allocation = new GtkAllocation ();
+		allocation.x = x;
+		allocation.y = y;
+		allocation.width = OS.GTK_WIDGET_WIDTH (topHandle);
+		allocation.height = OS.GTK_WIDGET_HEIGHT (topHandle);
+		OS.gtk_widget_size_allocate (topHandle, allocation);
+		Control control = child.findBackgroundControl ();
+		if (control != null && control.backgroundImage != null) {
+			if (child.isVisible ()) child.redrawWidget (0, 0, 0, 0, true, true, true);
+		}
+	}
+}
+
+Point minimumSize (int wHint, int hHint, boolean changed) {
+	Control [] children = _getChildren ();
+	int width = 0, height = 0;
+	for (int i=0; i<children.length; i++) {
+		Rectangle rect = children [i].getBounds ();
+		width = Math.max (width, rect.x + rect.width);
+		height = Math.max (height, rect.y + rect.height);
+	}
+	return new Point (width, height);
+}
+
+int /*long*/ parentingHandle () {
+	if ((state & CANVAS) != 0) return handle;
+	return fixedHandle != 0 ? fixedHandle : handle;
+}
+
+void printWidget (GC gc, int /*long*/ drawable, int depth, int x, int y) {
+	Region oldClip = new Region (gc.getDevice ());
+	Region newClip = new Region (gc.getDevice ());
+	gc.getClipping (oldClip);
+	Rectangle rect = getBounds ();
+	newClip.add (oldClip);
+	newClip.intersect (x, y, rect.width, rect.height);
+	gc.setClipping (newClip);
+	super.printWidget (gc, drawable, depth, x, y);
+	Rectangle clientRect = getClientArea ();
+	Point pt = display.map (this, parent, clientRect.x, clientRect.y);
+	clientRect.x = x + pt.x - rect.x;
+	clientRect.y = y + pt.y - rect.y;
+	newClip.intersect (clientRect);
+	gc.setClipping (newClip);
+	Control [] children = _getChildren ();
+	for (int i=children.length-1; i>=0; --i) {
+		Control child = children [i];
+		if (child.getVisible ()) {
+			Point location = child.getLocation ();
+			child.printWidget (gc, drawable, depth, x + location.x, y + location.y);
+		}
+	}
+	gc.setClipping (oldClip);
+	oldClip.dispose ();
+	newClip.dispose ();
+}
+
+void redrawChildren () {
+	super.redrawChildren ();
+	Control [] children = _getChildren ();
+	for (int i = 0; i < children.length; i++) {
+		Control child = children [i];
+		if ((child.state & PARENT_BACKGROUND) != 0) {
+			child.redrawWidget (0, 0, 0, 0, true, false, true);
+			child.redrawChildren ();
+		}
+	}
+}
+
+void register () {
+	super.register ();
+	if (socketHandle != 0) display.addWidget (socketHandle, this);
+}
+
+void releaseChildren (boolean destroy) {
+	Control [] children = _getChildren ();
+	for (int i=0; i<children.length; i++) {
+		Control child = children [i];
+		if (child != null && !child.isDisposed ()) {
+			child.release (false);
+		}
+	}
+	super.releaseChildren (destroy);
+}
+
+void releaseHandle () {
+	super.releaseHandle ();
+	socketHandle = embeddedHandle = 0;
+}
+
+void releaseWidget () {
+	super.releaseWidget ();
+	if (imHandle != 0) OS.g_object_unref (imHandle);
+	imHandle = 0;
+	layout = null;
+	tabList = null;
+}
+
+void removeControl (Control control) {
+	fixTabList (control);
+}
+
+void resizeHandle (int width, int height) {
+	super.resizeHandle (width, height);
+	if (socketHandle != 0) OS.gtk_widget_set_size_request (socketHandle, width, height);
+}
+
+/**
+ * Sets the background drawing mode to the argument which should
+ * be one of the following constants defined in class <code>SWT</code>:
+ * <code>INHERIT_NONE</code>, <code>INHERIT_DEFAULT</code>,
+ * <code>INHERIT_FORCE</code>.
+ *
+ * @param mode the new background mode
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SWT
+ * 
+ * @since 3.2
+ */
+public void setBackgroundMode (int mode) {
+	checkWidget ();
+	backgroundMode = mode;
+	Control[] children = _getChildren ();
+	for (int i = 0; i < children.length; i++) {
+		children [i].updateBackgroundMode ();
+	}
+}
+
+int setBounds (int x, int y, int width, int height, boolean move, boolean resize) {
+	int result = super.setBounds (x, y, width, height, move, resize);
+	if ((result & RESIZED) != 0 && layout != null) {
+		markLayout (false, false);
+		updateLayout (false);
+	}
+	return result;
+}
+
+public boolean setFocus () {
+	checkWidget();
+	Control [] children = _getChildren ();
+	for (int i=0; i<children.length; i++) {
+		Control child = children [i];
+		if (child.getVisible () && child.setFocus ()) return true;
+	}
+	return super.setFocus ();
+}
+
+/**
+ * Sets the layout which is associated with the receiver to be
+ * the argument which may be null.
+ *
+ * @param layout the receiver's new layout or null
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setLayout (Layout layout) {
+	checkWidget();
+	this.layout = layout;
+}
+
+/**
+ * If the argument is <code>true</code>, causes subsequent layout
+ * operations in the receiver or any of its children to be ignored.
+ * No layout of any kind can occur in the receiver or any of its
+ * children until the flag is set to false.
+ * Layout operations that occurred while the flag was
+ * <code>true</code> are remembered and when the flag is set to 
+ * <code>false</code>, the layout operations are performed in an
+ * optimized manner.  Nested calls to this method are stacked.
+ *
+ * @param defer the new defer state
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see #layout(boolean)
+ * @see #layout(Control[])
+ *
+ * @since 3.1
+ */
+public void setLayoutDeferred (boolean defer) {
+	if (!defer) {
+		if (--layoutCount == 0) {
+			if ((state & LAYOUT_CHILD) != 0 || (state & LAYOUT_NEEDED) != 0) {
+				updateLayout (true);
+			}
+		}
+	} else {
+		layoutCount++;
+	}
+}
+
+boolean setScrollBarVisible (ScrollBar bar, boolean visible) {
+	boolean changed = super.setScrollBarVisible (bar, visible);
+	if (changed && layout != null) {
+		markLayout (false, false);
+		updateLayout (false);
+	}
+	return changed;
+}
+
+boolean setTabGroupFocus (boolean next) {
+	if (isTabItem ()) return setTabItemFocus (next);
+	boolean takeFocus = (style & SWT.NO_FOCUS) == 0;
+	if ((state & CANVAS) != 0) takeFocus = hooksKeys ();
+	if (socketHandle != 0) takeFocus = true;
+	if (takeFocus  && setTabItemFocus (next)) return true;
+	Control [] children = _getChildren ();
+	for (int i=0; i<children.length; i++) {
+		Control child = children [i];
+		if (child.isTabItem () && child.setTabItemFocus (next)) return true;
+	}
+	return false;
+}
+
+boolean setTabItemFocus (boolean next) {
+	if (!super.setTabItemFocus (next)) return false;
+	if (socketHandle != 0) {
+		int direction = next ? OS.GTK_DIR_TAB_FORWARD : OS.GTK_DIR_TAB_BACKWARD;
+		OS.GTK_WIDGET_UNSET_FLAGS (socketHandle, OS.GTK_HAS_FOCUS);
+		OS.gtk_widget_child_focus (socketHandle, direction);
+		OS.GTK_WIDGET_SET_FLAGS (socketHandle, OS.GTK_HAS_FOCUS);
+	}
+	return true;
+}
+
+/**
+ * Sets the tabbing order for the specified controls to
+ * match the order that they occur in the argument list.
+ *
+ * @param tabList the ordered list of controls representing the tab order or null
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if a widget in the tabList is null or has been disposed</li> 
+ *    <li>ERROR_INVALID_PARENT - if widget in the tabList is not in the same widget tree</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setTabList (Control [] tabList) {
+	checkWidget ();
+	if (tabList != null) {
+		for (int i=0; i<tabList.length; i++) {
+			Control control = tabList [i];
+			if (control == null) error (SWT.ERROR_INVALID_ARGUMENT);
+			if (control.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT);
+			if (control.parent != this) error (SWT.ERROR_INVALID_PARENT);
+		}
+		Control [] newList = new Control [tabList.length];
+		System.arraycopy (tabList, 0, newList, 0, tabList.length);
+		tabList = newList;
+	} 
+	this.tabList = tabList;
+}
+
+void showWidget () {
+	super.showWidget ();
+	if (socketHandle != 0) {
+		OS.gtk_widget_show (socketHandle);
+		embeddedHandle = OS.gtk_socket_get_id (socketHandle);
+	}
+	if (scrolledHandle == 0) fixStyle (handle);
+}
+
+boolean translateMnemonic (Event event, Control control) {
+	if (super.translateMnemonic (event, control)) return true;
+	if (control != null) {
+		Control [] children = _getChildren ();
+		for (int i=0; i<children.length; i++) {
+			Control child = children [i];
+			if (child.translateMnemonic (event, control)) return true;
+		}
+	}
+	return false;
+}
+
+int traversalCode(int key, GdkEventKey event) {
+	if ((state & CANVAS) != 0) {
+		if ((style & SWT.NO_FOCUS) != 0) return 0;
+		if (hooksKeys ()) return 0;
+	}
+	return super.traversalCode (key, event);
+}
+
+boolean translateTraversal (GdkEventKey keyEvent) {
+	if (socketHandle != 0) return false;
+	return super.translateTraversal (keyEvent);
+}
+
+void updateBackgroundMode () {
+	super.updateBackgroundMode ();
+	Control [] children = _getChildren ();
+	for (int i = 0; i < children.length; i++) {
+		children [i].updateBackgroundMode ();
+	}
+}
+
+void updateLayout (boolean all) {
+	Composite parent = findDeferredControl ();
+	if (parent != null) {
+		parent.state |= LAYOUT_CHILD;
+		return;
+	}
+	if ((state & LAYOUT_NEEDED) != 0) {
+		boolean changed = (state & LAYOUT_CHANGED) != 0;
+		state &= ~(LAYOUT_NEEDED | LAYOUT_CHANGED);
+		layout.layout (this, changed);
+	}
+	if (all) {
+		state &= ~LAYOUT_CHILD;
+		Control [] children = _getChildren ();
+		for (int i=0; i<children.length; i++) {
+			children [i].updateLayout (all);
+		}
+	}
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Control.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Control.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Control.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,4508 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.widgets;
+
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.Converter;
+import org.eclipse.swt.internal.accessibility.gtk.ATK;
+import org.eclipse.swt.internal.gtk.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.accessibility.*;
+
+/**
+ * Control is the abstract superclass of all windowed user interface classes.
+ * <p>
+ * <dl>
+ * <dt><b>Styles:</b>
+ * <dd>BORDER</dd>
+ * <dd>LEFT_TO_RIGHT, RIGHT_TO_LEFT</dd>
+ * <dt><b>Events:</b>
+ * <dd>DragDetect, FocusIn, FocusOut, Help, KeyDown, KeyUp, MenuDetect, MouseDoubleClick, MouseDown, MouseEnter,
+ *     MouseExit, MouseHover, MouseUp, MouseMove, Move, Paint, Resize, Traverse</dd>
+ * </dl>
+ * </p><p>
+ * Only one of LEFT_TO_RIGHT or RIGHT_TO_LEFT may be specified.
+ * </p><p>
+ * IMPORTANT: This class is intended to be subclassed <em>only</em>
+ * within the SWT implementation.
+ * </p>
+ * 
+ * @see <a href="http://www.eclipse.org/swt/snippets/#control">Control snippets</a>
+ * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: ControlExample</a>
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public abstract class Control extends Widget implements Drawable {
+	int /*long*/ fixedHandle;
+	int /*long*/ redrawWindow, enableWindow;
+	int drawCount;
+	Composite parent;
+	Cursor cursor;
+	Menu menu;
+	Image backgroundImage;
+	Font font;
+	Region region;
+	String toolTipText;
+	Object layoutData;
+	Accessible accessible;
+
+Control () {
+}
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT#BORDER
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public Control (Composite parent, int style) {
+	super (parent, style);
+	this.parent = parent;
+	createWidget (0);
+}
+
+Font defaultFont () {
+	return display.getSystemFont ();
+}
+
+void deregister () {
+	super.deregister ();
+	if (fixedHandle != 0) display.removeWidget (fixedHandle);
+	int /*long*/ imHandle = imHandle ();
+	if (imHandle != 0) display.removeWidget (imHandle);
+}
+
+boolean drawGripper (int x, int y, int width, int height, boolean vertical) {
+	int /*long*/ paintHandle = paintHandle ();
+	int /*long*/ window = OS.GTK_WIDGET_WINDOW (paintHandle);
+	if (window == 0) return false;
+	int orientation = vertical ? OS.GTK_ORIENTATION_HORIZONTAL : OS.GTK_ORIENTATION_VERTICAL;
+	if ((style & SWT.MIRRORED) != 0) x = getClientWidth () - width - x;
+	OS.gtk_paint_handle (OS.gtk_widget_get_style (paintHandle), window, OS.GTK_STATE_NORMAL, OS.GTK_SHADOW_OUT, null, paintHandle, new byte [1], x, y, width, height, orientation);
+	return true;
+}
+
+void enableWidget (boolean enabled) {
+	OS.gtk_widget_set_sensitive (handle, enabled);
+}
+
+int /*long*/ enterExitHandle () {
+	return eventHandle ();
+}
+
+int /*long*/ eventHandle () {
+	return handle;
+}
+
+int /*long*/ eventWindow () {
+	int /*long*/ eventHandle = eventHandle ();
+	OS.gtk_widget_realize (eventHandle);
+	return OS.GTK_WIDGET_WINDOW (eventHandle);
+}
+
+void fixFocus (Control focusControl) {
+	Shell shell = getShell ();
+	Control control = this;
+	while (control != shell && (control = control.parent) != null) {
+		if (control.setFocus ()) return;
+	}
+	shell.setSavedFocus (focusControl);
+	int /*long*/ focusHandle = shell.vboxHandle;
+	OS.GTK_WIDGET_SET_FLAGS (focusHandle, OS.GTK_CAN_FOCUS);
+	OS.gtk_widget_grab_focus (focusHandle);
+	OS.GTK_WIDGET_UNSET_FLAGS (focusHandle, OS.GTK_CAN_FOCUS);
+}
+
+void fixStyle () {
+	if (fixedHandle != 0) fixStyle (fixedHandle);
+}
+
+void fixStyle (int /*long*/ handle) {
+	/*
+	* Feature in GTK.  Some GTK themes apply a different background to
+	* the contents of a GtkNotebook.  However, in an SWT TabFolder, the
+	* children are not parented below the GtkNotebook widget, and usually
+	* have their own GtkFixed.  The fix is to look up the correct style
+	* for a child of a GtkNotebook and apply its background to any GtkFixed
+	* widgets that are direct children of an SWT TabFolder.
+	* 
+	* Note that this has to be when the theme settings changes and that it
+	* should not override the application background.
+	*/
+	if ((state & BACKGROUND) != 0) return;
+	int /*long*/ childStyle = parent.childStyle ();
+	if (childStyle != 0) {		
+		GdkColor color = new GdkColor();
+		OS.gtk_style_get_bg (childStyle, 0, color);
+		OS.gtk_widget_modify_bg (handle, 0, color);
+	}
+}
+
+int /*long*/ focusHandle () {
+	return handle;
+}
+
+int /*long*/ fontHandle () {
+	return handle;
+}
+
+boolean hasFocus () {
+	return this == display.getFocusControl();
+}
+
+void hookEvents () {
+	/* Connect the keyboard signals */
+	int /*long*/ focusHandle = focusHandle ();
+	int focusMask = OS.GDK_KEY_PRESS_MASK | OS.GDK_KEY_RELEASE_MASK | OS.GDK_FOCUS_CHANGE_MASK;
+	OS.gtk_widget_add_events (focusHandle, focusMask);
+	OS.g_signal_connect_closure_by_id (focusHandle, display.signalIds [POPUP_MENU], 0, display.closures [POPUP_MENU], false);
+	OS.g_signal_connect_closure_by_id (focusHandle, display.signalIds [SHOW_HELP], 0, display.closures [SHOW_HELP], false);
+	OS.g_signal_connect_closure_by_id (focusHandle, display.signalIds [KEY_PRESS_EVENT], 0, display.closures [KEY_PRESS_EVENT], false);
+	OS.g_signal_connect_closure_by_id (focusHandle, display.signalIds [KEY_RELEASE_EVENT], 0, display.closures [KEY_RELEASE_EVENT], false);
+	OS.g_signal_connect_closure_by_id (focusHandle, display.signalIds [FOCUS], 0, display.closures [FOCUS], false);
+	OS.g_signal_connect_closure_by_id (focusHandle, display.signalIds [FOCUS_IN_EVENT], 0, display.closures [FOCUS_IN_EVENT], false);
+	OS.g_signal_connect_closure_by_id (focusHandle, display.signalIds [FOCUS_OUT_EVENT], 0, display.closures [FOCUS_OUT_EVENT], false);
+
+	/* Connect the mouse signals */
+	int /*long*/ eventHandle = eventHandle ();
+	int eventMask = OS.GDK_POINTER_MOTION_MASK | OS.GDK_BUTTON_PRESS_MASK | OS.GDK_BUTTON_RELEASE_MASK;
+	OS.gtk_widget_add_events (eventHandle, eventMask);
+	OS.g_signal_connect_closure_by_id (eventHandle, display.signalIds [BUTTON_PRESS_EVENT], 0, display.closures [BUTTON_PRESS_EVENT], false);
+	OS.g_signal_connect_closure_by_id (eventHandle, display.signalIds [BUTTON_RELEASE_EVENT], 0, display.closures [BUTTON_RELEASE_EVENT], false);
+	OS.g_signal_connect_closure_by_id (eventHandle, display.signalIds [MOTION_NOTIFY_EVENT], 0, display.closures [MOTION_NOTIFY_EVENT], false);
+	OS.g_signal_connect_closure_by_id (eventHandle, display.signalIds [SCROLL_EVENT], 0, display.closures [SCROLL_EVENT], false);
+	
+	/* Connect enter/exit signals */
+	int /*long*/ enterExitHandle = enterExitHandle ();
+	int enterExitMask = OS.GDK_ENTER_NOTIFY_MASK | OS.GDK_LEAVE_NOTIFY_MASK;
+	OS.gtk_widget_add_events (enterExitHandle, enterExitMask);
+	OS.g_signal_connect_closure_by_id (enterExitHandle, display.signalIds [ENTER_NOTIFY_EVENT], 0, display.closures [ENTER_NOTIFY_EVENT], false);
+	OS.g_signal_connect_closure_by_id (enterExitHandle, display.signalIds [LEAVE_NOTIFY_EVENT], 0, display.closures [LEAVE_NOTIFY_EVENT], false);
+
+	/*
+	* Feature in GTK.  Events such as mouse move are propagate up
+	* the widget hierarchy and are seen by the parent.  This is the
+	* correct GTK behavior but not correct for SWT.  The fix is to
+	* hook a signal after and stop the propagation using a negative
+	* event number to distinguish this case.
+	* 
+	* The signal is hooked to the fixedHandle to catch events sent to
+	* lightweight widgets.
+	*/
+	int /*long*/ blockHandle = fixedHandle != 0 ? fixedHandle : eventHandle;
+	OS.g_signal_connect_closure_by_id (blockHandle, display.signalIds [BUTTON_PRESS_EVENT], 0, display.closures [BUTTON_PRESS_EVENT_INVERSE], true);
+	OS.g_signal_connect_closure_by_id (blockHandle, display.signalIds [BUTTON_RELEASE_EVENT], 0, display.closures [BUTTON_RELEASE_EVENT_INVERSE], true);
+	OS.g_signal_connect_closure_by_id (blockHandle, display.signalIds [MOTION_NOTIFY_EVENT], 0, display.closures [MOTION_NOTIFY_EVENT_INVERSE], true);
+
+	/* Connect the event_after signal for both key and mouse */
+	OS.g_signal_connect_closure_by_id (eventHandle, display.signalIds [EVENT_AFTER], 0, display.closures [EVENT_AFTER], false);
+	if (focusHandle != eventHandle) {
+		OS.g_signal_connect_closure_by_id (focusHandle, display.signalIds [EVENT_AFTER], 0, display.closures [EVENT_AFTER], false);
+	}
+	
+	/* Connect the paint signal */
+	int /*long*/ paintHandle = paintHandle ();
+	int paintMask = OS.GDK_EXPOSURE_MASK | OS.GDK_VISIBILITY_NOTIFY_MASK;
+	OS.gtk_widget_add_events (paintHandle, paintMask);
+	OS.g_signal_connect_closure_by_id (paintHandle, display.signalIds [EXPOSE_EVENT], 0, display.closures [EXPOSE_EVENT_INVERSE], false);
+	OS.g_signal_connect_closure_by_id (paintHandle, display.signalIds [VISIBILITY_NOTIFY_EVENT], 0, display.closures [VISIBILITY_NOTIFY_EVENT], false);
+	OS.g_signal_connect_closure_by_id (paintHandle, display.signalIds [EXPOSE_EVENT], 0, display.closures [EXPOSE_EVENT], true);
+
+	/* Connect the Input Method signals */
+	OS.g_signal_connect_closure_by_id (handle, display.signalIds [REALIZE], 0, display.closures [REALIZE], true);
+	OS.g_signal_connect_closure_by_id (handle, display.signalIds [UNREALIZE], 0, display.closures [UNREALIZE], false);
+	int /*long*/ imHandle = imHandle ();
+	if (imHandle != 0) {
+		OS.g_signal_connect_closure (imHandle, OS.commit, display.closures [COMMIT], false);
+		OS.g_signal_connect_closure (imHandle, OS.preedit_changed, display.closures [PREEDIT_CHANGED], false);
+	}
+	
+	OS.g_signal_connect_closure_by_id (paintHandle, display.signalIds [STYLE_SET], 0, display.closures [STYLE_SET], false);
+   
+	int /*long*/ topHandle = topHandle ();
+	OS.g_signal_connect_closure_by_id (topHandle, display.signalIds [MAP], 0, display.closures [MAP], true);
+}
+
+int /*long*/ hoverProc (int /*long*/ widget) {
+	int [] x = new int [1], y = new int [1], mask = new int [1];
+	OS.gdk_window_get_pointer (0, x, y, mask);
+	sendMouseEvent (SWT.MouseHover, 0, /*time*/0, x [0], y [0], false, mask [0]);
+	/* Always return zero in order to cancel the hover timer */
+	return 0;
+}
+
+int /*long*/ topHandle() {
+	if (fixedHandle != 0) return fixedHandle;
+	return super.topHandle ();
+}
+
+int /*long*/ paintHandle () {
+	int /*long*/ topHandle = topHandle ();
+	int /*long*/ paintHandle = handle;
+	while (paintHandle != topHandle) {
+		if ((OS.GTK_WIDGET_FLAGS (paintHandle) & OS.GTK_NO_WINDOW) == 0) break;
+		paintHandle = OS.gtk_widget_get_parent (paintHandle);
+	}
+	return paintHandle;
+}
+
+int /*long*/ paintWindow () {
+	int /*long*/ paintHandle = paintHandle ();
+	OS.gtk_widget_realize (paintHandle);
+	return OS.GTK_WIDGET_WINDOW (paintHandle);
+}
+
+/**
+ * Prints the receiver and all children.
+ * 
+ * @param gc the gc where the drawing occurs
+ * @return <code>true</code> if the operation was successful and <code>false</code> otherwise
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the gc is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the gc has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.4
+ */
+public boolean print (GC gc) {
+	checkWidget ();
+	if (gc == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if (gc.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT);
+	int /*long*/ topHandle = topHandle ();
+	OS.gtk_widget_realize (topHandle);
+	int /*long*/ window = OS.GTK_WIDGET_WINDOW (topHandle);
+	GCData data = gc.getGCData ();
+	OS.gdk_window_process_updates (window, true);
+	printWidget (gc, data.drawable, OS.gdk_drawable_get_depth (data.drawable), 0, 0);
+	return true;
+}
+
+void printWidget (GC gc, int /*long*/ drawable, int depth, int x, int y) {
+	boolean obscured = (state & OBSCURED) != 0;
+	state &= ~OBSCURED;
+	int /*long*/ topHandle = topHandle ();
+	int /*long*/ window = OS.GTK_WIDGET_WINDOW (topHandle);
+	printWindow (true, this, gc.handle, drawable, depth, window, x, y);
+	if (obscured) state |= OBSCURED;
+}
+
+void printWindow (boolean first, Control control, int /*long*/ gc, int /*long*/ drawable, int depth, int /*long*/ window, int x, int y) {
+	if (OS.gdk_drawable_get_depth (window) != depth) return;
+	GdkRectangle rect = new GdkRectangle ();
+	int [] width = new int [1], height = new int [1];
+	OS.gdk_drawable_get_size (window, width, height);
+	rect.width = width [0];
+	rect.height = height [0];
+	OS.gdk_window_begin_paint_rect (window, rect);
+	int /*long*/ [] real_drawable = new int /*long*/ [1];
+	int [] x_offset = new int [1], y_offset = new int [1];
+	OS.gdk_window_get_internal_paint_info (window, real_drawable, x_offset, y_offset);	
+	int /*long*/ [] userData = new int /*long*/ [1];
+	OS.gdk_window_get_user_data (window, userData);
+	if (userData [0] != 0) {
+		int /*long*/ eventPtr = OS.gdk_event_new (OS.GDK_EXPOSE);
+		GdkEventExpose event = new GdkEventExpose ();
+		event.type = OS.GDK_EXPOSE;
+		event.window = OS.g_object_ref (window);
+		event.area_width = rect.width;
+		event.area_height = rect.height;
+		event.region = OS.gdk_region_rectangle (rect);
+		OS.memmove (eventPtr, event, GdkEventExpose.sizeof);
+		OS.gtk_widget_send_expose (userData [0], eventPtr);
+		OS.gdk_event_free (eventPtr);
+	}
+	int srcX = x_offset [0], srcY = y_offset [0];
+	int destX = x, destY = y, destWidth = width [0], destHeight = height [0];
+	if (!first) {
+		int [] cX = new int [1], cY = new int [1];
+		OS.gdk_window_get_position (window, cX, cY);
+		int /*long*/ parentWindow = OS.gdk_window_get_parent (window);
+		int [] pW = new int [1], pH = new int [1];
+		OS.gdk_drawable_get_size (parentWindow, pW, pH);
+		srcX = x_offset [0] - cX [0];
+		srcY = y_offset [0] - cY [0];
+		destX = x - cX [0];
+		destY = y - cY [0];
+		destWidth = Math.min (cX [0] + width [0], pW [0]);
+		destHeight = Math.min (cY [0] + height [0], pH [0]);
+	}
+	OS.gdk_draw_drawable (drawable, gc, real_drawable [0], srcX, srcY, destX, destY, destWidth, destHeight);
+	OS.gdk_window_end_paint (window);
+	int /*long*/ children = OS.gdk_window_get_children (window);
+	if (children != 0) {
+		int /*long*/ windows = children;
+		while (windows != 0) {
+			int /*long*/ child = OS.g_list_data (windows);
+			if (OS.gdk_window_is_visible (child)) {
+				int /*long*/ [] data = new int /*long*/ [1];
+				OS.gdk_window_get_user_data (child, data);
+				if (data [0] != 0) {
+					Widget widget = display.findWidget (data [0]);
+					if (widget == null || widget == control) {
+						int [] x_pos = new int [1], y_pos = new int [1];
+						OS.gdk_window_get_position (child, x_pos, y_pos);
+						printWindow (false, control, gc, drawable, depth, child, x + x_pos [0], y + y_pos [0]);
+					}
+				}
+			}
+			windows = OS.g_list_next (windows);
+		}
+		OS.g_list_free (children);
+	}
+}
+
+/**
+ * Returns the preferred size of the receiver.
+ * <p>
+ * The <em>preferred size</em> of a control is the size that it would
+ * best be displayed at. The width hint and height hint arguments
+ * allow the caller to ask a control questions such as "Given a particular
+ * width, how high does the control need to be to show all of the contents?"
+ * To indicate that the caller does not wish to constrain a particular 
+ * dimension, the constant <code>SWT.DEFAULT</code> is passed for the hint. 
+ * </p>
+ *
+ * @param wHint the width hint (can be <code>SWT.DEFAULT</code>)
+ * @param hHint the height hint (can be <code>SWT.DEFAULT</code>)
+ * @return the preferred size of the control
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see Layout
+ * @see #getBorderWidth
+ * @see #getBounds
+ * @see #getSize
+ * @see #pack(boolean)
+ * @see "computeTrim, getClientArea for controls that implement them"
+ */
+public Point computeSize (int wHint, int hHint) {
+	return computeSize (wHint, hHint, true);
+}
+
+Control computeTabGroup () {
+	if (isTabGroup()) return this;
+	return parent.computeTabGroup ();
+}
+
+Control[] computeTabList() {
+	if (isTabGroup()) {
+		if (getVisible() && getEnabled()) {
+			return new Control[] {this};
+		}
+	}
+	return new Control[0];
+}
+
+Control computeTabRoot () {
+	Control[] tabList = parent._getTabList();
+	if (tabList != null) {
+		int index = 0;
+		while (index < tabList.length) {
+			if (tabList [index] == this) break;
+			index++;
+		}
+		if (index == tabList.length) {
+			if (isTabGroup ()) return this;
+		}
+	}
+	return parent.computeTabRoot ();
+}
+
+void checkBuffered () {
+	style |= SWT.DOUBLE_BUFFERED;
+}
+
+void checkBackground () {
+	Shell shell = getShell ();
+	if (this == shell) return;
+	state &= ~PARENT_BACKGROUND;
+	Composite composite = parent;
+	do {
+		int mode = composite.backgroundMode;
+		if (mode != SWT.INHERIT_NONE) {
+			if (mode == SWT.INHERIT_DEFAULT) {
+				Control control = this;
+				do {
+					if ((control.state & THEME_BACKGROUND) == 0) {
+						return;
+					}
+					control = control.parent;
+				} while (control != composite);
+			}
+			state |= PARENT_BACKGROUND;
+			return;
+		}
+		if (composite == shell) break;		
+		composite = composite.parent;
+	} while (true);
+}
+
+void checkBorder () {
+	if (getBorderWidth () == 0) style &= ~SWT.BORDER;
+}
+
+void checkMirrored () {
+	if ((style & SWT.RIGHT_TO_LEFT) != 0) style |= SWT.MIRRORED;
+}
+
+int /*long*/ childStyle () {
+	return parent.childStyle ();
+}
+
+void createWidget (int index) {
+	state |= DRAG_DETECT;
+	checkOrientation (parent);
+	super.createWidget (index);
+	checkBackground ();
+	if ((state & PARENT_BACKGROUND) != 0) setBackground ();
+	checkBuffered ();
+	showWidget ();
+	setInitialBounds ();
+	setZOrder (null, false, false);
+	setRelations ();
+	checkMirrored ();
+	checkBorder ();
+}
+
+/**
+ * Returns the preferred size of the receiver.
+ * <p>
+ * The <em>preferred size</em> of a control is the size that it would
+ * best be displayed at. The width hint and height hint arguments
+ * allow the caller to ask a control questions such as "Given a particular
+ * width, how high does the control need to be to show all of the contents?"
+ * To indicate that the caller does not wish to constrain a particular 
+ * dimension, the constant <code>SWT.DEFAULT</code> is passed for the hint. 
+ * </p><p>
+ * If the changed flag is <code>true</code>, it indicates that the receiver's
+ * <em>contents</em> have changed, therefore any caches that a layout manager
+ * containing the control may have been keeping need to be flushed. When the
+ * control is resized, the changed flag will be <code>false</code>, so layout
+ * manager caches can be retained. 
+ * </p>
+ *
+ * @param wHint the width hint (can be <code>SWT.DEFAULT</code>)
+ * @param hHint the height hint (can be <code>SWT.DEFAULT</code>)
+ * @param changed <code>true</code> if the control's contents have changed, and <code>false</code> otherwise
+ * @return the preferred size of the control.
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see Layout
+ * @see #getBorderWidth
+ * @see #getBounds
+ * @see #getSize
+ * @see #pack(boolean)
+ * @see "computeTrim, getClientArea for controls that implement them"
+ */
+public Point computeSize (int wHint, int hHint, boolean changed) {
+	checkWidget();
+	if (wHint != SWT.DEFAULT && wHint < 0) wHint = 0;
+	if (hHint != SWT.DEFAULT && hHint < 0) hHint = 0;
+	return computeNativeSize (handle, wHint, hHint, changed);	
+}
+
+Point computeNativeSize (int /*long*/ h, int wHint, int hHint, boolean changed) {
+	int width = wHint, height = hHint;
+	if (wHint == SWT.DEFAULT && hHint == SWT.DEFAULT) {
+		GtkRequisition requisition = new GtkRequisition ();
+		gtk_widget_size_request (h, requisition);
+		width = OS.GTK_WIDGET_REQUISITION_WIDTH (h);
+		height = OS.GTK_WIDGET_REQUISITION_HEIGHT (h);
+	} else if (wHint == SWT.DEFAULT || hHint == SWT.DEFAULT) {
+		int [] reqWidth = new int [1], reqHeight = new int [1];
+		OS.gtk_widget_get_size_request (h, reqWidth, reqHeight);
+		OS.gtk_widget_set_size_request (h, wHint, hHint);
+		GtkRequisition requisition = new GtkRequisition ();
+		gtk_widget_size_request (h, requisition);
+		OS.gtk_widget_set_size_request (h, reqWidth [0], reqHeight [0]);
+		width = wHint == SWT.DEFAULT ? requisition.width : wHint;
+		height = hHint == SWT.DEFAULT ? requisition.height : hHint;
+	}
+	return new Point (width, height);
+}
+
+void forceResize () {
+	/*
+	* Force size allocation on all children of this widget's
+	* topHandle.  Note that all calls to gtk_widget_size_allocate()
+	* must be preceded by a call to gtk_widget_size_request().
+	*/
+	int /*long*/ topHandle = topHandle ();
+	GtkRequisition requisition = new GtkRequisition ();
+	gtk_widget_size_request (topHandle, requisition);
+	GtkAllocation allocation = new GtkAllocation ();
+	allocation.x = OS.GTK_WIDGET_X (topHandle);
+	allocation.y = OS.GTK_WIDGET_Y (topHandle);
+	allocation.width = OS.GTK_WIDGET_WIDTH (topHandle);
+	allocation.height = OS.GTK_WIDGET_HEIGHT (topHandle);
+	OS.gtk_widget_size_allocate (topHandle, allocation);
+}
+
+/**
+ * Returns the accessible object for the receiver.
+ * If this is the first time this object is requested,
+ * then the object is created and returned.
+ *
+ * @return the accessible object
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see Accessible#addAccessibleListener
+ * @see Accessible#addAccessibleControlListener
+ * 
+ * @since 2.0
+ */
+public Accessible getAccessible () {
+	checkWidget ();
+	if (accessible == null) {
+		accessible = Accessible.internal_new_Accessible (this);
+	}
+	return accessible;
+}
+
+/**
+ * Returns a rectangle describing the receiver's size and location
+ * relative to its parent (or its display if its parent is null),
+ * unless the receiver is a shell. In this case, the location is
+ * relative to the display.
+ *
+ * @return the receiver's bounding rectangle
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Rectangle getBounds () {
+	checkWidget();
+	int /*long*/ topHandle = topHandle ();
+	int x = OS.GTK_WIDGET_X (topHandle);
+	int y = OS.GTK_WIDGET_Y (topHandle);
+	int width = (state & ZERO_WIDTH) != 0 ? 0 : OS.GTK_WIDGET_WIDTH (topHandle);
+	int height = (state & ZERO_HEIGHT) != 0 ? 0 : OS.GTK_WIDGET_HEIGHT (topHandle);
+	if ((parent.style & SWT.MIRRORED) != 0) x = parent.getClientWidth () - width - x;
+	return new Rectangle (x, y, width, height);
+}
+
+/**
+ * Sets the receiver's size and location to the rectangular
+ * area specified by the argument. The <code>x</code> and 
+ * <code>y</code> fields of the rectangle are relative to
+ * the receiver's parent (or its display if its parent is null).
+ * <p>
+ * Note: Attempting to set the width or height of the
+ * receiver to a negative number will cause that
+ * value to be set to zero instead.
+ * </p>
+ *
+ * @param rect the new bounds for the receiver
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setBounds (Rectangle rect) {
+	checkWidget ();
+	if (rect == null) error (SWT.ERROR_NULL_ARGUMENT);
+	setBounds (rect.x, rect.y, Math.max (0, rect.width), Math.max (0, rect.height), true, true);
+}
+
+/**
+ * Sets the receiver's size and location to the rectangular
+ * area specified by the arguments. The <code>x</code> and 
+ * <code>y</code> arguments are relative to the receiver's
+ * parent (or its display if its parent is null), unless 
+ * the receiver is a shell. In this case, the <code>x</code>
+ * and <code>y</code> arguments are relative to the display.
+ * <p>
+ * Note: Attempting to set the width or height of the
+ * receiver to a negative number will cause that
+ * value to be set to zero instead.
+ * </p>
+ *
+ * @param x the new x coordinate for the receiver
+ * @param y the new y coordinate for the receiver
+ * @param width the new width for the receiver
+ * @param height the new height for the receiver
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setBounds (int x, int y, int width, int height) {
+	checkWidget();
+	setBounds (x, y, Math.max (0, width), Math.max (0, height), true, true);
+}
+
+void markLayout (boolean changed, boolean all) {
+	/* Do nothing */
+}
+
+void modifyStyle (int /*long*/ handle, int /*long*/ style) {
+	super.modifyStyle(handle, style);
+	/*
+	* Bug in GTK.  When changing the style of a control that  
+	* has had a region set on it, the region is lost.  The 
+	* fix is to set the region again.
+	*/
+	if (region != null) OS.gdk_window_shape_combine_region (OS.GTK_WIDGET_WINDOW (topHandle ()), region.handle, 0, 0);
+}
+
+void moveHandle (int x, int y) {
+	int /*long*/ topHandle = topHandle ();
+	int /*long*/ parentHandle = parent.parentingHandle ();
+	/*
+	* Feature in GTK.  Calling gtk_fixed_move() to move a child causes
+	* the whole parent to redraw.  This is a performance problem. The
+	* fix is temporarily make the parent not visible during the move.
+	* 
+	* NOTE: Because every widget in SWT has an X window, the new and
+	* old bounds of the child are correctly redrawn.
+	*/
+	int flags = OS.GTK_WIDGET_FLAGS (parentHandle);
+	OS.GTK_WIDGET_UNSET_FLAGS (parentHandle, OS.GTK_VISIBLE);
+	OS.gtk_fixed_move (parentHandle, topHandle, x, y);
+	if ((flags & OS.GTK_VISIBLE) != 0) {
+		OS.GTK_WIDGET_SET_FLAGS (parentHandle, OS.GTK_VISIBLE);	
+	}
+}
+
+void resizeHandle (int width, int height) {
+	int /*long*/ topHandle = topHandle ();
+	OS.gtk_widget_set_size_request (topHandle, width, height);
+	if (topHandle != handle) OS.gtk_widget_set_size_request (handle, width, height);
+}
+
+int setBounds (int x, int y, int width, int height, boolean move, boolean resize) {
+	int /*long*/ topHandle = topHandle ();
+	boolean sendMove = move;
+	if ((parent.style & SWT.MIRRORED) != 0) {
+		int clientWidth = parent.getClientWidth ();
+		int oldWidth = (state & ZERO_WIDTH) != 0 ? 0 : OS.GTK_WIDGET_WIDTH (topHandle);
+		int oldX = clientWidth - oldWidth - OS.GTK_WIDGET_X (topHandle);
+		if (move) {
+			sendMove &= x != oldX;
+			x = clientWidth - (resize ? width : oldWidth) - x;
+		} else {
+			move = true;
+			x = clientWidth - (resize ? width : oldWidth) - oldX;
+			y = OS.GTK_WIDGET_Y (topHandle);
+		}
+	}
+	boolean sameOrigin = true, sameExtent = true;
+	if (move) {
+		int oldX = OS.GTK_WIDGET_X (topHandle);
+		int oldY = OS.GTK_WIDGET_Y (topHandle);
+		sameOrigin = x == oldX && y == oldY;
+		if (!sameOrigin) {
+			if (enableWindow != 0) {
+				OS.gdk_window_move (enableWindow, x, y);
+			}
+			moveHandle (x, y);
+		}
+	}
+	int clientWidth = 0;
+	if (resize) {
+		int oldWidth = (state & ZERO_WIDTH) != 0 ? 0 : OS.GTK_WIDGET_WIDTH (topHandle);
+		int oldHeight = (state & ZERO_HEIGHT) != 0 ? 0 : OS.GTK_WIDGET_HEIGHT (topHandle);
+		sameExtent = width == oldWidth && height == oldHeight;
+		if (!sameExtent && (style & SWT.MIRRORED) != 0) clientWidth = getClientWidth ();
+		if (!sameExtent && !(width == 0 && height == 0)) {
+			int newWidth = Math.max (1, width);
+			int newHeight = Math.max (1, height);
+			if (redrawWindow != 0) {
+				OS.gdk_window_resize (redrawWindow, newWidth, newHeight);
+			}
+			if (enableWindow != 0) {
+				OS.gdk_window_resize (enableWindow, newWidth, newHeight);
+			}
+			resizeHandle (newWidth, newHeight);
+		}
+	}
+	if (!sameOrigin || !sameExtent) {
+		/*
+		* Cause a size allocation this widget's topHandle.  Note that
+		* all calls to gtk_widget_size_allocate() must be preceded by
+		* a call to gtk_widget_size_request().
+		*/
+		GtkRequisition requisition = new GtkRequisition ();
+		gtk_widget_size_request (topHandle, requisition);
+		GtkAllocation allocation = new GtkAllocation ();
+		if (move) {
+			allocation.x = x;
+			allocation.y = y;
+		} else {
+			allocation.x = OS.GTK_WIDGET_X (topHandle);
+			allocation.y = OS.GTK_WIDGET_Y (topHandle);
+		}
+		if (resize) {
+			allocation.width = width;
+			allocation.height = height;
+		} else {
+			allocation.width = OS.GTK_WIDGET_WIDTH (topHandle);
+			allocation.height = OS.GTK_WIDGET_HEIGHT (topHandle);
+		}
+		OS.gtk_widget_size_allocate (topHandle, allocation);
+	}
+	/*
+	* Bug in GTK.  Widgets cannot be sized smaller than 1x1.
+	* The fix is to hide zero-sized widgets and show them again
+	* when they are resized larger.
+	*/
+	if (!sameExtent) {
+		state = (width == 0) ? state | ZERO_WIDTH : state & ~ZERO_WIDTH;
+		state = (height == 0) ? state | ZERO_HEIGHT : state & ~ZERO_HEIGHT;
+		if ((state & (ZERO_WIDTH | ZERO_HEIGHT)) != 0) {
+			if (enableWindow != 0) {
+				OS.gdk_window_hide (enableWindow);
+			}
+			OS.gtk_widget_hide (topHandle);
+		} else {
+			if ((state & HIDDEN) == 0) {
+				if (enableWindow != 0) {
+					OS.gdk_window_show_unraised (enableWindow);
+				}
+				OS.gtk_widget_show (topHandle);
+			}
+		}
+		if ((style & SWT.MIRRORED) != 0) moveChildren (clientWidth);
+	}
+	int result = 0;
+	if (move && !sameOrigin) {
+		Control control = findBackgroundControl ();
+		if (control != null && control.backgroundImage != null) {
+			if (isVisible ()) redrawWidget (0, 0, 0, 0, true, true, true);
+		}
+		if (sendMove) sendEvent (SWT.Move);
+		result |= MOVED;
+	}
+	if (resize && !sameExtent) {
+		sendEvent (SWT.Resize);
+		result |= RESIZED;
+	}
+	return result;
+}
+
+/**
+ * Returns a point describing the receiver's location relative
+ * to its parent (or its display if its parent is null), unless
+ * the receiver is a shell. In this case, the point is 
+ * relative to the display. 
+ *
+ * @return the receiver's location
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Point getLocation () {
+	checkWidget();
+	int /*long*/ topHandle = topHandle ();
+	int x = OS.GTK_WIDGET_X (topHandle);
+	int y = OS.GTK_WIDGET_Y (topHandle);
+	if ((parent.style & SWT.MIRRORED) != 0) {
+		int width = (state & ZERO_WIDTH) != 0 ? 0 : OS.GTK_WIDGET_WIDTH (topHandle);
+		x = parent.getClientWidth () - width - x;
+	}
+	return new Point (x, y);
+}
+
+/**
+ * Sets the receiver's location to the point specified by
+ * the arguments which are relative to the receiver's
+ * parent (or its display if its parent is null), unless 
+ * the receiver is a shell. In this case, the point is 
+ * relative to the display. 
+ *
+ * @param location the new location for the receiver
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setLocation (Point location) {
+	checkWidget ();
+	if (location == null) error (SWT.ERROR_NULL_ARGUMENT);
+	setBounds (location.x, location.y, 0, 0, true, false);
+}
+
+/**
+ * Sets the receiver's location to the point specified by
+ * the arguments which are relative to the receiver's
+ * parent (or its display if its parent is null), unless 
+ * the receiver is a shell. In this case, the point is 
+ * relative to the display. 
+ *
+ * @param x the new x coordinate for the receiver
+ * @param y the new y coordinate for the receiver
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setLocation(int x, int y) {
+	checkWidget();
+	setBounds (x, y, 0, 0, true, false);
+}
+
+/**
+ * Returns a point describing the receiver's size. The
+ * x coordinate of the result is the width of the receiver.
+ * The y coordinate of the result is the height of the
+ * receiver.
+ *
+ * @return the receiver's size
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Point getSize () {
+	checkWidget();
+	int /*long*/ topHandle = topHandle ();
+	int width = (state & ZERO_WIDTH) != 0 ? 0 : OS.GTK_WIDGET_WIDTH (topHandle);
+	int height = (state & ZERO_HEIGHT) != 0 ? 0 : OS.GTK_WIDGET_HEIGHT (topHandle);
+	return new Point (width, height);
+}
+
+/**
+ * Sets the receiver's size to the point specified by the argument.
+ * <p>
+ * Note: Attempting to set the width or height of the
+ * receiver to a negative number will cause them to be
+ * set to zero instead.
+ * </p>
+ *
+ * @param size the new size for the receiver
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the point is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setSize (Point size) {
+	checkWidget ();
+	if (size == null) error (SWT.ERROR_NULL_ARGUMENT);
+	setBounds (0, 0, Math.max (0, size.x), Math.max (0, size.y), false, true);
+}
+
+/**
+ * Sets the shape of the control to the region specified
+ * by the argument.  When the argument is null, the
+ * default shape of the control is restored.
+ *
+ * @param region the region that defines the shape of the control (or null)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the region has been disposed</li>
+ * </ul>  
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 3.4
+ */
+public void setRegion (Region region) {
+	checkWidget ();
+	if (region != null && region.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);
+	int /*long*/ window = OS.GTK_WIDGET_WINDOW (topHandle ());
+	int /*long*/ shape_region = (region == null) ? 0 : region.handle;
+	OS.gdk_window_shape_combine_region (window, shape_region, 0, 0);
+	this.region = region;
+}
+
+void setRelations () {
+	int /*long*/ parentHandle = parent.parentingHandle ();
+	int /*long*/ list = OS.gtk_container_get_children (parentHandle);
+	if (list == 0) return;
+	int count = OS.g_list_length (list);
+	if (count > 1) {
+		/*
+		 * the receiver is the last item in the list, so its predecessor will
+		 * be the second-last item in the list
+		 */
+		int /*long*/ handle = OS.g_list_nth_data (list, count - 2);
+		if (handle != 0) {
+			Widget widget = display.getWidget (handle);
+			if (widget != null && widget != this) {
+				if (widget instanceof Control) {
+					Control sibling = (Control)widget;
+					sibling.addRelation (this);
+				}
+			}
+		}
+	}
+	OS.g_list_free (list);
+}
+
+/**
+ * Sets the receiver's size to the point specified by the arguments.
+ * <p>
+ * Note: Attempting to set the width or height of the
+ * receiver to a negative number will cause that
+ * value to be set to zero instead.
+ * </p>
+ *
+ * @param width the new width for the receiver
+ * @param height the new height for the receiver
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setSize (int width, int height) {
+	checkWidget();
+	setBounds (0, 0, Math.max (0, width), Math.max (0, height), false, true);
+}
+
+/*
+ * Answers a boolean indicating whether a Label that precedes the receiver in
+ * a layout should be read by screen readers as the recevier's label.
+ */
+boolean isDescribedByLabel () {
+	return true;
+}
+
+boolean isFocusHandle (int /*long*/ widget) {
+	return widget == focusHandle (); 
+}
+
+/**
+ * Moves the receiver above the specified control in the
+ * drawing order. If the argument is null, then the receiver
+ * is moved to the top of the drawing order. The control at
+ * the top of the drawing order will not be covered by other
+ * controls even if they occupy intersecting areas.
+ *
+ * @param control the sibling control (or null)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the control has been disposed</li> 
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see Control#moveBelow
+ * @see Composite#getChildren
+ */
+public void moveAbove (Control control) {
+	checkWidget();
+	if (control != null) {
+		if (control.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT);
+		if (parent != control.parent) return;
+	}
+	setZOrder (control, true, true);
+}
+
+/**
+ * Moves the receiver below the specified control in the
+ * drawing order. If the argument is null, then the receiver
+ * is moved to the bottom of the drawing order. The control at
+ * the bottom of the drawing order will be covered by all other
+ * controls which occupy intersecting areas.
+ *
+ * @param control the sibling control (or null)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the control has been disposed</li> 
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see Control#moveAbove
+ * @see Composite#getChildren
+ */
+public void moveBelow (Control control) {
+	checkWidget();
+	if (control != null) {
+		if (control.isDisposed ()) error(SWT.ERROR_INVALID_ARGUMENT);
+		if (parent != control.parent) return;
+	}
+	setZOrder (control, false, true);
+}
+
+void moveChildren (int oldWidth) {
+}
+
+/**
+ * Causes the receiver to be resized to its preferred size.
+ * For a composite, this involves computing the preferred size
+ * from its layout, if there is one.
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #computeSize(int, int, boolean)
+ */
+public void pack () {
+	pack (true);
+}
+
+/**
+ * Causes the receiver to be resized to its preferred size.
+ * For a composite, this involves computing the preferred size
+ * from its layout, if there is one.
+ * <p>
+ * If the changed flag is <code>true</code>, it indicates that the receiver's
+ * <em>contents</em> have changed, therefore any caches that a layout manager
+ * containing the control may have been keeping need to be flushed. When the
+ * control is resized, the changed flag will be <code>false</code>, so layout
+ * manager caches can be retained. 
+ * </p>
+ *
+ * @param changed whether or not the receiver's contents have changed
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #computeSize(int, int, boolean)
+ */
+public void pack (boolean changed) {
+	setSize (computeSize (SWT.DEFAULT, SWT.DEFAULT, changed));
+}
+
+/**
+ * Sets the layout data associated with the receiver to the argument.
+ * 
+ * @param layoutData the new layout data for the receiver.
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setLayoutData (Object layoutData) {
+	checkWidget();
+	this.layoutData = layoutData;
+}
+
+/**
+ * Returns a point which is the result of converting the
+ * argument, which is specified in display relative coordinates,
+ * to coordinates relative to the receiver.
+ * <p>
+ * @param x the x coordinate to be translated
+ * @param y the y coordinate to be translated
+ * @return the translated coordinates
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 2.1
+ */
+public Point toControl (int x, int y) {
+	checkWidget ();
+	int /*long*/ window = eventWindow ();
+	int [] origin_x = new int [1], origin_y = new int [1];
+	OS.gdk_window_get_origin (window, origin_x, origin_y);
+	x -= origin_x [0];
+	y -= origin_y [0];
+	if ((style & SWT.MIRRORED) != 0) x = getClientWidth () - x;
+	return new Point (x, y);
+}
+
+/**
+ * Returns a point which is the result of converting the
+ * argument, which is specified in display relative coordinates,
+ * to coordinates relative to the receiver.
+ * <p>
+ * @param point the point to be translated (must not be null)
+ * @return the translated coordinates
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the point is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Point toControl (Point point) {
+	checkWidget ();
+	if (point == null) error (SWT.ERROR_NULL_ARGUMENT);
+	return toControl (point.x, point.y);
+}
+
+/**
+ * Returns a point which is the result of converting the
+ * argument, which is specified in coordinates relative to
+ * the receiver, to display relative coordinates.
+ * <p>
+ * @param x the x coordinate to be translated
+ * @param y the y coordinate to be translated
+ * @return the translated coordinates
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 2.1
+ */
+public Point toDisplay (int x, int y) {
+	checkWidget();
+	int /*long*/ window = eventWindow ();
+	int [] origin_x = new int [1], origin_y = new int [1];
+	OS.gdk_window_get_origin (window, origin_x, origin_y);
+	if ((style & SWT.MIRRORED) != 0) x = getClientWidth () - x;
+	x += origin_x [0];
+	y += origin_y [0];
+	return new Point (x, y);
+}
+
+/**
+ * Returns a point which is the result of converting the
+ * argument, which is specified in coordinates relative to
+ * the receiver, to display relative coordinates.
+ * <p>
+ * @param point the point to be translated (must not be null)
+ * @return the translated coordinates
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the point is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Point toDisplay (Point point) {
+	checkWidget();
+	if (point == null) error (SWT.ERROR_NULL_ARGUMENT);
+	return toDisplay (point.x, point.y);
+}
+ 
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the control is moved or resized, by sending
+ * it one of the messages defined in the <code>ControlListener</code>
+ * interface.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see ControlListener
+ * @see #removeControlListener
+ */
+public void addControlListener(ControlListener listener) {
+	checkWidget();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	TypedListener typedListener = new TypedListener (listener);
+	addListener (SWT.Resize,typedListener);
+	addListener (SWT.Move,typedListener);
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when a drag gesture occurs, by sending it
+ * one of the messages defined in the <code>DragDetectListener</code>
+ * interface.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see DragDetectListener
+ * @see #removeDragDetectListener
+ * 
+ * @since 3.3
+ */
+public void addDragDetectListener (DragDetectListener listener) {
+	checkWidget ();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	TypedListener typedListener = new TypedListener (listener);
+	addListener (SWT.DragDetect,typedListener);
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the control gains or loses focus, by sending
+ * it one of the messages defined in the <code>FocusListener</code>
+ * interface.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see FocusListener
+ * @see #removeFocusListener
+ */
+public void addFocusListener(FocusListener listener) {
+	checkWidget();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	TypedListener typedListener = new TypedListener (listener);
+	addListener(SWT.FocusIn,typedListener);
+	addListener(SWT.FocusOut,typedListener);
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when help events are generated for the control,
+ * by sending it one of the messages defined in the
+ * <code>HelpListener</code> interface.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see HelpListener
+ * @see #removeHelpListener
+ */
+public void addHelpListener (HelpListener listener) {
+	checkWidget();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	TypedListener typedListener = new TypedListener (listener);
+	addListener (SWT.Help, typedListener);
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when keys are pressed and released on the system keyboard, by sending
+ * it one of the messages defined in the <code>KeyListener</code>
+ * interface.
+ * <p>
+ * When a key listener is added to a control, the control
+ * will take part in widget traversal.  By default, all
+ * traversal keys (such as the tab key and so on) are
+ * delivered to the control.  In order for a control to take
+ * part in traversal, it should listen for traversal events.
+ * Otherwise, the user can traverse into a control but not
+ * out.  Note that native controls such as table and tree
+ * implement key traversal in the operating system.  It is
+ * not necessary to add traversal listeners for these controls,
+ * unless you want to override the default traversal.
+ * </p>
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see KeyListener
+ * @see #removeKeyListener
+ */
+public void addKeyListener(KeyListener listener) {
+	checkWidget();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	TypedListener typedListener = new TypedListener (listener);
+	addListener(SWT.KeyUp,typedListener);
+	addListener(SWT.KeyDown,typedListener);
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the platform-specific context menu trigger
+ * has occurred, by sending it one of the messages defined in
+ * the <code>MenuDetectListener</code> interface.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see MenuDetectListener
+ * @see #removeMenuDetectListener
+ *
+ * @since 3.3
+ */
+public void addMenuDetectListener (MenuDetectListener listener) {
+	checkWidget ();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	TypedListener typedListener = new TypedListener (listener);
+	addListener (SWT.MenuDetect, typedListener);
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when mouse buttons are pressed and released, by sending
+ * it one of the messages defined in the <code>MouseListener</code>
+ * interface.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see MouseListener
+ * @see #removeMouseListener
+ */
+public void addMouseListener(MouseListener listener) {
+	checkWidget();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	TypedListener typedListener = new TypedListener (listener);
+	addListener(SWT.MouseDown,typedListener);
+	addListener(SWT.MouseUp,typedListener);
+	addListener(SWT.MouseDoubleClick,typedListener);
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the mouse moves, by sending it one of the
+ * messages defined in the <code>MouseMoveListener</code>
+ * interface.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see MouseMoveListener
+ * @see #removeMouseMoveListener
+ */
+public void addMouseMoveListener(MouseMoveListener listener) {
+	checkWidget();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	TypedListener typedListener = new TypedListener (listener);
+	addListener(SWT.MouseMove,typedListener);
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the mouse passes or hovers over controls, by sending
+ * it one of the messages defined in the <code>MouseTrackListener</code>
+ * interface.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see MouseTrackListener
+ * @see #removeMouseTrackListener
+ */
+public void addMouseTrackListener (MouseTrackListener listener) {
+	checkWidget();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	TypedListener typedListener = new TypedListener (listener);
+	addListener (SWT.MouseEnter,typedListener);
+	addListener (SWT.MouseExit,typedListener);
+	addListener (SWT.MouseHover,typedListener);
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the mouse wheel is scrolled, by sending
+ * it one of the messages defined in the
+ * <code>MouseWheelListener</code> interface.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see MouseWheelListener
+ * @see #removeMouseWheelListener
+ *
+ * @since 3.3
+ */
+public void addMouseWheelListener (MouseWheelListener listener) {
+	checkWidget ();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	TypedListener typedListener = new TypedListener (listener);
+	addListener (SWT.MouseWheel, typedListener);
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the receiver needs to be painted, by sending it
+ * one of the messages defined in the <code>PaintListener</code>
+ * interface.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see PaintListener
+ * @see #removePaintListener
+ */
+public void addPaintListener(PaintListener listener) {
+	checkWidget();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	TypedListener typedListener = new TypedListener (listener);
+	addListener(SWT.Paint,typedListener);
+}
+
+void addRelation (Control control) {
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when traversal events occur, by sending it
+ * one of the messages defined in the <code>TraverseListener</code>
+ * interface.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see TraverseListener
+ * @see #removeTraverseListener
+ */
+public void addTraverseListener (TraverseListener listener) {
+	checkWidget();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	TypedListener typedListener = new TypedListener (listener);
+	addListener (SWT.Traverse,typedListener);
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the control is moved or resized.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see ControlListener
+ * @see #addControlListener
+ */
+public void removeControlListener (ControlListener listener) {
+	checkWidget();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if (eventTable == null) return;
+	eventTable.unhook (SWT.Move, listener);
+	eventTable.unhook (SWT.Resize, listener);
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when a drag gesture occurs.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see DragDetectListener
+ * @see #addDragDetectListener
+ * 
+ * @since 3.3
+ */
+public void removeDragDetectListener(DragDetectListener listener) {
+	checkWidget ();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if (eventTable == null) return;
+	eventTable.unhook (SWT.DragDetect, listener);
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the control gains or loses focus.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see FocusListener
+ * @see #addFocusListener
+ */
+public void removeFocusListener(FocusListener listener) {
+	checkWidget();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if (eventTable == null) return;
+	eventTable.unhook (SWT.FocusIn, listener);
+	eventTable.unhook (SWT.FocusOut, listener);
+}
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the help events are generated for the control.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see HelpListener
+ * @see #addHelpListener
+ */
+public void removeHelpListener (HelpListener listener) {
+	checkWidget();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if (eventTable == null) return;
+	eventTable.unhook (SWT.Help, listener);
+}
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when keys are pressed and released on the system keyboard.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see KeyListener
+ * @see #addKeyListener
+ */
+public void removeKeyListener(KeyListener listener) {
+	checkWidget();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if (eventTable == null) return;
+	eventTable.unhook (SWT.KeyUp, listener);
+	eventTable.unhook (SWT.KeyDown, listener);
+}
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the platform-specific context menu trigger has
+ * occurred.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see MenuDetectListener
+ * @see #addMenuDetectListener
+ *
+ * @since 3.3
+ */
+public void removeMenuDetectListener (MenuDetectListener listener) {
+	checkWidget ();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if (eventTable == null) return;
+	eventTable.unhook (SWT.MenuDetect, listener);
+}
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when mouse buttons are pressed and released.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see MouseListener
+ * @see #addMouseListener
+ */
+public void removeMouseListener (MouseListener listener) {
+	checkWidget();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if (eventTable == null) return;
+	eventTable.unhook (SWT.MouseDown, listener);
+	eventTable.unhook (SWT.MouseUp, listener);
+	eventTable.unhook (SWT.MouseDoubleClick, listener);
+}
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the mouse moves.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see MouseMoveListener
+ * @see #addMouseMoveListener
+ */
+public void removeMouseMoveListener(MouseMoveListener listener) {
+	checkWidget();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if (eventTable == null) return;
+	eventTable.unhook (SWT.MouseMove, listener);
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the mouse passes or hovers over controls.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see MouseTrackListener
+ * @see #addMouseTrackListener
+ */
+public void removeMouseTrackListener(MouseTrackListener listener) {
+	checkWidget();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if (eventTable == null) return;
+	eventTable.unhook (SWT.MouseEnter, listener);
+	eventTable.unhook (SWT.MouseExit, listener);
+	eventTable.unhook (SWT.MouseHover, listener);
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the mouse wheel is scrolled.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see MouseWheelListener
+ * @see #addMouseWheelListener
+ *
+ * @since 3.3
+ */
+public void removeMouseWheelListener (MouseWheelListener listener) {
+	checkWidget ();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if (eventTable == null) return;
+	eventTable.unhook (SWT.MouseWheel, listener);
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the receiver needs to be painted.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see PaintListener
+ * @see #addPaintListener
+ */
+public void removePaintListener(PaintListener listener) {
+	checkWidget();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if (eventTable == null) return;
+	eventTable.unhook(SWT.Paint, listener);
+}
+
+/*
+ * Remove "Labelled by" relations from the receiver.
+ */
+void removeRelation () {
+	if (!isDescribedByLabel ()) return;		/* there will not be any */
+	int /*long*/ accessible = OS.gtk_widget_get_accessible (handle);
+	if (accessible == 0) return;
+	int /*long*/ set = ATK.atk_object_ref_relation_set (accessible);
+	int count = ATK.atk_relation_set_get_n_relations (set);
+	for (int i = 0; i < count; i++) {
+		int /*long*/ relation = ATK.atk_relation_set_get_relation (set, 0);
+		ATK.atk_relation_set_remove (set, relation);
+	}
+	OS.g_object_unref (set);
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when traversal events occur.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see TraverseListener
+ * @see #addTraverseListener
+ */
+public void removeTraverseListener(TraverseListener listener) {
+	checkWidget ();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if (eventTable == null) return;
+	eventTable.unhook (SWT.Traverse, listener);
+}
+
+/**
+ * Detects a drag and drop gesture.  This method is used
+ * to detect a drag gesture when called from within a mouse
+ * down listener.
+ * 
+ * <p>By default, a drag is detected when the gesture
+ * occurs anywhere within the client area of a control.
+ * Some controls, such as tables and trees, override this
+ * behavior.  In addition to the operating system specific
+ * drag gesture, they require the mouse to be inside an
+ * item.  Custom widget writers can use <code>setDragDetect</code>
+ * to disable the default detection, listen for mouse down,
+ * and then call <code>dragDetect()</code> from within the
+ * listener to conditionally detect a drag.
+ * </p>
+ *
+ * @param event the mouse down event
+ * 
+ * @return <code>true</code> if the gesture occurred, and <code>false</code> otherwise.
+ *
+ * @exception IllegalArgumentException <ul>
+ *   <li>ERROR_NULL_ARGUMENT when the event is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *  
+ * @see DragDetectListener
+ * @see #addDragDetectListener
+ * 
+ * @see #getDragDetect
+ * @see #setDragDetect
+ * 
+ * @since 3.3
+ */
+public boolean dragDetect (Event event) {
+	checkWidget ();
+	if (event == null) error (SWT.ERROR_NULL_ARGUMENT);
+	return dragDetect (event.button, event.count, event.stateMask, event.x, event.y);
+}
+
+/**
+ * Detects a drag and drop gesture.  This method is used
+ * to detect a drag gesture when called from within a mouse
+ * down listener.
+ * 
+ * <p>By default, a drag is detected when the gesture
+ * occurs anywhere within the client area of a control.
+ * Some controls, such as tables and trees, override this
+ * behavior.  In addition to the operating system specific
+ * drag gesture, they require the mouse to be inside an
+ * item.  Custom widget writers can use <code>setDragDetect</code>
+ * to disable the default detection, listen for mouse down,
+ * and then call <code>dragDetect()</code> from within the
+ * listener to conditionally detect a drag.
+ * </p>
+ *
+ * @param event the mouse down event
+ * 
+ * @return <code>true</code> if the gesture occurred, and <code>false</code> otherwise.
+ *
+ * @exception IllegalArgumentException <ul>
+ *   <li>ERROR_NULL_ARGUMENT when the event is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see DragDetectListener
+ * @see #addDragDetectListener
+ * 
+ * @see #getDragDetect
+ * @see #setDragDetect
+ * 
+ * @since 3.3
+ */
+public boolean dragDetect (MouseEvent event) {
+	checkWidget ();
+	if (event == null) error (SWT.ERROR_NULL_ARGUMENT);
+	return dragDetect (event.button, event.count, event.stateMask, event.x, event.y);
+}
+
+boolean dragDetect (int button, int count, int stateMask, int x, int y) {
+	if (button != 1 || count != 1) return false;
+	if (!dragDetect (x, y, false, null)) return false;
+	return sendDragEvent (button, stateMask, x, y, true);
+}
+
+boolean dragDetect (int x, int y, boolean filter, boolean [] consume) {
+	boolean quit = false, dragging = false;
+	while (!quit) {
+		int /*long*/ eventPtr = 0;
+		while (true) {
+			eventPtr = OS.gdk_event_get ();
+			if (eventPtr != 0) {
+				break;
+			} else {
+				try {Thread.sleep(50);} catch (Exception ex) {}
+			}
+		}
+		switch (OS.GDK_EVENT_TYPE (eventPtr)) {
+			case OS.GDK_MOTION_NOTIFY: {
+				GdkEventMotion gdkMotionEvent = new GdkEventMotion ();
+				OS.memmove (gdkMotionEvent, eventPtr, GdkEventMotion.sizeof);
+				if ((gdkMotionEvent.state & OS.GDK_BUTTON1_MASK) != 0) {
+					if (OS.gtk_drag_check_threshold (handle, x, y, (int) gdkMotionEvent.x, (int) gdkMotionEvent.y)) {
+						dragging = true;
+						quit = true;
+					}
+				} else {
+					quit = true;
+				}
+				int [] newX = new int [1], newY = new int [1];
+				OS.gdk_window_get_pointer (gdkMotionEvent.window, newX, newY, null);
+				break;
+			}
+			case OS.GDK_KEY_PRESS:
+			case OS.GDK_KEY_RELEASE: {
+				GdkEventKey gdkEvent = new GdkEventKey ();
+				OS.memmove (gdkEvent, eventPtr, GdkEventKey.sizeof);
+				if (gdkEvent.keyval == OS.GDK_Escape) quit = true;
+				break;
+			}
+			case OS.GDK_BUTTON_RELEASE:
+			case OS.GDK_BUTTON_PRESS:
+			case OS.GDK_2BUTTON_PRESS:
+			case OS.GDK_3BUTTON_PRESS: {
+				OS.gdk_event_put (eventPtr);
+				quit = true;
+				break;
+			}
+			default:
+				OS.gtk_main_do_event (eventPtr);
+		}
+		OS.gdk_event_free (eventPtr);
+	}
+	return dragging;
+}
+
+boolean filterKey (int keyval, int /*long*/ event) {
+	int /*long*/ imHandle = imHandle ();
+	if (imHandle != 0) {
+		return OS.gtk_im_context_filter_keypress (imHandle, event);
+	}
+	return false;
+}
+
+Control findBackgroundControl () {
+	if ((state & BACKGROUND) != 0 || backgroundImage != null) return this;
+	return (state & PARENT_BACKGROUND) != 0 ? parent.findBackgroundControl () : null;
+}
+
+Menu [] findMenus (Control control) {
+	if (menu != null && this != control) return new Menu [] {menu};
+	return new Menu [0];
+}
+
+void fixChildren (Shell newShell, Shell oldShell, Decorations newDecorations, Decorations oldDecorations, Menu [] menus) {
+	oldShell.fixShell (newShell, this);
+	oldDecorations.fixDecorations (newDecorations, this, menus);
+}
+
+int /*long*/ fixedMapProc (int /*long*/ widget) {
+	OS.GTK_WIDGET_SET_FLAGS (widget, OS.GTK_MAPPED);
+	int /*long*/ widgetList = OS.gtk_container_get_children (widget);
+	if (widgetList != 0) {
+		int /*long*/ widgets = widgetList;
+		while (widgets != 0) {
+			int /*long*/ child = OS.g_list_data (widgets);
+			if (OS.GTK_WIDGET_VISIBLE (child) && OS.gtk_widget_get_child_visible (child) && !OS.GTK_WIDGET_MAPPED (child)) {
+				OS.gtk_widget_map (child);
+			}
+			widgets = OS.g_list_next (widgets);
+		}
+		OS.g_list_free (widgetList);
+	}
+	if ((OS.GTK_WIDGET_FLAGS (widget) & OS.GTK_NO_WINDOW) == 0) {
+		OS.gdk_window_show_unraised (OS.GTK_WIDGET_WINDOW (widget));
+	}
+	return 0;
+}
+
+void fixModal(int /*long*/ group, int /*long*/ modalGroup) {	
+}
+
+/**
+ * Forces the receiver to have the <em>keyboard focus</em>, causing
+ * all keyboard events to be delivered to it.
+ *
+ * @return <code>true</code> if the control got focus, and <code>false</code> if it was unable to.
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #setFocus
+ */
+public boolean forceFocus () {
+	checkWidget();
+	if (display.focusEvent == SWT.FocusOut) return false;
+	Shell shell = getShell ();
+	shell.setSavedFocus (this);
+	if (!isEnabled () || !isVisible ()) return false;
+	shell.bringToTop (false);
+	return forceFocus (focusHandle ());
+}
+
+boolean forceFocus (int /*long*/ focusHandle) {
+	/* When the control is zero sized it must be realized */
+	OS.gtk_widget_realize (focusHandle);
+	OS.gtk_widget_grab_focus (focusHandle);
+	Shell shell = getShell ();
+	int /*long*/ shellHandle = shell.shellHandle;
+	int /*long*/ handle = OS.gtk_window_get_focus (shellHandle);
+	while (handle != 0) {
+		if (handle == focusHandle) return true;
+		Widget widget = display.getWidget (handle);
+		if (widget != null && widget instanceof Control) {
+			return widget == this;
+		}
+		handle = OS.gtk_widget_get_parent (handle);
+	}
+	return false;
+}
+
+/**
+ * Returns the receiver's background color.
+ *
+ * @return the background color
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Color getBackground () {
+	checkWidget();
+	Control control = findBackgroundControl ();
+	if (control == null) control = this;
+	return Color.gtk_new (display, control.getBackgroundColor ());
+}
+
+GdkColor getBackgroundColor () {
+	return getBgColor ();
+}
+
+/**
+ * Returns the receiver's background image.
+ *
+ * @return the background image
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.2
+ */
+public Image getBackgroundImage () {
+	checkWidget ();
+	Control control = findBackgroundControl ();
+	if (control == null) control = this;
+	return control.backgroundImage;
+}
+
+GdkColor getBgColor () {
+	int /*long*/ fontHandle = fontHandle ();
+	OS.gtk_widget_realize (fontHandle);
+	GdkColor color = new GdkColor ();
+	OS.gtk_style_get_bg (OS.gtk_widget_get_style (fontHandle), OS.GTK_STATE_NORMAL, color);
+	return color;
+}
+
+GdkColor getBaseColor () {
+	int /*long*/ fontHandle = fontHandle ();
+	OS.gtk_widget_realize (fontHandle);
+	GdkColor color = new GdkColor ();
+	OS.gtk_style_get_base (OS.gtk_widget_get_style (fontHandle), OS.GTK_STATE_NORMAL, color);
+	return color;
+}
+
+/**
+ * Returns the receiver's border width.
+ *
+ * @return the border width
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getBorderWidth () {
+	checkWidget();
+	return 0;
+}
+
+int getClientWidth () {
+	return 0;
+}
+
+/**
+ * Returns the receiver's cursor, or null if it has not been set.
+ * <p>
+ * When the mouse pointer passes over a control its appearance
+ * is changed to match the control's cursor.
+ * </p>
+ *
+ * @return the receiver's cursor or <code>null</code>
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.3
+ */
+public Cursor getCursor () {
+	checkWidget ();
+	return cursor;
+}
+
+/**
+ * Returns <code>true</code> if the receiver is detecting
+ * drag gestures, and  <code>false</code> otherwise. 
+ *
+ * @return the receiver's drag detect state
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.3
+ */
+public boolean getDragDetect () {
+	checkWidget ();
+	return (state & DRAG_DETECT) != 0;
+}
+
+/**
+ * Returns <code>true</code> if the receiver is enabled, and
+ * <code>false</code> otherwise. A disabled control is typically
+ * not selectable from the user interface and draws with an
+ * inactive or "grayed" look.
+ *
+ * @return the receiver's enabled state
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see #isEnabled
+ */
+public boolean getEnabled () {
+	checkWidget ();
+	return (state & DISABLED) == 0;
+}
+
+/**
+ * Returns the font that the receiver will use to paint textual information.
+ *
+ * @return the receiver's font
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Font getFont () {
+	checkWidget();
+	return font != null ? font : defaultFont ();
+}
+	
+int /*long*/ getFontDescription () {
+	int /*long*/ fontHandle = fontHandle ();
+	OS.gtk_widget_realize (fontHandle);
+	return OS.gtk_style_get_font_desc (OS.gtk_widget_get_style (fontHandle));
+}
+
+/**
+ * Returns the foreground color that the receiver will use to draw.
+ *
+ * @return the receiver's foreground color
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Color getForeground () {
+	checkWidget();
+	return Color.gtk_new (display, getForegroundColor ());
+}
+
+GdkColor getForegroundColor () {
+	return getFgColor ();
+}
+
+GdkColor getFgColor () {
+	int /*long*/ fontHandle = fontHandle ();
+	OS.gtk_widget_realize (fontHandle);
+	GdkColor color = new GdkColor ();
+	OS.gtk_style_get_fg (OS.gtk_widget_get_style (fontHandle), OS.GTK_STATE_NORMAL, color);
+	return color;
+}
+
+Point getIMCaretPos () {
+	return new Point (0, 0);
+}
+
+GdkColor getTextColor () {
+	int /*long*/ fontHandle = fontHandle ();
+	OS.gtk_widget_realize (fontHandle);
+	GdkColor color = new GdkColor ();
+	OS.gtk_style_get_text (OS.gtk_widget_get_style (fontHandle), OS.GTK_STATE_NORMAL, color);
+	return color;
+}
+
+/**
+ * Returns layout data which is associated with the receiver.
+ *
+ * @return the receiver's layout data
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Object getLayoutData () {
+	checkWidget();
+	return layoutData;
+}
+
+/**
+ * Returns the receiver's pop up menu if it has one, or null
+ * if it does not. All controls may optionally have a pop up
+ * menu that is displayed when the user requests one for
+ * the control. The sequence of key strokes, button presses
+ * and/or button releases that are used to request a pop up
+ * menu is platform specific.
+ *
+ * @return the receiver's menu
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Menu getMenu () {
+	checkWidget();
+	return menu;
+}
+
+/**
+ * Returns the receiver's monitor.
+ * 
+ * @return the receiver's monitor
+ * 
+ * @since 3.0
+ */
+public Monitor getMonitor () {
+	checkWidget();
+	Monitor monitor = null;
+	int /*long*/ screen = OS.gdk_screen_get_default ();
+	if (screen != 0) {
+		int monitorNumber = OS.gdk_screen_get_monitor_at_window (screen, paintWindow ());
+		GdkRectangle dest = new GdkRectangle ();
+		OS.gdk_screen_get_monitor_geometry (screen, monitorNumber, dest);
+		monitor = new Monitor ();
+		monitor.handle = monitorNumber;
+		monitor.x = dest.x;
+		monitor.y = dest.y;
+		monitor.width = dest.width;
+		monitor.height = dest.height;
+		Rectangle workArea = null;
+		if (monitorNumber == 0) workArea = display.getWorkArea ();
+		if (workArea != null) {
+			monitor.clientX = workArea.x;
+			monitor.clientY = workArea.y;
+			monitor.clientWidth = workArea.width;
+			monitor.clientHeight = workArea.height;
+		} else {
+			monitor.clientX = monitor.x;
+			monitor.clientY = monitor.y;
+			monitor.clientWidth = monitor.width;
+			monitor.clientHeight = monitor.height;
+		}
+	} else {
+		monitor = display.getPrimaryMonitor ();
+	}
+	return monitor;
+}
+
+/**
+ * Returns the receiver's parent, which must be a <code>Composite</code>
+ * or null when the receiver is a shell that was created with null or
+ * a display for a parent.
+ *
+ * @return the receiver's parent
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Composite getParent () {
+	checkWidget();
+	return parent;
+}
+
+Control [] getPath () {
+	int count = 0;
+	Shell shell = getShell ();
+	Control control = this;
+	while (control != shell) {
+		count++;
+		control = control.parent;
+	}
+	control = this;
+	Control [] result = new Control [count];
+	while (control != shell) {
+		result [--count] = control;
+		control = control.parent;
+	}
+	return result;
+}
+
+/** 
+ * Returns the region that defines the shape of the control,
+ * or null if the control has the default shape.
+ *
+ * @return the region that defines the shape of the shell (or null)
+ *	
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 3.4
+ */
+public Region getRegion () {
+	checkWidget ();
+	return region;
+}
+
+/**
+ * Returns the receiver's shell. For all controls other than
+ * shells, this simply returns the control's nearest ancestor
+ * shell. Shells return themselves, even if they are children
+ * of other shells.
+ *
+ * @return the receiver's shell
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #getParent
+ */
+public Shell getShell() {
+	checkWidget();
+	return _getShell();
+}
+
+Shell _getShell() {
+	return parent._getShell();
+}
+
+/**
+ * Returns the receiver's tool tip text, or null if it has
+ * not been set.
+ *
+ * @return the receiver's tool tip text
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public String getToolTipText () {
+	checkWidget();
+	return toolTipText;
+}
+/**
+ * Returns <code>true</code> if the receiver is visible, and
+ * <code>false</code> otherwise.
+ * <p>
+ * If one of the receiver's ancestors is not visible or some
+ * other condition makes the receiver not visible, this method
+ * may still indicate that it is considered visible even though
+ * it may not actually be showing.
+ * </p>
+ *
+ * @return the receiver's visibility state
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public boolean getVisible () {
+	checkWidget();
+	return (state & HIDDEN) == 0;
+}
+
+int /*long*/ gtk_button_press_event (int /*long*/ widget, int /*long*/ event) {
+	return gtk_button_press_event (widget, event, true);
+}
+
+int /*long*/ gtk_button_press_event (int /*long*/ widget, int /*long*/ event, boolean sendMouseDown) {
+	GdkEventButton gdkEvent = new GdkEventButton ();
+	OS.memmove (gdkEvent, event, GdkEventButton.sizeof);
+	if (gdkEvent.type == OS.GDK_3BUTTON_PRESS) return 0;
+	
+	/*
+	* When a shell is created with SWT.ON_TOP and SWT.NO_FOCUS,
+	* do not activate the shell when the user clicks on the
+	* the client area or on the border or a control within the
+	* shell that does not take focus.
+	*/
+	Shell shell = _getShell ();
+	if (((shell.style & SWT.ON_TOP) != 0) && (((shell.style & SWT.NO_FOCUS) == 0) || ((style & SWT.NO_FOCUS) == 0))) {
+		shell.forceActive();
+	}
+	int /*long*/ result = 0;
+	if (gdkEvent.type == OS.GDK_BUTTON_PRESS) {
+		display.clickCount = 1;
+		int /*long*/ nextEvent = OS.gdk_event_peek ();
+		if (nextEvent != 0) {
+			int eventType = OS.GDK_EVENT_TYPE (nextEvent);
+			if (eventType == OS.GDK_2BUTTON_PRESS) display.clickCount = 2;
+			if (eventType == OS.GDK_3BUTTON_PRESS) display.clickCount = 3;
+			OS.gdk_event_free (nextEvent);
+		}
+		boolean dragging = false;
+		if ((state & DRAG_DETECT) != 0 && hooks (SWT.DragDetect)) {
+			if (gdkEvent.button == 1) {
+				boolean [] consume = new boolean [1];
+				if (dragDetect ((int) gdkEvent.x, (int) gdkEvent.y, true, consume)) {
+					dragging = true;
+					if (consume [0]) result = 1;
+				}
+				if (isDisposed ()) return 1;
+			}
+		}
+		if (sendMouseDown && !sendMouseEvent (SWT.MouseDown, gdkEvent.button, display.clickCount, 0, false, gdkEvent.time, gdkEvent.x_root, gdkEvent.y_root, false, gdkEvent.state)) {
+			result = 1;
+		}
+		if (isDisposed ()) return 1;
+		if (dragging) {
+			sendDragEvent (gdkEvent.button, gdkEvent.state, (int) gdkEvent.x, (int) gdkEvent.y, false);
+			if (isDisposed ()) return 1;
+		}
+		/*
+		* Pop up the context menu in the button press event for widgets
+		* that have default operating system menus in order to stop the
+		* operating system from displaying the menu if necessary.
+		*/
+		if ((state & MENU) != 0) {
+			if (gdkEvent.button == 3) {
+				if (showMenu ((int)gdkEvent.x_root, (int)gdkEvent.y_root)) {
+					result = 1;
+				}
+			}
+		}
+	} else {
+		display.clickCount = 2;
+		result = sendMouseEvent (SWT.MouseDoubleClick, gdkEvent.button, display.clickCount, 0, false, gdkEvent.time, gdkEvent.x_root, gdkEvent.y_root, false, gdkEvent.state) ? 0 : 1;
+		if (isDisposed ()) return 1;
+	}
+	if (!shell.isDisposed ()) shell.setActiveControl (this);
+	return result;
+}
+
+int /*long*/ gtk_button_release_event (int /*long*/ widget, int /*long*/ event) {
+	GdkEventButton gdkEvent = new GdkEventButton ();
+	OS.memmove (gdkEvent, event, GdkEventButton.sizeof);
+	/*
+	* Feature in GTK.  When button 4, 5, 6, or 7 is released, GTK
+	* does not deliver a corresponding GTK event.  Button 6 and 7
+	* are mapped to buttons 4 and 5 in SWT.  The fix is to change
+	* the button number of the event to a negative number so that
+	* it gets dispatched by GTK.  SWT has been modified to look
+	* for negative button numbers.
+	*/
+	int button = gdkEvent.button;
+	switch (button) {
+		case -6: button = 4; break;
+		case -7: button = 5; break;
+	}
+	return sendMouseEvent (SWT.MouseUp, button, display.clickCount, 0, false, gdkEvent.time, gdkEvent.x_root, gdkEvent.y_root, false, gdkEvent.state) ? 0 : 1;
+}
+
+int /*long*/ gtk_commit (int /*long*/ imcontext, int /*long*/ text) {
+	if (text == 0) return 0;
+	int length = OS.strlen (text);
+	if (length == 0) return 0;
+	byte [] buffer = new byte [length];
+	OS.memmove (buffer, text, length);
+	char [] chars = Converter.mbcsToWcs (null, buffer);
+	sendIMKeyEvent (SWT.KeyDown, null, chars);
+	return 0;
+}
+
+int /*long*/ gtk_enter_notify_event (int /*long*/ widget, int /*long*/ event) {
+	if (OS.GTK_VERSION >= OS.VERSION (2, 12, 0)) {
+		/*
+		 * Feature in GTK. Children of a shell will inherit and display the shell's
+		 * tooltip if they do not have a tooltip of their own. The fix is to use the
+		 * new tooltip API in GTK 2.12 to null the shell's tooltip when the control
+		 * being entered does not have any tooltip text set. 
+		 */
+		byte [] buffer = null;
+		if (toolTipText != null && toolTipText.length() != 0) { 
+			char [] chars = fixMnemonic (toolTipText, false);
+			buffer = Converter.wcsToMbcs (null, chars, true);
+		}
+		int /*long*/ toolHandle = getShell().handle;
+		OS.gtk_widget_set_tooltip_text (toolHandle, buffer);
+	}
+	if (display.currentControl == this) return 0;
+	GdkEventCrossing gdkEvent = new GdkEventCrossing ();
+	OS.memmove (gdkEvent, event, GdkEventCrossing.sizeof);
+	if (gdkEvent.mode != OS.GDK_CROSSING_NORMAL && gdkEvent.mode != OS.GDK_CROSSING_UNGRAB) return 0;
+	if ((gdkEvent.state & (OS.GDK_BUTTON1_MASK | OS.GDK_BUTTON2_MASK | OS.GDK_BUTTON3_MASK)) != 0) return 0;
+	if (display.currentControl != null && !display.currentControl.isDisposed ()) {
+		display.removeMouseHoverTimeout (display.currentControl.handle);
+		display.currentControl.sendMouseEvent (SWT.MouseExit,  0, gdkEvent.time, gdkEvent.x_root, gdkEvent.y_root, false, gdkEvent.state);
+	}
+	if (!isDisposed ()) {
+		display.currentControl = this;
+		return sendMouseEvent (SWT.MouseEnter, 0, gdkEvent.time, gdkEvent.x_root, gdkEvent.y_root, false, gdkEvent.state) ? 0 : 1;
+	}
+	return 0;
+}
+
+int /*long*/ gtk_event_after (int /*long*/ widget, int /*long*/ gdkEvent) {
+	GdkEvent event = new GdkEvent ();
+	OS.memmove (event, gdkEvent, GdkEvent.sizeof);
+	switch (event.type) {
+		case OS.GDK_BUTTON_PRESS: {
+			if (widget != eventHandle ()) break;
+			/*
+			* Pop up the context menu in the event_after signal to allow
+			* the widget to process the button press.  This allows widgets
+			* such as GtkTreeView to select items before a menu is shown.
+			*/
+			if ((state & MENU) == 0) {
+				GdkEventButton gdkEventButton = new GdkEventButton ();
+				OS.memmove (gdkEventButton, gdkEvent, GdkEventButton.sizeof);
+				if (gdkEventButton.button == 3) {
+					showMenu ((int) gdkEventButton.x_root, (int) gdkEventButton.y_root);
+				}
+			}
+			break;
+		}
+		case OS.GDK_FOCUS_CHANGE: {
+			if (!isFocusHandle (widget)) break;
+			GdkEventFocus gdkEventFocus = new GdkEventFocus ();
+			OS.memmove (gdkEventFocus, gdkEvent, GdkEventFocus.sizeof);
+
+			/*
+			 * Feature in GTK. The GTK combo box popup under some window managers
+			 * is implemented as a GTK_MENU.  When it pops up, it causes the combo
+			 * box to lose focus when focus is received for the menu.  The
+			 * fix is to check the current grab handle and see if it is a GTK_MENU
+			 * and ignore the focus event when the menu is both shown and hidden.
+			 */
+			Display display = this.display;
+			if (gdkEventFocus.in != 0) {
+				if (display.ignoreFocus) { 
+					display.ignoreFocus = false;
+					break;
+				}
+			} else {
+				display.ignoreFocus = false;
+				int /*long*/ grabHandle = OS.gtk_grab_get_current ();
+				if (grabHandle != 0) {
+					if (OS.G_OBJECT_TYPE (grabHandle) == OS.GTK_TYPE_MENU ()) {
+						display.ignoreFocus = true;
+						break;
+					}
+				}
+			}
+
+			sendFocusEvent (gdkEventFocus.in != 0 ? SWT.FocusIn : SWT.FocusOut);
+			break;
+		}
+	}
+	return 0;
+}
+
+int /*long*/ gtk_expose_event (int /*long*/ widget, int /*long*/ eventPtr) {
+	if ((state & OBSCURED) != 0) return 0;
+	if (!hooks (SWT.Paint) && !filters (SWT.Paint)) return 0;
+	GdkEventExpose gdkEvent = new GdkEventExpose ();
+	OS.memmove(gdkEvent, eventPtr, GdkEventExpose.sizeof);
+	Event event = new Event ();
+	event.count = gdkEvent.count;
+	event.x = gdkEvent.area_x;
+	event.y = gdkEvent.area_y;
+	event.width = gdkEvent.area_width;
+	event.height = gdkEvent.area_height;
+	if ((style & SWT.MIRRORED) != 0) event.x = getClientWidth () - event.width - event.x;
+	GCData data = new GCData ();
+	data.damageRgn = gdkEvent.region;
+	GC gc = event.gc = GC.gtk_new (this, data);
+	OS.gdk_gc_set_clip_region (gc.handle, gdkEvent.region);
+	sendEvent (SWT.Paint, event);
+	gc.dispose ();
+	event.gc = null;
+	return 0;
+}
+
+int /*long*/ gtk_focus (int /*long*/ widget, int /*long*/ directionType) {
+	/* Stop GTK traversal for every widget */
+	return 1;
+}
+
+int /*long*/ gtk_focus_in_event (int /*long*/ widget, int /*long*/ event) {
+	// widget could be disposed at this point
+	if (handle != 0) {
+		Control oldControl = display.imControl;
+		if (oldControl != this)  {
+			if (oldControl != null && !oldControl.isDisposed ()) {
+				int /*long*/ oldIMHandle = oldControl.imHandle ();
+				if (oldIMHandle != 0) OS.gtk_im_context_reset (oldIMHandle);
+			}
+		}
+		if (hooks (SWT.KeyDown) || hooks (SWT.KeyUp)) {
+			int /*long*/ imHandle = imHandle ();
+			if (imHandle != 0) OS.gtk_im_context_focus_in (imHandle);
+		}
+	}
+	return 0;
+}
+
+int /*long*/ gtk_focus_out_event (int /*long*/ widget, int /*long*/ event) {
+	// widget could be disposed at this point
+	if (handle != 0) {
+		if (hooks (SWT.KeyDown) || hooks (SWT.KeyUp)) {
+			int /*long*/ imHandle = imHandle ();
+			if (imHandle != 0) {
+				OS.gtk_im_context_focus_out (imHandle);
+			}
+		}
+	}
+	return 0;
+}
+
+int /*long*/ gtk_key_press_event (int /*long*/ widget, int /*long*/ event) {
+	if (!hasFocus ()) return 0;
+	GdkEventKey gdkEvent = new GdkEventKey ();
+	OS.memmove (gdkEvent, event, GdkEventKey.sizeof);
+	
+	if (translateMnemonic (gdkEvent.keyval, gdkEvent)) return 1;
+	// widget could be disposed at this point
+	if (isDisposed ()) return 0;
+	
+	if (filterKey (gdkEvent.keyval, event)) return 1;
+	// widget could be disposed at this point
+	if (isDisposed ()) return 0;	
+	
+	if (translateTraversal (gdkEvent)) return 1;
+	// widget could be disposed at this point
+	if (isDisposed ()) return 0;
+	return super.gtk_key_press_event (widget, event);
+}
+
+int /*long*/ gtk_key_release_event (int /*long*/ widget, int /*long*/ event) {
+	if (!hasFocus ()) return 0;
+	int /*long*/ imHandle = imHandle ();
+	if (imHandle != 0) {
+		if (OS.gtk_im_context_filter_keypress (imHandle, event)) return 1;
+	}
+	return super.gtk_key_release_event (widget, event);
+}
+
+int /*long*/ gtk_leave_notify_event (int /*long*/ widget, int /*long*/ event) {
+	if (display.currentControl != this) return 0;
+	display.removeMouseHoverTimeout (handle);
+	int result = 0;
+	if (sendLeaveNotify () || display.getCursorControl () == null) {
+		GdkEventCrossing gdkEvent = new GdkEventCrossing ();
+		OS.memmove (gdkEvent, event, GdkEventCrossing.sizeof);
+		if (gdkEvent.mode != OS.GDK_CROSSING_NORMAL && gdkEvent.mode != OS.GDK_CROSSING_UNGRAB) return 0;
+		if ((gdkEvent.state & (OS.GDK_BUTTON1_MASK | OS.GDK_BUTTON2_MASK | OS.GDK_BUTTON3_MASK)) != 0) return 0;
+		result = sendMouseEvent (SWT.MouseExit, 0, gdkEvent.time, gdkEvent.x_root, gdkEvent.y_root, false, gdkEvent.state) ? 0 : 1;
+		display.currentControl = null;
+	}
+	return result;
+}
+
+int /*long*/ gtk_mnemonic_activate (int /*long*/ widget, int /*long*/ arg1) {
+	int result = 0;
+	int /*long*/ eventPtr = OS.gtk_get_current_event ();
+	if (eventPtr != 0) {
+		GdkEventKey keyEvent = new GdkEventKey ();
+		OS.memmove (keyEvent, eventPtr, GdkEventKey.sizeof);
+		if (keyEvent.type == OS.GDK_KEY_PRESS) {
+			Control focusControl = display.getFocusControl ();
+			int /*long*/ focusHandle = focusControl != null ? focusControl.focusHandle () : 0;
+			if (focusHandle != 0) {
+				display.mnemonicControl = this;
+				OS.gtk_widget_event (focusHandle, eventPtr);
+				display.mnemonicControl = null;
+			}
+			result = 1;
+		}
+		OS.gdk_event_free (eventPtr);
+	}
+	return result;
+}
+
+int /*long*/ gtk_motion_notify_event (int /*long*/ widget, int /*long*/ event) {
+	GdkEventMotion gdkEvent = new GdkEventMotion ();
+	OS.memmove (gdkEvent, event, GdkEventMotion.sizeof);
+	if (this == display.currentControl && (hooks (SWT.MouseHover) || filters (SWT.MouseHover))) {
+		display.addMouseHoverTimeout (handle);
+	}
+	double x = gdkEvent.x_root, y = gdkEvent.y_root;
+	int state = gdkEvent.state;
+	if (gdkEvent.is_hint != 0) {
+		int [] pointer_x = new int [1], pointer_y = new int [1], mask = new int [1];
+		int /*long*/ window = eventWindow ();
+		OS.gdk_window_get_pointer (window, pointer_x, pointer_y, mask);
+		x = pointer_x [0];
+		y = pointer_y [0];
+		state = mask [0];
+	}
+	int result = sendMouseEvent (SWT.MouseMove, 0, gdkEvent.time, x, y, gdkEvent.is_hint != 0, state) ? 0 : 1;
+	return result;
+}
+
+int /*long*/ gtk_popup_menu (int /*long*/ widget) {
+	if (!hasFocus()) return 0;
+	int [] x = new int [1], y = new int [1];
+	OS.gdk_window_get_pointer (0, x, y, null);
+	return showMenu (x [0], y [0]) ? 1 : 0;
+}
+
+int /*long*/ gtk_preedit_changed (int /*long*/ imcontext) {
+	display.showIMWindow (this);
+	return 0;
+}
+
+int /*long*/ gtk_realize (int /*long*/ widget) {
+	int /*long*/ imHandle = imHandle ();
+	if (imHandle != 0) {
+		int /*long*/ window = OS.GTK_WIDGET_WINDOW (paintHandle ());
+		OS.gtk_im_context_set_client_window (imHandle, window);
+	}
+	if (backgroundImage != null) {
+		int /*long*/ window = OS.GTK_WIDGET_WINDOW (paintHandle ());
+		if (window != 0) OS.gdk_window_set_back_pixmap (window, backgroundImage.pixmap, false);
+	}
+	return 0;
+}
+
+int /*long*/ gtk_scroll_event (int /*long*/ widget, int /*long*/ eventPtr) {
+	GdkEventScroll gdkEvent = new GdkEventScroll ();
+	OS.memmove (gdkEvent, eventPtr, GdkEventScroll.sizeof);
+	switch (gdkEvent.direction) {
+		case OS.GDK_SCROLL_UP:
+			return sendMouseEvent (SWT.MouseWheel, 0, 3, SWT.SCROLL_LINE, true, gdkEvent.time, gdkEvent.x_root, gdkEvent.y_root, false, gdkEvent.state) ? 0 : 1;
+		case OS.GDK_SCROLL_DOWN:
+			return sendMouseEvent (SWT.MouseWheel, 0, -3, SWT.SCROLL_LINE, true, gdkEvent.time, gdkEvent.x_root, gdkEvent.y_root, false, gdkEvent.state) ? 0 : 1;
+		case OS.GDK_SCROLL_LEFT:
+			return sendMouseEvent (SWT.MouseDown, 4, gdkEvent.time, gdkEvent.x_root, gdkEvent.y_root, false, gdkEvent.state) ? 0 : 1;
+		case OS.GDK_SCROLL_RIGHT:
+			return sendMouseEvent (SWT.MouseDown, 5, gdkEvent.time, gdkEvent.x_root, gdkEvent.y_root, false, gdkEvent.state) ? 0 : 1;
+	}
+	return 0;
+}
+
+int /*long*/ gtk_show_help (int /*long*/ widget, int /*long*/ helpType) {
+	if (!hasFocus ()) return 0;
+	return sendHelpEvent (helpType) ? 1 : 0;
+}
+
+int /*long*/ gtk_style_set (int /*long*/ widget, int /*long*/ previousStyle) {
+	if (backgroundImage != null) {
+		setBackgroundPixmap (backgroundImage.pixmap);
+	}
+	return 0;
+}
+
+int /*long*/ gtk_unrealize (int /*long*/ widget) {
+	int /*long*/ imHandle = imHandle ();
+	if (imHandle != 0) OS.gtk_im_context_set_client_window (imHandle, 0);
+	return 0;	
+}
+
+int /*long*/ gtk_visibility_notify_event (int /*long*/ widget, int /*long*/ event) {
+	GdkEventVisibility gdkEvent = new GdkEventVisibility ();
+	OS.memmove (gdkEvent, event, GdkEventVisibility.sizeof);
+	int /*long*/ paintWindow = paintWindow();
+	int /*long*/ window = gdkEvent.window;
+	if (window == paintWindow) {
+		if (gdkEvent.state == OS.GDK_VISIBILITY_FULLY_OBSCURED) {
+			state |= OBSCURED;
+		} else {
+			if ((state & OBSCURED) != 0) {		
+				int [] width = new int [1], height = new int [1];
+				OS.gdk_drawable_get_size (window, width, height);
+				GdkRectangle rect = new GdkRectangle ();
+				rect.width = width [0];
+				rect.height = height [0];
+				OS.gdk_window_invalidate_rect (window, rect, false);
+			}
+			state &= ~OBSCURED;
+		}
+	}
+	return 0;
+}
+
+void gtk_widget_size_request (int /*long*/ widget, GtkRequisition requisition) {
+	OS.gtk_widget_size_request (widget, requisition);	
+}
+
+/**	 
+ * Invokes platform specific functionality to allocate a new GC handle.
+ * <p>
+ * <b>IMPORTANT:</b> This method is <em>not</em> part of the public
+ * API for <code>Control</code>. It is marked public only so that it
+ * can be shared within the packages provided by SWT. It is not
+ * available on all platforms, and should never be called from
+ * application code.
+ * </p>
+ *
+ * @param data the platform specific GC data 
+ * @return the platform specific GC handle
+ */
+public int /*long*/ internal_new_GC (GCData data) {
+	checkWidget ();
+	int /*long*/ window = paintWindow ();
+	if (window == 0) SWT.error (SWT.ERROR_NO_HANDLES);
+	int /*long*/ gdkGC = OS.gdk_gc_new (window);
+	if (gdkGC == 0) error (SWT.ERROR_NO_HANDLES);	
+	if (data != null) {
+		int mask = SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT;
+		if ((data.style & mask) == 0) {
+			data.style |= style & (mask | SWT.MIRRORED);
+		} else {
+			if ((data.style & SWT.RIGHT_TO_LEFT) != 0) {
+				data.style |= SWT.MIRRORED;
+			}
+		}
+		data.drawable = window;
+		data.device = display;
+		data.foreground = getForegroundColor ();
+		Control control = findBackgroundControl ();
+		if (control == null) control = this;
+		data.background = control.getBackgroundColor ();
+		data.font = font != null ? font : defaultFont (); 
+	}	
+	return gdkGC;
+}
+
+int /*long*/ imHandle () {
+	return 0;
+}
+
+/**	 
+ * Invokes platform specific functionality to dispose a GC handle.
+ * <p>
+ * <b>IMPORTANT:</b> This method is <em>not</em> part of the public
+ * API for <code>Control</code>. It is marked public only so that it
+ * can be shared within the packages provided by SWT. It is not
+ * available on all platforms, and should never be called from
+ * application code.
+ * </p>
+ *
+ * @param hDC the platform specific GC handle
+ * @param data the platform specific GC data 
+ */
+public void internal_dispose_GC (int /*long*/ gdkGC, GCData data) {
+	checkWidget ();
+	OS.g_object_unref (gdkGC);
+}
+
+/**
+ * Returns <code>true</code> if the underlying operating
+ * system supports this reparenting, otherwise <code>false</code>
+ *
+ * @return <code>true</code> if the widget can be reparented, otherwise <code>false</code>
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public boolean isReparentable () {
+	checkWidget();
+	return true;
+}
+boolean isShowing () {
+	/*
+	* This is not complete.  Need to check if the
+	* widget is obscurred by a parent or sibling.
+	*/
+	if (!isVisible ()) return false;
+	Control control = this;
+	while (control != null) {
+		Point size = control.getSize ();
+		if (size.x == 0 || size.y == 0) {
+			return false;
+		}
+		control = control.parent;
+	}
+	return true;
+}
+boolean isTabGroup () {
+	Control [] tabList = parent._getTabList ();
+	if (tabList != null) {
+		for (int i=0; i<tabList.length; i++) {
+			if (tabList [i] == this) return true;
+		}
+	}
+	int code = traversalCode (0, null);
+	if ((code & (SWT.TRAVERSE_ARROW_PREVIOUS | SWT.TRAVERSE_ARROW_NEXT)) != 0) return false;
+	return (code & (SWT.TRAVERSE_TAB_PREVIOUS | SWT.TRAVERSE_TAB_NEXT)) != 0;
+}
+boolean isTabItem () {
+	Control [] tabList = parent._getTabList ();
+	if (tabList != null) {
+		for (int i=0; i<tabList.length; i++) {
+			if (tabList [i] == this) return false;
+		}
+	}
+	int code = traversalCode (0, null);
+	return (code & (SWT.TRAVERSE_ARROW_PREVIOUS | SWT.TRAVERSE_ARROW_NEXT)) != 0;
+}
+
+/**
+ * Returns <code>true</code> if the receiver is enabled and all
+ * ancestors up to and including the receiver's nearest ancestor
+ * shell are enabled.  Otherwise, <code>false</code> is returned.
+ * A disabled control is typically not selectable from the user
+ * interface and draws with an inactive or "grayed" look.
+ *
+ * @return the receiver's enabled state
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see #getEnabled
+ */
+public boolean isEnabled () {
+	checkWidget ();
+	return getEnabled () && parent.isEnabled ();
+}
+
+boolean isFocusAncestor (Control control) {
+	while (control != null && control != this && !(control instanceof Shell)) {
+		control = control.parent;
+	}
+	return control == this;
+}
+
+/**
+ * Returns <code>true</code> if the receiver has the user-interface
+ * focus, and <code>false</code> otherwise.
+ *
+ * @return the receiver's focus state
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public boolean isFocusControl () {
+	checkWidget();
+	Control focusControl = display.focusControl;
+	if (focusControl != null && !focusControl.isDisposed ()) {
+		return this == focusControl;
+	}
+	return hasFocus ();
+}
+
+/**
+ * Returns <code>true</code> if the receiver is visible and all
+ * ancestors up to and including the receiver's nearest ancestor
+ * shell are visible. Otherwise, <code>false</code> is returned.
+ *
+ * @return the receiver's visibility state
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #getVisible
+ */
+public boolean isVisible () {
+	checkWidget();
+	return getVisible () && parent.isVisible ();
+}
+
+Decorations menuShell () {
+	return parent.menuShell ();
+}
+
+boolean mnemonicHit (char key) {
+	return false;
+}
+
+boolean mnemonicMatch (char key) {
+	return false;
+}
+
+void register () {
+	super.register ();
+	if (fixedHandle != 0) display.addWidget (fixedHandle, this);
+	int /*long*/ imHandle = imHandle ();
+	if (imHandle != 0) display.addWidget (imHandle, this);
+}
+
+/**
+ * Causes the entire bounds of the receiver to be marked
+ * as needing to be redrawn. The next time a paint request
+ * is processed, the control will be completely painted,
+ * including the background.
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #update()
+ * @see PaintListener
+ * @see SWT#Paint
+ * @see SWT#NO_BACKGROUND
+ * @see SWT#NO_REDRAW_RESIZE
+ * @see SWT#NO_MERGE_PAINTS
+ * @see SWT#DOUBLE_BUFFERED
+ */
+public void redraw () {
+	checkWidget();
+	redraw (false);
+}
+
+void redraw (boolean all) {
+//	checkWidget();
+	if (!OS.GTK_WIDGET_VISIBLE (topHandle ())) return;
+	redrawWidget (0, 0, 0, 0, true, all, false);
+}
+
+/**
+ * Causes the rectangular area of the receiver specified by
+ * the arguments to be marked as needing to be redrawn. 
+ * The next time a paint request is processed, that area of
+ * the receiver will be painted, including the background.
+ * If the <code>all</code> flag is <code>true</code>, any
+ * children of the receiver which intersect with the specified
+ * area will also paint their intersecting areas. If the
+ * <code>all</code> flag is <code>false</code>, the children
+ * will not be painted.
+ *
+ * @param x the x coordinate of the area to draw
+ * @param y the y coordinate of the area to draw
+ * @param width the width of the area to draw
+ * @param height the height of the area to draw
+ * @param all <code>true</code> if children should redraw, and <code>false</code> otherwise
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #update()
+ * @see PaintListener
+ * @see SWT#Paint
+ * @see SWT#NO_BACKGROUND
+ * @see SWT#NO_REDRAW_RESIZE
+ * @see SWT#NO_MERGE_PAINTS
+ * @see SWT#DOUBLE_BUFFERED
+ */
+public void redraw (int x, int y, int width, int height, boolean all) {
+	checkWidget();
+	if (!OS.GTK_WIDGET_VISIBLE (topHandle ())) return;
+	if ((style & SWT.MIRRORED) != 0) x = getClientWidth () - width - x;
+	redrawWidget (x, y, width, height, false, all, false);
+}
+
+void redrawChildren () {
+}
+
+void redrawWidget (int x, int y, int width, int height, boolean redrawAll, boolean all, boolean trim) {
+	if ((OS.GTK_WIDGET_FLAGS (handle) & OS.GTK_REALIZED) == 0) return;
+	int /*long*/ window = paintWindow ();
+	GdkRectangle rect = new GdkRectangle ();
+	if (redrawAll) {
+		int [] w = new int [1], h = new int [1];
+		OS.gdk_drawable_get_size (window, w, h);
+		rect.width = w [0];
+		rect.height = h [0];
+	} else {
+		rect.x = x;
+		rect.y = y;
+		rect.width = width;
+		rect.height = height;
+	}
+	OS.gdk_window_invalidate_rect (window, rect, all);
+}
+
+void release (boolean destroy) {
+	Control next = null, previous = null;
+	if (destroy && parent != null) {
+		Control[] children = parent._getChildren ();
+		int index = 0;
+		while (index < children.length) {
+			if (children [index] == this) break;
+			index++;
+		}
+		if (0 < index && (index + 1) < children.length) {
+			next = children [index + 1];
+			previous = children [index - 1];
+		}
+	}
+	super.release (destroy);
+	if (destroy) {
+		if (previous != null) previous.addRelation (next);
+	}
+}
+
+void releaseHandle () {
+	super.releaseHandle ();
+	fixedHandle = 0;
+	parent = null;
+}
+
+void releaseParent () {
+	parent.removeControl (this);
+}
+
+void releaseWidget () {
+	super.releaseWidget ();
+	if (display.currentControl == this) display.currentControl = null;
+	display.removeMouseHoverTimeout (handle);
+	int /*long*/ imHandle = imHandle ();
+	if (imHandle != 0) {
+		OS.gtk_im_context_reset (imHandle);
+		OS.gtk_im_context_set_client_window (imHandle, 0);
+	}
+	if (enableWindow != 0) {
+		OS.gdk_window_set_user_data (enableWindow, 0);
+		OS.gdk_window_destroy (enableWindow);
+		enableWindow = 0;
+	}
+	redrawWindow = 0;
+	if (menu != null && !menu.isDisposed ()) {
+		menu.dispose ();
+	}
+	menu = null;
+	cursor = null;
+	toolTipText = null;
+	layoutData = null;
+	accessible = null;
+	region = null;
+}
+
+boolean sendDragEvent (int button, int stateMask, int x, int y, boolean isStateMask) {
+	Event event = new Event ();
+	event.button = button;
+	event.x = x;
+	event.y = y;
+	if ((style & SWT.MIRRORED) != 0) event.x = getClientWidth () - event.x;
+	if (isStateMask) {
+		event.stateMask = stateMask;
+	} else {
+		setInputState (event, stateMask);
+	}
+	postEvent (SWT.DragDetect, event);
+	if (isDisposed ()) return false;
+	return event.doit;
+}
+
+void sendFocusEvent (int type) {
+	Shell shell = _getShell ();
+	Display display = this.display;
+	display.focusControl = this;
+	display.focusEvent = type;
+	sendEvent (type);
+	display.focusControl = null;
+	display.focusEvent = SWT.None;
+	/*
+	* It is possible that the shell may be
+	* disposed at this point.  If this happens
+	* don't send the activate and deactivate
+	* events.
+	*/
+	if (!shell.isDisposed ()) {
+		switch (type) {
+			case SWT.FocusIn: 
+				shell.setActiveControl (this);
+				break;
+			case SWT.FocusOut:
+				if (shell != display.activeShell) {
+					shell.setActiveControl (null);
+				}
+				break;
+		}
+	}
+}
+
+boolean sendHelpEvent (int /*long*/ helpType) {
+	Control control = this;
+	while (control != null) {
+		if (control.hooks (SWT.Help)) {
+			control.postEvent (SWT.Help);
+			return true;
+		}
+		control = control.parent;
+	}
+	return false;
+}
+
+boolean sendLeaveNotify() {
+	return false;
+}
+
+boolean sendMouseEvent (int type, int button, int time, double x, double y, boolean is_hint, int state) {
+	return sendMouseEvent (type, button, 0, 0, false, time, x, y, is_hint, state);
+}
+
+boolean sendMouseEvent (int type, int button, int count, int detail, boolean send, int time, double x, double y, boolean is_hint, int state) {
+	if (!hooks (type) && !filters (type)) return true;
+	Event event = new Event ();
+	event.time = time;
+	event.button = button;
+	event.detail = detail;
+	event.count = count;
+	if (is_hint) {
+		event.x = (int)x;
+		event.y = (int)y;
+	} else {
+		int /*long*/ window = eventWindow ();
+		int [] origin_x = new int [1], origin_y = new int [1];
+		OS.gdk_window_get_origin (window, origin_x, origin_y);
+		event.x = (int)x - origin_x [0];
+		event.y = (int)y - origin_y [0];
+	}
+	if ((style & SWT.MIRRORED) != 0) event.x = getClientWidth () - event.x;
+	setInputState (event, state);
+	if (send) {
+		sendEvent (type, event);
+		if (isDisposed ()) return false;
+	} else {
+		postEvent (type, event);
+	}
+	return event.doit;
+}
+
+void setBackground () {
+	if ((state & PARENT_BACKGROUND) != 0 && (state & BACKGROUND) == 0 && backgroundImage == null) {
+		setParentBackground ();
+	} else {
+		setWidgetBackground ();
+	}
+	redrawWidget (0, 0, 0, 0, true, false, false);
+}
+
+/**
+ * Sets the receiver's background color to the color specified
+ * by the argument, or to the default system color for the control
+ * if the argument is null.
+ * <p>
+ * Note: This operation is a hint and may be overridden by the platform.
+ * For example, on Windows the background of a Button cannot be changed.
+ * </p>
+ * @param color the new color (or null)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li> 
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setBackground (Color color) {
+	checkWidget();
+	if (((state & BACKGROUND) == 0) && color == null) return;
+	GdkColor gdkColor = null;
+	if (color != null) {
+		if (color.isDisposed ()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+		gdkColor = color.handle;
+	}
+	boolean set = false;
+	if (gdkColor == null) {
+		int /*long*/ style = OS.gtk_widget_get_modifier_style (handle);
+		set = (OS.gtk_rc_style_get_color_flags (style, OS.GTK_STATE_NORMAL) & OS.GTK_RC_BG) != 0;
+	} else {
+		GdkColor oldColor = getBackgroundColor ();
+		set = oldColor.pixel != gdkColor.pixel;
+	}
+	if (set) {
+		if (color == null) {
+			state &= ~BACKGROUND;
+		} else {
+			state |= BACKGROUND;
+		}
+		setBackgroundColor (gdkColor);
+		redrawChildren ();
+	}
+}
+
+void setBackgroundColor (int /*long*/ handle, GdkColor color) {
+	int index = OS.GTK_STATE_NORMAL;
+	int /*long*/ style = OS.gtk_widget_get_modifier_style (handle);
+	int /*long*/ ptr = OS.gtk_rc_style_get_bg_pixmap_name (style, index);
+	if (ptr != 0) OS.g_free (ptr);
+	String name = color == null ? "<parent>" : "<none>";
+	byte[] buffer = Converter.wcsToMbcs (null, name, true);
+	ptr = OS.g_malloc (buffer.length);
+	OS.memmove (ptr, buffer, buffer.length);
+	OS.gtk_rc_style_set_bg_pixmap_name (style, index, ptr);
+	OS.gtk_rc_style_set_bg (style, index, color);
+	int flags = OS.gtk_rc_style_get_color_flags (style, index);
+	flags = (color == null) ? flags & ~OS.GTK_RC_BG : flags | OS.GTK_RC_BG;
+	OS.gtk_rc_style_set_color_flags (style, index, flags);
+	modifyStyle (handle, style);
+}
+
+void setBackgroundColor (GdkColor color) {
+	setBackgroundColor (handle, color);
+}
+
+/**
+ * Sets the receiver's background image to the image specified
+ * by the argument, or to the default system color for the control
+ * if the argument is null.  The background image is tiled to fill
+ * the available space.
+ * <p>
+ * Note: This operation is a hint and may be overridden by the platform.
+ * For example, on Windows the background of a Button cannot be changed.
+ * </p>
+ * @param image the new image (or null)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li> 
+ *    <li>ERROR_INVALID_ARGUMENT - if the argument is not a bitmap</li> 
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.2
+ */
+public void setBackgroundImage (Image image) {
+	checkWidget ();
+	if (image != null && image.isDisposed ()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+	if (image == backgroundImage) return;
+	this.backgroundImage = image;
+	if (backgroundImage != null) {
+		setBackgroundPixmap (backgroundImage.pixmap);
+		redrawWidget (0, 0, 0, 0, true, false, false);
+	} else {
+		setWidgetBackground ();
+	}
+	redrawChildren ();
+}
+
+void setBackgroundPixmap (int /*long*/ pixmap) {
+	int /*long*/ window = OS.GTK_WIDGET_WINDOW (paintHandle ());
+	if (window != 0) OS.gdk_window_set_back_pixmap (window, backgroundImage.pixmap, false);
+}
+
+/**
+ * If the argument is <code>true</code>, causes the receiver to have
+ * all mouse events delivered to it until the method is called with
+ * <code>false</code> as the argument.  Note that on some platforms,
+ * a mouse button must currently be down for capture to be assigned.
+ *
+ * @param capture <code>true</code> to capture the mouse, and <code>false</code> to release it
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setCapture (boolean capture) {
+	checkWidget();
+	/* FIXME !!!!! */
+	/*
+	if (capture) {
+		OS.gtk_widget_grab_focus (handle);
+	} else {
+		OS.gtk_widget_grab_default (handle);
+	}
+	*/
+}
+/**
+ * Sets the receiver's cursor to the cursor specified by the
+ * argument, or to the default cursor for that kind of control
+ * if the argument is null.
+ * <p>
+ * When the mouse pointer passes over a control its appearance
+ * is changed to match the control's cursor.
+ * </p>
+ *
+ * @param cursor the new cursor (or null)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li> 
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setCursor (Cursor cursor) {
+	checkWidget();
+	if (cursor != null && cursor.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT);
+	this.cursor = cursor;
+	setCursor (cursor != null ? cursor.handle : 0);
+}
+
+void setCursor (int /*long*/ cursor) {
+	int /*long*/ window = eventWindow ();
+	if (window != 0) {
+		OS.gdk_window_set_cursor (window, cursor);
+		if (!OS.GDK_WINDOWING_X11 ()) {
+			OS.gdk_flush ();
+		} else {
+			int /*long*/ xDisplay = OS.GDK_DISPLAY ();
+			OS.XFlush (xDisplay);
+		}
+	}
+}
+
+/**
+ * Sets the receiver's drag detect state. If the argument is
+ * <code>true</code>, the receiver will detect drag gestures,
+ * otherwise these gestures will be ignored.
+ *
+ * @param dragDetect the new drag detect state
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.3
+ */
+public void setDragDetect (boolean dragDetect) {
+	checkWidget ();
+	if (dragDetect) {
+		state |= DRAG_DETECT;
+	} else {
+		state &= ~DRAG_DETECT;
+	}
+}
+
+/**
+ * Enables the receiver if the argument is <code>true</code>,
+ * and disables it otherwise. A disabled control is typically
+ * not selectable from the user interface and draws with an
+ * inactive or "grayed" look.
+ *
+ * @param enabled the new enabled state
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setEnabled (boolean enabled) {
+	checkWidget();
+	if (((state & DISABLED) == 0) == enabled) return;
+	Control control = null;
+	boolean fixFocus = false;
+	if (!enabled) {
+		if (display.focusEvent != SWT.FocusOut) {
+			control = display.getFocusControl ();
+			fixFocus = isFocusAncestor (control);
+		}
+	}
+	if (enabled) {
+		state &= ~DISABLED;
+	} else {
+		state |= DISABLED;
+	}
+	enableWidget (enabled);
+	if (isDisposed ()) return;
+	if (enabled) {
+		if (enableWindow != 0) {
+			OS.gdk_window_set_user_data (enableWindow, 0);
+			OS.gdk_window_destroy (enableWindow);
+			enableWindow = 0;
+		}
+	} else {
+		OS.gtk_widget_realize (handle);
+		int /*long*/ parentHandle = parent.eventHandle ();
+		int /*long*/ window = parent.eventWindow ();
+		int /*long*/ topHandle = topHandle ();
+		GdkWindowAttr attributes = new GdkWindowAttr ();
+		attributes.x = OS.GTK_WIDGET_X (topHandle);
+		attributes.y = OS.GTK_WIDGET_Y (topHandle);
+		attributes.width = (state & ZERO_WIDTH) != 0 ? 0 : OS.GTK_WIDGET_WIDTH (topHandle);
+		attributes.height = (state & ZERO_HEIGHT) != 0 ? 0 : OS.GTK_WIDGET_HEIGHT (topHandle);
+		attributes.event_mask = (0xFFFFFFFF & ~OS.ExposureMask);
+		attributes.wclass = OS.GDK_INPUT_ONLY;
+		attributes.window_type = OS.GDK_WINDOW_CHILD;
+		enableWindow = OS.gdk_window_new (window, attributes, OS.GDK_WA_X | OS.GDK_WA_Y);
+		if (enableWindow != 0) {
+			OS.gdk_window_set_user_data (enableWindow, parentHandle);
+			if (!OS.GDK_WINDOWING_X11 ()) {
+				OS.gdk_window_raise (enableWindow);
+			} else {
+				int /*long*/ topWindow = OS.GTK_WIDGET_WINDOW (topHandle);			
+				int /*long*/ xDisplay = OS.gdk_x11_drawable_get_xdisplay (topWindow);
+				int /*long*/ xWindow = OS.gdk_x11_drawable_get_xid (enableWindow);
+				int xScreen = OS.XDefaultScreen (xDisplay);
+				int flags = OS.CWStackMode | OS.CWSibling;			
+				XWindowChanges changes = new XWindowChanges ();
+				changes.sibling = OS.gdk_x11_drawable_get_xid (topWindow);
+				changes.stack_mode = OS.Above;
+				OS.XReconfigureWMWindow (xDisplay, xWindow, xScreen, flags, changes);
+			}
+			if (OS.GTK_WIDGET_VISIBLE (topHandle)) OS.gdk_window_show_unraised (enableWindow);
+		}
+	}
+	if (fixFocus) fixFocus (control);
+}
+
+/**
+ * Causes the receiver to have the <em>keyboard focus</em>, 
+ * such that all keyboard events will be delivered to it.  Focus
+ * reassignment will respect applicable platform constraints.
+ *
+ * @return <code>true</code> if the control got focus, and <code>false</code> if it was unable to.
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #forceFocus
+ */
+public boolean setFocus () {
+	checkWidget();
+	if ((style & SWT.NO_FOCUS) != 0) return false;
+	return forceFocus ();
+}
+
+/**
+ * Sets the font that the receiver will use to paint textual information
+ * to the font specified by the argument, or to the default font for that
+ * kind of control if the argument is null.
+ *
+ * @param font the new font (or null)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li> 
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setFont (Font font) {
+	checkWidget();
+	if (((state & FONT) == 0) && font == null) return;
+	this.font = font;
+	int /*long*/ fontDesc;
+	if (font == null) {
+		fontDesc = defaultFont ().handle;
+	} else {
+		if (font.isDisposed ()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+		fontDesc = font.handle;
+	}
+	if (font == null) {
+		state &= ~FONT;
+	} else {
+		state |= FONT;
+	}
+	setFontDescription (fontDesc);
+}
+	
+void setFontDescription (int /*long*/ font) {
+	OS.gtk_widget_modify_font (handle, font);
+}
+
+/**
+ * Sets the receiver's foreground color to the color specified
+ * by the argument, or to the default system color for the control
+ * if the argument is null.
+ * <p>
+ * Note: This operation is a hint and may be overridden by the platform.
+ * </p>
+ * @param color the new color (or null)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li> 
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setForeground (Color color) {
+	checkWidget();
+	if (((state & FOREGROUND) == 0) && color == null) return;
+	GdkColor gdkColor = null;
+	if (color != null) {
+		if (color.isDisposed ()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+		gdkColor = color.handle;
+	}
+	boolean set = false;
+	if (gdkColor == null) {
+		int /*long*/ style = OS.gtk_widget_get_modifier_style (handle);
+		set = (OS.gtk_rc_style_get_color_flags (style, OS.GTK_STATE_NORMAL) & OS.GTK_RC_FG) != 0;
+	} else {
+		GdkColor oldColor = getForegroundColor ();
+		set = oldColor.pixel != gdkColor.pixel;
+	}
+	if (set) {
+		if (color == null) {
+			state &= ~FOREGROUND;
+		} else {
+			state |= FOREGROUND;
+		}
+		setForegroundColor (gdkColor);
+	}
+}
+
+void setForegroundColor (GdkColor color) {
+	setForegroundColor (handle, color);
+}
+
+void setInitialBounds () {
+	if ((state & ZERO_WIDTH) != 0 && (state & ZERO_HEIGHT) != 0) {
+		/*
+		* Feature in GTK.  On creation, each widget's allocation is
+		* initialized to a position of (-1, -1) until the widget is
+		* first sized.  The fix is to set the value to (0, 0) as
+		* expected by SWT.
+		*/
+		int /*long*/ topHandle = topHandle ();
+		if ((parent.style & SWT.MIRRORED) != 0) {
+			OS.GTK_WIDGET_SET_X (topHandle, parent.getClientWidth ());
+		} else {
+			OS.GTK_WIDGET_SET_X (topHandle, 0);
+		}
+		OS.GTK_WIDGET_SET_Y (topHandle, 0);
+	} else {
+		resizeHandle (1, 1);
+		forceResize ();
+	}
+}
+
+/**
+ * Sets the receiver's pop up menu to the argument.
+ * All controls may optionally have a pop up
+ * menu that is displayed when the user requests one for
+ * the control. The sequence of key strokes, button presses
+ * and/or button releases that are used to request a pop up
+ * menu is platform specific.
+ * <p>
+ * Note: Disposing of a control that has a pop up menu will
+ * dispose of the menu.  To avoid this behavior, set the
+ * menu to null before the control is disposed.
+ * </p>
+ *
+ * @param menu the new pop up menu
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_MENU_NOT_POP_UP - the menu is not a pop up menu</li>
+ *    <li>ERROR_INVALID_PARENT - if the menu is not in the same widget tree</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the menu has been disposed</li> 
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setMenu (Menu menu) {
+	checkWidget();
+	if (menu != null) {
+		if ((menu.style & SWT.POP_UP) == 0) {
+			error (SWT.ERROR_MENU_NOT_POP_UP);
+		}
+		if (menu.parent != menuShell ()) {
+			error (SWT.ERROR_INVALID_PARENT);
+		}
+	}
+	this.menu = menu;
+}
+
+void setOrientation () {
+	if ((style & SWT.RIGHT_TO_LEFT) != 0) {
+		if (handle != 0) OS.gtk_widget_set_direction (handle, OS.GTK_TEXT_DIR_RTL);
+		if (fixedHandle != 0) OS.gtk_widget_set_direction (fixedHandle, OS.GTK_TEXT_DIR_RTL);
+	}
+}
+
+/**
+ * Changes the parent of the widget to be the one provided if
+ * the underlying operating system supports this feature.
+ * Returns <code>true</code> if the parent is successfully changed.
+ *
+ * @param parent the new parent for the control.
+ * @return <code>true</code> if the parent is changed and <code>false</code> otherwise.
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is <code>null</code></li> 
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *	</ul>
+ */
+public boolean setParent (Composite parent) {
+	checkWidget ();
+	if (parent == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+	if (parent.isDisposed()) SWT.error (SWT.ERROR_INVALID_ARGUMENT);
+	if (this.parent == parent) return true;
+	if (!isReparentable ()) return false;
+	int /*long*/ topHandle = topHandle ();
+	int x = OS.GTK_WIDGET_X (topHandle);
+	int width = (state & ZERO_WIDTH) != 0 ? 0 : OS.GTK_WIDGET_WIDTH (topHandle);
+	if ((this.parent.style & SWT.MIRRORED) != 0) {
+		x =  this.parent.getClientWidth () - width - x;
+	}
+	if ((parent.style & SWT.MIRRORED) != 0) {
+		x = parent.getClientWidth () - width - x;
+	}
+	int y = OS.GTK_WIDGET_Y (topHandle);
+	releaseParent ();
+	Shell newShell = parent.getShell (), oldShell = getShell ();
+	Decorations newDecorations = parent.menuShell (), oldDecorations = menuShell ();
+	Menu [] menus = oldShell.findMenus (this);
+	if (oldShell != newShell || oldDecorations != newDecorations) {
+		fixChildren (newShell, oldShell, newDecorations, oldDecorations, menus);
+		newDecorations.fixAccelGroup ();
+		oldDecorations.fixAccelGroup ();
+	}
+	int /*long*/ newParent = parent.parentingHandle();
+	OS.gtk_widget_reparent (topHandle, newParent);
+	OS.gtk_fixed_move (newParent, topHandle, x, y);
+	this.parent = parent;
+	setZOrder (null, false, true);
+	return true;
+}
+
+void setParentBackground () {
+	setBackgroundColor (handle, null);
+	if (fixedHandle != 0) setBackgroundColor (fixedHandle, null);
+}
+
+void setParentWindow (int /*long*/ widget) {
+}
+
+boolean setRadioSelection (boolean value) {
+	return false;
+}
+
+/**
+ * If the argument is <code>false</code>, causes subsequent drawing
+ * operations in the receiver to be ignored. No drawing of any kind
+ * can occur in the receiver until the flag is set to true.
+ * Graphics operations that occurred while the flag was
+ * <code>false</code> are lost. When the flag is set to <code>true</code>,
+ * the entire widget is marked as needing to be redrawn.  Nested calls
+ * to this method are stacked.
+ * <p>
+ * Note: This operation is a hint and may not be supported on some
+ * platforms or for some widgets.
+ * </p>
+ *
+ * @param redraw the new redraw state
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see #redraw(int, int, int, int, boolean)
+ * @see #update()
+ */
+public void setRedraw (boolean redraw) {
+	checkWidget();
+	if (redraw) {
+		if (--drawCount == 0) {
+			if (redrawWindow != 0) {
+				int /*long*/ window = paintWindow ();
+				/* Explicitly hiding the window avoids flicker on GTK+ >= 2.6 */
+				OS.gdk_window_hide (redrawWindow);
+				OS.gdk_window_destroy (redrawWindow);
+				OS.gdk_window_set_events (window, OS.gtk_widget_get_events (paintHandle ()));
+				redrawWindow = 0;
+			}
+		}
+	} else {
+		if (drawCount++ == 0) {
+			if ((OS.GTK_WIDGET_FLAGS (handle) & OS.GTK_REALIZED) != 0) {
+				int /*long*/ window = paintWindow ();
+				Rectangle rect = getBounds ();
+				GdkWindowAttr attributes = new GdkWindowAttr ();
+				attributes.width = rect.width;
+				attributes.height = rect.height;
+				attributes.event_mask = OS.GDK_EXPOSURE_MASK;
+				attributes.window_type = OS.GDK_WINDOW_CHILD;
+				redrawWindow = OS.gdk_window_new (window, attributes, 0);
+				if (redrawWindow != 0) {
+					int mouseMask = OS.GDK_BUTTON_PRESS_MASK | OS.GDK_BUTTON_RELEASE_MASK |
+						OS.GDK_ENTER_NOTIFY_MASK | OS.GDK_LEAVE_NOTIFY_MASK |
+						OS.GDK_POINTER_MOTION_MASK | OS.GDK_POINTER_MOTION_HINT_MASK |
+						OS.GDK_BUTTON_MOTION_MASK | OS.GDK_BUTTON1_MOTION_MASK | 
+						OS.GDK_BUTTON2_MOTION_MASK | OS.GDK_BUTTON3_MOTION_MASK;
+					OS.gdk_window_set_events (window, OS.gdk_window_get_events (window) & ~mouseMask);
+					OS.gdk_window_set_back_pixmap (redrawWindow, 0, false);
+					OS.gdk_window_show (redrawWindow);
+				}
+			}
+		}
+	}
+}
+
+boolean setTabGroupFocus (boolean next) {
+	return setTabItemFocus (next);
+}
+boolean setTabItemFocus (boolean next) {
+	if (!isShowing ()) return false;
+	return forceFocus ();
+}
+
+/**
+ * Sets the receiver's tool tip text to the argument, which
+ * may be null indicating that no tool tip text should be shown.
+ *
+ * @param string the new tool tip text (or null)
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setToolTipText (String string) {
+	checkWidget();
+	setToolTipText (_getShell (), string);
+	toolTipText = string;
+}
+
+void setToolTipText (Shell shell, String newString) {
+	if (OS.GTK_VERSION >= OS.VERSION (2, 12, 0)) {
+		/*
+		* Feature in GTK.  In order to prevent children widgets
+		* from inheriting their parent's tooltip, the tooltip is
+		* a set on a shell only. In order to force the shell tooltip
+		* to update when a new tip string is set, the existing string
+		* in the tooltip is set to null, followed by running a query.
+		* The real tip text can then be set. 
+		* 
+		* Note that this will only run if the control for which the 
+		* tooltip is being set is the current control (i.e. the control
+		* under the pointer).
+		*/
+		if (display.currentControl == this) {
+			shell.setToolTipText (shell.handle, eventHandle (), newString);
+		}
+	} else {
+		shell.setToolTipText (eventHandle (), newString);
+	}
+}
+
+/**
+ * Marks the receiver as visible if the argument is <code>true</code>,
+ * and marks it invisible otherwise. 
+ * <p>
+ * If one of the receiver's ancestors is not visible or some
+ * other condition makes the receiver not visible, marking
+ * it visible may not actually cause it to be displayed.
+ * </p>
+ *
+ * @param visible the new visibility state
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setVisible (boolean visible) {
+	checkWidget();
+	if (((state & HIDDEN) == 0) == visible) return;
+	int /*long*/ topHandle = topHandle();
+	if (visible) {
+		/*
+		* It is possible (but unlikely), that application
+		* code could have disposed the widget in the show
+		* event.  If this happens, just return.
+		*/
+		sendEvent (SWT.Show);
+		if (isDisposed ()) return;
+		state &= ~HIDDEN;
+		if ((state & (ZERO_WIDTH | ZERO_HEIGHT)) == 0) {
+			if (enableWindow != 0) OS.gdk_window_show_unraised (enableWindow);
+			OS.gtk_widget_show (topHandle);
+		}
+	} else {
+		/*
+		* Bug in GTK.  Invoking gtk_widget_hide() on a widget that has
+		* focus causes a focus_out_event to be sent. If the client disposes
+		* the widget inside the event, GTK GP's.  The fix is to reassign focus
+		* before hiding the widget.
+		* 
+		* NOTE: In order to stop the same widget from taking focus,
+		* temporarily clear and set the GTK_VISIBLE flag.
+		*/		
+		Control control = null;
+		boolean fixFocus = false;
+		if (display.focusEvent != SWT.FocusOut) {
+			control = display.getFocusControl ();
+			fixFocus = isFocusAncestor (control);
+		}
+		state |= HIDDEN;
+		if (fixFocus) {
+			OS.GTK_WIDGET_UNSET_FLAGS (topHandle, OS.GTK_VISIBLE);
+			fixFocus (control);
+			if (isDisposed ()) return;
+			OS.GTK_WIDGET_SET_FLAGS (topHandle, OS.GTK_VISIBLE);
+		}
+		OS.gtk_widget_hide (topHandle);
+		if (isDisposed ()) return;
+		if (enableWindow != 0) OS.gdk_window_hide (enableWindow);
+		sendEvent (SWT.Hide);
+	}
+}
+
+void setZOrder (Control sibling, boolean above, boolean fixRelations) {
+	 setZOrder (sibling, above, fixRelations, true);
+}
+
+void setZOrder (Control sibling, boolean above, boolean fixRelations, boolean fixChildren) {
+	int index = 0, siblingIndex = 0, oldNextIndex = -1;
+	Control[] children = null;
+	if (fixRelations) {
+		/* determine the receiver's and sibling's indexes in the parent */
+		children = parent._getChildren ();
+		while (index < children.length) {
+			if (children [index] == this) break;
+			index++;
+		}
+		if (sibling != null) {
+			while (siblingIndex < children.length) {
+				if (children [siblingIndex] == sibling) break;
+				siblingIndex++;
+			}
+		}
+		/* remove "Labelled by" relationships that will no longer be valid */
+		removeRelation ();
+		if (index + 1 < children.length) {
+			oldNextIndex = index + 1;
+			children [oldNextIndex].removeRelation ();
+		}
+		if (sibling != null) {
+			if (above) {
+				sibling.removeRelation ();
+			} else {
+				if (siblingIndex + 1 < children.length) {
+					children [siblingIndex + 1].removeRelation ();
+				}
+			}
+		}
+	}
+
+	int /*long*/ topHandle = topHandle ();
+	int /*long*/ siblingHandle = sibling != null ? sibling.topHandle () : 0;
+	int /*long*/ window = OS.GTK_WIDGET_WINDOW (topHandle);
+	if (window != 0) {
+		int /*long*/ siblingWindow = 0;
+		if (sibling != null) {
+			if (above && sibling.enableWindow != 0) {
+				siblingWindow = enableWindow;
+			} else {
+				siblingWindow = OS.GTK_WIDGET_WINDOW (siblingHandle);
+			}
+		}
+		int /*long*/ redrawWindow = fixChildren ? parent.redrawWindow : 0;
+		if (!OS.GDK_WINDOWING_X11 () || (siblingWindow == 0 && (!above || redrawWindow == 0))) {
+			if (above) {
+				OS.gdk_window_raise (window);
+				if (redrawWindow != 0) OS.gdk_window_raise (redrawWindow);
+				if (enableWindow != 0) OS.gdk_window_raise (enableWindow);
+			} else {
+				if (enableWindow != 0) OS.gdk_window_lower (enableWindow);
+				OS.gdk_window_lower (window);
+			}
+		} else {
+			XWindowChanges changes = new XWindowChanges ();
+			changes.sibling = OS.gdk_x11_drawable_get_xid (siblingWindow != 0 ? siblingWindow : redrawWindow);
+			changes.stack_mode = above ? OS.Above : OS.Below;
+			if (redrawWindow != 0 && siblingWindow == 0) changes.stack_mode = OS.Below;
+			int /*long*/ xDisplay = OS.gdk_x11_drawable_get_xdisplay (window);
+			int /*long*/ xWindow = OS.gdk_x11_drawable_get_xid (window);
+			int xScreen = OS.XDefaultScreen (xDisplay);
+			int flags = OS.CWStackMode | OS.CWSibling;
+			/*
+			* Feature in X. If the receiver is a top level, XConfigureWindow ()
+			* will fail (with a BadMatch error) for top level shells because top
+			* level shells are reparented by the window manager and do not share
+			* the same X window parent.  This is the correct behavior but it is
+			* unexpected.  The fix is to use XReconfigureWMWindow () instead.
+			* When the receiver is not a top level shell, XReconfigureWMWindow ()
+			* behaves the same as XConfigureWindow ().
+			*/
+			OS.XReconfigureWMWindow (xDisplay, xWindow, xScreen, flags, changes);			
+			if (enableWindow != 0) {
+				changes.sibling = OS.gdk_x11_drawable_get_xid (window);
+				changes.stack_mode = OS.Above;
+				xWindow = OS.gdk_x11_drawable_get_xid (enableWindow);
+				OS.XReconfigureWMWindow (xDisplay, xWindow, xScreen, flags, changes);
+			}
+		}
+	}
+	if (fixChildren) {
+		if (above) {
+			parent.moveAbove (topHandle, siblingHandle);
+		} else {
+			parent.moveBelow (topHandle, siblingHandle);
+		}
+	}
+	/*  Make sure that the parent internal windows are on the bottom of the stack	*/
+	if (!above && fixChildren) 	parent.fixZOrder ();
+
+	if (fixRelations) {
+		/* determine the receiver's new index in the parent */
+		if (sibling != null) {
+			if (above) {
+				index = siblingIndex - (index < siblingIndex ? 1 : 0);
+			} else {
+				index = siblingIndex + (siblingIndex < index ? 1 : 0);
+			}
+		} else {
+			if (above) {
+				index = 0;
+			} else {
+				index = children.length - 1;
+			}
+		}
+
+		/* add new "Labelled by" relations as needed */
+		children = parent._getChildren ();
+		if (0 < index) {
+			children [index - 1].addRelation (this);
+		}
+		if (index + 1 < children.length) {
+			addRelation (children [index + 1]);
+		}
+		if (oldNextIndex != -1) {
+			if (oldNextIndex <= index) oldNextIndex--;
+			/* the last two conditions below ensure that duplicate relations are not hooked */
+			if (0 < oldNextIndex && oldNextIndex != index && oldNextIndex != index + 1) {
+				children [oldNextIndex - 1].addRelation (children [oldNextIndex]);
+			}
+		}
+	}
+}
+
+void setWidgetBackground  () {
+	if (fixedHandle != 0) {
+		int /*long*/ style = OS.gtk_widget_get_modifier_style (fixedHandle);
+		modifyStyle (fixedHandle, style);
+	}
+	int /*long*/ style = OS.gtk_widget_get_modifier_style (handle);
+	modifyStyle (handle, style);
+}
+
+boolean showMenu (int x, int y) {
+	Event event = new Event ();
+	event.x = x;
+	event.y = y;
+	sendEvent (SWT.MenuDetect, event);
+	if (event.doit) {
+		if (menu != null && !menu.isDisposed ()) {
+			boolean hooksKeys = hooks (SWT.KeyDown) || hooks (SWT.KeyUp);
+			menu.createIMMenu (hooksKeys ? imHandle() : 0);
+			if (event.x != x || event.y != y) {
+				menu.setLocation (event.x, event.y);
+			}
+			menu.setVisible (true);
+			return true;
+		}
+	}
+	return false;
+}
+
+void showWidget () {
+	// Comment this line to disable zero-sized widgets
+	state |= ZERO_WIDTH | ZERO_HEIGHT;
+	int /*long*/ topHandle = topHandle ();
+	int /*long*/ parentHandle = parent.parentingHandle ();
+	parent.setParentWindow (topHandle);
+	OS.gtk_container_add (parentHandle, topHandle);
+	if (handle != 0 && handle != topHandle) OS.gtk_widget_show (handle);
+	if ((state & (ZERO_WIDTH | ZERO_HEIGHT)) == 0) {
+		if (fixedHandle != 0) OS.gtk_widget_show (fixedHandle);
+	}
+	if (fixedHandle != 0) fixStyle (fixedHandle);
+}
+
+void sort (int [] items) {
+	/* Shell Sort from K&R, pg 108 */
+	int length = items.length;
+	for (int gap=length/2; gap>0; gap/=2) {
+		for (int i=gap; i<length; i++) {
+			for (int j=i-gap; j>=0; j-=gap) {
+		   		if (items [j] <= items [j + gap]) {
+					int swap = items [j];
+					items [j] = items [j + gap];
+					items [j + gap] = swap;
+		   		}
+	    	}
+	    }
+	}
+}
+
+/**
+ * Based on the argument, perform one of the expected platform
+ * traversal action. The argument should be one of the constants:
+ * <code>SWT.TRAVERSE_ESCAPE</code>, <code>SWT.TRAVERSE_RETURN</code>, 
+ * <code>SWT.TRAVERSE_TAB_NEXT</code>, <code>SWT.TRAVERSE_TAB_PREVIOUS</code>, 
+ * <code>SWT.TRAVERSE_ARROW_NEXT</code> and <code>SWT.TRAVERSE_ARROW_PREVIOUS</code>.
+ *
+ * @param traversal the type of traversal
+ * @return true if the traversal succeeded
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public boolean traverse (int traversal) {
+	checkWidget ();
+	Event event = new Event ();
+	event.doit = true;
+	event.detail = traversal;
+	return traverse (event);
+}
+
+boolean translateMnemonic (Event event, Control control) {
+	if (control == this) return false;
+	if (!isVisible () || !isEnabled ()) return false;
+	event.doit = this == display.mnemonicControl || mnemonicMatch (event.character);
+	return traverse (event);
+}
+
+boolean translateMnemonic (int keyval, GdkEventKey gdkEvent) {
+	int key = OS.gdk_keyval_to_unicode (keyval);
+	if (key < 0x20) return false;
+	if (gdkEvent.state == 0) {
+		int code = traversalCode (keyval, gdkEvent);
+		if ((code & SWT.TRAVERSE_MNEMONIC) == 0) return false;
+	} else {
+		Shell shell = _getShell ();
+		int mask = OS.GDK_CONTROL_MASK | OS.GDK_SHIFT_MASK | OS.GDK_MOD1_MASK;
+		if ((gdkEvent.state & mask) != OS.gtk_window_get_mnemonic_modifier (shell.shellHandle)) return false;
+	}
+	Decorations shell = menuShell ();
+	if (shell.isVisible () && shell.isEnabled ()) {
+		Event event = new Event ();
+		event.detail = SWT.TRAVERSE_MNEMONIC;
+		if (setKeyState (event, gdkEvent)) {
+			return translateMnemonic (event, null) || shell.translateMnemonic (event, this);
+		}
+	}
+	return false;
+}
+
+boolean translateTraversal (GdkEventKey keyEvent) {
+	int detail = SWT.TRAVERSE_NONE;
+	int key = keyEvent.keyval;
+	int code = traversalCode (key, keyEvent);
+	boolean all = false;
+	switch (key) {
+		case OS.GDK_Escape: {
+			all = true;
+			detail = SWT.TRAVERSE_ESCAPE;
+			break;
+		}
+		case OS.GDK_KP_Enter:
+		case OS.GDK_Return: {
+			all = true;
+			detail = SWT.TRAVERSE_RETURN;
+			break;
+		}
+		case OS.GDK_ISO_Left_Tab: 
+		case OS.GDK_Tab: {
+			boolean next = (keyEvent.state & OS.GDK_SHIFT_MASK) == 0;
+			detail = next ? SWT.TRAVERSE_TAB_NEXT : SWT.TRAVERSE_TAB_PREVIOUS;
+			break;
+		}
+		case OS.GDK_Up:
+		case OS.GDK_Left: 
+		case OS.GDK_Down:
+		case OS.GDK_Right: {
+			boolean next = key == OS.GDK_Down || key == OS.GDK_Right;
+			if (parent != null && (parent.style & SWT.MIRRORED) != 0) {
+				if (key == OS.GDK_Left || key == OS.GDK_Right) next = !next;
+			}
+			detail = next ? SWT.TRAVERSE_ARROW_NEXT : SWT.TRAVERSE_ARROW_PREVIOUS;
+			break;
+		}
+		case OS.GDK_Page_Up:
+		case OS.GDK_Page_Down: {
+			all = true;
+			if ((keyEvent.state & OS.GDK_CONTROL_MASK) == 0) return false;
+			detail = key == OS.GDK_Page_Down ? SWT.TRAVERSE_PAGE_NEXT : SWT.TRAVERSE_PAGE_PREVIOUS;
+			break;
+		}
+		default:
+			return false;
+	}
+	Event event = new Event ();
+	event.doit = (code & detail) != 0;
+	event.detail = detail;
+	event.time = keyEvent.time;
+	if (!setKeyState (event, keyEvent)) return false;
+	Shell shell = getShell ();
+	Control control = this;
+	do {
+		if (control.traverse (event)) return true;
+		if (!event.doit && control.hooks (SWT.Traverse)) return false;
+		if (control == shell) return false;
+		control = control.parent;
+	} while (all && control != null);
+	return false;
+}
+
+int traversalCode (int key, GdkEventKey event) {
+	int code = SWT.TRAVERSE_RETURN | SWT.TRAVERSE_TAB_NEXT |  SWT.TRAVERSE_TAB_PREVIOUS | SWT.TRAVERSE_PAGE_NEXT | SWT.TRAVERSE_PAGE_PREVIOUS;
+	Shell shell = getShell ();
+	if (shell.parent != null) code |= SWT.TRAVERSE_ESCAPE;
+	return code;
+}
+
+boolean traverse (Event event) {
+	/*
+	* It is possible (but unlikely), that application
+	* code could have disposed the widget in the traverse
+	* event.  If this happens, return true to stop further
+	* event processing.
+	*/	
+	sendEvent (SWT.Traverse, event);
+	if (isDisposed ()) return true;
+	if (!event.doit) return false;
+	switch (event.detail) {
+		case SWT.TRAVERSE_NONE:			return true;
+		case SWT.TRAVERSE_ESCAPE:			return traverseEscape ();
+		case SWT.TRAVERSE_RETURN:			return traverseReturn ();
+		case SWT.TRAVERSE_TAB_NEXT:		return traverseGroup (true);
+		case SWT.TRAVERSE_TAB_PREVIOUS:	return traverseGroup (false);
+		case SWT.TRAVERSE_ARROW_NEXT:		return traverseItem (true);
+		case SWT.TRAVERSE_ARROW_PREVIOUS:	return traverseItem (false);
+		case SWT.TRAVERSE_MNEMONIC:		return traverseMnemonic (event.character);	
+		case SWT.TRAVERSE_PAGE_NEXT:		return traversePage (true);
+		case SWT.TRAVERSE_PAGE_PREVIOUS:	return traversePage (false);
+	}
+	return false;
+}
+
+boolean traverseEscape () {
+	return false;
+}
+
+boolean traverseGroup (boolean next) {
+	Control root = computeTabRoot ();
+	Control group = computeTabGroup ();
+	Control [] list = root.computeTabList ();
+	int length = list.length;
+	int index = 0;
+	while (index < length) {
+		if (list [index] == group) break;
+		index++;
+	}
+	/*
+	* It is possible (but unlikely), that application
+	* code could have disposed the widget in focus in
+	* or out events.  Ensure that a disposed widget is
+	* not accessed.
+	*/
+	if (index == length) return false;
+	int start = index, offset = (next) ? 1 : -1;
+	while ((index = ((index + offset + length) % length)) != start) {
+		Control control = list [index];
+		if (!control.isDisposed () && control.setTabGroupFocus (next)) {
+			return true;
+		}
+	}
+	if (group.isDisposed ()) return false;
+	return group.setTabGroupFocus (next);
+}
+
+boolean traverseItem (boolean next) {
+	Control [] children = parent._getChildren ();
+	int length = children.length;
+	int index = 0;
+	while (index < length) {
+		if (children [index] == this) break;
+		index++;
+	}
+	/*
+	* It is possible (but unlikely), that application
+	* code could have disposed the widget in focus in
+	* or out events.  Ensure that a disposed widget is
+	* not accessed.
+	*/
+	if (index == length) return false;
+	int start = index, offset = (next) ? 1 : -1;
+	while ((index = (index + offset + length) % length) != start) {
+		Control child = children [index];
+		if (!child.isDisposed () && child.isTabItem ()) {
+			if (child.setTabItemFocus (next)) return true;
+		}
+	}
+	return false;
+}
+
+boolean traverseReturn () {
+	return false;
+}
+
+boolean traversePage (boolean next) {
+	return false;
+}
+
+boolean traverseMnemonic (char key) {
+	return mnemonicHit (key);
+}
+
+/**
+ * Forces all outstanding paint requests for the widget
+ * to be processed before this method returns. If there
+ * are no outstanding paint request, this method does
+ * nothing.
+ * <p>
+ * Note: This method does not cause a redraw.
+ * </p>
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #redraw()
+ * @see #redraw(int, int, int, int, boolean)
+ * @see PaintListener
+ * @see SWT#Paint
+ */
+public void update () {
+	checkWidget ();
+	update (false, true);
+}
+
+void update (boolean all, boolean flush) {
+//	checkWidget();
+	if (!OS.GTK_WIDGET_VISIBLE (topHandle ())) return; 
+	if ((OS.GTK_WIDGET_FLAGS (handle) & OS.GTK_REALIZED) == 0) return;
+	int /*long*/ window = paintWindow ();
+	if (flush) display.flushExposes (window, all);
+	OS.gdk_window_process_updates (window, all);
+	OS.gdk_flush ();
+}
+
+void updateBackgroundMode () {
+	int oldState = state & PARENT_BACKGROUND;
+	checkBackground ();
+	if (oldState != (state & PARENT_BACKGROUND)) {
+		setBackground ();
+	}
+}
+
+void updateLayout (boolean all) {
+	/* Do nothing */
+}
+
+int /*long*/ windowProc (int /*long*/ handle, int /*long*/ arg0, int /*long*/ user_data) {
+	switch ((int)/*64*/user_data) {
+		case EXPOSE_EVENT_INVERSE: {
+			if ((OS.GTK_VERSION <  OS.VERSION (2, 8, 0)) && ((state & OBSCURED) == 0)) {
+				Control control = findBackgroundControl ();
+				if (control != null && control.backgroundImage != null) {
+					GdkEventExpose gdkEvent = new GdkEventExpose ();
+					OS.memmove (gdkEvent, arg0, GdkEventExpose.sizeof);
+					int /*long*/ paintWindow = paintWindow();
+					int /*long*/ window = gdkEvent.window;
+					if (window != paintWindow) break;
+					int /*long*/ gdkGC = OS.gdk_gc_new (window);
+					OS.gdk_gc_set_clip_region (gdkGC, gdkEvent.region);
+					int[] dest_x = new int[1], dest_y = new int[1];
+					OS.gtk_widget_translate_coordinates (paintHandle (), control.paintHandle (), 0, 0, dest_x, dest_y);
+					OS.gdk_gc_set_fill (gdkGC, OS.GDK_TILED);
+					OS.gdk_gc_set_ts_origin (gdkGC, -dest_x [0], -dest_y [0]);
+					OS.gdk_gc_set_tile (gdkGC, control.backgroundImage.pixmap); 
+					OS.gdk_draw_rectangle (window, gdkGC, 1, gdkEvent.area_x, gdkEvent.area_y, gdkEvent.area_width, gdkEvent.area_height);
+					OS.g_object_unref (gdkGC);
+				}
+			}
+			break;
+		}
+	}
+	return super.windowProc (handle, arg0, user_data);
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/CoolBar.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/CoolBar.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/CoolBar.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,1188 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.widgets;
+
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
+/**
+ * Instances of this class provide an area for dynamically
+ * positioning the items they contain.
+ * <p>
+ * The item children that may be added to instances of this class
+ * must be of type <code>CoolItem</code>.
+ * </p><p>
+ * Note that although this class is a subclass of <code>Composite</code>,
+ * it does not make sense to add <code>Control</code> children to it,
+ * or set a layout on it.
+ * </p><p>
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>FLAT, HORIZONTAL, VERTICAL</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>(none)</dd>
+ * </dl>
+ * </p><p>
+ * Note: Only one of the styles HORIZONTAL and VERTICAL may be specified.
+ * </p><p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ * 
+ * @see <a href="http://www.eclipse.org/swt/snippets/#coolbar">CoolBar snippets</a>
+ * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: ControlExample</a>
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public class CoolBar extends Composite {
+	CoolItem[][] items = new CoolItem[0][0];
+	CoolItem[] originalItems = new CoolItem[0];
+	Cursor hoverCursor, dragCursor, cursor;
+	CoolItem dragging = null;
+	int mouseXOffset, itemXOffset;
+	boolean isLocked = false;
+	boolean inDispose = false;
+	static final int ROW_SPACING = 2;
+	static final int CLICK_DISTANCE = 3;
+	static final int DEFAULT_COOLBAR_WIDTH = 0;
+	static final int DEFAULT_COOLBAR_HEIGHT = 0;
+	
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public CoolBar (Composite parent, int style) {
+	super (parent, checkStyle(style));
+	if ((style & SWT.VERTICAL) != 0) {
+		this.style |= SWT.VERTICAL;
+		hoverCursor = new Cursor(display, SWT.CURSOR_SIZENS);
+	} else {
+		this.style |= SWT.HORIZONTAL;
+		hoverCursor = new Cursor(display, SWT.CURSOR_SIZEWE);
+	}
+	dragCursor = new Cursor(display, SWT.CURSOR_SIZEALL);
+	Listener listener = new Listener() {
+		public void handleEvent(Event event) {
+			switch (event.type) {
+				case SWT.Dispose:      		onDispose(event);        	break;
+				case SWT.MouseDown:    		onMouseDown(event);			break;
+				case SWT.MouseExit:    		onMouseExit();      		break;
+				case SWT.MouseMove:    		onMouseMove(event); 		break;
+				case SWT.MouseUp:      		onMouseUp(event);   		break;
+				case SWT.MouseDoubleClick:	onMouseDoubleClick(event); 	break;
+				case SWT.Paint:        		onPaint(event);     		break;
+				case SWT.Resize:          	onResize();     			break;
+			}
+		}
+	};
+	int[] events = new int[] { 
+		SWT.Dispose, 
+		SWT.MouseDown,
+		SWT.MouseExit, 
+		SWT.MouseMove, 
+		SWT.MouseUp, 
+		SWT.MouseDoubleClick,
+		SWT.Paint,
+		SWT.Resize
+	};
+	for (int i = 0; i < events.length; i++) {
+		addListener(events[i], listener);	
+	}
+}
+static int checkStyle (int style) {
+	style |= SWT.NO_FOCUS;
+	return (style | SWT.NO_REDRAW_RESIZE) & ~(SWT.V_SCROLL | SWT.H_SCROLL);
+}
+void _setCursor (Cursor cursor) {
+	if (this.cursor != null) return;
+	super.setCursor (cursor);
+}
+protected void checkSubclass () {
+	if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
+}
+public Point computeSize (int wHint, int hHint, boolean changed) {
+	checkWidget();
+	int width = 0, height = 0;
+	wrapItems((style & SWT.VERTICAL) != 0 ? hHint : wHint);
+	boolean flat = (style & SWT.FLAT) != 0;
+	for (int row = 0; row < items.length; row++) {
+		int rowWidth = 0, rowHeight = 0;
+		for (int i = 0; i < items[row].length; i++) {
+			CoolItem item = items[row][i];
+			rowWidth += item.preferredWidth;
+			rowHeight = Math.max(rowHeight, item.preferredHeight);
+		}
+		height += rowHeight;
+		if (!flat && row > 0) height += ROW_SPACING;
+		width = Math.max(width, rowWidth);
+	}
+	wrapItems(getWidth());
+	if (width == 0) width = DEFAULT_COOLBAR_WIDTH;
+	if (height == 0) height = DEFAULT_COOLBAR_HEIGHT;
+	if (wHint != SWT.DEFAULT) width = wHint;
+	if (hHint != SWT.DEFAULT) height = hHint;
+	Rectangle trim = computeTrim(0, 0, width, height);
+	return fixPoint(trim.width, trim.height);
+}
+CoolItem getGrabbedItem(int x, int y) {
+	for (int row = 0; row < items.length; row++) {
+		for (int i = 0; i < items[row].length; i++) {
+			CoolItem item = items[row][i];
+			Rectangle bounds = item.internalGetBounds();
+			bounds.width = CoolItem.MINIMUM_WIDTH;
+			if (bounds.x > x) break;
+			if (bounds.y > y) return null;
+			if (bounds.contains(x, y)) {
+				return item;	
+			}	
+		}	
+	}
+	return null;
+}
+/**
+ * Returns the item that is currently displayed at the given,
+ * zero-relative index. Throws an exception if the index is
+ * out of range.
+ *
+ * @param index the visual index of the item to return
+ * @return the item at the given visual index
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public CoolItem getItem (int index) {
+	checkWidget();
+	if (index < 0) error (SWT.ERROR_INVALID_RANGE);
+	for (int row = 0; row < items.length; row++) {
+		if (items[row].length > index) {
+			return items[row][index];			
+		} else {
+			index -= items[row].length;
+		}
+	}
+	error (SWT.ERROR_INVALID_RANGE);
+	return null;
+}
+/**
+ * Returns the number of items contained in the receiver.
+ *
+ * @return the number of items
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getItemCount () {
+	checkWidget();
+	return originalItems.length;
+}
+/**
+ * Returns an array of <code>CoolItem</code>s in the order
+ * in which they are currently being displayed.
+ * <p>
+ * Note: This is not the actual structure used by the receiver
+ * to maintain its list of items, so modifying the array will
+ * not affect the receiver. 
+ * </p>
+ *
+ * @return the receiver's items in their current visual order
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public CoolItem [] getItems () {
+	checkWidget();
+	CoolItem [] result = new CoolItem [getItemCount()];
+	int offset = 0;
+	for (int row = 0; row < items.length; row++) {
+		System.arraycopy(items[row], 0, result, offset, items[row].length);
+		offset += items[row].length;
+	}
+	return result;
+}
+Point findItem (CoolItem item) {
+	for (int row = 0; row < items.length; row++) {
+		for (int i = 0; i < items[row].length; i++) {
+			if (items[row][i].equals(item)) return new Point(i, row);		
+		}
+	}
+	return new Point(-1, -1);
+}
+void fixEvent (Event event) {
+	if ((style & SWT.VERTICAL) != 0) {
+		int tmp = event.x;
+		event.x = event.y;
+		event.y = tmp;
+	}
+}
+Rectangle fixRectangle (int x, int y, int width, int height) {
+	if ((style & SWT.VERTICAL) != 0) {
+		return new Rectangle(y, x, height, width);
+	}
+	return new Rectangle(x, y, width, height);
+}
+Point fixPoint (int x, int y) {
+	if ((style & SWT.VERTICAL) != 0) {
+		return new Point(y, x);
+	}
+	return new Point(x, y);	
+}
+/**
+ * Searches the receiver's items in the order they are currently
+ * being displayed, starting at the first item (index 0), until
+ * an item is found that is equal to the argument, and returns
+ * the index of that item. If no item is found, returns -1.
+ *
+ * @param item the search item
+ * @return the visual order index of the search item, or -1 if the item is not found
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the item is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the item is disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int indexOf (CoolItem item) {
+	checkWidget();
+	if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if (item.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);
+	int answer = 0;
+	for (int row = 0; row < items.length; row++) {
+		for (int i = 0; i < items[row].length; i++) {
+			if (items[row][i].equals(item)) {
+				return answer;		
+			} else {
+				answer++;
+			}
+		}
+	}
+	return -1;
+}
+/**
+ * Insert the item into the row. Adjust the x and width values
+ * appropriately.
+ */
+void insertItemIntoRow(CoolItem item, int rowIndex, int x_root) {
+	int barWidth = getWidth();
+	int rowY = items[rowIndex][0].internalGetBounds().y;
+	int x = Math.max(0, Math.abs(x_root - toDisplay(new Point(0, 0)).x));
+	
+	/* Find the insertion index and add the item. */
+	int index;
+	for (index = 0; index < items[rowIndex].length; index++) {
+		if (x < items[rowIndex][index].internalGetBounds().x) break;
+	}
+	if (index == 0) {
+		item.wrap = true;
+		items[rowIndex][0].wrap = false;
+	}
+	int oldLength = items[rowIndex].length;
+	CoolItem[] newRow = new CoolItem[oldLength + 1];
+	System.arraycopy(items[rowIndex], 0, newRow, 0, index);
+	newRow[index] = item;
+	System.arraycopy(items[rowIndex], index, newRow, index + 1, oldLength - index);
+	items[rowIndex] = newRow;
+
+	/* Adjust the width of the item to the left. */
+	if (index > 0) {
+		CoolItem left = items[rowIndex][index - 1];
+		Rectangle leftBounds = left.internalGetBounds();
+		int newWidth = x - leftBounds.x;
+		if (newWidth < left.internalGetMinimumWidth()) {
+			x += left.internalGetMinimumWidth() - newWidth;
+			newWidth = left.internalGetMinimumWidth();
+		}
+		left.setBounds(leftBounds.x, leftBounds.y, newWidth, leftBounds.height);
+		left.requestedWidth = newWidth;
+	}
+	
+	/* Set the item's bounds. */
+	int width = 0, height = item.internalGetBounds().height;
+	if (index < items[rowIndex].length - 1) {
+		CoolItem right = items[rowIndex][index + 1];
+		width = right.internalGetBounds().x - x;
+		if (width < right.internalGetMinimumWidth()) {
+			moveRight(right, right.internalGetMinimumWidth() - width);
+			width = right.internalGetBounds().x - x;
+		}
+		item.setBounds(x, rowY, width, height);
+		if (width < item.internalGetMinimumWidth()) moveLeft(item, item.internalGetMinimumWidth() - width);
+	} else {
+		width = Math.max(item.internalGetMinimumWidth(), barWidth - x);
+		item.setBounds(x, rowY, width, height);
+		if (x + width > barWidth) moveLeft(item, x + width - barWidth); 
+	}
+	Rectangle bounds = item.internalGetBounds();
+	item.requestedWidth = bounds.width;
+	internalRedraw(bounds.x, bounds.y, item.internalGetMinimumWidth(), bounds.height);
+}
+void internalRedraw (int x, int y, int width, int height) {
+	if ((style & SWT.VERTICAL) != 0) {
+		redraw (y, x, height, width, false);
+	} else {
+		redraw (x, y, width, height, false);
+	}
+}
+void createItem (CoolItem item, int index) {
+	int itemCount = getItemCount(), row = 0;
+	if (!(0 <= index && index <= itemCount)) error (SWT.ERROR_INVALID_RANGE);
+	if (items.length == 0) {
+		items = new CoolItem[1][1];
+		items[0][0] = item;	
+	} else {
+		int i = index;
+		/* find the row to insert into */
+		if (index < itemCount) {
+			while (i > items[row].length) {
+				i -= items[row].length;
+				row++;
+			}   
+		} else {
+			row = items.length - 1;
+			i = items[row].length;	
+		}
+		
+		// Set the last item in the row to the preferred size 
+		// and add the new one just to it's right
+		int lastIndex = items[row].length - 1;
+		CoolItem lastItem = items[row][lastIndex];
+		if (lastItem.ideal) {
+			Rectangle bounds = lastItem.internalGetBounds();
+			bounds.width = lastItem.preferredWidth;
+			bounds.height = lastItem.preferredHeight;
+			lastItem.requestedWidth = lastItem.preferredWidth;
+			lastItem.setBounds(bounds.x, bounds.y, bounds.width, bounds.height);  
+		}
+		if (i == 0) {
+			item.wrap = true;
+			items[row][0].wrap = false;
+		}
+		int oldLength = items[row].length;
+		CoolItem[] newRow = new CoolItem[oldLength + 1];
+		System.arraycopy(items[row], 0, newRow, 0, i);
+		newRow[i] = item;
+		System.arraycopy(items[row], i, newRow, i + 1, oldLength - i);
+		items[row] = newRow;
+	}
+	item.requestedWidth = CoolItem.MINIMUM_WIDTH;
+	
+	int length = originalItems.length;
+	CoolItem [] newOriginals = new CoolItem [length + 1];
+	System.arraycopy (originalItems, 0, newOriginals, 0, index);
+	System.arraycopy (originalItems, index, newOriginals, index + 1, length - index);
+	newOriginals [index] = item;
+	originalItems = newOriginals;
+	layoutItems();
+
+}
+void destroyItem(CoolItem item) {
+	if (inDispose) return;
+	int row = findItem(item).y;
+	if (row == -1) return;
+	Rectangle bounds = item.internalGetBounds();
+	removeItemFromRow(item, row, true);
+	
+	int index = 0;
+	while (index < originalItems.length) {
+		if (originalItems [index] == item) break;
+		index++;
+	}
+	int length = originalItems.length - 1;
+	CoolItem [] newOriginals = new CoolItem [length];
+	System.arraycopy (originalItems, 0, newOriginals, 0, index);
+	System.arraycopy (originalItems, index + 1, newOriginals, index, length - index);
+	originalItems = newOriginals;
+	
+	internalRedraw(bounds.x, bounds.y, CoolItem.MINIMUM_WIDTH, bounds.height);
+	relayout();
+}
+void moveDown(CoolItem item, int x_root) {
+	int oldRowIndex = findItem(item).y;
+	boolean resize = false;
+	if (items[oldRowIndex].length == 1) {
+		resize = true;
+		/* If this is the only item in the bottom row, don't move it. */
+		if (oldRowIndex == items.length - 1) return;
+	}
+	int newRowIndex = (items[oldRowIndex].length == 1) ? oldRowIndex : oldRowIndex + 1;
+	removeItemFromRow(item, oldRowIndex, false);
+	Rectangle old = item.internalGetBounds();
+	internalRedraw(old.x, old.y, CoolItem.MINIMUM_WIDTH, old.height);
+	if (newRowIndex == items.length) {
+		/* Create a new bottom row for the item. */
+		CoolItem[][] newRows = new CoolItem[items.length + 1][];
+		System.arraycopy(items, 0, newRows, 0, items.length);
+		int row = items.length;
+		newRows[row] = new CoolItem[1];
+		newRows[row][0] = item;
+		items = newRows;
+		resize = true;
+		item.wrap = true;
+	} else {	
+		insertItemIntoRow(item, newRowIndex, x_root);
+	}
+	if (resize) {
+		relayout();
+	} else {
+		layoutItems();
+	}
+}
+void moveLeft(CoolItem item, int pixels) {
+	Point point = findItem(item);
+	int row = point.y;
+	int index = point.x;
+	if (index == 0) return;	
+	Rectangle bounds = item.internalGetBounds();
+	int minSpaceOnLeft = 0;
+	for (int i = 0; i < index; i++) {
+		minSpaceOnLeft += items[row][i].internalGetMinimumWidth();
+	}
+	int x = Math.max(minSpaceOnLeft, bounds.x - pixels);
+	CoolItem left = items[row][index - 1];
+	Rectangle leftBounds = left.internalGetBounds();
+	if (leftBounds.x + left.internalGetMinimumWidth() > x) {
+		int shift = leftBounds.x + left.internalGetMinimumWidth() - x;
+		moveLeft(left, shift);
+		leftBounds = left.internalGetBounds();
+	}
+	int leftWidth = Math.max(left.internalGetMinimumWidth(), leftBounds.width - pixels);
+	left.setBounds(leftBounds.x, leftBounds.y, leftWidth, leftBounds.height);
+	left.requestedWidth = leftWidth;
+	int width = bounds.width + (bounds.x - x);
+	item.setBounds(x, bounds.y, width, bounds.height);
+	item.requestedWidth = width;
+
+	int damagedWidth = bounds.x - x + CoolItem.MINIMUM_WIDTH;
+	if (damagedWidth > CoolItem.MINIMUM_WIDTH) {
+		internalRedraw(x, bounds.y, damagedWidth, bounds.height);
+	}
+}
+void moveRight(CoolItem item, int pixels) {
+	Point point = findItem(item);
+	int row = point.y;
+	int index = point.x;
+	if (index == 0) return;	
+	Rectangle bounds = item.internalGetBounds();
+	int minSpaceOnRight = 0;
+	for (int i = index; i < items[row].length; i++) {
+		minSpaceOnRight += items[row][i].internalGetMinimumWidth(); 
+	}
+	int max = getWidth() - minSpaceOnRight;
+	int x = Math.min(max, bounds.x + pixels);	
+	int width = 0;
+	if (index + 1 == items[row].length) {
+		width = getWidth() - x;
+	} else {
+		CoolItem right = items[row][index + 1];
+		Rectangle rightBounds = right.internalGetBounds();
+		if (x + item.internalGetMinimumWidth() > rightBounds.x) {
+			int shift = x + item.internalGetMinimumWidth() - rightBounds.x;
+			moveRight(right, shift);
+			rightBounds = right.internalGetBounds();
+		}
+		width = rightBounds.x - x;
+	}
+	item.setBounds(x, bounds.y, width, bounds.height);
+	item.requestedWidth = width;
+	CoolItem left = items[row][index - 1];
+	Rectangle leftBounds = left.internalGetBounds();
+	int leftWidth = x - leftBounds.x;
+	left.setBounds(leftBounds.x, leftBounds.y, leftWidth, leftBounds.height);
+	left.requestedWidth = leftWidth;
+	
+	int damagedWidth = x - bounds.x + CoolItem.MINIMUM_WIDTH + CoolItem.MARGIN_WIDTH;
+	if (x - bounds.x > 0) {
+		internalRedraw(bounds.x - CoolItem.MARGIN_WIDTH, bounds.y, damagedWidth, bounds.height);
+	}
+}
+void moveUp(CoolItem item, int x_root) {
+	Point point = findItem(item);
+	int oldRowIndex = point.y;
+	boolean resize = false;
+	if (items[oldRowIndex].length == 1) {
+		resize = true;
+		/* If this is the only item in the top row, don't move it. */
+		if (oldRowIndex == 0) return;
+	}
+	removeItemFromRow(item, oldRowIndex, false);
+	Rectangle old = item.internalGetBounds();
+	internalRedraw(old.x, old.y, CoolItem.MINIMUM_WIDTH, old.height);
+	int newRowIndex = Math.max(0, oldRowIndex - 1);
+	if (oldRowIndex == 0) {
+		/* Create a new top row for the item. */
+		CoolItem[][] newRows = new CoolItem[items.length + 1][];
+		System.arraycopy(items, 0, newRows, 1, items.length);
+		newRows[0] = new CoolItem[1];
+		newRows[0][0] = item;
+		items = newRows;
+		resize = true;
+		item.wrap = true;
+	} else {
+		insertItemIntoRow(item, newRowIndex, x_root);
+	}
+	if (resize) {
+		relayout();
+	} else {
+		layoutItems();
+	}
+}
+void onDispose(Event event) {
+	/*
+	 * Usually when an item is disposed, destroyItem will change the size of the items array
+	 * and reset the bounds of all the remaining cool items.
+	 * Since the whole cool bar is being disposed, this is not necessary.  For speed
+	 * the inDispose flag is used to skip over this part of the item dispose.
+	 */
+	if (inDispose) return;
+	inDispose = true;
+	notifyListeners(SWT.Dispose, event);
+	event.type = SWT.None;
+	for (int i = 0; i < items.length; i++) {
+		for (int j = 0; j < items[i].length; j++) {
+			items[i][j].dispose();
+		}
+	}
+	hoverCursor.dispose();
+	dragCursor.dispose();
+	cursor = null;
+}
+void onMouseDown(Event event) {
+	if (isLocked || event.button != 1) return;
+	fixEvent(event);
+	dragging = getGrabbedItem(event.x, event.y);
+	if (dragging != null) {
+		mouseXOffset = event.x;
+		itemXOffset = mouseXOffset - dragging.internalGetBounds().x;
+		_setCursor(dragCursor);
+	}
+	fixEvent(event);
+}
+void onMouseExit() {
+	if (dragging == null) _setCursor(null);
+}
+void onMouseMove(Event event) {
+	if (isLocked) return;
+	fixEvent(event);
+	CoolItem grabbed = getGrabbedItem(event.x, event.y);
+	if (dragging != null) {
+		int left_root = toDisplay(new Point(event.x - itemXOffset, event.y)).x;
+		Rectangle bounds = dragging.internalGetBounds();
+		if (event.y < bounds.y) {
+			moveUp(dragging, left_root);
+		} else if (event.y > bounds.y + bounds.height){
+			moveDown(dragging, left_root);
+		} else if (event.x < mouseXOffset) {
+			int distance = Math.min(mouseXOffset, bounds.x + itemXOffset) - event.x;
+			if (distance > 0) moveLeft(dragging, distance);
+		} else if (event.x > mouseXOffset) {
+			int distance = event.x - Math.max(mouseXOffset, bounds.x + itemXOffset);
+			if (distance > 0) moveRight(dragging, distance);
+		}
+		mouseXOffset = event.x;		
+	} else {
+		if (grabbed != null) {
+			_setCursor(hoverCursor);
+		} else {
+			_setCursor(null);	
+		}
+	}
+	fixEvent(event);
+}
+void onMouseUp(Event event) {
+	_setCursor(null);
+	dragging = null;
+}
+void onMouseDoubleClick(Event event) {
+	if (isLocked) return;	
+	dragging = null;
+	fixEvent(event);
+	CoolItem target = getGrabbedItem(event.x, event.y);
+	if (target == null) {
+		_setCursor(null);
+	} else {
+		Point location = findItem(target);
+		int row = location.y;
+		int index = location.x;
+		if (items[row].length > 1) {
+			Rectangle  bounds = target.internalGetBounds();
+			int maxSize = getWidth ();
+			for (int i = 0; i < items[row].length; i++) {
+				if (i != index) {
+					maxSize -= items[row][i].internalGetMinimumWidth();	
+				}
+			}
+			if (bounds.width == maxSize) {
+				/* The item is at its maximum width. It should be resized to its minimum width. */
+				int distance = bounds.width - target.internalGetMinimumWidth();
+				if (index + 1 < items[row].length) {
+					/* There is an item to the right. Maximize it. */
+					CoolItem right = items[row][index + 1];
+					moveLeft(right, distance);
+				} else {
+					/* There is no item to the right. Move the item all the way right. */
+					moveRight(target, distance);
+				}
+			} else if (bounds.width < target.preferredWidth) {
+				/* The item is less than its preferredWidth. Resize to preferredWidth. */
+				int distance = target.preferredWidth - bounds.width;
+				if (index + 1 < items[row].length) {
+					CoolItem right = items[row][index + 1];
+					moveRight(right, distance);	
+					distance = target.preferredWidth - target.internalGetBounds().width;
+				}
+				if (distance > 0) {
+					moveLeft(target, distance);
+				}
+			} else {
+				/* The item is at its minimum width. Maximize it. */
+				for (int i = 0; i < items[row].length; i++) {
+					if (i != index) {
+						CoolItem item = items[row][i];
+						item.requestedWidth = Math.max(item.internalGetMinimumWidth(), CoolItem.MINIMUM_WIDTH); 
+					}
+				}
+				target.requestedWidth = maxSize;
+				layoutItems();
+			}
+			_setCursor(hoverCursor);
+		}
+	}
+	fixEvent(event);
+}
+void onPaint(Event event) {
+	GC gc = event.gc;
+	if (items.length == 0) return;
+	Color shadowColor = display.getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW);
+	Color highlightColor = display.getSystemColor(SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW);
+	boolean vertical = (style & SWT.VERTICAL) != 0;
+	boolean flat = (style & SWT.FLAT) != 0;
+	int stopX = getWidth();
+	Rectangle rect;
+	Rectangle clipping = gc.getClipping();
+	for (int row = 0; row < items.length; row++) {
+		Rectangle bounds = new Rectangle(0, 0, 0, 0);
+		for (int i = 0; i < items[row].length; i++) {
+			bounds = items[row][i].internalGetBounds();
+			rect = fixRectangle(bounds.x, bounds.y, bounds.width, bounds.height);
+			if (!clipping.intersects(rect)) continue;
+			boolean nativeGripper = false;
+			
+			/* Draw gripper. */
+			if (!isLocked) {
+				rect = fixRectangle(bounds.x, bounds.y, CoolItem.MINIMUM_WIDTH, bounds.height);
+				if (!flat) 	nativeGripper = drawGripper(rect.x, rect.y, rect.width, rect.height, vertical);
+				if (!nativeGripper) {
+					int grabberTrim = 2; 
+					int grabberHeight = bounds.height - (2 * grabberTrim) - 1;
+					gc.setForeground(shadowColor);
+					rect = fixRectangle(
+							bounds.x + CoolItem.MARGIN_WIDTH, 
+							bounds.y + grabberTrim, 
+							2, 
+							grabberHeight);
+					gc.drawRectangle(rect);
+					gc.setForeground(highlightColor);
+					rect = fixRectangle(
+							bounds.x + CoolItem.MARGIN_WIDTH, 
+							bounds.y + grabberTrim + 1, 
+							bounds.x + CoolItem.MARGIN_WIDTH, 
+							bounds.y + grabberTrim + grabberHeight - 1);
+					gc.drawLine(rect.x, rect.y, rect.width, rect.height);
+					rect = fixRectangle(
+							bounds.x + CoolItem.MARGIN_WIDTH, 
+							bounds.y + grabberTrim, 
+							bounds.x + CoolItem.MARGIN_WIDTH + 1, 
+							bounds.y + grabberTrim);
+					gc.drawLine(rect.x, rect.y, rect.width, rect.height);
+				}
+			}
+			
+			/* Draw separator. */
+			if (!flat && !nativeGripper && i != 0) {
+				gc.setForeground(shadowColor);
+				rect = fixRectangle(bounds.x, bounds.y, bounds.x, bounds.y + bounds.height - 1);
+				gc.drawLine(rect.x, rect.y, rect.width, rect.height);
+				gc.setForeground(highlightColor);
+				rect = fixRectangle(bounds.x + 1, bounds.y, bounds.x + 1, bounds.y + bounds.height - 1);
+				gc.drawLine(rect.x, rect.y, rect.width, rect.height);
+			}
+		}
+		if (!flat && row + 1 < items.length) {
+			/* Draw row separator. */
+			int separatorY = bounds.y + bounds.height;
+			gc.setForeground(shadowColor);
+			rect = fixRectangle(0, separatorY, stopX, separatorY);
+			gc.drawLine(rect.x, rect.y, rect.width, rect.height);	
+			gc.setForeground(highlightColor);
+			rect = fixRectangle(0, separatorY + 1, stopX, separatorY + 1);
+			gc.drawLine(rect.x, rect.y, rect.width, rect.height);
+		}
+	}
+}
+void onResize () {
+	layoutItems ();
+}
+void removeControl (Control control) {
+	super.removeControl (control);
+	CoolItem [] items = getItems ();
+	for (int i=0; i<items.length; i++) {
+		CoolItem item = items [i];
+		if (item.control == control) item.setControl (null);
+	}
+}
+/**
+ * Remove the item from the row. Adjust the x and width values
+ * appropriately.
+ */
+void removeItemFromRow(CoolItem item, int rowIndex, boolean disposed) {
+	int index = findItem(item).x;
+	int newLength = items[rowIndex].length - 1;
+	Rectangle itemBounds = item.internalGetBounds();
+	item.wrap = false;
+	if (newLength > 0) {
+		CoolItem[] newRow = new CoolItem[newLength];
+		System.arraycopy(items[rowIndex], 0, newRow, 0, index);
+		System.arraycopy(items[rowIndex], index + 1, newRow, index, newRow.length - index);
+		items[rowIndex] = newRow;
+		items[rowIndex][0].wrap = true;
+	} else {
+		CoolItem[][] newRows = new CoolItem[items.length - 1][];
+		System.arraycopy(items, 0, newRows, 0, rowIndex);
+		System.arraycopy(items, rowIndex + 1, newRows, rowIndex, newRows.length - rowIndex);
+		items = newRows;
+		return;
+	}
+	if (!disposed) {
+		if (index == 0) {
+			CoolItem first = items[rowIndex][0];
+			Rectangle bounds = first.internalGetBounds();
+			int width = bounds.x + bounds.width;
+			first.setBounds(0, bounds.y, width, bounds.height);
+			first.requestedWidth = width;
+			internalRedraw(bounds.x, bounds.y, CoolItem.MINIMUM_WIDTH, bounds.height);
+		} else {
+			CoolItem previous = items[rowIndex][index - 1];
+			Rectangle bounds = previous.internalGetBounds();
+			int width = bounds.width + itemBounds.width;
+			previous.setBounds(bounds.x, bounds.y, width, bounds.height);
+			previous.requestedWidth = width;
+		}
+	}
+}
+/**
+ * Return the height of the bar after it has
+ * been properly laid out for the given width.
+ */
+int layoutItems () {
+	int y = 0, width;
+	if ((style&SWT.VERTICAL) != 0) {
+		width = getClientArea().height; 
+	} else {
+		width = getClientArea().width;
+	}
+	wrapItems(width);
+	int rowSpacing = (style & SWT.FLAT) != 0 ? 0 : ROW_SPACING; 
+	for (int row = 0; row < items.length; row++) {
+		int count = items[row].length;
+		int x = 0;
+
+		/* determine the height and the available width for the row */
+		int rowHeight = 0;
+		int available = width;
+		for (int i = 0; i < count; i++) {
+			CoolItem item = items[row][i];
+			rowHeight = Math.max(rowHeight, item.internalGetBounds().height);
+			available -= item.internalGetMinimumWidth();	
+		}
+		if (row > 0) y += rowSpacing;
+	
+		/* lay the items out */
+		for (int i = 0; i < count; i++) {
+			CoolItem child = items[row][i];
+			int newWidth = available + child.internalGetMinimumWidth();
+			if (i + 1 < count) {
+				newWidth = Math.min(newWidth, child.requestedWidth);
+				available -= (newWidth - child.internalGetMinimumWidth());
+			}
+			Rectangle oldBounds = child.internalGetBounds();
+			Rectangle newBounds = new Rectangle(x, y, newWidth, rowHeight);
+			if (!oldBounds.equals(newBounds)) {
+				child.setBounds(newBounds.x, newBounds.y, newBounds.width, newBounds.height);
+				Rectangle damage = new Rectangle(0, 0, 0, 0);
+				/* Cases are in descending order from most area to redraw to least. */
+				if (oldBounds.y != newBounds.y) {
+					damage = newBounds;
+					damage.add(oldBounds);
+					/* Redraw the row separator as well. */
+					damage.y -= rowSpacing;
+					damage.height += 2 * rowSpacing;
+				} else if (oldBounds.height != newBounds.height) {
+					/* 
+					 * Draw from the bottom of the gripper to the bottom of the new area.
+					 * (Bottom of the gripper is -3 from the bottom of the item).
+					 */
+					damage.y = newBounds.y + Math.min(oldBounds.height, newBounds.height) - 3;
+					damage.height = newBounds.y + newBounds.height + rowSpacing;
+					damage.x = oldBounds.x - CoolItem.MARGIN_WIDTH;
+					damage.width = oldBounds.width + CoolItem.MARGIN_WIDTH;
+				} else if (oldBounds.x != newBounds.x) {
+					/* Redraw only the difference between the separators. */
+					damage.x = Math.min(oldBounds.x, newBounds.x);
+					damage.width = Math.abs(oldBounds.x - newBounds.x) + CoolItem.MINIMUM_WIDTH;
+					damage.y = oldBounds.y;
+					damage.height = oldBounds.height;
+				}
+				internalRedraw(damage.x, damage.y, damage.width, damage.height);
+			}
+			x += newWidth;
+		}
+		y += rowHeight;
+	}
+	return y;
+}
+void relayout() {
+	Point size = getSize();
+	int height = layoutItems();
+	if ((style & SWT.VERTICAL) != 0) {
+		Rectangle trim = computeTrim (0, 0, height, 0);
+		if (height != size.x) super.setSize(trim.width, size.y);
+	} else {
+		Rectangle trim = computeTrim (0, 0, 0, height);
+		if (height != size.y) super.setSize(size.x, trim.height);		
+	}
+}
+/**
+ * Returns an array of zero-relative ints that map
+ * the creation order of the receiver's items to the
+ * order in which they are currently being displayed.
+ * <p>
+ * Specifically, the indices of the returned array represent
+ * the current visual order of the items, and the contents
+ * of the array represent the creation order of the items.
+ * </p><p>
+ * Note: This is not the actual structure used by the receiver
+ * to maintain its list of items, so modifying the array will
+ * not affect the receiver. 
+ * </p>
+ *
+ * @return the current visual order of the receiver's items
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int[] getItemOrder () {
+	checkWidget ();
+	int count = getItemCount ();
+	int [] indices = new int [count];
+	count = 0;
+	for (int i = 0; i < items.length; i++) {
+		for (int j = 0; j < items[i].length; j++) {
+			CoolItem item = items[i][j];
+			int index = 0;
+			while (index<originalItems.length) {
+				if (originalItems [index] == item) break;
+				index++;	
+			}
+			if (index == originalItems.length) error (SWT.ERROR_CANNOT_GET_ITEM);
+			indices [count++] = index;
+		}
+	}
+	return indices;
+}
+void setItemOrder (int[] itemOrder) {
+	if (itemOrder == null) error(SWT.ERROR_NULL_ARGUMENT);
+	int count = originalItems.length;
+	if (itemOrder.length != count) error(SWT.ERROR_INVALID_ARGUMENT);
+
+	/* Ensure that itemOrder does not contain any duplicates. */	
+	boolean [] set = new boolean [count];
+	for (int i = 0; i < set.length; i++) set [i] = false;
+	for (int i = 0; i < itemOrder.length; i++) {
+		if (itemOrder [i] < 0 || itemOrder [i] >= count) error (SWT.ERROR_INVALID_ARGUMENT);
+		if (set [itemOrder [i]]) error (SWT.ERROR_INVALID_ARGUMENT);
+		set [itemOrder [i]] = true;
+	}
+	
+	CoolItem[] row = new CoolItem[count];
+	for (int i = 0; i < count; i++) {
+		row[i] = originalItems[itemOrder[i]];
+	}
+	items = new CoolItem[1][count];
+	items[0] = row;
+}
+/**
+ * Returns an array of points whose x and y coordinates describe
+ * the widths and heights (respectively) of the items in the receiver
+ * in the order in which they are currently being displayed.
+ *
+ * @return the receiver's item sizes in their current visual order
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Point[] getItemSizes () {
+	checkWidget();
+	CoolItem[] items = getItems();
+	Point[] sizes = new Point[items.length];
+	for (int i = 0; i < items.length; i++) {
+		sizes[i] = items[i].getSize();
+	}
+	return sizes;
+}
+void setItemSizes (Point[] sizes) {
+	if (sizes == null) error(SWT.ERROR_NULL_ARGUMENT);
+	CoolItem[] items = getItems();
+	if (sizes.length != items.length) error(SWT.ERROR_INVALID_ARGUMENT);
+	for (int i = 0; i < items.length; i++) {
+		items[i].setSize(sizes[i]);
+	}
+}
+/**
+ * Returns whether or not the receiver is 'locked'. When a coolbar
+ * is locked, its items cannot be repositioned.
+ *
+ * @return true if the coolbar is locked, false otherwise
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 2.0
+ */
+public boolean getLocked () {
+	checkWidget ();
+	return isLocked;
+}
+int getWidth () {
+	if ((style & SWT.VERTICAL) != 0) return getSize().y;
+	return getSize().x;	
+}
+/**
+ * Returns an array of ints that describe the zero-relative
+ * indices of any item(s) in the receiver that will begin on
+ * a new row. The 0th visible item always begins the first row,
+ * therefore it does not count as a wrap index.
+ *
+ * @return an array containing the receiver's wrap indices, or an empty array if all items are in one row
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int[] getWrapIndices () {
+	checkWidget();
+	if (items.length <= 1) return new int[]{};
+	int[] wrapIndices = new int[items.length - 1];
+	int i = 0, nextWrap = items[0].length;
+	for (int row = 1; row < items.length; row++) {
+		if (items[row][0].wrap) wrapIndices[i++] = nextWrap;
+		nextWrap += items[row].length;
+	}
+	if (i != wrapIndices.length) {
+		int[] tmp = new int[i];
+		System.arraycopy(wrapIndices, 0, tmp, 0, i);
+		return tmp;
+	}
+	return wrapIndices;
+}
+/**
+ * Sets whether or not the receiver is 'locked'. When a coolbar
+ * is locked, its items cannot be repositioned.
+ *
+ * @param locked lock the coolbar if true, otherwise unlock the coolbar
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 2.0
+ */
+public void setLocked (boolean locked) {
+	checkWidget ();
+	if (isLocked != locked) {
+		redraw();
+	}
+	isLocked = locked;
+	
+}
+/**
+ * Sets the indices of all item(s) in the receiver that will
+ * begin on a new row. The indices are given in the order in
+ * which they are currently being displayed. The 0th item
+ * always begins the first row, therefore it does not count
+ * as a wrap index. If indices is null or empty, the items
+ * will be placed on one line.
+ *
+ * @param indices an array of wrap indices, or null
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setWrapIndices (int[] indices) {
+	checkWidget();
+	if (indices == null) indices = new int[0];
+	int count = originalItems.length;
+	for (int i=0; i<indices.length; i++) {
+		if (indices[i] < 0 || indices[i] >= count) {
+			error (SWT.ERROR_INVALID_ARGUMENT);
+		}
+	}
+	for (int i=0; i<originalItems.length; i++) {
+		originalItems[i].wrap = false;
+	}
+	for (int i=0; i<indices.length; i++) {
+		int index = indices[i];
+		for (int row = 0; row < items.length; row++) {
+			if (items[row].length > index) {
+				items[row][index].wrap = true;
+				break;
+			} else {
+				index -= items[row].length;
+			}
+		}
+	}
+	relayout();
+}
+public void setCursor (Cursor cursor) {
+	checkWidget ();
+	super.setCursor (this.cursor = cursor);
+}
+/**
+ * Sets the receiver's item order, wrap indices, and item sizes
+ * all at once. This method is typically used to restore the
+ * displayed state of the receiver to a previously stored state.
+ * <p>
+ * The item order is the order in which the items in the receiver
+ * should be displayed, given in terms of the zero-relative ordering
+ * of when the items were added.
+ * </p><p>
+ * The wrap indices are the indices of all item(s) in the receiver
+ * that will begin on a new row. The indices are given in the order
+ * specified by the item order. The 0th item always begins the first
+ * row, therefore it does not count as a wrap index. If wrap indices
+ * is null or empty, the items will be placed on one line.
+ * </p><p>
+ * The sizes are specified in an array of points whose x and y
+ * coordinates describe the new widths and heights (respectively)
+ * of the receiver's items in the order specified by the item order.
+ * </p>
+ *
+ * @param itemOrder an array of indices that describe the new order to display the items in
+ * @param wrapIndices an array of wrap indices, or null
+ * @param sizes an array containing the new sizes for each of the receiver's items in visual order
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if item order or sizes is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if item order or sizes is not the same length as the number of items</li>
+ * </ul>
+ */
+public void setItemLayout (int[] itemOrder, int[] wrapIndices, Point[] sizes) {
+	checkWidget();
+	setItemOrder(itemOrder);
+	setWrapIndices(wrapIndices);
+	setItemSizes(sizes);	
+	relayout();
+}
+void wrapItems (int maxWidth) {
+	int itemCount = originalItems.length;
+	if (itemCount < 2) return;
+	CoolItem[] itemsVisual = new CoolItem[itemCount];
+	int start = 0;
+	for (int row = 0; row < items.length; row++) {
+		System.arraycopy(items[row], 0, itemsVisual, start, items[row].length);
+		start += items[row].length;
+	}
+	CoolItem[][] newItems = new CoolItem[itemCount][];
+	int rowCount = 0, rowWidth =  0;
+	start = 0;
+	for (int i = 0; i < itemCount; i++) {
+		CoolItem item = itemsVisual[i];
+		int itemWidth = item.internalGetMinimumWidth();
+		if ((i > 0 && item.wrap) || (maxWidth != SWT.DEFAULT && rowWidth + itemWidth > maxWidth)) {
+			if (i == start) {
+				newItems[rowCount] = new CoolItem[1];
+				newItems[rowCount][0] = item;
+				start = i + 1;
+				rowWidth = 0;
+			} else {
+				int count = i - start;
+				newItems[rowCount] = new CoolItem[count];
+				System.arraycopy(itemsVisual, start, newItems[rowCount], 0, count);
+				start = i;
+				rowWidth = itemWidth;
+			}
+			rowCount++;			
+		} else {
+			rowWidth += itemWidth;
+		}
+	}
+	if (start < itemCount) {
+		int count = itemCount - start;
+		newItems[rowCount] = new CoolItem[count];
+		System.arraycopy(itemsVisual, start, newItems[rowCount], 0, count);
+		rowCount++;		
+	}
+	if (newItems.length != rowCount) {
+		CoolItem[][] tmp = new CoolItem[rowCount][];
+		System.arraycopy(newItems, 0, tmp, 0, rowCount);
+		items = tmp;
+	} else {
+		items = newItems;
+	}
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/CoolItem.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/CoolItem.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/CoolItem.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,652 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.widgets;
+
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
+ 
+/**
+ * Instances of this class are selectable user interface
+ * objects that represent the dynamically positionable
+ * areas of a <code>CoolBar</code>.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>DROP_DOWN</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Selection</dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ * 
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public class CoolItem extends Item {
+	Control control;
+	CoolBar parent;
+	boolean ideal;
+	int preferredWidth, preferredHeight, minimumWidth, minimumHeight, requestedWidth;
+	Rectangle itemBounds = new Rectangle(0, 0, 0, 0);
+	
+	static final int MARGIN_WIDTH = 4;
+	static final int GRABBER_WIDTH = 2;
+	static final int MINIMUM_WIDTH = (2 * MARGIN_WIDTH) + GRABBER_WIDTH;
+	
+	private int CHEVRON_HORIZONTAL_TRIM = -1;			//platform dependent values
+	private int CHEVRON_VERTICAL_TRIM = -1;	
+	private static final int CHEVRON_LEFT_MARGIN = 2;
+	private static final int CHEVRON_IMAGE_WIDTH = 8;	//Width to draw the double arrow
+	
+	ToolBar chevron;
+	boolean wrap;
+	Image arrowImage = null;
+	
+/**
+ * Constructs a new instance of this class given its parent
+ * (which must be a <code>CoolBar</code>) and a style value
+ * describing its behavior and appearance. The item is added
+ * to the end of the items maintained by its parent.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT#DROP_DOWN
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public CoolItem (CoolBar parent, int style) {
+	super(parent, style);
+	this.parent = parent;
+	parent.createItem (this, parent.getItemCount());
+	calculateChevronTrim ();
+}
+/**
+ * Constructs a new instance of this class given its parent
+ * (which must be a <code>CoolBar</code>), a style value
+ * describing its behavior and appearance, and the index
+ * at which to place it in the items maintained by its parent.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ * @param index the zero-relative index at which to store the receiver in its parent
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the parent (inclusive)</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT#DROP_DOWN
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public CoolItem (CoolBar parent, int style, int index) {
+	super(parent, style);
+	this.parent = parent;
+	parent.createItem (this, index);
+	calculateChevronTrim ();
+}
+/**
+ * Adds the listener to the collection of listeners that will
+ * be notified when the control is selected by the user, by sending it one
+ * of the messages defined in the <code>SelectionListener</code>
+ * interface.
+ * <p>
+ * If <code>widgetSelected</code> is called when the mouse is over
+ * the drop-down arrow (or 'chevron') portion of the cool item,
+ * the event object detail field contains the value <code>SWT.ARROW</code>,
+ * and the x and y fields in the event object represent the point at
+ * the bottom left of the chevron, where the menu should be popped up.
+ * <code>widgetDefaultSelected</code> is not called.
+ * </p>
+ *
+ * @param listener the listener which should be notified when the control is selected by the user
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent
+ * 
+ * @since 2.0
+ */
+public void addSelectionListener(SelectionListener listener) {
+	checkWidget();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	TypedListener typedListener = new TypedListener (listener);
+	addListener (SWT.Selection,typedListener);
+	addListener (SWT.DefaultSelection,typedListener);
+}
+protected void checkSubclass () {
+	if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
+}
+/* 
+ * Find the trim size of the Toolbar widget in the current platform.
+ */
+void calculateChevronTrim () {
+	ToolBar tb = new ToolBar (parent, SWT.FLAT);
+	ToolItem ti = new ToolItem (tb, SWT.PUSH);
+	Image image = new Image (display, 1, 1);
+	ti.setImage (image);
+	Point size = tb.computeSize (SWT.DEFAULT, SWT.DEFAULT);
+	size = parent.fixPoint(size.x, size.y);
+	CHEVRON_HORIZONTAL_TRIM = size.x - 1;
+	CHEVRON_VERTICAL_TRIM = size.y - 1;
+	tb.dispose ();
+	ti.dispose ();
+	image.dispose ();
+}
+/**
+ * Returns the preferred size of the receiver.
+ * <p>
+ * The <em>preferred size</em> of a <code>CoolItem</code> is the size that
+ * it would best be displayed at. The width hint and height hint arguments
+ * allow the caller to ask the instance questions such as "Given a particular
+ * width, how high does it need to be to show all of the contents?"
+ * To indicate that the caller does not wish to constrain a particular 
+ * dimension, the constant <code>SWT.DEFAULT</code> is passed for the hint. 
+ * </p>
+ *
+ * @param wHint the width hint (can be <code>SWT.DEFAULT</code>)
+ * @param hHint the height hint (can be <code>SWT.DEFAULT</code>)
+ * @return the preferred size
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see Layout
+ * @see #getBounds
+ * @see #getSize
+ * @see Control#getBorderWidth
+ * @see Scrollable#computeTrim
+ * @see Scrollable#getClientArea
+ */
+public Point computeSize (int wHint, int hHint) {
+	checkWidget();
+	int width = wHint, height = hHint;
+	if (wHint == SWT.DEFAULT) width = 32;
+	if (hHint == SWT.DEFAULT) height = 32;
+	if ((parent.style & SWT.VERTICAL) != 0) {
+		height += MINIMUM_WIDTH;
+	} else {
+		width += MINIMUM_WIDTH;
+	}	
+	return new Point (width, height);
+}
+public void dispose () {
+	if (isDisposed()) return;
+	
+	/*
+	 * Must call parent.destroyItem() before super.dispose(), since it needs to
+	 * query the bounds to properly remove the item.
+	 */
+	parent.destroyItem(this);
+	super.dispose ();
+	parent = null;
+	control = null;
+	
+	/* 
+	 * Although the parent for the chevron is the CoolBar (CoolItem can not be the parent)
+	 * it has to be disposed with the item 
+	 */
+	if (chevron != null && !chevron.isDisposed()) chevron.dispose();
+	chevron = null;
+	if (arrowImage != null && !arrowImage.isDisposed()) arrowImage.dispose();
+	arrowImage = null;
+}
+
+Image createArrowImage (int width, int height) {
+	Point point = parent.fixPoint(width, height);
+	width = point.x;
+	height = point.y;
+	Color foreground = parent.getForeground ();
+	Color black = display.getSystemColor (SWT.COLOR_BLACK);
+	Color background = parent.getBackground ();
+	
+	PaletteData palette = new PaletteData (new RGB[]{foreground.getRGB(), background.getRGB(), black.getRGB()});
+	ImageData imageData = new ImageData (width, height, 4, palette);
+	imageData.transparentPixel = 1;
+	Image image = new Image (display, imageData);
+		
+	GC gc = new GC (image, parent.getStyle() & SWT.RIGHT_TO_LEFT);
+	gc.setBackground (background);
+	gc.fillRectangle (0, 0, width, height);
+	gc.setForeground (black);
+	
+	int startX = 0 ;
+	if ((parent.style & SWT.VERTICAL) != 0) {
+		startX = width - CHEVRON_IMAGE_WIDTH;
+	}
+	int startY = height / 6; 
+	int step = 2;	
+	gc.drawLine (startX, startY, startX + step, startY + step);
+	gc.drawLine (startX, startY + (2 * step), startX + step, startY + step);
+	startX++;
+	gc.drawLine (startX, startY, startX + step, startY + step);
+	gc.drawLine (startX, startY + (2 * step), startX + step, startY + step);
+	startX += 3;
+	gc.drawLine (startX, startY, startX + step, startY + step);
+	gc.drawLine (startX, startY + (2 * step), startX + step, startY + step);
+	startX++;
+	gc.drawLine (startX, startY, startX + step, startY + step);
+	gc.drawLine (startX, startY + (2 * step), startX + step, startY + step);
+	gc.dispose ();
+	return image;
+}
+/**
+ * Returns a rectangle describing the receiver's size and location
+ * relative to its parent.
+ *
+ * @return the receiver's bounding rectangle
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Rectangle getBounds () {
+	checkWidget();
+	return parent.fixRectangle(itemBounds.x, itemBounds.y, itemBounds.width, itemBounds.height);
+}
+Rectangle internalGetBounds () {
+	return new Rectangle(itemBounds.x, itemBounds.y, itemBounds.width, itemBounds.height);
+}
+/**
+ * Returns the control that is associated with the receiver.
+ *
+ * @return the control that is contained by the receiver
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Control getControl () {
+	checkWidget();
+	return control;
+}
+/**
+ * Returns the minimum size that the cool item can
+ * be resized to using the cool item's gripper.
+ * 
+ * @return a point containing the minimum width and height of the cool item, in pixels
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 2.0
+ */
+public Point getMinimumSize () {
+	checkWidget();
+	return parent.fixPoint(minimumWidth, minimumHeight);
+}
+/**
+ * Returns the receiver's parent, which must be a <code>CoolBar</code>.
+ *
+ * @return the receiver's parent
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public CoolBar getParent () {
+	checkWidget();
+	return parent;
+}
+/**
+ * Returns a point describing the receiver's ideal size.
+ * The x coordinate of the result is the ideal width of the receiver.
+ * The y coordinate of the result is the ideal height of the receiver.
+ *
+ * @return the receiver's ideal size
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Point getPreferredSize () {
+	checkWidget();
+	return parent.fixPoint(preferredWidth, preferredHeight);
+}
+/**
+ * Returns a point describing the receiver's size. The
+ * x coordinate of the result is the width of the receiver.
+ * The y coordinate of the result is the height of the
+ * receiver.
+ *
+ * @return the receiver's size
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Point getSize () {
+	checkWidget();
+	return parent.fixPoint(itemBounds.width, itemBounds.height);
+}
+int internalGetMinimumWidth () {
+	int width = minimumWidth + MINIMUM_WIDTH;
+	if ((style & SWT.DROP_DOWN) != 0 && width < preferredWidth) {
+		width += CHEVRON_IMAGE_WIDTH + CHEVRON_HORIZONTAL_TRIM + CHEVRON_LEFT_MARGIN;
+	}
+	return width;
+}
+/*
+ *  Called when the chevron is selected.
+ */
+void onSelection (Event ev) {
+	Rectangle bounds = chevron.getBounds();
+	Event event = new Event();
+	event.detail = SWT.ARROW;
+	if ((parent.style & SWT.VERTICAL) != 0) {
+		event.x = bounds.x + bounds.width;
+		event.y = bounds.y;
+	} else {
+		event.x = bounds.x;
+		event.y = bounds.y + bounds.height;
+	}
+	postEvent (SWT.Selection, event);
+}
+/**
+ * Removes the listener from the collection of listeners that
+ * will be notified when the control is selected by the user.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #addSelectionListener
+ * 
+ * @since 2.0
+ */
+public void removeSelectionListener(SelectionListener listener) {
+	checkWidget();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if (eventTable == null) return;
+	eventTable.unhook (SWT.Selection, listener);
+	eventTable.unhook (SWT.DefaultSelection,listener);	
+}
+void setBounds (int x, int y, int width, int height) {
+	itemBounds.x = x;
+	itemBounds.y = y;
+	itemBounds.width = width;
+	itemBounds.height = height;
+	if (control != null) {
+		int controlWidth = width - MINIMUM_WIDTH;
+		if ((style & SWT.DROP_DOWN) != 0 && width < preferredWidth) {
+			controlWidth -= CHEVRON_IMAGE_WIDTH + CHEVRON_HORIZONTAL_TRIM + CHEVRON_LEFT_MARGIN;
+		}
+		control.setBounds (parent.fixRectangle(x + MINIMUM_WIDTH,	y, controlWidth, height));
+	}
+	updateChevron();
+}
+/**
+ * Sets the control that is associated with the receiver
+ * to the argument.
+ *
+ * @param control the new control that will be contained by the receiver
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the control has been disposed</li> 
+ *    <li>ERROR_INVALID_PARENT - if the control is not in the same widget tree</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setControl (Control control) {
+	checkWidget();
+	if (control != null) {
+		if (control.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);
+		if (control.parent != parent) error (SWT.ERROR_INVALID_PARENT);
+	}
+	this.control = control;
+	if (control != null) {
+		int controlWidth = itemBounds.width - MINIMUM_WIDTH;
+		if ((style & SWT.DROP_DOWN) != 0 && itemBounds.width < preferredWidth) {
+			controlWidth -= CHEVRON_IMAGE_WIDTH + CHEVRON_HORIZONTAL_TRIM + CHEVRON_LEFT_MARGIN;
+		}
+		control.setBounds (parent.fixRectangle(itemBounds.x + MINIMUM_WIDTH, itemBounds.y, controlWidth, itemBounds.height));
+	}
+}
+/**
+ * Sets the minimum size that the cool item can be resized to
+ * using the cool item's gripper, to the point specified by the arguments.
+ * 
+ * @param width the minimum width of the cool item, in pixels
+ * @param height the minimum height of the cool item, in pixels
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 2.0
+ */
+public void setMinimumSize (int width, int height) {
+	checkWidget ();
+	Point point = parent.fixPoint(width, height);
+	minimumWidth = point.x;
+	minimumHeight = point.y;
+}
+/**
+ * Sets the minimum size that the cool item can be resized to
+ * using the cool item's gripper, to the point specified by the argument.
+ * 
+ * @param size a point representing the minimum width and height of the cool item, in pixels
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the point is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 2.0
+ */
+public void setMinimumSize (Point size) {
+	checkWidget ();
+	if (size == null) error(SWT.ERROR_NULL_ARGUMENT);
+	setMinimumSize(size.x, size.y);
+}
+/**
+ * Sets the receiver's ideal size to the point specified by the arguments.
+ *
+ * @param width the new ideal width for the receiver
+ * @param height the new ideal height for the receiver
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setPreferredSize (int width, int height) {
+	checkWidget();
+	ideal = true;
+	Point point = parent.fixPoint(width, height);
+	preferredWidth = Math.max (point.x, MINIMUM_WIDTH);
+	preferredHeight = point.y;
+}
+/**
+ * Sets the receiver's ideal size to the point specified by the argument.
+ *
+ * @param size the new ideal size for the receiver
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the point is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setPreferredSize (Point size) {
+	checkWidget();
+	if (size == null) error(SWT.ERROR_NULL_ARGUMENT);
+	setPreferredSize(size.x, size.y);
+}
+/**
+ * Sets the receiver's size to the point specified by the arguments.
+ * <p>
+ * Note: Attempting to set the width or height of the
+ * receiver to a negative number will cause that
+ * value to be set to zero instead.
+ * </p>
+ *
+ * @param width the new width for the receiver
+ * @param height the new height for the receiver
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setSize (int width, int height) {
+	checkWidget();
+	Point point = parent.fixPoint(width, height);
+	width = Math.max(point.x, minimumWidth + MINIMUM_WIDTH);
+	height = point.y;
+	if (!ideal) {
+		preferredWidth = width;
+		preferredHeight = height;
+	}
+	itemBounds.width = requestedWidth = width;
+	itemBounds.height = height;
+	if (control != null) {
+		int controlWidth = width - MINIMUM_WIDTH;
+		if ((style & SWT.DROP_DOWN) != 0 && width < preferredWidth) {
+			controlWidth -= CHEVRON_IMAGE_WIDTH + CHEVRON_HORIZONTAL_TRIM + CHEVRON_LEFT_MARGIN;
+		}
+		control.setSize(parent.fixPoint(controlWidth, height));
+	}
+	parent.relayout();
+	updateChevron();
+}
+/**
+ * Sets the receiver's size to the point specified by the argument.
+ * <p>
+ * Note: Attempting to set the width or height of the
+ * receiver to a negative number will cause them to be
+ * set to zero instead.
+ * </p>
+ *
+ * @param size the new size for the receiver
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the point is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setSize (Point size) {
+	checkWidget();
+	if (size == null) error (SWT.ERROR_NULL_ARGUMENT);
+	setSize (size.x, size.y);
+}
+void updateChevron() {
+	if (control != null) {
+		int width = itemBounds.width;
+		if ((style & SWT.DROP_DOWN) != 0 && width < preferredWidth) {
+			if (chevron == null) {
+				chevron = new ToolBar (parent, SWT.FLAT | SWT.NO_FOCUS);
+				ToolItem toolItem = new ToolItem (chevron, SWT.PUSH);
+				toolItem.addListener (SWT.Selection, new Listener() {
+					public void handleEvent (Event event) {
+						CoolItem.this.onSelection (event);
+					}
+				});
+			}
+			int controlHeight, currentImageHeight = 0;
+			if ((parent.style & SWT.VERTICAL) != 0) {
+				controlHeight = control.getSize ().x;
+				if (arrowImage != null) currentImageHeight = arrowImage.getBounds().width;
+			} else {
+				controlHeight = control.getSize ().y;
+				if (arrowImage != null) currentImageHeight = arrowImage.getBounds().height;
+			}			
+			int height = Math.min (controlHeight, itemBounds.height);
+			int imageHeight = Math.max(1, height - CHEVRON_VERTICAL_TRIM);			
+			if (currentImageHeight != imageHeight) {
+				Image image = createArrowImage (CHEVRON_IMAGE_WIDTH, imageHeight);
+				chevron.getItem (0).setImage (image);
+				if (arrowImage != null) arrowImage.dispose ();
+				arrowImage = image;
+			}
+			chevron.setBackground (parent.getBackground());
+			chevron.setBounds (parent.fixRectangle (
+				itemBounds.x + width - CHEVRON_LEFT_MARGIN - CHEVRON_IMAGE_WIDTH - CHEVRON_HORIZONTAL_TRIM,
+				itemBounds.y,
+				CHEVRON_IMAGE_WIDTH + CHEVRON_HORIZONTAL_TRIM,
+				height));
+			chevron.setVisible(true);
+		} else {
+			if (chevron != null) {
+				chevron.setVisible(false);
+			}
+		}
+	}
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/DateTime.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/DateTime.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/DateTime.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,1078 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.widgets;
+
+import java.text.DateFormatSymbols;
+import java.util.Calendar;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.gtk.OS;
+
+/**
+ * Instances of this class are selectable user interface
+ * objects that allow the user to enter and modify date
+ * or time values.
+ * <p>
+ * Note that although this class is a subclass of <code>Composite</code>,
+ * it does not make sense to add children to it, or set a layout on it.
+ * </p>
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>DATE, TIME, CALENDAR, SHORT, MEDIUM, LONG</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Selection</dd>
+ * </dl>
+ * <p>
+ * Note: Only one of the styles DATE, TIME, or CALENDAR may be specified,
+ * and only one of the styles SHORT, MEDIUM, or LONG may be specified.
+ * </p><p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ * 
+ * @see <a href="http://www.eclipse.org/swt/snippets/#datetime">DateTime snippets</a>
+ * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: ControlExample</a>
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ *
+ * @since 3.3
+ */
+public class DateTime extends Composite {
+	int day, month, year, hours, minutes, seconds;
+	
+	static final int MIN_YEAR = 1752; // Gregorian switchover in North America: September 19, 1752
+	static final int MAX_YEAR = 9999;
+
+	/* Emulated DATE and TIME variables */
+	Calendar calendar;
+	DateFormatSymbols formatSymbols;
+	Button down, up;
+	Text text;
+	String format;
+	Point[] fieldIndices;
+	int[] fieldNames;
+	int fieldCount, currentField = 0, characterCount = 0;
+	boolean ignoreVerify = false;
+	static final String DEFAULT_SHORT_DATE_FORMAT = "MM/YYYY";
+	static final String DEFAULT_MEDIUM_DATE_FORMAT = "MM/DD/YYYY";
+	static final String DEFAULT_LONG_DATE_FORMAT = "MM/DD/YYYY";
+	static final String DEFAULT_SHORT_TIME_FORMAT = "HH:MM AM";
+	static final String DEFAULT_MEDIUM_TIME_FORMAT = "HH:MM:SS AM";
+	static final String DEFAULT_LONG_TIME_FORMAT = "HH:MM:SS AM";
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT#DATE
+ * @see SWT#TIME
+ * @see SWT#CALENDAR
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public DateTime (Composite parent, int style) {
+	super (parent, checkStyle (style));
+	if ((this.style & SWT.CALENDAR) == 0) {
+		/* SWT.DATE and SWT.TIME */
+		calendar = Calendar.getInstance();
+		formatSymbols = new DateFormatSymbols();
+		text = new Text(this, SWT.SINGLE);
+		/* disable the native drag and drop for the date/time text field */
+		OS.gtk_drag_dest_unset(text.handle);
+		if ((this.style & SWT.DATE) != 0) {
+			setFormat((this.style & SWT.SHORT) != 0 ? DEFAULT_SHORT_DATE_FORMAT : (this.style & SWT.LONG) != 0 ? DEFAULT_LONG_DATE_FORMAT : DEFAULT_MEDIUM_DATE_FORMAT);
+		} else { // SWT.TIME
+			setFormat((this.style & SWT.SHORT) != 0 ? DEFAULT_SHORT_TIME_FORMAT : (this.style & SWT.LONG) != 0 ? DEFAULT_LONG_TIME_FORMAT : DEFAULT_MEDIUM_TIME_FORMAT);
+		}
+		text.setText(getFormattedString(this.style));
+		Listener listener = new Listener() {
+			public void handleEvent(Event event) {
+				switch(event.type) {
+					case SWT.KeyDown: onKeyDown(event); break;
+					case SWT.FocusIn: onFocusIn(event); break;
+					case SWT.FocusOut: onFocusOut(event); break;
+					case SWT.MouseDown: onMouseClick(event); break;
+					case SWT.MouseUp: onMouseClick(event); break;
+					case SWT.Verify: onVerify(event); break;
+				}
+			}
+		};
+		text.addListener(SWT.KeyDown, listener);
+		text.addListener(SWT.FocusIn, listener);
+		text.addListener(SWT.FocusOut, listener);
+		text.addListener(SWT.MouseDown, listener);
+		text.addListener(SWT.MouseUp, listener);
+		text.addListener(SWT.Verify, listener);
+		up = new Button(this, SWT.ARROW | SWT.UP);
+		//up.setToolTipText(SWT.getMessage ("SWT_Up")); //$NON-NLS-1$
+		down = new Button(this, SWT.ARROW | SWT.DOWN);
+		//down.setToolTipText(SWT.getMessage ("SWT_Down")); //$NON-NLS-1$
+		up.addListener(SWT.Selection, new Listener() {
+			public void handleEvent(Event event) {
+				incrementField(+1);
+				text.setFocus();
+			}
+		});
+		down.addListener(SWT.Selection, new Listener() {
+			public void handleEvent(Event event) {
+				incrementField(-1);
+				text.setFocus();
+			}
+		});
+		addListener(SWT.Resize, new Listener() {
+			public void handleEvent(Event event) {
+				onResize(event);
+			}
+		});
+	}
+}
+
+static int checkStyle (int style) {
+	/*
+	* Even though it is legal to create this widget
+	* with scroll bars, they serve no useful purpose
+	* because they do not automatically scroll the
+	* widget's client area.  The fix is to clear
+	* the SWT style.
+	*/
+	style &= ~(SWT.H_SCROLL | SWT.V_SCROLL);
+	style = checkBits (style, SWT.DATE, SWT.TIME, SWT.CALENDAR, 0, 0, 0);
+	return checkBits (style, SWT.MEDIUM, SWT.SHORT, SWT.LONG, 0, 0, 0);
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the control is selected by the user, by sending
+ * it one of the messages defined in the <code>SelectionListener</code>
+ * interface.
+ * <p>
+ * <code>widgetSelected</code> is called when the user changes the control's value.
+ * <code>widgetDefaultSelected</code> is not called.
+ * </p>
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent
+ */
+public void addSelectionListener (SelectionListener listener) {
+	checkWidget ();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	TypedListener typedListener = new TypedListener (listener);
+	addListener (SWT.Selection, typedListener);
+	addListener (SWT.DefaultSelection, typedListener);
+}
+
+protected void checkSubclass () {
+	if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
+}
+
+public Point computeSize (int wHint, int hHint, boolean changed) {
+	checkWidget ();
+	int width = 0, height = 0;
+	if (wHint == SWT.DEFAULT || hHint == SWT.DEFAULT) {
+		if ((style & SWT.CALENDAR) != 0) {
+			// TODO: CALENDAR computeSize
+			width = 300;
+			height = 200;
+		} else {
+			/* SWT.DATE and SWT.TIME */
+			GC gc = new GC(text);
+			Point textSize = gc.stringExtent(getComputeSizeString(style));
+			gc.dispose();
+			Rectangle trim = text.computeTrim(0, 0, textSize.x, textSize.y);
+			Point buttonSize = up.computeSize(SWT.DEFAULT, SWT.DEFAULT, changed);
+			width = trim.width + buttonSize.x;
+			height = Math.max(trim.height, buttonSize.y);
+		}
+	}
+	if (width == 0) width = DEFAULT_WIDTH;
+	if (height == 0) height = DEFAULT_HEIGHT;
+	if (wHint != SWT.DEFAULT) width = wHint;
+	if (hHint != SWT.DEFAULT) height = hHint;
+	int border = getBorderWidth ();
+	width += border * 2; height += border * 2;
+	return new Point (width, height);
+}
+
+void createHandle (int index) {
+	if ((style & SWT.CALENDAR) != 0) {
+		state |= HANDLE;
+		fixedHandle = OS.g_object_new (display.gtk_fixed_get_type (), 0);
+		if (fixedHandle == 0) error (SWT.ERROR_NO_HANDLES);
+		OS.gtk_fixed_set_has_window (fixedHandle, true);
+		handle = OS.gtk_calendar_new ();
+		if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+		OS.gtk_container_add (fixedHandle, handle);
+		if (OS.GTK_VERSION >= OS.VERSION(2, 4, 0)) {
+			OS.gtk_calendar_set_display_options(handle, OS.GTK_CALENDAR_SHOW_HEADING | OS.GTK_CALENDAR_SHOW_DAY_NAMES);
+		} else {
+			OS.gtk_calendar_display_options(handle, OS.GTK_CALENDAR_SHOW_HEADING | OS.GTK_CALENDAR_SHOW_DAY_NAMES);			
+		}
+	} else {
+		super.createHandle(index);
+	}
+}
+
+void createWidget (int index) {
+	super.createWidget (index);
+	if ((style & SWT.CALENDAR) != 0) {
+		getDate();
+	}
+}
+
+void commitCurrentField() {
+	if (characterCount > 0) {
+		characterCount = 0;
+		int fieldName = fieldNames[currentField];
+		int start = fieldIndices[currentField].x;
+		int end = fieldIndices[currentField].y;
+		String value = text.getText(start, end - 1);
+		int s = value.lastIndexOf(' ');
+		if (s != -1) value = value.substring(s + 1);
+		int newValue = unformattedIntValue(fieldName, value, characterCount == 0, calendar.getActualMaximum(fieldName));
+		if (newValue != -1) setTextField(fieldName, newValue, true, true);
+	}
+}
+
+String formattedStringValue(int fieldName, int value, boolean adjust) {
+	if (fieldName == Calendar.AM_PM) {
+		String[] ampm = formatSymbols.getAmPmStrings();
+		return ampm[value];
+	}
+	if (adjust) {
+		if (fieldName == Calendar.HOUR && value == 0) {
+			return String.valueOf(12);
+		}
+		if (fieldName == Calendar.MONTH) {
+			return String.valueOf(value + 1);
+		}
+	}
+	return String.valueOf(value);
+}
+
+String getComputeSizeString(int style) {
+	if ((style & SWT.DATE) != 0) {
+		return (style & SWT.SHORT) != 0 ? DEFAULT_SHORT_DATE_FORMAT : (style & SWT.LONG) != 0 ? DEFAULT_LONG_DATE_FORMAT : DEFAULT_MEDIUM_DATE_FORMAT;
+	}
+	// SWT.TIME
+	return (style & SWT.SHORT) != 0 ? DEFAULT_SHORT_TIME_FORMAT : (style & SWT.LONG) != 0 ? DEFAULT_LONG_TIME_FORMAT : DEFAULT_MEDIUM_TIME_FORMAT;
+}
+
+int getFieldIndex(int fieldName) {
+	for (int i = 0; i < fieldCount; i++) {
+		if (fieldNames[i] == fieldName) {
+			return i;
+		}
+	}
+	return -1;
+}
+
+String getFormattedString(int style) {
+	if ((style & SWT.TIME) != 0) {
+		String[] ampm = formatSymbols.getAmPmStrings();
+		int h = calendar.get(Calendar.HOUR); if (h == 0) h = 12;
+		int m = calendar.get(Calendar.MINUTE);
+		int s = calendar.get(Calendar.SECOND);
+		int a = calendar.get(Calendar.AM_PM);
+		if ((style & SWT.SHORT) != 0) return "" + (h < 10 ? " " : "") + h + ":" + (m < 10 ? "0" : "") + m + " " + ampm[a];
+		return "" + (h < 10 ? " " : "") + h + ":" + (m < 10 ? "0" : "") + m + ":" + (s < 10 ? "0" : "") + s + " " + ampm[a];
+	}
+	/* SWT.DATE */
+	int y = calendar.get(Calendar.YEAR);
+	int m = calendar.get(Calendar.MONTH) + 1;
+	int d = calendar.get(Calendar.DAY_OF_MONTH);
+	if ((style & SWT.SHORT) != 0) return "" + (m < 10 ? " " : "") + m + "/" + y;
+	return "" + (m < 10 ? " " : "") + m + "/" + (d < 10 ? " " : "") + d + "/" + y;
+}
+
+void getDate() {
+	int [] y = new int [1];
+	int [] m = new int [1];
+	int [] d = new int [1];
+	OS.gtk_calendar_get_date(handle, y, m, d);
+	year = y[0];
+	month = m[0];
+	day = d[0];
+}
+
+/**
+ * Returns the receiver's date, or day of the month.
+ * <p>
+ * The first day of the month is 1, and the last day depends on the month and year.
+ * </p>
+ *
+ * @return a positive integer beginning with 1
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getDay () {
+	checkWidget ();
+	if ((style & SWT.CALENDAR) != 0) {
+		getDate();
+		return day;
+	} else {
+		return calendar.get(Calendar.DAY_OF_MONTH);
+	}
+}
+
+/**
+ * Returns the receiver's hours.
+ * <p>
+ * Hours is an integer between 0 and 23.
+ * </p>
+ *
+ * @return an integer between 0 and 23
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getHours () {
+	checkWidget ();
+	if ((style & SWT.CALENDAR) != 0) {
+		return hours;
+	} else {
+		return calendar.get(Calendar.HOUR_OF_DAY);
+	}
+}
+
+/**
+ * Returns the receiver's minutes.
+ * <p>
+ * Minutes is an integer between 0 and 59.
+ * </p>
+ *
+ * @return an integer between 0 and 59
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getMinutes () {
+	checkWidget ();
+	if ((style & SWT.CALENDAR) != 0) {
+		return minutes;
+	} else {
+		return calendar.get(Calendar.MINUTE);
+	}
+}
+
+/**
+ * Returns the receiver's month.
+ * <p>
+ * The first month of the year is 0, and the last month is 11.
+ * </p>
+ *
+ * @return an integer between 0 and 11
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getMonth () {
+	checkWidget ();
+	if ((style & SWT.CALENDAR) != 0) {
+		getDate();
+		return month;
+	} else {
+		return calendar.get(Calendar.MONTH);
+	}
+}
+
+String getNameText() {
+	return (style & SWT.TIME) != 0 ? getHours() + ":" + getMinutes() + ":" + getSeconds()
+			: (getMonth() + 1) + "/" + getDay() + "/" + getYear();
+}
+
+/**
+ * Returns the receiver's seconds.
+ * <p>
+ * Seconds is an integer between 0 and 59.
+ * </p>
+ *
+ * @return an integer between 0 and 59
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getSeconds () {
+	checkWidget ();
+	if ((style & SWT.CALENDAR) != 0) {
+		return seconds;
+	} else {
+		return calendar.get(Calendar.SECOND);
+	}
+}
+
+/**
+ * Returns the receiver's year.
+ * <p>
+ * The first year is 1752 and the last year is 9999.
+ * </p>
+ *
+ * @return an integer between 1752 and 9999
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getYear () {
+	checkWidget ();
+	if ((style & SWT.CALENDAR) != 0) {
+		getDate();
+		return year;
+	} else {
+		return calendar.get(Calendar.YEAR);
+	}
+}
+
+int /*long*/ gtk_day_selected (int /*long*/ widget) {
+	sendSelectionEvent ();
+	return 0;
+}
+
+int /*long*/ gtk_month_changed (int /*long*/ widget) {
+	sendSelectionEvent ();
+	return 0;
+}
+
+void hookEvents () {
+	super.hookEvents();
+	if ((style & SWT.CALENDAR) != 0) {
+		OS.g_signal_connect_closure (handle, OS.day_selected, display.closures [DAY_SELECTED], false);
+		OS.g_signal_connect_closure (handle, OS.month_changed, display.closures [MONTH_CHANGED], false);
+	}
+}
+
+boolean isValid(int fieldName, int value) {
+	Calendar validCalendar;
+	if ((style & SWT.CALENDAR) != 0) {
+		validCalendar = Calendar.getInstance();
+		validCalendar.set(Calendar.YEAR, year);
+		validCalendar.set(Calendar.MONTH, month);
+	} else {
+		validCalendar = calendar;
+	}
+	int min = validCalendar.getActualMinimum(fieldName);
+	int max = validCalendar.getActualMaximum(fieldName);
+	return value >= min && value <= max;
+}
+
+boolean isValid(int year, int month, int day) {
+	Calendar valid = Calendar.getInstance();
+	valid.set(year, month, day);
+	return valid.get(Calendar.YEAR) == year && valid.get(Calendar.MONTH) == month && valid.get(Calendar.DAY_OF_MONTH) == day;
+}
+
+void incrementField(int amount) {
+	int fieldName = fieldNames[currentField];
+	int value = calendar.get(fieldName);
+	if (fieldName == Calendar.HOUR) {
+		int max = calendar.getMaximum(Calendar.HOUR);
+		int min = calendar.getMinimum(Calendar.HOUR);
+		if ((value == max && amount == 1) || (value == min && amount == -1)) {
+			int temp = currentField;
+			currentField = getFieldIndex(Calendar.AM_PM);
+			setTextField(Calendar.AM_PM, (calendar.get(Calendar.AM_PM) + 1) % 2, true, true);
+			currentField = temp;
+		}
+	}
+	setTextField(fieldName, value + amount, true, true);
+}
+
+void onKeyDown(Event event) {
+	int fieldName;
+	switch (event.keyCode) {
+		case SWT.ARROW_RIGHT:
+		case SWT.KEYPAD_DIVIDE:
+			// a right arrow or a valid separator navigates to the field on the right, with wraping
+			selectField((currentField + 1) % fieldCount);
+			break;
+		case SWT.ARROW_LEFT:
+			// navigate to the field on the left, with wrapping
+			int index = currentField - 1;
+			selectField(index < 0 ? fieldCount - 1 : index);
+			break;
+		case SWT.ARROW_UP:
+		case SWT.KEYPAD_ADD:
+			// set the value of the current field to value + 1, with wrapping
+			commitCurrentField();
+			incrementField(+1);
+			break;
+		case SWT.ARROW_DOWN:
+		case SWT.KEYPAD_SUBTRACT:
+			// set the value of the current field to value - 1, with wrapping
+			commitCurrentField();
+			incrementField(-1);
+			break;
+		case SWT.HOME:
+			// set the value of the current field to its minimum
+			fieldName = fieldNames[currentField];
+			setTextField(fieldName, calendar.getActualMinimum(fieldName), true, true);
+			break;
+		case SWT.END:
+			// set the value of the current field to its maximum
+			fieldName = fieldNames[currentField];
+			setTextField(fieldName, calendar.getActualMaximum(fieldName), true, true);
+			break;
+		default:
+			switch (event.character) {
+				case '/':
+				case ':':
+				case '-':
+				case '.':
+					// a valid separator navigates to the field on the right, with wraping
+					selectField((currentField + 1) % fieldCount);
+					break;
+			}
+	}
+}
+
+void onFocusIn(Event event) {
+	selectField(currentField);
+}
+
+void onFocusOut(Event event) {
+	commitCurrentField();
+}
+
+void onMouseClick(Event event) {
+	if (event.button != 1) return;
+	Point sel = text.getSelection();
+	for (int i = 0; i < fieldCount; i++) {
+		if (sel.x >= fieldIndices[i].x && sel.x <= fieldIndices[i].y) {
+			currentField = i;
+			break;
+		}
+	}
+	selectField(currentField);
+}
+
+void onResize(Event event) {
+	Rectangle rect = getClientArea ();
+	int width = rect.width;
+	int height = rect.height;
+	Point buttonSize = up.computeSize(SWT.DEFAULT, height);
+	int buttonHeight = buttonSize.y / 2;
+	text.setBounds(0, 0, width - buttonSize.x, height);
+	up.setBounds(width - buttonSize.x, 0, buttonSize.x, buttonHeight);
+	down.setBounds(width - buttonSize.x, buttonHeight, buttonSize.x, buttonHeight);
+}
+
+void onVerify(Event event) {
+	if (ignoreVerify) return;
+	event.doit = false;
+	int fieldName = fieldNames[currentField];
+	int start = fieldIndices[currentField].x;
+	int end = fieldIndices[currentField].y;
+	int length = end - start;
+	String newText = event.text;
+	if (fieldName == Calendar.AM_PM) {
+		String[] ampm = formatSymbols.getAmPmStrings();
+		if (newText.equalsIgnoreCase(ampm[Calendar.AM].substring(0, 1)) || newText.equalsIgnoreCase(ampm[Calendar.AM])) {
+			setTextField(fieldName, Calendar.AM, true, false);
+		} else if (newText.equalsIgnoreCase(ampm[Calendar.PM].substring(0, 1)) || newText.equalsIgnoreCase(ampm[Calendar.PM])) {
+			setTextField(fieldName, Calendar.PM, true, false);
+		}
+		return;
+	}
+	if (characterCount > 0) {
+		try {
+			Integer.parseInt(newText);
+		} catch (NumberFormatException ex) {
+			return;
+		}
+		String value = text.getText(start, end - 1);
+		int s = value.lastIndexOf(' ');
+		if (s != -1) value = value.substring(s + 1);
+		newText = "" + value + newText;
+	}
+	int newTextLength = newText.length();
+	boolean first = characterCount == 0;
+	characterCount = (newTextLength < length) ? newTextLength : 0;
+	int max = calendar.getActualMaximum(fieldName);
+	int min = calendar.getActualMinimum(fieldName);
+	int newValue = unformattedIntValue(fieldName, newText, characterCount == 0, max);
+	if (newValue == -1) {
+		characterCount = 0;
+		return;
+	}
+	if (first && newValue == 0 && length > 1) {
+		setTextField(fieldName, newValue, false, false);
+	} else if (min <= newValue && newValue <= max) {
+		setTextField(fieldName, newValue, characterCount == 0, characterCount == 0);
+	} else {
+		if (newTextLength >= length) {
+			newText = newText.substring(newTextLength - length + 1);
+			newValue = unformattedIntValue(fieldName, newText, characterCount == 0, max);
+			if (newValue != -1) {
+				characterCount = length - 1;
+				if (min <= newValue && newValue <= max) {
+					setTextField(fieldName, newValue, characterCount == 0, true);
+				}
+			}
+		}
+	}
+}
+
+void releaseWidget () {
+	super.releaseWidget();
+	//TODO: need to do anything here?
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the control is selected by the user.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #addSelectionListener
+ */
+public void removeSelectionListener (SelectionListener listener) {
+	checkWidget ();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if (eventTable == null) return;
+	eventTable.unhook (SWT.Selection, listener);
+	eventTable.unhook (SWT.DefaultSelection, listener);	
+}
+
+void selectField(int index) {
+	if (index != currentField) {
+		commitCurrentField();
+	}
+	final int start = fieldIndices[index].x;
+	final int end = fieldIndices[index].y;
+	Point pt = text.getSelection();
+	if (index == currentField && start == pt.x && end == pt.y) return;
+	currentField = index;
+	display.asyncExec(new Runnable() {
+		public void run() {
+			if (!text.isDisposed()) {
+				String value = text.getText(start, end - 1);
+				int s = value.lastIndexOf(' ');
+				if (s == -1) s = start;
+				else s = start + s + 1;
+				text.setSelection(s, end);
+			}
+		}
+	});	
+}
+
+void sendSelectionEvent () {
+	int [] y = new int [1];
+	int [] m = new int [1];
+	int [] d = new int [1];
+	OS.gtk_calendar_get_date(handle, y, m, d);
+	//TODO: hours, minutes, seconds?
+	if (d[0] != day ||
+		m[0] != month ||
+		y[0] != year) {
+		year = y[0];
+		month = m[0];
+		day = d[0];
+		postEvent (SWT.Selection);
+	}
+}
+
+public void setBackground(Color color) {
+	checkWidget();
+	super.setBackground(color);
+	if (text != null) text.setBackground(color);
+}
+
+public void setFont(Font font) {
+	checkWidget();
+	super.setFont(font);
+	if (text != null) text.setFont(font);
+	redraw();
+}
+
+public void setForeground(Color color) {
+	checkWidget();
+	super.setForeground(color);
+	if (text != null) text.setForeground(color);
+}
+
+/*public*/ void setFormat(String string) {
+	checkWidget();
+	// TODO: this needs to be locale sensitive
+	fieldCount = (style & SWT.DATE) != 0 ? ((style & SWT.SHORT) != 0 ? 2 : 3) : ((style & SWT.SHORT) != 0 ? 3 : 4);
+	fieldIndices = new Point[fieldCount];
+	fieldNames = new int[fieldCount];
+	if ((style & SWT.DATE) != 0) {
+		fieldNames[0] = Calendar.MONTH;
+		fieldIndices[0] = new Point(0, 2);
+		if ((style & SWT.SHORT) != 0) {
+			fieldNames[1] = Calendar.YEAR;
+			fieldIndices[1] = new Point(3, 7);
+		} else {
+			fieldNames[1] = Calendar.DAY_OF_MONTH;
+			fieldIndices[1] = new Point(3, 5);
+			fieldNames[2] = Calendar.YEAR;
+			fieldIndices[2] = new Point(6, 10);
+		}
+	} else { /* SWT.TIME */
+		fieldNames[0] = Calendar.HOUR;
+		fieldIndices[0] = new Point(0, 2);
+		fieldNames[1] = Calendar.MINUTE;
+		fieldIndices[1] = new Point(3, 5);
+		if ((style & SWT.SHORT) != 0) {
+			fieldNames[2] = Calendar.AM_PM;
+			fieldIndices[2] = new Point(6, 8);
+		} else {
+			fieldNames[2] = Calendar.SECOND;
+			fieldIndices[2] = new Point(6, 8);
+			fieldNames[3] = Calendar.AM_PM;
+			fieldIndices[3] = new Point(9, 11);
+		}
+	}
+}
+
+void setField(int fieldName, int value) {
+	if (calendar.get(fieldName) == value) return;
+	if (fieldName == Calendar.AM_PM) {
+		calendar.roll(Calendar.HOUR_OF_DAY, 12); // TODO: needs more work for setFormat and locale
+	}
+	calendar.set(fieldName, value);
+	postEvent(SWT.Selection);
+}
+
+void setTextField(int fieldName, int value, boolean commit, boolean adjust) {
+	if (commit) {
+		int max = calendar.getActualMaximum(fieldName);
+		int min = calendar.getActualMinimum(fieldName);
+		if (fieldName == Calendar.YEAR) {
+			max = MAX_YEAR;
+			min = MIN_YEAR;
+			/* Special case: convert 1 or 2-digit years into reasonable 4-digit years. */
+			int currentYear = Calendar.getInstance().get(Calendar.YEAR);
+			int currentCentury = (currentYear / 100) * 100;
+			if (value < (currentYear + 30) % 100) value += currentCentury;
+			else if (value < 100) value += currentCentury - 100;
+		}
+		if (value > max) value = min; // wrap
+		if (value < min) value = max; // wrap
+	}
+	int start = fieldIndices[currentField].x;
+	int end = fieldIndices[currentField].y;
+	text.setSelection(start, end);
+	String newValue = formattedStringValue(fieldName, value, adjust);
+	StringBuffer buffer = new StringBuffer(newValue);
+	/* Convert leading 0's into spaces. */
+	int prependCount = end - start - buffer.length();
+	for (int i = 0; i < prependCount; i++) {
+		switch (fieldName) {
+		case Calendar.MINUTE:
+		case Calendar.SECOND:
+			buffer.insert(0, 0);
+		break;
+		default:
+			buffer.insert(0, ' ');
+		break;
+		}
+	}		
+	newValue = buffer.toString();
+	ignoreVerify = true;
+	text.insert(newValue);
+	ignoreVerify = false;
+	selectField(currentField);
+	if (commit) setField(fieldName, value);
+}
+
+/**
+ * Sets the receiver's year, month, and day in a single operation.
+ * <p>
+ * This is the recommended way to set the date, because setting the year,
+ * month, and day separately may result in invalid intermediate dates.
+ * </p>
+ *
+ * @param year an integer between 1752 and 9999
+ * @param month an integer between 0 and 11
+ * @param day a positive integer beginning with 1
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 3.4
+ */
+public void setDate (int year, int month, int day) {
+	checkWidget ();
+	if (!isValid(year, month, day)) return;
+	if ((style & SWT.CALENDAR) != 0) {
+		this.year = year;
+		this.month = month;
+		this.day = day;
+		OS.gtk_calendar_select_month(handle, month, year);
+		OS.gtk_calendar_select_day(handle, day);
+	} else {
+		calendar.set(Calendar.YEAR, year);
+		calendar.set(Calendar.MONTH, month);
+		calendar.set(Calendar.DAY_OF_MONTH, day);
+		updateControl();
+	}
+}
+
+/**
+ * Sets the receiver's date, or day of the month, to the specified day.
+ * <p>
+ * The first day of the month is 1, and the last day depends on the month and year.
+ * </p>
+ *
+ * @param day a positive integer beginning with 1
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setDay (int day) {
+	checkWidget ();
+	if (!isValid(Calendar.DAY_OF_MONTH, day)) return;
+	if ((style & SWT.CALENDAR) != 0) {
+		this.day = day;
+		OS.gtk_calendar_select_day(handle, day);
+	} else {
+		calendar.set(Calendar.DAY_OF_MONTH, day);
+		updateControl();
+	}
+}
+
+/**
+ * Sets the receiver's hours.
+ * <p>
+ * Hours is an integer between 0 and 23.
+ * </p>
+ *
+ * @param hours an integer between 0 and 23
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setHours (int hours) {
+	checkWidget ();
+	if (!isValid(Calendar.HOUR_OF_DAY, hours)) return;
+	if ((style & SWT.CALENDAR) != 0) {
+		this.hours = hours;
+	} else {
+		calendar.set(Calendar.HOUR_OF_DAY, hours);
+		updateControl();
+	}
+}
+
+/**
+ * Sets the receiver's minutes.
+ * <p>
+ * Minutes is an integer between 0 and 59.
+ * </p>
+ *
+ * @param minutes an integer between 0 and 59
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setMinutes (int minutes) {
+	checkWidget ();
+	if (!isValid(Calendar.MINUTE, minutes)) return;
+	if ((style & SWT.CALENDAR) != 0) {
+		this.minutes = minutes;
+	} else {
+		calendar.set(Calendar.MINUTE, minutes);
+		updateControl();
+	}
+}
+
+/**
+ * Sets the receiver's month.
+ * <p>
+ * The first month of the year is 0, and the last month is 11.
+ * </p>
+ *
+ * @param month an integer between 0 and 11
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setMonth (int month) {
+	checkWidget ();
+	if (!isValid(Calendar.MONTH, month)) return;
+	if ((style & SWT.CALENDAR) != 0) {
+		this.month = month;
+		OS.gtk_calendar_select_month(handle, month, year);
+	} else {
+		calendar.set(Calendar.MONTH, month);
+		updateControl();
+	}
+}
+
+/**
+ * Sets the receiver's seconds.
+ * <p>
+ * Seconds is an integer between 0 and 59.
+ * </p>
+ *
+ * @param seconds an integer between 0 and 59
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setSeconds (int seconds) {
+	checkWidget ();
+	if (!isValid(Calendar.SECOND, seconds)) return;
+	if ((style & SWT.CALENDAR) != 0) {
+		this.seconds = seconds;
+	} else {
+		calendar.set(Calendar.SECOND, seconds);
+		updateControl();
+	}
+}
+
+/**
+ * Sets the receiver's hours, minutes, and seconds in a single operation.
+ *
+ * @param hours an integer between 0 and 23
+ * @param minutes an integer between 0 and 59
+ * @param seconds an integer between 0 and 59
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 3.4
+ */
+public void setTime (int hours, int minutes, int seconds) {
+	checkWidget ();
+	if (!isValid(Calendar.HOUR_OF_DAY, hours)) return;
+	if (!isValid(Calendar.MINUTE, minutes)) return;
+	if (!isValid(Calendar.SECOND, seconds)) return;
+	if ((style & SWT.CALENDAR) != 0) {
+		this.hours = hours;
+		this.minutes = minutes;
+		this.seconds = seconds;
+	} else {
+		calendar.set(Calendar.HOUR_OF_DAY, hours);
+		calendar.set(Calendar.MINUTE, minutes);
+		calendar.set(Calendar.SECOND, seconds);
+		updateControl();
+	}
+}
+
+/**
+ * Sets the receiver's year.
+ * <p>
+ * The first year is 1752 and the last year is 9999.
+ * </p>
+ *
+ * @param year an integer between 1752 and 9999
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setYear (int year) {
+	checkWidget ();
+	//if (!isValid(Calendar.YEAR, year)) return;
+	if (year < MIN_YEAR || year > MAX_YEAR) return;
+	if ((style & SWT.CALENDAR) != 0) {
+		this.year = year;
+		OS.gtk_calendar_select_month(handle, month, year);
+	} else {
+		calendar.set(Calendar.YEAR, year);
+		updateControl();
+	}
+}
+
+int unformattedIntValue(int fieldName, String newText, boolean adjust, int max) {
+	int newValue;
+	try {
+		newValue = Integer.parseInt(newText);
+	} catch (NumberFormatException ex) {
+		return -1;
+	}
+	if (fieldName == Calendar.MONTH && adjust) {
+		newValue--;
+		if (newValue == -1) newValue = max;
+	}
+	if (fieldName == Calendar.HOUR && adjust) {
+		if (newValue == 12) newValue = 0; // TODO: needs more work for setFormat and locale
+	}
+	return newValue;
+}
+
+public void updateControl() {
+	if (text != null) {
+		String string = getFormattedString(style);
+		ignoreVerify = true;
+		text.setText(string);
+		ignoreVerify = false;
+	}
+	redraw();	
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Decorations.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Decorations.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Decorations.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,751 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.widgets;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.gtk.*;
+import org.eclipse.swt.graphics.*;
+
+/**
+ * Instances of this class provide the appearance and
+ * behavior of <code>Shells</code>, but are not top
+ * level shells or dialogs. Class <code>Shell</code>
+ * shares a significant amount of code with this class,
+ * and is a subclass.
+ * <p>
+ * IMPORTANT: This class was intended to be abstract and
+ * should <em>never</em> be referenced or instantiated.
+ * Instead, the class <code>Shell</code> should be used.
+ * </p>
+ * <p>
+ * Instances are always displayed in one of the maximized, 
+ * minimized or normal states:
+ * <ul>
+ * <li>
+ * When an instance is marked as <em>maximized</em>, the
+ * window manager will typically resize it to fill the
+ * entire visible area of the display, and the instance
+ * is usually put in a state where it can not be resized 
+ * (even if it has style <code>RESIZE</code>) until it is
+ * no longer maximized.
+ * </li><li>
+ * When an instance is in the <em>normal</em> state (neither
+ * maximized or minimized), its appearance is controlled by
+ * the style constants which were specified when it was created
+ * and the restrictions of the window manager (see below).
+ * </li><li>
+ * When an instance has been marked as <em>minimized</em>,
+ * its contents (client area) will usually not be visible,
+ * and depending on the window manager, it may be
+ * "iconified" (that is, replaced on the desktop by a small
+ * simplified representation of itself), relocated to a
+ * distinguished area of the screen, or hidden. Combinations
+ * of these changes are also possible.
+ * </li>
+ * </ul>
+ * </p>
+ * Note: The styles supported by this class must be treated
+ * as <em>HINT</em>s, since the window manager for the
+ * desktop on which the instance is visible has ultimate
+ * control over the appearance and behavior of decorations.
+ * For example, some window managers only support resizable
+ * windows and will always assume the RESIZE style, even if
+ * it is not set.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>BORDER, CLOSE, MIN, MAX, NO_TRIM, RESIZE, TITLE, ON_TOP, TOOL</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>(none)</dd>
+ * </dl>
+ * Class <code>SWT</code> provides two "convenience constants"
+ * for the most commonly required style combinations:
+ * <dl>
+ * <dt><code>SHELL_TRIM</code></dt>
+ * <dd>
+ * the result of combining the constants which are required
+ * to produce a typical application top level shell: (that 
+ * is, <code>CLOSE | TITLE | MIN | MAX | RESIZE</code>)
+ * </dd>
+ * <dt><code>DIALOG_TRIM</code></dt>
+ * <dd>
+ * the result of combining the constants which are required
+ * to produce a typical application dialog shell: (that 
+ * is, <code>TITLE | CLOSE | BORDER</code>)
+ * </dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is intended to be subclassed <em>only</em>
+ * within the SWT implementation.
+ * </p>
+ *
+ * @see #getMinimized
+ * @see #getMaximized
+ * @see Shell
+ * @see SWT
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public class Decorations extends Canvas {
+	String text;
+	Image image;
+	Image [] images = new Image [0];
+	boolean minimized, maximized;
+	Menu menuBar;
+	Menu [] menus;
+	Control savedFocus;
+	Button defaultButton, saveDefault;
+	int /*long*/ accelGroup, vboxHandle;
+	
+Decorations () {
+	/* Do nothing */
+}
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT#BORDER
+ * @see SWT#CLOSE
+ * @see SWT#MIN
+ * @see SWT#MAX
+ * @see SWT#RESIZE
+ * @see SWT#TITLE
+ * @see SWT#NO_TRIM
+ * @see SWT#SHELL_TRIM
+ * @see SWT#DIALOG_TRIM
+ * @see SWT#ON_TOP
+ * @see SWT#TOOL
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public Decorations (Composite parent, int style) {
+	super (parent, checkStyle (style));
+}
+
+static int checkStyle (int style) {
+	if ((style & SWT.NO_TRIM) != 0) {
+		style &= ~(SWT.CLOSE | SWT.TITLE | SWT.MIN | SWT.MAX | SWT.RESIZE | SWT.BORDER);
+	}
+	if ((style & (SWT.MENU | SWT.MIN | SWT.MAX | SWT.CLOSE)) != 0) {
+		style |= SWT.TITLE;
+	}
+	return style;
+}
+
+protected void checkSubclass () {
+	if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
+}
+
+void _setImages (Image [] images) {
+	if (images != null && images.length > 1) {
+		Image [] bestImages = new Image [images.length];
+		System.arraycopy (images, 0, bestImages, 0, images.length);
+		sort (bestImages);
+		images = bestImages;
+	}
+	int /*long*/ pixbufs = 0;
+	if (images != null) {
+		for (int i = 0; i < images.length; i++) {
+			Image image = images [i];
+			int /*long*/ pixbuf = Display.createPixbuf (image);
+			pixbufs = OS.g_list_append (pixbufs, pixbuf);			
+		}
+	}
+	OS.gtk_window_set_icon_list (topHandle (), pixbufs);
+	int /*long*/ [] data = new int /*long*/ [1];
+	int /*long*/ temp = pixbufs;
+	while (temp != 0) {
+		OS.memmove (data, temp, OS.PTR_SIZEOF);
+		OS.g_object_unref (data [0]);
+		temp = OS.g_list_next (temp);
+	}
+	if (pixbufs != 0) OS.g_list_free (pixbufs);
+}
+
+void addMenu (Menu menu) {
+	if (menus == null) menus = new Menu [4];
+	for (int i=0; i<menus.length; i++) {
+		if (menus [i] == null) {
+			menus [i] = menu;
+			return;
+		}
+	}
+	Menu [] newMenus = new Menu [menus.length + 4];
+	newMenus [menus.length] = menu;
+	System.arraycopy (menus, 0, newMenus, 0, menus.length);
+	menus = newMenus;
+}
+
+int compare (ImageData data1, ImageData data2) {
+	if (data1.width == data2.width && data1.height == data2.height) {
+		int transparent1 = data1.getTransparencyType ();
+		int transparent2 = data2.getTransparencyType ();
+		if (transparent1 == SWT.TRANSPARENCY_ALPHA) return -1;
+		if (transparent2 == SWT.TRANSPARENCY_ALPHA) return 1;
+		if (transparent1 == SWT.TRANSPARENCY_MASK) return -1;
+		if (transparent2 == SWT.TRANSPARENCY_MASK) return 1;
+		if (transparent1 == SWT.TRANSPARENCY_PIXEL) return -1;
+		if (transparent2 == SWT.TRANSPARENCY_PIXEL) return 1;
+		return 0;
+	}
+	return data1.width > data2.width || data1.height > data2.height ? -1 : 1;
+}
+
+Control computeTabGroup () {
+	return this;
+}
+
+Control computeTabRoot () {
+	return this;
+}
+
+void createAccelGroup () {
+	if (accelGroup != 0) return;
+	accelGroup = OS.gtk_accel_group_new ();
+	if (accelGroup == 0) SWT.error (SWT.ERROR_NO_HANDLES);
+	//FIXME - what should we do for Decorations
+	int /*long*/ shellHandle = topHandle ();
+	OS.gtk_window_add_accel_group (shellHandle, accelGroup);
+}
+
+void createWidget (int index) {
+	super.createWidget (index);
+	text = "";
+}
+
+void destroyAccelGroup () {
+	if (accelGroup == 0) return;
+	int /*long*/ shellHandle = topHandle ();
+	OS.gtk_window_remove_accel_group (shellHandle, accelGroup);
+	//TEMPORARY CODE
+//	OS.g_object_unref (accelGroup);
+	accelGroup = 0;
+}
+
+void fixAccelGroup () {
+	if (menuBar == null) return;
+	destroyAccelGroup ();
+	createAccelGroup ();
+	menuBar.addAccelerators (accelGroup);
+}
+
+void fixDecorations (Decorations newDecorations, Control control, Menu [] menus) {
+	if (this == newDecorations) return;
+	if (control == savedFocus) savedFocus = null;
+	if (control == defaultButton) defaultButton = null;
+	if (control == saveDefault) saveDefault = null;
+	if (menus == null) return;
+	Menu menu = control.menu;
+	if (menu != null) {
+		int index = 0;
+		while (index <menus.length) {
+			if (menus [index] == menu) {
+				control.setMenu (null);
+				return;
+			}
+			index++;
+		}
+		menu.fixMenus (newDecorations);
+	}
+}
+
+/**
+ * Returns the receiver's default button if one had
+ * previously been set, otherwise returns null.
+ *
+ * @return the default button or null
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #setDefaultButton(Button)
+ */
+public Button getDefaultButton () {
+	checkWidget();
+	return defaultButton != null ? defaultButton : saveDefault;
+}
+
+/**
+ * Returns the receiver's image if it had previously been 
+ * set using <code>setImage()</code>. The image is typically
+ * displayed by the window manager when the instance is
+ * marked as iconified, and may also be displayed somewhere
+ * in the trim when the instance is in normal or maximized
+ * states.
+ * <p>
+ * Note: This method will return null if called before
+ * <code>setImage()</code> is called. It does not provide
+ * access to a window manager provided, "default" image
+ * even if one exists.
+ * </p>
+ * 
+ * @return the image
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Image getImage () {
+	checkWidget ();
+	return image;
+}
+
+/**
+ * Returns the receiver's images if they had previously been 
+ * set using <code>setImages()</code>. Images are typically
+ * displayed by the window manager when the instance is
+ * marked as iconified, and may also be displayed somewhere
+ * in the trim when the instance is in normal or maximized
+ * states. Depending where the icon is displayed, the platform
+ * chooses the icon with the "best" attributes.  It is expected
+ * that the array will contain the same icon rendered at different
+ * sizes, with different depth and transparency attributes.
+ * 
+ * <p>
+ * Note: This method will return an empty array if called before
+ * <code>setImages()</code> is called. It does not provide
+ * access to a window manager provided, "default" image
+ * even if one exists.
+ * </p>
+ * 
+ * @return the images
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.0
+ */
+public Image [] getImages () {
+	checkWidget ();
+	if (images == null) return new Image [0];
+	Image [] result = new Image [images.length];
+	System.arraycopy (images, 0, result, 0, images.length);
+	return result;
+}
+
+/**
+ * Returns <code>true</code> if the receiver is currently
+ * maximized, and false otherwise. 
+ * <p>
+ *
+ * @return the maximized state
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #setMaximized
+ */
+public boolean getMaximized () {
+	checkWidget();
+	return maximized;
+}
+
+/**
+ * Returns the receiver's menu bar if one had previously
+ * been set, otherwise returns null.
+ *
+ * @return the menu bar or null
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Menu getMenuBar () {
+	checkWidget();
+	return menuBar;
+}
+
+/**
+ * Returns <code>true</code> if the receiver is currently
+ * minimized, and false otherwise. 
+ * <p>
+ *
+ * @return the minimized state
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #setMinimized
+ */
+public boolean getMinimized () {
+	checkWidget();
+	return minimized;
+}
+
+String getNameText () {
+	return getText ();
+}
+
+/**
+ * Returns the receiver's text, which is the string that the
+ * window manager will typically display as the receiver's
+ * <em>title</em>. If the text has not previously been set, 
+ * returns an empty string.
+ *
+ * @return the text
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public String getText () {
+	checkWidget();
+	return text;
+}
+
+public boolean isReparentable () {
+	checkWidget ();
+	return false;
+}
+
+boolean isTabGroup () {
+	return true;
+}
+
+boolean isTabItem () {
+	return false;
+}
+
+Decorations menuShell () {
+	return this;
+}
+
+void removeMenu (Menu menu) {
+	if (menus == null) return;
+	for (int i=0; i<menus.length; i++) {
+		if (menus [i] == menu) {
+			menus [i] = null;
+			return;
+		}
+	}
+}
+
+void releaseChildren (boolean destroy) {
+	if (menuBar != null) {
+		menuBar.release (false);
+		menuBar = null;
+	}
+	super.releaseChildren (destroy);
+	if (menus != null) {
+		for (int i=0; i<menus.length; i++) {
+			Menu menu = menus [i];
+			if (menu != null && !menu.isDisposed ()) {
+				menu.dispose ();
+			}
+		}
+		menus = null;
+	}
+}
+
+void releaseHandle () {
+	super.releaseHandle ();
+	vboxHandle = 0;
+}
+
+void releaseWidget () {
+	super.releaseWidget ();
+	image = null;
+	images = null;
+	savedFocus = null;
+	defaultButton = saveDefault = null;
+}
+
+boolean restoreFocus () {
+	if (savedFocus != null && savedFocus.isDisposed ()) savedFocus = null;
+	boolean restored = savedFocus != null && savedFocus.setFocus ();
+	savedFocus = null;
+	/*
+	* This code is intentionally commented.  When no widget
+	* has been given focus, some platforms give focus to the
+	* default button.  Motif doesn't do this.
+	*/
+//	if (restored) return true;
+//	if (defaultButton != null && !defaultButton.isDisposed ()) {
+//		if (defaultButton.setFocus ()) return true;
+//	}
+//	return false;
+	return restored;
+}
+
+/**
+ * If the argument is not null, sets the receiver's default
+ * button to the argument, and if the argument is null, sets
+ * the receiver's default button to the first button which
+ * was set as the receiver's default button (called the 
+ * <em>saved default button</em>). If no default button had
+ * previously been set, or the saved default button was
+ * disposed, the receiver's default button will be set to
+ * null.
+ * <p>
+ * The default button is the button that is selected when
+ * the receiver is active and the user presses ENTER.
+ * </p>
+ *
+ * @param button the new default button
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the button has been disposed</li> 
+ *    <li>ERROR_INVALID_PARENT - if the control is not in the same widget tree</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setDefaultButton (Button button) {
+	checkWidget();
+	int /*long*/ buttonHandle = 0;
+	if (button != null) {
+		if (button.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT);
+		if (button.menuShell () != this) error (SWT.ERROR_INVALID_PARENT);
+		buttonHandle = button.handle;
+	}
+	saveDefault = defaultButton = button;
+	OS.gtk_window_set_default (topHandle (), buttonHandle);
+}
+
+/**
+ * Sets the receiver's image to the argument, which may
+ * be null. The image is typically displayed by the window
+ * manager when the instance is marked as iconified, and
+ * may also be displayed somewhere in the trim when the
+ * instance is in normal or maximized states.
+ * 
+ * @param image the new image (or null)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li> 
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setImage (Image image) {
+	checkWidget ();
+	this.image = image;
+	_setImages (image != null ? new Image [] {image} : null);
+}
+
+/**
+ * Sets the receiver's images to the argument, which may
+ * be an empty array. Images are typically displayed by the
+ * window manager when the instance is marked as iconified,
+ * and may also be displayed somewhere in the trim when the
+ * instance is in normal or maximized states. Depending where
+ * the icon is displayed, the platform chooses the icon with
+ * the "best" attributes. It is expected that the array will
+ * contain the same icon rendered at different sizes, with
+ * different depth and transparency attributes.
+ * 
+ * @param images the new image array
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the array of images is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if one of the images is null or has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.0
+ */
+public void setImages (Image [] images) {
+	checkWidget ();
+	if (images == null) error (SWT.ERROR_INVALID_ARGUMENT);
+	for (int i = 0; i < images.length; i++) {
+		if (images [i] == null || images [i].isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT);
+	}
+	this.images = images;
+	_setImages (images);
+}
+
+/**
+ * Sets the maximized state of the receiver.
+ * If the argument is <code>true</code> causes the receiver
+ * to switch to the maximized state, and if the argument is
+ * <code>false</code> and the receiver was previously maximized,
+ * causes the receiver to switch back to either the minimized
+ * or normal states.
+ * <p>
+ * Note: The result of intermixing calls to <code>setMaximized(true)</code>
+ * and <code>setMinimized(true)</code> will vary by platform. Typically,
+ * the behavior will match the platform user's expectations, but not
+ * always. This should be avoided if possible.
+ * </p>
+ *
+ * @param maximized the new maximized state
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #setMinimized
+ */
+public void setMaximized (boolean maximized) {
+	checkWidget();
+	this.maximized = maximized;
+}
+
+/**
+ * Sets the receiver's menu bar to the argument, which
+ * may be null.
+ *
+ * @param menu the new menu bar
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the menu has been disposed</li> 
+ *    <li>ERROR_INVALID_PARENT - if the menu is not in the same widget tree</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setMenuBar (Menu menu) {
+	checkWidget();
+	if (menuBar == menu) return;
+	if (menu != null) {
+		if ((menu.style & SWT.BAR) == 0) error (SWT.ERROR_MENU_NOT_BAR);
+		if (menu.parent != this) error (SWT.ERROR_INVALID_PARENT);
+	}
+	menuBar = menu;
+}
+
+/**
+ * Sets the minimized stated of the receiver.
+ * If the argument is <code>true</code> causes the receiver
+ * to switch to the minimized state, and if the argument is
+ * <code>false</code> and the receiver was previously minimized,
+ * causes the receiver to switch back to either the maximized
+ * or normal states.
+ * <p>
+ * Note: The result of intermixing calls to <code>setMaximized(true)</code>
+ * and <code>setMinimized(true)</code> will vary by platform. Typically,
+ * the behavior will match the platform user's expectations, but not
+ * always. This should be avoided if possible.
+ * </p>
+ *
+ * @param minimized the new maximized state
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #setMaximized
+ */
+public void setMinimized (boolean minimized) {
+	checkWidget();
+	this.minimized = minimized;
+}
+
+void setSavedFocus (Control control) {
+	if (this == control) return;
+	savedFocus = control;
+}
+
+/**
+ * Sets the receiver's text, which is the string that the
+ * window manager will typically display as the receiver's
+ * <em>title</em>, to the argument, which must not be null. 
+ *
+ * @param string the new text
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the text is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setText (String string) {
+	checkWidget();
+	if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+	text = string;
+}
+
+void sort (Image [] images) {
+	/* Shell Sort from K&R, pg 108 */
+	int length = images.length;
+	if (length <= 1) return; 
+	ImageData [] datas = new ImageData [length];
+	for (int i = 0; i < length; i++) {
+		datas [i] = images [i].getImageData ();
+	}
+	for (int gap=length/2; gap>0; gap/=2) {
+		for (int i=gap; i<length; i++) {
+			for (int j=i-gap; j>=0; j-=gap) {
+		   		if (compare (datas [j], datas [j + gap]) >= 0) {
+					Image swap = images [j];
+					images [j] = images [j + gap];
+					images [j + gap] = swap;
+					ImageData swapData = datas [j];
+					datas [j] = datas [j + gap];
+					datas [j + gap] = swapData;
+		   		}
+	    	}
+	    }
+	}
+}
+
+boolean traverseItem (boolean next) {
+	return false;
+}
+
+boolean traverseReturn () {
+	Button button = defaultButton != null ? defaultButton: saveDefault;
+	if (button == null || button.isDisposed ()) return false;
+	/*
+	* Bug in GTK.  When a default button that is disabled is
+	* activated using the Enter key, GTK GP's.  The fix is to
+	* detect this case and stop GTK from processing the Enter
+	* key.
+	*/
+	if (!button.isVisible () || !button.isEnabled ()) return true;
+	int /*long*/ shellHandle = _getShell ().topHandle ();
+	return OS.gtk_window_activate_default (shellHandle);
+}
+
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Dialog.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Dialog.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Dialog.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,265 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.widgets;
+
+
+import org.eclipse.swt.*;
+
+/**
+ * This class is the abstract superclass of the classes
+ * that represent the built in platform dialogs.
+ * A <code>Dialog</code> typically contains other widgets
+ * that are not accessible. A <code>Dialog</code> is not
+ * a <code>Widget</code>.
+ * <p>
+ * This class can also be used as the abstract superclass
+ * for user-designed dialogs. Such dialogs usually consist
+ * of a Shell with child widgets. The basic template for a
+ * user-defined dialog typically looks something like this:
+ * <pre><code>
+ * public class MyDialog extends Dialog {
+ *	Object result;
+ *		
+ *	public MyDialog (Shell parent, int style) {
+ *		super (parent, style);
+ *	}
+ *	public MyDialog (Shell parent) {
+ *		this (parent, 0); // your default style bits go here (not the Shell's style bits)
+ *	}
+ *	public Object open () {
+ *		Shell parent = getParent();
+ *		Shell shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
+ *		shell.setText(getText());
+ *		// Your code goes here (widget creation, set result, etc).
+ *		shell.open();
+ *		Display display = parent.getDisplay();
+ *		while (!shell.isDisposed()) {
+ *			if (!display.readAndDispatch()) display.sleep();
+ *		}
+ *		return result;
+ *	}
+ * }
+ * </pre></code>
+ * <p>
+ * Note: The <em>modality</em> styles supported by this class
+ * are treated as <em>HINT</em>s, because not all are supported
+ * by every subclass on every platform. If a modality style is
+ * not supported, it is "upgraded" to a more restrictive modality
+ * style that is supported.  For example, if <code>PRIMARY_MODAL</code>
+ * is not supported by a particular dialog, it would be upgraded to 
+ * <code>APPLICATION_MODAL</code>. In addition, as is the case
+ * for shells, the window manager for the desktop on which the
+ * instance is visible has ultimate control over the appearance
+ * and behavior of the instance, including its modality.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>APPLICATION_MODAL, PRIMARY_MODAL, SYSTEM_MODAL</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>(none)</dd>
+ * </dl>
+ * <p>
+ * Note: Only one of the styles APPLICATION_MODAL, PRIMARY_MODAL,
+ * and SYSTEM_MODAL may be specified.
+ * </p>
+ * 
+ * @see Shell
+ * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: ControlExample</a>
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+
+public abstract class Dialog {
+	int style;
+	Shell parent;
+	String title;
+
+/**
+ * Constructs a new instance of this class given only its
+ * parent.
+ *
+ * @param parent a shell which will be the parent of the new instance
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * </ul>
+ */
+public Dialog (Shell parent) {
+	this (parent, SWT.PRIMARY_MODAL);
+}
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ *
+ * @param parent a shell which will be the parent of the new instance
+ * @param style the style of dialog to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * </ul>
+ * 
+ * @see SWT#PRIMARY_MODAL
+ * @see SWT#APPLICATION_MODAL
+ * @see SWT#SYSTEM_MODAL
+ */
+public Dialog (Shell parent, int style) {
+	checkParent (parent);
+	this.parent = parent;
+	this.style = style;
+	title = "";
+}
+
+/**
+ * Checks that this class can be subclassed.
+ * <p>
+ * IMPORTANT: See the comment in <code>Widget.checkSubclass()</code>.
+ * </p>
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see Widget#checkSubclass
+ */
+protected void checkSubclass () {
+	if (!Display.isValidClass (getClass ())) {
+		error (SWT.ERROR_INVALID_SUBCLASS);
+	}
+}
+
+/**
+ * Throws an exception if the specified widget can not be
+ * used as a parent for the receiver.
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the parent is disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * </ul>
+ */
+void checkParent (Shell parent) {
+	if (parent == null) error (SWT.ERROR_NULL_ARGUMENT);
+	parent.checkWidget ();
+}
+
+static int checkStyle (Shell parent, int style) {
+	if ((style & (SWT.PRIMARY_MODAL | SWT.APPLICATION_MODAL | SWT.SYSTEM_MODAL)) == 0) {
+		style |= SWT.APPLICATION_MODAL;
+	}
+	style &= ~SWT.MIRRORED;
+	if ((style & (SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT)) == 0) {
+		if (parent != null) {
+			if ((parent.style & SWT.LEFT_TO_RIGHT) != 0) style |= SWT.LEFT_TO_RIGHT;
+			if ((parent.style & SWT.RIGHT_TO_LEFT) != 0) style |= SWT.RIGHT_TO_LEFT;
+		}
+	}
+	return Widget.checkBits (style, SWT.LEFT_TO_RIGHT, SWT.RIGHT_TO_LEFT, 0, 0, 0, 0);
+}
+
+/**
+ * Does whatever dialog specific cleanup is required, and then
+ * uses the code in <code>SWTError.error</code> to handle the error.
+ *
+ * @param code the descriptive error code
+ *
+ * @see SWT#error(int)
+ */
+void error (int code) {
+	SWT.error(code);
+}
+
+/**
+ * Returns the receiver's parent, which must be a <code>Shell</code>
+ * or null.
+ *
+ * @return the receiver's parent
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Shell getParent () {
+	return parent;
+}
+
+/**
+ * Returns the receiver's style information.
+ * <p>
+ * Note that, the value which is returned by this method <em>may
+ * not match</em> the value which was provided to the constructor
+ * when the receiver was created. 
+ * </p>
+ *
+ * @return the style bits
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getStyle () {
+	return style;
+}
+
+/**
+ * Returns the receiver's text, which is the string that the
+ * window manager will typically display as the receiver's
+ * <em>title</em>. If the text has not previously been set, 
+ * returns an empty string.
+ *
+ * @return the text
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public String getText () {
+	return title;
+}
+
+/**
+ * Sets the receiver's text, which is the string that the
+ * window manager will typically display as the receiver's
+ * <em>title</em>, to the argument, which must not be null. 
+ *
+ * @param string the new text
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the text is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setText (String string) {
+	if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+	title = string;
+}
+
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/DirectoryDialog.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/DirectoryDialog.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/DirectoryDialog.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,337 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.widgets;
+
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.gtk.*;
+
+/**
+ * Instances of this class allow the user to navigate
+ * the file system and select a directory.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>(none)</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>(none)</dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is intended to be subclassed <em>only</em>
+ * within the SWT implementation.
+ * </p>
+ * 
+ * @see <a href="http://www.eclipse.org/swt/snippets/#directorydialog">DirectoryDialog snippets</a>
+ * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: ControlExample, Dialog tab</a>
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public class DirectoryDialog extends Dialog {
+	String message = "", filterPath = "";
+	static final String SEPARATOR = System.getProperty ("file.separator");
+
+/**
+ * Constructs a new instance of this class given only its parent.
+ *
+ * @param parent a shell which will be the parent of the new instance
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ */
+public DirectoryDialog (Shell parent) {
+	this (parent, SWT.APPLICATION_MODAL);
+}
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a shell which will be the parent of the new instance
+ * @param style the style of dialog to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ */
+public DirectoryDialog (Shell parent, int style) {
+	super (parent, checkStyle (parent, style));
+	checkSubclass ();
+}
+/**
+ * Returns the path which the dialog will use to filter
+ * the directories it shows.
+ *
+ * @return the filter path
+ * 
+ * @see #setFilterPath
+ */
+public String getFilterPath () {
+	return filterPath;
+}
+/**
+ * Returns the dialog's message, which is a description of
+ * the purpose for which it was opened. This message will be
+ * visible on the dialog while it is open.
+ *
+ * @return the message
+ */
+public String getMessage () {
+	return message;
+}
+/**
+ * Makes the dialog visible and brings it to the front
+ * of the display.
+ *
+ * @return a string describing the absolute path of the selected directory,
+ *         or null if the dialog was cancelled or an error occurred
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the dialog has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the dialog</li>
+ * </ul>
+ */
+public String open () {
+	boolean useChooserDialog = OS.GTK_VERSION >= OS.VERSION (2, 4, 10); 
+	if (useChooserDialog) {
+		return openChooserDialog ();
+	} else {
+		return openClassicDialog ();
+	}
+}
+String openChooserDialog () {
+	byte [] titleBytes = Converter.wcsToMbcs (null, title, true);
+	int /*long*/ shellHandle = parent.topHandle ();
+	int /*long*/ handle = OS.gtk_file_chooser_dialog_new (
+		titleBytes,
+		shellHandle,
+		OS.GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
+		OS.GTK_STOCK_CANCEL (), OS.GTK_RESPONSE_CANCEL,
+		OS.GTK_STOCK_OK (), OS.GTK_RESPONSE_OK,
+		0);
+	int /*long*/ pixbufs = OS.gtk_window_get_icon_list (shellHandle);
+	if (pixbufs != 0) {
+		OS.gtk_window_set_icon_list (handle, pixbufs);
+		OS.g_list_free (pixbufs);
+	}
+	if (filterPath != null && filterPath.length () > 0) {
+		StringBuffer stringBuffer = new StringBuffer ();
+		/* filename must be a full path */
+		if (!filterPath.startsWith (SEPARATOR)) {
+			stringBuffer.append (SEPARATOR);
+		}
+		stringBuffer.append (filterPath);
+		byte [] buffer = Converter.wcsToMbcs (null, stringBuffer.toString (), true);
+		/*
+		* Bug in GTK. GtkFileChooser may crash on GTK versions 2.4.10 to 2.6
+		* when setting a file name that is not a true canonical path. 
+		* The fix is to use the canonical path.
+		*/
+		int /*long*/ ptr = OS.realpath (buffer, null);
+		if (ptr != 0) {
+			OS.gtk_file_chooser_set_current_folder (handle, ptr);
+			OS.g_free (ptr);
+		}
+	}
+	if (message.length () > 0) {
+		byte [] buffer = Converter.wcsToMbcs (null, message, true);
+		int /*long*/ box = OS.gtk_hbox_new (false, 0);
+		if (box == 0) error (SWT.ERROR_NO_HANDLES);
+		int /*long*/ label = OS.gtk_label_new (buffer);
+		if (label == 0) error (SWT.ERROR_NO_HANDLES);
+		OS.gtk_container_add (box, label);
+		OS.gtk_widget_show (label);
+		OS.gtk_label_set_line_wrap (label, true);
+		OS.gtk_label_set_justify (label, OS.GTK_JUSTIFY_CENTER);
+		OS.gtk_file_chooser_set_extra_widget (handle, box);
+	}
+	String answer = null;
+	Display display = parent != null ? parent.getDisplay (): Display.getCurrent ();
+	display.addIdleProc ();
+	Dialog oldModal = null;
+	if (OS.gtk_window_get_modal (handle)) {
+		oldModal = display.getModalDialog ();
+		display.setModalDialog (this);
+	}
+	int signalId = 0;
+	int /*long*/ hookId = 0;
+	if ((style & SWT.RIGHT_TO_LEFT) != 0) {
+		signalId = OS.g_signal_lookup (OS.map, OS.GTK_TYPE_WIDGET());
+		hookId = OS.g_signal_add_emission_hook (signalId, 0, display.emissionProc, handle, 0);
+	}	
+	int response = OS.gtk_dialog_run (handle);
+	if ((style & SWT.RIGHT_TO_LEFT) != 0) {
+		OS.g_signal_remove_emission_hook (signalId, hookId);
+	}
+	if (OS.gtk_window_get_modal (handle)) {
+		display.setModalDialog (oldModal);
+	}
+	if (response == OS.GTK_RESPONSE_OK) {
+		int /*long*/ path = OS.gtk_file_chooser_get_filename (handle);
+		if (path != 0) {
+			int /*long*/ utf8Ptr = OS.g_filename_to_utf8 (path, -1, null, null, null);
+			OS.g_free (path);
+			if (utf8Ptr != 0) {
+				int /*long*/ [] items_written = new int /*long*/ [1];
+				int /*long*/ utf16Ptr = OS.g_utf8_to_utf16 (utf8Ptr, -1, null, items_written, null);
+				OS.g_free (utf8Ptr);
+				if (utf16Ptr != 0) {
+					int clength = (int)/*64*/items_written [0];
+					char [] chars = new char [clength];
+					OS.memmove (chars, utf16Ptr, clength * 2);
+					OS.g_free (utf16Ptr);
+					answer = new String (chars);
+					filterPath = answer;
+				}
+			}
+		}
+	}
+	display.removeIdleProc ();
+	OS.gtk_widget_destroy (handle);
+	return answer;
+}
+String openClassicDialog () {
+	byte [] titleBytes = Converter.wcsToMbcs (null, title, true);
+	int /*long*/ handle = OS.gtk_file_selection_new (titleBytes);
+	if (parent != null) {
+		int /*long*/ shellHandle = parent.topHandle ();
+		OS.gtk_window_set_transient_for (handle, shellHandle);
+		int /*long*/ pixbufs = OS.gtk_window_get_icon_list (shellHandle);
+		if (pixbufs != 0) {
+			OS.gtk_window_set_icon_list (handle, pixbufs);
+			OS.g_list_free (pixbufs);
+		}
+	}
+	String answer = null;
+	if (filterPath != null) {
+		String path = filterPath;
+		if (path.length () > 0 && !path.endsWith (SEPARATOR)) {
+			path += SEPARATOR;
+		}
+		int length = path.length ();
+		char [] buffer = new char [length + 1];
+		path.getChars (0, length, buffer, 0);
+		int /*long*/ utf8Ptr = OS.g_utf16_to_utf8 (buffer, -1, null, null, null);
+		int /*long*/ fileNamePtr = OS.g_filename_from_utf8 (utf8Ptr, -1, null, null, null);
+		OS.gtk_file_selection_set_filename (handle, fileNamePtr);
+		OS.g_free (utf8Ptr);
+		OS.g_free (fileNamePtr);		
+	}
+	GtkFileSelection selection = new GtkFileSelection ();
+	OS.memmove (selection, handle);
+	OS.gtk_file_selection_hide_fileop_buttons (handle);
+	int /*long*/ fileListParent = OS.gtk_widget_get_parent (selection.file_list);
+	OS.gtk_widget_hide (selection.file_list);
+	OS.gtk_widget_hide (fileListParent);
+	if (message.length () > 0) {
+		byte [] buffer = Converter.wcsToMbcs (null, message, true);
+		int /*long*/ labelHandle = OS.gtk_label_new (buffer);
+		OS.gtk_label_set_line_wrap (labelHandle, true);		
+		OS.gtk_misc_set_alignment (labelHandle, 0.0f, 0.0f);
+		OS.gtk_container_add (selection.main_vbox, labelHandle);
+		OS.gtk_box_set_child_packing (
+			selection.main_vbox, labelHandle, false, false, 0, OS.GTK_PACK_START);
+		OS.gtk_widget_show (labelHandle);
+	}
+	Display display = parent != null ? parent.getDisplay (): Display.getCurrent ();
+	display.addIdleProc ();
+	Dialog oldModal = null;
+	if (OS.gtk_window_get_modal (handle)) {
+		oldModal = display.getModalDialog ();
+		display.setModalDialog (this);
+	}
+	int signalId = 0;
+	int /*long*/ hookId = 0;
+	if ((style & SWT.RIGHT_TO_LEFT) != 0) {
+		signalId = OS.g_signal_lookup (OS.map, OS.GTK_TYPE_WIDGET());
+		hookId = OS.g_signal_add_emission_hook (signalId, 0, display.emissionProc, handle, 0);
+	}	
+	int response = OS.gtk_dialog_run (handle);
+	if ((style & SWT.RIGHT_TO_LEFT) != 0) {
+		OS.g_signal_remove_emission_hook (signalId, hookId);
+	}
+	if (OS.gtk_window_get_modal (handle)) {
+		display.setModalDialog (oldModal);
+	}
+	if (response == OS.GTK_RESPONSE_OK) {
+		int /*long*/ fileNamePtr = OS.gtk_file_selection_get_filename (handle);
+		int /*long*/ utf8Ptr = OS.g_filename_to_utf8 (fileNamePtr, -1, null, null, null);
+		if (utf8Ptr != 0) {
+			int /*long*/ [] items_written = new int /*long*/ [1];
+			int /*long*/ utf16Ptr = OS.g_utf8_to_utf16 (utf8Ptr, -1, null, items_written, null);
+			if (utf16Ptr != 0) {
+				int length = (int)/*64*/items_written [0];
+				char [] buffer = new char [length];
+				OS.memmove (buffer, utf16Ptr, length * 2);
+				String osAnswer = new String (buffer);
+				if (osAnswer != null) {
+					/* remove trailing separator, unless root directory */
+					if (!osAnswer.equals (SEPARATOR) && osAnswer.endsWith (SEPARATOR)) {
+						osAnswer = osAnswer.substring (0, osAnswer.length () - 1);
+					}
+					answer = filterPath = osAnswer;
+				}
+				OS.g_free (utf16Ptr);
+			}
+			OS.g_free (utf8Ptr);
+		}
+	}
+	display.removeIdleProc ();
+	OS.gtk_widget_destroy (handle);
+	return answer;
+}
+/**
+ * Sets the path that the dialog will use to filter
+ * the directories it shows to the argument, which may
+ * be null. If the string is null, then the operating
+ * system's default filter path will be used.
+ * <p>
+ * Note that the path string is platform dependent.
+ * For convenience, either '/' or '\' can be used
+ * as a path separator.
+ * </p>
+ *
+ * @param string the filter path
+ */
+public void setFilterPath (String string) {
+	filterPath = string;
+}
+/**
+ * Sets the dialog's message, which is a description of
+ * the purpose for which it was opened. This message will be
+ * visible on the dialog while it is open.
+ *
+ * @param string the message
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ * </ul>
+ */
+public void setMessage (String string) {
+	if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+	message = string;
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Display.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Display.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Display.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,4120 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.widgets;
+
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.gtk.*;
+import org.eclipse.swt.graphics.*;
+
+/**
+ * Instances of this class are responsible for managing the
+ * connection between SWT and the underlying operating
+ * system. Their most important function is to implement
+ * the SWT event loop in terms of the platform event model.
+ * They also provide various methods for accessing information
+ * about the operating system, and have overall control over
+ * the operating system resources which SWT allocates.
+ * <p>
+ * Applications which are built with SWT will <em>almost always</em>
+ * require only a single display. In particular, some platforms
+ * which SWT supports will not allow more than one <em>active</em>
+ * display. In other words, some platforms do not support
+ * creating a new display if one already exists that has not been
+ * sent the <code>dispose()</code> message.
+ * <p>
+ * In SWT, the thread which creates a <code>Display</code>
+ * instance is distinguished as the <em>user-interface thread</em>
+ * for that display.
+ * </p>
+ * The user-interface thread for a particular display has the
+ * following special attributes:
+ * <ul>
+ * <li>
+ * The event loop for that display must be run from the thread.
+ * </li>
+ * <li>
+ * Some SWT API methods (notably, most of the public methods in
+ * <code>Widget</code> and its subclasses), may only be called
+ * from the thread. (To support multi-threaded user-interface
+ * applications, class <code>Display</code> provides inter-thread
+ * communication methods which allow threads other than the 
+ * user-interface thread to request that it perform operations
+ * on their behalf.)
+ * </li>
+ * <li>
+ * The thread is not allowed to construct other 
+ * <code>Display</code>s until that display has been disposed.
+ * (Note that, this is in addition to the restriction mentioned
+ * above concerning platform support for multiple displays. Thus,
+ * the only way to have multiple simultaneously active displays,
+ * even on platforms which support it, is to have multiple threads.)
+ * </li>
+ * </ul>
+ * Enforcing these attributes allows SWT to be implemented directly
+ * on the underlying operating system's event model. This has 
+ * numerous benefits including smaller footprint, better use of 
+ * resources, safer memory management, clearer program logic,
+ * better performance, and fewer overall operating system threads
+ * required. The down side however, is that care must be taken
+ * (only) when constructing multi-threaded applications to use the
+ * inter-thread communication mechanisms which this class provides
+ * when required.
+ * </p><p>
+ * All SWT API methods which may only be called from the user-interface
+ * thread are distinguished in their documentation by indicating that
+ * they throw the "<code>ERROR_THREAD_INVALID_ACCESS</code>"
+ * SWT exception.
+ * </p>
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>(none)</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Close, Dispose, Settings</dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ * @see #syncExec
+ * @see #asyncExec
+ * @see #wake
+ * @see #readAndDispatch
+ * @see #sleep
+ * @see Device#dispose
+ * @see <a href="http://www.eclipse.org/swt/snippets/#display">Display snippets</a>
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public class Display extends Device {
+
+	/* Events Dispatching and Callback */
+	int gdkEventCount;
+	int /*long*/ [] gdkEvents;
+	Widget [] gdkEventWidgets;
+	int [] dispatchEvents;
+	Event [] eventQueue;
+	int /*long*/ fds;
+	int allocated_nfds;
+	boolean wake;
+	int [] max_priority = new int [1], timeout = new int [1];
+	Callback eventCallback, filterCallback;
+	int /*long*/ eventProc, filterProc, windowProc2, windowProc3, windowProc4, windowProc5;
+	Callback windowCallback2, windowCallback3, windowCallback4, windowCallback5;
+	EventTable eventTable, filterTable;
+	static String APP_NAME = "SWT"; //$NON-NLS-1$
+	static final String DISPATCH_EVENT_KEY = "org.eclipse.swt.internal.gtk.dispatchEvent"; //$NON-NLS-1$
+	static final String ADD_WIDGET_KEY = "org.eclipse.swt.internal.addWidget"; //$NON-NLS-1$
+	int /*long*/ [] closures;
+	int [] signalIds;
+	int /*long*/ shellMapProcClosure;
+
+	/* Widget Table */
+	int [] indexTable;
+	int freeSlot;
+	int /*long*/ lastHandle;
+	Widget lastWidget;
+	Widget [] widgetTable;
+	final static int GROW_SIZE = 1024;
+	static final int SWT_OBJECT_INDEX;
+	static final int SWT_OBJECT_INDEX1;
+	static final int SWT_OBJECT_INDEX2;
+	static {
+		byte [] buffer = Converter.wcsToMbcs (null, "SWT_OBJECT_INDEX", true); //$NON-NLS-1$
+		SWT_OBJECT_INDEX = OS.g_quark_from_string (buffer);
+		buffer = Converter.wcsToMbcs (null, "SWT_OBJECT_INDEX1", true); //$NON-NLS-1$
+		SWT_OBJECT_INDEX1 = OS.g_quark_from_string (buffer);
+		buffer = Converter.wcsToMbcs (null, "SWT_OBJECT_INDEX2", true); //$NON-NLS-1$
+		SWT_OBJECT_INDEX2 = OS.g_quark_from_string (buffer);
+	}
+
+	/* Modality */
+	Shell [] modalShells;
+	Dialog modalDialog;
+	static final String GET_MODAL_DIALOG = "org.eclipse.swt.internal.gtk.getModalDialog"; //$NON-NLS-1$
+	static final String SET_MODAL_DIALOG = "org.eclipse.swt.internal.gtk.setModalDialog"; //$NON-NLS-1$
+
+	/* Focus */
+	int focusEvent;
+	Control focusControl;
+	Shell activeShell;
+	boolean activePending;
+	boolean ignoreActivate, ignoreFocus;
+	
+	/* Input method resources */
+	Control imControl;
+	int /*long*/ preeditWindow, preeditLabel;
+
+	/* Sync/Async Widget Communication */
+	Synchronizer synchronizer = new Synchronizer (this);
+	Thread thread;
+
+	/* Display Shutdown */
+	Runnable [] disposeList;
+	
+	/* System Tray */
+	Tray tray;
+	
+	/* Timers */
+	int [] timerIds;
+	Runnable [] timerList;
+	Callback timerCallback;
+	int /*long*/ timerProc;
+	Callback windowTimerCallback;
+	int /*long*/ windowTimerProc;
+	
+	/* Caret */
+	Caret currentCaret;
+	Callback caretCallback;
+	int caretId;
+	int /*long*/ caretProc;
+	
+	/* Mnemonics */
+	Control mnemonicControl;
+
+	/* Mouse hover */
+	int mouseHoverId;
+	int /*long*/ mouseHoverHandle, mouseHoverProc;
+	Callback mouseHoverCallback;
+	
+	/* Menu position callback */
+	int /*long*/ menuPositionProc;
+	Callback menuPositionCallback;
+
+	/* Tooltip size allocate callback */
+	int /*long*/ sizeAllocateProc;
+	Callback sizeAllocateCallback;
+	int /*long*/ sizeRequestProc;
+	Callback sizeRequestCallback;
+
+	/* Shell map callback */
+	int /*long*/ shellMapProc;
+	Callback shellMapCallback;
+	
+	/* Idle proc callback */
+	int /*long*/ idleProc;
+	int idleHandle;
+	Callback idleCallback;
+	static final String ADD_IDLE_PROC_KEY = "org.eclipse.swt.internal.gtk.addIdleProc"; //$NON-NLS-1$
+	static final String REMOVE_IDLE_PROC_KEY = "org.eclipse.swt.internal.gtk.removeIdleProc"; //$NON-NLS-1$
+	Object idleLock = new Object();
+	boolean idleNeeded;
+	
+	/* GtkTreeView callbacks */
+	int[] treeSelection;
+	int treeSelectionLength;
+	int /*long*/ treeSelectionProc;
+	Callback treeSelectionCallback;
+	int /*long*/ cellDataProc;
+	Callback cellDataCallback;
+	
+	/* Set direction callback */
+	int /*long*/ setDirectionProc;
+	Callback setDirectionCallback;
+	static final String GET_DIRECTION_PROC_KEY = "org.eclipse.swt.internal.gtk.getDirectionProc"; //$NON-NLS-1$
+	
+	/* Set emissionProc callback */
+	int /*long*/ emissionProc;
+	Callback emissionProcCallback;
+	static final String GET_EMISSION_PROC_KEY = "org.eclipse.swt.internal.gtk.getEmissionProc"; //$NON-NLS-1$
+	
+	/* Get all children callback */
+	int /*long*/ allChildrenProc, allChildren;
+	Callback allChildrenCallback;
+
+	/* Settings callbacks */
+	int /*long*/ styleSetProc;
+	Callback styleSetCallback;
+	int /*long*/ shellHandle;
+	boolean settingsChanged, runSettings;
+	
+	/* Entry focus behaviour */
+	boolean entrySelectOnFocus;
+	
+	/* Enter/Exit events */
+	Control currentControl;
+	
+	/* Flush exposes */
+	int /*long*/ checkIfEventProc;
+	Callback checkIfEventCallback;
+	int /*long*/ flushWindow;
+	boolean flushAll;
+	GdkRectangle flushRect = new GdkRectangle ();
+	XExposeEvent exposeEvent = new XExposeEvent ();
+	XVisibilityEvent visibilityEvent = new XVisibilityEvent ();
+	int /*long*/ [] flushData = new int /*long*/ [1];
+
+	/* System Resources */
+	Font systemFont;
+	Image errorImage, infoImage, questionImage, warningImage;
+	Cursor [] cursors = new Cursor [SWT.CURSOR_HAND + 1];
+	Resource [] resources;
+	static final int RESOURCE_SIZE = 1 + 4 + SWT.CURSOR_HAND + 1;
+
+	/* Colors */
+	GdkColor COLOR_WIDGET_DARK_SHADOW, COLOR_WIDGET_NORMAL_SHADOW, COLOR_WIDGET_LIGHT_SHADOW;
+	GdkColor COLOR_WIDGET_HIGHLIGHT_SHADOW, COLOR_WIDGET_BACKGROUND, COLOR_WIDGET_FOREGROUND, COLOR_WIDGET_BORDER;
+	GdkColor COLOR_LIST_FOREGROUND, COLOR_LIST_BACKGROUND, COLOR_LIST_SELECTION, COLOR_LIST_SELECTION_TEXT;
+	GdkColor COLOR_INFO_BACKGROUND, COLOR_INFO_FOREGROUND;
+	GdkColor COLOR_TITLE_FOREGROUND, COLOR_TITLE_BACKGROUND, COLOR_TITLE_BACKGROUND_GRADIENT;
+	GdkColor COLOR_TITLE_INACTIVE_FOREGROUND, COLOR_TITLE_INACTIVE_BACKGROUND, COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT;
+
+	/* Popup Menus */
+	Menu [] popups;
+	
+	/* Click count*/
+	int clickCount = 1;
+	
+	/* Timestamp of the Last Received Events */
+	int lastEventTime, lastUserEventTime;
+	
+	/* Fixed Subclass */
+	static int /*long*/ fixed_type;
+	static int /*long*/ fixed_info_ptr;
+	static Callback fixedClassInitCallback, fixedMapCallback, fixedSizeAllocateCallback;
+	static int /*long*/ fixedClassInitProc, fixedMapProc, fixedSizeAllocateProc, oldFixedSizeAllocateProc;
+
+	/* Renderer Subclass */
+	static int /*long*/ text_renderer_type, pixbuf_renderer_type, toggle_renderer_type;
+	static int /*long*/ text_renderer_info_ptr, pixbuf_renderer_info_ptr, toggle_renderer_info_ptr;
+	static Callback rendererClassInitCallback, rendererRenderCallback, rendererGetSizeCallback;
+	static int /*long*/ rendererClassInitProc, rendererRenderProc, rendererGetSizeProc;
+
+	/* Key Mappings */
+	static final int [] [] KeyTable = {
+		
+		/* Keyboard and Mouse Masks */
+		{OS.GDK_Alt_L,		SWT.ALT},
+		{OS.GDK_Alt_R,		SWT.ALT},
+		{OS.GDK_Meta_L,	SWT.ALT},
+		{OS.GDK_Meta_R,	SWT.ALT},
+		{OS.GDK_Shift_L,		SWT.SHIFT},
+		{OS.GDK_Shift_R,		SWT.SHIFT},
+		{OS.GDK_Control_L,	SWT.CONTROL},
+		{OS.GDK_Control_R,	SWT.CONTROL},
+//		{OS.GDK_????,		SWT.COMMAND},
+//		{OS.GDK_????,		SWT.COMMAND},
+		
+		/* Non-Numeric Keypad Keys */
+		{OS.GDK_Up,						SWT.ARROW_UP},
+		{OS.GDK_KP_Up,					SWT.ARROW_UP},
+		{OS.GDK_Down,					SWT.ARROW_DOWN},
+		{OS.GDK_KP_Down,			SWT.ARROW_DOWN},
+		{OS.GDK_Left,						SWT.ARROW_LEFT},
+		{OS.GDK_KP_Left,				SWT.ARROW_LEFT},
+		{OS.GDK_Right,					SWT.ARROW_RIGHT},
+		{OS.GDK_KP_Right,				SWT.ARROW_RIGHT},
+		{OS.GDK_Page_Up,				SWT.PAGE_UP},
+		{OS.GDK_KP_Page_Up,		SWT.PAGE_UP},
+		{OS.GDK_Page_Down,			SWT.PAGE_DOWN},
+		{OS.GDK_KP_Page_Down,	SWT.PAGE_DOWN},
+		{OS.GDK_Home,					SWT.HOME},
+		{OS.GDK_KP_Home,			SWT.HOME},
+		{OS.GDK_End,						SWT.END},
+		{OS.GDK_KP_End,				SWT.END},
+		{OS.GDK_Insert,					SWT.INSERT},
+		{OS.GDK_KP_Insert,			SWT.INSERT},
+		
+		/* Virtual and Ascii Keys */
+		{OS.GDK_BackSpace,		SWT.BS},
+		{OS.GDK_Return,				SWT.CR},
+		{OS.GDK_Delete,				SWT.DEL},
+		{OS.GDK_KP_Delete,		SWT.DEL},
+		{OS.GDK_Escape,			SWT.ESC},
+		{OS.GDK_Linefeed,			SWT.LF},
+		{OS.GDK_Tab,					SWT.TAB},
+		{OS.GDK_ISO_Left_Tab, 	SWT.TAB},
+	
+		/* Functions Keys */
+		{OS.GDK_F1,		SWT.F1},
+		{OS.GDK_F2,		SWT.F2},
+		{OS.GDK_F3,		SWT.F3},
+		{OS.GDK_F4,		SWT.F4},
+		{OS.GDK_F5,		SWT.F5},
+		{OS.GDK_F6,		SWT.F6},
+		{OS.GDK_F7,		SWT.F7},
+		{OS.GDK_F8,		SWT.F8},
+		{OS.GDK_F9,		SWT.F9},
+		{OS.GDK_F10,		SWT.F10},
+		{OS.GDK_F11,		SWT.F11},
+		{OS.GDK_F12,		SWT.F12},
+		{OS.GDK_F13,		SWT.F13},
+		{OS.GDK_F14,		SWT.F14},
+		{OS.GDK_F15,		SWT.F15},
+		
+		/* Numeric Keypad Keys */
+		{OS.GDK_KP_Multiply,		SWT.KEYPAD_MULTIPLY},
+		{OS.GDK_KP_Add,			SWT.KEYPAD_ADD},
+		{OS.GDK_KP_Enter,			SWT.KEYPAD_CR},
+		{OS.GDK_KP_Subtract,	SWT.KEYPAD_SUBTRACT},
+		{OS.GDK_KP_Decimal,	SWT.KEYPAD_DECIMAL},
+		{OS.GDK_KP_Divide,		SWT.KEYPAD_DIVIDE},
+		{OS.GDK_KP_0,			SWT.KEYPAD_0},
+		{OS.GDK_KP_1,			SWT.KEYPAD_1},
+		{OS.GDK_KP_2,			SWT.KEYPAD_2},
+		{OS.GDK_KP_3,			SWT.KEYPAD_3},
+		{OS.GDK_KP_4,			SWT.KEYPAD_4},
+		{OS.GDK_KP_5,			SWT.KEYPAD_5},
+		{OS.GDK_KP_6,			SWT.KEYPAD_6},
+		{OS.GDK_KP_7,			SWT.KEYPAD_7},
+		{OS.GDK_KP_8,			SWT.KEYPAD_8},
+		{OS.GDK_KP_9,			SWT.KEYPAD_9},
+		{OS.GDK_KP_Equal,	SWT.KEYPAD_EQUAL},
+
+		/* Other keys */
+		{OS.GDK_Caps_Lock,		SWT.CAPS_LOCK},
+		{OS.GDK_Num_Lock,		SWT.NUM_LOCK},
+		{OS.GDK_Scroll_Lock,		SWT.SCROLL_LOCK},
+		{OS.GDK_Pause,				SWT.PAUSE},
+		{OS.GDK_Break,				SWT.BREAK},
+		{OS.GDK_Print,					SWT.PRINT_SCREEN},
+		{OS.GDK_Help,					SWT.HELP},
+		
+	};
+
+	/* Multiple Displays. */
+	static Display Default;
+	static Display [] Displays = new Display [4];
+
+	/* Package name */
+	static final String PACKAGE_PREFIX = "org.eclipse.swt.widgets."; //$NON-NLS-1$
+	/* This code is intentionally commented.
+	 * ".class" can not be used on CLDC.
+	 */
+//	static {
+//		String name = Display.class.getName ();
+//		int index = name.lastIndexOf ('.');
+//		PACKAGE_NAME = name.substring (0, index + 1);
+//	}
+
+	/* GTK Version */
+	static final int MAJOR = 2;
+	static final int MINOR = 0;
+	static final int MICRO = 6;
+
+	/* Display Data */
+	Object data;
+	String [] keys;
+	Object [] values;
+	
+	/* Initial Guesses for Shell Trimmings. */
+	int borderTrimWidth = 4, borderTrimHeight = 4;
+	int resizeTrimWidth = 6, resizeTrimHeight = 6;
+	int titleBorderTrimWidth = 5, titleBorderTrimHeight = 28;
+	int titleResizeTrimWidth = 6, titleResizeTrimHeight = 29;
+	int titleTrimWidth = 0, titleTrimHeight = 23;
+	boolean ignoreTrim;
+
+	/* Window Manager */
+	String windowManager;
+
+	/*
+	* TEMPORARY CODE.  Install the runnable that
+	* gets the current display. This code will
+	* be removed in the future.
+	*/
+	static {
+		DeviceFinder = new Runnable () {
+			public void run () {
+				Device device = getCurrent ();
+				if (device == null) {
+					device = getDefault ();
+				}
+				setDevice (device);
+			}
+		};
+	}
+
+/*
+* TEMPORARY CODE.
+*/
+static void setDevice (Device device) {
+	CurrentDevice = device;
+}
+
+/**
+ * Constructs a new instance of this class.
+ * <p>
+ * Note: The resulting display is marked as the <em>current</em>
+ * display. If this is the first display which has been 
+ * constructed since the application started, it is also
+ * marked as the <em>default</em> display.
+ * </p>
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if called from a thread that already created an existing display</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see #getCurrent
+ * @see #getDefault
+ * @see Widget#checkSubclass
+ * @see Shell
+ */
+public Display () {
+	this (null);
+}
+
+/**
+ * Constructs a new instance of this class using the parameter.
+ * 
+ * @param data the device data
+ */
+public Display (DeviceData data) {
+	super (data);
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when an event of the given type occurs anywhere
+ * in a widget. The event type is one of the event constants
+ * defined in class <code>SWT</code>. When the event does occur,
+ * the listener is notified by sending it the <code>handleEvent()</code>
+ * message.
+ * <p>
+ * Setting the type of an event to <code>SWT.None</code> from
+ * within the <code>handleEvent()</code> method can be used to
+ * change the event type and stop subsequent Java listeners
+ * from running. Because event filters run before other listeners,
+ * event filters can both block other listeners and set arbitrary
+ * fields within an event. For this reason, event filters are both
+ * powerful and dangerous. They should generally be avoided for
+ * performance, debugging and code maintenance reasons.
+ * </p>
+ * 
+ * @param eventType the type of event to listen for
+ * @param listener the listener which should be notified when the event occurs
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see Listener
+ * @see SWT
+ * @see #removeFilter
+ * @see #removeListener
+ * 
+ * @since 3.0 
+ */
+public void addFilter (int eventType, Listener listener) {
+	checkDevice ();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if (filterTable == null) filterTable = new EventTable ();
+	filterTable.hook (eventType, listener);
+}
+
+void addGdkEvent (int /*long*/ event) {
+	if (gdkEvents == null) {
+		int length = GROW_SIZE;
+		gdkEvents = new int /*long*/ [length];
+		gdkEventWidgets = new Widget [length];
+		gdkEventCount = 0;
+	}
+	if (gdkEventCount == gdkEvents.length) {
+		int length = gdkEventCount + GROW_SIZE;
+		int /*long*/ [] newEvents = new int /*long*/ [length];
+		System.arraycopy (gdkEvents, 0, newEvents, 0, gdkEventCount);
+		gdkEvents = newEvents;
+		Widget [] newWidgets = new Widget [length];
+		System.arraycopy (gdkEventWidgets, 0, newWidgets, 0, gdkEventCount);
+		gdkEventWidgets = newWidgets;
+	}
+	Widget widget = null;
+	int /*long*/ handle = OS.gtk_get_event_widget (event);
+	if (handle != 0) {
+		do {
+			widget = getWidget (handle);
+		} while (widget == null && (handle = OS.gtk_widget_get_parent (handle)) != 0);
+	}
+	gdkEvents [gdkEventCount] = event;
+	gdkEventWidgets [gdkEventCount] = widget;
+	gdkEventCount++;
+}
+
+void addIdleProc() {
+	synchronized (idleLock){
+		this.idleNeeded = true;
+		if (idleHandle == 0) {
+			idleHandle = OS.g_idle_add (idleProc, 0);
+		}
+	}
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when an event of the given type occurs. The event
+ * type is one of the event constants defined in class <code>SWT</code>.
+ * When the event does occur in the display, the listener is notified by
+ * sending it the <code>handleEvent()</code> message.
+ *
+ * @param eventType the type of event to listen for
+ * @param listener the listener which should be notified when the event occurs
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see Listener
+ * @see SWT
+ * @see #removeListener
+ * 
+ * @since 2.0 
+ */
+public void addListener (int eventType, Listener listener) {
+	checkDevice ();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if (eventTable == null) eventTable = new EventTable ();
+	eventTable.hook (eventType, listener);
+}
+
+int /*long*/ allChildrenProc (int /*long*/ widget, int /*long*/ recurse) {
+	allChildren = OS.g_list_append (allChildren, widget);
+	if (recurse != 0 && OS.GTK_IS_CONTAINER (widget)) {
+		OS.gtk_container_forall (widget, allChildrenProc, recurse);
+	}
+	return 0;
+}
+
+void addMouseHoverTimeout (int /*long*/ handle) {
+	if (mouseHoverId != 0) OS.gtk_timeout_remove (mouseHoverId);
+	mouseHoverId = OS.gtk_timeout_add (400, mouseHoverProc, handle);
+	mouseHoverHandle = handle;
+}
+
+void addPopup (Menu menu) {
+	if (popups == null) popups = new Menu [4];
+	int length = popups.length;
+	for (int i=0; i<length; i++) {
+		if (popups [i] == menu) return;
+	}
+	int index = 0;
+	while (index < length) {
+		if (popups [index] == null) break;
+		index++;
+	}
+	if (index == length) {
+		Menu [] newPopups = new Menu [length + 4];
+		System.arraycopy (popups, 0, newPopups, 0, length);
+		popups = newPopups;
+	}
+	popups [index] = menu;
+}
+
+void addWidget (int /*long*/ handle, Widget widget) {
+	if (handle == 0) return;
+	if (freeSlot == -1) {
+		int length = (freeSlot = indexTable.length) + GROW_SIZE;
+		int[] newIndexTable = new int[length];
+		Widget[] newWidgetTable = new Widget [length];
+		System.arraycopy (indexTable, 0, newIndexTable, 0, freeSlot);
+		System.arraycopy (widgetTable, 0, newWidgetTable, 0, freeSlot);
+		for (int i = freeSlot; i < length - 1; i++) {
+			newIndexTable[i] = i + 1;
+		}
+		newIndexTable[length - 1] = -1;
+		indexTable = newIndexTable;
+		widgetTable = newWidgetTable;
+	}
+	int index = freeSlot + 1;
+	OS.g_object_set_qdata (handle, SWT_OBJECT_INDEX, index);
+	int oldSlot = freeSlot;
+	freeSlot = indexTable[oldSlot];
+	indexTable [oldSlot] = -2;
+	widgetTable [oldSlot] = widget;
+}
+
+/**
+ * Causes the <code>run()</code> method of the runnable to
+ * be invoked by the user-interface thread at the next 
+ * reasonable opportunity. The caller of this method continues 
+ * to run in parallel, and is not notified when the
+ * runnable has completed.  Specifying <code>null</code> as the
+ * runnable simply wakes the user-interface thread when run.
+ * <p>
+ * Note that at the time the runnable is invoked, widgets 
+ * that have the receiver as their display may have been
+ * disposed. Therefore, it is necessary to check for this
+ * case inside the runnable before accessing the widget.
+ * </p>
+ *
+ * @param runnable code to run on the user-interface thread or <code>null</code>
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @see #syncExec
+ */
+public void asyncExec (Runnable runnable) {
+	synchronized (Device.class) {
+		if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED);
+		synchronized (idleLock) {
+			if (idleNeeded && idleHandle == 0) {
+	 			//NOTE: calling unlocked function in OS
+				idleHandle = OS._g_idle_add (idleProc, 0);
+			}
+		}
+		synchronizer.asyncExec (runnable);
+	}
+}
+
+/**
+ * Causes the system hardware to emit a short sound
+ * (if it supports this capability).
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void beep () {
+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+	OS.gdk_beep();
+	if (!OS.GDK_WINDOWING_X11 ()) {
+		OS.gdk_flush ();
+	} else {
+		int /*long*/ xDisplay = OS.GDK_DISPLAY ();
+		OS.XFlush (xDisplay);
+	}
+}
+
+int /*long*/ cellDataProc (int /*long*/ tree_column, int /*long*/ cell, int /*long*/ tree_model, int /*long*/ iter, int /*long*/ data) {
+	Widget widget = getWidget (data);
+	if (widget == null) return 0;
+	return widget.cellDataProc (tree_column, cell, tree_model, iter, data);
+}
+
+protected void checkDevice () {
+	if (thread == null) error (SWT.ERROR_WIDGET_DISPOSED);
+	if (thread != Thread.currentThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+	if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED);
+}
+
+static void checkDisplay (Thread thread, boolean multiple) {
+	synchronized (Device.class) {
+		for (int i=0; i<Displays.length; i++) {
+			if (Displays [i] != null) {
+				if (!multiple) SWT.error (SWT.ERROR_NOT_IMPLEMENTED, null, " [multiple displays]"); //$NON-NLS-1$
+				if (Displays [i].thread == thread) SWT.error (SWT.ERROR_THREAD_INVALID_ACCESS);
+			}
+		}
+	}
+}
+
+int /*long*/ checkIfEventProc (int /*long*/ display, int /*long*/ xEvent, int /*long*/ userData) {
+	int type = OS.X_EVENT_TYPE (xEvent);
+	switch (type) {
+		case OS.VisibilityNotify:
+		case OS.Expose:
+		case OS.GraphicsExpose:
+			break;
+		default:
+			return 0;
+	}
+	int /*long*/ window = OS.gdk_window_lookup (OS.X_EVENT_WINDOW (xEvent));
+	if (window == 0) return 0;
+	if (flushWindow != 0) {
+		if (flushAll) {
+			int /*long*/ tempWindow = window;
+			do {
+				if (tempWindow == flushWindow) break;
+			} while ((tempWindow = OS.gdk_window_get_parent (tempWindow)) != 0);
+			if (tempWindow != flushWindow) return 0;
+		} else {
+			if (window != flushWindow) return 0;
+		}
+	}
+	OS.memmove (exposeEvent, xEvent, XExposeEvent.sizeof);
+	switch (type) {
+		case OS.Expose:
+		case OS.GraphicsExpose: {
+			flushRect.x = exposeEvent.x;
+			flushRect.y = exposeEvent.y;
+			flushRect.width = exposeEvent.width;
+			flushRect.height = exposeEvent.height;
+			OS.gdk_window_invalidate_rect (window, flushRect, true);
+			exposeEvent.type = -1;
+			OS.memmove (xEvent, exposeEvent, XExposeEvent.sizeof);
+			break;
+		}
+		case OS.VisibilityNotify: {
+			OS.memmove (visibilityEvent, xEvent, XVisibilityEvent.sizeof);
+			OS.gdk_window_get_user_data (window, flushData);
+			int /*long*/ handle = flushData [0];
+			Widget widget = handle != 0 ? getWidget (handle) : null;
+			if (widget != null && widget instanceof Control) {
+				Control control = (Control) widget;
+				if (window == control.paintWindow ()) {
+					if (visibilityEvent.state == OS.VisibilityFullyObscured) {
+						control.state |= Widget.OBSCURED;
+					} else {
+						control.state &= ~Widget.OBSCURED;
+					}
+				}
+			}
+			break;
+		}
+	}
+	return 0;
+}
+
+/**
+ * Checks that this class can be subclassed.
+ * <p>
+ * IMPORTANT: See the comment in <code>Widget.checkSubclass()</code>.
+ * </p>
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see Widget#checkSubclass
+ */
+protected void checkSubclass () {
+	if (!isValidClass (getClass ())) error (SWT.ERROR_INVALID_SUBCLASS);
+}
+
+void clearModal (Shell shell) {
+	if (modalShells == null) return;
+	int index = 0, length = modalShells.length;
+	while (index < length) {
+		if (modalShells [index] == shell) break;
+		if (modalShells [index] == null) return;
+		index++;
+	}
+	if (index == length) return;
+	System.arraycopy (modalShells, index + 1, modalShells, index, --length - index);
+	modalShells [length] = null;
+	if (index == 0 && modalShells [0] == null) modalShells = null;
+	Shell [] shells = getShells ();
+	for (int i=0; i<shells.length; i++) shells [i].updateModal ();
+}
+
+/**
+ * Requests that the connection between SWT and the underlying
+ * operating system be closed.
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see Device#dispose
+ * 
+ * @since 2.0
+ */
+public void close () {
+	checkDevice ();
+	Event event = new Event ();
+	sendEvent (SWT.Close, event);
+	if (event.doit) dispose ();
+}
+
+/**
+ * Creates the device in the operating system.  If the device
+ * does not have a handle, this method may do nothing depending
+ * on the device.
+ * <p>
+ * This method is called before <code>init</code>.
+ * </p>
+ *
+ * @param data the DeviceData which describes the receiver
+ *
+ * @see #init
+ */
+protected void create (DeviceData data) {
+	checkSubclass ();
+	checkDisplay(thread = Thread.currentThread (), false);
+	createDisplay (data);
+	register (this);
+	if (Default == null) Default = this;
+}
+
+void createDisplay (DeviceData data) {
+	/* Required for g_main_context_wakeup */
+	if (!OS.g_thread_supported ()) {
+		OS.g_thread_init (0);
+	}
+	OS.gtk_set_locale();
+	if (!OS.gtk_init_check (new int /*long*/ [] {0}, null)) {
+		SWT.error (SWT.ERROR_NO_HANDLES, null, " [gtk_init_check() failed]"); //$NON-NLS-1$
+	}
+	if (OS.GDK_WINDOWING_X11 ()) xDisplay = OS.GDK_DISPLAY ();
+	int /*long*/ ptr = OS.gtk_check_version (MAJOR, MINOR, MICRO);
+	if (ptr != 0) {
+		int length = OS.strlen (ptr);
+		byte [] buffer = new byte [length];
+		OS.memmove (buffer, ptr, length);
+		System.out.println ("***WARNING: " + new String (Converter.mbcsToWcs (null, buffer))); //$NON-NLS-1$
+		System.out.println ("***WARNING: SWT requires GTK " + MAJOR+ "." + MINOR + "." + MICRO); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+		int major = OS.gtk_major_version (), minor = OS.gtk_minor_version (), micro = OS.gtk_micro_version ();
+		System.out.println ("***WARNING: Detected: " + major + "." + minor + "." + micro); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+	}
+	if (fixed_type == 0) {
+		byte [] type_name = Converter.wcsToMbcs (null, "SwtFixed", true); //$NON-NLS-1$
+		fixedClassInitCallback = new Callback (getClass (), "fixedClassInitProc", 2); //$NON-NLS-1$
+		fixedClassInitProc = fixedClassInitCallback.getAddress ();
+		if (fixedClassInitProc == 0) SWT.error (SWT.ERROR_NO_MORE_CALLBACKS);
+		fixedMapCallback = new Callback (getClass (), "fixedMapProc", 1); //$NON-NLS-1$
+		fixedMapProc = fixedMapCallback.getAddress ();
+		if (fixedMapProc == 0) SWT.error (SWT.ERROR_NO_MORE_CALLBACKS);
+		fixedSizeAllocateCallback = new Callback (getClass (), "fixedSizeAllocateProc", 2); //$NON-NLS-1$
+		fixedSizeAllocateProc = fixedSizeAllocateCallback.getAddress ();
+		if (fixedSizeAllocateProc == 0) SWT.error (SWT.ERROR_NO_MORE_CALLBACKS);
+		GTypeInfo fixed_info = new GTypeInfo ();
+		fixed_info.class_size = (short) OS.GtkFixedClass_sizeof ();
+		fixed_info.class_init = fixedClassInitProc;
+		fixed_info.instance_size = (short) OS.GtkFixed_sizeof ();
+		fixed_info_ptr = OS.g_malloc (GTypeInfo.sizeof);
+		OS.memmove (fixed_info_ptr, fixed_info, GTypeInfo.sizeof);
+		fixed_type = OS.g_type_register_static (OS.GTK_TYPE_FIXED (), type_name, fixed_info_ptr, 0);
+	}
+	if (rendererClassInitProc == 0) {
+		rendererClassInitCallback = new Callback (getClass (), "rendererClassInitProc", 2); //$NON-NLS-1$
+		rendererClassInitProc = rendererClassInitCallback.getAddress ();
+		if (rendererClassInitProc == 0) SWT.error (SWT.ERROR_NO_MORE_CALLBACKS);
+	}
+	if (rendererRenderProc == 0) {
+		rendererRenderCallback = new Callback (getClass (), "rendererRenderProc", 7); //$NON-NLS-1$
+		rendererRenderProc = rendererRenderCallback.getAddress ();
+		if (rendererRenderProc == 0) SWT.error (SWT.ERROR_NO_MORE_CALLBACKS);
+	}
+	if (rendererGetSizeProc == 0) {
+		rendererGetSizeCallback = new Callback (getClass (), "rendererGetSizeProc", 7); //$NON-NLS-1$
+		rendererGetSizeProc = rendererGetSizeCallback.getAddress ();
+		if (rendererGetSizeProc == 0) SWT.error (SWT.ERROR_NO_MORE_CALLBACKS);
+	}
+	if (text_renderer_type == 0) {
+		GTypeInfo renderer_info = new GTypeInfo ();
+		renderer_info.class_size = (short) OS.GtkCellRendererTextClass_sizeof ();
+		renderer_info.class_init = rendererClassInitProc;
+		renderer_info.instance_size = (short) OS.GtkCellRendererText_sizeof ();
+		text_renderer_info_ptr = OS.g_malloc (GTypeInfo.sizeof);
+		OS.memmove (text_renderer_info_ptr, renderer_info, GTypeInfo.sizeof);
+		byte [] type_name = Converter.wcsToMbcs (null, "SwtTextRenderer", true); //$NON-NLS-1$
+		text_renderer_type = OS.g_type_register_static (OS.GTK_TYPE_CELL_RENDERER_TEXT (), type_name, text_renderer_info_ptr, 0);
+	}
+	if (pixbuf_renderer_type == 0) {
+		GTypeInfo renderer_info = new GTypeInfo ();
+		renderer_info.class_size = (short) OS.GtkCellRendererPixbufClass_sizeof ();
+		renderer_info.class_init = rendererClassInitProc;
+		renderer_info.instance_size = (short) OS.GtkCellRendererPixbuf_sizeof ();
+		pixbuf_renderer_info_ptr = OS.g_malloc (GTypeInfo.sizeof);
+		OS.memmove (pixbuf_renderer_info_ptr, renderer_info, GTypeInfo.sizeof);
+		byte [] type_name = Converter.wcsToMbcs (null, "SwtPixbufRenderer", true); //$NON-NLS-1$
+		pixbuf_renderer_type = OS.g_type_register_static (OS.GTK_TYPE_CELL_RENDERER_PIXBUF (), type_name, pixbuf_renderer_info_ptr, 0);
+	}	
+	if (toggle_renderer_type == 0) {
+		GTypeInfo renderer_info = new GTypeInfo ();
+		renderer_info.class_size = (short) OS.GtkCellRendererToggleClass_sizeof ();
+		renderer_info.class_init = rendererClassInitProc;
+		renderer_info.instance_size = (short) OS.GtkCellRendererToggle_sizeof ();
+		toggle_renderer_info_ptr = OS.g_malloc (GTypeInfo.sizeof);
+		OS.memmove (toggle_renderer_info_ptr, renderer_info, GTypeInfo.sizeof);
+		byte [] type_name = Converter.wcsToMbcs (null, "SwtToggleRenderer", true); //$NON-NLS-1$
+		toggle_renderer_type = OS.g_type_register_static (OS.GTK_TYPE_CELL_RENDERER_TOGGLE (), type_name, toggle_renderer_info_ptr, 0);
+	}
+	
+	OS.gtk_widget_set_default_direction (OS.GTK_TEXT_DIR_LTR);
+	OS.gdk_rgb_init ();
+	byte [] buffer = Converter.wcsToMbcs (null, APP_NAME, true);
+	OS.g_set_prgname (buffer);
+	OS.gdk_set_program_class (buffer);
+	byte [] flatStyle = Converter.wcsToMbcs (null, "style \"swt-flat\" { GtkToolbar::shadow-type = none } widget \"*.swt-toolbar-flat\" style : highest \"swt-flat\"", true); //$NON-NLS-1$
+	OS.gtk_rc_parse_string (flatStyle);
+
+	/* Initialize the hidden shell */
+	shellHandle = OS.gtk_window_new (OS.GTK_WINDOW_TOPLEVEL);
+	if (shellHandle == 0) SWT.error (SWT.ERROR_NO_HANDLES);
+	OS.gtk_widget_realize (shellHandle);
+
+	/* Initialize the filter and event callback */
+	eventCallback = new Callback (this, "eventProc", 2); //$NON-NLS-1$
+	eventProc = eventCallback.getAddress ();
+	if (eventProc == 0) SWT.error (SWT.ERROR_NO_MORE_CALLBACKS);
+	OS.gdk_event_handler_set (eventProc, 0, 0);
+	filterCallback = new Callback (this, "filterProc", 3); //$NON-NLS-1$
+	filterProc = filterCallback.getAddress ();
+	if (filterProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);
+	OS.gdk_window_add_filter  (0, filterProc, 0);
+}
+
+Image createImage (String name) {
+	int /*long*/ style = OS.gtk_widget_get_default_style ();
+	byte[] buffer = Converter.wcsToMbcs (null, name, true);
+	int /*long*/ pixbuf = OS.gtk_icon_set_render_icon (
+		OS.gtk_icon_factory_lookup_default (buffer), style,
+		OS.GTK_TEXT_DIR_NONE, OS.GTK_STATE_NORMAL, OS.GTK_ICON_SIZE_DIALOG, 0, 0);
+	if (pixbuf == 0) return null;
+	int width = OS.gdk_pixbuf_get_width (pixbuf);
+	int height = OS.gdk_pixbuf_get_height (pixbuf);
+	int stride = OS.gdk_pixbuf_get_rowstride (pixbuf);
+	boolean hasAlpha = OS.gdk_pixbuf_get_has_alpha (pixbuf);
+	int /*long*/ pixels = OS.gdk_pixbuf_get_pixels (pixbuf);
+	byte [] data = new byte [stride * height];
+	OS.memmove (data, pixels, data.length);
+	OS.g_object_unref (pixbuf);
+	ImageData imageData = null;
+	if (hasAlpha) {
+		PaletteData palette = new PaletteData (0xFF000000, 0xFF0000, 0xFF00);
+		imageData = new ImageData (width, height, 32, palette);
+		byte [] alpha = new byte [stride * height];
+		for (int y=0; y<height; y++) {
+			for (int x=0; x<width; x++) {
+				alpha [y*width+x] = data [y*stride+x*4+3];
+				data [y*stride+x*4+3] = 0;
+			}
+		}
+		imageData.setAlphas (0, 0, width * height, alpha, 0);
+	} else {
+		PaletteData palette = new PaletteData (0xFF0000, 0xFF00, 0xFF);
+		imageData = new ImageData (width, height, 24, palette);
+	}
+	imageData.data = data;
+	imageData.bytesPerLine = stride;
+	return new Image (this, imageData);
+}
+
+static int /*long*/ createPixbuf(Image image) {
+	int [] w = new int [1], h = new int [1];
+ 	OS.gdk_drawable_get_size (image.pixmap, w, h);
+	int /*long*/ colormap = OS.gdk_colormap_get_system ();
+	int /*long*/ pixbuf;
+	boolean hasMask = image.mask != 0 && OS.gdk_drawable_get_depth (image.mask) == 1;
+	if (hasMask) {
+		pixbuf = OS.gdk_pixbuf_new (OS.GDK_COLORSPACE_RGB, true, 8, w [0], h [0]);
+		if (pixbuf == 0) SWT.error (SWT.ERROR_NO_HANDLES);
+		OS.gdk_pixbuf_get_from_drawable (pixbuf, image.pixmap, colormap, 0, 0, 0, 0, w [0], h [0]);
+		int /*long*/ maskPixbuf = OS.gdk_pixbuf_new(OS.GDK_COLORSPACE_RGB, false, 8, w [0], h [0]);
+		if (maskPixbuf == 0) SWT.error (SWT.ERROR_NO_HANDLES);
+		OS.gdk_pixbuf_get_from_drawable(maskPixbuf, image.mask, 0, 0, 0, 0, 0, w [0], h [0]);
+		int stride = OS.gdk_pixbuf_get_rowstride(pixbuf);
+		int /*long*/ pixels = OS.gdk_pixbuf_get_pixels(pixbuf);
+		byte[] line = new byte[stride];
+		int maskStride = OS.gdk_pixbuf_get_rowstride(maskPixbuf);
+		int /*long*/ maskPixels = OS.gdk_pixbuf_get_pixels(maskPixbuf);
+		byte[] maskLine = new byte[maskStride];
+		for (int y=0; y<h[0]; y++) {
+			int /*long*/ offset = pixels + (y * stride);
+			OS.memmove(line, offset, stride);
+			int /*long*/ maskOffset = maskPixels + (y * maskStride);
+			OS.memmove(maskLine, maskOffset, maskStride);
+			for (int x=0; x<w[0]; x++) {
+				if (maskLine[x * 3] == 0) {
+					line[x * 4 + 3] = 0;
+				}
+			}
+			OS.memmove(offset, line, stride);
+		}
+		OS.g_object_unref(maskPixbuf);
+	} else {
+		ImageData data = image.getImageData ();
+		boolean hasAlpha = data.getTransparencyType () == SWT.TRANSPARENCY_ALPHA;
+		pixbuf = OS.gdk_pixbuf_new (OS.GDK_COLORSPACE_RGB, hasAlpha, 8, w [0], h [0]);
+		if (pixbuf == 0) SWT.error (SWT.ERROR_NO_HANDLES);
+		OS.gdk_pixbuf_get_from_drawable (pixbuf, image.pixmap, colormap, 0, 0, 0, 0, w [0], h [0]);
+		if (hasAlpha) {
+			byte [] alpha = data.alphaData;
+			int stride = OS.gdk_pixbuf_get_rowstride (pixbuf);
+			int /*long*/ pixels = OS.gdk_pixbuf_get_pixels (pixbuf);
+			byte [] line = new byte [stride];
+			for (int y = 0; y < h [0]; y++) {
+				int /*long*/ offset = pixels + (y * stride);
+				OS.memmove (line, offset, stride);
+				for (int x = 0; x < w [0]; x++) {
+					line [x*4+3] = alpha [y*w [0]+x];
+				}
+				OS.memmove (offset, line, stride);
+			}
+		}
+	}
+	return pixbuf;
+}
+
+static void deregister (Display display) {
+	synchronized (Device.class) {
+		for (int i=0; i<Displays.length; i++) {
+			if (display == Displays [i]) Displays [i] = null;
+		}
+	}
+}
+
+/**
+ * Destroys the device in the operating system and releases
+ * the device's handle.  If the device does not have a handle,
+ * this method may do nothing depending on the device.
+ * <p>
+ * This method is called after <code>release</code>.
+ * </p>
+ * @see Device#dispose
+ * @see #release
+ */
+protected void destroy () {
+	if (this == Default) Default = null;
+	deregister (this);
+	destroyDisplay ();
+}
+
+void destroyDisplay () {
+}
+
+int /*long*/ emissionProc (int /*long*/ ihint, int /*long*/ n_param_values, int /*long*/ param_values, int /*long*/ data) {
+	if (OS.gtk_widget_get_toplevel (OS.g_value_peek_pointer(param_values)) == data) {
+		OS.gtk_widget_set_direction (OS.g_value_peek_pointer(param_values), OS.GTK_TEXT_DIR_RTL);
+	}
+	return 1;
+}
+
+/**
+ * Returns the display which the given thread is the
+ * user-interface thread for, or null if the given thread
+ * is not a user-interface thread for any display.  Specifying
+ * <code>null</code> as the thread will return <code>null</code>
+ * for the display. 
+ *
+ * @param thread the user-interface thread
+ * @return the display for the given thread
+ */
+public static Display findDisplay (Thread thread) {
+	synchronized (Device.class) {
+		for (int i=0; i<Displays.length; i++) {
+			Display display = Displays [i];
+			if (display != null && display.thread == thread) {
+				return display;
+			}
+		}
+		return null;
+	}
+}
+
+/**
+ * Causes the <code>run()</code> method of the runnable to
+ * be invoked by the user-interface thread just before the
+ * receiver is disposed.  Specifying a <code>null</code> runnable
+ * is ignored.
+ *
+ * @param runnable code to run at dispose time.
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public void disposeExec (Runnable runnable) {
+	checkDevice ();
+	if (disposeList == null) disposeList = new Runnable [4];
+	for (int i=0; i<disposeList.length; i++) {
+		if (disposeList [i] == null) {
+			disposeList [i] = runnable;
+			return;
+		}
+	}
+	Runnable [] newDisposeList = new Runnable [disposeList.length + 4];
+	System.arraycopy (disposeList, 0, newDisposeList, 0, disposeList.length);
+	newDisposeList [disposeList.length] = runnable;
+	disposeList = newDisposeList;
+}
+
+/**
+ * Does whatever display specific cleanup is required, and then
+ * uses the code in <code>SWTError.error</code> to handle the error.
+ *
+ * @param code the descriptive error code
+ *
+ * @see SWTError#error
+ */
+void error (int code) {
+	SWT.error (code);
+}
+
+int /*long*/ eventProc (int /*long*/ event, int /*long*/ data) {
+	/*
+	* Use gdk_event_get_time() rather than event.time or
+	* gtk_get_current_event_time().  If the event does not
+	* have a time stamp, then the field will contain garbage.
+	* Note that calling gtk_get_current_event_time() from
+	* outside of gtk_main_do_event() seems to always
+	* return zero.
+	*/
+	int time = OS.gdk_event_get_time (event);
+	if (time != 0) lastEventTime = time;
+
+	int eventType = OS.GDK_EVENT_TYPE (event);
+	switch (eventType) {
+		case OS.GDK_BUTTON_PRESS:
+		case OS.GDK_KEY_PRESS:
+			lastUserEventTime = time;
+	}
+	boolean dispatch = true;
+	if (dispatchEvents != null) {
+		dispatch = false;
+		for (int i = 0; i < dispatchEvents.length; i++) {
+			if (eventType == dispatchEvents [i]) {
+				dispatch = true;
+				break;
+			}
+		}
+	}
+	if (!dispatch) {
+		addGdkEvent (OS.gdk_event_copy (event));
+		return 0;
+	}
+	OS.gtk_main_do_event (event);
+	if (dispatchEvents == null) putGdkEvents ();
+	return 0;
+}
+
+/**
+ * Given the operating system handle for a widget, returns
+ * the instance of the <code>Widget</code> subclass which
+ * represents it in the currently running application, if
+ * such exists, or null if no matching widget can be found.
+ * <p>
+ * <b>IMPORTANT:</b> This method should not be called from
+ * application code. The arguments are platform-specific.
+ * </p>
+ *
+ * @param handle the handle for the widget
+ * @return the SWT widget that the handle represents
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public Widget findWidget (int /*long*/ handle) {
+	checkDevice ();
+	return getWidget (handle);
+}
+
+/**
+ * Given the operating system handle for a widget,
+ * and widget-specific id, returns the instance of
+ * the <code>Widget</code> subclass which represents
+ * the handle/id pair in the currently running application,
+ * if such exists, or null if no matching widget can be found.
+ * <p>
+ * <b>IMPORTANT:</b> This method should not be called from
+ * application code. The arguments are platform-specific.
+ * </p>
+ *
+ * @param handle the handle for the widget
+ * @param id the id for the subwidget (usually an item)
+ * @return the SWT widget that the handle/id pair represents
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @since 3.1
+ */
+public Widget findWidget (int /*long*/ handle, int /*long*/ id) {
+	checkDevice ();
+	return null;
+}
+
+/**
+ * Given a widget and a widget-specific id, returns the
+ * instance of the <code>Widget</code> subclass which represents
+ * the widget/id pair in the currently running application,
+ * if such exists, or null if no matching widget can be found.
+ *
+ * @param widget the widget
+ * @param id the id for the subwidget (usually an item)
+ * @return the SWT subwidget (usually an item) that the widget/id pair represents
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @since 3.3
+ */
+public Widget findWidget (Widget widget, int /*long*/ id) {
+	checkDevice ();
+	return null;
+}
+
+static int /*long*/ fixedClassInitProc (int /*long*/ g_class, int /*long*/ class_data) {
+	GtkWidgetClass klass = new GtkWidgetClass ();
+	OS.memmove (klass, g_class);
+	klass.map = fixedMapProc;
+	oldFixedSizeAllocateProc = klass.size_allocate;
+	klass.size_allocate = fixedSizeAllocateProc;
+	OS.memmove (g_class, klass);
+	return 0;
+}
+
+static int /*long*/ fixedMapProc (int /*long*/ handle) {
+	Display display = getCurrent ();
+	Widget widget = display.getWidget (handle);
+	if (widget != null) return widget.fixedMapProc (handle);
+	return 0;
+}
+
+static int /*long*/ fixedSizeAllocateProc (int /*long*/ handle, int /*long*/ allocation) {
+	Display display = getCurrent ();
+	Widget widget = display.getWidget (handle);
+	if (widget != null) return widget.fixedSizeAllocateProc (handle, allocation);
+	return OS.Call (oldFixedSizeAllocateProc, handle, allocation);
+}
+
+static int /*long*/ rendererClassInitProc (int /*long*/ g_class, int /*long*/ class_data) {
+	GtkCellRendererClass klass = new GtkCellRendererClass ();
+	OS.memmove (klass, g_class);
+	klass.render = rendererRenderProc;
+	klass.get_size = rendererGetSizeProc;
+	OS.memmove (g_class, klass);
+	return 0;
+}
+
+static int /*long*/ rendererGetSizeProc (int /*long*/ cell, int /*long*/ handle, int /*long*/ cell_area, int /*long*/ x_offset, int /*long*/ y_offset, int /*long*/ width, int /*long*/ height) {
+	Display display = getCurrent ();
+	Widget widget = display.getWidget (handle);
+	if (widget != null) return widget.rendererGetSizeProc (cell, handle, cell_area, x_offset, y_offset, width, height);
+	return 0;
+}
+
+static int /*long*/ rendererRenderProc (int /*long*/ cell, int /*long*/ window, int /*long*/ handle, int /*long*/ background_area, int /*long*/ cell_area, int /*long*/ expose_area, int /*long*/ flags) {
+	Display display = getCurrent ();
+	Widget widget = display.getWidget (handle);
+	if (widget != null) return widget.rendererRenderProc (cell, window, handle, background_area, cell_area, expose_area, flags);
+	return 0;
+}
+
+void flushExposes (int /*long*/ window, boolean all) {
+	OS.gdk_flush ();
+	OS.gdk_flush ();
+	if (OS.GDK_WINDOWING_X11 ()) {
+		this.flushWindow = window;
+		this.flushAll = all;
+		int /*long*/ xDisplay = OS.GDK_DISPLAY ();
+		int /*long*/ xEvent = OS.g_malloc (XEvent.sizeof);
+		OS.XCheckIfEvent (xDisplay, xEvent, checkIfEventProc, 0);
+		OS.g_free (xEvent);
+		this.flushWindow = 0;
+	}
+}
+
+/**
+ * Returns the currently active <code>Shell</code>, or null
+ * if no shell belonging to the currently running application
+ * is active.
+ *
+ * @return the active shell or null
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public Shell getActiveShell () {
+	checkDevice ();
+	return activeShell;
+}
+
+/**
+ * Returns a rectangle describing the receiver's size and location. Note that
+ * on multi-monitor systems the origin can be negative.
+ *
+ * @return the bounding rectangle
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public Rectangle getBounds () {
+	checkDevice ();
+	return new Rectangle (0, 0, OS.gdk_screen_width (), OS.gdk_screen_height ());
+}
+
+/**
+ * Returns the display which the currently running thread is
+ * the user-interface thread for, or null if the currently
+ * running thread is not a user-interface thread for any display.
+ *
+ * @return the current display
+ */
+public static Display getCurrent () {
+	return findDisplay (Thread.currentThread ());
+}
+
+int getCaretBlinkTime () {
+//	checkDevice ();
+	int /*long*/ settings = OS.gtk_settings_get_default ();
+	if (settings == 0) return 500;
+	int [] buffer = new int [1];
+	OS.g_object_get (settings, OS.gtk_cursor_blink, buffer, 0);
+	if (buffer [0] == 0) return 0;
+	OS.g_object_get (settings, OS.gtk_cursor_blink_time, buffer, 0);
+	if (buffer [0] == 0) return 500;
+	/*
+	* By experimentation, GTK application don't use the whole
+	* blink cycle time.  Instead, they divide up the time, using
+	* an effective blink rate of about 1/2 the total time.
+	*/
+	return buffer [0] / 2;
+}
+
+/**
+ * Returns the control which the on-screen pointer is currently
+ * over top of, or null if it is not currently over one of the
+ * controls built by the currently running application.
+ *
+ * @return the control under the cursor
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public Control getCursorControl () {
+	checkDevice();
+	int[] x = new int[1], y = new int[1];
+	int /*long*/ handle = 0;
+	int /*long*/ [] user_data = new int /*long*/ [1];
+	int /*long*/ window = OS.gdk_window_at_pointer (x,y);
+	if (window != 0) {
+		OS.gdk_window_get_user_data (window, user_data);
+		handle = user_data [0];
+	} else {
+		/*
+		* Feature in GTK. gdk_window_at_pointer() will not return a window 
+		* if the pointer is over a foreign embedded window. The fix is to use
+		* XQueryPointer to find the containing GDK window.
+		*/
+		if (!OS.GDK_WINDOWING_X11 ()) return null;
+		OS.gdk_error_trap_push ();
+		int[] unusedInt = new int[1];
+		int /*long*/[] unusedPtr = new int /*long*/[1], buffer = new int /*long*/[1];
+		int /*long*/ xWindow, xParent = OS.XDefaultRootWindow (xDisplay);
+		do {
+			if (OS.XQueryPointer (xDisplay, xParent, unusedPtr, buffer, unusedInt, unusedInt, unusedInt, unusedInt, unusedInt) == 0) {
+				handle = 0;
+				break;
+			}
+			if ((xWindow = buffer [0]) != 0) {
+				xParent = xWindow;
+				int /*long*/ gdkWindow = OS.gdk_window_lookup (xWindow);
+				if (gdkWindow != 0)	{
+					OS.gdk_window_get_user_data (gdkWindow, user_data);
+					if (user_data[0] != 0) handle = user_data[0];	
+				}
+			}
+		} while (xWindow != 0);
+		OS.gdk_error_trap_pop ();
+	}
+	if (handle == 0) return null;
+	do {
+		Widget widget = getWidget (handle);
+		if (widget != null && widget instanceof Control) {
+			Control control = (Control) widget;
+			if (control.isEnabled ()) return control;
+		}
+	} while ((handle = OS.gtk_widget_get_parent (handle)) != 0);
+	return null;
+}
+
+boolean filterEvent (Event event) {
+	if (filterTable != null) filterTable.sendEvent (event);
+	return false;
+}
+
+boolean filters (int eventType) {
+	if (filterTable == null) return false;
+	return filterTable.hooks (eventType);
+}
+
+int /*long*/ filterProc (int /*long*/ xEvent, int /*long*/ gdkEvent, int /*long*/ data) {
+	if (data == 0) {
+		/*
+		* Feature in GTK.  When button 4, 5, 6, or 7 is released, GTK
+		* does not deliver a corresponding GTK event.  Button 6 and 7
+		* are mapped to buttons 4 and 5 in SWT.  The fix is to change
+		* the button number of the event to a negative number so that
+		* it gets dispatched by GTK.  SWT has been modified to look
+		* for negative button numbers.
+		*/
+		XButtonEvent mouseEvent = new XButtonEvent ();
+		OS.memmove (mouseEvent, xEvent, 4);
+		if (mouseEvent.type == OS.ButtonRelease) {
+			OS.memmove (mouseEvent, xEvent, XButtonEvent.sizeof);
+			switch (mouseEvent.button) {
+				case 6:
+				case 7:
+					mouseEvent.button = -mouseEvent.button;
+					OS.memmove (xEvent, mouseEvent, XButtonEvent.sizeof);
+					break;
+			}
+		}
+	}
+	Widget widget = getWidget (data);
+	if (widget == null) return 0;
+	return widget.filterProc (xEvent, gdkEvent, data);
+}
+
+/**
+ * Returns the location of the on-screen pointer relative
+ * to the top left corner of the screen.
+ *
+ * @return the cursor location
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public Point getCursorLocation () {
+	checkDevice ();
+	int [] x = new int [1], y = new int [1];
+	OS.gdk_window_get_pointer (0, x, y, null);
+	return new Point (x [0], y [0]);
+}
+
+/**
+ * Returns an array containing the recommended cursor sizes.
+ *
+ * @return the array of cursor sizes
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @since 3.0
+ */
+public Point [] getCursorSizes () {
+	checkDevice ();
+	return new Point [] {new Point (16, 16), new Point (32, 32)}; 
+}
+
+/**
+ * Returns the application defined property of the receiver
+ * with the specified name, or null if it has not been set.
+ * <p>
+ * Applications may have associated arbitrary objects with the
+ * receiver in this fashion. If the objects stored in the
+ * properties need to be notified when the display is disposed
+ * of, it is the application's responsibility to provide a
+ * <code>disposeExec()</code> handler which does so.
+ * </p>
+ *
+ * @param key the name of the property
+ * @return the value of the property or null if it has not been set
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the key is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see #setData(String, Object)
+ * @see #disposeExec(Runnable)
+ */
+public Object getData (String key) {
+	checkDevice ();
+	if (key == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if (key.equals (DISPATCH_EVENT_KEY)) {
+		return dispatchEvents;
+	}
+	if (key.equals (GET_MODAL_DIALOG)) {
+		return modalDialog;
+	}
+	if (key.equals (GET_DIRECTION_PROC_KEY)) {
+		return new LONG (setDirectionProc);
+	}
+	if (key.equals (GET_EMISSION_PROC_KEY)) {
+		return new LONG (emissionProc);
+	}
+	if (keys == null) return null;
+	for (int i=0; i<keys.length; i++) {
+		if (keys [i].equals (key)) return values [i];
+	}
+	return null;
+}
+
+/**
+ * Returns the application defined, display specific data
+ * associated with the receiver, or null if it has not been
+ * set. The <em>display specific data</em> is a single,
+ * unnamed field that is stored with every display. 
+ * <p>
+ * Applications may put arbitrary objects in this field. If
+ * the object stored in the display specific data needs to
+ * be notified when the display is disposed of, it is the
+ * application's responsibility to provide a
+ * <code>disposeExec()</code> handler which does so.
+ * </p>
+ *
+ * @return the display specific data
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see #setData(Object)
+ * @see #disposeExec(Runnable)
+ */
+public Object getData () {
+	checkDevice ();
+	return data;
+}
+
+/**
+ * Returns a point whose x coordinate is the horizontal
+ * dots per inch of the display, and whose y coordinate
+ * is the vertical dots per inch of the display.
+ *
+ * @return the horizontal and vertical DPI
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Point getDPI () {
+	checkDevice ();
+	int widthMM = OS.gdk_screen_width_mm ();
+	int width = OS.gdk_screen_width ();
+	int dpi = Compatibility.round (254 * width, widthMM * 10);
+	return new Point (dpi, dpi);
+}
+
+int /*long*/ gtk_fixed_get_type () {
+	return fixed_type;
+}
+
+int /*long*/ gtk_cell_renderer_text_get_type () {
+	return text_renderer_type;
+}
+
+int /*long*/ gtk_cell_renderer_pixbuf_get_type () {
+	return pixbuf_renderer_type;
+}
+
+int /*long*/ gtk_cell_renderer_toggle_get_type () {
+	return toggle_renderer_type;
+}
+
+/**
+ * Returns the default display. One is created (making the
+ * thread that invokes this method its user-interface thread)
+ * if it did not already exist.
+ *
+ * @return the default display
+ */
+public static Display getDefault () {
+	synchronized (Device.class) {
+		if (Default == null) Default = new Display ();
+		return Default;
+	}
+}
+
+static boolean isValidClass (Class clazz) {
+	String name = clazz.getName ();
+	int index = name.lastIndexOf ('.');
+	return name.substring (0, index + 1).equals (PACKAGE_PREFIX);
+}
+
+/**
+ * Returns the button dismissal alignment, one of <code>LEFT</code> or <code>RIGHT</code>.
+ * The button dismissal alignment is the ordering that should be used when positioning the
+ * default dismissal button for a dialog.  For example, in a dialog that contains an OK and
+ * CANCEL button, on platforms where the button dismissal alignment is <code>LEFT</code>, the
+ * button ordering should be OK/CANCEL.  When button dismissal alignment is <code>RIGHT</code>,
+ * the button ordering should be CANCEL/OK.
+ *
+ * @return the button dismissal order
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @since 2.1
+ */
+public int getDismissalAlignment () {
+	checkDevice ();
+	return SWT.RIGHT;
+}
+
+/**
+ * Returns the longest duration, in milliseconds, between
+ * two mouse button clicks that will be considered a
+ * <em>double click</em> by the underlying operating system.
+ *
+ * @return the double click time
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public int getDoubleClickTime () {
+	checkDevice ();
+	int /*long*/ settings = OS.gtk_settings_get_default ();
+	int [] buffer = new int [1];
+	OS.g_object_get (settings, OS.gtk_double_click_time, buffer, 0);
+	return buffer [0];
+}
+
+/**
+ * Returns the control which currently has keyboard focus,
+ * or null if keyboard events are not currently going to
+ * any of the controls built by the currently running
+ * application.
+ *
+ * @return the control under the cursor
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public Control getFocusControl () {
+	checkDevice ();
+	if (focusControl != null && !focusControl.isDisposed ()) {
+		return focusControl;
+	}
+	if (activeShell == null) return null;
+	int /*long*/ shellHandle = activeShell.shellHandle;
+	int /*long*/ handle = OS.gtk_window_get_focus (shellHandle);
+	if (handle == 0) return null;
+	do {
+		Widget widget = getWidget (handle);
+		if (widget != null && widget instanceof Control) {
+			Control control = (Control) widget;
+			return control.isEnabled () ? control : null;
+		}
+	} while ((handle = OS.gtk_widget_get_parent (handle)) != 0);
+	return null;
+}
+
+/**
+ * Returns true when the high contrast mode is enabled.
+ * Otherwise, false is returned.
+ * <p>
+ * Note: This operation is a hint and is not supported on
+ * platforms that do not have this concept.
+ * </p>
+ *
+ * @return the high contrast mode
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @since 3.0
+ */
+public boolean getHighContrast () {
+	checkDevice ();
+	return false;
+}
+
+public int getDepth () {
+	checkDevice ();
+	GdkVisual visual = new GdkVisual ();
+	OS.memmove (visual, OS.gdk_visual_get_system());
+	return visual.depth;
+}
+
+/**
+ * Returns the maximum allowed depth of icons on this display, in bits per pixel.
+ * On some platforms, this may be different than the actual depth of the display.
+ *
+ * @return the maximum icon depth
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @see Device#getDepth
+ */
+public int getIconDepth () {
+	checkDevice ();
+	return getDepth ();
+}
+
+/**
+ * Returns an array containing the recommended icon sizes.
+ *
+ * @return the array of icon sizes
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @see Decorations#setImages(Image[])
+ * 
+ * @since 3.0
+ */
+public Point [] getIconSizes () {
+	checkDevice ();
+	return new Point [] {new Point (16, 16), new Point (32, 32)}; 
+}
+
+int getLastEventTime () {
+	return lastEventTime;
+}
+
+int getMessageCount () {
+	return synchronizer.getMessageCount ();
+}
+
+Dialog getModalDialog () {
+	return modalDialog;
+}
+
+/**
+ * Returns the work area, an EWMH property to store the size
+ * and position of the screen not covered by dock and panel
+ * windows.  See http://freedesktop.org/Standards/wm-spec.
+ */
+Rectangle getWorkArea() {
+	byte[] name = Converter.wcsToMbcs (null, "_NET_WORKAREA", true); //$NON-NLS-1$
+	int /*long*/ atom = OS.gdk_atom_intern (name, true);
+	if (atom == OS.GDK_NONE) return null;
+	int /*long*/[] actualType = new int /*long*/[1];
+	int[] actualFormat = new int[1];
+	int[] actualLength = new int[1];
+	int /*long*/[] data = new int /*long*/[1];
+	if (!OS.gdk_property_get (OS.GDK_ROOT_PARENT (), atom, OS.GDK_NONE, 0, 16, 0, actualType, actualFormat, actualLength, data)) {
+		return null;
+	}
+	Rectangle result = null;
+	if (data [0] != 0) {
+		if (actualLength [0] == 16) {
+			int values [] = new int [4];
+			OS.memmove (values, data[0], 16);
+			result = new Rectangle (values [0],values [1],values [2],values [3]);
+		} else if (actualLength [0] == 32) {
+			long values [] = new long [4];
+			OS.memmove (values, data[0], 32);
+			result = new Rectangle ((int)values [0],(int)values [1],(int)values [2],(int)values [3]);			
+		}
+		OS.g_free (data [0]);
+	}
+	return result;
+}
+
+/**
+ * Returns an array of monitors attached to the device.
+ * 
+ * @return the array of monitors
+ * 
+ * @since 3.0
+ */
+public Monitor [] getMonitors () {
+	checkDevice ();
+	Monitor [] monitors = null;
+	Rectangle workArea = getWorkArea();
+	int /*long*/ screen = OS.gdk_screen_get_default ();
+	if (screen != 0) {
+		int monitorCount = OS.gdk_screen_get_n_monitors (screen);
+		if (monitorCount > 0) {
+			monitors = new Monitor [monitorCount];
+			GdkRectangle dest = new GdkRectangle ();
+			for (int i = 0; i < monitorCount; i++) {
+				OS.gdk_screen_get_monitor_geometry (screen, i, dest);
+				Monitor monitor = new Monitor ();
+				monitor.handle = i;
+				monitor.x = dest.x;
+				monitor.y = dest.y;
+				monitor.width = dest.width;
+				monitor.height = dest.height;
+				if (i == 0 && workArea != null) {
+					monitor.clientX = workArea.x;
+					monitor.clientY = workArea.y;
+					monitor.clientWidth = workArea.width;
+					monitor.clientHeight = workArea.height;
+				} else {
+					monitor.clientX = monitor.x;
+					monitor.clientY = monitor.y;
+					monitor.clientWidth = monitor.width;
+					monitor.clientHeight = monitor.height;
+				}
+				monitors [i] = monitor;
+			}
+		}
+	}
+	if (monitors == null) {
+		/* No multimonitor support detected, default to one monitor */
+		Monitor monitor = new Monitor ();
+		Rectangle bounds = getBounds ();
+		monitor.x = bounds.x;
+		monitor.y = bounds.y;
+		monitor.width = bounds.width;
+		monitor.height = bounds.height;
+		if (workArea != null) {
+			monitor.clientX = workArea.x;
+			monitor.clientY = workArea.y;
+			monitor.clientWidth = workArea.width;
+			monitor.clientHeight = workArea.height;
+		} else {
+			monitor.clientX = monitor.x;
+			monitor.clientY = monitor.y;
+			monitor.clientWidth = monitor.width;
+			monitor.clientHeight = monitor.height;
+		}
+		monitors = new Monitor [] { monitor };			
+	}
+	return monitors;
+}
+
+/**
+ * Returns the primary monitor for that device.
+ * 
+ * @return the primary monitor
+ * 
+ * @since 3.0
+ */
+public Monitor getPrimaryMonitor () {
+	checkDevice ();
+	Monitor [] monitors = getMonitors ();
+	return monitors [0];
+}
+
+/**
+ * Returns a (possibly empty) array containing all shells which have
+ * not been disposed and have the receiver as their display.
+ *
+ * @return the receiver's shells
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public Shell [] getShells () {
+	checkDevice ();
+	int index = 0;
+	Shell [] result = new Shell [16];
+	for (int i = 0; i < widgetTable.length; i++) {
+		Widget widget = widgetTable [i];
+		if (widget != null && widget instanceof Shell) {
+			int j = 0;
+			while (j < index) {
+				if (result [j] == widget) break;
+				j++;
+			}
+			if (j == index) {
+				if (index == result.length) {
+					Shell [] newResult = new Shell [index + 16];
+					System.arraycopy (result, 0, newResult, 0, index);
+					result = newResult;
+				}
+				result [index++] = (Shell) widget;	
+			}
+		}
+	}
+	if (index == result.length) return result;
+	Shell [] newResult = new Shell [index];
+	System.arraycopy (result, 0, newResult, 0, index);
+	return newResult;
+}
+
+/**
+ * Gets the synchronizer used by the display.
+ *
+ * @return the receiver's synchronizer
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @since 3.4
+ */
+public Synchronizer getSynchronizer () {
+	checkDevice ();
+	return synchronizer;
+}
+
+/**
+ * Returns the thread that has invoked <code>syncExec</code>
+ * or null if no such runnable is currently being invoked by
+ * the user-interface thread.
+ * <p>
+ * Note: If a runnable invoked by asyncExec is currently
+ * running, this method will return null.
+ * </p>
+ *
+ * @return the receiver's sync-interface thread
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public Thread getSyncThread () {
+	synchronized (Device.class) {
+		if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED);
+		return synchronizer.syncThread;
+	}
+}
+
+/**
+ * Returns the matching standard color for the given
+ * constant, which should be one of the color constants
+ * specified in class <code>SWT</code>. Any value other
+ * than one of the SWT color constants which is passed
+ * in will result in the color black. This color should
+ * not be free'd because it was allocated by the system,
+ * not the application.
+ *
+ * @param id the color constant
+ * @return the matching color
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see SWT
+ */
+public Color getSystemColor (int id) {
+	checkDevice ();
+	GdkColor gdkColor = null;
+	switch (id) {
+		case SWT.COLOR_INFO_FOREGROUND: 					gdkColor = COLOR_INFO_FOREGROUND; break;
+		case SWT.COLOR_INFO_BACKGROUND: 					gdkColor = COLOR_INFO_BACKGROUND; break;
+		case SWT.COLOR_TITLE_FOREGROUND:					gdkColor = COLOR_TITLE_FOREGROUND; break;
+		case SWT.COLOR_TITLE_BACKGROUND:					gdkColor = COLOR_TITLE_BACKGROUND; break;
+		case SWT.COLOR_TITLE_BACKGROUND_GRADIENT:			gdkColor = COLOR_TITLE_BACKGROUND_GRADIENT; break;
+		case SWT.COLOR_TITLE_INACTIVE_FOREGROUND:			gdkColor = COLOR_TITLE_INACTIVE_FOREGROUND; break;
+		case SWT.COLOR_TITLE_INACTIVE_BACKGROUND:			gdkColor = COLOR_TITLE_INACTIVE_BACKGROUND; break;
+		case SWT.COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT:	gdkColor = COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT; break;
+		case SWT.COLOR_WIDGET_DARK_SHADOW:					gdkColor = COLOR_WIDGET_DARK_SHADOW; break;
+		case SWT.COLOR_WIDGET_NORMAL_SHADOW:				gdkColor = COLOR_WIDGET_NORMAL_SHADOW; break;
+		case SWT.COLOR_WIDGET_LIGHT_SHADOW: 				gdkColor = COLOR_WIDGET_LIGHT_SHADOW; break;
+		case SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW:				gdkColor = COLOR_WIDGET_HIGHLIGHT_SHADOW; break;
+		case SWT.COLOR_WIDGET_BACKGROUND: 					gdkColor = COLOR_WIDGET_BACKGROUND; break;
+		case SWT.COLOR_WIDGET_FOREGROUND: 					gdkColor = COLOR_WIDGET_FOREGROUND; break;
+		case SWT.COLOR_WIDGET_BORDER: 						gdkColor = COLOR_WIDGET_BORDER; break;
+		case SWT.COLOR_LIST_FOREGROUND: 					gdkColor = COLOR_LIST_FOREGROUND; break;
+		case SWT.COLOR_LIST_BACKGROUND: 					gdkColor = COLOR_LIST_BACKGROUND; break;
+		case SWT.COLOR_LIST_SELECTION: 						gdkColor = COLOR_LIST_SELECTION; break;
+		case SWT.COLOR_LIST_SELECTION_TEXT: 				gdkColor = COLOR_LIST_SELECTION_TEXT; break;
+		default:
+			return super.getSystemColor (id);	
+	}
+	if (gdkColor == null) return super.getSystemColor (SWT.COLOR_BLACK);
+	return Color.gtk_new (this, gdkColor);
+}
+
+/**
+ * Returns the matching standard platform cursor for the given
+ * constant, which should be one of the cursor constants
+ * specified in class <code>SWT</code>. This cursor should
+ * not be free'd because it was allocated by the system,
+ * not the application.  A value of <code>null</code> will
+ * be returned if the supplied constant is not an SWT cursor
+ * constant. 
+ *
+ * @param id the SWT cursor constant
+ * @return the corresponding cursor or <code>null</code>
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see SWT#CURSOR_ARROW
+ * @see SWT#CURSOR_WAIT
+ * @see SWT#CURSOR_CROSS
+ * @see SWT#CURSOR_APPSTARTING
+ * @see SWT#CURSOR_HELP
+ * @see SWT#CURSOR_SIZEALL
+ * @see SWT#CURSOR_SIZENESW
+ * @see SWT#CURSOR_SIZENS
+ * @see SWT#CURSOR_SIZENWSE
+ * @see SWT#CURSOR_SIZEWE
+ * @see SWT#CURSOR_SIZEN
+ * @see SWT#CURSOR_SIZES
+ * @see SWT#CURSOR_SIZEE
+ * @see SWT#CURSOR_SIZEW
+ * @see SWT#CURSOR_SIZENE
+ * @see SWT#CURSOR_SIZESE
+ * @see SWT#CURSOR_SIZESW
+ * @see SWT#CURSOR_SIZENW
+ * @see SWT#CURSOR_UPARROW
+ * @see SWT#CURSOR_IBEAM
+ * @see SWT#CURSOR_NO
+ * @see SWT#CURSOR_HAND
+ * 
+ * @since 3.0
+ */
+public Cursor getSystemCursor (int id) {
+	checkDevice ();
+	if (!(0 <= id && id < cursors.length)) return null;
+	if (cursors [id] == null) {
+		cursors [id] = new Cursor (this, id);
+	}
+	return cursors [id];
+}
+
+/**
+ * Returns the matching standard platform image for the given
+ * constant, which should be one of the icon constants
+ * specified in class <code>SWT</code>. This image should
+ * not be free'd because it was allocated by the system,
+ * not the application.  A value of <code>null</code> will
+ * be returned either if the supplied constant is not an
+ * SWT icon constant or if the platform does not define an
+ * image that corresponds to the constant. 
+ *
+ * @param id the SWT icon constant
+ * @return the corresponding image or <code>null</code>
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see SWT#ICON_ERROR
+ * @see SWT#ICON_INFORMATION
+ * @see SWT#ICON_QUESTION
+ * @see SWT#ICON_WARNING
+ * @see SWT#ICON_WORKING
+ * 
+ * @since 3.0
+ */
+public Image getSystemImage (int id) {
+	checkDevice ();
+	switch (id) {
+		case SWT.ICON_ERROR:
+			if (errorImage == null) {
+				errorImage = createImage ("gtk-dialog-error"); //$NON-NLS-1$
+			}
+			return errorImage;
+		case SWT.ICON_INFORMATION:
+		case SWT.ICON_WORKING:
+			if (infoImage == null) {
+				infoImage = createImage ("gtk-dialog-info"); //$NON-NLS-1$
+			}
+			return infoImage;
+		case SWT.ICON_QUESTION:
+			if (questionImage == null) {
+				questionImage = createImage ("gtk-dialog-question"); //$NON-NLS-1$
+			}
+			return questionImage;
+		case SWT.ICON_WARNING:
+			if (warningImage == null) {
+				warningImage = createImage ("gtk-dialog-warning"); //$NON-NLS-1$
+			}
+			return warningImage;
+	}
+	return null;
+}
+
+void initializeSystemColors () {
+	GdkColor gdkColor;
+	
+	/* Get Tooltip resources */
+	int /*long*/ tooltipShellHandle = OS.gtk_window_new (OS.GTK_WINDOW_POPUP);
+	if (tooltipShellHandle == 0) SWT.error (SWT.ERROR_NO_HANDLES);
+	byte[] gtk_tooltips = Converter.wcsToMbcs (null, "gtk-tooltips", true); //$NON-NLS-1$
+	OS.gtk_widget_set_name (tooltipShellHandle, gtk_tooltips);
+	OS.gtk_widget_realize (tooltipShellHandle);
+	int /*long*/ tooltipStyle = OS.gtk_widget_get_style (tooltipShellHandle);
+	gdkColor = new GdkColor();
+	OS.gtk_style_get_fg (tooltipStyle, OS.GTK_STATE_NORMAL, gdkColor);
+	COLOR_INFO_FOREGROUND = gdkColor;
+	gdkColor = new GdkColor();
+	OS.gtk_style_get_bg (tooltipStyle, OS.GTK_STATE_NORMAL, gdkColor);
+	COLOR_INFO_BACKGROUND = gdkColor;
+	OS.gtk_widget_destroy (tooltipShellHandle);	
+
+	/* Get Shell resources */
+	int /*long*/ style = OS.gtk_widget_get_style (shellHandle);	
+	gdkColor = new GdkColor();
+	OS.gtk_style_get_black (style, gdkColor);
+	COLOR_WIDGET_DARK_SHADOW = gdkColor;
+	gdkColor = new GdkColor();
+	OS.gtk_style_get_dark (style, OS.GTK_STATE_NORMAL, gdkColor);
+	COLOR_WIDGET_NORMAL_SHADOW = gdkColor;
+	gdkColor = new GdkColor();
+	OS.gtk_style_get_bg (style, OS.GTK_STATE_NORMAL, gdkColor);
+	COLOR_WIDGET_LIGHT_SHADOW = gdkColor;
+	gdkColor = new GdkColor();
+	OS.gtk_style_get_light (style, OS.GTK_STATE_NORMAL, gdkColor);
+	COLOR_WIDGET_HIGHLIGHT_SHADOW = gdkColor;
+	gdkColor = new GdkColor();
+	OS.gtk_style_get_fg (style, OS.GTK_STATE_NORMAL, gdkColor);
+	COLOR_WIDGET_FOREGROUND = gdkColor;
+	gdkColor = new GdkColor();
+	OS.gtk_style_get_bg (style, OS.GTK_STATE_NORMAL, gdkColor);
+	COLOR_WIDGET_BACKGROUND = gdkColor;
+	//gdkColor = new GdkColor();
+	//OS.gtk_style_get_text (style, OS.GTK_STATE_NORMAL, gdkColor);
+	//COLOR_TEXT_FOREGROUND = gdkColor;
+	//gdkColor = new GdkColor();
+	//OS.gtk_style_get_base (style, OS.GTK_STATE_NORMAL, gdkColor);
+	//COLOR_TEXT_BACKGROUND = gdkColor;
+	gdkColor = new GdkColor();
+	OS.gtk_style_get_text (style, OS.GTK_STATE_NORMAL, gdkColor);
+	COLOR_LIST_FOREGROUND = gdkColor;
+	gdkColor = new GdkColor();
+	OS.gtk_style_get_base (style, OS.GTK_STATE_NORMAL, gdkColor);
+	COLOR_LIST_BACKGROUND = gdkColor;
+	gdkColor = new GdkColor();
+	OS.gtk_style_get_text (style, OS.GTK_STATE_SELECTED, gdkColor);
+	COLOR_LIST_SELECTION_TEXT = gdkColor;
+	gdkColor = new GdkColor();
+	OS.gtk_style_get_base (style, OS.GTK_STATE_SELECTED, gdkColor);
+	COLOR_LIST_SELECTION = gdkColor;
+	gdkColor = new GdkColor();
+	OS.gtk_style_get_bg (style, OS.GTK_STATE_SELECTED, gdkColor);
+	COLOR_TITLE_BACKGROUND = gdkColor;
+	gdkColor = new GdkColor();
+	OS.gtk_style_get_fg (style, OS.GTK_STATE_SELECTED, gdkColor);
+	COLOR_TITLE_FOREGROUND = gdkColor;
+	gdkColor = new GdkColor();
+	OS.gtk_style_get_light (style, OS.GTK_STATE_SELECTED, gdkColor);
+	COLOR_TITLE_BACKGROUND_GRADIENT = gdkColor;
+	gdkColor = new GdkColor();
+	OS.gtk_style_get_bg (style, OS.GTK_STATE_INSENSITIVE, gdkColor);
+	COLOR_TITLE_INACTIVE_BACKGROUND = gdkColor;
+	gdkColor = new GdkColor();
+	OS.gtk_style_get_fg (style, OS.GTK_STATE_INSENSITIVE, gdkColor);
+	COLOR_TITLE_INACTIVE_FOREGROUND = gdkColor;
+	gdkColor = new GdkColor();
+	OS.gtk_style_get_light (style, OS.GTK_STATE_INSENSITIVE, gdkColor);
+	COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT = gdkColor;
+}
+
+/**
+ * Returns a reasonable font for applications to use.
+ * On some platforms, this will match the "default font"
+ * or "system font" if such can be found.  This font
+ * should not be free'd because it was allocated by the
+ * system, not the application.
+ * <p>
+ * Typically, applications which want the default look
+ * should simply not set the font on the widgets they
+ * create. Widgets are always created with the correct
+ * default font for the class of user-interface component
+ * they represent.
+ * </p>
+ *
+ * @return a font
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public Font getSystemFont () {
+	checkDevice ();
+	if (systemFont != null) return systemFont;
+	int /*long*/ style = OS.gtk_widget_get_style (shellHandle);	
+	int /*long*/ defaultFont = OS.pango_font_description_copy (OS.gtk_style_get_font_desc (style));
+	return systemFont = Font.gtk_new (this, defaultFont);
+}
+
+/**
+ * Returns the single instance of the system tray or null
+ * when there is no system tray available for the platform.
+ *
+ * @return the system tray or <code>null</code>
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @since 3.0
+ */
+public Tray getSystemTray () {
+	checkDevice ();
+	if (tray != null) return tray;
+	return tray = new Tray (this, SWT.NONE);
+}
+
+/**
+ * Returns the user-interface thread for the receiver.
+ *
+ * @return the receiver's user-interface thread
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public Thread getThread () {
+	synchronized (Device.class) {
+		if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED);
+		return thread;
+	}
+}
+
+Widget getWidget (int /*long*/ handle) {
+	if (handle == 0) return null;
+	if (lastWidget != null && lastHandle == handle) return lastWidget;
+	int /*long*/ index = OS.g_object_get_qdata (handle, SWT_OBJECT_INDEX) - 1;
+	if (0 <= index && index < widgetTable.length) {
+		lastHandle = handle;
+		return lastWidget = widgetTable [(int)/*64*/index];
+	}
+	return null;	
+}
+
+int /*long*/ idleProc (int /*long*/ data) {
+	boolean result = runAsyncMessages (false);
+	if (!result) {
+		synchronized (idleLock) {
+			idleHandle = 0;
+		}
+	}
+	return result ? 1 : 0;
+}
+
+/**
+ * Initializes any internal resources needed by the
+ * device.
+ * <p>
+ * This method is called after <code>create</code>.
+ * </p>
+ * 
+ * @see #create
+ */
+protected void init () {
+	super.init ();
+	initializeCallbacks ();
+	initializeSystemColors ();
+	initializeSystemSettings ();
+	initializeWidgetTable ();
+	initializeWindowManager ();
+}
+
+void initializeCallbacks () {
+	closures = new int /*long*/ [Widget.LAST_SIGNAL];
+	signalIds = new int [Widget.LAST_SIGNAL];
+
+	/* Cache signals for GtkWidget */
+	signalIds [Widget.BUTTON_PRESS_EVENT] = OS.g_signal_lookup (OS.button_press_event, OS.GTK_TYPE_WIDGET ());
+	signalIds [Widget.BUTTON_RELEASE_EVENT] = OS.g_signal_lookup (OS.button_release_event, OS.GTK_TYPE_WIDGET ());
+	signalIds [Widget.CONFIGURE_EVENT] = OS.g_signal_lookup (OS.configure_event, OS.GTK_TYPE_WIDGET ());
+	signalIds [Widget.DELETE_EVENT] = OS.g_signal_lookup (OS.delete_event, OS.GTK_TYPE_WIDGET ());
+	signalIds [Widget.ENTER_NOTIFY_EVENT] = OS.g_signal_lookup (OS.enter_notify_event, OS.GTK_TYPE_WIDGET ());
+	signalIds [Widget.EVENT] = OS.g_signal_lookup (OS.event, OS.GTK_TYPE_WIDGET ());
+	signalIds [Widget.EVENT_AFTER] = OS.g_signal_lookup (OS.event_after, OS.GTK_TYPE_WIDGET ());
+	signalIds [Widget.EXPOSE_EVENT] = OS.g_signal_lookup (OS.expose_event, OS.GTK_TYPE_WIDGET ());
+	signalIds [Widget.FOCUS] = OS.g_signal_lookup (OS.focus, OS.GTK_TYPE_WIDGET ());
+	signalIds [Widget.FOCUS_IN_EVENT] = OS.g_signal_lookup (OS.focus_in_event, OS.GTK_TYPE_WIDGET ());
+	signalIds [Widget.FOCUS_OUT_EVENT] = OS.g_signal_lookup (OS.focus_out_event, OS.GTK_TYPE_WIDGET ());
+	signalIds [Widget.GRAB_FOCUS] = OS.g_signal_lookup (OS.grab_focus, OS.GTK_TYPE_WIDGET ());
+	signalIds [Widget.HIDE] = OS.g_signal_lookup (OS.hide, OS.GTK_TYPE_WIDGET ());
+	signalIds [Widget.KEY_PRESS_EVENT] = OS.g_signal_lookup (OS.key_press_event, OS.GTK_TYPE_WIDGET ());
+	signalIds [Widget.KEY_RELEASE_EVENT] = OS.g_signal_lookup (OS.key_release_event, OS.GTK_TYPE_WIDGET ());
+	signalIds [Widget.LEAVE_NOTIFY_EVENT] = OS.g_signal_lookup (OS.leave_notify_event, OS.GTK_TYPE_WIDGET ());
+	signalIds [Widget.MAP] = OS.g_signal_lookup (OS.map, OS.GTK_TYPE_WIDGET ());
+	signalIds [Widget.MAP_EVENT] = OS.g_signal_lookup (OS.map_event, OS.GTK_TYPE_WIDGET ());
+	signalIds [Widget.MNEMONIC_ACTIVATE] = OS.g_signal_lookup (OS.mnemonic_activate, OS.GTK_TYPE_WIDGET ());
+	signalIds [Widget.MOTION_NOTIFY_EVENT] = OS.g_signal_lookup (OS.motion_notify_event, OS.GTK_TYPE_WIDGET ());
+	signalIds [Widget.POPUP_MENU] = OS.g_signal_lookup (OS.popup_menu, OS.GTK_TYPE_WIDGET ());
+	signalIds [Widget.REALIZE] = OS.g_signal_lookup (OS.realize, OS.GTK_TYPE_WIDGET ());
+	signalIds [Widget.SCROLL_EVENT] = OS.g_signal_lookup (OS.scroll_event, OS.GTK_TYPE_WIDGET ());
+	signalIds [Widget.SHOW] = OS.g_signal_lookup (OS.show, OS.GTK_TYPE_WIDGET ());
+	signalIds [Widget.SHOW_HELP] = OS.g_signal_lookup (OS.show_help, OS.GTK_TYPE_WIDGET ());
+	signalIds [Widget.SIZE_ALLOCATE] = OS.g_signal_lookup (OS.size_allocate, OS.GTK_TYPE_WIDGET ());
+	signalIds [Widget.STYLE_SET] = OS.g_signal_lookup (OS.style_set, OS.GTK_TYPE_WIDGET ());
+	signalIds [Widget.UNMAP] = OS.g_signal_lookup (OS.unmap, OS.GTK_TYPE_WIDGET ());
+	signalIds [Widget.UNMAP_EVENT] = OS.g_signal_lookup (OS.unmap_event, OS.GTK_TYPE_WIDGET ());
+	signalIds [Widget.UNREALIZE] = OS.g_signal_lookup (OS.realize, OS.GTK_TYPE_WIDGET ());
+	signalIds [Widget.VISIBILITY_NOTIFY_EVENT] = OS.g_signal_lookup (OS.visibility_notify_event, OS.GTK_TYPE_WIDGET ());
+	signalIds [Widget.WINDOW_STATE_EVENT] = OS.g_signal_lookup (OS.window_state_event, OS.GTK_TYPE_WIDGET ());
+
+	windowCallback2 = new Callback (this, "windowProc", 2); //$NON-NLS-1$
+	windowProc2 = windowCallback2.getAddress ();
+	if (windowProc2 == 0) SWT.error (SWT.ERROR_NO_MORE_CALLBACKS);
+
+	closures [Widget.ACTIVATE] = OS.g_cclosure_new (windowProc2, Widget.ACTIVATE, 0);
+	closures [Widget.ACTIVATE_INVERSE] = OS.g_cclosure_new (windowProc2, Widget.ACTIVATE_INVERSE, 0);
+	closures [Widget.CHANGED] = OS.g_cclosure_new (windowProc2, Widget.CHANGED, 0);
+	closures [Widget.CLICKED] = OS.g_cclosure_new (windowProc2, Widget.CLICKED, 0);
+	closures [Widget.DAY_SELECTED] = OS.g_cclosure_new (windowProc2, Widget.DAY_SELECTED, 0);
+	closures [Widget.HIDE] = OS.g_cclosure_new (windowProc2, Widget.HIDE, 0);
+	closures [Widget.GRAB_FOCUS] = OS.g_cclosure_new (windowProc2, Widget.GRAB_FOCUS, 0);
+	closures [Widget.MAP] = OS.g_cclosure_new (windowProc2, Widget.MAP, 0);
+	closures [Widget.MONTH_CHANGED] = OS.g_cclosure_new (windowProc2, Widget.MONTH_CHANGED, 0);
+	closures [Widget.OUTPUT] = OS.g_cclosure_new (windowProc2, Widget.OUTPUT, 0);
+	closures [Widget.POPUP_MENU] = OS.g_cclosure_new (windowProc2, Widget.POPUP_MENU, 0);
+	closures [Widget.PREEDIT_CHANGED] = OS.g_cclosure_new (windowProc2, Widget.PREEDIT_CHANGED, 0);
+	closures [Widget.REALIZE] = OS.g_cclosure_new (windowProc2, Widget.REALIZE, 0);
+	closures [Widget.SELECT] = OS.g_cclosure_new (windowProc2, Widget.SELECT, 0);
+	closures [Widget.SHOW] = OS.g_cclosure_new (windowProc2, Widget.SHOW, 0);
+	closures [Widget.VALUE_CHANGED] = OS.g_cclosure_new (windowProc2, Widget.VALUE_CHANGED, 0);
+	closures [Widget.UNMAP] = OS.g_cclosure_new (windowProc2, Widget.UNMAP, 0);
+	closures [Widget.UNREALIZE] = OS.g_cclosure_new (windowProc2, Widget.UNREALIZE, 0);
+
+	windowCallback3 = new Callback (this, "windowProc", 3); //$NON-NLS-1$
+	windowProc3 = windowCallback3.getAddress ();
+	if (windowProc3 == 0) SWT.error (SWT.ERROR_NO_MORE_CALLBACKS);	
+
+	closures [Widget.BUTTON_PRESS_EVENT] = OS.g_cclosure_new (windowProc3, Widget.BUTTON_PRESS_EVENT, 0);
+	closures [Widget.BUTTON_PRESS_EVENT_INVERSE] = OS.g_cclosure_new (windowProc3, Widget.BUTTON_PRESS_EVENT_INVERSE, 0);
+	closures [Widget.BUTTON_RELEASE_EVENT] = OS.g_cclosure_new (windowProc3, Widget.BUTTON_RELEASE_EVENT, 0);
+	closures [Widget.BUTTON_RELEASE_EVENT_INVERSE] = OS.g_cclosure_new (windowProc3, Widget.BUTTON_RELEASE_EVENT_INVERSE, 0);
+	closures [Widget.COMMIT] = OS.g_cclosure_new (windowProc3, Widget.COMMIT, 0);
+	closures [Widget.CONFIGURE_EVENT] = OS.g_cclosure_new (windowProc3, Widget.CONFIGURE_EVENT, 0);
+	closures [Widget.DELETE_EVENT] = OS.g_cclosure_new (windowProc3, Widget.DELETE_EVENT, 0);
+	closures [Widget.ENTER_NOTIFY_EVENT] = OS.g_cclosure_new (windowProc3, Widget.ENTER_NOTIFY_EVENT, 0);
+	closures [Widget.EVENT] = OS.g_cclosure_new (windowProc3, Widget.EVENT, 0);
+	closures [Widget.EVENT_AFTER] = OS.g_cclosure_new (windowProc3, Widget.EVENT_AFTER, 0);
+	closures [Widget.EXPOSE_EVENT] = OS.g_cclosure_new (windowProc3, Widget.EXPOSE_EVENT, 0);
+	closures [Widget.EXPOSE_EVENT_INVERSE] = OS.g_cclosure_new (windowProc3, Widget.EXPOSE_EVENT_INVERSE, 0);
+	closures [Widget.FOCUS] = OS.g_cclosure_new (windowProc3, Widget.FOCUS, 0);
+	closures [Widget.FOCUS_IN_EVENT] = OS.g_cclosure_new (windowProc3, Widget.FOCUS_IN_EVENT, 0);
+	closures [Widget.FOCUS_OUT_EVENT] = OS.g_cclosure_new (windowProc3, Widget.FOCUS_OUT_EVENT, 0);
+	closures [Widget.KEY_PRESS_EVENT] = OS.g_cclosure_new (windowProc3, Widget.KEY_PRESS_EVENT, 0);
+	closures [Widget.KEY_RELEASE_EVENT] = OS.g_cclosure_new (windowProc3, Widget.KEY_RELEASE_EVENT, 0);
+	closures [Widget.INPUT] = OS.g_cclosure_new (windowProc3, Widget.INPUT, 0);
+	closures [Widget.LEAVE_NOTIFY_EVENT] = OS.g_cclosure_new (windowProc3, Widget.LEAVE_NOTIFY_EVENT, 0);
+	closures [Widget.MAP_EVENT] = OS.g_cclosure_new (windowProc3, Widget.MAP_EVENT, 0);
+	closures [Widget.MNEMONIC_ACTIVATE] = OS.g_cclosure_new (windowProc3, Widget.MNEMONIC_ACTIVATE, 0);
+	closures [Widget.MOTION_NOTIFY_EVENT] = OS.g_cclosure_new (windowProc3, Widget.MOTION_NOTIFY_EVENT, 0);
+	closures [Widget.MOTION_NOTIFY_EVENT_INVERSE] = OS.g_cclosure_new (windowProc3, Widget.MOTION_NOTIFY_EVENT_INVERSE, 0);
+	closures [Widget.MOVE_FOCUS] = OS.g_cclosure_new (windowProc3, Widget.MOVE_FOCUS, 0);
+	closures [Widget.POPULATE_POPUP] = OS.g_cclosure_new (windowProc3, Widget.POPULATE_POPUP, 0);
+	closures [Widget.SCROLL_EVENT] = OS.g_cclosure_new (windowProc3, Widget.SCROLL_EVENT, 0);
+	closures [Widget.SHOW_HELP] = OS.g_cclosure_new (windowProc3, Widget.SHOW_HELP, 0);
+	closures [Widget.SIZE_ALLOCATE] = OS.g_cclosure_new (windowProc3, Widget.SIZE_ALLOCATE, 0);
+	closures [Widget.STYLE_SET] = OS.g_cclosure_new (windowProc3, Widget.STYLE_SET, 0);
+	closures [Widget.TOGGLED] = OS.g_cclosure_new (windowProc3, Widget.TOGGLED, 0);	
+	closures [Widget.UNMAP_EVENT] = OS.g_cclosure_new (windowProc3, Widget.UNMAP_EVENT, 0);
+	closures [Widget.VISIBILITY_NOTIFY_EVENT] = OS.g_cclosure_new (windowProc3, Widget.VISIBILITY_NOTIFY_EVENT, 0);
+	closures [Widget.WINDOW_STATE_EVENT] = OS.g_cclosure_new (windowProc3, Widget.WINDOW_STATE_EVENT, 0);
+
+	windowCallback4 = new Callback (this, "windowProc", 4); //$NON-NLS-1$
+	windowProc4 = windowCallback4.getAddress ();
+	if (windowProc4 == 0) SWT.error (SWT.ERROR_NO_MORE_CALLBACKS);	
+
+	closures [Widget.DELETE_RANGE] = OS.g_cclosure_new (windowProc4, Widget.DELETE_RANGE, 0);
+	closures [Widget.DELETE_TEXT] = OS.g_cclosure_new (windowProc4, Widget.DELETE_TEXT, 0);
+	closures [Widget.ROW_ACTIVATED] = OS.g_cclosure_new (windowProc4, Widget.ROW_ACTIVATED, 0);
+	closures [Widget.SCROLL_CHILD] = OS.g_cclosure_new (windowProc4, Widget.SCROLL_CHILD, 0);
+	closures [Widget.SWITCH_PAGE] = OS.g_cclosure_new (windowProc4, Widget.SWITCH_PAGE, 0);
+	closures [Widget.TEST_COLLAPSE_ROW] = OS.g_cclosure_new (windowProc4, Widget.TEST_COLLAPSE_ROW, 0);
+	closures [Widget.TEST_EXPAND_ROW] = OS.g_cclosure_new (windowProc4, Widget.TEST_EXPAND_ROW, 0);
+
+	windowCallback5 = new Callback (this, "windowProc", 5); //$NON-NLS-1$
+	windowProc5 = windowCallback5.getAddress ();
+	if (windowProc5 == 0) SWT.error (SWT.ERROR_NO_MORE_CALLBACKS);
+
+	closures [Widget.CHANGE_VALUE] = OS.g_cclosure_new (windowProc5, Widget.CHANGE_VALUE, 0);
+	closures [Widget.EXPAND_COLLAPSE_CURSOR_ROW] = OS.g_cclosure_new (windowProc5, Widget.EXPAND_COLLAPSE_CURSOR_ROW, 0);
+	closures [Widget.INSERT_TEXT] = OS.g_cclosure_new (windowProc5, Widget.INSERT_TEXT, 0);
+	closures [Widget.TEXT_BUFFER_INSERT_TEXT] = OS.g_cclosure_new (windowProc5, Widget.TEXT_BUFFER_INSERT_TEXT, 0);
+
+	for (int i = 0; i < Widget.LAST_SIGNAL; i++) {
+		if (closures [i] != 0) OS.g_closure_ref (closures [i]);
+	}
+
+	timerCallback = new Callback (this, "timerProc", 1); //$NON-NLS-1$
+	timerProc = timerCallback.getAddress ();
+	if (timerProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);
+
+	windowTimerCallback = new Callback (this, "windowTimerProc", 1); //$NON-NLS-1$
+	windowTimerProc = windowTimerCallback.getAddress ();
+	if (windowTimerProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);
+	
+	mouseHoverCallback = new Callback (this, "mouseHoverProc", 1); //$NON-NLS-1$
+	mouseHoverProc = mouseHoverCallback.getAddress ();
+	if (mouseHoverProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);
+
+	caretCallback = new Callback(this, "caretProc", 1); //$NON-NLS-1$
+	caretProc = caretCallback.getAddress();
+	if (caretProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);
+
+	menuPositionCallback = new Callback(this, "menuPositionProc", 5); //$NON-NLS-1$
+	menuPositionProc = menuPositionCallback.getAddress();
+	if (menuPositionProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);
+	
+	sizeAllocateCallback = new Callback(this, "sizeAllocateProc", 3); //$NON-NLS-1$
+	sizeAllocateProc = sizeAllocateCallback.getAddress();
+	if (sizeAllocateProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);
+	
+	sizeRequestCallback = new Callback(this, "sizeRequestProc", 3); //$NON-NLS-1$
+	sizeRequestProc = sizeRequestCallback.getAddress();
+	if (sizeRequestProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);
+	
+	shellMapCallback = new Callback(this, "shellMapProc", 3); //$NON-NLS-1$
+	shellMapProc = shellMapCallback.getAddress();
+	if (shellMapProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);
+
+	shellMapProcClosure = OS.g_cclosure_new (shellMapProc, 0, 0);
+	OS.g_closure_ref (shellMapProcClosure);
+
+	treeSelectionCallback = new Callback(this, "treeSelectionProc", 4); //$NON-NLS-1$
+	treeSelectionProc = treeSelectionCallback.getAddress();
+	if (treeSelectionProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);
+	
+	cellDataCallback = new Callback (this, "cellDataProc", 5); //$NON-NLS-1$
+	cellDataProc = cellDataCallback.getAddress ();
+	if (cellDataProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);
+
+	setDirectionCallback = new Callback (this, "setDirectionProc", 2); //$NON-NLS-1$
+	setDirectionProc = setDirectionCallback.getAddress ();
+	if (setDirectionProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);
+	
+	emissionProcCallback = new Callback (this, "emissionProc", 4); //$NON-NLS-1$
+	emissionProc = emissionProcCallback.getAddress ();
+	if (emissionProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);
+
+	allChildrenCallback = new Callback (this, "allChildrenProc", 2); //$NON-NLS-1$
+	allChildrenProc = allChildrenCallback.getAddress ();
+	if (allChildrenProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);
+
+	checkIfEventCallback = new Callback (this, "checkIfEventProc", 3); //$NON-NLS-1$
+	checkIfEventProc = checkIfEventCallback.getAddress ();
+	if (checkIfEventProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);
+
+	idleCallback = new Callback (this, "idleProc", 1); //$NON-NLS-1$
+	idleProc = idleCallback.getAddress ();
+	if (idleProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);
+}
+
+void initializeSystemSettings () {
+	styleSetCallback = new Callback (this, "styleSetProc", 3); //$NON-NLS-1$
+	styleSetProc = styleSetCallback.getAddress ();
+	if (styleSetProc == 0) SWT.error (SWT.ERROR_NO_MORE_CALLBACKS);
+	OS.g_signal_connect (shellHandle, OS.style_set, styleSetProc, 0);
+	
+	/*
+	* Feature in GTK.  Despite the fact that the
+	* gtk-entry-select-on-focus property is a global
+	* setting, it is initialized when the GtkEntry
+	* is initialized.  This means that it cannot be
+	* accessed before a GtkEntry is created.  The
+	* fix is to for the initializaion by creating
+	* a temporary GtkEntry.
+	*/
+	int /*long*/ entry = OS.gtk_entry_new ();
+	OS.gtk_widget_destroy (entry);
+	int [] buffer2 = new int [1];
+	int /*long*/ settings = OS.gtk_settings_get_default ();
+	OS.g_object_get (settings, OS.gtk_entry_select_on_focus, buffer2, 0);
+	entrySelectOnFocus = buffer2 [0] != 0;
+}
+
+void initializeWidgetTable () {
+	indexTable = new int [GROW_SIZE];
+	widgetTable = new Widget [GROW_SIZE];
+	for (int i=0; i<GROW_SIZE-1; i++) indexTable [i] = i + 1;
+	indexTable [GROW_SIZE - 1] = -1;
+}
+
+void initializeWindowManager () {
+	/* Get the window manager name */
+	windowManager = ""; //$NON-NLS-1$
+	if (OS.GTK_VERSION >= OS.VERSION (2, 2, 0)) {
+		int /*long*/ screen = OS.gdk_screen_get_default ();
+		if (screen != 0) {
+			int /*long*/ ptr2 = OS.gdk_x11_screen_get_window_manager_name (screen);
+			if (ptr2 != 0) {
+				int length = OS.strlen (ptr2);
+				if (length > 0) {
+					byte [] buffer2 = new byte [length];
+					OS.memmove (buffer2, ptr2, length);
+					windowManager = new String (Converter.mbcsToWcs (null, buffer2));
+				}
+			}
+		}
+	}
+}
+
+/**	 
+ * Invokes platform specific functionality to dispose a GC handle.
+ * <p>
+ * <b>IMPORTANT:</b> This method is <em>not</em> part of the public
+ * API for <code>Display</code>. It is marked public only so that it
+ * can be shared within the packages provided by SWT. It is not
+ * available on all platforms, and should never be called from
+ * application code.
+ * </p>
+ *
+ * @param hDC the platform specific GC handle
+ * @param data the platform specific GC data 
+ */
+public void internal_dispose_GC (int /*long*/ gdkGC, GCData data) {
+	OS.g_object_unref (gdkGC);
+}
+
+/**	 
+ * Invokes platform specific functionality to allocate a new GC handle.
+ * <p>
+ * <b>IMPORTANT:</b> This method is <em>not</em> part of the public
+ * API for <code>Display</code>. It is marked public only so that it
+ * can be shared within the packages provided by SWT. It is not
+ * available on all platforms, and should never be called from
+ * application code.
+ * </p>
+ *
+ * @param data the platform specific GC data 
+ * @return the platform specific GC handle
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * @exception SWTError <ul>
+ *    <li>ERROR_NO_HANDLES if a handle could not be obtained for gc creation</li>
+ * </ul>
+ */
+public int /*long*/ internal_new_GC (GCData data) {
+	if (isDisposed()) SWT.error(SWT.ERROR_DEVICE_DISPOSED);
+	int /*long*/ root = OS.GDK_ROOT_PARENT ();
+	int /*long*/ gdkGC = OS.gdk_gc_new (root);
+	if (gdkGC == 0) SWT.error (SWT.ERROR_NO_HANDLES);
+	OS.gdk_gc_set_subwindow (gdkGC, OS.GDK_INCLUDE_INFERIORS);
+	if (data != null) {
+		int mask = SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT;
+		if ((data.style & mask) == 0) {
+			data.style |= SWT.LEFT_TO_RIGHT;
+		}
+		data.device = this;
+		data.drawable = root;
+		data.background = getSystemColor (SWT.COLOR_WHITE).handle;
+		data.foreground = getSystemColor (SWT.COLOR_BLACK).handle;
+		data.font = getSystemFont ();
+	}
+	return gdkGC;
+}
+
+boolean isValidThread () {
+	return thread == Thread.currentThread ();
+}
+
+/**
+ * Maps a point from one coordinate system to another.
+ * When the control is null, coordinates are mapped to
+ * the display.
+ * <p>
+ * NOTE: On right-to-left platforms where the coordinate
+ * systems are mirrored, special care needs to be taken
+ * when mapping coordinates from one control to another
+ * to ensure the result is correctly mirrored.
+ * 
+ * Mapping a point that is the origin of a rectangle and
+ * then adding the width and height is not equivalent to
+ * mapping the rectangle.  When one control is mirrored
+ * and the other is not, adding the width and height to a
+ * point that was mapped causes the rectangle to extend
+ * in the wrong direction.  Mapping the entire rectangle
+ * instead of just one point causes both the origin and
+ * the corner of the rectangle to be mapped.
+ * </p>
+ * 
+ * @param from the source <code>Control</code> or <code>null</code>
+ * @param to the destination <code>Control</code> or <code>null</code>
+ * @param point to be mapped 
+ * @return point with mapped coordinates 
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the point is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the Control from or the Control to have been disposed</li> 
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @since 2.1.2
+ */
+public Point map (Control from, Control to, Point point) {
+	checkDevice ();
+	if (point == null) error (SWT.ERROR_NULL_ARGUMENT);	
+	return map (from, to, point.x, point.y);
+}
+
+/**
+ * Maps a point from one coordinate system to another.
+ * When the control is null, coordinates are mapped to
+ * the display.
+ * <p>
+ * NOTE: On right-to-left platforms where the coordinate
+ * systems are mirrored, special care needs to be taken
+ * when mapping coordinates from one control to another
+ * to ensure the result is correctly mirrored.
+ * 
+ * Mapping a point that is the origin of a rectangle and
+ * then adding the width and height is not equivalent to
+ * mapping the rectangle.  When one control is mirrored
+ * and the other is not, adding the width and height to a
+ * point that was mapped causes the rectangle to extend
+ * in the wrong direction.  Mapping the entire rectangle
+ * instead of just one point causes both the origin and
+ * the corner of the rectangle to be mapped.
+ * </p>
+ * 
+ * @param from the source <code>Control</code> or <code>null</code>
+ * @param to the destination <code>Control</code> or <code>null</code>
+ * @param x coordinates to be mapped
+ * @param y coordinates to be mapped
+ * @return point with mapped coordinates
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the Control from or the Control to have been disposed</li> 
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @since 2.1.2
+ */
+public Point map (Control from, Control to, int x, int y) {
+	checkDevice ();
+	if (from != null && from.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);
+	if (to != null && to.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);
+	Point point = new Point (x, y);
+	if (from == to) return point;
+	if (from != null) {
+		int /*long*/ window = from.eventWindow ();
+		int [] origin_x = new int [1], origin_y = new int [1];
+		OS.gdk_window_get_origin (window, origin_x, origin_y);
+		if ((from.style & SWT.MIRRORED) != 0) point.x = from.getClientWidth () - point.x;
+		point.x += origin_x [0];
+		point.y += origin_y [0];
+	}
+	if (to != null) {
+		int /*long*/ window = to.eventWindow ();
+		int [] origin_x = new int [1], origin_y = new int [1];
+		OS.gdk_window_get_origin (window, origin_x, origin_y);
+		point.x -= origin_x [0];
+		point.y -= origin_y [0];
+		if ((to.style & SWT.MIRRORED) != 0) point.x = to.getClientWidth () - point.x;
+	}
+	return point;
+}
+
+/**
+ * Maps a point from one coordinate system to another.
+ * When the control is null, coordinates are mapped to
+ * the display.
+ * <p>
+ * NOTE: On right-to-left platforms where the coordinate
+ * systems are mirrored, special care needs to be taken
+ * when mapping coordinates from one control to another
+ * to ensure the result is correctly mirrored.
+ * 
+ * Mapping a point that is the origin of a rectangle and
+ * then adding the width and height is not equivalent to
+ * mapping the rectangle.  When one control is mirrored
+ * and the other is not, adding the width and height to a
+ * point that was mapped causes the rectangle to extend
+ * in the wrong direction.  Mapping the entire rectangle
+ * instead of just one point causes both the origin and
+ * the corner of the rectangle to be mapped.
+ * </p>
+ * 
+ * @param from the source <code>Control</code> or <code>null</code>
+ * @param to the destination <code>Control</code> or <code>null</code>
+ * @param rectangle to be mapped
+ * @return rectangle with mapped coordinates
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the rectangle is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the Control from or the Control to have been disposed</li> 
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @since 2.1.2
+ */
+public Rectangle map (Control from, Control to, Rectangle rectangle) {
+	checkDevice();
+	if (rectangle == null) error (SWT.ERROR_NULL_ARGUMENT);
+	return map (from, to, rectangle.x, rectangle.y, rectangle.width, rectangle.height);
+}
+
+static char mbcsToWcs (char ch) {
+	int key = ch & 0xFFFF;
+	if (key <= 0x7F) return ch;
+	byte [] buffer;
+	if (key <= 0xFF) {
+		buffer = new byte [1];
+		buffer [0] = (byte) key;
+	} else {
+		buffer = new byte [2];
+		buffer [0] = (byte) ((key >> 8) & 0xFF);
+		buffer [1] = (byte) (key & 0xFF);
+	}
+	char [] result = Converter.mbcsToWcs (null, buffer);
+	if (result.length == 0) return 0;
+	return result [0];
+}
+
+int /*long*/ menuPositionProc (int /*long*/ menu, int /*long*/ x, int /*long*/ y, int /*long*/ push_in, int /*long*/ user_data) {
+	Widget widget = getWidget (menu);
+	if (widget == null) return 0;
+	return widget.menuPositionProc (menu, x, y, push_in, user_data);	
+}
+
+/**
+ * Maps a point from one coordinate system to another.
+ * When the control is null, coordinates are mapped to
+ * the display.
+ * <p>
+ * NOTE: On right-to-left platforms where the coordinate
+ * systems are mirrored, special care needs to be taken
+ * when mapping coordinates from one control to another
+ * to ensure the result is correctly mirrored.
+ * 
+ * Mapping a point that is the origin of a rectangle and
+ * then adding the width and height is not equivalent to
+ * mapping the rectangle.  When one control is mirrored
+ * and the other is not, adding the width and height to a
+ * point that was mapped causes the rectangle to extend
+ * in the wrong direction.  Mapping the entire rectangle
+ * instead of just one point causes both the origin and
+ * the corner of the rectangle to be mapped.
+ * </p>
+ * 
+ * @param from the source <code>Control</code> or <code>null</code>
+ * @param to the destination <code>Control</code> or <code>null</code>
+ * @param x coordinates to be mapped
+ * @param y coordinates to be mapped
+ * @param width coordinates to be mapped
+ * @param height coordinates to be mapped
+ * @return rectangle with mapped coordinates
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the Control from or the Control to have been disposed</li> 
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @since 2.1.2
+ */
+public Rectangle map (Control from, Control to, int x, int y, int width, int height) {
+	checkDevice();
+	if (from != null && from.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);
+	if (to != null && to.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);
+	Rectangle rect = new Rectangle (x, y, width, height);
+	if (from == to) return rect;
+	boolean fromRTL = false, toRTL = false;
+	if (from != null) {
+		int /*long*/ window = from.eventWindow ();
+		int [] origin_x = new int [1], origin_y = new int [1];
+		OS.gdk_window_get_origin (window, origin_x, origin_y);
+		if (fromRTL = (from.style & SWT.MIRRORED) != 0) rect.x = from.getClientWidth() - rect.x;
+		rect.x += origin_x [0];
+		rect.y += origin_y [0];
+	}
+	if (to != null) {
+		int /*long*/ window = to.eventWindow ();
+		int [] origin_x = new int [1], origin_y = new int [1];
+		OS.gdk_window_get_origin (window, origin_x, origin_y);
+		rect.x -= origin_x [0];
+		rect.y -= origin_y [0];
+		if (toRTL = (to.style & SWT.MIRRORED) != 0) rect.x = to.getClientWidth () - rect.x;
+	}
+	if (fromRTL != toRTL) rect.x -= rect.width;
+	return rect;
+}
+
+int /*long*/ mouseHoverProc (int /*long*/ handle) {
+	Widget widget = getWidget (handle);
+	if (widget == null) return 0;
+	return widget.hoverProc (handle);
+}
+
+/**
+ * Generate a low level system event.
+ * 
+ * <code>post</code> is used to generate low level keyboard
+ * and mouse events. The intent is to enable automated UI
+ * testing by simulating the input from the user.  Most
+ * SWT applications should never need to call this method.
+ * <p>
+ * Note that this operation can fail when the operating system
+ * fails to generate the event for any reason.  For example,
+ * this can happen when there is no such key or mouse button
+ * or when the system event queue is full.
+ * </p>
+ * <p>
+ * <b>Event Types:</b>
+ * <p>KeyDown, KeyUp
+ * <p>The following fields in the <code>Event</code> apply:
+ * <ul>
+ * <li>(in) type KeyDown or KeyUp</li>
+ * <p> Either one of:
+ * <li>(in) character a character that corresponds to a keyboard key</li>
+ * <li>(in) keyCode the key code of the key that was typed,
+ *          as defined by the key code constants in class <code>SWT</code></li>
+ * </ul>
+ * <p>MouseDown, MouseUp</p>
+ * <p>The following fields in the <code>Event</code> apply:
+ * <ul>
+ * <li>(in) type MouseDown or MouseUp
+ * <li>(in) button the button that is pressed or released
+ * </ul>
+ * <p>MouseMove</p>
+ * <p>The following fields in the <code>Event</code> apply:
+ * <ul>
+ * <li>(in) type MouseMove
+ * <li>(in) x the x coordinate to move the mouse pointer to in screen coordinates
+ * <li>(in) y the y coordinate to move the mouse pointer to in screen coordinates
+ * </ul>
+ * </dl>
+ * 
+ * @param event the event to be generated
+ * 
+ * @return true if the event was generated or false otherwise
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the event is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @since 3.0
+ * 
+ */
+public boolean post (Event event) {
+	synchronized (Device.class) {
+		if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED);
+		if (event == null) error (SWT.ERROR_NULL_ARGUMENT);
+		if (!OS.GDK_WINDOWING_X11()) return false;
+		int /*long*/ xDisplay = OS.GDK_DISPLAY ();
+		int type = event.type;
+		switch (type) {
+			case SWT.KeyDown:
+			case SWT.KeyUp: {
+				int keyCode = 0;
+				int /*long*/ keysym = untranslateKey (event.keyCode);
+				if (keysym != 0) keyCode = OS.XKeysymToKeycode (xDisplay, keysym);
+				if (keyCode == 0) {
+					char key = event.character;
+					switch (key) {
+						case SWT.BS: keysym = OS.GDK_BackSpace; break;
+						case SWT.CR: keysym = OS.GDK_Return; break;
+						case SWT.DEL: keysym = OS.GDK_Delete; break;
+						case SWT.ESC: keysym = OS.GDK_Escape; break;
+						case SWT.TAB: keysym = OS.GDK_Tab; break;
+						case SWT.LF: keysym = OS.GDK_Linefeed; break;
+						default:
+							keysym = key;
+					}
+					keyCode = OS.XKeysymToKeycode (xDisplay, keysym);
+					if (keyCode == 0) return false;
+				}
+				OS.XTestFakeKeyEvent (xDisplay, keyCode, type == SWT.KeyDown, 0);
+				return true;
+			}
+			case SWT.MouseDown:
+			case SWT.MouseMove: 
+			case SWT.MouseUp: {
+				if (type == SWT.MouseMove) {
+					OS.XTestFakeMotionEvent (xDisplay, -1, event.x, event.y, 0);
+				} else {
+					int button = event.button;
+					switch (button) {
+						case 1:
+						case 2:
+						case 3:	break;
+						case 4: button = 6;	break;
+						case 5: button = 7;	break;
+						default: return false;
+					}
+					OS.XTestFakeButtonEvent (xDisplay, button, type == SWT.MouseDown, 0);
+				}
+				return true;
+			}
+			/*
+			* This code is intentionally commented. After posting a
+			* mouse wheel event the system may respond unpredictably
+			* to subsequent mouse actions.
+			*/
+//			case SWT.MouseWheel: {
+//				if (event.count == 0) return false;
+//				int button = event.count < 0 ? 5 : 4;
+//				OS.XTestFakeButtonEvent (xDisplay, button, type == SWT.MouseWheel, 0);			
+//			}
+		}
+		return false;
+	}
+}
+
+void postEvent (Event event) {
+	/*
+	* Place the event at the end of the event queue.
+	* This code is always called in the Display's
+	* thread so it must be re-enterant but does not
+	* need to be synchronized.
+	*/
+	if (eventQueue == null) eventQueue = new Event [4];
+	int index = 0;
+	int length = eventQueue.length;
+	while (index < length) {
+		if (eventQueue [index] == null) break;
+		index++;
+	}
+	if (index == length) {
+		Event [] newQueue = new Event [length + 4];
+		System.arraycopy (eventQueue, 0, newQueue, 0, length);
+		eventQueue = newQueue;
+	}
+	eventQueue [index] = event;
+}
+
+void putGdkEvents () {
+	if (gdkEventCount != 0) {
+		for (int i = 0; i < gdkEventCount; i++) {
+			int /*long*/ event = gdkEvents [i];
+			Widget widget = gdkEventWidgets [i];
+			if (widget == null || !widget.isDisposed ()) {
+				OS.gdk_event_put (event);
+			}
+			OS.gdk_event_free (event);
+			gdkEvents [i] = 0;
+			gdkEventWidgets [i] = null;
+		}
+		gdkEventCount = 0;
+	}
+}
+
+/**
+ * Reads an event from the operating system's event queue,
+ * dispatches it appropriately, and returns <code>true</code>
+ * if there is potentially more work to do, or <code>false</code>
+ * if the caller can sleep until another event is placed on
+ * the event queue.
+ * <p>
+ * In addition to checking the system event queue, this method also
+ * checks if any inter-thread messages (created by <code>syncExec()</code>
+ * or <code>asyncExec()</code>) are waiting to be processed, and if
+ * so handles them before returning.
+ * </p>
+ *
+ * @return <code>false</code> if the caller can sleep upon return from this method
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_FAILED_EXEC - if an exception occurred while running an inter-thread message</li>
+ * </ul>
+ *
+ * @see #sleep
+ * @see #wake
+ */
+public boolean readAndDispatch () {
+	checkDevice ();
+	boolean events = false;
+	events |= runSettings ();
+	events |= runPopups ();
+	events |= OS.g_main_context_iteration (0, false);
+	if (events) {
+		runDeferredEvents ();
+		return true;
+	}
+	return runAsyncMessages (false);
+}
+
+static void register (Display display) {
+	synchronized (Device.class) {
+		for (int i=0; i<Displays.length; i++) {
+			if (Displays [i] == null) {
+				Displays [i] = display;
+				return;
+			}
+		}
+		Display [] newDisplays = new Display [Displays.length + 4];
+		System.arraycopy (Displays, 0, newDisplays, 0, Displays.length);
+		newDisplays [Displays.length] = display;
+		Displays = newDisplays;
+	}
+}
+
+/**
+ * Releases any internal resources back to the operating
+ * system and clears all fields except the device handle.
+ * <p>
+ * Disposes all shells which are currently open on the display. 
+ * After this method has been invoked, all related related shells
+ * will answer <code>true</code> when sent the message
+ * <code>isDisposed()</code>.
+ * </p><p>
+ * When a device is destroyed, resources that were acquired
+ * on behalf of the programmer need to be returned to the
+ * operating system.  For example, if the device allocated a
+ * font to be used as the system font, this font would be
+ * freed in <code>release</code>.  Also,to assist the garbage
+ * collector and minimize the amount of memory that is not
+ * reclaimed when the programmer keeps a reference to a
+ * disposed device, all fields except the handle are zero'd.
+ * The handle is needed by <code>destroy</code>.
+ * </p>
+ * This method is called before <code>destroy</code>.
+ * 
+ * @see Device#dispose
+ * @see #destroy
+ */
+protected void release () {
+	sendEvent (SWT.Dispose, new Event ());
+	Shell [] shells = getShells ();
+	for (int i=0; i<shells.length; i++) {
+		Shell shell = shells [i];
+		if (!shell.isDisposed ())  shell.dispose ();
+	}
+	if (tray != null) tray.dispose ();
+	tray = null;
+	while (readAndDispatch ()) {}
+	if (disposeList != null) {
+		for (int i=0; i<disposeList.length; i++) {
+			if (disposeList [i] != null) disposeList [i].run ();
+		}
+	}
+	disposeList = null;
+	synchronizer.releaseSynchronizer ();
+	synchronizer = null;
+	releaseDisplay ();
+	super.release ();
+}
+
+void releaseDisplay () {
+	windowCallback2.dispose ();  windowCallback2 = null;
+	windowCallback3.dispose ();  windowCallback3 = null;
+	windowCallback4.dispose ();  windowCallback4 = null;
+	windowCallback5.dispose ();  windowCallback5 = null;
+	windowProc2 = windowProc3 = windowProc4 = windowProc5 = 0;
+	
+	/* Dispose xfilter callback */
+	if (filterProc != 0) {
+		OS.gdk_window_remove_filter(0, filterProc, 0);
+	}
+	filterCallback.dispose(); filterCallback = null;
+	filterProc = 0;
+
+	/* Dispose checkIfEvent callback */
+	checkIfEventCallback.dispose(); checkIfEventCallback = null;
+	checkIfEventProc = 0;
+	
+	/* Dispose preedit window */
+	if (preeditWindow != 0) OS.gtk_widget_destroy (preeditWindow);
+	imControl = null;
+
+	/* Dispose the menu callback */
+	menuPositionCallback.dispose (); menuPositionCallback = null;
+	menuPositionProc = 0;
+
+	/* Dispose the tooltip map callback */
+	sizeAllocateCallback.dispose (); sizeAllocateCallback = null;
+	sizeAllocateProc = 0;
+	sizeRequestCallback.dispose (); sizeRequestCallback = null;
+	sizeRequestProc = 0;
+	
+	/* Dispose the shell map callback */
+	shellMapCallback.dispose (); shellMapCallback = null;
+	shellMapProc = 0;
+	
+	/* Dispose the run async messages callback */
+	idleCallback.dispose (); idleCallback = null;
+	idleProc = 0;
+	if (idleHandle != 0) OS.g_source_remove (idleHandle);
+	idleHandle = 0;
+	
+	/* Dispose GtkTreeView callbacks */
+	treeSelectionCallback.dispose (); treeSelectionCallback = null;
+	treeSelectionProc = 0;
+	cellDataCallback.dispose (); cellDataCallback = null;
+	cellDataProc = 0;
+	
+	/* Dispose the set direction callback */
+	setDirectionCallback.dispose (); setDirectionCallback = null;
+	setDirectionProc = 0;
+	
+	/* Dispose the emission proc callback */
+	emissionProcCallback.dispose (); emissionProcCallback = null;
+	emissionProc = 0;
+
+	/* Dispose the set direction callback */
+	allChildrenCallback.dispose (); allChildrenCallback = null;
+	allChildrenProc = 0;
+
+	/* Dispose the caret callback */
+	if (caretId != 0) OS.gtk_timeout_remove (caretId);
+	caretId = 0;
+	caretProc = 0;
+	caretCallback.dispose ();
+	caretCallback = null;
+	
+	/* Release closures */
+	for (int i = 0; i < Widget.LAST_SIGNAL; i++) {
+		if (closures [i] != 0) OS.g_closure_unref (closures [i]);
+	}
+	if (shellMapProcClosure != 0) OS.g_closure_unref (shellMapProcClosure);
+
+	/* Dispose the timer callback */
+	if (timerIds != null) {
+		for (int i=0; i<timerIds.length; i++) {
+			if (timerIds [i] != 0) OS.gtk_timeout_remove (timerIds [i]);
+		}
+	}
+	timerIds = null;
+	timerList = null;
+	timerProc = 0;
+	timerCallback.dispose ();
+	timerCallback = null;
+	windowTimerProc = 0;
+	windowTimerCallback.dispose ();
+	windowTimerCallback = null;
+	
+	/* Dispose mouse hover callback */
+	if (mouseHoverId != 0) OS.gtk_timeout_remove (mouseHoverId);
+	mouseHoverId = 0;
+	mouseHoverHandle = mouseHoverProc = 0;
+	mouseHoverCallback.dispose ();
+	mouseHoverCallback = null;
+	
+	/* Dispose the default font */
+	if (systemFont != null) systemFont.dispose ();
+	systemFont = null;
+	
+	/* Dispose the System Images */
+	if (errorImage != null) errorImage.dispose();
+	if (infoImage != null) infoImage.dispose();
+	if (questionImage != null) questionImage.dispose();
+	if (warningImage != null) warningImage.dispose();
+	errorImage = infoImage = questionImage = warningImage = null;
+	
+	/* Release the System Cursors */
+	for (int i = 0; i < cursors.length; i++) {
+		if (cursors [i] != null) cursors [i].dispose ();
+	}
+	cursors = null;
+
+	/* Release Acquired Resources */
+	if (resources != null) {
+		for (int i=0; i<resources.length; i++) {
+			if (resources [i] != null) resources [i].dispose ();
+		}
+		resources = null;
+	}
+
+	/* Release the System Colors */
+	COLOR_WIDGET_DARK_SHADOW = COLOR_WIDGET_NORMAL_SHADOW = COLOR_WIDGET_LIGHT_SHADOW =
+	COLOR_WIDGET_HIGHLIGHT_SHADOW = COLOR_WIDGET_BACKGROUND = COLOR_WIDGET_BORDER =
+	COLOR_LIST_FOREGROUND = COLOR_LIST_BACKGROUND = COLOR_LIST_SELECTION = COLOR_LIST_SELECTION_TEXT =
+	COLOR_WIDGET_FOREGROUND = COLOR_TITLE_FOREGROUND = COLOR_TITLE_BACKGROUND = COLOR_TITLE_BACKGROUND_GRADIENT =
+	COLOR_TITLE_INACTIVE_FOREGROUND = COLOR_TITLE_INACTIVE_BACKGROUND = COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT =
+	COLOR_INFO_BACKGROUND = COLOR_INFO_FOREGROUND = null;
+
+	/* Dispose the event callback */
+	OS.gdk_event_handler_set (0, 0, 0);
+	eventCallback.dispose ();  eventCallback = null;
+	
+	/* Dispose the hidden shell */
+	if (shellHandle != 0) OS.gtk_widget_destroy (shellHandle);
+	shellHandle = 0;
+	
+	/* Dispose the settings callback */
+	styleSetCallback.dispose(); styleSetCallback = null;
+	styleSetProc = 0;
+
+	/* Release the sleep resources */
+	max_priority = timeout = null;
+	if (fds != 0) OS.g_free (fds);
+	fds = 0;
+
+	/* Release references */
+	popups = null;
+	thread = null;
+	lastWidget = activeShell = null;
+	flushData = closures = null;
+	indexTable = signalIds = treeSelection = null;
+	widgetTable = modalShells = null;
+	data = null;
+	values = keys = null;
+	windowManager = null;
+	eventTable = filterTable = null;
+	modalDialog = null;
+	flushRect = null;
+	exposeEvent = null;
+	visibilityEvent = null;
+	idleLock = null;
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when an event of the given type occurs anywhere in
+ * a widget. The event type is one of the event constants defined
+ * in class <code>SWT</code>.
+ *
+ * @param eventType the type of event to listen for
+ * @param listener the listener which should no longer be notified when the event occurs
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see Listener
+ * @see SWT
+ * @see #addFilter
+ * @see #addListener
+ * 
+ * @since 3.0
+ */
+public void removeFilter (int eventType, Listener listener) {
+	checkDevice ();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if (filterTable == null) return;
+	filterTable.unhook (eventType, listener);
+	if (filterTable.size () == 0) filterTable = null;
+}
+
+int /*long*/ removeGdkEvent () {
+	if (gdkEventCount == 0) return 0;
+	int /*long*/ event = gdkEvents [0];
+	--gdkEventCount;
+	System.arraycopy (gdkEvents, 1, gdkEvents, 0, gdkEventCount);
+	System.arraycopy (gdkEventWidgets, 1, gdkEventWidgets, 0, gdkEventCount);
+	gdkEvents [gdkEventCount] = 0;
+	gdkEventWidgets [gdkEventCount] = null;
+	if (gdkEventCount == 0) {
+		gdkEvents = null;
+		gdkEventWidgets = null;
+	}
+	return event;
+}
+
+void removeIdleProc () {
+	synchronized (idleLock) {
+		if (idleHandle != 0) OS.g_source_remove (idleHandle);
+		idleNeeded = false;
+		idleHandle = 0;
+	}
+}
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when an event of the given type occurs. The event type
+ * is one of the event constants defined in class <code>SWT</code>.
+ *
+ * @param eventType the type of event to listen for
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see Listener
+ * @see SWT
+ * @see #addListener
+ * 
+ * @since 2.0 
+ */
+public void removeListener (int eventType, Listener listener) {
+	checkDevice ();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if (eventTable == null) return;
+	eventTable.unhook (eventType, listener);
+}
+
+void removeMouseHoverTimeout (int /*long*/ handle) {
+	if (handle != mouseHoverHandle) return;
+	if (mouseHoverId != 0) OS.gtk_timeout_remove (mouseHoverId);
+	mouseHoverId = 0;
+	mouseHoverHandle = 0;
+}
+
+void removePopup (Menu menu) {
+	if (popups == null) return;
+	for (int i=0; i<popups.length; i++) {
+		if (popups [i] == menu) {
+			popups [i] = null;
+			return;
+		}
+	}
+}
+
+Widget removeWidget (int /*long*/ handle) {
+	if (handle == 0) return null;
+	lastWidget = null;
+	Widget widget = null;
+	int index = (int)/*64*/ OS.g_object_get_qdata (handle, SWT_OBJECT_INDEX) - 1;
+	if (0 <= index && index < widgetTable.length) {
+		widget = widgetTable [index];
+		widgetTable [index] = null;
+		indexTable [index] = freeSlot;
+		freeSlot = index;
+		OS.g_object_set_qdata (handle, SWT_OBJECT_INDEX, 0);
+	}
+	return widget;	
+}
+
+boolean runAsyncMessages (boolean all) {
+	return synchronizer.runAsyncMessages (all);
+}
+
+boolean runDeferredEvents () {
+	/*
+	* Run deferred events.  This code is always
+	* called in the Display's thread so it must
+	* be re-enterant but need not be synchronized.
+	*/
+	while (eventQueue != null) {
+		
+		/* Take an event off the queue */
+		Event event = eventQueue [0];
+		if (event == null) break;
+		int length = eventQueue.length;
+		System.arraycopy (eventQueue, 1, eventQueue, 0, --length);
+		eventQueue [length] = null;
+
+		/* Run the event */
+		Widget widget = event.widget;
+		if (widget != null && !widget.isDisposed ()) {
+			Widget item = event.item;
+			if (item == null || !item.isDisposed ()) {
+				widget.sendEvent (event);
+			}
+		}
+
+		/*
+		* At this point, the event queue could
+		* be null due to a recursive invokation
+		* when running the event.
+		*/
+	}
+
+	/* Clear the queue */
+	eventQueue = null;
+	return true;
+}
+
+boolean runPopups () {
+	if (popups == null) return false;
+	boolean result = false;
+	while (popups != null) {
+		Menu menu = popups [0];
+		if (menu == null) break;
+		int length = popups.length;
+		System.arraycopy (popups, 1, popups, 0, --length);
+		popups [length] = null;
+		runDeferredEvents ();
+		if (!menu.isDisposed ()) menu._setVisible (true);
+		result = true;
+	}
+	popups = null;
+	return result;
+}
+
+boolean runSettings () {
+	if (!runSettings) return false;
+	runSettings = false;
+	saveResources ();
+	initializeSystemColors ();
+	sendEvent (SWT.Settings, null);
+	Shell [] shells = getShells ();
+	for (int i=0; i<shells.length; i++) {
+		Shell shell = shells [i];
+		if (!shell.isDisposed ()) {
+			shell.fixStyle ();
+			shell.redraw (true);
+			shell.layout (true, true);
+		}
+	}
+	return true;
+}
+
+/**
+ * On platforms which support it, sets the application name
+ * to be the argument. On Motif, for example, this can be used
+ * to set the name used for resource lookup.  Specifying
+ * <code>null</code> for the name clears it.
+ *
+ * @param name the new app name or <code>null</code>
+ */
+public static void setAppName (String name) {
+	APP_NAME = name;
+}
+
+/**
+ * Sets the location of the on-screen pointer relative to the top left corner
+ * of the screen.  <b>Note: It is typically considered bad practice for a
+ * program to move the on-screen pointer location.</b>
+ *
+ * @param x the new x coordinate for the cursor
+ * @param y the new y coordinate for the cursor
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @since 2.1
+ */
+public void setCursorLocation (int x, int y) {
+	checkDevice ();
+	if (OS.GDK_WINDOWING_X11 ()) {
+		int /*long*/ xDisplay = OS.GDK_DISPLAY ();
+		int /*long*/ xWindow = OS.XDefaultRootWindow (xDisplay);
+		OS.XWarpPointer (xDisplay, OS.None, xWindow, 0, 0, 0, 0, x, y);
+	}
+}
+
+/**
+ * Sets the location of the on-screen pointer relative to the top left corner
+ * of the screen.  <b>Note: It is typically considered bad practice for a
+ * program to move the on-screen pointer location.</b>
+ *
+ * @param point new position
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_NULL_ARGUMENT - if the point is null
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @since 2.0
+ */
+public void setCursorLocation (Point point) {
+	checkDevice ();
+	if (point == null) error (SWT.ERROR_NULL_ARGUMENT);
+	setCursorLocation (point.x, point.y);
+}
+
+/**
+ * Sets the application defined property of the receiver
+ * with the specified name to the given argument.
+ * <p>
+ * Applications may have associated arbitrary objects with the
+ * receiver in this fashion. If the objects stored in the
+ * properties need to be notified when the display is disposed
+ * of, it is the application's responsibility provide a
+ * <code>disposeExec()</code> handler which does so.
+ * </p>
+ *
+ * @param key the name of the property
+ * @param value the new value for the property
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the key is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see #getData(String)
+ * @see #disposeExec(Runnable)
+ */
+public void setData (String key, Object value) {
+	checkDevice ();
+	if (key == null) error (SWT.ERROR_NULL_ARGUMENT);
+
+	if (key.equals (DISPATCH_EVENT_KEY)) {
+		if (value == null || value instanceof int []) {
+			dispatchEvents = (int []) value;
+			if (value == null) putGdkEvents ();
+			return;
+		}
+	}
+	if (key.equals (SET_MODAL_DIALOG)) {
+		setModalDialog ((Dialog) data);
+		return;
+	}
+	if (key.equals (ADD_WIDGET_KEY)) {
+		Object [] data = (Object []) value;
+		int /*long*/ handle = ((LONG) data [0]).value;
+		Widget widget = (Widget) data [1];
+		if (widget != null) {
+			addWidget (handle, widget);
+		} else {
+			removeWidget (handle);
+		}
+	}
+	if (key.equals (ADD_IDLE_PROC_KEY)) {	
+		addIdleProc ();
+		return;
+	}
+	if (key.equals (REMOVE_IDLE_PROC_KEY)) {
+		removeIdleProc ();
+		return;
+	}
+
+	/* Remove the key/value pair */
+	if (value == null) {
+		if (keys == null) return;
+		int index = 0;
+		while (index < keys.length && !keys [index].equals (key)) index++;
+		if (index == keys.length) return;
+		if (keys.length == 1) {
+			keys = null;
+			values = null;
+		} else {
+			String [] newKeys = new String [keys.length - 1];
+			Object [] newValues = new Object [values.length - 1];
+			System.arraycopy (keys, 0, newKeys, 0, index);
+			System.arraycopy (keys, index + 1, newKeys, index, newKeys.length - index);
+			System.arraycopy (values, 0, newValues, 0, index);
+			System.arraycopy (values, index + 1, newValues, index, newValues.length - index);
+			keys = newKeys;
+			values = newValues;
+		}
+		return;
+	}
+	
+	/* Add the key/value pair */
+	if (keys == null) {
+		keys = new String [] {key};
+		values = new Object [] {value};
+		return;
+	}
+	for (int i=0; i<keys.length; i++) {
+		if (keys [i].equals (key)) {
+			values [i] = value;
+			return;
+		}
+	}
+	String [] newKeys = new String [keys.length + 1];
+	Object [] newValues = new Object [values.length + 1];
+	System.arraycopy (keys, 0, newKeys, 0, keys.length);
+	System.arraycopy (values, 0, newValues, 0, values.length);
+	newKeys [keys.length] = key;
+	newValues [values.length] = value;
+	keys = newKeys;
+	values = newValues;
+}
+
+/**
+ * Sets the application defined, display specific data
+ * associated with the receiver, to the argument.
+ * The <em>display specific data</em> is a single,
+ * unnamed field that is stored with every display. 
+ * <p>
+ * Applications may put arbitrary objects in this field. If
+ * the object stored in the display specific data needs to
+ * be notified when the display is disposed of, it is the
+ * application's responsibility provide a
+ * <code>disposeExec()</code> handler which does so.
+ * </p>
+ *
+ * @param data the new display specific data
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see #getData()
+ * @see #disposeExec(Runnable)
+ */
+public void setData (Object data) {
+	checkDevice ();
+	this.data = data;
+}
+
+int /*long*/ setDirectionProc (int /*long*/ widget, int /*long*/ direction) {
+	OS.gtk_widget_set_direction (widget, (int)/*64*/ direction);
+	if (OS.GTK_IS_MENU_ITEM (widget)) {
+		int /*long*/ submenu = OS.gtk_menu_item_get_submenu (widget);
+		if (submenu != 0) {
+			OS.gtk_widget_set_direction (submenu, (int)/*64*/ direction);
+			OS.gtk_container_forall (submenu, setDirectionProc, direction);
+		}
+	}
+	if (OS.GTK_IS_CONTAINER (widget)) {
+		OS.gtk_container_forall (widget, setDirectionProc, direction);
+	}
+	return 0;
+}
+
+void setModalDialog (Dialog modalDailog) {
+	this.modalDialog = modalDailog;
+	Shell [] shells = getShells ();
+	for (int i=0; i<shells.length; i++) shells [i].updateModal ();
+}
+
+void setModalShell (Shell shell) {
+	if (modalShells == null) modalShells = new Shell [4];
+	int index = 0, length = modalShells.length;
+	while (index < length) {
+		if (modalShells [index] == shell) return;
+		if (modalShells [index] == null) break;
+		index++;
+	}
+	if (index == length) {
+		Shell [] newModalShells = new Shell [length + 4];
+		System.arraycopy (modalShells, 0, newModalShells, 0, length);
+		modalShells = newModalShells;
+	}
+	modalShells [index] = shell;
+	Shell [] shells = getShells ();
+	for (int i=0; i<shells.length; i++) shells [i].updateModal ();
+}
+
+/**
+ * Sets the synchronizer used by the display to be
+ * the argument, which can not be null.
+ *
+ * @param synchronizer the new synchronizer for the display (must not be null)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the synchronizer is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_FAILED_EXEC - if an exception occurred while running an inter-thread message</li>
+ * </ul>
+ */
+public void setSynchronizer (Synchronizer synchronizer) {
+	checkDevice ();
+	if (synchronizer == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if (synchronizer == this.synchronizer) return;
+	Synchronizer oldSynchronizer;
+	synchronized (Device.class) {
+		oldSynchronizer = this.synchronizer;
+		this.synchronizer = synchronizer;
+	}
+	if (oldSynchronizer != null) {
+		oldSynchronizer.runAsyncMessages(true);
+	}
+}
+
+void showIMWindow (Control control) {
+	imControl = control;
+	if (preeditWindow == 0) { 
+		preeditWindow = OS.gtk_window_new (OS.GTK_WINDOW_POPUP);
+		if (preeditWindow == 0) error (SWT.ERROR_NO_HANDLES);
+		preeditLabel = OS.gtk_label_new (null);
+		if (preeditLabel == 0) error (SWT.ERROR_NO_HANDLES);
+		OS.gtk_container_add (preeditWindow, preeditLabel);
+		OS.gtk_widget_show (preeditLabel);
+	}
+	int /*long*/ [] preeditString = new int /*long*/ [1];
+	int /*long*/ [] pangoAttrs = new int /*long*/ [1];
+	int /*long*/ imHandle = control.imHandle ();
+	OS.gtk_im_context_get_preedit_string (imHandle, preeditString, pangoAttrs, null);
+	if (preeditString [0] != 0 && OS.strlen (preeditString [0]) > 0) {
+		Control widget = control.findBackgroundControl ();
+		if (widget == null) widget = control;
+		OS.gtk_widget_modify_bg (preeditWindow,  OS.GTK_STATE_NORMAL, widget.getBackgroundColor ());
+		widget.setForegroundColor (preeditLabel, control.getForegroundColor());
+		OS.gtk_widget_modify_font (preeditLabel, control.getFontDescription ());
+		if (pangoAttrs [0] != 0) OS.gtk_label_set_attributes (preeditLabel, pangoAttrs[0]);
+		OS.gtk_label_set_text (preeditLabel, preeditString [0]);
+		Point point = control.toDisplay (control.getIMCaretPos ());
+		OS.gtk_window_move (preeditWindow, point.x, point.y);		
+		GtkRequisition requisition = new GtkRequisition ();
+		OS.gtk_widget_size_request (preeditLabel, requisition);
+		OS.gtk_window_resize (preeditWindow, requisition.width, requisition.height);
+		OS.gtk_widget_show (preeditWindow);
+	} else {
+		OS.gtk_widget_hide (preeditWindow);
+	}		
+	if (preeditString [0] != 0) OS.g_free (preeditString [0]);
+	if (pangoAttrs [0] != 0) OS.pango_attr_list_unref (pangoAttrs [0]);	
+}
+
+/**
+ * Causes the user-interface thread to <em>sleep</em> (that is,
+ * to be put in a state where it does not consume CPU cycles)
+ * until an event is received or it is otherwise awakened.
+ *
+ * @return <code>true</code> if an event requiring dispatching was placed on the queue.
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see #wake
+ */
+public boolean sleep () {
+	checkDevice ();
+	if (gdkEventCount == 0) {
+		gdkEvents = null;
+		gdkEventWidgets = null;
+	}
+	if (settingsChanged) {
+		settingsChanged = false;
+		runSettings = true;
+		return false;
+	}
+	if (getMessageCount () != 0) return true;
+	if (fds == 0) {
+		allocated_nfds = 2;
+		fds = OS.g_malloc (OS.GPollFD_sizeof () * allocated_nfds);
+	}
+	max_priority [0] = timeout [0] = 0;
+	int /*long*/ context = OS.g_main_context_default ();
+	boolean result = false;
+	do {
+		if (OS.g_main_context_acquire (context)) {
+			result = OS.g_main_context_prepare (context, max_priority);
+			int nfds;
+			while ((nfds = OS.g_main_context_query (context, max_priority [0], timeout, fds, allocated_nfds)) > allocated_nfds) {
+				OS.g_free (fds);
+				allocated_nfds = nfds;
+				fds = OS.g_malloc (OS.GPollFD_sizeof() * allocated_nfds);
+			}
+			int /*long*/ poll = OS.g_main_context_get_poll_func (context);
+			if (poll != 0) {
+				if (nfds > 0 || timeout [0] != 0) {
+					/*
+					* Bug in GTK. For some reason, g_main_context_wakeup() may 
+					* fail to wake up the UI thread from the polling function.
+					* The fix is to sleep for a maximum of 50 milliseconds.
+					*/
+					if (timeout [0] < 0) timeout [0] = 50;
+					
+					/* Exit the OS lock to allow other threads to enter GTK */
+					Lock lock = OS.lock;
+					int count = lock.lock ();
+					for (int i = 0; i < count; i++) lock.unlock ();
+					try {
+						wake = false;
+						OS.Call (poll, fds, nfds, timeout [0]);
+					} finally {
+						for (int i = 0; i < count; i++) lock.lock ();
+						lock.unlock ();
+					}
+				}
+			}
+			OS.g_main_context_check (context, max_priority [0], fds, nfds);
+			OS.g_main_context_release (context);
+		}
+	} while (!result && getMessageCount () == 0 && !wake);
+	wake = false;
+	return true;
+}
+
+/**
+ * Causes the <code>run()</code> method of the runnable to
+ * be invoked by the user-interface thread after the specified
+ * number of milliseconds have elapsed. If milliseconds is less
+ * than zero, the runnable is not executed.
+ * <p>
+ * Note that at the time the runnable is invoked, widgets 
+ * that have the receiver as their display may have been
+ * disposed. Therefore, it is necessary to check for this
+ * case inside the runnable before accessing the widget.
+ * </p>
+ *
+ * @param milliseconds the delay before running the runnable
+ * @param runnable code to run on the user-interface thread
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the runnable is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see #asyncExec
+ */
+public void timerExec (int milliseconds, Runnable runnable) {
+	checkDevice ();
+	if (runnable == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if (timerList == null) timerList = new Runnable [4];
+	if (timerIds == null) timerIds = new int [4];	
+	int index = 0;
+	while (index < timerList.length) {
+		if (timerList [index] == runnable) break;
+		index++;
+	}
+	if (index != timerList.length) {
+		OS.gtk_timeout_remove (timerIds [index]);
+		timerList [index] = null;
+		timerIds [index] = 0;
+		if (milliseconds < 0) return;
+	} else {
+		if (milliseconds < 0) return;
+		index = 0;
+		while (index < timerList.length) {
+			if (timerList [index] == null) break;
+			index++;
+		}
+		if (index == timerList.length) {
+			Runnable [] newTimerList = new Runnable [timerList.length + 4];
+			System.arraycopy (timerList, 0, newTimerList, 0, timerList.length);
+			timerList = newTimerList;
+			int [] newTimerIds = new int [timerIds.length + 4];
+			System.arraycopy (timerIds, 0, newTimerIds, 0, timerIds.length);
+			timerIds = newTimerIds;
+		}
+	}
+	int timerId = OS.gtk_timeout_add (milliseconds, timerProc, index);
+	if (timerId != 0) {
+		timerIds [index] = timerId;
+		timerList [index] = runnable;
+	}
+}
+
+int /*long*/ timerProc (int /*long*/ i) {
+	if (timerList == null) return 0;
+	int index = (int)/*64*/i;
+	if (0 <= index && index < timerList.length) {
+		Runnable runnable = timerList [index];
+		timerList [index] = null;
+		timerIds [index] = 0;
+		if (runnable != null) runnable.run ();
+	}
+	return 0;
+}
+
+int /*long*/ caretProc (int /*long*/ clientData) {
+	caretId = 0;
+	if (currentCaret == null) {
+		return 0;
+	}
+	if (currentCaret.blinkCaret()) {
+		int blinkRate = currentCaret.blinkRate;
+		if (blinkRate == 0) return 0;
+		caretId = OS.gtk_timeout_add (blinkRate, caretProc, 0);
+	} else {
+		currentCaret = null;
+	}
+	return 0;
+}
+
+int /*long*/ sizeAllocateProc (int /*long*/ handle, int /*long*/ arg0, int /*long*/ user_data) {
+	Widget widget = getWidget (user_data);
+	if (widget == null) return 0;
+	return widget.sizeAllocateProc (handle, arg0, user_data);
+}
+
+int /*long*/ sizeRequestProc (int /*long*/ handle, int /*long*/ arg0, int /*long*/ user_data) {
+	Widget widget = getWidget (user_data);
+	if (widget == null) return 0;
+	return widget.sizeRequestProc (handle, arg0, user_data);
+}
+
+int /*long*/ treeSelectionProc (int /*long*/ model, int /*long*/ path, int /*long*/ iter, int /*long*/ data) {
+	Widget widget = getWidget (data);
+	if (widget == null) return 0;
+	return widget.treeSelectionProc (model, path, iter, treeSelection, treeSelectionLength++);
+}
+
+void saveResources () {
+	int resourceCount = 0;
+	if (resources == null) {
+		resources = new Resource [RESOURCE_SIZE];
+	} else {
+		resourceCount = resources.length;
+		Resource [] newResources = new Resource [resourceCount + RESOURCE_SIZE];
+		System.arraycopy (resources, 0, newResources, 0, resourceCount);
+		resources = newResources;
+	}
+	if (systemFont != null) {
+		resources [resourceCount++] = systemFont;
+		systemFont = null;
+	}
+	if (errorImage != null) resources [resourceCount++] = errorImage;
+	if (infoImage != null) resources [resourceCount++] = infoImage;
+	if (questionImage != null) resources [resourceCount++] = questionImage;
+	if (warningImage != null) resources [resourceCount++] = warningImage;
+	errorImage = infoImage = questionImage = warningImage = null;
+	for (int i=0; i<cursors.length; i++) {
+		if (cursors [i] != null) resources [resourceCount++] = cursors [i];
+		cursors [i] = null;
+	}
+	if (resourceCount < RESOURCE_SIZE) {
+		Resource [] newResources = new Resource [resourceCount];
+		System.arraycopy (resources, 0, newResources, 0, resourceCount);
+		resources = newResources;
+	}
+}
+
+void sendEvent (int eventType, Event event) {
+	if (eventTable == null && filterTable == null) {
+		return;
+	}
+	if (event == null) event = new Event ();
+	event.display = this;
+	event.type = eventType;
+	if (event.time == 0) event.time = getLastEventTime ();
+	if (!filterEvent (event)) {
+		if (eventTable != null) eventTable.sendEvent (event);
+	}
+}
+
+void setCurrentCaret (Caret caret) {
+	if (caretId != 0) OS.gtk_timeout_remove(caretId);
+	caretId = 0;
+	currentCaret = caret;
+	if (caret == null) return;
+	int blinkRate = currentCaret.blinkRate;
+	caretId = OS.gtk_timeout_add (blinkRate, caretProc, 0); 
+}
+
+int /*long*/ shellMapProc (int /*long*/ handle, int /*long*/ arg0, int /*long*/ user_data) {
+	Widget widget = getWidget (handle);
+	if (widget == null) return 0;
+	return widget.shellMapProc (handle, arg0, user_data);
+}
+
+int /*long*/ styleSetProc (int /*long*/ gobject, int /*long*/ arg1, int /*long*/ user_data) {
+	settingsChanged = true;
+	return 0;
+}
+
+/**
+ * Causes the <code>run()</code> method of the runnable to
+ * be invoked by the user-interface thread at the next 
+ * reasonable opportunity. The thread which calls this method
+ * is suspended until the runnable completes.  Specifying <code>null</code>
+ * as the runnable simply wakes the user-interface thread.
+ * <p>
+ * Note that at the time the runnable is invoked, widgets 
+ * that have the receiver as their display may have been
+ * disposed. Therefore, it is necessary to check for this
+ * case inside the runnable before accessing the widget.
+ * </p>
+ * 
+ * @param runnable code to run on the user-interface thread or <code>null</code>
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_FAILED_EXEC - if an exception occurred when executing the runnable</li>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see #asyncExec
+ */
+public void syncExec (Runnable runnable) {
+	Synchronizer synchronizer;
+	synchronized (Device.class) {
+		if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED);
+		synchronizer = this.synchronizer;
+		synchronized (idleLock) {
+			if (idleNeeded && idleHandle == 0) {
+				//NOTE: calling unlocked function in OS
+				idleHandle = OS._g_idle_add (idleProc, 0);
+			}
+		}
+	}
+	synchronizer.syncExec (runnable);
+}
+
+static int translateKey (int key) {
+	for (int i=0; i<KeyTable.length; i++) {
+		if (KeyTable [i] [0] == key) return KeyTable [i] [1];
+	}
+	return 0;
+}
+
+static int untranslateKey (int key) {
+	for (int i=0; i<KeyTable.length; i++) {
+		if (KeyTable [i] [1] == key) return KeyTable [i] [0];
+	}
+	return 0;
+}
+
+/**
+ * Forces all outstanding paint requests for the display
+ * to be processed before this method returns.
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @see Control#update()
+ */
+public void update () {
+	checkDevice ();
+	flushExposes (0, true);
+	OS.gdk_window_process_all_updates ();
+}
+
+/**
+ * If the receiver's user-interface thread was <code>sleep</code>ing, 
+ * causes it to be awakened and start running again. Note that this
+ * method may be called from any thread.
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ * 
+ * @see #sleep
+ */
+public void wake () {
+	synchronized (Device.class) {
+		if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED);
+		if (thread == Thread.currentThread ()) return;
+		wakeThread ();
+	}
+}
+
+void wakeThread () {
+	OS.g_main_context_wakeup (0);
+	wake = true;
+}
+
+static char wcsToMbcs (char ch) {
+	int key = ch & 0xFFFF;
+	if (key <= 0x7F) return ch;
+	byte [] buffer = Converter.wcsToMbcs (null, new char [] {ch}, false);
+	if (buffer.length == 1) return (char) buffer [0];
+	if (buffer.length == 2) {
+		return (char) (((buffer [0] & 0xFF) << 8) | (buffer [1] & 0xFF));
+	}
+	return 0;
+}
+
+int /*long*/ windowProc (int /*long*/ handle, int /*long*/ user_data) {
+	Widget widget = getWidget (handle);
+	if (widget == null) return 0;
+	return widget.windowProc (handle, user_data);
+}
+
+int /*long*/ windowProc (int /*long*/ handle, int /*long*/ arg0, int /*long*/ user_data) {
+	Widget widget = getWidget (handle);
+	if (widget == null) return 0;
+	return widget.windowProc (handle, arg0, user_data);
+}
+
+int /*long*/ windowProc (int /*long*/ handle, int /*long*/ arg0, int /*long*/ arg1, int /*long*/ user_data) {
+	Widget widget = getWidget (handle);
+	if (widget == null) return 0;
+	return widget.windowProc (handle, arg0, arg1, user_data);
+}
+
+int /*long*/ windowProc (int /*long*/ handle, int /*long*/ arg0, int /*long*/ arg1, int /*long*/ arg2, int /*long*/ user_data) {
+	Widget widget = getWidget (handle);
+	if (widget == null) return 0;
+	return widget.windowProc (handle, arg0, arg1, arg2, user_data);
+}
+
+int /*long*/ windowTimerProc (int /*long*/ handle) {
+	Widget widget = getWidget (handle);
+	if (widget == null) return 0;
+	return widget.timerProc (handle);
+}
+
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Event.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Event.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Event.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,222 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.widgets;
+
+
+import org.eclipse.swt.graphics.*;
+
+/**
+ * Instances of this class provide a description of a particular
+ * event which occurred within SWT. The SWT <em>untyped listener</em>
+ * API uses these instances for all event dispatching.
+ * <p>
+ * Note: For a given event, only the fields which are appropriate
+ * will be filled in. The contents of the fields which are not used
+ * by the event are unspecified.
+ * </p>
+ * 
+ * @see Listener
+ * @see org.eclipse.swt.events.TypedEvent
+ * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: ControlExample, Listeners</a>
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+
+public class Event {
+	
+	/**
+	 * the display where the event occurred
+	 * 
+	 * @since 2.0 
+	 */	
+	public Display display;
+		
+	/**
+	 * the widget that issued the event
+	 */
+	public Widget widget;
+	
+	/**
+	 * the type of event, as defined by the event type constants
+	 * in class <code>SWT</code>
+	 *
+	 * @see org.eclipse.swt.SWT
+	 */
+	public int type;
+	
+	/**
+	 * the event specific detail field, as defined by the detail constants
+	 * in class <code>SWT</code>
+	 * 
+	 * @see org.eclipse.swt.SWT
+	 */
+	public int detail;
+	
+	/**
+	 * the item that the event occurred in (can be null)
+	 */
+	public Widget item;
+	
+	/**
+	 * the index of the item where the event occurred
+	 * 
+	 * @since 3.2
+	 */
+	public int index;
+	
+	/**
+	 * the graphics context to use when painting
+	 * that is configured to use the colors, font and
+	 * damaged region of the control.  It is valid
+	 * only during the paint and must not be disposed
+	 */
+	public GC gc;
+	
+	/**
+	 * depending on the event type, the x offset of the bounding
+	 * rectangle of the region that requires painting or the
+	 * widget-relative, x coordinate of the pointer at the
+	 * time the mouse button was pressed or released
+	 */
+	public int x;
+	
+	/**
+	 * depending on the event type, the y offset of the bounding
+	 * rectangle of the  region that requires painting or the
+	 * widget-relative, y coordinate of the pointer at the
+	 * time the mouse button was pressed or released
+	 */
+	public int y;
+	
+	/**
+	 * the width of the bounding rectangle of the 
+	 * region that requires painting
+	 */
+	public int width;
+	
+	/**
+	 * the height of the bounding rectangle of the 
+	 * region that requires painting
+	 */
+	public int height;
+
+	/**
+	 * depending on the event type, the number of following
+	 * paint events which are pending which may always be zero
+	 * on some platforms or the number of lines or pages to
+	 * scroll using the mouse wheel
+	 */
+	public int count;
+	
+	/**
+	 * the time that the event occurred.
+	 * 
+	 * NOTE: This field is an unsigned integer and should
+	 * be AND'ed with 0xFFFFFFFFL so that it can be treated
+	 * as a signed long.
+	 */	
+	public int time;
+	
+	/**
+	 * the button that was pressed or released; 1 for the
+	 * first button, 2 for the second button, and 3 for the
+	 * third button, etc.
+	 */	
+	public int button;
+	
+	/**
+	 * depending on the event, the character represented by the key
+	 * that was typed.  This is the final character that results
+	 * after all modifiers have been applied.  For example, when the
+	 * user types Ctrl+A, the character value is 0x01 (ASCII SOH).
+	 * It is important that applications do not attempt to modify the
+	 * character value based on a stateMask (such as SWT.CTRL) or the
+	 * resulting character will not be correct.
+	 */
+	public char character;
+	
+	/**
+	 * depending on the event, the key code of the key that was typed,
+	 * as defined by the key code constants in class <code>SWT</code>.
+	 * When the character field of the event is ambiguous, this field
+	 * contains the unaffected value of the original character.  For
+	 * example, typing Ctrl+M or Enter both result in the character '\r'
+	 * but the keyCode field will also contain '\r' when Enter was typed
+	 * and 'm' when Ctrl+M was typed.
+	 * 
+	 * @see org.eclipse.swt.SWT
+	 */
+	public int keyCode;
+	
+	/**
+	 * depending on the event, the state of the keyboard modifier
+	 * keys and mouse masks at the time the event was generated.
+	 * 
+	 * @see org.eclipse.swt.SWT
+	 */
+	public int stateMask;
+	
+	/**
+	 * depending on the event, the range of text being modified.
+	 * Setting these fields only has effect during ImeComposition 
+	 * events.
+	 */
+	public int start, end;
+	
+	/**
+	 * depending on the event, the new text that will be inserted.
+	 * Setting this field will change the text that is about to
+	 * be inserted or deleted.
+	 */
+	public String text;
+
+	/**
+	 * depending on the event, a flag indicating whether the operation
+	 * should be allowed.  Setting this field to false will cancel the
+	 * operation.
+	 */
+	public boolean doit = true;
+	
+	/**
+	 * a field for application use
+	 */
+	public Object data;
+	
+/**
+ * Gets the bounds.
+ * 
+ * @return a rectangle that is the bounds.
+ */
+public Rectangle getBounds () {
+	return new Rectangle (x, y, width, height);
+}
+
+/**
+ * Sets the bounds.
+ * 
+ * @param rect the new rectangle
+ */
+public void setBounds (Rectangle rect) {
+	this.x = rect.x;
+	this.y = rect.y;
+	this.width = rect.width;
+	this.height = rect.height;
+}
+
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the event
+ */
+public String toString () {
+	return "Event {type=" + type + " " + widget + " time=" + time + " data=" + data + " x=" + x + " y=" + y + " width=" + width + " height=" + height + " detail=" + detail + "}";  //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/EventTable.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/EventTable.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/EventTable.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,154 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.widgets;
+
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.SWTEventListener;
+
+/**
+ * Instances of this class implement a simple
+ * look up mechanism that maps an event type
+ * to a listener.  Multiple listeners for the
+ * same event type are supported.
+ */
+
+class EventTable {
+	int [] types;
+	Listener [] listeners;
+	int level;
+	static final int GROW_SIZE = 4;
+	
+public Listener [] getListeners (int eventType) {
+	if (types == null) return new Listener [0];
+	int count = 0;
+	for (int i=0; i<types.length; i++) {
+		if (types [i] == eventType) count++;
+	}
+	if (count == 0) return new Listener [0];
+	Listener [] result = new Listener [count];
+	count = 0;
+	for (int i=0; i<types.length; i++) {
+		if (types [i] == eventType) {
+			result [count++] = listeners [i];
+		}
+	}
+	return result;
+}
+
+public void hook (int eventType, Listener listener) {
+	if (types == null) types = new int [GROW_SIZE];
+	if (listeners == null) listeners = new Listener [GROW_SIZE];
+	int length = types.length, index = length - 1;
+	while (index >= 0) {
+		if (types [index] != 0) break;
+		--index;
+	}
+	index++;
+	if (index == length) {
+		int [] newTypes = new int [length + GROW_SIZE];
+		System.arraycopy (types, 0, newTypes, 0, length);
+		types = newTypes;
+		Listener [] newListeners = new Listener [length + GROW_SIZE];
+		System.arraycopy (listeners, 0, newListeners, 0, length);
+		listeners = newListeners;
+	}
+	types [index] = eventType;
+	listeners [index] = listener;
+}
+
+public boolean hooks (int eventType) {
+	if (types == null) return false;
+	for (int i=0; i<types.length; i++) {
+		if (types [i] == eventType) return true;
+	}
+	return false;
+}
+
+public void sendEvent (Event event) {
+	if (types == null) return;
+	level += level >= 0 ? 1 : -1;
+	try {
+		for (int i=0; i<types.length; i++) {
+			if (event.type == SWT.None) return;
+			if (types [i] == event.type) {
+				Listener listener = listeners [i];
+				if (listener != null) listener.handleEvent (event);
+			}
+		}
+	} finally {
+		boolean compact = level < 0;
+		level -= level >= 0 ? 1 : -1;
+		if (compact && level == 0) {
+			int index = 0;
+			for (int i=0; i<types.length; i++) {
+				if (types [i] != 0) {
+					types [index] = types [i];
+					listeners [index] = listeners [i];
+					index++;
+				}
+			}
+			for (int i=index; i<types.length; i++) {
+				types [i] = 0;
+				listeners [i] = null;
+			}
+		}
+	}
+}
+
+public int size () {
+	if (types == null) return 0;
+	int count = 0;
+	for (int i=0; i<types.length; i++) {
+		if (types [i] != 0) count++;
+	}
+	return count;
+}
+
+void remove (int index) {
+	if (level == 0) {
+		int end = types.length - 1;
+		System.arraycopy (types, index + 1, types, index, end - index);
+		System.arraycopy (listeners, index + 1, listeners, index, end - index);
+		index = end;
+	} else {
+		if (level > 0) level = -level;
+	}
+	types [index] = 0;
+	listeners [index] = null;
+}
+
+public void unhook (int eventType, Listener listener) {
+	if (types == null) return;
+	for (int i=0; i<types.length; i++) {
+		if (types [i] == eventType && listeners [i] == listener) {
+			remove (i);
+			return;
+		}
+	}
+}
+
+public void unhook (int eventType, SWTEventListener listener) {
+	if (types == null) return;
+	for (int i=0; i<types.length; i++) {
+		if (types [i] == eventType) {
+			if (listeners [i] instanceof TypedListener) {
+				TypedListener typedListener = (TypedListener) listeners [i];
+				if (typedListener.getEventListener () == listener) {
+					remove (i);
+					return;
+				}
+			}
+		}
+	}
+}
+
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/ExpandBar.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/ExpandBar.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/ExpandBar.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,710 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.widgets;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.gtk.*;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
+
+/**
+ * Instances of this class support the layout of selectable
+ * expand bar items.
+ * <p>
+ * The item children that may be added to instances of this class
+ * must be of type <code>ExpandItem</code>.
+ * </p><p>
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>V_SCROLL</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Expand, Collapse</dd>
+ * </dl>
+ * </p><p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ * 
+ * @see ExpandItem
+ * @see ExpandEvent
+ * @see ExpandListener
+ * @see ExpandAdapter
+ * @see <a href="http://www.eclipse.org/swt/snippets/#expandbar">ExpandBar snippets</a>
+ * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: ControlExample</a>
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ * 
+ * @since 3.2
+ */
+public class ExpandBar extends Composite {
+	ExpandItem [] items;
+	ExpandItem lastFocus;
+	int itemCount;
+	int spacing;
+	int yCurrentScroll;
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public ExpandBar (Composite parent, int style) {
+	super (parent, style);
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when an item in the receiver is expanded or collapsed
+ * by sending it one of the messages defined in the <code>ExpandListener</code>
+ * interface.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see ExpandListener
+ * @see #removeExpandListener
+ */
+public void addExpandListener (ExpandListener listener) {
+	checkWidget ();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	TypedListener typedListener = new TypedListener (listener);
+	addListener (SWT.Expand, typedListener);
+	addListener (SWT.Collapse, typedListener);
+}
+
+protected void checkSubclass () {
+	if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
+}
+
+public Point computeSize (int wHint, int hHint, boolean changed) {
+	if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
+		if (wHint != SWT.DEFAULT && wHint < 0) wHint = 0;
+		if (hHint != SWT.DEFAULT && hHint < 0) hHint = 0;
+		Point size = computeNativeSize (handle, wHint, hHint, changed);
+		int border = OS.gtk_container_get_border_width (handle);
+		size.x += 2 * border;
+		size.y += 2 * border;
+		return size;
+	} else {
+		int height = 0, width = 0;
+		if (wHint == SWT.DEFAULT || hHint == SWT.DEFAULT) {
+			if (itemCount > 0) {
+				height += spacing;
+				GC gc = new GC (this);
+				for (int i = 0; i < itemCount; i++) {
+					ExpandItem item = items [i];
+					height += item.getHeaderHeight ();
+					if (item.expanded) height += item.height;
+					height += spacing;
+					width = Math.max (width, item.getPreferredWidth (gc));
+				}
+				gc.dispose ();
+			}
+		}
+		if (width == 0) width = DEFAULT_WIDTH;
+		if (height == 0) height = DEFAULT_HEIGHT;
+		if (wHint != SWT.DEFAULT) width = wHint;
+		if (hHint != SWT.DEFAULT) height = hHint;
+		return new Point (width, height);	
+	} 
+}
+
+void createHandle (int index) {
+	state |= HANDLE;
+	if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
+		fixedHandle = OS.g_object_new (display.gtk_fixed_get_type (), 0);
+		if (fixedHandle == 0) error (SWT.ERROR_NO_HANDLES);
+		OS.gtk_fixed_set_has_window (fixedHandle, true);
+		handle = OS.gtk_vbox_new (false, 0);
+		if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+		if ((style & SWT.V_SCROLL) != 0) {
+			scrolledHandle = OS.gtk_scrolled_window_new (0, 0);
+			if (scrolledHandle == 0) error (SWT.ERROR_NO_HANDLES);
+			int vsp = (style & SWT.V_SCROLL) != 0 ? OS.GTK_POLICY_AUTOMATIC : OS.GTK_POLICY_NEVER;
+			OS.gtk_scrolled_window_set_policy (scrolledHandle, OS.GTK_POLICY_NEVER, vsp);
+			OS.gtk_container_add (fixedHandle, scrolledHandle);
+			OS.gtk_scrolled_window_add_with_viewport (scrolledHandle, handle);
+		} else {
+			OS.gtk_container_add (fixedHandle, handle);
+		}
+		OS.gtk_container_set_border_width (handle, 0);
+	} else {
+		int /*long*/ topHandle = OS.g_object_new (display.gtk_fixed_get_type (), 0);
+		if (topHandle == 0) error (SWT.ERROR_NO_HANDLES);
+		OS.gtk_fixed_set_has_window (topHandle, true);
+		if ((style & SWT.V_SCROLL) != 0) {
+			fixedHandle = topHandle;
+			scrolledHandle = OS.gtk_scrolled_window_new (0, 0);
+			if (scrolledHandle == 0) error (SWT.ERROR_NO_HANDLES);
+			handle = OS.g_object_new (display.gtk_fixed_get_type (), 0);
+			if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+			OS.gtk_fixed_set_has_window (handle, true);
+			OS.gtk_container_add (fixedHandle, scrolledHandle);
+				
+			/*
+			* Force the scrolledWindow to have a single child that is
+			* not scrolled automatically.  Calling gtk_container_add()
+			* seems to add the child correctly but cause a warning.
+			*/
+			boolean warnings = display.getWarnings ();
+			display.setWarnings (false);
+			OS.gtk_container_add (scrolledHandle, handle);
+			display.setWarnings (warnings);
+		} else {
+			handle = topHandle;
+		}
+		OS.GTK_WIDGET_SET_FLAGS (handle, OS.GTK_CAN_FOCUS);
+	}
+}
+
+void createItem (ExpandItem item, int style, int index) {
+	if (!(0 <= index && index <= itemCount)) error (SWT.ERROR_INVALID_RANGE);
+	if (itemCount == items.length) {
+		ExpandItem [] newItems = new ExpandItem [itemCount + 4];
+		System.arraycopy (items, 0, newItems, 0, items.length);
+		items = newItems;
+	}
+	System.arraycopy (items, index, items, index + 1, itemCount - index);
+	items [index] = item;
+	itemCount++;
+	if (OS.GTK_VERSION < OS.VERSION (2, 4, 0)) {
+		if (lastFocus == null) lastFocus = item;
+	}
+	item.width = Math.max (0, getClientArea ().width - spacing * 2);
+	layoutItems (index, true);
+}
+
+void createWidget (int index) {
+	super.createWidget (index);
+	items = new ExpandItem [4];	
+}
+
+void destroyItem (ExpandItem item) {
+	int index = 0;
+	while (index < itemCount) {
+		if (items [index] == item) break;
+		index++;
+	}
+	if (index == itemCount) return;
+	if (OS.GTK_VERSION < OS.VERSION (2, 4, 0)) {
+		if (item == lastFocus) {
+			int focusIndex = index > 0 ? index - 1 : 1;
+			if (focusIndex < itemCount) {
+				lastFocus = items [focusIndex];
+				lastFocus.redraw ();
+			} else {
+				lastFocus = null;
+			}
+		}
+	}
+	System.arraycopy (items, index + 1, items, index, --itemCount - index);
+	items [itemCount] = null;
+	item.redraw ();
+	layoutItems (index, true);
+}
+
+int /*long*/ eventHandle () {
+	return OS.GTK_VERSION >= OS.VERSION (2, 4, 0) ? fixedHandle : handle;
+}
+
+boolean forceFocus (int /*long*/ focusHandle) {
+	if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
+		if (lastFocus != null && lastFocus.setFocus ()) return true;
+		for (int i = 0; i < itemCount; i++) {
+			ExpandItem item = items [i];
+			if (item.setFocus ()) return true;
+		}
+	}
+	return super.forceFocus (focusHandle);
+}
+
+boolean hasFocus () {
+	if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
+		for (int i=0; i<itemCount; i++) {
+			ExpandItem item = items [i];
+			if (item.hasFocus ()) return true;
+		}
+	}
+	return super.hasFocus();
+}
+
+int getBandHeight () {
+	if (font == null) return ExpandItem.CHEVRON_SIZE;
+	GC gc = new GC (this);
+	FontMetrics metrics = gc.getFontMetrics ();
+	gc.dispose ();
+	return Math.max (ExpandItem.CHEVRON_SIZE, metrics.getHeight ());
+}
+
+GdkColor getForegroundColor () {
+	if (OS.GTK_VERSION < OS.VERSION (2, 4, 0)) {
+		if ((state & FOREGROUND) == 0) {
+			return display.getSystemColor (SWT.COLOR_TITLE_FOREGROUND).handle;
+		}
+	}
+	return super.getForegroundColor ();
+}
+
+/**
+ * Returns the item at the given, zero-relative index in the
+ * receiver. Throws an exception if the index is out of range.
+ *
+ * @param index the index of the item to return
+ * @return the item at the given index
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public ExpandItem getItem (int index) {
+	checkWidget();
+	if (!(0 <= index && index < itemCount)) error (SWT.ERROR_INVALID_RANGE);
+	return items [index];
+}
+
+/**
+ * Returns the number of items contained in the receiver.
+ *
+ * @return the number of items
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getItemCount () {
+	checkWidget();
+	return itemCount;
+}
+
+/**
+ * Returns an array of <code>ExpandItem</code>s which are the items
+ * in the receiver. 
+ * <p>
+ * Note: This is not the actual structure used by the receiver
+ * to maintain its list of items, so modifying the array will
+ * not affect the receiver. 
+ * </p>
+ *
+ * @return the items in the receiver
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public ExpandItem [] getItems () {
+	checkWidget ();
+	ExpandItem [] result = new ExpandItem [itemCount];
+	System.arraycopy (items, 0, result, 0, itemCount);
+	return result;
+}
+
+/**
+ * Returns the receiver's spacing.
+ *
+ * @return the spacing
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getSpacing () {
+	checkWidget ();
+	return spacing;
+}
+
+int /*long*/ gtk_button_press_event (int /*long*/ widget, int /*long*/ event) {
+	if (OS.GTK_VERSION < OS.VERSION (2, 4, 0)) {
+		GdkEventButton gdkEvent = new GdkEventButton ();
+		OS.memmove (gdkEvent, event, GdkEventButton.sizeof);
+		int x = (int)gdkEvent.x;
+		int y = (int)gdkEvent.y;
+		for (int i = 0; i < itemCount; i++) {
+			ExpandItem item = items[i];
+			boolean hover = item.x <= x && x < (item.x + item.width) && item.y <= y && y < (item.y + getBandHeight ());
+			if (hover && item != lastFocus) {
+				lastFocus.redraw ();
+				lastFocus = item;
+				lastFocus.redraw ();
+				forceFocus ();
+				break;
+			}
+		}
+	}
+	return super.gtk_button_press_event (widget, event);
+}
+
+int /*long*/ gtk_button_release_event (int /*long*/ widget, int /*long*/ event) {
+	if (OS.GTK_VERSION < OS.VERSION (2, 4, 0)) {
+		if (lastFocus != null) {
+			GdkEventButton gdkEvent = new GdkEventButton ();
+			OS.memmove (gdkEvent, event, GdkEventButton.sizeof);
+			int x = (int)gdkEvent.x;
+			int y = (int)gdkEvent.y;
+			boolean hover = lastFocus.x <= x && x < (lastFocus.x + lastFocus.width) && lastFocus.y <= y && y < (lastFocus.y + getBandHeight ()); 
+			if (hover) {
+				Event ev = new Event ();
+				ev.item = lastFocus;
+				notifyListeners (lastFocus.expanded ? SWT.Collapse : SWT.Expand, ev);
+				lastFocus.expanded = !lastFocus.expanded;
+				showItem (lastFocus);
+			}
+		}
+	}
+	return super.gtk_button_release_event (widget, event);
+}
+
+int /*long*/ gtk_expose_event (int /*long*/ widget, int /*long*/ eventPtr) {
+	if (OS.GTK_VERSION < OS.VERSION (2, 4, 0)) {
+		GdkEventExpose gdkEvent = new GdkEventExpose ();
+		OS.memmove(gdkEvent, eventPtr, GdkEventExpose.sizeof);
+		GCData data = new GCData ();
+		data.damageRgn = gdkEvent.region;
+		GC gc = GC.gtk_new (this, data);
+		OS.gdk_gc_set_clip_region (gc.handle, gdkEvent.region);
+		boolean hasFocus = isFocusControl ();
+		for (int i = 0; i < itemCount; i++) {
+			ExpandItem item = items [i];
+			item.drawItem (gc, hasFocus && item == lastFocus);
+		}
+		gc.dispose ();
+	}
+	return super.gtk_expose_event (widget, eventPtr);
+}
+
+int /*long*/ gtk_focus_in_event (int /*long*/ widget, int /*long*/ event) {
+	if (OS.GTK_VERSION < OS.VERSION (2, 4, 0)) {
+		if (lastFocus != null) lastFocus.redraw ();
+	}
+	return super.gtk_focus_in_event(widget, event);
+}
+
+int /*long*/ gtk_focus_out_event (int /*long*/ widget, int /*long*/ event) {
+	if (OS.GTK_VERSION < OS.VERSION (2, 4, 0)) {
+		if (lastFocus != null) lastFocus.redraw ();
+	}
+	return super.gtk_focus_out_event (widget, event);
+}
+
+int /*long*/ gtk_key_press_event (int /*long*/ widget, int /*long*/ event) {
+	if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
+		if (!hasFocus ()) return 0;
+		int /*long*/ result = super.gtk_key_press_event (widget, event);
+		if (result != 0) return result;
+		int index = 0;
+		while (index < itemCount) {
+			if (items [index].hasFocus ()) break;
+			index++;
+		}
+		GdkEventKey gdkEvent = new GdkEventKey ();
+		OS.memmove (gdkEvent, event, GdkEventKey.sizeof);
+		boolean next = false;
+		switch (gdkEvent.keyval) {
+			case OS.GDK_Up:
+			case OS.GDK_Left: next = false; break;
+			case OS.GDK_Down: 
+			case OS.GDK_Right: next = true; break;
+			default: return result;
+		}
+		int start = index, offset = next ? 1 : -1;
+		while ((index = (index + offset + itemCount) % itemCount) != start) {
+			ExpandItem item = items [index];
+			if (item.setFocus ()) return result;
+		}
+		return result;
+	} else {
+		if (lastFocus != null) {
+			GdkEventKey keyEvent = new GdkEventKey ();
+			OS.memmove (keyEvent, event, GdkEventKey.sizeof);
+			switch (keyEvent.keyval) {
+				case OS.GDK_Return:
+				case OS.GDK_space:
+					Event ev = new Event ();
+					ev.item = lastFocus;
+					sendEvent (lastFocus.expanded ? SWT.Collapse :SWT.Expand, ev);
+					lastFocus.expanded = !lastFocus.expanded;
+					showItem (lastFocus);
+					break;
+				case OS.GDK_Up:
+				case OS.GDK_KP_Up: {
+					int focusIndex = indexOf (lastFocus);
+					if (focusIndex > 0) {
+						lastFocus.redraw ();
+						lastFocus = items [focusIndex - 1];
+						lastFocus.redraw ();
+					}
+					break;
+				}
+				case OS.GDK_Down:
+				case OS.GDK_KP_Down: {
+					int focusIndex = indexOf (lastFocus);
+					if (focusIndex < itemCount - 1) {
+						lastFocus.redraw ();
+						lastFocus = items [focusIndex + 1];
+						lastFocus.redraw ();
+					}
+					break;
+				}
+			}
+		}
+	}
+	return super.gtk_key_press_event (widget, event);
+}
+
+/**
+ * Searches the receiver's list starting at the first item
+ * (index 0) until an item is found that is equal to the 
+ * argument, and returns the index of that item. If no item
+ * is found, returns -1.
+ *
+ * @param item the search item
+ * @return the index of the item
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the item is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the item has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int indexOf (ExpandItem item) {
+	checkWidget();
+	if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
+	for (int i = 0; i < itemCount; i++) {
+		if (items [i] == item) return i;
+	}
+	return -1;
+}
+
+void layoutItems (int index, boolean setScrollbar) {
+	if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
+		for (int i = 0; i < itemCount; i++) {
+			ExpandItem item = items [i];
+			if (item != null) item.resizeControl (yCurrentScroll);
+		}
+	} else {
+		if (index < itemCount) {
+			int y = spacing - yCurrentScroll;
+			for (int i = 0; i < index; i++) {
+				ExpandItem item = items [i];
+				if (item.expanded) y += item.height;
+				y += item.getHeaderHeight() + spacing;
+			}
+			for (int i = index; i < itemCount; i++) {
+				ExpandItem item = items [i];
+				item.setBounds (spacing, y, 0, 0, true, false);
+				if (item.expanded) y += item.height;
+				y += item.getHeaderHeight() + spacing;
+			}
+		}
+		if (setScrollbar) setScrollbar ();
+	}
+}
+
+int /*long*/ parentingHandle () {
+	return OS.GTK_VERSION >= OS.VERSION (2, 4, 0) ? fixedHandle : handle;
+}
+
+void releaseChildren (boolean destroy) {
+	for (int i = 0; i < itemCount; i++) {
+		ExpandItem item = items [i];
+		if (item != null && !item.isDisposed ()) {
+			item.release (false);
+		}
+	}
+	super.releaseChildren (destroy);
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when items in the receiver are expanded or collapsed.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see ExpandListener
+ * @see #addExpandListener
+ */
+public void removeExpandListener (ExpandListener listener) {
+	checkWidget ();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if (eventTable == null) return;
+	eventTable.unhook (SWT.Expand, listener);
+	eventTable.unhook (SWT.Collapse, listener);
+}
+
+int setBounds (int x, int y, int width, int height, boolean move, boolean resize) {
+	int result = super.setBounds (x, y, width, height, move, resize);
+	if (OS.GTK_VERSION < OS.VERSION (2, 4, 0)) {
+		if (resize) {
+			if ((style & SWT.V_SCROLL) != 0) {
+				setScrollbar ();
+			} else {
+				for (int i = 0; i < itemCount; i++) {
+					ExpandItem item = items [i];
+					int newWidth = Math.max (0, getClientArea ().width - spacing * 2);
+					if (item.width != newWidth) {
+						item.setBounds (0, 0, newWidth, item.height, false, true);
+					}
+				}
+			}
+		}
+	}
+	return result;
+}
+
+void setFontDescription (int /*long*/ font) {
+	super.setFontDescription (font);
+	if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
+		for (int i = 0; i < itemCount; i++) {
+			items[i].setFontDescription (font);
+		}
+		layoutItems (0, true);
+	}
+}
+
+void setForegroundColor (GdkColor color) {
+	super.setForegroundColor (color);
+	if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
+		for (int i = 0; i < itemCount; i++) {
+			items[i].setForegroundColor (color);
+		}
+	}
+}
+
+void setScrollbar () {
+	if (itemCount == 0) return;
+	if ((style & SWT.V_SCROLL) == 0) return;
+	int height = getClientArea ().height;
+	ExpandItem item = items [itemCount - 1];
+	int maxHeight = item.y + getBandHeight () + spacing;
+	if (item.expanded) maxHeight += item.height;
+	int /*long*/ adjustmentHandle = OS.gtk_scrolled_window_get_vadjustment (scrolledHandle);
+	GtkAdjustment adjustment = new GtkAdjustment ();
+	OS.memmove (adjustment, adjustmentHandle);
+	yCurrentScroll = (int)adjustment.value;
+
+	//claim bottom free space
+	if (yCurrentScroll > 0 && height > maxHeight) {
+		yCurrentScroll = Math.max (0, yCurrentScroll + maxHeight - height);
+		layoutItems (0, false);
+	}
+	maxHeight += yCurrentScroll;	
+	adjustment.value = Math.min (yCurrentScroll, maxHeight);
+	adjustment.upper = maxHeight;
+	adjustment.page_size = height;
+	OS.memmove (adjustmentHandle, adjustment);
+	OS.gtk_adjustment_changed (adjustmentHandle);
+	int policy = maxHeight > height ? OS.GTK_POLICY_ALWAYS : OS.GTK_POLICY_NEVER;
+	OS.gtk_scrolled_window_set_policy (scrolledHandle, OS.GTK_POLICY_NEVER, policy);
+	int width = OS.GTK_WIDGET_WIDTH (fixedHandle) - spacing * 2;
+	if (policy == OS.GTK_POLICY_ALWAYS) {
+		int /*long*/ vHandle = OS.GTK_SCROLLED_WINDOW_VSCROLLBAR (scrolledHandle);
+		GtkRequisition requisition = new GtkRequisition ();
+		OS.gtk_widget_size_request (vHandle, requisition);
+		width -= requisition.width;
+	}
+	width = Math.max (0,  width);
+	for (int i = 0; i < itemCount; i++) {
+		ExpandItem item2 = items[i];
+		item2.setBounds (0, 0, width, item2.height, false, true);
+	}
+}
+
+/**
+ * Sets the receiver's spacing. Spacing specifies the number of pixels allocated around 
+ * each item.
+ * 
+ * @param spacing the spacing around each item
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setSpacing (int spacing) {
+	checkWidget ();
+	if (spacing < 0) return;
+	if (spacing == this.spacing) return;
+	this.spacing = spacing;
+	if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
+		OS.gtk_box_set_spacing (handle, spacing);
+		OS.gtk_container_set_border_width (handle, spacing);
+	} else {
+		if ((style & SWT.V_SCROLL) == 0) {
+			int width = Math.max (0, getClientArea ().width - spacing * 2);
+			for (int i = 0; i < itemCount; i++) {
+				ExpandItem item = items [i];
+				if (item.width != width) item.setBounds (0, 0, width, item.height, false, true);
+			}
+		}
+		layoutItems (0, true);
+		redraw ();
+	}
+}
+
+void showItem (ExpandItem item) {
+	Control control = item.control;
+	if (control != null && !control.isDisposed ()) {
+		control.setVisible (item.expanded);
+	}
+	item.redraw ();
+	int index = indexOf (item);
+	layoutItems (index + 1, true);
+}
+
+void updateScrollBarValue (ScrollBar bar) {
+	yCurrentScroll = bar.getSelection();
+	layoutItems (0, false);
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/ExpandItem.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/ExpandItem.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/ExpandItem.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,615 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.widgets;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.gtk.*;
+import org.eclipse.swt.graphics.*;
+
+/**
+ * Instances of this class represent a selectable user interface object
+ * that represents a expandable item in a expand bar.
+ * <p>
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>(none)</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>(none)</dd>
+ * </dl>
+ * </p><p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ * 
+ * @see ExpandBar
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ * 
+ * @since 3.2
+ */
+public class ExpandItem extends Item {
+	ExpandBar parent;
+	Control control;
+	ImageList imageList;
+	int /*long*/ clientHandle, boxHandle, labelHandle, imageHandle;
+	boolean expanded;
+	int x, y, width, height;
+	int imageHeight, imageWidth;
+	static final int TEXT_INSET = 6;
+	static final int BORDER = 1;
+	static final int CHEVRON_SIZE = 24;
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public ExpandItem (ExpandBar parent, int style) {
+	super (parent, style);
+	this.parent = parent;
+	createWidget (parent.getItemCount ());
+}
+
+/**
+ * Constructs a new instance of this class given its parent, a
+ * style value describing its behavior and appearance, and the index
+ * at which to place it in the items maintained by its parent.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ * @param index the zero-relative index to store the receiver in its parent
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the parent (inclusive)</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public ExpandItem (ExpandBar parent, int style, int index) {
+	super (parent, style);
+	this.parent = parent;
+	createWidget (index);
+}
+
+protected void checkSubclass () {
+	if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
+}
+
+void createHandle (int index) {
+	if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
+		state |= HANDLE;
+		handle = OS.gtk_expander_new (null);
+		if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+		clientHandle = OS.g_object_new (display.gtk_fixed_get_type (), 0);
+		if (clientHandle == 0) error (SWT.ERROR_NO_HANDLES);
+		OS.gtk_container_add (handle, clientHandle);	
+		boxHandle = OS.gtk_hbox_new (false, 4);
+		if (boxHandle == 0) error (SWT.ERROR_NO_HANDLES);
+		labelHandle = OS.gtk_label_new (null);
+		if (labelHandle == 0) error (SWT.ERROR_NO_HANDLES);
+		imageHandle = OS.gtk_image_new ();
+		if (imageHandle == 0) error (SWT.ERROR_NO_HANDLES);
+		OS.gtk_container_add (boxHandle, imageHandle);
+		OS.gtk_container_add (boxHandle, labelHandle);
+		OS.gtk_expander_set_label_widget (handle, boxHandle);
+		OS.GTK_WIDGET_SET_FLAGS (handle, OS.GTK_CAN_FOCUS);
+	}
+}
+
+void createWidget (int index) {
+	super.createWidget (index);
+	showWidget (index);
+	parent.createItem (this, style, index);
+}
+
+void deregister() {
+	super.deregister();
+	if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
+		display.removeWidget (clientHandle);
+		display.removeWidget (boxHandle);
+		display.removeWidget (labelHandle);
+		display.removeWidget (imageHandle);
+	}
+}
+
+void destroyWidget () {
+	parent.destroyItem (this);
+	super.destroyWidget ();
+}
+
+void drawChevron (GC gc, int x, int y) {
+	int [] polyline1, polyline2;
+	if (expanded) {
+		int px = x + 4 + 5;
+		int py = y + 4 + 7;
+		polyline1 = new int [] {
+				px,py, px+1,py, px+1,py-1, px+2,py-1, px+2,py-2, px+3,py-2, px+3,py-3,
+				px+3,py-2, px+4,py-2, px+4,py-1, px+5,py-1, px+5,py, px+6,py};
+		py += 4;
+		polyline2 = new int [] {
+				px,py, px+1,py, px+1,py-1, px+2,py-1, px+2,py-2, px+3,py-2, px+3,py-3,
+				px+3,py-2, px+4,py-2, px+4,py-1,  px+5,py-1, px+5,py, px+6,py};
+	} else {
+		int px = x + 4 + 5;
+		int py = y + 4 + 4;
+		polyline1 = new int[] {
+				px,py, px+1,py, px+1,py+1, px+2,py+1, px+2,py+2, px+3,py+2, px+3,py+3,
+				px+3,py+2, px+4,py+2, px+4,py+1,  px+5,py+1, px+5,py, px+6,py};
+		py += 4;
+		polyline2 = new int [] {
+				px,py, px+1,py, px+1,py+1, px+2,py+1, px+2,py+2, px+3,py+2, px+3,py+3,
+				px+3,py+2, px+4,py+2, px+4,py+1,  px+5,py+1, px+5,py, px+6,py};
+	}
+	gc.setForeground (display.getSystemColor (SWT.COLOR_TITLE_FOREGROUND));
+	gc.drawPolyline (polyline1);
+	gc.drawPolyline (polyline2);
+}
+
+void drawItem (GC gc, boolean drawFocus) {
+	int headerHeight = parent.getBandHeight ();
+	Display display = getDisplay ();
+	gc.setForeground (display.getSystemColor (SWT.COLOR_TITLE_BACKGROUND));
+	gc.setBackground (display.getSystemColor (SWT.COLOR_TITLE_BACKGROUND_GRADIENT));
+	gc.fillGradientRectangle (x, y, width, headerHeight, true);
+	if (expanded) {
+		gc.setForeground (display.getSystemColor (SWT.COLOR_TITLE_BACKGROUND_GRADIENT));
+		gc.drawLine (x, y + headerHeight, x, y + headerHeight + height - 1);
+		gc.drawLine (x, y + headerHeight + height - 1, x + width - 1, y + headerHeight + height - 1);
+		gc.drawLine (x + width - 1, y + headerHeight + height - 1, x + width - 1, y + headerHeight);
+	}
+	int drawX = x;
+	if (image != null) {
+		drawX += ExpandItem.TEXT_INSET;
+		if (imageHeight > headerHeight) {
+			gc.drawImage (image, drawX, y + headerHeight - imageHeight);
+		} else {
+			gc.drawImage (image, drawX, y + (headerHeight - imageHeight) / 2);
+		}
+		drawX += imageWidth;
+	}
+	if (text.length() > 0) {
+		drawX += ExpandItem.TEXT_INSET;
+		Point size = gc.stringExtent (text);
+		gc.setForeground (parent.getForeground ());
+		gc.drawString (text, drawX, y + (headerHeight - size.y) / 2, true);
+	}
+	int chevronSize = ExpandItem.CHEVRON_SIZE;
+	drawChevron (gc, x + width - chevronSize, y + (headerHeight - chevronSize) / 2);
+	if (drawFocus) {
+		gc.drawFocus (x + 1, y + 1, width - 2, headerHeight - 2);
+	}
+}
+
+/**
+ * Returns the control that is shown when the item is expanded.
+ * If no control has been set, return <code>null</code>.
+ *
+ * @return the control
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Control getControl () {
+	checkWidget ();
+	return control;
+}
+
+/**
+ * Returns <code>true</code> if the receiver is expanded,
+ * and false otherwise.
+ *
+ * @return the expanded state
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public boolean getExpanded () {
+	checkWidget ();
+	return expanded;
+}
+
+/**
+ * Returns the height of the receiver's header 
+ *
+ * @return the height of the header 
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getHeaderHeight () {
+	checkWidget ();
+	if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
+		return OS.GTK_WIDGET_HEIGHT (handle) - (expanded ? height : 0);
+	}
+	return Math.max (parent.getBandHeight (), imageHeight);
+}
+
+/**
+ * Gets the height of the receiver.
+ *
+ * @return the height
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getHeight () {
+	checkWidget ();
+	return height;
+}
+
+/**
+ * Returns the receiver's parent, which must be a <code>ExpandBar</code>.
+ *
+ * @return the receiver's parent
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public ExpandBar getParent () {
+	checkWidget();
+	return parent;
+}
+
+int getPreferredWidth (GC gc) {
+	int width = ExpandItem.TEXT_INSET * 2 + ExpandItem.CHEVRON_SIZE;
+	if (image != null) {
+		width += ExpandItem.TEXT_INSET + imageWidth;
+	}
+	if (text.length() > 0) {
+		width += gc.stringExtent (text).x;
+	}
+	return width;
+}
+
+int /*long*/ gtk_activate (int /*long*/ widget) {
+	Event event = new Event ();
+	event.item = this;
+	int type = OS.gtk_expander_get_expanded (handle) ? SWT.Collapse : SWT.Expand;
+	parent.sendEvent (type, event);
+	return 0;
+}
+
+int /*long*/ gtk_button_press_event (int /*long*/ widget, int /*long*/ event) {
+	setFocus ();
+	return 0;
+}
+
+int /*long*/ gtk_focus_out_event (int /*long*/ widget, int /*long*/ event) {
+	OS.GTK_WIDGET_UNSET_FLAGS (handle, OS.GTK_CAN_FOCUS);
+	parent.lastFocus = this;
+	return 0;
+}
+
+int /*long*/ gtk_size_allocate (int /*long*/ widget, int /*long*/ allocation) {
+	parent.layoutItems (0, false);
+	return 0;
+}
+
+int /*long*/ gtk_enter_notify_event (int /*long*/ widget, int /*long*/ event) {
+	parent.gtk_enter_notify_event(widget, event);
+	return 0;
+}
+
+boolean hasFocus () {
+	return OS.GTK_WIDGET_HAS_FOCUS (handle);
+}
+
+void hookEvents () {
+	super.hookEvents ();
+	if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
+		OS.g_signal_connect_closure (handle, OS.activate, display.closures [ACTIVATE], false);
+		OS.g_signal_connect_closure (handle, OS.activate, display.closures [ACTIVATE_INVERSE], true);
+		OS.g_signal_connect_closure_by_id (handle, display.signalIds [BUTTON_PRESS_EVENT], 0, display.closures [BUTTON_PRESS_EVENT], false);
+		OS.g_signal_connect_closure_by_id (handle, display.signalIds [FOCUS_OUT_EVENT], 0, display.closures [FOCUS_OUT_EVENT], false);
+		OS.g_signal_connect_closure (clientHandle, OS.size_allocate, display.closures [SIZE_ALLOCATE], true);
+		OS.g_signal_connect_closure_by_id (handle, display.signalIds [ENTER_NOTIFY_EVENT], 0, display.closures [ENTER_NOTIFY_EVENT], false);
+	}
+}
+
+void redraw () {
+	if (OS.GTK_VERSION < OS.VERSION (2, 4, 0)) {
+		int headerHeight = parent.getBandHeight ();
+		if (imageHeight > headerHeight) {
+			parent.redraw (x + ExpandItem.TEXT_INSET, y + headerHeight - imageHeight, imageWidth, imageHeight, false);
+		}
+		parent.redraw (x, y, width, headerHeight + height, false);
+	}
+}
+
+void register () {
+	super.register ();
+	if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
+		display.addWidget (clientHandle, this);
+		display.addWidget (boxHandle, this);
+		display.addWidget (labelHandle, this);
+		display.addWidget (imageHandle, this);
+	}
+}
+
+void releaseHandle () {
+	super.releaseHandle ();
+	clientHandle = boxHandle = labelHandle = imageHandle = 0;
+	parent = null;
+}
+
+void releaseWidget () {
+	super.releaseWidget ();
+	if (imageList != null) imageList.dispose ();
+	if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
+		if (parent.lastFocus == this) parent.lastFocus = null;
+	}
+	imageList = null;
+	control = null;
+}
+
+void resizeControl (int yScroll) {
+	if (control != null && !control.isDisposed ()) {
+		boolean visible = OS.gtk_expander_get_expanded (handle);
+		if (visible) {
+			int x = OS.GTK_WIDGET_X (clientHandle);
+			int y = OS.GTK_WIDGET_Y (clientHandle);
+			if (x != -1 && y != -1) {
+				int width = OS.GTK_WIDGET_WIDTH (clientHandle);
+				int height = OS.GTK_WIDGET_HEIGHT (clientHandle);
+				int [] property = new int [1];
+				OS.gtk_widget_style_get (handle, OS.focus_line_width, property, 0);				
+				y += property [0] * 2;
+				height -= property [0] * 2;
+				control.setBounds (x, y - yScroll, width, Math.max (0, height), true, true);
+			}
+		}
+		control.setVisible (visible);
+	}
+}
+
+void setBounds (int x, int y, int width, int height, boolean move, boolean size) {
+	redraw ();
+	int headerHeight = parent.getBandHeight ();
+	if (move) {
+		if (imageHeight > headerHeight) {
+			y += (imageHeight - headerHeight);
+		}
+		this.x = x;
+		this.y = y;
+		redraw ();
+	}
+	if (size) {
+		this.width = width;
+		this.height = height;
+		redraw ();
+	}
+	if (control != null && !control.isDisposed ()) {
+		if (move) control.setLocation (x + BORDER, y + headerHeight);
+		if (size) control.setSize (Math.max (0, width - 2 * BORDER), Math.max (0, height - BORDER));
+	}
+}
+
+/**
+ * Sets the control that is shown when the item is expanded.
+ *
+ * @param control the new control (or null)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the control has been disposed</li> 
+ *    <li>ERROR_INVALID_PARENT - if the control is not in the same widget tree</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setControl (Control control) {
+	checkWidget ();
+	if (control != null) {
+		if (control.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT);
+		if (control.parent != parent) error (SWT.ERROR_INVALID_PARENT);
+	}
+	if (this.control == control) return;
+	this.control = control;
+	if (control != null) {
+		control.setVisible (expanded);
+		if (OS.GTK_VERSION < OS.VERSION (2, 4, 0)) {
+			int headerHeight = parent.getBandHeight ();
+			control.setBounds (x + BORDER, y + headerHeight, Math.max (0, width - 2 * BORDER), Math.max (0, height - BORDER));
+		}
+	}
+	if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
+		parent.layoutItems (0, true);
+	}
+}
+
+/**
+ * Sets the expanded state of the receiver.
+ *
+ * @param expanded the new expanded state
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setExpanded (boolean expanded) {
+	checkWidget ();
+	this.expanded = expanded;
+	if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
+		OS.gtk_expander_set_expanded (handle, expanded);
+		parent.layoutItems (0, true);
+	} else {
+		parent.showItem (this);
+	}
+}
+
+boolean setFocus () {
+	if (!OS.gtk_widget_get_child_visible (handle)) return false;
+	OS.GTK_WIDGET_SET_FLAGS (handle, OS.GTK_CAN_FOCUS);
+	OS.gtk_widget_grab_focus (handle);
+	boolean result = OS.gtk_widget_is_focus (handle);
+	if (!result) OS.GTK_WIDGET_UNSET_FLAGS (handle, OS.GTK_CAN_FOCUS);
+	return result;
+}
+
+void setFontDescription (int /*long*/ font) {
+	OS.gtk_widget_modify_font (handle, font);
+	if (labelHandle != 0) OS.gtk_widget_modify_font (labelHandle, font);
+	if (imageHandle != 0) OS.gtk_widget_modify_font (imageHandle, font);
+}
+
+void setForegroundColor (GdkColor color) {
+	setForegroundColor (handle, color);
+	if (labelHandle != 0) setForegroundColor (labelHandle, color);
+	if (imageHandle != 0) setForegroundColor (imageHandle, color);
+}
+
+/**
+ * Sets the height of the receiver. This is height of the item when it is expanded, 
+ * excluding the height of the header.
+ *
+ * @param height the new height
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setHeight (int height) {
+	checkWidget ();
+	if (height < 0) return;
+	if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
+		this.height = height;
+		OS.gtk_widget_set_size_request (clientHandle, -1, height);
+		parent.layoutItems (0, false);
+	} else {
+		setBounds (0, 0, width, height, false, true);
+		if (expanded) parent.layoutItems (parent.indexOf (this) + 1, true);
+	}
+}
+
+public void setImage (Image image) {
+	super.setImage (image);
+	if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
+		if (imageList != null) imageList.dispose ();
+		imageList = null;
+		if (image != null) {
+			if (image.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT);
+			imageList = new ImageList ();
+			int imageIndex = imageList.add (image);
+			int /*long*/ pixbuf = imageList.getPixbuf (imageIndex);
+			OS.gtk_image_set_from_pixbuf (imageHandle, pixbuf);
+			if (text.length () == 0) OS.gtk_widget_hide (labelHandle);
+			OS.gtk_widget_show (imageHandle);
+		} else {
+			OS.gtk_image_set_from_pixbuf (imageHandle, 0);
+			OS.gtk_widget_show (labelHandle);
+			OS.gtk_widget_hide (imageHandle);
+		}
+	} else {
+		int oldImageHeight = imageHeight;
+		if (image != null) {
+			Rectangle bounds = image.getBounds ();
+			imageHeight = bounds.height;
+			imageWidth = bounds.width;
+		} else {
+			imageHeight = imageWidth = 0;
+		}
+		if (oldImageHeight != imageHeight) {
+			parent.layoutItems (parent.indexOf (this), true);
+		} else {
+			redraw ();
+		}
+	}
+}
+
+void setOrientation() {
+	super.setOrientation ();
+	if ((parent.style & SWT.RIGHT_TO_LEFT) != 0) {
+		OS.gtk_widget_set_direction (handle, OS.GTK_TEXT_DIR_RTL);
+		OS.gtk_container_forall (handle, display.setDirectionProc, OS.GTK_TEXT_DIR_RTL);	
+	}
+}
+	
+public void setText (String string) {
+	super.setText (string);
+	if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
+		byte [] buffer = Converter.wcsToMbcs (null, string, true);
+		OS.gtk_label_set_text (labelHandle, buffer);
+	} else {
+		redraw ();
+	}
+}
+
+void showWidget (int index) {
+	if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
+		OS.gtk_widget_show (handle);
+		OS.gtk_widget_show (clientHandle);
+		OS.gtk_container_add (parent.handle, handle);
+		OS.gtk_box_set_child_packing (parent.handle, handle, false, false, 0, OS.GTK_PACK_START);
+		if (boxHandle != 0) OS.gtk_widget_show (boxHandle);
+		if (labelHandle != 0) OS.gtk_widget_show (labelHandle);
+	}
+}
+
+int /*long*/ windowProc (int /*long*/ handle, int /*long*/ user_data) {
+	switch ((int)/*64*/user_data) {
+		case ACTIVATE_INVERSE: {
+			expanded = OS.gtk_expander_get_expanded (handle);
+			parent.layoutItems (0, false);
+			return 0;
+		}
+	}
+	return super.windowProc (handle, user_data);
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/FileDialog.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/FileDialog.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/FileDialog.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,700 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.widgets;
+
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.gtk.*;
+
+/**
+ * Instances of this class allow the user to navigate
+ * the file system and select or enter a file name.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>SAVE, OPEN, MULTI</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>(none)</dd>
+ * </dl>
+ * <p>
+ * Note: Only one of the styles SAVE and OPEN may be specified.
+ * </p><p>
+ * IMPORTANT: This class is intended to be subclassed <em>only</em>
+ * within the SWT implementation.
+ * </p>
+ * 
+ * @see <a href="http://www.eclipse.org/swt/snippets/#filedialog">FileDialog snippets</a>
+ * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: ControlExample, Dialog tab</a>
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public class FileDialog extends Dialog {
+	String [] filterNames = new String [0];
+	String [] filterExtensions = new String [0];
+	String filterPath = "";
+	String fileName = "";
+	String[] fileNames = new String [0];
+	String fullPath = "";
+	int filterIndex = -1;
+	boolean overwrite = false;
+	int /*long*/ handle;
+	static final char SEPARATOR = System.getProperty ("file.separator").charAt (0);
+	static final char EXTENSION_SEPARATOR = ';';
+	
+/**
+ * Constructs a new instance of this class given only its parent.
+ *
+ * @param parent a shell which will be the parent of the new instance
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ */
+public FileDialog (Shell parent) {
+	this (parent, SWT.APPLICATION_MODAL);
+}
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a shell which will be the parent of the new instance
+ * @param style the style of dialog to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ */
+public FileDialog (Shell parent, int style) {
+	super (parent, checkStyle (parent, style));
+	checkSubclass ();
+}
+String computeResultChooserDialog () {
+	/* MULTI is only valid if the native dialog's action is Open */
+	fullPath = null;
+	if ((style & (SWT.SAVE | SWT.MULTI)) == SWT.MULTI) {
+		int /*long*/ list = OS.gtk_file_chooser_get_filenames (handle);
+		int listLength = OS.g_slist_length (list);
+		fileNames = new String [listLength];
+		int /*long*/ current = list;
+		int writePos = 0;
+		for (int i = 0; i < listLength; i++) {
+			int /*long*/ name = OS.g_slist_data (current);
+			int /*long*/ utf8Ptr = OS.g_filename_to_utf8 (name, -1, null, null, null);
+			OS.g_free (name);
+			if (utf8Ptr != 0) {
+				int /*long*/ [] items_written = new int /*long*/ [1];
+				int /*long*/ utf16Ptr = OS.g_utf8_to_utf16 (utf8Ptr, -1, null, items_written, null);
+				OS.g_free (utf8Ptr);
+				if (utf16Ptr != 0) {
+					int clength = (int)/*64*/items_written [0];
+					char [] chars = new char [clength];
+					OS.memmove (chars, utf16Ptr, clength * 2);
+					OS.g_free (utf16Ptr);
+					fullPath = new String (chars);
+					fileNames [writePos++] = fullPath.substring (fullPath.lastIndexOf (SEPARATOR) + 1);
+				}
+			}
+			current = OS.g_slist_next (current);
+		}
+		if (writePos != 0 && writePos != listLength) {
+			String [] validFileNames = new String [writePos];
+			System.arraycopy (fileNames, 0, validFileNames, 0, writePos);
+			fileNames = validFileNames;
+		}
+		OS.g_slist_free (list);
+	} else {
+		int /*long*/ path = OS.gtk_file_chooser_get_filename (handle);
+		if (path != 0) {
+			int /*long*/ utf8Ptr = OS.g_filename_to_utf8 (path, -1, null, null, null);
+			OS.g_free (path);
+			if (utf8Ptr != 0) {
+				int /*long*/ [] items_written = new int /*long*/ [1];
+				int /*long*/ utf16Ptr = OS.g_utf8_to_utf16 (utf8Ptr, -1, null, items_written, null);
+				OS.g_free (utf8Ptr);
+				if (utf16Ptr != 0) {
+					int clength = (int)/*64*/items_written [0];
+					char [] chars = new char [clength];
+					OS.memmove (chars, utf16Ptr, clength * 2);
+					OS.g_free (utf16Ptr);
+					fullPath = new String (chars);
+					fileNames = new String [1];
+					fileNames[0] = fullPath.substring (fullPath.lastIndexOf (SEPARATOR) + 1);
+				}
+			}
+		}
+	}
+	filterIndex = -1;
+	int /*long*/ filter = OS.gtk_file_chooser_get_filter (handle);
+	if (filter != 0) {
+		int /*long*/ filterNamePtr = OS.gtk_file_filter_get_name (filter);
+		if (filterNamePtr != 0) {
+			int length = OS.strlen (filterNamePtr);
+			byte[] buffer = new byte [length];
+			OS.memmove (buffer, filterNamePtr, length);
+			//OS.g_free (filterNamePtr); //GTK owns this pointer - do not free
+			String filterName = new String (Converter.mbcsToWcs (null, buffer));
+			for (int i = 0; i < filterExtensions.length; i++) {
+				if (filterNames.length > 0) {
+					if (filterNames[i].equals(filterName)) {
+						filterIndex = i;
+						break;
+					}
+				} else {
+					if (filterExtensions[i].equals(filterName)) {
+						filterIndex = i;
+						break;
+					}
+				}
+			}
+		}
+	}
+	if (fullPath != null) {
+		int separatorIndex = fullPath.lastIndexOf (SEPARATOR);
+		fileName = fullPath.substring (separatorIndex + 1);
+		filterPath = fullPath.substring (0, separatorIndex);
+	}
+	return fullPath;
+}
+String computeResultClassicDialog () {
+	filterIndex = -1;
+	GtkFileSelection selection = new GtkFileSelection ();
+	OS.memmove (selection, handle);
+	int /*long*/ entry = selection.selection_entry;
+	int /*long*/ entryText = OS.gtk_entry_get_text (entry);
+	int entryLength = OS.strlen (entryText);
+	if (entryLength == 0) {
+		int /*long*/ fileList = selection.file_list;
+		int /*long*/ listSelection = OS.gtk_tree_view_get_selection (fileList);
+		int /*long*/[] model = new int /*long*/[1];
+		int /*long*/ selectedList = OS.gtk_tree_selection_get_selected_rows (listSelection, model);
+		if (selectedList == 0) return null;
+		int listLength = OS.g_list_length (selectedList);
+		if (listLength == 0) {
+			OS.g_list_free (selectedList);
+			return null;
+		}
+		int /*long*/ path = OS.g_list_nth_data (selectedList, 0);
+		int /*long*/ [] ptr = new int /*long*/[1];
+		int /*long*/ iter = OS.g_malloc (OS.GtkTreeIter_sizeof ());
+		if (OS.gtk_tree_model_get_iter (model [0], iter, path)) {
+			OS.gtk_tree_model_get (model [0], iter, 0, ptr, -1);
+		}
+		OS.g_free (iter);
+		for (int i = 0; i < listLength; i++) {
+			OS.gtk_tree_path_free (OS.g_list_nth_data (selectedList, i));
+		}
+		OS.g_list_free (selectedList);
+		if (ptr [0] == 0) return null;
+		int length = OS.strlen (ptr [0]);
+		byte [] buffer = new byte [length];
+		OS.memmove (buffer, ptr [0], length);
+		OS.g_free (ptr [0]);
+		OS.gtk_entry_set_text (entry, buffer);
+	}
+
+	int /*long*/ fileNamePtr = OS.gtk_file_selection_get_filename (handle);
+	int /*long*/ utf8Ptr = OS.g_filename_to_utf8 (fileNamePtr, -1, null, null, null);
+	int /*long*/ [] items_written = new int /*long*/ [1];
+	int /*long*/ utf16Ptr = OS.g_utf8_to_utf16 (utf8Ptr, -1, null, items_written, null);
+	entryLength = (int)/*64*/items_written [0];
+	char [] buffer = new char [entryLength];
+	OS.memmove (buffer, utf16Ptr, entryLength * 2);
+	String osAnswer = new String (buffer);
+	OS.g_free (utf16Ptr);
+	OS.g_free (utf8Ptr);
+
+	if (osAnswer == null) return null;
+	int separatorIndex = osAnswer.lastIndexOf (SEPARATOR);
+	if (separatorIndex+1 == osAnswer.length ()) return null;
+	
+	String answer = fullPath = osAnswer;
+	fileName = fullPath.substring (separatorIndex+1);
+	filterPath = fullPath.substring (0, separatorIndex);
+	if ((style & SWT.MULTI) == 0) {
+		fileNames = new String[] {fileName};
+	} else {
+		int /*long*/ namesPtr = OS.gtk_file_selection_get_selections (handle);
+		int /*long*/ namesPtr1 = namesPtr;
+		int /*long*/ [] namePtr = new int /*long*/ [1];
+		OS.memmove (namePtr, namesPtr1, OS.PTR_SIZEOF);
+		int length = 0;
+		while (namePtr[0] != 0) {
+			length++;
+			namesPtr1+=OS.PTR_SIZEOF;
+			OS.memmove(namePtr, namesPtr1, OS.PTR_SIZEOF);
+		}
+		fileNames = new String [length];
+		namePtr = new int /*long*/ [length];
+		OS.memmove (namePtr, namesPtr, length * OS.PTR_SIZEOF);
+		for (int i = 0; i < length; i++) {			
+			utf8Ptr = OS.g_filename_to_utf8 (namePtr [i], -1, null, null, null);
+			items_written = new int /*long*/ [1];
+			utf16Ptr = OS.g_utf8_to_utf16 (utf8Ptr, -1, null, items_written, null);
+			buffer = new char [(int)/*64*/items_written [0]];
+			OS.memmove (buffer, utf16Ptr, items_written [0] * 2);
+			String name = new String (buffer);
+			fileNames [i] = name.substring (name.lastIndexOf (SEPARATOR) + 1);
+			OS.g_free (utf16Ptr);
+			OS.g_free (utf8Ptr);
+		}
+		OS.g_strfreev (namesPtr);
+	}
+	return answer;
+}
+/**
+ * Returns the path of the first file that was
+ * selected in the dialog relative to the filter path, or an
+ * empty string if no such file has been selected.
+ * 
+ * @return the relative path of the file
+ */
+public String getFileName () {
+	return fileName;
+}
+/**
+ * Returns a (possibly empty) array with the paths of all files
+ * that were selected in the dialog relative to the filter path.
+ * 
+ * @return the relative paths of the files
+ */
+public String [] getFileNames () {
+	return fileNames;
+}
+/**
+ * Returns the file extensions which the dialog will
+ * use to filter the files it shows.
+ *
+ * @return the file extensions filter
+ */
+public String [] getFilterExtensions () {
+	return filterExtensions;
+}
+/**
+ * Get the 0-based index of the file extension filter
+ * which was selected by the user, or -1 if no filter
+ * was selected.
+ * <p>
+ * This is an index into the FilterExtensions array and
+ * the FilterNames array.
+ * </p>
+ *
+ * @return index the file extension filter index
+ * 
+ * @see #getFilterExtensions
+ * @see #getFilterNames
+ * 
+ * @since 3.4
+ */
+public int getFilterIndex () {
+	return filterIndex;
+}
+/**
+ * Returns the names that describe the filter extensions
+ * which the dialog will use to filter the files it shows.
+ *
+ * @return the list of filter names
+ */
+public String [] getFilterNames () {
+	return filterNames;
+}
+/**
+ * Returns the directory path that the dialog will use, or an empty
+ * string if this is not set.  File names in this path will appear
+ * in the dialog, filtered according to the filter extensions.
+ *
+ * @return the directory path string
+ * 
+ * @see #setFilterExtensions
+ */
+public String getFilterPath () {
+	return filterPath;
+}
+/**
+ * Returns the flag that the dialog will use to
+ * determine whether to prompt the user for file
+ * overwrite if the selected file already exists.
+ *
+ * @return true if the dialog will prompt for file overwrite, false otherwise
+ * 
+ * @since 3.4
+ */
+public boolean getOverwrite () {
+	return overwrite;
+}
+/**
+ * Makes the dialog visible and brings it to the front
+ * of the display.
+ *
+ * @return a string describing the absolute path of the first selected file,
+ *         or null if the dialog was cancelled or an error occurred
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the dialog has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the dialog</li>
+ * </ul>
+ */
+public String open () {
+	boolean useChooserDialog = OS.GTK_VERSION >= OS.VERSION (2, 4, 10); 
+	if (useChooserDialog) {
+		return openChooserDialog ();
+	} else {
+		return openClassicDialog ();
+	}
+}
+String openChooserDialog () {
+	byte [] titleBytes = Converter.wcsToMbcs (null, title, true);
+	int action = (style & SWT.SAVE) != 0 ?
+		OS.GTK_FILE_CHOOSER_ACTION_SAVE :
+		OS.GTK_FILE_CHOOSER_ACTION_OPEN;
+	int /*long*/ shellHandle = parent.topHandle ();
+	handle = OS.gtk_file_chooser_dialog_new (
+		titleBytes,
+		shellHandle,
+		action,
+		OS.GTK_STOCK_CANCEL (), OS.GTK_RESPONSE_CANCEL,
+		OS.GTK_STOCK_OK (), OS.GTK_RESPONSE_OK,
+		0);
+	int /*long*/ pixbufs = OS.gtk_window_get_icon_list (shellHandle);
+	if (pixbufs != 0) {
+		OS.gtk_window_set_icon_list (handle, pixbufs);
+		OS.g_list_free (pixbufs);
+	}
+	presetChooserDialog ();
+	Display display = parent != null ? parent.getDisplay (): Display.getCurrent ();
+	display.addIdleProc ();
+	String answer = null;
+	Dialog oldModal = null;
+	if (OS.gtk_window_get_modal (handle)) {
+		oldModal = display.getModalDialog ();
+		display.setModalDialog (this);
+	}
+	int signalId = 0;
+	int /*long*/ hookId = 0;
+	if ((style & SWT.RIGHT_TO_LEFT) != 0) {
+		signalId = OS.g_signal_lookup (OS.map, OS.GTK_TYPE_WIDGET());
+		hookId = OS.g_signal_add_emission_hook (signalId, 0, display.emissionProc, handle, 0);
+	}	
+	int response = OS.gtk_dialog_run (handle);
+	if ((style & SWT.RIGHT_TO_LEFT) != 0) {
+		OS.g_signal_remove_emission_hook (signalId, hookId);
+	}
+	if (OS.gtk_window_get_modal (handle)) {
+		display.setModalDialog (oldModal);
+	}
+	if (response == OS.GTK_RESPONSE_OK) {
+		answer = computeResultChooserDialog ();
+	}
+	display.removeIdleProc ();
+	OS.gtk_widget_destroy (handle);
+	return answer;
+}
+String openClassicDialog () {
+	byte [] titleBytes = Converter.wcsToMbcs (null, title, true);
+	handle = OS.gtk_file_selection_new (titleBytes);
+	if (parent != null) {
+		int /*long*/ shellHandle = parent.topHandle ();
+		OS.gtk_window_set_transient_for (handle, shellHandle);
+		int /*long*/ pixbufs = OS.gtk_window_get_icon_list (shellHandle);
+		if (pixbufs != 0) {
+			OS.gtk_window_set_icon_list (handle, pixbufs);
+			OS.g_list_free (pixbufs);
+		}
+	}
+	presetClassicDialog ();
+	Display display = parent != null ? parent.getDisplay (): Display.getCurrent ();
+	display.addIdleProc ();
+	String answer = null;
+	Dialog oldModal = null;
+	if (OS.gtk_window_get_modal (handle)) {
+		oldModal = display.getModalDialog ();
+		display.setModalDialog (this);
+	}
+	int signalId = 0;
+	int /*long*/ hookId = 0;
+	if ((style & SWT.RIGHT_TO_LEFT) != 0) {
+		signalId = OS.g_signal_lookup (OS.map, OS.GTK_TYPE_WIDGET());
+		hookId = OS.g_signal_add_emission_hook (signalId, 0, display.emissionProc, handle, 0);
+	}	
+	int response = OS.gtk_dialog_run (handle);
+	if ((style & SWT.RIGHT_TO_LEFT) != 0) {
+		OS.g_signal_remove_emission_hook (signalId, hookId);
+	}
+	if (OS.gtk_window_get_modal (handle)) {
+		display.setModalDialog (oldModal);
+	}
+	if (response == OS.GTK_RESPONSE_OK) {
+		answer = computeResultClassicDialog ();
+	}
+	display.removeIdleProc ();
+	OS.gtk_widget_destroy (handle);
+	return answer;
+}
+void presetChooserDialog () {
+	/* MULTI is only valid if the native dialog's action is Open */   
+	if ((style & (SWT.SAVE | SWT.MULTI)) == SWT.MULTI) {
+		OS.gtk_file_chooser_set_select_multiple (handle, true);
+	}
+	if (filterPath == null) filterPath = "";
+	if (fileName == null) fileName = "";
+	if (filterPath.length () > 0) {
+		StringBuffer stringBuffer = new StringBuffer ();
+		/* filename must be a full path */
+		if (filterPath.charAt (0) != SEPARATOR) {
+			stringBuffer.append (SEPARATOR);
+		}
+		stringBuffer.append (filterPath);
+
+		if (fileName.length () > 0 && (style & SWT.SAVE) == 0) {
+			if (filterPath.charAt (filterPath.length () - 1) != SEPARATOR) {
+				stringBuffer.append (SEPARATOR);
+			}
+			stringBuffer.append (fileName);
+			byte [] buffer = Converter.wcsToMbcs (null, stringBuffer.toString (), true);
+			/*
+			* Bug in GTK. GtkFileChooser may crash on GTK versions 2.4.10 to 2.6
+			* when setting a file name that is not a true canonical path. 
+			* The fix is to use the canonical path.
+			*/
+			int /*long*/ ptr = OS.realpath (buffer, null);
+			if (ptr != 0) {
+				OS.gtk_file_chooser_set_filename (handle, ptr);
+				OS.g_free (ptr);
+			}
+		} else {
+			byte [] buffer = Converter.wcsToMbcs (null, stringBuffer.toString (), true);
+			/*
+			* Bug in GTK. GtkFileChooser may crash on GTK versions 2.4.10 to 2.6
+			* when setting a file name that is not a true canonical path. 
+			* The fix is to use the canonical path.
+			*/
+			int /*long*/ ptr = OS.realpath (buffer, null);
+			if (ptr != 0) {
+				OS.gtk_file_chooser_set_current_folder (handle, ptr);
+				OS.g_free (ptr);
+			}
+		}
+	} else {
+		if (fileName.length () > 0) {
+			if (fileName.charAt (0) == SEPARATOR) {
+				byte [] buffer = Converter.wcsToMbcs (null, fileName, true);
+				/*
+				* Bug in GTK. GtkFileChooser may crash on GTK versions 2.4.10 to 2.6
+				* when setting a file name that is not a true canonical path. 
+				* The fix is to use the canonical path.
+				*/
+				int /*long*/ ptr = OS.realpath (buffer, null);
+				if (ptr != 0) {
+					OS.gtk_file_chooser_set_filename (handle, ptr);
+					OS.g_free (ptr);
+				}
+			}
+		}
+	}
+	if ((style & SWT.SAVE) != 0 && fileName.length () > 0) {
+		byte [] buffer = Converter.wcsToMbcs (null, fileName, true);
+		OS.gtk_file_chooser_set_current_name (handle, buffer);
+	}
+	if ((style & SWT.SAVE) != 0) {
+		if (OS.GTK_VERSION >= OS.VERSION (2, 8, 0)) {
+			OS.gtk_file_chooser_set_do_overwrite_confirmation (handle, overwrite);
+		}
+	}
+
+	/* Set the extension filters */
+	if (filterNames == null) filterNames = new String [0];
+	if (filterExtensions == null) filterExtensions = new String [0];
+	int /*long*/ initialFilter = 0;
+	for (int i = 0; i < filterExtensions.length; i++) {
+		if (filterExtensions [i] != null) {
+			int /*long*/ filter = OS.gtk_file_filter_new ();
+			if (filterNames.length > i && filterNames [i] != null) {
+				byte [] name = Converter.wcsToMbcs (null, filterNames [i], true);
+				OS.gtk_file_filter_set_name (filter, name);
+			} else {
+				byte [] name = Converter.wcsToMbcs (null, filterExtensions [i], true);
+				OS.gtk_file_filter_set_name (filter, name);
+			}
+			int start = 0;
+			int index = filterExtensions [i].indexOf (EXTENSION_SEPARATOR);
+			while (index != -1) {
+				String current = filterExtensions [i].substring (start, index);
+				byte [] filterString = Converter.wcsToMbcs (null, current, true);
+				OS.gtk_file_filter_add_pattern (filter, filterString);
+				start = index + 1;
+				index = filterExtensions [i].indexOf (EXTENSION_SEPARATOR, start);
+			}
+			String current = filterExtensions [i].substring (start);
+			byte [] filterString = Converter.wcsToMbcs (null, current, true);
+			OS.gtk_file_filter_add_pattern (filter, filterString);
+			OS.gtk_file_chooser_add_filter (handle, filter);
+			if (i == filterIndex) {
+				initialFilter = filter;
+			}
+		}
+	}
+	if (initialFilter != 0) {
+		OS.gtk_file_chooser_set_filter(handle, initialFilter);
+	}
+	fullPath = null;
+	fileNames = new String [0];
+}
+void presetClassicDialog () {
+	OS.gtk_file_selection_set_select_multiple(handle, (style & SWT.MULTI) != 0);
+
+	/* Calculate the fully-specified file name and convert to bytes */
+	StringBuffer stringBuffer = new StringBuffer ();
+	if (filterPath == null) {
+		filterPath = "";
+	} else {
+		if (filterPath.length () > 0) {
+			stringBuffer.append (filterPath);
+			if (filterPath.charAt (filterPath.length () - 1) != SEPARATOR) {
+				stringBuffer.append (SEPARATOR);
+			}
+		}
+	}
+	if (fileName == null) {
+		fileName = "";
+	} else {
+		stringBuffer.append (fileName);
+	}
+	fullPath = stringBuffer.toString ();
+	int length = fullPath.length ();
+	char [] buffer = new char [length + 1];
+	fullPath.getChars (0, length, buffer, 0);
+	int /*long*/ utf8Ptr = OS.g_utf16_to_utf8 (buffer, -1, null, null, null);
+	int /*long*/ fileNamePtr = OS.g_filename_from_utf8 (utf8Ptr, -1, null, null, null);
+	OS.gtk_file_selection_set_filename (handle, fileNamePtr);
+	OS.g_free (utf8Ptr);
+	OS.g_free (fileNamePtr);
+				
+	if (filterNames == null) filterNames = new String [0];
+	if (filterExtensions == null) filterExtensions = new String [0];
+	fullPath = null;
+	fileNames = new String [0];
+}
+/**
+ * Set the initial filename which the dialog will
+ * select by default when opened to the argument,
+ * which may be null.  The name will be prefixed with
+ * the filter path when one is supplied.
+ * 
+ * @param string the file name
+ */
+public void setFileName (String string) {
+	fileName = string;
+}
+/**
+ * Set the file extensions which the dialog will
+ * use to filter the files it shows to the argument,
+ * which may be null.
+ * <p>
+ * The strings are platform specific. For example, on
+ * some platforms, an extension filter string is typically
+ * of the form "*.extension", where "*.*" matches all files.
+ * For filters with multiple extensions, use semicolon as
+ * a separator, e.g. "*.jpg;*.png".
+ * </p>
+ *
+ * @param extensions the file extension filter
+ * 
+ * @see #setFilterNames to specify the user-friendly
+ * names corresponding to the extensions
+ */
+public void setFilterExtensions (String [] extensions) {
+	filterExtensions = extensions;
+}
+/**
+ * Set the 0-based index of the file extension filter
+ * which the dialog will use initially to filter the files
+ * it shows to the argument.
+ * <p>
+ * This is an index into the FilterExtensions array and
+ * the FilterNames array.
+ * </p>
+ *
+ * @param index the file extension filter index
+ * 
+ * @see #setFilterExtensions
+ * @see #setFilterNames
+ * 
+ * @since 3.4
+ */
+public void setFilterIndex (int index) {
+	filterIndex = index;
+}
+/**
+ * Sets the names that describe the filter extensions
+ * which the dialog will use to filter the files it shows
+ * to the argument, which may be null.
+ * <p>
+ * Each name is a user-friendly short description shown for
+ * its corresponding filter. The <code>names</code> array must
+ * be the same length as the <code>extensions</code> array.
+ * </p>
+ *
+ * @param names the list of filter names, or null for no filter names
+ * 
+ * @see #setFilterExtensions
+ */
+public void setFilterNames (String [] names) {
+	filterNames = names;
+}
+/**
+ * Sets the directory path that the dialog will use
+ * to the argument, which may be null. File names in this
+ * path will appear in the dialog, filtered according
+ * to the filter extensions. If the string is null,
+ * then the operating system's default filter path
+ * will be used.
+ * <p>
+ * Note that the path string is platform dependent.
+ * For convenience, either '/' or '\' can be used
+ * as a path separator.
+ * </p>
+ *
+ * @param string the directory path
+ * 
+ * @see #setFilterExtensions
+ */
+public void setFilterPath (String string) {
+	filterPath = string;
+}
+
+/**
+ * Sets the flag that the dialog will use to
+ * determine whether to prompt the user for file
+ * overwrite if the selected file already exists.
+ *
+ * @param overwrite true if the dialog will prompt for file overwrite, false otherwise
+ * 
+ * @since 3.4
+ */
+public void setOverwrite (boolean overwrite) {
+	this.overwrite = overwrite;
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/FontDialog.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/FontDialog.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/FontDialog.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,241 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.widgets;
+
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.gtk.*;
+import org.eclipse.swt.graphics.*;
+
+/**
+ * Instances of this class allow the user to select a font
+ * from all available fonts in the system.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>(none)</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>(none)</dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is intended to be subclassed <em>only</em>
+ * within the SWT implementation.
+ * </p>
+ * 
+ * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: ControlExample, Dialog tab</a>
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public class FontDialog extends Dialog {
+	FontData fontData;
+	RGB rgb;
+/**
+ * Constructs a new instance of this class given only its parent.
+ *
+ * @param parent a shell which will be the parent of the new instance
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ */
+public FontDialog (Shell parent) {
+	this (parent, SWT.APPLICATION_MODAL);
+}
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a shell which will be the parent of the new instance
+ * @param style the style of dialog to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ */
+public FontDialog (Shell parent, int style) {
+	super (parent, checkStyle (parent, style));
+	checkSubclass ();
+}
+
+/**
+ * Returns a FontData object describing the font that was
+ * selected in the dialog, or null if none is available.
+ * 
+ * @return the FontData for the selected font, or null
+ * @deprecated use #getFontList ()
+ */
+public FontData getFontData () {
+	return fontData;
+}
+
+/**
+ * Returns a FontData set describing the font that was
+ * selected in the dialog, or null if none is available.
+ * 
+ * @return the FontData for the selected font, or null
+ * @since 2.1.1
+ */
+public FontData [] getFontList () {
+	if (fontData == null) return null;
+	FontData [] result = new FontData [1];
+	result [0] = fontData;
+	return result;
+}
+
+/**
+ * Returns an RGB describing the color that was selected
+ * in the dialog, or null if none is available.
+ *
+ * @return the RGB value for the selected color, or null
+ *
+ * @see PaletteData#getRGBs
+ * 
+ * @since 2.1
+ */
+public RGB getRGB () {
+	return rgb;
+}
+
+/**
+ * Makes the dialog visible and brings it to the front
+ * of the display.
+ *
+ * @return a FontData object describing the font that was selected,
+ *         or null if the dialog was cancelled or an error occurred
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the dialog has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the dialog</li>
+ * </ul>
+ */
+public FontData open () {
+	int /*long*/ handle;
+	byte [] titleBytes;
+	titleBytes = Converter.wcsToMbcs (null, title, true);
+	Display display = parent != null ? parent.getDisplay (): Display.getCurrent ();
+	handle = OS.gtk_font_selection_dialog_new (titleBytes);
+	if (parent!=null) {
+		int /*long*/ shellHandle = parent.topHandle ();
+		OS.gtk_window_set_transient_for(handle, shellHandle);
+		int /*long*/ pixbufs = OS.gtk_window_get_icon_list (shellHandle);
+		if (pixbufs != 0) {
+			OS.gtk_window_set_icon_list (handle, pixbufs);
+			OS.g_list_free (pixbufs);
+		}
+	}
+	if (fontData != null) {
+		Font font = new Font (display, fontData);
+		int /*long*/ fontName = OS.pango_font_description_to_string (font.handle);
+		int length = OS.strlen (fontName);
+		byte [] buffer = new byte [length + 1];
+		OS.memmove (buffer, fontName, length);
+		font.dispose();
+		OS.g_free (fontName);
+		OS.gtk_font_selection_dialog_set_font_name (handle, buffer);
+	}
+	display.addIdleProc ();
+	Dialog oldModal = null;
+	if (OS.gtk_window_get_modal (handle)) {
+		oldModal = display.getModalDialog ();
+		display.setModalDialog (this);
+	}
+	int signalId = 0;
+	int /*long*/ hookId = 0;
+	if ((style & SWT.RIGHT_TO_LEFT) != 0) {
+		signalId = OS.g_signal_lookup (OS.map, OS.GTK_TYPE_WIDGET());
+		hookId = OS.g_signal_add_emission_hook (signalId, 0, display.emissionProc, handle, 0);
+	}	
+	int response = OS.gtk_dialog_run (handle);
+	if ((style & SWT.RIGHT_TO_LEFT) != 0) {
+		OS.g_signal_remove_emission_hook (signalId, hookId);
+	}
+	if (OS.gtk_window_get_modal (handle)) {
+		display.setModalDialog (oldModal);
+	}
+	boolean success = response == OS.GTK_RESPONSE_OK; 
+	if (success) {
+		int /*long*/ fontName = OS.gtk_font_selection_dialog_get_font_name (handle);
+		int length = OS.strlen (fontName);
+		byte [] buffer = new byte [length + 1];
+		OS.memmove (buffer, fontName, length);
+		OS.g_free (fontName);
+		int /*long*/ fontDesc = OS.pango_font_description_from_string (buffer);
+		Font font = Font.gtk_new (display, fontDesc);
+		fontData = font.getFontData () [0];
+		OS.pango_font_description_free (fontDesc);		
+	}
+	display.removeIdleProc ();
+	OS.gtk_widget_destroy(handle);
+	if (!success) return null;
+	return fontData;
+}
+/**
+ * Sets a FontData object describing the font to be
+ * selected by default in the dialog, or null to let
+ * the platform choose one.
+ * 
+ * @param fontData the FontData to use initially, or null
+ * @deprecated use #setFontList (FontData [])
+ */
+public void setFontData (FontData fontData) {
+	this.fontData = fontData;
+}
+
+/**
+ * Sets the set of FontData objects describing the font to
+ * be selected by default in the dialog, or null to let
+ * the platform choose one.
+ * 
+ * @param fontData the set of FontData objects to use initially, or null
+ *        to let the platform select a default when open() is called
+ *
+ * @see Font#getFontData
+ * 
+ * @since 2.1.1
+ */
+public void setFontList (FontData [] fontData) {
+	if (fontData != null && fontData.length > 0) {
+		this.fontData = fontData [0];
+	} else {
+		this.fontData = null;
+	}
+}
+/**
+ * Sets the RGB describing the color to be selected by default
+ * in the dialog, or null to let the platform choose one.
+ *
+ * @param rgb the RGB value to use initially, or null to let
+ *        the platform select a default when open() is called
+ *
+ * @see PaletteData#getRGBs
+ * 
+ * @since 2.1
+ */
+public void setRGB (RGB rgb) {
+	this.rgb = rgb;
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Group.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Group.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Group.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,291 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.widgets;
+
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.gtk.*;
+import org.eclipse.swt.graphics.*;
+
+/**
+ * Instances of this class provide an etched border
+ * with an optional title.
+ * <p>
+ * Shadow styles are hints and may not be honoured
+ * by the platform.  To create a group with the
+ * default shadow style for the platform, do not
+ * specify a shadow style.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>SHADOW_ETCHED_IN, SHADOW_ETCHED_OUT, SHADOW_IN, SHADOW_OUT, SHADOW_NONE</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>(none)</dd>
+ * </dl>
+ * <p>
+ * Note: Only one of the above styles may be specified.
+ * </p><p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ * 
+ * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: ControlExample</a>
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public class Group extends Composite {
+	int /*long*/ clientHandle, labelHandle;
+	String text = "";
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT#SHADOW_ETCHED_IN
+ * @see SWT#SHADOW_ETCHED_OUT
+ * @see SWT#SHADOW_IN
+ * @see SWT#SHADOW_OUT
+ * @see SWT#SHADOW_NONE
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public Group (Composite parent, int style) {
+	super (parent, checkStyle (style));
+}
+
+static int checkStyle (int style) {
+	style |= SWT.NO_FOCUS;
+	/*
+	* Even though it is legal to create this widget
+	* with scroll bars, they serve no useful purpose
+	* because they do not automatically scroll the
+	* widget's client area.  The fix is to clear
+	* the SWT style.
+	*/
+	return style & ~(SWT.H_SCROLL | SWT.V_SCROLL);
+}
+
+protected void checkSubclass () {
+	if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
+}
+
+int /*long*/ clientHandle () {
+	return clientHandle;
+}
+
+public Point computeSize (int wHint, int hHint, boolean changed) {
+	Point size = super.computeSize(wHint, hHint, changed);
+	int width = computeNativeSize (handle, SWT.DEFAULT, SWT.DEFAULT, false).x;
+	size.x = Math.max (size.x, width);
+	return size;
+}
+public Rectangle computeTrim (int x, int y, int width, int height) {
+	checkWidget();
+	forceResize ();
+	int clientX = OS.GTK_WIDGET_X (clientHandle);
+	int clientY = OS.GTK_WIDGET_Y (clientHandle);
+	x -= clientX;
+	y -= clientY;
+	width += clientX + clientX;
+	height += clientX + clientY;
+	return new Rectangle (x, y, width, height);
+}
+
+void createHandle(int index) {
+	state |= HANDLE | THEME_BACKGROUND;
+	fixedHandle = OS.g_object_new (display.gtk_fixed_get_type (), 0);
+	if (fixedHandle == 0) error (SWT.ERROR_NO_HANDLES);
+	OS.gtk_fixed_set_has_window (fixedHandle, true);
+	handle = OS.gtk_frame_new (null);
+	if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+	labelHandle = OS.gtk_label_new (null);
+	if (labelHandle == 0) error (SWT.ERROR_NO_HANDLES);
+	OS.g_object_ref (labelHandle);
+	OS.gtk_object_sink (labelHandle);
+	clientHandle = OS.g_object_new (display.gtk_fixed_get_type (), 0);
+	if (clientHandle == 0) error (SWT.ERROR_NO_HANDLES);
+	OS.gtk_container_add (fixedHandle, handle);
+	OS.gtk_container_add (handle, clientHandle);
+	if ((style & SWT.SHADOW_IN) != 0) {
+		OS.gtk_frame_set_shadow_type (handle, OS.GTK_SHADOW_IN);
+	}
+	if ((style & SWT.SHADOW_OUT) != 0) {
+		OS.gtk_frame_set_shadow_type (handle, OS.GTK_SHADOW_OUT);
+	}
+	if ((style & SWT.SHADOW_ETCHED_IN) != 0) {
+		OS.gtk_frame_set_shadow_type (handle, OS.GTK_SHADOW_ETCHED_IN);
+	}
+	if ((style & SWT.SHADOW_ETCHED_OUT) != 0) {
+		OS.gtk_frame_set_shadow_type (handle, OS.GTK_SHADOW_ETCHED_OUT);
+	}
+}
+
+void deregister () {
+	super.deregister ();
+	display.removeWidget (clientHandle);
+	display.removeWidget (labelHandle);
+}
+
+void enableWidget (boolean enabled) {
+	OS.gtk_widget_set_sensitive (labelHandle, enabled);
+}
+
+int /*long*/ eventHandle () {
+	return fixedHandle;
+}
+
+String getNameText () {
+	return getText ();
+}
+
+/**
+ * Returns the receiver's text, which is the string that the
+ * is used as the <em>title</em>. If the text has not previously
+ * been set, returns an empty string.
+ *
+ * @return the text
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public String getText () {
+	checkWidget();
+	return text;
+}
+
+void hookEvents () {
+	super.hookEvents();
+	if (labelHandle != 0) {
+		OS.g_signal_connect_closure_by_id (labelHandle, display.signalIds [MNEMONIC_ACTIVATE], 0, display.closures [MNEMONIC_ACTIVATE], false);
+	}
+}
+
+boolean mnemonicHit (char key) {
+	if (labelHandle == 0) return false;
+	boolean result = super.mnemonicHit (labelHandle, key);
+	if (result) setFocus ();
+	return result;
+}
+
+boolean mnemonicMatch (char key) {
+	if (labelHandle == 0) return false;
+	return mnemonicMatch (labelHandle, key);
+}
+
+int /*long*/ parentingHandle() {
+	return fixedHandle;
+}
+
+void register () {
+	super.register ();
+	display.addWidget (clientHandle, this);
+	display.addWidget (labelHandle, this);
+}
+
+void releaseHandle () {
+	super.releaseHandle ();
+	clientHandle = labelHandle = 0;
+}
+
+void releaseWidget () {
+	super.releaseWidget ();
+	if (labelHandle != 0) OS.g_object_unref (labelHandle);
+	text = null;
+}
+
+void setBackgroundColor (GdkColor color) {
+	super.setBackgroundColor (color);
+	setBackgroundColor(fixedHandle, color);
+}
+
+void setFontDescription (int /*long*/ font) {
+	super.setFontDescription (font);
+	OS.gtk_widget_modify_font (labelHandle, font);
+}
+
+void setForegroundColor (GdkColor color) {
+	super.setForegroundColor (color);
+	setForegroundColor (labelHandle, color);
+}
+
+void setOrientation () {
+	super.setOrientation ();
+	if ((style & SWT.RIGHT_TO_LEFT) != 0) {
+		OS.gtk_widget_set_direction (labelHandle, OS.GTK_TEXT_DIR_RTL);
+	}
+}
+
+/**
+ * Sets the receiver's text, which is the string that will
+ * be displayed as the receiver's <em>title</em>, to the argument,
+ * which may not be null. The string may include the mnemonic character.
+ * </p>
+ * Mnemonics are indicated by an '&amp;' that causes the next
+ * character to be the mnemonic.  When the user presses a
+ * key sequence that matches the mnemonic, focus is assigned
+ * to the first child of the group. On most platforms, the
+ * mnemonic appears underlined but may be emphasised in a
+ * platform specific manner.  The mnemonic indicator character
+ * '&amp;' can be escaped by doubling it in the string, causing
+ * a single '&amp;' to be displayed.
+ * </p>
+ * @param string the new text
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the text is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setText (String string) {
+	checkWidget();
+	if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+	text = string;
+	char [] chars = fixMnemonic (string);
+	byte [] buffer = Converter.wcsToMbcs (null, chars, true);
+	OS.gtk_label_set_text_with_mnemonic (labelHandle, buffer);
+	if (string.length () != 0) {
+		if (OS.gtk_frame_get_label_widget (handle) == 0) {
+			OS.gtk_frame_set_label_widget (handle, labelHandle);
+		}	
+	} else {
+		OS.gtk_frame_set_label_widget (handle, 0);
+	}
+}
+
+void showWidget () {
+	super.showWidget ();
+	if (clientHandle != 0) OS.gtk_widget_show (clientHandle);
+	if (labelHandle != 0) OS.gtk_widget_show (labelHandle);
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/IME.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/IME.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/IME.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,430 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.widgets;
+
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.gtk.*;
+
+
+/**
+ * Instances of this class represent input method editors.
+ * These are typically in-line pre-edit text areas that allow
+ * the user to compose characters from Far Eastern languages
+ * such as Japanese, Chinese or Korean.
+ * 
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>(none)</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>ImeComposition</dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ * 
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ * 
+ * @since 3.4
+ */
+public class IME extends Widget {
+	Canvas parent;
+	int caretOffset;
+	int startOffset;
+	int commitCount;
+	String text;
+	int [] ranges;
+	TextStyle [] styles;
+	boolean inComposition;
+
+/**
+ * Prevents uninitialized instances from being created outside the package.
+ */
+IME () {
+}
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a canvas control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public IME (Canvas parent, int style) {
+	super (parent, style);
+	this.parent = parent;
+	createWidget ();
+}
+
+void createWidget () {
+	text = "";
+	startOffset = -1;
+	if (parent.getIME () == null) {
+		parent.setIME (this);
+	}
+}
+
+/**
+ * Returns the offset of the caret from the start of the document.
+ * The caret is within the current composition.
+ *
+ * @return the caret offset
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getCaretOffset () {
+	checkWidget ();
+	return startOffset + caretOffset;
+}
+
+/**
+ * Returns the commit count of the composition.  This is the
+ * number of characters that have been composed.  When the
+ * commit count is equal to the length of the composition
+ * text, then the in-line edit operation is complete.
+ * 
+ * @return the commit count
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see IME#getText
+ */
+public int getCommitCount () {
+	checkWidget ();
+	return commitCount;
+}
+
+/**
+ * Returns the offset of the composition from the start of the document.
+ * This is the start offset of the composition within the document and
+ * in not changed by the input method editor itself during the in-line edit
+ * session.
+ *
+ * @return the offset of the composition
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getCompositionOffset () {
+	checkWidget ();
+	return startOffset;
+}
+
+/**
+ * Returns the ranges for the style that should be applied during the
+ * in-line edit session.
+ * <p>
+ * The ranges array contains start and end pairs.  Each pair refers to
+ * the corresponding style in the styles array.  For example, the pair
+ * that starts at ranges[n] and ends at ranges[n+1] uses the style
+ * at styles[n/2] returned by <code>getStyles()</code>.
+ * </p>
+ * @return the ranges for the styles
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see IME#getStyles
+ */
+public int [] getRanges () {
+	checkWidget ();
+	if (ranges == null) return new int [0];
+	int [] result = new int [ranges.length];
+	for (int i = 0; i < result.length; i++) {
+		result [i] = ranges [i] + startOffset; 
+	}
+	return result;
+}
+
+/**
+ * Returns the styles for the ranges.
+ * <p>
+ * The ranges array contains start and end pairs.  Each pair refers to
+ * the corresponding style in the styles array.  For example, the pair
+ * that starts at ranges[n] and ends at ranges[n+1] uses the style
+ * at styles[n/2].
+ * </p>
+ * 
+ * @return the ranges for the styles
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see IME#getRanges
+ */
+public TextStyle [] getStyles () {
+	checkWidget ();
+	if (styles == null) return new TextStyle [0];
+	TextStyle [] result = new TextStyle [styles.length];
+	System.arraycopy (styles, 0, result, 0, styles.length);
+	return result;
+}
+
+/**
+ * Returns the composition text.
+ * <p>
+ * The text for an IME is the characters in the widget that
+ * are in the current composition. When the commit count is
+ * equal to the length of the composition text, then the
+ * in-line edit operation is complete.
+ * </p>
+ *
+ * @return the widget text
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public String getText () {
+	checkWidget ();
+	return text;
+}
+
+/**
+ * Returns <code>true</code> if the caret should be wide, and
+ * <code>false</code> otherwise.  In some languages, for example
+ * Korean, the caret is typically widened to the width of the
+ * current character in the in-line edit session.
+ * 
+ * @return the wide caret state
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public boolean getWideCaret () {
+	checkWidget ();
+	return false; 
+}
+
+int /*long*/ gtk_button_press_event (int /*long*/ widget, int /*long*/ event) {
+	if (!isInlineEnabled ()) return 0;
+	int /*long*/ imHandle = imHandle ();
+	if (imHandle != 0) OS.gtk_im_context_reset (imHandle);
+	return 0;
+}
+
+int /*long*/ gtk_commit (int /*long*/ imcontext, int /*long*/ textPtr) {
+	if (!isInlineEnabled ()) return 0;
+	boolean doit = true;
+	ranges = null;
+	styles = null;
+	caretOffset = commitCount = 0;
+	if (textPtr != 0 && inComposition) {
+		int length = OS.strlen (textPtr);
+		if (length != 0) {
+			byte [] buffer = new byte [length];
+			OS.memmove (buffer, textPtr, length);
+			char [] chars = Converter.mbcsToWcs (null, buffer);
+			Event event = new Event();
+			event.detail = SWT.COMPOSITION_CHANGED;
+			event.start = startOffset;
+			event.end = startOffset + text.length ();
+			event.text = text = chars != null ? new String (chars) : "";
+			commitCount = text.length();
+			sendEvent (SWT.ImeComposition, event);
+			doit = event.doit;
+			text = "";
+			startOffset = -1;
+			commitCount = 0;
+		}
+	}
+	inComposition = false;
+	return doit ? 0 : 1;
+}
+
+int /*long*/ gtk_preedit_changed (int /*long*/ imcontext) {
+	if (!isInlineEnabled ()) return 0;
+	ranges = null;
+	styles = null;
+	commitCount = 0;
+	int /*long*/ imHandle = imHandle ();
+	int /*long*/ [] preeditString = new int /*long*/ [1];
+	int /*long*/ [] pangoAttrs = new int /*long*/ [1];
+	int [] cursorPos = new int [1];
+	OS.gtk_im_context_get_preedit_string (imHandle, preeditString, pangoAttrs, cursorPos);
+	caretOffset = cursorPos [0];
+	char [] chars = null;
+	if (preeditString [0] != 0) {
+		int length = OS.strlen (preeditString [0]);
+		byte [] buffer = new byte [length];
+		OS.memmove (buffer, preeditString [0], length);
+		chars = Converter.mbcsToWcs (null, buffer);
+		if (pangoAttrs [0] != 0) {
+			int count = 0;
+			int /*long*/ iterator = OS.pango_attr_list_get_iterator (pangoAttrs [0]);
+			while (OS.pango_attr_iterator_next (iterator)) count++;
+			OS.pango_attr_iterator_destroy (iterator);
+			ranges = new int [count * 2];
+			styles = new TextStyle [count];
+			iterator = OS.pango_attr_list_get_iterator (pangoAttrs [0]);
+			PangoAttrColor attrColor = new PangoAttrColor ();
+			PangoAttrInt attrInt = new PangoAttrInt ();
+			int [] start = new int [1];
+			int [] end = new int [1];
+			for (int i = 0; i < count; i++) {
+				OS.pango_attr_iterator_range (iterator, start, end);
+				ranges [i * 2] = (int)/*64*/OS.g_utf8_pointer_to_offset (preeditString [0], preeditString [0] + start [0]);
+				ranges [i * 2 + 1] = (int)/*64*/OS.g_utf8_pointer_to_offset (preeditString [0], preeditString [0] + end [0]) - 1;
+				styles [i] = new TextStyle (null, null, null);
+				int /*long*/ attr = OS.pango_attr_iterator_get (iterator, OS.PANGO_ATTR_FOREGROUND);
+				if (attr != 0) {
+					OS.memmove (attrColor, attr, PangoAttrColor.sizeof);
+					GdkColor color = new GdkColor ();
+					color.red = attrColor.color_red;
+					color.green = attrColor.color_green;
+					color.blue = attrColor.color_blue;
+					styles [i].foreground = Color.gtk_new (display, color);
+				}
+				attr = OS.pango_attr_iterator_get (iterator, OS.PANGO_ATTR_BACKGROUND);
+				if (attr != 0) {
+					OS.memmove (attrColor, attr, PangoAttrColor.sizeof);
+					GdkColor color = new GdkColor ();
+					color.red = attrColor.color_red;
+					color.green = attrColor.color_green;
+					color.blue = attrColor.color_blue;
+					styles [i].background = Color.gtk_new (display, color);
+				}
+				attr = OS.pango_attr_iterator_get (iterator, OS.PANGO_ATTR_UNDERLINE);
+				if (attr != 0) {
+					OS.memmove (attrInt, attr, PangoAttrInt.sizeof);
+					styles [i].underline = attrInt.value != OS.PANGO_UNDERLINE_NONE;;
+					styles [i].underlineStyle = SWT.UNDERLINE_SINGLE;
+					switch (attrInt.value) {
+						case OS.PANGO_UNDERLINE_DOUBLE:
+							styles [i].underlineStyle = SWT.UNDERLINE_DOUBLE;
+							break;
+						case OS.PANGO_UNDERLINE_ERROR:
+							styles [i].underlineStyle = SWT.UNDERLINE_ERROR;
+							break;
+					}
+					if (styles [i].underline) {
+						attr = OS.pango_attr_iterator_get(iterator, OS.PANGO_ATTR_UNDERLINE_COLOR);
+						if (attr != 0) {
+							OS.memmove (attrColor, attr, PangoAttrColor.sizeof);
+							GdkColor color = new GdkColor ();
+							color.red = attrColor.color_red;
+							color.green = attrColor.color_green;
+							color.blue = attrColor.color_blue;
+							styles [i].underlineColor = Color.gtk_new (display, color);
+						}
+					}
+				}
+				OS.pango_attr_iterator_next (iterator);
+			}
+			OS.pango_attr_iterator_destroy (iterator);
+			OS.pango_attr_list_unref (pangoAttrs [0]);	
+		}
+		OS.g_free (preeditString [0]);
+	}
+	if (chars != null) {
+		if (text.length() == 0) startOffset = -1;
+		int end = startOffset + text.length();
+		if (startOffset == -1) {
+			Event event = new Event ();
+			event.detail = SWT.COMPOSITION_SELECTION;
+			sendEvent (SWT.ImeComposition, event);
+			startOffset = event.start;
+			end = event.end;
+		}
+		inComposition = true;
+		Event event = new Event ();
+		event.detail = SWT.COMPOSITION_CHANGED;
+		event.start = startOffset;
+		event.end = end;
+		event.text = text = chars != null ? new String (chars) : "";
+		sendEvent (SWT.ImeComposition, event);
+	}
+	return 1;
+}
+
+int /*long*/ imHandle () {
+	return parent.imHandle ();
+}
+
+boolean isInlineEnabled () {
+	return hooks (SWT.ImeComposition);
+}
+
+void releaseParent () {
+	super.releaseParent ();
+	if (this == parent.getIME ()) parent.setIME (null);
+}
+
+void releaseWidget () {
+	super.releaseWidget ();
+	parent = null;
+	text = null;
+	styles = null;
+	ranges = null;
+}
+
+/**
+ * Sets the offset of the composition from the start of the document.
+ * This is the start offset of the composition within the document and
+ * in not changed by the input method editor itself during the in-line edit
+ * session but may need to be changed by clients of the IME.  For example,
+ * if during an in-line edit operation, a text editor inserts characters
+ * above the IME, then the IME must be informed that the composition
+ * offset has changed.
+ *
+ * @return the offset of the composition
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setCompositionOffset (int offset) {
+	checkWidget ();
+	if (offset < 0) return;
+	if (startOffset != -1) {
+		startOffset = offset;
+	}
+}
+
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/ImageList.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/ImageList.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/ImageList.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,154 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.widgets;
+
+
+import org.eclipse.swt.internal.gtk.*;
+import org.eclipse.swt.graphics.*;
+
+class ImageList {
+	int /*long*/ [] pixbufs;
+	int width = -1, height = -1;
+	Image [] images;
+	
+public ImageList() {
+	images = new Image [4];
+	pixbufs = new int /*long*/ [4];
+}
+
+public int add (Image image) {
+	int index = 0;
+	while (index < images.length) {
+		if (images [index] != null) {
+			if (images [index].isDisposed ()) {
+				OS.g_object_unref (pixbufs [index]);
+				images [index] = null;
+				pixbufs [index] = 0;
+			}
+		}
+		if (images [index] == null) break;
+		index++;
+	}
+	if (index == images.length) {
+		Image [] newImages = new Image [images.length + 4];
+		System.arraycopy (images, 0, newImages, 0, images.length);
+		images = newImages;
+		int /*long*/ [] newPixbufs = new int /*long*/ [pixbufs.length + 4];
+		System.arraycopy (pixbufs, 0, newPixbufs, 0, pixbufs.length);
+		pixbufs = newPixbufs;
+	}
+	set (index, image);
+	return index;
+}
+
+public void dispose () {
+	if (pixbufs == null) return;
+	for (int index=0; index<pixbufs.length; index++) {
+		if (pixbufs [index] != 0) OS.g_object_unref (pixbufs [index]);
+	}
+	images = null;
+	pixbufs = null;
+}
+
+public Image get (int index) {
+	return images [index];
+}
+
+int /*long*/ getPixbuf (int index) {
+	return pixbufs [index];
+}
+
+public int indexOf (Image image) {
+	if (image == null) return -1;
+	for (int index=0; index<images.length; index++) {
+		if (image == images [index]) return index;
+	}
+	return -1;
+}
+
+int indexOf (int /*long*/ pixbuf) {
+	if (pixbuf == 0) return -1;
+	for (int index=0; index<images.length; index++) {
+		if (pixbuf == pixbufs [index]) return index;
+	}
+	return -1;
+}
+
+public boolean isDisposed () {
+	return images == null;
+}
+
+public void put (int index, Image image) {
+	int count = images.length;
+	if (!(0 <= index && index < count)) return;
+	if (image != null) {
+		set (index, image);
+	} else {
+		images [index] = null;	
+		if (pixbufs [index] != 0) OS.g_object_unref (pixbufs [index]);
+		pixbufs [index] = 0;
+	}
+}
+
+public void remove (Image image) {
+	if (image == null) return;
+	for (int index=0; index<images.length; index++) {
+		if (image == images [index]){
+			OS.g_object_unref (pixbufs [index]);
+			images [index] = null;
+			pixbufs [index] = 0;
+		}
+	}
+}
+
+void set (int index, Image image) {
+	int [] w = new int [1], h = new int [1];
+ 	OS.gdk_drawable_get_size (image.pixmap, w, h);
+	int /*long*/ pixbuf = Display.createPixbuf (image);
+	if (width == -1 || height == -1) {
+		width = w [0];
+		height = h [0];
+	}
+	if (w [0] != width || h [0] != height) {
+		int /*long*/ scaledPixbuf = OS.gdk_pixbuf_scale_simple(pixbuf, width, height, OS.GDK_INTERP_BILINEAR);
+		OS.g_object_unref (pixbuf);
+		pixbuf = scaledPixbuf;
+	}
+	int /*long*/ oldPixbuf = pixbufs [index];
+	if (oldPixbuf != 0) {
+		if (images [index] == image) {
+			OS.gdk_pixbuf_copy_area (pixbuf, 0, 0, width, height, oldPixbuf, 0, 0);
+			OS.g_object_unref (pixbuf);
+			pixbuf = oldPixbuf;
+		} else {
+			OS.g_object_unref (oldPixbuf);
+		}
+	}
+	pixbufs [index] = pixbuf;
+	images [index] = image;	
+}
+
+public int size () {
+	int result = 0;
+	for (int index=0; index<images.length; index++) {
+		if (images [index] != null) {
+			if (images [index].isDisposed ()) {
+				OS.g_object_unref (pixbufs [index]);
+				images [index] = null;
+				pixbufs [index] = 0;
+			}
+			if (images [index] != null) result++;
+		}
+	}
+	return result;
+}
+
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Item.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Item.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Item.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,186 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.widgets;
+
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
+/**
+ * This class is the abstract superclass of all non-windowed
+ * user interface objects that occur within specific controls.
+ * For example, a tree will contain tree items.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>(none)</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>(none)</dd>
+ * </dl>
+ *
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+
+public abstract class Item extends Widget {
+	String text;
+	Image image;
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * The item is added to the end of the items maintained by its parent.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a widget which will be the parent of the new instance (cannot be null)
+ * @param style the style of item to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * </ul>
+ *
+ * @see SWT
+ * @see Widget#getStyle
+ */
+public Item (Widget parent, int style) {
+	super (parent, style);
+	text = "";
+}
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance,
+ * and the index at which to place it in the items maintained
+ * by its parent.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a widget which will be the parent of the new instance (cannot be null)
+ * @param style the style of item to construct
+ * @param index the zero-relative index at which to store the receiver in its parent
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the parent (inclusive)</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * </ul>
+ *
+ * @see SWT
+ * @see Widget#getStyle
+ */
+public Item (Widget parent, int style, int index) {
+	this (parent, style);
+}
+
+protected void checkSubclass () {
+	/* Do Nothing - Subclassing is allowed */
+}
+
+/**
+ * Returns the receiver's image if it has one, or null
+ * if it does not.
+ *
+ * @return the receiver's image
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Image getImage () {
+	checkWidget ();
+	return image;
+}
+
+String getNameText () {
+	return getText ();
+}
+
+/**
+ * Returns the receiver's text, which will be an empty
+ * string if it has never been set.
+ *
+ * @return the receiver's text
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public String getText () {
+	checkWidget();
+	return text;
+}
+
+void releaseWidget () {
+	super.releaseWidget ();
+	text = null;
+	image = null;
+}
+
+/**
+ * Sets the receiver's image to the argument, which may be
+ * null indicating that no image should be displayed.
+ *
+ * @param image the image to display on the receiver (may be null)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li> 
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setImage (Image image) {
+	checkWidget ();
+	if (image != null && image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
+	this.image = image;
+}
+
+/**
+ * Sets the receiver's text.
+ *
+ * @param string the new text
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the text is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setText (String string) {
+	checkWidget ();
+	if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+	text = string;
+}
+
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Label.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Label.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Label.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,577 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.widgets;
+
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.gtk.*;
+import org.eclipse.swt.graphics.*;
+
+/**
+ * Instances of this class represent a non-selectable
+ * user interface object that displays a string or image.
+ * When SEPARATOR is specified, displays a single
+ * vertical or horizontal line.
+ * <p>
+ * Shadow styles are hints and may not be honoured
+ * by the platform.  To create a separator label
+ * with the default shadow style for the platform,
+ * do not specify a shadow style.
+ * </p>
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>SEPARATOR, HORIZONTAL, VERTICAL</dd>
+ * <dd>SHADOW_IN, SHADOW_OUT, SHADOW_NONE</dd>
+ * <dd>CENTER, LEFT, RIGHT, WRAP</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>(none)</dd>
+ * </dl>
+ * <p>
+ * Note: Only one of SHADOW_IN, SHADOW_OUT and SHADOW_NONE may be specified.
+ * SHADOW_NONE is a HINT. Only one of HORIZONTAL and VERTICAL may be specified.
+ * Only one of CENTER, LEFT and RIGHT may be specified.
+ * </p><p>
+ * IMPORTANT: This class is intended to be subclassed <em>only</em>
+ * within the SWT implementation.
+ * </p>
+ *
+ * @see <a href="http://www.eclipse.org/swt/snippets/#label">Label snippets</a>
+ * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: ControlExample</a>
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public class Label extends Control {
+	int /*long*/ frameHandle, labelHandle, imageHandle;
+	ImageList imageList;
+	Image image;
+	String text;
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT#SEPARATOR
+ * @see SWT#HORIZONTAL
+ * @see SWT#VERTICAL
+ * @see SWT#SHADOW_IN
+ * @see SWT#SHADOW_OUT
+ * @see SWT#SHADOW_NONE
+ * @see SWT#CENTER
+ * @see SWT#LEFT
+ * @see SWT#RIGHT
+ * @see SWT#WRAP
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public Label (Composite parent, int style) {
+	super (parent, checkStyle (style));
+}
+
+static int checkStyle (int style) {
+	style |= SWT.NO_FOCUS;
+	if ((style & SWT.SEPARATOR) != 0) {
+		style = checkBits (style, SWT.VERTICAL, SWT.HORIZONTAL, 0, 0, 0, 0);
+		return checkBits (style, SWT.SHADOW_OUT, SWT.SHADOW_IN, SWT.SHADOW_NONE, 0, 0, 0);
+	} 
+	return checkBits (style, SWT.LEFT, SWT.CENTER, SWT.RIGHT, 0, 0, 0);
+}
+
+void addRelation (Control control) {
+	if (!control.isDescribedByLabel ()) return;
+	if (labelHandle == 0) return;
+	int /*long*/ accessible = OS.gtk_widget_get_accessible (labelHandle);
+	int /*long*/ controlAccessible = OS.gtk_widget_get_accessible (control.handle);
+	if (accessible != 0 && controlAccessible != 0) {
+		OS.atk_object_add_relationship (controlAccessible, OS.ATK_RELATION_LABELLED_BY, accessible);
+	}
+}
+
+public Point computeSize (int wHint, int hHint, boolean changed) {
+	checkWidget ();
+	if (wHint != SWT.DEFAULT && wHint < 0) wHint = 0;
+	if (hHint != SWT.DEFAULT && hHint < 0) hHint = 0;
+	if ((style & SWT.SEPARATOR) != 0) {
+		if ((style & SWT.HORIZONTAL) != 0) {
+			if (wHint == SWT.DEFAULT) wHint = DEFAULT_WIDTH;
+		} else {
+			if (hHint == SWT.DEFAULT) hHint = DEFAULT_HEIGHT;
+		}
+	}
+	boolean fixWrap = labelHandle != 0 && (style & SWT.WRAP) != 0;
+	if (fixWrap || frameHandle != 0) forceResize ();
+	int [] labelWidth = new int [1], labelHeight = new int [1];
+	if (fixWrap) {
+		OS.gtk_widget_get_size_request (labelHandle, labelWidth, labelHeight);
+		OS.gtk_widget_set_size_request (labelHandle, wHint, hHint);
+	}	
+	Point size; 
+	if (frameHandle != 0) {
+		int [] reqWidth = new int [1], reqHeight = new int [1];
+		OS.gtk_widget_get_size_request (handle, reqWidth, reqHeight);
+		OS.gtk_widget_set_size_request (handle, wHint, hHint);
+		size = computeNativeSize (frameHandle, -1, -1, changed);
+		OS.gtk_widget_set_size_request (handle, reqWidth [0], reqHeight [0]);
+	} else {
+		size = computeNativeSize (handle, wHint, hHint, changed);
+	}
+	if (fixWrap) {
+		OS.gtk_widget_set_size_request (labelHandle, labelWidth [0], labelHeight [0]);
+	}
+	/*
+	* Feature in GTK.  Instead of using the font height to determine
+	* the preferred height of the widget, GTK uses the text metrics.
+	* The fix is to ensure that the preferred height is at least as
+	* tall as the font height.
+	* 
+	* NOTE: This work around does not fix the case when there are
+	* muliple lines of text.
+	*/
+	if (hHint == SWT.DEFAULT && labelHandle != 0) {
+		int /*long*/ layout = OS.gtk_label_get_layout (labelHandle);
+		int /*long*/ context = OS.pango_layout_get_context (layout);
+		int /*long*/ lang = OS.pango_context_get_language (context);
+		int /*long*/ font = getFontDescription ();
+		int /*long*/ metrics = OS.pango_context_get_metrics (context, font, lang);
+		int ascent = OS.PANGO_PIXELS (OS.pango_font_metrics_get_ascent (metrics));
+		int descent = OS.PANGO_PIXELS (OS.pango_font_metrics_get_descent (metrics));
+		OS.pango_font_metrics_unref (metrics);
+		int fontHeight = ascent + descent;
+		int [] buffer = new int [1];
+		OS.g_object_get (labelHandle, OS.ypad, buffer, 0);
+		fontHeight += 2 * buffer [0];
+		if (frameHandle != 0) {
+			int /*long*/ style = OS.gtk_widget_get_style (frameHandle);
+			fontHeight += 2 * OS.gtk_style_get_ythickness (style);
+			fontHeight += 2 * OS.gtk_container_get_border_width (frameHandle);
+		}
+		size.y = Math.max (size.y, fontHeight);
+	}
+	return size;
+}
+
+void createHandle (int index) {
+	state |= HANDLE | THEME_BACKGROUND;
+	fixedHandle = OS.g_object_new (display.gtk_fixed_get_type (), 0);
+	if (fixedHandle == 0) error (SWT.ERROR_NO_HANDLES);
+	OS.gtk_fixed_set_has_window (fixedHandle, true);
+	if ((style & SWT.SEPARATOR) != 0) {
+		if ((style & SWT.HORIZONTAL)!= 0) {
+			handle = OS.gtk_hseparator_new ();
+		} else {
+			handle = OS.gtk_vseparator_new ();
+		}
+		if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+	} else {
+		handle = OS.gtk_hbox_new (false, 0);
+		if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+		labelHandle = OS.gtk_label_new_with_mnemonic (null);
+		if (labelHandle == 0) error (SWT.ERROR_NO_HANDLES);
+		imageHandle = OS.gtk_image_new ();
+		if (imageHandle == 0) error (SWT.ERROR_NO_HANDLES);
+		OS.gtk_container_add (handle, labelHandle);
+		OS.gtk_container_add (handle, imageHandle);
+	}
+	if ((style & SWT.BORDER) != 0) {
+		frameHandle = OS.gtk_frame_new (null);
+		if (frameHandle == 0) error (SWT.ERROR_NO_HANDLES);
+		OS.gtk_container_add (fixedHandle, frameHandle);
+		OS.gtk_container_add (frameHandle, handle);
+		OS.gtk_frame_set_shadow_type (frameHandle, OS.GTK_SHADOW_ETCHED_IN);
+	} else {
+		OS.gtk_container_add (fixedHandle, handle);
+	}
+	if ((style & SWT.SEPARATOR) != 0) return;
+	if ((style & SWT.WRAP) != 0) {
+		OS.gtk_label_set_line_wrap (labelHandle, true);
+		if (OS.GTK_VERSION >= OS.VERSION (2, 10, 0)) {
+			OS.gtk_label_set_line_wrap_mode (labelHandle, OS.PANGO_WRAP_WORD_CHAR);
+		}
+	}
+	setAlignment ();
+}
+
+void createWidget (int index) {
+	super.createWidget (index);
+	text = "";
+}
+
+void deregister () {
+	super.deregister ();
+	if (frameHandle != 0) display.removeWidget (frameHandle);
+	if (labelHandle != 0) display.removeWidget (labelHandle);
+	if (imageHandle != 0) display.removeWidget (imageHandle);
+}
+
+int /*long*/ eventHandle () {
+	return fixedHandle;
+}
+
+/**
+ * Returns a value which describes the position of the
+ * text or image in the receiver. The value will be one of
+ * <code>LEFT</code>, <code>RIGHT</code> or <code>CENTER</code>
+ * unless the receiver is a <code>SEPARATOR</code> label, in 
+ * which case, <code>NONE</code> is returned.
+ *
+ * @return the alignment 
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getAlignment () {
+	checkWidget ();
+	if ((style & SWT.SEPARATOR) != 0) return 0;
+	if ((style & SWT.LEFT) != 0) return SWT.LEFT;
+	if ((style & SWT.CENTER) != 0) return SWT.CENTER;
+	if ((style & SWT.RIGHT) != 0) return SWT.RIGHT;
+	return SWT.LEFT;
+}
+
+public int getBorderWidth () {
+	checkWidget();
+	if (frameHandle != 0) {
+		return OS.gtk_style_get_xthickness (OS.gtk_widget_get_style (frameHandle));
+	}
+	return 0;
+}
+
+/**
+ * Returns the receiver's image if it has one, or null
+ * if it does not.
+ *
+ * @return the receiver's image
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Image getImage () {
+	checkWidget ();
+	return image;
+}
+
+String getNameText () {
+	return getText ();
+}
+
+/**
+ * Returns the receiver's text, which will be an empty
+ * string if it has never been set or if the receiver is
+ * a <code>SEPARATOR</code> label.
+ *
+ * @return the receiver's text
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public String getText () {
+	checkWidget ();
+	if ((style & SWT.SEPARATOR) != 0) return "";
+	return text;
+}
+
+void hookEvents () {
+	super.hookEvents();
+	if (labelHandle != 0) {
+		OS.g_signal_connect_closure_by_id (labelHandle, display.signalIds [MNEMONIC_ACTIVATE], 0, display.closures [MNEMONIC_ACTIVATE], false);
+	}
+}
+
+boolean isDescribedByLabel () {
+	return false;
+}
+
+boolean mnemonicHit (char key) {
+	if (labelHandle == 0) return false;
+	boolean result = super.mnemonicHit (labelHandle, key);
+	if (result) {
+		Composite control = this.parent;
+		while (control != null) {
+			Control [] children = control._getChildren ();
+			int index = 0;
+			while (index < children.length) {
+				if (children [index] == this) break;
+				index++;
+			}
+			index++;
+			if (index < children.length) {
+				if (children [index].setFocus ()) return result;
+			}
+			control = control.parent;
+		}
+	}
+	return result;
+}
+
+boolean mnemonicMatch (char key) {
+	if (labelHandle == 0) return false;
+	return mnemonicMatch (labelHandle, key);
+}
+
+void register () {
+	super.register ();
+	if (frameHandle != 0) display.addWidget (frameHandle, this);
+	if (labelHandle != 0) display.addWidget (labelHandle, this);
+	if (imageHandle != 0) display.addWidget (imageHandle, this);
+}
+
+void releaseHandle () {
+	super.releaseHandle ();
+	frameHandle = imageHandle = labelHandle = 0;
+}
+
+void releaseWidget () {
+	super.releaseWidget ();
+	if (imageList != null) imageList.dispose ();
+	imageList = null;
+	image = null;
+	text = null;
+}
+
+void resizeHandle (int width, int height) {
+	OS.gtk_widget_set_size_request (fixedHandle, width, height);
+	OS.gtk_widget_set_size_request (frameHandle != 0 ? frameHandle : handle, width, height);
+}
+
+/**
+ * Controls how text and images will be displayed in the receiver.
+ * The argument should be one of <code>LEFT</code>, <code>RIGHT</code>
+ * or <code>CENTER</code>.  If the receiver is a <code>SEPARATOR</code>
+ * label, the argument is ignored and the alignment is not changed.
+ *
+ * @param alignment the new alignment 
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setAlignment (int alignment) {
+	checkWidget ();
+	if ((style & SWT.SEPARATOR) != 0) return;
+	if ((alignment & (SWT.LEFT | SWT.RIGHT | SWT.CENTER)) == 0) return;
+	style &= ~(SWT.LEFT | SWT.RIGHT | SWT.CENTER);
+	style |= alignment & (SWT.LEFT | SWT.RIGHT | SWT.CENTER);
+	setAlignment ();
+}
+
+void setAlignment () {
+	boolean isRTL = (style & SWT.RIGHT_TO_LEFT) != 0;
+	if (text != null && text.length () != 0) {
+		if (OS.GTK_VERSION >= OS.VERSION(2, 4, 0)) {
+			int /*long*/ layout = OS.gtk_label_get_layout (labelHandle);
+			int /*long*/ linePtr = OS.pango_layout_get_line (layout, 0);
+			int resolved_dir = OS.pango_layout_line_get_resolved_dir (linePtr);
+			if (resolved_dir == OS.PANGO_DIRECTION_RTL) {
+				isRTL = !isRTL;
+			}
+		}
+	}
+	if ((style & SWT.LEFT) != 0) {
+		OS.gtk_misc_set_alignment (labelHandle, 0.0f, 0.0f);
+		OS.gtk_label_set_justify (labelHandle, isRTL ? OS.GTK_JUSTIFY_RIGHT : OS.GTK_JUSTIFY_LEFT);
+		OS.gtk_misc_set_alignment (imageHandle, 0.0f, 0.5f);
+		return;
+	}
+	if ((style & SWT.CENTER) != 0) {
+		OS.gtk_misc_set_alignment (labelHandle, 0.5f, 0.0f);
+		OS.gtk_label_set_justify (labelHandle, OS.GTK_JUSTIFY_CENTER);
+		OS.gtk_misc_set_alignment (imageHandle, 0.5f, 0.5f);
+		return;
+	}
+	if ((style & SWT.RIGHT) != 0) {
+		OS.gtk_misc_set_alignment (labelHandle, 1.0f, 0.0f);
+		OS.gtk_label_set_justify (labelHandle, isRTL ? OS.GTK_JUSTIFY_LEFT : OS.GTK_JUSTIFY_RIGHT);
+		OS.gtk_misc_set_alignment (imageHandle, 1.0f, 0.5f);
+		return;
+	}
+}
+
+void setBackgroundColor (GdkColor color) {
+	super.setBackgroundColor (color);
+	setBackgroundColor(fixedHandle, color);
+	if (labelHandle != 0) setBackgroundColor(labelHandle, color);
+	if (imageHandle != 0) setBackgroundColor(imageHandle, color);
+}
+
+int setBounds (int x, int y, int width, int height, boolean move, boolean resize) {
+	/*
+	* Bug in GTK.  For some reason, when the label is
+	* wrappable and its container is resized, it does not
+	* cause the label to be wrapped.  The fix is to
+	* determine the size that will wrap the label
+	* and expilictly set that size to force the label
+	* to wrap.
+	* 
+	* This part of the fix causes the label to be
+	* resized to the preferred size but it still
+	* won't draw properly.
+	*/
+	boolean fixWrap = resize && labelHandle != 0 && (style & SWT.WRAP) != 0;
+	if (fixWrap) OS.gtk_widget_set_size_request (labelHandle, -1, -1);
+	int result = super.setBounds (x, y, width, height, move, resize);
+	/*
+	* Bug in GTK.  For some reason, when the label is
+	* wrappable and its container is resized, it does not
+	* cause the label to be wrapped.  The fix is to
+	* determine the size that will wrap the label
+	* and expilictly set that size to force the label
+	* to wrap.
+	* 
+	* This part of the fix forces the label to be
+	* resized so that it will draw wrapped.
+	*/
+	if (fixWrap) {
+		int labelWidth = OS.GTK_WIDGET_WIDTH (handle);
+		int labelHeight = OS.GTK_WIDGET_HEIGHT (handle);
+		OS.gtk_widget_set_size_request (labelHandle, labelWidth, labelHeight);
+		/*
+		* Bug in GTK.  Setting the size request should invalidate the label's
+		* layout, but it does not.  The fix is to resize the label directly. 
+		*/
+		GtkRequisition requisition = new GtkRequisition ();
+		OS.gtk_widget_size_request (labelHandle, requisition);
+		GtkAllocation allocation = new GtkAllocation ();
+		allocation.x = OS.GTK_WIDGET_X (labelHandle);
+		allocation.y = OS.GTK_WIDGET_Y (labelHandle);
+		allocation.width = labelWidth;
+		allocation.height = labelHeight;
+		OS.gtk_widget_size_allocate (labelHandle, allocation);
+	}
+	return result;
+}
+
+void setFontDescription (int /*long*/ font) {
+	super.setFontDescription (font);
+	if (labelHandle != 0) OS.gtk_widget_modify_font (labelHandle, font);
+	if (imageHandle != 0) OS.gtk_widget_modify_font (imageHandle, font);
+}
+
+void setForegroundColor (GdkColor color) {
+	super.setForegroundColor (color);
+	setForegroundColor (fixedHandle, color);
+	if (labelHandle != 0) setForegroundColor (labelHandle, color);
+	if (imageHandle != 0) setForegroundColor (imageHandle, color);
+}
+
+void setOrientation () {
+	super.setOrientation ();
+	if ((style & SWT.RIGHT_TO_LEFT) != 0) {
+		if (labelHandle != 0) OS.gtk_widget_set_direction (labelHandle, OS.GTK_TEXT_DIR_RTL);
+		if (imageHandle != 0) OS.gtk_widget_set_direction (imageHandle, OS.GTK_TEXT_DIR_RTL);
+	}
+}
+
+/**
+ * Sets the receiver's image to the argument, which may be
+ * null indicating that no image should be displayed.
+ *
+ * @param image the image to display on the receiver (may be null)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li> 
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setImage (Image image) {
+	checkWidget ();
+	if ((style & SWT.SEPARATOR) != 0) return;
+	this.image = image;
+	if (imageList != null) imageList.dispose ();
+	imageList = null;
+	if (image != null) {
+		imageList = new ImageList ();
+		int imageIndex = imageList.add (image);
+		int /*long*/ pixbuf = imageList.getPixbuf (imageIndex);
+		OS.gtk_image_set_from_pixbuf (imageHandle, pixbuf);
+		OS.gtk_widget_hide (labelHandle);
+		OS.gtk_widget_show (imageHandle);
+	} else {
+		OS.gtk_image_set_from_pixbuf (imageHandle, 0);
+		OS.gtk_widget_show (labelHandle);
+		OS.gtk_widget_hide (imageHandle);
+	}
+}
+
+/**
+ * Sets the receiver's text.
+ * <p>
+ * This method sets the widget label.  The label may include
+ * the mnemonic character and line delimiters.
+ * </p>
+ * <p>
+ * Mnemonics are indicated by an '&amp;' that causes the next
+ * character to be the mnemonic.  When the user presses a
+ * key sequence that matches the mnemonic, focus is assigned
+ * to the control that follows the label. On most platforms,
+ * the mnemonic appears underlined but may be emphasised in a
+ * platform specific manner.  The mnemonic indicator character
+ * '&amp;' can be escaped by doubling it in the string, causing
+ * a single '&amp;' to be displayed.
+ * </p>
+ * 
+ * @param string the new text
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the text is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setText (String string) {
+	checkWidget ();
+	if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if ((style & SWT.SEPARATOR) != 0) return;
+	text = string;
+	char [] chars = fixMnemonic (string);
+	byte [] buffer = Converter.wcsToMbcs (null, chars, true);
+	OS.gtk_label_set_text_with_mnemonic (labelHandle, buffer);
+	OS.gtk_widget_hide (imageHandle);
+	OS.gtk_widget_show (labelHandle);
+	setAlignment ();
+}
+
+void showWidget () {
+	super.showWidget ();
+	if (frameHandle != 0) OS.gtk_widget_show (frameHandle);
+	if (labelHandle != 0) OS.gtk_widget_show (labelHandle);
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Layout.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Layout.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Layout.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,104 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.widgets;
+
+
+import org.eclipse.swt.graphics.*;
+
+/**
+ * A layout controls the position and size
+ * of the children of a composite widget.
+ * This class is the abstract base class for
+ * layouts.
+ * 
+ * @see Composite#setLayout(Layout)
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public abstract class Layout {
+
+/**
+ * Computes and returns the size of the specified
+ * composite's client area according to this layout.
+ * <p>
+ * This method computes the size that the client area 
+ * of the composite must be in order to position all 
+ * children at their preferred size inside the
+ * composite according to the layout algorithm
+ * encoded by this layout.
+ * </p>
+ * <p>
+ * When a width or height hint is supplied, it is
+ * used to constrain the result. For example, if a
+ * width hint is provided that is less than the
+ * width of the client area, the layout may choose
+ * to wrap and increase height, clip, overlap, or
+ * otherwise constrain the children.
+ * </p>
+ *
+ * @param composite a composite widget using this layout
+ * @param wHint width (<code>SWT.DEFAULT</code> for preferred size)
+ * @param hHint height (<code>SWT.DEFAULT</code> for preferred size)
+ * @param flushCache <code>true</code> means flush cached layout values
+ * @return a point containing the computed size (width, height)
+ * 
+ * @see #layout
+ * @see Control#getBorderWidth
+ * @see Control#getBounds
+ * @see Control#getSize
+ * @see Control#pack(boolean)
+ * @see "computeTrim, getClientArea for controls that implement them"
+ */
+protected abstract Point computeSize (Composite composite, int wHint, int hHint, boolean flushCache);
+
+/**
+ * Instruct the layout to flush any cached values
+ * associated with the control specified in the argument 
+ * <code>control</code>.
+ * 
+ * @param control a control managed by this layout
+ * @return true if the Layout has flushed all cached information associated with control
+ * 
+ * @since 3.1
+ */
+protected boolean flushCache (Control control) {
+	return false;
+}
+
+/**
+ * Lays out the children of the specified composite
+ * according to this layout.
+ * <p>
+ * This method positions and sizes the children of a
+ * composite using the layout algorithm encoded by this
+ * layout. Children of the composite are positioned in
+ * the client area of the composite. The position of
+ * the composite is not altered by this method.
+ * </p>
+ * <p>
+ * When the flush cache hint is true, the layout is
+ * instructed to flush any cached values associated
+ * with the children. Typically, a layout will cache
+ * the preferred sizes of the children to avoid the
+ * expense of computing these values each time the
+ * widget is laid out.
+ * </p>
+ * <p>
+ * When layout is triggered explicitly by the programmer
+ * the flush cache hint is true. When layout is triggered
+ * by a resize, either caused by the programmer or by the
+ * user, the hint is false.
+ * </p>
+ *
+ * @param composite a composite widget using this layout
+ * @param flushCache <code>true</code> means flush cached layout values
+ */
+protected abstract void layout (Composite composite, boolean flushCache);
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Link.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Link.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Link.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,738 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.widgets;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.gtk.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.accessibility.*;
+
+/**
+ * Instances of this class represent a selectable
+ * user interface object that displays a text with 
+ * links.
+ * <p>
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>(none)</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Selection</dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ *
+ * @see <a href="http://www.eclipse.org/swt/snippets/#link">Link snippets</a>
+ * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: ControlExample</a>
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ * 
+ * @since 3.1
+ */
+public class Link extends Control {
+	String text;
+	TextLayout layout;
+	Color linkColor, disabledColor;
+	Point [] offsets;
+	Point selection;
+	String [] ids;
+	int [] mnemonics;
+	int focusIndex;
+	
+	static final RGB LINK_FOREGROUND = new RGB (0, 51, 153);
+	static final RGB LINK_DISABLED_FOREGROUND = new RGB (172, 168, 153);
+	
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public Link (Composite parent, int style) {
+	super (parent, style);
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the control is selected by the user, by sending
+ * it one of the messages defined in the <code>SelectionListener</code>
+ * interface.
+ * <p>
+ * <code>widgetSelected</code> is called when the control is selected by the user.
+ * <code>widgetDefaultSelected</code> is not called.
+ * </p>
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent
+ */
+public void addSelectionListener (SelectionListener listener) {
+	checkWidget ();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	TypedListener typedListener = new TypedListener (listener);
+	addListener (SWT.Selection, typedListener);
+	addListener (SWT.DefaultSelection, typedListener);
+}
+
+public Point computeSize (int wHint, int hHint, boolean changed) {
+	checkWidget ();
+	if (wHint != SWT.DEFAULT && wHint < 0) wHint = 0;
+	if (hHint != SWT.DEFAULT && hHint < 0) hHint = 0;
+	int width, height;
+	int layoutWidth = layout.getWidth ();
+	//TEMPORARY CODE
+	if (wHint == 0) {
+		layout.setWidth (1);
+		Rectangle rect = layout.getBounds ();
+		width = 0;
+		height = rect.height;
+	} else {
+		layout.setWidth (wHint);
+		Rectangle rect = layout.getBounds ();
+		width = rect.width;
+		height = rect.height;
+	}
+	layout.setWidth (layoutWidth);
+	if (wHint != SWT.DEFAULT) width = wHint;
+	if (hHint != SWT.DEFAULT) height = hHint;
+	int border = getBorderWidth ();
+	width += border * 2;
+	height += border * 2;
+	return new Point (width, height);
+}
+
+void createHandle(int index) {
+	state |= HANDLE | THEME_BACKGROUND;
+	handle = OS.g_object_new (display.gtk_fixed_get_type (), 0);
+	if (handle == 0) SWT.error (SWT.ERROR_NO_HANDLES);
+	OS.gtk_fixed_set_has_window (handle, true);
+	OS.GTK_WIDGET_SET_FLAGS (handle, OS.GTK_CAN_FOCUS);
+	layout = new TextLayout (display);
+	layout.setOrientation((style & SWT.RIGHT_TO_LEFT) != 0? SWT.RIGHT_TO_LEFT : SWT.LEFT_TO_RIGHT);
+	linkColor = new Color (display, LINK_FOREGROUND);
+	disabledColor = new Color (display, LINK_DISABLED_FOREGROUND);
+	offsets = new Point [0];
+	ids = new String [0];
+	mnemonics = new int [0];
+	selection = new Point (-1, -1);
+	focusIndex = -1;
+}
+
+void createWidget (int index) {
+	super.createWidget (index);
+	layout.setFont (getFont ());
+	text = "";
+	initAccessible ();
+}
+
+void enableWidget (boolean enabled) {
+	super.enableWidget (enabled);
+	if (isDisposed ()) return;
+	TextStyle linkStyle = new TextStyle (null, enabled ? linkColor : disabledColor, null);
+	linkStyle.underline = true;
+	for (int i = 0; i < offsets.length; i++) {
+		Point point = offsets [i];
+		layout.setStyle (linkStyle, point.x, point.y);
+	}
+	redraw ();
+}
+
+void fixStyle () {
+	fixStyle (handle);
+}
+
+void initAccessible () {
+	Accessible accessible = getAccessible ();
+	accessible.addAccessibleListener (new AccessibleAdapter () {
+		public void getName (AccessibleEvent e) {
+			e.result = parse (text);
+		}
+	});
+		
+	accessible.addAccessibleControlListener (new AccessibleControlAdapter () {
+		public void getChildAtPoint (AccessibleControlEvent e) {
+			e.childID = ACC.CHILDID_SELF;
+		}
+		
+		public void getLocation (AccessibleControlEvent e) {
+			Rectangle rect = display.map (getParent (), null, getBounds ());
+			e.x = rect.x;
+			e.y = rect.y;
+			e.width = rect.width;
+			e.height = rect.height;
+		}
+		
+		public void getChildCount (AccessibleControlEvent e) {
+			e.detail = 0;
+		}
+		
+		public void getRole (AccessibleControlEvent e) {
+			e.detail = ACC.ROLE_LINK;
+		}
+		
+		public void getState (AccessibleControlEvent e) {
+			e.detail = ACC.STATE_FOCUSABLE;
+			if (hasFocus ()) e.detail |= ACC.STATE_FOCUSED;
+		}
+		
+		public void getDefaultAction (AccessibleControlEvent e) {
+			e.result = SWT.getMessage ("SWT_Press"); //$NON-NLS-1$
+		}
+		
+		public void getSelection (AccessibleControlEvent e) {
+			if (hasFocus ()) e.childID = ACC.CHILDID_SELF;
+		}
+		
+		public void getFocus (AccessibleControlEvent e) {
+			if (hasFocus ()) e.childID = ACC.CHILDID_SELF;
+		}
+	});
+}
+
+String getNameText () {
+	return getText ();
+}
+
+Rectangle [] getRectangles (int linkIndex) {
+	int lineCount = layout.getLineCount ();
+	Rectangle [] rects = new Rectangle [lineCount];
+	int [] lineOffsets = layout.getLineOffsets ();
+	Point point = offsets [linkIndex];
+	int lineStart = 1;
+	while (point.x > lineOffsets [lineStart]) lineStart++;
+	int lineEnd = 1;
+	while (point.y > lineOffsets [lineEnd]) lineEnd++;
+	int index = 0;
+	if (lineStart == lineEnd) {
+		rects [index++] = layout.getBounds (point.x, point.y);		
+	} else {
+		rects [index++] = layout.getBounds (point.x, lineOffsets [lineStart]-1);
+		rects [index++] = layout.getBounds (lineOffsets [lineEnd-1], point.y);
+		if (lineEnd - lineStart > 1) {
+			for (int i = lineStart; i < lineEnd - 1; i++) {
+				rects [index++] = layout.getLineBounds (i);
+			}
+		}
+	}
+	if (rects.length != index) {
+		Rectangle [] tmp = new Rectangle [index];
+		System.arraycopy (rects, 0, tmp, 0, index);
+		rects = tmp;
+	}	
+	return rects;
+}
+
+int getClientWidth () {
+	return (state & ZERO_WIDTH) != 0 ? 0 : OS.GTK_WIDGET_WIDTH (handle);
+}
+
+/**
+ * Returns the receiver's text, which will be an empty
+ * string if it has never been set.
+ *
+ * @return the receiver's text
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public String getText () {
+	checkWidget ();
+	return text;
+}
+
+int /*long*/ gtk_button_press_event (int /*long*/ widget, int /*long*/ event) {
+	int /*long*/ result = super.gtk_button_press_event (widget, event);	
+	if (result != 0) return result;
+	GdkEventButton gdkEvent = new GdkEventButton ();
+	OS.memmove (gdkEvent, event, GdkEventButton.sizeof);
+	if (gdkEvent.button == 1 && gdkEvent.type == OS.GDK_BUTTON_PRESS) {
+		if (focusIndex != -1) setFocus ();
+		int x = (int) gdkEvent.x;
+		int y = (int) gdkEvent.y;
+		if ((style & SWT.MIRRORED) != 0) x = getClientWidth () - x;
+		int offset = layout.getOffset (x, y, null);
+		int oldSelectionX = selection.x;
+		int oldSelectionY = selection.y;
+		selection.x = offset;
+		selection.y = -1;
+		if (oldSelectionX != -1 && oldSelectionY != -1) {
+			if (oldSelectionX > oldSelectionY) {
+				int temp = oldSelectionX;
+				oldSelectionX = oldSelectionY;
+				oldSelectionY = temp;
+			}
+			Rectangle rect = layout.getBounds (oldSelectionX, oldSelectionY);
+			redraw (rect.x, rect.y, rect.width, rect.height, false);
+		}
+		for (int j = 0; j < offsets.length; j++) {
+			Rectangle [] rects = getRectangles (j);
+			for (int i = 0; i < rects.length; i++) {
+				Rectangle rect = rects [i];
+				if (rect.contains (x, y)) {
+					focusIndex = j;						
+					redraw ();
+					return result;
+				}
+			}
+		}
+	}
+	return result;
+}
+
+int /*long*/ gtk_button_release_event (int /*long*/ widget, int /*long*/ event) {
+	int /*long*/ result = super.gtk_button_release_event (widget, event);
+	if (result != 0) return result;
+	if (focusIndex == -1) return result;
+	GdkEventButton gdkEvent = new GdkEventButton ();
+	OS.memmove (gdkEvent, event, GdkEventButton.sizeof);
+	if (gdkEvent.button == 1) {
+		int x = (int) gdkEvent.x;
+		int y = (int) gdkEvent.y;
+		if ((style & SWT.MIRRORED) != 0) x = getClientWidth () - x;
+		Rectangle [] rects = getRectangles (focusIndex);
+		for (int i = 0; i < rects.length; i++) {
+			Rectangle rect = rects [i];
+			if (rect.contains (x, y)) {
+				Event ev = new Event ();
+				ev.text = ids [focusIndex];
+				sendEvent (SWT.Selection, ev);
+				return result;
+			}
+		}
+	}
+	return result;
+}
+
+int /*long*/ gtk_event_after (int /*long*/ widget, int /*long*/ gdkEvent) {
+	int /*long*/ result = super.gtk_event_after (widget, gdkEvent);
+	GdkEvent event = new GdkEvent ();
+	OS.memmove (event, gdkEvent, GdkEvent.sizeof);
+	switch (event.type) {
+		case OS.GDK_FOCUS_CHANGE:
+			redraw ();
+			break;
+	}
+	return result;
+}
+
+int /*long*/ gtk_expose_event (int /*long*/ widget, int /*long*/ eventPtr) {
+	if ((state & OBSCURED) != 0) return 0;
+	GdkEventExpose gdkEvent = new GdkEventExpose ();
+	OS.memmove (gdkEvent, eventPtr, GdkEventExpose.sizeof);
+	GCData data = new GCData ();
+	data.damageRgn = gdkEvent.region;
+	GC gc = GC.gtk_new (this, data);
+	OS.gdk_gc_set_clip_region (gc.handle, gdkEvent.region);
+	int selStart = selection.x;
+	int selEnd = selection.y;
+	if (selStart > selEnd) {
+		selStart = selection.y;
+		selEnd = selection.x;
+	}
+	// temporary code to disable text selection
+	selStart = selEnd = -1;
+	if ((state & DISABLED) != 0) gc.setForeground (disabledColor);
+	layout.draw (gc, 0, 0, selStart, selEnd, null, null);
+	if (hasFocus () && focusIndex != -1) {
+		Rectangle [] rects = getRectangles (focusIndex);
+		for (int i = 0; i < rects.length; i++) {
+			Rectangle rect = rects [i];
+			gc.drawFocus (rect.x, rect.y, rect.width, rect.height);					
+		}
+	}
+	if (hooks (SWT.Paint) || filters (SWT.Paint)) {
+		Event event = new Event ();
+		event.count = gdkEvent.count;
+		event.x = gdkEvent.area_x;
+		event.y = gdkEvent.area_y;
+		event.width = gdkEvent.area_width;
+		event.height = gdkEvent.area_height;
+		if ((style & SWT.MIRRORED) != 0) event.x = getClientWidth () - event.width - event.x;
+		event.gc = gc;
+		sendEvent (SWT.Paint, event);
+		event.gc = null;
+	}
+	gc.dispose ();
+	return 0;
+}
+
+int /*long*/ gtk_key_press_event (int /*long*/ widget, int /*long*/ eventPtr) {
+	int /*long*/ result = super.gtk_key_press_event (widget, eventPtr);
+	if (result != 0) return result;
+	if (focusIndex == -1) return result;
+	GdkEventKey gdkEvent = new GdkEventKey ();
+	OS.memmove (gdkEvent, eventPtr, GdkEventKey.sizeof);
+	switch (gdkEvent.keyval) {
+		case OS.GDK_Return:
+		case OS.GDK_KP_Enter:
+		case OS.GDK_space:
+			Event event = new Event ();
+			event.text = ids [focusIndex];
+			sendEvent (SWT.Selection, event);
+			break;
+		case OS.GDK_Tab:
+			if (focusIndex < offsets.length - 1) {
+				focusIndex++;
+				redraw ();
+			}
+			break;
+		case OS.GDK_ISO_Left_Tab:
+			if (focusIndex > 0) {
+				focusIndex--;
+				redraw ();
+			}
+			break;
+	}
+	return result;
+}
+
+int /*long*/ gtk_motion_notify_event (int /*long*/ widget, int /*long*/ event) {
+	int /*long*/ result = super.gtk_motion_notify_event (widget, event);
+	if (result != 0) return result;
+	GdkEventMotion gdkEvent = new GdkEventMotion ();
+	OS.memmove (gdkEvent, event, GdkEventMotion.sizeof);
+	int x = (int) gdkEvent.x;
+	int y = (int) gdkEvent.y;	
+	if ((style & SWT.MIRRORED) != 0) x = getClientWidth () - x;
+	if ((gdkEvent.state & OS.GDK_BUTTON1_MASK) != 0) {
+		int oldSelection = selection.y;
+		selection.y = layout.getOffset (x, y, null);
+		if (selection.y != oldSelection) {
+			int newSelection = selection.y;
+			if (oldSelection > newSelection) {
+				int temp = oldSelection;
+				oldSelection = newSelection;
+				newSelection = temp;
+			}
+			Rectangle rect = layout.getBounds (oldSelection, newSelection);
+			redraw (rect.x, rect.y, rect.width, rect.height, false);
+		}
+	} else {
+		for (int j = 0; j < offsets.length; j++) {
+			Rectangle [] rects = getRectangles (j);
+			for (int i = 0; i < rects.length; i++) {
+				Rectangle rect = rects [i];
+				if (rect.contains (x, y)) {
+					setCursor (display.getSystemCursor (SWT.CURSOR_HAND));
+					return result;
+				}
+			}
+		}
+		setCursor (null);
+	}
+	return result;
+}
+
+void releaseWidget () {
+	super.releaseWidget ();
+	if (layout != null)	layout.dispose ();
+	layout = null;
+	if (linkColor != null)	linkColor.dispose ();
+	linkColor = null;
+	if (disabledColor != null) disabledColor.dispose ();
+	disabledColor = null;
+	offsets = null;
+	ids = null;
+	mnemonics = null;
+	text = null;
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the control is selected by the user.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #addSelectionListener
+ */
+public void removeSelectionListener (SelectionListener listener) {
+	checkWidget ();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if (eventTable == null) return;
+	eventTable.unhook (SWT.Selection, listener);
+	eventTable.unhook (SWT.DefaultSelection, listener);	
+}
+
+String parse (String string) {
+	int length = string.length ();
+	offsets = new Point [length / 4];
+	ids = new String [length / 4];
+	mnemonics = new int [length / 4 + 1];
+	StringBuffer result = new StringBuffer ();
+	char [] buffer = new char [length];
+	string.getChars (0, string.length (), buffer, 0);
+	int index = 0, state = 0, linkIndex = 0;
+	int start = 0, tagStart = 0, linkStart = 0, endtagStart = 0, refStart = 0;
+	while (index < length) {
+		char c = Character.toLowerCase (buffer [index]);
+		switch (state) {
+			case 0: 
+				if (c == '<') {
+					tagStart = index;
+					state++;
+				}
+				break;
+			case 1:
+				if (c == 'a') state++;
+				break;
+			case 2:
+				switch (c) {
+					case 'h':
+						state = 7;
+						break;
+					case '>':
+						linkStart = index  + 1;
+						state++;
+						break;
+					default:
+						if (Character.isWhitespace(c)) break;
+						else state = 13;
+				}
+				break;
+			case 3:
+				if (c == '<') {
+					endtagStart = index;
+					state++;
+				}
+				break;
+			case 4:
+				state = c == '/' ? state + 1 : 3;
+				break;
+			case 5:
+				state = c == 'a' ? state + 1 : 3;
+				break;
+			case 6:
+				if (c == '>') {
+					mnemonics [linkIndex] = parseMnemonics (buffer, start, tagStart, result);
+					int offset = result.length ();
+					parseMnemonics (buffer, linkStart, endtagStart, result);
+					offsets [linkIndex] = new Point (offset, result.length () - 1);
+					if (ids [linkIndex] == null) {
+						ids [linkIndex] = new String (buffer, linkStart, endtagStart - linkStart);
+					}
+					linkIndex++;
+					start = tagStart = linkStart = endtagStart = refStart = index + 1;
+					state = 0;
+				} else {
+					state = 3;
+				}
+				break;
+			case 7:
+				state = c == 'r' ? state + 1 : 0;
+				break;
+			case 8:
+				state = c == 'e' ? state + 1 : 0;
+				break;
+			case 9:
+				state = c == 'f' ? state + 1 : 0;
+				break;
+			case 10:
+				state = c == '=' ? state + 1 : 0;
+				break;
+			case 11:
+				if (c == '"') {
+					state++;
+					refStart = index + 1;
+				} else {
+					state = 0;
+				}
+				break;
+			case 12:
+				if (c == '"') {
+					ids[linkIndex] = new String (buffer, refStart, index - refStart);
+					state = 2;
+				}
+				break;
+			case 13:
+				if (Character.isWhitespace (c)) {
+					state = 0;
+				} else if (c == '='){
+					state++;
+				}
+				break;
+			case 14:
+				state = c == '"' ? state + 1 : 0;
+				break;
+			case 15:
+				if (c == '"') state = 2;
+				break;
+			default:
+				state = 0;
+				break;
+		}
+		index++;
+	}
+	if (start < length) {
+		int tmp = parseMnemonics (buffer, start, tagStart, result);
+		int mnemonic = parseMnemonics (buffer, Math.max (tagStart, linkStart), length, result);
+		if (mnemonic == -1) mnemonic = tmp;
+		mnemonics [linkIndex] = mnemonic;
+	} else {
+		mnemonics [linkIndex] = -1;
+	}
+	if (offsets.length != linkIndex) {
+		Point [] newOffsets = new Point [linkIndex];
+		System.arraycopy (offsets, 0, newOffsets, 0, linkIndex);
+		offsets = newOffsets;
+		String [] newIDs = new String [linkIndex];
+		System.arraycopy (ids, 0, newIDs, 0, linkIndex);
+		ids = newIDs;
+		int [] newMnemonics = new int [linkIndex + 1];
+		System.arraycopy (mnemonics, 0, newMnemonics, 0, linkIndex + 1);
+		mnemonics = newMnemonics;		
+	}
+	return result.toString ();
+}
+
+int parseMnemonics (char[] buffer, int start, int end, StringBuffer result) {
+	int mnemonic = -1, index = start;
+	while (index < end) {
+		if (buffer [index] == '&') {
+			if (index + 1 < end && buffer [index + 1] == '&') {
+				result.append (buffer [index]);
+				index++;
+			} else {
+				mnemonic = result.length();
+			}
+		} else {
+			result.append (buffer [index]);
+		}
+		index++;
+	}
+	return mnemonic;
+}
+
+int setBounds(int x, int y, int width, int height, boolean move, boolean resize) {
+	int result = super.setBounds (x, y, width,height, move, resize);
+	if ((result & RESIZED) != 0) {		
+		layout.setWidth (width > 0 ? width : -1);
+		redraw ();
+	}
+	return result;
+}
+
+void setFontDescription (int /*long*/ font) {
+	super.setFontDescription (font);
+	layout.setFont (Font.gtk_new (display, font));
+}
+
+/**
+ * Sets the receiver's text.
+ * <p>
+ * The string can contain both regular text and hyperlinks.  A hyperlink
+ * is delimited by an anchor tag, &lt;A&gt; and &lt;/A&gt;.  Within an
+ * anchor, a single HREF attribute is supported.  When a hyperlink is
+ * selected, the text field of the selection event contains either the
+ * text of the hyperlink or the value of its HREF, if one was specified.
+ * In the rare case of identical hyperlinks within the same string, the
+ * HREF tag can be used to distinguish between them.  The string may
+ * include the mnemonic character and line delimiters.
+ * </p>
+ * 
+ * @param string the new text
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the text is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setText (String string) {
+	checkWidget ();
+	if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if (string.equals (text)) return;
+	text = string;
+	layout.setText (parse (string));
+	focusIndex = offsets.length > 0 ? 0 : -1;
+	selection.x = selection.y = -1;
+	boolean enabled = (state & DISABLED) == 0;
+	TextStyle linkStyle = new TextStyle (null, enabled ? linkColor : disabledColor, null);
+	linkStyle.underline = true;
+	int [] bidiSegments = new int [offsets.length*2];
+	for (int i = 0; i < offsets.length; i++) {
+		Point point = offsets [i];
+		layout.setStyle (linkStyle, point.x, point.y);
+		bidiSegments[i*2] = point.x;
+		bidiSegments[i*2+1] = point.y+1;
+	}
+	layout.setSegments (bidiSegments);
+	TextStyle mnemonicStyle = new TextStyle (null, null, null);
+	mnemonicStyle.underline = true;
+	for (int i = 0; i < mnemonics.length; i++) {
+		int mnemonic  = mnemonics [i];
+		if (mnemonic != -1) {
+			layout.setStyle (mnemonicStyle, mnemonic, mnemonic);
+		}
+	}
+	redraw ();
+}
+
+void showWidget () {
+	super.showWidget ();
+	fixStyle (handle);
+}
+
+int traversalCode (int key, GdkEventKey event) {
+	if (offsets.length == 0) return 0;
+	int bits = super.traversalCode (key, event);
+	if (key == OS.GDK_Tab && focusIndex < offsets.length - 1) {
+		return bits & ~SWT.TRAVERSE_TAB_NEXT;
+	}
+	if (key == OS.GDK_ISO_Left_Tab && focusIndex > 0) {
+		return bits & ~SWT.TRAVERSE_TAB_PREVIOUS;
+	}
+	return bits;
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/List.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/List.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/List.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,1593 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.widgets;
+
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.gtk.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.events.*;
+
+/** 
+ * Instances of this class represent a selectable user interface
+ * object that displays a list of strings and issues notification
+ * when a string is selected.  A list may be single or multi select.
+ * <p>
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>SINGLE, MULTI</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Selection, DefaultSelection</dd>
+ * </dl>
+ * <p>
+ * Note: Only one of SINGLE and MULTI may be specified.
+ * </p><p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ *
+ * @see <a href="http://www.eclipse.org/swt/snippets/#list">List snippets</a>
+ * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: ControlExample</a>
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public class List extends Scrollable {
+	int /*long*/ modelHandle;
+
+	static final int TEXT_COLUMN = 0;
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT#SINGLE
+ * @see SWT#MULTI
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public List (Composite parent, int style) {
+	super (parent, checkStyle (style));
+}
+
+/**
+ * Adds the argument to the end of the receiver's list.
+ *
+ * @param string the new item
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #add(String,int)
+ */
+public void add (String string) {
+	checkWidget();
+	if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+	byte [] buffer = Converter.wcsToMbcs (null, string, true);
+	int /*long*/ iter = OS.g_malloc (OS.GtkTreeIter_sizeof ());
+	if (iter == 0) error (SWT.ERROR_ITEM_NOT_ADDED);
+	OS.gtk_list_store_append (modelHandle, iter);
+	OS.gtk_list_store_set (modelHandle, iter, TEXT_COLUMN, buffer, -1);
+	OS.g_free (iter);
+}
+
+/**
+ * Adds the argument to the receiver's list at the given
+ * zero-relative index.
+ * <p>
+ * Note: To add an item at the end of the list, use the
+ * result of calling <code>getItemCount()</code> as the
+ * index or use <code>add(String)</code>.
+ * </p>
+ *
+ * @param string the new item
+ * @param index the index for the item
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list (inclusive)</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #add(String)
+ */
+public void add (String string, int index) {
+	checkWidget();
+	if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+	int count = OS.gtk_tree_model_iter_n_children (modelHandle, 0);
+	if (!(0 <= index && index <= count)) {
+		error (SWT.ERROR_INVALID_RANGE);
+	}
+	byte [] buffer = Converter.wcsToMbcs (null, string, true);
+	int /*long*/ iter = OS.g_malloc (OS.GtkTreeIter_sizeof ());
+	if (iter == 0) error (SWT.ERROR_ITEM_NOT_ADDED);
+	/*
+	* Feature in GTK.  It is much faster to append to a list store
+	* than to insert at the end using gtk_list_store_insert(). 
+	*/
+	if (index == count) {
+		OS.gtk_list_store_append (modelHandle, iter);
+	} else {
+		OS.gtk_list_store_insert (modelHandle, iter, index);
+	}
+	OS.gtk_list_store_set (modelHandle, iter, TEXT_COLUMN, buffer, -1);
+	OS.g_free (iter);
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the user changes the receiver's selection, by sending
+ * it one of the messages defined in the <code>SelectionListener</code>
+ * interface.
+ * <p>
+ * <code>widgetSelected</code> is called when the selection changes.
+ * <code>widgetDefaultSelected</code> is typically called when an item is double-clicked.
+ * </p>
+ *
+ * @param listener the listener which should be notified when the user changes the receiver's selection
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent
+ */
+public void addSelectionListener(SelectionListener listener) {
+	checkWidget();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	TypedListener typedListener = new TypedListener (listener);
+	addListener (SWT.Selection,typedListener);
+	addListener (SWT.DefaultSelection,typedListener);
+}
+
+static int checkStyle (int style) {
+	return checkBits (style, SWT.SINGLE, SWT.MULTI, 0, 0, 0, 0);
+}
+
+void createHandle (int index) {
+	state |= HANDLE;
+	fixedHandle = OS.g_object_new (display.gtk_fixed_get_type (), 0);
+	if (fixedHandle == 0) error (SWT.ERROR_NO_HANDLES);
+	OS.gtk_fixed_set_has_window (fixedHandle, true);
+	scrolledHandle = OS.gtk_scrolled_window_new (0, 0);
+	if (scrolledHandle == 0) error (SWT.ERROR_NO_HANDLES);
+	/*
+	* Columns:
+	* 0 - text
+	*/
+	int /*long*/ [] types = new int /*long*/ [] {OS.G_TYPE_STRING ()};
+	modelHandle = OS.gtk_list_store_newv (types.length, types);
+	if (modelHandle == 0) error (SWT.ERROR_NO_HANDLES);
+	handle = OS.gtk_tree_view_new_with_model (modelHandle);
+	if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+	int /*long*/ textRenderer = OS.gtk_cell_renderer_text_new ();
+	if (textRenderer == 0) error (SWT.ERROR_NO_HANDLES);
+	int /*long*/ columnHandle = OS.gtk_tree_view_column_new ();
+	if (columnHandle == 0) error (SWT.ERROR_NO_HANDLES);
+	OS.gtk_tree_view_column_pack_start (columnHandle, textRenderer, true);
+	OS.gtk_tree_view_column_add_attribute (columnHandle, textRenderer, OS.text, TEXT_COLUMN);
+	OS.gtk_tree_view_insert_column (handle, columnHandle, index);
+	OS.gtk_container_add (fixedHandle, scrolledHandle);
+	OS.gtk_container_add (scrolledHandle, handle);
+	
+	int mode = (style & SWT.MULTI) != 0 ? OS.GTK_SELECTION_MULTIPLE : OS.GTK_SELECTION_BROWSE;
+	int /*long*/ selectionHandle = OS.gtk_tree_view_get_selection (handle);
+	OS.gtk_tree_selection_set_mode (selectionHandle, mode);
+	OS.gtk_tree_view_set_headers_visible (handle, false);	
+	int hsp = (style & SWT.H_SCROLL) != 0 ? OS.GTK_POLICY_AUTOMATIC : OS.GTK_POLICY_NEVER;
+	int vsp = (style & SWT.V_SCROLL) != 0 ? OS.GTK_POLICY_AUTOMATIC : OS.GTK_POLICY_NEVER;
+	OS.gtk_scrolled_window_set_policy (scrolledHandle, hsp, vsp);
+	if ((style & SWT.BORDER) != 0) OS.gtk_scrolled_window_set_shadow_type (scrolledHandle, OS.GTK_SHADOW_ETCHED_IN);
+	/*
+	* Bug in GTK. When a treeview is the child of an override shell, 
+	* and if the user has ever invokes the interactive search field, 
+	* and the treeview is disposed on a focus out event, it segment
+	* faults. The fix is to disable the search field in an override 
+	* shell.
+	*/
+	if ((getShell ().style & SWT.ON_TOP) != 0) {
+		/*
+		* Bug in GTK. Until GTK 2.6.5, calling gtk_tree_view_set_enable_search(FALSE)
+		* would prevent the user from being able to type in text to search the tree.
+		* After 2.6.5, GTK introduced Ctrl+F as being the key binding for interactive
+		* search. This meant that even if FALSE was passed to enable_search, the user
+		* can still bring up the search pop up using the keybinding. GTK also introduced
+		* the notion of passing a -1 to gtk_set_search_column to disable searching
+		* (including the search key binding).  The fix is to use the right calls
+		* for the right version.
+		*/
+		if (OS.GTK_VERSION >= OS.VERSION (2, 6, 5)) {
+			OS.gtk_tree_view_set_search_column (handle, -1);
+		} else {
+			OS.gtk_tree_view_set_enable_search (handle, false);
+		}
+	}
+}
+
+public Point computeSize (int wHint, int hHint, boolean changed) {
+	checkWidget ();
+	if (wHint != SWT.DEFAULT && wHint < 0) wHint = 0;
+	if (hHint != SWT.DEFAULT && hHint < 0) hHint = 0;
+	Point size = computeNativeSize (handle, wHint, hHint, changed);
+	Rectangle trim = computeTrim (0, 0, size.x, size.y);
+	size.x = trim.width;
+	size.y = trim.height;
+	return size;
+}
+
+void deregister() {
+	super.deregister ();
+	display.removeWidget (OS.gtk_tree_view_get_selection (handle));
+}
+
+/**
+ * Deselects the item at the given zero-relative index in the receiver.
+ * If the item at the index was already deselected, it remains
+ * deselected. Indices that are out of range are ignored.
+ *
+ * @param index the index of the item to deselect
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void deselect (int index) {
+	checkWidget();
+	if (!(0 <= index && index < OS.gtk_tree_model_iter_n_children (modelHandle, 0)))  return;
+	int /*long*/ iter = OS.g_malloc (OS.GtkTreeIter_sizeof ());
+	int /*long*/ selection = OS.gtk_tree_view_get_selection (handle);
+	OS.g_signal_handlers_block_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+	OS.gtk_tree_model_iter_nth_child (modelHandle, iter, 0, index); 
+	OS.gtk_tree_selection_unselect_iter (selection, iter);
+	OS.g_signal_handlers_unblock_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+	OS.g_free (iter);
+}
+
+/**
+ * Deselects the items at the given zero-relative indices in the receiver.
+ * If the item at the given zero-relative index in the receiver 
+ * is selected, it is deselected.  If the item at the index
+ * was not selected, it remains deselected.  The range of the
+ * indices is inclusive. Indices that are out of range are ignored.
+ *
+ * @param start the start index of the items to deselect
+ * @param end the end index of the items to deselect
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void deselect (int start, int end) {
+	checkWidget();
+	if (start < 0 && end < 0) return;
+	int count = OS.gtk_tree_model_iter_n_children (modelHandle, 0);
+	if (start >= count && end >= count) return;
+	start = Math.min (count - 1, Math.max (0, start));
+	end = Math.min (count - 1, Math.max (0, end));
+	int /*long*/ iter = OS.g_malloc (OS.GtkTreeIter_sizeof ());
+	int /*long*/ selection = OS.gtk_tree_view_get_selection (handle);
+	OS.g_signal_handlers_block_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+	for (int index=start; index<=end; index++) {
+		OS.gtk_tree_model_iter_nth_child (modelHandle, iter, 0, index); 
+		OS.gtk_tree_selection_unselect_iter (selection, iter);
+	}
+	OS.g_signal_handlers_unblock_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+	OS.g_free (iter);
+}
+
+/**
+ * Deselects the items at the given zero-relative indices in the receiver.
+ * If the item at the given zero-relative index in the receiver 
+ * is selected, it is deselected.  If the item at the index
+ * was not selected, it remains deselected. Indices that are out
+ * of range and duplicate indices are ignored.
+ *
+ * @param indices the array of indices for the items to deselect
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the set of indices is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void deselect (int [] indices) {
+	checkWidget();
+	if (indices == null) error (SWT.ERROR_NULL_ARGUMENT);
+	int /*long*/ iter = OS.g_malloc (OS.GtkTreeIter_sizeof ());
+	int count = OS.gtk_tree_model_iter_n_children (modelHandle, 0);
+	int /*long*/ selection = OS.gtk_tree_view_get_selection (handle);
+	OS.g_signal_handlers_block_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+	for (int i=0; i<indices.length; i++) {
+		int index = indices [i];
+		if (index < 0 || index > count - 1) continue;
+		OS.gtk_tree_model_iter_nth_child (modelHandle, iter, 0, index); 
+		OS.gtk_tree_selection_unselect_iter (selection, iter);
+	}
+	OS.g_signal_handlers_unblock_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+	OS.g_free (iter);
+}
+
+/**
+ * Deselects all selected items in the receiver.
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void deselectAll () {
+	checkWidget();
+	int /*long*/ selection = OS.gtk_tree_view_get_selection (handle);
+	OS.g_signal_handlers_block_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+	OS.gtk_tree_selection_unselect_all (selection);
+	OS.g_signal_handlers_unblock_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+}
+
+boolean dragDetect (int x, int y, boolean filter, boolean [] consume) {
+	boolean selected = false;
+	if (filter) {
+		int /*long*/ [] path = new int /*long*/ [1];
+		if (OS.gtk_tree_view_get_path_at_pos (handle, x, y, path, null, null, null)) {
+			if (path [0] != 0) {
+				int /*long*/ selection = OS.gtk_tree_view_get_selection (handle);
+				if (OS.gtk_tree_selection_path_is_selected (selection, path [0])) selected = true;
+				OS.gtk_tree_path_free (path [0]);
+			}
+		} else {
+			return false;
+		}
+	}
+	boolean dragDetect = super.dragDetect (x, y, filter, consume);
+	if (dragDetect && selected && consume != null) consume [0] = true;
+	return dragDetect;
+}
+
+int /*long*/ eventWindow () {
+	return paintWindow ();
+}
+
+GdkColor getBackgroundColor () {
+	return getBaseColor ();
+}
+
+/**
+ * Returns the zero-relative index of the item which currently
+ * has the focus in the receiver, or -1 if no item has focus.
+ *
+ * @return the index of the selected item
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getFocusIndex () {
+	checkWidget();
+	int /*long*/ [] path = new int /*long*/ [1];
+	OS.gtk_tree_view_get_cursor (handle, path, null);
+	if (path [0] == 0) return -1;
+	int /*long*/ indices = OS.gtk_tree_path_get_indices (path [0]);
+	int [] index = new int []{-1};
+	if (indices != 0) OS.memmove (index, indices, 4);
+	OS.gtk_tree_path_free (path [0]);
+	return index [0];
+}
+
+GdkColor getForegroundColor () {
+	return getTextColor ();
+}
+
+/**
+ * Returns the item at the given, zero-relative index in the
+ * receiver. Throws an exception if the index is out of range.
+ *
+ * @param index the index of the item to return
+ * @return the item at the given index
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public String getItem (int index) {
+	checkWidget();
+	if (!(0 <= index && index < OS.gtk_tree_model_iter_n_children (modelHandle, 0)))  {
+		error (SWT.ERROR_INVALID_RANGE);
+	}
+	int /*long*/ [] ptr = new int /*long*/ [1];
+	int /*long*/ iter = OS.g_malloc (OS.GtkTreeIter_sizeof ());
+	OS.gtk_tree_model_iter_nth_child (modelHandle, iter, 0, index);
+	OS.gtk_tree_model_get (modelHandle, iter, 0, ptr, -1);
+	OS.g_free (iter);
+	if (ptr [0] == 0) return null;
+	int length = OS.strlen (ptr [0]);
+	byte[] buffer2 = new byte [length];
+	OS.memmove (buffer2, ptr [0], length);
+	OS.g_free (ptr [0]);
+	return new String (Converter.mbcsToWcs (null, buffer2));
+}
+
+/**
+ * Returns the number of items contained in the receiver.
+ *
+ * @return the number of items
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getItemCount () {
+	checkWidget();
+	return OS.gtk_tree_model_iter_n_children (modelHandle, 0);
+}
+
+/**
+ * Returns the height of the area which would be used to
+ * display <em>one</em> of the items in the list.
+ *
+ * @return the height of one item
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getItemHeight () {
+	checkWidget();
+	int itemCount = OS.gtk_tree_model_iter_n_children (modelHandle, 0);
+	int /*long*/ column = OS.gtk_tree_view_get_column (handle, 0);
+	if (itemCount == 0) {
+		int [] w = new int [1], h = new int [1];
+		OS.gtk_tree_view_column_cell_get_size (column, null, null, null, w, h);
+		return h [0];
+	} else {
+		int /*long*/ iter = OS.g_malloc (OS.GtkTreeIter_sizeof ());
+		OS.gtk_tree_model_get_iter_first (modelHandle, iter);
+		OS.gtk_tree_view_column_cell_set_cell_data (column, modelHandle, iter, false, false);
+		int [] w = new int [1], h = new int [1];
+		OS.gtk_tree_view_column_cell_get_size (column, null, null, null, w, h);
+		OS.g_free (iter);
+		return h [0];
+	}
+}
+
+/**
+ * Returns a (possibly empty) array of <code>String</code>s which
+ * are the items in the receiver. 
+ * <p>
+ * Note: This is not the actual structure used by the receiver
+ * to maintain its list of items, so modifying the array will
+ * not affect the receiver. 
+ * </p>
+ *
+ * @return the items in the receiver's list
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public String [] getItems () {
+	checkWidget();
+	int count = OS.gtk_tree_model_iter_n_children (modelHandle, 0);
+	int /*long*/ [] ptr = new int /*long*/ [1];
+	String [] result = new String [count];
+	int /*long*/ iter = OS.g_malloc (OS.GtkTreeIter_sizeof ());
+	for (int index=0; index<count; index++) {
+		OS.gtk_tree_model_iter_nth_child (modelHandle, iter, 0, index);
+		OS.gtk_tree_model_get (modelHandle, iter, 0, ptr, -1);
+		if (ptr [0] != 0) {
+			int length = OS.strlen (ptr [0]);
+			byte[] buffer = new byte [length];
+			OS.memmove (buffer, ptr [0], length);
+			OS.g_free (ptr [0]);
+			result [index] = new String (Converter.mbcsToWcs (null, buffer));
+		}
+	}
+	OS.g_free (iter);
+	return result;
+}
+
+/**
+ * Returns an array of <code>String</code>s that are currently
+ * selected in the receiver.  The order of the items is unspecified.
+ * An empty array indicates that no items are selected.
+ * <p>
+ * Note: This is not the actual structure used by the receiver
+ * to maintain its selection, so modifying the array will
+ * not affect the receiver. 
+ * </p>
+ * @return an array representing the selection
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public String [] getSelection () {
+	checkWidget();
+	int [] indices = getSelectionIndices ();
+	String [] result = new String [indices.length];
+	for (int i=0; i<indices.length; i++) {
+		result [i] = getItem (indices [i]);
+	}
+	return result;
+}
+
+/**
+ * Returns the number of selected items contained in the receiver.
+ *
+ * @return the number of selected items
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getSelectionCount () {
+	checkWidget();
+	int /*long*/ selection = OS.gtk_tree_view_get_selection (handle);
+	if (OS.GTK_VERSION < OS.VERSION (2, 2, 0)) {
+		display.treeSelectionLength = 0;
+		display.treeSelection = null;
+		OS.gtk_tree_selection_selected_foreach (selection, display.treeSelectionProc, handle);
+		return display.treeSelectionLength;
+	}
+	return OS.gtk_tree_selection_count_selected_rows (selection);
+}
+
+/**
+ * Returns the zero-relative index of the item which is currently
+ * selected in the receiver, or -1 if no item is selected.
+ *
+ * @return the index of the selected item or -1
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getSelectionIndex () {
+	checkWidget();
+	int /*long*/ selection = OS.gtk_tree_view_get_selection (handle);
+	if (OS.GTK_VERSION < OS.VERSION (2, 2, 0)) {
+		int itemCount = OS.gtk_tree_model_iter_n_children (modelHandle, 0);
+		display.treeSelectionLength  = 0;
+		display.treeSelection = new int [itemCount];
+		OS.gtk_tree_selection_selected_foreach (selection, display.treeSelectionProc, handle);
+		if (display.treeSelectionLength == 0) return -1;
+		return display.treeSelection [0];
+	}
+	/*
+	* Bug in GTK.  gtk_tree_selection_get_selected_rows() segmentation faults
+	* in versions smaller than 2.2.4 if the model is NULL.  The fix is
+	* to give a valid pointer instead.
+	*/
+	int /*long*/ [] model = OS.GTK_VERSION < OS.VERSION (2, 2, 4) ? new int /*long*/ [1] : null;
+	int /*long*/ list = OS.gtk_tree_selection_get_selected_rows (selection, model);
+	if (list != 0) {
+		int count = OS.g_list_length (list);
+		int [] index = new int [1];
+		for (int i=0; i<count; i++) {
+			int /*long*/ data = OS.g_list_nth_data (list, i);
+			int /*long*/ indices = OS.gtk_tree_path_get_indices (data);
+			if (indices != 0) {
+				OS.memmove (index, indices, 4);
+				break;
+			}
+		}
+		OS.g_list_free (list);
+		return index [0];
+	}
+	return -1;
+}
+
+/**
+ * Returns the zero-relative indices of the items which are currently
+ * selected in the receiver.  The order of the indices is unspecified.
+ * The array is empty if no items are selected.
+ * <p>
+ * Note: This is not the actual structure used by the receiver
+ * to maintain its selection, so modifying the array will
+ * not affect the receiver. 
+ * </p>
+ * @return the array of indices of the selected items
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int [] getSelectionIndices () {
+	checkWidget();
+	int /*long*/ selection = OS.gtk_tree_view_get_selection (handle);
+	if (OS.GTK_VERSION < OS.VERSION (2, 2, 0)) {
+		int itemCount = OS.gtk_tree_model_iter_n_children (modelHandle, 0);
+		display.treeSelectionLength  = 0;
+		display.treeSelection = new int [itemCount];
+		OS.gtk_tree_selection_selected_foreach (selection, display.treeSelectionProc, handle);
+		if (display.treeSelectionLength == display.treeSelection.length) return display.treeSelection;
+		int [] result = new int [display.treeSelectionLength];
+		System.arraycopy (display.treeSelection, 0, result, 0, display.treeSelectionLength);
+		return result;
+	}
+	/*
+	* Bug in GTK.  gtk_tree_selection_get_selected_rows() segmentation faults
+	* in versions smaller than 2.2.4 if the model is NULL.  The fix is
+	* to give a valid pointer instead.
+	*/
+	int /*long*/ [] model = OS.GTK_VERSION < OS.VERSION (2, 2, 4) ? new int /*long*/ [1] : null;
+	int /*long*/ list = OS.gtk_tree_selection_get_selected_rows (selection, model);
+	if (list != 0) {
+		int count = OS.g_list_length (list);
+		int [] treeSelection = new int [count];
+		int length = 0;
+		for (int i=0; i<count; i++) {
+			int /*long*/ data = OS.g_list_nth_data (list, i);
+			int /*long*/ indices = OS.gtk_tree_path_get_indices (data);
+			if (indices != 0) {
+				int [] index = new int [1];
+				OS.memmove (index, indices, 4);
+				treeSelection [length] = index [0];
+				length++;
+			}
+		}
+		OS.g_list_free (list);
+		int [] result = new int [length];
+		System.arraycopy (treeSelection, 0, result, 0, length);
+		return result;
+	}
+	return new int [0];
+}
+
+/**
+ * Returns the zero-relative index of the item which is currently
+ * at the top of the receiver. This index can change when items are
+ * scrolled or new items are added or removed.
+ *
+ * @return the index of the top item
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getTopIndex () {
+	checkWidget();
+	int /*long*/ [] path = new int /*long*/ [1];
+	OS.gtk_widget_realize (handle);
+	if (!OS.gtk_tree_view_get_path_at_pos (handle, 1, 1, path, null, null, null)) return 0;
+	if (path [0] == 0) return 0;
+	int /*long*/ indices = OS.gtk_tree_path_get_indices (path[0]);
+	int[] index = new int [1];
+	if (indices != 0) OS.memmove (index, indices, 4);
+	OS.gtk_tree_path_free (path [0]);
+	return index [0];
+}
+
+int /*long*/ gtk_changed (int /*long*/ widget) {
+	postEvent (SWT.Selection);
+	return 0;
+}
+
+int /*long*/ gtk_button_press_event (int /*long*/ widget, int /*long*/ event) {
+	int /*long*/ result = super.gtk_button_press_event (widget, event);
+	if (result != 0) return result;
+	/*
+	* Feature in GTK.  In a multi-select list view, when multiple items are already
+	* selected, the selection state of the item is toggled and the previous selection 
+	* is cleared. This is not the desired behaviour when bringing up a popup menu.
+	* Also, when an item is reselected with the right button, the tree view issues
+	* an unwanted selection event. The workaround is to detect that case and not
+	* run the default handler when the item is already part of the current selection.
+	*/
+	GdkEventButton gdkEvent = new GdkEventButton ();
+	OS.memmove (gdkEvent, event, GdkEventButton.sizeof);
+	int button = gdkEvent.button;
+	if (button == 3 && gdkEvent.type == OS.GDK_BUTTON_PRESS) {
+		int /*long*/ [] path = new int /*long*/ [1];
+		if (OS.gtk_tree_view_get_path_at_pos (handle, (int)gdkEvent.x, (int)gdkEvent.y, path, null, null, null)) {
+			if (path [0] != 0) {
+				int /*long*/ selection = OS.gtk_tree_view_get_selection (handle);
+				if (OS.gtk_tree_selection_path_is_selected (selection, path [0])) result = 1;
+				OS.gtk_tree_path_free (path [0]);
+			}
+		}
+	}
+	
+	/*
+	* Feature in GTK.  When the user clicks in a single selection GtkTreeView
+	* and there are no selected items, the first item is selected automatically
+	* before the click is processed, causing two selection events.  The is fix
+	* is the set the cursor item to be same as the clicked item to stop the
+	* widget from automatically selecting the first item.
+	*/
+	if ((style & SWT.SINGLE) != 0 && getSelectionCount () == 0) {
+		int /*long*/ [] path = new int /*long*/ [1];
+		if (OS.gtk_tree_view_get_path_at_pos (handle, (int)gdkEvent.x, (int)gdkEvent.y, path, null, null, null)) {
+			if (path [0] != 0) {
+				int /*long*/ selection = OS.gtk_tree_view_get_selection (handle);
+				OS.g_signal_handlers_block_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+				OS.gtk_tree_view_set_cursor (handle, path [0], 0, false);
+				OS.g_signal_handlers_unblock_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+				OS.gtk_tree_path_free (path [0]);
+			}
+		}
+	}
+	/*
+	* Bug in GTK. GTK segments fault, if the GtkTreeView widget is
+	* not in focus and all items in the widget are disposed before
+	* it finishes processing a button press.  The fix is to give
+	* focus to the widget before it starts processing the event.
+	*/
+	if (!OS.GTK_WIDGET_HAS_FOCUS (handle)) {
+		OS.gtk_widget_grab_focus (handle);
+	}
+	return result;
+}
+
+int /*long*/ gtk_key_press_event (int /*long*/ widget, int /*long*/ event) {
+	int /*long*/ result = super.gtk_key_press_event (widget, event);
+	if (result != 0) return result;
+	if (OS.GTK_VERSION < OS.VERSION (2, 2 ,0)) {
+		/*
+		* Feature in GTK 2.0.x.  When an item is default selected using
+		* the return key, GTK does not issue notification. The fix is
+		* to issue this notification when the return key is pressed.
+		*/
+		GdkEventKey keyEvent = new GdkEventKey ();
+		OS.memmove (keyEvent, event, GdkEventKey.sizeof);
+		int key = keyEvent.keyval;
+		switch (key) {
+			case OS.GDK_Return:
+			case OS.GDK_KP_Enter: {
+				postEvent (SWT.DefaultSelection);
+				break;
+			}
+		}
+	}
+	return result;
+}
+
+int /*long*/ gtk_popup_menu (int /*long*/ widget) {
+	int /*long*/ result = super.gtk_popup_menu (widget);
+	/*
+	* Bug in GTK.  The context menu for the typeahead in GtkTreeViewer
+	* opens in the bottom right corner of the screen when Shift+F10
+	* is pressed and the typeahead window was not visible.  The fix is
+	* to prevent the context menu from opening by stopping the default
+	* handler.
+	* 
+	* NOTE: The bug only happens in GTK 2.6.5 and lower.
+	*/
+	return OS.GTK_VERSION < OS.VERSION (2, 6, 5) ? 1 : result;
+}
+
+int /*long*/ gtk_row_activated (int /*long*/ tree, int /*long*/ path, int /*long*/ column) {
+	postEvent (SWT.DefaultSelection);
+	return 0;
+}
+
+void hookEvents () {
+	super.hookEvents();
+	int /*long*/ selection = OS.gtk_tree_view_get_selection(handle);
+	OS.g_signal_connect_closure (selection, OS.changed, display.closures [CHANGED], false);
+	OS.g_signal_connect_closure (handle, OS.row_activated, display.closures [ROW_ACTIVATED], false);
+}
+
+/**
+ * Gets the index of an item.
+ * <p>
+ * The list is searched starting at 0 until an
+ * item is found that is equal to the search item.
+ * If no item is found, -1 is returned.  Indexing
+ * is zero based.
+ *
+ * @param string the search item
+ * @return the index of the item
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int indexOf (String string) {
+	checkWidget();
+	return indexOf (string, 0);
+}
+
+/**
+ * Searches the receiver's list starting at the given, 
+ * zero-relative index until an item is found that is equal
+ * to the argument, and returns the index of that item. If
+ * no item is found or the starting index is out of range,
+ * returns -1.
+ *
+ * @param string the search item
+ * @param start the zero-relative index at which to start the search
+ * @return the index of the item
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int indexOf (String string, int start) {
+	checkWidget();
+	if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+	String [] items = getItems ();
+	for (int i=start; i<items.length; i++) {
+		if (items [i].equals (string)) return i;
+	}
+	return -1;
+}
+
+/**
+ * Returns <code>true</code> if the item is selected,
+ * and <code>false</code> otherwise.  Indices out of
+ * range are ignored.
+ *
+ * @param index the index of the item
+ * @return the selection state of the item at the index
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public boolean isSelected (int index) {
+	checkWidget();
+	int /*long*/ selection = OS.gtk_tree_view_get_selection (handle);
+	byte [] buffer = Converter.wcsToMbcs (null, Integer.toString (index), true);
+	int /*long*/ path = OS.gtk_tree_path_new_from_string (buffer);
+	boolean answer = OS.gtk_tree_selection_path_is_selected (selection, path);
+	OS.gtk_tree_path_free (path);
+	return answer;
+}
+
+int /*long*/ paintWindow () {
+	OS.gtk_widget_realize (handle);
+	return OS.gtk_tree_view_get_bin_window (handle);
+}
+
+void register () {
+	super.register ();
+	display.addWidget (OS.gtk_tree_view_get_selection (handle), this);
+}
+
+void releaseWidget () {
+	super.releaseWidget ();
+	if (modelHandle != 0) OS.g_object_unref (modelHandle);
+	modelHandle = 0;
+}
+
+/**
+ * Removes the item from the receiver at the given
+ * zero-relative index.
+ *
+ * @param index the index for the item
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void remove (int index) {
+	checkWidget();
+	if (!(0 <= index && index < OS.gtk_tree_model_iter_n_children (modelHandle, 0)))  {
+		error (SWT.ERROR_INVALID_RANGE);
+	}
+	int /*long*/ iter = OS.g_malloc (OS.GtkTreeIter_sizeof ());
+	OS.gtk_tree_model_iter_nth_child (modelHandle, iter, 0, index);
+	int /*long*/ selection = OS.gtk_tree_view_get_selection (handle);
+	OS.g_signal_handlers_block_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+	OS.gtk_list_store_remove (modelHandle, iter);
+	OS.g_signal_handlers_unblock_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+	OS.g_free (iter);
+}
+
+/**
+ * Removes the items from the receiver which are
+ * between the given zero-relative start and end 
+ * indices (inclusive).
+ *
+ * @param start the start of the range
+ * @param end the end of the range
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_RANGE - if either the start or end are not between 0 and the number of elements in the list minus 1 (inclusive)</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void remove (int start, int end) {
+	checkWidget();
+	if (start > end) return;
+	int count =  OS.gtk_tree_model_iter_n_children (modelHandle, 0);
+	if (!(0 <= start && start <= end && end < count)) {
+		error (SWT.ERROR_INVALID_RANGE);
+	}
+	int /*long*/ iter = OS.g_malloc (OS.GtkTreeIter_sizeof ());
+	int /*long*/ selection = OS.gtk_tree_view_get_selection (handle);
+	OS.g_signal_handlers_block_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+	for (int index=end; index>=start; index--) {
+		OS.gtk_tree_model_iter_nth_child (modelHandle, iter, 0, index);
+		OS.gtk_list_store_remove (modelHandle, iter);
+	}
+	OS.g_signal_handlers_unblock_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+	OS.g_free (iter);
+}
+
+/**
+ * Searches the receiver's list starting at the first item
+ * until an item is found that is equal to the argument, 
+ * and removes that item from the list.
+ *
+ * @param string the item to remove
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the string is not found in the list</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void remove (String string) {
+	checkWidget();
+	if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+	int index = indexOf (string, 0);
+	if (index == -1) error (SWT.ERROR_INVALID_ARGUMENT);
+	remove (index);
+}
+
+/**
+ * Removes the items from the receiver at the given
+ * zero-relative indices.
+ *
+ * @param indices the array of indices of the items
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
+ *    <li>ERROR_NULL_ARGUMENT - if the indices array is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void remove (int [] indices) {
+	checkWidget();
+	if (indices == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if (indices.length == 0) return;
+	int [] newIndices = new int [indices.length];
+	System.arraycopy (indices, 0, newIndices, 0, indices.length);
+	sort (newIndices);
+	int start = newIndices [newIndices.length - 1], end = newIndices [0];
+	int count = getItemCount();
+	if (!(0 <= start && start <= end && end < count)) {
+		error (SWT.ERROR_INVALID_RANGE);
+	}
+	int /*long*/ iter = OS.g_malloc (OS.GtkTreeIter_sizeof ());
+	int /*long*/ selection = OS.gtk_tree_view_get_selection (handle);
+	OS.g_signal_handlers_block_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+	int last = -1;
+	for (int i=0; i<newIndices.length; i++) {
+		int index = newIndices [i];
+		if (index != last) {
+			OS.gtk_tree_model_iter_nth_child (modelHandle, iter, 0, index);
+			OS.gtk_list_store_remove (modelHandle, iter);
+			last = index;
+		}
+	}
+	OS.g_signal_handlers_unblock_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+	OS.g_free (iter);
+}
+
+/**
+ * Removes all of the items from the receiver.
+ * <p>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void removeAll () {
+	checkWidget();
+	int /*long*/ selection = OS.gtk_tree_view_get_selection (handle);
+	OS.g_signal_handlers_block_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+	OS.gtk_list_store_clear (modelHandle);
+	OS.g_signal_handlers_unblock_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the user changes the receiver's selection.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #addSelectionListener
+ */
+public void removeSelectionListener(SelectionListener listener) {
+	checkWidget();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if (eventTable == null) return;
+	eventTable.unhook (SWT.Selection, listener);
+	eventTable.unhook (SWT.DefaultSelection,listener);	
+}
+
+/**
+ * Selects the item at the given zero-relative index in the receiver's 
+ * list.  If the item at the index was already selected, it remains
+ * selected. Indices that are out of range are ignored.
+ *
+ * @param index the index of the item to select
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void select (int index) {
+	checkWidget();
+	if (!(0 <= index && index < OS.gtk_tree_model_iter_n_children (modelHandle, 0)))  return;
+	int /*long*/ iter = OS.g_malloc (OS.GtkTreeIter_sizeof ());
+	int /*long*/ selection = OS.gtk_tree_view_get_selection (handle);
+	OS.g_signal_handlers_block_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+	OS.gtk_tree_model_iter_nth_child (modelHandle, iter, 0, index);
+	OS.gtk_tree_selection_select_iter (selection, iter); 
+	if ((style & SWT.SINGLE) != 0) {
+		int /*long*/ path = OS.gtk_tree_model_get_path (modelHandle, iter);
+		OS.gtk_tree_view_set_cursor (handle, path, 0, false);
+		OS.gtk_tree_path_free (path);
+	}
+	OS.g_signal_handlers_unblock_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+	OS.g_free (iter);
+}
+
+/**
+ * Selects the items in the range specified by the given zero-relative
+ * indices in the receiver. The range of indices is inclusive.
+ * The current selection is not cleared before the new items are selected.
+ * <p>
+ * If an item in the given range is not selected, it is selected.
+ * If an item in the given range was already selected, it remains selected.
+ * Indices that are out of range are ignored and no items will be selected
+ * if start is greater than end.
+ * If the receiver is single-select and there is more than one item in the
+ * given range, then all indices are ignored.
+ *
+ * @param start the start of the range
+ * @param end the end of the range
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see List#setSelection(int,int)
+ */
+public void select (int start, int end) {
+	checkWidget ();
+	if (end < 0 || start > end || ((style & SWT.SINGLE) != 0 && start != end)) return;
+	int count = OS.gtk_tree_model_iter_n_children (modelHandle, 0);
+	if (count == 0 || start >= count) return;
+	start = Math.max (0, start);
+	end = Math.min (end, count - 1);
+	int /*long*/ iter = OS.g_malloc (OS.GtkTreeIter_sizeof ());
+	int /*long*/ selection = OS.gtk_tree_view_get_selection (handle);
+	OS.g_signal_handlers_block_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+	for (int index=start; index<=end; index++) {
+		OS.gtk_tree_model_iter_nth_child (modelHandle, iter, 0, index);
+		OS.gtk_tree_selection_select_iter (selection, iter);
+		if ((style & SWT.SINGLE) != 0) {
+			int /*long*/ path = OS.gtk_tree_model_get_path (modelHandle, iter);
+			OS.gtk_tree_view_set_cursor (handle, path, 0, false);
+			OS.gtk_tree_path_free (path);
+		}
+	}
+	OS.g_signal_handlers_unblock_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+	OS.g_free (iter);
+}
+
+/**
+ * Selects the items at the given zero-relative indices in the receiver.
+ * The current selection is not cleared before the new items are selected.
+ * <p>
+ * If the item at a given index is not selected, it is selected.
+ * If the item at a given index was already selected, it remains selected.
+ * Indices that are out of range and duplicate indices are ignored.
+ * If the receiver is single-select and multiple indices are specified,
+ * then all indices are ignored.
+ *
+ * @param indices the array of indices for the items to select
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the array of indices is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see List#setSelection(int[])
+ */
+public void select (int [] indices) {
+	checkWidget ();
+	if (indices == null) error (SWT.ERROR_NULL_ARGUMENT);
+	int length = indices.length;
+	if (length == 0 || ((style & SWT.SINGLE) != 0 && length > 1)) return;
+	int /*long*/ iter = OS.g_malloc (OS.GtkTreeIter_sizeof ());
+	int count = OS.gtk_tree_model_iter_n_children (modelHandle, 0);
+	int /*long*/ selection = OS.gtk_tree_view_get_selection (handle);
+	OS.g_signal_handlers_block_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+	for (int i=0; i<length; i++) {
+		int index = indices [i];
+		if (!(0 <= index && index < count)) continue;
+		OS.gtk_tree_model_iter_nth_child (modelHandle, iter, 0, index);
+		OS.gtk_tree_selection_select_iter (selection, iter); 
+		if ((style & SWT.SINGLE) != 0) {
+			int /*long*/ path = OS.gtk_tree_model_get_path (modelHandle, iter);
+			OS.gtk_tree_view_set_cursor (handle, path, 0, false);
+			OS.gtk_tree_path_free (path);
+		}
+	}
+	OS.g_signal_handlers_unblock_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+	OS.g_free (iter);
+}
+
+/**
+ * Selects all of the items in the receiver.
+ * <p>
+ * If the receiver is single-select, do nothing.
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void selectAll () {
+	checkWidget();
+	if ((style & SWT.SINGLE) != 0) return;
+	int /*long*/ selection = OS.gtk_tree_view_get_selection (handle);
+	OS.g_signal_handlers_block_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+	OS.gtk_tree_selection_select_all (selection);
+	OS.g_signal_handlers_unblock_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+}
+
+void selectFocusIndex (int index) {
+	/*
+	* Note that this method both selects and sets the focus to the
+	* specified index, so any previous selection in the list will be lost.
+	* gtk does not provide a way to just set focus to a specified list item.
+	*/
+	int count = OS.gtk_tree_model_iter_n_children (modelHandle, 0);
+	if (!(0 <= index && index < count))  return;
+	int /*long*/ iter = OS.g_malloc (OS.GtkTreeIter_sizeof ());
+	OS.gtk_tree_model_iter_nth_child (modelHandle, iter, 0, index);
+	int /*long*/ path = OS.gtk_tree_model_get_path (modelHandle, iter);
+	int /*long*/ selection = OS.gtk_tree_view_get_selection (handle);
+	OS.g_signal_handlers_block_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+	OS.gtk_tree_view_set_cursor (handle, path, 0, false);
+	/*
+	* Bug in GTK. For some reason, when an event loop is run from
+	* within a key pressed handler and a dialog is displayed that
+	* contains a GtkTreeView,  gtk_tree_view_set_cursor() does
+	* not set the cursor or select the item.  The fix is to select the
+	* item with gtk_tree_selection_select_iter() as well.
+	* 
+	* NOTE: This happens in GTK 2.2.1 and is fixed in GTK 2.2.4.
+	*/
+	OS.gtk_tree_selection_select_iter (selection, iter);	
+	OS.g_signal_handlers_unblock_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+	OS.gtk_tree_path_free (path);
+	OS.g_free (iter);
+}
+
+void setBackgroundColor (GdkColor color) {
+	super.setBackgroundColor (color);
+	OS.gtk_widget_modify_base (handle, 0, color);
+}
+
+int setBounds (int x, int y, int width, int height, boolean move, boolean resize) {
+	int result = super.setBounds (x, y, width, height, move, resize);
+	/*
+	* Bug on GTK.  The tree view sometimes does not get a paint
+	* event or resizes to a one pixel square when resized in a new
+	* shell that is not visible after any event loop has been run.  The
+	* problem is intermittent. It doesn't seem to happen the first time
+	* a new shell is created. The fix is to ensure the tree view is realized
+	* after it has been resized.
+	*/
+	OS.gtk_widget_realize (handle);
+	/*
+	* Bug in GTK.  An empty GtkTreeView fails to repaint the focus rectangle
+	* correctly when resized on versions before 2.6.0.  The fix is to force
+	* the widget to redraw.
+	*/
+	if (OS.GTK_VERSION < OS.VERSION (2, 6, 0) && OS.gtk_tree_model_iter_n_children (modelHandle, 0) == 0) {
+		redraw (false);
+	}
+	return result;
+}
+
+/**
+ * Sets the text of the item in the receiver's list at the given
+ * zero-relative index to the string argument.
+ *
+ * @param index the index for the item
+ * @param string the new text for the item
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
+ *    <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setItem (int index, String string) {
+	checkWidget();
+	if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if (!(0 <= index && index < OS.gtk_tree_model_iter_n_children (modelHandle, 0)))  {
+		error (SWT.ERROR_INVALID_RANGE);
+	}
+	int /*long*/ iter = OS.g_malloc (OS.GtkTreeIter_sizeof ());
+	OS.gtk_tree_model_iter_nth_child (modelHandle, iter, 0, index);
+	byte [] buffer = Converter.wcsToMbcs (null, string, true);
+	OS.gtk_list_store_set (modelHandle, iter, TEXT_COLUMN, buffer, -1);
+	OS.g_free (iter);
+}
+
+/**
+ * Sets the receiver's items to be the given array of items.
+ *
+ * @param items the array of items
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the items array is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if an item in the items array is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setItems (String [] items) {
+	checkWidget();
+	if (items == null) error (SWT.ERROR_NULL_ARGUMENT);
+	for (int i=0; i<items.length; i++) {
+		if (items [i] == null) error (SWT.ERROR_INVALID_ARGUMENT);
+	}
+	int /*long*/ selection = OS.gtk_tree_view_get_selection (handle);
+	OS.g_signal_handlers_block_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+	OS.gtk_list_store_clear (modelHandle);
+	OS.g_signal_handlers_unblock_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+	int /*long*/ iter = OS.g_malloc (OS.GtkTreeIter_sizeof ());
+	if (iter == 0) error (SWT.ERROR_ITEM_NOT_ADDED);
+	for (int i=0; i<items.length; i++) {
+		String string = items [i];
+		byte [] buffer = Converter.wcsToMbcs (null, string, true);
+		OS.gtk_list_store_append (modelHandle, iter);
+		OS.gtk_list_store_set (modelHandle, iter, TEXT_COLUMN, buffer, -1);
+	}
+	OS.g_free (iter);
+}
+
+/**
+ * Selects the item at the given zero-relative index in the receiver. 
+ * If the item at the index was already selected, it remains selected.
+ * The current selection is first cleared, then the new item is selected.
+ * Indices that are out of range are ignored.
+ *
+ * @param index the index of the item to select
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @see List#deselectAll()
+ * @see List#select(int)
+ */
+public void setSelection (int index) {
+	checkWidget ();
+	deselectAll ();
+	selectFocusIndex (index);
+	showSelection ();
+}
+
+/**
+ * Selects the items in the range specified by the given zero-relative
+ * indices in the receiver. The range of indices is inclusive.
+ * The current selection is cleared before the new items are selected.
+ * <p>
+ * Indices that are out of range are ignored and no items will be selected
+ * if start is greater than end.
+ * If the receiver is single-select and there is more than one item in the
+ * given range, then all indices are ignored.
+ *
+ * @param start the start index of the items to select
+ * @param end the end index of the items to select
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see List#deselectAll()
+ * @see List#select(int,int)
+ */
+public void setSelection (int start, int end) {
+	checkWidget ();
+	deselectAll ();
+	if (end < 0 || start > end || ((style & SWT.SINGLE) != 0 && start != end)) return;
+	int count = OS.gtk_tree_model_iter_n_children (modelHandle, 0);
+	if (count == 0 || start >= count) return;
+	start = Math.max (0, start);
+	end = Math.min (end, count - 1);
+	selectFocusIndex (start);
+	if ((style & SWT.MULTI) != 0) {
+		select (start, end);
+	}
+	showSelection ();
+}
+
+/**
+ * Selects the items at the given zero-relative indices in the receiver.
+ * The current selection is cleared before the new items are selected.
+ * <p>
+ * Indices that are out of range and duplicate indices are ignored.
+ * If the receiver is single-select and multiple indices are specified,
+ * then all indices are ignored.
+ *
+ * @param indices the indices of the items to select
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the array of indices is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see List#deselectAll()
+ * @see List#select(int[])
+ */
+public void setSelection(int[] indices) {
+	checkWidget ();
+	if (indices == null) error (SWT.ERROR_NULL_ARGUMENT);
+	deselectAll ();
+	int length = indices.length;
+	if (length == 0 || ((style & SWT.SINGLE) != 0 && length > 1)) return;
+	selectFocusIndex (indices [0]);
+	if ((style & SWT.MULTI) != 0) {
+		select (indices);
+	}
+	showSelection ();
+}
+
+/**
+ * Sets the receiver's selection to be the given array of items.
+ * The current selection is cleared before the new items are selected.
+ * <p>
+ * Items that are not in the receiver are ignored.
+ * If the receiver is single-select and multiple items are specified,
+ * then all items are ignored.
+ *
+ * @param items the array of items
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the array of items is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see List#deselectAll()
+ * @see List#select(int[])
+ * @see List#setSelection(int[])
+ */
+public void setSelection (String [] items) {
+	checkWidget ();
+	if (items == null) error (SWT.ERROR_NULL_ARGUMENT);
+	deselectAll ();
+	int length = items.length;
+	if (length == 0 || ((style & SWT.SINGLE) != 0 && length > 1)) return;
+	boolean first = true;
+	for (int i = 0; i < length; i++) {
+		int index = 0;
+		String string = items [i];
+		if (string != null) {
+			while ((index = indexOf (string, index)) != -1) {
+				if ((style & SWT.MULTI) != 0) {
+					if (first) {
+						first = false;
+						selectFocusIndex (index);
+					} else {
+						select (index);
+					}
+				} else {
+					selectFocusIndex (index);
+					break;
+				}
+				index++;
+			}
+		}
+	}
+	showSelection ();
+}
+
+/**
+ * Sets the zero-relative index of the item which is currently
+ * at the top of the receiver. This index can change when items
+ * are scrolled or new items are added and removed.
+ *
+ * @param index the index of the top item
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setTopIndex (int index) {
+	checkWidget();
+	if (!(0 <= index && index < OS.gtk_tree_model_iter_n_children (modelHandle, 0))) return;
+	int /*long*/ iter = OS.g_malloc (OS.GtkTreeIter_sizeof ());
+	OS.gtk_tree_model_iter_nth_child (modelHandle, iter, 0, index);
+	int /*long*/ path = OS.gtk_tree_model_get_path (modelHandle, iter);
+	OS.gtk_tree_view_scroll_to_cell (handle, path, 0, true, 0, 0);
+	if (OS.GTK_VERSION < OS.VERSION (2, 8, 0)) {
+		/*
+		* Bug in GTK.  According to the documentation, gtk_tree_view_scroll_to_cell
+		* should vertically scroll the cell to the top if use_align is true and row_align is 0.
+		* However, prior to version 2.8 it does not scroll at all.  The fix is to determine
+		* the new location and use gtk_tree_view_scroll_to_point.
+		* If the widget is a pinhead, calling gtk_tree_view_scroll_to_point
+		* will have no effect. Therefore, it is still neccessary to call 
+		* gtk_tree_view_scroll_to_cell.
+		*/
+		OS.gtk_widget_realize (handle);
+		GdkRectangle cellRect = new GdkRectangle ();
+		OS.gtk_tree_view_get_cell_area (handle, path, 0, cellRect);
+		int[] tx = new int[1], ty = new int[1];
+		OS.gtk_tree_view_widget_to_tree_coords(handle, cellRect.x, cellRect.y, tx, ty);
+		OS.gtk_tree_view_scroll_to_point (handle, -1, ty[0]);
+	}
+	OS.gtk_tree_path_free (path);
+	OS.g_free (iter);
+}
+
+/**
+ * Shows the selection.  If the selection is already showing in the receiver,
+ * this method simply returns.  Otherwise, the items are scrolled until
+ * the selection is visible.
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void showSelection () {
+	checkWidget();
+	int index = getSelectionIndex ();
+	if (index == -1) return;
+	int /*long*/ iter = OS.g_malloc (OS.GtkTreeIter_sizeof ());
+	OS.gtk_tree_model_iter_nth_child (modelHandle, iter, 0, index);
+	int /*long*/ path = OS.gtk_tree_model_get_path (modelHandle, iter);
+	/*
+	* This code intentionally commented.
+	* Bug in GTK.  According to the documentation, gtk_tree_view_scroll_to_cell
+	* should scroll the minimum amount to show the cell if use_align is false.
+	* However, what actually happens is the cell is scrolled to the top.
+	* The fix is to determine the new location and use gtk_tree_view_scroll_to_point.
+	* If the widget is a pinhead, calling gtk_tree_view_scroll_to_point
+	* will have no effect. Therefore, it is still neccessary to 
+	* call gtk_tree_view_scroll_to_cell.
+	*/
+//	OS.gtk_tree_view_scroll_to_cell (handle, path, 0, false, 0, 0);
+	OS.gtk_widget_realize (handle);
+	GdkRectangle visibleRect = new GdkRectangle ();
+	OS.gtk_tree_view_get_visible_rect (handle, visibleRect);
+	GdkRectangle cellRect = new GdkRectangle ();
+	OS.gtk_tree_view_get_cell_area (handle, path, 0, cellRect);
+	int[] tx = new int[1], ty = new int[1];
+	OS.gtk_tree_view_widget_to_tree_coords(handle, cellRect.x, cellRect.y, tx, ty);
+	if (ty[0] < visibleRect.y ) {
+		OS.gtk_tree_view_scroll_to_cell (handle, path, 0, true, 0f, 0f);
+		OS.gtk_tree_view_scroll_to_point (handle, -1, ty[0]);
+	} else {
+		int height = Math.min (visibleRect.height, cellRect.height);
+		if (ty[0] + height > visibleRect.y + visibleRect.height) {
+			OS.gtk_tree_view_scroll_to_cell (handle, path, 0, true, 1f, 0f);
+			ty[0] += cellRect.height - visibleRect.height;
+			OS.gtk_tree_view_scroll_to_point (handle, -1, ty[0]);
+		}
+	}
+	OS.gtk_tree_path_free (path);
+	OS.g_free (iter);
+}
+
+int /*long*/ treeSelectionProc (int /*long*/ model, int /*long*/ path, int /*long*/ iter, int[] selection, int length) {
+	if (selection != null) { 
+		int /*long*/ indices = OS.gtk_tree_path_get_indices (path);
+		if (indices != 0) {
+			int [] index = new int [1];
+			OS.memmove (index, indices, 4);
+			selection [length] = index [0];
+		}
+	}
+	return 0;
+}
+
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Listener.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Listener.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Listener.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.widgets;
+
+
+/**
+ * Implementers of <code>Listener</code> provide a simple 
+ * <code>handleEvent()</code> method that is used internally 
+ * by SWT to dispatch events.
+ * <p>
+ * After creating an instance of a class that implements this interface
+ * it can be added to a widget using the 
+ * <code>addListener(int eventType, Listener handler)</code> method and
+ * removed using the 
+ * <code>removeListener (int eventType, Listener handler)</code> method. 
+ * When the specified event occurs, <code>handleEvent(...)</code> will
+ * be sent to the instance.
+ * </p>
+ * <p>
+ * Classes which implement this interface are described within SWT as
+ * providing the <em>untyped listener</em> API. Typically, widgets will
+ * also provide a higher-level <em>typed listener</em> API, that is based
+ * on the standard <code>java.util.EventListener</code> pattern.
+ * </p> 
+ * <p>
+ * Note that, since all internal SWT event dispatching is based on untyped
+ * listeners, it is simple to build subsets of SWT for use on memory 
+ * constrained, small footprint devices, by removing the classes and
+ * methods which implement the typed listener API.
+ * </p>
+ *
+ * @see Widget#addListener
+ * @see java.util.EventListener
+ * @see org.eclipse.swt.events
+ */
+public interface Listener {
+
+/**
+ * Sent when an event that the receiver has registered for occurs.
+ *
+ * @param event the event which occurred
+ */
+void handleEvent (Event event);
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Menu.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Menu.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Menu.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,977 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.widgets;
+
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.gtk.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
+
+/**
+ * Instances of this class are user interface objects that contain
+ * menu items.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>BAR, DROP_DOWN, POP_UP, NO_RADIO_GROUP</dd>
+ * <dd>LEFT_TO_RIGHT, RIGHT_TO_LEFT</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Help, Hide, Show </dd>
+ * </dl>
+ * <p>
+ * Note: Only one of BAR, DROP_DOWN and POP_UP may be specified.
+ * Only one of LEFT_TO_RIGHT or RIGHT_TO_LEFT may be specified.
+ * </p><p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ *
+ * @see <a href="http://www.eclipse.org/swt/snippets/#menu">Menu snippets</a>
+ * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: ControlExample</a>
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public class Menu extends Widget {
+	int x, y;
+	boolean hasLocation;
+	MenuItem cascade, selectedItem;
+	Decorations parent;
+	int /*long*/ imItem, imSeparator, imHandle;
+	ImageList imageList;
+
+/**
+ * Constructs a new instance of this class given its parent,
+ * and sets the style for the instance so that the instance
+ * will be a popup menu on the given parent's shell.
+ * <p>
+ * After constructing a menu, it can be set into its parent
+ * using <code>parent.setMenu(menu)</code>.  In this case, the parent may
+ * be any control in the same widget tree as the parent.
+ * </p>
+ *
+ * @param parent a control which will be the parent of the new instance (cannot be null)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT#POP_UP
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public Menu (Control parent) {
+	this (checkNull (parent).menuShell (), SWT.POP_UP);
+}
+
+/**
+ * Constructs a new instance of this class given its parent
+ * (which must be a <code>Decorations</code>) and a style value
+ * describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p><p>
+ * After constructing a menu or menuBar, it can be set into its parent
+ * using <code>parent.setMenu(menu)</code> or <code>parent.setMenuBar(menuBar)</code>.
+ * </p>
+ *
+ * @param parent a decorations control which will be the parent of the new instance (cannot be null)
+ * @param style the style of menu to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT#BAR
+ * @see SWT#DROP_DOWN
+ * @see SWT#POP_UP
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public Menu (Decorations parent, int style) {
+	super (parent, checkStyle (style));
+	this.parent = parent;
+	createWidget (0);
+}
+
+/**
+ * Constructs a new instance of this class given its parent
+ * (which must be a <code>Menu</code>) and sets the style
+ * for the instance so that the instance will be a drop-down
+ * menu on the given parent's parent.
+ * <p>
+ * After constructing a drop-down menu, it can be set into its parentMenu
+ * using <code>parentMenu.setMenu(menu)</code>.
+ * </p>
+ *
+ * @param parentMenu a menu which will be the parent of the new instance (cannot be null)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT#DROP_DOWN
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public Menu (Menu parentMenu) {
+	this (checkNull (parentMenu).parent, SWT.DROP_DOWN);
+}
+
+/**
+ * Constructs a new instance of this class given its parent
+ * (which must be a <code>MenuItem</code>) and sets the style
+ * for the instance so that the instance will be a drop-down
+ * menu on the given parent's parent menu.
+ * <p>
+ * After constructing a drop-down menu, it can be set into its parentItem
+ * using <code>parentItem.setMenu(menu)</code>.
+ * </p>
+ *
+ * @param parentItem a menu item which will be the parent of the new instance (cannot be null)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT#DROP_DOWN
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public Menu (MenuItem parentItem) {
+	this (checkNull (parentItem).parent);
+}
+
+static Control checkNull (Control control) {
+	if (control == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+	return control;
+}
+
+static Menu checkNull (Menu menu) {
+	if (menu == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+	return menu;
+}
+
+static MenuItem checkNull (MenuItem item) {
+	if (item == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+	return item;
+}
+
+static int checkStyle (int style) {
+	return checkBits (style, SWT.POP_UP, SWT.BAR, SWT.DROP_DOWN, 0, 0, 0);
+}
+
+void _setVisible (boolean visible) {
+	if (visible == OS.GTK_WIDGET_MAPPED (handle)) return;
+	if (visible) {
+		sendEvent (SWT.Show);
+		if (getItemCount () != 0) {
+			if ((OS.GTK_VERSION >=  OS.VERSION (2, 8, 0))) {
+				/*
+				* Feature in GTK. ON_TOP shells will send out 
+				* SWT.Deactivate whenever a context menu is shown.
+				* The fix is to prevent the menu from taking focus
+				* when it is being shown in an ON_TOP shell.
+				*/
+				if ((parent._getShell ().style & SWT.ON_TOP) != 0) {
+					OS.gtk_menu_shell_set_take_focus (handle, false);
+				}
+			}
+			int /*long*/ address = hasLocation ? display.menuPositionProc: 0;
+			/*
+			* Bug in GTK.  The timestamp passed into gtk_menu_popup is used
+			* to perform an X pointer grab.  It cannot be zero, else the grab
+			* will fail.  The fix is to ensure that the timestamp of the last
+			* event processed is used.
+			*/
+			OS.gtk_menu_popup (handle, 0, 0, address, 0, 0, display.getLastEventTime ());
+		} else {
+			sendEvent (SWT.Hide);
+		}
+	} else {
+		OS.gtk_menu_popdown (handle);
+	}
+}
+
+void addAccelerators (int /*long*/ accelGroup) {
+	MenuItem [] items = getItems ();
+	for (int i = 0; i < items.length; i++) {
+		MenuItem item = items[i];
+		item.addAccelerators (accelGroup);
+	}
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when menus are hidden or shown, by sending it
+ * one of the messages defined in the <code>MenuListener</code>
+ * interface.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see MenuListener
+ * @see #removeMenuListener
+ */
+public void addMenuListener (MenuListener listener) {
+	checkWidget();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	TypedListener typedListener = new TypedListener (listener);
+	addListener (SWT.Hide,typedListener);
+	addListener (SWT.Show,typedListener);
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when help events are generated for the control,
+ * by sending it one of the messages defined in the
+ * <code>HelpListener</code> interface.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see HelpListener
+ * @see #removeHelpListener
+ */
+public void addHelpListener (HelpListener listener) {
+	checkWidget();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	TypedListener typedListener = new TypedListener (listener);
+	addListener (SWT.Help, typedListener);
+}
+
+void createHandle (int index) {
+	state |= HANDLE;
+	if ((style & SWT.BAR) != 0) {
+		handle = OS.gtk_menu_bar_new ();
+		if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+		int /*long*/ vboxHandle = parent.vboxHandle;
+		OS.gtk_container_add (vboxHandle, handle);
+		OS.gtk_box_set_child_packing (vboxHandle, handle, false, true, 0, OS.GTK_PACK_START);
+	} else {
+		handle = OS.gtk_menu_new ();
+		if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+	}
+}
+
+void createIMMenu (int /*long*/ imHandle) {
+	if (this.imHandle == imHandle) return;
+	this.imHandle = imHandle;
+	if (imHandle == 0) {
+		if (imItem != 0) {
+			OS.gtk_widget_destroy (imItem);
+			imItem = 0;
+		}
+		if (imSeparator != 0) {
+			OS.gtk_widget_destroy (imSeparator);
+			imSeparator = 0;
+		}
+		return;
+	} 
+	if (imSeparator == 0) {
+		imSeparator = OS.gtk_separator_menu_item_new ();
+		OS.gtk_widget_show (imSeparator);
+		OS.gtk_menu_shell_insert (handle, imSeparator, -1);
+	}
+	if (imItem == 0) {
+		byte[] buffer = Converter.wcsToMbcs (null, SWT.getMessage("SWT_InputMethods"), true);
+		imItem = OS.gtk_image_menu_item_new_with_label (buffer);
+		OS.gtk_widget_show (imItem);
+		OS.gtk_menu_shell_insert (handle, imItem, -1);
+	}
+	int /*long*/ imSubmenu = OS.gtk_menu_new ();
+	OS.gtk_im_multicontext_append_menuitems (imHandle, imSubmenu);
+	OS.gtk_menu_item_set_submenu (imItem, imSubmenu);
+}
+
+void createWidget (int index) {
+	checkOrientation (parent);
+	super.createWidget (index);
+	parent.addMenu (this);
+}
+
+void fixMenus (Decorations newParent) {
+	MenuItem [] items = getItems ();
+	for (int i=0; i<items.length; i++) {
+		items [i].fixMenus (newParent);
+	}
+	parent.removeMenu (this);
+	newParent.addMenu (this);
+	this.parent = newParent;
+}
+
+/*public*/ Rectangle getBounds () {
+	checkWidget();
+	if (!OS.GTK_WIDGET_MAPPED (handle)) {
+		return new Rectangle (0, 0, 0, 0);
+	}
+	int /*long*/ window = OS.GTK_WIDGET_WINDOW (handle);
+	int [] origin_x = new int [1], origin_y = new int [1];
+	OS.gdk_window_get_origin (window, origin_x, origin_y);
+	int x = origin_x [0] + OS.GTK_WIDGET_X (handle);
+	int y = origin_y [0] + OS.GTK_WIDGET_Y (handle);
+	int width = OS.GTK_WIDGET_WIDTH (handle);
+	int height = OS.GTK_WIDGET_HEIGHT (handle);
+	return new Rectangle (x, y, width, height);
+}
+
+/**
+ * Returns the default menu item or null if none has
+ * been previously set.
+ *
+ * @return the default menu item.
+ *
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public MenuItem getDefaultItem () {
+	checkWidget();
+	return null;
+}
+
+/**
+ * Returns <code>true</code> if the receiver is enabled, and
+ * <code>false</code> otherwise. A disabled menu is typically
+ * not selectable from the user interface and draws with an
+ * inactive or "grayed" look.
+ *
+ * @return the receiver's enabled state
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see #isEnabled
+ */
+public boolean getEnabled () {
+	checkWidget();
+	return OS.GTK_WIDGET_SENSITIVE (handle);     
+}
+
+/**
+ * Returns the item at the given, zero-relative index in the
+ * receiver. Throws an exception if the index is out of range.
+ *
+ * @param index the index of the item to return
+ * @return the item at the given index
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public MenuItem getItem (int index) {
+	checkWidget();
+	int /*long*/ list = OS.gtk_container_get_children (handle);
+	if (list == 0) error (SWT.ERROR_CANNOT_GET_ITEM);
+	int count = OS.g_list_length (list);
+	if (imSeparator != 0) count--;
+	if (imItem != 0) count--;
+	if (!(0 <= index && index < count)) error (SWT.ERROR_INVALID_RANGE);
+	int /*long*/ data = OS.g_list_nth_data (list, index);
+	OS.g_list_free (list);
+	if (data == 0) error (SWT.ERROR_CANNOT_GET_ITEM);
+	return (MenuItem) display.getWidget (data);
+}
+
+/**
+ * Returns the number of items contained in the receiver.
+ *
+ * @return the number of items
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getItemCount () {
+	checkWidget();
+	int /*long*/ list = OS.gtk_container_get_children (handle);
+	if (list == 0) return 0;
+	int count = OS.g_list_length (list);
+	OS.g_list_free (list);
+	if (imSeparator != 0) count--;
+	if (imItem != 0) count--;
+	return count;
+}
+
+/**
+ * Returns a (possibly empty) array of <code>MenuItem</code>s which
+ * are the items in the receiver. 
+ * <p>
+ * Note: This is not the actual structure used by the receiver
+ * to maintain its list of items, so modifying the array will
+ * not affect the receiver. 
+ * </p>
+ *
+ * @return the items in the receiver
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public MenuItem [] getItems () {
+	checkWidget();
+	int /*long*/ list = OS.gtk_container_get_children (handle);
+	if (list == 0) return new MenuItem [0];
+	int count = OS.g_list_length (list);
+	if (imSeparator != 0) count--;
+	if (imItem != 0) count--;
+	MenuItem [] items = new MenuItem [count];
+	int index = 0;
+	for (int i=0; i<count; i++) {
+		int /*long*/ data = OS.g_list_nth_data (list, i);
+		MenuItem item = (MenuItem) display.getWidget (data);
+		if (item != null) items [index++] = item; 
+	}
+	OS.g_list_free (list);
+	if (index != items.length) {
+		MenuItem [] newItems = new MenuItem[index];
+		System.arraycopy(items, 0, newItems, 0, index);
+		items = newItems;
+	}
+	return items;
+}
+
+String getNameText () {
+	String result = "";
+	MenuItem [] items = getItems ();
+	int length = items.length;
+	if (length > 0) {
+		for (int i=0; i<length-1; i++) {
+			result = result + items [i].getNameText() + ", ";
+		}
+		result = result + items [length-1].getNameText ();
+	}
+	return result;
+}
+
+/**
+ * Returns the receiver's parent, which must be a <code>Decorations</code>.
+ *
+ * @return the receiver's parent
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Decorations getParent () {
+	checkWidget();
+	return parent;
+}
+
+/**
+ * Returns the receiver's parent item, which must be a
+ * <code>MenuItem</code> or null when the receiver is a
+ * root.
+ *
+ * @return the receiver's parent item
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public MenuItem getParentItem () {
+	checkWidget();
+	return cascade;
+}
+
+/**
+ * Returns the receiver's parent item, which must be a
+ * <code>Menu</code> or null when the receiver is a
+ * root.
+ *
+ * @return the receiver's parent item
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Menu getParentMenu () {
+	checkWidget();
+	if (cascade == null) return null;
+	return cascade.getParent ();
+}
+
+/**
+ * Returns the receiver's shell. For all controls other than
+ * shells, this simply returns the control's nearest ancestor
+ * shell. Shells return themselves, even if they are children
+ * of other shells.
+ *
+ * @return the receiver's shell
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #getParent
+ */
+public Shell getShell () {
+	checkWidget();
+	return parent.getShell ();
+}
+
+/**
+ * Returns <code>true</code> if the receiver is visible, and
+ * <code>false</code> otherwise.
+ * <p>
+ * If one of the receiver's ancestors is not visible or some
+ * other condition makes the receiver not visible, this method
+ * may still indicate that it is considered visible even though
+ * it may not actually be showing.
+ * </p>
+ *
+ * @return the receiver's visibility state
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public boolean getVisible () {
+	checkWidget();
+	if ((style & SWT.POP_UP) != 0) {
+		Menu [] popups = display.popups;
+		if (popups != null) {
+			for (int i=0; i<popups.length; i++) {
+				if (popups [i] == this) return true;
+			}
+		}
+	}
+	return OS.GTK_WIDGET_MAPPED (handle);
+}
+
+int /*long*/ gtk_hide (int /*long*/ widget) {
+	if ((style & SWT.POP_UP) != 0) {
+		display.activeShell = getShell ();
+	}
+	if (OS.GTK_VERSION >= OS.VERSION (2, 6, 0)) {
+		sendEvent (SWT.Hide);
+	} else {
+		/*
+		* Bug in GTK.  In GTK 2.4 and earlier
+		* a crash could occur if a menu item 
+		* was disposed within gtk_hide.  The
+		* workaroud is to post the event instead
+		* of send it on these platforms  
+		*/
+		postEvent (SWT.Hide);
+	}
+	return 0;
+}
+
+int /*long*/ gtk_show (int /*long*/ widget) {
+	if ((style & SWT.POP_UP) != 0) {
+		display.activeShell = getShell ();
+		return 0;
+	} 
+	sendEvent (SWT.Show);
+	return 0;
+}
+
+
+int /*long*/ gtk_show_help (int /*long*/ widget, int /*long*/ helpType) {
+	if (sendHelpEvent (helpType)) {
+		OS.gtk_menu_shell_deactivate (handle);
+		return 1;
+	}
+	return 0;
+}
+
+void hookEvents () {
+	super.hookEvents ();
+	OS.g_signal_connect_closure_by_id (handle, display.signalIds [SHOW], 0, display.closures [SHOW], false);
+	OS.g_signal_connect_closure_by_id (handle, display.signalIds [HIDE], 0, display.closures [HIDE], false);
+	OS.g_signal_connect_closure_by_id (handle, display.signalIds [SHOW_HELP], 0, display.closures [SHOW_HELP], false);
+}
+
+/**
+ * Searches the receiver's list starting at the first item
+ * (index 0) until an item is found that is equal to the 
+ * argument, and returns the index of that item. If no item
+ * is found, returns -1.
+ *
+ * @param item the search item
+ * @return the index of the item
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the item is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int indexOf (MenuItem item) {
+	checkWidget();
+	if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
+	MenuItem [] items = getItems ();
+	for (int i=0; i<items.length; i++) {
+		if (items [i] == item) return i;
+	}
+	return -1;
+}
+
+/**
+ * Returns <code>true</code> if the receiver is enabled and all
+ * of the receiver's ancestors are enabled, and <code>false</code>
+ * otherwise. A disabled menu is typically not selectable from the
+ * user interface and draws with an inactive or "grayed" look.
+ *
+ * @return the receiver's enabled state
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see #getEnabled
+ */
+public boolean isEnabled () {
+	checkWidget();
+	Menu parentMenu = getParentMenu ();
+	if (parentMenu == null) {
+		return getEnabled () && parent.isEnabled ();
+	}
+	return getEnabled () && parentMenu.isEnabled ();
+}
+
+/**
+ * Returns <code>true</code> if the receiver is visible and all
+ * of the receiver's ancestors are visible and <code>false</code>
+ * otherwise.
+ *
+ * @return the receiver's visibility state
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #getVisible
+ */
+public boolean isVisible () {
+	checkWidget();
+	return getVisible ();
+}
+
+int /*long*/ menuPositionProc (int /*long*/ menu, int /*long*/ x, int /*long*/ y, int /*long*/ push_in, int /*long*/ user_data) {
+	/*
+	* Feature in GTK.  The menu position function sets the position of the
+	* top-left pixel of the menu.  If the menu would be off-screen, GTK will
+	* add a scroll arrow at the bottom and position the first menu entry at
+	* the specified position.  The fix is to flip the menu location to be
+	* completely inside the screen.
+	* 
+	* NOTE: This code doesn't work for multiple monitors.
+	*/
+    GtkRequisition requisition = new GtkRequisition ();
+    OS.gtk_widget_size_request (menu, requisition);
+    int screenHeight = OS.gdk_screen_height ();
+	int reqy = this.y;
+	if (reqy + requisition.height > screenHeight) {
+    	reqy = Math.max (0, reqy - requisition.height);
+	} 
+    int screenWidth = OS.gdk_screen_width ();
+	int reqx = this.x;
+    if ((style & SWT.RIGHT_TO_LEFT) != 0) {
+    	if (reqx - requisition.width >= 0) reqx -= requisition.width;
+    } else {
+    	if (reqx + requisition.width > screenWidth) reqx -= requisition.width;
+    }
+	if (x != 0) OS.memmove (x, new int [] {reqx}, 4);
+	if (y != 0) OS.memmove (y, new int [] {reqy}, 4);
+	if (push_in != 0) OS.memmove (push_in, new int [] {1}, 4);
+	return 0;
+}
+
+void releaseChildren (boolean destroy) {
+	MenuItem [] items = getItems ();
+	for (int i=0; i<items.length; i++) {
+		MenuItem item = items [i];
+		if (item != null && !item.isDisposed ()) {
+			item.release (false);
+		}
+	}
+	super.releaseChildren (destroy);
+}
+
+void releaseParent () {
+	super.releaseParent ();
+	if (cascade != null) cascade.setMenu (null);
+	if ((style & SWT.BAR) != 0 && this == parent.menuBar) {
+		parent.setMenuBar (null);
+	}  else {
+		if ((style & SWT.POP_UP) != 0) {
+			display.removePopup (this);
+		}
+	}
+}
+
+void releaseWidget () {
+	super.releaseWidget ();
+	if (parent != null) parent.removeMenu (this); 
+	parent = null;
+	cascade = null;
+	imItem = imSeparator = imHandle = 0;
+	if (imageList != null) imageList.dispose ();
+	imageList = null;
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the menu events are generated for the control.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see MenuListener
+ * @see #addMenuListener
+ */
+public void removeMenuListener (MenuListener listener) {
+	checkWidget();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if (eventTable == null) return;
+	eventTable.unhook (SWT.Hide, listener);
+	eventTable.unhook (SWT.Show, listener);
+}
+
+void removeAccelerators (int /*long*/ accelGroup) {
+	MenuItem [] items = getItems ();
+	for (int i = 0; i < items.length; i++) {
+		MenuItem item = items[i];
+		item.removeAccelerators (accelGroup);
+	}
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the help events are generated for the control.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see HelpListener
+ * @see #addHelpListener
+ */
+public void removeHelpListener (HelpListener listener) {
+	checkWidget();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if (eventTable == null) return;
+	eventTable.unhook (SWT.Help, listener);
+}
+
+boolean sendHelpEvent (int /*long*/ helpType) {
+	if (selectedItem != null && !selectedItem.isDisposed()) {
+		if (selectedItem.hooks (SWT.Help)) {
+			selectedItem.postEvent (SWT.Help);
+			return true;
+		}
+	}
+	if (hooks (SWT.Help)) {
+		postEvent (SWT.Help);
+		return true;
+	}
+	return parent.sendHelpEvent (helpType);
+}
+
+/**
+ * Sets the default menu item to the argument or removes
+ * the default emphasis when the argument is <code>null</code>.
+ * 
+ * @param item the default menu item or null
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the menu item has been disposed</li> 
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setDefaultItem (MenuItem item) {
+	checkWidget();
+}
+
+/**
+ * Enables the receiver if the argument is <code>true</code>,
+ * and disables it otherwise. A disabled menu is typically
+ * not selectable from the user interface and draws with an
+ * inactive or "grayed" look.
+ *
+ * @param enabled the new enabled state
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setEnabled (boolean enabled) {
+	checkWidget();
+	if (enabled) {
+		OS.GTK_WIDGET_SET_FLAGS (handle, OS.GTK_SENSITIVE);
+	} else {
+		OS.GTK_WIDGET_UNSET_FLAGS (handle, OS.GTK_SENSITIVE);
+	}
+}
+
+/**
+ * Sets the location of the receiver, which must be a popup,
+ * to the point specified by the arguments which are relative
+ * to the display.
+ * <p>
+ * Note that this is different from most widgets where the
+ * location of the widget is relative to the parent.
+ * </p><p>
+ * Note that the platform window manager ultimately has control
+ * over the location of popup menus.
+ * </p>
+ *
+ * @param x the new x coordinate for the receiver
+ * @param y the new y coordinate for the receiver
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setLocation (int x, int y) {
+	checkWidget();
+	if ((style & (SWT.BAR | SWT.DROP_DOWN)) != 0) return;
+	this.x = x;
+	this.y = y;
+	hasLocation = true;	
+}
+
+/**
+ * Sets the location of the receiver, which must be a popup,
+ * to the point specified by the argument which is relative
+ * to the display.
+ * <p>
+ * Note that this is different from most widgets where the
+ * location of the widget is relative to the parent.
+ * </p><p>
+ * Note that the platform window manager ultimately has control
+ * over the location of popup menus.
+ * </p>
+ *
+ * @param location the new location for the receiver
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the point is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 2.1
+ */
+public void setLocation (Point location) {
+	checkWidget();
+	if (location == null) error (SWT.ERROR_NULL_ARGUMENT);
+	setLocation (location.x, location.y);
+}
+
+void setOrientation() {
+	if ((parent.style & SWT.RIGHT_TO_LEFT) != 0) {
+		if (handle != 0) OS.gtk_widget_set_direction (handle, OS.GTK_TEXT_DIR_RTL);
+	}
+}
+
+/**
+ * Marks the receiver as visible if the argument is <code>true</code>,
+ * and marks it invisible otherwise. 
+ * <p>
+ * If one of the receiver's ancestors is not visible or some
+ * other condition makes the receiver not visible, marking
+ * it visible may not actually cause it to be displayed.
+ * </p>
+ *
+ * @param visible the new visibility state
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setVisible (boolean visible) {
+	checkWidget();
+	if ((style & (SWT.BAR | SWT.DROP_DOWN)) != 0) return;
+	if (visible) {
+		display.addPopup (this);
+	} else {
+		display.removePopup (this);
+		_setVisible (false);
+	}
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/MenuItem.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/MenuItem.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/MenuItem.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,882 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.widgets;
+
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.gtk.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.events.*;
+
+/**
+ * Instances of this class represent a selectable user interface object
+ * that issues notification when pressed and released. 
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>CHECK, CASCADE, PUSH, RADIO, SEPARATOR</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Arm, Help, Selection</dd>
+ * </dl>
+ * <p>
+ * Note: Only one of the styles CHECK, CASCADE, PUSH, RADIO and SEPARATOR
+ * may be specified.
+ * </p><p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ *
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public class MenuItem extends Item {
+	Menu parent, menu;
+	int /*long*/ groupHandle;
+	int accelerator;
+	
+/**
+ * Constructs a new instance of this class given its parent
+ * (which must be a <code>Menu</code>) and a style value
+ * describing its behavior and appearance. The item is added
+ * to the end of the items maintained by its parent.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a menu control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT#CHECK
+ * @see SWT#CASCADE
+ * @see SWT#PUSH
+ * @see SWT#RADIO
+ * @see SWT#SEPARATOR
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public MenuItem (Menu parent, int style) {
+	super (parent, checkStyle (style));
+	this.parent = parent;
+	createWidget (parent.getItemCount ());
+}
+
+/**
+ * Constructs a new instance of this class given its parent
+ * (which must be a <code>Menu</code>), a style value
+ * describing its behavior and appearance, and the index
+ * at which to place it in the items maintained by its parent.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a menu control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ * @param index the zero-relative index to store the receiver in its parent
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the parent (inclusive)</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT#CHECK
+ * @see SWT#CASCADE
+ * @see SWT#PUSH
+ * @see SWT#RADIO
+ * @see SWT#SEPARATOR
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public MenuItem (Menu parent, int style, int index) {
+	super (parent, checkStyle (style));
+	this.parent = parent;
+	int count = parent.getItemCount ();
+	if (!(0 <= index && index <= count)) {
+		error (SWT.ERROR_INVALID_RANGE);
+	}
+	createWidget (index);
+}
+
+void addAccelerator (int /*long*/ accelGroup) {
+	updateAccelerator (accelGroup, true);
+}
+
+void addAccelerators (int /*long*/ accelGroup) {
+	addAccelerator (accelGroup);
+	if (menu != null) menu.addAccelerators (accelGroup);
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the arm events are generated for the control, by sending
+ * it one of the messages defined in the <code>ArmListener</code>
+ * interface.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see ArmListener
+ * @see #removeArmListener
+ */
+public void addArmListener (ArmListener listener) {
+	checkWidget();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	TypedListener typedListener = new TypedListener (listener);
+	addListener (SWT.Arm, typedListener);
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the help events are generated for the control, by sending
+ * it one of the messages defined in the <code>HelpListener</code>
+ * interface.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see HelpListener
+ * @see #removeHelpListener
+ */
+public void addHelpListener (HelpListener listener) {
+	checkWidget();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	TypedListener typedListener = new TypedListener (listener);
+	addListener (SWT.Help, typedListener);
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the menu item is selected by the user, by sending
+ * it one of the messages defined in the <code>SelectionListener</code>
+ * interface.
+ * <p>
+ * When <code>widgetSelected</code> is called, the stateMask field of the event object is valid.
+ * <code>widgetDefaultSelected</code> is not called.
+ * </p>
+ *
+ * @param listener the listener which should be notified when the menu item is selected by the user
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent
+ */
+public void addSelectionListener (SelectionListener listener) {
+	checkWidget();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	TypedListener typedListener = new TypedListener(listener);
+	addListener (SWT.Selection,typedListener);
+	addListener (SWT.DefaultSelection,typedListener);
+}
+
+static int checkStyle (int style) {
+	return checkBits (style, SWT.PUSH, SWT.CHECK, SWT.RADIO, SWT.SEPARATOR, SWT.CASCADE, 0);
+}
+
+protected void checkSubclass () {
+	if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
+}
+
+void createHandle (int index) {
+	state |= HANDLE;
+	byte [] buffer = new byte [1];
+	int bits = SWT.CHECK | SWT.RADIO | SWT.PUSH | SWT.SEPARATOR;
+	switch (style & bits) {
+		case SWT.SEPARATOR:
+			handle = OS.gtk_separator_menu_item_new ();
+			break;
+		case SWT.RADIO:
+			/*
+			* Feature in GTK.  In GTK, radio button must always be part of
+			* a radio button group.  In a GTK radio group, one button is always
+			* selected.  This means that it is not possible to have a single
+			* radio button that is unselected.  This is necessary to allow
+			* applications to implement their own radio behavior or use radio
+			* buttons outside of radio groups.  The fix is to create a hidden
+			* radio button for each radio button we create and add them
+			* to the same group.  This allows the visible button to be
+			* unselected.
+			*/
+			groupHandle = OS.gtk_radio_menu_item_new (0);
+			if (groupHandle == 0) error (SWT.ERROR_NO_HANDLES);
+			OS.g_object_ref (groupHandle);
+			OS.gtk_object_sink (groupHandle);
+			int /*long*/ group = OS.gtk_radio_menu_item_get_group (groupHandle);
+			handle = OS.gtk_radio_menu_item_new_with_label (group, buffer);
+			break;
+		case SWT.CHECK:
+			handle = OS.gtk_check_menu_item_new_with_label (buffer);
+			break;
+		case SWT.PUSH:
+		default:
+			handle = OS.gtk_image_menu_item_new_with_label (buffer);
+			break;
+	}
+	if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+	if ((style & SWT.SEPARATOR) == 0) {
+		int /*long*/ label = OS.gtk_bin_get_child (handle);
+		OS.gtk_accel_label_set_accel_widget (label, 0);
+	}
+	int /*long*/ parentHandle = parent.handle;
+	boolean enabled = OS.GTK_WIDGET_SENSITIVE (parentHandle);     
+	if (!enabled) OS.GTK_WIDGET_SET_FLAGS (parentHandle, OS.GTK_SENSITIVE);
+	OS.gtk_menu_shell_insert (parentHandle, handle, index);
+	if (!enabled) OS.GTK_WIDGET_UNSET_FLAGS (parentHandle, OS.GTK_SENSITIVE);
+	OS.gtk_widget_show (handle);
+}
+
+void fixMenus (Decorations newParent) {
+	if (menu != null) menu.fixMenus (newParent);
+}
+
+/**
+ * Returns the widget accelerator.  An accelerator is the bit-wise
+ * OR of zero or more modifier masks and a key. Examples:
+ * <code>SWT.CONTROL | SWT.SHIFT | 'T', SWT.ALT | SWT.F2</code>.
+ * The default value is zero, indicating that the menu item does
+ * not have an accelerator.
+ *
+ * @return the accelerator or 0
+ *
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getAccelerator () {
+	checkWidget();
+	return accelerator;
+}
+
+int /*long*/ getAccelGroup () {
+	Menu menu = parent;
+	while (menu != null && menu.cascade != null) {
+		menu = menu.cascade.parent;
+	}
+	if (menu == null) return 0;
+	Decorations shell = menu.parent;
+	return shell.menuBar == menu ? shell.accelGroup : 0;
+}
+
+/*public*/ Rectangle getBounds () {
+	checkWidget();
+	if (!OS.GTK_WIDGET_MAPPED (handle)) {
+		return new Rectangle (0, 0, 0, 0);
+	}
+	int x = OS.GTK_WIDGET_X (handle);
+	int y = OS.GTK_WIDGET_Y (handle);
+	int width = OS.GTK_WIDGET_WIDTH (handle);
+	int height = OS.GTK_WIDGET_HEIGHT (handle);
+	return new Rectangle (x, y, width, height);
+}
+
+/**
+ * Returns <code>true</code> if the receiver is enabled, and
+ * <code>false</code> otherwise. A disabled menu item is typically
+ * not selectable from the user interface and draws with an
+ * inactive or "grayed" look.
+ *
+ * @return the receiver's enabled state
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see #isEnabled
+ */
+public boolean getEnabled () {
+	checkWidget();
+	return OS.GTK_WIDGET_SENSITIVE (handle);
+}
+
+/**
+ * Returns the receiver's cascade menu if it has one or null
+ * if it does not. Only <code>CASCADE</code> menu items can have
+ * a pull down menu. The sequence of key strokes, button presses 
+ * and/or button releases that are used to request a pull down
+ * menu is platform specific.
+ *
+ * @return the receiver's menu
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Menu getMenu () {
+	checkWidget();
+	return menu;
+}
+
+String getNameText () {
+	if ((style & SWT.SEPARATOR) != 0) return "|";
+	return super.getNameText ();
+}
+
+/**
+ * Returns the receiver's parent, which must be a <code>Menu</code>.
+ *
+ * @return the receiver's parent
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Menu getParent () {
+	checkWidget();
+	return parent;
+}
+
+/**
+ * Returns <code>true</code> if the receiver is selected,
+ * and false otherwise.
+ * <p>
+ * When the receiver is of type <code>CHECK</code> or <code>RADIO</code>,
+ * it is selected when it is checked.
+ *
+ * @return the selection state
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public boolean getSelection () {
+	checkWidget();
+	if ((style & (SWT.CHECK | SWT.RADIO)) == 0) return false;
+	return OS.gtk_check_menu_item_get_active(handle);
+}
+
+int /*long*/ gtk_activate (int /*long*/ widget) {
+	if ((style & SWT.CASCADE) != 0 && menu != null) return 0;
+	/*
+	* Bug in GTK.  When an ancestor menu is disabled and
+	* the user types an accelerator key, GTK delivers the
+	* the activate signal even though the menu item cannot
+	* be invoked using the mouse.  The fix is to ignore
+	* activate signals when an ancestor menu is disabled.
+	*/
+	if (!isEnabled ()) return 0;
+	Event event = new Event ();
+	int /*long*/ ptr = OS.gtk_get_current_event ();
+	if (ptr != 0) {
+		GdkEvent gdkEvent = new GdkEvent ();
+		OS.memmove (gdkEvent, ptr, GdkEvent.sizeof);
+		switch (gdkEvent.type) {
+			case OS.GDK_KEY_PRESS:
+			case OS.GDK_KEY_RELEASE: 
+			case OS.GDK_BUTTON_PRESS:
+			case OS.GDK_2BUTTON_PRESS: 
+			case OS.GDK_BUTTON_RELEASE: {
+				int [] state = new int [1];
+				OS.gdk_event_get_state (ptr, state);
+				setInputState (event, state [0]);
+				break;
+			}
+		}
+		OS.gdk_event_free (ptr);
+	}
+	if ((style & SWT.RADIO) != 0) {
+		if ((parent.getStyle () & SWT.NO_RADIO_GROUP) == 0) {
+			selectRadio ();
+		}
+	}
+	postEvent (SWT.Selection, event);
+	return 0;
+}
+
+int /*long*/ gtk_select (int /*long*/ item) {
+	parent.selectedItem = this;
+	sendEvent (SWT.Arm);
+	return 0;
+}
+
+int /*long*/ gtk_show_help (int /*long*/ widget, int /*long*/ helpType) {
+	boolean handled = hooks (SWT.Help);
+	if (handled) {
+		postEvent (SWT.Help);
+	} else {
+		handled = parent.sendHelpEvent (helpType);
+	}
+	if (handled) {
+		OS.gtk_menu_shell_deactivate (parent.handle);
+		return 1;
+	}
+	return 0;
+}
+
+void hookEvents () {
+	super.hookEvents ();
+	OS.g_signal_connect_closure (handle, OS.activate, display.closures [ACTIVATE], false);
+	OS.g_signal_connect_closure (handle, OS.select, display.closures [SELECT], false);
+	OS.g_signal_connect_closure_by_id (handle, display.signalIds [SHOW_HELP], 0, display.closures [SHOW_HELP], false);
+}
+
+/**
+ * Returns <code>true</code> if the receiver is enabled and all
+ * of the receiver's ancestors are enabled, and <code>false</code>
+ * otherwise. A disabled menu item is typically not selectable from the
+ * user interface and draws with an inactive or "grayed" look.
+ *
+ * @return the receiver's enabled state
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see #getEnabled
+ */
+public boolean isEnabled () {
+	return getEnabled () && parent.isEnabled ();
+}
+
+void releaseChildren (boolean destroy) {
+	if (menu != null) {
+		menu.release (false);
+		menu = null;
+	}
+	super.releaseChildren (destroy);
+}
+
+void releaseParent () {
+	super.releaseParent ();
+	if (menu != null) {
+		if (menu.selectedItem == this) menu.selectedItem = null;
+		menu.dispose ();
+	}
+	menu = null;
+}
+
+void releaseWidget () {
+	super.releaseWidget ();
+	int /*long*/ accelGroup = getAccelGroup ();
+	if (accelGroup != 0) removeAccelerator (accelGroup);
+	if (groupHandle != 0) OS.g_object_unref (groupHandle);
+	groupHandle = 0;
+	accelerator = 0;
+	parent = null;
+}
+
+void removeAccelerator (int /*long*/ accelGroup) {
+	updateAccelerator (accelGroup, false);
+}
+
+void removeAccelerators (int /*long*/ accelGroup) {
+	removeAccelerator (accelGroup);
+	if (menu != null) menu.removeAccelerators (accelGroup);
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the arm events are generated for the control.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see ArmListener
+ * @see #addArmListener
+ */
+public void removeArmListener (ArmListener listener) {
+	checkWidget();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if (eventTable == null) return;
+	eventTable.unhook (SWT.Arm, listener);
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the help events are generated for the control.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see HelpListener
+ * @see #addHelpListener
+ */
+public void removeHelpListener (HelpListener listener) {
+	checkWidget();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if (eventTable == null) return;
+	eventTable.unhook (SWT.Help, listener);
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the control is selected by the user.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #addSelectionListener
+ */
+public void removeSelectionListener (SelectionListener listener) {
+	checkWidget();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if (eventTable == null) return;
+	eventTable.unhook (SWT.Selection, listener);
+	eventTable.unhook (SWT.DefaultSelection,listener);	
+}
+void selectRadio () {
+	int index = 0;
+	MenuItem [] items = parent.getItems ();
+	while (index < items.length && items [index] != this) index++;
+	int i = index - 1;
+	while (i >= 0 && items [i].setRadioSelection (false)) --i;
+	int j = index + 1;
+	while (j < items.length && items [j].setRadioSelection (false)) j++;
+	setSelection (true);
+}
+/**
+ * Sets the widget accelerator.  An accelerator is the bit-wise
+ * OR of zero or more modifier masks and a key. Examples:
+ * <code>SWT.MOD1 | SWT.MOD2 | 'T', SWT.MOD3 | SWT.F2</code>.
+ * <code>SWT.CONTROL | SWT.SHIFT | 'T', SWT.ALT | SWT.F2</code>.
+ * The default value is zero, indicating that the menu item does
+ * not have an accelerator.
+ *
+ * @param accelerator an integer that is the bit-wise OR of masks and a key
+ *
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setAccelerator (int accelerator) {
+	checkWidget();
+	if (this.accelerator == accelerator) return;
+	int /*long*/ accelGroup = getAccelGroup ();
+	if (accelGroup != 0) removeAccelerator (accelGroup);
+	this.accelerator = accelerator;
+	if (accelGroup != 0) addAccelerator (accelGroup);
+}
+
+/**
+ * Enables the receiver if the argument is <code>true</code>,
+ * and disables it otherwise. A disabled menu item is typically
+ * not selectable from the user interface and draws with an
+ * inactive or "grayed" look.
+ *
+ * @param enabled the new enabled state
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setEnabled (boolean enabled) {
+	checkWidget();
+	if (OS.GTK_WIDGET_SENSITIVE (handle) == enabled) return;
+	int /*long*/ accelGroup = getAccelGroup ();
+	if (accelGroup != 0) removeAccelerator (accelGroup);
+	OS.gtk_widget_set_sensitive (handle, enabled);
+	if (accelGroup != 0) addAccelerator (accelGroup);
+}
+
+/**
+ * Sets the image the receiver will display to the argument.
+ * <p>
+ * Note: This operation is a hint and is not supported on
+ * platforms that do not have this concept (for example, Windows NT).
+ * Furthermore, some platforms (such as GTK), cannot display both
+ * a check box and an image at the same time.  Instead, they hide
+ * the image and display the check box.
+ * </p>
+ *
+ * @param image the image to display
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setImage (Image image) {
+	checkWidget();
+	if ((style & SWT.SEPARATOR) != 0) return;
+	super.setImage (image);
+	if (!OS.GTK_IS_IMAGE_MENU_ITEM (handle)) return;
+	if (image != null) {
+		ImageList imageList = parent.imageList;
+		if (imageList == null) imageList = parent.imageList = new ImageList ();
+		int imageIndex = imageList.indexOf (image);
+		if (imageIndex == -1) {
+			imageIndex = imageList.add (image);
+		} else {
+			imageList.put (imageIndex, image);
+		}
+		int /*long*/ pixbuf = imageList.getPixbuf (imageIndex);
+		int /*long*/ imageHandle = OS.gtk_image_new_from_pixbuf (pixbuf);
+		OS.gtk_image_menu_item_set_image (handle, imageHandle);
+		OS.gtk_widget_show (imageHandle);
+	} else {
+		OS.gtk_image_menu_item_set_image (handle, 0);
+	}
+}
+
+/**
+ * Sets the receiver's pull down menu to the argument.
+ * Only <code>CASCADE</code> menu items can have a
+ * pull down menu. The sequence of key strokes, button presses
+ * and/or button releases that are used to request a pull down
+ * menu is platform specific.
+ * <p>
+ * Note: Disposing of a menu item that has a pull down menu
+ * will dispose of the menu.  To avoid this behavior, set the
+ * menu to null before the menu item is disposed.
+ * </p>
+ *
+ * @param menu the new pull down menu
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_MENU_NOT_DROP_DOWN - if the menu is not a drop down menu</li>
+ *    <li>ERROR_MENUITEM_NOT_CASCADE - if the menu item is not a <code>CASCADE</code></li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the menu has been disposed</li>
+ *    <li>ERROR_INVALID_PARENT - if the menu is not in the same widget tree</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setMenu (Menu menu) {
+	checkWidget ();
+
+	/* Check to make sure the new menu is valid */
+	if ((style & SWT.CASCADE) == 0) {
+		error (SWT.ERROR_MENUITEM_NOT_CASCADE);
+	}
+	if (menu != null) {
+		if ((menu.style & SWT.DROP_DOWN) == 0) {
+			error (SWT.ERROR_MENU_NOT_DROP_DOWN);
+		}
+		if (menu.parent != parent.parent) {
+			error (SWT.ERROR_INVALID_PARENT);
+		}
+	}
+
+	/* Assign the new menu */
+	Menu oldMenu = this.menu;
+	if (oldMenu == menu) return;
+	int /*long*/ accelGroup = getAccelGroup ();
+	if (accelGroup != 0) removeAccelerators (accelGroup);
+	if (oldMenu != null) {
+		oldMenu.cascade = null;
+		/*
+		* Add a reference to the menu we are about
+		* to replace or GTK will destroy it.
+		*/
+		OS.g_object_ref (oldMenu.handle);
+		OS.gtk_menu_item_remove_submenu (handle);
+	}
+	if ((this.menu = menu) != null) {
+		menu.cascade = this;
+		OS.gtk_menu_item_set_submenu (handle, menu.handle);
+	}
+	if (accelGroup != 0) addAccelerators (accelGroup);
+}
+
+void setOrientation() {
+	if ((parent.style & SWT.RIGHT_TO_LEFT) != 0) {
+		if (handle != 0) {
+			OS.gtk_widget_set_direction (handle, OS.GTK_TEXT_DIR_RTL);
+			OS.gtk_container_forall (handle, display.setDirectionProc, OS.GTK_TEXT_DIR_RTL);		
+		}
+	}
+}
+
+boolean setRadioSelection (boolean value) {
+	if ((style & SWT.RADIO) == 0) return false;
+	if (getSelection () != value) {
+		setSelection (value);
+		postEvent (SWT.Selection);
+	}
+	return true;
+}
+
+/**
+ * Sets the selection state of the receiver.
+ * <p>
+ * When the receiver is of type <code>CHECK</code> or <code>RADIO</code>,
+ * it is selected when it is checked.
+ *
+ * @param selected the new selection state
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setSelection (boolean selected) {
+	checkWidget();
+	if ((style & (SWT.CHECK | SWT.RADIO)) == 0) return;
+	OS.g_signal_handlers_block_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, ACTIVATE);
+	OS.gtk_check_menu_item_set_active (handle, selected);
+	if ((style & SWT.RADIO) != 0) OS.gtk_check_menu_item_set_active (groupHandle, !selected);
+	OS.g_signal_handlers_unblock_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, ACTIVATE);
+}
+
+/**
+ * Sets the receiver's text. The string may include
+ * the mnemonic character and accelerator text.
+ * <p>
+ * Mnemonics are indicated by an '&amp;' that causes the next
+ * character to be the mnemonic.  When the user presses a
+ * key sequence that matches the mnemonic, a selection
+ * event occurs. On most platforms, the mnemonic appears
+ * underlined but may be emphasised in a platform specific
+ * manner.  The mnemonic indicator character '&amp;' can be
+ * escaped by doubling it in the string, causing a single
+ * '&amp;' to be displayed.
+ * </p>
+ * <p>
+ * Accelerator text is indicated by the '\t' character.
+ * On platforms that support accelerator text, the text
+ * that follows the '\t' character is displayed to the user,
+ * typically indicating the key stroke that will cause
+ * the item to become selected.  On most platforms, the
+ * accelerator text appears right aligned in the menu.
+ * Setting the accelerator text does not install the
+ * accelerator key sequence. The accelerator key sequence
+ * is installed using #setAccelerator.
+ * </p>
+ * 
+ * @param string the new text
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the text is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see #setAccelerator
+ */
+public void setText (String string) {
+	checkWidget();
+	if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if ((style & SWT.SEPARATOR) != 0) return;
+	if (text.equals (string)) return;
+	super.setText (string);
+	String accelString = "";
+	int index = string.indexOf ('\t');
+	if (index != -1) {
+		boolean isRTL = (parent.style & SWT.RIGHT_TO_LEFT) != 0;
+		accelString = (isRTL? "" : "  ") + string.substring (index+1, string.length()) + (isRTL? "  " : "");
+		string = string.substring (0, index);
+	}
+	char [] chars = fixMnemonic (string);
+	byte [] buffer = Converter.wcsToMbcs (null, chars, true);
+	int /*long*/ label = OS.gtk_bin_get_child (handle);
+	OS.gtk_label_set_text_with_mnemonic (label, buffer);
+	buffer = Converter.wcsToMbcs (null, accelString, true);
+	int /*long*/ ptr = OS.g_malloc (buffer.length);
+	OS.memmove (ptr, buffer, buffer.length);
+	int /*long*/ oldPtr = OS.GTK_ACCEL_LABEL_GET_ACCEL_STRING (label);
+	OS.GTK_ACCEL_LABEL_SET_ACCEL_STRING (label, ptr);
+	if (oldPtr != 0) OS.g_free (oldPtr);
+}
+
+void updateAccelerator (int /*long*/ accelGroup, boolean add) {
+	if (accelerator == 0 || !getEnabled ()) return;
+	if ((accelerator & SWT.COMMAND) != 0) return;
+	int mask = 0;
+	if ((accelerator & SWT.ALT) != 0) mask |= OS.GDK_MOD1_MASK;
+	if ((accelerator & SWT.SHIFT) != 0) mask |= OS.GDK_SHIFT_MASK;
+	if ((accelerator & SWT.CONTROL) != 0) mask |= OS.GDK_CONTROL_MASK;
+	int keysym = accelerator & SWT.KEY_MASK;
+	int newKey = Display.untranslateKey (keysym);
+	if (newKey != 0) {
+		keysym = newKey;
+	} else {
+		switch (keysym) {
+			case '\r': keysym = OS.GDK_Return; break;
+			default: keysym = Display.wcsToMbcs ((char) keysym);
+		}
+	}
+	/* When accel_key is zero, it causes GTK warnings */
+	if (keysym != 0) {
+		if (add) {
+			OS.gtk_widget_add_accelerator (handle, OS.activate, accelGroup, keysym, mask, OS.GTK_ACCEL_VISIBLE);
+		} else {
+			OS.gtk_widget_remove_accelerator (handle, accelGroup, keysym, mask);
+		}
+	}
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/MessageBox.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/MessageBox.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/MessageBox.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,214 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.widgets;
+
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.gtk.*;
+
+/**
+ * Instances of this class are used to inform or warn the user.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>ICON_ERROR, ICON_INFORMATION, ICON_QUESTION, ICON_WARNING, ICON_WORKING</dd>
+ * <dd>OK, OK | CANCEL</dd>
+ * <dd>YES | NO, YES | NO | CANCEL</dd>
+ * <dd>RETRY | CANCEL</dd>
+ * <dd>ABORT | RETRY | IGNORE</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>(none)</dd>
+ * </dl>
+ * <p>
+ * Note: Only one of the styles ICON_ERROR, ICON_INFORMATION, ICON_QUESTION,
+ * ICON_WARNING and ICON_WORKING may be specified.
+ * </p><p>
+ * IMPORTANT: This class is intended to be subclassed <em>only</em>
+ * within the SWT implementation.
+ * </p>
+ *
+ * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: ControlExample, Dialog tab</a>
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public class MessageBox extends Dialog {
+
+	String message = "";
+	int /*long*/ handle;
+/**
+ * Constructs a new instance of this class given only its parent.
+ *
+ * @param parent a shell which will be the parent of the new instance
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ */
+public MessageBox (Shell parent) {
+	this (parent, SWT.OK | SWT.ICON_INFORMATION | SWT.APPLICATION_MODAL);
+}
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ *
+ * @param parent a shell which will be the parent of the new instance
+ * @param style the style of dialog to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ */
+public MessageBox (Shell parent, int style) {
+	super (parent, checkStyle (parent, checkStyle (style)));
+	checkSubclass ();
+}
+
+/**
+ * Returns the dialog's message, or an empty string if it does not have one.
+ * The message is a description of the purpose for which the dialog was opened.
+ * This message will be visible in the dialog while it is open.
+ *
+ * @return the message
+ */
+public String getMessage () {
+	return message;
+}
+
+/**
+ * Sets the dialog's message, which is a description of
+ * the purpose for which it was opened. This message will be
+ * visible on the dialog while it is open.
+ *
+ * @param string the message
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ * </ul>
+ */
+public void setMessage (String string) {
+	if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+	message = string;
+}
+
+/**
+ * Makes the dialog visible and brings it to the front
+ * of the display.
+ *
+ * @return the ID of the button that was selected to dismiss the
+ *         message box (e.g. SWT.OK, SWT.CANCEL, etc.)
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the dialog has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the dialog</li>
+ * </ul>
+ */
+public int open () {
+	int /*long*/ parentHandle = (parent != null) ? parent.topHandle() : 0;
+	int dialogFlags = OS.GTK_DIALOG_DESTROY_WITH_PARENT;
+	if ((style & (SWT.PRIMARY_MODAL | SWT.APPLICATION_MODAL | SWT.SYSTEM_MODAL)) != 0) {
+		dialogFlags |= OS.GTK_DIALOG_MODAL;
+	}
+	int messageType = OS.GTK_MESSAGE_INFO;
+	if ((style & (SWT.ICON_WARNING)) != 0)  messageType = OS.GTK_MESSAGE_WARNING;
+	if ((style & (SWT.ICON_QUESTION)) != 0) messageType = OS.GTK_MESSAGE_QUESTION;
+	if ((style & (SWT.ICON_ERROR)) != 0)    messageType = OS.GTK_MESSAGE_ERROR;
+	
+	byte [] buffer = Converter.wcsToMbcs (null, fixPercent (message), true);
+	handle = OS.gtk_message_dialog_new(parentHandle, dialogFlags, messageType, 0, buffer);
+	if (handle == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+	if (parentHandle != 0) {
+		int /*long*/ pixbufs = OS.gtk_window_get_icon_list (parentHandle);
+		if (pixbufs != 0) {
+			OS.gtk_window_set_icon_list (handle, pixbufs);
+			OS.g_list_free (pixbufs);
+		}
+	}
+	createButtons();
+	buffer = Converter.wcsToMbcs(null, title, true);
+	OS.gtk_window_set_title(handle,buffer);
+	Display display = parent != null ? parent.getDisplay (): Display.getCurrent ();
+	display.addIdleProc ();
+	Dialog oldModal = null;
+	if (OS.gtk_window_get_modal (handle)) {
+		oldModal = display.getModalDialog ();
+		display.setModalDialog (this);
+	}
+	int signalId = 0;
+	int /*long*/ hookId = 0;
+	if ((style & SWT.RIGHT_TO_LEFT) != 0) {
+		signalId = OS.g_signal_lookup (OS.map, OS.GTK_TYPE_WIDGET());
+		hookId = OS.g_signal_add_emission_hook (signalId, 0, display.emissionProc, handle, 0);
+	}	
+	int response = OS.gtk_dialog_run (handle);
+	if ((style & SWT.RIGHT_TO_LEFT) != 0) {
+		OS.g_signal_remove_emission_hook (signalId, hookId);
+	}
+	if (OS.gtk_window_get_modal (handle)) {
+		display.setModalDialog (oldModal);
+	}	
+	display.removeIdleProc ();
+	OS.gtk_widget_destroy (handle);
+	return response;
+}
+
+private void createButtons() {
+	if ((style & SWT.OK) != 0) OS.gtk_dialog_add_button(handle, Converter.wcsToMbcs (null, "gtk-ok", true), SWT.OK);
+	if ((style & SWT.CANCEL) != 0) OS.gtk_dialog_add_button(handle, Converter.wcsToMbcs (null, "gtk-cancel", true), SWT.CANCEL);
+	if ((style & SWT.YES) != 0) OS.gtk_dialog_add_button(handle, Converter.wcsToMbcs (null, "gtk-yes", true), SWT.YES);
+	if ((style & SWT.NO) != 0) OS.gtk_dialog_add_button(handle, Converter.wcsToMbcs (null, "gtk-no", true), SWT.NO);
+	if ((style & SWT.ABORT) != 0) OS.gtk_dialog_add_button(handle, Converter.wcsToMbcs (null, SWT.getMessage("SWT_Abort"), true), SWT.ABORT);
+	if ((style & SWT.RETRY) != 0) OS.gtk_dialog_add_button(handle, Converter.wcsToMbcs (null, SWT.getMessage("SWT_Retry"), true), SWT.RETRY);
+	if ((style & SWT.IGNORE) != 0) OS.gtk_dialog_add_button(handle, Converter.wcsToMbcs (null, SWT.getMessage("SWT_Ignore"), true), SWT.IGNORE);
+}
+
+private static int checkStyle (int style) {
+	int mask = (SWT.YES | SWT.NO | SWT.OK | SWT.CANCEL | SWT.ABORT | SWT.RETRY | SWT.IGNORE);
+	int bits = style & mask;
+	if (bits == SWT.OK || bits == SWT.CANCEL || bits == (SWT.OK | SWT.CANCEL)) return style;
+	if (bits == SWT.YES || bits == SWT.NO || bits == (SWT.YES | SWT.NO) || bits == (SWT.YES | SWT.NO | SWT.CANCEL)) return style;
+	if (bits == (SWT.RETRY | SWT.CANCEL) || bits == (SWT.ABORT | SWT.RETRY | SWT.IGNORE)) return style;
+	style = (style & ~mask) | SWT.OK;
+	return style;
+}
+
+char[] fixPercent (String string) {
+	int length = string.length ();
+	char [] text = new char [length];
+	string.getChars (0, length, text, 0);
+	int i = 0, j = 0;
+	char [] result = new char [length * 2];
+	while (i < length) {
+		switch (text [i]) {
+			case '%':
+				result [j++] = '%';
+				break;
+		}
+		result [j++] = text [i++];
+	}
+	return result;    
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Monitor.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Monitor.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Monitor.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,87 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.widgets;
+
+import org.eclipse.swt.graphics.*;
+
+/**
+ * Instances of this class are descriptions of monitors.
+ *
+ * @see Display
+ * @see <a href="http://www.eclipse.org/swt/snippets/#monitor">Monitor snippets</a>
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ * 
+ * @since 3.0
+ */
+public final class Monitor {
+	int /*long*/ handle;
+	int x, y, width, height;
+	int clientX, clientY, clientWidth, clientHeight;
+	
+/**
+ * Prevents uninitialized instances from being created outside the package.
+ */
+Monitor () {	
+}
+	
+/**
+ * Compares the argument to the receiver, and returns true
+ * if they represent the <em>same</em> object using a class
+ * specific comparison.
+ *
+ * @param object the object to compare with this object
+ * @return <code>true</code> if the object is the same as this object and <code>false</code> otherwise
+ *
+ * @see #hashCode()
+ */
+public boolean equals (Object object) {
+	if (object == this) return true;
+	if (!(object instanceof Monitor)) return false;
+	Monitor monitor = (Monitor) object;
+	return handle == monitor.handle;
+}
+
+/**
+ * Returns a rectangle describing the receiver's size and location
+ * relative to its device. Note that on multi-monitor systems the
+ * origin can be negative.
+ *
+ * @return the receiver's bounding rectangle
+ */	
+public Rectangle getBounds () {
+	return new Rectangle (x, y, width, height);
+}
+	
+/**
+ * Returns a rectangle which describes the area of the
+ * receiver which is capable of displaying data.
+ * 
+ * @return the client area
+ */
+public Rectangle getClientArea () {
+	return new Rectangle (clientX, clientY, clientWidth, clientHeight);
+}
+	
+/**
+ * Returns an integer hash code for the receiver. Any two 
+ * objects that return <code>true</code> when passed to 
+ * <code>equals</code> must return the same value for this
+ * method.
+ *
+ * @return the receiver's hash
+ *
+ * @see #equals(Object)
+ */
+public int hashCode () {
+	return (int)/*64*/handle;
+}
+
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/ProgressBar.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/ProgressBar.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/ProgressBar.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,300 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.widgets;
+
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.gtk.*;
+
+/**
+ * Instances of the receiver represent an unselectable
+ * user interface object that is used to display progress,
+ * typically in the form of a bar.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>SMOOTH, HORIZONTAL, VERTICAL, INDETERMINATE</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>(none)</dd>
+ * </dl>
+ * <p>
+ * Note: Only one of the styles HORIZONTAL and VERTICAL may be specified.
+ * </p><p>
+ * IMPORTANT: This class is intended to be subclassed <em>only</em>
+ * within the SWT implementation.
+ * </p>
+ *
+ * @see <a href="http://www.eclipse.org/swt/snippets/#progressbar">ProgressBar snippets</a>
+ * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: ControlExample</a>
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public class ProgressBar extends Control {
+	int timerId, minimum = 0, maximum = 100, selection = 0;
+	static final int DELAY = 100;
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT#SMOOTH
+ * @see SWT#HORIZONTAL
+ * @see SWT#VERTICAL
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public ProgressBar (Composite parent, int style) {
+	super (parent, checkStyle(style));
+}
+
+static int checkStyle (int style) {
+	style |= SWT.NO_FOCUS;
+	return checkBits (style, SWT.HORIZONTAL, SWT.VERTICAL, 0, 0, 0, 0);
+}
+
+void createHandle (int index) {
+	state |= HANDLE;
+	fixedHandle = OS.g_object_new (display.gtk_fixed_get_type (), 0);
+	if (fixedHandle == 0) error (SWT.ERROR_NO_HANDLES);
+	OS.gtk_fixed_set_has_window (fixedHandle, true);
+	handle = OS.gtk_progress_bar_new ();
+	if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+	OS.gtk_container_add (fixedHandle, handle);
+	int orientation = (style & SWT.VERTICAL) != 0 ? OS.GTK_PROGRESS_BOTTOM_TO_TOP : OS.GTK_PROGRESS_LEFT_TO_RIGHT;
+	OS.gtk_progress_bar_set_orientation (handle, orientation);
+	if ((style & SWT.INDETERMINATE) != 0) {
+		timerId = OS.gtk_timeout_add (DELAY, display.windowTimerProc, handle);
+	}
+}
+
+/**
+ * Returns the maximum value which the receiver will allow.
+ *
+ * @return the maximum
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getMaximum () {
+	checkWidget ();
+	return maximum;
+}
+
+/**
+ * Returns the minimum value which the receiver will allow.
+ *
+ * @return the minimum
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getMinimum () {
+	checkWidget ();
+	return minimum;
+}
+
+/**
+ * Returns the single 'selection' that is the receiver's position.
+ *
+ * @return the selection
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getSelection () {
+	checkWidget ();
+	return selection;
+}
+
+/**
+ * Returns the state of the receiver. The value will be one of:
+ * <ul>
+ * 	<li>{@link SWT#NORMAL}</li>
+ * 	<li>{@link SWT#ERROR}</li>
+ * 	<li>{@link SWT#PAUSED}</li>
+ * </ul>
+ *
+ * @return the state 
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.4
+ */
+public int getState () {
+	checkWidget ();
+	return SWT.NORMAL;
+}
+
+int /*long*/ gtk_realize (int /*long*/ widget) {
+	int /*long*/ result = super.gtk_realize (widget);
+	if (result != 0) return result;
+	/*
+	* Bug in GTK.  When a progress bar has been unrealized after being
+	* realized at least once, gtk_progress_bar_set_fraction() GP's.  The
+	* fix is to update the progress bar state only when realized and restore
+	* the state when the progress bar becomes realized.
+	*/
+	updateBar (selection, minimum, maximum);
+	return 0;
+}
+
+void releaseWidget () {
+	super.releaseWidget ();
+	if (timerId != 0) OS.gtk_timeout_remove (timerId);
+	timerId = 0;
+}
+
+void setParentBackground () {
+	/*
+	* Bug in GTK.  For some reason, some theme managers will crash
+	* when the progress bar is inheriting the background from a parent.
+	* The fix is to stop inheriting the background. This is acceptable
+	* since progress bars do not use the inherited background. 
+	*/
+}
+
+/**
+ * Sets the maximum value that the receiver will allow.  This new
+ * value will be ignored if it is not greater than the receiver's current
+ * minimum value.  If the new maximum is applied then the receiver's
+ * selection value will be adjusted if necessary to fall within its new range.
+ *
+ * @param value the new maximum, which must be greater than the current minimum
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setMaximum (int value) {
+	checkWidget ();
+	if (value <= minimum) return;
+	maximum = value;
+	selection = Math.min (selection, maximum);
+	updateBar (selection, minimum, maximum);
+}
+
+/**
+ * Sets the minimum value that the receiver will allow.  This new
+ * value will be ignored if it is negative or is not less than the receiver's
+ * current maximum value.  If the new minimum is applied then the receiver's
+ * selection value will be adjusted if necessary to fall within its new range.
+ *
+ * @param value the new minimum, which must be nonnegative and less than the current maximum
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setMinimum (int value) {
+	checkWidget ();
+	if (value < 0 || value >= maximum) return;
+	minimum = value;
+	selection = Math.max (selection, minimum);
+	updateBar (selection, minimum, maximum);
+}
+
+/**
+ * Sets the single 'selection' that is the receiver's
+ * position to the argument which must be greater than or equal
+ * to zero.
+ *
+ * @param value the new selection (must be zero or greater)
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setSelection (int value) {
+	checkWidget ();
+	selection = Math.max (minimum, Math.min (maximum, value));
+	updateBar (selection, minimum, maximum);
+}
+
+/**
+ * Sets the state of the receiver. The state must be one of these values:
+ * <ul>
+ * 	<li>{@link SWT#NORMAL}</li>
+ * 	<li>{@link SWT#ERROR}</li>
+ * 	<li>{@link SWT#PAUSED}</li>
+ * </ul>
+ *
+ * @param state the new state
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.4
+ */
+public void setState (int state) {
+	checkWidget ();
+	//NOT IMPLEMENTED
+}
+
+int /*long*/ timerProc (int /*long*/ widget) {
+	if (isVisible ()) OS.gtk_progress_bar_pulse (handle);
+	return 1;
+}
+
+void updateBar (int selection, int minimum, int maximum) {
+	/*
+	* Bug in GTK.  When a progress bar has been unrealized after being
+	* realized at least once, gtk_progress_bar_set_fraction() GP's.  The
+	* fix is to update the progress bar state only when realized and restore
+	* the state when the progress bar becomes realized.
+	*/
+	if ((OS.GTK_WIDGET_FLAGS (handle) & OS.GTK_REALIZED) == 0) return;
+
+	double fraction = minimum == maximum ? 1 : (double)(selection - minimum) / (maximum - minimum);
+	OS.gtk_progress_bar_set_fraction (handle, fraction);
+	/*
+	* Feature in GTK.  The progress bar does
+	* not redraw right away when a value is
+	* changed.  This is not strictly incorrect
+	* but unexpected.  The fix is to force all
+	* outstanding redraws to be delivered.
+	*/
+	int /*long*/ window = paintWindow ();
+	OS.gdk_window_process_updates (window, false);
+	OS.gdk_flush ();
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/RunnableLock.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/RunnableLock.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/RunnableLock.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.widgets;
+
+
+/**
+ * Instances of this class are used to ensure that an
+ * application cannot interfere with the locking mechanism
+ * used to implement asynchronous and synchronous communication
+ * between widgets and background threads.
+ */
+
+class RunnableLock {
+	Runnable runnable;
+	Thread thread;
+	Throwable throwable;
+	
+RunnableLock (Runnable runnable) {
+	this.runnable = runnable;
+}
+
+boolean done () {
+	return runnable == null || throwable != null;
+}
+
+void run () {
+	if (runnable != null) runnable.run ();
+	runnable = null;
+}
+
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Sash.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Sash.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Sash.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,439 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.widgets;
+
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.gtk.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.events.*;
+
+/**
+ * Instances of the receiver represent a selectable user interface object
+ * that allows the user to drag a rubber banded outline of the sash within
+ * the parent control.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>HORIZONTAL, VERTICAL, SMOOTH</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Selection</dd>
+ * </dl>
+ * <p>
+ * Note: Only one of the styles HORIZONTAL and VERTICAL may be specified.
+ * </p><p>
+ * IMPORTANT: This class is intended to be subclassed <em>only</em>
+ * within the SWT implementation.
+ * </p>
+ *
+ * @see <a href="http://www.eclipse.org/swt/snippets/#sash">Sash snippets</a>
+ * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: ControlExample</a>
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public class Sash extends Control {
+	boolean dragging;
+	int startX, startY, lastX, lastY;
+	int /*long*/ defaultCursor;
+
+	private final static int INCREMENT = 1;
+	private final static int PAGE_INCREMENT = 9;
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT#HORIZONTAL
+ * @see SWT#VERTICAL
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public Sash (Composite parent, int style) {
+	super (parent, checkStyle (style));
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the control is selected by the user, by sending
+ * it one of the messages defined in the <code>SelectionListener</code>
+ * interface.
+ * <p>
+ * When <code>widgetSelected</code> is called, the x, y, width, and height fields of the event object are valid.
+ * If the receiver is being dragged, the event object detail field contains the value <code>SWT.DRAG</code>.
+ * <code>widgetDefaultSelected</code> is not called.
+ * </p>
+ *
+ * @param listener the listener which should be notified when the control is selected by the user
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent
+ */
+public void addSelectionListener (SelectionListener listener) {
+	checkWidget ();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	TypedListener typedListener = new TypedListener (listener);
+	addListener (SWT.Selection,typedListener);
+	addListener (SWT.DefaultSelection,typedListener);
+}
+
+static int checkStyle (int style) {
+	return checkBits (style, SWT.HORIZONTAL, SWT.VERTICAL, 0, 0, 0, 0);
+}
+
+public Point computeSize (int wHint, int hHint, boolean changed) {
+	checkWidget ();
+	if (wHint != SWT.DEFAULT && wHint < 0) wHint = 0;
+	if (hHint != SWT.DEFAULT && hHint < 0) hHint = 0;
+	int border = getBorderWidth ();
+	int width = border * 2, height = border * 2;
+	if ((style & SWT.HORIZONTAL) != 0) {
+		width += DEFAULT_WIDTH;  height += 3;
+	} else {
+		width += 3; height += DEFAULT_HEIGHT;
+	}
+	if (wHint != SWT.DEFAULT) width = wHint + (border * 2);
+	if (hHint != SWT.DEFAULT) height = hHint + (border * 2);
+	return new Point (width, height);
+}
+
+void createHandle (int index) {
+	state |= HANDLE | THEME_BACKGROUND;
+	handle = OS.g_object_new (display.gtk_fixed_get_type (), 0);
+	if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+	OS.gtk_fixed_set_has_window (handle, true);
+	OS.GTK_WIDGET_SET_FLAGS (handle, OS.GTK_CAN_FOCUS);
+	int type = (style & SWT.VERTICAL) != 0 ? OS.GDK_SB_H_DOUBLE_ARROW : OS.GDK_SB_V_DOUBLE_ARROW;
+	defaultCursor = OS.gdk_cursor_new (type);
+}
+
+void drawBand (int x, int y, int width, int height) {
+	if ((style & SWT.SMOOTH) != 0) return;
+	int /*long*/ window = OS.GTK_WIDGET_WINDOW (parent.paintHandle());
+	if (window == 0) return;
+	byte [] bits = {-86, 85, -86, 85, -86, 85, -86, 85};
+	int /*long*/ stipplePixmap = OS.gdk_bitmap_create_from_data (window, bits, 8, 8);
+	int /*long*/ gc = OS.gdk_gc_new (window);
+	int /*long*/ colormap = OS.gdk_colormap_get_system();
+	GdkColor color = new GdkColor ();
+	OS.gdk_color_white (colormap, color);
+	OS.gdk_gc_set_foreground (gc, color);	
+	OS.gdk_gc_set_stipple (gc, stipplePixmap);
+	OS.gdk_gc_set_subwindow (gc, OS.GDK_INCLUDE_INFERIORS);
+	OS.gdk_gc_set_fill (gc, OS.GDK_STIPPLED);
+	OS.gdk_gc_set_function (gc, OS.GDK_XOR);
+	OS.gdk_draw_rectangle (window, gc, 1, x, y, width, height);	
+	OS.g_object_unref (stipplePixmap);
+	OS.g_object_unref (gc);
+}
+
+int /*long*/ gtk_button_press_event (int /*long*/ widget, int /*long*/ eventPtr) {
+	int /*long*/ result = super.gtk_button_press_event (widget, eventPtr);
+	if (result != 0) return result;
+	GdkEventButton gdkEvent = new GdkEventButton ();
+	OS.memmove (gdkEvent, eventPtr, GdkEventButton.sizeof);
+	int button = gdkEvent.button;
+	if (button != 1) return 0;
+	if (gdkEvent.type == OS.GDK_2BUTTON_PRESS) return 0;
+	if (gdkEvent.type == OS.GDK_3BUTTON_PRESS) return 0;
+	int /*long*/ window = OS.GTK_WIDGET_WINDOW (widget);
+	int [] origin_x = new int [1], origin_y = new int [1];
+	OS.gdk_window_get_origin (window, origin_x, origin_y);
+	startX = (int) (gdkEvent.x_root - origin_x [0]);
+	startY = (int) (gdkEvent.y_root - origin_y [0]);
+	int x = OS.GTK_WIDGET_X (handle);
+	int y = OS.GTK_WIDGET_Y (handle);
+	int width = OS.GTK_WIDGET_WIDTH (handle);
+	int height = OS.GTK_WIDGET_HEIGHT (handle);
+	lastX = x; 
+	lastY = y;
+	Event event = new Event ();
+	event.time = gdkEvent.time;
+	event.x = lastX;
+	event.y = lastY;
+	event.width = width;
+	event.height = height;
+	if ((style & SWT.SMOOTH) == 0) {
+		event.detail = SWT.DRAG;
+	}
+	if ((parent.style & SWT.MIRRORED) != 0) event.x = parent.getClientWidth () - width  - event.x;
+	sendEvent (SWT.Selection, event);
+	if (isDisposed ()) return 0;
+	if (event.doit) {
+		dragging = true;
+		lastX = event.x;
+		lastY = event.y;
+		if ((parent.style & SWT.MIRRORED) != 0) lastX = parent.getClientWidth () - width  - lastX;
+		parent.update (true, (style & SWT.SMOOTH) == 0);
+		drawBand (lastX, event.y, width, height);
+		if ((style & SWT.SMOOTH) != 0) {
+			setBounds (event.x, event.y, width, height);
+			// widget could be disposed at this point
+		}
+	}
+	return result;	
+}
+
+int /*long*/ gtk_button_release_event (int /*long*/ widget, int /*long*/ eventPtr) {
+	int /*long*/ result = super.gtk_button_release_event (widget, eventPtr);
+	if (result != 0) return result;
+	GdkEventButton gdkEvent = new GdkEventButton ();
+	OS.memmove (gdkEvent, eventPtr, GdkEventButton.sizeof);
+	int button = gdkEvent.button;
+	if (button != 1) return 0;
+	if (!dragging) return 0;
+	dragging = false;
+	int width = OS.GTK_WIDGET_WIDTH (handle);
+	int height = OS.GTK_WIDGET_HEIGHT (handle);
+	Event event = new Event ();
+	event.time = gdkEvent.time;
+	event.x = lastX;
+	event.y = lastY;
+	event.width = width;
+	event.height = height;
+	drawBand (lastX, lastY, width, height);
+	if ((parent.style & SWT.MIRRORED) != 0) event.x = parent.getClientWidth () - width  - event.x;
+	sendEvent (SWT.Selection, event);
+	if (isDisposed ()) return result;
+	if (event.doit) {
+		if ((style & SWT.SMOOTH) != 0) {
+			setBounds (event.x, event.y, width, height);
+			// widget could be disposed at this point
+		}
+	}
+	return result;
+}
+
+int /*long*/ gtk_focus_in_event (int /*long*/ widget, int /*long*/ event) {
+	int /*long*/ result = super.gtk_focus_in_event (widget, event);
+	if (result != 0) return result;
+	// widget could be disposed at this point
+	if (handle != 0) {
+			lastX = OS.GTK_WIDGET_X (handle);
+			lastY = OS.GTK_WIDGET_Y (handle);
+	}
+	return 0;
+}
+
+int /*long*/ gtk_key_press_event (int /*long*/ widget, int /*long*/ eventPtr) {
+	int /*long*/ result = super.gtk_key_press_event (widget, eventPtr);
+	if (result != 0) return result;
+	GdkEventKey gdkEvent = new GdkEventKey ();
+	OS.memmove (gdkEvent, eventPtr, GdkEventKey.sizeof);
+	int keyval = gdkEvent.keyval;
+	switch (keyval) {
+		case OS.GDK_Left:
+		case OS.GDK_Right:
+		case OS.GDK_Up:
+		case OS.GDK_Down:
+			int xChange = 0, yChange = 0;
+			int stepSize = PAGE_INCREMENT;
+			if ((gdkEvent.state & OS.GDK_CONTROL_MASK) != 0) stepSize = INCREMENT;
+			if ((style & SWT.VERTICAL) != 0) {
+				if (keyval == OS.GDK_Up || keyval == OS.GDK_Down) break;
+				xChange = keyval == OS.GDK_Left ? -stepSize : stepSize;
+			} else {
+				if (keyval == OS.GDK_Left ||keyval == OS.GDK_Right) break;
+				yChange = keyval == OS.GDK_Up ? -stepSize : stepSize;
+			}
+			
+			int width = OS.GTK_WIDGET_WIDTH (handle);
+			int height = OS.GTK_WIDGET_HEIGHT (handle);
+			int parentBorder = 0;
+			int parentWidth = OS.GTK_WIDGET_WIDTH (parent.handle);
+			int parentHeight = OS.GTK_WIDGET_HEIGHT (parent.handle);
+			int newX = lastX, newY = lastY;
+			if ((style & SWT.VERTICAL) != 0) {
+				newX = Math.min (Math.max (0, lastX + xChange - parentBorder - startX), parentWidth - width);
+			} else {
+				newY = Math.min (Math.max (0, lastY + yChange - parentBorder - startY), parentHeight - height);
+			}
+			if (newX == lastX && newY == lastY) return result;
+			
+			/* Ensure that the pointer image does not change */
+			int /*long*/ window = OS.GTK_WIDGET_WINDOW (handle);
+			int grabMask = OS.GDK_POINTER_MOTION_MASK | OS.GDK_BUTTON_RELEASE_MASK;
+			int /*long*/ gdkCursor = cursor != null ? cursor.handle : defaultCursor;
+			int ptrGrabResult = OS.gdk_pointer_grab (window, false, grabMask, window, gdkCursor, OS.GDK_CURRENT_TIME);
+
+			/* The event must be sent because its doit flag is used. */
+			Event event = new Event ();
+			event.time = gdkEvent.time;
+			event.x = newX;
+			event.y = newY;
+			event.width = width;
+			event.height = height;
+			if ((parent.style & SWT.MIRRORED) != 0) event.x = parent.getClientWidth () - width  - event.x;
+			sendEvent (SWT.Selection, event);
+			if (ptrGrabResult == OS.GDK_GRAB_SUCCESS) OS.gdk_pointer_ungrab (OS.GDK_CURRENT_TIME);
+			if (isDisposed ()) break;
+			
+			if (event.doit) {
+				lastX = event.x;
+				lastY = event.y;
+				if ((parent.style & SWT.MIRRORED) != 0) lastX = parent.getClientWidth () - width  - lastX;
+				if ((style & SWT.SMOOTH) != 0) {
+					setBounds (event.x, event.y, width, height);
+					if (isDisposed ()) break;
+				}
+				int cursorX = event.x, cursorY = event.y;
+				if ((style & SWT.VERTICAL) != 0) {
+					cursorY += height / 2;
+				} else {
+					cursorX += width / 2;
+				}
+				display.setCursorLocation (parent.toDisplay (cursorX, cursorY));
+			}
+			break;
+	}
+
+	return result;
+}
+
+int /*long*/ gtk_motion_notify_event (int /*long*/ widget, int /*long*/ eventPtr) {
+	int /*long*/ result = super.gtk_motion_notify_event (widget, eventPtr);
+	if (result != 0) return result;
+	if (!dragging) return 0;
+	GdkEventMotion gdkEvent = new GdkEventMotion ();
+	OS.memmove (gdkEvent, eventPtr, GdkEventButton.sizeof);
+	int eventX, eventY, eventState;
+	if (gdkEvent.is_hint != 0) {
+		int [] pointer_x = new int [1], pointer_y = new int [1], mask = new int [1];
+		OS.gdk_window_get_pointer (gdkEvent.window, pointer_x, pointer_y, mask);
+		eventX = pointer_x [0];
+		eventY = pointer_y [0];
+		eventState = mask [0];
+	} else {
+		int [] origin_x = new int [1], origin_y = new int [1];
+		OS.gdk_window_get_origin (gdkEvent.window, origin_x, origin_y);	
+		eventX = (int) (gdkEvent.x_root - origin_x [0]);
+		eventY = (int) (gdkEvent.y_root - origin_y [0]);
+		eventState = gdkEvent.state;
+	}
+	if ((eventState & OS.GDK_BUTTON1_MASK) == 0) return 0;
+	int x = OS.GTK_WIDGET_X (handle);
+	int y = OS.GTK_WIDGET_Y (handle);
+	int width = OS.GTK_WIDGET_WIDTH (handle);
+	int height = OS.GTK_WIDGET_HEIGHT (handle);
+	int parentBorder = 0;
+	int parentWidth = OS.GTK_WIDGET_WIDTH (parent.handle);
+	int parentHeight = OS.GTK_WIDGET_HEIGHT (parent.handle);
+	int newX = lastX, newY = lastY;
+	if ((style & SWT.VERTICAL) != 0) {
+		newX = Math.min (Math.max (0, eventX + x - startX - parentBorder), parentWidth - width);
+	} else {
+		newY = Math.min (Math.max (0, eventY + y - startY - parentBorder), parentHeight - height);
+	}
+	if (newX == lastX && newY == lastY) return 0;
+	drawBand (lastX, lastY, width, height);
+	
+	Event event = new Event ();
+	event.time = gdkEvent.time;
+	event.x = newX;
+	event.y = newY;
+	event.width = width;
+	event.height = height;
+	if ((style & SWT.SMOOTH) == 0) {
+		event.detail = SWT.DRAG;
+	}
+	if ((parent.style & SWT.MIRRORED) != 0) event.x = parent.getClientWidth() - width  - event.x;
+	sendEvent (SWT.Selection, event);
+	if (isDisposed ()) return 0;
+	if (event.doit) {
+		lastX = event.x;
+		lastY = event.y;
+		if ((parent.style & SWT.MIRRORED) != 0) lastX = parent.getClientWidth () - width  - lastX;
+	}
+	parent.update (true, (style & SWT.SMOOTH) == 0);
+	drawBand (lastX, lastY, width, height);
+	if ((style & SWT.SMOOTH) != 0) {
+		setBounds (event.x, lastY, width, height);
+		// widget could be disposed at this point
+	}
+	return result;
+}
+
+int /*long*/ gtk_realize (int /*long*/ widget) {
+	setCursor (cursor != null ? cursor.handle : 0);
+	return super.gtk_realize (widget);
+}
+
+void hookEvents () {
+	super.hookEvents ();
+	OS.gtk_widget_add_events (handle, OS.GDK_POINTER_MOTION_HINT_MASK);
+}
+
+void releaseWidget () {
+	super.releaseWidget ();
+	if (defaultCursor != 0) OS.gdk_cursor_destroy (defaultCursor);
+	defaultCursor = 0;
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the control is selected by the user.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #addSelectionListener
+ */
+public void removeSelectionListener(SelectionListener listener) {
+	checkWidget();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if (eventTable == null) return;
+	eventTable.unhook (SWT.Selection, listener);
+	eventTable.unhook (SWT.DefaultSelection,listener);	
+}
+
+void setCursor (int /*long*/ cursor) {
+	super.setCursor (cursor != 0 ? cursor : defaultCursor);
+}
+
+int traversalCode (int key, GdkEventKey event) {
+	return 0;
+}
+
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Scale.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Scale.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Scale.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,376 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.widgets;
+
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.gtk.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.events.*;
+
+/**
+ * Instances of the receiver represent a selectable user
+ * interface object that present a range of continuous
+ * numeric values.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>HORIZONTAL, VERTICAL</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Selection</dd>
+ * </dl>
+ * <p>
+ * Note: Only one of the styles HORIZONTAL and VERTICAL may be specified.
+ * </p><p>
+ * <p>
+ * IMPORTANT: This class is intended to be subclassed <em>only</em>
+ * within the SWT implementation.
+ * </p>
+ *
+ * @see <a href="http://www.eclipse.org/swt/snippets/#scale">Scale snippets</a>
+ * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: ControlExample</a>
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public class Scale extends Control {
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT#HORIZONTAL
+ * @see SWT#VERTICAL
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public Scale (Composite parent, int style) {
+	super (parent, checkStyle (style));
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the user changes the receiver's value, by sending
+ * it one of the messages defined in the <code>SelectionListener</code>
+ * interface.
+ * <p>
+ * <code>widgetSelected</code> is called when the user changes the receiver's value.
+ * <code>widgetDefaultSelected</code> is not called.
+ * </p>
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ */
+public void addSelectionListener (SelectionListener listener) {
+	checkWidget ();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	TypedListener typedListener = new TypedListener (listener);
+	addListener (SWT.Selection,typedListener);
+	addListener (SWT.DefaultSelection,typedListener);
+}
+
+static int checkStyle (int style) {
+	return checkBits (style, SWT.HORIZONTAL, SWT.VERTICAL, 0, 0, 0, 0);
+}
+
+public Point computeSize (int wHint, int hHint, boolean changed) {
+	checkWidget();
+	if (wHint != SWT.DEFAULT && wHint < 0) wHint = 0;
+	if (hHint != SWT.DEFAULT && hHint < 0) hHint = 0;
+	Point size = computeNativeSize(handle, wHint, hHint, changed);
+	if ((style & SWT.HORIZONTAL) != 0) {
+		if (wHint == SWT.DEFAULT) size.x = 2 * size.x;
+	} else {
+		if (hHint == SWT.DEFAULT) size.y = 2 * size.y;
+	}
+	return size;
+}
+
+void createHandle (int index) {
+	state |= HANDLE | THEME_BACKGROUND;
+	fixedHandle = OS.g_object_new (display.gtk_fixed_get_type (), 0);
+	if (fixedHandle == 0) error (SWT.ERROR_NO_HANDLES);
+	OS.gtk_fixed_set_has_window (fixedHandle, true);
+	int /*long*/ hAdjustment = OS.gtk_adjustment_new (0, 0, 100, 1, 10, 0);
+	if (hAdjustment == 0) error (SWT.ERROR_NO_HANDLES);	
+	if ((style & SWT.HORIZONTAL) != 0) {
+		handle = OS.gtk_hscale_new (hAdjustment);
+	} else {
+		handle = OS.gtk_vscale_new (hAdjustment);
+	}
+	if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+	OS.gtk_container_add (fixedHandle, handle);
+	OS.gtk_scale_set_digits (handle, 0); 
+	OS.gtk_scale_set_draw_value (handle, false);
+}
+
+void hookEvents () {
+	super.hookEvents ();
+	OS.g_signal_connect_closure (handle, OS.value_changed, display.closures [VALUE_CHANGED], false);
+}
+
+/**
+ * Returns the amount that the receiver's value will be
+ * modified by when the up/down (or right/left) arrows
+ * are pressed.
+ *
+ * @return the increment
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getIncrement () {
+	checkWidget ();
+	int /*long*/ hAdjustment = OS.gtk_range_get_adjustment (handle);
+	GtkAdjustment adjustment = new GtkAdjustment ();
+	OS.memmove (adjustment, hAdjustment);
+	return (int) adjustment.step_increment;
+}
+
+/**
+ * Returns the maximum value which the receiver will allow.
+ *
+ * @return the maximum
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getMaximum () {
+	checkWidget ();
+	int /*long*/ hAdjustment = OS.gtk_range_get_adjustment (handle);
+	GtkAdjustment adjustment = new GtkAdjustment ();
+	OS.memmove (adjustment, hAdjustment);
+	return (int) adjustment.upper;
+}
+
+/**
+ * Returns the minimum value which the receiver will allow.
+ *
+ * @return the minimum
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getMinimum () {
+	checkWidget ();
+	int /*long*/ hAdjustment = OS.gtk_range_get_adjustment (handle);
+	GtkAdjustment adjustment = new GtkAdjustment ();
+	OS.memmove (adjustment, hAdjustment);
+	return (int) adjustment.lower;
+}
+
+/**
+ * Returns the amount that the receiver's value will be
+ * modified by when the page increment/decrement areas
+ * are selected.
+ *
+ * @return the page increment
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getPageIncrement () {
+	checkWidget ();
+	int /*long*/ hAdjustment = OS.gtk_range_get_adjustment (handle);
+	GtkAdjustment adjustment = new GtkAdjustment ();
+	OS.memmove (adjustment, hAdjustment);
+	return (int) adjustment.page_increment;
+}
+
+/**
+ * Returns the 'selection', which is the receiver's position.
+ *
+ * @return the selection
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getSelection () {
+	checkWidget ();
+	int /*long*/ hAdjustment = OS.gtk_range_get_adjustment (handle);
+	GtkAdjustment adjustment = new GtkAdjustment ();
+	OS.memmove (adjustment, hAdjustment);
+	return (int) adjustment.value;
+}
+
+int /*long*/ gtk_value_changed (int /*long*/ adjustment) {
+	postEvent (SWT.Selection);
+	return 0;
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the user changes the receiver's value.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #addSelectionListener
+ */
+public void removeSelectionListener (SelectionListener listener) {
+	checkWidget ();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if (eventTable == null) return;
+	eventTable.unhook (SWT.Selection, listener);
+	eventTable.unhook (SWT.DefaultSelection,listener);	
+}
+
+/**
+ * Sets the amount that the receiver's value will be
+ * modified by when the up/down (or right/left) arrows
+ * are pressed to the argument, which must be at least 
+ * one.
+ *
+ * @param increment the new increment (must be greater than zero)
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setIncrement (int value) {
+	checkWidget ();
+	if (value < 1) return;
+	OS.g_signal_handlers_block_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, VALUE_CHANGED);
+	OS.gtk_range_set_increments (handle, value, getPageIncrement ());
+	OS.g_signal_handlers_unblock_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, VALUE_CHANGED);
+}
+
+/**
+ * Sets the maximum value that the receiver will allow.  This new
+ * value will be ignored if it is not greater than the receiver's current
+ * minimum value.  If the new maximum is applied then the receiver's
+ * selection value will be adjusted if necessary to fall within its new range.
+ *
+ * @param value the new maximum, which must be greater than the current minimum
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setMaximum (int value) {
+	checkWidget ();
+	int minimum = getMinimum();
+	if (value <= minimum) return;
+	OS.g_signal_handlers_block_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, VALUE_CHANGED);
+	OS.gtk_range_set_range (handle, minimum, value);
+	OS.g_signal_handlers_unblock_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, VALUE_CHANGED);
+}
+
+/**
+ * Sets the minimum value that the receiver will allow.  This new
+ * value will be ignored if it is negative or is not less than the receiver's
+ * current maximum value.  If the new minimum is applied then the receiver's
+ * selection value will be adjusted if necessary to fall within its new range.
+ *
+ * @param value the new minimum, which must be nonnegative and less than the current maximum
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setMinimum (int value) {
+	checkWidget ();
+	if (value < 0) return;
+	int maximum = getMaximum ();
+	if (value >= maximum) return;
+	OS.g_signal_handlers_block_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, VALUE_CHANGED);
+	OS.gtk_range_set_range (handle, value, maximum);
+	OS.g_signal_handlers_unblock_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, VALUE_CHANGED);
+}
+
+/**
+ * Sets the amount that the receiver's value will be
+ * modified by when the page increment/decrement areas
+ * are selected to the argument, which must be at least
+ * one.
+ *
+ * @param pageIncrement the page increment (must be greater than zero)
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setPageIncrement (int value) {
+	checkWidget ();
+	if (value < 1) return;
+	OS.g_signal_handlers_block_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, VALUE_CHANGED);
+	OS.gtk_range_set_increments (handle, getIncrement (), value);
+	OS.g_signal_handlers_unblock_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, VALUE_CHANGED);
+}
+
+/**
+ * Sets the 'selection', which is the receiver's value,
+ * to the argument which must be greater than or equal to zero.
+ *
+ * @param value the new selection (must be zero or greater)
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setSelection (int value) {
+	checkWidget ();
+	OS.g_signal_handlers_block_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, VALUE_CHANGED);
+	OS.gtk_range_set_value (handle, value);
+	OS.g_signal_handlers_unblock_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, VALUE_CHANGED);
+}
+
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/ScrollBar.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/ScrollBar.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/ScrollBar.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,767 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.widgets;
+
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.gtk.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.events.*;
+
+/**
+ * Instances of this class are selectable user interface
+ * objects that represent a range of positive, numeric values. 
+ * <p>
+ * At any given moment, a given scroll bar will have a 
+ * single 'selection' that is considered to be its
+ * value, which is constrained to be within the range of
+ * values the scroll bar represents (that is, between its
+ * <em>minimum</em> and <em>maximum</em> values).
+ * </p><p>
+ * Typically, scroll bars will be made up of five areas:
+ * <ol>
+ * <li>an arrow button for decrementing the value</li>
+ * <li>a page decrement area for decrementing the value by a larger amount</li>
+ * <li>a <em>thumb</em> for modifying the value by mouse dragging</li>
+ * <li>a page increment area for incrementing the value by a larger amount</li>
+ * <li>an arrow button for incrementing the value</li>
+ * </ol>
+ * Based on their style, scroll bars are either <code>HORIZONTAL</code>
+ * (which have a left facing button for decrementing the value and a
+ * right facing button for incrementing it) or <code>VERTICAL</code>
+ * (which have an upward facing button for decrementing the value
+ * and a downward facing buttons for incrementing it).
+ * </p><p>
+ * On some platforms, the size of the scroll bar's thumb can be
+ * varied relative to the magnitude of the range of values it
+ * represents (that is, relative to the difference between its
+ * maximum and minimum values). Typically, this is used to
+ * indicate some proportional value such as the ratio of the
+ * visible area of a document to the total amount of space that
+ * it would take to display it. SWT supports setting the thumb
+ * size even if the underlying platform does not, but in this
+ * case the appearance of the scroll bar will not change.
+ * </p><p>
+ * Scroll bars are created by specifying either <code>H_SCROLL</code>,
+ * <code>V_SCROLL</code> or both when creating a <code>Scrollable</code>.
+ * They are accessed from the <code>Scrollable</code> using
+ * <code>getHorizontalBar</code> and <code>getVerticalBar</code>.
+ * </p><p>
+ * Note: Scroll bars are not Controls.  On some platforms, scroll bars
+ * that appear as part of some standard controls such as a text or list
+ * have no operating system resources and are not children of the control.
+ * For this reason, scroll bars are treated specially.  To create a control
+ * that looks like a scroll bar but has operating system resources, use
+ * <code>Slider</code>. 
+ * </p>
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>HORIZONTAL, VERTICAL</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Selection</dd>
+ * </dl>
+ * <p>
+ * Note: Only one of the styles HORIZONTAL and VERTICAL may be specified.
+ * </p><p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ *
+ * @see Slider
+ * @see Scrollable
+ * @see Scrollable#getHorizontalBar
+ * @see Scrollable#getVerticalBar
+ * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: ControlExample</a>
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public class ScrollBar extends Widget {
+	Scrollable parent;
+	int /*long*/ adjustmentHandle;
+	int detail;
+	boolean dragSent;
+	
+ScrollBar () {
+}
+
+/**
+* Creates a new instance of the widget.
+*/
+ScrollBar (Scrollable parent, int style) {
+	super (parent, checkStyle (style));
+	this.parent = parent;
+	createWidget (0);
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the user changes the receiver's value, by sending
+ * it one of the messages defined in the <code>SelectionListener</code>
+ * interface.
+ * <p>
+ * When <code>widgetSelected</code> is called, the event object detail field contains one of the following values:
+ * <code>SWT.NONE</code> - for the end of a drag.
+ * <code>SWT.DRAG</code>.
+ * <code>SWT.HOME</code>.
+ * <code>SWT.END</code>.
+ * <code>SWT.ARROW_DOWN</code>.
+ * <code>SWT.ARROW_UP</code>.
+ * <code>SWT.PAGE_DOWN</code>.
+ * <code>SWT.PAGE_UP</code>.
+ * <code>widgetDefaultSelected</code> is not called.
+ * </p>
+ *
+ * @param listener the listener which should be notified when the user changes the receiver's value
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent
+ */
+public void addSelectionListener (SelectionListener listener) {
+	checkWidget ();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	TypedListener typedListener = new TypedListener (listener);
+	addListener (SWT.Selection,typedListener);
+	addListener (SWT.DefaultSelection,typedListener);
+}
+
+static int checkStyle (int style) {
+	return checkBits (style, SWT.HORIZONTAL, SWT.VERTICAL, 0, 0, 0, 0);
+}
+
+void deregister () {
+	super.deregister ();
+	if (adjustmentHandle != 0) display.removeWidget (adjustmentHandle);
+}
+
+void destroyHandle () {
+	super.destroyWidget ();
+}
+
+void destroyWidget () {
+	parent.destroyScrollBar (this);
+	releaseHandle ();
+	//parent.sendEvent (SWT.Resize);
+}
+
+/**
+ * Returns <code>true</code> if the receiver is enabled, and
+ * <code>false</code> otherwise. A disabled control is typically
+ * not selectable from the user interface and draws with an
+ * inactive or "grayed" look.
+ *
+ * @return the receiver's enabled state
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see #isEnabled
+ */
+public boolean getEnabled () {
+	checkWidget ();
+	if (handle != 0) return OS.GTK_WIDGET_SENSITIVE (handle);
+	return true;
+}
+
+/**
+ * Returns the amount that the receiver's value will be
+ * modified by when the up/down (or right/left) arrows
+ * are pressed.
+ *
+ * @return the increment
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getIncrement () {
+	checkWidget ();
+	GtkAdjustment adjustment = new GtkAdjustment ();
+	OS.memmove (adjustment, adjustmentHandle);
+	return (int) adjustment.step_increment;
+}
+
+/**
+ * Returns the maximum value which the receiver will allow.
+ *
+ * @return the maximum
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getMaximum () {
+	checkWidget ();
+	GtkAdjustment adjustment = new GtkAdjustment ();
+	OS.memmove (adjustment, adjustmentHandle);
+	return (int) adjustment.upper;
+}
+
+/**
+ * Returns the minimum value which the receiver will allow.
+ *
+ * @return the minimum
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getMinimum () {
+	checkWidget ();
+	GtkAdjustment adjustment = new GtkAdjustment ();
+	OS.memmove (adjustment, adjustmentHandle);
+	return (int) adjustment.lower;
+}
+
+/**
+ * Returns the amount that the receiver's value will be
+ * modified by when the page increment/decrement areas
+ * are selected.
+ *
+ * @return the page increment
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getPageIncrement () {
+	checkWidget ();
+	GtkAdjustment adjustment = new GtkAdjustment ();
+	OS.memmove (adjustment, adjustmentHandle);
+	return (int) adjustment.page_increment;
+}
+
+/**
+ * Returns the receiver's parent, which must be a Scrollable.
+ *
+ * @return the receiver's parent
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Scrollable getParent () {
+	checkWidget ();
+	return parent;
+}
+
+/**
+ * Returns the single 'selection' that is the receiver's value.
+ *
+ * @return the selection
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getSelection () {
+	checkWidget ();
+	GtkAdjustment adjustment = new GtkAdjustment ();
+	OS.memmove (adjustment, adjustmentHandle);
+	return (int) adjustment.value;
+}
+
+/**
+ * Returns a point describing the receiver's size. The
+ * x coordinate of the result is the width of the receiver.
+ * The y coordinate of the result is the height of the
+ * receiver.
+ *
+ * @return the receiver's size
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Point getSize () {
+	checkWidget ();
+	if (handle == 0) return new Point (0,0);
+	GtkRequisition requisition = new GtkRequisition ();
+	OS.gtk_widget_size_request (handle, requisition);
+	return new Point (requisition.width, requisition.height);
+}
+
+/**
+ * Returns the size of the receiver's thumb relative to the
+ * difference between its maximum and minimum values.
+ *
+ * @return the thumb value
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see ScrollBar
+ */
+public int getThumb () {
+	checkWidget ();
+	GtkAdjustment adjustment = new GtkAdjustment ();
+	OS.memmove (adjustment, adjustmentHandle);
+	return (int) adjustment.page_size;
+}
+
+/**
+ * Returns <code>true</code> if the receiver is visible, and
+ * <code>false</code> otherwise.
+ * <p>
+ * If one of the receiver's ancestors is not visible or some
+ * other condition makes the receiver not visible, this method
+ * may still indicate that it is considered visible even though
+ * it may not actually be showing.
+ * </p>
+ *
+ * @return the receiver's visibility state
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public boolean getVisible () {
+	checkWidget ();
+	int /*long*/ scrolledHandle = parent.scrolledHandle;
+	int [] hsp = new int [1], vsp = new int [1];
+	OS.gtk_scrolled_window_get_policy (scrolledHandle, hsp, vsp);
+	if ((style & SWT.HORIZONTAL) != 0) {
+		return hsp [0] != OS.GTK_POLICY_NEVER;
+	} else {
+		return vsp [0] != OS.GTK_POLICY_NEVER;
+	}
+}
+
+int /*long*/ gtk_button_press_event (int /*long*/ widget, int /*long*/ eventPtr) {
+	int /*long*/ result = super.gtk_button_press_event (widget, eventPtr);
+	if (result != 0) return result;
+	detail = OS.GTK_SCROLL_NONE;
+	dragSent = false;	
+	return result;
+}
+
+int /*long*/ gtk_change_value (int /*long*/ widget, int /*long*/ scroll, int /*long*/ value1, int /*long*/ value2) {
+	detail = (int)/*64*/scroll;
+	return 0;
+}
+
+int /*long*/ gtk_value_changed (int /*long*/ adjustment) {
+	Event event = new Event ();
+	dragSent = detail == OS.GTK_SCROLL_JUMP;
+	switch (detail) {
+		case OS.GTK_SCROLL_NONE:			event.detail = SWT.NONE; break;
+		case OS.GTK_SCROLL_JUMP:			event.detail = SWT.DRAG; break;
+		case OS.GTK_SCROLL_START:			event.detail = SWT.HOME; break;
+		case OS.GTK_SCROLL_END:				event.detail = SWT.END; break;
+		case OS.GTK_SCROLL_PAGE_DOWN:
+		case OS.GTK_SCROLL_PAGE_RIGHT:
+		case OS.GTK_SCROLL_PAGE_FORWARD:	event.detail = SWT.PAGE_DOWN; break;
+		case OS.GTK_SCROLL_PAGE_UP:
+		case OS.GTK_SCROLL_PAGE_LEFT:
+		case OS.GTK_SCROLL_PAGE_BACKWARD:	event.detail = SWT.PAGE_UP; break;
+		case OS.GTK_SCROLL_STEP_DOWN:
+		case OS.GTK_SCROLL_STEP_RIGHT:
+		case OS.GTK_SCROLL_STEP_FORWARD:	event.detail = SWT.ARROW_DOWN; break;
+		case OS.GTK_SCROLL_STEP_UP:
+		case OS.GTK_SCROLL_STEP_LEFT:
+		case OS.GTK_SCROLL_STEP_BACKWARD:	event.detail = SWT.ARROW_UP; break;
+	}
+	detail = OS.GTK_SCROLL_NONE;
+	if (!dragSent) detail = OS.GTK_SCROLL_NONE;
+	postEvent (SWT.Selection, event);
+	parent.updateScrollBarValue (this);
+	return 0;
+}
+
+int /*long*/ gtk_event_after (int /*long*/ widget, int /*long*/ gdkEvent) {
+	GdkEvent gtkEvent = new GdkEvent ();
+	OS.memmove (gtkEvent, gdkEvent, GdkEvent.sizeof);
+	switch (gtkEvent.type) {
+		case OS.GDK_BUTTON_RELEASE: {
+			GdkEventButton gdkEventButton = new GdkEventButton ();
+			OS.memmove (gdkEventButton, gdkEvent, GdkEventButton.sizeof);
+			if (gdkEventButton.button == 1 && detail == SWT.DRAG) {
+				if (!dragSent) {
+					Event event = new Event ();
+					event.detail = SWT.DRAG;
+					postEvent (SWT.Selection, event);
+				}
+				postEvent (SWT.Selection);
+			}
+			detail = OS.GTK_SCROLL_NONE;
+			dragSent = false;
+			break;
+		}
+	}
+	return super.gtk_event_after (widget, gdkEvent);
+}
+
+void hookEvents () {
+	super.hookEvents ();
+	if (OS.GTK_VERSION >= OS.VERSION (2, 6, 0)) {
+		OS.g_signal_connect_closure (handle, OS.change_value, display.closures [CHANGE_VALUE], false);
+	}
+	OS.g_signal_connect_closure (adjustmentHandle, OS.value_changed, display.closures [VALUE_CHANGED], false);
+	OS.g_signal_connect_closure_by_id (handle, display.signalIds [EVENT_AFTER], 0, display.closures [EVENT_AFTER], false);
+	OS.g_signal_connect_closure_by_id (handle, display.signalIds [BUTTON_PRESS_EVENT], 0, display.closures [BUTTON_PRESS_EVENT], false);	
+}
+
+/**
+ * Returns <code>true</code> if the receiver is enabled and all
+ * of the receiver's ancestors are enabled, and <code>false</code>
+ * otherwise. A disabled control is typically not selectable from the
+ * user interface and draws with an inactive or "grayed" look.
+ *
+ * @return the receiver's enabled state
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see #getEnabled
+ */
+public boolean isEnabled () {
+	checkWidget ();
+	return getEnabled () && getParent ().getEnabled ();
+}
+
+/**
+ * Returns <code>true</code> if the receiver is visible and all
+ * of the receiver's ancestors are visible and <code>false</code>
+ * otherwise.
+ *
+ * @return the receiver's visibility state
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #getVisible
+ */
+public boolean isVisible () {
+	checkWidget ();
+	return getVisible () && getParent ().isVisible ();
+}
+
+void register () {
+	super.register ();
+	if (adjustmentHandle != 0) display.addWidget (adjustmentHandle, this);
+}
+
+void releaseHandle () {
+	super.releaseHandle ();
+	parent = null;
+}
+
+void releaseParent () {
+	super.releaseParent ();
+	if (parent.horizontalBar == this) parent.horizontalBar = null;
+	if (parent.verticalBar == this) parent.verticalBar = null;
+}
+
+void releaseWidget () {
+	super.releaseWidget ();
+	//parent = null;
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the user changes the receiver's value.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #addSelectionListener
+ */
+public void removeSelectionListener (SelectionListener listener) {
+	checkWidget ();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if (eventTable == null) return;
+	eventTable.unhook (SWT.Selection, listener);
+	eventTable.unhook (SWT.DefaultSelection,listener);	
+}
+
+/**
+ * Enables the receiver if the argument is <code>true</code>,
+ * and disables it otherwise. A disabled control is typically
+ * not selectable from the user interface and draws with an
+ * inactive or "grayed" look.
+ *
+ * @param enabled the new enabled state
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setEnabled (boolean enabled) {
+	checkWidget ();
+	if (handle != 0) OS.gtk_widget_set_sensitive (handle, enabled);
+}
+
+/**
+ * Sets the amount that the receiver's value will be
+ * modified by when the up/down (or right/left) arrows
+ * are pressed to the argument, which must be at least 
+ * one.
+ *
+ * @param value the new increment (must be greater than zero)
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setIncrement (int value) {
+	checkWidget ();
+	if (value < 1) return;
+	GtkAdjustment adjustment = new GtkAdjustment ();
+	OS.memmove (adjustment, adjustmentHandle);
+	adjustment.step_increment = (float) value;
+	OS.memmove (adjustmentHandle, adjustment);
+	OS.g_signal_handlers_block_matched (adjustmentHandle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, VALUE_CHANGED);
+	OS.gtk_adjustment_changed (adjustmentHandle);
+	OS.g_signal_handlers_unblock_matched (adjustmentHandle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, VALUE_CHANGED);
+}
+
+/**
+ * Sets the maximum. If this value is negative or less than or
+ * equal to the minimum, the value is ignored. If necessary, first
+ * the thumb and then the selection are adjusted to fit within the
+ * new range.
+ *
+ * @param value the new maximum
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setMaximum (int value) {
+	checkWidget ();
+	GtkAdjustment adjustment = new GtkAdjustment ();
+	OS.memmove (adjustment, adjustmentHandle);
+	int minimum = (int) adjustment.lower;
+	if (value <= minimum) return;
+	adjustment.upper = value;
+	adjustment.page_size = Math.min ((int)adjustment.page_size, value - minimum);
+	adjustment.value = Math.min ((int)adjustment.value, (int)(value - adjustment.page_size));
+	OS.memmove (adjustmentHandle, adjustment);
+	OS.g_signal_handlers_block_matched (adjustmentHandle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, VALUE_CHANGED);
+	OS.gtk_adjustment_changed (adjustmentHandle);
+	OS.g_signal_handlers_unblock_matched (adjustmentHandle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, VALUE_CHANGED);
+}
+	
+/**
+ * Sets the minimum value. If this value is negative or greater
+ * than or equal to the maximum, the value is ignored. If necessary,
+ * first the thumb and then the selection are adjusted to fit within
+ * the new range.
+ *
+ * @param value the new minimum
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setMinimum (int value) {
+	checkWidget ();
+	if (value < 0) return;
+	GtkAdjustment adjustment = new GtkAdjustment ();
+	OS.memmove (adjustment, adjustmentHandle);
+	int maximum = (int) adjustment.upper;
+	if (value >= maximum) return;
+	adjustment.lower = value;
+	adjustment.page_size = Math.min ((int)adjustment.page_size, maximum - value);
+	adjustment.value = Math.max ((int)adjustment.value, value);
+	OS.memmove (adjustmentHandle, adjustment);
+	OS.g_signal_handlers_block_matched (adjustmentHandle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, VALUE_CHANGED);
+	OS.gtk_adjustment_changed (adjustmentHandle);
+	OS.g_signal_handlers_unblock_matched (adjustmentHandle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, VALUE_CHANGED);
+}
+
+void setOrientation () {
+	super.setOrientation ();
+	if ((parent.style & SWT.MIRRORED) != 0) {
+		if ((parent.state & CANVAS) != 0) {
+			if ((style & SWT.HORIZONTAL) != 0) {
+				OS.gtk_range_set_inverted (handle, true);
+			}
+		}
+	}
+}
+
+/**
+ * Sets the amount that the receiver's value will be
+ * modified by when the page increment/decrement areas
+ * are selected to the argument, which must be at least
+ * one.
+ *
+ * @param value the page increment (must be greater than zero)
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setPageIncrement (int value) {
+	checkWidget ();
+	if (value < 1) return;
+	GtkAdjustment adjustment = new GtkAdjustment ();
+	OS.memmove (adjustment, adjustmentHandle);
+	adjustment.page_increment = (float) value;
+	OS.memmove (adjustmentHandle, adjustment);
+	OS.g_signal_handlers_block_matched (adjustmentHandle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, VALUE_CHANGED);
+	OS.gtk_adjustment_changed (adjustmentHandle);
+	OS.g_signal_handlers_unblock_matched (adjustmentHandle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, VALUE_CHANGED);
+}
+
+/**
+ * Sets the single <em>selection</em> that is the receiver's
+ * value to the argument which must be greater than or equal
+ * to zero.
+ *
+ * @param selection the new selection (must be zero or greater)
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setSelection (int value) {
+	checkWidget ();
+	value = Math.min (value, getMaximum() - getThumb());
+	OS.g_signal_handlers_block_matched (adjustmentHandle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, VALUE_CHANGED);
+	OS.gtk_adjustment_set_value (adjustmentHandle, value);
+	OS.g_signal_handlers_unblock_matched (adjustmentHandle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, VALUE_CHANGED);
+}
+
+/**
+ * Sets the size of the receiver's thumb relative to the
+ * difference between its maximum and minimum values.  This new
+ * value will be ignored if it is less than one, and will be
+ * clamped if it exceeds the receiver's current range.
+ *
+ * @param value the new thumb value, which must be at least one and not
+ * larger than the size of the current range
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setThumb (int value) {
+	checkWidget ();
+	if (value < 1) return;
+	GtkAdjustment adjustment = new GtkAdjustment ();
+	OS.memmove (adjustment, adjustmentHandle);
+	value = (int) Math.min (value, (int)(adjustment.upper - adjustment.lower)); 
+	adjustment.page_size = (double) value;
+	adjustment.value = Math.min ((int)adjustment.value, (int)(adjustment.upper - value));
+	OS.memmove (adjustmentHandle, adjustment);
+	OS.g_signal_handlers_block_matched (adjustmentHandle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, VALUE_CHANGED);
+	OS.gtk_adjustment_changed (adjustmentHandle);
+	OS.g_signal_handlers_unblock_matched (adjustmentHandle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, VALUE_CHANGED);
+}
+
+/**
+ * Sets the receiver's selection, minimum value, maximum
+ * value, thumb, increment and page increment all at once.
+ * <p>
+ * Note: This is similar to setting the values individually
+ * using the appropriate methods, but may be implemented in a 
+ * more efficient fashion on some platforms.
+ * </p>
+ *
+ * @param selection the new selection value
+ * @param minimum the new minimum value
+ * @param maximum the new maximum value
+ * @param thumb the new thumb value
+ * @param increment the new increment value
+ * @param pageIncrement the new pageIncrement value
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setValues (int selection, int minimum, int maximum, int thumb, int increment, int pageIncrement) {
+	checkWidget ();
+	if (minimum < 0) return;
+	if (maximum < 0) return;
+	if (thumb < 1) return;
+	if (increment < 1) return;
+	if (pageIncrement < 1) return;
+	thumb = Math.min (thumb, maximum - minimum);
+	GtkAdjustment adjustment = new GtkAdjustment ();
+	OS.memmove (adjustment, adjustmentHandle);
+	adjustment.lower = minimum;
+	adjustment.upper = maximum;
+	adjustment.step_increment = increment;
+	adjustment.page_increment = pageIncrement;
+	adjustment.page_size = thumb;
+	adjustment.value = Math.min (Math.max (selection, minimum), maximum - thumb);
+	OS.memmove (adjustmentHandle, adjustment);
+	OS.g_signal_handlers_block_matched (adjustmentHandle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, VALUE_CHANGED);
+	OS.gtk_adjustment_changed (adjustmentHandle);
+	OS.gtk_adjustment_value_changed (adjustmentHandle);
+	OS.g_signal_handlers_unblock_matched (adjustmentHandle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, VALUE_CHANGED);
+}
+
+/**
+ * Marks the receiver as visible if the argument is <code>true</code>,
+ * and marks it invisible otherwise. 
+ * <p>
+ * If one of the receiver's ancestors is not visible or some
+ * other condition makes the receiver not visible, marking
+ * it visible may not actually cause it to be displayed.
+ * </p>
+ *
+ * @param visible the new visibility state
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setVisible (boolean visible) {
+	checkWidget ();
+	if (parent.setScrollBarVisible (this, visible)) {
+		sendEvent (visible ? SWT.Show : SWT.Hide);
+		parent.sendEvent (SWT.Resize);
+	}
+}
+
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Scrollable.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Scrollable.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Scrollable.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,383 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.widgets;
+
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.gtk.*;
+import org.eclipse.swt.graphics.*;
+
+/**
+ * This class is the abstract superclass of all classes which
+ * represent controls that have standard scroll bars.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>H_SCROLL, V_SCROLL</dd>
+ * <dt><b>Events:</b>
+ * <dd>(none)</dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is intended to be subclassed <em>only</em>
+ * within the SWT implementation.
+ * </p>
+ *
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public abstract class Scrollable extends Control {
+	int /*long*/ scrolledHandle;
+	ScrollBar horizontalBar, verticalBar;
+
+/**
+ * Prevents uninitialized instances from being created outside the package.
+ */
+Scrollable () {}
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT#H_SCROLL
+ * @see SWT#V_SCROLL
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public Scrollable (Composite parent, int style) {
+	super (parent, style);
+}
+
+int /*long*/ clientHandle () {
+	return handle;
+}
+
+/**
+ * Given a desired <em>client area</em> for the receiver
+ * (as described by the arguments), returns the bounding
+ * rectangle which would be required to produce that client
+ * area.
+ * <p>
+ * In other words, it returns a rectangle such that, if the
+ * receiver's bounds were set to that rectangle, the area
+ * of the receiver which is capable of displaying data
+ * (that is, not covered by the "trimmings") would be the
+ * rectangle described by the arguments (relative to the
+ * receiver's parent).
+ * </p>
+ * 
+ * @param x the desired x coordinate of the client area
+ * @param y the desired y coordinate of the client area
+ * @param width the desired width of the client area
+ * @param height the desired height of the client area
+ * @return the required bounds to produce the given client area
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #getClientArea
+ */
+public Rectangle computeTrim (int x, int y, int width, int height) {
+	checkWidget();
+	int border = 0;
+	if (fixedHandle != 0) border += OS.gtk_container_get_border_width (fixedHandle);
+	if (scrolledHandle != 0) border += OS.gtk_container_get_border_width (scrolledHandle);
+	int trimX = x - border, trimY = y - border;
+	int trimWidth = width + (border * 2), trimHeight = height + (border * 2);
+	trimHeight += hScrollBarWidth ();
+	trimWidth  += vScrollBarWidth ();
+	if (scrolledHandle != 0) {
+		if (OS.gtk_scrolled_window_get_shadow_type (scrolledHandle) != OS.GTK_SHADOW_NONE) {
+			int /*long*/ style = OS.gtk_widget_get_style (scrolledHandle);
+			int xthickness = OS.gtk_style_get_xthickness (style);
+			int ythickness = OS.gtk_style_get_ythickness (style);
+			trimX -= xthickness;
+			trimY -= ythickness;
+			trimWidth += xthickness * 2;
+			trimHeight += ythickness * 2;
+		}
+	}
+	return new Rectangle (trimX, trimY, trimWidth, trimHeight);
+}
+
+ScrollBar createScrollBar (int style) {
+	if (scrolledHandle == 0) return null;
+	ScrollBar bar = new ScrollBar ();
+	bar.parent = this;
+	bar.style = style;
+	bar.display = display;
+	bar.state |= HANDLE;
+	if ((style & SWT.H_SCROLL) != 0) {
+		bar.handle = OS.GTK_SCROLLED_WINDOW_HSCROLLBAR (scrolledHandle);
+		bar.adjustmentHandle = OS.gtk_scrolled_window_get_hadjustment (scrolledHandle);
+	} else {
+		bar.handle = OS.GTK_SCROLLED_WINDOW_VSCROLLBAR (scrolledHandle);
+		bar.adjustmentHandle = OS.gtk_scrolled_window_get_vadjustment (scrolledHandle);
+	}
+	bar.setOrientation();
+	bar.hookEvents ();
+	bar.register ();
+	return bar;
+}
+
+void createWidget (int index) {
+	super.createWidget (index);
+	if ((style & SWT.H_SCROLL) != 0) horizontalBar = createScrollBar (SWT.H_SCROLL);
+	if ((style & SWT.V_SCROLL) != 0) verticalBar = createScrollBar (SWT.V_SCROLL);
+}
+
+void deregister () {
+	super.deregister ();
+	if (scrolledHandle != 0) display.removeWidget (scrolledHandle);
+}
+
+void destroyScrollBar (ScrollBar bar) {
+	setScrollBarVisible (bar, false);
+	//This code is intentionally commented
+	//bar.destroyHandle ();
+}
+
+public int getBorderWidth () {
+	checkWidget();
+	int border = 0;
+	if (fixedHandle != 0) border += OS.gtk_container_get_border_width (fixedHandle);
+	if (scrolledHandle != 0) {
+		border += OS.gtk_container_get_border_width (scrolledHandle);
+		if (OS.gtk_scrolled_window_get_shadow_type (scrolledHandle) != OS.GTK_SHADOW_NONE) {
+			border += OS.gtk_style_get_xthickness (OS.gtk_widget_get_style (scrolledHandle));
+		}
+	}
+	return border;
+}
+
+/**
+ * Returns a rectangle which describes the area of the
+ * receiver which is capable of displaying data (that is,
+ * not covered by the "trimmings").
+ * 
+ * @return the client area
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #computeTrim
+ */
+public Rectangle getClientArea () {
+	checkWidget ();
+	forceResize ();
+	int /*long*/ clientHandle = clientHandle ();
+	int x = OS.GTK_WIDGET_X (clientHandle);
+	int y = OS.GTK_WIDGET_Y (clientHandle);
+	int width = (state & ZERO_WIDTH) != 0 ? 0 : OS.GTK_WIDGET_WIDTH (clientHandle);
+	int height = (state & ZERO_HEIGHT) != 0 ? 0 : OS.GTK_WIDGET_HEIGHT (clientHandle);
+	return new Rectangle (x, y, width, height);
+}
+/**
+ * Returns the receiver's horizontal scroll bar if it has
+ * one, and null if it does not.
+ *
+ * @return the horizontal scroll bar (or null)
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public ScrollBar getHorizontalBar () {
+	checkWidget ();
+	return horizontalBar;
+}
+/**
+ * Returns the receiver's vertical scroll bar if it has
+ * one, and null if it does not.
+ *
+ * @return the vertical scroll bar (or null)
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public ScrollBar getVerticalBar () {
+	checkWidget ();
+	return verticalBar;
+}
+
+int /*long*/ gtk_scroll_event (int /*long*/ widget, int /*long*/ eventPtr) {
+	int /*long*/ result = super.gtk_scroll_event (widget, eventPtr);
+	
+	/*
+	* Feature in GTK.  Scrolled windows do not scroll if the scrollbars
+	* are hidden.  This is not a bug, but is inconsistent with other platforms.
+	* The fix is to set the adjustment values directly.
+	*/
+	if ((state & CANVAS) != 0) {
+		ScrollBar scrollBar;
+		GdkEventScroll gdkEvent = new GdkEventScroll ();
+		OS.memmove (gdkEvent, eventPtr, GdkEventScroll.sizeof);
+		if (gdkEvent.direction == OS.GDK_SCROLL_UP || gdkEvent.direction == OS.GDK_SCROLL_DOWN) {
+			scrollBar = verticalBar;
+		} else {
+			scrollBar = horizontalBar;
+		}
+		if (scrollBar != null && !OS.GTK_WIDGET_VISIBLE (scrollBar.handle) && scrollBar.getEnabled()) {
+			GtkAdjustment adjustment = new GtkAdjustment ();
+			OS.memmove (adjustment, scrollBar.adjustmentHandle);
+			/* Calculate wheel delta to match GTK+ 2.4 and higher */
+			int wheel_delta = (int) Math.pow(adjustment.page_size, 2.0 / 3.0);
+			if (gdkEvent.direction == OS.GDK_SCROLL_UP || gdkEvent.direction == OS.GDK_SCROLL_LEFT)
+				wheel_delta = -wheel_delta;
+			int value = (int) Math.max(adjustment.lower,
+					Math.min(adjustment.upper - adjustment.page_size, adjustment.value + wheel_delta));
+			OS.gtk_adjustment_set_value (scrollBar.adjustmentHandle, value);
+			return 1;
+		}
+	}
+	return result;
+}
+
+int hScrollBarWidth() {
+	if (horizontalBar==null) return 0;
+	int /*long*/ hBarHandle = OS.GTK_SCROLLED_WINDOW_HSCROLLBAR(scrolledHandle);
+	if (hBarHandle==0) return 0;
+	GtkRequisition requisition = new GtkRequisition();
+	OS.gtk_widget_size_request(hBarHandle, requisition);
+	int spacing = OS.GTK_SCROLLED_WINDOW_SCROLLBAR_SPACING(scrolledHandle);
+	return requisition.height + spacing;
+}
+
+boolean sendLeaveNotify () {
+	return scrolledHandle != 0;
+}
+
+void setOrientation () {
+	super.setOrientation ();
+	if ((style & SWT.RIGHT_TO_LEFT) != 0) {
+		if (scrolledHandle != 0) {
+			OS.gtk_widget_set_direction (scrolledHandle, OS.GTK_TEXT_DIR_RTL);
+		}
+	}
+}
+
+boolean setScrollBarVisible (ScrollBar bar, boolean visible) {
+	if (scrolledHandle == 0) return false;
+	int [] hsp = new int [1], vsp = new int [1];
+	OS.gtk_scrolled_window_get_policy (scrolledHandle, hsp, vsp);
+	int policy = visible ? OS.GTK_POLICY_ALWAYS : OS.GTK_POLICY_NEVER;
+	if ((bar.style & SWT.HORIZONTAL) != 0) {
+		if (hsp [0] == policy) return false;
+		hsp [0] = policy;
+	} else {
+		if (vsp [0] == policy) return false;
+		vsp [0] = policy;
+	}
+	OS.gtk_scrolled_window_set_policy (scrolledHandle, hsp [0], vsp [0]);
+	return true;
+}
+
+void redrawBackgroundImage () {
+}
+
+void redrawWidget (int x, int y, int width, int height, boolean redrawAll, boolean all, boolean trim) {
+	super.redrawWidget (x, y, width, height, redrawAll, all, trim);
+	if ((OS.GTK_WIDGET_FLAGS (handle) & OS.GTK_REALIZED) == 0) return;
+	if (!trim) return;
+	int /*long*/ topHandle = topHandle (), paintHandle = paintHandle ();
+	if (topHandle == paintHandle) return;
+	int /*long*/ window = OS.GTK_WIDGET_WINDOW (topHandle);
+	GdkRectangle rect = new GdkRectangle ();
+	if (redrawAll) {
+		rect.width = OS.GTK_WIDGET_WIDTH (topHandle);
+		rect.height = OS.GTK_WIDGET_HEIGHT (topHandle);
+	} else {
+		int [] destX = new int [1], destY = new int [1];
+		OS.gtk_widget_translate_coordinates (paintHandle, topHandle, x, y, destX, destY);
+		rect.x = destX [0];
+		rect.y = destY [0];
+		rect.width = width;
+		rect.height = height;
+	}
+	OS.gdk_window_invalidate_rect (window, rect, all);
+}
+
+void register () {
+	super.register ();
+	if (scrolledHandle != 0) display.addWidget (scrolledHandle, this);
+}
+
+void releaseHandle () {
+	super.releaseHandle ();
+	scrolledHandle = 0;
+}
+
+void releaseChildren (boolean destroy) {
+	if (horizontalBar != null) {
+		horizontalBar.release (false);
+		horizontalBar = null;
+	}
+	if (verticalBar != null) {
+		verticalBar.release (false);
+		verticalBar = null;
+	}
+	super.releaseChildren (destroy);
+}
+
+void resizeHandle (int width, int height) {
+	if (fixedHandle != 0) OS.gtk_widget_set_size_request (fixedHandle, width, height);
+	OS.gtk_widget_set_size_request (scrolledHandle != 0 ? scrolledHandle : handle, width, height);
+}
+
+void showWidget () {
+	super.showWidget ();
+	if (scrolledHandle != 0) OS.gtk_widget_show (scrolledHandle);
+}
+
+int /*long*/ topHandle () {
+	if (fixedHandle != 0) return fixedHandle;
+	if (scrolledHandle != 0) return scrolledHandle;
+	return super.topHandle ();
+}
+
+void updateScrollBarValue (ScrollBar bar) {
+	redrawBackgroundImage ();
+}
+
+int vScrollBarWidth() {
+	if (verticalBar == null) return 0;
+	int /*long*/ vBarHandle = OS.GTK_SCROLLED_WINDOW_VSCROLLBAR(scrolledHandle);
+	if (vBarHandle == 0) return 0;
+	GtkRequisition requisition = new GtkRequisition();
+	OS.gtk_widget_size_request (vBarHandle, requisition);
+	int spacing = OS.GTK_SCROLLED_WINDOW_SCROLLBAR_SPACING(scrolledHandle);
+	return requisition.width + spacing;
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Shell.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Shell.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Shell.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,2080 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.widgets;
+
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.gtk.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.events.*;
+
+/**
+ * Instances of this class represent the "windows"
+ * which the desktop or "window manager" is managing.
+ * Instances that do not have a parent (that is, they
+ * are built using the constructor, which takes a 
+ * <code>Display</code> as the argument) are described
+ * as <em>top level</em> shells. Instances that do have
+ * a parent are described as <em>secondary</em> or
+ * <em>dialog</em> shells.
+ * <p>
+ * Instances are always displayed in one of the maximized, 
+ * minimized or normal states:
+ * <ul>
+ * <li>
+ * When an instance is marked as <em>maximized</em>, the
+ * window manager will typically resize it to fill the
+ * entire visible area of the display, and the instance
+ * is usually put in a state where it can not be resized 
+ * (even if it has style <code>RESIZE</code>) until it is
+ * no longer maximized.
+ * </li><li>
+ * When an instance is in the <em>normal</em> state (neither
+ * maximized or minimized), its appearance is controlled by
+ * the style constants which were specified when it was created
+ * and the restrictions of the window manager (see below).
+ * </li><li>
+ * When an instance has been marked as <em>minimized</em>,
+ * its contents (client area) will usually not be visible,
+ * and depending on the window manager, it may be
+ * "iconified" (that is, replaced on the desktop by a small
+ * simplified representation of itself), relocated to a
+ * distinguished area of the screen, or hidden. Combinations
+ * of these changes are also possible.
+ * </li>
+ * </ul>
+ * </p><p>
+ * The <em>modality</em> of an instance may be specified using
+ * style bits. The modality style bits are used to determine
+ * whether input is blocked for other shells on the display.
+ * The <code>PRIMARY_MODAL</code> style allows an instance to block
+ * input to its parent. The <code>APPLICATION_MODAL</code> style
+ * allows an instance to block input to every other shell in the
+ * display. The <code>SYSTEM_MODAL</code> style allows an instance
+ * to block input to all shells, including shells belonging to
+ * different applications.
+ * </p><p>
+ * Note: The styles supported by this class are treated
+ * as <em>HINT</em>s, since the window manager for the
+ * desktop on which the instance is visible has ultimate
+ * control over the appearance and behavior of decorations
+ * and modality. For example, some window managers only
+ * support resizable windows and will always assume the
+ * RESIZE style, even if it is not set. In addition, if a
+ * modality style is not supported, it is "upgraded" to a
+ * more restrictive modality style that is supported. For
+ * example, if <code>PRIMARY_MODAL</code> is not supported,
+ * it would be upgraded to <code>APPLICATION_MODAL</code>.
+ * A modality style may also be "downgraded" to a less
+ * restrictive style. For example, most operating systems
+ * no longer support <code>SYSTEM_MODAL</code> because
+ * it can freeze up the desktop, so this is typically
+ * downgraded to <code>APPLICATION_MODAL</code>.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>BORDER, CLOSE, MIN, MAX, NO_TRIM, RESIZE, TITLE, ON_TOP, TOOL</dd>
+ * <dd>APPLICATION_MODAL, MODELESS, PRIMARY_MODAL, SYSTEM_MODAL</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Activate, Close, Deactivate, Deiconify, Iconify</dd>
+ * </dl>
+ * Class <code>SWT</code> provides two "convenience constants"
+ * for the most commonly required style combinations:
+ * <dl>
+ * <dt><code>SHELL_TRIM</code></dt>
+ * <dd>
+ * the result of combining the constants which are required
+ * to produce a typical application top level shell: (that 
+ * is, <code>CLOSE | TITLE | MIN | MAX | RESIZE</code>)
+ * </dd>
+ * <dt><code>DIALOG_TRIM</code></dt>
+ * <dd>
+ * the result of combining the constants which are required
+ * to produce a typical application dialog shell: (that 
+ * is, <code>TITLE | CLOSE | BORDER</code>)
+ * </dd>
+ * </dl>
+ * </p>
+ * <p>
+ * Note: Only one of the styles APPLICATION_MODAL, MODELESS, 
+ * PRIMARY_MODAL and SYSTEM_MODAL may be specified.
+ * </p><p>
+ * IMPORTANT: This class is not intended to be subclassed.
+ * </p>
+ *
+ * @see Decorations
+ * @see SWT
+ * @see <a href="http://www.eclipse.org/swt/snippets/#shell">Shell snippets</a>
+ * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: ControlExample</a>
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public class Shell extends Decorations {
+	int /*long*/ shellHandle, tooltipsHandle, tooltipWindow, group, modalGroup;
+	boolean mapped, moved, resized, opened, fullScreen, showWithParent;
+	int oldX, oldY, oldWidth, oldHeight;
+	int minWidth, minHeight;
+	Control lastActive;
+
+	static final int MAXIMUM_TRIM = 128;
+
+/**
+ * Constructs a new instance of this class. This is equivalent
+ * to calling <code>Shell((Display) null)</code>.
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ */
+public Shell () {
+	this ((Display) null);
+}
+/**
+ * Constructs a new instance of this class given only the style
+ * value describing its behavior and appearance. This is equivalent
+ * to calling <code>Shell((Display) null, style)</code>.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param style the style of control to construct
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ * 
+ * @see SWT#BORDER
+ * @see SWT#CLOSE
+ * @see SWT#MIN
+ * @see SWT#MAX
+ * @see SWT#RESIZE
+ * @see SWT#TITLE
+ * @see SWT#NO_TRIM
+ * @see SWT#SHELL_TRIM
+ * @see SWT#DIALOG_TRIM
+ * @see SWT#MODELESS
+ * @see SWT#PRIMARY_MODAL
+ * @see SWT#APPLICATION_MODAL
+ * @see SWT#SYSTEM_MODAL
+ */
+public Shell (int style) {
+	this ((Display) null, style);
+}
+
+/**
+ * Constructs a new instance of this class given only the display
+ * to create it on. It is created with style <code>SWT.SHELL_TRIM</code>.
+ * <p>
+ * Note: Currently, null can be passed in for the display argument.
+ * This has the effect of creating the shell on the currently active
+ * display if there is one. If there is no current display, the 
+ * shell is created on a "default" display. <b>Passing in null as
+ * the display argument is not considered to be good coding style,
+ * and may not be supported in a future release of SWT.</b>
+ * </p>
+ *
+ * @param display the display to create the shell on
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ */
+public Shell (Display display) {
+	this (display, SWT.SHELL_TRIM);
+}
+/**
+ * Constructs a new instance of this class given the display
+ * to create it on and a style value describing its behavior
+ * and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p><p>
+ * Note: Currently, null can be passed in for the display argument.
+ * This has the effect of creating the shell on the currently active
+ * display if there is one. If there is no current display, the 
+ * shell is created on a "default" display. <b>Passing in null as
+ * the display argument is not considered to be good coding style,
+ * and may not be supported in a future release of SWT.</b>
+ * </p>
+ *
+ * @param display the display to create the shell on
+ * @param style the style of control to construct
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ * 
+ * @see SWT#BORDER
+ * @see SWT#CLOSE
+ * @see SWT#MIN
+ * @see SWT#MAX
+ * @see SWT#RESIZE
+ * @see SWT#TITLE
+ * @see SWT#NO_TRIM
+ * @see SWT#SHELL_TRIM
+ * @see SWT#DIALOG_TRIM
+ * @see SWT#MODELESS
+ * @see SWT#PRIMARY_MODAL
+ * @see SWT#APPLICATION_MODAL
+ * @see SWT#SYSTEM_MODAL
+ */
+public Shell (Display display, int style) {
+	this (display, null, style, 0, false);
+}
+
+Shell (Display display, Shell parent, int style, int /*long*/ handle, boolean embedded) {
+	super ();
+	checkSubclass ();
+	if (display == null) display = Display.getCurrent ();
+	if (display == null) display = Display.getDefault ();
+	if (!display.isValidThread ()) {
+		error (SWT.ERROR_THREAD_INVALID_ACCESS);
+	}
+	if (parent != null && parent.isDisposed ()) {
+		error (SWT.ERROR_INVALID_ARGUMENT);	
+	}
+	this.style = checkStyle (style);
+	this.parent = parent;
+	this.display = display;
+	if (handle != 0) {
+		if (embedded) {
+			this.handle = handle;
+		} else {
+			shellHandle = handle;
+			state |= FOREIGN_HANDLE;
+		}
+	}
+	createWidget (0);
+}
+
+/**
+ * Constructs a new instance of this class given only its
+ * parent. It is created with style <code>SWT.DIALOG_TRIM</code>.
+ * <p>
+ * Note: Currently, null can be passed in for the parent.
+ * This has the effect of creating the shell on the currently active
+ * display if there is one. If there is no current display, the 
+ * shell is created on a "default" display. <b>Passing in null as
+ * the parent is not considered to be good coding style,
+ * and may not be supported in a future release of SWT.</b>
+ * </p>
+ *
+ * @param parent a shell which will be the parent of the new instance
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the parent is disposed</li> 
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ */
+public Shell (Shell parent) {
+	this (parent, SWT.DIALOG_TRIM);
+}
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p><p>
+ * Note: Currently, null can be passed in for the parent.
+ * This has the effect of creating the shell on the currently active
+ * display if there is one. If there is no current display, the 
+ * shell is created on a "default" display. <b>Passing in null as
+ * the parent is not considered to be good coding style,
+ * and may not be supported in a future release of SWT.</b>
+ * </p>
+ *
+ * @param parent a shell which will be the parent of the new instance
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the parent is disposed</li> 
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ * 
+ * @see SWT#BORDER
+ * @see SWT#CLOSE
+ * @see SWT#MIN
+ * @see SWT#MAX
+ * @see SWT#RESIZE
+ * @see SWT#TITLE
+ * @see SWT#NO_TRIM
+ * @see SWT#SHELL_TRIM
+ * @see SWT#DIALOG_TRIM
+ * @see SWT#ON_TOP
+ * @see SWT#TOOL
+ * @see SWT#MODELESS
+ * @see SWT#PRIMARY_MODAL
+ * @see SWT#APPLICATION_MODAL
+ * @see SWT#SYSTEM_MODAL
+ */
+public Shell (Shell parent, int style) {
+	this (parent != null ? parent.display : null, parent, style, 0, false);
+}
+
+public static Shell gtk_new (Display display, int /*long*/ handle) {
+	return new Shell (display, null, SWT.NO_TRIM, handle, true);
+}
+
+/**	 
+ * Invokes platform specific functionality to allocate a new shell
+ * that is not embedded.
+ * <p>
+ * <b>IMPORTANT:</b> This method is <em>not</em> part of the public
+ * API for <code>Shell</code>. It is marked public only so that it
+ * can be shared within the packages provided by SWT. It is not
+ * available on all platforms, and should never be called from
+ * application code.
+ * </p>
+ *
+ * @param display the display for the shell
+ * @param handle the handle for the shell
+ * @return a new shell object containing the specified display and handle
+ * 
+ * @since 3.3
+ */
+public static Shell internal_new (Display display, int /*long*/ handle) {
+	return new Shell (display, null, SWT.NO_TRIM, handle, false);
+}
+
+static int checkStyle (int style) {
+	style = Decorations.checkStyle (style);
+	style &= ~SWT.TRANSPARENT;
+	if ((style & SWT.ON_TOP) != 0) style &= ~SWT.SHELL_TRIM;
+	int mask = SWT.SYSTEM_MODAL | SWT.APPLICATION_MODAL | SWT.PRIMARY_MODAL;
+	int bits = style & ~mask;
+	if ((style & SWT.SYSTEM_MODAL) != 0) return bits | SWT.SYSTEM_MODAL;
+	if ((style & SWT.APPLICATION_MODAL) != 0) return bits | SWT.APPLICATION_MODAL;
+	if ((style & SWT.PRIMARY_MODAL) != 0) return bits | SWT.PRIMARY_MODAL;
+	return bits;
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when operations are performed on the receiver,
+ * by sending the listener one of the messages defined in the
+ * <code>ShellListener</code> interface.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see ShellListener
+ * @see #removeShellListener
+ */
+public void addShellListener (ShellListener listener) {
+	checkWidget();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	TypedListener typedListener = new TypedListener (listener);
+	addListener (SWT.Close,typedListener);
+	addListener (SWT.Iconify,typedListener);
+	addListener (SWT.Deiconify,typedListener);
+	addListener (SWT.Activate, typedListener);
+	addListener (SWT.Deactivate, typedListener);
+}
+
+void adjustTrim () {
+	if (display.ignoreTrim) return;
+	int width = OS.GTK_WIDGET_WIDTH (shellHandle);
+	int height = OS.GTK_WIDGET_HEIGHT (shellHandle);
+	int /*long*/ window = OS.GTK_WIDGET_WINDOW (shellHandle);
+	GdkRectangle rect = new GdkRectangle ();
+	OS.gdk_window_get_frame_extents (window, rect);
+	int trimWidth = Math.max (0, rect.width - width);
+	int trimHeight = Math.max (0, rect.height - height);
+	/*
+	* Bug in GTK.  gdk_window_get_frame_extents() fails for various window
+	* managers, causing a large incorrect value to be returned as the trim.
+	* The fix is to ignore the returned trim values if they are too large.
+	*/
+	if (trimWidth > MAXIMUM_TRIM || trimHeight > MAXIMUM_TRIM) {
+		display.ignoreTrim = true;
+		return;
+	}
+	boolean hasTitle = false, hasResize = false, hasBorder = false;
+	if ((style & SWT.NO_TRIM) == 0) {
+		hasTitle = (style & (SWT.MIN | SWT.MAX | SWT.TITLE | SWT.MENU)) != 0;
+		hasResize = (style & SWT.RESIZE) != 0;
+		hasBorder = (style & SWT.BORDER) != 0;
+	}
+	if (hasTitle) {
+		if (hasResize)  {
+			display.titleResizeTrimWidth = trimWidth;
+			display.titleResizeTrimHeight = trimHeight;
+			return;
+		}
+		if (hasBorder) {
+			display.titleBorderTrimWidth = trimWidth;
+			display.titleBorderTrimHeight = trimHeight;
+			return;
+		}
+		display.titleTrimWidth = trimWidth;
+		display.titleTrimHeight = trimHeight;
+		return;
+	}
+	if (hasResize) {
+		display.resizeTrimWidth = trimWidth;
+		display.resizeTrimHeight = trimHeight;
+		return;
+	}
+	if (hasBorder) {
+		display.borderTrimWidth = trimWidth;
+		display.borderTrimHeight = trimHeight;
+		return;
+	}
+}
+
+void bringToTop (boolean force) {
+	if (!OS.GTK_WIDGET_VISIBLE (shellHandle)) return;
+	Display display = this.display;
+	Shell activeShell = display.activeShell;
+	if (activeShell == this) return;
+	if (!force) {
+		if (activeShell == null) return;
+		if (!display.activePending) {
+			int /*long*/ focusHandle = OS.gtk_window_get_focus (activeShell.shellHandle);
+			if (focusHandle != 0 && !OS.GTK_WIDGET_HAS_FOCUS (focusHandle)) return;
+		}
+	}
+	/*
+	* Bug in GTK.  When a shell that is not managed by the window
+	* manage is given focus, GTK gets stuck in "focus follows pointer"
+	* mode when the pointer is within the shell and its parent when
+	* the shell is hidden or disposed. The fix is to use XSetInputFocus()
+	* to assign focus when ever the active shell has not managed by
+	* the window manager.
+	* 
+	* NOTE: This bug is fixed in GTK+ 2.6.8 and above.
+	*/
+	boolean xFocus = false;
+	if (activeShell != null) {
+		if (OS.GTK_VERSION < OS.VERSION (2, 6, 8)) {
+			xFocus = activeShell.isUndecorated ();
+		}
+		display.activeShell = null;
+		display.activePending = true;
+	}
+	/*
+	* Feature in GTK.  When the shell is an override redirect
+	* window, gdk_window_focus() does not give focus to the
+	* window.  The fix is to use XSetInputFocus() to force
+	* the focus.
+	*/
+	int /*long*/ window = OS.GTK_WIDGET_WINDOW (shellHandle);
+	if ((xFocus || (style & SWT.ON_TOP) != 0) && OS.GDK_WINDOWING_X11 ()) {
+		int /*long*/ xDisplay = OS.gdk_x11_drawable_get_xdisplay (window);
+		int /*long*/ xWindow = OS.gdk_x11_drawable_get_xid (window);
+		OS.gdk_error_trap_push ();
+		/* Use CurrentTime instead of the last event time to ensure that the shell becomes active */
+		OS.XSetInputFocus (xDisplay, xWindow, OS.RevertToParent, OS.CurrentTime);
+		OS.gdk_error_trap_pop ();
+	} else {
+		/*
+		* Bug in metacity.  Calling gdk_window_focus() with a timestamp more
+		* recent than the last user interaction time can cause windows not
+		* to come forward in versions > 2.10.0.  The fix is to use the last
+		* user event time. 
+		*/
+		if (display.windowManager.toLowerCase ().equals ("metacity")) {
+			OS.gdk_window_focus (window, display.lastUserEventTime);
+		} else {
+			OS.gdk_window_focus (window, OS.GDK_CURRENT_TIME);
+		}
+	}
+	display.activeShell = this;
+	display.activePending = true;
+}
+
+void checkBorder () {
+	/* Do nothing */
+}
+
+void checkOpen () {
+	if (!opened) resized = false;
+}
+
+int /*long*/ childStyle () {
+	return 0;
+}
+
+/**
+ * Requests that the window manager close the receiver in
+ * the same way it would be closed when the user clicks on
+ * the "close box" or performs some other platform specific
+ * key or mouse combination that indicates the window
+ * should be removed.
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SWT#Close
+ * @see #dispose
+ */
+public void close () {
+	checkWidget ();
+	closeWidget ();
+}
+void closeWidget () {
+	Event event = new Event ();
+	sendEvent (SWT.Close, event);
+	if (event.doit && !isDisposed ()) dispose ();
+}
+
+public Rectangle computeTrim (int x, int y, int width, int height) {
+	checkWidget();
+	Rectangle trim = super.computeTrim (x, y, width, height);
+	int border = 0;
+	if ((style & (SWT.NO_TRIM | SWT.BORDER | SWT.SHELL_TRIM)) == 0) {
+		border = OS.gtk_container_get_border_width (shellHandle);
+	}
+	int trimWidth = trimWidth (), trimHeight = trimHeight ();
+	trim.x -= (trimWidth / 2) + border;
+	trim.y -= trimHeight - (trimWidth / 2) + border;
+	trim.width += trimWidth + border * 2;
+	trim.height += trimHeight + border * 2;
+	if (menuBar != null) {
+		forceResize ();
+		int menuBarHeight = OS.GTK_WIDGET_HEIGHT (menuBar.handle);
+		trim.y -= menuBarHeight;
+		trim.height += menuBarHeight;
+	}
+	return trim;
+}
+
+void createHandle (int index) {
+	state |= HANDLE | CANVAS;
+	if (shellHandle == 0) {
+		if (handle == 0) {
+			int type = OS.GTK_WINDOW_TOPLEVEL;
+			if ((style & SWT.ON_TOP) != 0) type = OS.GTK_WINDOW_POPUP;
+			shellHandle = OS.gtk_window_new (type);
+		} else {
+			shellHandle = OS.gtk_plug_new (handle);
+		}
+		if (shellHandle == 0) error (SWT.ERROR_NO_HANDLES);
+		if (parent != null) {
+			OS.gtk_window_set_transient_for (shellHandle, parent.topHandle ());
+			OS.gtk_window_set_destroy_with_parent (shellHandle, true);
+			if (!isUndecorated ()) {
+				OS.gtk_window_set_type_hint (shellHandle, OS.GDK_WINDOW_TYPE_HINT_DIALOG);
+			} else {
+				if (OS.GTK_VERSION >= OS.VERSION (2, 2, 0)) {
+					OS.gtk_window_set_skip_taskbar_hint (shellHandle, true);
+				}
+			}
+		}
+		/*
+		* Feature in GTK.  The window size must be set when the window
+		* is created or it will not be allowed to be resized smaller that the
+		* initial size by the user.  The fix is to set the size to zero.
+		*/
+		if ((style & SWT.RESIZE) != 0) {
+			OS.gtk_widget_set_size_request (shellHandle, 0, 0);
+			OS.gtk_window_set_resizable (shellHandle, true);
+		} else {
+			OS.gtk_window_set_resizable (shellHandle, false);
+		}
+		vboxHandle = OS.gtk_vbox_new (false, 0);
+		if (vboxHandle == 0) error (SWT.ERROR_NO_HANDLES);
+		createHandle (index, false, true);
+		OS.gtk_container_add (vboxHandle, scrolledHandle);
+		OS.gtk_box_set_child_packing (vboxHandle, scrolledHandle, true, true, 0, OS.GTK_PACK_END);
+		OS.gtk_window_set_title (shellHandle, new byte [1]);
+		if ((style & (SWT.NO_TRIM | SWT.BORDER | SWT.SHELL_TRIM)) == 0) {
+			OS.gtk_container_set_border_width (shellHandle, 1);
+			GdkColor color = new GdkColor ();
+			OS.gtk_style_get_black (OS.gtk_widget_get_style (shellHandle), color);
+			OS.gtk_widget_modify_bg (shellHandle,  OS.GTK_STATE_NORMAL, color);
+		}
+	} else {
+		vboxHandle = OS.gtk_bin_get_child (shellHandle);
+		if (vboxHandle == 0) error (SWT.ERROR_NO_HANDLES);
+		int /*long*/ children = OS.gtk_container_get_children (vboxHandle);
+		if (OS.g_list_length (children) > 0) {
+			scrolledHandle = OS.g_list_data (children);
+		}
+		OS.g_list_free (children);
+		if (scrolledHandle == 0) error (SWT.ERROR_NO_HANDLES);
+		handle = OS.gtk_bin_get_child (scrolledHandle);
+		if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+	}
+	group = OS.gtk_window_group_new ();
+	if (group == 0) error (SWT.ERROR_NO_HANDLES);
+	/*
+	* Feature in GTK.  Realizing the shell triggers a size allocate event,
+	* which may be confused for a resize event from the window manager if
+	* received too late.  The fix is to realize the window during creation
+	* to avoid confusion.
+	*/
+	OS.gtk_widget_realize (shellHandle);
+}
+
+int /*long*/ filterProc (int /*long*/ xEvent, int /*long*/ gdkEvent, int /*long*/ data2) {
+	int eventType = OS.X_EVENT_TYPE (xEvent);
+	if (eventType != OS.FocusOut && eventType != OS.FocusIn) return 0;
+	XFocusChangeEvent xFocusEvent = new XFocusChangeEvent();
+	OS.memmove (xFocusEvent, xEvent, XFocusChangeEvent.sizeof);
+	switch (eventType) {
+		case OS.FocusIn: 
+			if (xFocusEvent.mode == OS.NotifyNormal || xFocusEvent.mode == OS.NotifyWhileGrabbed) {
+				switch (xFocusEvent.detail) {
+					case OS.NotifyNonlinear:
+					case OS.NotifyNonlinearVirtual:
+					case OS.NotifyAncestor:
+						if (tooltipsHandle != 0) OS.gtk_tooltips_enable (tooltipsHandle);
+						display.activeShell = this;
+						display.activePending = false;
+						sendEvent (SWT.Activate);
+						break;
+				}
+			} 
+			break;
+		case OS.FocusOut:
+			if (xFocusEvent.mode == OS.NotifyNormal || xFocusEvent.mode == OS.NotifyWhileGrabbed) {
+				switch (xFocusEvent.detail) {
+					case OS.NotifyNonlinear:
+					case OS.NotifyNonlinearVirtual:
+					case OS.NotifyVirtual:
+						if (tooltipsHandle != 0) OS.gtk_tooltips_disable (tooltipsHandle);
+						Display display = this.display;
+						sendEvent (SWT.Deactivate);
+						setActiveControl (null);
+						if (display.activeShell == this) {
+							display.activeShell = null;
+							display.activePending = false;
+						}
+						break;
+				}
+			}
+			break;
+	}
+	return 0;
+}
+
+Control findBackgroundControl () {
+	return (state & BACKGROUND) != 0 || backgroundImage != null ? this : null;
+}
+
+Composite findDeferredControl () {
+	return layoutCount > 0 ? this : null;
+}
+
+boolean hasBorder () {
+	return false;
+}
+
+void hookEvents () {
+	super.hookEvents ();
+	OS.g_signal_connect_closure_by_id (shellHandle, display.signalIds [KEY_PRESS_EVENT], 0, display.closures [KEY_PRESS_EVENT], false);
+	OS.g_signal_connect_closure_by_id (shellHandle, display.signalIds [WINDOW_STATE_EVENT], 0, display.closures [WINDOW_STATE_EVENT], false);
+	OS.g_signal_connect_closure_by_id (shellHandle, display.signalIds [SIZE_ALLOCATE], 0, display.closures [SIZE_ALLOCATE], false);
+	OS.g_signal_connect_closure_by_id (shellHandle, display.signalIds [CONFIGURE_EVENT], 0, display.closures [CONFIGURE_EVENT], false);
+	OS.g_signal_connect_closure_by_id (shellHandle, display.signalIds [DELETE_EVENT], 0, display.closures [DELETE_EVENT], false);
+	OS.g_signal_connect_closure_by_id (shellHandle, display.signalIds [MAP_EVENT], 0, display.shellMapProcClosure, false);
+	OS.g_signal_connect_closure_by_id (shellHandle, display.signalIds [ENTER_NOTIFY_EVENT], 0, display.closures [ENTER_NOTIFY_EVENT], false);
+	OS.g_signal_connect_closure (shellHandle, OS.move_focus, display.closures [MOVE_FOCUS], false);
+	int /*long*/ window = OS.GTK_WIDGET_WINDOW (shellHandle);
+	OS.gdk_window_add_filter  (window, display.filterProc, shellHandle);
+}
+
+public boolean isEnabled () {
+	checkWidget ();
+	return getEnabled ();
+}
+
+boolean isUndecorated () {
+	return
+		(style & (SWT.SHELL_TRIM | SWT.BORDER)) == SWT.NONE ||
+		(style & (SWT.NO_TRIM | SWT.ON_TOP)) != 0;
+}
+
+public boolean isVisible () {
+	checkWidget();
+	return getVisible ();
+}
+
+void register () {
+	super.register ();
+	display.addWidget (shellHandle, this);
+}
+
+void releaseParent () {
+	/* Do nothing */
+}
+
+int /*long*/ topHandle () {
+	return shellHandle;
+}
+
+void fixActiveShell () {
+	if (display.activeShell == this) {
+		Shell shell = null;
+		if (parent != null && parent.isVisible ()) shell = parent.getShell ();
+		if (shell == null && isUndecorated ()) {
+			Shell [] shells = display.getShells ();
+			for (int i = 0; i < shells.length; i++) {
+				if (shells [i] != null && shells [i].isVisible ()) {
+					shell = shells [i];
+					break;
+				}
+			}
+		}
+		if (shell != null) shell.bringToTop (false);
+	}
+}
+
+void fixShell (Shell newShell, Control control) {
+	if (this == newShell) return;
+	if (control == lastActive) setActiveControl (null);
+	String toolTipText = control.toolTipText;
+	if (toolTipText != null) {
+		control.setToolTipText (this, null);
+		control.setToolTipText (newShell, toolTipText);
+	}
+}
+
+int /*long*/ fixedSizeAllocateProc(int /*long*/ widget, int /*long*/ allocationPtr) {
+	int clientWidth = 0;
+	if ((style & SWT.MIRRORED) != 0) clientWidth = getClientWidth ();
+	int /*long*/ result = super.fixedSizeAllocateProc (widget, allocationPtr);
+	if ((style & SWT.MIRRORED) != 0) moveChildren (clientWidth);
+	return result;
+}
+
+void fixStyle (int /*long*/ handle) {
+}
+
+void forceResize () {
+	forceResize (OS.GTK_WIDGET_WIDTH (vboxHandle), OS.GTK_WIDGET_HEIGHT (vboxHandle));
+}
+
+void forceResize (int width, int height) {
+	GtkRequisition requisition = new GtkRequisition ();
+	OS.gtk_widget_size_request (vboxHandle, requisition);
+	GtkAllocation allocation = new GtkAllocation ();
+	int border = OS.gtk_container_get_border_width (shellHandle);
+	allocation.x = border;
+	allocation.y = border;
+	allocation.width = width;
+	allocation.height = height;
+	OS.gtk_widget_size_allocate (vboxHandle, allocation);
+}
+
+/**
+ * Returns the receiver's alpha value. The alpha value
+ * is between 0 (transparent) and 255 (opaque).
+ *
+ * @return the alpha value
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.4
+ */
+public int getAlpha () {
+	checkWidget ();
+	if (OS.GTK_VERSION >= OS.VERSION (2, 12, 0)) {
+		if (OS.gtk_widget_is_composited (shellHandle)) {
+			return (int) (OS.gtk_window_get_opacity (shellHandle) * 255);
+		}
+	}
+	return 255;  
+}
+
+/**
+ * Returns <code>true</code> if the receiver is currently
+ * in fullscreen state, and false otherwise. 
+ * <p>
+ *
+ * @return the fullscreen state
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 3.4
+ */
+public boolean getFullScreen () {
+	checkWidget();
+	return fullScreen;
+}
+
+public Point getLocation () {
+	checkWidget ();
+	int [] x = new int [1], y = new int [1];
+	OS.gtk_window_get_position (shellHandle, x,y);
+	return new Point (x [0], y [0]);
+}
+
+public boolean getMaximized () {
+	checkWidget();
+	return !fullScreen && super.getMaximized ();
+}
+
+/**
+ * Returns a point describing the minimum receiver's size. The
+ * x coordinate of the result is the minimum width of the receiver.
+ * The y coordinate of the result is the minimum height of the
+ * receiver.
+ *
+ * @return the receiver's size
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.1
+ */
+public Point getMinimumSize () {
+	checkWidget ();
+	int width = Math.max (1, minWidth + trimWidth ());
+	int height = Math.max (1, minHeight + trimHeight ());
+	return new Point (width, height);
+}
+
+Shell getModalShell () {
+	Shell shell = null;
+	Shell [] modalShells = display.modalShells;
+	if (modalShells != null) {
+		int bits = SWT.APPLICATION_MODAL | SWT.SYSTEM_MODAL;
+		int index = modalShells.length;
+		while (--index >= 0) {
+			Shell modal = modalShells [index];
+			if (modal != null) {
+				if ((modal.style & bits) != 0) {
+					Control control = this;
+					while (control != null) {
+						if (control == modal) break;
+						control = control.parent;
+					}
+					if (control != modal) return modal;
+					break;
+				}
+				if ((modal.style & SWT.PRIMARY_MODAL) != 0) {
+					if (shell == null) shell = getShell ();
+					if (modal.parent == shell) return modal;
+				}
+			}
+		}
+	}
+	return null;
+}
+
+public Point getSize () {
+	checkWidget ();
+	int width = OS.GTK_WIDGET_WIDTH (vboxHandle);
+	int height = OS.GTK_WIDGET_HEIGHT (vboxHandle);
+	int border = 0;
+	if ((style & (SWT.NO_TRIM | SWT.BORDER | SWT.SHELL_TRIM)) == 0) {
+		border = OS.gtk_container_get_border_width (shellHandle);
+	}
+	return new Point (width + trimWidth () + 2*border, height + trimHeight () + 2*border);
+}
+
+public boolean getVisible () {
+	checkWidget();
+	return OS.GTK_WIDGET_VISIBLE (shellHandle); 
+}
+
+/** 
+ * Returns the region that defines the shape of the shell,
+ * or null if the shell has the default shape.
+ *
+ * @return the region that defines the shape of the shell (or null)
+ *	
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 3.0
+ *
+ */
+public Region getRegion () {
+	/* This method is needed for @since 3.0 Javadoc */
+	checkWidget ();
+	return region;
+}
+
+/**
+ * Returns the receiver's input method editor mode. This
+ * will be the result of bitwise OR'ing together one or
+ * more of the following constants defined in class
+ * <code>SWT</code>:
+ * <code>NONE</code>, <code>ROMAN</code>, <code>DBCS</code>, 
+ * <code>PHONETIC</code>, <code>NATIVE</code>, <code>ALPHA</code>.
+ *
+ * @return the IME mode
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SWT
+ */
+public int getImeInputMode () {
+	checkWidget();
+	return SWT.NONE;
+}
+
+Shell _getShell () {
+	return this;
+}
+/**
+ * Returns an array containing all shells which are 
+ * descendants of the receiver.
+ * <p>
+ * @return the dialog shells
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Shell [] getShells () {
+	checkWidget();
+	int count = 0;
+	Shell [] shells = display.getShells ();
+	for (int i=0; i<shells.length; i++) {
+		Control shell = shells [i];
+		do {
+			shell = shell.getParent ();
+		} while (shell != null && shell != this);
+		if (shell == this) count++;
+	}
+	int index = 0;
+	Shell [] result = new Shell [count];
+	for (int i=0; i<shells.length; i++) {
+		Control shell = shells [i];
+		do {
+			shell = shell.getParent ();
+		} while (shell != null && shell != this);
+		if (shell == this) {
+			result [index++] = shells [i];
+		}
+	}
+	return result;
+}
+
+int /*long*/ gtk_configure_event (int /*long*/ widget, int /*long*/ event) {
+	int [] x = new int [1], y = new int [1];
+	OS.gtk_window_get_position (shellHandle, x, y);
+	if (!moved || oldX != x [0] || oldY != y [0]) {
+		moved = true;
+		oldX = x [0];
+		oldY = y [0];
+		sendEvent (SWT.Move);
+		// widget could be disposed at this point
+	}
+	return 0;
+}
+
+int /*long*/ gtk_delete_event (int /*long*/ widget, int /*long*/ event) {
+	if (isEnabled()) closeWidget ();
+	return 1;
+}
+
+int /*long*/ gtk_enter_notify_event (int /*long*/ widget, int /*long*/ event) {
+	if (widget != shellHandle) {
+		return super.gtk_enter_notify_event (widget, event);
+	}
+	return 0;
+}
+
+int /*long*/ gtk_focus (int /*long*/ widget, int /*long*/ directionType) {
+	switch ((int)/*64*/directionType) {
+		case OS.GTK_DIR_TAB_FORWARD:
+		case OS.GTK_DIR_TAB_BACKWARD:
+			Control control = display.getFocusControl ();
+			if (control != null) {
+				if ((control.state & CANVAS) != 0 && (control.style & SWT.EMBEDDED) != 0) {
+					int traversal = directionType == OS.GTK_DIR_TAB_FORWARD ? SWT.TRAVERSE_TAB_NEXT : SWT.TRAVERSE_TAB_PREVIOUS;
+					control.traverse (traversal);
+					return 1;
+				}
+			}
+			break;
+	}
+	return super.gtk_focus (widget, directionType);
+}
+
+int /*long*/ gtk_move_focus (int /*long*/ widget, int /*long*/ directionType) {
+	Control control = display.getFocusControl ();
+	if (control != null) {
+		int /*long*/ focusHandle = control.focusHandle ();
+		OS.gtk_widget_child_focus (focusHandle, (int)/*64*/directionType);
+	}
+	OS.g_signal_stop_emission_by_name (shellHandle, OS.move_focus);
+	return 1;
+}
+
+int /*long*/ gtk_key_press_event (int /*long*/ widget, int /*long*/ event) {
+	/* Stop menu mnemonics when the shell is disabled */
+	if (widget == shellHandle) {
+		return (state & DISABLED) != 0 ? 1 : 0;
+	}
+	return super.gtk_key_press_event (widget, event);
+}
+
+int /*long*/ gtk_size_allocate (int /*long*/ widget, int /*long*/ allocation) {
+	int width = OS.GTK_WIDGET_WIDTH (shellHandle);
+	int height = OS.GTK_WIDGET_HEIGHT (shellHandle);
+	if (!resized || oldWidth != width || oldHeight != height) {
+		oldWidth = width;
+		oldHeight = height;
+		resizeBounds (width, height, true);
+	}
+	return 0;
+}
+
+int /*long*/ gtk_realize (int /*long*/ widget) {
+	int /*long*/ result = super.gtk_realize (widget);
+	int /*long*/ window = OS.GTK_WIDGET_WINDOW (shellHandle);
+	if ((style & SWT.SHELL_TRIM) != SWT.SHELL_TRIM) {
+		int decorations = 0;
+		if ((style & SWT.NO_TRIM) == 0) {
+			if ((style & SWT.MIN) != 0) decorations |= OS.GDK_DECOR_MINIMIZE;
+			if ((style & SWT.MAX) != 0) decorations |= OS.GDK_DECOR_MAXIMIZE;
+			if ((style & SWT.RESIZE) != 0) decorations |= OS.GDK_DECOR_RESIZEH;
+			if ((style & SWT.BORDER) != 0) decorations |= OS.GDK_DECOR_BORDER;
+			if ((style & SWT.MENU) != 0) decorations |= OS.GDK_DECOR_MENU;
+			if ((style & SWT.TITLE) != 0) decorations |= OS.GDK_DECOR_TITLE;
+			/*
+			* Feature in GTK.  Under some Window Managers (Sawmill), in order
+			* to get any border at all from the window manager it is necessary to
+			* set GDK_DECOR_BORDER.  The fix is to force these bits when any
+			* kind of border is requested.
+			*/
+			if ((style & SWT.RESIZE) != 0) decorations |= OS.GDK_DECOR_BORDER;
+		}
+		OS.gdk_window_set_decorations (window, decorations);
+	}
+	if ((style & SWT.ON_TOP) != 0) {
+		OS.gdk_window_set_override_redirect (window, true);
+	}
+	return result;
+}
+
+int /*long*/ gtk_window_state_event (int /*long*/ widget, int /*long*/ event) {
+	GdkEventWindowState gdkEvent = new GdkEventWindowState ();
+	OS.memmove (gdkEvent, event, GdkEventWindowState.sizeof);
+	minimized = (gdkEvent.new_window_state & OS.GDK_WINDOW_STATE_ICONIFIED) != 0;
+	maximized = (gdkEvent.new_window_state & OS.GDK_WINDOW_STATE_MAXIMIZED) != 0;
+	fullScreen = (gdkEvent.new_window_state & OS.GDK_WINDOW_STATE_FULLSCREEN) != 0;
+	if ((gdkEvent.changed_mask & OS.GDK_WINDOW_STATE_ICONIFIED) != 0) {
+		if (minimized) {
+			sendEvent (SWT.Iconify);
+		} else {
+			sendEvent (SWT.Deiconify);
+		}
+		updateMinimized (minimized);
+	}
+	return 0;
+}
+
+/**
+ * Moves the receiver to the top of the drawing order for
+ * the display on which it was created (so that all other
+ * shells on that display, which are not the receiver's
+ * children will be drawn behind it), marks it visible,
+ * sets the focus and asks the window manager to make the
+ * shell active.
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see Control#moveAbove
+ * @see Control#setFocus
+ * @see Control#setVisible
+ * @see Display#getActiveShell
+ * @see Decorations#setDefaultButton(Button)
+ * @see Shell#setActive
+ * @see Shell#forceActive
+ */
+public void open () {
+	checkWidget ();
+	bringToTop (false);
+	setVisible (true);
+	if (isDisposed ()) return;
+	if (!restoreFocus () && !traverseGroup (true)) setFocus ();
+}
+
+public boolean print (GC gc) {
+	checkWidget ();
+	if (gc == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if (gc.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT);
+	return false;
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when operations are performed on the receiver.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see ShellListener
+ * @see #addShellListener
+ */
+public void removeShellListener (ShellListener listener) {
+	checkWidget();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if (eventTable == null) return;
+	eventTable.unhook (SWT.Close, listener);
+	eventTable.unhook (SWT.Iconify,listener);
+	eventTable.unhook (SWT.Deiconify,listener);
+	eventTable.unhook (SWT.Activate, listener);
+	eventTable.unhook (SWT.Deactivate, listener);
+}
+
+/**
+ * If the receiver is visible, moves it to the top of the 
+ * drawing order for the display on which it was created 
+ * (so that all other shells on that display, which are not 
+ * the receiver's children will be drawn behind it) and asks 
+ * the window manager to make the shell active 
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.0
+ * @see Control#moveAbove
+ * @see Control#setFocus
+ * @see Control#setVisible
+ * @see Display#getActiveShell
+ * @see Decorations#setDefaultButton(Button)
+ * @see Shell#open
+ * @see Shell#setActive
+ */
+public void setActive () {
+	checkWidget ();
+	bringToTop (false);
+}
+
+void setActiveControl (Control control) {
+	if (control != null && control.isDisposed ()) control = null;
+	if (lastActive != null && lastActive.isDisposed ()) lastActive = null;
+	if (lastActive == control) return;
+	
+	/*
+	* Compute the list of controls to be activated and
+	* deactivated by finding the first common parent
+	* control.
+	*/
+	Control [] activate = (control == null) ? new Control[0] : control.getPath ();
+	Control [] deactivate = (lastActive == null) ? new Control[0] : lastActive.getPath ();
+	lastActive = control;
+	int index = 0, length = Math.min (activate.length, deactivate.length);
+	while (index < length) {
+		if (activate [index] != deactivate [index]) break;
+		index++;
+	}
+	
+	/*
+	* It is possible (but unlikely), that application
+	* code could have destroyed some of the widgets. If
+	* this happens, keep processing those widgets that
+	* are not disposed.
+	*/
+	for (int i=deactivate.length-1; i>=index; --i) {
+		if (!deactivate [i].isDisposed ()) {
+			deactivate [i].sendEvent (SWT.Deactivate);
+		}
+	}
+	for (int i=activate.length-1; i>=index; --i) {
+		if (!activate [i].isDisposed ()) {
+			activate [i].sendEvent (SWT.Activate);
+		}
+	}
+}
+
+/**
+ * Sets the receiver's alpha value which must be
+ * between 0 (transparent) and 255 (opaque).
+ * <p>
+ * This operation requires the operating system's advanced
+ * widgets subsystem which may not be available on some
+ * platforms.
+ * </p>
+ * @param alpha the alpha value
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.4
+ */
+public void setAlpha (int alpha) {
+	checkWidget ();
+	if (OS.GTK_VERSION >= OS.VERSION (2, 12, 0)) {
+		if (OS.gtk_widget_is_composited (shellHandle)) {
+			alpha &= 0xFF;
+			OS.gtk_window_set_opacity (shellHandle, alpha / 255f);
+		}
+	}
+}
+
+void resizeBounds (int width, int height, boolean notify) {
+	if (redrawWindow != 0) {
+		OS.gdk_window_resize (redrawWindow, width, height);
+	}
+	if (enableWindow != 0) {
+		OS.gdk_window_resize (enableWindow, width, height);
+	}
+	int border = OS.gtk_container_get_border_width (shellHandle);
+	int boxWidth = width - 2*border;
+	int boxHeight = height - 2*border;
+	OS.gtk_widget_set_size_request (vboxHandle, boxWidth, boxHeight);
+	forceResize (boxWidth, boxHeight);
+	if (notify) {
+		resized = true;
+		sendEvent (SWT.Resize);
+		if (isDisposed ()) return;
+		if (layout != null) {
+			markLayout (false, false);
+			updateLayout (false);
+		}
+	}
+}
+
+int setBounds (int x, int y, int width, int height, boolean move, boolean resize) {
+	if (fullScreen) setFullScreen (false);
+	/*
+	* Bug in GTK.  When either of the location or size of
+	* a shell is changed while the shell is maximized, the
+	* shell is moved to (0, 0).  The fix is to explicitly
+	* unmaximize the shell before setting the bounds to
+	* anything different from the current bounds.
+	*/
+	if (getMaximized ()) {
+		Rectangle rect = getBounds ();
+		boolean sameOrigin = !move || (rect.x == x && rect.y == y);
+		boolean sameExtent = !resize || (rect.width == width && rect.height == height);
+		if (sameOrigin && sameExtent) return 0;
+		setMaximized (false);
+	}
+	int result = 0;
+	if (move) {
+		int [] x_pos = new int [1], y_pos = new int [1];
+		OS.gtk_window_get_position (shellHandle, x_pos, y_pos);
+		OS.gtk_window_move (shellHandle, x, y);
+		if (x_pos [0] != x || y_pos [0] != y) {
+			moved = true;
+			oldX = x;
+			oldY = y;
+			sendEvent (SWT.Move);
+			if (isDisposed ()) return 0;
+			result |= MOVED;
+		}
+	}
+	if (resize) {
+		width = Math.max (1, Math.max (minWidth, width - trimWidth ()));
+		height = Math.max (1, Math.max (minHeight, height - trimHeight ()));
+		if ((style & SWT.RESIZE) != 0) OS.gtk_window_resize (shellHandle, width, height);
+		boolean changed = width != oldWidth || height != oldHeight;
+		if (changed) {
+			oldWidth = width;
+			oldHeight = height;
+			result |= RESIZED;
+		}
+		resizeBounds (width, height, changed);
+	}
+	return result;
+}
+
+void setCursor (int /*long*/ cursor) {
+	if (enableWindow != 0) {
+		OS.gdk_window_set_cursor (enableWindow, cursor);
+		if (!OS.GDK_WINDOWING_X11 ()) {
+			OS.gdk_flush ();
+		} else {
+			int /*long*/ xDisplay = OS.GDK_DISPLAY ();
+			OS.XFlush (xDisplay);
+		}
+	}
+	super.setCursor (cursor);
+}
+
+public void setEnabled (boolean enabled) {
+	checkWidget();
+	if (((state & DISABLED) == 0) == enabled) return;
+	Display display = this.display;
+	Control control = null;
+	boolean fixFocus = false;
+	if (!enabled) {
+		if (display.focusEvent != SWT.FocusOut) {
+			control = display.getFocusControl ();
+			fixFocus = isFocusAncestor (control);
+		}
+	}
+	if (enabled) {
+		state &= ~DISABLED;
+	} else {
+		state |= DISABLED;
+	}
+	enableWidget (enabled);
+	if (isDisposed ()) return;
+	if (enabled) {
+		if (enableWindow != 0) {
+			OS.gdk_window_set_user_data (enableWindow, 0);
+			OS.gdk_window_destroy (enableWindow);
+			enableWindow = 0;
+		}
+	} else {
+		int /*long*/ parentHandle = shellHandle;
+		OS.gtk_widget_realize (parentHandle);
+		int /*long*/ window = OS.GTK_WIDGET_WINDOW (parentHandle);
+		Rectangle rect = getBounds ();
+		GdkWindowAttr attributes = new GdkWindowAttr ();
+		attributes.width = rect.width;
+		attributes.height = rect.height;
+		attributes.event_mask = (0xFFFFFFFF & ~OS.ExposureMask);
+		attributes.wclass = OS.GDK_INPUT_ONLY;
+		attributes.window_type = OS.GDK_WINDOW_CHILD;
+		enableWindow = OS.gdk_window_new (window, attributes, 0);
+		if (enableWindow != 0) {
+			if (cursor != null) {
+				OS.gdk_window_set_cursor (enableWindow, cursor.handle);
+				if (!OS.GDK_WINDOWING_X11 ()) {
+					OS.gdk_flush ();
+				} else {
+					int /*long*/ xDisplay = OS.GDK_DISPLAY ();
+					OS.XFlush (xDisplay);
+				}
+			}
+			OS.gdk_window_set_user_data (enableWindow, parentHandle);
+			OS.gdk_window_show (enableWindow);
+		}
+	}
+	if (fixFocus) fixFocus (control);
+	if (enabled && display.activeShell == this) {
+		if (!restoreFocus ()) traverseGroup (false);
+	}
+}
+
+/**
+ * Sets the full screen state of the receiver.
+ * If the argument is <code>true</code> causes the receiver
+ * to switch to the full screen state, and if the argument is
+ * <code>false</code> and the receiver was previously switched
+ * into full screen state, causes the receiver to switch back
+ * to either the maximmized or normal states.
+ * <p>
+ * Note: The result of intermixing calls to <code>setFullScreen(true)</code>, 
+ * <code>setMaximized(true)</code> and <code>setMinimized(true)</code> will 
+ * vary by platform. Typically, the behavior will match the platform user's 
+ * expectations, but not always. This should be avoided if possible.
+ * </p>
+ * 
+ * @param fullScreen the new fullscreen state
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 3.4
+ */
+public void setFullScreen (boolean fullScreen) {
+	checkWidget();
+	if (fullScreen) {
+		OS.gtk_window_fullscreen (shellHandle);
+	} else {
+		OS.gtk_window_unfullscreen (shellHandle);
+		if (maximized) {
+			setMaximized (true);
+		}
+	}
+	this.fullScreen = fullScreen;
+}
+
+/**
+ * Sets the input method editor mode to the argument which 
+ * should be the result of bitwise OR'ing together one or more
+ * of the following constants defined in class <code>SWT</code>:
+ * <code>NONE</code>, <code>ROMAN</code>, <code>DBCS</code>, 
+ * <code>PHONETIC</code>, <code>NATIVE</code>, <code>ALPHA</code>.
+ *
+ * @param mode the new IME mode
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SWT
+ */
+public void setImeInputMode (int mode) {
+	checkWidget();
+}
+
+void setInitialBounds () {
+	if ((state & FOREIGN_HANDLE) != 0) return;
+	Monitor monitor = getMonitor ();
+	Rectangle rect = monitor.getClientArea ();
+	int width = rect.width * 5 / 8;
+	int height = rect.height * 5 / 8;
+	if ((style & SWT.RESIZE) != 0) {
+		OS.gtk_window_resize (shellHandle, width, height);
+	}
+	resizeBounds (width, height, false);
+}
+
+public void setMaximized (boolean maximized) {
+	checkWidget();
+	super.setMaximized (maximized);
+	if (maximized) {
+		OS.gtk_window_maximize (shellHandle);
+	} else {
+		OS.gtk_window_unmaximize (shellHandle);
+	}
+}
+
+public void setMenuBar (Menu menu) {
+	checkWidget();
+	if (menuBar == menu) return;
+	boolean both = menu != null && menuBar != null;
+	if (menu != null) {
+		if ((menu.style & SWT.BAR) == 0) error (SWT.ERROR_MENU_NOT_BAR);
+		if (menu.parent != this) error (SWT.ERROR_INVALID_PARENT);
+	}
+	if (menuBar != null) {
+		int /*long*/ menuHandle = menuBar.handle;
+		OS.gtk_widget_hide (menuHandle);
+		destroyAccelGroup ();
+	}
+	menuBar = menu;
+	if (menuBar != null) {
+		int /*long*/ menuHandle = menu.handle;
+		OS.gtk_widget_show (menuHandle);
+		createAccelGroup ();
+		menuBar.addAccelerators (accelGroup);
+	}
+	int width = OS.GTK_WIDGET_WIDTH (vboxHandle);
+	int height = OS.GTK_WIDGET_HEIGHT (vboxHandle);
+	resizeBounds (width, height, !both);
+}
+
+public void setMinimized (boolean minimized) {
+	checkWidget();
+	if (this.minimized == minimized) return;
+	super.setMinimized (minimized);
+	if (minimized) {
+		OS.gtk_window_iconify (shellHandle);
+	} else {
+		OS.gtk_window_deiconify (shellHandle);
+		bringToTop (false);
+	}
+}
+
+/**
+ * Sets the receiver's minimum size to the size specified by the arguments.
+ * If the new minimum size is larger than the current size of the receiver,
+ * the receiver is resized to the new minimum size.
+ *
+ * @param width the new minimum width for the receiver
+ * @param height the new minimum height for the receiver
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.1
+ */
+public void setMinimumSize (int width, int height) {
+	checkWidget ();
+	GdkGeometry geometry = new GdkGeometry ();
+	minWidth = geometry.min_width = Math.max (width, trimWidth ()) - trimWidth ();
+	minHeight = geometry.min_height = Math.max (height, trimHeight ()) - trimHeight ();
+	OS.gtk_window_set_geometry_hints (shellHandle, 0, geometry, OS.GDK_HINT_MIN_SIZE);
+}
+
+/**
+ * Sets the receiver's minimum size to the size specified by the argument.
+ * If the new minimum size is larger than the current size of the receiver,
+ * the receiver is resized to the new minimum size.
+ *
+ * @param size the new minimum size for the receiver
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the point is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.1
+ */
+public void setMinimumSize (Point size) {
+	checkWidget ();
+	if (size == null) error (SWT.ERROR_NULL_ARGUMENT);
+	setMinimumSize (size.x, size.y);
+}
+
+/**
+ * Sets the shape of the shell to the region specified
+ * by the argument.  When the argument is null, the
+ * default shape of the shell is restored.  The shell
+ * must be created with the style SWT.NO_TRIM in order
+ * to specify a region.
+ *
+ * @param region the region that defines the shape of the shell (or null)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the region has been disposed</li>
+ * </ul>  
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 3.0
+ *
+ */
+public void setRegion (Region region) {
+	checkWidget ();
+	if ((style & SWT.NO_TRIM) == 0) return;
+	super.setRegion (region);
+}
+
+/*
+ * Shells are never labelled by other widgets, so no initialization is needed.
+ */
+void setRelations() {
+}
+
+public void setText (String string) {
+	super.setText (string);
+
+	/* 
+	* GTK bug 82013.  For some reason, if the title string
+	* is less than 7 bytes long and is not terminated by
+	* a space, some window managers occasionally draw
+	* garbage after the last character in  the title.
+	* The fix is to pad the title.
+	*/
+	int length = string.length ();
+	char [] chars = new char [Math.max (6, length) + 1];
+	string.getChars (0, length , chars, 0);
+	for (int i=length; i<chars.length; i++)  chars [i] = ' ';
+	byte [] buffer = Converter.wcsToMbcs (null, chars, true);
+	OS.gtk_window_set_title (shellHandle, buffer);
+}
+
+public void setVisible (boolean visible) {
+	checkWidget();
+	int mask = SWT.PRIMARY_MODAL | SWT.APPLICATION_MODAL | SWT.SYSTEM_MODAL;
+	if ((style & mask) != 0) {
+		if (visible) {
+			display.setModalShell (this);
+			OS.gtk_window_set_modal (shellHandle, true);
+		} else {
+			display.clearModal (this);
+			OS.gtk_window_set_modal (shellHandle, false);
+		}
+	} else {
+		updateModal ();
+	}
+	showWithParent = visible;
+	if ((OS.GTK_WIDGET_MAPPED (shellHandle) == visible)) return;
+	if (visible) {
+		sendEvent (SWT.Show);
+		if (isDisposed ()) return;
+
+		/*
+		* In order to ensure that the shell is visible
+		* and fully painted, dispatch events such as
+		* GDK_MAP and GDK_CONFIGURE, until the GDK_MAP
+		* event for the shell is received.
+		* 
+		* Note that if the parent is minimized or withdrawn
+		* from the desktop, this should not be done since
+		* the shell not will be mapped until the parent is
+		* unminimized or shown on the desktop.
+		*/
+		OS.gtk_widget_show (shellHandle);
+		if (enableWindow != 0) OS.gdk_window_raise (enableWindow);
+		if (!OS.GTK_IS_PLUG (shellHandle)) {
+			mapped = false;
+			if (isDisposed ()) return;
+			display.dispatchEvents = new int [] {
+				OS.GDK_EXPOSE,
+				OS.GDK_FOCUS_CHANGE,
+				OS.GDK_CONFIGURE,
+				OS.GDK_MAP,
+				OS.GDK_UNMAP,
+				OS.GDK_NO_EXPOSE,
+			};
+			Display display = this.display;
+			display.putGdkEvents();
+			boolean iconic = false;
+			Shell shell = parent != null ? parent.getShell() : null;
+			do {
+				OS.g_main_context_iteration (0, false);
+				if (isDisposed ()) break;
+				iconic = minimized || (shell != null && shell.minimized);
+			} while (!mapped && !iconic);
+			display.dispatchEvents = null;
+			if (isDisposed ()) return;
+			if (!iconic) {
+				update (true, true);
+				if (isDisposed ()) return;
+				adjustTrim ();
+			}
+		}
+		mapped = true;
+
+		if ((style & mask) != 0) {
+			OS.gdk_pointer_ungrab (OS.GDK_CURRENT_TIME);
+		}
+		opened = true;
+		if (!moved) {
+			moved = true;
+			Point location = getLocation();
+			oldX = location.x;
+			oldY = location.y;
+			sendEvent (SWT.Move);
+			if (isDisposed ()) return;
+		}
+		if (!resized) {
+			resized = true;
+			Point size = getSize ();
+			oldWidth = size.x - trimWidth ();
+			oldHeight = size.y - trimHeight ();
+			sendEvent (SWT.Resize);
+			if (isDisposed ()) return;
+			if (layout != null) {
+				markLayout (false, false);
+				updateLayout (false);
+			}
+		}
+	} else {
+		fixActiveShell ();
+		OS.gtk_widget_hide (shellHandle);
+		sendEvent (SWT.Hide);
+	}
+}
+
+void setZOrder (Control sibling, boolean above, boolean fixRelations) {
+	/*
+	* Bug in GTK+.  Changing the toplevel window Z-order causes
+	* X to send a resize event.  Before the shell is mapped, these
+	* resize events always have a size of 200x200, causing extra
+	* layout work to occur.  The fix is to modify the Z-order only
+	* if the shell has already been mapped at least once.
+	*/
+	/* Shells are never included in labelled-by relations */
+	if (mapped) setZOrder (sibling, above, false, false);
+}
+
+int /*long*/ shellMapProc (int /*long*/ handle, int /*long*/ arg0, int /*long*/ user_data) {
+	mapped = true;
+	display.dispatchEvents = null;
+	return 0;
+}
+
+void showWidget () {
+	if ((state & FOREIGN_HANDLE) != 0) return;
+	OS.gtk_container_add (shellHandle, vboxHandle);
+	if (scrolledHandle != 0) OS.gtk_widget_show (scrolledHandle);
+	if (handle != 0) OS.gtk_widget_show (handle);
+	if (vboxHandle != 0) OS.gtk_widget_show (vboxHandle);
+}
+
+int /*long*/ sizeAllocateProc (int /*long*/ handle, int /*long*/ arg0, int /*long*/ user_data) {
+	int offset = 16;
+	int [] x = new int [1], y = new int [1];
+	OS.gdk_window_get_pointer (0, x, y, null);
+	y [0] += offset;
+	int /*long*/ screen = OS.gdk_screen_get_default ();
+	if (screen != 0) {
+		int monitorNumber = OS.gdk_screen_get_monitor_at_point (screen, x[0], y[0]);
+		GdkRectangle dest = new GdkRectangle ();
+		OS.gdk_screen_get_monitor_geometry (screen, monitorNumber, dest);
+		int width = OS.GTK_WIDGET_WIDTH (handle);
+		int height = OS.GTK_WIDGET_HEIGHT (handle);
+		if (x[0] + width > dest.x + dest.width) {
+			x [0] = (dest.x + dest.width) - width;
+		}
+		if (y[0] + height > dest.y + dest.height) {
+			y[0] = (dest.y + dest.height) - height;
+		}
+	} 
+	OS.gtk_window_move (handle, x [0], y [0]);
+	return 0;
+}
+
+int /*long*/ sizeRequestProc (int /*long*/ handle, int /*long*/ arg0, int /*long*/ user_data) {
+	OS.gtk_widget_hide (handle);
+	return 0;
+}
+
+boolean traverseEscape () {
+	if (parent == null) return false;
+	if (!isVisible () || !isEnabled ()) return false;
+	close ();
+	return true;
+}
+int trimHeight () {
+	if ((style & SWT.NO_TRIM) != 0) return 0;
+	if (fullScreen) return 0;
+	boolean hasTitle = false, hasResize = false, hasBorder = false;
+	hasTitle = (style & (SWT.MIN | SWT.MAX | SWT.TITLE | SWT.MENU)) != 0;
+	hasResize = (style & SWT.RESIZE) != 0;
+	hasBorder = (style & SWT.BORDER) != 0;
+	if (hasTitle) {
+		if (hasResize) return display.titleResizeTrimHeight;
+		if (hasBorder) return display.titleBorderTrimHeight;
+		return display.titleTrimHeight;
+	}
+	if (hasResize) return display.resizeTrimHeight;
+	if (hasBorder) return display.borderTrimHeight;
+	return 0;
+}
+
+int trimWidth () {
+	if ((style & SWT.NO_TRIM) != 0) return 0;
+	if (fullScreen) return 0;
+	boolean hasTitle = false, hasResize = false, hasBorder = false;
+	hasTitle = (style & (SWT.MIN | SWT.MAX | SWT.TITLE | SWT.MENU)) != 0;
+	hasResize = (style & SWT.RESIZE) != 0;
+	hasBorder = (style & SWT.BORDER) != 0;
+	if (hasTitle) {
+		if (hasResize) return display.titleResizeTrimWidth;
+		if (hasBorder) return display.titleBorderTrimWidth;
+		return display.titleTrimWidth;
+	}
+	if (hasResize) return display.resizeTrimWidth;
+	if (hasBorder) return display.borderTrimWidth;
+	return 0;
+}
+
+void updateModal () {
+	int /*long*/ group = 0;
+	if (display.getModalDialog () == null) {
+		Shell modal = getModalShell ();
+		int mask = SWT.PRIMARY_MODAL | SWT.APPLICATION_MODAL | SWT.SYSTEM_MODAL;
+		Composite shell = null;
+		if (modal == null) {
+			if ((style & mask) != 0) shell = this;
+		} else {
+			shell = modal;
+		}
+		while (shell != null) {
+			if ((shell.style & mask) == 0) {
+				group = shell.getShell ().group;
+				break;
+			}
+			shell = shell.parent;
+		}
+	}
+	if (OS.GTK_VERSION >= OS.VERSION (2, 10, 0) && group == 0) { 
+		/*
+		* Feature in GTK. Starting with GTK version 2.10, GTK
+		* doesn't assign windows to a default group. The fix is to
+		* get the handle of the default group and add windows to the
+		* group.
+		*/
+		group = OS.gtk_window_get_group(0);
+	}
+	if (group != 0) {
+		OS.gtk_window_group_add_window (group, shellHandle);
+	} else {
+		if (modalGroup != 0) {
+			OS.gtk_window_group_remove_window (modalGroup, shellHandle);
+		}
+	}
+	if (OS.GTK_VERSION < OS.VERSION (2, 4, 0)) {
+		fixModal (group, modalGroup);
+	}
+	modalGroup = group;
+}
+
+void updateMinimized (boolean minimized) {
+	Shell[] shells = getShells ();
+	for (int i = 0; i < shells.length; i++) {
+		boolean update = false;
+		Shell shell = shells[i];
+		while (shell != null && shell != this && !shell.isUndecorated ()) {
+			shell = (Shell) shell.getParent ();
+		}
+		if (shell != null && shell != this) update = true;
+		if (update) {
+			if (minimized) {
+				if (shells[i].isVisible ()) {
+					shells[i].showWithParent = true;
+					OS.gtk_widget_hide(shells[i].shellHandle);
+				}
+			} else {
+				if (shells[i].showWithParent) {
+					shells[i].showWithParent = false;
+					OS.gtk_widget_show(shells[i].shellHandle);
+				}
+			}
+		}
+	}
+}
+
+void deregister () {
+	super.deregister ();
+	display.removeWidget (shellHandle);
+}
+
+public void dispose () {
+	/*
+	* Note:  It is valid to attempt to dispose a widget
+	* more than once.  If this happens, fail silently.
+	*/
+	if (isDisposed()) return;
+	fixActiveShell ();
+	OS.gtk_widget_hide (shellHandle);
+	super.dispose ();
+}
+
+/**
+ * If the receiver is visible, moves it to the top of the 
+ * drawing order for the display on which it was created 
+ * (so that all other shells on that display, which are not 
+ * the receiver's children will be drawn behind it) and forces 
+ * the window manager to make the shell active.
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 2.0
+ * @see Control#moveAbove
+ * @see Control#setFocus
+ * @see Control#setVisible
+ * @see Display#getActiveShell
+ * @see Decorations#setDefaultButton(Button)
+ * @see Shell#open
+ * @see Shell#setActive
+ */
+public void forceActive () {
+	checkWidget ();
+	bringToTop (true);
+}
+
+public Rectangle getBounds () {
+	checkWidget ();
+	int [] x = new int [1], y = new int [1];
+	OS.gtk_window_get_position (shellHandle, x, y);
+	int width = OS.GTK_WIDGET_WIDTH (vboxHandle);
+	int height = OS.GTK_WIDGET_HEIGHT (vboxHandle);
+	int border = 0;
+	if ((style & (SWT.NO_TRIM | SWT.BORDER | SWT.SHELL_TRIM)) == 0) {
+		border = OS.gtk_container_get_border_width (shellHandle);
+	}
+	return new Rectangle (x [0], y [0], width + trimWidth () + 2*border, height + trimHeight () + 2*border);
+}
+
+void releaseHandle () {
+	super.releaseHandle ();
+	shellHandle = 0;
+}
+
+void releaseChildren (boolean destroy) {
+	Shell [] shells = getShells ();
+	for (int i=0; i<shells.length; i++) {
+		Shell shell = shells [i];
+		if (shell != null && !shell.isDisposed ()) {
+			shell.release (false);
+		}
+	}
+	super.releaseChildren (destroy);
+}
+
+void releaseWidget () {
+	super.releaseWidget ();
+	destroyAccelGroup ();
+	display.clearModal (this);
+	if (display.activeShell == this) display.activeShell = null;
+	if (tooltipsHandle != 0) OS.g_object_unref (tooltipsHandle);
+	tooltipsHandle = 0;
+	if (group != 0) OS.g_object_unref (group);
+	group = modalGroup = 0;
+	int /*long*/ window = OS.GTK_WIDGET_WINDOW (shellHandle);
+	OS.gdk_window_remove_filter(window, display.filterProc, shellHandle);
+	lastActive = null;
+}
+
+void setToolTipText (int /*long*/ tipWidget, String string) {
+	setToolTipText (tipWidget, tipWidget, string);
+}
+
+void setToolTipText (int /*long*/ rootWidget, int /*long*/ tipWidget, String string) {
+	if (OS.GTK_VERSION >= OS.VERSION (2, 12, 0)) {
+		byte [] buffer = null;
+		if (string != null && string.length () > 0) {
+			char [] chars = fixMnemonic (string, false);
+			buffer = Converter.wcsToMbcs (null, chars, true);
+		}
+		OS.gtk_widget_set_tooltip_text (rootWidget, null);
+		/*
+		* Bug in GTK. In GTK 2.12, due to a miscalculation of window
+		* coordinates, using gtk_tooltip_trigger_tooltip_query ()
+		* to update an existing a tooltip will result in the tooltip 
+		* being displayed at a wrong position. The fix is to send out 
+		* 2 fake GDK_MOTION_NOTIFY events (to mimic the GTK call) which 
+		* contain the proper x and y coordinates.
+		*/
+		int /*long*/ eventPtr = 0;
+		int /*long*/ tipWindow = OS.GTK_WIDGET_WINDOW (rootWidget);
+		if (tipWindow != 0) {
+			int [] x = new int [1], y = new int [1];
+			int /*long*/ window = OS.gdk_window_at_pointer (x, y);
+			int /*long*/ [] user_data = new int /*long*/ [1];
+			if (window != 0) OS.gdk_window_get_user_data (window, user_data);
+			if (tipWidget == user_data [0]) {
+				eventPtr = OS.gdk_event_new (OS.GDK_MOTION_NOTIFY);
+				GdkEventMotion event = new GdkEventMotion ();
+				event.type = OS.GDK_MOTION_NOTIFY;
+				event.window = OS.g_object_ref (tipWindow);
+				event.x = x [0];
+				event.y = y [0];
+				OS.gdk_window_get_origin (window, x, y);
+				event.x_root = event.x + x [0];
+				event.y_root = event.y + y [0];
+				OS.memmove (eventPtr, event, GdkEventMotion.sizeof);
+				OS.gtk_main_do_event (eventPtr);
+			}
+		}
+		OS.gtk_widget_set_tooltip_text (rootWidget, buffer);
+		if (eventPtr != 0) {
+			OS.gtk_main_do_event (eventPtr);
+			OS.gdk_event_free (eventPtr);
+		}
+	} else {
+		byte [] buffer = null;
+		if (string != null && string.length () > 0) {
+			char [] chars = fixMnemonic (string, false);
+			buffer = Converter.wcsToMbcs (null, chars, true);
+		}
+		if (tooltipsHandle == 0) {
+			tooltipsHandle = OS.gtk_tooltips_new ();
+			if (tooltipsHandle == 0) error (SWT.ERROR_NO_HANDLES);
+			OS.g_object_ref (tooltipsHandle);
+			OS.gtk_object_sink (tooltipsHandle);
+		}
+	
+		/*
+		* Feature in GTK.  There is no API to position a tooltip.
+		* The fix is to connect to the size_allocate signal for
+		* the tooltip window and position it before it is mapped.
+		*
+		* Bug in Solaris-GTK.  Invoking gtk_tooltips_force_window()
+		* can cause a crash in older versions of GTK.  The fix is
+		* to avoid this call if the GTK version is older than 2.2.x.
+		*/
+		if (OS.GTK_VERSION >= OS.VERSION (2, 2, 1)) {
+			OS.gtk_tooltips_force_window (tooltipsHandle);
+		}
+		int /*long*/ tipWindow = OS.GTK_TOOLTIPS_TIP_WINDOW (tooltipsHandle);
+		if (tipWindow != 0 && tipWindow != tooltipWindow) {
+			OS.g_signal_connect (tipWindow, OS.size_allocate, display.sizeAllocateProc, shellHandle);
+			tooltipWindow = tipWindow;
+		}
+		
+		/*
+		* Bug in GTK.  If the cursor is inside the window when a new
+		* tooltip is set and the old tooltip is hidden, the new tooltip
+		* is not displayed until the mouse re-enters the window.  The
+		* fix is force the new tooltip to be active.
+		*/
+		boolean set = true;
+		if (tipWindow != 0) {
+			if ((OS.GTK_WIDGET_FLAGS (tipWidget) & (OS.GTK_REALIZED | OS.GTK_VISIBLE)) != 0) {
+				int [] x = new int [1], y = new int [1];
+				int /*long*/ window = OS.gdk_window_at_pointer (x, y);
+				if (window != 0) {
+					int /*long*/ [] user_data = new int /*long*/ [1];
+					OS.gdk_window_get_user_data (window, user_data);
+					if (tipWidget == user_data [0]) {
+						/* 
+						* Feature in GTK.  Calling gtk_tooltips_set_tip() positions and
+						* shows the tooltip.  If the tooltip is already visible, moving
+						* it to a new location in the size_allocate signal causes flashing.
+						* The fix is to hide the tip window in the size_request signal
+						* and before the new tooltip is forced to be active. 
+						*/
+						set = false;
+						int handler_id = OS.g_signal_connect (tipWindow, OS.size_request, display.sizeRequestProc, shellHandle);
+						OS.gtk_tooltips_set_tip (tooltipsHandle, tipWidget, buffer, null);
+						OS.gtk_widget_hide (tipWindow);
+						int /*long*/ data = OS.gtk_tooltips_data_get (tipWidget);
+						OS.GTK_TOOLTIPS_SET_ACTIVE (tooltipsHandle, data);
+						OS.gtk_tooltips_set_tip (tooltipsHandle, tipWidget, buffer, null);
+						if (handler_id != 0) OS.g_signal_handler_disconnect (tipWindow, handler_id);
+					}
+				}
+			}
+		}
+		if (set) OS.gtk_tooltips_set_tip (tooltipsHandle, tipWidget, buffer, null);
+	}
+		
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Slider.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Slider.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Slider.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,613 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.widgets;
+
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.gtk.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.events.*;
+
+/**
+ * Instances of this class are selectable user interface
+ * objects that represent a range of positive, numeric values. 
+ * <p>
+ * At any given moment, a given slider will have a 
+ * single 'selection' that is considered to be its
+ * value, which is constrained to be within the range of
+ * values the slider represents (that is, between its
+ * <em>minimum</em> and <em>maximum</em> values).
+ * </p><p>
+ * Typically, sliders will be made up of five areas:
+ * <ol>
+ * <li>an arrow button for decrementing the value</li>
+ * <li>a page decrement area for decrementing the value by a larger amount</li>
+ * <li>a <em>thumb</em> for modifying the value by mouse dragging</li>
+ * <li>a page increment area for incrementing the value by a larger amount</li>
+ * <li>an arrow button for incrementing the value</li>
+ * </ol>
+ * Based on their style, sliders are either <code>HORIZONTAL</code>
+ * (which have a left facing button for decrementing the value and a
+ * right facing button for incrementing it) or <code>VERTICAL</code>
+ * (which have an upward facing button for decrementing the value
+ * and a downward facing buttons for incrementing it).
+ * </p><p>
+ * On some platforms, the size of the slider's thumb can be
+ * varied relative to the magnitude of the range of values it
+ * represents (that is, relative to the difference between its
+ * maximum and minimum values). Typically, this is used to
+ * indicate some proportional value such as the ratio of the
+ * visible area of a document to the total amount of space that
+ * it would take to display it. SWT supports setting the thumb
+ * size even if the underlying platform does not, but in this
+ * case the appearance of the slider will not change.
+ * </p>
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>HORIZONTAL, VERTICAL</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Selection</dd>
+ * </dl>
+ * <p>
+ * Note: Only one of the styles HORIZONTAL and VERTICAL may be specified.
+ * </p><p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ *
+ * @see ScrollBar
+ * @see <a href="http://www.eclipse.org/swt/snippets/#slider">Slider snippets</a>
+ * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: ControlExample</a>
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public class Slider extends Control {
+	int detail;
+	boolean dragSent;
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT#HORIZONTAL
+ * @see SWT#VERTICAL
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public Slider (Composite parent, int style) {
+	super (parent, checkStyle (style));
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the user changes the receiver's value, by sending
+ * it one of the messages defined in the <code>SelectionListener</code>
+ * interface.
+ * <p>
+ * When <code>widgetSelected</code> is called, the event object detail field contains one of the following values:
+ * <code>SWT.NONE</code> - for the end of a drag.
+ * <code>SWT.DRAG</code>.
+ * <code>SWT.HOME</code>.
+ * <code>SWT.END</code>.
+ * <code>SWT.ARROW_DOWN</code>.
+ * <code>SWT.ARROW_UP</code>.
+ * <code>SWT.PAGE_DOWN</code>.
+ * <code>SWT.PAGE_UP</code>.
+ * <code>widgetDefaultSelected</code> is not called.
+ * </p>
+ *
+ * @param listener the listener which should be notified when the user changes the receiver's value
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent
+ */
+public void addSelectionListener (SelectionListener listener) {
+	checkWidget ();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	TypedListener typedListener = new TypedListener (listener);
+	addListener (SWT.Selection,typedListener);
+	addListener (SWT.DefaultSelection,typedListener);
+}
+
+static int checkStyle (int style) {
+	return checkBits (style, SWT.HORIZONTAL, SWT.VERTICAL, 0, 0, 0, 0);
+}
+
+void createHandle (int index) {
+	state |= HANDLE;
+	fixedHandle = OS.g_object_new (display.gtk_fixed_get_type (), 0);
+	if (fixedHandle == 0) error (SWT.ERROR_NO_HANDLES);
+	OS.gtk_fixed_set_has_window (fixedHandle, true);
+	int /*long*/ hAdjustment = OS.gtk_adjustment_new (0, 0, 100, 1, 10, 10);
+	if (hAdjustment == 0) error (SWT.ERROR_NO_HANDLES);
+	if ((style & SWT.HORIZONTAL) != 0) {
+		handle = OS.gtk_hscrollbar_new (hAdjustment);
+	} else {
+		handle = OS.gtk_vscrollbar_new (hAdjustment);
+	}
+	if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+	/*
+	* Bug in GTK. In GTK 2.10, the buttons on either end of
+	* a horizontal slider are created taller then the slider bar
+	* when the GTK_CAN_FOCUS flag is set. The fix is not to set
+	* the flag for horizontal bars in all versions of 2.10. Note
+	* that a bug has been logged with GTK about this issue.
+	* (http://bugzilla.gnome.org/show_bug.cgi?id=475909) 
+	*/
+	if (OS.GTK_VERSION < OS.VERSION (2, 10, 0) || (style & SWT.VERTICAL) != 0) {
+		OS.GTK_WIDGET_SET_FLAGS (handle, OS.GTK_CAN_FOCUS);
+	}
+	OS.gtk_container_add (fixedHandle, handle);
+}
+
+int /*long*/ gtk_button_press_event (int /*long*/ widget, int /*long*/ eventPtr) {
+	int /*long*/ result = super.gtk_button_press_event (widget, eventPtr);
+	if (result != 0) return result;
+	detail = OS.GTK_SCROLL_NONE;
+	dragSent = false;
+	return result;
+}
+
+int /*long*/ gtk_change_value (int /*long*/ widget, int /*long*/ scroll, int /*long*/ value1, int /*long*/ value2) {
+	detail = (int)/*64*/scroll;
+	return 0;
+}
+
+int /*long*/ gtk_value_changed (int /*long*/ adjustment) {
+	Event event = new Event ();
+	dragSent = detail == OS.GTK_SCROLL_JUMP;
+	switch (detail) {
+		case OS.GTK_SCROLL_NONE:			event.detail = SWT.NONE; break;
+		case OS.GTK_SCROLL_JUMP:			event.detail = SWT.DRAG; break;
+		case OS.GTK_SCROLL_START:			event.detail = SWT.HOME; break;
+		case OS.GTK_SCROLL_END:				event.detail = SWT.END; break;
+		case OS.GTK_SCROLL_PAGE_DOWN:
+		case OS.GTK_SCROLL_PAGE_RIGHT:
+		case OS.GTK_SCROLL_PAGE_FORWARD:	event.detail = SWT.PAGE_DOWN; break;
+		case OS.GTK_SCROLL_PAGE_UP:
+		case OS.GTK_SCROLL_PAGE_LEFT:
+		case OS.GTK_SCROLL_PAGE_BACKWARD:	event.detail = SWT.PAGE_UP; break;
+		case OS.GTK_SCROLL_STEP_DOWN:
+		case OS.GTK_SCROLL_STEP_RIGHT:
+		case OS.GTK_SCROLL_STEP_FORWARD:	event.detail = SWT.ARROW_DOWN; break;
+		case OS.GTK_SCROLL_STEP_UP:
+		case OS.GTK_SCROLL_STEP_LEFT:
+		case OS.GTK_SCROLL_STEP_BACKWARD:	event.detail = SWT.ARROW_UP; break;
+	}
+	if (!dragSent) detail = OS.GTK_SCROLL_NONE;
+	postEvent (SWT.Selection, event);
+	return 0;
+}
+
+int /*long*/ gtk_event_after (int /*long*/ widget, int /*long*/ gdkEvent) {
+	GdkEvent gtkEvent = new GdkEvent ();
+	OS.memmove (gtkEvent, gdkEvent, GdkEvent.sizeof);
+	switch (gtkEvent.type) {
+		case OS.GDK_BUTTON_RELEASE: {
+			GdkEventButton gdkEventButton = new GdkEventButton ();
+			OS.memmove (gdkEventButton, gdkEvent, GdkEventButton.sizeof);
+			if (gdkEventButton.button == 1 && detail == SWT.DRAG) {
+				if (!dragSent) {
+					Event event = new Event ();
+					event.detail = SWT.DRAG;
+					postEvent (SWT.Selection, event);
+				}
+				postEvent (SWT.Selection);
+			}
+			detail = OS.GTK_SCROLL_NONE;
+			dragSent = false;
+			break;
+		}
+	}
+	return super.gtk_event_after (widget, gdkEvent);
+}
+
+void hookEvents () {
+	super.hookEvents ();
+	if (OS.GTK_VERSION >= OS.VERSION (2, 6, 0)) {
+		OS.g_signal_connect_closure (handle, OS.change_value, display.closures [CHANGE_VALUE], false);
+	}
+	OS.g_signal_connect_closure (handle, OS.value_changed, display.closures [VALUE_CHANGED], false);
+}
+
+void register () {
+	super.register ();
+	int /*long*/ hAdjustment = OS.gtk_range_get_adjustment (handle);
+	display.addWidget (hAdjustment, this);
+}
+
+void deregister () {
+	super.deregister ();
+	int /*long*/ hAdjustment = OS.gtk_range_get_adjustment (handle);
+	display.removeWidget (hAdjustment);
+}
+
+public Point computeSize (int wHint, int hHint, boolean changed) {
+	checkWidget();
+	if (wHint != SWT.DEFAULT && wHint < 0) wHint = 0;
+	if (hHint != SWT.DEFAULT && hHint < 0) hHint = 0;
+	Point size = computeNativeSize(handle, wHint, hHint, changed);
+	if ((style & SWT.HORIZONTAL) != 0) {
+		if (wHint == SWT.DEFAULT) size.x = 2 * size.x;
+	} else {
+		if (hHint == SWT.DEFAULT) size.y = 2 * size.y;
+	}
+	return size;
+}
+
+/**
+ * Returns the amount that the receiver's value will be
+ * modified by when the up/down (or right/left) arrows
+ * are pressed.
+ *
+ * @return the increment
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getIncrement () {
+	checkWidget ();
+	int /*long*/ hAdjustment = OS.gtk_range_get_adjustment (handle);
+	GtkAdjustment adjustment = new GtkAdjustment ();
+	OS.memmove (adjustment, hAdjustment);
+	return (int) adjustment.step_increment;
+}
+
+/**
+ * Returns the maximum value which the receiver will allow.
+ *
+ * @return the maximum
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getMaximum () {
+	checkWidget ();
+	int /*long*/ hAdjustment = OS.gtk_range_get_adjustment (handle);
+	GtkAdjustment adjustment = new GtkAdjustment ();
+	OS.memmove (adjustment, hAdjustment);
+	return (int) adjustment.upper;
+}
+
+/**
+ * Returns the minimum value which the receiver will allow.
+ *
+ * @return the minimum
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getMinimum () {
+	checkWidget ();
+	int /*long*/ hAdjustment = OS.gtk_range_get_adjustment (handle);
+	GtkAdjustment adjustment = new GtkAdjustment ();
+	OS.memmove (adjustment, hAdjustment);
+	return (int) adjustment.lower;
+}
+
+/**
+ * Returns the amount that the receiver's value will be
+ * modified by when the page increment/decrement areas
+ * are selected.
+ *
+ * @return the page increment
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getPageIncrement () {
+	checkWidget ();
+	int /*long*/ hAdjustment = OS.gtk_range_get_adjustment (handle);
+	GtkAdjustment adjustment = new GtkAdjustment ();
+	OS.memmove (adjustment, hAdjustment);
+	return (int) adjustment.page_increment;
+}
+
+/**
+ * Returns the 'selection', which is the receiver's value.
+ *
+ * @return the selection
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getSelection () {
+	checkWidget ();
+	int /*long*/ hAdjustment = OS.gtk_range_get_adjustment (handle);
+	GtkAdjustment adjustment = new GtkAdjustment ();
+	OS.memmove (adjustment, hAdjustment);
+	return (int) adjustment.value;
+}
+
+/**
+ * Returns the size of the receiver's thumb relative to the
+ * difference between its maximum and minimum values.
+ *
+ * @return the thumb value
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getThumb () {
+	checkWidget ();
+	int /*long*/ hAdjustment = OS.gtk_range_get_adjustment (handle);
+	GtkAdjustment adjustment = new GtkAdjustment ();
+	OS.memmove (adjustment, hAdjustment);
+	return (int) adjustment.page_size;
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the user changes the receiver's value.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #addSelectionListener
+ */
+public void removeSelectionListener (SelectionListener listener) {
+	checkWidget();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if (eventTable == null) return;
+	eventTable.unhook (SWT.Selection, listener);
+	eventTable.unhook (SWT.DefaultSelection,listener);	
+}
+
+/**
+ * Sets the amount that the receiver's value will be
+ * modified by when the up/down (or right/left) arrows
+ * are pressed to the argument, which must be at least 
+ * one.
+ *
+ * @param value the new increment (must be greater than zero)
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setIncrement (int value) {
+	checkWidget ();
+	if (value < 1) return;
+	OS.g_signal_handlers_block_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, VALUE_CHANGED);
+	OS.gtk_range_set_increments (handle, value, getPageIncrement ());
+	OS.g_signal_handlers_unblock_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, VALUE_CHANGED);
+}
+
+/**
+ * Sets the maximum. If this value is negative or less than or
+ * equal to the minimum, the value is ignored. If necessary, first
+ * the thumb and then the selection are adjusted to fit within the
+ * new range.
+ *
+ * @param value the new maximum, which must be greater than the current minimum
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setMaximum (int value) {
+	checkWidget ();
+	int /*long*/ hAdjustment = OS.gtk_range_get_adjustment (handle);
+	GtkAdjustment adjustment = new GtkAdjustment ();
+	OS.memmove (adjustment, hAdjustment);
+	int minimum = (int) adjustment.lower;
+	if (value <= minimum) return;
+	adjustment.upper = value;
+	adjustment.page_size = Math.min ((int)adjustment.page_size, value - minimum);
+	adjustment.value = Math.min ((int)adjustment.value, (int)(value - adjustment.page_size));
+	OS.memmove (hAdjustment, adjustment);
+	OS.g_signal_handlers_block_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, VALUE_CHANGED);
+	OS.gtk_adjustment_changed (hAdjustment);
+	OS.g_signal_handlers_unblock_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, VALUE_CHANGED);
+}
+
+/**
+ * Sets the minimum value. If this value is negative or greater
+ * than or equal to the maximum, the value is ignored. If necessary,
+ * first the thumb and then the selection are adjusted to fit within
+ * the new range.
+ *
+ * @param value the new minimum
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setMinimum (int value) {
+	checkWidget ();
+	if (value < 0) return;
+	int /*long*/ hAdjustment = OS.gtk_range_get_adjustment (handle);
+	GtkAdjustment adjustment = new GtkAdjustment ();
+	OS.memmove (adjustment, hAdjustment);
+	int maximum = (int) adjustment.upper;
+	if (value >= maximum) return;
+	adjustment.lower = value;
+	adjustment.page_size = Math.min ((int)adjustment.page_size, maximum - value);
+	adjustment.value = Math.max ((int)adjustment.value, value);
+	OS.memmove (hAdjustment, adjustment);
+	OS.g_signal_handlers_block_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, VALUE_CHANGED);
+	OS.gtk_adjustment_changed (hAdjustment);
+	OS.g_signal_handlers_unblock_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, VALUE_CHANGED);
+}
+
+void setOrientation () {
+	super.setOrientation ();
+	if ((style & SWT.RIGHT_TO_LEFT) != 0) {
+		if ((style & SWT.HORIZONTAL) != 0) {
+			OS.gtk_range_set_inverted (handle, true);
+		}
+	}
+}
+
+/**
+ * Sets the amount that the receiver's value will be
+ * modified by when the page increment/decrement areas
+ * are selected to the argument, which must be at least
+ * one.
+ *
+ * @param value the page increment (must be greater than zero)
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setPageIncrement (int value) {
+	checkWidget ();
+	if (value < 1) return;
+	OS.g_signal_handlers_block_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, VALUE_CHANGED);
+	OS.gtk_range_set_increments (handle, getIncrement (), value);
+	OS.g_signal_handlers_unblock_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, VALUE_CHANGED);
+}
+
+/**
+ * Sets the 'selection', which is the receiver's
+ * value, to the argument which must be greater than or equal
+ * to zero.
+ *
+ * @param value the new selection (must be zero or greater)
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setSelection (int value) {
+	checkWidget ();
+	OS.g_signal_handlers_block_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, VALUE_CHANGED);
+	OS.gtk_range_set_value (handle, value);
+	OS.g_signal_handlers_unblock_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, VALUE_CHANGED);
+}
+
+/**
+ * Sets the size of the receiver's thumb relative to the
+ * difference between its maximum and minimum values.  This new
+ * value will be ignored if it is less than one, and will be
+ * clamped if it exceeds the receiver's current range.
+ *
+ * @param value the new thumb value, which must be at least one and not
+ * larger than the size of the current range
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setThumb (int value) {
+	checkWidget ();
+	if (value < 1) return;
+	int /*long*/ hAdjustment = OS.gtk_range_get_adjustment (handle);
+	GtkAdjustment adjustment = new GtkAdjustment ();
+	OS.memmove (adjustment, hAdjustment);
+	value = (int) Math.min (value, (int)(adjustment.upper - adjustment.lower));
+	adjustment.page_size = (double) value;
+	adjustment.value = Math.min ((int)adjustment.value, (int)(adjustment.upper - value));
+	OS.memmove (hAdjustment, adjustment);
+	OS.g_signal_handlers_block_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, VALUE_CHANGED);
+	OS.gtk_adjustment_changed (hAdjustment);
+	OS.g_signal_handlers_unblock_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, VALUE_CHANGED);
+}
+
+/**
+ * Sets the receiver's selection, minimum value, maximum
+ * value, thumb, increment and page increment all at once.
+ * <p>
+ * Note: This is similar to setting the values individually
+ * using the appropriate methods, but may be implemented in a 
+ * more efficient fashion on some platforms.
+ * </p>
+ *
+ * @param selection the new selection value
+ * @param minimum the new minimum value
+ * @param maximum the new maximum value
+ * @param thumb the new thumb value
+ * @param increment the new increment value
+ * @param pageIncrement the new pageIncrement value
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setValues (int selection, int minimum, int maximum, int thumb, int increment, int pageIncrement) {
+	checkWidget ();
+	if (minimum < 0) return;
+	if (maximum < 0) return;
+	if (thumb < 1) return;
+	if (increment < 1) return;
+	if (pageIncrement < 1) return;
+	thumb = Math.min (thumb, maximum - minimum);
+	int /*long*/ hAdjustment = OS.gtk_range_get_adjustment (handle);
+	GtkAdjustment adjustment = new GtkAdjustment ();
+	OS.memmove (adjustment, hAdjustment);
+	adjustment.value = Math.min (Math.max (selection, minimum), maximum - thumb);
+	adjustment.lower = (double) minimum;
+	adjustment.upper = (double) maximum;
+	adjustment.page_size = (double) thumb;
+	adjustment.step_increment = (double) increment;
+	adjustment.page_increment = (double) pageIncrement;
+	OS.memmove (hAdjustment, adjustment);
+	OS.g_signal_handlers_block_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, VALUE_CHANGED);
+	OS.gtk_adjustment_changed (hAdjustment);
+	OS.gtk_adjustment_value_changed (hAdjustment);
+	OS.g_signal_handlers_unblock_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, VALUE_CHANGED);
+}
+
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Spinner.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Spinner.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Spinner.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,1196 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.widgets;
+
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.gtk.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.events.*;
+
+/**
+ * Instances of this class are selectable user interface
+ * objects that allow the user to enter and modify numeric
+ * values.
+ * <p>
+ * Note that although this class is a subclass of <code>Composite</code>,
+ * it does not make sense to add children to it, or set a layout on it.
+ * </p><p>
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>READ_ONLY, WRAP</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Selection, Modify, Verify</dd>
+ * </dl>
+ * </p><p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ *
+ * @see <a href="http://www.eclipse.org/swt/snippets/#spinner">Spinner snippets</a>
+ * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: ControlExample</a>
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ * 
+ * @since 3.1
+ */
+public class Spinner extends Composite {
+	static final int INNER_BORDER = 2;
+	static final int MIN_ARROW_WIDTH = 6;
+	int lastEventTime = 0;
+	int /*long*/ gdkEventKey = 0;
+	int fixStart = -1, fixEnd = -1;
+	
+	/**
+	 * the operating system limit for the number of characters
+	 * that the text field in an instance of this class can hold
+	 * 
+	 * @since 3.4
+	 */
+	public final static int LIMIT;
+	/*
+	* These values can be different on different platforms.
+	* Therefore they are not initialized in the declaration
+	* to stop the compiler from inlining.
+	*/
+	static {
+		LIMIT = 0x7FFFFFFF;
+	}
+	
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT#READ_ONLY
+ * @see SWT#WRAP
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public Spinner (Composite parent, int style) {
+	super (parent, checkStyle (style));
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the receiver's text is modified, by sending
+ * it one of the messages defined in the <code>ModifyListener</code>
+ * interface.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see ModifyListener
+ * @see #removeModifyListener
+ */
+public void addModifyListener (ModifyListener listener) {
+	checkWidget ();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	TypedListener typedListener = new TypedListener (listener);
+	addListener (SWT.Modify, typedListener);
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the control is selected by the user, by sending
+ * it one of the messages defined in the <code>SelectionListener</code>
+ * interface.
+ * <p>
+ * <code>widgetSelected</code> is not called for texts.
+ * <code>widgetDefaultSelected</code> is typically called when ENTER is pressed in a single-line text.
+ * </p>
+ *
+ * @param listener the listener which should be notified when the control is selected by the user
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent
+ */
+public void addSelectionListener(SelectionListener listener) {
+	checkWidget ();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	TypedListener typedListener = new TypedListener(listener);
+	addListener(SWT.Selection,typedListener);
+	addListener(SWT.DefaultSelection,typedListener);
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the receiver's text is verified, by sending
+ * it one of the messages defined in the <code>VerifyListener</code>
+ * interface.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see VerifyListener
+ * @see #removeVerifyListener
+ */
+void addVerifyListener (VerifyListener listener) {
+	checkWidget();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	TypedListener typedListener = new TypedListener (listener);
+	addListener (SWT.Verify, typedListener);
+}
+
+static int checkStyle (int style) {
+	/*
+	* Even though it is legal to create this widget
+	* with scroll bars, they serve no useful purpose
+	* because they do not automatically scroll the
+	* widget's client area.  The fix is to clear
+	* the SWT style.
+	*/
+	return style & ~(SWT.H_SCROLL | SWT.V_SCROLL);
+}
+
+protected void checkSubclass () {
+	if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
+}
+
+public Point computeSize (int wHint, int hHint, boolean changed) {
+	checkWidget ();
+	if (wHint != SWT.DEFAULT && wHint < 0) wHint = 0;
+	if (hHint != SWT.DEFAULT && hHint < 0) hHint = 0;
+	int[] w = new int [1], h = new int [1];
+	OS.gtk_widget_realize (handle);
+	int /*long*/ layout = OS.gtk_entry_get_layout (handle);
+	int /*long*/ hAdjustment = OS.gtk_spin_button_get_adjustment (handle);
+	GtkAdjustment adjustment = new GtkAdjustment ();
+	OS.memmove (adjustment, hAdjustment);
+	int digits = OS.gtk_spin_button_get_digits (handle);
+	for (int i = 0; i < digits; i++) adjustment.upper *= 10; 
+	String string = String.valueOf ((int) adjustment.upper);
+	if (digits > 0) {
+		StringBuffer buffer = new StringBuffer ();
+		buffer.append (string);
+		buffer.append (getDecimalSeparator ());
+		int count = digits - string.length ();
+		while (count >= 0) {
+			buffer.append ("0");
+			count--;
+		}
+		string = buffer.toString ();
+	}
+	byte [] buffer1 = Converter.wcsToMbcs (null, string, false);
+	int /*long*/ ptr = OS.pango_layout_get_text (layout);
+	int length = OS.strlen (ptr);
+	byte [] buffer2 = new byte [length];
+	OS.memmove (buffer2, ptr, length);	
+	OS.pango_layout_set_text (layout, buffer1, buffer1.length);
+	OS.pango_layout_get_size (layout, w, h);
+	OS.pango_layout_set_text (layout, buffer2, buffer2.length);
+	int width = OS.PANGO_PIXELS (w [0]);
+	int height = OS.PANGO_PIXELS (h [0]);
+	width = wHint == SWT.DEFAULT ? width : wHint;
+	height = hHint == SWT.DEFAULT ? height : hHint;
+	Rectangle trim = computeTrim (0, 0, width, height);
+	return new Point (trim.width, trim.height);
+}
+
+public Rectangle computeTrim (int x, int y, int width, int height) {
+	checkWidget ();
+	int xborder = 0, yborder = 0;
+	int /*long*/ style = OS.gtk_widget_get_style (handle);
+	if ((this.style & SWT.BORDER) != 0) {
+		xborder += OS.gtk_style_get_xthickness (style);
+		yborder += OS.gtk_style_get_ythickness (style);
+	}
+	xborder += INNER_BORDER;
+	yborder += INNER_BORDER;
+	int [] property = new int [1];
+	OS.gtk_widget_style_get (handle, OS.interior_focus, property, 0);
+	if (property [0] == 0) {
+		OS.gtk_widget_style_get (handle, OS.focus_line_width, property, 0);
+		xborder += property [0];
+		yborder += property [0];
+	}
+	int /*long*/ fontDesc = OS.gtk_style_get_font_desc (style);
+	int fontSize = OS.pango_font_description_get_size (fontDesc);
+	int arrowSize = Math.max (OS.PANGO_PIXELS (fontSize), MIN_ARROW_WIDTH);
+	arrowSize = arrowSize - arrowSize % 2;	
+	Rectangle trim = super.computeTrim (x, y, width, height);
+	trim.x -= xborder;
+	trim.y -= yborder;
+	trim.width += 2 * xborder;
+	trim.height += 2 * yborder;
+	trim.width += arrowSize + (2 * OS.gtk_style_get_xthickness (style));
+	return new Rectangle (trim.x, trim.y, trim.width, trim.height);
+}
+
+/**
+ * Copies the selected text.
+ * <p>
+ * The current selection is copied to the clipboard.
+ * </p>
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void copy () {
+	checkWidget ();
+	OS.gtk_editable_copy_clipboard (handle);
+}
+
+void createHandle (int index) {
+	state |= HANDLE | MENU;
+	fixedHandle = OS.g_object_new (display.gtk_fixed_get_type (), 0);
+	if (fixedHandle == 0) error (SWT.ERROR_NO_HANDLES);
+	OS.gtk_fixed_set_has_window (fixedHandle, true);
+	int /*long*/ adjustment = OS.gtk_adjustment_new (0, 0, 100, 1, 10, 0);
+	if (adjustment == 0) error (SWT.ERROR_NO_HANDLES);
+	handle = OS.gtk_spin_button_new (adjustment, 1, 0);
+	if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+	OS.gtk_container_add (fixedHandle, handle);
+	OS.gtk_editable_set_editable (handle, (style & SWT.READ_ONLY) == 0);
+	OS.gtk_entry_set_has_frame (handle, (style & SWT.BORDER) != 0);
+	OS.gtk_spin_button_set_wrap (handle, (style & SWT.WRAP) != 0);
+}
+
+/**
+ * Cuts the selected text.
+ * <p>
+ * The current selection is first copied to the
+ * clipboard and then deleted from the widget.
+ * </p>
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void cut () {
+	checkWidget ();
+	OS.gtk_editable_cut_clipboard (handle);
+}
+
+void deregister () {
+	super.deregister ();
+	int /*long*/ imContext = imContext ();
+	if (imContext != 0) display.removeWidget (imContext);
+}
+
+int /*long*/ eventWindow () {
+	return paintWindow ();
+}
+
+int /*long*/ enterExitHandle () {
+	return fixedHandle;
+}
+
+boolean filterKey (int keyval, int /*long*/ event) {
+	int time = OS.gdk_event_get_time (event);
+	if (time != lastEventTime) {
+		lastEventTime = time;
+		int /*long*/ imContext = imContext ();
+		if (imContext != 0) {
+			return OS.gtk_im_context_filter_keypress (imContext, event);
+		}
+	}
+	gdkEventKey = event;
+	return false;
+}
+
+void fixIM () {
+	/*
+	*  The IM filter has to be called one time for each key press event.
+	*  When the IM is open the key events are duplicated. The first event
+	*  is filtered by SWT and the second event is filtered by GTK.  In some 
+	*  cases the GTK handler does not run (the widget is destroyed, the 
+	*  application code consumes the event, etc), for these cases the IM
+	*  filter has to be called by SWT.
+	*/	
+	if (gdkEventKey != 0 && gdkEventKey != -1) {
+		int /*long*/ imContext = imContext ();
+		if (imContext != 0) {
+			OS.gtk_im_context_filter_keypress (imContext, gdkEventKey);
+			gdkEventKey = -1;
+			return;
+		}
+	}
+	gdkEventKey = 0;
+}
+
+GdkColor getBackgroundColor () {
+	return getBaseColor ();
+}
+
+public int getBorderWidth () {
+	checkWidget();
+	int /*long*/ style = OS.gtk_widget_get_style (handle);
+	if ((this.style & SWT.BORDER) != 0) {
+		 return OS.gtk_style_get_xthickness (style);
+	}
+	return 0;
+}
+
+GdkColor getForegroundColor () {
+	return getTextColor ();
+}
+
+/**
+ * Returns the amount that the receiver's value will be
+ * modified by when the up/down arrows are pressed.
+ *
+ * @return the increment
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getIncrement () {
+	checkWidget ();
+	int /*long*/ hAdjustment = OS.gtk_spin_button_get_adjustment (handle);
+	GtkAdjustment adjustment = new GtkAdjustment ();
+	OS.memmove (adjustment, hAdjustment);
+	int digits = OS.gtk_spin_button_get_digits (handle);
+	double value = adjustment.step_increment;
+	for (int i = 0; i < digits; i++) value *= 10;
+	return (int) (value > 0 ? value + 0.5 : value - 0.5);
+}
+
+/**
+ * Returns the maximum value which the receiver will allow.
+ *
+ * @return the maximum
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getMaximum () {
+	checkWidget ();
+	int /*long*/ hAdjustment = OS.gtk_spin_button_get_adjustment (handle);
+	GtkAdjustment adjustment = new GtkAdjustment ();
+	OS.memmove (adjustment, hAdjustment);
+	int digits = OS.gtk_spin_button_get_digits (handle);
+	double value = adjustment.upper;
+	for (int i = 0; i < digits; i++) value *= 10;
+	return (int) (value > 0 ? value + 0.5 : value - 0.5);
+}
+
+/**
+ * Returns the minimum value which the receiver will allow.
+ *
+ * @return the minimum
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getMinimum () {
+	checkWidget ();
+	int /*long*/ hAdjustment = OS.gtk_spin_button_get_adjustment (handle);
+	GtkAdjustment adjustment = new GtkAdjustment ();
+	OS.memmove (adjustment, hAdjustment);
+	int digits = OS.gtk_spin_button_get_digits (handle);
+	double value = adjustment.lower;
+	for (int i = 0; i < digits; i++) value *= 10;
+	return (int) (value > 0 ? value + 0.5 : value - 0.5);
+}
+
+/**
+ * Returns the amount that the receiver's position will be
+ * modified by when the page up/down keys are pressed.
+ *
+ * @return the page increment
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getPageIncrement () {
+	checkWidget ();
+	int /*long*/ hAdjustment = OS.gtk_spin_button_get_adjustment (handle);
+	GtkAdjustment adjustment = new GtkAdjustment ();
+	OS.memmove (adjustment, hAdjustment);
+	int digits = OS.gtk_spin_button_get_digits (handle);
+	double value = adjustment.page_increment;
+	for (int i = 0; i < digits; i++) value *= 10;
+	return (int) (value > 0 ? value + 0.5 : value - 0.5);
+}
+
+/**
+ * Returns the <em>selection</em>, which is the receiver's position.
+ *
+ * @return the selection 
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getSelection () {
+	checkWidget ();	
+	int /*long*/ hAdjustment = OS.gtk_spin_button_get_adjustment (handle);
+	GtkAdjustment adjustment = new GtkAdjustment ();
+	OS.memmove (adjustment, hAdjustment);
+	int digits = OS.gtk_spin_button_get_digits (handle);
+	double value = adjustment.value;
+	for (int i = 0; i < digits; i++) value *= 10;
+	return (int) (value > 0 ? value + 0.5 : value - 0.5);
+}
+
+/**
+ * Returns a string containing a copy of the contents of the
+ * receiver's text field, or an empty string if there are no
+ * contents.
+ *
+ * @return the receiver's text
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.4
+ */
+public String getText () {
+	checkWidget ();
+	int /*long*/ str = OS.gtk_entry_get_text (handle);
+	if (str == 0) return "";
+	int length = OS.strlen (str);
+	byte [] buffer = new byte [length];
+	OS.memmove (buffer, str, length);
+	return new String (Converter.mbcsToWcs (null, buffer));
+}
+
+/**
+ * Returns the maximum number of characters that the receiver's
+ * text field is capable of holding. If this has not been changed
+ * by <code>setTextLimit()</code>, it will be the constant
+ * <code>Spinner.LIMIT</code>.
+ * 
+ * @return the text limit
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #LIMIT
+ * 
+ * @since 3.4
+ */
+public int getTextLimit () {
+	checkWidget ();
+	int limit = OS.gtk_entry_get_max_length (handle);
+	return limit == 0 ? 0xFFFF : limit;
+}
+
+/**
+ * Returns the number of decimal places used by the receiver.
+ *
+ * @return the digits
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getDigits () {
+	checkWidget ();
+	return OS.gtk_spin_button_get_digits (handle);
+}
+
+String getDecimalSeparator () {
+	int /*long*/ ptr = OS.localeconv_decimal_point ();
+	int length = OS.strlen (ptr);
+	byte [] buffer = new byte [length];
+	OS.memmove (buffer, ptr, length);	
+	return new String (Converter.mbcsToWcs (null, buffer));
+}
+
+int /*long*/ gtk_activate (int /*long*/ widget) {
+	postEvent (SWT.DefaultSelection);
+	return 0;
+}
+
+int /*long*/ gtk_changed (int /*long*/ widget) {
+	int /*long*/ str = OS.gtk_entry_get_text (handle);
+	int length = OS.strlen (str);
+	if (length > 0) {
+		int /*long*/ [] endptr = new int /*long*/ [1];
+		double value = OS.g_strtod (str, endptr);
+		if (endptr [0] == str + length) {
+			int /*long*/ hAdjustment = OS.gtk_spin_button_get_adjustment (handle);
+			GtkAdjustment adjustment = new GtkAdjustment ();
+			OS.memmove (adjustment, hAdjustment);
+			if (value != adjustment.value && adjustment.lower <= value && value <= adjustment.upper) {
+				OS.gtk_spin_button_update (handle);
+			}
+		}
+	}
+	
+	/*
+	* Feature in GTK.  When the user types, GTK positions
+	* the caret after sending the changed signal.  This
+	* means that application code that attempts to position
+	* the caret during a changed signal will fail.  The fix
+	* is to post the modify event when the user is typing.
+	*/
+	boolean keyPress = false;
+	int /*long*/ eventPtr = OS.gtk_get_current_event ();
+	if (eventPtr != 0) {
+		GdkEventKey gdkEvent = new GdkEventKey ();
+		OS.memmove (gdkEvent, eventPtr, GdkEventKey.sizeof);
+		switch (gdkEvent.type) {
+			case OS.GDK_KEY_PRESS:
+				keyPress = true;
+				break;
+		}
+		OS.gdk_event_free (eventPtr);
+	}
+	if (keyPress) {
+		postEvent (SWT.Modify);
+	} else {
+		sendEvent (SWT.Modify);
+	}
+	return 0;
+}
+
+int /*long*/ gtk_commit (int /*long*/ imContext, int /*long*/ text) {
+	if (text == 0) return 0;
+	if (!OS.gtk_editable_get_editable (handle)) return 0;
+	int length = OS.strlen (text);
+	if (length == 0) return 0;
+	byte [] buffer = new byte [length];
+	OS.memmove (buffer, text, length);
+	char [] chars = Converter.mbcsToWcs (null, buffer);
+	char [] newChars = sendIMKeyEvent (SWT.KeyDown, null, chars);
+	if (newChars == null) return 0;
+	/*
+	* Feature in GTK.  For a GtkEntry, during the insert-text signal,
+	* GTK allows the programmer to change only the caret location,
+	* not the selection.  If the programmer changes the selection,
+	* the new selection is lost.  The fix is to detect a selection
+	* change and set it after the insert-text signal has completed.
+	*/
+	fixStart = fixEnd = -1;
+	OS.g_signal_handlers_block_matched (imContext, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, COMMIT);
+	int id = OS.g_signal_lookup (OS.commit, OS.gtk_im_context_get_type ());
+	int mask =  OS.G_SIGNAL_MATCH_DATA | OS.G_SIGNAL_MATCH_ID;
+	OS.g_signal_handlers_unblock_matched (imContext, mask, id, 0, 0, 0, handle);
+	if (newChars == chars) {
+		OS.g_signal_emit_by_name (imContext, OS.commit, text);
+	} else {
+		buffer = Converter.wcsToMbcs (null, newChars, true);
+		OS.g_signal_emit_by_name (imContext, OS.commit, buffer);
+	}
+	OS.g_signal_handlers_unblock_matched (imContext, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, COMMIT);
+	OS.g_signal_handlers_block_matched (imContext, mask, id, 0, 0, 0, handle);
+	if (fixStart != -1 && fixEnd != -1) {
+		OS.gtk_editable_set_position (handle, fixStart);
+		OS.gtk_editable_select_region (handle, fixStart, fixEnd);
+	}
+	fixStart = fixEnd = -1;
+	return 0;
+}
+
+int /*long*/ gtk_delete_text (int /*long*/ widget, int /*long*/ start_pos, int /*long*/ end_pos) {
+	if (!hooks (SWT.Verify) && !filters (SWT.Verify)) return 0;
+	String newText = verifyText ("", (int)/*64*/start_pos, (int)/*64*/end_pos);
+	if (newText == null) {
+		OS.g_signal_stop_emission_by_name (handle, OS.delete_text);
+	} else {
+		if (newText.length () > 0) {
+			int [] pos = new int [1];
+			pos [0] = (int)/*64*/end_pos;
+			byte [] buffer = Converter.wcsToMbcs (null, newText, false);
+			OS.g_signal_handlers_block_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+			OS.g_signal_handlers_block_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, INSERT_TEXT);
+			OS.gtk_editable_insert_text (handle, buffer, buffer.length, pos);
+			OS.g_signal_handlers_unblock_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, INSERT_TEXT);
+			OS.g_signal_handlers_unblock_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+			OS.gtk_editable_set_position (handle, pos [0]);
+		}
+	}
+	return 0;
+}
+
+int /*long*/ gtk_event_after (int /*long*/ widget, int /*long*/ gdkEvent) {
+	if (cursor != null) setCursor (cursor.handle);
+	return super.gtk_event_after (widget, gdkEvent);
+}
+
+int /*long*/ gtk_focus_out_event (int /*long*/ widget, int /*long*/ event) {
+	fixIM ();
+	return super.gtk_focus_out_event (widget, event);
+}
+
+int /*long*/ gtk_insert_text (int /*long*/ widget, int /*long*/ new_text, int /*long*/ new_text_length, int /*long*/ position) {
+//	if (!hooks (SWT.Verify) && !filters (SWT.Verify)) return 0;
+	if (new_text == 0 || new_text_length == 0) return 0;
+	byte [] buffer = new byte [(int)/*64*/new_text_length];
+	OS.memmove (buffer, new_text, buffer.length);
+	String oldText = new String (Converter.mbcsToWcs (null, buffer));
+	int [] pos = new int [1];
+	OS.memmove (pos, position, 4);
+	if (pos [0] == -1) {
+		int /*long*/ ptr = OS.gtk_entry_get_text (handle);
+		pos [0] = (int)/*64*/OS.g_utf8_strlen (ptr, -1);
+	}
+	String newText = verifyText (oldText, pos [0], pos [0]);
+	if (newText != oldText) {
+		int [] newStart = new int [1], newEnd = new int [1];
+		OS.gtk_editable_get_selection_bounds (handle, newStart, newEnd);
+		if (newText != null) {
+			if (newStart [0] != newEnd [0]) {
+				OS.g_signal_handlers_block_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, DELETE_TEXT);
+				OS.g_signal_handlers_block_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+				OS.gtk_editable_delete_selection (handle);
+				OS.g_signal_handlers_unblock_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, DELETE_TEXT);
+				OS.g_signal_handlers_unblock_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+			}
+			byte [] buffer3 = Converter.wcsToMbcs (null, newText, false);
+			OS.g_signal_handlers_block_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, INSERT_TEXT);
+			OS.gtk_editable_insert_text (handle, buffer3, buffer3.length, pos);
+			OS.g_signal_handlers_unblock_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, INSERT_TEXT);
+			newStart [0] = newEnd [0] = pos [0];
+		}
+		pos [0] = newEnd [0];
+		if (newStart [0] != newEnd [0]) {
+			fixStart = newStart [0];
+			fixEnd = newEnd [0];
+		}
+		OS.memmove (position, pos, 4);
+		OS.g_signal_stop_emission_by_name (handle, OS.insert_text);
+	}
+	return 0;
+}
+
+int /*long*/ gtk_key_press_event (int /*long*/ widget, int /*long*/ event) {
+	int /*long*/ result = super.gtk_key_press_event (widget, event);
+	if (result != 0) fixIM ();
+	if (gdkEventKey == -1) result = 1;
+	gdkEventKey = 0;
+	return result;
+}
+
+int /*long*/ gtk_populate_popup (int /*long*/ widget, int /*long*/ menu) {
+	if ((style & SWT.RIGHT_TO_LEFT) != 0) {
+		OS.gtk_widget_set_direction (menu, OS.GTK_TEXT_DIR_RTL);
+		OS.gtk_container_forall (menu, display.setDirectionProc, OS.GTK_TEXT_DIR_RTL);
+	}
+	return 0;
+}
+
+int /*long*/ gtk_value_changed (int /*long*/ widget) {
+	postEvent (SWT.Selection);
+	return 0;
+}
+
+void hookEvents () {
+	super.hookEvents();
+	OS.g_signal_connect_closure (handle, OS.changed, display.closures [CHANGED], true);
+	OS.g_signal_connect_closure (handle, OS.insert_text, display.closures [INSERT_TEXT], false);
+	OS.g_signal_connect_closure (handle, OS.delete_text, display.closures [DELETE_TEXT], false);
+	OS.g_signal_connect_closure (handle, OS.value_changed, display.closures [VALUE_CHANGED], false);
+	OS.g_signal_connect_closure (handle, OS.activate, display.closures [ACTIVATE], false);
+	OS.g_signal_connect_closure (handle, OS.populate_popup, display.closures [POPULATE_POPUP], false);
+	int /*long*/ imContext = imContext ();
+	if (imContext != 0) {
+		OS.g_signal_connect_closure (imContext, OS.commit, display.closures [COMMIT], false);
+		int id = OS.g_signal_lookup (OS.commit, OS.gtk_im_context_get_type ());
+		int mask =  OS.G_SIGNAL_MATCH_DATA | OS.G_SIGNAL_MATCH_ID;
+		OS.g_signal_handlers_block_matched (imContext, mask, id, 0, 0, 0, handle);
+	}
+}
+
+int /*long*/ imContext () {
+	return OS.GTK_ENTRY_IM_CONTEXT (handle);
+}
+
+int /*long*/ paintWindow () {
+	int /*long*/ window = super.paintWindow ();
+	int /*long*/ children = OS.gdk_window_get_children (window);
+	if (children != 0) window = OS.g_list_data (children);
+	OS.g_list_free (children);
+	return window;
+}
+
+/**
+ * Pastes text from clipboard.
+ * <p>
+ * The selected text is deleted from the widget
+ * and new text inserted from the clipboard.
+ * </p>
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void paste () {
+	checkWidget ();
+	OS.gtk_editable_paste_clipboard (handle);
+}
+
+void register () {
+	super.register ();
+	int /*long*/ imContext = imContext ();
+	if (imContext != 0) display.addWidget (imContext, this);
+}
+
+void releaseWidget () {
+	super.releaseWidget ();
+	fixIM ();
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the receiver's text is modified.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see ModifyListener
+ * @see #addModifyListener
+ */
+public void removeModifyListener (ModifyListener listener) {
+	checkWidget ();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if (eventTable == null) return;
+	eventTable.unhook (SWT.Modify, listener);	
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the control is selected by the user.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #addSelectionListener
+ */
+public void removeSelectionListener(SelectionListener listener) {
+	checkWidget ();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if (eventTable == null) return;
+	eventTable.unhook(SWT.Selection, listener);
+	eventTable.unhook(SWT.DefaultSelection,listener);	
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the control is verified.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see VerifyListener
+ * @see #addVerifyListener
+ */
+void removeVerifyListener (VerifyListener listener) {
+	checkWidget ();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if (eventTable == null) return;
+	eventTable.unhook (SWT.Verify, listener);	
+}
+
+void setBackgroundColor (GdkColor color) {
+	super.setBackgroundColor (color);
+	OS.gtk_widget_modify_base (handle, 0, color);
+}
+
+void setCursor (int /*long*/ cursor) {
+	int /*long*/ defaultCursor = 0;
+	if (cursor == 0) defaultCursor = OS.gdk_cursor_new (OS.GDK_XTERM);
+	super.setCursor (cursor != 0 ? cursor : defaultCursor);
+	if (cursor == 0) OS.gdk_cursor_destroy (defaultCursor);
+}
+
+void setFontDescription (int /*long*/ font) {
+	super.setFontDescription (font);
+}
+
+/**
+ * Sets the amount that the receiver's value will be
+ * modified by when the up/down arrows are pressed to
+ * the argument, which must be at least one.
+ *
+ * @param value the new increment (must be greater than zero)
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setIncrement (int value) {
+	checkWidget ();
+	if (value < 1) return;
+	int /*long*/ hAdjustment = OS.gtk_spin_button_get_adjustment (handle);
+	GtkAdjustment adjustment = new GtkAdjustment ();
+	OS.memmove (adjustment, hAdjustment);
+	double newValue = value;
+	int digits = OS.gtk_spin_button_get_digits (handle);
+	for (int i = 0; i < digits; i++) newValue /= 10;
+	OS.g_signal_handlers_block_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, VALUE_CHANGED);
+	OS.gtk_spin_button_set_increments (handle, newValue, adjustment.page_increment);
+	OS.g_signal_handlers_unblock_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, VALUE_CHANGED);
+}
+
+/**
+ * Sets the maximum value that the receiver will allow.  This new
+ * value will be ignored if it is not greater than the receiver's current
+ * minimum value.  If the new maximum is applied then the receiver's
+ * selection value will be adjusted if necessary to fall within its new range.
+ *
+ * @param value the new maximum, which must be greater than the current minimum
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setMaximum (int value) {
+	checkWidget ();
+	int /*long*/ hAdjustment = OS.gtk_spin_button_get_adjustment (handle);
+	GtkAdjustment adjustment = new GtkAdjustment ();
+	OS.memmove (adjustment, hAdjustment);
+	double newValue = value;
+	int digits = OS.gtk_spin_button_get_digits (handle);
+	for (int i = 0; i < digits; i++) newValue /= 10;
+	if (newValue <= adjustment.lower) return;
+	OS.g_signal_handlers_block_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, VALUE_CHANGED);
+	OS.gtk_spin_button_set_range (handle, adjustment.lower, newValue);
+	OS.g_signal_handlers_unblock_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, VALUE_CHANGED);
+}
+
+/**
+ * Sets the minimum value that the receiver will allow.  This new
+ * value will be ignored if it is not less than the receiver's
+ * current maximum value.  If the new minimum is applied then the receiver's
+ * selection value will be adjusted if necessary to fall within its new range.
+ *
+ * @param value the new minimum, which must be less than the current maximum
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setMinimum (int value) {
+	checkWidget ();
+	int /*long*/ hAdjustment = OS.gtk_spin_button_get_adjustment (handle);
+	GtkAdjustment adjustment = new GtkAdjustment ();
+	OS.memmove (adjustment, hAdjustment);
+	double newValue = value;
+	int digits = OS.gtk_spin_button_get_digits (handle);
+	for (int i = 0; i < digits; i++) newValue /= 10;
+	if (newValue >= adjustment.upper) return;
+	OS.g_signal_handlers_block_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, VALUE_CHANGED);
+	OS.gtk_spin_button_set_range (handle, newValue, adjustment.upper);
+	OS.g_signal_handlers_unblock_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, VALUE_CHANGED);
+}
+
+/**
+ * Sets the amount that the receiver's position will be
+ * modified by when the page up/down keys are pressed
+ * to the argument, which must be at least one.
+ *
+ * @param value the page increment (must be greater than zero)
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setPageIncrement (int value) {
+	checkWidget ();
+	if (value < 1) return;
+	int /*long*/ hAdjustment = OS.gtk_spin_button_get_adjustment (handle);
+	GtkAdjustment adjustment = new GtkAdjustment ();
+	OS.memmove (adjustment, hAdjustment);
+	double newValue = value;
+	int digits = OS.gtk_spin_button_get_digits (handle);
+	for (int i = 0; i < digits; i++) newValue /= 10;
+	OS.g_signal_handlers_block_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, VALUE_CHANGED);
+	OS.gtk_spin_button_set_increments (handle, adjustment.step_increment, newValue);
+	OS.g_signal_handlers_unblock_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, VALUE_CHANGED);
+}
+
+/**
+ * Sets the <em>selection</em>, which is the receiver's
+ * position, to the argument. If the argument is not within
+ * the range specified by minimum and maximum, it will be
+ * adjusted to fall within this range.
+ *
+ * @param value the new selection (must be zero or greater)
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setSelection (int value) {
+	checkWidget ();
+	double newValue = value;
+	int digits = OS.gtk_spin_button_get_digits (handle);
+	for (int i = 0; i < digits; i++) newValue /= 10;
+	OS.g_signal_handlers_block_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, VALUE_CHANGED);
+	OS.gtk_spin_button_set_value (handle, newValue);
+	OS.g_signal_handlers_unblock_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, VALUE_CHANGED);
+}
+
+/**
+ * Sets the maximum number of characters that the receiver's
+ * text field is capable of holding to be the argument.
+ * <p>
+ * To reset this value to the default, use <code>setTextLimit(Spinner.LIMIT)</code>.
+ * Specifying a limit value larger than <code>Spinner.LIMIT</code> sets the
+ * receiver's limit to <code>Spinner.LIMIT</code>.
+ * </p>
+ * @param limit new text limit
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_CANNOT_BE_ZERO - if the limit is zero</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see #LIMIT
+ * 
+ * @since 3.4
+ */
+public void setTextLimit (int limit) {
+	checkWidget ();
+	if (limit == 0) error (SWT.ERROR_CANNOT_BE_ZERO);
+	OS.gtk_entry_set_max_length (handle, limit);
+}
+
+/**
+ * Sets the number of decimal places used by the receiver.
+ * <p>
+ * The digit setting is used to allow for floating point values in the receiver.
+ * For example, to set the selection to a floating point value of 1.37 call setDigits() with 
+ * a value of 2 and setSelection() with a value of 137. Similarly, if getDigits() has a value
+ * of 2 and getSelection() returns 137 this should be interpreted as 1.37. This applies to all
+ * numeric APIs. 
+ * </p>
+ * 
+ * @param value the new digits (must be greater than or equal to zero)
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the value is less than zero</li>
+ * </ul> 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setDigits (int value) {
+	checkWidget ();
+	if (value < 0) error (SWT.ERROR_INVALID_ARGUMENT);
+	int digits = OS.gtk_spin_button_get_digits (handle);
+	if (value == digits) return;
+	int /*long*/ hAdjustment = OS.gtk_spin_button_get_adjustment (handle);
+	GtkAdjustment adjustment = new GtkAdjustment ();
+	OS.memmove (adjustment, hAdjustment);
+	int diff = Math.abs (value - digits);
+	int factor = 1;
+	for (int i = 0; i < diff; i++) factor *= 10;
+	if (digits > value) {
+		adjustment.value *= factor;
+		adjustment.upper *= factor;
+		adjustment.lower *= factor;
+		adjustment.step_increment *= factor;
+		adjustment.page_increment *= factor;
+	} else {
+		adjustment.value /= factor;
+		adjustment.upper /= factor;
+		adjustment.lower /= factor;
+		adjustment.step_increment /= factor;
+		adjustment.page_increment /= factor;
+	}
+	OS.memmove (hAdjustment, adjustment);
+	OS.gtk_spin_button_set_digits (handle, value);
+}
+
+/**
+ * Sets the receiver's selection, minimum value, maximum
+ * value, digits, increment and page increment all at once.
+ * <p>
+ * Note: This is similar to setting the values individually
+ * using the appropriate methods, but may be implemented in a 
+ * more efficient fashion on some platforms.
+ * </p>
+ *
+ * @param selection the new selection value
+ * @param minimum the new minimum value
+ * @param maximum the new maximum value
+ * @param digits the new digits value
+ * @param increment the new increment value
+ * @param pageIncrement the new pageIncrement value
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.2
+ */
+public void setValues (int selection, int minimum, int maximum, int digits, int increment, int pageIncrement) {
+	checkWidget ();
+	if (maximum <= minimum) return;
+	if (digits < 0) return;
+	if (increment < 1) return;
+	if (pageIncrement < 1) return;
+	selection = Math.min (Math.max (minimum, selection), maximum);
+	double factor = 1;
+	for (int i = 0; i < digits; i++) factor *= 10;	
+	OS.g_signal_handlers_block_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, VALUE_CHANGED);
+	OS.gtk_spin_button_set_range (handle, minimum / factor, maximum / factor);
+	OS.gtk_spin_button_set_increments (handle, increment / factor, pageIncrement / factor);
+	OS.gtk_spin_button_set_value (handle, selection / factor);
+	OS.gtk_spin_button_set_digits (handle, digits);
+	OS.g_signal_handlers_unblock_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, VALUE_CHANGED);
+}
+
+boolean translateTraversal (GdkEventKey keyEvent) {
+	int key = keyEvent.keyval;
+	switch (key) {
+		case OS.GDK_KP_Enter:
+		case OS.GDK_Return: {
+			int /*long*/ imContext =  imContext ();
+			if (imContext != 0) {
+				int /*long*/ [] preeditString = new int /*long*/ [1];
+				OS.gtk_im_context_get_preedit_string (imContext, preeditString, null, null);
+				if (preeditString [0] != 0) {
+					int length = OS.strlen (preeditString [0]);
+					OS.g_free (preeditString [0]);
+					if (length != 0) return false;
+				}
+			}
+		}
+	}
+	return super.translateTraversal (keyEvent);
+}
+
+String verifyText (String string, int start, int end) {
+	if (string.length () == 0 && start == end) return null;
+	Event event = new Event ();
+	event.text = string;
+	event.start = start;
+	event.end = end;
+	int /*long*/ eventPtr = OS.gtk_get_current_event ();
+	if (eventPtr != 0) {
+		GdkEventKey gdkEvent = new GdkEventKey ();
+		OS.memmove (gdkEvent, eventPtr, GdkEventKey.sizeof);
+		switch (gdkEvent.type) {
+			case OS.GDK_KEY_PRESS:
+				setKeyState (event, gdkEvent);
+				break;
+		}
+		OS.gdk_event_free (eventPtr);
+	}
+	int index = 0;
+	if (OS.gtk_spin_button_get_digits (handle) > 0) {
+		String decimalSeparator = getDecimalSeparator ();
+		index = string.indexOf (decimalSeparator);
+		if (index != -1) {
+			string = string.substring (0, index) + string.substring (index + 1);
+		}
+		index = 0;
+	}
+	if (string.length () > 0) {
+		int /*long*/ hAdjustment = OS.gtk_spin_button_get_adjustment (handle);
+		GtkAdjustment adjustment = new GtkAdjustment ();
+		OS.memmove (adjustment, hAdjustment);
+		if (adjustment.lower < 0 && string.charAt (0) == '-') index++;
+	}
+	while (index < string.length ()) {
+		if (!Character.isDigit (string.charAt (index))) break;
+		index++;
+	}
+	event.doit = index == string.length ();
+	/*
+	 * It is possible (but unlikely), that application
+	 * code could have disposed the widget in the verify
+	 * event.  If this happens, answer null to cancel
+	 * the operation.
+	 */
+	sendEvent (SWT.Verify, event);
+	if (!event.doit || isDisposed ()) return null;
+	return event.text;
+}
+
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Synchronizer.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Synchronizer.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Synchronizer.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,199 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.widgets;
+
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.Compatibility;
+ 
+/**
+ * Instances of this class provide synchronization support
+ * for displays. A default instance is created automatically
+ * for each display, and this instance is sufficient for almost
+ * all applications.
+ * <p>
+ * <b>IMPORTANT:</b> Typical application code <em>never</em>
+ * needs to deal with this class. It is provided only to
+ * allow applications which require non-standard
+ * synchronization behavior to plug in the support they
+ * require. <em>Subclasses which override the methods in 
+ * this class must ensure that the superclass methods are
+ * invoked in their implementations</em>
+ * </p>
+ *
+ * @see Display#setSynchronizer
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public class Synchronizer {
+	Display display;
+	int messageCount;
+	RunnableLock [] messages;
+	Object messageLock = new Object ();
+	Thread syncThread;
+	static final int GROW_SIZE = 4;
+	static final int MESSAGE_LIMIT = 64;
+
+	//TEMPORARY CODE
+	static final boolean IS_CARBON = "carbon".equals (SWT.getPlatform ());
+
+/**
+ * Constructs a new instance of this class.
+ * 
+ * @param display the display to create the synchronizer on
+ */
+public Synchronizer (Display display) {
+	this.display = display;
+}
+	
+void addLast (RunnableLock lock) {
+	boolean wake = false;
+	synchronized (messageLock) {
+		if (messages == null) messages = new RunnableLock [GROW_SIZE];
+		if (messageCount == messages.length) {
+			RunnableLock[] newMessages = new RunnableLock [messageCount + GROW_SIZE];
+			System.arraycopy (messages, 0, newMessages, 0, messageCount);
+			messages = newMessages;
+		}
+		messages [messageCount++] = lock;
+		wake = messageCount == 1;
+	}	
+	if (wake) display.wakeThread ();
+}
+
+/**
+ * Causes the <code>run()</code> method of the runnable to
+ * be invoked by the user-interface thread at the next 
+ * reasonable opportunity. The caller of this method continues 
+ * to run in parallel, and is not notified when the
+ * runnable has completed.
+ *
+ * @param runnable code to run on the user-interface thread.
+ *
+ * @see #syncExec
+ */
+protected void asyncExec (Runnable runnable) {
+	if (runnable == null) {
+		//TEMPORARY CODE
+		if (!IS_CARBON) {
+			display.wake ();
+			return;
+		}
+	}
+	addLast (new RunnableLock (runnable));
+}
+
+int getMessageCount () {
+	synchronized (messageLock) {
+		return messageCount;
+	}
+}
+
+void releaseSynchronizer () {
+	display = null;
+	messages = null;
+	messageLock = null;
+	syncThread = null;
+}
+
+RunnableLock removeFirst () {
+	synchronized (messageLock) {
+		if (messageCount == 0) return null;
+		RunnableLock lock = messages [0];
+		System.arraycopy (messages, 1, messages, 0, --messageCount);
+		messages [messageCount] = null;
+		if (messageCount == 0) {
+			if (messages.length > MESSAGE_LIMIT) messages = null;
+		}
+		return lock;
+	}
+}
+
+boolean runAsyncMessages () {
+	return runAsyncMessages (false);
+}
+
+boolean runAsyncMessages (boolean all) {
+	boolean run = false;
+	do {
+		RunnableLock lock = removeFirst ();
+		if (lock == null) return run;
+		run = true;
+		synchronized (lock) {
+			syncThread = lock.thread;
+			try {
+				lock.run ();
+			} catch (Throwable t) {
+				lock.throwable = t;
+				SWT.error (SWT.ERROR_FAILED_EXEC, t);
+			} finally {
+				syncThread = null;
+				lock.notifyAll ();
+			}
+		}
+	} while (all);
+	return run;
+}
+
+/**
+ * Causes the <code>run()</code> method of the runnable to
+ * be invoked by the user-interface thread at the next 
+ * reasonable opportunity. The thread which calls this method
+ * is suspended until the runnable completes.
+ *
+ * @param runnable code to run on the user-interface thread.
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_FAILED_EXEC - if an exception occurred when executing the runnable</li>
+ * </ul>
+ *
+ * @see #asyncExec
+ */
+protected void syncExec (Runnable runnable) {
+	RunnableLock lock = null;
+	synchronized (Device.class) {
+		if (display == null || display.isDisposed ()) SWT.error (SWT.ERROR_DEVICE_DISPOSED);
+		if (!display.isValidThread ()) {
+			if (runnable == null) {
+				display.wake ();
+				return;
+			}
+			lock = new RunnableLock (runnable);
+			/*
+			 * Only remember the syncThread for syncExec.
+			 */
+			lock.thread = Thread.currentThread();
+			addLast (lock);
+		}
+	}
+	if (lock == null) {
+		if (runnable != null) runnable.run ();
+		return;
+	}
+	synchronized (lock) {
+		boolean interrupted = false;
+		while (!lock.done ()) {
+			try {
+				lock.wait ();
+			} catch (InterruptedException e) {
+				interrupted = true;
+			}
+		}
+		if (interrupted) {
+			Compatibility.interrupt();
+		}
+		if (lock.throwable != null) {
+			SWT.error (SWT.ERROR_FAILED_EXEC, lock.throwable);
+		}
+	}
+}
+
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/TabFolder.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/TabFolder.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/TabFolder.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,730 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.widgets;
+
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.gtk.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.events.*;
+
+/**
+ * Instances of this class implement the notebook user interface
+ * metaphor.  It allows the user to select a notebook page from
+ * set of pages.
+ * <p>
+ * The item children that may be added to instances of this class
+ * must be of type <code>TabItem</code>.
+ * <code>Control</code> children are created and then set into a
+ * tab item using <code>TabItem#setControl</code>.
+ * </p><p>
+ * Note that although this class is a subclass of <code>Composite</code>,
+ * it does not make sense to set a layout on it.
+ * </p><p>
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>TOP, BOTTOM</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Selection</dd>
+ * </dl>
+ * <p>
+ * Note: Only one of the styles TOP and BOTTOM may be specified.
+ * </p><p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ *
+ * @see <a href="http://www.eclipse.org/swt/snippets/#tabfolder">TabFolder, TabItem snippets</a>
+ * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: ControlExample</a>
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public class TabFolder extends Composite {
+	TabItem [] items;
+	ImageList imageList;
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public TabFolder (Composite parent, int style) {
+	super (parent, checkStyle (style));
+}
+
+static int checkStyle (int style) {
+	style = checkBits (style, SWT.TOP, SWT.BOTTOM, 0, 0, 0, 0);
+	/*
+	* Even though it is legal to create this widget
+	* with scroll bars, they serve no useful purpose
+	* because they do not automatically scroll the
+	* widget's client area.  The fix is to clear
+	* the SWT style.
+	*/
+	return style & ~(SWT.H_SCROLL | SWT.V_SCROLL);
+}
+
+protected void checkSubclass () {
+	if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
+}
+
+int /*long*/ childStyle () {
+	int /*long*/ rcStyle = OS.gtk_widget_get_modifier_style (handle);
+	if ((OS.gtk_rc_style_get_color_flags (rcStyle, 0) & OS.GTK_RC_BG) != 0) return 0;
+	OS.gtk_widget_realize (handle);
+	return OS.gtk_widget_get_style (handle);
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the user changes the receiver's selection, by sending
+ * it one of the messages defined in the <code>SelectionListener</code>
+ * interface.
+ * <p>
+ * When <code>widgetSelected</code> is called, the item field of the event object is valid.
+ * <code>widgetDefaultSelected</code> is not called.
+ * </p>
+ *
+ * @param listener the listener which should be notified when the user changes the receiver's selection
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent
+ */
+public void addSelectionListener(SelectionListener listener) {
+	checkWidget ();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	TypedListener typedListener = new TypedListener(listener);
+	addListener(SWT.Selection,typedListener);
+	addListener(SWT.DefaultSelection,typedListener);
+}
+
+int /*long*/ clientHandle () {
+	int index = OS.gtk_notebook_get_current_page (handle);
+	if (index != -1 && items [index] != null) {
+		return items [index].pageHandle;
+	}
+	return handle;
+}
+
+public Point computeSize (int wHint, int hHint, boolean changed) {
+	checkWidget ();
+	Point size = super.computeSize (wHint, hHint, changed);
+	if (wHint != SWT.DEFAULT && wHint < 0) wHint = 0;
+	if (hHint != SWT.DEFAULT && hHint < 0) hHint = 0;
+	boolean scrollable = OS.gtk_notebook_get_scrollable (handle);
+	OS.gtk_notebook_set_scrollable (handle, false);
+	Point notebookSize = computeNativeSize (handle, wHint, hHint, changed);
+	OS.gtk_notebook_set_scrollable (handle, scrollable);
+	size.x = Math.max (notebookSize.x, size.x);
+	size.y = Math.max (notebookSize.y, size.y);
+	return size;
+}
+
+public Rectangle computeTrim (int x, int y, int width, int height) {
+	checkWidget();
+	forceResize ();
+	int /*long*/ clientHandle = clientHandle ();
+	int clientX = OS.GTK_WIDGET_X (clientHandle);
+	int clientY = OS.GTK_WIDGET_Y (clientHandle);
+	x -= clientX;
+	y -= clientY;
+	width +=  clientX + clientX;
+	if ((style & SWT.BOTTOM) != 0) {
+		int parentHeight = OS.GTK_WIDGET_HEIGHT (handle);
+		int clientHeight = OS.GTK_WIDGET_HEIGHT (clientHandle);
+		height += parentHeight - clientHeight;
+	} else {
+		height +=  clientX + clientY;
+	}
+	return new Rectangle (x, y, width, height);
+}
+
+void createHandle (int index) {
+	state |= HANDLE;
+	fixedHandle = OS.g_object_new (display.gtk_fixed_get_type (), 0);
+	if (fixedHandle == 0) error (SWT.ERROR_NO_HANDLES);
+	OS.gtk_fixed_set_has_window (fixedHandle, true);
+	handle = OS.gtk_notebook_new ();
+	if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+	OS.gtk_container_add (fixedHandle, handle);
+	OS.gtk_notebook_set_scrollable (handle, true);
+	OS.gtk_notebook_set_show_tabs (handle, true);
+	if ((style & SWT.BOTTOM) != 0) {
+		OS.gtk_notebook_set_tab_pos (handle, OS.GTK_POS_BOTTOM);
+	}
+}
+
+void createWidget (int index) {
+	super.createWidget(index);
+	items = new TabItem [4];
+}
+
+void createItem (TabItem item, int index) {
+	int /*long*/ list = OS.gtk_container_get_children (handle);
+	int itemCount = 0;
+	if (list != 0) {
+		itemCount = OS.g_list_length (list);
+		OS.g_list_free (list);
+	}
+	if (!(0 <= index && index <= itemCount)) error (SWT.ERROR_INVALID_RANGE);
+	if (itemCount == items.length) {
+		TabItem [] newItems = new TabItem [items.length + 4];
+		System.arraycopy (items, 0, newItems, 0, items.length);
+		items = newItems;
+	}
+	int /*long*/ boxHandle = OS.gtk_hbox_new (false, 0);
+	if (boxHandle == 0) error (SWT.ERROR_NO_HANDLES);
+	int /*long*/ labelHandle = OS.gtk_label_new_with_mnemonic (null);
+	if (labelHandle == 0) error (SWT.ERROR_NO_HANDLES);
+	int /*long*/ imageHandle = OS.gtk_image_new ();
+	if (imageHandle == 0) error (SWT.ERROR_NO_HANDLES);
+	OS.gtk_container_add (boxHandle, imageHandle);
+	OS.gtk_container_add (boxHandle, labelHandle);
+	int /*long*/ pageHandle = OS.g_object_new (display.gtk_fixed_get_type (), 0);
+	if (pageHandle == 0) error (SWT.ERROR_NO_HANDLES);
+	OS.g_signal_handlers_block_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, SWITCH_PAGE);
+	OS.gtk_notebook_insert_page (handle, pageHandle, boxHandle, index);
+	OS.g_signal_handlers_unblock_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, SWITCH_PAGE);
+	OS.gtk_widget_show (boxHandle);
+	OS.gtk_widget_show (labelHandle);
+	OS.gtk_widget_show (pageHandle);
+	item.state |= HANDLE;
+	item.handle = boxHandle;
+	item.labelHandle = labelHandle;
+	item.imageHandle = imageHandle;
+	item.pageHandle = pageHandle;
+	System.arraycopy (items, index, items, index + 1, itemCount++ - index);
+	items [index] = item;
+	if ((state & FOREGROUND) != 0) {
+		item.setForegroundColor (getForegroundColor());
+	}
+	if ((state & FONT) != 0) {
+		item.setFontDescription (getFontDescription());
+	}
+	if (itemCount == 1) {
+		OS.g_signal_handlers_block_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, SWITCH_PAGE);
+		OS.gtk_notebook_set_current_page (handle, 0);
+		OS.g_signal_handlers_unblock_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, SWITCH_PAGE);
+		Event event = new Event();
+		event.item = items[0];
+		sendEvent (SWT.Selection, event);
+		// the widget could be destroyed at this point
+	}
+}
+
+void destroyItem (TabItem item) {
+	int index = 0;
+	int itemCount = getItemCount();
+	while (index < itemCount) {
+		if (items [index] == item) break;
+		index++;
+	}
+	if (index == itemCount) error (SWT.ERROR_ITEM_NOT_REMOVED);
+	int oldIndex = OS.gtk_notebook_get_current_page (handle);
+	OS.g_signal_handlers_block_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, SWITCH_PAGE);
+	OS.gtk_notebook_remove_page (handle, index);
+	OS.g_signal_handlers_unblock_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, SWITCH_PAGE);
+	System.arraycopy (items, index + 1, items, index, --itemCount - index);
+	items [itemCount] = null;
+	if (index == oldIndex) {
+		int newIndex = OS.gtk_notebook_get_current_page (handle);
+		if (newIndex != -1) {
+			Control control = items [newIndex].getControl ();
+			if (control != null && !control.isDisposed ()) {
+				control.setBounds (getClientArea());
+				control.setVisible (true);
+			}
+			Event event = new Event ();
+			event.item = items [newIndex];
+			sendEvent (SWT.Selection, event);	
+			// the widget could be destroyed at this point
+		}
+	}
+}
+
+int /*long*/ eventHandle () {
+	return handle;
+}
+		
+/**
+ * Returns the item at the given, zero-relative index in the
+ * receiver. Throws an exception if the index is out of range.
+ *
+ * @param index the index of the item to return
+ * @return the item at the given index
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public TabItem getItem (int index) {
+	checkWidget();
+	if (!(0 <= index && index < getItemCount())) error (SWT.ERROR_INVALID_RANGE);	
+	int /*long*/ list = OS.gtk_container_get_children (handle);
+	if (list == 0) error (SWT.ERROR_CANNOT_GET_ITEM);
+	int itemCount = OS.g_list_length (list);
+	OS.g_list_free (list);
+	if (!(0 <= index && index < itemCount)) error (SWT.ERROR_CANNOT_GET_ITEM);
+	return items [index];
+}
+
+/**
+ * Returns the tab item at the given point in the receiver
+ * or null if no such item exists. The point is in the
+ * coordinate system of the receiver.
+ *
+ * @param point the point used to locate the item
+ * @return the tab item at the given point, or null if the point is not in a tab item
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the point is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.4
+ */
+public TabItem getItem(Point point) {
+	checkWidget();
+	if (point == null) error (SWT.ERROR_NULL_ARGUMENT);
+	int /*long*/ list = OS.gtk_container_get_children (handle);
+	if (list == 0) return null;
+	int itemCount = OS.g_list_length (list);
+	OS.g_list_free (list);
+	for (int i = 0; i < itemCount; i++) {
+		TabItem item = items[i];
+		Rectangle rect = item.getBounds();
+		if (rect.contains(point)) return item;
+	}
+	return null;
+}
+
+/**
+ * Returns the number of items contained in the receiver.
+ *
+ * @return the number of items
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getItemCount () {
+	checkWidget();
+	int /*long*/ list = OS.gtk_container_get_children (handle);
+	if (list == 0) return 0;
+	int itemCount = OS.g_list_length (list);
+	OS.g_list_free (list);
+	return itemCount;
+}
+
+/**
+ * Returns an array of <code>TabItem</code>s which are the items
+ * in the receiver. 
+ * <p>
+ * Note: This is not the actual structure used by the receiver
+ * to maintain its list of items, so modifying the array will
+ * not affect the receiver. 
+ * </p>
+ *
+ * @return the items in the receiver
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public TabItem [] getItems () {
+	checkWidget();
+	int count = getItemCount ();
+	TabItem [] result = new TabItem [count];
+	System.arraycopy (items, 0, result, 0, count);
+	return result;
+}
+
+/**
+ * Returns an array of <code>TabItem</code>s that are currently
+ * selected in the receiver. An empty array indicates that no
+ * items are selected.
+ * <p>
+ * Note: This is not the actual structure used by the receiver
+ * to maintain its selection, so modifying the array will
+ * not affect the receiver. 
+ * </p>
+ * @return an array representing the selection
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public TabItem [] getSelection () {
+	checkWidget();
+	int index = OS.gtk_notebook_get_current_page (handle);
+	if (index == -1) return new TabItem [0];
+	return new TabItem [] {items [index]};
+}
+
+/**
+ * Returns the zero-relative index of the item which is currently
+ * selected in the receiver, or -1 if no item is selected.
+ *
+ * @return the index of the selected item
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getSelectionIndex () {
+	checkWidget();
+	return OS.gtk_notebook_get_current_page (handle);
+}
+
+int /*long*/ gtk_focus (int /*long*/ widget, int /*long*/ directionType) {
+	return 0;
+}
+
+int /*long*/ gtk_switch_page (int /*long*/ widget, int /*long*/ page, int /*long*/ page_num) {
+	int index = OS.gtk_notebook_get_current_page (handle);
+	if (index != -1) {
+		Control control = items [index].getControl ();
+		if (control != null && !control.isDisposed ()) {
+			control.setVisible (false);
+		}
+	}
+	TabItem item = items [(int)/*64*/page_num];
+	Control control = item.getControl ();
+	if (control != null && !control.isDisposed ()) {
+		control.setBounds(getClientArea());
+		control.setVisible (true);
+	}
+	Event event = new Event();
+	event.item = item;
+	postEvent(SWT.Selection, event);
+	return 0;
+}
+
+void hookEvents () {
+	super.hookEvents ();
+	OS.g_signal_connect_closure (handle, OS.switch_page, display.closures [SWITCH_PAGE], false);
+}
+
+/**
+ * Searches the receiver's list starting at the first item
+ * (index 0) until an item is found that is equal to the 
+ * argument, and returns the index of that item. If no item
+ * is found, returns -1.
+ *
+ * @param item the search item
+ * @return the index of the item
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the item is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int indexOf (TabItem item) {
+	checkWidget();
+	if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
+	int /*long*/ list = OS.gtk_container_get_children (handle);
+	if (list == 0) return -1;
+	int count = OS.g_list_length (list);
+	OS.g_list_free (list);
+	for (int i=0; i<count; i++) {
+		if (items [i] == item) return i;
+	}
+	return -1;
+}
+
+Point minimumSize (int wHint, int hHint, boolean flushCache) {
+	Control [] children = _getChildren ();
+	int width = 0, height = 0;
+	for (int i=0; i<children.length; i++) {
+		Control child = children [i];
+		int index = 0;
+		int count = 0;
+		int /*long*/ list = OS.gtk_container_get_children (handle);
+		if (list != 0) {
+			count = OS.g_list_length (list);
+			OS.g_list_free (list);
+		}
+		while (index < count) {
+			if (items [index].control == child) break;
+			index++;
+		}
+		if (index == count) {
+			Rectangle rect = child.getBounds ();
+			width = Math.max (width, rect.x + rect.width);
+			height = Math.max (height, rect.y + rect.height);
+		} else {
+			Point size = child.computeSize (wHint, hHint, flushCache);
+			width = Math.max (width, size.x);
+			height = Math.max (height, size.y);
+		}
+	}
+	return new Point (width, height);
+}
+
+boolean mnemonicHit (char key) {
+	int itemCount = getItemCount ();
+	for (int i=0; i<itemCount; i++) {
+		int /*long*/ labelHandle = items [i].labelHandle;
+		if (labelHandle != 0 && mnemonicHit (labelHandle, key)) return true;
+	}
+	return false;
+}
+
+boolean mnemonicMatch (char key) {
+	int itemCount = getItemCount ();
+	for (int i=0; i<itemCount; i++) {
+		int /*long*/ labelHandle = items [i].labelHandle;
+		if (labelHandle != 0 && mnemonicHit (labelHandle, key)) return true;
+	}
+	return false;
+}
+
+void releaseChildren (boolean destroy) {
+	if (items != null) {
+		for (int i=0; i<items.length; i++) {
+			TabItem item = items [i];
+			if (item != null && !item.isDisposed ()) {
+				item.release (false);
+			}
+		}
+		items = null;
+	}
+	super.releaseChildren (destroy);
+}
+
+void releaseWidget () {
+	super.releaseWidget ();
+	if (imageList != null) imageList.dispose ();
+	imageList = null;
+}
+
+void removeControl (Control control) {
+	super.removeControl (control);
+	int count = getItemCount ();
+	for (int i=0; i<count; i++) {
+		TabItem item = items [i];
+		if (item.control == control) item.setControl (null);
+	}
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the user changes the receiver's selection.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #addSelectionListener
+ */
+public void removeSelectionListener (SelectionListener listener) {
+	checkWidget ();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if (eventTable == null) return;
+	eventTable.unhook (SWT.Selection, listener);
+	eventTable.unhook (SWT.DefaultSelection,listener);	
+}
+
+int setBounds (int x, int y, int width, int height, boolean move, boolean resize) {
+	int result = super.setBounds (x, y, width, height, move, resize);
+	if ((result & RESIZED) != 0) {
+		int index = getSelectionIndex ();
+		if (index != -1) {
+			TabItem item = items [index];
+			Control control = item.control;
+			if (control != null && !control.isDisposed ()) {
+				control.setBounds (getClientArea ());
+			}
+		}
+	}
+	return result;
+}
+
+void setFontDescription (int /*long*/ font) {
+	super.setFontDescription (font);
+	TabItem [] items = getItems ();
+	for (int i = 0; i < items.length; i++) {
+		if (items[i] != null) {
+			items[i].setFontDescription (font);
+		}
+	}
+}
+
+void setForegroundColor (GdkColor color) {
+	super.setForegroundColor (color);
+	TabItem [] items = getItems ();
+	for (int i = 0; i < items.length; i++) {
+		if (items[i] != null) {
+			items[i].setForegroundColor (color);
+		}
+	}
+}
+
+/**
+ * Selects the item at the given zero-relative index in the receiver. 
+ * If the item at the index was already selected, it remains selected.
+ * The current selection is first cleared, then the new items are
+ * selected. Indices that are out of range are ignored.
+ *
+ * @param index the index of the item to select
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setSelection (int index) {
+	checkWidget ();
+	if (!(0 <= index && index < getItemCount ())) return;
+	setSelection (index, false);
+}
+
+void setSelection (int index, boolean notify) {
+	if (index < 0) return;
+	int oldIndex = OS.gtk_notebook_get_current_page (handle);
+	if (oldIndex == index) return;
+	if (oldIndex != -1) {
+		TabItem item = items [oldIndex];
+		Control control = item.control;
+		if (control != null && !control.isDisposed ()) {
+			control.setVisible (false);
+		}
+	}
+	OS.g_signal_handlers_block_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, SWITCH_PAGE);
+	OS.gtk_notebook_set_current_page (handle, index);
+	OS.g_signal_handlers_unblock_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, SWITCH_PAGE);
+	int newIndex = OS.gtk_notebook_get_current_page (handle);
+	if (newIndex != -1) {
+		TabItem item = items [newIndex];
+		Control control = item.control;
+		if (control != null && !control.isDisposed ()) {
+			control.setBounds (getClientArea ());
+			control.setVisible (true);
+		}
+		if (notify) {
+			Event event = new Event ();
+			event.item = item;
+			sendEvent (SWT.Selection, event);
+		}
+	}
+}
+
+/**
+ * Sets the receiver's selection to the given item.
+ * The current selected is first cleared, then the new item is
+ * selected.
+ *
+ * @param item the item to select
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the item is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.2
+ */
+public void setSelection (TabItem item) {
+	if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
+	setSelection (new TabItem [] {item});
+}
+
+/**
+ * Sets the receiver's selection to be the given array of items.
+ * The current selected is first cleared, then the new items are
+ * selected.
+ *
+ * @param items the array of items
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the items array is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setSelection (TabItem [] items) {
+	checkWidget();
+	if (items == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if (items.length == 0) {
+		setSelection (-1, false);
+	} else {
+		for (int i=items.length-1; i>=0; --i) {
+			int index = indexOf (items [i]);
+			if (index != -1) setSelection (index, false);
+		}
+	}
+}
+
+boolean traversePage (final boolean next) {
+	if (next) {
+		OS.gtk_notebook_next_page (handle);
+	} else {
+		OS.gtk_notebook_prev_page (handle);
+	}
+	return true;
+}
+
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/TabItem.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/TabItem.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/TabItem.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,374 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.widgets;
+
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.gtk.*;
+import org.eclipse.swt.graphics.*;
+
+/**
+ * Instances of this class represent a selectable user interface object
+ * corresponding to a tab for a page in a tab folder.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>(none)</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>(none)</dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ *
+ * @see <a href="http://www.eclipse.org/swt/snippets/#tabfolder">TabFolder, TabItem snippets</a>
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public class TabItem extends Item {
+	int /*long*/ labelHandle, imageHandle, pageHandle;
+	Control control;
+	TabFolder parent;
+	String toolTipText;
+
+/**
+ * Constructs a new instance of this class given its parent
+ * (which must be a <code>TabFolder</code>) and a style value
+ * describing its behavior and appearance. The item is added
+ * to the end of the items maintained by its parent.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public TabItem (TabFolder parent, int style) {
+	super (parent, style);
+	this.parent = parent;
+	createWidget (parent.getItemCount ());
+}
+
+/**
+ * Constructs a new instance of this class given its parent
+ * (which must be a <code>TabFolder</code>), a style value
+ * describing its behavior and appearance, and the index
+ * at which to place it in the items maintained by its parent.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ * @param index the zero-relative index to store the receiver in its parent
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the parent (inclusive)</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public TabItem (TabFolder parent, int style, int index) {
+	super (parent, style);
+	this.parent = parent;
+	createWidget (index);
+}
+
+protected void checkSubclass () {
+	if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
+}
+
+void createWidget (int index) {
+	parent.createItem (this, index);
+	setOrientation ();
+	hookEvents ();
+	register ();
+	text = "";
+}
+
+void deregister() {
+	super.deregister ();
+	if (labelHandle != 0) display.removeWidget (labelHandle);
+}
+
+void destroyWidget () {
+	parent.destroyItem (this);
+	releaseHandle ();
+}
+
+/**
+ * Returns a rectangle describing the receiver's size and location
+ * relative to its parent.
+ *
+ * @return the receiver's bounding rectangle
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.4
+ */
+public Rectangle getBounds () {
+	checkWidget();
+	int x = OS.GTK_WIDGET_X (handle);
+	int y = OS.GTK_WIDGET_Y (handle);
+	int width = (state & ZERO_WIDTH) != 0 ? 0 : OS.GTK_WIDGET_WIDTH (handle);
+	int height = (state & ZERO_HEIGHT) != 0 ? 0 : OS.GTK_WIDGET_HEIGHT (handle);
+	if ((parent.style & SWT.MIRRORED) != 0) x = parent.getClientWidth () - width - x;
+	return new Rectangle (x, y, width, height);
+}
+
+/**
+ * Returns the control that is used to fill the client area of
+ * the tab folder when the user selects the tab item.  If no
+ * control has been set, return <code>null</code>.
+ * <p>
+ * @return the control
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Control getControl () {
+	checkWidget ();
+	return control;
+}
+
+/**
+ * Returns the receiver's parent, which must be a <code>TabFolder</code>.
+ *
+ * @return the receiver's parent
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public TabFolder getParent () {
+	checkWidget ();
+	return parent;
+}
+
+/**
+ * Returns the receiver's tool tip text, or null if it has
+ * not been set.
+ *
+ * @return the receiver's tool tip text
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public String getToolTipText () {
+	checkWidget ();
+	return toolTipText;
+}
+
+int /*long*/ gtk_enter_notify_event (int /*long*/ widget, int /*long*/ event) {
+	parent.gtk_enter_notify_event (widget, event);
+	return 0;
+}
+
+int /*long*/ gtk_mnemonic_activate (int /*long*/ widget, int /*long*/ arg1) {
+	return parent.gtk_mnemonic_activate (widget, arg1);
+}
+
+void hookEvents () {
+	super.hookEvents ();
+	if (labelHandle != 0) OS.g_signal_connect_closure_by_id (labelHandle, display.signalIds [MNEMONIC_ACTIVATE], 0, display.closures [MNEMONIC_ACTIVATE], false);
+	OS.g_signal_connect_closure_by_id (handle, display.signalIds [ENTER_NOTIFY_EVENT], 0, display.closures [ENTER_NOTIFY_EVENT], false);
+}
+
+void register () {
+	super.register ();
+	if (labelHandle != 0) display.addWidget (labelHandle, this);
+}
+
+void releaseHandle () {
+	super.releaseHandle ();
+	pageHandle = labelHandle = imageHandle = 0;
+	parent = null;
+}
+
+void releaseParent () {
+	super.releaseParent ();
+	int index = parent.indexOf (this);
+	if (index == parent.getSelectionIndex ()) {
+		if (control != null) control.setVisible (false);
+	}
+}
+
+/**
+ * Sets the control that is used to fill the client area of
+ * the tab folder when the user selects the tab item.
+ * <p>
+ * @param control the new control (or null)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the control has been disposed</li> 
+ *    <li>ERROR_INVALID_PARENT - if the control is not in the same widget tree</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setControl (Control control) {
+	checkWidget ();
+	if (control != null) {
+		if (control.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT);
+		if (control.parent != parent) error (SWT.ERROR_INVALID_PARENT);
+	}
+	Control oldControl = this.control, newControl = control;
+	this.control = control;
+	int index = parent.indexOf (this);
+	if (index != parent.getSelectionIndex ()) {
+		if (newControl != null) newControl.setVisible (false);
+		return;
+	}
+	if (newControl != null) {
+		newControl.setBounds (parent.getClientArea ());
+		newControl.setVisible (true);
+	}
+	if (oldControl != null) oldControl.setVisible (false);
+}
+
+void setFontDescription (int /*long*/ font) {
+	OS.gtk_widget_modify_font (labelHandle, font);
+	OS.gtk_widget_modify_font (imageHandle, font);
+}
+
+void setForegroundColor (GdkColor color) {
+	/* Don't set the color in vbox handle (it doesn't draw) */
+	setForegroundColor (labelHandle, color);
+	setForegroundColor (imageHandle, color);
+}
+
+public void setImage (Image image) {
+	checkWidget ();
+	super.setImage (image);
+	if (image != null) {
+		ImageList imageList = parent.imageList;
+		if (imageList == null) imageList = parent.imageList = new ImageList ();
+		int imageIndex = imageList.indexOf (image);
+		if (imageIndex == -1) {
+			imageIndex = imageList.add (image);
+		} else {
+			imageList.put (imageIndex, image);
+		}
+		int /*long*/ pixbuf = imageList.getPixbuf (imageIndex);
+		OS.gtk_image_set_from_pixbuf (imageHandle, pixbuf);
+		OS.gtk_widget_show (imageHandle);
+	} else {
+		OS.gtk_image_set_from_pixbuf (imageHandle, 0);
+		OS.gtk_widget_hide (imageHandle);
+	}
+}
+
+void setOrientation () {
+	if ((parent.style & SWT.RIGHT_TO_LEFT) != 0) {
+		if (handle != 0) OS.gtk_widget_set_direction (handle, OS.GTK_TEXT_DIR_RTL);
+		if (labelHandle != 0) OS.gtk_widget_set_direction (labelHandle, OS.GTK_TEXT_DIR_RTL);
+		if (imageHandle != 0) OS.gtk_widget_set_direction (imageHandle, OS.GTK_TEXT_DIR_RTL);
+		if (pageHandle != 0) OS.gtk_widget_set_direction (pageHandle, OS.GTK_TEXT_DIR_RTL);
+	}
+}
+
+/**
+ * Sets the receiver's text.  The string may include
+ * the mnemonic character.
+ * </p>
+ * <p>
+ * Mnemonics are indicated by an '&amp;' that causes the next
+ * character to be the mnemonic.  When the user presses a
+ * key sequence that matches the mnemonic, a selection
+ * event occurs. On most platforms, the mnemonic appears
+ * underlined but may be emphasised in a platform specific
+ * manner.  The mnemonic indicator character '&amp;' can be
+ * escaped by doubling it in the string, causing a single
+ * '&amp;' to be displayed.
+ * </p>
+ * 
+ * @param string the new text
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the text is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ */
+public void setText (String string) {
+	checkWidget ();
+	if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+	super.setText (string);
+	char [] chars = fixMnemonic (string);
+	byte [] buffer = Converter.wcsToMbcs (null, chars, true);
+	OS.gtk_label_set_text_with_mnemonic (labelHandle, buffer);
+	if (string.length () != 0) {
+		OS.gtk_widget_show (labelHandle);
+	} else {
+		OS.gtk_widget_hide (labelHandle);
+	}
+}
+
+/**
+ * Sets the receiver's tool tip text to the argument, which
+ * may be null indicating that no tool tip text should be shown.
+ *
+ * @param string the new tool tip text (or null)
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setToolTipText (String string) {
+	checkWidget ();
+	toolTipText = string;
+}
+
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Table.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Table.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Table.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,3458 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.widgets;
+
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.gtk.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.events.*;
+
+/** 
+ * Instances of this class implement a selectable user interface
+ * object that displays a list of images and strings and issues
+ * notification when selected.
+ * <p>
+ * The item children that may be added to instances of this class
+ * must be of type <code>TableItem</code>.
+ * </p><p>
+ * Style <code>VIRTUAL</code> is used to create a <code>Table</code> whose
+ * <code>TableItem</code>s are to be populated by the client on an on-demand basis
+ * instead of up-front.  This can provide significant performance improvements for
+ * tables that are very large or for which <code>TableItem</code> population is
+ * expensive (for example, retrieving values from an external source).
+ * </p><p>
+ * Here is an example of using a <code>Table</code> with style <code>VIRTUAL</code>:
+ * <code><pre>
+ *  final Table table = new Table (parent, SWT.VIRTUAL | SWT.BORDER);
+ *  table.setItemCount (1000000);
+ *  table.addListener (SWT.SetData, new Listener () {
+ *      public void handleEvent (Event event) {
+ *          TableItem item = (TableItem) event.item;
+ *          int index = table.indexOf (item);
+ *          item.setText ("Item " + index);
+ *          System.out.println (item.getText ());
+ *      }
+ *  }); 
+ * </pre></code>
+ * </p><p>
+ * Note that although this class is a subclass of <code>Composite</code>,
+ * it does not normally make sense to add <code>Control</code> children to
+ * it, or set a layout on it, unless implementing something like a cell
+ * editor.
+ * </p><p>
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>SINGLE, MULTI, CHECK, FULL_SELECTION, HIDE_SELECTION, VIRTUAL, NO_SCROLL</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Selection, DefaultSelection, SetData, MeasureItem, EraseItem, PaintItem</dd>
+ * </dl>
+ * </p><p>
+ * Note: Only one of the styles SINGLE, and MULTI may be specified.
+ * </p><p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ *
+ * @see <a href="http://www.eclipse.org/swt/snippets/#table">Table, TableItem, TableColumn snippets</a>
+ * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: ControlExample</a>
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public class Table extends Composite {
+	int /*long*/ modelHandle, checkRenderer;
+	int itemCount, columnCount, lastIndexOf, sortDirection;
+	int /*long*/ ignoreCell;
+	TableItem [] items;
+	TableColumn [] columns;
+	TableItem currentItem;
+	TableColumn sortColumn;
+	ImageList imageList, headerImageList;
+	boolean firstCustomDraw;
+	int drawState, drawFlags;
+	GdkColor drawForeground;
+	boolean ownerDraw, ignoreSize;
+	
+	static final int CHECKED_COLUMN = 0;
+	static final int GRAYED_COLUMN = 1;
+	static final int FOREGROUND_COLUMN = 2;
+	static final int BACKGROUND_COLUMN = 3;
+	static final int FONT_COLUMN = 4;
+	static final int FIRST_COLUMN = FONT_COLUMN + 1;
+	static final int CELL_PIXBUF = 0;
+	static final int CELL_TEXT = 1;
+	static final int CELL_FOREGROUND = 2;
+	static final int CELL_BACKGROUND = 3;
+	static final int CELL_FONT = 4;
+	static final int CELL_TYPES = CELL_FONT + 1;
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT#SINGLE
+ * @see SWT#MULTI
+ * @see SWT#CHECK
+ * @see SWT#FULL_SELECTION
+ * @see SWT#HIDE_SELECTION
+ * @see SWT#VIRTUAL
+ * @see SWT#NO_SCROLL
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public Table (Composite parent, int style) {
+	super (parent, checkStyle (style));
+}
+
+void _addListener (int eventType, Listener listener) {
+	super._addListener (eventType, listener);
+	if (!ownerDraw) {
+		switch (eventType) {
+			case SWT.MeasureItem:
+			case SWT.EraseItem:
+			case SWT.PaintItem:
+				ownerDraw = true;
+				recreateRenderers ();
+				break;
+		}
+	}
+}
+
+TableItem _getItem (int index) {
+	if ((style & SWT.VIRTUAL) == 0) return items [index];
+	if (items [index] != null) return items [index];
+	return items [index] = new TableItem (this, SWT.NONE, index, false);
+}
+
+static int checkStyle (int style) {
+	/*
+	* Feature in Windows.  Even when WS_HSCROLL or
+	* WS_VSCROLL is not specified, Windows creates
+	* trees and tables with scroll bars.  The fix
+	* is to set H_SCROLL and V_SCROLL.
+	* 
+	* NOTE: This code appears on all platforms so that
+	* applications have consistent scroll bar behavior.
+	*/
+	if ((style & SWT.NO_SCROLL) == 0) {
+		style |= SWT.H_SCROLL | SWT.V_SCROLL;
+	}
+	/* GTK is always FULL_SELECTION */
+	style |= SWT.FULL_SELECTION;
+	return checkBits (style, SWT.SINGLE, SWT.MULTI, 0, 0, 0, 0);
+}
+
+int /*long*/ cellDataProc (int /*long*/ tree_column, int /*long*/ cell, int /*long*/ tree_model, int /*long*/ iter, int /*long*/ data) {
+	if (cell == ignoreCell) return 0;
+	int /*long*/ path = OS.gtk_tree_model_get_path (tree_model, iter);
+	int [] index = new int [1];
+	OS.memmove (index, OS.gtk_tree_path_get_indices (path), 4);
+	TableItem item = _getItem (index[0]);
+	OS.gtk_tree_path_free (path);
+	if (item != null) OS.g_object_set_qdata (cell, Display.SWT_OBJECT_INDEX2, item.handle);
+	boolean isPixbuf = OS.GTK_IS_CELL_RENDERER_PIXBUF (cell);
+	if (!(isPixbuf || OS.GTK_IS_CELL_RENDERER_TEXT (cell))) return 0;
+	int modelIndex = -1;
+	boolean customDraw = false;
+	if (columnCount == 0) {
+		modelIndex = Table.FIRST_COLUMN;
+		customDraw = firstCustomDraw;
+	} else {
+		TableColumn column = (TableColumn) display.getWidget (tree_column);
+		if (column != null) {
+			modelIndex = column.modelIndex;
+			customDraw = column.customDraw;
+		}
+	}
+	if (modelIndex == -1) return 0;
+	boolean setData = false;
+	if ((style & SWT.VIRTUAL) != 0) {
+		/*
+		* Feature in GTK.  On GTK before 2.4, fixed_height_mode is not
+		* supported, and the tree asks for the data of all items.  The
+		* fix is to only provide the data if the row is visible.
+		*/
+		if (OS.GTK_VERSION < OS.VERSION (2, 3, 2)) {
+			OS.gtk_widget_realize (handle);
+			GdkRectangle visible = new GdkRectangle ();
+			OS.gtk_tree_view_get_visible_rect (handle, visible);
+			GdkRectangle area = new GdkRectangle ();
+			path = OS.gtk_tree_model_get_path (tree_model, iter);
+			OS.gtk_tree_view_get_cell_area (handle, path, tree_column, area);
+			OS.gtk_tree_path_free (path);
+			if (area.y + area.height < 0 || area.y + visible.y > visible.y + visible.height) {
+				/* Give an image from the image list to make sure the row has
+				* the correct height.
+				*/
+				if (imageList != null && imageList.pixbufs.length > 0) {
+					if (isPixbuf) OS.g_object_set (cell, OS.pixbuf, imageList.pixbufs [0], 0);
+				}
+				return 0;
+			}
+		}
+		if (!item.cached) {
+			lastIndexOf = index[0];
+			setData = checkData (item);
+		}
+	}
+	int /*long*/ [] ptr = new int /*long*/ [1];
+	if (setData) {
+		ptr [0] = 0;
+		if (isPixbuf) {
+			OS.gtk_tree_model_get (tree_model, iter, modelIndex + CELL_PIXBUF, ptr, -1);
+			OS.g_object_set (cell, OS.pixbuf, ptr [0], 0);
+		} else {
+			OS.gtk_tree_model_get (tree_model, iter, modelIndex + CELL_TEXT, ptr, -1); 
+			if (ptr [0] != 0) {
+				OS.g_object_set (cell, OS.text, ptr [0], 0);
+				OS.g_free (ptr [0]);
+			}
+		}
+	}
+	if (customDraw) {
+		/*
+		* Bug on GTK. Gtk renders the background on top of the checkbox and pixbuf.
+		* This only happens in version 2.2.1 and earlier. The fix is not to set the background.   
+		*/
+		if (OS.GTK_VERSION > OS.VERSION (2, 2, 1)) {
+			if (!ownerDraw) {
+				ptr [0] = 0;
+				OS.gtk_tree_model_get (tree_model, iter, modelIndex + CELL_BACKGROUND, ptr, -1);
+				if (ptr [0] != 0) {
+					OS.g_object_set (cell, OS.cell_background_gdk, ptr [0], 0);
+				}
+			}
+		}
+		if (!isPixbuf) {
+			ptr [0] = 0;
+			OS.gtk_tree_model_get (tree_model, iter, modelIndex + CELL_FOREGROUND, ptr, -1);
+			if (ptr [0] != 0) {
+				OS.g_object_set (cell, OS.foreground_gdk, ptr [0], 0);
+			}
+			ptr [0] = 0;
+			OS.gtk_tree_model_get (tree_model, iter, modelIndex + CELL_FONT, ptr, -1);
+			if (ptr [0] != 0) {
+				OS.g_object_set (cell, OS.font_desc, ptr [0], 0);
+			}
+		}
+	}
+	if (setData) {
+		ignoreCell = cell;
+		setScrollWidth (tree_column, item);
+		ignoreCell = 0;
+	}
+	return 0;
+}
+
+boolean checkData (TableItem item) {
+	if (item.cached) return true;
+	if ((style & SWT.VIRTUAL) != 0) {
+		item.cached = true;
+		Event event = new Event ();
+		event.item = item;
+		event.index = indexOf (item);
+		int mask = OS.G_SIGNAL_MATCH_DATA | OS.G_SIGNAL_MATCH_ID;
+		int signal_id = OS.g_signal_lookup (OS.row_changed, OS.gtk_tree_model_get_type ());
+		OS.g_signal_handlers_block_matched (modelHandle, mask, signal_id, 0, 0, 0, handle);
+		currentItem = item;
+		sendEvent (SWT.SetData, event);
+		//widget could be disposed at this point
+		currentItem = null;
+		if (isDisposed ()) return false;
+		OS.g_signal_handlers_unblock_matched (modelHandle, mask, signal_id, 0, 0, 0, handle);
+		if (item.isDisposed ()) return false;
+	}
+	return true;
+}
+
+protected void checkSubclass () {
+	if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the user changes the receiver's selection, by sending
+ * it one of the messages defined in the <code>SelectionListener</code>
+ * interface.
+ * <p>
+ * When <code>widgetSelected</code> is called, the item field of the event object is valid.
+ * If the receiver has the <code>SWT.CHECK</code> style and the check selection changes,
+ * the event object detail field contains the value <code>SWT.CHECK</code>.
+ * <code>widgetDefaultSelected</code> is typically called when an item is double-clicked.
+ * The item field of the event object is valid for default selection, but the detail field is not used.
+ * </p>
+ *
+ * @param listener the listener which should be notified when the user changes the receiver's selection
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent
+ */
+public void addSelectionListener (SelectionListener listener) {
+	checkWidget ();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	TypedListener typedListener = new TypedListener (listener);
+	addListener (SWT.Selection, typedListener);
+	addListener (SWT.DefaultSelection, typedListener);
+}
+
+int calculateWidth (int /*long*/ column, int /*long*/ iter) {
+	OS.gtk_tree_view_column_cell_set_cell_data (column, modelHandle, iter, false, false);
+	/*
+	* Bug in GTK.  The width calculated by gtk_tree_view_column_cell_get_size()
+	* always grows in size regardless of the text or images in the table.
+	* The fix is to determine the column width from the cell renderers.
+	*/
+	// Code intentionally commented
+	//int [] width = new int [1];
+	//OS.gtk_tree_view_column_cell_get_size (column, null, null, null, width, null);
+	//return width [0];
+	
+	int width = 0;
+	int [] w = new int [1];
+	OS.gtk_widget_style_get(handle, OS.focus_line_width, w, 0);
+	width += 2 * w [0];
+	int /*long*/ list = OS.gtk_tree_view_column_get_cell_renderers (column);
+	if (list == 0) return 0;
+	int /*long*/ temp = list;
+	while (temp != 0) {
+		int /*long*/ renderer = OS.g_list_data (temp);
+		if (renderer != 0) {
+			OS.gtk_cell_renderer_get_size (renderer, handle, null, null, null, w, null);
+			width += w [0];
+		}
+		temp = OS.g_list_next (temp);
+	}
+	OS.g_list_free (list);
+	return width;
+}
+
+/**
+ * Clears the item at the given zero-relative index in the receiver.
+ * The text, icon and other attributes of the item are set to the default
+ * value.  If the table was created with the <code>SWT.VIRTUAL</code> style,
+ * these attributes are requested again as needed.
+ *
+ * @param index the index of the item to clear
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see SWT#VIRTUAL
+ * @see SWT#SetData
+ * 
+ * @since 3.0
+ */
+public void clear (int index) {
+	checkWidget ();
+	if (!(0 <= index && index < itemCount)) {
+		error(SWT.ERROR_INVALID_RANGE);
+	}
+	TableItem item = items [index];
+	if (item != null) item.clear ();
+}
+
+/**
+ * Removes the items from the receiver which are between the given
+ * zero-relative start and end indices (inclusive).  The text, icon
+ * and other attributes of the items are set to their default values.
+ * If the table was created with the <code>SWT.VIRTUAL</code> style,
+ * these attributes are requested again as needed.
+ *
+ * @param start the start index of the item to clear
+ * @param end the end index of the item to clear
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_RANGE - if either the start or end are not between 0 and the number of elements in the list minus 1 (inclusive)</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see SWT#VIRTUAL
+ * @see SWT#SetData
+ * 
+ * @since 3.0
+ */
+public void clear (int start, int end) {
+	checkWidget ();
+	if (start > end) return;
+	if (!(0 <= start && start <= end && end < itemCount)) {
+		error (SWT.ERROR_INVALID_RANGE);
+	}
+	if (start == 0 && end == itemCount - 1) {
+		clearAll();
+	} else {
+		for (int i=start; i<=end; i++) {
+			TableItem item = items [i];
+			if (item != null) item.clear();
+		}
+	}
+}
+
+/**
+ * Clears the items at the given zero-relative indices in the receiver.
+ * The text, icon and other attributes of the items are set to their default
+ * values.  If the table was created with the <code>SWT.VIRTUAL</code> style,
+ * these attributes are requested again as needed.
+ *
+ * @param indices the array of indices of the items
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
+ *    <li>ERROR_NULL_ARGUMENT - if the indices array is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see SWT#VIRTUAL
+ * @see SWT#SetData
+ * 
+ * @since 3.0
+ */
+public void clear (int [] indices) {
+	checkWidget ();
+	if (indices == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if (indices.length == 0) return;
+	for (int i=0; i<indices.length; i++) {
+		if (!(0 <= indices [i] && indices [i] < itemCount)) {
+			error (SWT.ERROR_INVALID_RANGE);
+		}
+	}
+	for (int i=0; i<indices.length; i++) {
+		TableItem item = items [indices [i]];
+		if (item != null) item.clear();
+	}
+}
+
+/**
+ * Clears all the items in the receiver. The text, icon and other
+ * attributes of the items are set to their default values. If the
+ * table was created with the <code>SWT.VIRTUAL</code> style, these
+ * attributes are requested again as needed.
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see SWT#VIRTUAL
+ * @see SWT#SetData
+ * 
+ * @since 3.0
+ */
+public void clearAll () {
+	checkWidget ();
+	for (int i=0; i<itemCount; i++) {
+		TableItem item = items [i];
+		if (item != null) item.clear();
+	}
+}
+
+public Point computeSize (int wHint, int hHint, boolean changed) {
+	checkWidget ();
+	if (wHint != SWT.DEFAULT && wHint < 0) wHint = 0;
+	if (hHint != SWT.DEFAULT && hHint < 0) hHint = 0;
+	Point size = computeNativeSize (handle, wHint, hHint, changed);
+	Rectangle trim = computeTrim (0, 0, size.x, size.y);
+	size.x = trim.width;
+	size.y = trim.height;
+	return size;
+}
+
+void createColumn (TableColumn column, int index) {
+	int modelIndex = FIRST_COLUMN;
+	if (columnCount != 0) {
+		int modelLength = OS.gtk_tree_model_get_n_columns (modelHandle);
+		boolean [] usedColumns = new boolean [modelLength];
+		for (int i=0; i<columnCount; i++) {
+			int columnIndex = columns [i].modelIndex;
+			for (int j = 0; j < CELL_TYPES; j++) {
+				usedColumns [columnIndex + j] = true;
+			}
+		}
+		while (modelIndex < modelLength) {
+			if (!usedColumns [modelIndex]) break;
+			modelIndex++;
+		}
+		if (modelIndex == modelLength) {
+			int /*long*/ oldModel = modelHandle;
+			int /*long*/[] types = getColumnTypes (columnCount + 4); // grow by 4 rows at a time
+			int /*long*/ newModel = OS.gtk_list_store_newv (types.length, types);
+			if (newModel == 0) error (SWT.ERROR_NO_HANDLES);
+			int /*long*/ [] ptr = new int /*long*/ [1];
+			for (int i=0; i<itemCount; i++) {
+				int /*long*/ newItem = OS.g_malloc (OS.GtkTreeIter_sizeof ());
+				if (newItem == 0) error (SWT.ERROR_NO_HANDLES);
+				OS.gtk_list_store_append (newModel, newItem);
+				TableItem item = items [i];
+				if (item != null) {
+					int /*long*/ oldItem = item.handle;
+					for (int j=0; j<modelLength; j++) {
+						OS.gtk_tree_model_get (oldModel, oldItem, j, ptr, -1);
+						OS.gtk_list_store_set (newModel, newItem, j, ptr [0], -1);
+						if (types [j] == OS.G_TYPE_STRING ()) OS.g_free ((ptr [0]));
+					}
+					OS.gtk_list_store_remove (oldModel, oldItem);
+					OS.g_free (oldItem);
+					item.handle = newItem;
+				} else {
+					OS.g_free (newItem);
+				}
+			}
+			OS.gtk_tree_view_set_model (handle, newModel);
+			OS.g_object_unref (oldModel);
+			modelHandle = newModel;
+		}
+	}
+	int /*long*/ columnHandle = OS.gtk_tree_view_column_new ();
+	if (columnHandle == 0) error (SWT.ERROR_NO_HANDLES);
+	if (index == 0 && columnCount > 0) {
+		TableColumn checkColumn = columns [0];
+		createRenderers (checkColumn.handle, checkColumn.modelIndex, false, checkColumn.style);
+	}
+	createRenderers (columnHandle, modelIndex, index == 0, column == null ? 0 : column.style);
+	/*
+	* Use GTK_TREE_VIEW_COLUMN_GROW_ONLY on GTK versions < 2.3.2
+	* because fixed_height_mode is not supported.
+	*/
+	boolean useVirtual = (style & SWT.VIRTUAL) != 0 && OS.GTK_VERSION >= OS.VERSION (2, 3, 2);
+	if (!useVirtual && columnCount == 0) {
+		OS.gtk_tree_view_column_set_sizing (columnHandle, OS.GTK_TREE_VIEW_COLUMN_GROW_ONLY);
+	} else {
+		OS.gtk_tree_view_column_set_sizing (columnHandle, OS.GTK_TREE_VIEW_COLUMN_FIXED);
+		if (columnCount != 0) OS.gtk_tree_view_column_set_visible (columnHandle, false);
+	}
+	OS.gtk_tree_view_column_set_resizable (columnHandle, true);
+	OS.gtk_tree_view_column_set_clickable (columnHandle, true);
+	OS.gtk_tree_view_column_set_min_width (columnHandle, 0);
+	OS.gtk_tree_view_insert_column (handle, columnHandle, index);
+	if (column != null) {
+		column.handle = columnHandle;
+		column.modelIndex = modelIndex;
+	}
+	/* Disable searching when using VIRTUAL */
+	if ((style & SWT.VIRTUAL) != 0) {
+		/*
+		* Bug in GTK. Until GTK 2.6.5, calling gtk_tree_view_set_enable_search(FALSE)
+		* would prevent the user from being able to type in text to search the tree.
+		* After 2.6.5, GTK introduced Ctrl+F as being the key binding for interactive
+		* search. This meant that even if FALSE was passed to enable_search, the user
+		* can still bring up the search pop up using the keybinding. GTK also introduced
+		* the notion of passing a -1 to gtk_set_search_column to disable searching
+		* (including the search key binding).  The fix is to use the right calls
+		* for the right version.
+		*/
+		if (OS.GTK_VERSION >= OS.VERSION (2, 6, 5)) {
+			OS.gtk_tree_view_set_search_column (handle, -1); 
+		} else {
+			OS.gtk_tree_view_set_enable_search (handle, false);
+		}
+	} else {
+		/* Set the search column whenever the model changes */
+		int firstColumn = columnCount == 0 ? FIRST_COLUMN : columns [0].modelIndex;
+		OS.gtk_tree_view_set_search_column (handle, firstColumn + CELL_TEXT);
+	}
+}
+
+void createHandle (int index) {
+	state |= HANDLE;
+	fixedHandle = OS.g_object_new (display.gtk_fixed_get_type (), 0);
+	if (fixedHandle == 0) error (SWT.ERROR_NO_HANDLES);
+	OS.gtk_fixed_set_has_window (fixedHandle, true);
+	scrolledHandle = OS.gtk_scrolled_window_new (0, 0);
+	if (scrolledHandle == 0) error (SWT.ERROR_NO_HANDLES);
+	int /*long*/ [] types = getColumnTypes (1);
+	modelHandle = OS.gtk_list_store_newv (types.length, types);
+	if (modelHandle == 0) error (SWT.ERROR_NO_HANDLES);
+	handle = OS.gtk_tree_view_new_with_model (modelHandle);
+	if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+	if ((style & SWT.CHECK) != 0) {
+		checkRenderer = OS.gtk_cell_renderer_toggle_new ();
+		if (checkRenderer == 0) error (SWT.ERROR_NO_HANDLES);
+		OS.g_object_ref (checkRenderer);
+	}
+	createColumn (null, 0);
+	OS.gtk_container_add (fixedHandle, scrolledHandle);
+	OS.gtk_container_add (scrolledHandle, handle);
+	
+	int mode = (style & SWT.MULTI) != 0 ? OS.GTK_SELECTION_MULTIPLE : OS.GTK_SELECTION_BROWSE;
+	int /*long*/ selectionHandle = OS.gtk_tree_view_get_selection (handle);
+	OS.gtk_tree_selection_set_mode (selectionHandle, mode);
+	OS.gtk_tree_view_set_headers_visible (handle, false);	
+	int hsp = (style & SWT.H_SCROLL) != 0 ? OS.GTK_POLICY_AUTOMATIC : OS.GTK_POLICY_NEVER;
+	int vsp = (style & SWT.V_SCROLL) != 0 ? OS.GTK_POLICY_AUTOMATIC : OS.GTK_POLICY_NEVER;
+	OS.gtk_scrolled_window_set_policy (scrolledHandle, hsp, vsp);
+	if ((style & SWT.BORDER) != 0) OS.gtk_scrolled_window_set_shadow_type (scrolledHandle, OS.GTK_SHADOW_ETCHED_IN);
+	/* Disable searching when using VIRTUAL */
+	if ((style & SWT.VIRTUAL) != 0) {
+		/* The fixed_height_mode property only exists in GTK 2.3.2 and greater */
+		if (OS.GTK_VERSION >= OS.VERSION (2, 3, 2)) {
+			OS.g_object_set (handle, OS.fixed_height_mode, true, 0);
+		}
+		/*
+		* Bug in GTK. Until GTK 2.6.5, calling gtk_tree_view_set_enable_search(FALSE)
+		* would prevent the user from being able to type in text to search the tree.
+		* After 2.6.5, GTK introduced Ctrl+F as being the key binding for interactive
+		* search. This meant that even if FALSE was passed to enable_search, the user
+		* can still bring up the search pop up using the keybinding. GTK also introduced
+		* the notion of passing a -1 to gtk_set_search_column to disable searching
+		* (including the search key binding).  The fix is to use the right calls
+		* for the right version.
+		*/
+		if (OS.GTK_VERSION >= OS.VERSION (2, 6, 5)) {
+			OS.gtk_tree_view_set_search_column (handle, -1); 
+		} else {
+			OS.gtk_tree_view_set_enable_search (handle, false);
+		}
+	}
+}
+
+void createItem (TableColumn column, int index) {
+	if (!(0 <= index && index <= columnCount)) error (SWT.ERROR_INVALID_RANGE);
+	if (columnCount == 0) {
+		column.handle = OS.gtk_tree_view_get_column (handle, 0);
+		OS.gtk_tree_view_column_set_sizing (column.handle, OS.GTK_TREE_VIEW_COLUMN_FIXED);
+		OS.gtk_tree_view_column_set_visible (column.handle, false);
+		column.modelIndex = FIRST_COLUMN;
+		createRenderers (column.handle, column.modelIndex, true, column.style);
+		column.customDraw = firstCustomDraw;
+		firstCustomDraw = false;
+	} else {
+		createColumn (column, index);
+	}
+	int /*long*/ boxHandle = OS.gtk_hbox_new (false, 3);
+	if (boxHandle == 0) error (SWT.ERROR_NO_HANDLES);
+	int /*long*/ labelHandle = OS.gtk_label_new_with_mnemonic (null);
+	if (labelHandle == 0) error (SWT.ERROR_NO_HANDLES);
+	int /*long*/ imageHandle = OS.gtk_image_new ();
+	if (imageHandle == 0) error (SWT.ERROR_NO_HANDLES);
+	OS.gtk_container_add (boxHandle, imageHandle);
+	OS.gtk_container_add (boxHandle, labelHandle);
+	OS.gtk_widget_show (boxHandle);
+	OS.gtk_widget_show (labelHandle);
+	column.labelHandle = labelHandle;
+	column.imageHandle = imageHandle;	
+	OS.gtk_tree_view_column_set_widget (column.handle, boxHandle);
+	int /*long*/ widget = OS.gtk_widget_get_parent (boxHandle);
+	while (widget != handle) {
+		if (OS.GTK_IS_BUTTON (widget)) {
+			column.buttonHandle = widget;
+			break;
+		}
+		widget = OS.gtk_widget_get_parent (widget);
+	}
+	if (columnCount == columns.length) {
+		TableColumn [] newColumns = new TableColumn [columns.length + 4];
+		System.arraycopy (columns, 0, newColumns, 0, columns.length);
+		columns = newColumns;
+	}
+	System.arraycopy (columns, index, columns, index + 1, columnCount++ - index);
+	columns [index] = column;
+	if ((state & FONT) != 0) {
+		column.setFontDescription (getFontDescription ());
+	}
+	if (columnCount >= 1) {
+		for (int i=0; i<itemCount; i++) {
+			TableItem item = items [i];
+			if (item != null) {
+				Font [] cellFont = item.cellFont;
+				if (cellFont != null) {
+					Font [] temp = new Font [columnCount];
+					System.arraycopy (cellFont, 0, temp, 0, index);
+					System.arraycopy (cellFont, index, temp, index+1, columnCount-index-1);
+					item.cellFont = temp;
+				}
+			}
+		}
+	}
+}
+
+void createItem (TableItem item, int index) {
+	if (!(0 <= index && index <= itemCount)) error (SWT.ERROR_INVALID_RANGE);
+	if (itemCount == items.length) {
+		int length = drawCount == 0 ? items.length + 4 : Math.max (4, items.length * 3 / 2);
+		TableItem [] newItems = new TableItem [length];	
+		System.arraycopy (items, 0, newItems, 0, items.length);
+		items = newItems;
+	}
+	item.handle = OS.g_malloc (OS.GtkTreeIter_sizeof ());
+	if (item.handle == 0) error (SWT.ERROR_NO_HANDLES);
+	/*
+	* Feature in GTK.  It is much faster to append to a list store
+	* than to insert at the end using gtk_list_store_insert(). 
+	*/
+	if (index == itemCount) {
+		OS.gtk_list_store_append (modelHandle, item.handle);
+	} else {
+		OS.gtk_list_store_insert (modelHandle, item.handle, index);
+	}
+	System.arraycopy (items, index, items, index + 1, itemCount++ - index);
+	items [index] = item;
+}
+
+void createRenderers (int /*long*/ columnHandle, int modelIndex, boolean check, int columnStyle) {
+	OS.gtk_tree_view_column_clear (columnHandle);
+	if ((style & SWT.CHECK) != 0 && check) {
+		OS.gtk_tree_view_column_pack_start (columnHandle, checkRenderer, false);
+		OS.gtk_tree_view_column_add_attribute (columnHandle, checkRenderer, OS.active, CHECKED_COLUMN);
+		/*
+		* Feature in GTK. The inconsistent property only exists in GTK 2.2.x.
+		*/
+		if (OS.GTK_VERSION >= OS.VERSION (2, 2, 0)) {
+			OS.gtk_tree_view_column_add_attribute (columnHandle, checkRenderer, OS.inconsistent, GRAYED_COLUMN);
+		}
+		/*
+		* Bug in GTK. GTK renders the background on top of the checkbox.
+		* This only happens in version 2.2.1 and earlier. The fix is not to set the background.   
+		*/
+		if (OS.GTK_VERSION > OS.VERSION (2, 2, 1)) {
+			if (!ownerDraw) OS.gtk_tree_view_column_add_attribute (columnHandle, checkRenderer, OS.cell_background_gdk, BACKGROUND_COLUMN);
+		}
+		if (ownerDraw) {
+			OS.gtk_tree_view_column_set_cell_data_func (columnHandle, checkRenderer, display.cellDataProc, handle, 0);
+			OS.g_object_set_qdata (checkRenderer, Display.SWT_OBJECT_INDEX1, columnHandle);
+		}
+	}
+	int /*long*/ pixbufRenderer = ownerDraw ? OS.g_object_new (display.gtk_cell_renderer_pixbuf_get_type (), 0) : OS.gtk_cell_renderer_pixbuf_new ();
+	if (pixbufRenderer == 0) error (SWT.ERROR_NO_HANDLES);
+	int /*long*/ textRenderer = ownerDraw ? OS.g_object_new (display.gtk_cell_renderer_text_get_type (), 0) : OS.gtk_cell_renderer_text_new ();
+	if (textRenderer == 0) error (SWT.ERROR_NO_HANDLES);
+	
+	if (ownerDraw) {
+		OS.g_object_set_qdata (pixbufRenderer, Display.SWT_OBJECT_INDEX1, columnHandle);
+		OS.g_object_set_qdata (textRenderer, Display.SWT_OBJECT_INDEX1, columnHandle);
+	}
+
+	/*
+	* Feature in GTK.  When a tree view column contains only one activatable
+	* cell renderer such as a toggle renderer, mouse clicks anywhere in a cell
+	* activate that renderer. The workaround is to set a second cell renderer
+	* to be activatable.
+	*/
+	if ((style & SWT.CHECK) != 0 && check) {
+		OS.g_object_set (pixbufRenderer, OS.mode, OS.GTK_CELL_RENDERER_MODE_ACTIVATABLE, 0);
+	}
+
+	/* Set alignment */
+	if ((columnStyle & SWT.RIGHT) != 0) {
+		OS.g_object_set(textRenderer, OS.xalign, 1f, 0);
+		OS.gtk_tree_view_column_pack_end (columnHandle, textRenderer, true);
+		OS.gtk_tree_view_column_pack_end (columnHandle, pixbufRenderer, false);
+		OS.gtk_tree_view_column_set_alignment (columnHandle, 1f);
+	} else if ((columnStyle & SWT.CENTER) != 0) {
+		OS.g_object_set(textRenderer, OS.xalign, 0.5f, 0);
+		OS.gtk_tree_view_column_pack_start (columnHandle, pixbufRenderer, false);
+		OS.gtk_tree_view_column_pack_end (columnHandle, textRenderer, true);
+		OS.gtk_tree_view_column_set_alignment (columnHandle, 0.5f);
+	} else {
+		OS.gtk_tree_view_column_pack_start (columnHandle, pixbufRenderer, false);
+		OS.gtk_tree_view_column_pack_start (columnHandle, textRenderer, true);
+		OS.gtk_tree_view_column_set_alignment (columnHandle, 0f);
+	}
+
+	/* Add attributes */
+	OS.gtk_tree_view_column_add_attribute (columnHandle, pixbufRenderer, OS.pixbuf, modelIndex + CELL_PIXBUF);
+	/*
+	 * Bug on GTK. Gtk renders the background on top of the pixbuf.
+	 * This only happens in version 2.2.1 and earlier. The fix is not to set the background.   
+	 */
+	if (OS.GTK_VERSION > OS.VERSION (2, 2, 1)) {
+		if (!ownerDraw) {
+			OS.gtk_tree_view_column_add_attribute (columnHandle, pixbufRenderer, OS.cell_background_gdk, BACKGROUND_COLUMN);
+			OS.gtk_tree_view_column_add_attribute (columnHandle, textRenderer, OS.cell_background_gdk, BACKGROUND_COLUMN);
+		}
+	}
+	OS.gtk_tree_view_column_add_attribute (columnHandle, textRenderer, OS.text, modelIndex + CELL_TEXT);
+	OS.gtk_tree_view_column_add_attribute (columnHandle, textRenderer, OS.foreground_gdk, FOREGROUND_COLUMN);
+	OS.gtk_tree_view_column_add_attribute (columnHandle, textRenderer, OS.font_desc, FONT_COLUMN);
+	
+	boolean customDraw = firstCustomDraw;
+	if (columnCount != 0) {
+		for (int i=0; i<columnCount; i++) {
+			if (columns [i].handle == columnHandle) {
+				customDraw = columns [i].customDraw;
+				break;
+			}
+		}
+	}
+	if ((style & SWT.VIRTUAL) != 0 || customDraw || ownerDraw) {
+		OS.gtk_tree_view_column_set_cell_data_func (columnHandle, textRenderer, display.cellDataProc, handle, 0);
+		OS.gtk_tree_view_column_set_cell_data_func (columnHandle, pixbufRenderer, display.cellDataProc, handle, 0);
+	}
+}
+
+void createWidget (int index) {
+	super.createWidget (index);
+	items = new TableItem [4];
+	columns = new TableColumn [4];
+	itemCount = columnCount = 0;
+}
+
+GdkColor defaultBackground () {
+	return display.COLOR_LIST_BACKGROUND;
+}
+
+GdkColor defaultForeground () {
+	return display.COLOR_LIST_FOREGROUND;
+}
+
+void deregister () {
+	super.deregister ();
+	display.removeWidget (OS.gtk_tree_view_get_selection (handle));
+	if (checkRenderer != 0) display.removeWidget (checkRenderer);
+}
+
+/**
+ * Deselects the item at the given zero-relative index in the receiver.
+ * If the item at the index was already deselected, it remains
+ * deselected. Indices that are out of range are ignored.
+ *
+ * @param index the index of the item to deselect
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void deselect (int index) {
+	checkWidget();
+	if (index < 0 || index >= itemCount) return;
+	boolean fixColumn = showFirstColumn ();
+	int /*long*/ selection = OS.gtk_tree_view_get_selection (handle);
+	OS.g_signal_handlers_block_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+	OS.gtk_tree_selection_unselect_iter (selection, _getItem (index).handle);
+	OS.g_signal_handlers_unblock_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+	if (fixColumn) hideFirstColumn ();
+}
+
+/**
+ * Deselects the items at the given zero-relative indices in the receiver.
+ * If the item at the given zero-relative index in the receiver 
+ * is selected, it is deselected.  If the item at the index
+ * was not selected, it remains deselected.  The range of the
+ * indices is inclusive. Indices that are out of range are ignored.
+ *
+ * @param start the start index of the items to deselect
+ * @param end the end index of the items to deselect
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void deselect (int start, int end) {
+	checkWidget();
+	boolean fixColumn = showFirstColumn ();
+	int /*long*/ selection = OS.gtk_tree_view_get_selection (handle);
+	OS.g_signal_handlers_block_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+	for (int index=start; index<=end; index++) {
+		if (index < 0 || index >= itemCount) continue;
+		OS.gtk_tree_selection_unselect_iter (selection, _getItem (index).handle);
+	}
+	OS.g_signal_handlers_unblock_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+	if (fixColumn) hideFirstColumn ();
+}
+
+/**
+ * Deselects the items at the given zero-relative indices in the receiver.
+ * If the item at the given zero-relative index in the receiver 
+ * is selected, it is deselected.  If the item at the index
+ * was not selected, it remains deselected. Indices that are out
+ * of range and duplicate indices are ignored.
+ *
+ * @param indices the array of indices for the items to deselect
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the set of indices is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void deselect (int [] indices) {
+	checkWidget();
+	if (indices == null) error (SWT.ERROR_NULL_ARGUMENT);
+	boolean fixColumn = showFirstColumn ();
+	int /*long*/ selection = OS.gtk_tree_view_get_selection (handle);
+	OS.g_signal_handlers_block_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+	for (int i=0; i<indices.length; i++) {
+		int index = indices[i];
+		if (index < 0 || index >= itemCount) continue;
+		OS.gtk_tree_selection_unselect_iter (selection, _getItem (index).handle);
+	}
+	OS.g_signal_handlers_unblock_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+	if (fixColumn) hideFirstColumn ();
+}
+
+/**
+ * Deselects all selected items in the receiver.
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void deselectAll () {
+	checkWidget();
+	boolean fixColumn = showFirstColumn ();
+	int /*long*/ selection = OS.gtk_tree_view_get_selection (handle);
+	OS.g_signal_handlers_block_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+	OS.gtk_tree_selection_unselect_all (selection);
+	OS.g_signal_handlers_unblock_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+	if (fixColumn) hideFirstColumn ();
+}
+
+void destroyItem (TableColumn column) {
+	int index = 0;
+	while (index < columnCount) {
+		if (columns [index] == column) break;
+		index++;
+	}
+	if (index == columnCount) return;
+	int /*long*/ columnHandle = column.handle;
+	if (columnCount == 1) {
+		firstCustomDraw = column.customDraw;
+	}
+	System.arraycopy (columns, index + 1, columns, index, --columnCount - index);
+	columns [columnCount] = null;
+	OS.gtk_tree_view_remove_column (handle, columnHandle);
+	if (columnCount == 0) {
+		int /*long*/ oldModel = modelHandle;
+		int /*long*/[] types = getColumnTypes (1);
+		int /*long*/ newModel = OS.gtk_list_store_newv (types.length, types);
+		if (newModel == 0) error (SWT.ERROR_NO_HANDLES);
+		int /*long*/ [] ptr = new int /*long*/ [1];
+		for (int i=0; i<itemCount; i++) {
+			int /*long*/ newItem = OS.g_malloc (OS.GtkTreeIter_sizeof ());
+			if (newItem == 0) error (SWT.ERROR_NO_HANDLES);
+			OS.gtk_list_store_append (newModel, newItem);
+			TableItem item = items [i];
+			if (item != null) {
+				int /*long*/ oldItem = item.handle;
+				for (int j=0; j<FIRST_COLUMN; j++) {
+					OS.gtk_tree_model_get (oldModel, oldItem, j, ptr, -1);
+					OS.gtk_list_store_set (newModel, newItem, j, ptr [0], -1);
+				}
+				OS.gtk_tree_model_get (oldModel, oldItem, column.modelIndex + CELL_PIXBUF, ptr, -1);
+				OS.gtk_list_store_set (newModel, newItem, FIRST_COLUMN + CELL_PIXBUF, ptr [0], -1);
+				OS.gtk_tree_model_get (oldModel, oldItem, column.modelIndex + CELL_TEXT, ptr, -1);
+				OS.gtk_list_store_set (newModel, newItem, FIRST_COLUMN + CELL_TEXT, ptr [0], -1);
+				OS.g_free (ptr [0]);
+				OS.gtk_tree_model_get (oldModel, oldItem, column.modelIndex + CELL_FOREGROUND, ptr, -1);
+				OS.gtk_list_store_set (newModel, newItem, FIRST_COLUMN + CELL_FOREGROUND, ptr [0], -1);
+				OS.gtk_tree_model_get (oldModel, oldItem, column.modelIndex + CELL_BACKGROUND, ptr, -1);
+				OS.gtk_list_store_set (newModel, newItem, FIRST_COLUMN + CELL_BACKGROUND, ptr [0], -1);
+				OS.gtk_tree_model_get (oldModel, oldItem, column.modelIndex + CELL_FONT, ptr, -1);
+				OS.gtk_list_store_set (newModel, newItem, FIRST_COLUMN + CELL_FONT, ptr [0], -1);
+				OS.gtk_list_store_remove (oldModel, oldItem);
+				OS.g_free (oldItem);
+				item.handle = newItem;
+			} else {
+				OS.g_free (newItem);
+			}
+		}
+		OS.gtk_tree_view_set_model (handle, newModel);
+		OS.g_object_unref (oldModel);
+		modelHandle = newModel;
+		createColumn (null, 0);
+	} else {
+		for (int i=0; i<itemCount; i++) {
+			TableItem item = items [i];
+			if (item != null) {
+				int /*long*/ iter = item.handle;
+				int modelIndex = column.modelIndex;
+				OS.gtk_list_store_set (modelHandle, iter, modelIndex + CELL_PIXBUF, 0, -1);
+				OS.gtk_list_store_set (modelHandle, iter, modelIndex + CELL_TEXT, 0, -1);
+				OS.gtk_list_store_set (modelHandle, iter, modelIndex + CELL_FOREGROUND, 0, -1);
+				OS.gtk_list_store_set (modelHandle, iter, modelIndex + CELL_BACKGROUND, 0, -1);
+				OS.gtk_list_store_set (modelHandle, iter, modelIndex + CELL_FONT, 0, -1);
+				
+				Font [] cellFont = item.cellFont;
+				if (cellFont != null) {
+					if (columnCount == 0) {
+						item.cellFont = null;
+					} else {
+						Font [] temp = new Font [columnCount];
+						System.arraycopy (cellFont, 0, temp, 0, index);
+						System.arraycopy (cellFont, index + 1, temp, index, columnCount - index);
+						item.cellFont = temp;
+					}
+				}
+			}
+		}
+		if (index == 0) {
+			TableColumn checkColumn = columns [0];
+			createRenderers (checkColumn.handle, checkColumn.modelIndex, true, checkColumn.style);
+		}
+	}
+	/* Disable searching when using VIRTUAL */
+	if ((style & SWT.VIRTUAL) != 0) {
+		/*
+		* Bug in GTK. Until GTK 2.6.5, calling gtk_tree_view_set_enable_search(FALSE)
+		* would prevent the user from being able to type in text to search the tree.
+		* After 2.6.5, GTK introduced Ctrl+F as being the key binding for interactive
+		* search. This meant that even if FALSE was passed to enable_search, the user
+		* can still bring up the search pop up using the keybinding. GTK also introduced
+		* the notion of passing a -1 to gtk_set_search_column to disable searching
+		* (including the search key binding).  The fix is to use the right calls
+		* for the right version.
+		*/
+		if (OS.GTK_VERSION >= OS.VERSION (2, 6, 5)) {
+			OS.gtk_tree_view_set_search_column (handle, -1); 
+		} else {
+			OS.gtk_tree_view_set_enable_search (handle, false);
+		}
+	} else {
+		/* Set the search column whenever the model changes */
+		int firstColumn = columnCount == 0 ? FIRST_COLUMN : columns [0].modelIndex;
+		OS.gtk_tree_view_set_search_column (handle, firstColumn + CELL_TEXT);
+	}
+}
+
+void destroyItem (TableItem item) {
+	int index = 0;
+	while (index < itemCount) {
+		if (items [index] == item) break;
+		index++;
+	}
+	if (index == itemCount) return;
+	int /*long*/ selection = OS.gtk_tree_view_get_selection (handle);
+	OS.g_signal_handlers_block_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+	OS.gtk_list_store_remove (modelHandle, item.handle);
+	OS.g_signal_handlers_unblock_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+	System.arraycopy (items, index + 1, items, index, --itemCount - index);
+	items [itemCount] = null;
+	if (itemCount == 0) resetCustomDraw ();
+}
+
+boolean dragDetect (int x, int y, boolean filter, boolean [] consume) {
+	boolean selected = false;
+	if (filter) {
+		int /*long*/ [] path = new int /*long*/ [1];
+		if (OS.gtk_tree_view_get_path_at_pos (handle, x, y, path, null, null, null)) {
+			if (path [0] != 0) {
+				int /*long*/ selection = OS.gtk_tree_view_get_selection (handle);
+				if (OS.gtk_tree_selection_path_is_selected (selection, path [0])) selected = true;
+				OS.gtk_tree_path_free (path [0]);
+			}
+		} else {
+			return false;
+		}
+	}
+	boolean dragDetect = super.dragDetect (x, y, filter, consume);
+	if (dragDetect && selected && consume != null) consume [0] = true;
+	return dragDetect;
+}
+
+int /*long*/ eventWindow () {
+	return paintWindow ();
+}
+
+void fixChildren (Shell newShell, Shell oldShell, Decorations newDecorations, Decorations oldDecorations, Menu [] menus) {
+	super.fixChildren (newShell, oldShell, newDecorations, oldDecorations, menus);
+	for (int i=0; i<columnCount; i++) {
+		TableColumn column = columns [i];
+		if (column.toolTipText != null) {
+			column.setToolTipText(oldShell, null);
+			column.setToolTipText(newShell, column.toolTipText);
+		}
+	}
+}
+
+GdkColor getBackgroundColor () {
+	return getBaseColor ();
+}
+
+public Rectangle getClientArea () {
+	checkWidget ();
+	forceResize ();
+	OS.gtk_widget_realize (handle);
+	int /*long*/ fixedWindow = OS.GTK_WIDGET_WINDOW (fixedHandle);
+	int /*long*/ binWindow = OS.gtk_tree_view_get_bin_window (handle);
+	int [] binX = new int [1], binY = new int [1];
+	OS.gdk_window_get_origin (binWindow, binX, binY);
+	int [] fixedX = new int [1], fixedY = new int [1];
+	OS.gdk_window_get_origin (fixedWindow, fixedX, fixedY);
+	int /*long*/ clientHandle = clientHandle ();
+	int width = (state & ZERO_WIDTH) != 0 ? 0 : OS.GTK_WIDGET_WIDTH (clientHandle);
+	int height = (state & ZERO_HEIGHT) != 0 ? 0 : OS.GTK_WIDGET_HEIGHT (clientHandle);
+	return new Rectangle (fixedX [0] - binX [0], fixedY [0] - binY [0], width, height);
+}
+
+int getClientWidth () {
+	int [] w = new int [1], h = new int [1];
+	OS.gtk_widget_realize (handle);
+	OS.gdk_drawable_get_size(OS.gtk_tree_view_get_bin_window(handle), w, h);
+	return w[0];
+}
+
+/**
+ * Returns the column at the given, zero-relative index in the
+ * receiver. Throws an exception if the index is out of range.
+ * Columns are returned in the order that they were created.
+ * If no <code>TableColumn</code>s were created by the programmer,
+ * this method will throw <code>ERROR_INVALID_RANGE</code> despite
+ * the fact that a single column of data may be visible in the table.
+ * This occurs when the programmer uses the table like a list, adding
+ * items but never creating a column.
+ *
+ * @param index the index of the column to return
+ * @return the column at the given index
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see Table#getColumnOrder()
+ * @see Table#setColumnOrder(int[])
+ * @see TableColumn#getMoveable()
+ * @see TableColumn#setMoveable(boolean)
+ * @see SWT#Move
+ */
+public TableColumn getColumn (int index) {
+	checkWidget();
+	if (!(0 <= index && index < columnCount)) error (SWT.ERROR_INVALID_RANGE);
+	return columns [index];
+}
+
+/**
+ * Returns the number of columns contained in the receiver.
+ * If no <code>TableColumn</code>s were created by the programmer,
+ * this value is zero, despite the fact that visually, one column
+ * of items may be visible. This occurs when the programmer uses
+ * the table like a list, adding items but never creating a column.
+ *
+ * @return the number of columns
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getColumnCount () {
+	checkWidget();
+	return columnCount;
+}
+
+int /*long*/[] getColumnTypes (int columnCount) {
+	int /*long*/[] types = new int /*long*/ [FIRST_COLUMN + (columnCount * CELL_TYPES)];
+	// per row data
+	types [CHECKED_COLUMN] = OS.G_TYPE_BOOLEAN ();
+	types [GRAYED_COLUMN] = OS.G_TYPE_BOOLEAN ();
+	types [FOREGROUND_COLUMN] = OS.GDK_TYPE_COLOR ();
+	types [BACKGROUND_COLUMN] = OS.GDK_TYPE_COLOR ();
+	types [FONT_COLUMN] = OS.PANGO_TYPE_FONT_DESCRIPTION ();
+	// per cell data
+	for (int i=FIRST_COLUMN; i<types.length; i+=CELL_TYPES) {
+		types [i + CELL_PIXBUF] = OS.GDK_TYPE_PIXBUF ();
+		types [i + CELL_TEXT] = OS.G_TYPE_STRING ();
+		types [i + CELL_FOREGROUND] = OS.GDK_TYPE_COLOR ();
+		types [i + CELL_BACKGROUND] = OS.GDK_TYPE_COLOR ();
+		types [i + CELL_FONT] = OS.PANGO_TYPE_FONT_DESCRIPTION ();
+	}
+	return types;
+}
+
+/**
+ * Returns an array of zero-relative integers that map
+ * the creation order of the receiver's items to the
+ * order in which they are currently being displayed.
+ * <p>
+ * Specifically, the indices of the returned array represent
+ * the current visual order of the items, and the contents
+ * of the array represent the creation order of the items.
+ * </p><p>
+ * Note: This is not the actual structure used by the receiver
+ * to maintain its list of items, so modifying the array will
+ * not affect the receiver. 
+ * </p>
+ *
+ * @return the current visual order of the receiver's items
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see Table#setColumnOrder(int[])
+ * @see TableColumn#getMoveable()
+ * @see TableColumn#setMoveable(boolean)
+ * @see SWT#Move
+ * 
+ * @since 3.1
+ */
+public int [] getColumnOrder () {
+	checkWidget ();
+	if (columnCount == 0) return new int [0];
+	int /*long*/ list = OS.gtk_tree_view_get_columns (handle);
+	if (list == 0) return new int [0];
+	int  i = 0, count = OS.g_list_length (list);
+	int [] order = new int [count];
+	int /*long*/ temp = list;
+	while (temp != 0) {
+		int /*long*/ column = OS.g_list_data (temp);
+		if (column != 0) {
+			for (int j=0; j<columnCount; j++) {
+				if (columns [j].handle == column) {
+					order [i++] = j;
+					break;
+				}
+			}
+		}
+		temp = OS.g_list_next (temp);
+	}
+	OS.g_list_free (list);
+	return order;
+}
+
+/**
+ * Returns an array of <code>TableColumn</code>s which are the
+ * columns in the receiver.  Columns are returned in the order
+ * that they were created.  If no <code>TableColumn</code>s were
+ * created by the programmer, the array is empty, despite the fact
+ * that visually, one column of items may be visible. This occurs
+ * when the programmer uses the table like a list, adding items but
+ * never creating a column.
+ * <p>
+ * Note: This is not the actual structure used by the receiver
+ * to maintain its list of items, so modifying the array will
+ * not affect the receiver. 
+ * </p>
+ *
+ * @return the items in the receiver
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see Table#getColumnOrder()
+ * @see Table#setColumnOrder(int[])
+ * @see TableColumn#getMoveable()
+ * @see TableColumn#setMoveable(boolean)
+ * @see SWT#Move
+ */
+public TableColumn [] getColumns () {
+	checkWidget();
+	TableColumn [] result = new TableColumn [columnCount];
+	System.arraycopy (columns, 0, result, 0, columnCount);
+	return result;
+}
+
+TableItem getFocusItem () {
+	int /*long*/ [] path = new int /*long*/ [1];
+	OS.gtk_tree_view_get_cursor (handle, path, null);
+	if (path [0] == 0) return null;
+	TableItem item = null;
+	int /*long*/ indices = OS.gtk_tree_path_get_indices (path [0]);
+	if (indices != 0) {
+		int [] index = new int []{-1};
+		OS.memmove (index, indices, 4);
+		item = _getItem (index [0]); 
+	}
+	OS.gtk_tree_path_free (path [0]);
+	return item;
+} 
+
+GdkColor getForegroundColor () {
+	return getTextColor ();
+}
+
+/**
+ * Returns the width in pixels of a grid line.
+ *
+ * @return the width of a grid line in pixels
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getGridLineWidth () {
+	checkWidget();
+	return 0;
+}
+
+/**
+ * Returns the height of the receiver's header 
+ *
+ * @return the height of the header or zero if the header is not visible
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 2.0 
+ */
+public int getHeaderHeight () {
+	checkWidget ();
+	if (!OS.gtk_tree_view_get_headers_visible (handle)) return 0;
+	if (columnCount > 0) {
+		GtkRequisition requisition = new GtkRequisition ();
+		int height = 0;
+		for (int i=0; i<columnCount; i++) {
+			int /*long*/ buttonHandle = columns [i].buttonHandle;
+			if (buttonHandle != 0) {
+				OS.gtk_widget_size_request (buttonHandle, requisition);
+				height = Math.max (height, requisition.height);
+			}
+		}
+		return height;
+	}
+	OS.gtk_widget_realize (handle);
+	int /*long*/ fixedWindow = OS.GTK_WIDGET_WINDOW (fixedHandle);
+	int /*long*/ binWindow = OS.gtk_tree_view_get_bin_window (handle);
+	int [] binY = new int [1];
+	OS.gdk_window_get_origin (binWindow, null, binY);
+	int [] fixedY = new int [1];
+	OS.gdk_window_get_origin (fixedWindow, null, fixedY);
+	return binY [0] - fixedY [0];
+}
+
+/**
+ * Returns <code>true</code> if the receiver's header is visible,
+ * and <code>false</code> otherwise.
+ * <p>
+ * If one of the receiver's ancestors is not visible or some
+ * other condition makes the receiver not visible, this method
+ * may still indicate that it is considered visible even though
+ * it may not actually be showing.
+ * </p>
+ *
+ * @return the receiver's header's visibility state
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public boolean getHeaderVisible () {
+	checkWidget();
+	return OS.gtk_tree_view_get_headers_visible (handle);
+}
+
+/**
+ * Returns the item at the given, zero-relative index in the
+ * receiver. Throws an exception if the index is out of range.
+ *
+ * @param index the index of the item to return
+ * @return the item at the given index
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public TableItem getItem (int index) {
+	checkWidget();
+	if (!(0 <= index && index < itemCount)) error (SWT.ERROR_INVALID_RANGE);
+	return _getItem (index);
+}
+
+/**
+ * Returns the item at the given point in the receiver
+ * or null if no such item exists. The point is in the
+ * coordinate system of the receiver.
+ * <p>
+ * The item that is returned represents an item that could be selected by the user.
+ * For example, if selection only occurs in items in the first column, then null is 
+ * returned if the point is outside of the item. 
+ * Note that the SWT.FULL_SELECTION style hint, which specifies the selection policy,
+ * determines the extent of the selection.
+ * </p>
+ *
+ * @param point the point used to locate the item
+ * @return the item at the given point, or null if the point is not in a selectable item
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the point is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public TableItem getItem (Point point) {
+	checkWidget();
+	if (point == null) error (SWT.ERROR_NULL_ARGUMENT);
+	int /*long*/ [] path = new int /*long*/ [1];
+	OS.gtk_widget_realize (handle);
+	if (!OS.gtk_tree_view_get_path_at_pos (handle, point.x, point.y, path, null, null, null)) return null;
+	if (path [0] == 0) return null;
+	int /*long*/ indices = OS.gtk_tree_path_get_indices (path [0]);
+	TableItem item = null;
+	if (indices != 0) {
+		int [] index = new int [1];
+		OS.memmove (index, indices, 4);
+		item = _getItem (index [0]);
+	}
+	OS.gtk_tree_path_free (path [0]);
+	return item;
+}
+
+/**
+ * Returns the number of items contained in the receiver.
+ *
+ * @return the number of items
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getItemCount () {
+	checkWidget ();
+	return itemCount;
+}
+
+/**
+ * Returns the height of the area which would be used to
+ * display <em>one</em> of the items in the receiver.
+ *
+ * @return the height of one item
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getItemHeight () {
+	checkWidget();
+	if (itemCount == 0) {
+		int /*long*/ column = OS.gtk_tree_view_get_column (handle, 0);
+		int [] w = new int [1], h = new int [1];
+		ignoreSize = true;
+		OS.gtk_tree_view_column_cell_get_size (column, null, null, null, w, h);
+		ignoreSize = false;
+		return h [0];
+	} else {
+		int height = 0;
+		int /*long*/ iter = OS.g_malloc (OS.GtkTreeIter_sizeof ());
+		OS.gtk_tree_model_get_iter_first (modelHandle, iter);
+		int columnCount = Math.max (1, this.columnCount);
+		for (int i=0; i<columnCount; i++) {
+			int /*long*/ column = OS.gtk_tree_view_get_column (handle, i);
+			OS.gtk_tree_view_column_cell_set_cell_data (column, modelHandle, iter, false, false);
+			int [] w = new int [1], h = new int [1];
+			OS.gtk_tree_view_column_cell_get_size (column, null, null, null, w, h);
+			height = Math.max (height, h [0]);
+		}
+		OS.g_free (iter);
+		return height;
+	}
+}
+
+/**
+ * Returns a (possibly empty) array of <code>TableItem</code>s which
+ * are the items in the receiver. 
+ * <p>
+ * Note: This is not the actual structure used by the receiver
+ * to maintain its list of items, so modifying the array will
+ * not affect the receiver. 
+ * </p>
+ *
+ * @return the items in the receiver
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public TableItem [] getItems () {
+	checkWidget();
+	TableItem [] result = new TableItem [itemCount];
+	if ((style & SWT.VIRTUAL) != 0) {
+		for (int i=0; i<itemCount; i++) {
+			result [i] = _getItem (i);
+		}
+	} else {
+		System.arraycopy (items, 0, result, 0, itemCount);
+	}
+	return result;
+}
+
+/**
+ * Returns <code>true</code> if the receiver's lines are visible,
+ * and <code>false</code> otherwise.
+ * <p>
+ * If one of the receiver's ancestors is not visible or some
+ * other condition makes the receiver not visible, this method
+ * may still indicate that it is considered visible even though
+ * it may not actually be showing.
+ * </p>
+ *
+ * @return the visibility state of the lines
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public boolean getLinesVisible() {
+	checkWidget();
+	return OS.gtk_tree_view_get_rules_hint (handle);
+}
+
+int /*long*/ getPixbufRenderer (int /*long*/ column) {
+	int /*long*/ list = OS.gtk_tree_view_column_get_cell_renderers (column);
+	if (list == 0) return 0;
+	int count = OS.g_list_length (list);
+	int /*long*/ pixbufRenderer = 0;
+	int i = 0;
+	while (i < count) {
+		int /*long*/ renderer = OS.g_list_nth_data (list, i);
+		 if (OS.GTK_IS_CELL_RENDERER_PIXBUF (renderer)) {
+			pixbufRenderer = renderer;
+			break;
+		}
+		i++;
+	}
+	OS.g_list_free (list);
+	return pixbufRenderer;
+}
+
+/**
+ * Returns an array of <code>TableItem</code>s that are currently
+ * selected in the receiver. The order of the items is unspecified.
+ * An empty array indicates that no items are selected.
+ * <p>
+ * Note: This is not the actual structure used by the receiver
+ * to maintain its selection, so modifying the array will
+ * not affect the receiver. 
+ * </p>
+ * @return an array representing the selection
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public TableItem [] getSelection () {
+	checkWidget();
+	int /*long*/ selection = OS.gtk_tree_view_get_selection (handle);
+	if (OS.GTK_VERSION < OS.VERSION (2, 2, 0)) {
+		display.treeSelectionLength  = 0;
+		display.treeSelection = new int [itemCount];
+		OS.gtk_tree_selection_selected_foreach (selection, display.treeSelectionProc, handle);
+		TableItem [] result = new TableItem [display.treeSelectionLength];
+		for (int i=0; i<result.length; i++) result [i] = _getItem (display.treeSelection [i]);
+		return result;
+	}
+	/*
+	* Bug in GTK.  gtk_tree_selection_get_selected_rows() segmentation faults
+	* in versions smaller than 2.2.4 if the model is NULL.  The fix is
+	* to give a valid pointer instead.
+	*/
+	int /*long*/ [] model = OS.GTK_VERSION < OS.VERSION (2, 2, 4) ? new int /*long*/ [1] : null;
+	int /*long*/ list = OS.gtk_tree_selection_get_selected_rows (selection, model);
+	if (list != 0) {
+		int count = OS.g_list_length (list);
+		int [] treeSelection = new int [count];
+		int length = 0;
+		for (int i=0; i<count; i++) {
+			int /*long*/ data = OS.g_list_nth_data (list, i);
+			int /*long*/ indices = OS.gtk_tree_path_get_indices (data);
+			if (indices != 0) {
+				int [] index = new int [1];
+				OS.memmove (index, indices, 4);
+				treeSelection [length] = index [0];
+				length++;
+			}
+		}
+		OS.g_list_free (list);
+		TableItem [] result = new TableItem [length];
+		for (int i=0; i<result.length; i++) result [i] = _getItem (treeSelection [i]);
+		return result;
+	}
+	return new TableItem [0];
+}
+
+/**
+ * Returns the number of selected items contained in the receiver.
+ *
+ * @return the number of selected items
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getSelectionCount () {
+	checkWidget();
+	int /*long*/ selection = OS.gtk_tree_view_get_selection (handle);
+	if (OS.GTK_VERSION < OS.VERSION (2, 2, 0)) {
+		display.treeSelectionLength = 0;
+		display.treeSelection = null;
+		OS.gtk_tree_selection_selected_foreach (selection, display.treeSelectionProc, handle);
+		return display.treeSelectionLength;
+	}
+	return OS.gtk_tree_selection_count_selected_rows (selection);
+}
+
+/**
+ * Returns the zero-relative index of the item which is currently
+ * selected in the receiver, or -1 if no item is selected.
+ *
+ * @return the index of the selected item
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getSelectionIndex () {
+	checkWidget();
+	if (OS.GTK_VERSION < OS.VERSION (2, 2, 0)) {
+		display.treeSelectionLength  = 0;
+		display.treeSelection = new int [itemCount];
+		int /*long*/ selection = OS.gtk_tree_view_get_selection (handle);
+		OS.gtk_tree_selection_selected_foreach (selection, display.treeSelectionProc, handle);
+		if (display.treeSelectionLength == 0) return -1;
+		return display.treeSelection [0];
+	}
+	int /*long*/ selection = OS.gtk_tree_view_get_selection (handle);
+	/*
+	* Bug in GTK.  gtk_tree_selection_get_selected_rows() segmentation faults
+	* in versions smaller than 2.2.4 if the model is NULL.  The fix is
+	* to give a valid pointer instead.
+	*/
+	int /*long*/ [] model = OS.GTK_VERSION < OS.VERSION (2, 2, 4) ? new int /*long*/ [1] : null;
+	int /*long*/ list = OS.gtk_tree_selection_get_selected_rows (selection, model);
+	if (list != 0) {
+		int count = OS.g_list_length (list);
+		int [] index = new int [1];
+		for (int i=0; i<count; i++) {
+			int /*long*/ data = OS.g_list_nth_data (list, i);
+			int /*long*/ indices = OS.gtk_tree_path_get_indices (data);
+			if (indices != 0) {
+				OS.memmove (index, indices, 4);
+				break;
+			}
+		}
+		OS.g_list_free (list);
+		return index [0];
+	}
+	return -1;
+}
+
+/**
+ * Returns the zero-relative indices of the items which are currently
+ * selected in the receiver. The order of the indices is unspecified.
+ * The array is empty if no items are selected.
+ * <p>
+ * Note: This is not the actual structure used by the receiver
+ * to maintain its selection, so modifying the array will
+ * not affect the receiver. 
+ * </p>
+ * @return the array of indices of the selected items
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int [] getSelectionIndices () {
+	checkWidget();
+	int /*long*/ selection = OS.gtk_tree_view_get_selection (handle);
+	if (OS.GTK_VERSION < OS.VERSION (2, 2, 0)) {
+		display.treeSelectionLength  = 0;
+		display.treeSelection = new int [itemCount];
+		OS.gtk_tree_selection_selected_foreach (selection, display.treeSelectionProc, handle);
+		if (display.treeSelectionLength == display.treeSelection.length) return display.treeSelection;
+		int [] result = new int [display.treeSelectionLength];
+		System.arraycopy (display.treeSelection, 0, result, 0, display.treeSelectionLength);
+		return result;
+	}
+	/*
+	* Bug in GTK.  gtk_tree_selection_get_selected_rows() segmentation faults
+	* in versions smaller than 2.2.4 if the model is NULL.  The fix is
+	* to give a valid pointer instead.
+	*/
+	int /*long*/ [] model = OS.GTK_VERSION < OS.VERSION (2, 2, 4) ? new int /*long*/ [1] : null;
+	int /*long*/ list = OS.gtk_tree_selection_get_selected_rows (selection, model);
+	if (list != 0) {
+		int count = OS.g_list_length (list);
+		int [] treeSelection = new int [count];
+		int length = 0;
+		for (int i=0; i<count; i++) {
+			int /*long*/ data = OS.g_list_nth_data (list, i);
+			int /*long*/ indices = OS.gtk_tree_path_get_indices (data);
+			if (indices != 0) {
+				int [] index = new int [1];
+				OS.memmove (index, indices, 4);
+				treeSelection [length] = index [0];
+				length++;
+			}
+		}
+		OS.g_list_free (list);
+		int [] result = new int [length];
+		System.arraycopy (treeSelection, 0, result, 0, length);
+		return result;
+	}
+	return new int [0];
+}
+
+/**
+ * Returns the column which shows the sort indicator for
+ * the receiver. The value may be null if no column shows
+ * the sort indicator.
+ *
+ * @return the sort indicator 
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see #setSortColumn(TableColumn)
+ * 
+ * @since 3.2
+ */
+public TableColumn getSortColumn () {
+	checkWidget ();
+	return sortColumn;
+}
+
+/**
+ * Returns the direction of the sort indicator for the receiver. 
+ * The value will be one of <code>UP</code>, <code>DOWN</code> 
+ * or <code>NONE</code>.
+ *
+ * @return the sort direction
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see #setSortDirection(int)
+ * 
+ * @since 3.2
+ */
+public int getSortDirection () {
+	checkWidget ();
+	return sortDirection;
+}
+
+int /*long*/ getTextRenderer (int /*long*/ column) {
+	int /*long*/ list = OS.gtk_tree_view_column_get_cell_renderers (column);
+	if (list == 0) return 0;
+	int count = OS.g_list_length (list);
+	int /*long*/ textRenderer = 0;
+	int i = 0;
+	while (i < count) {
+		int /*long*/ renderer = OS.g_list_nth_data (list, i);
+		 if (OS.GTK_IS_CELL_RENDERER_TEXT (renderer)) {
+			textRenderer = renderer;
+			break;
+		}
+		i++;
+	}
+	OS.g_list_free (list);
+	return textRenderer;
+}
+
+/**
+ * Returns the zero-relative index of the item which is currently
+ * at the top of the receiver. This index can change when items are
+ * scrolled or new items are added or removed.
+ *
+ * @return the index of the top item
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getTopIndex () {
+	checkWidget();
+	int /*long*/ [] path = new int /*long*/ [1];
+	OS.gtk_widget_realize (handle);
+	if (!OS.gtk_tree_view_get_path_at_pos (handle, 1, 1, path, null, null, null)) return 0;
+	if (path [0] == 0) return 0;
+	int /*long*/ indices = OS.gtk_tree_path_get_indices (path[0]);
+	int[] index = new int [1];
+	if (indices != 0) OS.memmove (index, indices, 4);
+	OS.gtk_tree_path_free (path [0]);
+	return index [0];
+}
+
+int /*long*/ gtk_button_press_event (int /*long*/ widget, int /*long*/ event) {
+	GdkEventButton gdkEvent = new GdkEventButton ();
+	OS.memmove (gdkEvent, event, GdkEventButton.sizeof);
+	if (gdkEvent.window != OS.gtk_tree_view_get_bin_window (handle)) return 0;
+	int /*long*/ result = super.gtk_button_press_event (widget, event);
+	if (result != 0) return result;
+	/*
+	* Feature in GTK.  In a multi-select table view, when multiple items are already
+	* selected, the selection state of the item is toggled and the previous selection 
+	* is cleared. This is not the desired behaviour when bringing up a popup menu.
+	* Also, when an item is reselected with the right button, the tree view issues
+	* an unwanted selection event. The workaround is to detect that case and not
+	* run the default handler when the item is already part of the current selection.
+	*/
+	int button = gdkEvent.button;
+	if (button == 3 && gdkEvent.type == OS.GDK_BUTTON_PRESS) {
+		int /*long*/ [] path = new int /*long*/ [1];
+		if (OS.gtk_tree_view_get_path_at_pos (handle, (int)gdkEvent.x, (int)gdkEvent.y, path, null, null, null)) {
+			if (path [0] != 0) {
+				int /*long*/ selection = OS.gtk_tree_view_get_selection (handle);
+				if (OS.gtk_tree_selection_path_is_selected (selection, path [0])) result = 1;
+				OS.gtk_tree_path_free (path [0]);
+			}
+		}
+	}
+	
+	/*
+	* Feature in GTK.  When the user clicks in a single selection GtkTreeView
+	* and there are no selected items, the first item is selected automatically
+	* before the click is processed, causing two selection events.  The is fix
+	* is the set the cursor item to be same as the clicked item to stop the
+	* widget from automatically selecting the first item.
+	*/
+	if ((style & SWT.SINGLE) != 0 && getSelectionCount () == 0) {
+		int /*long*/ [] path = new int /*long*/ [1];
+		if (OS.gtk_tree_view_get_path_at_pos (handle, (int)gdkEvent.x, (int)gdkEvent.y, path, null, null, null)) {
+			if (path [0] != 0) {
+				int /*long*/ selection = OS.gtk_tree_view_get_selection (handle);
+				OS.g_signal_handlers_block_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+				OS.gtk_tree_view_set_cursor (handle, path [0], 0, false);
+				OS.g_signal_handlers_unblock_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+				OS.gtk_tree_path_free (path [0]);
+			}
+		}
+	}
+	/*
+	* Bug in GTK. GTK segments fault, if the GtkTreeView widget is
+	* not in focus and all items in the widget are disposed before
+	* it finishes processing a button press.  The fix is to give
+	* focus to the widget before it starts processing the event.
+	*/
+	if (!OS.GTK_WIDGET_HAS_FOCUS (handle)) {
+		OS.gtk_widget_grab_focus (handle);
+	}
+	return result;
+}
+
+int /*long*/ gtk_button_release_event (int /*long*/ widget, int /*long*/ event) {
+	int /*long*/ window = OS.GDK_EVENT_WINDOW (event);
+	if (window != OS.gtk_tree_view_get_bin_window (handle)) return 0;
+	return super.gtk_button_release_event (widget, event);
+}
+
+int /*long*/ gtk_changed (int /*long*/ widget) {
+	TableItem item = getFocusItem ();
+	if (item != null) {
+		Event event = new Event ();
+		event.item = item; 
+		postEvent (SWT.Selection, event);
+	}
+	return 0;
+}
+
+int /*long*/ gtk_key_press_event (int /*long*/ widget, int /*long*/ eventPtr) {
+	int /*long*/ result = super.gtk_key_press_event (widget, eventPtr);
+	if (result != 0) return result;
+	if (OS.GTK_VERSION < OS.VERSION (2, 2 ,0)) {
+		/*
+		* Feature in GTK 2.0.x.  When an item is default selected using
+		* the return key, GTK does not issue notification. The fix is
+		* to issue this notification when the return key is pressed.
+		*/
+		GdkEventKey keyEvent = new GdkEventKey ();
+		OS.memmove (keyEvent, eventPtr, GdkEventKey.sizeof);
+		int key = keyEvent.keyval;
+		switch (key) {
+			case OS.GDK_Return:
+			case OS.GDK_KP_Enter: {
+				Event event = new Event ();
+				event.item = getFocusItem (); 
+				postEvent (SWT.DefaultSelection, event);
+				break;
+			}
+		}
+	}
+	return result;
+}
+
+int /*long*/ gtk_popup_menu (int /*long*/ widget) {
+	int /*long*/ result = super.gtk_popup_menu (widget);
+	/*
+	* Bug in GTK.  The context menu for the typeahead in GtkTreeViewer
+	* opens in the bottom right corner of the screen when Shift+F10
+	* is pressed and the typeahead window was not visible.  The fix is
+	* to prevent the context menu from opening by stopping the default
+	* handler.
+	* 
+	* NOTE: The bug only happens in GTK 2.6.5 and lower.
+	*/
+	return OS.GTK_VERSION < OS.VERSION (2, 6, 5) ? 1 : result;
+}
+
+int /*long*/ gtk_motion_notify_event (int /*long*/ widget, int /*long*/ event) {
+	int /*long*/ window = OS.GDK_EVENT_WINDOW (event);
+	if (window != OS.gtk_tree_view_get_bin_window (handle)) return 0;
+	return super.gtk_motion_notify_event (widget, event);
+}
+
+int /*long*/ gtk_row_activated (int /*long*/ tree, int /*long*/ path, int /*long*/ column) {
+	TableItem item = null;
+	int /*long*/ indices = OS.gtk_tree_path_get_indices (path);
+	if (indices != 0) {
+		int [] index = new int []{-1};
+		OS.memmove (index, indices, 4);
+		item = _getItem (index [0]); 
+	}
+	Event event = new Event ();
+	event.item = item;
+	postEvent (SWT.DefaultSelection, event);
+	return 0;
+}
+
+int /*long*/ gtk_toggled (int /*long*/ renderer, int /*long*/ pathStr) {
+	int /*long*/ path = OS.gtk_tree_path_new_from_string (pathStr);
+	if (path == 0) return 0;
+	int /*long*/ indices = OS.gtk_tree_path_get_indices (path);
+	if (indices != 0) {
+		int [] index = new int [1];
+		OS.memmove (index, indices, 4);
+		TableItem item = _getItem (index [0]);
+		item.setChecked (!item.getChecked ());
+		Event event = new Event ();
+		event.detail = SWT.CHECK;
+		event.item = item;
+		postEvent (SWT.Selection, event);
+	}
+	OS.gtk_tree_path_free (path);
+	return 0;
+}
+
+void gtk_widget_size_request (int /*long*/ widget, GtkRequisition requisition) {
+	/*
+	 * Bug in GTK.  For some reason, gtk_widget_size_request() fails
+	 * to include the height of the tree view items when there are
+	 * no columns visible.  The fix is to temporarily make one column
+	 * visible. 
+	 */
+	if (columnCount == 0) {
+		super.gtk_widget_size_request (widget, requisition);
+		return;
+	}
+	int /*long*/ columns = OS.gtk_tree_view_get_columns (handle), list = columns;
+	boolean fixVisible = columns != 0;
+	while (list != 0) {
+		int /*long*/ column = OS.g_list_data (list);
+		if (OS.gtk_tree_view_column_get_visible (column)) {
+			fixVisible = false;
+			break;
+		}
+		list = OS.g_list_next (list);
+	}
+	int /*long*/ columnHandle = 0;
+	if (fixVisible) {
+		columnHandle = OS.g_list_data (columns);
+		OS.gtk_tree_view_column_set_visible (columnHandle, true);
+	}
+	super.gtk_widget_size_request (widget, requisition);
+	if (fixVisible) {
+		OS.gtk_tree_view_column_set_visible (columnHandle, false);
+	}
+	if (columns != 0) OS.g_list_free (columns);
+}
+
+void hideFirstColumn () {
+	int /*long*/ firstColumn = OS.gtk_tree_view_get_column (handle, 0);
+	OS.gtk_tree_view_column_set_visible (firstColumn, false);	
+}
+
+void hookEvents () {
+	super.hookEvents ();
+	int /*long*/ selection = OS.gtk_tree_view_get_selection(handle);
+	OS.g_signal_connect_closure (selection, OS.changed, display.closures [CHANGED], false);
+	OS.g_signal_connect_closure (handle, OS.row_activated, display.closures [ROW_ACTIVATED], false);
+	if (checkRenderer != 0) {
+		OS.g_signal_connect_closure (checkRenderer, OS.toggled, display.closures [TOGGLED], false);
+	}
+}
+
+/**
+ * Searches the receiver's list starting at the first column
+ * (index 0) until a column is found that is equal to the 
+ * argument, and returns the index of that column. If no column
+ * is found, returns -1.
+ *
+ * @param column the search column
+ * @return the index of the column
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the column is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int indexOf (TableColumn column) {
+	checkWidget();
+	if (column == null) error (SWT.ERROR_NULL_ARGUMENT);
+	for (int i=0; i<columnCount; i++) {
+		if (columns [i] == column) return i;
+	}
+	return -1;
+}
+
+/**
+ * Searches the receiver's list starting at the first item
+ * (index 0) until an item is found that is equal to the 
+ * argument, and returns the index of that item. If no item
+ * is found, returns -1.
+ *
+ * @param item the search item
+ * @return the index of the item
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the item is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int indexOf (TableItem item) {
+	checkWidget();
+	if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if (1 <= lastIndexOf && lastIndexOf < itemCount - 1) {
+		if (items [lastIndexOf] == item) return lastIndexOf;
+		if (items [lastIndexOf + 1] == item) return ++lastIndexOf;
+		if (items [lastIndexOf - 1] == item) return --lastIndexOf;
+	}
+	if (lastIndexOf < itemCount / 2) {
+		for (int i=0; i<itemCount; i++) {
+			if (items [i] == item) return lastIndexOf = i;
+		}
+	} else {
+		for (int i=itemCount - 1; i>=0; --i) {
+			if (items [i] == item) return lastIndexOf = i;
+		}
+	}
+	return -1;
+}
+
+/**
+ * Returns <code>true</code> if the item is selected,
+ * and <code>false</code> otherwise.  Indices out of
+ * range are ignored.
+ *
+ * @param index the index of the item
+ * @return the selection state of the item at the index
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public boolean isSelected (int index) {
+	checkWidget();
+	int /*long*/ selection = OS.gtk_tree_view_get_selection (handle);
+	byte [] buffer = Converter.wcsToMbcs (null, Integer.toString (index), true);
+	int /*long*/ path = OS.gtk_tree_path_new_from_string (buffer);
+	boolean answer = OS.gtk_tree_selection_path_is_selected (selection, path);
+	OS.gtk_tree_path_free (path);
+	return answer;
+}
+
+boolean mnemonicHit (char key) {
+	for (int i=0; i<columnCount; i++) {
+		int /*long*/ labelHandle = columns [i].labelHandle;
+		if (labelHandle != 0 && mnemonicHit (labelHandle, key)) return true;
+	}
+	return false;
+}
+
+boolean mnemonicMatch (char key) {
+	for (int i=0; i<columnCount; i++) {
+		int /*long*/ labelHandle = columns [i].labelHandle;
+		if (labelHandle != 0 && mnemonicMatch (labelHandle, key)) return true;
+	}
+	return false;
+}
+
+int /*long*/ paintWindow () {
+	OS.gtk_widget_realize (handle);
+	return OS.gtk_tree_view_get_bin_window (handle);
+}
+
+void recreateRenderers () {
+	if (checkRenderer != 0) {
+		display.removeWidget (checkRenderer);
+		OS.g_object_unref (checkRenderer);
+		checkRenderer = ownerDraw ? OS.g_object_new (display.gtk_cell_renderer_toggle_get_type(), 0) : OS.gtk_cell_renderer_toggle_new ();
+		if (checkRenderer == 0) error (SWT.ERROR_NO_HANDLES);
+		OS.g_object_ref (checkRenderer);
+		display.addWidget (checkRenderer, this);
+		OS.g_signal_connect_closure (checkRenderer, OS.toggled, display.closures [TOGGLED], false);
+	}
+	if (columnCount == 0) {
+		createRenderers (OS.gtk_tree_view_get_column (handle, 0), Table.FIRST_COLUMN, true, 0);
+	} else {
+		for (int i = 0; i < columnCount; i++) {
+			TableColumn column = columns [i];
+			createRenderers (column.handle, column.modelIndex, i == 0, column.style);
+		}
+	}
+}
+
+void redrawBackgroundImage () {
+	Control control = findBackgroundControl ();
+	if (control != null && control.backgroundImage != null) {
+		redrawWidget (0, 0, 0, 0, true, false, false);
+	}
+}
+
+void register () {
+	super.register ();
+	display.addWidget (OS.gtk_tree_view_get_selection (handle), this);
+	if (checkRenderer != 0) display.addWidget (checkRenderer, this);
+}
+
+void releaseChildren (boolean destroy) {
+	if (items != null) {
+		for (int i=0; i<itemCount; i++) {
+			TableItem item = items [i];
+			if (item != null && !item.isDisposed ()) {
+				item.release (false);
+			}
+		}
+		items = null;
+	}
+	if (columns != null) {
+		for (int i=0; i<columnCount; i++) {
+			TableColumn column = columns [i];
+			if (column != null && !column.isDisposed ()) {
+				column.release (false);
+			}
+		}
+		columns = null;
+	}
+	super.releaseChildren (destroy);
+}
+
+void releaseWidget () {
+	super.releaseWidget ();
+	if (modelHandle != 0) OS.g_object_unref (modelHandle);
+	modelHandle = 0;
+	if (checkRenderer != 0) OS.g_object_unref (checkRenderer);
+	checkRenderer = 0;
+	if (imageList != null) imageList.dispose ();
+	if (headerImageList != null) headerImageList.dispose ();
+	imageList = headerImageList = null;
+	currentItem = null;
+}
+
+/**
+ * Removes the item from the receiver at the given
+ * zero-relative index.
+ *
+ * @param index the index for the item
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void remove (int index) {
+	checkWidget();
+	if (!(0 <= index && index < itemCount)) error (SWT.ERROR_ITEM_NOT_REMOVED);
+	int /*long*/ iter = OS.g_malloc (OS.GtkTreeIter_sizeof ());
+	TableItem item = items [index];
+	boolean disposed = false;
+	if (item != null) {
+		disposed = item.isDisposed ();
+		if (!disposed) {
+			OS.memmove (iter, item.handle, OS.GtkTreeIter_sizeof ());
+			item.release (false);
+		}
+	} else {
+		OS.gtk_tree_model_iter_nth_child (modelHandle, iter, 0, index);
+	}
+	if (!disposed) {
+		int /*long*/ selection = OS.gtk_tree_view_get_selection (handle);
+		OS.g_signal_handlers_block_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+		OS.gtk_list_store_remove (modelHandle, iter);
+		OS.g_signal_handlers_unblock_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+		System.arraycopy (items, index + 1, items, index, --itemCount - index);
+		items [itemCount] = null;
+	}
+	OS.g_free (iter);
+}
+
+/**
+ * Removes the items from the receiver which are
+ * between the given zero-relative start and end 
+ * indices (inclusive).
+ *
+ * @param start the start of the range
+ * @param end the end of the range
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_RANGE - if either the start or end are not between 0 and the number of elements in the list minus 1 (inclusive)</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void remove (int start, int end) {
+	checkWidget();
+	if (start > end) return;
+	if (!(0 <= start && start <= end && end < itemCount)) {
+		error (SWT.ERROR_INVALID_RANGE);
+	}
+	int /*long*/ selection = OS.gtk_tree_view_get_selection (handle);
+	int /*long*/ iter = OS.g_malloc (OS.GtkTreeIter_sizeof ());
+	OS.gtk_tree_model_iter_nth_child (modelHandle, iter, 0, start);
+	int index = start;
+	while (index <= end) {
+		TableItem item = items [index];
+		if (item != null && !item.isDisposed ()) item.release (false);
+		OS.g_signal_handlers_block_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+		OS.gtk_list_store_remove (modelHandle, iter);
+		OS.g_signal_handlers_unblock_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+		index++;
+	}
+	OS.g_free (iter);
+	System.arraycopy (items, index, items, start, itemCount - index);
+	for (int i=itemCount-(index-start); i<itemCount; i++) items [i] = null;
+	itemCount = itemCount - (index - start);
+}
+
+/**
+ * Removes the items from the receiver's list at the given
+ * zero-relative indices.
+ *
+ * @param indices the array of indices of the items
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
+ *    <li>ERROR_NULL_ARGUMENT - if the indices array is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void remove (int [] indices) {
+	checkWidget();
+	if (indices == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if (indices.length == 0) return;
+	int [] newIndices = new int [indices.length];
+	System.arraycopy (indices, 0, newIndices, 0, indices.length);
+	sort (newIndices);
+	int start = newIndices [newIndices.length - 1], end = newIndices [0];
+	if (!(0 <= start && start <= end && end < itemCount)) {
+		error (SWT.ERROR_INVALID_RANGE);
+	}
+	int /*long*/ selection = OS.gtk_tree_view_get_selection (handle);
+	int last = -1;
+	int /*long*/ iter = OS.g_malloc (OS.GtkTreeIter_sizeof ());
+	for (int i=0; i<newIndices.length; i++) {
+		int index = newIndices [i];
+		if (index != last) {
+			TableItem item = items [index];
+			boolean disposed = false;
+			if (item != null) {
+				disposed = item.isDisposed ();
+				if (!disposed) {
+					OS.memmove (iter, item.handle, OS.GtkTreeIter_sizeof ());
+					item.release (false);
+				}
+			} else {
+				OS.gtk_tree_model_iter_nth_child (modelHandle, iter, 0, index);
+			}
+			if (!disposed) {
+				OS.g_signal_handlers_block_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+				OS.gtk_list_store_remove (modelHandle, iter);
+				OS.g_signal_handlers_unblock_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+				System.arraycopy (items, index + 1, items, index, --itemCount - index);
+				items [itemCount] = null;
+			}
+			last = index;
+		}
+	}
+	OS.g_free (iter);
+}
+
+/**
+ * Removes all of the items from the receiver.
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void removeAll () {
+	checkWidget();
+	int index = itemCount - 1;
+	while (index >= 0) {
+		TableItem item = items [index];
+		if (item != null && !item.isDisposed ()) item.release (false);
+		--index;
+	}
+	items = new TableItem [4];
+	itemCount = 0;
+	int /*long*/ selection = OS.gtk_tree_view_get_selection (handle);
+	OS.g_signal_handlers_block_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+	OS.gtk_list_store_clear (modelHandle);
+	OS.g_signal_handlers_unblock_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+
+	resetCustomDraw ();
+	/* Disable searching when using VIRTUAL */
+	if ((style & SWT.VIRTUAL) != 0) {
+		/*
+		* Bug in GTK. Until GTK 2.6.5, calling gtk_tree_view_set_enable_search(FALSE)
+		* would prevent the user from being able to type in text to search the tree.
+		* After 2.6.5, GTK introduced Ctrl+F as being the key binding for interactive
+		* search. This meant that even if FALSE was passed to enable_search, the user
+		* can still bring up the search pop up using the keybinding. GTK also introduced
+		* the notion of passing a -1 to gtk_set_search_column to disable searching
+		* (including the search key binding).  The fix is to use the right calls
+		* for the right version.
+		*/
+		if (OS.GTK_VERSION >= OS.VERSION (2, 6, 5)){
+			OS.gtk_tree_view_set_search_column (handle, -1); 
+		} else {
+			OS.gtk_tree_view_set_enable_search (handle, false);
+		}
+	} else {
+		/* Set the search column whenever the model changes */
+		int firstColumn = columnCount == 0 ? FIRST_COLUMN : columns [0].modelIndex;
+		OS.gtk_tree_view_set_search_column (handle, firstColumn + CELL_TEXT);
+	}
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the user changes the receiver's selection.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #addSelectionListener(SelectionListener)
+ */
+public void removeSelectionListener(SelectionListener listener) {
+	checkWidget();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if (eventTable == null) return;
+	eventTable.unhook (SWT.Selection, listener);
+	eventTable.unhook (SWT.DefaultSelection,listener);	
+}
+
+int /*long*/ rendererGetSizeProc (int /*long*/ cell, int /*long*/ widget, int /*long*/ cell_area, int /*long*/ x_offset, int /*long*/ y_offset, int /*long*/ width, int /*long*/ height) {
+	int /*long*/ g_class = OS.g_type_class_peek_parent (OS.G_OBJECT_GET_CLASS (cell));
+	GtkCellRendererClass klass = new GtkCellRendererClass ();
+	OS.memmove (klass, g_class);
+	int /*long*/ result = OS.call (klass.get_size, cell, handle, cell_area, x_offset, y_offset, width, height);
+	if (!ignoreSize && OS.GTK_IS_CELL_RENDERER_TEXT (cell)) {
+		int /*long*/ iter = OS.g_object_get_qdata (cell, Display.SWT_OBJECT_INDEX2);
+		TableItem item = null;
+		if (iter != 0) {
+			int /*long*/ path = OS.gtk_tree_model_get_path (modelHandle, iter);
+			int [] buffer = new int [1];
+			OS.memmove (buffer, OS.gtk_tree_path_get_indices (path), 4);
+			int index = buffer [0];
+			item = _getItem (index);
+			OS.gtk_tree_path_free (path);
+		}
+		if (item != null) {
+			int columnIndex = 0;
+			if (columnCount > 0) {
+				int /*long*/ columnHandle = OS.g_object_get_qdata (cell, Display.SWT_OBJECT_INDEX1);
+				for (int i = 0; i < columnCount; i++) {
+					if (columns [i].handle == columnHandle) {
+						columnIndex = i;
+						break;
+					}				
+				}
+			}
+			if (hooks (SWT.MeasureItem)) {
+				int [] contentWidth = new int [1], contentHeight = new int  [1];
+				if (width != 0) OS.memmove (contentWidth, width, 4);
+				if (height != 0) OS.memmove (contentHeight, height, 4);
+				Image image = item.getImage (columnIndex);
+				int imageWidth = 0;
+				if (image != null) {
+					Rectangle bounds = image.getBounds ();
+					imageWidth = bounds.width;
+				}
+				contentWidth [0] += imageWidth;
+				GC gc = new GC (this);
+				gc.setFont (item.getFont (columnIndex));
+				Event event = new Event ();
+				event.item = item;
+				event.index = columnIndex;
+				event.gc = gc;
+				event.width = contentWidth [0];
+				event.height = contentHeight [0];
+				sendEvent (SWT.MeasureItem, event);
+				gc.dispose ();
+				contentWidth [0] = event.width - imageWidth;
+				if (contentHeight [0] < event.height) contentHeight [0] = event.height;
+				if (width != 0) OS.memmove (width, contentWidth, 4);
+				if (height != 0) OS.memmove (height, contentHeight, 4);
+			}
+		}
+	}
+	return result;
+}
+
+int /*long*/ rendererRenderProc (int /*long*/ cell, int /*long*/ window, int /*long*/ widget, int /*long*/ background_area, int /*long*/ cell_area, int /*long*/ expose_area, int /*long*/ flags) {
+	TableItem item = null;
+	int /*long*/ iter = OS.g_object_get_qdata (cell, Display.SWT_OBJECT_INDEX2);
+	if (iter != 0) {
+		int /*long*/ path = OS.gtk_tree_model_get_path (modelHandle, iter);
+		int [] buffer = new int [1];
+		OS.memmove (buffer, OS.gtk_tree_path_get_indices (path), 4);
+		int index = buffer [0];
+		item = _getItem (index);
+		OS.gtk_tree_path_free (path);
+	}
+	int /*long*/ columnHandle = OS.g_object_get_qdata (cell, Display.SWT_OBJECT_INDEX1);
+	int columnIndex = 0;
+	if (columnCount > 0) {
+		for (int i = 0; i < columnCount; i++) {
+			if (columns [i].handle == columnHandle) {
+				columnIndex = i;
+				break;
+			}				
+		}
+	}
+	if (item != null) {
+		if (OS.GTK_IS_CELL_RENDERER_TOGGLE (cell) || (OS.GTK_IS_CELL_RENDERER_PIXBUF (cell) && (columnIndex != 0 || (style & SWT.CHECK) == 0))) {
+			drawFlags = (int)/*64*/flags;
+			drawState = SWT.FOREGROUND;
+			int /*long*/ [] ptr = new int /*long*/ [1];
+			OS.gtk_tree_model_get (modelHandle, item.handle, Table.BACKGROUND_COLUMN, ptr, -1);
+			if (ptr [0] == 0) {
+				int modelIndex = columnCount == 0 ? Table.FIRST_COLUMN : columns [columnIndex].modelIndex;
+				OS.gtk_tree_model_get (modelHandle, item.handle, modelIndex + Table.CELL_BACKGROUND, ptr, -1);
+			}
+			if (ptr [0] != 0) drawState |= SWT.BACKGROUND;
+			if ((flags & OS.GTK_CELL_RENDERER_SELECTED) != 0) drawState |= SWT.SELECTED;
+			if ((flags & OS.GTK_CELL_RENDERER_FOCUSED) != 0) drawState |= SWT.FOCUSED;			
+			
+			GdkRectangle rect = new GdkRectangle ();
+			int /*long*/ path = OS.gtk_tree_model_get_path (modelHandle, iter);
+			OS.gtk_tree_view_get_background_area (handle, path, columnHandle, rect);
+			OS.gtk_tree_path_free (path);
+			
+			if ((drawState & SWT.SELECTED) == 0) {
+				Control control = findBackgroundControl ();
+				if (control != null && control.backgroundImage != null) {
+					OS.gdk_window_clear_area (window, rect.x, rect.y, rect.width, rect.height);
+				}
+			}
+
+			if (hooks (SWT.EraseItem)) {
+				boolean wasSelected = false; 
+				if ((drawState & SWT.SELECTED) != 0) {
+					wasSelected = true;
+					OS.gdk_window_clear_area (window, rect.x, rect.y, rect.width, rect.height);
+				}
+				GC gc = new GC (this);
+				if ((drawState & SWT.SELECTED) != 0) {
+					gc.setBackground (display.getSystemColor (SWT.COLOR_LIST_SELECTION));
+					gc.setForeground (display.getSystemColor (SWT.COLOR_LIST_SELECTION_TEXT));
+				} else {
+					gc.setBackground (item.getBackground (columnIndex));
+					gc.setForeground (item.getForeground (columnIndex));
+				}
+				gc.setFont (item.getFont (columnIndex));
+				if ((style & SWT.MIRRORED) != 0) rect.x = getClientWidth () - rect.width - rect.x;
+				gc.setClipping (rect.x, rect.y, rect.width, rect.height);
+				Event event = new Event ();
+				event.item = item;
+				event.index = columnIndex;
+				event.gc = gc;
+				event.x = rect.x;
+				event.y = rect.y;
+				event.width = rect.width;
+				event.height = rect.height;
+				event.detail = drawState;
+				sendEvent (SWT.EraseItem, event);
+				drawForeground = null;
+				drawState = event.doit ? event.detail : 0;
+				drawFlags &= ~(OS.GTK_CELL_RENDERER_FOCUSED | OS.GTK_CELL_RENDERER_SELECTED);
+				if ((drawState & SWT.SELECTED) != 0) drawFlags |= OS.GTK_CELL_RENDERER_SELECTED;
+				if ((drawState & SWT.FOCUSED) != 0) drawFlags |= OS.GTK_CELL_RENDERER_FOCUSED;
+				if ((drawState & SWT.SELECTED) != 0) {
+					int /*long*/ style = OS.gtk_widget_get_style (widget);					
+					//TODO - parity and sorted
+					byte[] detail = Converter.wcsToMbcs (null, "cell_odd", true);
+					OS.gtk_paint_flat_box (style, window, OS.GTK_STATE_SELECTED, OS.GTK_SHADOW_NONE, rect, widget, detail, rect.x, rect.y, rect.width, rect.height);
+				} else {
+					if (wasSelected) drawForeground = gc.getForeground ().handle;
+				}
+				gc.dispose();
+			}
+		}
+	}
+	int /*long*/ result = 0;
+	if ((drawState & SWT.BACKGROUND) != 0 && (drawState & SWT.SELECTED) == 0) {
+		GC gc = new GC (this);
+		gc.setBackground (item.getBackground (columnIndex));
+		GdkRectangle rect = new GdkRectangle ();
+		OS.memmove (rect, background_area, GdkRectangle.sizeof);
+		gc.fillRectangle (rect.x, rect.y, rect.width, rect.height);
+		gc.dispose ();
+	}
+	if ((drawState & SWT.FOREGROUND) != 0 || OS.GTK_IS_CELL_RENDERER_TOGGLE (cell)) {
+		int /*long*/ g_class = OS.g_type_class_peek_parent (OS.G_OBJECT_GET_CLASS (cell));
+		GtkCellRendererClass klass = new GtkCellRendererClass ();
+		OS.memmove (klass, g_class);
+		if (drawForeground != null && OS.GTK_IS_CELL_RENDERER_TEXT (cell)) {
+			OS.g_object_set (cell, OS.foreground_gdk, drawForeground, 0);
+		}
+		result = OS.call (klass.render, cell, window, handle, background_area, cell_area, expose_area, drawFlags);
+	}
+	if (item != null) {
+		if (OS.GTK_IS_CELL_RENDERER_TEXT (cell)) {
+			if (hooks (SWT.PaintItem)) {
+				GdkRectangle rect = new GdkRectangle ();
+				int /*long*/ path = OS.gtk_tree_model_get_path (modelHandle, iter);
+				OS.gtk_tree_view_get_background_area (handle, path, columnHandle, rect);
+				OS.gtk_tree_path_free (path);
+				ignoreSize = true;
+				int [] contentX = new int [1], contentWidth = new int [1];
+				OS.gtk_cell_renderer_get_size (cell, handle, null, null, null, contentWidth, null);
+				OS.gtk_tree_view_column_cell_get_position (columnHandle, cell, contentX, null);
+				ignoreSize = false;
+				Image image = item.getImage (columnIndex);
+				int imageWidth = 0;
+				if (image != null) {
+					Rectangle bounds = image.getBounds ();
+					imageWidth = bounds.width;
+				}
+				contentX [0] -= imageWidth;
+				contentWidth [0] += imageWidth;
+				GC gc = new GC (this);
+				if ((drawState & SWT.SELECTED) != 0) {
+					gc.setBackground (display.getSystemColor (SWT.COLOR_LIST_SELECTION));
+					gc.setForeground (display.getSystemColor (SWT.COLOR_LIST_SELECTION_TEXT));
+				} else {
+					gc.setBackground (item.getBackground (columnIndex));
+					Color foreground = drawForeground != null ? Color.gtk_new (display, drawForeground) : item.getForeground (columnIndex);
+					gc.setForeground (foreground);
+				}
+				gc.setFont (item.getFont (columnIndex));
+				if ((style & SWT.MIRRORED) != 0) rect.x = getClientWidth () - rect.width - rect.x;
+				gc.setClipping (rect.x, rect.y, rect.width, rect.height);
+				Event event = new Event ();
+				event.item = item;
+				event.index = columnIndex;
+				event.gc = gc;
+				event.x = rect.x + contentX [0];
+				event.y = rect.y;
+				event.width = contentWidth [0];
+				event.height = rect.height;
+				event.detail = drawState;
+				sendEvent (SWT.PaintItem, event);	
+				gc.dispose();
+			}
+		}
+	}
+	return result;
+}
+
+void resetCustomDraw () {
+	if ((style & SWT.VIRTUAL) != 0 || ownerDraw) return;
+	int end = Math.max (1, columnCount);
+	for (int i=0; i<end; i++) {
+		boolean customDraw = columnCount != 0 ? columns [i].customDraw : firstCustomDraw;
+		if (customDraw) {
+			int /*long*/ column = OS.gtk_tree_view_get_column (handle, i);
+			int /*long*/ textRenderer = getTextRenderer (column);
+			OS.gtk_tree_view_column_set_cell_data_func (column, textRenderer, 0, 0, 0);
+			if (columnCount != 0) columns [i].customDraw = false;
+		}
+	}
+	firstCustomDraw = false;
+}
+
+/**
+ * Selects the item at the given zero-relative index in the receiver. 
+ * If the item at the index was already selected, it remains
+ * selected. Indices that are out of range are ignored.
+ *
+ * @param index the index of the item to select
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void select (int index) {
+	checkWidget();
+	if (!(0 <= index && index < itemCount))  return;
+	boolean fixColumn = showFirstColumn ();
+	int /*long*/ selection = OS.gtk_tree_view_get_selection (handle);
+	OS.g_signal_handlers_block_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+	TableItem item = _getItem (index);
+	OS.gtk_tree_selection_select_iter (selection, item.handle);
+	if ((style & SWT.SINGLE) != 0) {
+		int /*long*/ path = OS.gtk_tree_model_get_path (modelHandle, item.handle);
+		OS.gtk_tree_view_set_cursor (handle, path, 0, false);
+		OS.gtk_tree_path_free (path);
+	}
+	OS.g_signal_handlers_unblock_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+	if (fixColumn) hideFirstColumn ();
+}
+
+/**
+ * Selects the items in the range specified by the given zero-relative
+ * indices in the receiver. The range of indices is inclusive.
+ * The current selection is not cleared before the new items are selected.
+ * <p>
+ * If an item in the given range is not selected, it is selected.
+ * If an item in the given range was already selected, it remains selected.
+ * Indices that are out of range are ignored and no items will be selected
+ * if start is greater than end.
+ * If the receiver is single-select and there is more than one item in the
+ * given range, then all indices are ignored.
+ * </p>
+ *
+ * @param start the start of the range
+ * @param end the end of the range
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see Table#setSelection(int,int)
+ */
+public void select (int start, int end) {
+	checkWidget ();
+	if (end < 0 || start > end || ((style & SWT.SINGLE) != 0 && start != end)) return;
+	if (itemCount == 0 || start >= itemCount) return;
+	start = Math.max (0, start);
+	end = Math.min (end, itemCount - 1);
+	boolean fixColumn = showFirstColumn ();
+	int /*long*/ selection = OS.gtk_tree_view_get_selection (handle);
+	OS.g_signal_handlers_block_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+	for (int index=start; index<=end; index++) {
+		TableItem item = _getItem (index);
+		OS.gtk_tree_selection_select_iter (selection, item.handle);
+		if ((style & SWT.SINGLE) != 0) {
+			int /*long*/ path = OS.gtk_tree_model_get_path (modelHandle, item.handle);
+			OS.gtk_tree_view_set_cursor (handle, path, 0, false);
+			OS.gtk_tree_path_free (path);
+		}
+	}
+	OS.g_signal_handlers_unblock_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+	if (fixColumn) hideFirstColumn ();
+}
+
+/**
+ * Selects the items at the given zero-relative indices in the receiver.
+ * The current selection is not cleared before the new items are selected.
+ * <p>
+ * If the item at a given index is not selected, it is selected.
+ * If the item at a given index was already selected, it remains selected.
+ * Indices that are out of range and duplicate indices are ignored.
+ * If the receiver is single-select and multiple indices are specified,
+ * then all indices are ignored.
+ * </p>
+ *
+ * @param indices the array of indices for the items to select
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the array of indices is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see Table#setSelection(int[])
+ */
+public void select (int [] indices) {
+	checkWidget ();
+	if (indices == null) error (SWT.ERROR_NULL_ARGUMENT);
+	int length = indices.length;
+	if (length == 0 || ((style & SWT.SINGLE) != 0 && length > 1)) return;
+	boolean fixColumn = showFirstColumn ();
+	int /*long*/ selection = OS.gtk_tree_view_get_selection (handle);
+	OS.g_signal_handlers_block_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+	for (int i=0; i<length; i++) {
+		int index = indices [i];
+		if (!(0 <= index && index < itemCount)) continue;
+		TableItem item = _getItem (index);
+		OS.gtk_tree_selection_select_iter (selection, item.handle);
+		if ((style & SWT.SINGLE) != 0) {
+			int /*long*/ path = OS.gtk_tree_model_get_path (modelHandle, item.handle);
+			OS.gtk_tree_view_set_cursor (handle, path, 0, false);
+			OS.gtk_tree_path_free (path);
+		}
+	}
+	OS.g_signal_handlers_unblock_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+	if (fixColumn) hideFirstColumn ();
+}
+
+/**
+ * Selects all of the items in the receiver.
+ * <p>
+ * If the receiver is single-select, do nothing.
+ * </p>
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void selectAll () {
+	checkWidget();
+	if ((style & SWT.SINGLE) != 0) return;
+	boolean fixColumn = showFirstColumn ();
+	int /*long*/ selection = OS.gtk_tree_view_get_selection (handle);
+	OS.g_signal_handlers_block_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+	OS.gtk_tree_selection_select_all (selection);
+	OS.g_signal_handlers_unblock_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+	if (fixColumn) hideFirstColumn ();
+}
+
+void selectFocusIndex (int index) {
+	/*
+	* Note that this method both selects and sets the focus to the
+	* specified index, so any previous selection in the list will be lost.
+	* gtk does not provide a way to just set focus to a specified list item.
+	*/
+	if (!(0 <= index && index < itemCount))  return;
+	TableItem item = _getItem (index);
+	int /*long*/ path = OS.gtk_tree_model_get_path (modelHandle, item.handle);
+	int /*long*/ selection = OS.gtk_tree_view_get_selection (handle);
+	OS.g_signal_handlers_block_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+	OS.gtk_tree_view_set_cursor (handle, path, 0, false);
+	/*
+	* Bug in GTK. For some reason, when an event loop is run from
+	* within a key pressed handler and a dialog is displayed that
+	* contains a GtkTreeView,  gtk_tree_view_set_cursor() does
+	* not set the cursor or select the item.  The fix is to select the
+	* item with gtk_tree_selection_select_iter() as well.
+	* 
+	* NOTE: This happens in GTK 2.2.1 and is fixed in GTK 2.2.4.
+	*/
+	OS.gtk_tree_selection_select_iter (selection, item.handle);
+	OS.g_signal_handlers_unblock_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+	OS.gtk_tree_path_free (path);
+}
+
+void setBackgroundColor (GdkColor color) {
+	super.setBackgroundColor (color);
+	OS.gtk_widget_modify_base (handle, 0, color);
+}
+
+void setBackgroundPixmap (int /*long*/ pixmap) {
+	super.setBackgroundPixmap (pixmap);
+	int /*long*/ window = paintWindow ();
+	if (window != 0) OS.gdk_window_set_back_pixmap (window, 0, true);	
+}
+
+int setBounds (int x, int y, int width, int height, boolean move, boolean resize) {
+	int result = super.setBounds (x, y, width, height, move, resize);
+	/*
+	* Bug on GTK.  The tree view sometimes does not get a paint
+	* event or resizes to a one pixel square when resized in a new
+	* shell that is not visible after any event loop has been run.  The
+	* problem is intermittent. It doesn't seem to happen the first time
+	* a new shell is created. The fix is to ensure the tree view is realized
+	* after it has been resized.
+	*/
+	OS.gtk_widget_realize (handle);
+	/*
+	* Bug in GTK.  An empty GtkTreeView fails to repaint the focus rectangle
+	* correctly when resized on versions before 2.6.0.  The fix is to force
+	* the widget to redraw.
+	*/
+	if (OS.GTK_VERSION < OS.VERSION (2, 6, 0) && itemCount == 0) redraw (false);
+	return result;
+}
+
+/**
+ * Sets the order that the items in the receiver should 
+ * be displayed in to the given argument which is described
+ * in terms of the zero-relative ordering of when the items
+ * were added.
+ *
+ * @param order the new order to display the items
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the item order is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the item order is not the same length as the number of items</li>
+ * </ul>
+ * 
+ * @see Table#getColumnOrder()
+ * @see TableColumn#getMoveable()
+ * @see TableColumn#setMoveable(boolean)
+ * @see SWT#Move
+ * 
+ * @since 3.1
+ */
+public void setColumnOrder (int [] order) {
+	checkWidget ();
+	if (order == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if (columnCount == 0) {
+		if (order.length > 0) error (SWT.ERROR_INVALID_ARGUMENT);
+		return;
+	}
+	if (order.length != columnCount) error (SWT.ERROR_INVALID_ARGUMENT);
+	boolean [] seen = new boolean [columnCount];
+	for (int i = 0; i<order.length; i++) {
+		int index = order [i];
+		if (index < 0 || index >= columnCount) error (SWT.ERROR_INVALID_RANGE);
+		if (seen [index]) error (SWT.ERROR_INVALID_ARGUMENT);
+		seen [index] = true;
+	}
+	for (int i=0; i<order.length; i++) {
+		int /*long*/ column = columns [order [i]].handle;
+		int /*long*/ baseColumn = i == 0 ? 0 : columns [order [i-1]].handle;
+		OS.gtk_tree_view_move_column_after (handle, column, baseColumn);
+	}
+}
+
+void setFontDescription (int /*long*/ font) {
+	super.setFontDescription (font);
+	TableColumn[] columns = getColumns ();
+	for (int i = 0; i < columns.length; i++) {
+		if (columns[i] != null) {
+			columns[i].setFontDescription (font);
+		}
+	}
+}
+
+/**
+ * Marks the receiver's header as visible if the argument is <code>true</code>,
+ * and marks it invisible otherwise. 
+ * <p>
+ * If one of the receiver's ancestors is not visible or some
+ * other condition makes the receiver not visible, marking
+ * it visible may not actually cause it to be displayed.
+ * </p>
+ *
+ * @param show the new visibility state
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setHeaderVisible (boolean show) {
+	checkWidget ();
+	OS.gtk_tree_view_set_headers_visible (handle, show);
+}
+
+/**
+ * Sets the number of items contained in the receiver.
+ *
+ * @param count the number of items
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 3.0
+ */
+public void setItemCount (int count) {
+	checkWidget ();
+	count = Math.max (0, count);
+	if (count == itemCount) return;
+	boolean isVirtual = (style & SWT.VIRTUAL) != 0;
+	if (!isVirtual) setRedraw (false);
+	remove (count, itemCount - 1);
+	int length = Math.max (4, (count + 3) / 4 * 4);
+	TableItem [] newItems = new TableItem [length];
+	System.arraycopy (items, 0, newItems, 0, itemCount);
+	items = newItems;
+	if (isVirtual) {
+		int /*long*/ iter = OS.g_malloc (OS.GtkTreeIter_sizeof ());
+		if (iter == 0) error (SWT.ERROR_NO_HANDLES);
+		for (int i=itemCount; i<count; i++) {
+			OS.gtk_list_store_append (modelHandle, iter);
+		}
+		OS.g_free (iter);
+		itemCount = count;
+	} else {
+		for (int i=itemCount; i<count; i++) {
+			new TableItem (this, SWT.NONE, i, true);
+		}
+	}
+	if (!isVirtual) setRedraw (true);
+}
+
+/**
+ * Marks the receiver's lines as visible if the argument is <code>true</code>,
+ * and marks it invisible otherwise. 
+ * <p>
+ * If one of the receiver's ancestors is not visible or some
+ * other condition makes the receiver not visible, marking
+ * it visible may not actually cause it to be displayed.
+ * </p>
+ *
+ * @param show the new visibility state
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setLinesVisible (boolean show) {
+	checkWidget();
+	OS.gtk_tree_view_set_rules_hint (handle, show);
+}
+
+void setParentBackground () {
+	super.setParentBackground ();
+	int /*long*/ window = paintWindow ();
+	if (window != 0) OS.gdk_window_set_back_pixmap (window, 0, true);
+}
+
+void setParentWindow (int /*long*/ widget) {
+	int /*long*/ window = eventWindow ();
+	OS.gtk_widget_set_parent_window (widget, window);
+}
+
+public void setRedraw (boolean redraw) {
+	checkWidget();
+	super.setRedraw (redraw);
+	if (redraw && drawCount == 0) {
+		/* Resize the item array to match the item count */
+		if (items.length > 4 && items.length - itemCount > 3) {
+			int length = Math.max (4, (itemCount + 3) / 4 * 4);
+			TableItem [] newItems = new TableItem [length];
+			System.arraycopy (items, 0, newItems, 0, itemCount);
+			items = newItems;
+		}
+	}
+}
+
+void setScrollWidth (int /*long*/ column, TableItem item) {
+	if (columnCount != 0 || currentItem == item) return;
+	/*
+	* Use GTK_TREE_VIEW_COLUMN_GROW_ONLY on GTK versions < 2.3.2
+	* because fixed_height_mode is not supported.
+	*/
+	if (((style & SWT.VIRTUAL) != 0) && OS.GTK_VERSION < OS.VERSION (2, 3, 2)) return;
+	int width = OS.gtk_tree_view_column_get_fixed_width (column);
+	int itemWidth = calculateWidth (column, item.handle);
+	if (width < itemWidth) {
+		OS.gtk_tree_view_column_set_fixed_width (column, itemWidth);
+	}
+}
+
+/**
+ * Sets the column used by the sort indicator for the receiver. A null
+ * value will clear the sort indicator.  The current sort column is cleared 
+ * before the new column is set.
+ *
+ * @param column the column used by the sort indicator or <code>null</code>
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the column is disposed</li> 
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.2
+ */
+public void setSortColumn (TableColumn column) {
+	checkWidget ();
+	if (column != null && column.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT);
+	if (sortColumn != null && !sortColumn.isDisposed()) {
+		OS.gtk_tree_view_column_set_sort_indicator (sortColumn.handle, false);
+	}
+	sortColumn = column;
+	if (sortColumn != null && sortDirection != SWT.NONE) {
+		OS.gtk_tree_view_column_set_sort_indicator (sortColumn.handle, true);
+		OS.gtk_tree_view_column_set_sort_order (sortColumn.handle, sortDirection == SWT.DOWN ? 0 : 1);
+	}
+}
+
+/**
+ * Sets the direction of the sort indicator for the receiver. The value 
+ * can be one of <code>UP</code>, <code>DOWN</code> or <code>NONE</code>.
+ *
+ * @param direction the direction of the sort indicator 
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.2
+ */
+public void setSortDirection  (int direction) {
+	checkWidget ();
+	if (direction != SWT.UP && direction != SWT.DOWN && direction != SWT.NONE) return;
+	sortDirection = direction;
+	if (sortColumn == null || sortColumn.isDisposed ()) return;
+	if (sortDirection == SWT.NONE) {
+		OS.gtk_tree_view_column_set_sort_indicator (sortColumn.handle, false);
+	} else {
+		OS.gtk_tree_view_column_set_sort_indicator (sortColumn.handle, true);
+		OS.gtk_tree_view_column_set_sort_order (sortColumn.handle, sortDirection == SWT.DOWN ? 0 : 1);
+	}
+}
+
+/**
+ * Selects the item at the given zero-relative index in the receiver. 
+ * The current selection is first cleared, then the new item is selected.
+ *
+ * @param index the index of the item to select
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see Table#deselectAll()
+ * @see Table#select(int)
+ */
+public void setSelection (int index) {
+	checkWidget ();
+	boolean fixColumn = showFirstColumn ();
+	deselectAll ();
+	selectFocusIndex (index);
+	showSelection ();
+	if (fixColumn) hideFirstColumn ();
+}
+
+/**
+ * Selects the items in the range specified by the given zero-relative
+ * indices in the receiver. The range of indices is inclusive.
+ * The current selection is cleared before the new items are selected.
+ * <p>
+ * Indices that are out of range are ignored and no items will be selected
+ * if start is greater than end.
+ * If the receiver is single-select and there is more than one item in the
+ * given range, then all indices are ignored.
+ * </p>
+ * 
+ * @param start the start index of the items to select
+ * @param end the end index of the items to select
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see Table#deselectAll()
+ * @see Table#select(int,int)
+ */
+public void setSelection (int start, int end) {
+	checkWidget ();
+	deselectAll();
+	if (end < 0 || start > end || ((style & SWT.SINGLE) != 0 && start != end)) return;
+	if (itemCount == 0 || start >= itemCount) return;
+	boolean fixColumn = showFirstColumn ();
+	start = Math.max (0, start);
+	end = Math.min (end, itemCount - 1);
+	selectFocusIndex (start);
+	if ((style & SWT.MULTI) != 0) {
+		select (start, end);
+	}
+	showSelection ();
+	if (fixColumn) hideFirstColumn ();
+}
+
+/**
+ * Selects the items at the given zero-relative indices in the receiver.
+ * The current selection is cleared before the new items are selected.
+ * <p>
+ * Indices that are out of range and duplicate indices are ignored.
+ * If the receiver is single-select and multiple indices are specified,
+ * then all indices are ignored.
+ * </p>
+ *
+ * @param indices the indices of the items to select
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the array of indices is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see Table#deselectAll()
+ * @see Table#select(int[])
+ */
+public void setSelection (int [] indices) {
+	checkWidget ();
+	if (indices == null) error (SWT.ERROR_NULL_ARGUMENT);
+	deselectAll ();
+	int length = indices.length;
+	if (length == 0 || ((style & SWT.SINGLE) != 0 && length > 1)) return;
+	boolean fixColumn = showFirstColumn ();
+	selectFocusIndex (indices [0]);
+	if ((style & SWT.MULTI) != 0) {
+		select (indices);
+	}
+	showSelection ();
+	if (fixColumn) hideFirstColumn ();
+}
+
+/**
+ * Sets the receiver's selection to the given item.
+ * The current selection is cleared before the new item is selected.
+ * <p>
+ * If the item is not in the receiver, then it is ignored.
+ * </p>
+ *
+ * @param item the item to select
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the item is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the item has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.2
+ */
+public void setSelection (TableItem item) {
+	if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
+	setSelection (new TableItem [] {item});
+}
+
+
+/**
+ * Sets the receiver's selection to be the given array of items.
+ * The current selection is cleared before the new items are selected.
+ * <p>
+ * Items that are not in the receiver are ignored.
+ * If the receiver is single-select and multiple items are specified,
+ * then all items are ignored.
+ * </p>
+ *
+ * @param items the array of items
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the array of items is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if one of the items has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see Table#deselectAll()
+ * @see Table#select(int[])
+ * @see Table#setSelection(int[])
+ */
+public void setSelection (TableItem [] items) {
+	checkWidget ();
+	if (items == null) error (SWT.ERROR_NULL_ARGUMENT);
+	boolean fixColumn = showFirstColumn ();
+	deselectAll ();
+	int length = items.length;
+	if (!(length == 0 || ((style & SWT.SINGLE) != 0 && length > 1))) {
+		boolean first = true;
+		for (int i = 0; i < length; i++) {
+			int index = indexOf (items [i]);
+			if (index != -1) {
+				if (first) {
+					first = false;
+					selectFocusIndex (index);
+				} else {
+					select (index);
+				}
+			}
+		}
+		showSelection ();
+	}
+	if (fixColumn) hideFirstColumn ();
+}
+
+/**
+ * Sets the zero-relative index of the item which is currently
+ * at the top of the receiver. This index can change when items
+ * are scrolled or new items are added and removed.
+ *
+ * @param index the index of the top item
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setTopIndex (int index) {
+	checkWidget();
+	if (!(0 <= index && index < itemCount)) return;
+	int /*long*/ path = OS.gtk_tree_model_get_path (modelHandle, _getItem (index).handle);
+	OS.gtk_tree_view_scroll_to_cell (handle, path, 0, true, 0f, 0f);
+	if (OS.GTK_VERSION < OS.VERSION (2, 8, 0)) {
+		/*
+		* Bug in GTK.  According to the documentation, gtk_tree_view_scroll_to_cell
+		* should vertically scroll the cell to the top if use_align is true and row_align is 0.
+		* However, prior to version 2.8 it does not scroll at all.  The fix is to determine
+		* the new location and use gtk_tree_view_scroll_to_point.
+		* If the widget is a pinhead, calling gtk_tree_view_scroll_to_point
+		* will have no effect. Therefore, it is still neccessary to call 
+		* gtk_tree_view_scroll_to_cell.
+		*/
+		OS.gtk_widget_realize (handle);
+		GdkRectangle cellRect = new GdkRectangle ();
+		OS.gtk_tree_view_get_cell_area (handle, path, 0, cellRect);
+		int[] tx = new int[1], ty = new int[1];
+		OS.gtk_tree_view_widget_to_tree_coords(handle, cellRect.x, cellRect.y, tx, ty);
+		OS.gtk_tree_view_scroll_to_point (handle, -1, ty[0]);
+	}
+	OS.gtk_tree_path_free (path);
+}
+
+/**
+ * Shows the column.  If the column is already showing in the receiver,
+ * this method simply returns.  Otherwise, the columns are scrolled until
+ * the column is visible.
+ *
+ * @param column the column to be shown
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the column is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the column has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 3.0
+ */
+public void showColumn (TableColumn column) {
+	checkWidget ();
+	if (column == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if (column.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
+	if (column.parent != this) return;
+	/*
+	* This code is intentionally commented. According to the
+	* documentation, gtk_tree_view_scroll_to_cell should scroll the
+	* minimum amount to show the column but instead it scrolls strangely.
+	*/
+	//OS.gtk_tree_view_scroll_to_cell (handle, 0, column.handle, false, 0, 0);
+	OS.gtk_widget_realize (handle);
+	GdkRectangle cellRect = new GdkRectangle ();
+	OS.gtk_tree_view_get_cell_area (handle, 0, column.handle, cellRect);
+	GdkRectangle visibleRect = new GdkRectangle ();
+	OS.gtk_tree_view_get_visible_rect (handle, visibleRect);
+	if (cellRect.x < visibleRect.x) {
+		OS.gtk_tree_view_scroll_to_point (handle, cellRect.x, -1);
+	} else {
+		int width = Math.min (visibleRect.width, cellRect.width);
+		if (cellRect.x + width > visibleRect.x + visibleRect.width) {
+			int tree_x = cellRect.x + width - visibleRect.width;
+			OS.gtk_tree_view_scroll_to_point (handle, tree_x, -1);
+		}
+	}
+}
+
+boolean showFirstColumn () {	
+	/*
+	* Bug in GTK.  If no columns are visible, changing the selection
+	* will fail.  The fix is to temporarily make a column visible. 
+	*/
+	int columnCount = Math.max (1, this.columnCount);
+	for (int i=0; i<columnCount; i++) {
+		int /*long*/ column = OS.gtk_tree_view_get_column (handle, i);
+		if (OS.gtk_tree_view_column_get_visible (column)) return false;
+	}
+	int /*long*/ firstColumn = OS.gtk_tree_view_get_column (handle, 0);
+	OS.gtk_tree_view_column_set_visible (firstColumn, true);
+	return true;
+}
+
+/**
+ * Shows the item.  If the item is already showing in the receiver,
+ * this method simply returns.  Otherwise, the items are scrolled until
+ * the item is visible.
+ *
+ * @param item the item to be shown
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the item is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the item has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see Table#showSelection()
+ */
+public void showItem (TableItem item) {
+	checkWidget ();
+	if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if (item.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);
+	if (item.parent != this) return;
+	showItem (item.handle);
+}
+
+void showItem (int /*long*/ iter) {
+	int /*long*/ path = OS.gtk_tree_model_get_path (modelHandle, iter);
+	/*
+	* This code intentionally commented.
+	* Bug in GTK.  According to the documentation, gtk_tree_view_scroll_to_cell
+	* should scroll the minimum amount to show the cell if use_align is false.
+	* However, what actually happens is the cell is scrolled to the top.
+	* The fix is to determine the new location and use gtk_tree_view_scroll_to_point.
+	* If the widget is a pinhead, calling gtk_tree_view_scroll_to_point
+	* will have no effect. Therefore, it is still neccessary to 
+	* call gtk_tree_view_scroll_to_cell.
+	*/
+//	OS.gtk_tree_view_scroll_to_cell (handle, path, 0, false, 0, 0);
+	OS.gtk_widget_realize (handle);
+	GdkRectangle visibleRect = new GdkRectangle ();
+	OS.gtk_tree_view_get_visible_rect (handle, visibleRect);
+	GdkRectangle cellRect = new GdkRectangle ();
+	OS.gtk_tree_view_get_cell_area (handle, path, 0, cellRect);
+	int[] tx = new int[1], ty = new int[1];
+	OS.gtk_tree_view_widget_to_tree_coords(handle, cellRect.x, cellRect.y, tx, ty);
+	if (ty[0] < visibleRect.y ) {
+		OS.gtk_tree_view_scroll_to_cell (handle, path, 0, true, 0f, 0f);
+		OS.gtk_tree_view_scroll_to_point (handle, -1, ty[0]);
+	} else {
+		int height = Math.min (visibleRect.height, cellRect.height);
+		if (ty[0] + height > visibleRect.y + visibleRect.height) {
+			OS.gtk_tree_view_scroll_to_cell (handle, path, 0, true, 1f, 0f);
+			ty[0] += cellRect.height - visibleRect.height;
+			OS.gtk_tree_view_scroll_to_point (handle, -1, ty[0]);
+		}
+	}
+	OS.gtk_tree_path_free (path);
+}
+
+/**
+ * Shows the selection.  If the selection is already showing in the receiver,
+ * this method simply returns.  Otherwise, the items are scrolled until
+ * the selection is visible.
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see Table#showItem(TableItem)
+ */
+public void showSelection () {
+	checkWidget();
+	TableItem [] selection = getSelection ();
+	if (selection.length == 0) return;
+	TableItem item = selection [0];
+	showItem (item.handle);
+}
+
+int /*long*/ treeSelectionProc (int /*long*/ model, int /*long*/ path, int /*long*/ iter, int[] selection, int length) {
+	if (selection != null) { 
+		int /*long*/ indices = OS.gtk_tree_path_get_indices (path);
+		if (indices != 0) {
+			int [] index = new int [1];
+			OS.memmove (index, indices, 4);
+			selection [(int)/*64*/length] = index [0];
+		}
+	}
+	return 0;
+}
+
+void updateScrollBarValue (ScrollBar bar) {
+	super.updateScrollBarValue (bar);
+	/*
+	*  Bug in GTK. Scrolling changes the XWindow position
+	* and makes the child widgets appear to scroll even
+	* though when queried their position is unchanged.
+	* The fix is to queue a resize event for each child to
+	* force the position to be corrected.
+	*/
+	int /*long*/ parentHandle = parentingHandle ();
+	int /*long*/ list = OS.gtk_container_get_children (parentHandle);
+	if (list == 0) return;
+	int /*long*/ temp = list;
+	while (temp != 0) {
+		int /*long*/ widget = OS.g_list_data (temp);
+		if (widget != 0) OS.gtk_widget_queue_resize  (widget);
+		temp = OS.g_list_next (temp);
+	}
+	OS.g_list_free (list);
+}
+
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/TableColumn.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/TableColumn.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/TableColumn.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,673 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.widgets;
+
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.gtk.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.events.*;
+
+/**
+ * Instances of this class represent a column in a table widget.
+ * <p><dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>LEFT, RIGHT, CENTER</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd> Move, Resize, Selection</dd>
+ * </dl>
+ * </p><p>
+ * Note: Only one of the styles LEFT, RIGHT and CENTER may be specified.
+ * </p><p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ *
+ * @see <a href="http://www.eclipse.org/swt/snippets/#table">Table, TableItem, TableColumn snippets</a>
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public class TableColumn extends Item {
+	int /*long*/ labelHandle, imageHandle, buttonHandle;
+	Table parent;
+	int modelIndex, lastButton, lastTime, lastX, lastWidth;
+	boolean customDraw, useFixedWidth;
+	String toolTipText;
+
+/**
+ * Constructs a new instance of this class given its parent
+ * (which must be a <code>Table</code>) and a style value
+ * describing its behavior and appearance. The item is added
+ * to the end of the items maintained by its parent.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT#LEFT
+ * @see SWT#RIGHT
+ * @see SWT#CENTER
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public TableColumn (Table parent, int style) {
+	super (parent, checkStyle (style));
+	this.parent = parent;
+	createWidget (parent.getColumnCount ());
+}
+
+/**
+ * Constructs a new instance of this class given its parent
+ * (which must be a <code>Table</code>), a style value
+ * describing its behavior and appearance, and the index
+ * at which to place it in the items maintained by its parent.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ * <p>
+ * Note that due to a restriction on some platforms, the first column
+ * is always left aligned.
+ * </p>
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ * @param index the zero-relative index to store the receiver in its parent
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the parent (inclusive)</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT#LEFT
+ * @see SWT#RIGHT
+ * @see SWT#CENTER
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public TableColumn (Table parent, int style, int index) {
+	super (parent, checkStyle (style));
+	this.parent = parent;
+	createWidget (index);
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the control is moved or resized, by sending
+ * it one of the messages defined in the <code>ControlListener</code>
+ * interface.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see ControlListener
+ * @see #removeControlListener
+ */
+public void addControlListener(ControlListener listener) {
+	checkWidget();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	TypedListener typedListener = new TypedListener (listener);
+	addListener (SWT.Resize,typedListener);
+	addListener (SWT.Move,typedListener);
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the control is selected by the user, by sending
+ * it one of the messages defined in the <code>SelectionListener</code>
+ * interface.
+ * <p>
+ * <code>widgetSelected</code> is called when the column header is selected.
+ * <code>widgetDefaultSelected</code> is not called.
+ * </p>
+ *
+ * @param listener the listener which should be notified when the control is selected by the user
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent
+ */
+public void addSelectionListener (SelectionListener listener) {
+	checkWidget();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	TypedListener typedListener = new TypedListener (listener);
+	addListener (SWT.Selection,typedListener);
+	addListener (SWT.DefaultSelection,typedListener);
+}
+
+static int checkStyle (int style) {
+	return checkBits (style, SWT.LEFT, SWT.CENTER, SWT.RIGHT, 0, 0, 0);
+}
+
+protected void checkSubclass () {
+	if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
+}
+
+void createWidget (int index) {
+	parent.createItem (this, index);
+	setOrientation ();
+	hookEvents ();
+	register ();
+	text = "";
+}
+
+void deregister() {
+	super.deregister ();
+	display.removeWidget (handle);
+	if (buttonHandle != 0) display.removeWidget (buttonHandle);
+	if (labelHandle != 0) display.removeWidget (labelHandle);
+}
+
+void destroyWidget () {
+	parent.destroyItem (this);
+	releaseHandle ();
+}
+
+/**
+ * Returns a value which describes the position of the
+ * text or image in the receiver. The value will be one of
+ * <code>LEFT</code>, <code>RIGHT</code> or <code>CENTER</code>.
+ *
+ * @return the alignment 
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getAlignment () {
+	checkWidget();
+	if ((style & SWT.LEFT) != 0) return SWT.LEFT;
+	if ((style & SWT.CENTER) != 0) return SWT.CENTER;
+	if ((style & SWT.RIGHT) != 0) return SWT.RIGHT;
+	return SWT.LEFT;
+}
+
+/**
+ * Gets the moveable attribute. A column that is
+ * not moveable cannot be reordered by the user 
+ * by dragging the header but may be reordered 
+ * by the programmer.
+ *
+ * @return the moveable attribute
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see Table#getColumnOrder()
+ * @see Table#setColumnOrder(int[])
+ * @see TableColumn#setMoveable(boolean)
+ * @see SWT#Move
+ * 
+ * @since 3.1
+ */
+public boolean getMoveable() {
+	checkWidget();
+	return OS.gtk_tree_view_column_get_reorderable (handle);
+}
+
+/**
+ * Returns the receiver's parent, which must be a <code>Table</code>.
+ *
+ * @return the receiver's parent
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Table getParent () {
+	checkWidget();
+	return parent;
+}
+
+/**
+ * Gets the resizable attribute. A column that is
+ * not resizable cannot be dragged by the user but
+ * may be resized by the programmer.
+ *
+ * @return the resizable attribute
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public boolean getResizable () {
+	checkWidget();
+	return OS.gtk_tree_view_column_get_resizable (handle);
+}
+
+/**
+ * Returns the receiver's tool tip text, or null if it has
+ * not been set.
+ *
+ * @return the receiver's tool tip text
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.2
+ */
+public String getToolTipText () {
+	checkWidget();
+	return toolTipText;
+}
+
+/**
+ * Gets the width of the receiver.
+ *
+ * @return the width
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getWidth () {
+	checkWidget();
+	if (!OS.gtk_tree_view_column_get_visible (handle)) {
+		return 0;
+	}
+	if (useFixedWidth) return OS.gtk_tree_view_column_get_fixed_width (handle);
+	return OS.gtk_tree_view_column_get_width (handle);
+}
+
+int /*long*/ gtk_clicked (int /*long*/ widget) {
+	/*
+	* There is no API to get a double click on a table column.  Normally, when
+	* the mouse is double clicked, this is indicated by GDK_2BUTTON_PRESS
+	* but the table column sends the click signal on button release.  The fix is to
+	* test for double click by remembering the last click time and mouse button
+	* and testing for the double click interval.
+	*/
+	boolean doubleClick = false;
+	boolean postEvent = true;
+	int /*long*/ eventPtr = OS.gtk_get_current_event ();
+	if (eventPtr != 0) {
+		GdkEventButton gdkEvent = new GdkEventButton ();
+		OS.memmove (gdkEvent, eventPtr, GdkEventButton.sizeof);
+		OS.gdk_event_free (eventPtr);
+		switch (gdkEvent.type) {
+			case OS.GDK_BUTTON_RELEASE: {
+				int clickTime = display.getDoubleClickTime ();
+				int eventTime = gdkEvent.time, eventButton = gdkEvent.button;
+				if (lastButton == eventButton && lastTime != 0 && Math.abs (lastTime - eventTime) <= clickTime) {
+					doubleClick = true;
+				}
+				lastTime = eventTime == 0 ? 1: eventTime;
+				lastButton = eventButton;
+				break;
+			}
+			case OS.GDK_MOTION_NOTIFY: {
+				/*
+				* Bug in GTK.  Dragging a column in a GtkTreeView causes a clicked 
+				* signal to be emitted even though the mouse button was never released.
+				* The fix to ignore the signal if the current GDK event is a motion notify.
+				* The GTK bug was fixed in version 2.6
+				*/
+				if (OS.GTK_VERSION < OS.VERSION (2, 6, 0)) postEvent = false;
+				break;
+			}
+		}
+	}
+	if (postEvent) postEvent (doubleClick ? SWT.DefaultSelection : SWT.Selection);
+	return 0;
+}
+
+int /*long*/ gtk_mnemonic_activate (int /*long*/ widget, int /*long*/ arg1) {
+	return parent.gtk_mnemonic_activate (widget, arg1);
+}
+
+int /*long*/ gtk_size_allocate (int /*long*/ widget, int /*long*/ allocation) {
+	useFixedWidth = false;
+	int x = OS.GTK_WIDGET_X (widget);
+	int width = OS.GTK_WIDGET_WIDTH (widget);
+	if (x != lastX) {
+		lastX = x;
+		sendEvent (SWT.Move);
+	}
+	if (width != lastWidth) {
+		lastWidth = width;
+		sendEvent (SWT.Resize);
+	}
+	return 0;
+}
+
+void hookEvents () {
+	super.hookEvents ();
+	OS.g_signal_connect_closure (handle, OS.clicked, display.closures [CLICKED], false);
+	if (buttonHandle != 0) OS.g_signal_connect_closure_by_id (buttonHandle, display.signalIds [SIZE_ALLOCATE], 0, display.closures [SIZE_ALLOCATE], false);
+	if (labelHandle != 0) OS.g_signal_connect_closure_by_id (labelHandle, display.signalIds [MNEMONIC_ACTIVATE], 0, display.closures [MNEMONIC_ACTIVATE], false);
+}
+
+/**
+ * Causes the receiver to be resized to its preferred size.
+ * For a composite, this involves computing the preferred size
+ * from its layout, if there is one.
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ */
+public void pack () {
+	checkWidget();
+	int width = 0;
+	if (buttonHandle != 0) {
+		GtkRequisition requisition = new GtkRequisition ();
+		OS.gtk_widget_size_request (buttonHandle, requisition);
+		width = requisition.width;
+	}
+	if ((parent.style & SWT.VIRTUAL) != 0) {
+		for (int i=0; i<parent.items.length; i++) {
+			TableItem item = parent.items [i];
+			if (item != null && item.cached) {
+				width = Math.max (width, parent.calculateWidth (handle, item.handle));
+			}
+		}
+	} else {
+		int /*long*/ iter = OS.g_malloc (OS.GtkTreeIter_sizeof ());
+		if (OS.gtk_tree_model_get_iter_first (parent.modelHandle, iter)) {
+			do {
+				width = Math.max (width, parent.calculateWidth (handle, iter));
+			} while (OS.gtk_tree_model_iter_next(parent.modelHandle, iter));
+		}
+		OS.g_free (iter);
+	}
+	setWidth(width);
+}
+
+void register () {
+	super.register ();
+	display.addWidget (handle, this);
+	if (buttonHandle != 0) display.addWidget (buttonHandle, this);
+	if (labelHandle != 0) display.addWidget (labelHandle, this);
+}
+
+void releaseHandle () {
+	super.releaseHandle ();
+	handle = buttonHandle = labelHandle = imageHandle = 0;
+	modelIndex = -1; 
+	parent = null;
+}
+
+void releaseParent () {
+	super.releaseParent ();
+	if (parent.sortColumn == this) {
+		parent.sortColumn = null;
+	}
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the control is moved or resized.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see ControlListener
+ * @see #addControlListener
+ */
+public void removeControlListener (ControlListener listener) {
+	checkWidget();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if (eventTable == null) return;
+	eventTable.unhook (SWT.Move, listener);
+	eventTable.unhook (SWT.Resize, listener);
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the control is selected by the user.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #addSelectionListener
+ */
+public void removeSelectionListener(SelectionListener listener) {
+	checkWidget();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if (eventTable == null) return;
+	eventTable.unhook (SWT.Selection, listener);
+	eventTable.unhook (SWT.DefaultSelection,listener);	
+}
+
+/**
+ * Controls how text and images will be displayed in the receiver.
+ * The argument should be one of <code>LEFT</code>, <code>RIGHT</code>
+ * or <code>CENTER</code>.
+ * <p>
+ * Note that due to a restriction on some platforms, the first column
+ * is always left aligned.
+ * </p>
+ * @param alignment the new alignment 
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setAlignment (int alignment) {
+	checkWidget();
+	if ((alignment & (SWT.LEFT | SWT.RIGHT | SWT.CENTER)) == 0) return;
+	int index = parent.indexOf (this);
+	if (index == -1 || index == 0) return;
+	style &= ~(SWT.LEFT | SWT.RIGHT | SWT.CENTER);
+	style |= alignment & (SWT.LEFT | SWT.RIGHT | SWT.CENTER);
+	parent.createRenderers (handle, modelIndex, index == 0, style);
+}
+
+void setFontDescription (int /*long*/ font) {
+	OS.gtk_widget_modify_font (labelHandle, font);
+	OS.gtk_widget_modify_font (imageHandle, font);
+}
+
+public void setImage (Image image) {
+	checkWidget ();
+	super.setImage (image);
+	if (image != null) {
+		ImageList headerImageList = parent.headerImageList;
+		if (headerImageList == null) {
+			headerImageList = parent.headerImageList = new ImageList ();
+		}
+		int imageIndex = headerImageList.indexOf (image);
+		if (imageIndex == -1) imageIndex = headerImageList.add (image);
+		int /*long*/ pixbuf = headerImageList.getPixbuf (imageIndex);
+		OS.gtk_image_set_from_pixbuf (imageHandle, pixbuf);
+		OS.gtk_widget_show (imageHandle);
+	} else {
+		OS.gtk_image_set_from_pixbuf (imageHandle, 0);
+		OS.gtk_widget_hide (imageHandle);
+	}
+}
+
+/**
+ * Sets the resizable attribute.  A column that is
+ * resizable can be resized by the user dragging the
+ * edge of the header.  A column that is not resizable 
+ * cannot be dragged by the user but may be resized 
+ * by the programmer.
+ *
+ * @param resizable the resize attribute
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setResizable (boolean resizable) {
+	checkWidget();
+	OS.gtk_tree_view_column_set_resizable (handle, resizable);
+}
+
+/**
+ * Sets the moveable attribute.  A column that is
+ * moveable can be reordered by the user by dragging
+ * the header. A column that is not moveable cannot be 
+ * dragged by the user but may be reordered 
+ * by the programmer.
+ *
+ * @param moveable the moveable attribute
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see Table#setColumnOrder(int[])
+ * @see Table#getColumnOrder()
+ * @see TableColumn#getMoveable()
+ * @see SWT#Move
+ * 
+ * @since 3.1
+ */
+public void setMoveable (boolean moveable) {
+	checkWidget();
+	OS.gtk_tree_view_column_set_reorderable (handle, moveable);
+}
+
+void setOrientation() {
+	if ((parent.style & SWT.RIGHT_TO_LEFT) != 0) {
+		if (buttonHandle != 0) {
+			OS.gtk_widget_set_direction (buttonHandle, OS.GTK_TEXT_DIR_RTL);
+			OS.gtk_container_forall (buttonHandle, display.setDirectionProc, OS.GTK_TEXT_DIR_RTL);	
+		}
+	}
+}
+
+public void setText (String string) {
+	checkWidget();
+	if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+	super.setText (string);
+	char [] chars = fixMnemonic (string);
+	byte [] buffer = Converter.wcsToMbcs (null, chars, true);
+	OS.gtk_label_set_text_with_mnemonic (labelHandle, buffer);
+	if (string.length () != 0) {
+		OS.gtk_widget_show (labelHandle);
+	} else {
+		OS.gtk_widget_hide (labelHandle);
+	}
+}
+
+/**
+ * Sets the receiver's tool tip text to the argument, which
+ * may be null indicating that no tool tip text should be shown.
+ *
+ * @param string the new tool tip text (or null)
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.2
+ */
+public void setToolTipText (String string) {
+	checkWidget();
+	Shell shell = parent._getShell ();
+	setToolTipText (shell, string);
+	toolTipText = string;
+}
+
+void setToolTipText (Shell shell, String newString) {
+	shell.setToolTipText (buttonHandle, newString);
+}
+
+/**
+ * Sets the width of the receiver.
+ *
+ * @param width the new width
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setWidth (int width) {
+	checkWidget();
+	if (width < 0) return;
+	if (width == lastWidth) return;
+	if (width > 0) {
+		useFixedWidth = true;
+		OS.gtk_tree_view_column_set_fixed_width (handle, width);
+	}
+	/*
+	 * Bug in GTK.  For some reason, calling gtk_tree_view_column_set_visible()
+	 * when the parent is not realized fails to show the column. The fix is to
+	 * ensure that the table has been realized.
+	 */
+	if (width != 0) OS.gtk_widget_realize (parent.handle);
+	OS.gtk_tree_view_column_set_visible (handle, width != 0);
+	lastWidth = width;
+	sendEvent (SWT.Resize);
+}
+
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/TableItem.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/TableItem.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/TableItem.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,1323 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.widgets;
+
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.gtk.*;
+import org.eclipse.swt.graphics.*;
+
+/**
+ * Instances of this class represent a selectable user interface object
+ * that represents an item in a table.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>(none)</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>(none)</dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ *
+ * @see <a href="http://www.eclipse.org/swt/snippets/#table">Table, TableItem, TableColumn snippets</a>
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public class TableItem extends Item {
+	Table parent;
+	Font font;
+	Font[] cellFont;
+	boolean cached, grayed;
+	
+/**
+ * Constructs a new instance of this class given its parent
+ * (which must be a <code>Table</code>), a style value
+ * describing its behavior and appearance, and the index
+ * at which to place it in the items maintained by its parent.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ * @param index the zero-relative index to store the receiver in its parent
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the parent (inclusive)</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public TableItem (Table parent, int style, int index) {
+	this (parent, style, index, true);
+}
+
+/**
+ * Constructs a new instance of this class given its parent
+ * (which must be a <code>Table</code>) and a style value
+ * describing its behavior and appearance. The item is added
+ * to the end of the items maintained by its parent.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public TableItem (Table parent, int style) {
+	this (parent, style, checkNull (parent).getItemCount (), true);
+}
+
+
+TableItem (Table parent, int style, int index, boolean create) {
+	super (parent, style);
+	this.parent = parent;
+	if (create) {
+		parent.createItem (this, index);
+	} else {
+		handle = OS.g_malloc (OS.GtkTreeIter_sizeof ());
+		OS.gtk_tree_model_iter_nth_child (parent.modelHandle, handle, 0, index);
+	}
+}
+
+static Table checkNull (Table control) {
+	if (control == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+	return control;
+}
+
+Color _getBackground () {
+	int /*long*/ [] ptr = new int /*long*/ [1];
+	OS.gtk_tree_model_get (parent.modelHandle, handle, Table.BACKGROUND_COLUMN, ptr, -1);
+	if (ptr [0] == 0) return parent.getBackground ();
+	GdkColor gdkColor = new GdkColor ();
+	OS.memmove (gdkColor, ptr [0], GdkColor.sizeof);
+	return Color.gtk_new (display, gdkColor);
+}
+
+Color _getBackground (int index) {
+	int count = Math.max (1, parent.columnCount);
+	if (0 > index || index > count - 1) return _getBackground ();
+	int /*long*/ [] ptr = new int /*long*/ [1];
+	int modelIndex = parent.columnCount == 0 ? Table.FIRST_COLUMN : parent.columns [index].modelIndex;
+	OS.gtk_tree_model_get (parent.modelHandle, handle, modelIndex + Table.CELL_BACKGROUND, ptr, -1);
+	if (ptr [0] == 0) return _getBackground ();
+	GdkColor gdkColor = new GdkColor ();
+	OS.memmove (gdkColor, ptr [0], GdkColor.sizeof);
+	return Color.gtk_new (display, gdkColor);
+}
+
+boolean _getChecked () {
+	int /*long*/ [] ptr = new int /*long*/ [1];
+	OS.gtk_tree_model_get (parent.modelHandle, handle, Table.CHECKED_COLUMN, ptr, -1);
+	return ptr [0] != 0;
+}
+
+Color _getForeground () {
+	int /*long*/ [] ptr = new int /*long*/ [1];
+	OS.gtk_tree_model_get (parent.modelHandle, handle, Table.FOREGROUND_COLUMN, ptr, -1);
+	if (ptr [0] == 0) return parent.getForeground ();
+	GdkColor gdkColor = new GdkColor ();
+	OS.memmove (gdkColor, ptr [0], GdkColor.sizeof);
+	return Color.gtk_new (display, gdkColor);
+}
+
+Color _getForeground (int index) {
+	int count = Math.max (1, parent.columnCount);
+	if (0 > index || index > count - 1) return _getForeground ();
+	int /*long*/ [] ptr = new int /*long*/ [1];
+	int modelIndex =  parent.columnCount == 0 ? Table.FIRST_COLUMN : parent.columns [index].modelIndex;
+	OS.gtk_tree_model_get (parent.modelHandle, handle, modelIndex + Table.CELL_FOREGROUND, ptr, -1);
+	if (ptr [0] == 0) return _getForeground ();
+	GdkColor gdkColor = new GdkColor ();
+	OS.memmove (gdkColor, ptr [0], GdkColor.sizeof);
+	return Color.gtk_new (display, gdkColor);
+}
+
+Image _getImage (int index) {
+	int count = Math.max (1, parent.getColumnCount ());
+	if (0 > index || index > count - 1) return null;
+	int /*long*/ [] ptr = new int /*long*/ [1];
+	int modelIndex = parent.columnCount == 0 ? Table.FIRST_COLUMN : parent.columns [index].modelIndex;
+	OS.gtk_tree_model_get (parent.modelHandle, handle, modelIndex + Table.CELL_PIXBUF, ptr, -1);
+	if (ptr [0] == 0) return null;
+	ImageList imageList = parent.imageList;
+	int imageIndex = imageList.indexOf (ptr [0]);
+	if (imageIndex == -1) return null;
+	return imageList.get (imageIndex);
+}
+
+String _getText (int index) {
+	int count = Math.max (1, parent.getColumnCount ());
+	if (0 > index || index > count - 1) return "";
+	int /*long*/ [] ptr = new int /*long*/ [1];
+	int modelIndex = parent.columnCount == 0 ? Table.FIRST_COLUMN : parent.columns [index].modelIndex;
+	OS.gtk_tree_model_get (parent.modelHandle, handle, modelIndex + Table.CELL_TEXT, ptr, -1);
+	if (ptr [0] == 0) return "";
+	int length = OS.strlen (ptr [0]);
+	byte[] buffer = new byte [length];
+	OS.memmove (buffer, ptr [0], length);
+	OS.g_free (ptr [0]);
+	return new String (Converter.mbcsToWcs (null, buffer));
+}
+
+protected void checkSubclass () {
+	if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
+}
+
+void clear () {
+	if (parent.currentItem == this) return;
+	if (cached || (parent.style & SWT.VIRTUAL) == 0) {
+		int columnCount = OS.gtk_tree_model_get_n_columns (parent.modelHandle);
+		for (int i=0; i<columnCount; i++) {
+			OS.gtk_list_store_set (parent.modelHandle, handle, i, 0, -1);
+		}
+		/*
+		* Bug in GTK.  When using fixed-height-mode,
+		* row changes do not cause the row to be repainted.  The fix is to
+		* invalidate the row when it is cleared.
+		*/
+		if ((parent.style & SWT.VIRTUAL) != 0) {
+			if (OS.GTK_VERSION >= OS.VERSION (2, 3, 2) && OS.GTK_VERSION < OS.VERSION (2, 6, 3)) {
+				redraw ();
+			}
+		}
+	}
+	cached = false;
+	font = null;
+	cellFont = null;
+}
+
+void destroyWidget () {
+	parent.destroyItem (this);
+	releaseHandle ();
+}
+
+/**
+ * Returns the receiver's background color.
+ *
+ * @return the background color
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 2.0
+ */
+public Color getBackground () {
+	checkWidget ();
+	if (!parent.checkData (this)) error (SWT.ERROR_WIDGET_DISPOSED);
+	return _getBackground ();
+}
+
+/**
+ * Returns a rectangle describing the receiver's size and location
+ * relative to its parent.
+ *
+ * @return the receiver's bounding rectangle
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.2
+ */
+public Rectangle getBounds () {
+	// TODO fully test on early and later versions of GTK
+	// shifted a bit too far right on later versions of GTK - however, old Tree also had this problem
+	checkWidget ();
+	if (!parent.checkData (this)) error (SWT.ERROR_WIDGET_DISPOSED);
+	int /*long*/ parentHandle = parent.handle;
+	int /*long*/ column = OS.gtk_tree_view_get_column (parentHandle, 0);
+	if (column == 0) return new Rectangle (0, 0, 0, 0);
+	int /*long*/ textRenderer = parent.getTextRenderer (column);
+	int /*long*/ pixbufRenderer = parent.getPixbufRenderer (column);
+	if (textRenderer == 0 || pixbufRenderer == 0)  return new Rectangle (0, 0, 0, 0);
+
+	int /*long*/ path = OS.gtk_tree_model_get_path (parent.modelHandle, handle);
+	OS.gtk_widget_realize (parentHandle);
+	
+	boolean isExpander = OS.gtk_tree_model_iter_n_children (parent.modelHandle, handle) > 0;
+	boolean isExpanded = OS.gtk_tree_view_row_expanded (parentHandle, path);
+	OS.gtk_tree_view_column_cell_set_cell_data (column, parent.modelHandle, handle, isExpander, isExpanded);
+	
+	GdkRectangle rect = new GdkRectangle ();
+	OS.gtk_tree_view_get_cell_area (parentHandle, path, column, rect);
+	OS.gtk_tree_path_free (path);
+	if ((parent.getStyle () & SWT.MIRRORED) != 0) rect.x = parent.getClientWidth () - rect.width - rect.x;
+	int right = rect.x + rect.width;
+
+	int [] x = new int [1], w = new int [1];
+	parent.ignoreSize = true;
+	OS.gtk_cell_renderer_get_size (textRenderer, parentHandle, null, null, null, w, null);
+	parent.ignoreSize = false;
+	rect.width = w [0];
+	int [] buffer = new int [1];
+	if (OS.gtk_tree_view_get_expander_column (parentHandle) == column) {
+		OS.gtk_widget_style_get (parentHandle, OS.expander_size, buffer, 0);
+		rect.x += buffer [0] + TreeItem.EXPANDER_EXTRA_PADDING;
+	}
+	OS.gtk_widget_style_get (parentHandle, OS.horizontal_separator, buffer, 0);
+	int horizontalSeparator = buffer[0];
+	rect.x += horizontalSeparator;
+	
+	if (OS.GTK_VERSION >= OS.VERSION (2, 1, 3)) {
+		OS.gtk_tree_view_column_cell_get_position (column, textRenderer, x, null);
+		rect.x += x [0];
+	} else {
+		if ((parent.style & SWT.CHECK) != 0) {
+			OS.gtk_cell_renderer_get_size (parent.checkRenderer, parentHandle, null, null, null, w, null);
+			rect.x += w [0] + horizontalSeparator;
+		}
+		OS.gtk_cell_renderer_get_size (pixbufRenderer, parentHandle, null, null, null, w, null);
+		rect.x += w [0] + horizontalSeparator;
+	}
+	if (parent.columnCount > 0) {
+		if (rect.x + rect.width > right) {
+			rect.width = Math.max (0, right - rect.x);
+		}
+	}
+	int width = OS.gtk_tree_view_column_get_visible (column) ? rect.width + 1 : 0;
+	return new Rectangle (rect.x, rect.y, width, rect.height + 1);
+}
+
+/**
+ * Returns the background color at the given column index in the receiver.
+ *
+ * @param index the column index
+ * @return the background color
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.0
+ */
+public Color getBackground (int index) {
+	checkWidget ();
+	if (!parent.checkData (this)) error (SWT.ERROR_WIDGET_DISPOSED);
+	return _getBackground (index);
+}
+
+/**
+ * Returns a rectangle describing the receiver's size and location
+ * relative to its parent at a column in the table.
+ *
+ * @param index the index that specifies the column
+ * @return the receiver's bounding column rectangle
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Rectangle getBounds (int index) {
+	checkWidget();
+	if (!parent.checkData (this)) error (SWT.ERROR_WIDGET_DISPOSED);
+	int /*long*/ parentHandle = parent.handle;
+	int /*long*/ column = 0;
+	if (index >= 0 && index < parent.columnCount) {
+		column = parent.columns [index].handle;
+	} else {
+		column = OS.gtk_tree_view_get_column (parentHandle, index);
+	}
+	if (column == 0) return new Rectangle (0, 0, 0, 0);
+	int /*long*/ path = OS.gtk_tree_model_get_path (parent.modelHandle, handle);
+	OS.gtk_widget_realize (parentHandle);
+	GdkRectangle rect = new GdkRectangle ();
+	OS.gtk_tree_view_get_cell_area (parentHandle, path, column, rect);
+	OS.gtk_tree_path_free (path);
+	if ((parent.getStyle () & SWT.MIRRORED) != 0) rect.x = parent.getClientWidth () - rect.width - rect.x;
+	
+	if (index == 0 && (parent.style & SWT.CHECK) != 0) {
+		if (OS.GTK_VERSION >= OS.VERSION (2, 1, 3)) {
+			int [] x = new int [1], w = new int [1];
+			OS.gtk_tree_view_column_cell_get_position (column, parent.checkRenderer, x, w);
+			rect.x += x [0] + w [0];
+			rect.width -= x [0] + w [0];
+		} else {
+			int [] w = new int [1];
+			OS.gtk_cell_renderer_get_size (parent.checkRenderer, parentHandle, null, null, null, w, null);
+			int [] buffer = new int [1];
+			OS.gtk_widget_style_get (parentHandle, OS.horizontal_separator, buffer, 0);
+			rect.x += w [0]  + buffer [0];
+			rect.width -= w [0]  + buffer [0];
+		}
+	}
+	int width = OS.gtk_tree_view_column_get_visible (column) ? rect.width + 1 : 0;
+	return new Rectangle (rect.x, rect.y, width, rect.height + 1);
+}
+
+/**
+ * Returns <code>true</code> if the receiver is checked,
+ * and false otherwise.  When the parent does not have
+ * the <code>CHECK</code> style, return false.
+ *
+ * @return the checked state of the checkbox
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public boolean getChecked () {
+	checkWidget();
+	if (!parent.checkData (this)) error (SWT.ERROR_WIDGET_DISPOSED);
+	if ((parent.style & SWT.CHECK) == 0) return false;
+	return _getChecked ();
+}
+
+/**
+ * Returns the font that the receiver will use to paint textual information for this item.
+ *
+ * @return the receiver's font
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 3.0
+ */
+public Font getFont () {
+	checkWidget ();
+	if (!parent.checkData (this)) error (SWT.ERROR_WIDGET_DISPOSED);
+	return font != null ? font : parent.getFont ();
+}
+
+/**
+ * Returns the font that the receiver will use to paint textual information
+ * for the specified cell in this item.
+ *
+ * @param index the column index
+ * @return the receiver's font
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 3.0
+ */
+public Font getFont (int index) {
+	checkWidget ();
+	if (!parent.checkData (this)) error (SWT.ERROR_WIDGET_DISPOSED);
+	int count = Math.max (1, parent.columnCount);
+	if (0 > index || index > count - 1) return getFont ();
+	if (cellFont == null || cellFont [index] == null) return getFont ();
+	return cellFont [index];
+}
+
+/**
+ * Returns the foreground color that the receiver will use to draw.
+ *
+ * @return the receiver's foreground color
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 2.0
+ */
+public Color getForeground () {
+	checkWidget ();
+	if (!parent.checkData (this)) error (SWT.ERROR_WIDGET_DISPOSED);
+	return _getForeground ();
+}
+
+/**
+ * 
+ * Returns the foreground color at the given column index in the receiver.
+ *
+ * @param index the column index
+ * @return the foreground color
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.0
+ */
+public Color getForeground (int index) {
+	checkWidget ();
+	if (!parent.checkData (this)) error (SWT.ERROR_WIDGET_DISPOSED);
+	return _getForeground (index);
+}
+
+/**
+ * Returns <code>true</code> if the receiver is grayed,
+ * and false otherwise. When the parent does not have
+ * the <code>CHECK</code> style, return false.
+ *
+ * @return the grayed state of the checkbox
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public boolean getGrayed () {
+	checkWidget ();
+	if (!parent.checkData (this)) error (SWT.ERROR_WIDGET_DISPOSED);
+	if ((parent.style & SWT.CHECK) == 0) return false;
+	return grayed;
+}
+
+public Image getImage () {
+	checkWidget ();
+	if (!parent.checkData (this)) error (SWT.ERROR_WIDGET_DISPOSED);
+	return getImage (0);
+}
+
+/**
+ * Returns the image stored at the given column index in the receiver,
+ * or null if the image has not been set or if the column does not exist.
+ *
+ * @param index the column index
+ * @return the image stored at the given column index in the receiver
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Image getImage (int index) {
+	checkWidget ();
+	if (!parent.checkData (this)) error (SWT.ERROR_WIDGET_DISPOSED);
+	return _getImage (index);
+}
+
+/**
+ * Returns a rectangle describing the size and location
+ * relative to its parent of an image at a column in the
+ * table.  An empty rectangle is returned if index exceeds
+ * the index of the table's last column.
+ *
+ * @param index the index that specifies the column
+ * @return the receiver's bounding image rectangle
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Rectangle getImageBounds (int index) {
+	checkWidget ();
+	if (!parent.checkData (this)) error (SWT.ERROR_WIDGET_DISPOSED);
+	int /*long*/ parentHandle = parent.handle;
+	int /*long*/ column = 0;
+	if (index >= 0 && index < parent.columnCount) {
+		column = parent.columns [index].handle;
+	} else {
+		column = OS.gtk_tree_view_get_column (parentHandle, index);
+	}
+	if (column == 0) return new Rectangle (0, 0, 0, 0);
+	int /*long*/ pixbufRenderer = parent.getPixbufRenderer (column);
+	if (pixbufRenderer == 0)  return new Rectangle (0, 0, 0, 0);
+	GdkRectangle rect = new GdkRectangle ();
+	int /*long*/ path = OS.gtk_tree_model_get_path (parent.modelHandle, handle);
+	OS.gtk_widget_realize (parentHandle);
+	OS.gtk_tree_view_get_cell_area (parentHandle, path, column, rect);
+	OS.gtk_tree_path_free (path);
+	if ((parent.getStyle () & SWT.MIRRORED) != 0) rect.x = parent.getClientWidth () - rect.width - rect.x;
+	/*
+	* The OS call gtk_cell_renderer_get_size() provides the width of image to be drawn
+	* by the cell renderer.  If there is no image in the cell, the width is zero.  If the table contains
+	* images of varying widths, gtk_cell_renderer_get_size() will return the width of the image, 
+	* not the width of the area in which the image is drawn.
+	* New API was added in GTK 2.1.3 for determining the full width of the renderer area.
+	* For earlier versions of GTK, the result is only correct if all rows have images of the same
+	* width.
+	*/
+	if (OS.GTK_VERSION >= OS.VERSION (2, 1, 3)) {
+		int [] x = new int [1], w = new int[1];
+		OS.gtk_tree_view_column_cell_get_position (column, pixbufRenderer, x, w);
+		rect.x += x [0];
+		rect.width = w [0];
+	} else {
+		int [] w = new int [1];
+		OS.gtk_tree_view_column_cell_set_cell_data (column, parent.modelHandle, handle, false, false);
+		OS.gtk_cell_renderer_get_size (pixbufRenderer, parentHandle, null, null, null, w, null);
+		rect.width = w [0];
+	}
+	int width = OS.gtk_tree_view_column_get_visible (column) ? rect.width : 0;
+	return new Rectangle (rect.x, rect.y, width, rect.height + 1);
+}
+
+/**
+ * Gets the image indent.
+ *
+ * @return the indent
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getImageIndent () {
+	checkWidget ();
+	if (!parent.checkData (this)) error (SWT.ERROR_WIDGET_DISPOSED);
+	/* Image indent is not supported on GTK */
+	return 0;
+}
+
+String getNameText () {
+	if ((parent.style & SWT.VIRTUAL) != 0) {
+		if (!cached) return "*virtual*"; //$NON-NLS-1$
+	}
+	return super.getNameText ();
+}
+
+/**
+ * Returns the receiver's parent, which must be a <code>Table</code>.
+ *
+ * @return the receiver's parent
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Table getParent () {
+	checkWidget ();
+	return parent;
+}
+
+public String getText () {
+	checkWidget ();
+	if (!parent.checkData (this)) error (SWT.ERROR_WIDGET_DISPOSED);
+	return getText (0);
+}
+
+/**
+ * Returns the text stored at the given column index in the receiver,
+ * or empty string if the text has not been set.
+ *
+ * @param index the column index
+ * @return the text stored at the given column index in the receiver
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public String getText (int index) {
+	checkWidget ();
+	if (!parent.checkData (this)) error (SWT.ERROR_WIDGET_DISPOSED);
+	return _getText (index);
+}
+
+/**
+ * Returns a rectangle describing the size and location
+ * relative to its parent of the text at a column in the
+ * table.  An empty rectangle is returned if index exceeds
+ * the index of the table's last column.
+ *
+ * @param index the index that specifies the column
+ * @return the receiver's bounding text rectangle
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.3
+ */
+public Rectangle getTextBounds (int index) {
+	checkWidget ();
+	if (!parent.checkData (this)) error (SWT.ERROR_WIDGET_DISPOSED);
+	int count = Math.max (1, parent.getColumnCount ());
+	if (0 > index || index > count - 1) return new Rectangle (0, 0, 0, 0);
+	// TODO fully test on early and later versions of GTK
+	// shifted a bit too far right on later versions of GTK - however, old Tree also had this problem
+	int /*long*/ parentHandle = parent.handle;
+	int /*long*/ column = 0;
+	if (index >= 0 && index < parent.columnCount) {
+		column = parent.columns [index].handle;
+	} else {
+		column = OS.gtk_tree_view_get_column (parentHandle, index);
+	}
+	if (column == 0) return new Rectangle (0, 0, 0, 0);
+	int /*long*/ textRenderer = parent.getTextRenderer (column);
+	int /*long*/ pixbufRenderer = parent.getPixbufRenderer (column);
+	if (textRenderer == 0 || pixbufRenderer == 0)  return new Rectangle (0, 0, 0, 0);
+
+	int /*long*/ path = OS.gtk_tree_model_get_path (parent.modelHandle, handle);
+	OS.gtk_widget_realize (parentHandle);
+	
+	boolean isExpander = OS.gtk_tree_model_iter_n_children (parent.modelHandle, handle) > 0;
+	boolean isExpanded = OS.gtk_tree_view_row_expanded (parentHandle, path);
+	OS.gtk_tree_view_column_cell_set_cell_data (column, parent.modelHandle, handle, isExpander, isExpanded);
+	
+	GdkRectangle rect = new GdkRectangle ();
+	OS.gtk_tree_view_get_cell_area (parentHandle, path, column, rect);
+	OS.gtk_tree_path_free (path);
+	if ((parent.getStyle () & SWT.MIRRORED) != 0) rect.x = parent.getClientWidth () - rect.width - rect.x;
+	int right = rect.x + rect.width;
+
+	int [] x = new int [1], w = new int [1];
+	parent.ignoreSize = true;
+	OS.gtk_cell_renderer_get_size (textRenderer, parentHandle, null, null, null, w, null);
+	parent.ignoreSize = false;
+	int [] buffer = new int [1];
+	if (OS.gtk_tree_view_get_expander_column (parentHandle) == column) {
+		OS.gtk_widget_style_get (parentHandle, OS.expander_size, buffer, 0);
+		rect.x += buffer [0] + TreeItem.EXPANDER_EXTRA_PADDING;
+	}
+	OS.gtk_widget_style_get (parentHandle, OS.horizontal_separator, buffer, 0);
+	int horizontalSeparator = buffer[0];
+	rect.x += horizontalSeparator;
+	
+	if (OS.GTK_VERSION >= OS.VERSION (2, 1, 3)) {
+		OS.gtk_tree_view_column_cell_get_position (column, textRenderer, x, null);
+		rect.x += x [0];
+	} else {
+		if ((parent.style & SWT.CHECK) != 0) {
+			OS.gtk_cell_renderer_get_size (parent.checkRenderer, parentHandle, null, null, null, w, null);
+			rect.x += w [0] + horizontalSeparator;
+		}
+		OS.gtk_cell_renderer_get_size (pixbufRenderer, parentHandle, null, null, null, w, null);
+		rect.x += w [0] + horizontalSeparator;
+	}
+	if (parent.columnCount > 0) {
+		if (rect.x + rect.width > right) {
+			rect.width = Math.max (0, right - rect.x);
+		}
+	}
+	int width = OS.gtk_tree_view_column_get_visible (column) ? rect.width + 1 : 0;
+	return new Rectangle (rect.x, rect.y, width, rect.height + 1);
+}
+
+void redraw () {
+	if ((OS.GTK_WIDGET_FLAGS (parent.handle) & OS.GTK_REALIZED) != 0) {
+		int /*long*/ parentHandle = parent.handle;
+		int /*long*/ path = OS.gtk_tree_model_get_path (parent.modelHandle, handle);
+		GdkRectangle rect = new GdkRectangle ();
+		OS.gtk_tree_view_get_cell_area (parentHandle, path, 0, rect);
+		OS.gtk_tree_path_free (path);
+		int /*long*/ window = OS.gtk_tree_view_get_bin_window (parentHandle);
+		rect.x = 0;
+		int [] w = new int [1], h = new int [1];
+		OS.gdk_drawable_get_size (window, w, h);
+		rect.width = w [0];
+		OS.gdk_window_invalidate_rect (window, rect, false);
+	}
+}
+
+void releaseHandle () {
+	if (handle != 0) OS.g_free (handle);
+	handle = 0;
+	super.releaseHandle ();
+	parent = null;
+}
+
+void releaseWidget () {
+	super.releaseWidget ();
+	font = null;
+	cellFont = null;
+}
+
+/**
+ * Sets the receiver's background color to the color specified
+ * by the argument, or to the default system color for the item
+ * if the argument is null.
+ *
+ * @param color the new color (or null)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li> 
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 2.0
+ */
+public void setBackground (Color color) {
+	checkWidget ();
+	if (color != null && color.isDisposed ()) {
+		SWT.error (SWT.ERROR_INVALID_ARGUMENT);
+	}
+	if (_getBackground ().equals (color)) return;
+	GdkColor gdkColor = color != null ? color.handle : null;
+	OS.gtk_list_store_set (parent.modelHandle, handle, Table.BACKGROUND_COLUMN, gdkColor, -1);
+	/*
+	* Bug in GTK.  When using fixed-height-mode,
+	* row changes do not cause the row to be repainted.  The fix is to
+	* invalidate the row when it is cleared.
+	*/
+	if ((parent.style & SWT.VIRTUAL) != 0) {
+		if (OS.GTK_VERSION >= OS.VERSION (2, 3, 2) && OS.GTK_VERSION < OS.VERSION (2, 6, 3)) {
+			redraw ();
+		}
+	}
+	cached = true;
+}
+
+/**
+ * Sets the background color at the given column index in the receiver 
+ * to the color specified by the argument, or to the default system color for the item
+ * if the argument is null.
+ *
+ * @param index the column index
+ * @param color the new color (or null)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li> 
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.0
+ */
+public void setBackground (int index, Color color) {
+	checkWidget ();
+	if (color != null && color.isDisposed ()) {
+		SWT.error (SWT.ERROR_INVALID_ARGUMENT);
+	}
+	if (_getBackground (index).equals (color)) return;
+	int count = Math.max (1, parent.getColumnCount ());
+	if (0 > index || index > count - 1) return;
+	int modelIndex = parent.columnCount == 0 ? Table.FIRST_COLUMN : parent.columns [index].modelIndex;
+	GdkColor gdkColor = color != null ? color.handle : null;
+	OS.gtk_list_store_set (parent.modelHandle, handle, modelIndex + Table.CELL_BACKGROUND, gdkColor, -1);
+	/*
+	* Bug in GTK.  When using fixed-height-mode,
+	* row changes do not cause the row to be repainted.  The fix is to
+	* invalidate the row when it is cleared.
+	*/
+	if ((parent.style & SWT.VIRTUAL) != 0) {
+		if (OS.GTK_VERSION >= OS.VERSION (2, 3, 2) && OS.GTK_VERSION < OS.VERSION (2, 6, 3)) {
+			redraw ();
+		}
+	}
+	cached = true;
+	
+	if (color != null) {
+		boolean customDraw = (parent.columnCount == 0)  ? parent.firstCustomDraw : parent.columns [index].customDraw;
+		if (!customDraw) {
+			if ((parent.style & SWT.VIRTUAL) == 0) {
+				int /*long*/ parentHandle = parent.handle;
+				int /*long*/ column = 0;
+				if (parent.columnCount > 0) {
+					column = parent.columns [index].handle;
+				} else {
+					column = OS.gtk_tree_view_get_column (parentHandle, index);
+				}
+				if (column == 0) return;
+				int /*long*/ textRenderer = parent.getTextRenderer (column);
+				int /*long*/ imageRenderer = parent.getPixbufRenderer (column);
+				OS.gtk_tree_view_column_set_cell_data_func (column, textRenderer, display.cellDataProc, parentHandle, 0);
+				OS.gtk_tree_view_column_set_cell_data_func (column, imageRenderer, display.cellDataProc, parentHandle, 0);
+			}
+			if (parent.columnCount == 0) {
+				parent.firstCustomDraw = true;
+			} else {
+				parent.columns [index].customDraw = true;
+			}
+		}
+	}
+}
+
+/**
+ * Sets the checked state of the checkbox for this item.  This state change 
+ * only applies if the Table was created with the SWT.CHECK style.
+ *
+ * @param checked the new checked state of the checkbox
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setChecked (boolean checked) {
+	checkWidget();
+	if ((parent.style & SWT.CHECK) == 0) return;
+	if (_getChecked () == checked) return;
+	OS.gtk_list_store_set (parent.modelHandle, handle, Table.CHECKED_COLUMN, checked, -1);
+	/*
+	* GTK+'s "inconsistent" state does not match SWT's concept of grayed.  To
+	* show checked+grayed differently from unchecked+grayed, we must toggle the
+	* grayed state on check and uncheck. 
+	*/
+	OS.gtk_list_store_set (parent.modelHandle, handle, Table.GRAYED_COLUMN, !checked ? false : grayed, -1);
+	cached = true;
+}
+
+/**
+ * Sets the font that the receiver will use to paint textual information
+ * for this item to the font specified by the argument, or to the default font
+ * for that kind of control if the argument is null.
+ *
+ * @param font the new font (or null)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li> 
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.0
+ */
+public void setFont (Font font){
+	checkWidget ();
+	if (font != null && font.isDisposed ()) {
+		SWT.error (SWT.ERROR_INVALID_ARGUMENT);
+	}
+	Font oldFont = this.font;
+	if (oldFont == font) return;
+	this.font = font;
+	if (oldFont != null && oldFont.equals (font)) return;
+	int /*long*/ fontHandle = font != null ? font.handle : 0;
+	OS.gtk_list_store_set (parent.modelHandle, handle, Table.FONT_COLUMN, fontHandle, -1);
+	/*
+	* Bug in GTK.  When using fixed-height-mode,
+	* row changes do not cause the row to be repainted.  The fix is to
+	* invalidate the row when it is cleared.
+	*/
+	if ((parent.style & SWT.VIRTUAL) != 0) {
+		if (OS.GTK_VERSION >= OS.VERSION (2, 3, 2) && OS.GTK_VERSION < OS.VERSION (2, 6, 3)) {
+			redraw ();
+		}
+	}
+	cached = true;
+}
+
+/**
+ * Sets the font that the receiver will use to paint textual information
+ * for the specified cell in this item to the font specified by the 
+ * argument, or to the default font for that kind of control if the 
+ * argument is null.
+ *
+ * @param index the column index
+ * @param font the new font (or null)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li> 
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.0
+ */
+public void setFont (int index, Font font) {
+	checkWidget ();
+	if (font != null && font.isDisposed ()) {
+		SWT.error (SWT.ERROR_INVALID_ARGUMENT);
+	}
+	int count = Math.max (1, parent.getColumnCount ());
+	if (0 > index || index > count - 1) return;
+	if (cellFont == null) {
+		if (font == null) return;
+		cellFont = new Font [count];
+	}
+	Font oldFont = cellFont [index];
+	if (oldFont == font) return;
+	cellFont [index] = font;
+	if (oldFont != null && oldFont.equals (font)) return;
+
+	int modelIndex = parent.columnCount == 0 ? Table.FIRST_COLUMN : parent.columns [index].modelIndex;
+	int /*long*/ fontHandle  = font != null ? font.handle : 0;
+	OS.gtk_list_store_set (parent.modelHandle, handle, modelIndex + Table.CELL_FONT, fontHandle, -1);
+	/*
+	* Bug in GTK.  When using fixed-height-mode,
+	* row changes do not cause the row to be repainted.  The fix is to
+	* invalidate the row when it is cleared.
+	*/
+	if ((parent.style & SWT.VIRTUAL) != 0) {
+		if (OS.GTK_VERSION >= OS.VERSION (2, 3, 2) && OS.GTK_VERSION < OS.VERSION (2, 6, 3)) {
+			redraw ();
+		}
+	}
+	cached = true;	
+	
+	if (font != null) {
+		boolean customDraw = (parent.columnCount == 0)  ? parent.firstCustomDraw : parent.columns [index].customDraw;
+		if (!customDraw) {
+			if ((parent.style & SWT.VIRTUAL) == 0) {
+				int /*long*/ parentHandle = parent.handle;
+				int /*long*/ column = 0;
+				if (parent.columnCount > 0) {
+					column = parent.columns [index].handle;
+				} else {
+					column = OS.gtk_tree_view_get_column (parentHandle, index);
+				}
+				if (column == 0) return;
+				int /*long*/ textRenderer = parent.getTextRenderer (column);
+				int /*long*/ imageRenderer = parent.getPixbufRenderer (column);
+				OS.gtk_tree_view_column_set_cell_data_func (column, textRenderer, display.cellDataProc, parentHandle, 0);
+				OS.gtk_tree_view_column_set_cell_data_func (column, imageRenderer, display.cellDataProc, parentHandle, 0);
+			}
+			if (parent.columnCount == 0) {
+				parent.firstCustomDraw = true;
+			} else {
+				parent.columns [index].customDraw = true;
+			}
+		}
+	}
+}
+
+/**
+ * Sets the receiver's foreground color to the color specified
+ * by the argument, or to the default system color for the item
+ * if the argument is null.
+ *
+ * @param color the new color (or null)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li> 
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 2.0
+ */
+public void setForeground (Color color){
+	checkWidget ();
+	if (color != null && color.isDisposed ()) {
+		SWT.error (SWT.ERROR_INVALID_ARGUMENT);
+	}
+	if (_getForeground ().equals (color)) return;
+	GdkColor gdkColor = color != null ? color.handle : null;
+	OS.gtk_list_store_set (parent.modelHandle, handle, Table.FOREGROUND_COLUMN, gdkColor, -1);
+	/*
+	* Bug in GTK.  When using fixed-height-mode,
+	* row changes do not cause the row to be repainted.  The fix is to
+	* invalidate the row when it is cleared.
+	*/
+	if ((parent.style & SWT.VIRTUAL) != 0) {
+		if (OS.GTK_VERSION >= OS.VERSION (2, 3, 2) && OS.GTK_VERSION < OS.VERSION (2, 6, 3)) {
+			redraw ();
+		}
+	}
+	cached = true;
+}
+
+/**
+ * Sets the foreground color at the given column index in the receiver 
+ * to the color specified by the argument, or to the default system color for the item
+ * if the argument is null.
+ *
+ * @param index the column index
+ * @param color the new color (or null)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li> 
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.0
+ */
+public void setForeground (int index, Color color){
+	checkWidget ();
+	if (color != null && color.isDisposed ()) {
+		SWT.error (SWT.ERROR_INVALID_ARGUMENT);
+	}
+	if (_getForeground (index).equals (color)) return;
+	int count = Math.max (1, parent.getColumnCount ());
+	if (0 > index || index > count - 1) return;
+	int modelIndex = parent.columnCount == 0 ? Table.FIRST_COLUMN : parent.columns [index].modelIndex;
+	GdkColor gdkColor = color != null ? color.handle : null;
+	OS.gtk_list_store_set (parent.modelHandle, handle, modelIndex + Table.CELL_FOREGROUND, gdkColor, -1);
+	/*
+	* Bug in GTK.  When using fixed-height-mode,
+	* row changes do not cause the row to be repainted.  The fix is to
+	* invalidate the row when it is cleared.
+	*/
+	if ((parent.style & SWT.VIRTUAL) != 0) {
+		if (OS.GTK_VERSION >= OS.VERSION (2, 3, 2) && OS.GTK_VERSION < OS.VERSION (2, 6, 3)) {
+			redraw ();
+		}
+	}
+	cached = true;
+	
+	if (color != null) {
+		boolean customDraw = (parent.columnCount == 0)  ? parent.firstCustomDraw : parent.columns [index].customDraw;
+		if (!customDraw) {
+			if ((parent.style & SWT.VIRTUAL) == 0) {
+				int /*long*/ parentHandle = parent.handle;
+				int /*long*/ column = 0;
+				if (parent.columnCount > 0) {
+					column = parent.columns [index].handle;
+				} else {
+					column = OS.gtk_tree_view_get_column (parentHandle, index);
+				}
+				if (column == 0) return;
+				int /*long*/ textRenderer = parent.getTextRenderer (column);
+				int /*long*/ imageRenderer = parent.getPixbufRenderer (column);
+				OS.gtk_tree_view_column_set_cell_data_func (column, textRenderer, display.cellDataProc, parentHandle, 0);
+				OS.gtk_tree_view_column_set_cell_data_func (column, imageRenderer, display.cellDataProc, parentHandle, 0);
+			}
+			if (parent.columnCount == 0) {
+				parent.firstCustomDraw = true;
+			} else {
+				parent.columns [index].customDraw = true;
+			}
+		}
+	}
+}
+
+/**
+ * Sets the grayed state of the checkbox for this item.  This state change 
+ * only applies if the Table was created with the SWT.CHECK style.
+ *
+ * @param grayed the new grayed state of the checkbox; 
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setGrayed (boolean grayed) {
+	checkWidget();
+	if ((parent.style & SWT.CHECK) == 0) return;
+	if (this.grayed == grayed) return;
+	this.grayed = grayed;
+	/*
+	* GTK+'s "inconsistent" state does not match SWT's concept of grayed.
+	* Render checked+grayed as "inconsistent", unchecked+grayed as blank.
+	*/
+	int /*long*/ [] ptr = new int /*long*/ [1];
+	OS.gtk_tree_model_get (parent.modelHandle, handle, Table.CHECKED_COLUMN, ptr, -1);
+	OS.gtk_list_store_set (parent.modelHandle, handle, Table.GRAYED_COLUMN, ptr [0] == 0 ? false : grayed, -1);
+	cached = true;
+}
+
+/**
+ * Sets the receiver's image at a column.
+ *
+ * @param index the column index
+ * @param image the new image
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setImage (int index, Image image) {
+	checkWidget ();
+	if (image != null && image.isDisposed ()) {
+		error(SWT.ERROR_INVALID_ARGUMENT);
+	}
+	if (image != null && image.type == SWT.ICON) {
+		if (image.equals (_getImage (index))) return;
+	}
+	int count = Math.max (1, parent.getColumnCount ());
+	if (0 > index || index > count - 1) return;
+	int /*long*/ pixbuf = 0;
+	if (image != null) {
+		ImageList imageList = parent.imageList;
+		if (imageList == null) imageList = parent.imageList = new ImageList ();
+		int imageIndex = imageList.indexOf (image);
+		if (imageIndex == -1) imageIndex = imageList.add (image);
+		pixbuf = imageList.getPixbuf (imageIndex);
+	}
+	int modelIndex = parent.columnCount == 0 ? Table.FIRST_COLUMN : parent.columns [index].modelIndex;
+	OS.gtk_list_store_set (parent.modelHandle, handle, modelIndex + Table.CELL_PIXBUF, pixbuf, -1);
+	/*
+	* Bug in GTK.  When using fixed-height-mode,
+	* row changes do not cause the row to be repainted.  The fix is to
+	* invalidate the row when it is cleared.
+	*/
+	if ((parent.style & SWT.VIRTUAL) != 0) {
+		if (OS.GTK_VERSION >= OS.VERSION (2, 3, 2) && OS.GTK_VERSION < OS.VERSION (2, 6, 3)) {
+			redraw ();
+		}
+	}
+	/*
+	 * Bug in GTK.  When in fixed height mode, GTK does not recalculate the cell renderer width
+	 * when the image is changed in the model.  The fix is to force it to recalculate the width if
+	 * more space is required.
+	 */
+	if ((parent.style & SWT.VIRTUAL) != 0 && parent.currentItem == null) {
+		if (OS.GTK_VERSION >= OS.VERSION (2, 3, 2)) {
+			if (image != null) {
+				int /*long*/parentHandle = parent.handle;
+				int /*long*/ column = OS.gtk_tree_view_get_column (parentHandle, index);
+				int [] w = new int [1];
+				int /*long*/ pixbufRenderer = parent.getPixbufRenderer(column);
+				OS.gtk_tree_view_column_cell_get_position (column, pixbufRenderer, null, w);
+				if (w[0] < image.getBounds().width) {
+					/*
+					* There is no direct way to clear the cell renderer width so we
+					* are relying on the fact that it is done as part of modifying
+					* the style.
+					*/
+					int /*long*/ style = OS.gtk_widget_get_modifier_style (parentHandle);
+					parent.modifyStyle (parentHandle, style);
+				}
+			} 
+		}
+	}
+	cached = true;
+}
+
+public void setImage (Image image) {
+	checkWidget ();
+	setImage (0, image);
+}
+
+/**
+ * Sets the image for multiple columns in the table. 
+ * 
+ * @param images the array of new images
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the array of images is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if one of the images has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setImage (Image [] images) {
+	checkWidget ();
+	if (images == null) error (SWT.ERROR_NULL_ARGUMENT);
+	for (int i=0; i<images.length; i++) {
+		setImage (i, images [i]);
+	}
+}
+
+/**
+ * Sets the indent of the first column's image, expressed in terms of the image's width.
+ *
+ * @param indent the new indent
+ *
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @deprecated this functionality is not supported on most platforms
+ */
+public void setImageIndent (int indent) {
+	checkWidget ();
+	if (indent < 0) return;
+	/* Image indent is not supported on GTK */
+	cached = true;
+}
+
+/**
+ * Sets the receiver's text at a column
+ *
+ * @param index the column index
+ * @param string the new text
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the text is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setText (int index, String string) {
+	checkWidget ();
+	if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if (_getText (index).equals (string)) return;
+	int count = Math.max (1, parent.getColumnCount ());
+	if (0 > index || index > count - 1) return;
+	byte[] buffer = Converter.wcsToMbcs (null, string, true);
+	int modelIndex = parent.columnCount == 0 ? Table.FIRST_COLUMN : parent.columns [index].modelIndex;
+	OS.gtk_list_store_set (parent.modelHandle, handle, modelIndex + Table.CELL_TEXT, buffer, -1);
+	/*
+	* Bug in GTK.  When using fixed-height-mode,
+	* row changes do not cause the row to be repainted.  The fix is to
+	* invalidate the row when it is cleared.
+	*/
+	if ((parent.style & SWT.VIRTUAL) != 0) {
+		if (OS.GTK_VERSION >= OS.VERSION (2, 3, 2) && OS.GTK_VERSION < OS.VERSION (2, 6, 3)) {
+			redraw ();
+		}
+	}
+	cached = true;
+}
+
+public void setText (String string) {
+	checkWidget ();
+	setText (0, string);
+}
+
+/**
+ * Sets the text for multiple columns in the table. 
+ * 
+ * @param strings the array of new strings
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the text is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setText (String [] strings) {
+	checkWidget ();
+	if (strings == null) error (SWT.ERROR_NULL_ARGUMENT);
+	for (int i=0; i<strings.length; i++) {
+		String string = strings [i];
+		if (string != null) setText (i, string);
+	}
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Text.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Text.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Text.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,2066 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.widgets;
+
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.gtk.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.events.*;
+
+/**
+ * Instances of this class are selectable user interface
+ * objects that allow the user to enter and modify text.
+ * Text controls can be either single or multi-line.
+ * When a text control is created with a border, the
+ * operating system includes a platform specific inset
+ * around the contents of the control.  When created
+ * without a border, an effort is made to remove the
+ * inset such that the preferred size of the control
+ * is the same size as the contents.
+ * <p>
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>CANCEL, CENTER, LEFT, MULTI, PASSWORD, SEARCH, SINGLE, RIGHT, READ_ONLY, WRAP</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>DefaultSelection, Modify, Verify</dd>
+ * </dl>
+ * <p>
+ * Note: Only one of the styles MULTI and SINGLE may be specified,
+ * and only one of the styles LEFT, CENTER, and RIGHT may be specified.
+ * </p><p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ *
+ * @see <a href="http://www.eclipse.org/swt/snippets/#text">Text snippets</a>
+ * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: ControlExample</a>
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public class Text extends Scrollable {
+	int /*long*/ bufferHandle;
+	int tabs = 8, lastEventTime = 0;
+	int /*long*/ gdkEventKey = 0;
+	int fixStart = -1, fixEnd = -1;
+	boolean doubleClick;
+	String message = "";
+	
+	static final int INNER_BORDER = 2;
+	static final int ITER_SIZEOF = OS.GtkTextIter_sizeof();
+	
+	/**
+	* The maximum number of characters that can be entered
+	* into a text widget.
+	* <p>
+	* Note that this value is platform dependent, based upon
+	* the native widget implementation.
+	* </p>
+	*/
+	public final static int LIMIT;
+	/**
+	* The delimiter used by multi-line text widgets.  When text
+	* is queried and from the widget, it will be delimited using
+	* this delimiter.
+	*/
+	public final static String DELIMITER;
+	/*
+	* These values can be different on different platforms.
+	* Therefore they are not initialized in the declaration
+	* to stop the compiler from inlining.
+	*/
+	static {
+		LIMIT = 0x7FFFFFFF;
+		DELIMITER = "\n";
+	}
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT#SINGLE
+ * @see SWT#MULTI
+ * @see SWT#READ_ONLY
+ * @see SWT#WRAP
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public Text (Composite parent, int style) {
+	super (parent, checkStyle (style));
+}
+
+static int checkStyle (int style) {
+	if ((style & SWT.SEARCH) != 0) {
+		style |= SWT.SINGLE | SWT.BORDER;
+		style &= ~SWT.PASSWORD;
+	}
+	style &= ~SWT.SEARCH;
+	if ((style & SWT.SINGLE) != 0 && (style & SWT.MULTI) != 0) {
+		style &= ~SWT.MULTI;
+	}
+	style = checkBits (style, SWT.LEFT, SWT.CENTER, SWT.RIGHT, 0, 0, 0);
+	if ((style & SWT.SINGLE) != 0) style &= ~(SWT.H_SCROLL | SWT.V_SCROLL | SWT.WRAP);
+	if ((style & SWT.WRAP) != 0) {
+		style |= SWT.MULTI;
+		style &= ~SWT.H_SCROLL;
+	}
+	if ((style & SWT.MULTI) != 0) style &= ~SWT.PASSWORD;
+	if ((style & (SWT.SINGLE | SWT.MULTI)) != 0) return style;
+	if ((style & (SWT.H_SCROLL | SWT.V_SCROLL)) != 0) return style | SWT.MULTI;
+	return style | SWT.SINGLE;
+}
+
+void createHandle (int index) {
+	state |= HANDLE | MENU;
+	fixedHandle = OS.g_object_new (display.gtk_fixed_get_type (), 0);
+	if (fixedHandle == 0) error (SWT.ERROR_NO_HANDLES);
+	OS.gtk_fixed_set_has_window (fixedHandle, true);
+	if ((style & SWT.SINGLE) != 0) {
+		handle = OS.gtk_entry_new ();
+		if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+		OS.gtk_container_add (fixedHandle, handle);
+		OS.gtk_editable_set_editable (handle, (style & SWT.READ_ONLY) == 0);
+		OS.gtk_entry_set_has_frame (handle, (style & SWT.BORDER) != 0);
+		OS.gtk_entry_set_visibility (handle, (style & SWT.PASSWORD) == 0);
+		float alignment = 0.0f;
+		if ((style & SWT.CENTER) != 0) alignment = 0.5f;
+		if ((style & SWT.RIGHT) != 0) alignment = 1.0f;
+		if (alignment > 0.0f) {
+			OS.gtk_entry_set_alignment (handle, alignment);
+		}
+	} else {
+		scrolledHandle = OS.gtk_scrolled_window_new (0, 0);
+		if (scrolledHandle == 0) error (SWT.ERROR_NO_HANDLES);
+		handle = OS.gtk_text_view_new ();
+		if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+		bufferHandle = OS.gtk_text_view_get_buffer (handle);
+		if (bufferHandle == 0) error (SWT.ERROR_NO_HANDLES);
+		OS.gtk_container_add (fixedHandle, scrolledHandle);
+		OS.gtk_container_add (scrolledHandle, handle);
+		OS.gtk_text_view_set_editable (handle, (style & SWT.READ_ONLY) == 0);
+		if ((style & SWT.WRAP) != 0) OS.gtk_text_view_set_wrap_mode (handle, OS.GTK_WRAP_WORD_CHAR);
+		int hsp = (style & SWT.H_SCROLL) != 0 ? OS.GTK_POLICY_ALWAYS : OS.GTK_POLICY_NEVER;
+		int vsp = (style & SWT.V_SCROLL) != 0 ? OS.GTK_POLICY_ALWAYS : OS.GTK_POLICY_NEVER;
+		OS.gtk_scrolled_window_set_policy (scrolledHandle, hsp, vsp);
+		if ((style & SWT.BORDER) != 0) {
+			OS.gtk_scrolled_window_set_shadow_type (scrolledHandle, OS.GTK_SHADOW_ETCHED_IN);
+		}
+		int just = OS.GTK_JUSTIFY_LEFT;
+		if ((style & SWT.CENTER) != 0) just = OS.GTK_JUSTIFY_CENTER; 
+		if ((style & SWT.RIGHT) != 0) just = OS.GTK_JUSTIFY_RIGHT;
+		OS.gtk_text_view_set_justification (handle, just);
+	}
+}
+
+void createWidget (int index) {
+	super.createWidget (index);
+	doubleClick = true;
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the receiver's text is modified, by sending
+ * it one of the messages defined in the <code>ModifyListener</code>
+ * interface.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see ModifyListener
+ * @see #removeModifyListener
+ */
+public void addModifyListener (ModifyListener listener) {
+	checkWidget ();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	TypedListener typedListener = new TypedListener (listener);
+	addListener (SWT.Modify, typedListener);
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the control is selected by the user, by sending
+ * it one of the messages defined in the <code>SelectionListener</code>
+ * interface.
+ * <p>
+ * <code>widgetSelected</code> is not called for texts.
+ * <code>widgetDefaultSelected</code> is typically called when ENTER is pressed in a single-line text,
+ * or when ENTER is pressed in a search text. If the receiver has the <code>SWT.SEARCH | SWT.CANCEL</code> style
+ * and the user cancels the search, the event object detail field contains the value <code>SWT.CANCEL</code>.
+ * </p>
+ *
+ * @param listener the listener which should be notified when the control is selected by the user
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent
+ */
+public void addSelectionListener(SelectionListener listener) {
+	checkWidget ();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	TypedListener typedListener = new TypedListener(listener);
+	addListener(SWT.Selection,typedListener);
+	addListener(SWT.DefaultSelection,typedListener);
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the receiver's text is verified, by sending
+ * it one of the messages defined in the <code>VerifyListener</code>
+ * interface.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see VerifyListener
+ * @see #removeVerifyListener
+ */
+public void addVerifyListener (VerifyListener listener) {
+	checkWidget();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	TypedListener typedListener = new TypedListener (listener);
+	addListener (SWT.Verify, typedListener);
+}
+
+/**
+ * Appends a string.
+ * <p>
+ * The new text is appended to the text at
+ * the end of the widget.
+ * </p>
+ *
+ * @param string the string to be appended
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void append (String string) {
+	checkWidget ();
+	if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+	byte [] buffer = Converter.wcsToMbcs (null, string, false);
+	if ((style & SWT.SINGLE) != 0) {
+		OS.gtk_editable_insert_text (handle, buffer, buffer.length, new int[]{-1});
+		OS.gtk_editable_set_position (handle, -1);
+	} else {
+		byte [] position =  new byte [ITER_SIZEOF];
+		OS.gtk_text_buffer_get_end_iter (bufferHandle, position);
+		OS.gtk_text_buffer_insert (bufferHandle, position, buffer, buffer.length);
+		OS.gtk_text_buffer_place_cursor (bufferHandle, position);
+		int /*long*/ mark = OS.gtk_text_buffer_get_insert (bufferHandle);
+		OS.gtk_text_view_scroll_mark_onscreen (handle, mark);
+	}
+}
+
+/**
+ * Clears the selection.
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void clearSelection () {
+	checkWidget ();
+	if ((style & SWT.SINGLE) != 0) {
+		int position = OS.gtk_editable_get_position (handle);
+		OS.gtk_editable_select_region (handle, position, position);
+	} else {
+		byte [] position = new byte [ITER_SIZEOF];
+		int /*long*/ insertMark = OS.gtk_text_buffer_get_insert (bufferHandle);
+		int /*long*/ selectionMark = OS.gtk_text_buffer_get_selection_bound (bufferHandle);
+		OS.gtk_text_buffer_get_iter_at_mark (bufferHandle, position, insertMark);
+		OS.gtk_text_buffer_move_mark (bufferHandle, selectionMark, position);
+		OS.gtk_text_buffer_move_mark (bufferHandle, insertMark, position);
+	}
+}
+
+public Point computeSize (int wHint, int hHint, boolean changed) {
+	checkWidget ();
+	if (wHint != SWT.DEFAULT && wHint < 0) wHint = 0;
+	if (hHint != SWT.DEFAULT && hHint < 0) hHint = 0;
+	int[] w = new int [1], h = new int [1];
+	if ((style & SWT.SINGLE) != 0) {
+		OS.gtk_widget_realize (handle);
+		int /*long*/ layout = OS.gtk_entry_get_layout (handle);
+		OS.pango_layout_get_size (layout, w, h);
+	} else {
+		byte [] start =  new byte [ITER_SIZEOF], end  =  new byte [ITER_SIZEOF];
+		OS.gtk_text_buffer_get_bounds (bufferHandle, start, end);
+		int /*long*/ text = OS.gtk_text_buffer_get_text (bufferHandle, start, end, true);
+		int /*long*/ layout = OS.gtk_widget_create_pango_layout (handle, text);
+		OS.g_free (text);
+		OS.pango_layout_set_width (layout, wHint * OS.PANGO_SCALE);
+		OS.pango_layout_get_size (layout, w, h);
+		OS.g_object_unref (layout);
+	}
+	int width = OS.PANGO_PIXELS (w [0]);
+	int height = OS.PANGO_PIXELS (h [0]);
+	//This code is intentionally commented
+//	if ((style & SWT.SEARCH) != 0 && message.length () != 0) {
+//		GC gc = new GC (this);
+//		Point size = gc.stringExtent (message);
+//		width = Math.max (width, size.x);
+//		gc.dispose ();
+//	}
+	if (width == 0) width = DEFAULT_WIDTH;
+	if (height == 0) height = DEFAULT_HEIGHT;
+	width = wHint == SWT.DEFAULT ? width : wHint;
+	height = hHint == SWT.DEFAULT ? height : hHint;
+	Rectangle trim = computeTrim (0, 0, width, height);
+	return new Point (trim.width, trim.height);
+}
+
+public Rectangle computeTrim (int x, int y, int width, int height) {
+	checkWidget ();
+	Rectangle trim = super.computeTrim (x, y, width, height);
+	int xborder = 0, yborder = 0;
+	if ((style & SWT.SINGLE) != 0) {
+		if ((style & SWT.BORDER) != 0) {
+			int /*long*/ style = OS.gtk_widget_get_style (handle);
+			xborder += OS.gtk_style_get_xthickness (style);
+			yborder += OS.gtk_style_get_ythickness (style);
+		}
+		xborder += INNER_BORDER;
+		yborder += INNER_BORDER;
+	} else {
+		int borderWidth = OS.gtk_container_get_border_width (handle);  
+		xborder += borderWidth;
+		yborder += borderWidth;
+	}
+	int [] property = new int [1];
+	OS.gtk_widget_style_get (handle, OS.interior_focus, property, 0);
+	if (property [0] == 0) {
+		OS.gtk_widget_style_get (handle, OS.focus_line_width, property, 0);
+		xborder += property [0];
+		yborder += property [0];
+	}
+	trim.x -= xborder;
+	trim.y -= yborder;
+	trim.width += 2 * xborder;
+	trim.height += 2 * yborder;
+	return new Rectangle (trim.x, trim.y, trim.width, trim.height);
+}
+
+/**
+ * Copies the selected text.
+ * <p>
+ * The current selection is copied to the clipboard.
+ * </p>
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void copy () {
+	checkWidget ();
+	if ((style & SWT.SINGLE) != 0) {
+		OS.gtk_editable_copy_clipboard (handle);
+	} else {
+		int /*long*/ clipboard = OS.gtk_clipboard_get (OS.GDK_NONE);
+		OS.gtk_text_buffer_copy_clipboard (bufferHandle, clipboard);
+	}
+}
+
+/**
+ * Cuts the selected text.
+ * <p>
+ * The current selection is first copied to the
+ * clipboard and then deleted from the widget.
+ * </p>
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void cut () {
+	checkWidget ();
+	if ((style & SWT.SINGLE) != 0) {
+		OS.gtk_editable_cut_clipboard (handle);
+	} else {
+		int /*long*/ clipboard = OS.gtk_clipboard_get (OS.GDK_NONE);
+		OS.gtk_text_buffer_cut_clipboard (bufferHandle, clipboard, OS.gtk_text_view_get_editable (handle));
+	}
+}
+
+void deregister () {
+	super.deregister ();
+	if (bufferHandle != 0) display.removeWidget (bufferHandle);
+	int /*long*/ imContext = imContext ();
+	if (imContext != 0) display.removeWidget (imContext);
+}
+
+boolean dragDetect (int x, int y, boolean filter, boolean [] consume) {
+	if (filter) {
+		int start = 0, end = 0;
+		if ((style & SWT.SINGLE) != 0) {
+			int [] s = new int [1], e = new int [1];
+			OS.gtk_editable_get_selection_bounds (handle, s, e);
+			start = s [0];
+			end = e [0];
+		} else {
+			byte [] s = new byte [ITER_SIZEOF], e =  new byte [ITER_SIZEOF];
+			OS.gtk_text_buffer_get_selection_bounds (bufferHandle, s, e);
+			start = OS.gtk_text_iter_get_offset (s);
+			end = OS.gtk_text_iter_get_offset (e);
+		}
+		if (start != end) {
+			if (end < start) {
+				int temp = end;
+				end = start;
+				start = temp;
+			}
+			int position = -1;
+			if ((style & SWT.SINGLE) != 0) {
+				int [] index = new int [1];
+				int [] trailing = new int [1];
+				int /*long*/ layout = OS.gtk_entry_get_layout (handle);
+				OS.pango_layout_xy_to_index (layout, x * OS.PANGO_SCALE, y * OS.PANGO_SCALE, index, trailing);
+				int /*long*/ ptr = OS.pango_layout_get_text (layout);
+				position = (int)/*64*/OS.g_utf8_pointer_to_offset (ptr, ptr + index[0]) + trailing[0];
+			} else {
+				byte [] p = new byte [ITER_SIZEOF];
+				OS.gtk_text_view_get_iter_at_location (handle, p, x, y);
+				position = OS.gtk_text_iter_get_offset (p);
+			}
+			if (start <= position && position < end) {
+				if (super.dragDetect (x, y, filter, consume)) {
+					if (consume != null) consume [0] = true;
+					return true;
+				}
+			}
+		}
+		return false;
+	}
+	return super.dragDetect (x, y, filter, consume);
+}
+
+int /*long*/ eventWindow () {
+	return paintWindow ();
+}
+
+boolean filterKey (int keyval, int /*long*/ event) {
+	int time = OS.gdk_event_get_time (event);
+	if (time != lastEventTime) {
+		lastEventTime = time;
+		int /*long*/ imContext = imContext ();
+		if (imContext != 0) {
+			return OS.gtk_im_context_filter_keypress (imContext, event);
+		}
+	}
+	gdkEventKey = event;
+	return false;
+}
+
+void fixIM () {
+	/*
+	*  The IM filter has to be called one time for each key press event.
+	*  When the IM is open the key events are duplicated. The first event
+	*  is filtered by SWT and the second event is filtered by GTK.  In some 
+	*  cases the GTK handler does not run (the widget is destroyed, the 
+	*  application code consumes the event, etc), for these cases the IM
+	*  filter has to be called by SWT.
+	*/
+	if (gdkEventKey != 0 && gdkEventKey != -1) {
+		int /*long*/ imContext = imContext ();
+		if (imContext != 0) {
+			OS.gtk_im_context_filter_keypress (imContext, gdkEventKey);
+			gdkEventKey = -1;
+			return;
+		}
+	}
+	gdkEventKey = 0;
+}
+
+GdkColor getBackgroundColor () {
+	return getBaseColor ();
+}
+
+public int getBorderWidth () {
+	checkWidget();
+	if ((style & SWT.MULTI) != 0) return super.getBorderWidth ();
+	int /*long*/ style = OS.gtk_widget_get_style (handle);
+	if ((this.style & SWT.BORDER) != 0) {
+		 return OS.gtk_style_get_xthickness (style);
+	}
+	return 0;
+}
+
+/**
+ * Returns the line number of the caret.
+ * <p>
+ * The line number of the caret is returned.
+ * </p>
+ *
+ * @return the line number
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getCaretLineNumber () {
+	checkWidget ();
+	if ((style & SWT.SINGLE) != 0) return 1;
+	byte [] position = new byte [ITER_SIZEOF];
+	int /*long*/ mark = OS.gtk_text_buffer_get_insert (bufferHandle);
+	OS.gtk_text_buffer_get_iter_at_mark (bufferHandle, position, mark);
+	return OS.gtk_text_iter_get_line (position);
+}
+
+/**
+ * Returns a point describing the receiver's location relative
+ * to its parent (or its display if its parent is null).
+ * <p>
+ * The location of the caret is returned.
+ * </p>
+ *
+ * @return a point, the location of the caret
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Point getCaretLocation () {
+	checkWidget ();
+	if ((style & SWT.SINGLE) != 0) {
+		int index = OS.gtk_editable_get_position (handle);
+		if (OS.GTK_VERSION >= OS.VERSION (2, 6, 0)) {
+			index = OS.gtk_entry_text_index_to_layout_index (handle, index);
+		}
+		int [] offset_x = new int [1], offset_y = new int [1];
+		OS.gtk_entry_get_layout_offsets (handle, offset_x, offset_y);
+		int /*long*/ layout = OS.gtk_entry_get_layout (handle);
+		PangoRectangle pos = new PangoRectangle ();
+		OS.pango_layout_index_to_pos (layout, index, pos);
+		int x = offset_x [0] + OS.PANGO_PIXELS (pos.x) - getBorderWidth ();
+		int y = offset_y [0] + OS.PANGO_PIXELS (pos.y);
+		return new Point (x, y);
+	}
+	byte [] position = new byte [ITER_SIZEOF];
+	int /*long*/ mark = OS.gtk_text_buffer_get_insert (bufferHandle);
+	OS.gtk_text_buffer_get_iter_at_mark (bufferHandle, position, mark);
+	GdkRectangle rect = new GdkRectangle ();
+	OS.gtk_text_view_get_iter_location (handle, position, rect);
+	int [] x = new int [1];
+	int [] y  = new int [1];
+	OS.gtk_text_view_buffer_to_window_coords (handle, OS.GTK_TEXT_WINDOW_TEXT, rect.x, rect.y, x, y);
+	return new Point (x [0], y [0]);
+}
+
+/**
+ * Returns the character position of the caret.
+ * <p>
+ * Indexing is zero based.
+ * </p>
+ *
+ * @return the position of the caret
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getCaretPosition () {
+	checkWidget ();
+	if ((style & SWT.SINGLE) != 0)  {
+		return OS.gtk_editable_get_position (handle);
+	}
+	byte [] position = new byte [ITER_SIZEOF];
+	int /*long*/ mark = OS.gtk_text_buffer_get_insert (bufferHandle);
+	OS.gtk_text_buffer_get_iter_at_mark (bufferHandle, position, mark);
+	return OS.gtk_text_iter_get_offset (position);
+}
+
+/**
+ * Returns the number of characters.
+ *
+ * @return number of characters in the widget
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getCharCount () {
+	checkWidget ();
+	if ((style & SWT.SINGLE) != 0) {
+		int /*long*/ ptr = OS.gtk_entry_get_text (handle);
+		return (int)/*64*/OS.g_utf8_strlen (ptr, -1);
+	}
+	return OS.gtk_text_buffer_get_char_count (bufferHandle);
+}
+
+/**
+ * Returns the double click enabled flag.
+ * <p>
+ * The double click flag enables or disables the
+ * default action of the text widget when the user
+ * double clicks.
+ * </p>
+ * 
+ * @return whether or not double click is enabled
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public boolean getDoubleClickEnabled () {
+	checkWidget ();
+	return doubleClick;
+}
+
+/**
+ * Returns the echo character.
+ * <p>
+ * The echo character is the character that is
+ * displayed when the user enters text or the
+ * text is changed by the programmer.
+ * </p>
+ * 
+ * @return the echo character
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see #setEchoChar
+ */
+public char getEchoChar () {
+	checkWidget ();
+	if ((style & SWT.SINGLE) != 0) {
+		if (!OS.gtk_entry_get_visibility (handle)) {
+			return OS.gtk_entry_get_invisible_char (handle);
+		}
+	}
+	return '\0';
+}
+
+/**
+ * Returns the editable state.
+ *
+ * @return whether or not the receiver is editable
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public boolean getEditable () {
+	checkWidget ();
+	if ((style & SWT.SINGLE) != 0) {
+		return OS.gtk_editable_get_editable (handle);
+	}
+	return OS.gtk_text_view_get_editable (handle);
+}
+
+GdkColor getForegroundColor () {
+	return getTextColor ();
+}
+
+/**
+ * Returns the number of lines.
+ *
+ * @return the number of lines in the widget
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getLineCount () {
+	checkWidget ();
+	if ((style & SWT.SINGLE) != 0) return 1;
+	return OS.gtk_text_buffer_get_line_count (bufferHandle);
+}
+
+/**
+ * Returns the line delimiter.
+ *
+ * @return a string that is the line delimiter
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see #DELIMITER
+ */
+public String getLineDelimiter () {
+	checkWidget ();
+	return "\n";
+}
+
+/**
+ * Returns the height of a line.
+ *
+ * @return the height of a row of text
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getLineHeight () {
+	checkWidget ();
+	return fontHeight (getFontDescription (), handle);
+}
+
+/**
+ * Returns the widget message. When the widget is created
+ * with the style <code>SWT.SEARCH</code>, the message text
+ * is displayed as a hint for the user, indicating the
+ * purpose of the field.
+ * <p>
+ * Note: This operation is a <em>HINT</em> and is not
+ * supported on platforms that do not have this concept.
+ * </p>
+ * 
+ * @return the widget message
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.3
+ */
+public String getMessage () {
+	checkWidget ();
+	return message;
+}
+
+/**
+ * Returns the orientation of the receiver, which will be one of the
+ * constants <code>SWT.LEFT_TO_RIGHT</code> or <code>SWT.RIGHT_TO_LEFT</code>.
+ *
+ * @return the orientation style
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 2.1.2
+ */
+public int getOrientation () {
+	checkWidget();
+	return style & (SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT);
+}
+
+/*public*/ int getPosition (Point point) {
+	checkWidget ();
+	if (point == null) error (SWT.ERROR_NULL_ARGUMENT);
+	int position = -1;
+	if ((style & SWT.SINGLE) != 0) {
+		int [] index = new int [1];
+		int [] trailing = new int [1];
+		int /*long*/ layout = OS.gtk_entry_get_layout (handle);
+		OS.pango_layout_xy_to_index (layout, point.x * OS.PANGO_SCALE, point.y * OS.PANGO_SCALE, index, trailing);
+		int /*long*/ ptr = OS.pango_layout_get_text (layout);
+		position = (int)/*64*/OS.g_utf8_pointer_to_offset (ptr, ptr + index[0]) + trailing[0];
+	} else {
+		byte [] p = new byte [ITER_SIZEOF];
+		OS.gtk_text_view_get_iter_at_location (handle, p, point.x, point.y);
+		position = OS.gtk_text_iter_get_offset (p);
+	}
+	return position;
+}
+
+/**
+ * Returns a <code>Point</code> whose x coordinate is the
+ * character position representing the start of the selected
+ * text, and whose y coordinate is the character position
+ * representing the end of the selection. An "empty" selection
+ * is indicated by the x and y coordinates having the same value.
+ * <p>
+ * Indexing is zero based.  The range of a selection is from
+ * 0..N where N is the number of characters in the widget.
+ * </p>
+ *
+ * @return a point representing the selection start and end
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Point getSelection () {
+	checkWidget ();
+	if ((style & SWT.SINGLE) != 0) {
+		int [] start = new int [1];
+		int [] end = new int [1];
+		OS.gtk_editable_get_selection_bounds (handle, start, end);
+		return new Point (start [0], end [0]);
+	}
+	byte [] start =  new byte [ITER_SIZEOF];
+	byte [] end =  new byte [ITER_SIZEOF];
+	OS.gtk_text_buffer_get_selection_bounds (bufferHandle, start, end);
+	return new Point (OS.gtk_text_iter_get_offset (start), OS.gtk_text_iter_get_offset (end));
+}
+
+/**
+ * Returns the number of selected characters.
+ *
+ * @return the number of selected characters.
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getSelectionCount () {
+	checkWidget ();
+	Point selection = getSelection ();
+	return Math.abs (selection.y - selection.x);
+}
+
+/**
+ * Gets the selected text, or an empty string if there is no current selection.
+ *
+ * @return the selected text
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public String getSelectionText () {
+	checkWidget ();
+	Point selection = getSelection ();
+	return getText ().substring(selection.x, selection.y);
+}
+
+/**
+ * Returns the number of tabs.
+ * <p>
+ * Tab stop spacing is specified in terms of the
+ * space (' ') character.  The width of a single
+ * tab stop is the pixel width of the spaces.
+ * </p>
+ *
+ * @return the number of tab characters
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getTabs () {
+	checkWidget ();
+	return tabs;
+}
+
+int getTabWidth (int tabs) {
+	byte[] buffer = Converter.wcsToMbcs(null, " ", true);
+	int /*long*/ layout = OS.gtk_widget_create_pango_layout (handle, buffer);
+	int [] width = new int [1];
+	int [] height = new int [1];
+	OS.pango_layout_get_size (layout, width, height);
+	OS.g_object_unref (layout);
+	return width [0] * tabs;
+}
+
+/**
+ * Returns the widget text.
+ * <p>
+ * The text for a text widget is the characters in the widget, or
+ * an empty string if this has never been set.
+ * </p>
+ *
+ * @return the widget text
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public String getText () {
+	checkWidget ();
+	int /*long*/ address;
+	if ((style & SWT.SINGLE) != 0) {
+		address = OS.gtk_entry_get_text (handle);
+	} else {
+		byte [] start =  new byte [ITER_SIZEOF];
+		byte [] end =  new byte [ITER_SIZEOF];
+		OS.gtk_text_buffer_get_bounds (bufferHandle, start, end);
+		address = OS.gtk_text_buffer_get_text (bufferHandle, start, end, true);
+	}
+	if (address == 0) return "";
+	int length = OS.strlen (address);
+	byte [] buffer = new byte [length];
+	OS.memmove (buffer, address, length);
+	if ((style & SWT.MULTI) != 0) OS.g_free (address);
+	return new String (Converter.mbcsToWcs (null, buffer));
+}
+
+/**
+ * Returns a range of text.  Returns an empty string if the
+ * start of the range is greater than the end.
+ * <p>
+ * Indexing is zero based.  The range of
+ * a selection is from 0..N-1 where N is
+ * the number of characters in the widget.
+ * </p>
+ *
+ * @param start the start of the range
+ * @param end the end of the range
+ * @return the range of text
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public String getText (int start, int end) {
+	checkWidget ();
+	if (!(start <= end && 0 <= end)) return "";
+	start = Math.max (0, start);
+	int /*long*/ address;
+	if ((style & SWT.SINGLE) != 0) {
+		address = OS.gtk_editable_get_chars (handle, start, end + 1);
+	} else {
+		int length = OS.gtk_text_buffer_get_char_count (bufferHandle);
+		end = Math.min (end, length - 1);
+		byte [] startIter =  new byte [ITER_SIZEOF];
+		byte [] endIter =  new byte [ITER_SIZEOF];
+		OS.gtk_text_buffer_get_iter_at_offset (bufferHandle, startIter, start);
+		OS.gtk_text_buffer_get_iter_at_offset (bufferHandle, endIter, end + 1);
+		address = OS.gtk_text_buffer_get_text (bufferHandle, startIter, endIter, true);
+	}
+	if (address == 0) error (SWT.ERROR_CANNOT_GET_TEXT);
+	int length = OS.strlen (address);
+	byte [] buffer = new byte [length];
+	OS.memmove (buffer, address, length);
+	OS.g_free (address);
+	return new String (Converter.mbcsToWcs (null, buffer));
+}
+
+/**
+ * Returns the maximum number of characters that the receiver is capable of holding. 
+ * <p>
+ * If this has not been changed by <code>setTextLimit()</code>,
+ * it will be the constant <code>Text.LIMIT</code>.
+ * </p>
+ * 
+ * @return the text limit
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see #LIMIT
+ */
+public int getTextLimit () {
+	checkWidget ();
+	if ((style & SWT.MULTI) != 0) return LIMIT;
+	int limit = OS.gtk_entry_get_max_length (handle);
+	return limit == 0 ? 0xFFFF : limit;
+}
+
+/**
+ * Returns the zero-relative index of the line which is currently
+ * at the top of the receiver.
+ * <p>
+ * This index can change when lines are scrolled or new lines are added or removed.
+ * </p>
+ *
+ * @return the index of the top line
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getTopIndex () {
+	checkWidget ();
+	if ((style & SWT.SINGLE) != 0) return 0;
+	byte [] position = new byte [ITER_SIZEOF];
+	GdkRectangle rect = new GdkRectangle ();
+	OS.gtk_text_view_get_visible_rect (handle, rect);
+	OS.gtk_text_view_get_line_at_y (handle, position, rect.y, null);
+	return OS.gtk_text_iter_get_line (position);
+}
+
+/**
+ * Returns the top pixel.
+ * <p>
+ * The top pixel is the pixel position of the line
+ * that is currently at the top of the widget.  On
+ * some platforms, a text widget can be scrolled by
+ * pixels instead of lines so that a partial line
+ * is displayed at the top of the widget.
+ * </p><p>
+ * The top pixel changes when the widget is scrolled.
+ * The top pixel does not include the widget trimming.
+ * </p>
+ *
+ * @return the pixel position of the top line
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getTopPixel () {
+	checkWidget ();
+	if ((style & SWT.SINGLE) != 0) return 0;
+	byte [] position = new byte [ITER_SIZEOF];
+	GdkRectangle rect = new GdkRectangle ();
+	OS.gtk_text_view_get_visible_rect (handle, rect);
+	int [] lineTop = new int[1];
+	OS.gtk_text_view_get_line_at_y (handle, position, rect.y, lineTop);
+	return lineTop [0];
+}
+
+int /*long*/ gtk_activate (int /*long*/ widget) {
+	postEvent (SWT.DefaultSelection);
+	return 0;
+}
+
+int /*long*/ gtk_button_press_event (int /*long*/ widget, int /*long*/ event) {
+	int /*long*/ result = super.gtk_button_press_event (widget, event);
+	if (result != 0) return result;
+	GdkEventButton gdkEvent = new GdkEventButton ();
+	OS.memmove (gdkEvent, event, GdkEventButton.sizeof);
+	if (!doubleClick) {
+		switch (gdkEvent.type) {
+			case OS.GDK_2BUTTON_PRESS:
+			case OS.GDK_3BUTTON_PRESS:
+				return 1;
+		}
+	}
+	return result;
+}
+
+
+int /*long*/ gtk_changed (int /*long*/ widget) {
+	/*
+	* Feature in GTK.  When the user types, GTK positions
+	* the caret after sending the changed signal.  This
+	* means that application code that attempts to position
+	* the caret during a changed signal will fail.  The fix
+	* is to post the modify event when the user is typing.
+	*/
+	boolean keyPress = false;
+	int /*long*/ eventPtr = OS.gtk_get_current_event ();
+	if (eventPtr != 0) {
+		GdkEventKey gdkEvent = new GdkEventKey ();
+		OS.memmove (gdkEvent, eventPtr, GdkEventKey.sizeof);
+		switch (gdkEvent.type) {
+			case OS.GDK_KEY_PRESS:
+				keyPress = true;
+				break;
+		}
+		OS.gdk_event_free (eventPtr);
+	}
+	if (keyPress) {
+		postEvent (SWT.Modify);
+	} else {
+		sendEvent (SWT.Modify);
+	}
+	return 0;
+}
+
+int /*long*/ gtk_commit (int /*long*/ imContext, int /*long*/ text) {
+	if (text == 0) return 0;
+	if ((style & SWT.SINGLE) != 0) {
+		if (!OS.gtk_editable_get_editable (handle)) return 0;
+	}
+	int length = OS.strlen (text);
+	if (length == 0) return 0;
+	byte [] buffer = new byte [length];
+	OS.memmove (buffer, text, length);
+	char [] chars = Converter.mbcsToWcs (null, buffer);
+	char [] newChars = sendIMKeyEvent (SWT.KeyDown, null, chars);
+	if (newChars == null) return 0;
+	/*
+	* Feature in GTK.  For a GtkEntry, during the insert-text signal,
+	* GTK allows the programmer to change only the caret location,
+	* not the selection.  If the programmer changes the selection,
+	* the new selection is lost.  The fix is to detect a selection
+	* change and set it after the insert-text signal has completed.
+	*/
+	fixStart = fixEnd = -1;
+	OS.g_signal_handlers_block_matched (imContext, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, COMMIT);
+	int id = OS.g_signal_lookup (OS.commit, OS.gtk_im_context_get_type ());
+	int mask =  OS.G_SIGNAL_MATCH_DATA | OS.G_SIGNAL_MATCH_ID;
+	OS.g_signal_handlers_unblock_matched (imContext, mask, id, 0, 0, 0, handle);
+	if (newChars == chars) {
+		OS.g_signal_emit_by_name (imContext, OS.commit, text);
+	} else {
+		buffer = Converter.wcsToMbcs (null, newChars, true);
+		OS.g_signal_emit_by_name (imContext, OS.commit, buffer);
+	}
+	OS.g_signal_handlers_unblock_matched (imContext, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, COMMIT);
+	OS.g_signal_handlers_block_matched (imContext, mask, id, 0, 0, 0, handle);
+	if ((style & SWT.SINGLE) != 0) { 
+		if (fixStart != -1 && fixEnd != -1) {
+			OS.gtk_editable_set_position (handle, fixStart);
+			OS.gtk_editable_select_region (handle, fixStart, fixEnd);
+		}
+	}
+	fixStart = fixEnd = -1;
+	return 0;
+}
+
+int /*long*/ gtk_delete_range (int /*long*/ widget, int /*long*/ iter1, int /*long*/ iter2) {
+	if (!hooks (SWT.Verify) && !filters (SWT.Verify)) return 0;
+	byte [] startIter = new byte [ITER_SIZEOF];
+	byte [] endIter = new byte [ITER_SIZEOF];
+	OS.memmove (startIter, iter1, startIter.length);
+	OS.memmove (endIter, iter2, endIter.length);
+	int start = OS.gtk_text_iter_get_offset (startIter);
+	int end = OS.gtk_text_iter_get_offset (endIter);
+	String newText = verifyText ("", start, end);
+	if (newText == null) {
+		/* Remember the selection when the text was deleted */
+		OS.gtk_text_buffer_get_selection_bounds (bufferHandle, startIter, endIter);
+		start = OS.gtk_text_iter_get_offset (startIter);
+		end = OS.gtk_text_iter_get_offset (endIter);
+		if (start != end) {
+			fixStart = start;
+			fixEnd = end;
+		}
+		OS.g_signal_stop_emission_by_name (bufferHandle, OS.delete_range);
+	} else {
+		if (newText.length () > 0) {
+			byte [] buffer = Converter.wcsToMbcs (null, newText, false);
+			OS.g_signal_handlers_block_matched (bufferHandle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+			OS.g_signal_handlers_block_matched (bufferHandle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, DELETE_RANGE);
+			OS.gtk_text_buffer_delete (bufferHandle, startIter, endIter);
+			OS.g_signal_handlers_unblock_matched (bufferHandle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, DELETE_RANGE);
+			OS.g_signal_handlers_unblock_matched (bufferHandle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+			OS.g_signal_handlers_block_matched (bufferHandle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, TEXT_BUFFER_INSERT_TEXT);
+			OS.gtk_text_buffer_insert (bufferHandle, startIter, buffer, buffer.length);
+			OS.g_signal_handlers_unblock_matched (bufferHandle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, TEXT_BUFFER_INSERT_TEXT);
+			OS.g_signal_stop_emission_by_name (bufferHandle, OS.delete_range);
+		}
+	}
+	return 0;
+}
+
+int /*long*/ gtk_delete_text (int /*long*/ widget, int /*long*/ start_pos, int /*long*/ end_pos) {
+	if (!hooks (SWT.Verify) && !filters (SWT.Verify)) return 0;
+	String newText = verifyText ("", (int)/*64*/start_pos, (int)/*64*/end_pos);
+	if (newText == null) {
+		/* Remember the selection when the text was deleted */
+		int [] newStart = new int [1], newEnd = new int [1];
+		OS.gtk_editable_get_selection_bounds (handle, newStart, newEnd);
+		if (newStart [0] != newEnd [0]) {
+			fixStart = newStart [0];
+			fixEnd = newEnd [0];
+		}
+		OS.g_signal_stop_emission_by_name (handle, OS.delete_text);
+	} else {
+		if (newText.length () > 0) {
+			int [] pos = new int [1];
+			pos [0] = (int)/*64*/end_pos;
+			byte [] buffer = Converter.wcsToMbcs (null, newText, false);
+			OS.g_signal_handlers_block_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+			OS.g_signal_handlers_block_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, INSERT_TEXT);
+			OS.gtk_editable_insert_text (handle, buffer, buffer.length, pos);
+			OS.g_signal_handlers_unblock_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, INSERT_TEXT);
+			OS.g_signal_handlers_unblock_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+			OS.gtk_editable_set_position (handle, pos [0]);
+		}
+	}
+	return 0;
+}
+
+int /*long*/ gtk_event_after (int /*long*/ widget, int /*long*/ gdkEvent) {
+	if (cursor != null) setCursor (cursor.handle);
+	/*
+	* Feature in GTK.  The gtk-entry-select-on-focus property is a global
+	* setting.  Return it to its default value after the GtkEntry has done
+	* its focus in processing so that other widgets (such as the combo)
+	* use the correct value.
+	*/
+	if ((style & SWT.SINGLE) != 0 && display.entrySelectOnFocus) {
+		GdkEvent event = new GdkEvent ();
+		OS.memmove (event, gdkEvent, GdkEvent.sizeof);
+		switch (event.type) {
+			case OS.GDK_FOCUS_CHANGE:
+				GdkEventFocus gdkEventFocus = new GdkEventFocus ();
+				OS.memmove (gdkEventFocus, gdkEvent, GdkEventFocus.sizeof);
+				if (gdkEventFocus.in == 0) {
+					int /*long*/ settings = OS.gtk_settings_get_default ();
+					OS.g_object_set (settings, OS.gtk_entry_select_on_focus, true, 0);
+				}
+				break;
+		}
+	}
+	return super.gtk_event_after (widget, gdkEvent);
+}
+
+int /*long*/ gtk_focus_out_event (int /*long*/ widget, int /*long*/ event) {
+	fixIM ();
+	return super.gtk_focus_out_event (widget, event);
+}
+
+int /*long*/ gtk_grab_focus (int /*long*/ widget) {
+	int /*long*/ result = super.gtk_grab_focus (widget);
+	/*
+	* Feature in GTK.  GtkEntry widgets select their text on focus in,
+	* clearing the previous selection.  This behavior is controlled by
+	* the gtk-entry-select-on-focus property.  The fix is to disable
+	* this property when a GtkEntry is given focus and restore it after
+	* the entry has done focus in processing.
+	*/
+	if ((style & SWT.SINGLE) != 0 && display.entrySelectOnFocus) {
+		int /*long*/ settings = OS.gtk_settings_get_default ();
+		OS.g_object_set (settings, OS.gtk_entry_select_on_focus, false, 0);
+	}
+	return result;
+}
+
+int /*long*/ gtk_insert_text (int /*long*/ widget, int /*long*/ new_text, int /*long*/ new_text_length, int /*long*/ position) {
+	if (!hooks (SWT.Verify) && !filters (SWT.Verify)) return 0;
+	if (new_text == 0 || new_text_length == 0) return 0;
+	byte [] buffer = new byte [(int)/*64*/new_text_length];
+	OS.memmove (buffer, new_text, buffer.length);
+	String oldText = new String (Converter.mbcsToWcs (null, buffer));
+	int [] pos = new int [1];
+	OS.memmove (pos, position, 4);
+	if (pos [0] == -1) {
+		int /*long*/ ptr = OS.gtk_entry_get_text (handle);
+		pos [0] = (int)/*64*/OS.g_utf8_strlen (ptr, -1);
+	}
+	/* Use the selection when the text was deleted */
+	int start = pos [0], end = pos [0];
+	if (fixStart != -1 && fixEnd != -1) {
+		start = pos [0] = fixStart;
+		end = fixEnd;
+		fixStart = fixEnd = -1;
+	}
+	String newText = verifyText (oldText, start, end);
+	if (newText != oldText) {
+		int [] newStart = new int [1], newEnd = new int [1];
+		OS.gtk_editable_get_selection_bounds (handle, newStart, newEnd);
+		if (newText != null) {
+			if (newStart [0] != newEnd [0]) {
+				OS.g_signal_handlers_block_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, DELETE_TEXT);
+				OS.g_signal_handlers_block_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+				OS.gtk_editable_delete_selection (handle);
+				OS.g_signal_handlers_unblock_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, DELETE_TEXT);
+				OS.g_signal_handlers_unblock_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+			}
+			byte [] buffer3 = Converter.wcsToMbcs (null, newText, false);
+			OS.g_signal_handlers_block_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, INSERT_TEXT);
+			OS.gtk_editable_insert_text (handle, buffer3, buffer3.length, pos);
+			OS.g_signal_handlers_unblock_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, INSERT_TEXT);
+			newStart [0] = newEnd [0] = pos [0];
+		}
+		pos [0] = newEnd [0];
+		if (newStart [0] != newEnd [0]) {
+			fixStart = newStart [0];
+			fixEnd = newEnd [0];
+		}
+		OS.memmove (position, pos, 4);
+		OS.g_signal_stop_emission_by_name (handle, OS.insert_text);
+	}
+	return 0;
+}
+
+int /*long*/ gtk_key_press_event (int /*long*/ widget, int /*long*/ event) {
+	int /*long*/ result = super.gtk_key_press_event (widget, event);
+	if (result != 0) fixIM ();
+	if (gdkEventKey == -1) result = 1;
+	gdkEventKey = 0;
+	return result;
+}
+
+int /*long*/ gtk_populate_popup (int /*long*/ widget, int /*long*/ menu) {
+	if ((style & SWT.RIGHT_TO_LEFT) != 0) {
+		OS.gtk_widget_set_direction (menu, OS.GTK_TEXT_DIR_RTL);
+		OS.gtk_container_forall (menu, display.setDirectionProc, OS.GTK_TEXT_DIR_RTL);
+	}
+	return 0;
+}
+
+int /*long*/ gtk_text_buffer_insert_text (int /*long*/ widget, int /*long*/ iter, int /*long*/ text, int /*long*/ length) {
+	if (!hooks (SWT.Verify) && !filters (SWT.Verify)) return 0;
+	byte [] position = new byte [ITER_SIZEOF];
+	OS.memmove (position, iter, position.length);
+	/* Use the selection when the text was deleted */
+	int start = OS.gtk_text_iter_get_offset (position), end = start;
+	if (fixStart != -1 && fixEnd != -1) {
+		start = fixStart;
+		end = fixEnd;
+		fixStart = fixEnd = -1;
+	}
+	byte [] buffer = new byte [(int)/*64*/length];
+	OS.memmove (buffer, text, buffer.length);
+	String oldText = new String (Converter.mbcsToWcs (null, buffer));
+	String newText = verifyText (oldText, start, end);
+	if (newText == null) {
+		OS.g_signal_stop_emission_by_name (bufferHandle, OS.insert_text);
+	} else {
+		if (newText != oldText) {
+			byte [] buffer1 = Converter.wcsToMbcs (null, newText, false);
+			OS.g_signal_handlers_block_matched (bufferHandle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, TEXT_BUFFER_INSERT_TEXT);
+			OS.gtk_text_buffer_insert (bufferHandle, iter, buffer1, buffer1.length);
+			OS.g_signal_handlers_unblock_matched (bufferHandle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, TEXT_BUFFER_INSERT_TEXT);
+			OS.g_signal_stop_emission_by_name (bufferHandle, OS.insert_text);
+		}
+	}
+	return 0;
+}
+
+void hookEvents () {
+	super.hookEvents();
+	if ((style & SWT.SINGLE) != 0) {
+		OS.g_signal_connect_closure (handle, OS.changed, display.closures [CHANGED], true);
+		OS.g_signal_connect_closure (handle, OS.insert_text, display.closures [INSERT_TEXT], false);
+		OS.g_signal_connect_closure (handle, OS.delete_text, display.closures [DELETE_TEXT], false);
+		OS.g_signal_connect_closure (handle, OS.activate, display.closures [ACTIVATE], false);
+		OS.g_signal_connect_closure (handle, OS.grab_focus, display.closures [GRAB_FOCUS], false);
+		OS.g_signal_connect_closure (handle, OS.populate_popup, display.closures [POPULATE_POPUP], false);
+	} else {
+		OS.g_signal_connect_closure (bufferHandle, OS.changed, display.closures [CHANGED], false);
+		OS.g_signal_connect_closure (bufferHandle, OS.insert_text, display.closures [TEXT_BUFFER_INSERT_TEXT], false);
+		OS.g_signal_connect_closure (bufferHandle, OS.delete_range, display.closures [DELETE_RANGE], false);
+		OS.g_signal_connect_closure (handle, OS.populate_popup, display.closures [POPULATE_POPUP], false);
+	}
+	int /*long*/ imContext = imContext ();
+	if (imContext != 0) {
+		OS.g_signal_connect_closure (imContext, OS.commit, display.closures [COMMIT], false);
+		int id = OS.g_signal_lookup (OS.commit, OS.gtk_im_context_get_type ());
+		int mask =  OS.G_SIGNAL_MATCH_DATA | OS.G_SIGNAL_MATCH_ID;
+		OS.g_signal_handlers_block_matched (imContext, mask, id, 0, 0, 0, handle);
+	}
+}
+
+int /*long*/ imContext () {
+	if ((style & SWT.SINGLE) != 0) {
+		return OS.gtk_editable_get_editable (handle) ? OS.GTK_ENTRY_IM_CONTEXT (handle) : 0;
+	} 
+	return OS.GTK_TEXTVIEW_IM_CONTEXT (handle);
+}
+
+/**
+ * Inserts a string.
+ * <p>
+ * The old selection is replaced with the new text.
+ * </p>
+ *
+ * @param string the string
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the string is <code>null</code></li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void insert (String string) {
+	checkWidget ();
+	if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+	byte [] buffer = Converter.wcsToMbcs (null, string, false);
+	if ((style & SWT.SINGLE) != 0) {
+		int [] start = new int [1], end = new int [1];
+		OS.gtk_editable_get_selection_bounds (handle, start, end);
+		OS.gtk_editable_delete_selection (handle);
+		OS.gtk_editable_insert_text (handle, buffer, buffer.length, start);
+		OS.gtk_editable_set_position (handle, start [0]);
+	} else {
+		byte [] start =  new byte [ITER_SIZEOF];
+		byte [] end =  new byte [ITER_SIZEOF];
+		if (OS.gtk_text_buffer_get_selection_bounds (bufferHandle, start, end)) {
+			OS.gtk_text_buffer_delete (bufferHandle, start, end);
+		}
+		OS.gtk_text_buffer_insert (bufferHandle, start, buffer, buffer.length);
+		OS.gtk_text_buffer_place_cursor (bufferHandle, start);
+		int /*long*/ mark = OS.gtk_text_buffer_get_insert (bufferHandle);
+		OS.gtk_text_view_scroll_mark_onscreen (handle, mark);
+	}
+}
+
+int /*long*/ paintWindow () {
+	if ((style & SWT.SINGLE) != 0) {
+		int /*long*/ window = super.paintWindow ();
+		int /*long*/ children = OS.gdk_window_get_children (window);
+		if (children != 0) window = OS.g_list_data (children);
+		OS.g_list_free (children);
+		return window;
+	}
+	OS.gtk_widget_realize (handle);
+	return OS.gtk_text_view_get_window (handle, OS.GTK_TEXT_WINDOW_TEXT);
+}
+
+/**
+ * Pastes text from clipboard.
+ * <p>
+ * The selected text is deleted from the widget
+ * and new text inserted from the clipboard.
+ * </p>
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void paste () {
+	checkWidget ();
+	if ((style & SWT.SINGLE) != 0) {
+		OS.gtk_editable_paste_clipboard (handle);
+	} else {
+		int /*long*/ clipboard = OS.gtk_clipboard_get (OS.GDK_NONE);
+		OS.gtk_text_buffer_paste_clipboard (bufferHandle, clipboard, null, OS.gtk_text_view_get_editable (handle));
+	}
+}
+
+void register () {
+	super.register ();
+	if (bufferHandle != 0) display.addWidget (bufferHandle, this);
+	int /*long*/ imContext = imContext ();
+	if (imContext != 0) display.addWidget (imContext, this);
+}
+
+void releaseWidget () {
+	super.releaseWidget ();
+	fixIM ();	
+	if (OS.GTK_VERSION < OS.VERSION (2, 6, 0)) {		 
+		/*
+		* Bug in GTK.  Any text copied into the clipboard will be lost when
+		* the GtkTextView is destroyed.  The fix is to paste the contents as
+		* the widget is being destroyed to reference the text buffer, keeping
+		* it around until ownership of the clipboard is lost.
+		*/
+		if ((style & SWT.MULTI) != 0) {
+			int /*long*/ clipboard = OS.gtk_clipboard_get (OS.GDK_NONE);
+			OS.gtk_text_buffer_paste_clipboard (bufferHandle, clipboard, null, OS.gtk_text_view_get_editable (handle));
+		}
+	}
+	message = null;
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the receiver's text is modified.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see ModifyListener
+ * @see #addModifyListener
+ */
+public void removeModifyListener (ModifyListener listener) {
+	checkWidget ();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if (eventTable == null) return;
+	eventTable.unhook (SWT.Modify, listener);	
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the control is selected by the user.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #addSelectionListener
+ */
+public void removeSelectionListener(SelectionListener listener) {
+	checkWidget ();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if (eventTable == null) return;
+	eventTable.unhook(SWT.Selection, listener);
+	eventTable.unhook(SWT.DefaultSelection,listener);	
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the control is verified.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see VerifyListener
+ * @see #addVerifyListener
+ */
+public void removeVerifyListener (VerifyListener listener) {
+	checkWidget ();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if (eventTable == null) return;
+	eventTable.unhook (SWT.Verify, listener);	
+}
+
+/**
+ * Selects all the text in the receiver.
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void selectAll () {
+	checkWidget ();
+	if ((style & SWT.SINGLE) != 0) {
+		OS.gtk_editable_select_region (handle, 0, -1);
+	} else {
+		byte [] start =  new byte [ITER_SIZEOF];
+		byte [] end =  new byte [ITER_SIZEOF];
+		OS.gtk_text_buffer_get_iter_at_offset (bufferHandle, start, 0);
+		OS.gtk_text_buffer_get_end_iter (bufferHandle, end);
+		int /*long*/ insertMark = OS.gtk_text_buffer_get_insert (bufferHandle);
+		int /*long*/ selectionMark = OS.gtk_text_buffer_get_selection_bound (bufferHandle);
+		OS.gtk_text_buffer_move_mark (bufferHandle, selectionMark, start);
+		OS.gtk_text_buffer_move_mark (bufferHandle, insertMark, end);
+	}
+}
+
+void setBackgroundColor (GdkColor color) {
+	super.setBackgroundColor (color);
+	OS.gtk_widget_modify_base (handle, 0, color);
+}
+
+void setCursor (int /*long*/ cursor) {
+	int /*long*/ defaultCursor = 0;
+	if (cursor == 0) defaultCursor = OS.gdk_cursor_new (OS.GDK_XTERM);
+	super.setCursor (cursor != 0 ? cursor : defaultCursor);
+	if (cursor == 0) OS.gdk_cursor_destroy (defaultCursor);
+}
+
+/**
+ * Sets the double click enabled flag.
+ * <p>
+ * The double click flag enables or disables the
+ * default action of the text widget when the user
+ * double clicks.
+ * </p><p>
+ * Note: This operation is a hint and is not supported on
+ * platforms that do not have this concept.
+ * </p>
+ * 
+ * @param doubleClick the new double click flag
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setDoubleClickEnabled (boolean doubleClick) {
+	checkWidget ();
+	this.doubleClick = doubleClick;
+}
+
+/**
+ * Sets the echo character.
+ * <p>
+ * The echo character is the character that is
+ * displayed when the user enters text or the
+ * text is changed by the programmer. Setting
+ * the echo character to '\0' clears the echo
+ * character and redraws the original text.
+ * If for any reason the echo character is invalid,
+ * or if the platform does not allow modification
+ * of the echo character, the default echo character
+ * for the platform is used.
+ * </p>
+ *
+ * @param echo the new echo character
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setEchoChar (char echo) {
+	checkWidget ();
+	if ((style & SWT.SINGLE) != 0) {
+		OS.gtk_entry_set_visibility (handle, echo == '\0');
+		OS.gtk_entry_set_invisible_char (handle, echo);
+	}
+}
+
+/**
+ * Sets the editable state.
+ *
+ * @param editable the new editable state
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setEditable (boolean editable) {
+	checkWidget ();
+	style &= ~SWT.READ_ONLY;
+	if (!editable) style |= SWT.READ_ONLY;
+	if ((style & SWT.SINGLE) != 0) {
+		OS.gtk_editable_set_editable (handle, editable);
+	} else {
+		OS.gtk_text_view_set_editable (handle, editable);
+	}
+}
+
+void setFontDescription (int /*long*/ font) {
+	super.setFontDescription (font);
+	setTabStops (tabs);
+}
+
+/**
+ * Sets the widget message. When the widget is created
+ * with the style <code>SWT.SEARCH</code>, the message text
+ * is displayed as a hint for the user, indicating the
+ * purpose of the field.
+ * <p>
+ * Note: This operation is a <em>HINT</em> and is not
+ * supported on platforms that do not have this concept.
+ * </p>
+ * 
+ * @param message the new message
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the message is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.3
+ */
+public void setMessage (String message) {
+	checkWidget ();
+	if (message == null) error (SWT.ERROR_NULL_ARGUMENT);
+	this.message = message;
+}
+
+/**
+ * Sets the orientation of the receiver, which must be one
+ * of the constants <code>SWT.LEFT_TO_RIGHT</code> or <code>SWT.RIGHT_TO_LEFT</code>.
+ * <p>
+ * Note: This operation is a hint and is not supported on
+ * platforms that do not have this concept.
+ * </p>
+ *
+ * @param orientation new orientation style
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 2.1.2
+ */
+public void setOrientation (int orientation) {
+	checkWidget();
+}
+
+/**
+ * Sets the selection.
+ * <p>
+ * Indexing is zero based.  The range of
+ * a selection is from 0..N where N is
+ * the number of characters in the widget.
+ * </p><p>
+ * Text selections are specified in terms of
+ * caret positions.  In a text widget that
+ * contains N characters, there are N+1 caret
+ * positions, ranging from 0..N.  This differs
+ * from other functions that address character
+ * position such as getText () that use the
+ * regular array indexing rules.
+ * </p>
+ *
+ * @param start new caret position
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setSelection (int start) {
+	checkWidget ();
+	if ((style & SWT.SINGLE) != 0) {
+		OS.gtk_editable_set_position (handle, start);
+	} else {
+		byte [] position =  new byte [ITER_SIZEOF];
+		OS.gtk_text_buffer_get_iter_at_offset (bufferHandle, position, start);
+		OS.gtk_text_buffer_place_cursor (bufferHandle, position);
+		int /*long*/ mark = OS.gtk_text_buffer_get_insert (bufferHandle);
+		OS.gtk_text_view_scroll_mark_onscreen (handle, mark);
+	}
+}
+
+/**
+ * Sets the selection to the range specified
+ * by the given start and end indices.
+ * <p>
+ * Indexing is zero based.  The range of
+ * a selection is from 0..N where N is
+ * the number of characters in the widget.
+ * </p><p>
+ * Text selections are specified in terms of
+ * caret positions.  In a text widget that
+ * contains N characters, there are N+1 caret
+ * positions, ranging from 0..N.  This differs
+ * from other functions that address character
+ * position such as getText () that use the
+ * usual array indexing rules.
+ * </p>
+ *
+ * @param start the start of the range
+ * @param end the end of the range
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setSelection (int start, int end) {
+	checkWidget ();
+	if ((style & SWT.SINGLE) != 0) { 
+		OS.gtk_editable_set_position (handle, start);
+		OS.gtk_editable_select_region (handle, start, end);
+	} else {
+		byte [] startIter =  new byte [ITER_SIZEOF];
+		byte [] endIter =  new byte [ITER_SIZEOF];
+		OS.gtk_text_buffer_get_iter_at_offset (bufferHandle, startIter, start);
+		OS.gtk_text_buffer_get_iter_at_offset (bufferHandle, endIter, end);
+		int /*long*/ insertMark = OS.gtk_text_buffer_get_insert (bufferHandle);
+		int /*long*/ selectionMark = OS.gtk_text_buffer_get_selection_bound (bufferHandle);
+		OS.gtk_text_buffer_move_mark (bufferHandle, selectionMark, startIter);
+		OS.gtk_text_buffer_move_mark (bufferHandle, insertMark, endIter);
+	}
+}
+
+/**
+ * Sets the selection to the range specified
+ * by the given point, where the x coordinate
+ * represents the start index and the y coordinate
+ * represents the end index.
+ * <p>
+ * Indexing is zero based.  The range of
+ * a selection is from 0..N where N is
+ * the number of characters in the widget.
+ * </p><p>
+ * Text selections are specified in terms of
+ * caret positions.  In a text widget that
+ * contains N characters, there are N+1 caret
+ * positions, ranging from 0..N.  This differs
+ * from other functions that address character
+ * position such as getText () that use the
+ * usual array indexing rules.
+ * </p>
+ *
+ * @param selection the point
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the point is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setSelection (Point selection) {
+	checkWidget ();
+	if (selection == null) error (SWT.ERROR_NULL_ARGUMENT);
+	setSelection (selection.x, selection.y);
+}
+
+/**
+ * Sets the number of tabs.
+ * <p>
+ * Tab stop spacing is specified in terms of the
+ * space (' ') character.  The width of a single
+ * tab stop is the pixel width of the spaces.
+ * </p>
+ *
+ * @param tabs the number of tabs
+ *
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setTabs (int tabs) {
+	checkWidget ();
+	if (tabs < 0) return;
+	setTabStops (this.tabs = tabs);
+}
+	
+void setTabStops (int tabs) {
+	if ((style & SWT.SINGLE) != 0) return;
+	int tabWidth = getTabWidth (tabs);
+	int /*long*/ tabArray = OS.pango_tab_array_new (1, false);
+	OS.pango_tab_array_set_tab (tabArray, 0, OS.PANGO_TAB_LEFT, tabWidth);
+	OS.gtk_text_view_set_tabs (handle, tabArray);
+	OS.pango_tab_array_free (tabArray);
+}
+
+/**
+ * Sets the contents of the receiver to the given string. If the receiver has style
+ * SINGLE and the argument contains multiple lines of text, the result of this
+ * operation is undefined and may vary from platform to platform.
+ *
+ * @param string the new text
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the string is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setText (String string) {
+	checkWidget ();
+	if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+	/*
+	* Feature in gtk.  When text is set in gtk, separate events are fired for the deletion and 
+	* insertion of the text.  This is not wrong, but is inconsistent with other platforms.  The
+	* fix is to block the firing of these events and fire them ourselves in a consistent manner. 
+	*/
+	if (hooks (SWT.Verify) || filters (SWT.Verify)) {
+		string = verifyText (string, 0, getCharCount ());
+		if (string == null) return;
+	}
+	if ((style & SWT.SINGLE) != 0) {
+		byte [] buffer = Converter.wcsToMbcs (null, string, true);
+		OS.g_signal_handlers_block_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+		OS.g_signal_handlers_block_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, DELETE_TEXT);
+		OS.g_signal_handlers_block_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, INSERT_TEXT);
+		OS.gtk_entry_set_text (handle, buffer);
+		OS.g_signal_handlers_unblock_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+		OS.g_signal_handlers_unblock_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, DELETE_TEXT);
+		OS.g_signal_handlers_unblock_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, INSERT_TEXT);
+	} else {
+		byte [] buffer = Converter.wcsToMbcs (null, string, false);
+		byte [] position =  new byte [ITER_SIZEOF];
+		OS.g_signal_handlers_block_matched (bufferHandle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+		OS.g_signal_handlers_block_matched (bufferHandle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, DELETE_RANGE);
+		OS.g_signal_handlers_block_matched (bufferHandle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, TEXT_BUFFER_INSERT_TEXT);
+		OS.gtk_text_buffer_set_text (bufferHandle, buffer, buffer.length);
+		OS.g_signal_handlers_unblock_matched (bufferHandle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+		OS.g_signal_handlers_unblock_matched (bufferHandle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, DELETE_RANGE);
+		OS.g_signal_handlers_unblock_matched (bufferHandle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, TEXT_BUFFER_INSERT_TEXT);
+		OS.gtk_text_buffer_get_iter_at_offset (bufferHandle, position, 0);
+		OS.gtk_text_buffer_place_cursor (bufferHandle, position);
+		int /*long*/ mark = OS.gtk_text_buffer_get_insert (bufferHandle);
+		OS.gtk_text_view_scroll_mark_onscreen (handle, mark);
+	}
+	sendEvent (SWT.Modify);
+}
+
+/**
+ * Sets the maximum number of characters that the receiver
+ * is capable of holding to be the argument.
+ * <p>
+ * Instead of trying to set the text limit to zero, consider
+ * creating a read-only text widget.
+ * </p><p>
+ * To reset this value to the default, use <code>setTextLimit(Text.LIMIT)</code>.
+ * Specifying a limit value larger than <code>Text.LIMIT</code> sets the
+ * receiver's limit to <code>Text.LIMIT</code>.
+ * </p>
+ *
+ * @param limit new text limit
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_CANNOT_BE_ZERO - if the limit is zero</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see #LIMIT
+ */
+public void setTextLimit (int limit) {
+	checkWidget ();
+	if (limit == 0) error (SWT.ERROR_CANNOT_BE_ZERO);
+	if ((style & SWT.SINGLE) != 0) OS.gtk_entry_set_max_length (handle, limit);
+}
+
+/**
+ * Sets the zero-relative index of the line which is currently
+ * at the top of the receiver. This index can change when lines
+ * are scrolled or new lines are added and removed.
+ *
+ * @param index the index of the top item
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setTopIndex (int index) {
+	checkWidget ();
+	if ((style & SWT.SINGLE) != 0) return;
+	byte [] position = new byte [ITER_SIZEOF];
+	OS.gtk_text_buffer_get_iter_at_line (bufferHandle, position, index);
+	OS.gtk_text_view_scroll_to_iter (handle, position, 0, true, 0, 0);
+}
+
+/**
+ * Shows the selection.
+ * <p>
+ * If the selection is already showing
+ * in the receiver, this method simply returns.  Otherwise,
+ * lines are scrolled until the selection is visible.
+ * </p>
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void showSelection () {
+	checkWidget ();
+	if ((style & SWT.SINGLE) != 0) return;
+	int /*long*/ mark = OS.gtk_text_buffer_get_selection_bound (bufferHandle);
+	OS.gtk_text_view_scroll_mark_onscreen (handle, mark);
+	mark = OS.gtk_text_buffer_get_insert (bufferHandle);
+	OS.gtk_text_view_scroll_mark_onscreen (handle, mark);
+}
+
+boolean translateTraversal (GdkEventKey keyEvent) {
+	int key = keyEvent.keyval;
+	switch (key) {
+		case OS.GDK_KP_Enter:
+		case OS.GDK_Return: {
+			int /*long*/ imContext =  imContext ();
+			if (imContext != 0) {
+				int /*long*/ [] preeditString = new int /*long*/ [1];
+				OS.gtk_im_context_get_preedit_string (imContext, preeditString, null, null);
+				if (preeditString [0] != 0) {
+					int length = OS.strlen (preeditString [0]);
+					OS.g_free (preeditString [0]);
+					if (length != 0) return false;
+				}
+			}
+		}
+	}
+	return super.translateTraversal (keyEvent);
+}
+
+int traversalCode (int key, GdkEventKey event) {
+	int bits = super.traversalCode (key, event);
+	if ((style & SWT.READ_ONLY) != 0)  return bits;
+	if ((style & SWT.MULTI) != 0) {
+		bits &= ~SWT.TRAVERSE_RETURN;
+		if (key == OS.GDK_Tab && event != null) {
+			boolean next = (event.state & OS.GDK_SHIFT_MASK) == 0;
+			if (next && (event.state & OS.GDK_CONTROL_MASK) == 0) {
+				bits &= ~(SWT.TRAVERSE_TAB_NEXT | SWT.TRAVERSE_TAB_PREVIOUS);
+			}
+		}
+	}
+	return bits;
+}
+
+String verifyText (String string, int start, int end) {
+	if (string.length () == 0 && start == end) return null;
+	Event event = new Event ();
+	event.text = string;
+	event.start = start;
+	event.end = end;
+	int /*long*/ eventPtr = OS.gtk_get_current_event ();
+	if (eventPtr != 0) {
+		GdkEventKey gdkEvent = new GdkEventKey ();
+		OS.memmove (gdkEvent, eventPtr, GdkEventKey.sizeof);
+		switch (gdkEvent.type) {
+			case OS.GDK_KEY_PRESS:
+				setKeyState (event, gdkEvent);
+				break;
+		}
+		OS.gdk_event_free (eventPtr);
+	}
+	/*
+	 * It is possible (but unlikely), that application
+	 * code could have disposed the widget in the verify
+	 * event.  If this happens, answer null to cancel
+	 * the operation.
+	 */
+	sendEvent (SWT.Verify, event);
+	if (!event.doit || isDisposed ()) return null;
+	return event.text;
+}
+
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/ToolBar.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/ToolBar.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/ToolBar.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,461 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.widgets;
+
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.gtk.*;
+import org.eclipse.swt.graphics.*;
+
+/**
+ * Instances of this class support the layout of selectable
+ * tool bar items.
+ * <p>
+ * The item children that may be added to instances of this class
+ * must be of type <code>ToolItem</code>.
+ * </p><p>
+ * Note that although this class is a subclass of <code>Composite</code>,
+ * it does not make sense to add <code>Control</code> children to it,
+ * or set a layout on it.
+ * </p><p>
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>FLAT, WRAP, RIGHT, HORIZONTAL, VERTICAL, SHADOW_OUT</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>(none)</dd>
+ * </dl>
+ * <p>
+ * Note: Only one of the styles HORIZONTAL and VERTICAL may be specified.
+ * </p><p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ *
+ * @see <a href="http://www.eclipse.org/swt/snippets/#toolbar">ToolBar, ToolItem snippets</a>
+ * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: ControlExample</a>
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public class ToolBar extends Composite {
+	ToolItem lastFocus;
+	ImageList imageList;
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT#FLAT
+ * @see SWT#WRAP
+ * @see SWT#RIGHT
+ * @see SWT#HORIZONTAL
+ * @see SWT#SHADOW_OUT
+ * @see SWT#VERTICAL
+ * @see Widget#checkSubclass()
+ * @see Widget#getStyle()
+ */
+public ToolBar (Composite parent, int style) {
+	super (parent, checkStyle (style));
+	/*
+	* Ensure that either of HORIZONTAL or VERTICAL is set.
+	* NOTE: HORIZONTAL and VERTICAL have the same values
+	* as H_SCROLL and V_SCROLL so it is necessary to first
+	* clear these bits to avoid scroll bars and then reset
+	* the bits using the original style supplied by the
+	* programmer.
+	*/
+	if ((style & SWT.VERTICAL) != 0) {
+		this.style |= SWT.VERTICAL;
+	} else {
+		this.style |= SWT.HORIZONTAL;
+	}
+	int orientation = (style & SWT.VERTICAL) != 0 ? OS.GTK_ORIENTATION_VERTICAL : OS.GTK_ORIENTATION_HORIZONTAL;
+	OS.gtk_toolbar_set_orientation (handle, orientation);
+}
+
+static int checkStyle (int style) {
+	/*
+	* Feature in GTK.  It is not possible to create
+	* a toolbar that wraps.  Therefore, no matter what 
+	* style bits are specified,	clear the WRAP bits so 
+	* that the style matches the behavior.
+	*/
+	if ((style & SWT.WRAP) != 0) style &= ~SWT.WRAP;
+	/*
+	* Even though it is legal to create this widget
+	* with scroll bars, they serve no useful purpose
+	* because they do not automatically scroll the
+	* widget's client area.  The fix is to clear
+	* the SWT style.
+	*/
+	return style & ~(SWT.H_SCROLL | SWT.V_SCROLL);
+}
+
+protected void checkSubclass () {
+	if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
+}
+
+void createHandle (int index) {
+	state |= HANDLE | THEME_BACKGROUND;
+	fixedHandle = OS.g_object_new (display.gtk_fixed_get_type (), 0);
+	if (fixedHandle == 0) error (SWT.ERROR_NO_HANDLES);
+	OS.gtk_fixed_set_has_window (fixedHandle, true);
+	handle = OS.gtk_toolbar_new ();
+	if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+	OS.gtk_container_add (fixedHandle, handle);
+	if ((style & SWT.FLAT) != 0) {
+		byte [] swt_toolbar_flat = Converter.wcsToMbcs (null, "swt-toolbar-flat", true);
+		OS.gtk_widget_set_name (handle, swt_toolbar_flat);
+	}
+}
+
+public Point computeSize (int wHint, int hHint, boolean changed) {
+	checkWidget ();
+	if (wHint != SWT.DEFAULT && wHint < 0) wHint = 0;
+	if (hHint != SWT.DEFAULT && hHint < 0) hHint = 0;
+	return computeNativeSize (handle, wHint, hHint, changed);
+}
+
+int /*long*/ eventHandle () {
+	return fixedHandle;
+}
+
+int /*long*/ enterExitHandle() {
+	return handle;
+}
+
+void fixChildren (Shell newShell, Shell oldShell, Decorations newDecorations, Decorations oldDecorations, Menu [] menus) {
+	super.fixChildren (newShell, oldShell, newDecorations, oldDecorations, menus);
+	ToolItem [] items = getItems ();
+	if (toolTipText == null) {
+		for (int i = 0; i < items.length; i++) {
+			ToolItem item = items [i];
+			if (item.toolTipText != null) {
+				item.setToolTipText(oldShell, null);
+				item.setToolTipText(newShell, item.toolTipText);
+			}
+		}
+	}
+}
+
+boolean forceFocus (int /*long*/ focusHandle) {
+	if (lastFocus != null && lastFocus.setFocus ()) return true;
+	ToolItem [] items = getItems ();
+	for (int i = 0; i < items.length; i++) {
+		ToolItem item = items [i];
+		if (item.setFocus ()) return true;
+	}
+	return super.forceFocus (focusHandle);
+}
+
+/**
+ * Returns the item at the given, zero-relative index in the
+ * receiver. Throws an exception if the index is out of range.
+ *
+ * @param index the index of the item to return
+ * @return the item at the given index
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public ToolItem getItem (int index) {
+	checkWidget();
+	if (!(0 <= index && index < getItemCount())) error (SWT.ERROR_INVALID_RANGE);
+	return getItems()[index];
+}
+
+/**
+ * Returns the item at the given point in the receiver
+ * or null if no such item exists. The point is in the
+ * coordinate system of the receiver.
+ *
+ * @param point the point used to locate the item
+ * @return the item at the given point
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the point is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public ToolItem getItem (Point point) {
+	checkWidget();
+	if (point == null) error (SWT.ERROR_NULL_ARGUMENT);
+	ToolItem[] items = getItems();
+	for (int i=0; i<items.length; i++) {
+		if (items[i].getBounds().contains(point)) return items[i];
+	}
+	return null;
+}
+
+/**
+ * Returns the number of items contained in the receiver.
+ *
+ * @return the number of items
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getItemCount () {
+	checkWidget();
+	int /*long*/ list = OS.gtk_container_get_children (handle);
+	if (list == 0) return 0;
+	int itemCount = OS.g_list_length (list);
+	OS.g_list_free (list);
+	return itemCount;
+}
+
+/**
+ * Returns an array of <code>ToolItem</code>s which are the items
+ * in the receiver. 
+ * <p>
+ * Note: This is not the actual structure used by the receiver
+ * to maintain its list of items, so modifying the array will
+ * not affect the receiver. 
+ * </p>
+ *
+ * @return the items in the receiver
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public ToolItem [] getItems () {
+	checkWidget();
+	int /*long*/ list = OS.gtk_container_get_children (handle);
+	if (list == 0) return new ToolItem [0];
+	int count = OS.g_list_length (list);
+	ToolItem [] result = new ToolItem [count];
+	for (int i=0; i<count; i++) {
+		int /*long*/ data = OS.g_list_nth_data (list, i);
+		Widget widget = display.getWidget (data);
+		result [i] = (ToolItem) widget;
+	}
+	OS.g_list_free (list);
+	return result;
+}
+
+/**
+ * Returns the number of rows in the receiver. When
+ * the receiver has the <code>WRAP</code> style, the
+ * number of rows can be greater than one.  Otherwise,
+ * the number of rows is always one.
+ *
+ * @return the number of items
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getRowCount () {
+	checkWidget();
+	 /* On GTK, toolbars cannot wrap */
+	return 1;
+}
+
+int /*long*/ gtk_key_press_event (int /*long*/ widget, int /*long*/ eventPtr) {
+	if (!hasFocus ()) return 0;
+	int /*long*/ result = super.gtk_key_press_event (widget, eventPtr);
+	if (result != 0) return result;
+	ToolItem [] items = getItems ();
+	int length = items.length;
+	int index = 0;
+	while (index < length) {
+		if (items [index].hasFocus ()) break;
+		index++;
+	}
+	GdkEventKey gdkEvent = new GdkEventKey ();
+	OS.memmove (gdkEvent, eventPtr, GdkEventKey.sizeof);
+	boolean next = false;
+	switch (gdkEvent.keyval) {
+		case OS.GDK_Up:
+		case OS.GDK_Left: next = false; break;
+		case OS.GDK_Down: {
+			if (0 <= index && index < length) {
+				ToolItem item = items [index];
+				if ((item.style & SWT.DROP_DOWN) != 0) {
+					Event event = new Event ();
+					event.detail = SWT.ARROW;
+					int /*long*/ topHandle = item.topHandle ();
+					event.x = OS.GTK_WIDGET_X (topHandle);
+					event.y = OS.GTK_WIDGET_Y (topHandle) + OS.GTK_WIDGET_HEIGHT (topHandle);
+					if ((style & SWT.MIRRORED) != 0) event.x = getClientWidth() - OS.GTK_WIDGET_WIDTH(topHandle) - event.x;
+					item.postEvent (SWT.Selection, event);
+					return result;
+				}
+			}
+			//FALL THROUGH
+		}
+		case OS.GDK_Right: next = true; break;
+		default: return result;
+	}
+	if ((style & SWT.MIRRORED) != 0) next= !next;
+	int start = index, offset = next ? 1 : -1;
+	while ((index = (index + offset + length) % length) != start) {
+		ToolItem item = items [index];
+		if (item.setFocus ()) return result;
+	}
+	return result;
+}
+
+boolean hasFocus () {
+	ToolItem [] items = getItems ();
+	for (int i=0; i<items.length; i++) {
+		ToolItem item = items [i];
+		if (item.hasFocus ()) return true;
+	}
+	return super.hasFocus();
+}
+
+/**
+ * Searches the receiver's list starting at the first item
+ * (index 0) until an item is found that is equal to the 
+ * argument, and returns the index of that item. If no item
+ * is found, returns -1.
+ *
+ * @param item the search item
+ * @return the index of the item
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the tool item is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the tool item has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int indexOf (ToolItem item) {
+	checkWidget();
+	if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
+	ToolItem [] items = getItems ();
+	for (int i=0; i<items.length; i++) {
+		if (item == items[i]) return i;
+	}
+	return -1;
+}
+
+boolean mnemonicHit (char key) {
+	ToolItem [] items = getItems ();
+	for (int i=0; i<items.length; i++) {
+		int /*long*/ labelHandle = items [i].labelHandle;
+		if (labelHandle != 0 && mnemonicHit (labelHandle, key)) return true;
+	}
+	return false;
+}
+
+boolean mnemonicMatch (char key) {
+	ToolItem [] items = getItems ();
+	for (int i=0; i<items.length; i++) {
+		int /*long*/ labelHandle = items [i].labelHandle;
+		if (labelHandle != 0 && mnemonicMatch (labelHandle, key)) return true;
+	}
+	return false;
+}
+
+void relayout () {
+	ToolItem [] items = getItems ();
+	for (int i=0; i<items.length; i++) {
+		ToolItem item = items [i];
+		if (item != null) item.resizeControl ();
+	}
+}
+
+void releaseChildren (boolean destroy) {
+	ToolItem [] items = getItems ();
+	for (int i=0; i<items.length; i++) {
+		ToolItem item = items [i];
+		if (item != null && !item.isDisposed ()) {
+			item.release (false);
+		}
+	}
+	super.releaseChildren (destroy);
+}
+
+void releaseWidget () {
+	super.releaseWidget ();
+	if (imageList != null) imageList.dispose ();
+	imageList = null;
+}
+
+void removeControl (Control control) {
+	super.removeControl (control);
+	ToolItem [] items = getItems ();
+	for (int i=0; i<items.length; i++) {
+		ToolItem item = items [i];
+		if (item.control == control) item.setControl (null);
+	}
+}
+
+int setBounds (int x, int y, int width, int height, boolean move, boolean resize) {
+	int result = super.setBounds (x, y, width, height, move, resize);
+	if ((result & RESIZED) != 0) relayout ();
+	return result;
+}
+
+void setFontDescription (int /*long*/ font) {
+	super.setFontDescription (font);
+	ToolItem [] items = getItems ();
+	for (int i = 0; i < items.length; i++) {
+		items[i].setFontDescription (font);
+	}
+	relayout ();
+}
+
+void setForegroundColor (GdkColor color) {
+	super.setForegroundColor (color);
+	ToolItem [] items = getItems ();
+	for (int i = 0; i < items.length; i++) {
+		items[i].setForegroundColor (color);
+	}
+}
+
+public void setToolTipText (String string) {
+	checkWidget();
+	super.setToolTipText (string);
+	Shell shell = _getShell ();
+	ToolItem [] items = getItems ();
+	for (int i = 0; i < items.length; i++) {
+		String newString = string != null ? null : items [i].toolTipText;
+		shell.setToolTipText (items [i].handle, newString);
+	}
+}
+
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/ToolItem.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/ToolItem.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/ToolItem.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,1050 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.widgets;
+
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.gtk.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.events.*;
+
+/**
+ * Instances of this class represent a selectable user interface object
+ * that represents a button in a tool bar.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>PUSH, CHECK, RADIO, SEPARATOR, DROP_DOWN</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Selection</dd>
+ * </dl>
+ * <p>
+ * Note: Only one of the styles CHECK, PUSH, RADIO, SEPARATOR and DROP_DOWN 
+ * may be specified.
+ * </p><p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ *
+ * @see <a href="http://www.eclipse.org/swt/snippets/#toolbar">ToolBar, ToolItem snippets</a>
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public class ToolItem extends Item {
+	int /*long*/ boxHandle, arrowHandle, arrowBoxHandle, separatorHandle, labelHandle, imageHandle;
+	ToolBar parent;
+	Control control;
+	Image hotImage, disabledImage;
+	String toolTipText;
+	boolean drawHotImage;
+
+/**
+ * Constructs a new instance of this class given its parent
+ * (which must be a <code>ToolBar</code>) and a style value
+ * describing its behavior and appearance. The item is added
+ * to the end of the items maintained by its parent.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT#PUSH
+ * @see SWT#CHECK
+ * @see SWT#RADIO
+ * @see SWT#SEPARATOR
+ * @see SWT#DROP_DOWN
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public ToolItem (ToolBar parent, int style) {
+	super (parent, checkStyle (style));
+	this.parent = parent;
+	createWidget (parent.getItemCount ());
+}
+
+/**
+ * Constructs a new instance of this class given its parent
+ * (which must be a <code>ToolBar</code>), a style value
+ * describing its behavior and appearance, and the index
+ * at which to place it in the items maintained by its parent.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ * @param index the zero-relative index to store the receiver in its parent
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the parent (inclusive)</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT#PUSH
+ * @see SWT#CHECK
+ * @see SWT#RADIO
+ * @see SWT#SEPARATOR
+ * @see SWT#DROP_DOWN
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public ToolItem (ToolBar parent, int style, int index) {
+	super (parent, checkStyle (style));
+	this.parent = parent;
+	int count = parent.getItemCount ();
+	if (!(0 <= index && index <= count)) {
+		error (SWT.ERROR_INVALID_RANGE);
+	}
+	createWidget (index);
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the control is selected by the user, by sending
+ * it one of the messages defined in the <code>SelectionListener</code>
+ * interface.
+ * <p>
+ * When <code>widgetSelected</code> is called when the mouse is over the arrow portion of a drop-down tool,
+ * the event object detail field contains the value <code>SWT.ARROW</code>.
+ * <code>widgetDefaultSelected</code> is not called.
+ * </p>
+ *
+ * @param listener the listener which should be notified when the control is selected by the user,
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent
+ */
+public void addSelectionListener(SelectionListener listener) {
+	checkWidget();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	TypedListener typedListener = new TypedListener (listener);
+	addListener (SWT.Selection,typedListener);
+	addListener (SWT.DefaultSelection,typedListener);
+}
+
+static int checkStyle (int style) {
+	return checkBits (style, SWT.PUSH, SWT.CHECK, SWT.RADIO, SWT.SEPARATOR, SWT.DROP_DOWN, 0);
+}
+
+protected void checkSubclass () {
+	if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
+}
+
+void createHandle (int index) {
+	state |= HANDLE;
+	if ((style & SWT.SEPARATOR) == 0) {
+		boxHandle = (parent.style & SWT.RIGHT) != 0 ? OS.gtk_hbox_new (false, 0) : OS.gtk_vbox_new (false, 0);
+		if (boxHandle == 0) error (SWT.ERROR_NO_HANDLES);
+		labelHandle = OS.gtk_label_new_with_mnemonic (null);
+		if (labelHandle == 0) error (SWT.ERROR_NO_HANDLES);
+		imageHandle = OS.gtk_image_new ();
+		if (imageHandle == 0) error (SWT.ERROR_NO_HANDLES);
+		OS.gtk_container_add (boxHandle, imageHandle);
+		OS.gtk_container_add (boxHandle, labelHandle);
+		if ((parent.style & SWT.VERTICAL) != 0) {
+			// Align text and images to the left
+			OS.gtk_box_set_child_packing (boxHandle, imageHandle, false, false, 0, OS.GTK_PACK_START);
+			OS.gtk_box_set_child_packing (boxHandle, labelHandle, false, false, 2, OS.GTK_PACK_START);
+		}
+	}
+	int bits = SWT.SEPARATOR | SWT.RADIO | SWT.CHECK | SWT.PUSH | SWT.DROP_DOWN;
+	switch (style & bits) {
+		case SWT.SEPARATOR:
+			handle = OS.gtk_hbox_new (false, 0);
+			if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+			boolean isVertical = (parent.style & SWT.VERTICAL) != 0;
+			separatorHandle = isVertical ? OS.gtk_hseparator_new() : OS.gtk_vseparator_new();
+			if (separatorHandle == 0) error (SWT.ERROR_NO_HANDLES);
+			OS.gtk_widget_set_size_request (separatorHandle, isVertical ? 15 : 6, isVertical ? 6 : 15);
+			OS.gtk_widget_set_size_request (handle, isVertical ? 15 : 6, isVertical ? 6 : 15);
+			OS.gtk_container_add (handle, separatorHandle);
+			break;
+		case SWT.DROP_DOWN:
+			handle = OS.gtk_button_new ();
+			if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+			arrowBoxHandle = OS.gtk_hbox_new (false, 0);
+			if (arrowBoxHandle == 0) error(SWT.ERROR_NO_HANDLES);
+			arrowHandle = OS.gtk_arrow_new (OS.GTK_ARROW_DOWN, OS.GTK_SHADOW_NONE);
+			if (arrowHandle == 0) error (SWT.ERROR_NO_HANDLES);
+			OS.gtk_widget_set_size_request (arrowHandle, 8, 6);
+			OS.gtk_container_add (handle, arrowBoxHandle);
+			OS.gtk_container_add (arrowBoxHandle, boxHandle);	
+			OS.gtk_container_add (arrowBoxHandle, arrowHandle);	
+			break;
+		case SWT.RADIO:
+			/*
+			* This code is intentionally commented.  Because GTK
+			* enforces radio behavior in a button group a radio group
+			* is not created for each set of contiguous buttons, each
+			* radio button will not draw unpressed.  The fix is to use
+			* toggle buttons instead.
+			*/
+//			handle = OS.gtk_radio_button_new (0);
+//			if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+//			OS.gtk_toggle_button_set_mode (handle, false);
+//			OS.gtk_container_add (handle, boxHandle);	
+//			break;
+		case SWT.CHECK:
+			handle = OS.gtk_toggle_button_new ();
+			if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+			OS.gtk_toggle_button_set_mode (handle, false);
+			OS.gtk_container_add (handle, boxHandle);	
+			break;
+		case SWT.PUSH:
+		default:
+			handle = OS.gtk_button_new ();
+			if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+			OS.gtk_container_add (handle, boxHandle);
+			break;
+	}
+	if ((style & SWT.SEPARATOR) == 0) {
+		int [] relief = new int [1];
+		OS.gtk_widget_style_get (parent.handle, OS.button_relief, relief, 0);
+		OS.gtk_button_set_relief (handle, relief [0]);
+	}
+	OS.GTK_WIDGET_UNSET_FLAGS (handle, OS.GTK_CAN_FOCUS);
+//	This code is intentionally commented.
+//	int /*long*/ fontHandle = parent.fontHandle ();
+//	GdkColor color = new GdkColor ();
+//	int /*long*/ style = OS.gtk_widget_get_style (fontHandle);
+//	OS.gtk_style_get_fg (style, OS.GTK_STATE_NORMAL, color);
+//	int /*long*/ font = OS.gtk_style_get_font_desc (style);
+//	setForegroundColor (color);
+//	setFontDescription (font);
+	if ((parent.state & FOREGROUND) != 0) {
+		setForegroundColor (parent.getForegroundColor());
+	}
+	if ((parent.state & FONT) != 0) {
+		setFontDescription (parent.getFontDescription());
+	}
+}
+
+void createWidget (int index) {
+	super.createWidget (index);
+	showWidget (index);
+	parent.relayout ();
+}
+
+void deregister() {
+	super.deregister ();
+	if (labelHandle != 0) display.removeWidget (labelHandle);
+}
+
+public void dispose () {
+	if (isDisposed ()) return;
+	ToolBar parent = this.parent;
+	super.dispose ();
+	parent.relayout ();
+}
+
+/**
+ * Returns a rectangle describing the receiver's size and location
+ * relative to its parent.
+ *
+ * @return the receiver's bounding rectangle
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Rectangle getBounds () {
+	checkWidget();
+	parent.forceResize ();
+	int /*long*/ topHandle = topHandle ();
+	int x, y, width, height;
+	/*
+	* Bug in GTK.  Toolbar items are only allocated their minimum size
+	* in versions before 2.4.0.  The fix is to use the total size
+	* available minus any borders.
+	*/
+	if (OS.GTK_VERSION < OS.VERSION (2, 4, 0) && control != null && !control.isDisposed ()) {
+		int border = OS.gtk_container_get_border_width (parent.handle);
+		byte [] shadowType = Converter.wcsToMbcs (null, "shadow_type", true);
+		int [] shadow = new int [1];
+		OS.gtk_widget_style_get (parent.handle, shadowType, shadow, 0);
+		if (shadow [0] != OS.GTK_SHADOW_NONE) {
+			border += OS.gtk_style_get_xthickness (OS.gtk_widget_get_style (parent.handle));
+		}
+		if ((parent.style & SWT.VERTICAL) != 0) {
+			x = border;
+			y = OS.GTK_WIDGET_Y (topHandle) + border;
+			width = OS.GTK_WIDGET_WIDTH (parent.handle) - border*2;
+			height = OS.GTK_WIDGET_HEIGHT (topHandle);			
+		} else {
+			x = OS.GTK_WIDGET_X (topHandle) + border;
+			y = border;
+			width = OS.GTK_WIDGET_WIDTH (topHandle);
+			height = OS.GTK_WIDGET_HEIGHT (parent.handle) - border*2;
+		}
+	} else {
+		x = OS.GTK_WIDGET_X (topHandle);
+		y = OS.GTK_WIDGET_Y (topHandle);
+		width = OS.GTK_WIDGET_WIDTH (topHandle);
+		height = OS.GTK_WIDGET_HEIGHT (topHandle);		
+	}
+	if ((parent.style & SWT.MIRRORED) != 0) x = parent.getClientWidth () - width - x;
+	if ((style & SWT.SEPARATOR) != 0 && control != null) height = Math.max (height, 23);
+	return new Rectangle (x, y, width, height);
+}
+
+/**
+ * Returns the control that is used to fill the bounds of
+ * the item when the item is a <code>SEPARATOR</code>.
+ *
+ * @return the control
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Control getControl () {
+	checkWidget();
+	return control;
+}
+
+/**
+ * Returns the receiver's disabled image if it has one, or null
+ * if it does not.
+ * <p>
+ * The disabled image is displayed when the receiver is disabled.
+ * </p>
+ *
+ * @return the receiver's disabled image
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Image getDisabledImage () {
+	checkWidget();
+	return disabledImage;
+}
+
+/**
+ * Returns <code>true</code> if the receiver is enabled, and
+ * <code>false</code> otherwise. A disabled control is typically
+ * not selectable from the user interface and draws with an
+ * inactive or "grayed" look.
+ *
+ * @return the receiver's enabled state
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see #isEnabled
+ */
+public boolean getEnabled () {
+	checkWidget();
+	int /*long*/ topHandle = topHandle ();
+	return OS.GTK_WIDGET_SENSITIVE (topHandle);
+}
+
+/**
+ * Returns the receiver's hot image if it has one, or null
+ * if it does not.
+ * <p>
+ * The hot image is displayed when the mouse enters the receiver.
+ * </p>
+ *
+ * @return the receiver's hot image
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Image getHotImage () {
+	checkWidget();
+	return hotImage;
+}
+
+/**
+ * Returns the receiver's parent, which must be a <code>ToolBar</code>.
+ *
+ * @return the receiver's parent
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public ToolBar getParent () {
+	checkWidget();
+	if (parent == null) error (SWT.ERROR_WIDGET_DISPOSED);
+	return parent;
+}
+
+/**
+ * Returns <code>true</code> if the receiver is selected,
+ * and false otherwise.
+ * <p>
+ * When the receiver is of type <code>CHECK</code> or <code>RADIO</code>,
+ * it is selected when it is checked (which some platforms draw as a
+ * pushed in button). If the receiver is of any other type, this method
+ * returns false.
+ * </p>
+ *
+ * @return the selection state
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public boolean getSelection () {
+	checkWidget();
+	if ((style & (SWT.CHECK | SWT.RADIO)) == 0) return false;
+	return OS.gtk_toggle_button_get_active (handle);
+}
+
+/**
+ * Returns the receiver's tool tip text, or null if it has not been set.
+ *
+ * @return the receiver's tool tip text
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public String getToolTipText () {
+	checkWidget();
+	return toolTipText;
+}
+
+/**
+ * Gets the width of the receiver.
+ *
+ * @return the width
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getWidth () {
+	checkWidget();
+	parent.forceResize ();
+	int /*long*/ topHandle = topHandle ();
+	return OS.GTK_WIDGET_WIDTH (topHandle);
+}
+
+int /*long*/ gtk_button_press_event (int /*long*/ widget, int /*long*/ event) {
+	GdkEventButton gdkEvent = new GdkEventButton ();
+	OS.memmove (gdkEvent, event, GdkEventButton.sizeof);
+	double x = gdkEvent.x;
+	gdkEvent.x += OS.GTK_WIDGET_X (handle);
+	double y = gdkEvent.y;
+	gdkEvent.y += OS.GTK_WIDGET_Y (handle);
+	OS.memmove (event, gdkEvent, GdkEventButton.sizeof);
+	int /*long*/ result = parent.gtk_button_press_event (widget, event);
+	gdkEvent.x = x;
+	gdkEvent.y = y;
+	OS.memmove (event, gdkEvent, GdkEventButton.sizeof);
+	return result;
+}
+
+int /*long*/ gtk_button_release_event (int /*long*/ widget, int /*long*/ event) {
+	GdkEventButton gdkEvent = new GdkEventButton ();
+	OS.memmove (gdkEvent, event, GdkEventButton.sizeof);
+	double x = gdkEvent.x;
+	gdkEvent.x += OS.GTK_WIDGET_X (handle);
+	double y = gdkEvent.y;
+	gdkEvent.y += OS.GTK_WIDGET_Y (handle);
+	OS.memmove (event, gdkEvent, GdkEventButton.sizeof);
+	int /*long*/ result = parent.gtk_button_release_event (widget, event);
+	gdkEvent.x = x;
+	gdkEvent.y = y;
+	OS.memmove(event, gdkEvent, GdkEventButton.sizeof);
+	return result;
+}
+
+int /*long*/ gtk_clicked (int /*long*/ widget) {
+	Event event = new Event ();
+	if ((style & SWT.DROP_DOWN) != 0) {
+		int /*long*/ eventPtr = OS.gtk_get_current_event ();
+		if (eventPtr != 0) {
+			GdkEvent gdkEvent = new GdkEvent ();
+			OS.memmove (gdkEvent, eventPtr, GdkEvent.sizeof);
+			switch (gdkEvent.type) {
+				case OS.GDK_BUTTON_PRESS:
+				case OS.GDK_2BUTTON_PRESS: 
+				case OS.GDK_BUTTON_RELEASE: {
+					double [] x_win = new double [1];
+					double [] y_win = new double [1];
+					OS.gdk_event_get_coords (eventPtr, x_win, y_win);
+					int x = OS.GTK_WIDGET_X (arrowHandle) - OS.GTK_WIDGET_X (handle);
+					int width = OS.GTK_WIDGET_WIDTH (arrowHandle);
+					if ((((parent.style & SWT.RIGHT_TO_LEFT) == 0) && x <= (int)x_win [0])
+						|| (((parent.style & SWT.RIGHT_TO_LEFT) != 0) && (int)x_win [0] <= x + width)) {
+						event.detail = SWT.ARROW;
+						int /*long*/ topHandle = topHandle ();
+						event.x = OS.GTK_WIDGET_X (topHandle);
+						if ((parent.style & SWT.MIRRORED) != 0) event.x = parent.getClientWidth () - OS.GTK_WIDGET_WIDTH (topHandle) - event.x;
+						event.y = OS.GTK_WIDGET_Y (topHandle) + OS.GTK_WIDGET_HEIGHT (topHandle);
+					}
+					break;
+				}
+			}
+			OS.gdk_event_free (eventPtr);
+		}
+	}
+	if ((style & SWT.RADIO) != 0) {
+		if ((parent.getStyle () & SWT.NO_RADIO_GROUP) == 0) {
+			selectRadio ();
+		}
+	}
+	postEvent (SWT.Selection, event);
+	return 0;
+}
+
+int /*long*/ gtk_enter_notify_event (int /*long*/ widget, int /*long*/ event) {
+	parent.gtk_enter_notify_event (widget, event);
+	drawHotImage = (parent.style & SWT.FLAT) != 0 && hotImage != null;
+	if (drawHotImage && imageHandle != 0) {
+		ImageList imageList = parent.imageList;
+		if (imageList != null) {
+			int index = imageList.indexOf (hotImage);
+			if (index != -1) {
+				int /*long*/ pixbuf = imageList.getPixbuf (index);
+				OS.gtk_image_set_from_pixbuf (imageHandle, pixbuf);
+			}
+		}
+	}
+	return 0;
+}
+
+int /*long*/ gtk_event_after (int /*long*/ widget, int /*long*/ gdkEvent) {
+	GdkEvent event = new GdkEvent ();
+	OS.memmove (event, gdkEvent, GdkEvent.sizeof);
+	switch (event.type) {
+		case OS.GDK_BUTTON_PRESS: {
+			GdkEventButton gdkEventButton = new GdkEventButton ();
+			OS.memmove (gdkEventButton, gdkEvent, GdkEventButton.sizeof);
+			if (gdkEventButton.button == 3) {
+				parent.showMenu ((int) gdkEventButton.x_root, (int) gdkEventButton.y_root);
+			}
+			break;
+		}
+	}	
+	return 0;
+}
+
+int /*long*/ gtk_focus_out_event (int /*long*/ widget, int /*long*/ event) {
+	OS.GTK_WIDGET_UNSET_FLAGS (handle, OS.GTK_CAN_FOCUS);
+	parent.lastFocus = this;
+	return 0;
+}
+
+int /*long*/ gtk_leave_notify_event (int /*long*/ widget, int /*long*/ event) {
+	parent.gtk_leave_notify_event (widget, event);
+	if (drawHotImage) {
+		drawHotImage = false;
+		if (imageHandle != 0 && image != null) {
+			ImageList imageList = parent.imageList;
+			if (imageList != null) {
+				int index = imageList.indexOf (image);
+				if (index != -1) {
+					int /*long*/ pixbuf = imageList.getPixbuf (index);
+					OS.gtk_image_set_from_pixbuf (imageHandle, pixbuf);
+				}
+			}
+		}	
+	}
+	return 0;
+}
+
+int /*long*/ gtk_map (int /*long*/ widget) {
+	parent.fixZOrder ();
+	return 0;
+}
+
+int /*long*/ gtk_mnemonic_activate (int /*long*/ widget, int /*long*/ arg1) {
+	return parent.gtk_mnemonic_activate (widget, arg1);
+}
+
+boolean hasFocus () {
+	return OS.GTK_WIDGET_HAS_FOCUS (handle);
+}
+
+void hookEvents () {
+	super.hookEvents ();
+	if ((style & SWT.SEPARATOR) != 0) return;
+	OS.g_signal_connect_closure (handle, OS.clicked, display.closures [CLICKED], false);
+	OS.g_signal_connect_closure_by_id (handle, display.signalIds [ENTER_NOTIFY_EVENT], 0, display.closures [ENTER_NOTIFY_EVENT], false);
+	OS.g_signal_connect_closure_by_id (handle, display.signalIds [LEAVE_NOTIFY_EVENT], 0, display.closures [LEAVE_NOTIFY_EVENT], false);
+	if (labelHandle != 0) OS.g_signal_connect_closure_by_id (labelHandle, display.signalIds [MNEMONIC_ACTIVATE], 0, display.closures [MNEMONIC_ACTIVATE], false);
+
+	OS.g_signal_connect_closure_by_id (handle, display.signalIds [FOCUS_OUT_EVENT], 0, display.closures [FOCUS_OUT_EVENT], false);
+
+	/*
+	* Feature in GTK.  Usually, GTK widgets propagate all events to their
+	* parent when they are done their own processing.  However, in contrast
+	* to other widgets, the buttons that make up the tool items, do not propagate
+	* the mouse up/down events. It is interesting to note that they DO propagate
+	* mouse motion events.  The fix is to explicitly forward mouse up/down events
+	* to the parent.
+	*/
+	int mask =
+		OS.GDK_EXPOSURE_MASK | OS.GDK_POINTER_MOTION_MASK |
+		OS.GDK_BUTTON_PRESS_MASK | OS.GDK_BUTTON_RELEASE_MASK | 
+		OS.GDK_ENTER_NOTIFY_MASK | OS.GDK_LEAVE_NOTIFY_MASK | 
+		OS.GDK_KEY_PRESS_MASK | OS.GDK_KEY_RELEASE_MASK |
+		OS.GDK_FOCUS_CHANGE_MASK;
+	OS.gtk_widget_add_events (handle, mask);
+	OS.g_signal_connect_closure_by_id (handle, display.signalIds [BUTTON_PRESS_EVENT], 0, display.closures [BUTTON_PRESS_EVENT], false);
+	OS.g_signal_connect_closure_by_id (handle, display.signalIds [BUTTON_RELEASE_EVENT], 0, display.closures [BUTTON_RELEASE_EVENT], false);
+	OS.g_signal_connect_closure_by_id (handle, display.signalIds [EVENT_AFTER], 0, display.closures[EVENT_AFTER], false);
+
+	int /*long*/ topHandle = topHandle ();
+	OS.g_signal_connect_closure_by_id (topHandle, display.signalIds [MAP], 0, display.closures [MAP], true);
+}
+
+/**
+ * Returns <code>true</code> if the receiver is enabled and all
+ * of the receiver's ancestors are enabled, and <code>false</code>
+ * otherwise. A disabled control is typically not selectable from the
+ * user interface and draws with an inactive or "grayed" look.
+ *
+ * @return the receiver's enabled state
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see #getEnabled
+ */
+public boolean isEnabled () {
+	checkWidget();
+	return getEnabled () && parent.isEnabled ();
+}
+
+void register () {
+	super.register ();
+	if (labelHandle != 0) display.addWidget (labelHandle, this);
+}
+
+void releaseHandle () {
+	super.releaseHandle ();
+	boxHandle = arrowHandle = separatorHandle = labelHandle = imageHandle = 0;
+}
+
+void releaseWidget () {
+	super.releaseWidget ();
+	if (parent.lastFocus == this) parent.lastFocus = null;
+	parent = null;
+	control = null;
+	hotImage = disabledImage = null;
+	toolTipText = null;
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the control is selected by the user.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #addSelectionListener
+ */
+public void removeSelectionListener(SelectionListener listener) {
+	checkWidget();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if (eventTable == null) return;
+	eventTable.unhook (SWT.Selection, listener);
+	eventTable.unhook (SWT.DefaultSelection,listener);	
+}
+
+void resizeControl () {
+	if (control != null && !control.isDisposed ()) {
+		if (separatorHandle != 0) OS.gtk_widget_hide (separatorHandle);
+		/*
+		* Set the size and location of the control
+		* separately to minimize flashing in the
+		* case where the control does not resize
+		* to the size that was requested.  This
+		* case can occur when the control is a
+		* combo box.
+		*/
+		Rectangle itemRect = getBounds ();
+		control.setSize (itemRect.width, itemRect.height);
+		OS.gtk_widget_set_size_request (handle, itemRect.width, itemRect.height);
+		Rectangle rect = control.getBounds ();
+		rect.x = itemRect.x + (itemRect.width - rect.width) / 2;
+		rect.y = itemRect.y + (itemRect.height - rect.height) / 2;
+		control.setLocation (rect.x, rect.y);
+	} else {
+		if (separatorHandle != 0) OS.gtk_widget_show (separatorHandle);
+	}
+}
+
+void selectRadio () {
+	int index = 0;
+	ToolItem [] items = parent.getItems ();
+	while (index < items.length && items [index] != this) index++;
+	int i = index - 1;
+	while (i >= 0 && items [i].setRadioSelection (false)) --i;
+	int j = index + 1;
+	while (j < items.length && items [j].setRadioSelection (false)) j++;
+	setSelection (true);
+}
+
+/**
+ * Sets the control that is used to fill the bounds of
+ * the item when the item is a <code>SEPARATOR</code>.
+ *
+ * @param control the new control
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the control has been disposed</li> 
+ *    <li>ERROR_INVALID_PARENT - if the control is not in the same widget tree</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setControl (Control control) {
+	checkWidget ();
+	if (control != null) {
+		if (control.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);
+		if (control.parent != parent) error (SWT.ERROR_INVALID_PARENT);
+	}
+	if ((style & SWT.SEPARATOR) == 0) return;
+	if (this.control == control) return;
+	this.control = control;
+	parent.relayout ();
+}
+
+/**
+ * Sets the receiver's disabled image to the argument, which may be
+ * null indicating that no disabled image should be displayed.
+ * <p>
+ * The disabled image is displayed when the receiver is disabled.
+ * </p>
+ *
+ * @param image the disabled image to display on the receiver (may be null)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li> 
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setDisabledImage (Image image) {
+	checkWidget();
+	if ((style & SWT.SEPARATOR) != 0) return;
+	disabledImage = image;
+}
+
+/**
+ * Enables the receiver if the argument is <code>true</code>,
+ * and disables it otherwise.
+ * <p>
+ * A disabled control is typically
+ * not selectable from the user interface and draws with an
+ * inactive or "grayed" look.
+ * </p>
+ *
+ * @param enabled the new enabled state
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setEnabled (boolean enabled) {
+	checkWidget();
+	int /*long*/ topHandle = topHandle ();
+	OS.gtk_widget_set_sensitive (topHandle, enabled);
+	if (enabled) {
+		/*
+		* Bug in GTK.  GtkButton requires an enter notify before it
+		* allows the button to be pressed, but events are dropped when
+		* widgets are insensitive.  The fix is to hide and show the
+		* button if the pointer is within its bounds.
+		*/
+		int [] x = new int [1], y = new int [1];
+		OS.gdk_window_get_pointer (parent.paintWindow (), x, y, null);
+		if (getBounds ().contains (x [0], y [0])) {
+			OS.gtk_widget_hide (handle);
+			OS.gtk_widget_show (handle);
+		}
+	}
+}
+
+boolean setFocus () {
+	if ((style & SWT.SEPARATOR) != 0) return false;
+	if (!OS.gtk_widget_get_child_visible (handle)) return false;
+	OS.GTK_WIDGET_SET_FLAGS (handle, OS.GTK_CAN_FOCUS);
+	OS.gtk_widget_grab_focus (handle);
+	boolean result = OS.gtk_widget_is_focus (handle);
+	if (!result) OS.GTK_WIDGET_UNSET_FLAGS (handle, OS.GTK_CAN_FOCUS);
+	return result;
+}
+
+void setFontDescription (int /*long*/ font) {
+	OS.gtk_widget_modify_font (handle, font);
+	if (labelHandle != 0) OS.gtk_widget_modify_font (labelHandle, font);
+	if (imageHandle != 0) OS.gtk_widget_modify_font (imageHandle, font);
+}
+
+void setForegroundColor (GdkColor color) {
+	setForegroundColor (handle, color);
+	if (labelHandle != 0) setForegroundColor (labelHandle, color);
+	if (imageHandle != 0) setForegroundColor (imageHandle, color);
+}
+
+/**
+ * Sets the receiver's hot image to the argument, which may be
+ * null indicating that no hot image should be displayed.
+ * <p>
+ * The hot image is displayed when the mouse enters the receiver.
+ * </p>
+ *
+ * @param image the hot image to display on the receiver (may be null)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li> 
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setHotImage (Image image) {
+	checkWidget();
+	if ((style & SWT.SEPARATOR) != 0) return;
+	hotImage = image;
+	if (image != null) {
+		ImageList imageList = parent.imageList;
+		if (imageList == null) imageList = parent.imageList = new ImageList ();
+		int imageIndex = imageList.indexOf (image);
+		if (imageIndex == -1) {
+			imageIndex = imageList.add (image);
+		} else {
+			imageList.put (imageIndex, image);
+		}
+	}
+}
+
+public void setImage (Image image) {
+	checkWidget();
+	if ((style & SWT.SEPARATOR) != 0) return;
+	super.setImage (image);
+	if (imageHandle == 0) return;
+	if (image != null) {
+		ImageList imageList = parent.imageList;
+		if (imageList == null) imageList = parent.imageList = new ImageList ();
+		int imageIndex = imageList.indexOf (image);
+		if (imageIndex == -1) {
+			imageIndex = imageList.add (image);
+		} else {
+			imageList.put (imageIndex, image);
+		}
+		int /*long*/ pixbuf = imageList.getPixbuf (imageIndex);
+		OS.gtk_image_set_from_pixbuf (imageHandle, pixbuf);
+		OS.gtk_widget_show (imageHandle);
+	} else {
+		OS.gtk_image_set_from_pixbuf (imageHandle, 0);
+		OS.gtk_widget_hide (imageHandle);
+	}
+	parent.relayout ();
+}
+
+void setOrientation () {
+	if ((parent.style & SWT.RIGHT_TO_LEFT) != 0) {
+		if (handle != 0) OS.gtk_widget_set_direction (handle, OS.GTK_TEXT_DIR_RTL);
+		if (labelHandle != 0) OS.gtk_widget_set_direction (labelHandle, OS.GTK_TEXT_DIR_RTL);
+		if (imageHandle != 0) OS.gtk_widget_set_direction (imageHandle, OS.GTK_TEXT_DIR_RTL);
+		if (separatorHandle != 0) OS.gtk_widget_set_direction (separatorHandle, OS.GTK_TEXT_DIR_RTL);
+		if (arrowHandle != 0) OS.gtk_widget_set_direction (arrowHandle, OS.GTK_TEXT_DIR_RTL);
+		if (boxHandle != 0) OS.gtk_widget_set_direction (boxHandle, OS.GTK_TEXT_DIR_RTL);
+		if (arrowBoxHandle != 0) OS.gtk_widget_set_direction (arrowBoxHandle, OS.GTK_TEXT_DIR_RTL);
+	}
+}
+
+boolean setRadioSelection (boolean value) {
+	if ((style & SWT.RADIO) == 0) return false;
+	if (getSelection () != value) {
+		setSelection (value);
+		postEvent (SWT.Selection);
+	}
+	return true;
+}
+
+/**
+ * Sets the selection state of the receiver.
+ * <p>
+ * When the receiver is of type <code>CHECK</code> or <code>RADIO</code>,
+ * it is selected when it is checked (which some platforms draw as a
+ * pushed in button).
+ * </p>
+ *
+ * @param selected the new selection state
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setSelection (boolean selected) {
+	checkWidget ();
+	if ((style & (SWT.CHECK | SWT.RADIO)) == 0) return;
+	OS.g_signal_handlers_block_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CLICKED);
+	OS.gtk_toggle_button_set_active (handle, selected);
+	OS.g_signal_handlers_unblock_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CLICKED);
+}
+
+/**
+ * Sets the receiver's text. The string may include
+ * the mnemonic character.
+ * </p>
+ * <p>
+ * Mnemonics are indicated by an '&amp;' that causes the next
+ * character to be the mnemonic.  When the user presses a
+ * key sequence that matches the mnemonic, a selection
+ * event occurs. On most platforms, the mnemonic appears
+ * underlined but may be emphasised in a platform specific
+ * manner.  The mnemonic indicator character '&amp;' can be
+ * escaped by doubling it in the string, causing a single
+ * '&amp;' to be displayed.
+ * </p>
+ * 
+ * @param string the new text
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the text is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setText (String string) {
+	checkWidget();
+	if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if ((style & SWT.SEPARATOR) != 0) return;
+	super.setText (string);
+	if (labelHandle == 0) return;
+	char [] chars = fixMnemonic (string);
+	byte [] buffer = Converter.wcsToMbcs (null, chars, true);
+	OS.gtk_label_set_text_with_mnemonic (labelHandle, buffer);
+	if (string.length () != 0) {
+		OS.gtk_widget_show (labelHandle);
+	} else {
+		OS.gtk_widget_hide (labelHandle);
+	}
+	parent.relayout ();
+}
+
+/**
+ * Sets the receiver's tool tip text to the argument, which
+ * may be null indicating that no tool tip text should be shown.
+ *
+ * @param string the new tool tip text (or null)
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setToolTipText (String string) {
+	checkWidget();
+	if (parent.toolTipText == null) {
+		Shell shell = parent._getShell ();
+		setToolTipText (shell, string);
+	}
+	toolTipText = string;
+}
+
+void setToolTipText (Shell shell, String newString) {
+	shell.setToolTipText (handle, newString);
+}
+
+/**
+ * Sets the width of the receiver, for <code>SEPARATOR</code> ToolItems.
+ *
+ * @param width the new width
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setWidth (int width) {
+	checkWidget();
+	if ((style & SWT.SEPARATOR) == 0) return;
+	if (width < 0) return;
+	boolean isVertical = (parent.style & SWT.VERTICAL) != 0;
+	OS.gtk_widget_set_size_request (separatorHandle, width, isVertical ? 6 : 15);
+	OS.gtk_widget_set_size_request (handle, width, isVertical ? 6 : 15);
+	parent.relayout ();
+}
+
+void showWidget (int index) {
+	if (handle != 0) OS.gtk_widget_show (handle);
+	if (boxHandle != 0) OS.gtk_widget_show (boxHandle);
+	if (separatorHandle != 0) OS.gtk_widget_show (separatorHandle);
+	if (arrowBoxHandle != 0) OS.gtk_widget_show (arrowBoxHandle);
+	if (arrowHandle != 0) OS.gtk_widget_show (arrowHandle);
+	OS.gtk_toolbar_insert_widget (parent.handle, handle, null, null, index);
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/ToolTip.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/ToolTip.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/ToolTip.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,805 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.widgets;
+
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.gtk.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.events.*;
+
+/**
+ * Instances of this class represent popup windows that are used
+ * to inform or warn the user.
+ * <p>
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>BALLOON, ICON_ERROR, ICON_INFORMATION, ICON_WARNING</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Selection</dd>
+ * </dl>
+ * </p><p>
+ * Note: Only one of the styles ICON_ERROR, ICON_INFORMATION,
+ * and ICON_WARNING may be specified.
+ * </p><p>
+ * IMPORTANT: This class is intended to be subclassed <em>only</em>
+ * within the SWT implementation.
+ * </p>
+ *
+ * @see <a href="http://www.eclipse.org/swt/snippets/#tooltips">Tool Tips snippets</a>
+ * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: ControlExample</a>
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ * 
+ * @since 3.2
+ */
+public class ToolTip extends Widget {
+	Shell parent;
+	String text, message;
+	TrayItem item;
+	int x, y, timerId;
+	int /*long*/ layoutText = 0, layoutMessage = 0;
+	int [] borderPolygon;
+	boolean spikeAbove, autohide;
+	
+	static final int BORDER = 5;
+	static final int PADDING = 5;
+	static final int INSET = 4;
+	static final int TIP_HEIGHT = 20;
+	static final int IMAGE_SIZE = 16;
+	static final int DELAY = 8000;
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT#ICON_ERROR
+ * @see SWT#ICON_INFORMATION
+ * @see SWT#ICON_WARNING
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public ToolTip (Shell parent, int style) {
+	super (parent, checkStyle (style));
+	this.parent = parent;
+	createWidget (0);
+}
+
+static int checkStyle (int style) {
+	int mask = SWT.ICON_ERROR | SWT.ICON_INFORMATION | SWT.ICON_WARNING;
+	if ((style & mask) == 0) return style;
+	return checkBits (style, SWT.ICON_INFORMATION, SWT.ICON_WARNING, SWT.ICON_ERROR, 0, 0, 0);
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the receiver is selected by the user, by sending
+ * it one of the messages defined in the <code>SelectionListener</code>
+ * interface.
+ * <p>
+ * <code>widgetSelected</code> is called when the receiver is selected.
+ * <code>widgetDefaultSelected</code> is not called.
+ * </p>
+ *
+ * @param listener the listener which should be notified when the receiver is selected by the user
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent
+ */
+public void addSelectionListener (SelectionListener listener) {
+	checkWidget ();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	TypedListener typedListener = new TypedListener (listener);
+	addListener (SWT.Selection,typedListener);
+	addListener (SWT.DefaultSelection,typedListener);
+}
+
+void configure () {
+	int /*long*/ screen = OS.gdk_screen_get_default ();
+	OS.gtk_widget_realize (handle);
+	int monitorNumber = OS.gdk_screen_get_monitor_at_window (screen, OS.GTK_WIDGET_WINDOW (handle));
+	GdkRectangle dest = new GdkRectangle ();
+	OS.gdk_screen_get_monitor_geometry (screen, monitorNumber, dest);
+	Point point = getSize (dest.width / 4);
+	int w = point.x;
+	int h = point.y;
+	point = getLocation ();
+	int x = point.x;
+	int y = point.y;
+	OS.gtk_window_resize (handle, w, h + TIP_HEIGHT);
+	int[] polyline;
+	spikeAbove = dest.height >= y + h + TIP_HEIGHT;
+	if (dest.width >= x + w) {
+		if (dest.height >= y + h + TIP_HEIGHT) {
+			int t = TIP_HEIGHT;
+			polyline = new int[] {
+				0, 5+t, 1, 5+t, 1, 3+t, 3, 1+t,  5, 1+t, 5, t, 
+				16, t, 16, 0, 35, t,
+				w-5, t, w-5, 1+t, w-3, 1+t, w-1, 3+t, w-1, 5+t, w, 5+t,
+				w, h-5+t, w-1, h-5+t, w-1, h-3+t, w-2, h-3+t, w-2, h-2+t, w-3, h-2+t, w-3, h-1+t, w-5, h-1+t, w-5, h+t,
+				5, h+t, 5, h-1+t, 3, h-1+t, 3, h-2+t, 2, h-2+t, 2, h-3+t, 1, h-3+t, 1, h-5+t, 0, h-5+t, 
+				0, 5+t};
+			borderPolygon = new int[] {
+				0, 5+t, 1, 4+t, 1, 3+t, 3, 1+t,  4, 1+t, 5, t, 
+				16, t, 16, 1, 35, t,
+				w-6, 0+t, w-5, 1+t, w-4, 1+t, w-2, 3+t, w-2, 4+t, w-1, 5+t,
+				w-1, h-6+t, w-2, h-5+t, w-2, h-4+t, w-4, h-2+t, w-5, h-2+t, w-6, h-1+t,
+				5, h-1+t, 4, h-2+t, 3, h-2+t, 1, h-4+t, 1, h-5+t, 0, h-6+t, 
+				0, 5+t};
+			if ((parent.style & SWT.MIRRORED) != 0) {
+				x -= w - 36;
+				polyline[12] = w-36; 
+				polyline[14] = w-16; 
+				polyline[16] = w-15; 
+				borderPolygon[12] = w-35;
+				borderPolygon[14] = borderPolygon[16]  = w-16;
+			}
+			OS.gtk_window_move (handle, Math.max(0, x - 17), y);
+		} else {
+			polyline = new int[] {
+				0, 5, 1, 5, 1, 3, 3, 1,  5, 1, 5, 0, 
+				w-5, 0, w-5, 1, w-3, 1, w-1, 3, w-1, 5, w, 5,
+				w, h-5, w-1, h-5, w-1, h-3, w-2, h-3, w-2, h-2, w-3, h-2, w-3, h-1, w-5, h-1, w-5, h,
+				35, h, 16, h+TIP_HEIGHT, 16, h,
+				5, h, 5, h-1, 3, h-1, 3, h-2, 2, h-2, 2, h-3, 1, h-3, 1, h-5, 0, h-5, 
+				0, 5};
+			borderPolygon = new int[] {
+				0, 5, 1, 4, 1, 3, 3, 1,  4, 1, 5, 0, 
+				w-6, 0, w-5, 1, w-4, 1, w-2, 3, w-2, 4, w-1, 5,
+				w-1, h-6, w-2, h-5, w-2, h-4, w-4, h-2, w-5, h-2, w-6, h-1,
+				35, h-1, 17, h+TIP_HEIGHT-2, 17, h-1,
+				5, h-1, 4, h-2, 3, h-2, 1, h-4, 1, h-5, 0, h-6, 
+				0, 5};
+			if ((parent.style & SWT.MIRRORED) != 0) {
+				x -= w - 36;
+				polyline [42] =  polyline [44] =  w-16;
+				polyline [46] = w-35;
+				borderPolygon[36] = borderPolygon[38] = w-17;
+				borderPolygon [40] = w-35;
+			}
+			OS.gtk_window_move (handle, Math.max(0, x - 17), y - h - TIP_HEIGHT);
+		}
+	} else {
+		if (dest.height >= y + h + TIP_HEIGHT) {
+			int t = TIP_HEIGHT;
+			polyline = new int[] {
+				0, 5+t, 1, 5+t, 1, 3+t, 3, 1+t,  5, 1+t, 5, t, 
+				w-35, t, w-16, 0, w-16, t,
+				w-5, t, w-5, 1+t, w-3, 1+t, w-1, 3+t, w-1, 5+t, w, 5+t,
+				w, h-5+t, w-1, h-5+t, w-1, h-3+t, w-2, h-3+t, w-2, h-2+t, w-3, h-2+t, w-3, h-1+t, w-5, h-1+t, w-5, h+t,
+				5, h+t, 5, h-1+t, 3, h-1+t, 3, h-2+t, 2, h-2+t, 2, h-3+t, 1, h-3+t, 1, h-5+t, 0, h-5+t, 
+				0, 5+t};
+			borderPolygon = new int[] {
+				0, 5+t, 1, 4+t, 1, 3+t, 3, 1+t,  4, 1+t, 5, t, 
+				w-35, t, w-17, 2, w-17, t,
+				w-6, t, w-5, 1+t, w-4, 1+t, w-2, 3+t, w-2, 4+t, w-1, 5+t,
+				w-1, h-6+t, w-2, h-5+t, w-2, h-4+t, w-4, h-2+t, w-5, h-2+t, w-6, h-1+t,
+				5, h-1+t, 4, h-2+t, 3, h-2+t, 1, h-4+t, 1, h-5+t, 0, h-6+t, 
+				0, 5+t};
+			if ((parent.style & SWT.MIRRORED) != 0) {
+				x += w - 35;
+				polyline [12] = polyline [14] = 16;
+				polyline [16] = 35;
+				borderPolygon[12] =  borderPolygon[14] = 16;
+				borderPolygon [16] = 35;
+			}
+			OS.gtk_window_move (handle, Math.min(dest.width - w, x - w + 17), y);
+		} else {
+			polyline = new int[] {
+				0, 5, 1, 5, 1, 3, 3, 1,  5, 1, 5, 0, 
+				w-5, 0, w-5, 1, w-3, 1, w-1, 3, w-1, 5, w, 5,
+				w, h-5, w-1, h-5, w-1, h-3, w-2, h-3, w-2, h-2, w-3, h-2, w-3, h-1, w-5, h-1, w-5, h,
+				w-16, h, w-16, h+TIP_HEIGHT, w-35, h,
+				5, h, 5, h-1, 3, h-1, 3, h-2, 2, h-2, 2, h-3, 1, h-3, 1, h-5, 0, h-5, 
+				0, 5};
+			borderPolygon = new int[] {
+				0, 5, 1, 4, 1, 3, 3, 1,  4, 1, 5, 0, 
+				w-6, 0, w-5, 1, w-4, 1, w-2, 3, w-2, 4, w-1, 5,
+				w-1, h-6, w-2, h-5, w-2, h-4, w-4, h-2, w-5, h-2, w-6, h-1,
+				w-17, h-1, w-17, h+TIP_HEIGHT-2, w-36, h-1,
+				5, h-1, 4, h-2, 3, h-2, 1, h-4, 1, h-5, 0, h-6, 
+				0, 5};
+			if ((parent.style & SWT.MIRRORED) != 0) {
+				x += w - 35;
+				polyline [42] =  35;
+				polyline [44] = polyline [46] = 16;
+				borderPolygon[36] = 35;
+				borderPolygon[38] = borderPolygon [40] = 17;
+			}
+			OS.gtk_window_move (handle, Math.min(dest.width - w, x - w + 17), y - h - TIP_HEIGHT);
+		}
+	}
+	int /*long*/ rgn = OS.gdk_region_polygon (polyline, polyline.length / 2, OS.GDK_EVEN_ODD_RULE);
+	OS.gtk_widget_realize (handle);
+	int /*long*/ window = OS.GTK_WIDGET_WINDOW (handle);
+	OS.gdk_window_shape_combine_region (window, rgn, 0, 0);
+	OS.gdk_region_destroy (rgn);
+}
+
+void createHandle (int index) {
+	state |= HANDLE;
+	if ((style & SWT.BALLOON) != 0) {
+		handle = OS.gtk_window_new (OS.GTK_WINDOW_POPUP);
+		Color background = display.getSystemColor (SWT.COLOR_INFO_BACKGROUND);
+		OS.gtk_widget_modify_bg (handle, OS.GTK_STATE_NORMAL, background.handle);
+		OS.gtk_widget_set_app_paintable (handle, true);
+	} else {
+		handle = OS.gtk_tooltips_new ();
+		if (handle == 0) SWT.error (SWT.ERROR_NO_HANDLES);
+		/*
+		* Bug in Solaris-GTK.  Invoking gtk_tooltips_force_window()
+		* can cause a crash in older versions of GTK.  The fix is
+		* to avoid this call if the GTK version is older than 2.2.x.
+		*/
+		if (OS.GTK_VERSION >= OS.VERSION (2, 2, 1)) { 
+			OS.gtk_tooltips_force_window (handle);
+		}
+		OS.g_object_ref (handle);
+		OS.gtk_object_sink (handle);
+	}
+}
+
+void createWidget (int index) {
+	super.createWidget (index);
+	text = "";
+	message = "";
+	x = y = -1;
+	autohide = true;
+}
+
+void deregister () {
+	super.deregister ();
+	if ((style & SWT.BALLOON) == 0) {
+		int /*long*/ tipWindow = OS.GTK_TOOLTIPS_TIP_WINDOW (handle);
+		if (tipWindow != 0) display.removeWidget (tipWindow);
+	}
+}
+
+void destroyWidget () {
+	int /*long*/ topHandle = topHandle ();
+	releaseHandle ();
+	if (topHandle != 0 && (state & HANDLE) != 0) {
+		if ((style & SWT.BALLOON) != 0) {
+			OS.gtk_widget_destroy (topHandle);
+		} else {
+			OS.g_object_unref (topHandle);
+		}
+	}
+}
+
+/**
+ * Returns <code>true</code> if the receiver is automatically
+ * hidden by the platform, and <code>false</code> otherwise.
+ *
+ * @return the receiver's auto hide state
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ */
+public boolean getAutoHide () {
+	checkWidget ();
+	return autohide;
+}
+
+Point getLocation () {
+	int x = this.x;
+	int y = this.y;
+	if (item != null) {
+		int /*long*/ itemHandle = item.handle; 
+		OS.gtk_widget_realize (itemHandle);
+		int /*long*/ window = OS.GTK_WIDGET_WINDOW (itemHandle);
+		int [] px = new int [1], py = new int [1];
+		OS.gdk_window_get_origin (window, px, py);
+		x = px [0] + OS.GTK_WIDGET_WIDTH (itemHandle) / 2;
+		y = py [0] + OS.GTK_WIDGET_HEIGHT (itemHandle) / 2;
+	}
+	if (x == -1 || y == -1) {
+		int [] px = new int [1], py = new int [1];
+		OS.gdk_window_get_pointer (0, px, py, null);
+		x = px [0];
+		y = py [0];
+	}
+	return new Point(x, y);
+}
+
+/**
+ * Returns the receiver's message, which will be an empty
+ * string if it has never been set.
+ *
+ * @return the receiver's message
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public String getMessage () {
+	checkWidget ();
+	return message;
+}
+
+String getNameText () {
+	return getText ();
+}
+
+/**
+ * Returns the receiver's parent, which must be a <code>Shell</code>.
+ *
+ * @return the receiver's parent
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Shell getParent () {
+	checkWidget ();
+	return parent;
+}
+
+Point getSize (int maxWidth) {
+	int textWidth = 0, messageWidth = 0;
+	int [] w = new int [1], h = new int [1];
+	if (layoutText != 0) {
+		OS.pango_layout_set_width (layoutText, -1);
+		OS.pango_layout_get_size (layoutText, w, h);
+		textWidth = OS.PANGO_PIXELS (w [0]);
+	}
+	if (layoutMessage != 0) {
+		OS.pango_layout_set_width (layoutMessage, -1);
+		OS.pango_layout_get_size (layoutMessage, w, h);
+		messageWidth = OS.PANGO_PIXELS (w [0]);
+	}
+	int messageTrim = 2 * INSET + 2 * BORDER + 2 * PADDING;
+	boolean hasImage = layoutText != 0 && (style & (SWT.ICON_ERROR | SWT.ICON_INFORMATION | SWT.ICON_WARNING)) != 0;
+	int textTrim = messageTrim + (hasImage ? IMAGE_SIZE : 0);  
+	int width = Math.min (maxWidth, Math.max (textWidth + textTrim, messageWidth + messageTrim));
+	int textHeight = 0, messageHeight = 0;
+	if (layoutText != 0) {
+		OS.pango_layout_set_width (layoutText, (maxWidth - textTrim) * OS.PANGO_SCALE);
+		OS.pango_layout_get_size (layoutText, w, h);
+		textHeight = OS.PANGO_PIXELS (h [0]);
+	}
+	if (layoutMessage != 0) {
+		OS.pango_layout_set_width (layoutMessage, (maxWidth - messageTrim) * OS.PANGO_SCALE);
+		OS.pango_layout_get_size (layoutMessage, w, h);
+		messageHeight = OS.PANGO_PIXELS (h [0]);
+	}
+	int height = 2 * BORDER + 2 * PADDING + messageHeight;
+	if (layoutText != 0) height += Math.max (IMAGE_SIZE, textHeight) + 2 * PADDING;
+	return new Point(width, height);
+}
+
+/**
+ * Returns the receiver's text, which will be an empty
+ * string if it has never been set.
+ *
+ * @return the receiver's text
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public String getText () {
+	checkWidget ();
+	return text;
+}
+
+/**
+ * Returns <code>true</code> if the receiver is visible, and
+ * <code>false</code> otherwise.
+ * <p>
+ * If one of the receiver's ancestors is not visible or some
+ * other condition makes the receiver not visible, this method
+ * may still indicate that it is considered visible even though
+ * it may not actually be showing.
+ * </p>
+ *
+ * @return the receiver's visibility state
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public boolean getVisible () {
+	checkWidget ();
+	if ((style & SWT.BALLOON) != 0) return OS.GTK_WIDGET_VISIBLE (handle);
+	int /*long*/ tipWindow = OS.GTK_TOOLTIPS_TIP_WINDOW (handle);
+	return OS.GTK_WIDGET_VISIBLE (tipWindow);
+}
+
+int /*long*/ gtk_button_press_event (int /*long*/ widget, int /*long*/ event) {
+	notifyListeners (SWT.Selection, new Event ());
+	setVisible (false);
+	return 0;
+}
+
+int /*long*/ gtk_expose_event (int /*long*/ widget, int /*long*/ eventPtr) {
+	int /*long*/ window = OS.GTK_WIDGET_WINDOW (handle);
+	int /*long*/ gdkGC = OS.gdk_gc_new (window);
+	OS.gdk_draw_polygon (window, gdkGC, 0, borderPolygon, borderPolygon.length / 2);
+	int x = BORDER + PADDING;
+	int y = BORDER + PADDING;
+	if (spikeAbove) y += TIP_HEIGHT;
+	if (layoutText != 0) {
+		byte[] buffer = null;
+		int id = style & (SWT.ICON_ERROR | SWT.ICON_INFORMATION | SWT.ICON_WARNING);
+		switch (id) {
+			case SWT.ICON_ERROR: buffer = Converter.wcsToMbcs (null, "gtk-dialog-error", true); break; 
+			case SWT.ICON_INFORMATION: buffer = Converter.wcsToMbcs (null, "gtk-dialog-info", true); break;
+			case SWT.ICON_WARNING: buffer = Converter.wcsToMbcs (null, "gtk-dialog-warning", true); break;
+		}
+		if (buffer != null) {
+			int /*long*/ style = OS.gtk_widget_get_default_style ();
+			int /*long*/ pixbuf = OS.gtk_icon_set_render_icon (
+				OS.gtk_icon_factory_lookup_default (buffer), 
+				style,
+				OS.GTK_TEXT_DIR_NONE, 
+				OS.GTK_STATE_NORMAL, 
+				OS.GTK_ICON_SIZE_MENU,
+				0, 
+				0);
+			OS.gdk_draw_pixbuf (window, gdkGC, pixbuf, 0, 0, x, y, IMAGE_SIZE, IMAGE_SIZE, OS.GDK_RGB_DITHER_NORMAL, 0, 0);
+			OS.g_object_unref (pixbuf);
+			x += IMAGE_SIZE;
+		}
+		x += INSET;
+		OS.gdk_draw_layout (window, gdkGC, x, y, layoutText);
+		int [] w = new int [1], h = new int [1];
+		OS.pango_layout_get_size (layoutText, w, h);
+		y += 2 * PADDING + Math.max (IMAGE_SIZE, OS.PANGO_PIXELS (h [0]));
+	}
+	if (layoutMessage != 0) {
+		x = BORDER + PADDING + INSET;
+		OS.gdk_draw_layout (window, gdkGC, x, y, layoutMessage);
+	}
+	OS.g_object_unref (gdkGC);
+	return 0;
+}
+
+int /*long*/ gtk_size_allocate (int /*long*/ widget, int /*long*/ allocation) {
+	Point point = getLocation (); 
+	int x = point.x;
+	int y = point.y;
+	int /*long*/ screen = OS.gdk_screen_get_default ();
+	OS.gtk_widget_realize (widget);
+	int monitorNumber = OS.gdk_screen_get_monitor_at_window (screen, OS.GTK_WIDGET_WINDOW (widget));
+	GdkRectangle dest = new GdkRectangle ();
+	OS.gdk_screen_get_monitor_geometry (screen, monitorNumber, dest);
+	int w = OS.GTK_WIDGET_WIDTH (widget);
+	int h = OS.GTK_WIDGET_HEIGHT (widget);
+	if (dest.height < y + h) y -= h;
+	if (dest.width < x + w) x -= w;
+	OS.gtk_window_move (widget, x, y);
+	return 0;
+}
+
+void hookEvents () {
+	if ((style & SWT.BALLOON) != 0) {
+		OS.g_signal_connect_closure (handle, OS.expose_event, display.closures [EXPOSE_EVENT], false);
+		OS.gtk_widget_add_events (handle, OS.GDK_BUTTON_PRESS_MASK);
+		OS.g_signal_connect_closure (handle, OS.button_press_event, display.closures [BUTTON_PRESS_EVENT], false);
+	} else {
+		int /*long*/ tipWindow = OS.GTK_TOOLTIPS_TIP_WINDOW (handle);
+		if (tipWindow != 0) {
+			OS.g_signal_connect_closure (tipWindow, OS.size_allocate, display.closures [SIZE_ALLOCATE], false);
+			OS.gtk_widget_add_events (tipWindow, OS.GDK_BUTTON_PRESS_MASK);
+			OS.g_signal_connect_closure (tipWindow, OS.button_press_event, display.closures [BUTTON_PRESS_EVENT], false);
+		}
+	}
+}
+
+/**
+ * Returns <code>true</code> if the receiver is visible and all
+ * of the receiver's ancestors are visible and <code>false</code>
+ * otherwise.
+ *
+ * @return the receiver's visibility state
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #getVisible
+ */
+public boolean isVisible () {
+	checkWidget ();
+	return getVisible ();
+}
+
+void register () {
+	super.register ();
+	if ((style & SWT.BALLOON) == 0) {
+		int /*long*/ tipWindow = OS.GTK_TOOLTIPS_TIP_WINDOW (handle);
+		if (tipWindow != 0) display.addWidget (tipWindow, this);
+	}
+}
+
+void releaseWidget () {
+	super.releaseWidget ();
+	if (layoutText != 0) OS.g_object_unref (layoutText);
+	layoutText = 0;
+	if (layoutMessage != 0) OS.g_object_unref (layoutMessage);
+	layoutMessage = 0;
+	if (timerId != 0) OS.gtk_timeout_remove(timerId);
+	timerId = 0;
+	text = null;
+	message = null;
+	borderPolygon = null;
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the receiver is selected by the user.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #addSelectionListener
+ */
+public void removeSelectionListener (SelectionListener listener) {
+	checkWidget();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if (eventTable == null) return;
+	eventTable.unhook (SWT.Selection, listener);
+	eventTable.unhook (SWT.DefaultSelection, listener);
+}
+
+/**
+ * Makes the receiver hide automatically when <code>true</code>,
+ * and remain visible when <code>false</code>.
+ *
+ * @param autoHide the auto hide state
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see #getVisible
+ * @see #setVisible
+ */
+public void setAutoHide (boolean autohide) {
+	checkWidget ();
+	this.autohide = autohide;
+	//TODO - update when visible
+}
+
+/**
+ * Sets the location of the receiver, which must be a tooltip,
+ * to the point specified by the arguments which are relative
+ * to the display.
+ * <p>
+ * Note that this is different from most widgets where the
+ * location of the widget is relative to the parent.
+ * </p>
+ *
+ * @param x the new x coordinate for the receiver
+ * @param y the new y coordinate for the receiver
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setLocation (int x, int y) {
+	checkWidget ();
+	this.x = x;
+	this.y = y;
+	if ((style & SWT.BALLOON) != 0) {
+		if (OS.GTK_WIDGET_VISIBLE (handle)) configure ();
+	} else {
+		int /*long*/ tipWindow = OS.GTK_TOOLTIPS_TIP_WINDOW (handle);
+		if (OS.GTK_WIDGET_VISIBLE (tipWindow)) {
+			OS.gtk_window_move (tipWindow, x, y);
+		}
+	}
+}
+
+/**
+ * Sets the location of the receiver, which must be a tooltip,
+ * to the point specified by the argument which is relative
+ * to the display.
+ * <p>
+ * Note that this is different from most widgets where the
+ * location of the widget is relative to the parent.
+ * </p><p>
+ * Note that the platform window manager ultimately has control
+ * over the location of tooltips.
+ * </p>
+ *
+ * @param location the new location for the receiver
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the point is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setLocation (Point location) {
+	checkWidget ();
+	if (location == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+	setLocation (location.x, location.y);
+}
+
+/**
+ * Sets the receiver's message.
+ *
+ * @param string the new message
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the text is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setMessage (String string) {
+	checkWidget ();
+	if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+	message = string;
+	if ((style & SWT.BALLOON) == 0) return;
+	if (layoutMessage != 0) OS.g_object_unref (layoutMessage);
+	layoutMessage = 0;
+	if (message.length () != 0) {
+		byte [] buffer = Converter.wcsToMbcs (null, message, true);
+		layoutMessage = OS.gtk_widget_create_pango_layout (handle, buffer);
+		if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
+			OS.pango_layout_set_auto_dir (layoutMessage, false);
+		}
+		OS.pango_layout_set_wrap (layoutMessage, OS.PANGO_WRAP_WORD_CHAR);
+	}
+	if (OS.GTK_WIDGET_VISIBLE (handle)) configure ();
+}
+
+/**
+ * Sets the receiver's text.
+ *
+ * @param string the new text
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the text is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setText (String string) {
+	checkWidget ();
+	if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+	text = string;
+	if ((style & SWT.BALLOON) == 0) return;
+	if (layoutText != 0) OS.g_object_unref (layoutText);
+	layoutText = 0;
+	if (text.length () != 0) {
+		byte [] buffer = Converter.wcsToMbcs (null, text, true);
+		layoutText = OS.gtk_widget_create_pango_layout (handle, buffer);
+		if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
+			OS.pango_layout_set_auto_dir (layoutText, false);
+		}
+		int /*long*/ boldAttr = OS.pango_attr_weight_new (OS.PANGO_WEIGHT_BOLD);
+		PangoAttribute attribute = new PangoAttribute ();
+		OS.memmove (attribute, boldAttr, PangoAttribute.sizeof);
+		attribute.start_index = 0;
+		attribute.end_index = buffer.length;
+		OS.memmove (boldAttr, attribute, PangoAttribute.sizeof);
+		int /*long*/ attrList = OS.pango_attr_list_new ();
+		OS.pango_attr_list_insert (attrList, boldAttr);
+		OS.pango_layout_set_attributes (layoutText, attrList);
+		OS.pango_attr_list_unref (attrList);
+		OS.pango_layout_set_wrap (layoutText, OS.PANGO_WRAP_WORD_CHAR);
+	}
+	if (OS.GTK_WIDGET_VISIBLE (handle)) configure ();
+}
+
+/**
+ * Marks the receiver as visible if the argument is <code>true</code>,
+ * and marks it invisible otherwise. 
+ * <p>
+ * If one of the receiver's ancestors is not visible or some
+ * other condition makes the receiver not visible, marking
+ * it visible may not actually cause it to be displayed.
+ * </p>
+ *
+ * @param visible the new visibility state
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setVisible (boolean visible) {
+	if (timerId != 0) OS.gtk_timeout_remove(timerId);
+	timerId = 0;
+	if (visible) {
+		if ((style & SWT.BALLOON) != 0) {
+			configure ();
+			OS.gtk_widget_show (handle);
+		} else {
+			int /*long*/ vboxHandle = parent.vboxHandle;
+			StringBuffer string = new StringBuffer (text);
+			if (text.length () > 0) string.append ("\n\n");
+			string.append (message);
+			byte [] buffer = Converter.wcsToMbcs (null, string.toString(), true);
+			OS.gtk_tooltips_set_tip (handle, vboxHandle, buffer, null);
+			int /*long*/ data = OS.gtk_tooltips_data_get (vboxHandle);
+			OS.GTK_TOOLTIPS_SET_ACTIVE (handle, data);
+			OS.gtk_tooltips_set_tip (handle, vboxHandle, buffer, null);
+		}		
+		if (autohide) timerId = OS.gtk_timeout_add (DELAY, display.windowTimerProc, handle);
+	} else {
+		if ((style & SWT.BALLOON) != 0) {
+			OS.gtk_widget_hide (handle);
+		} else {
+			int /*long*/ tipWindow = OS.GTK_TOOLTIPS_TIP_WINDOW (handle);
+			OS.gtk_widget_hide (tipWindow);
+		}
+	}
+}
+
+int /*long*/ timerProc (int /*long*/ widget) {
+	if ((style & SWT.BALLOON) != 0) {
+		OS.gtk_widget_hide (handle);
+	} else {
+		int /*long*/ tipWindow = OS.GTK_TOOLTIPS_TIP_WINDOW (handle);
+		OS.gtk_widget_hide (tipWindow);
+	}
+	return 0;
+}
+
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Tracker.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Tracker.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Tracker.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,994 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.widgets;
+
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.gtk.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.events.*;
+
+/**
+ *  Instances of this class implement rubber banding rectangles that are
+ *  drawn onto a parent <code>Composite</code> or <code>Display</code>.
+ *  These rectangles can be specified to respond to mouse and key events
+ *  by either moving or resizing themselves accordingly.  Trackers are
+ *  typically used to represent window geometries in a lightweight manner.
+ *  
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>LEFT, RIGHT, UP, DOWN, RESIZE</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Move, Resize</dd>
+ * </dl>
+ * <p>
+ * Note: Rectangle move behavior is assumed unless RESIZE is specified.
+ * </p><p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ *
+ * @see <a href="http://www.eclipse.org/swt/snippets/#tracker">Tracker snippets</a>
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public class Tracker extends Widget {
+	Composite parent;
+	Cursor cursor;
+	int /*long*/ lastCursor, window;
+	boolean tracking, cancelled, grabbed, stippled;
+	Rectangle [] rectangles = new Rectangle [0], proportions = rectangles;
+	Rectangle bounds;
+	int cursorOrientation = SWT.NONE;
+	int oldX, oldY;
+
+	final static int STEPSIZE_SMALL = 1;
+	final static int STEPSIZE_LARGE = 9;
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a widget which will be the parent of the new instance (cannot be null)
+ * @param style the style of widget to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT#LEFT
+ * @see SWT#RIGHT
+ * @see SWT#UP
+ * @see SWT#DOWN
+ * @see SWT#RESIZE
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public Tracker (Composite parent, int style) {
+	super (parent, checkStyle(style));
+	this.parent = parent;
+}
+
+/**
+ * Constructs a new instance of this class given the display
+ * to create it on and a style value describing its behavior
+ * and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p><p>
+ * Note: Currently, null can be passed in for the display argument.
+ * This has the effect of creating the tracker on the currently active
+ * display if there is one. If there is no current display, the 
+ * tracker is created on a "default" display. <b>Passing in null as
+ * the display argument is not considered to be good coding style,
+ * and may not be supported in a future release of SWT.</b>
+ * </p>
+ *
+ * @param display the display to create the tracker on
+ * @param style the style of control to construct
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ * 
+ * @see SWT#LEFT
+ * @see SWT#RIGHT
+ * @see SWT#UP
+ * @see SWT#DOWN
+ */
+public Tracker (Display display, int style) {
+	if (display == null) display = Display.getCurrent ();
+	if (display == null) display = Display.getDefault ();
+	if (!display.isValidThread ()) {
+		error (SWT.ERROR_THREAD_INVALID_ACCESS);
+	}
+	this.style = checkStyle (style);
+	this.display = display;
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the control is moved or resized, by sending
+ * it one of the messages defined in the <code>ControlListener</code>
+ * interface.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see ControlListener
+ * @see #removeControlListener
+ */
+public void addControlListener(ControlListener listener) {
+	checkWidget();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	TypedListener typedListener = new TypedListener (listener);
+	addListener (SWT.Resize, typedListener);
+	addListener (SWT.Move, typedListener);
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when keys are pressed and released on the system keyboard, by sending
+ * it one of the messages defined in the <code>KeyListener</code>
+ * interface.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see KeyListener
+ * @see #removeKeyListener
+ */
+public void addKeyListener(KeyListener listener) {
+	checkWidget();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	TypedListener typedListener = new TypedListener (listener);
+	addListener(SWT.KeyUp,typedListener);
+	addListener(SWT.KeyDown,typedListener);
+}
+
+Point adjustMoveCursor () {	
+	if (bounds == null) return null;
+	int newX = bounds.x + bounds.width / 2;
+	int newY = bounds.y;
+	
+	Point point = display.map (parent, null, newX, newY);
+	display.setCursorLocation (point);
+	
+	/*
+	 * The call to XWarpPointer does not always place the pointer on the
+	 * exact location that is specified, so do a query (below) to get the
+	 * actual location of the pointer after it has been moved.
+	 */
+	int [] actualX = new int [1], actualY = new int [1], state = new int [1];
+	OS.gdk_window_get_pointer (window, actualX, actualY, state);
+	return new Point (actualX [0], actualY [0]);
+}
+
+Point adjustResizeCursor () {
+	if (bounds == null) return null;
+	int newX, newY;
+
+	if ((cursorOrientation & SWT.LEFT) != 0) {
+		newX = bounds.x;
+	} else if ((cursorOrientation & SWT.RIGHT) != 0) {
+		newX = bounds.x + bounds.width;
+	} else {
+		newX = bounds.x + bounds.width / 2;
+	}
+	
+	if ((cursorOrientation & SWT.UP) != 0) {
+		newY = bounds.y;
+	} else if ((cursorOrientation & SWT.DOWN) != 0) {
+		newY = bounds.y + bounds.height;
+	} else {
+		newY = bounds.y + bounds.height / 2;
+	}
+
+	Point point = display.map (parent, null, newX, newY);
+	display.setCursorLocation (point);
+	
+	/*
+	 * The call to XWarpPointer does not always place the pointer on the
+	 * exact location that is specified, so do a query (below) to get the
+	 * actual location of the pointer after it has been moved.
+	 */
+	int [] actualX = new int [1], actualY = new int [1], state = new int [1];
+	OS.gdk_window_get_pointer (window, actualX, actualY, state);
+	return new Point (actualX [0], actualY [0]);
+}
+
+
+/**
+ * Stops displaying the tracker rectangles.  Note that this is not considered
+ * to be a cancelation by the user.
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void close () {
+	checkWidget();
+	tracking = false;
+}
+
+static int checkStyle (int style) {
+	if ((style & (SWT.LEFT | SWT.RIGHT | SWT.UP | SWT.DOWN)) == 0) {
+		style |= SWT.LEFT | SWT.RIGHT | SWT.UP | SWT.DOWN;
+	}
+	return style;
+}
+
+Rectangle computeBounds () {
+	if (rectangles.length == 0) return null;
+	int xMin = rectangles [0].x;
+	int yMin = rectangles [0].y;
+	int xMax = rectangles [0].x + rectangles [0].width;
+	int yMax = rectangles [0].y + rectangles [0].height;
+	
+	for (int i = 1; i < rectangles.length; i++) {
+		if (rectangles [i].x < xMin) xMin = rectangles [i].x;
+		if (rectangles [i].y < yMin) yMin = rectangles [i].y;
+		int rectRight = rectangles [i].x + rectangles [i].width;
+		if (rectRight > xMax) xMax = rectRight;		
+		int rectBottom = rectangles [i].y + rectangles [i].height;
+		if (rectBottom > yMax) yMax = rectBottom;
+	}
+	
+	return new Rectangle (xMin, yMin, xMax - xMin, yMax - yMin);
+}
+
+Rectangle [] computeProportions (Rectangle [] rects) {
+	Rectangle [] result = new Rectangle [rects.length];
+	bounds = computeBounds ();
+	if (bounds != null) {
+		for (int i = 0; i < rects.length; i++) {
+			int x = 0, y = 0, width = 0, height = 0;
+			if (bounds.width != 0) {
+				x = (rects [i].x - bounds.x) * 100 / bounds.width;
+				width = rects [i].width * 100 / bounds.width;
+			} else {
+				width = 100;
+			}
+			if (bounds.height != 0) {
+				y = (rects [i].y - bounds.y) * 100 / bounds.height;
+				height = rects [i].height * 100 / bounds.height;
+			} else {
+				height = 100;
+			}
+			result [i] = new Rectangle (x, y, width, height);			
+		}
+	}
+	return result;
+}
+
+void drawRectangles (Rectangle [] rects) {
+	int /*long*/ window = OS.GDK_ROOT_PARENT ();
+	if (parent != null) {
+		window = OS.GTK_WIDGET_WINDOW (parent.paintHandle());
+	} 
+	if (window == 0) return;
+	int /*long*/ gc = OS.gdk_gc_new (window);
+	if (gc == 0) return;
+	int /*long*/ colormap = OS.gdk_colormap_get_system ();
+	GdkColor color = new GdkColor ();
+	OS.gdk_color_white (colormap, color);
+	OS.gdk_gc_set_foreground (gc, color);
+	OS.gdk_gc_set_subwindow (gc, OS.GDK_INCLUDE_INFERIORS);
+	OS.gdk_gc_set_function (gc, OS.GDK_XOR);
+	for (int i=0; i<rects.length; i++) {
+		Rectangle rect = rects [i];
+		int x = rect.x;
+		if (parent != null && (parent.style & SWT.MIRRORED) != 0) x = parent.getClientWidth () - rect.width - x;
+		OS.gdk_draw_rectangle (window, gc, 0, x, rect.y, rect.width, rect.height);
+	}
+	OS.g_object_unref (gc);
+}
+
+/**
+ * Returns the bounds that are being drawn, expressed relative to the parent
+ * widget.  If the parent is a <code>Display</code> then these are screen
+ * coordinates.
+ *
+ * @return the bounds of the Rectangles being drawn
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Rectangle [] getRectangles () {
+	checkWidget();
+	Rectangle [] result = new Rectangle [rectangles.length];
+	for (int i = 0; i < rectangles.length; i++) {
+		Rectangle current = rectangles [i];
+		result [i] = new Rectangle (current.x, current.y, current.width, current.height);
+	}
+	return result;
+}
+
+/**
+ * Returns <code>true</code> if the rectangles are drawn with a stippled line, <code>false</code> otherwise.
+ *
+ * @return the stippled effect of the rectangles
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public boolean getStippled () {
+	checkWidget();
+	return stippled;
+}
+
+boolean grab () {
+	int /*long*/ cursor = this.cursor != null ? this.cursor.handle : 0;
+	int result = OS.gdk_pointer_grab (window, false, OS.GDK_POINTER_MOTION_MASK | OS.GDK_BUTTON_RELEASE_MASK, window, cursor, OS.GDK_CURRENT_TIME);
+	return result == OS.GDK_GRAB_SUCCESS;
+}
+
+int /*long*/ gtk_button_release_event (int /*long*/ widget, int /*long*/ event) {
+	return gtk_mouse (OS.GDK_BUTTON_RELEASE, widget, event);
+}
+
+int /*long*/ gtk_key_press_event (int /*long*/ widget, int /*long*/ eventPtr) {
+	int /*long*/ result = super.gtk_key_press_event (widget, eventPtr);
+	if (result != 0) return result;
+	GdkEventKey keyEvent = new GdkEventKey ();
+	OS.memmove (keyEvent, eventPtr, GdkEventKey.sizeof);
+	int stepSize = ((keyEvent.state & OS.GDK_CONTROL_MASK) != 0) ? STEPSIZE_SMALL : STEPSIZE_LARGE;
+	int xChange = 0, yChange = 0;	
+	switch (keyEvent.keyval) {
+		case OS.GDK_Escape: 
+			cancelled = true;
+			// fallthrough
+		case OS.GDK_Return:
+			tracking = false;
+			break;
+		case OS.GDK_Left:
+			xChange = -stepSize;
+			break;
+		case OS.GDK_Right:
+			xChange = stepSize;
+			break;
+		case OS.GDK_Up:
+			yChange = -stepSize;
+			break;
+		case OS.GDK_Down:
+			yChange = stepSize;
+			break;
+	}
+	if (xChange != 0 || yChange != 0) {
+		Rectangle [] oldRectangles = rectangles;
+		Rectangle [] rectsToErase = new Rectangle [rectangles.length];
+		for (int i = 0; i < rectangles.length; i++) {
+			Rectangle current = rectangles [i];
+			rectsToErase [i] = new Rectangle (current.x, current.y, current.width, current.height);
+		}
+		Event event = new Event ();
+		event.x = oldX + xChange;
+		event.y = oldY + yChange;
+		if (parent != null && (parent.style & SWT.MIRRORED) != 0) {
+			event.x = parent.getClientWidth () - event.width - event.x;
+		}
+		if ((style & SWT.RESIZE) != 0) {
+			resizeRectangles (xChange, yChange);
+			sendEvent (SWT.Resize, event);
+			/*
+			* It is possible (but unlikely) that application
+			* code could have disposed the widget in the resize
+			* event.  If this happens return false to indicate
+			* that the tracking has failed.
+			*/
+			if (isDisposed ()) {
+				cancelled = true;
+				return 1;
+			}
+			boolean draw = false;
+			/*
+			 * It is possible that application code could have
+			 * changed the rectangles in the resize event.  If this
+			 * happens then only redraw the tracker if the rectangle
+			 * values have changed.
+			 */
+			if (rectangles != oldRectangles) {
+				int length = rectangles.length;
+				if (length != rectsToErase.length) {
+					draw = true;
+				} else {
+					for (int i = 0; i < length; i++) {
+						if (!rectangles [i].equals (rectsToErase [i])) {
+							draw = true;
+							break;
+						}
+					}
+				}
+			} else {
+				draw = true;
+			}
+			if (draw) {
+				drawRectangles (rectsToErase);
+				update ();
+				drawRectangles (rectangles);
+			}
+			Point cursorPos = adjustResizeCursor ();
+			if (cursorPos != null) {
+				oldX = cursorPos.x;
+				oldY = cursorPos.y;
+			}
+		} else {
+			moveRectangles (xChange, yChange);
+			sendEvent (SWT.Move, event);
+			/*
+			* It is possible (but unlikely) that application
+			* code could have disposed the widget in the move
+			* event.  If this happens return false to indicate
+			* that the tracking has failed.
+			*/
+			if (isDisposed ()) {
+				cancelled = true;
+				return 1;
+			}
+			boolean draw = false;
+			/*
+			 * It is possible that application code could have
+			 * changed the rectangles in the move event.  If this
+			 * happens then only redraw the tracker if the rectangle
+			 * values have changed.
+			 */
+			if (rectangles != oldRectangles) {
+				int length = rectangles.length;
+				if (length != rectsToErase.length) {
+					draw = true;
+				} else {
+					for (int i = 0; i < length; i++) {
+						if (!rectangles [i].equals (rectsToErase [i])) {
+							draw = true;
+							break;
+						}
+					}
+				}
+			} else {
+				draw = true;
+			}
+			if (draw) {
+				drawRectangles (rectsToErase);
+				update ();
+				drawRectangles (rectangles);
+			}
+			Point cursorPos = adjustMoveCursor ();
+			if (cursorPos != null) {
+				oldX = cursorPos.x;
+				oldY = cursorPos.y;
+			}
+		}
+	}
+	return result;
+}
+
+int /*long*/ gtk_motion_notify_event (int /*long*/ widget, int /*long*/ eventPtr) {
+	int /*long*/ cursor = this.cursor != null ? this.cursor.handle : 0;
+	if (cursor != lastCursor) {
+		ungrab ();
+		grabbed = grab ();
+		lastCursor = cursor;
+	}
+	return gtk_mouse (OS.GDK_MOTION_NOTIFY, widget, eventPtr);
+}
+
+int /*long*/ gtk_mouse (int eventType, int /*long*/ widget, int /*long*/ eventPtr) {
+	int [] newX = new int [1], newY = new int [1];
+	OS.gdk_window_get_pointer (window, newX, newY, null);
+	if (oldX != newX [0] || oldY != newY [0]) {
+		Rectangle [] oldRectangles = rectangles;
+		Rectangle [] rectsToErase = new Rectangle [rectangles.length];
+		for (int i = 0; i < rectangles.length; i++) {
+			Rectangle current = rectangles [i];
+			rectsToErase [i] = new Rectangle (current.x, current.y, current.width, current.height);
+		}
+		Event event = new Event ();
+		if (parent == null) {
+			event.x = newX [0];
+			event.y = newY [0];
+		} else {
+			Point screenCoord = display.map (parent, null, newX [0], newY [0]);
+			event.x = screenCoord.x;
+			event.y = screenCoord.y;
+		}
+		if ((style & SWT.RESIZE) != 0) {
+			resizeRectangles (newX [0] - oldX, newY [0] - oldY);
+			sendEvent (SWT.Resize, event);
+			/*
+			* It is possible (but unlikely), that application
+			* code could have disposed the widget in the resize
+			* event.  If this happens, return false to indicate
+			* that the tracking has failed.
+			*/
+			if (isDisposed ()) {
+				cancelled = true;
+				return 1;
+			}
+			boolean draw = false;
+			/*
+			 * It is possible that application code could have
+			 * changed the rectangles in the resize event.  If this
+			 * happens then only redraw the tracker if the rectangle
+			 * values have changed.
+			 */
+			if (rectangles != oldRectangles) {
+				int length = rectangles.length;
+				if (length != rectsToErase.length) {
+					draw = true;
+				} else {
+					for (int i = 0; i < length; i++) {
+						if (!rectangles [i].equals (rectsToErase [i])) {
+							draw = true;
+							break;
+						}
+					}
+				}
+			} else {
+				draw = true;
+			}
+			if (draw) {
+				drawRectangles (rectsToErase);
+				update ();
+				drawRectangles (rectangles);
+			}
+			Point cursorPos = adjustResizeCursor ();
+			if (cursorPos != null) {
+				newX [0] = cursorPos.x;
+				newY [0] = cursorPos.y;
+			}
+		} else {
+			moveRectangles (newX [0] - oldX, newY [0] - oldY);
+			sendEvent (SWT.Move, event);
+			/*
+			* It is possible (but unlikely), that application
+			* code could have disposed the widget in the move
+			* event.  If this happens, return false to indicate
+			* that the tracking has failed.
+			*/
+			if (isDisposed ()) {
+				cancelled = true;
+				return 1;
+			}
+			boolean draw = false;
+			/*
+			 * It is possible that application code could have
+			 * changed the rectangles in the move event.  If this
+			 * happens then only redraw the tracker if the rectangle
+			 * values have changed.
+			 */
+			if (rectangles != oldRectangles) {
+				int length = rectangles.length;
+				if (length != rectsToErase.length) {
+					draw = true;
+				} else {
+					for (int i = 0; i < length; i++) {
+						if (!rectangles [i].equals (rectsToErase [i])) {
+							draw = true;
+							break;
+						}
+					}
+				}
+			} else {
+				draw = true;
+			}
+			if (draw) {
+				drawRectangles (rectsToErase);
+				update ();
+				drawRectangles (rectangles);
+			}
+		}
+		oldX = newX [0];
+		oldY = newY [0];
+	}
+	tracking = eventType != OS.GDK_BUTTON_RELEASE;
+	return 0;
+}
+
+void moveRectangles (int xChange, int yChange) {
+	if (bounds == null) return;
+	if (xChange < 0 && ((style & SWT.LEFT) == 0)) xChange = 0;
+	if (xChange > 0 && ((style & SWT.RIGHT) == 0)) xChange = 0;
+	if (yChange < 0 && ((style & SWT.UP) == 0)) yChange = 0;
+	if (yChange > 0 && ((style & SWT.DOWN) == 0)) yChange = 0;
+	if (xChange == 0 && yChange == 0) return;
+	if (parent != null && (parent.style & SWT.MIRRORED) != 0) xChange *= -1;
+	bounds.x += xChange; bounds.y += yChange;
+	for (int i = 0; i < rectangles.length; i++) {
+		rectangles [i].x += xChange;
+		rectangles [i].y += yChange;
+	}
+}
+
+/**
+ * Displays the Tracker rectangles for manipulation by the user.  Returns when
+ * the user has either finished manipulating the rectangles or has cancelled the
+ * Tracker.
+ * 
+ * @return <code>true</code> if the user did not cancel the Tracker, <code>false</code> otherwise
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public boolean open () {
+	checkWidget();
+	window = OS.GDK_ROOT_PARENT ();
+	if (parent != null) {
+		window = OS.GTK_WIDGET_WINDOW (parent.paintHandle());
+	} 
+	if (window == 0) return false;
+	cancelled = false;
+	tracking = true;
+	update ();
+	drawRectangles (rectangles);
+	int [] oldX = new int [1], oldY = new int [1], state = new int [1];
+	OS.gdk_window_get_pointer (window, oldX, oldY, state);
+
+	/*
+	* if exactly one of UP/DOWN is specified as a style then set the cursor
+	* orientation accordingly (the same is done for LEFT/RIGHT styles below)
+	*/
+	int vStyle = style & (SWT.UP | SWT.DOWN);
+	if (vStyle == SWT.UP || vStyle == SWT.DOWN) {
+		cursorOrientation |= vStyle;
+	}
+	int hStyle = style & (SWT.LEFT | SWT.RIGHT);
+	if (hStyle == SWT.LEFT || hStyle == SWT.RIGHT) {
+		cursorOrientation |= hStyle;
+	}
+
+	int mask = OS.GDK_BUTTON1_MASK | OS.GDK_BUTTON2_MASK | OS.GDK_BUTTON3_MASK; 
+	boolean mouseDown = (state [0] & mask) != 0;
+	if (!mouseDown) {
+		Point cursorPos = null;
+		if ((style & SWT.RESIZE) != 0) {
+			cursorPos = adjustResizeCursor ();
+		} else {
+			cursorPos = adjustMoveCursor ();
+		}
+		if (cursorPos != null) {
+			oldX [0] = cursorPos.x;
+			oldY [0] = cursorPos.y;
+		}
+	}
+	this.oldX = oldX [0];
+	this.oldY = oldY [0];
+	
+	grabbed = grab ();
+	lastCursor = this.cursor != null ? this.cursor.handle : 0;
+
+	/* Tracker behaves like a Dialog with its own OS event loop. */
+	GdkEvent gdkEvent = new GdkEvent();
+	while (tracking) {
+		if (parent != null && parent.isDisposed ()) break;
+		int /*long*/ eventPtr;
+		while (true) {
+			eventPtr = OS.gdk_event_get ();
+			if (eventPtr != 0) {
+				break;
+			} else {
+				try { Thread.sleep(50); } catch (Exception ex) {}
+			}
+		}
+		OS.memmove (gdkEvent, eventPtr, GdkEvent.sizeof);
+		int /*long*/ widget = OS.gtk_get_event_widget (eventPtr);
+		switch (gdkEvent.type) {
+			case OS.GDK_MOTION_NOTIFY: gtk_motion_notify_event (widget, eventPtr); break;
+			case OS.GDK_BUTTON_RELEASE: gtk_button_release_event (widget, eventPtr); break;
+			case OS.GDK_KEY_PRESS: gtk_key_press_event (widget, eventPtr); break;
+			case OS.GDK_KEY_RELEASE: gtk_key_release_event (widget, eventPtr); break;
+			case OS.GDK_BUTTON_PRESS:
+			case OS.GDK_2BUTTON_PRESS:
+			case OS.GDK_3BUTTON_PRESS:
+			case OS.GDK_ENTER_NOTIFY:
+			case OS.GDK_LEAVE_NOTIFY:
+				/* Do not dispatch these */
+				break;
+			case OS.GDK_EXPOSE:
+				update ();
+				drawRectangles (rectangles);
+				OS.gtk_main_do_event (eventPtr);
+				drawRectangles (rectangles);
+				break;
+			default:
+				OS.gtk_main_do_event (eventPtr);
+		}
+		OS.gdk_event_free (eventPtr);
+	}
+	if (!isDisposed ()) {
+		update ();
+		drawRectangles (rectangles);
+	}
+	ungrab ();
+	window = 0;
+	return !cancelled;
+}
+
+void releaseWidget () {
+	super.releaseWidget ();
+	parent = null;
+	rectangles = proportions = null;
+	bounds = null;
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the control is moved or resized.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see ControlListener
+ * @see #addControlListener
+ */
+public void removeControlListener (ControlListener listener) {
+	checkWidget();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if (eventTable == null) return;
+	eventTable.unhook (SWT.Resize, listener);
+	eventTable.unhook (SWT.Move, listener);
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when keys are pressed and released on the system keyboard.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see KeyListener
+ * @see #addKeyListener
+ */
+public void removeKeyListener(KeyListener listener) {
+	checkWidget();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if (eventTable == null) return;
+	eventTable.unhook (SWT.KeyUp, listener);
+	eventTable.unhook (SWT.KeyDown, listener);
+}
+
+void resizeRectangles (int xChange, int yChange) {
+	if (bounds == null) return;
+	if (parent != null && (parent.style & SWT.MIRRORED) != 0) xChange *= -1;
+	/*
+	* If the cursor orientation has not been set in the orientation of
+	* this change then try to set it here.
+	*/
+	if (xChange < 0 && ((style & SWT.LEFT) != 0) && ((cursorOrientation & SWT.RIGHT) == 0)) {
+		cursorOrientation |= SWT.LEFT;
+	}
+	if (xChange > 0 && ((style & SWT.RIGHT) != 0) && ((cursorOrientation & SWT.LEFT) == 0)) {
+		cursorOrientation |= SWT.RIGHT;
+	}
+	if (yChange < 0 && ((style & SWT.UP) != 0) && ((cursorOrientation & SWT.DOWN) == 0)) {
+		cursorOrientation |= SWT.UP;
+	}
+	if (yChange > 0 && ((style & SWT.DOWN) != 0) && ((cursorOrientation & SWT.UP) == 0)) {
+		cursorOrientation |= SWT.DOWN;
+	}
+	
+	/*
+	 * If the bounds will flip about the x or y axis then apply the adjustment
+	 * up to the axis (ie.- where bounds width/height becomes 0), change the
+	 * cursor's orientation accordingly, and flip each Rectangle's origin (only
+	 * necessary for > 1 Rectangles) 
+	 */
+	if ((cursorOrientation & SWT.LEFT) != 0) {
+		if (xChange > bounds.width) {
+			if ((style & SWT.RIGHT) == 0) return;
+			cursorOrientation |= SWT.RIGHT;
+			cursorOrientation &= ~SWT.LEFT;
+			bounds.x += bounds.width;
+			xChange -= bounds.width;
+			bounds.width = 0;
+			if (proportions.length > 1) {
+				for (int i = 0; i < proportions.length; i++) {
+					Rectangle proportion = proportions [i];
+					proportion.x = 100 - proportion.x - proportion.width;
+				}
+			}
+		}
+	} else if ((cursorOrientation & SWT.RIGHT) != 0) {
+		if (bounds.width < -xChange) {
+			if ((style & SWT.LEFT) == 0) return;
+			cursorOrientation |= SWT.LEFT;
+			cursorOrientation &= ~SWT.RIGHT;
+			xChange += bounds.width;
+			bounds.width = 0;
+			if (proportions.length > 1) {
+				for (int i = 0; i < proportions.length; i++) {
+					Rectangle proportion = proportions [i];
+					proportion.x = 100 - proportion.x - proportion.width;
+				}
+			}
+		}
+	}
+	if ((cursorOrientation & SWT.UP) != 0) {
+		if (yChange > bounds.height) {
+			if ((style & SWT.DOWN) == 0) return;
+			cursorOrientation |= SWT.DOWN;
+			cursorOrientation &= ~SWT.UP;
+			bounds.y += bounds.height;
+			yChange -= bounds.height;
+			bounds.height = 0;
+			if (proportions.length > 1) {
+				for (int i = 0; i < proportions.length; i++) {
+					Rectangle proportion = proportions [i];
+					proportion.y = 100 - proportion.y - proportion.height;
+				}
+			}
+		}
+	} else if ((cursorOrientation & SWT.DOWN) != 0) {
+		if (bounds.height < -yChange) {
+			if ((style & SWT.UP) == 0) return;
+			cursorOrientation |= SWT.UP;
+			cursorOrientation &= ~SWT.DOWN;
+			yChange += bounds.height;
+			bounds.height = 0;
+			if (proportions.length > 1) {
+				for (int i = 0; i < proportions.length; i++) {
+					Rectangle proportion = proportions [i];
+					proportion.y = 100 - proportion.y - proportion.height;
+				}
+			}
+		}
+	}
+	
+	// apply the bounds adjustment
+	if ((cursorOrientation & SWT.LEFT) != 0) {
+		bounds.x += xChange;
+		bounds.width -= xChange;
+	} else if ((cursorOrientation & SWT.RIGHT) != 0) {
+		bounds.width += xChange;
+	}
+	if ((cursorOrientation & SWT.UP) != 0) {
+		bounds.y += yChange;
+		bounds.height -= yChange;
+	} else if ((cursorOrientation & SWT.DOWN) != 0) {
+		bounds.height += yChange;
+	}
+	
+	Rectangle [] newRects = new Rectangle [rectangles.length];
+	for (int i = 0; i < rectangles.length; i++) {
+		Rectangle proportion = proportions[i];
+		newRects[i] = new Rectangle (
+			proportion.x * bounds.width / 100 + bounds.x,
+			proportion.y * bounds.height / 100 + bounds.y,
+			proportion.width * bounds.width / 100,
+			proportion.height * bounds.height / 100);
+	}
+	rectangles = newRects;	
+}
+
+/**
+ * Sets the <code>Cursor</code> of the Tracker.  If this cursor is <code>null</code>
+ * then the cursor reverts to the default.
+ *
+ * @param newCursor the new <code>Cursor</code> to display
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setCursor (Cursor value) {
+	checkWidget ();
+	cursor = value;
+}
+
+/**
+ * Specifies the rectangles that should be drawn, expressed relative to the parent
+ * widget.  If the parent is a Display then these are screen coordinates.
+ *
+ * @param rectangles the bounds of the rectangles to be drawn
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the set of rectangles is null or contains a null rectangle</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setRectangles (Rectangle [] rectangles) {
+	checkWidget();
+	if (rectangles == null) error (SWT.ERROR_NULL_ARGUMENT);
+	int length = rectangles.length;
+	this.rectangles = new Rectangle [length];
+	for (int i = 0; i < length; i++) {
+		Rectangle current = rectangles [i];
+		if (current == null) error (SWT.ERROR_NULL_ARGUMENT);
+		this.rectangles [i] = new Rectangle (current.x, current.y, current.width, current.height);
+	}
+	proportions = computeProportions (rectangles);
+}
+
+/**
+ * Changes the appearance of the line used to draw the rectangles.
+ *
+ * @param stippled <code>true</code> if rectangle should appear stippled
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setStippled (boolean stippled) {
+	checkWidget();
+	this.stippled = stippled;
+}
+
+void ungrab () {
+	if (grabbed) OS.gdk_pointer_ungrab (OS.GDK_CURRENT_TIME);
+}
+
+void update () {
+	if (parent != null) {
+		if (parent.isDisposed ()) return;
+		parent.getShell ().update ();
+	} else {
+		display.update ();
+	}
+}
+
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Tray.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Tray.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Tray.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,148 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.widgets;
+
+
+import org.eclipse.swt.*;
+
+/**
+ * Instances of this class represent the system tray that is part
+ * of the task bar status area on some operating systems.
+ * 
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>(none)</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>(none)</dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ * 
+ * @see Display#getSystemTray
+ * @see <a href="http://www.eclipse.org/swt/snippets/#tray">Tray, TrayItem snippets</a>
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ * 
+ * @since 3.0
+ */
+public class Tray extends Widget {
+	int itemCount;
+	TrayItem [] items = new TrayItem [4];
+
+Tray (Display display, int style) {
+	if (display == null) display = Display.getCurrent ();
+	if (display == null) display = Display.getDefault ();
+	if (!display.isValidThread ()) {
+		error (SWT.ERROR_THREAD_INVALID_ACCESS);
+	}
+	this.display = display;
+}
+	
+void createItem (TrayItem item, int index) {
+	if (!(0 <= index && index <= itemCount)) error (SWT.ERROR_INVALID_RANGE);
+	if (itemCount == items.length) {
+		TrayItem [] newItems = new TrayItem [items.length + 4];
+		System.arraycopy (items, 0, newItems, 0, items.length);
+		items = newItems;
+	}
+	System.arraycopy (items, index, items, index + 1, itemCount++ - index);
+	items [index] = item;
+}
+
+void destroyItem (TrayItem item) {
+	int index = 0;
+	while (index < itemCount) {
+		if (items [index] == item) break;
+		index++;
+	}
+	if (index == itemCount) return;
+	System.arraycopy (items, index + 1, items, index, --itemCount - index);
+	items [itemCount] = null;
+}
+
+/**
+ * Returns the item at the given, zero-relative index in the
+ * receiver. Throws an exception if the index is out of range.
+ *
+ * @param index the index of the item to return
+ * @return the item at the given index
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public TrayItem getItem (int index) {
+	checkWidget ();
+	if (!(0 <= index && index < itemCount)) error (SWT.ERROR_INVALID_RANGE);
+	return items [index];
+}
+
+/**
+ * Returns the number of items contained in the receiver.
+ *
+ * @return the number of items
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getItemCount () {
+	checkWidget ();
+	return itemCount;
+}
+
+/**
+ * Returns an array of <code>TrayItem</code>s which are the items
+ * in the receiver. 
+ * <p>
+ * Note: This is not the actual structure used by the receiver
+ * to maintain its list of items, so modifying the array will
+ * not affect the receiver. 
+ * </p>
+ *
+ * @return the items in the receiver
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public TrayItem [] getItems () {
+	checkWidget ();
+	TrayItem [] result = new TrayItem [itemCount];
+	System.arraycopy (items, 0, result, 0, result.length);
+	return result;
+}
+
+void releaseChildren (boolean destroy) {
+	if (items != null) {
+		for (int i=0; i<items.length; i++) {
+			TrayItem item = items [i];
+			if (item != null && !item.isDisposed ()) {
+				item.release (false);
+			}
+		}
+		items = null;
+	}
+	super.releaseChildren (destroy);
+}
+
+void releaseParent () {
+	super.releaseParent ();
+	if (display.tray == this) display.tray = null;
+}
+
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/TrayItem.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/TrayItem.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/TrayItem.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,507 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.widgets;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.gtk.*;
+
+/**
+ * Instances of this class represent icons that can be placed on the
+ * system tray or task bar status area.
+ * <p>
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>(none)</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>DefaultSelection, MenuDetect, Selection</dd>
+ * </dl>
+ * </p><p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ *
+ * @see <a href="http://www.eclipse.org/swt/snippets/#tray">Tray, TrayItem snippets</a>
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ * 
+ * @since 3.0
+ */
+public class TrayItem extends Item {
+	Tray parent;
+	ToolTip toolTip;
+	String toolTipText;
+	int /*long*/ imageHandle;
+	int /*long*/ tooltipsHandle;
+	ImageList imageList;
+
+/**
+ * Constructs a new instance of this class given its parent
+ * (which must be a <code>Tray</code>) and a style value
+ * describing its behavior and appearance. The item is added
+ * to the end of the items maintained by its parent.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public TrayItem (Tray parent, int style) {
+	super (parent, style);
+	this.parent = parent;
+	createWidget (parent.getItemCount ());
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the platform-specific context menu trigger
+ * has occurred, by sending it one of the messages defined in
+ * the <code>MenuDetectListener</code> interface.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see MenuDetectListener
+ * @see #removeMenuDetectListener
+ *
+ * @since 3.3
+ */
+public void addMenuDetectListener (MenuDetectListener listener) {
+	checkWidget ();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	TypedListener typedListener = new TypedListener (listener);
+	addListener (SWT.MenuDetect, typedListener);
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the receiver is selected by the user, by sending
+ * it one of the messages defined in the <code>SelectionListener</code>
+ * interface.
+ * <p>
+ * <code>widgetSelected</code> is called when the receiver is selected
+ * <code>widgetDefaultSelected</code> is called when the receiver is double-clicked
+ * </p>
+ *
+ * @param listener the listener which should be notified when the receiver is selected by the user
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent
+ */
+public void addSelectionListener(SelectionListener listener) {
+	checkWidget ();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	TypedListener typedListener = new TypedListener (listener);
+	addListener (SWT.Selection, typedListener);
+	addListener (SWT.DefaultSelection, typedListener);
+}
+
+protected void checkSubclass () {
+	if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
+}
+
+void createWidget (int index) {
+	super.createWidget (index);
+	parent.createItem (this, index);
+}
+
+void createHandle (int index) {
+	state |= HANDLE;
+	handle = OS.gtk_plug_new (0);
+	if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+	imageHandle = OS.gtk_image_new ();
+	if (imageHandle == 0) error (SWT.ERROR_NO_HANDLES);
+	OS.gtk_container_add (handle, imageHandle);
+	OS.gtk_widget_show (handle);
+	OS.gtk_widget_show (imageHandle);
+	int /*long*/ id = OS.gtk_plug_get_id (handle);
+	int monitor = 0;
+	int /*long*/ screen = OS.gdk_screen_get_default ();
+	if (screen != 0) {
+		monitor = OS.gdk_screen_get_number (screen);
+	}
+	byte [] trayBuffer = Converter.wcsToMbcs (null, "_NET_SYSTEM_TRAY_S" + monitor, true);
+	int /*long*/ trayAtom = OS.gdk_atom_intern (trayBuffer, true);
+	int /*long*/ xTrayAtom = OS.gdk_x11_atom_to_xatom (trayAtom);
+	int /*long*/ xDisplay = OS.GDK_DISPLAY ();
+	int /*long*/ trayWindow = OS.XGetSelectionOwner (xDisplay, xTrayAtom);
+	byte [] messageBuffer = Converter.wcsToMbcs (null, "_NET_SYSTEM_TRAY_OPCODE", true);
+	int /*long*/ messageAtom = OS.gdk_atom_intern (messageBuffer, true);
+	int /*long*/ xMessageAtom = OS.gdk_x11_atom_to_xatom (messageAtom);
+	XClientMessageEvent event = new XClientMessageEvent ();
+	event.type = OS.ClientMessage;
+	event.window = trayWindow;
+	event.message_type = xMessageAtom;
+	event.format = 32;
+	event.data [0] = OS.GDK_CURRENT_TIME;
+	event.data [1] = OS.SYSTEM_TRAY_REQUEST_DOCK;
+	event.data [2] = id;
+	int /*long*/ clientEvent = OS.g_malloc (XClientMessageEvent.sizeof);
+	OS.memmove (clientEvent, event, XClientMessageEvent.sizeof);
+	OS.XSendEvent (xDisplay, trayWindow, false, OS.NoEventMask, clientEvent);
+	OS.g_free (clientEvent);
+}
+
+void deregister () {
+	super.deregister ();
+	display.removeWidget (imageHandle);
+}
+
+void destroyWidget () {
+	parent.destroyItem (this);
+	releaseHandle ();
+}
+
+/**
+ * Returns the receiver's parent, which must be a <code>Tray</code>.
+ *
+ * @return the receiver's parent
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.2
+ */
+public Tray getParent () {
+	checkWidget ();
+	return parent;
+}
+
+/**
+ * Returns the receiver's tool tip, or null if it has
+ * not been set.
+ *
+ * @return the receiver's tool tip text
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.2
+ */
+public ToolTip getToolTip () {
+	checkWidget ();
+	return toolTip;
+}
+
+/**
+ * Returns the receiver's tool tip text, or null if it has
+ * not been set.
+ *
+ * @return the receiver's tool tip text
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public String getToolTipText () {
+	checkWidget ();
+	return toolTipText;
+}
+
+int /*long*/ gtk_button_press_event (int /*long*/ widget, int /*long*/ eventPtr) {
+	GdkEventButton gdkEvent = new GdkEventButton ();
+	OS.memmove (gdkEvent, eventPtr, GdkEventButton.sizeof);
+	if (gdkEvent.type == OS.GDK_3BUTTON_PRESS) return 0;
+	if (gdkEvent.button == 3 && gdkEvent.type == OS.GDK_BUTTON_PRESS) {
+		sendEvent (SWT.MenuDetect);
+		return 0;
+	}
+	if (gdkEvent.type == OS.GDK_2BUTTON_PRESS) {
+		postEvent (SWT.DefaultSelection);
+	} else {
+		postEvent (SWT.Selection);
+	}
+	return 0;
+}
+
+int /*long*/ gtk_size_allocate (int /*long*/ widget, int /*long*/ allocation) {
+	if (image != null && image.mask != 0) {
+		if (OS.gdk_drawable_get_depth (image.mask) == 1) {
+			int xoffset = (int) Math.floor (OS.GTK_WIDGET_X (widget) + ((OS.GTK_WIDGET_WIDTH (widget) - OS.GTK_WIDGET_REQUISITION_WIDTH (widget)) * 0.5) + 0.5);
+			int yoffset = (int) Math.floor (OS.GTK_WIDGET_Y (widget) + ((OS.GTK_WIDGET_HEIGHT (widget) - OS.GTK_WIDGET_REQUISITION_HEIGHT (widget)) * 0.5) + 0.5);
+			Rectangle b = image.getBounds();
+			int /*long*/ gdkImagePtr = OS.gdk_drawable_get_image (image.mask, 0, 0, b.width, b.height);
+			if (gdkImagePtr == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+			GdkImage gdkImage = new GdkImage();
+			OS.memmove (gdkImage, gdkImagePtr);
+			byte[] maskData = new byte [gdkImage.bpl * gdkImage.height];
+			OS.memmove (maskData, gdkImage.mem, maskData.length);
+			OS.g_object_unref (gdkImagePtr);
+			Region region = new Region (display);
+			for (int y = 0; y < b.height; y++) {
+				for (int x = 0; x < b.width; x++) {
+					int index = (y * gdkImage.bpl) + (x >> 3);
+					int theByte = maskData [index] & 0xFF;
+					int mask = 1 << (x & 0x7);
+					if ((theByte & mask) != 0) {
+						region.add (xoffset + x, yoffset + y, 1, 1);
+					}
+				}
+			}
+			OS.gtk_widget_realize (handle);
+			int /*long*/ window = OS.GTK_WIDGET_WINDOW (handle);
+			OS.gdk_window_shape_combine_region (window, region.handle, 0, 0);
+			region.dispose ();
+		}
+	}
+	return 0;
+}
+
+void hookEvents () {
+	int eventMask = OS.GDK_BUTTON_PRESS_MASK;
+	OS.gtk_widget_add_events (handle, eventMask);
+	OS.g_signal_connect_closure_by_id (handle, display.signalIds [BUTTON_PRESS_EVENT], 0, display.closures [BUTTON_PRESS_EVENT], false);
+	OS.g_signal_connect_closure_by_id (imageHandle, display.signalIds [SIZE_ALLOCATE], 0, display.closures [SIZE_ALLOCATE], false);
+ }
+
+/**
+ * Returns <code>true</code> if the receiver is visible and 
+ * <code>false</code> otherwise.
+ *
+ * @return the receiver's visibility
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public boolean getVisible () {
+	checkWidget ();
+	return OS.GTK_WIDGET_VISIBLE (handle);
+}
+
+void register () {
+	super.register ();
+	display.addWidget (imageHandle, this);
+}
+
+void releaseHandle () {
+	if (handle != 0) OS.gtk_widget_destroy (handle);
+	handle = imageHandle = 0;
+	super.releaseHandle ();
+	parent = null;
+}
+
+void releaseWidget () {
+	super.releaseWidget ();
+	if (tooltipsHandle != 0) OS.g_object_unref (tooltipsHandle);
+	tooltipsHandle = 0;
+	if (imageList != null) imageList.dispose ();
+	imageList = null;
+	toolTipText = null;
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the platform-specific context menu trigger has
+ * occurred.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see MenuDetectListener
+ * @see #addMenuDetectListener
+ *
+ * @since 3.3
+ */
+public void removeMenuDetectListener (MenuDetectListener listener) {
+	checkWidget ();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if (eventTable == null) return;
+	eventTable.unhook (SWT.MenuDetect, listener);
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the receiver is selected by the user.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #addSelectionListener
+ */
+public void removeSelectionListener (SelectionListener listener) {
+	checkWidget ();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if (eventTable == null) return;
+	eventTable.unhook (SWT.Selection, listener);
+	eventTable.unhook (SWT.DefaultSelection, listener);
+}
+
+/**
+ * Sets the receiver's image.
+ *
+ * @param image the new image
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setImage (Image image) {
+	checkWidget ();
+	if (image != null && image.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT);
+	this.image = image;
+	if (image != null) {
+		Rectangle rect = image.getBounds ();
+		OS.gtk_widget_set_size_request (handle, rect.width, rect.height);
+		if (imageList == null) imageList = new ImageList ();
+		int imageIndex = imageList.indexOf (image);
+		if (imageIndex == -1) {
+			imageIndex = imageList.add (image);
+		} else {
+			imageList.put (imageIndex, image);
+		}
+		int /*long*/ pixbuf = imageList.getPixbuf (imageIndex);
+		OS.gtk_image_set_from_pixbuf (imageHandle, pixbuf);
+		OS.gtk_widget_show (imageHandle);
+	} else {
+		OS.gtk_widget_set_size_request (handle, 1, 1);
+		OS.gtk_image_set_from_pixbuf (imageHandle, 0);
+		OS.gtk_widget_hide (imageHandle);
+	}
+}
+
+/**
+ * Sets the receiver's tool tip to the argument, which
+ * may be null indicating that no tool tip should be shown.
+ *
+ * @param toolTip the new tool tip (or null)
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.2
+ */
+public void setToolTip (ToolTip toolTip) {
+	checkWidget ();
+	ToolTip oldTip = this.toolTip, newTip = toolTip;
+	if (oldTip != null) oldTip.item = null;
+	this.toolTip = newTip;
+	if (newTip != null) newTip.item = this;
+}
+
+/**
+ * Sets the receiver's tool tip text to the argument, which
+ * may be null indicating that no tool tip text should be shown.
+ *
+ * @param value the new tool tip text (or null)
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setToolTipText (String string) {
+	checkWidget ();
+	toolTipText = string;
+	byte [] buffer = null;
+	if (string != null && string.length () > 0) {
+		buffer = Converter.wcsToMbcs (null, string, true);
+	}
+	if (tooltipsHandle == 0) {
+		tooltipsHandle = OS.gtk_tooltips_new ();
+		if (tooltipsHandle == 0) error (SWT.ERROR_NO_HANDLES);
+		OS.g_object_ref (tooltipsHandle);
+		OS.gtk_object_sink (tooltipsHandle);
+	}
+	OS.gtk_tooltips_set_tip (tooltipsHandle, handle, buffer, null);
+}
+
+/**
+ * Makes the receiver visible if the argument is <code>true</code>,
+ * and makes it invisible otherwise. 
+ *
+ * @param visible the new visibility state
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setVisible (boolean visible) {
+	checkWidget ();
+	if (OS.GTK_WIDGET_VISIBLE (handle) == visible) return;
+	if (visible) {
+		/*
+		* It is possible (but unlikely), that application
+		* code could have disposed the widget in the show
+		* event.  If this happens, just return.
+		*/
+		sendEvent (SWT.Show);
+		if (isDisposed ()) return;
+		OS.gtk_widget_show (handle);
+	} else {
+		OS.gtk_widget_hide (handle);
+		sendEvent (SWT.Hide);
+	}
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Tree.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Tree.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Tree.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,3314 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.widgets;
+
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.gtk.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.events.*;
+
+/**
+ * Instances of this class provide a selectable user interface object
+ * that displays a hierarchy of items and issues notification when an
+ * item in the hierarchy is selected.
+ * <p>
+ * The item children that may be added to instances of this class
+ * must be of type <code>TreeItem</code>.
+ * </p><p>
+ * Style <code>VIRTUAL</code> is used to create a <code>Tree</code> whose
+ * <code>TreeItem</code>s are to be populated by the client on an on-demand basis
+ * instead of up-front.  This can provide significant performance improvements for
+ * trees that are very large or for which <code>TreeItem</code> population is
+ * expensive (for example, retrieving values from an external source).
+ * </p><p>
+ * Here is an example of using a <code>Tree</code> with style <code>VIRTUAL</code>:
+ * <code><pre>
+ *  final Tree tree = new Tree(parent, SWT.VIRTUAL | SWT.BORDER);
+ *  tree.setItemCount(20);
+ *  tree.addListener(SWT.SetData, new Listener() {
+ *      public void handleEvent(Event event) {
+ *          TreeItem item = (TreeItem)event.item;
+ *          TreeItem parentItem = item.getParentItem();
+ *          String text = null;
+ *          if (parentItem == null) {
+ *              text = "node " + tree.indexOf(item);
+ *          } else {
+ *              text = parentItem.getText() + " - " + parentItem.indexOf(item);
+ *          }
+ *          item.setText(text);
+ *          System.out.println(text);
+ *          item.setItemCount(10);
+ *      }
+ *  });
+ * </pre></code>
+ * </p><p>
+ * Note that although this class is a subclass of <code>Composite</code>,
+ * it does not normally make sense to add <code>Control</code> children to
+ * it, or set a layout on it, unless implementing something like a cell
+ * editor.
+ * </p><p>
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>SINGLE, MULTI, CHECK, FULL_SELECTION, VIRTUAL, NO_SCROLL</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Selection, DefaultSelection, Collapse, Expand, SetData, MeasureItem, EraseItem, PaintItem</dd>
+ * </dl>
+ * </p><p>
+ * Note: Only one of the styles SINGLE and MULTI may be specified.
+ * </p><p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ *
+ * @see <a href="http://www.eclipse.org/swt/snippets/#tree">Tree, TreeItem, TreeColumn snippets</a>
+ * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: ControlExample</a>
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public class Tree extends Composite {
+	int /*long*/ modelHandle, checkRenderer;
+	int columnCount, sortDirection;
+	int /*long*/ ignoreCell;
+	TreeItem[] items;
+	TreeColumn [] columns;
+	TreeColumn sortColumn;
+	TreeItem currentItem;
+	ImageList imageList, headerImageList;
+	boolean firstCustomDraw;
+	boolean modelChanged;
+	boolean expandAll;
+	int drawState, drawFlags;
+	GdkColor drawForeground;
+	boolean ownerDraw, ignoreSize;
+	
+	static final int ID_COLUMN = 0;
+	static final int CHECKED_COLUMN = 1;
+	static final int GRAYED_COLUMN = 2;
+	static final int FOREGROUND_COLUMN = 3;
+	static final int BACKGROUND_COLUMN = 4;
+	static final int FONT_COLUMN = 5;
+	static final int FIRST_COLUMN = FONT_COLUMN + 1;
+	static final int CELL_PIXBUF = 0;
+	static final int CELL_TEXT = 1;
+	static final int CELL_FOREGROUND = 2;
+	static final int CELL_BACKGROUND = 3;
+	static final int CELL_FONT = 4;
+	static final int CELL_TYPES = CELL_FONT + 1;
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT#SINGLE
+ * @see SWT#MULTI
+ * @see SWT#CHECK
+ * @see SWT#FULL_SELECTION
+ * @see SWT#VIRTUAL
+ * @see SWT#NO_SCROLL
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public Tree (Composite parent, int style) {
+	super (parent, checkStyle (style));
+}
+
+void _addListener (int eventType, Listener listener) {
+	super._addListener (eventType, listener);
+	if (!ownerDraw) {
+		switch (eventType) {
+			case SWT.MeasureItem:
+			case SWT.EraseItem:
+			case SWT.PaintItem:
+				ownerDraw = true;
+				recreateRenderers ();
+				break;
+		}
+	}
+}
+
+TreeItem _getItem (int /*long*/ iter) {
+	int id = getId (iter, true);
+	if (items [id] != null) return items [id];
+	int /*long*/ path = OS.gtk_tree_model_get_path (modelHandle, iter);
+	int depth = OS.gtk_tree_path_get_depth (path);
+	int [] indices = new int [depth];
+	OS.memmove (indices, OS.gtk_tree_path_get_indices (path), 4*depth);
+	int /*long*/ parentIter = 0;
+	if (depth > 1) {
+		OS.gtk_tree_path_up (path);
+		parentIter = OS.g_malloc (OS.GtkTreeIter_sizeof ());
+		OS.gtk_tree_model_get_iter (modelHandle, parentIter, path);
+	}
+	items [id] = new TreeItem (this, parentIter, SWT.NONE, indices [indices.length -1], false);
+	OS.gtk_tree_path_free (path);
+	if (parentIter != 0) OS.g_free (parentIter);
+	return items [id];
+}
+
+TreeItem _getItem (int /*long*/ parentIter, int index) {
+	int /*long*/ iter = OS.g_malloc (OS.GtkTreeIter_sizeof ());
+	OS.gtk_tree_model_iter_nth_child(modelHandle, iter, parentIter, index);
+	int id = getId (iter, true);
+	OS.g_free (iter);
+	if (items [id] != null) return items [id];
+	return items [id] = new TreeItem (this, parentIter, SWT.NONE, index, false);
+}
+
+int getId (int /*long*/ iter, boolean queryModel) {
+	if (queryModel) {
+		int[] value = new int[1];
+		OS.gtk_tree_model_get (modelHandle, iter, ID_COLUMN, value, -1);
+		if (value [0] != -1) return value [0];
+	}
+	// find next available id
+	int id = 0;
+	while (id < items.length && items [id] != null) id++;
+	if (id == items.length) {
+		TreeItem [] newItems = new TreeItem [items.length + 4];
+		System.arraycopy (items, 0, newItems, 0, items.length);
+		items = newItems;
+	}
+	OS.gtk_tree_store_set (modelHandle, iter, ID_COLUMN, id, -1);
+	return id;
+}
+
+static int checkStyle (int style) {
+	/*
+	* Feature in Windows.  Even when WS_HSCROLL or
+	* WS_VSCROLL is not specified, Windows creates
+	* trees and tables with scroll bars.  The fix
+	* is to set H_SCROLL and V_SCROLL.
+	* 
+	* NOTE: This code appears on all platforms so that
+	* applications have consistent scroll bar behavior.
+	*/
+	if ((style & SWT.NO_SCROLL) == 0) {
+		style |= SWT.H_SCROLL | SWT.V_SCROLL;
+	}
+	/* GTK is always FULL_SELECTION */
+	style |= SWT.FULL_SELECTION;
+	return checkBits (style, SWT.SINGLE, SWT.MULTI, 0, 0, 0, 0);
+}
+
+int /*long*/ cellDataProc (int /*long*/ tree_column, int /*long*/ cell, int /*long*/ tree_model, int /*long*/ iter, int /*long*/ data) {
+	if (cell == ignoreCell) return 0;
+	TreeItem item = _getItem (iter);
+	if (item != null) OS.g_object_set_qdata (cell, Display.SWT_OBJECT_INDEX2, item.handle);
+	boolean isPixbuf = OS.GTK_IS_CELL_RENDERER_PIXBUF (cell);
+	if (!(isPixbuf || OS.GTK_IS_CELL_RENDERER_TEXT (cell))) return 0;
+	int modelIndex = -1;
+	boolean customDraw = false;
+	if (columnCount == 0) {
+		modelIndex = Tree.FIRST_COLUMN;
+		customDraw = firstCustomDraw;
+	} else {
+		TreeColumn column = (TreeColumn) display.getWidget (tree_column);
+		if (column != null) {
+			modelIndex = column.modelIndex;
+			customDraw = column.customDraw;
+		}
+	}
+	if (modelIndex == -1) return 0;
+	boolean setData = false;
+	if ((style & SWT.VIRTUAL) != 0) {
+		/*
+		* Feature in GTK.  On GTK before 2.4, fixed_height_mode is not
+		* supported, and the tree asks for the data of all items.  The
+		* fix is to only provide the data if the row is visible.
+		*/
+		if (OS.GTK_VERSION < OS.VERSION (2, 3, 2)) {
+			int /*long*/ path = OS.gtk_tree_model_get_path (tree_model, iter);
+			OS.gtk_widget_realize (handle);
+			GdkRectangle visible = new GdkRectangle ();
+			OS.gtk_tree_view_get_visible_rect (handle, visible);
+			GdkRectangle area = new GdkRectangle ();
+			OS.gtk_tree_view_get_cell_area (handle, path, tree_column, area);
+			OS.gtk_tree_path_free (path);			
+			if (area.y + area.height < 0 || area.y + visible.y > visible.y + visible.height ) {
+				/* Give an image from the image list to make sure the row has
+				* the correct height.
+				*/
+				if (imageList != null && imageList.pixbufs.length > 0) {
+					if (isPixbuf) OS.g_object_set (cell, OS.pixbuf, imageList.pixbufs [0], 0);
+				}
+				return 0;
+			}
+		}
+		if (!item.cached) {
+			//lastIndexOf = index [0];
+			setData = checkData (item);
+		}
+	}
+	int /*long*/ [] ptr = new int /*long*/ [1];
+	if (setData) {
+		if (isPixbuf) {
+			ptr [0] = 0;
+			OS.gtk_tree_model_get (tree_model, iter, modelIndex + CELL_PIXBUF, ptr, -1);
+			OS.g_object_set (cell, OS.pixbuf, ptr[0], 0);
+		} else {
+			ptr [0] = 0;
+			OS.gtk_tree_model_get (tree_model, iter, modelIndex + CELL_TEXT, ptr, -1); 
+			if (ptr [0] != 0) {
+				OS.g_object_set (cell, OS.text, ptr[0], 0);
+				OS.g_free (ptr[0]);
+			}
+		}
+	}
+	if (customDraw) {
+		/*
+		 * Bug on GTK. Gtk renders the background on top of the checkbox and pixbuf.
+		 * This only happens in version 2.2.1 and earlier. The fix is not to set the background.   
+		 */
+		if (OS.GTK_VERSION > OS.VERSION (2, 2, 1)) {
+			if (!ownerDraw) {
+				ptr [0] = 0;
+				OS.gtk_tree_model_get (tree_model, iter, modelIndex + CELL_BACKGROUND, ptr, -1);
+				if (ptr [0] != 0) {
+					OS.g_object_set (cell, OS.cell_background_gdk, ptr[0], 0);
+				}
+			}
+		}
+		if (!isPixbuf) {
+			ptr [0] = 0;
+			OS.gtk_tree_model_get (tree_model, iter, modelIndex + CELL_FOREGROUND, ptr, -1);
+			if (ptr [0] != 0) {
+				OS.g_object_set (cell, OS.foreground_gdk, ptr[0], 0);
+			}
+			ptr [0] = 0;
+			OS.gtk_tree_model_get (tree_model, iter, modelIndex + CELL_FONT, ptr, -1);
+			if (ptr [0] != 0) {
+				OS.g_object_set (cell, OS.font_desc, ptr[0], 0);
+			}
+		}
+	}
+	if (setData) {
+		ignoreCell = cell;
+		setScrollWidth (tree_column, item);
+		ignoreCell = 0;
+	}
+	return 0;
+}
+
+boolean checkData (TreeItem item) {
+	if (item.cached) return true;
+	if ((style & SWT.VIRTUAL) != 0) {
+		item.cached = true;
+		TreeItem parentItem = item.getParentItem ();
+		Event event = new Event ();
+		event.item = item;
+		event.index = parentItem == null ? indexOf (item) : parentItem.indexOf (item);
+		int mask = OS.G_SIGNAL_MATCH_DATA | OS.G_SIGNAL_MATCH_ID;
+		int signal_id = OS.g_signal_lookup (OS.row_changed, OS.gtk_tree_model_get_type ());
+		OS.g_signal_handlers_block_matched (modelHandle, mask, signal_id, 0, 0, 0, handle);
+		currentItem = item;
+		sendEvent (SWT.SetData, event);
+		currentItem = null;
+		//widget could be disposed at this point
+		if (isDisposed ()) return false;
+		OS.g_signal_handlers_unblock_matched (modelHandle, mask, signal_id, 0, 0, 0, handle);
+		if (item.isDisposed ()) return false;
+	}
+	return true;
+}
+
+protected void checkSubclass () {
+	if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the user changes the receiver's selection, by sending
+ * it one of the messages defined in the <code>SelectionListener</code>
+ * interface.
+ * <p>
+ * When <code>widgetSelected</code> is called, the item field of the event object is valid.
+ * If the receiver has the <code>SWT.CHECK</code> style and the check selection changes,
+ * the event object detail field contains the value <code>SWT.CHECK</code>.
+ * <code>widgetDefaultSelected</code> is typically called when an item is double-clicked.
+ * The item field of the event object is valid for default selection, but the detail field is not used.
+ * </p>
+ *
+ * @param listener the listener which should be notified when the user changes the receiver's selection
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent
+ */
+public void addSelectionListener (SelectionListener listener) {
+	checkWidget ();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	TypedListener typedListener = new TypedListener (listener);
+	addListener (SWT.Selection, typedListener);
+	addListener (SWT.DefaultSelection, typedListener);
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when an item in the receiver is expanded or collapsed
+ * by sending it one of the messages defined in the <code>TreeListener</code>
+ * interface.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see TreeListener
+ * @see #removeTreeListener
+ */
+public void addTreeListener(TreeListener listener) {
+	checkWidget ();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	TypedListener typedListener = new TypedListener (listener);
+	addListener (SWT.Expand, typedListener);
+	addListener (SWT.Collapse, typedListener);
+}
+
+int calculateWidth (int /*long*/ column, int /*long*/ iter, boolean recurse) {
+	OS.gtk_tree_view_column_cell_set_cell_data (column, modelHandle, iter, false, false);
+	/*
+	* Bug in GTK.  The width calculated by gtk_tree_view_column_cell_get_size()
+	* always grows in size regardless of the text or images in the table.
+	* The fix is to determine the column width from the cell renderers.
+	*/
+	// Code intentionally commented
+	//int [] width = new int [1];
+	//OS.gtk_tree_view_column_cell_get_size (column, null, null, null, width, null);
+	//return width [0];
+	
+	int width = 0;
+	int [] w = new int [1];
+	int /*long*/ path = 0;
+
+	if (OS.gtk_tree_view_get_expander_column (handle) == column) {
+		/* indent */
+		GdkRectangle rect = new GdkRectangle ();
+		OS.gtk_widget_realize (handle);
+		path = OS.gtk_tree_model_get_path (modelHandle, iter);
+		OS.gtk_tree_view_get_cell_area (handle, path, column, rect);
+		width += rect.x;
+		/* expander */
+		OS.gtk_widget_style_get (handle, OS.expander_size, w, 0);
+		width += w [0] + TreeItem.EXPANDER_EXTRA_PADDING;
+	}
+	OS.gtk_widget_style_get(handle, OS.focus_line_width, w, 0);
+	width += 2 * w [0];
+	int /*long*/ list = OS.gtk_tree_view_column_get_cell_renderers (column);
+	if (list == 0) return 0;
+	int /*long*/ temp = list;
+	while (temp != 0) {
+		int /*long*/ renderer = OS.g_list_data (temp);
+		if (renderer != 0) {
+			OS.gtk_cell_renderer_get_size (renderer, handle, null, null, null, w, null);
+			width += w [0];
+		}
+		temp = OS.g_list_next (temp);
+	}
+	OS.g_list_free (list);
+
+	if (recurse) {
+		if (path == 0) path = OS.gtk_tree_model_get_path (modelHandle, iter);
+		boolean expanded = OS.gtk_tree_view_row_expanded (handle, path);
+		if (expanded) {
+			int /*long*/ childIter = OS.g_malloc (OS.GtkTreeIter_sizeof ());
+			boolean valid = OS.gtk_tree_model_iter_children (modelHandle, childIter, iter);
+			while (valid) {
+				width = Math.max (width, calculateWidth (column, childIter, true));
+				valid = OS.gtk_tree_model_iter_next (modelHandle, childIter);
+			}
+			OS.g_free (childIter);
+		}
+	}
+
+	if (path != 0) OS.gtk_tree_path_free (path);
+	return width;
+}
+
+/**
+ * Clears the item at the given zero-relative index in the receiver.
+ * The text, icon and other attributes of the item are set to the default
+ * value.  If the tree was created with the <code>SWT.VIRTUAL</code> style,
+ * these attributes are requested again as needed.
+ *
+ * @param index the index of the item to clear
+ * @param all <code>true</code> if all child items of the indexed item should be
+ * cleared recursively, and <code>false</code> otherwise
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see SWT#VIRTUAL
+ * @see SWT#SetData
+ * 
+ * @since 3.2
+ */
+public void clear(int index, boolean all) {
+	checkWidget ();
+	clear (0, index, all);
+}
+
+void clear (int /*long*/ parentIter, int index, boolean all) {
+	int /*long*/ iter = OS.g_malloc (OS.GtkTreeIter_sizeof ());
+	OS.gtk_tree_model_iter_nth_child(modelHandle, iter, parentIter, index);
+	int[] value = new int[1];
+	OS.gtk_tree_model_get (modelHandle, iter, ID_COLUMN, value, -1);
+	if (value [0] != -1) {
+		TreeItem item = items [value [0]];
+		item.clear ();
+	}
+	if (all) clearAll (all, iter);
+	OS.g_free (iter);
+}
+
+/**
+ * Clears all the items in the receiver. The text, icon and other
+ * attributes of the items are set to their default values. If the
+ * tree was created with the <code>SWT.VIRTUAL</code> style, these
+ * attributes are requested again as needed.
+ * 
+ * @param all <code>true</code> if all child items should be cleared
+ * recursively, and <code>false</code> otherwise
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see SWT#VIRTUAL
+ * @see SWT#SetData
+ * 
+ * @since 3.2
+ */
+public void clearAll (boolean all) {
+	checkWidget ();
+	clearAll (all, 0);
+}
+void clearAll (boolean all, int /*long*/ parentIter) {
+	int length = OS.gtk_tree_model_iter_n_children (modelHandle, parentIter);
+	if (length == 0) return;
+	int /*long*/ iter = OS.g_malloc (OS.GtkTreeIter_sizeof ());
+	boolean valid = OS.gtk_tree_model_iter_children (modelHandle, iter, parentIter);
+	int[] value = new int[1];
+	while (valid) {
+		OS.gtk_tree_model_get (modelHandle, iter, ID_COLUMN, value, -1);
+		if (value [0] != -1) {
+			TreeItem item = items [value [0]];
+			item.clear ();
+		}
+		if (all) clearAll (all, iter);
+		valid = OS.gtk_tree_model_iter_next (modelHandle, iter);
+	}
+	OS.g_free (iter);
+}
+
+public Point computeSize (int wHint, int hHint, boolean changed) {
+	checkWidget ();
+	if (wHint != SWT.DEFAULT && wHint < 0) wHint = 0;
+	if (hHint != SWT.DEFAULT && hHint < 0) hHint = 0;
+	Point size = computeNativeSize (handle, wHint, hHint, changed);
+	Rectangle trim = computeTrim (0, 0, size.x, size.y);
+	size.x = trim.width;
+	size.y = trim.height;
+	return size;
+}
+
+void copyModel (int /*long*/ oldModel, int oldStart, int /*long*/ newModel, int newStart, int /*long*/ [] types, int /*long*/ oldParent, int /*long*/ newParent, int modelLength) {
+	int /*long*/ iter = OS.g_malloc(OS.GtkTreeIter_sizeof ());
+	if (OS.gtk_tree_model_iter_children (oldModel, iter, oldParent))  {
+		int /*long*/ [] oldItems = new int /*long*/ [OS.gtk_tree_model_iter_n_children (oldModel, oldParent)];
+		int oldIndex = 0;
+		do {
+			int /*long*/ newItem = OS.g_malloc (OS.GtkTreeIter_sizeof ());
+			if (newItem == 0) error (SWT.ERROR_NO_HANDLES);	
+			OS.gtk_tree_store_append (newModel, newItem, newParent);
+			int [] index = new int [1];
+			OS.gtk_tree_model_get (oldModel, iter, ID_COLUMN, index, -1);
+			TreeItem item = null;
+			if (index [0] != -1) {
+				item = items [index [0]];
+				if (item != null) {
+					int /*long*/ oldItem = item.handle;
+					oldItems[oldIndex++] = oldItem;
+					int /*long*/ [] ptr = new int /*long*/ [1];
+					for (int j = 0; j < FIRST_COLUMN; j++) {
+						OS.gtk_tree_model_get (oldModel, oldItem, j, ptr, -1);
+						OS.gtk_tree_store_set (newModel, newItem, j, ptr [0], -1);
+						if (types [j] == OS.G_TYPE_STRING ()) OS.g_free ((ptr [0]));
+					}
+					for (int j= 0; j<modelLength - FIRST_COLUMN; j++) {
+						OS.gtk_tree_model_get (oldModel, oldItem, oldStart + j, ptr, -1);
+						OS.gtk_tree_store_set (newModel, newItem, newStart + j, ptr [0], -1);
+						if (types [j] == OS.G_TYPE_STRING ()) OS.g_free ((ptr [0]));
+					}
+				}
+			} else {
+				OS.gtk_tree_store_set (newModel, newItem, ID_COLUMN, -1, -1);
+			}
+			// recurse through children
+			copyModel(oldModel, oldStart, newModel, newStart, types, iter, newItem, modelLength);
+			
+			if (item!= null) {
+				item.handle = newItem;
+			} else {
+				OS.g_free (newItem);
+			}
+		} while (OS.gtk_tree_model_iter_next(oldModel, iter));
+		for (int i = 0; i < oldItems.length; i++) {
+			int /*long*/ oldItem = oldItems [i];
+			if (oldItem != 0) {
+				OS.gtk_tree_store_remove (oldModel, oldItem);
+				OS.g_free (oldItem);
+			}
+		}
+	}
+	OS.g_free (iter);
+}
+
+void createColumn (TreeColumn column, int index) {
+/*
+* Bug in ATK. For some reason, ATK segments fault if 
+* the GtkTreeView has a column and does not have items.
+* The fix is to insert the column only when an item is 
+* created.
+*/
+	
+	int modelIndex = FIRST_COLUMN;
+	if (columnCount != 0) {
+		int modelLength = OS.gtk_tree_model_get_n_columns (modelHandle);
+		boolean [] usedColumns = new boolean [modelLength];
+		for (int i=0; i<columnCount; i++) {
+			int columnIndex = columns [i].modelIndex;
+			for (int j = 0; j < CELL_TYPES; j++) {
+				usedColumns [columnIndex + j] = true;
+			}
+		}
+		while (modelIndex < modelLength) {
+			if (!usedColumns [modelIndex]) break;
+			modelIndex++;
+		}
+		if (modelIndex == modelLength) {
+			int /*long*/ oldModel = modelHandle;
+			int /*long*/[] types = getColumnTypes (columnCount + 4); // grow by 4 rows at a time
+			int /*long*/ newModel = OS.gtk_tree_store_newv (types.length, types);
+			if (newModel == 0) error (SWT.ERROR_NO_HANDLES);
+			copyModel (oldModel, FIRST_COLUMN, newModel, FIRST_COLUMN, types, (int /*long*/)0, (int /*long*/)0, modelLength);
+			OS.gtk_tree_view_set_model (handle, newModel);
+			OS.g_object_unref (oldModel);
+			modelHandle = newModel;
+		}
+	}
+	int /*long*/ columnHandle = OS.gtk_tree_view_column_new ();
+	if (columnHandle == 0) error (SWT.ERROR_NO_HANDLES);
+	if (index == 0 && columnCount > 0) {
+		TreeColumn checkColumn = columns [0];
+		createRenderers (checkColumn.handle, checkColumn.modelIndex, false, checkColumn.style);
+	}
+	createRenderers (columnHandle, modelIndex, index == 0, column == null ? 0 : column.style);
+	/*
+	* Use GTK_TREE_VIEW_COLUMN_GROW_ONLY on GTK versions < 2.3.2
+	* because fixed_height_mode is not supported.
+	*/
+	boolean useVirtual = (style & SWT.VIRTUAL) != 0 && OS.GTK_VERSION >= OS.VERSION (2, 3, 2);
+	if (!useVirtual && columnCount == 0) {
+		OS.gtk_tree_view_column_set_sizing (columnHandle, OS.GTK_TREE_VIEW_COLUMN_GROW_ONLY);
+	} else {
+		OS.gtk_tree_view_column_set_sizing (columnHandle, OS.GTK_TREE_VIEW_COLUMN_FIXED);
+		if (columnCount != 0) OS.gtk_tree_view_column_set_visible (columnHandle, false);
+	}
+	OS.gtk_tree_view_column_set_resizable (columnHandle, true);
+	OS.gtk_tree_view_column_set_clickable (columnHandle, true);
+	OS.gtk_tree_view_column_set_min_width (columnHandle, 0);
+	OS.gtk_tree_view_insert_column (handle, columnHandle, index);
+	if (column != null) {
+		column.handle = columnHandle;
+		column.modelIndex = modelIndex;
+	}
+	/* Disable searching when using VIRTUAL */
+	if ((style & SWT.VIRTUAL) != 0) {
+		/*
+		* Bug in GTK. Until GTK 2.6.5, calling gtk_tree_view_set_enable_search(FALSE)
+		* would prevent the user from being able to type in text to search the tree.
+		* After 2.6.5, GTK introduced Ctrl+F as being the key binding for interactive
+		* search. This meant that even if FALSE was passed to enable_search, the user
+		* can still bring up the search pop up using the keybinding. GTK also introduced
+		* the notion of passing a -1 to gtk_set_search_column to disable searching
+		* (including the search key binding).  The fix is to use the right calls
+		* for the right version.
+		*/
+		if (OS.GTK_VERSION >= OS.VERSION (2, 6, 5)) {
+			OS.gtk_tree_view_set_search_column (handle, -1); 
+		} else {
+			OS.gtk_tree_view_set_enable_search (handle, false);
+		}
+	} else {
+		/* Set the search column whenever the model changes */
+		int firstColumn = columnCount == 0 ? FIRST_COLUMN : columns [0].modelIndex;
+		OS.gtk_tree_view_set_search_column (handle, firstColumn + CELL_TEXT);
+	}
+}
+
+void createHandle (int index) {
+	state |= HANDLE;
+	fixedHandle = OS.g_object_new (display.gtk_fixed_get_type (), 0);
+	if (fixedHandle == 0) error (SWT.ERROR_NO_HANDLES);
+	OS.gtk_fixed_set_has_window (fixedHandle, true);
+	scrolledHandle = OS.gtk_scrolled_window_new (0, 0);
+	if (scrolledHandle == 0) error (SWT.ERROR_NO_HANDLES);
+	int /*long*/ [] types = getColumnTypes (1);
+	modelHandle = OS.gtk_tree_store_newv (types.length, types);
+	if (modelHandle == 0) error (SWT.ERROR_NO_HANDLES);
+	handle = OS.gtk_tree_view_new_with_model (modelHandle);
+	if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+	if ((style & SWT.CHECK) != 0) {
+		checkRenderer = OS.gtk_cell_renderer_toggle_new ();
+		if (checkRenderer == 0) error (SWT.ERROR_NO_HANDLES);
+		OS.g_object_ref (checkRenderer);
+	}
+	createColumn (null, 0);
+	OS.gtk_container_add (fixedHandle, scrolledHandle);
+	OS.gtk_container_add (scrolledHandle, handle);
+
+	int mode = (style & SWT.MULTI) != 0 ? OS.GTK_SELECTION_MULTIPLE : OS.GTK_SELECTION_BROWSE;
+	int /*long*/ selectionHandle = OS.gtk_tree_view_get_selection (handle);
+	OS.gtk_tree_selection_set_mode (selectionHandle, mode);
+	OS.gtk_tree_view_set_headers_visible (handle, false);	
+	int hsp = (style & SWT.H_SCROLL) != 0 ? OS.GTK_POLICY_AUTOMATIC : OS.GTK_POLICY_NEVER;
+	int vsp = (style & SWT.V_SCROLL) != 0 ? OS.GTK_POLICY_AUTOMATIC : OS.GTK_POLICY_NEVER;
+	OS.gtk_scrolled_window_set_policy (scrolledHandle, hsp, vsp);
+	if ((style & SWT.BORDER) != 0) OS.gtk_scrolled_window_set_shadow_type (scrolledHandle, OS.GTK_SHADOW_ETCHED_IN);
+	/* Disable searching when using VIRTUAL */
+	if ((style & SWT.VIRTUAL) != 0) {
+		/* The fixed_height_mode property only exists in GTK 2.3.2 and greater */
+		if (OS.GTK_VERSION >= OS.VERSION (2, 3, 2)) {
+			OS.g_object_set (handle, OS.fixed_height_mode, true, 0);
+		}
+		/*
+		* Bug in GTK. Until GTK 2.6.5, calling gtk_tree_view_set_enable_search(FALSE)
+		* would prevent the user from being able to type in text to search the tree.
+		* After 2.6.5, GTK introduced Ctrl+F as being the key binding for interactive
+		* search. This meant that even if FALSE was passed to enable_search, the user
+		* can still bring up the search pop up using the keybinding. GTK also introduced
+		* the notion of passing a -1 to gtk_set_search_column to disable searching
+		* (including the search key binding).  The fix is to use the right calls
+		* for the right version.
+		*/
+		if (OS.GTK_VERSION >= OS.VERSION (2, 6, 5)) {
+			OS.gtk_tree_view_set_search_column (handle, -1); 
+		} else {
+			OS.gtk_tree_view_set_enable_search (handle, false);
+		};
+	}
+}
+
+void createItem (TreeColumn column, int index) {
+	if (!(0 <= index && index <= columnCount)) error (SWT.ERROR_INVALID_RANGE);
+	if (index == 0) {
+		// first column must be left aligned
+		column.style &= ~(SWT.LEFT | SWT.RIGHT | SWT.CENTER);
+		column.style |= SWT.LEFT;
+	}
+	if (columnCount == 0) {
+		column.handle = OS.gtk_tree_view_get_column (handle, 0);
+		OS.gtk_tree_view_column_set_sizing (column.handle, OS.GTK_TREE_VIEW_COLUMN_FIXED);
+		OS.gtk_tree_view_column_set_visible (column.handle, false);
+		column.modelIndex = FIRST_COLUMN;
+		createRenderers (column.handle, column.modelIndex, true, column.style);
+		column.customDraw = firstCustomDraw;
+		firstCustomDraw = false;
+	} else {
+		createColumn (column, index);
+	}
+	int /*long*/ boxHandle = OS.gtk_hbox_new (false, 3);
+	if (boxHandle == 0) error (SWT.ERROR_NO_HANDLES);
+	int /*long*/ labelHandle = OS.gtk_label_new_with_mnemonic (null);
+	if (labelHandle == 0) error (SWT.ERROR_NO_HANDLES);
+	int /*long*/ imageHandle = OS.gtk_image_new ();
+	if (imageHandle == 0) error (SWT.ERROR_NO_HANDLES);
+	OS.gtk_container_add (boxHandle, imageHandle);
+	OS.gtk_container_add (boxHandle, labelHandle);
+	OS.gtk_widget_show (boxHandle);
+	OS.gtk_widget_show (labelHandle);
+	column.labelHandle = labelHandle;
+	column.imageHandle = imageHandle;	
+	OS.gtk_tree_view_column_set_widget (column.handle, boxHandle);
+	int /*long*/ widget = OS.gtk_widget_get_parent (boxHandle);
+	while (widget != handle) {
+		if (OS.GTK_IS_BUTTON (widget)) {
+			column.buttonHandle = widget;
+			break;
+		}
+		widget = OS.gtk_widget_get_parent (widget);
+	}
+	if (columnCount == columns.length) {
+		TreeColumn [] newColumns = new TreeColumn [columns.length + 4];
+		System.arraycopy (columns, 0, newColumns, 0, columns.length);
+		columns = newColumns;
+	}
+	System.arraycopy (columns, index, columns, index + 1, columnCount++ - index);
+	columns [index] = column;
+	if ((state & FONT) != 0) {
+		column.setFontDescription (getFontDescription ());
+	}
+	if (columnCount >= 1) {
+		for (int i=0; i<items.length; i++) {
+			TreeItem item = items [i];
+			if (item != null) {
+				Font [] cellFont = item.cellFont;
+				if (cellFont != null) {
+					Font [] temp = new Font [columnCount];
+					System.arraycopy (cellFont, 0, temp, 0, index);
+					System.arraycopy (cellFont, index, temp, index+1, columnCount-index-1);
+					item.cellFont = temp;
+				}
+			}
+		}
+	}
+}
+
+void createItem (TreeItem item, int /*long*/ parentIter, int index) {
+	int count = OS.gtk_tree_model_iter_n_children (modelHandle, parentIter);
+	if (index == -1) index = count;
+	if (!(0 <= index && index <= count)) error (SWT.ERROR_INVALID_RANGE);
+	item.handle = OS.g_malloc (OS.GtkTreeIter_sizeof ());
+	if (item.handle == 0) error(SWT.ERROR_NO_HANDLES);
+	/*
+	* Feature in GTK.  It is much faster to append to a tree store
+	* than to insert at the end using gtk_tree_store_insert(). 
+	*/
+	if (index == count) {
+		OS.gtk_tree_store_append (modelHandle, item.handle, parentIter);
+	} else {
+		OS.gtk_tree_store_insert (modelHandle, item.handle, parentIter, index);
+	}
+	int id = getId (item.handle, false);
+	items [id] = item;
+	modelChanged = true;
+}
+
+void createRenderers (int /*long*/ columnHandle, int modelIndex, boolean check, int columnStyle) {
+	OS.gtk_tree_view_column_clear (columnHandle);
+	if ((style & SWT.CHECK) != 0 && check) {
+		OS.gtk_tree_view_column_pack_start (columnHandle, checkRenderer, false);
+		OS.gtk_tree_view_column_add_attribute (columnHandle, checkRenderer, OS.active, CHECKED_COLUMN);
+		/*
+		* Feature in GTK. The inconsistent property only exists in GTK 2.2.x.
+		*/
+		if (OS.GTK_VERSION >= OS.VERSION (2, 2, 0)) {
+			OS.gtk_tree_view_column_add_attribute (columnHandle, checkRenderer, OS.inconsistent, GRAYED_COLUMN);
+		}
+		/*
+		* Bug in GTK. GTK renders the background on top of the checkbox.
+		* This only happens in version 2.2.1 and earlier. The fix is not to set the background.   
+		*/
+		if (OS.GTK_VERSION > OS.VERSION (2, 2, 1)) {
+			if (!ownerDraw) OS.gtk_tree_view_column_add_attribute (columnHandle, checkRenderer, OS.cell_background_gdk, BACKGROUND_COLUMN);
+		}
+		if (ownerDraw) {
+			OS.gtk_tree_view_column_set_cell_data_func (columnHandle, checkRenderer, display.cellDataProc, handle, 0);
+			OS.g_object_set_qdata (checkRenderer, Display.SWT_OBJECT_INDEX1, columnHandle);
+		}
+	}
+	int /*long*/ pixbufRenderer = ownerDraw ? OS.g_object_new (display.gtk_cell_renderer_pixbuf_get_type (), 0) : OS.gtk_cell_renderer_pixbuf_new ();
+	if (pixbufRenderer == 0) error (SWT.ERROR_NO_HANDLES);
+	int /*long*/ textRenderer = ownerDraw ? OS.g_object_new (display.gtk_cell_renderer_text_get_type (), 0) : OS.gtk_cell_renderer_text_new ();
+	if (textRenderer == 0) error (SWT.ERROR_NO_HANDLES);
+	
+	if (ownerDraw) {
+		OS.g_object_set_qdata (pixbufRenderer, Display.SWT_OBJECT_INDEX1, columnHandle);
+		OS.g_object_set_qdata (textRenderer, Display.SWT_OBJECT_INDEX1, columnHandle);
+	}
+
+	/*
+	* Feature in GTK.  When a tree view column contains only one activatable
+	* cell renderer such as a toggle renderer, mouse clicks anywhere in a cell
+	* activate that renderer. The workaround is to set a second  cell renderer
+	* to be activatable.
+	*/
+	if ((style & SWT.CHECK) != 0 && check) {
+		OS.g_object_set (pixbufRenderer, OS.mode, OS.GTK_CELL_RENDERER_MODE_ACTIVATABLE, 0);
+	}
+
+	/* Set alignment */
+	if ((columnStyle & SWT.RIGHT) != 0) {
+		OS.g_object_set(textRenderer, OS.xalign, 1f, 0);
+		OS.gtk_tree_view_column_pack_end (columnHandle, textRenderer, true);
+		OS.gtk_tree_view_column_pack_end (columnHandle, pixbufRenderer, false);
+		OS.gtk_tree_view_column_set_alignment (columnHandle, 1f);
+	} else if ((columnStyle & SWT.CENTER) != 0) {
+		OS.g_object_set(textRenderer, OS.xalign, 0.5f, 0);
+		OS.gtk_tree_view_column_pack_start (columnHandle, pixbufRenderer, false);
+		OS.gtk_tree_view_column_pack_end (columnHandle, textRenderer, true);
+		OS.gtk_tree_view_column_set_alignment (columnHandle, 0.5f);
+	} else {
+		OS.gtk_tree_view_column_pack_start (columnHandle, pixbufRenderer, false);
+		OS.gtk_tree_view_column_pack_start (columnHandle, textRenderer, true);
+		OS.gtk_tree_view_column_set_alignment (columnHandle, 0f);
+	}
+
+	/* Add attributes */
+	OS.gtk_tree_view_column_add_attribute (columnHandle, pixbufRenderer, OS.pixbuf, modelIndex + CELL_PIXBUF);
+	/*
+	 * Bug on GTK. Gtk renders the background on top of the pixbuf.
+	 * This only happens in version 2.2.1 and earlier. The fix is not to set the background.   
+	 */
+	if (OS.GTK_VERSION > OS.VERSION (2, 2, 1)) {
+		if (!ownerDraw) {
+			OS.gtk_tree_view_column_add_attribute (columnHandle, pixbufRenderer, OS.cell_background_gdk, BACKGROUND_COLUMN);
+			OS.gtk_tree_view_column_add_attribute (columnHandle, textRenderer, OS.cell_background_gdk, BACKGROUND_COLUMN);
+		}
+	}
+	OS.gtk_tree_view_column_add_attribute (columnHandle, textRenderer, OS.text, modelIndex + CELL_TEXT);
+	OS.gtk_tree_view_column_add_attribute (columnHandle, textRenderer, OS.foreground_gdk, FOREGROUND_COLUMN);
+	OS.gtk_tree_view_column_add_attribute (columnHandle, textRenderer, OS.font_desc, FONT_COLUMN);
+	
+	boolean customDraw = firstCustomDraw;
+	if (columnCount != 0) {
+		for (int i=0; i<columnCount; i++) {
+			if (columns [i].handle == columnHandle) {
+				customDraw = columns [i].customDraw;
+				break;
+			}
+		}
+	}
+	if ((style & SWT.VIRTUAL) != 0 || customDraw || ownerDraw) {
+		OS.gtk_tree_view_column_set_cell_data_func (columnHandle, textRenderer, display.cellDataProc, handle, 0);
+		OS.gtk_tree_view_column_set_cell_data_func (columnHandle, pixbufRenderer, display.cellDataProc, handle, 0);
+	}
+}
+
+void createWidget (int index) {
+	super.createWidget (index);
+	items = new TreeItem [4];
+	columns = new TreeColumn [4];
+	columnCount = 0;
+}
+
+GdkColor defaultBackground () {
+	return display.COLOR_LIST_BACKGROUND;
+}
+
+GdkColor defaultForeground () {
+	return display.COLOR_LIST_FOREGROUND;
+}
+
+void deregister () {
+	super.deregister ();
+	display.removeWidget (OS.gtk_tree_view_get_selection (handle));
+	if (checkRenderer != 0) display.removeWidget (checkRenderer);
+}
+
+/**
+ * Deselects an item in the receiver.  If the item was already
+ * deselected, it remains deselected.
+ *
+ * @param item the item to be deselected
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the item is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the item has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 3.4
+ */
+public void deselect (TreeItem item) {
+	checkWidget ();
+	if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if (item.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT);
+	boolean fixColumn = showFirstColumn ();
+	int /*long*/ selection = OS.gtk_tree_view_get_selection (handle);
+	OS.g_signal_handlers_block_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+	OS.gtk_tree_selection_unselect_iter (selection, item.handle);
+	OS.g_signal_handlers_unblock_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+	if (fixColumn) hideFirstColumn ();
+}
+
+/**
+ * Deselects all selected items in the receiver.
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void deselectAll() {
+	checkWidget();
+	boolean fixColumn = showFirstColumn ();
+	int /*long*/ selection = OS.gtk_tree_view_get_selection (handle);
+	OS.g_signal_handlers_block_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+	OS.gtk_tree_selection_unselect_all (selection);
+	OS.g_signal_handlers_unblock_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+	if (fixColumn) hideFirstColumn ();
+}
+
+void destroyItem (TreeColumn column) {
+	int index = 0;
+	while (index < columnCount) {
+		if (columns [index] == column) break;
+		index++;
+	}
+	if (index == columnCount) return;
+	int /*long*/ columnHandle = column.handle;
+	if (columnCount == 1) {
+		firstCustomDraw = column.customDraw;
+	}
+	System.arraycopy (columns, index + 1, columns, index, --columnCount - index);
+	columns [columnCount] = null;
+	OS.gtk_tree_view_remove_column (handle, columnHandle);
+	if (columnCount == 0) {
+		int /*long*/ oldModel = modelHandle;
+		int /*long*/[] types = getColumnTypes (1);
+		int /*long*/ newModel = OS.gtk_tree_store_newv (types.length, types);
+		if (newModel == 0) error (SWT.ERROR_NO_HANDLES);
+		copyModel(oldModel, column.modelIndex, newModel, FIRST_COLUMN, types, (int /*long*/)0, (int /*long*/)0, FIRST_COLUMN + CELL_TYPES);
+		OS.gtk_tree_view_set_model (handle, newModel);
+		OS.g_object_unref (oldModel);
+		modelHandle = newModel;
+		createColumn (null, 0);
+		
+	} else {
+		for (int i=0; i<items.length; i++) {
+			TreeItem item = items [i];
+			if (item != null) {
+				int /*long*/ iter = item.handle;
+				int modelIndex = column.modelIndex;
+				OS.gtk_tree_store_set (modelHandle, iter, modelIndex + CELL_PIXBUF, 0, -1);
+				OS.gtk_tree_store_set (modelHandle, iter, modelIndex + CELL_TEXT, 0, -1);
+				OS.gtk_tree_store_set (modelHandle, iter, modelIndex + CELL_FOREGROUND, 0, -1);
+				OS.gtk_tree_store_set (modelHandle, iter, modelIndex + CELL_BACKGROUND, 0, -1);
+				OS.gtk_tree_store_set (modelHandle, iter, modelIndex + CELL_FONT, 0, -1);
+				
+				Font [] cellFont = item.cellFont;
+				if (cellFont != null) {
+					if (columnCount == 0) {
+						item.cellFont = null;
+					} else {
+						Font [] temp = new Font [columnCount];
+						System.arraycopy (cellFont, 0, temp, 0, index);
+						System.arraycopy (cellFont, index + 1, temp, index, columnCount - index);
+						item.cellFont = temp;
+					}
+				}
+			}
+		}
+		if (index == 0) {
+			// first column must be left aligned and must show check box
+			TreeColumn firstColumn = columns [0];
+			firstColumn.style &= ~(SWT.LEFT | SWT.RIGHT | SWT.CENTER);
+			firstColumn.style |= SWT.LEFT;
+			createRenderers (firstColumn.handle, firstColumn.modelIndex, true, firstColumn.style);
+		}
+	}
+	/* Disable searching when using VIRTUAL */
+	if ((style & SWT.VIRTUAL) != 0) {
+		/*
+		* Bug in GTK. Until GTK 2.6.5, calling gtk_tree_view_set_enable_search(FALSE)
+		* would prevent the user from being able to type in text to search the tree.
+		* After 2.6.5, GTK introduced Ctrl+F as being the key binding for interactive
+		* search. This meant that even if FALSE was passed to enable_search, the user
+		* can still bring up the search pop up using the keybinding. GTK also introduced
+		* the notion of passing a -1 to gtk_set_search_column to disable searching
+		* (including the search key binding).  The fix is to use the right calls
+		* for the right version.
+		*/
+		if (OS.GTK_VERSION >= OS.VERSION (2, 6, 5)) {
+			OS.gtk_tree_view_set_search_column (handle, -1); 
+		} else {
+			OS.gtk_tree_view_set_enable_search (handle, false);
+		}
+	} else {
+		/* Set the search column whenever the model changes */
+		int firstColumn = columnCount == 0 ? FIRST_COLUMN : columns [0].modelIndex;
+		OS.gtk_tree_view_set_search_column (handle, firstColumn + CELL_TEXT);
+	}
+}
+
+
+void destroyItem (TreeItem item) {
+	/*
+	* Bug in GTK.  GTK segment faults when a root tree item
+	* is destroyed when the tree is expanded and the last leaf of
+	* the root is selected.  This only happens in versions earlier
+	* than 2.0.6.  The fix is to collapse the tree item being destroyed
+	* when it is a root, before it is destroyed.
+	*/
+	if (OS.GTK_VERSION < OS.VERSION (2, 0, 6)) {
+		int length = OS.gtk_tree_model_iter_n_children (modelHandle, 0);
+		if (length > 0) {
+			int /*long*/ iter = OS.g_malloc (OS.GtkTreeIter_sizeof ());
+			boolean valid = OS.gtk_tree_model_iter_children (modelHandle, iter, 0);
+			while (valid) {
+				if (item.handle == iter) {
+					item.setExpanded (false);
+					break;
+				}
+				valid = OS.gtk_tree_model_iter_next (modelHandle, iter);
+			}
+			OS.g_free (iter);
+		}
+	}
+	int /*long*/ selection = OS.gtk_tree_view_get_selection (handle);
+	OS.g_signal_handlers_block_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+	OS.gtk_tree_store_remove (modelHandle, item.handle);
+	OS.g_signal_handlers_unblock_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+	modelChanged = true;
+}
+
+boolean dragDetect (int x, int y, boolean filter, boolean [] consume) {
+	boolean selected = false;
+	if (filter) {
+		int /*long*/ [] path = new int /*long*/ [1];
+		if (OS.gtk_tree_view_get_path_at_pos (handle, x, y, path, null, null, null)) {
+			if (path [0] != 0) {
+				int /*long*/ selection = OS.gtk_tree_view_get_selection (handle);
+				if (OS.gtk_tree_selection_path_is_selected (selection, path [0])) selected = true;
+				OS.gtk_tree_path_free (path [0]);
+			}
+		} else {
+			return false;
+		}
+	}
+	boolean dragDetect = super.dragDetect (x, y, filter, consume);
+	if (dragDetect && selected && consume != null) consume [0] = true;
+	return dragDetect;
+}
+
+int /*long*/ eventWindow () {
+	return paintWindow ();
+}
+
+void fixChildren (Shell newShell, Shell oldShell, Decorations newDecorations, Decorations oldDecorations, Menu [] menus) {
+	super.fixChildren (newShell, oldShell, newDecorations, oldDecorations, menus);
+	for (int i=0; i<columnCount; i++) {
+		TreeColumn column = columns [i];
+		if (column.toolTipText != null) {
+			column.setToolTipText(oldShell, null);
+			column.setToolTipText(newShell, column.toolTipText);
+		}
+	}
+}
+
+GdkColor getBackgroundColor () {
+	return getBaseColor ();
+}
+
+public Rectangle getClientArea () {
+	checkWidget ();
+	forceResize ();
+	OS.gtk_widget_realize (handle);
+	int /*long*/ fixedWindow = OS.GTK_WIDGET_WINDOW (fixedHandle);
+	int /*long*/ binWindow = OS.gtk_tree_view_get_bin_window (handle);
+	int [] binX = new int [1], binY = new int [1];
+	OS.gdk_window_get_origin (binWindow, binX, binY);
+	int [] fixedX = new int [1], fixedY = new int [1];
+	OS.gdk_window_get_origin (fixedWindow, fixedX, fixedY);
+	int /*long*/ clientHandle = clientHandle ();
+	int width = (state & ZERO_WIDTH) != 0 ? 0 : OS.GTK_WIDGET_WIDTH (clientHandle);
+	int height = (state & ZERO_HEIGHT) != 0 ? 0 : OS.GTK_WIDGET_HEIGHT (clientHandle);
+	return new Rectangle (fixedX [0] - binX [0], fixedY [0] - binY [0], width, height);
+}
+
+int getClientWidth () {
+	int [] w = new int [1], h = new int [1];
+	OS.gtk_widget_realize (handle);
+	OS.gdk_drawable_get_size(OS.gtk_tree_view_get_bin_window(handle), w, h);
+	return w[0];
+}
+
+/**
+ * Returns the column at the given, zero-relative index in the
+ * receiver. Throws an exception if the index is out of range.
+ * Columns are returned in the order that they were created.
+ * If no <code>TreeColumn</code>s were created by the programmer,
+ * this method will throw <code>ERROR_INVALID_RANGE</code> despite
+ * the fact that a single column of data may be visible in the tree.
+ * This occurs when the programmer uses the tree like a list, adding
+ * items but never creating a column.
+ *
+ * @param index the index of the column to return
+ * @return the column at the given index
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see Tree#getColumnOrder()
+ * @see Tree#setColumnOrder(int[])
+ * @see TreeColumn#getMoveable()
+ * @see TreeColumn#setMoveable(boolean)
+ * @see SWT#Move
+ * 
+ * @since 3.1
+ */
+public TreeColumn getColumn (int index) {
+	checkWidget();
+	if (!(0 <= index && index < columnCount)) error (SWT.ERROR_INVALID_RANGE);
+	return columns [index];
+}
+
+/**
+ * Returns the number of columns contained in the receiver.
+ * If no <code>TreeColumn</code>s were created by the programmer,
+ * this value is zero, despite the fact that visually, one column
+ * of items may be visible. This occurs when the programmer uses
+ * the tree like a list, adding items but never creating a column.
+ *
+ * @return the number of columns
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.1
+ */
+public int getColumnCount () {
+	checkWidget();
+	return columnCount;
+}
+
+/**
+ * Returns an array of zero-relative integers that map
+ * the creation order of the receiver's items to the
+ * order in which they are currently being displayed.
+ * <p>
+ * Specifically, the indices of the returned array represent
+ * the current visual order of the items, and the contents
+ * of the array represent the creation order of the items.
+ * </p><p>
+ * Note: This is not the actual structure used by the receiver
+ * to maintain its list of items, so modifying the array will
+ * not affect the receiver. 
+ * </p>
+ *
+ * @return the current visual order of the receiver's items
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see Tree#setColumnOrder(int[])
+ * @see TreeColumn#getMoveable()
+ * @see TreeColumn#setMoveable(boolean)
+ * @see SWT#Move
+ * 
+ * @since 3.2
+ */
+public int [] getColumnOrder () {
+	checkWidget ();
+	if (columnCount == 0) return new int [0];
+	int /*long*/ list = OS.gtk_tree_view_get_columns (handle);
+	if (list == 0) return new int [0];
+	int  i = 0, count = OS.g_list_length (list);
+	int [] order = new int [count];
+	int /*long*/ temp = list;
+	while (temp != 0) {
+		int /*long*/ column = OS.g_list_data (temp);
+		if (column != 0) {
+			for (int j=0; j<columnCount; j++) {
+				if (columns [j].handle == column) {
+					order [i++] = j;
+					break;
+				}
+			}
+		}
+		temp = OS.g_list_next (temp);
+	}
+	OS.g_list_free (list);
+	return order;
+}
+
+int /*long*/[] getColumnTypes (int columnCount) {
+	int /*long*/[] types = new int /*long*/ [FIRST_COLUMN + (columnCount * CELL_TYPES)];
+	// per row data
+	types [ID_COLUMN] = OS.G_TYPE_INT ();
+	types [CHECKED_COLUMN] = OS.G_TYPE_BOOLEAN (); 
+	types [GRAYED_COLUMN] = OS.G_TYPE_BOOLEAN ();
+	types [FOREGROUND_COLUMN] = OS.GDK_TYPE_COLOR ();
+	types [BACKGROUND_COLUMN] = OS.GDK_TYPE_COLOR ();
+	types [FONT_COLUMN] = OS.PANGO_TYPE_FONT_DESCRIPTION ();
+	// per cell data
+	for (int i=FIRST_COLUMN; i<types.length; i+=CELL_TYPES) {
+		types [i + CELL_PIXBUF] = OS.GDK_TYPE_PIXBUF ();
+		types [i + CELL_TEXT] = OS.G_TYPE_STRING ();
+		types [i + CELL_FOREGROUND] = OS.GDK_TYPE_COLOR ();
+		types [i + CELL_BACKGROUND] = OS.GDK_TYPE_COLOR ();
+		types [i + CELL_FONT] = OS.PANGO_TYPE_FONT_DESCRIPTION ();
+	}
+	return types;
+}
+
+/**
+ * Returns an array of <code>TreeColumn</code>s which are the
+ * columns in the receiver. Columns are returned in the order
+ * that they were created.  If no <code>TreeColumn</code>s were
+ * created by the programmer, the array is empty, despite the fact
+ * that visually, one column of items may be visible. This occurs
+ * when the programmer uses the tree like a list, adding items but
+ * never creating a column.
+ * <p>
+ * Note: This is not the actual structure used by the receiver
+ * to maintain its list of items, so modifying the array will
+ * not affect the receiver. 
+ * </p>
+ *
+ * @return the items in the receiver
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see Tree#getColumnOrder()
+ * @see Tree#setColumnOrder(int[])
+ * @see TreeColumn#getMoveable()
+ * @see TreeColumn#setMoveable(boolean)
+ * @see SWT#Move
+ * 
+ * @since 3.1
+ */
+public TreeColumn [] getColumns () {
+	checkWidget();
+	TreeColumn [] result = new TreeColumn [columnCount];
+	System.arraycopy (columns, 0, result, 0, columnCount);
+	return result;
+}
+
+TreeItem getFocusItem () {
+	int /*long*/ [] path = new int /*long*/ [1];
+	OS.gtk_tree_view_get_cursor (handle, path, null);
+	if (path [0] == 0) return null;
+	TreeItem item = null;
+	int /*long*/ iter = OS.g_malloc (OS.GtkTreeIter_sizeof ());
+	if (OS.gtk_tree_model_get_iter (modelHandle, iter, path [0])) {
+		int [] index = new int [1];
+		OS.gtk_tree_model_get (modelHandle, iter, ID_COLUMN, index, -1);
+		if (index [0] != -1) item = items [index [0]]; //TODO should we be creating this item when index is -1?
+	}
+	OS.g_free (iter);
+	OS.gtk_tree_path_free (path [0]);
+	return item;	
+} 
+
+GdkColor getForegroundColor () {
+	return getTextColor ();
+}
+
+/**
+ * Returns the width in pixels of a grid line.
+ *
+ * @return the width of a grid line in pixels
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.1
+ */
+public int getGridLineWidth () {
+	checkWidget();
+	return 0;
+}
+
+/**
+ * Returns the height of the receiver's header 
+ *
+ * @return the height of the header or zero if the header is not visible
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.1 
+ */
+public int getHeaderHeight () {
+	checkWidget ();
+	if (!OS.gtk_tree_view_get_headers_visible (handle)) return 0;
+	if (columnCount > 0) {
+		GtkRequisition requisition = new GtkRequisition ();
+		int height = 0;
+		for (int i=0; i<columnCount; i++) {
+			int /*long*/ buttonHandle = columns [i].buttonHandle;
+			if (buttonHandle != 0) {
+				OS.gtk_widget_size_request (buttonHandle, requisition);
+				height = Math.max (height, requisition.height);
+			}
+		}
+		return height;
+	}
+	OS.gtk_widget_realize (handle);
+	int /*long*/ fixedWindow = OS.GTK_WIDGET_WINDOW (fixedHandle);
+	int /*long*/ binWindow = OS.gtk_tree_view_get_bin_window (handle);
+	int [] binY = new int [1];
+	OS.gdk_window_get_origin (binWindow, null, binY);
+	int [] fixedY = new int [1];
+	OS.gdk_window_get_origin (fixedWindow, null, fixedY);
+	return binY [0] - fixedY [0];
+}
+
+/**
+ * Returns <code>true</code> if the receiver's header is visible,
+ * and <code>false</code> otherwise.
+ * <p>
+ * If one of the receiver's ancestors is not visible or some
+ * other condition makes the receiver not visible, this method
+ * may still indicate that it is considered visible even though
+ * it may not actually be showing.
+ * </p>
+ *
+ * @return the receiver's header's visibility state
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.1
+ */
+public boolean getHeaderVisible () {
+	checkWidget();
+	return OS.gtk_tree_view_get_headers_visible (handle);
+}
+
+/**
+ * Returns the item at the given, zero-relative index in the
+ * receiver. Throws an exception if the index is out of range.
+ *
+ * @param index the index of the item to return
+ * @return the item at the given index
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.1
+ */
+public TreeItem getItem (int index) {
+	checkWidget();
+	if (!(0 <= index && index < OS.gtk_tree_model_iter_n_children (modelHandle, 0)))  {
+		error (SWT.ERROR_INVALID_RANGE);
+	}
+	return _getItem (0, index);
+}
+
+/**
+ * Returns the item at the given point in the receiver
+ * or null if no such item exists. The point is in the
+ * coordinate system of the receiver.
+ * <p>
+ * The item that is returned represents an item that could be selected by the user.
+ * For example, if selection only occurs in items in the first column, then null is 
+ * returned if the point is outside of the item. 
+ * Note that the SWT.FULL_SELECTION style hint, which specifies the selection policy,
+ * determines the extent of the selection.
+ * </p>
+ *
+ * @param point the point used to locate the item
+ * @return the item at the given point, or null if the point is not in a selectable item
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the point is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public TreeItem getItem (Point point) {
+	checkWidget ();
+	if (point == null) error (SWT.ERROR_NULL_ARGUMENT);
+	int /*long*/ [] path = new int /*long*/ [1];
+	OS.gtk_widget_realize (handle);
+	int /*long*/ [] columnHandle = new int /*long*/ [1];
+	if (!OS.gtk_tree_view_get_path_at_pos (handle, point.x, point.y, path, columnHandle, null, null)) return null;
+	if (path [0] == 0) return null;
+	TreeItem item = null;
+	int /*long*/ iter = OS.g_malloc (OS.GtkTreeIter_sizeof ());
+	if (OS.gtk_tree_model_get_iter (modelHandle, iter, path [0])) {
+		boolean overExpander = false;
+		if (OS.gtk_tree_view_get_expander_column (handle) == columnHandle [0]) {
+			int [] buffer = new int [1];
+			GdkRectangle rect = new GdkRectangle ();
+			OS.gtk_tree_view_get_cell_area (handle, path [0], columnHandle [0], rect);
+			if (OS.GTK_VERSION < OS.VERSION (2, 8, 18)) {
+				OS.gtk_widget_style_get (handle, OS.expander_size, buffer, 0);
+				int expanderSize = buffer [0] + TreeItem.EXPANDER_EXTRA_PADDING;
+				overExpander = point.x < rect.x + expanderSize;
+			} else {
+				overExpander = point.x < rect.x;
+			}
+		}
+		if (!overExpander) {
+			item = _getItem (iter);
+		}
+	}
+	OS.g_free (iter);
+	OS.gtk_tree_path_free (path [0]);
+	return item;
+}
+
+/**
+ * Returns the number of items contained in the receiver
+ * that are direct item children of the receiver.  The
+ * number that is returned is the number of roots in the
+ * tree.
+ *
+ * @return the number of items
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getItemCount () {
+	checkWidget ();
+	return OS.gtk_tree_model_iter_n_children (modelHandle, 0);
+}
+
+/**
+ * Returns the height of the area which would be used to
+ * display <em>one</em> of the items in the tree.
+ *
+ * @return the height of one item
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getItemHeight () {
+	checkWidget ();
+	int itemCount = OS.gtk_tree_model_iter_n_children (modelHandle, 0);
+	if (itemCount == 0) {
+		int /*long*/ column = OS.gtk_tree_view_get_column (handle, 0);
+		int [] w = new int [1], h = new int [1];
+		ignoreSize = true;
+		OS.gtk_tree_view_column_cell_get_size (column, null, null, null, w, h);
+		ignoreSize = false;
+		return h [0];
+	} else {
+		int height = 0;
+		int /*long*/ iter = OS.g_malloc (OS.GtkTreeIter_sizeof ());
+		OS.gtk_tree_model_get_iter_first (modelHandle, iter);
+		int columnCount = Math.max (1, this.columnCount);
+		for (int i=0; i<columnCount; i++) {
+			int /*long*/ column = OS.gtk_tree_view_get_column (handle, i);
+			OS.gtk_tree_view_column_cell_set_cell_data (column, modelHandle, iter, false, false);
+			int [] w = new int [1], h = new int [1];
+			OS.gtk_tree_view_column_cell_get_size (column, null, null, null, w, h);
+			height = Math.max (height, h [0]);
+		}
+		OS.g_free (iter);
+		return height;
+	}
+}
+
+/**
+ * Returns a (possibly empty) array of items contained in the
+ * receiver that are direct item children of the receiver.  These
+ * are the roots of the tree.
+ * <p>
+ * Note: This is not the actual structure used by the receiver
+ * to maintain its list of items, so modifying the array will
+ * not affect the receiver. 
+ * </p>
+ *
+ * @return the items
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public TreeItem [] getItems () {
+	checkWidget();
+	return getItems (0);
+}
+
+TreeItem [] getItems (int /*long*/ parent) {
+	int length = OS.gtk_tree_model_iter_n_children (modelHandle, parent);
+	TreeItem[] result = new TreeItem [length];
+	if (length == 0) return result;
+	if ((style & SWT.VIRTUAL) != 0) {
+		for (int i=0; i<length; i++) {
+			result [i] = _getItem (parent, i);
+		}
+	} else {
+		int i = 0;
+		int[] index = new int [1];
+		int /*long*/ iter = OS.g_malloc (OS.GtkTreeIter_sizeof ());
+		boolean valid = OS.gtk_tree_model_iter_children (modelHandle, iter, parent);
+		while (valid) {
+			OS.gtk_tree_model_get (modelHandle, iter, ID_COLUMN, index, -1);
+			result [i++] = items [index [0]];
+			valid = OS.gtk_tree_model_iter_next (modelHandle, iter);
+		}
+		OS.g_free (iter);
+	}
+	return result;
+}
+
+/**
+ * Returns <code>true</code> if the receiver's lines are visible,
+ * and <code>false</code> otherwise.
+ * <p>
+ * If one of the receiver's ancestors is not visible or some
+ * other condition makes the receiver not visible, this method
+ * may still indicate that it is considered visible even though
+ * it may not actually be showing.
+ * </p>
+ *
+ * @return the visibility state of the lines
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.1
+ */
+public boolean getLinesVisible() {
+	checkWidget();
+	return OS.gtk_tree_view_get_rules_hint (handle);
+}
+
+/**
+ * Returns the receiver's parent item, which must be a
+ * <code>TreeItem</code> or null when the receiver is a
+ * root.
+ *
+ * @return the receiver's parent item
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public TreeItem getParentItem () {
+	checkWidget ();
+	return null;
+}
+
+int /*long*/ getPixbufRenderer (int /*long*/ column) {
+	int /*long*/ list = OS.gtk_tree_view_column_get_cell_renderers (column);
+	if (list == 0) return 0;
+	int count = OS.g_list_length (list);
+	int /*long*/ pixbufRenderer = 0;
+	int i = 0;
+	while (i < count) {
+		int /*long*/ renderer = OS.g_list_nth_data (list, i);
+		 if (OS.GTK_IS_CELL_RENDERER_PIXBUF (renderer)) {
+			pixbufRenderer = renderer;
+			break;
+		}
+		i++;
+	}
+	OS.g_list_free (list);
+	return pixbufRenderer;
+}
+
+/**
+ * Returns an array of <code>TreeItem</code>s that are currently
+ * selected in the receiver. The order of the items is unspecified.
+ * An empty array indicates that no items are selected. 
+ * <p>
+ * Note: This is not the actual structure used by the receiver
+ * to maintain its selection, so modifying the array will
+ * not affect the receiver. 
+ * </p>
+ * @return an array representing the selection
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public TreeItem[] getSelection () {
+	checkWidget();
+	int /*long*/ selection = OS.gtk_tree_view_get_selection (handle);
+	if (OS.GTK_VERSION < OS.VERSION (2, 2, 0)) {
+		display.treeSelectionLength  = 0;
+		display.treeSelection = new int [items.length];
+		OS.gtk_tree_selection_selected_foreach (selection, display.treeSelectionProc, handle);
+		TreeItem [] result = new TreeItem [display.treeSelectionLength];
+		for (int i=0; i<result.length; i++) result [i] = items [display.treeSelection [i]];
+		return result;
+	}
+	/*
+	* Bug in GTK.  gtk_tree_selection_get_selected_rows() segmentation faults
+	* in versions smaller than 2.2.4 if the model is NULL.  The fix is
+	* to give a valid pointer instead.
+	*/
+	int /*long*/ [] model = OS.GTK_VERSION < OS.VERSION (2, 2, 4) ? new int /*long*/ [1] : null;
+	int /*long*/ list = OS.gtk_tree_selection_get_selected_rows (selection, model);
+	if (list != 0) {
+		int count = OS.g_list_length (list);
+		TreeItem [] treeSelection = new TreeItem [count];
+		int length = 0;
+		for (int i=0; i<count; i++) {
+			int /*long*/ data = OS.g_list_nth_data (list, i);
+			int /*long*/ iter = OS.g_malloc (OS.GtkTreeIter_sizeof ());
+			if (OS.gtk_tree_model_get_iter (modelHandle, iter, data)) {
+				treeSelection [length] = _getItem (iter);
+				length++;
+			}
+			OS.g_free (iter);
+		}
+		OS.g_list_free (list);
+		if (length < count) {
+			TreeItem [] temp = new TreeItem [length];
+			System.arraycopy(treeSelection, 0, temp, 0, length);
+			treeSelection = temp;
+		}
+		return treeSelection;
+	}
+	return new TreeItem [0];
+}
+	
+/**
+ * Returns the number of selected items contained in the receiver.
+ *
+ * @return the number of selected items
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getSelectionCount () {
+	checkWidget();
+	int /*long*/ selection = OS.gtk_tree_view_get_selection (handle);
+	if (OS.GTK_VERSION < OS.VERSION (2, 2, 0)) {
+		display.treeSelectionLength = 0;
+		display.treeSelection = null;
+		OS.gtk_tree_selection_selected_foreach (selection, display.treeSelectionProc, handle);
+		return display.treeSelectionLength;
+	}
+	return OS.gtk_tree_selection_count_selected_rows (selection);
+}
+
+/**
+ * Returns the column which shows the sort indicator for
+ * the receiver. The value may be null if no column shows
+ * the sort indicator.
+ *
+ * @return the sort indicator 
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see #setSortColumn(TreeColumn)
+ * 
+ * @since 3.2
+ */
+public TreeColumn getSortColumn () {
+	checkWidget ();
+	return sortColumn;
+}
+
+/**
+ * Returns the direction of the sort indicator for the receiver. 
+ * The value will be one of <code>UP</code>, <code>DOWN</code> 
+ * or <code>NONE</code>.
+ *
+ * @return the sort direction
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see #setSortDirection(int)
+ * 
+ * @since 3.2
+ */
+public int getSortDirection () {
+	checkWidget ();
+	return sortDirection;
+}
+
+int /*long*/ getTextRenderer (int /*long*/ column) {
+	int /*long*/ list = OS.gtk_tree_view_column_get_cell_renderers (column);
+	if (list == 0) return 0;
+	int count = OS.g_list_length (list);
+	int /*long*/ textRenderer = 0;
+	int i = 0;
+	while (i < count) {
+		int /*long*/ renderer = OS.g_list_nth_data (list, i);
+		 if (OS.GTK_IS_CELL_RENDERER_TEXT (renderer)) {
+			textRenderer = renderer;
+			break;
+		}
+		i++;
+	}
+	OS.g_list_free (list);
+	return textRenderer;
+}
+
+/**
+ * Returns the item which is currently at the top of the receiver.
+ * This item can change when items are expanded, collapsed, scrolled
+ * or new items are added or removed.
+ *
+ * @return the item at the top of the receiver 
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 2.1
+ */
+public TreeItem getTopItem () {
+	checkWidget ();
+	int /*long*/ [] path = new int /*long*/ [1];
+	OS.gtk_widget_realize (handle);
+	if (!OS.gtk_tree_view_get_path_at_pos (handle, 1, 1, path, null, null, null)) return null;
+	if (path [0] == 0) return null;
+	TreeItem item = null;
+	int /*long*/ iter = OS.g_malloc (OS.GtkTreeIter_sizeof());
+	if (OS.gtk_tree_model_get_iter (modelHandle, iter, path [0])) {
+		item = _getItem (iter);
+	}
+	OS.g_free (iter);
+	OS.gtk_tree_path_free (path [0]);
+	return item;
+}
+
+int /*long*/ gtk_button_press_event (int /*long*/ widget, int /*long*/ event) {
+	GdkEventButton gdkEvent = new GdkEventButton ();
+	OS.memmove (gdkEvent, event, GdkEventButton.sizeof);
+	if (gdkEvent.window != OS.gtk_tree_view_get_bin_window (handle)) return 0;
+	int /*long*/ result = super.gtk_button_press_event (widget, event);
+	if (result != 0) return result;
+	/*
+	* Feature in GTK.  In a multi-select tree view, when multiple items are already
+	* selected, the selection state of the item is toggled and the previous selection 
+	* is cleared. This is not the desired behaviour when bringing up a popup menu.
+	* Also, when an item is reselected with the right button, the tree view issues
+	* an unwanted selection event. The workaround is to detect that case and not
+	* run the default handler when the item is already part of the current selection.
+	*/
+	int button = gdkEvent.button;
+	if (button == 3 && gdkEvent.type == OS.GDK_BUTTON_PRESS) {
+		int /*long*/ [] path = new int /*long*/ [1];
+		if (OS.gtk_tree_view_get_path_at_pos (handle, (int)gdkEvent.x, (int)gdkEvent.y, path, null, null, null)) {
+			if (path [0] != 0) {
+				int /*long*/ selection = OS.gtk_tree_view_get_selection (handle);
+				if (OS.gtk_tree_selection_path_is_selected (selection, path [0])) result = 1;
+				OS.gtk_tree_path_free (path [0]);
+			}
+		}
+	}
+	
+	/*
+	* Feature in GTK.  When the user clicks in a single selection GtkTreeView
+	* and there are no selected items, the first item is selected automatically
+	* before the click is processed, causing two selection events.  The is fix
+	* is the set the cursor item to be same as the clicked item to stop the
+	* widget from automatically selecting the first item.
+	*/
+	if ((style & SWT.SINGLE) != 0 && getSelectionCount () == 0) {
+		int /*long*/ [] path = new int /*long*/ [1];
+		if (OS.gtk_tree_view_get_path_at_pos (handle, (int)gdkEvent.x, (int)gdkEvent.y, path, null, null, null)) {
+			if (path [0] != 0) {
+				int /*long*/ selection = OS.gtk_tree_view_get_selection (handle);
+				OS.g_signal_handlers_block_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+				OS.gtk_tree_view_set_cursor (handle, path [0], 0, false);
+				OS.g_signal_handlers_unblock_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+				OS.gtk_tree_path_free (path [0]);
+			}
+		}
+	}
+	/*
+	* Bug in GTK. GTK segments fault, if the GtkTreeView widget is
+	* not in focus and all items in the widget are disposed before
+	* it finishes processing a button press.  The fix is to give
+	* focus to the widget before it starts processing the event.
+	*/
+	if (!OS.GTK_WIDGET_HAS_FOCUS (handle)) {
+		OS.gtk_widget_grab_focus (handle);
+	}
+	return result;
+}
+
+int /*long*/ gtk_button_release_event (int /*long*/ widget, int /*long*/ event) {
+	int /*long*/ window = OS.GDK_EVENT_WINDOW (event);
+	if (window != OS.gtk_tree_view_get_bin_window (handle)) return 0;
+	return super.gtk_button_release_event (widget, event);
+}
+
+int /*long*/ gtk_changed (int /*long*/ widget) {
+	TreeItem item = getFocusItem ();
+	if (item != null) {
+		Event event = new Event ();
+		event.item = item;
+		postEvent (SWT.Selection, event);
+	}
+	return 0;
+}
+
+int /*long*/ gtk_expand_collapse_cursor_row (int /*long*/ widget, int /*long*/ logical, int /*long*/ expand, int /*long*/ open_all) {
+	// FIXME - this flag is never cleared.  It should be cleared when the expand all operation completes.
+	if (expand != 0 && open_all != 0) expandAll = true;
+	return 0;
+}
+
+int /*long*/ gtk_key_press_event (int /*long*/ widget, int /*long*/ eventPtr) {
+	int /*long*/ result = super.gtk_key_press_event (widget, eventPtr);
+	if (result != 0) return result;
+	if (OS.GTK_VERSION < OS.VERSION (2, 2 ,0)) {
+		/*
+		* Feature in GTK 2.0.x.  When an item is default selected using
+		* the return key, GTK does not issue notification. The fix is
+		* to issue this notification when the return key is pressed.
+		*/
+		GdkEventKey keyEvent = new GdkEventKey ();
+		OS.memmove (keyEvent, eventPtr, GdkEventKey.sizeof);
+		int key = keyEvent.keyval;
+		switch (key) {
+			case OS.GDK_Return:
+			case OS.GDK_KP_Enter: {
+				Event event = new Event ();
+				event.item = getFocusItem (); 
+				postEvent (SWT.DefaultSelection, event);
+				break;
+			}
+		}
+	}
+	return result;
+}
+
+int /*long*/ gtk_motion_notify_event (int /*long*/ widget, int /*long*/ event) {
+	int /*long*/ window = OS.GDK_EVENT_WINDOW (event);
+	if (window != OS.gtk_tree_view_get_bin_window (handle)) return 0;
+	return super.gtk_motion_notify_event (widget, event);
+}
+
+int /*long*/ gtk_popup_menu (int /*long*/ widget) {
+	int /*long*/ result = super.gtk_popup_menu (widget);
+	/*
+	* Bug in GTK.  The context menu for the typeahead in GtkTreeViewer
+	* opens in the bottom right corner of the screen when Shift+F10
+	* is pressed and the typeahead window was not visible.  The fix is
+	* to prevent the context menu from opening by stopping the default
+	* handler.
+	* 
+	* NOTE: The bug only happens in GTK 2.6.5 and lower.
+	*/
+	return OS.GTK_VERSION < OS.VERSION (2, 6, 5) ? 1 : result;
+}
+
+int /*long*/ gtk_row_activated (int /*long*/ tree, int /*long*/ path, int /*long*/ column) {
+	if (path == 0) return 0;
+	TreeItem item = null;
+	int /*long*/ iter = OS.g_malloc (OS.GtkTreeIter_sizeof ());
+	if (OS.gtk_tree_model_get_iter (modelHandle, iter, path)) {
+		int [] index = new int [1];
+		OS.gtk_tree_model_get (modelHandle, iter, ID_COLUMN, index, -1);
+		item = items [index [0]];
+	}
+	OS.g_free (iter);
+	Event event = new Event ();
+	event.item = item;
+	postEvent (SWT.DefaultSelection, event);
+	return 0;
+}
+
+int /*long*/ gtk_test_collapse_row (int /*long*/ tree, int /*long*/ iter, int /*long*/ path) {
+	int [] index = new int [1];
+	OS.gtk_tree_model_get (modelHandle, iter, ID_COLUMN, index, -1);
+	TreeItem item = items [index [0]];
+	Event event = new Event ();
+	event.item = item;
+	boolean oldModelChanged = modelChanged;
+	modelChanged = false;
+	sendEvent (SWT.Collapse, event);
+	/*
+	* Bug in GTK.  Collapsing the target row during the test_collapse_row
+	* handler will cause a segmentation fault if the animation code is allowed
+	* to run.  The fix is to block the animation if the row is already
+	* collapsed.
+	*/
+	boolean changed = modelChanged || !OS.gtk_tree_view_row_expanded (handle, path);
+	modelChanged = oldModelChanged;
+	if (isDisposed () || item.isDisposed ()) return 1;
+	/*
+	* Bug in GTK.  Expanding or collapsing a row which has no more
+	* children causes the model state to become invalid, causing
+	* GTK to give warnings and behave strangely.  Other changes to
+	* the model can cause expansion to fail when using the multiple
+	* expansion keys (such as *).  The fix is to stop the expansion
+	* if there are model changes.
+	* 
+	* Note: This callback must return 0 for the collapsing
+	* animation to occur.
+	*/
+	if (changed) {
+		OS.g_signal_handlers_block_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, TEST_COLLAPSE_ROW);
+		OS.gtk_tree_view_collapse_row (handle, path);
+		OS.g_signal_handlers_unblock_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, TEST_COLLAPSE_ROW);
+		return 1;
+	}
+	return 0;
+}
+
+int /*long*/ gtk_test_expand_row (int /*long*/ tree, int /*long*/ iter, int /*long*/ path) {
+	int [] index = new int [1];
+	OS.gtk_tree_model_get (modelHandle, iter, ID_COLUMN, index, -1);
+	TreeItem item = items [index [0]];
+	Event event = new Event ();
+	event.item = item;
+	boolean oldModelChanged = modelChanged;
+	modelChanged = false;
+	sendEvent (SWT.Expand, event);
+	/*
+	* Bug in GTK.  Expanding the target row during the test_expand_row
+	* handler will cause a segmentation fault if the animation code is allowed
+	* to run.  The fix is to block the animation if the row is already
+	* expanded.
+	*/
+	boolean changed = modelChanged || OS.gtk_tree_view_row_expanded (handle, path);
+	modelChanged = oldModelChanged;
+	if (isDisposed () || item.isDisposed ()) return 1;
+	/*
+	* Bug in GTK.  Expanding or collapsing a row which has no more
+	* children causes the model state to become invalid, causing
+	* GTK to give warnings and behave strangely.  Other changes to
+	* the model can cause expansion to fail when using the multiple
+	* expansion keys (such as *).  The fix is to stop the expansion
+	* if there are model changes.
+	* 
+	* Bug in GTK.  test-expand-row does not get called for each row
+	* in an expand all operation.  The fix is to block the initial
+	* expansion and only expand a single level.
+	* 
+	* Note: This callback must return 0 for the collapsing
+	* animation to occur.
+	*/
+	if (changed || expandAll) {
+		OS.g_signal_handlers_block_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, TEST_EXPAND_ROW);
+		OS.gtk_tree_view_expand_row (handle, path, false);
+		OS.g_signal_handlers_unblock_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, TEST_EXPAND_ROW);
+		return 1;
+	}
+	return 0;
+}
+
+int /*long*/ gtk_toggled (int /*long*/ renderer, int /*long*/ pathStr) {
+	int /*long*/ path = OS.gtk_tree_path_new_from_string (pathStr);
+	if (path == 0) return 0;
+	TreeItem item = null;
+	int /*long*/ iter = OS.g_malloc (OS.GtkTreeIter_sizeof());
+	if (OS.gtk_tree_model_get_iter (modelHandle, iter, path)) {
+		item = _getItem (iter);
+	}
+	OS.g_free (iter);
+	OS.gtk_tree_path_free (path);
+	if (item != null) {
+		item.setChecked (!item.getChecked ());
+		Event event = new Event ();
+		event.detail = SWT.CHECK;
+		event.item = item;
+		postEvent (SWT.Selection, event);
+	}
+	return 0;
+}
+
+void gtk_widget_size_request (int /*long*/ widget, GtkRequisition requisition) {
+	/*
+	 * Bug in GTK.  For some reason, gtk_widget_size_request() fails
+	 * to include the height of the tree view items when there are
+	 * no columns visible.  The fix is to temporarily make one column
+	 * visible. 
+	 */
+	if (columnCount == 0) {
+		super.gtk_widget_size_request (widget, requisition);
+		return;
+	}
+	int /*long*/ columns = OS.gtk_tree_view_get_columns (handle), list = columns;
+	boolean fixVisible = columns != 0;
+	while (list != 0) {
+		int /*long*/ column = OS.g_list_data (list);
+		if (OS.gtk_tree_view_column_get_visible (column)) {
+			fixVisible = false;
+			break;
+		}
+		list = OS.g_list_next (list);
+	}
+	int /*long*/ columnHandle = 0;
+	if (fixVisible) {
+		columnHandle = OS.g_list_data (columns);
+		OS.gtk_tree_view_column_set_visible (columnHandle, true);
+	}
+	super.gtk_widget_size_request (widget, requisition);
+	if (fixVisible) {
+		OS.gtk_tree_view_column_set_visible (columnHandle, false);
+	}
+	if (columns != 0) OS.g_list_free (columns);
+}
+
+void hideFirstColumn () {
+	int /*long*/ firstColumn = OS.gtk_tree_view_get_column (handle, 0);
+	OS.gtk_tree_view_column_set_visible (firstColumn, false);	
+}
+	
+void hookEvents () {
+	super.hookEvents ();
+	int /*long*/ selection = OS.gtk_tree_view_get_selection(handle);
+	OS.g_signal_connect_closure (selection, OS.changed, display.closures [CHANGED], false);
+	OS.g_signal_connect_closure (handle, OS.row_activated, display.closures [ROW_ACTIVATED], false);
+	OS.g_signal_connect_closure (handle, OS.test_expand_row, display.closures [TEST_EXPAND_ROW], false);
+	OS.g_signal_connect_closure (handle, OS.test_collapse_row, display.closures [TEST_COLLAPSE_ROW], false);
+	OS.g_signal_connect_closure (handle, OS.expand_collapse_cursor_row, display.closures [EXPAND_COLLAPSE_CURSOR_ROW], false);
+	if (checkRenderer != 0) {
+		OS.g_signal_connect_closure (checkRenderer, OS.toggled, display.closures [TOGGLED], false);
+	}
+}
+
+/**
+ * Searches the receiver's list starting at the first column
+ * (index 0) until a column is found that is equal to the 
+ * argument, and returns the index of that column. If no column
+ * is found, returns -1.
+ *
+ * @param column the search column
+ * @return the index of the column
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the column is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.1
+ */
+public int indexOf (TreeColumn column) {
+	checkWidget();
+	if (column == null) error (SWT.ERROR_NULL_ARGUMENT);
+	for (int i=0; i<columnCount; i++) {
+		if (columns [i] == column) return i;
+	}
+	return -1;
+}
+
+/**
+ * Searches the receiver's list starting at the first item
+ * (index 0) until an item is found that is equal to the 
+ * argument, and returns the index of that item. If no item
+ * is found, returns -1.
+ *
+ * @param item the search item
+ * @return the index of the item
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the item is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the item has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.1
+ */
+public int indexOf (TreeItem item) {
+	checkWidget();
+	if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if (item.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);
+	int index = -1;
+	int /*long*/ path = OS.gtk_tree_model_get_path (modelHandle, item.handle);
+	int depth = OS.gtk_tree_path_get_depth (path);
+	if (depth == 1) {
+		int /*long*/ indices = OS.gtk_tree_path_get_indices (path);
+		if (indices != 0) {	
+			int[] temp = new int[1];
+			OS.memmove (temp, indices, 4);
+			index = temp[0];
+		}
+	}
+	OS.gtk_tree_path_free (path);
+	return index;
+}
+
+boolean mnemonicHit (char key) {
+	for (int i=0; i<columnCount; i++) {
+		int /*long*/ labelHandle = columns [i].labelHandle;
+		if (labelHandle != 0 && mnemonicHit (labelHandle, key)) return true;
+	}
+	return false;
+}
+
+boolean mnemonicMatch (char key) {
+	for (int i=0; i<columnCount; i++) {
+		int /*long*/ labelHandle = columns [i].labelHandle;
+		if (labelHandle != 0 && mnemonicMatch (labelHandle, key)) return true;
+	}
+	return false;
+}
+
+int /*long*/ paintWindow () {
+	OS.gtk_widget_realize (handle);
+	return OS.gtk_tree_view_get_bin_window (handle);
+}
+
+void recreateRenderers () {
+	if (checkRenderer != 0) {
+		display.removeWidget (checkRenderer);
+		OS.g_object_unref (checkRenderer);
+		checkRenderer = ownerDraw ? OS.g_object_new (display.gtk_cell_renderer_toggle_get_type(), 0) : OS.gtk_cell_renderer_toggle_new ();
+		if (checkRenderer == 0) error (SWT.ERROR_NO_HANDLES);
+		OS.g_object_ref (checkRenderer);
+		display.addWidget (checkRenderer, this);
+		OS.g_signal_connect_closure (checkRenderer, OS.toggled, display.closures [TOGGLED], false);
+	}
+	if (columnCount == 0) {
+		createRenderers (OS.gtk_tree_view_get_column (handle, 0), Tree.FIRST_COLUMN, true, 0);
+	} else {
+		for (int i = 0; i < columnCount; i++) {
+			TreeColumn column = columns [i];
+			createRenderers (column.handle, column.modelIndex, i == 0, column.style);
+		}
+	}
+}
+
+void redrawBackgroundImage () {
+	Control control = findBackgroundControl ();
+	if (control != null && control.backgroundImage != null) {
+		redrawWidget (0, 0, 0, 0, true, false, false);
+	}
+}
+
+void register () {
+	super.register ();
+	display.addWidget (OS.gtk_tree_view_get_selection (handle), this);
+	if (checkRenderer != 0) display.addWidget (checkRenderer, this);
+}
+
+void releaseItem (TreeItem item, boolean release) {
+	int [] index = new int [1];
+	OS.gtk_tree_model_get (modelHandle, item.handle, ID_COLUMN, index, -1);
+	if (index [0] == -1) return;
+	if (release) item.release (false);
+	items [index [0]] = null;
+}
+
+void releaseItems (int /*long*/ parentIter) {
+	int[] index = new int [1];
+	int /*long*/ iter = OS.g_malloc (OS.GtkTreeIter_sizeof ());
+	boolean valid = OS.gtk_tree_model_iter_children (modelHandle, iter, parentIter);
+	while (valid) {
+		releaseItems (iter);
+		if (!isDisposed ()) {
+			OS.gtk_tree_model_get (modelHandle, iter, ID_COLUMN, index, -1);
+			if (index [0] != -1) {
+				TreeItem item = items [index [0]];
+				if (item != null) releaseItem (item, true);
+			}
+		}
+		valid = OS.gtk_tree_model_iter_next (modelHandle, iter);
+	}
+	OS.g_free (iter);
+}
+
+void releaseChildren (boolean destroy) {
+	if (items != null) {
+		for (int i=0; i<items.length; i++) {
+			TreeItem item = items [i];
+			if (item != null && !item.isDisposed ()) {
+				item.release (false);
+			}
+		}
+		items = null;
+	}
+	if (columns != null) {
+		for (int i=0; i<columnCount; i++) {
+			TreeColumn column = columns [i];
+			if (column != null && !column.isDisposed ()) {
+				column.release (false);
+			}
+		}
+		columns = null;
+	}
+	super.releaseChildren (destroy);
+}
+
+void releaseWidget () {
+	super.releaseWidget ();
+	if (modelHandle != 0) OS.g_object_unref (modelHandle);
+	modelHandle = 0;
+	if (checkRenderer != 0) OS.g_object_unref (checkRenderer);
+	checkRenderer = 0;
+	if (imageList != null) imageList.dispose ();
+	if (headerImageList != null) headerImageList.dispose ();
+	imageList = headerImageList = null;
+	currentItem = null;
+}
+
+void remove (int /*long*/ parentIter, int start, int end) {
+	if (start > end) return;
+	int itemCount = OS.gtk_tree_model_iter_n_children (modelHandle, parentIter);
+	if (!(0 <= start && start <= end && end < itemCount)) {
+		error (SWT.ERROR_INVALID_RANGE);
+	}
+	int /*long*/ selection = OS.gtk_tree_view_get_selection (handle);
+	int /*long*/ iter = OS.g_malloc (OS.GtkTreeIter_sizeof ());
+	int index = start;
+	for (int i = start; i <= end; i++) {
+		OS.gtk_tree_model_iter_nth_child (modelHandle, iter, parentIter, index);
+		int[] value = new int[1];
+		OS.gtk_tree_model_get (modelHandle, iter, ID_COLUMN, value, -1);
+		TreeItem item = value [0] != -1 ? items [value [0]] : null;
+		if (item != null && !item.isDisposed ()) {
+			item.dispose ();
+		} else {
+			OS.g_signal_handlers_block_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+			OS.gtk_tree_store_remove (modelHandle, iter);
+			OS.g_signal_handlers_unblock_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+		}
+	}
+	OS.g_free (iter);
+}
+
+/**
+ * Removes all of the items from the receiver.
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void removeAll () {
+	checkWidget ();
+	for (int i=0; i<items.length; i++) {
+		TreeItem item = items [i];
+		if (item != null && !item.isDisposed ()) item.release (false);
+	}
+	items = new TreeItem[4];
+	int /*long*/ selection = OS.gtk_tree_view_get_selection (handle);
+	OS.g_signal_handlers_block_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+	OS.gtk_tree_store_clear (modelHandle);
+	OS.g_signal_handlers_unblock_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+	
+	/* Disable searching when using VIRTUAL */
+	if ((style & SWT.VIRTUAL) != 0) {
+		/*
+		* Bug in GTK. Until GTK 2.6.5, calling gtk_tree_view_set_enable_search(FALSE)
+		* would prevent the user from being able to type in text to search the tree.
+		* After 2.6.5, GTK introduced Ctrl+F as being the key binding for interactive
+		* search. This meant that even if FALSE was passed to enable_search, the user
+		* can still bring up the search pop up using the keybinding. GTK also introduced
+		* the notion of passing a -1 to gtk_set_search_column to disable searching
+		* (including the search key binding).  The fix is to use the right calls
+		* for the right version.
+		*/
+		if (OS.GTK_VERSION >= OS.VERSION (2, 6, 5)) {
+			OS.gtk_tree_view_set_search_column (handle, -1); 
+		} else {
+			OS.gtk_tree_view_set_enable_search (handle, false);
+		}
+	} else {
+		/* Set the search column whenever the model changes */
+		int firstColumn = columnCount == 0 ? FIRST_COLUMN : columns [0].modelIndex;
+		OS.gtk_tree_view_set_search_column (handle, firstColumn + CELL_TEXT);
+	}
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the user changes the receiver's selection.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #addSelectionListener
+ */
+public void removeSelectionListener (SelectionListener listener) {
+	checkWidget ();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	eventTable.unhook (SWT.Selection, listener);
+	eventTable.unhook (SWT.DefaultSelection, listener);	
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when items in the receiver are expanded or collapsed.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see TreeListener
+ * @see #addTreeListener
+ */
+public void removeTreeListener(TreeListener listener) {
+	checkWidget ();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if (eventTable == null) return;
+	eventTable.unhook (SWT.Expand, listener);
+	eventTable.unhook (SWT.Collapse, listener);
+}
+
+int /*long*/ rendererGetSizeProc (int /*long*/ cell, int /*long*/ widget, int /*long*/ cell_area, int /*long*/ x_offset, int /*long*/ y_offset, int /*long*/ width, int /*long*/ height) {
+	int /*long*/ g_class = OS.g_type_class_peek_parent (OS.G_OBJECT_GET_CLASS (cell));
+	GtkCellRendererClass klass = new GtkCellRendererClass ();
+	OS.memmove (klass, g_class);
+	int /*long*/ result = OS.call (klass.get_size, cell, handle, cell_area, x_offset, y_offset, width, height);
+	if (!ignoreSize && OS.GTK_IS_CELL_RENDERER_TEXT (cell)) {
+		int /*long*/ iter = OS.g_object_get_qdata (cell, Display.SWT_OBJECT_INDEX2);
+		TreeItem item = null;
+		if (iter != 0) item = _getItem (iter);
+		if (item != null) {
+			int columnIndex = 0;
+			if (columnCount > 0) {
+				int /*long*/ columnHandle = OS.g_object_get_qdata (cell, Display.SWT_OBJECT_INDEX1);
+				for (int i = 0; i < columnCount; i++) {
+					if (columns [i].handle == columnHandle) {
+						columnIndex = i;
+						break;
+					}				
+				}
+			}
+			if (hooks (SWT.MeasureItem)) {
+				int [] contentWidth = new int [1], contentHeight = new int  [1];
+				if (width != 0) OS.memmove (contentWidth, width, 4);
+				if (height != 0) OS.memmove (contentHeight, height, 4);
+				Image image = item.getImage (columnIndex);
+				int imageWidth = 0;
+				if (image != null) {
+					Rectangle bounds = image.getBounds ();
+					imageWidth = bounds.width;
+				}
+				contentWidth [0] += imageWidth;
+				GC gc = new GC (this);
+				gc.setFont (item.getFont (columnIndex));
+				Event event = new Event ();
+				event.item = item;
+				event.index = columnIndex;
+				event.gc = gc;
+				event.width = contentWidth [0];
+				event.height = contentHeight [0];
+				sendEvent (SWT.MeasureItem, event);
+				gc.dispose ();
+				contentWidth [0] = event.width - imageWidth;
+				if (contentHeight [0] < event.height) contentHeight [0] = event.height;
+				if (width != 0) OS.memmove (width, contentWidth, 4);
+				if (height != 0) OS.memmove (height, contentHeight, 4);
+			}
+		}
+	}
+	return result;
+}
+
+int /*long*/ rendererRenderProc (int /*long*/ cell, int /*long*/ window, int /*long*/ widget, int /*long*/ background_area, int /*long*/ cell_area, int /*long*/ expose_area, int /*long*/ flags) {
+	TreeItem item = null;
+	int /*long*/ iter = OS.g_object_get_qdata (cell, Display.SWT_OBJECT_INDEX2);
+	if (iter != 0) item = _getItem (iter);
+	int /*long*/ columnHandle = OS.g_object_get_qdata (cell, Display.SWT_OBJECT_INDEX1);
+	int columnIndex = 0;
+	if (columnCount > 0) {
+		for (int i = 0; i < columnCount; i++) {
+			if (columns [i].handle == columnHandle) {
+				columnIndex = i;
+				break;
+			}				
+		}
+	}
+	if (item != null) {
+		if (OS.GTK_IS_CELL_RENDERER_TOGGLE (cell) || (OS.GTK_IS_CELL_RENDERER_PIXBUF (cell) && (columnIndex != 0 || (style & SWT.CHECK) == 0))) {
+			drawFlags = (int)/*64*/flags;
+			drawState = SWT.FOREGROUND;
+			int /*long*/ [] ptr = new int /*long*/ [1];
+			OS.gtk_tree_model_get (modelHandle, item.handle, Tree.BACKGROUND_COLUMN, ptr, -1);
+			if (ptr [0] == 0) {
+				int modelIndex = columnCount == 0 ? Tree.FIRST_COLUMN : columns [columnIndex].modelIndex;
+				OS.gtk_tree_model_get (modelHandle, item.handle, modelIndex + Tree.CELL_BACKGROUND, ptr, -1);
+			}
+			if (ptr [0] != 0) drawState |= SWT.BACKGROUND;
+			if ((flags & OS.GTK_CELL_RENDERER_SELECTED) != 0) drawState |= SWT.SELECTED;
+			if ((flags & OS.GTK_CELL_RENDERER_FOCUSED) != 0) drawState |= SWT.FOCUSED;			
+			
+			GdkRectangle rect = new GdkRectangle ();
+			int /*long*/ path = OS.gtk_tree_model_get_path (modelHandle, iter);
+			OS.gtk_tree_view_get_background_area (handle, path, columnHandle, rect);
+			OS.gtk_tree_path_free (path);
+			
+			if ((drawState & SWT.SELECTED) == 0) {
+				Control control = findBackgroundControl ();
+				if (control != null && control.backgroundImage != null) {
+					OS.gdk_window_clear_area (window, rect.x, rect.y, rect.width, rect.height);
+				}
+			}
+
+			if (hooks (SWT.EraseItem)) {
+				boolean wasSelected = false; 
+				if ((drawState & SWT.SELECTED) != 0) {
+					wasSelected = true;
+					OS.gdk_window_clear_area (window, rect.x, rect.y, rect.width, rect.height);
+				}
+				GC gc = new GC (this);
+				if ((drawState & SWT.SELECTED) != 0) {
+					gc.setBackground (display.getSystemColor (SWT.COLOR_LIST_SELECTION));
+					gc.setForeground (display.getSystemColor (SWT.COLOR_LIST_SELECTION_TEXT));
+				} else {
+					gc.setBackground (item.getBackground (columnIndex));
+					gc.setForeground (item.getForeground (columnIndex));
+				}
+				gc.setFont (item.getFont (columnIndex));
+				if ((style & SWT.MIRRORED) != 0) rect.x = getClientWidth () - rect.width - rect.x;
+				gc.setClipping (rect.x, rect.y, rect.width, rect.height);
+				Event event = new Event ();
+				event.item = item;
+				event.index = columnIndex;
+				event.gc = gc;
+				event.x = rect.x;
+				event.y = rect.y;
+				event.width = rect.width;
+				event.height = rect.height;
+				event.detail = drawState;
+				sendEvent (SWT.EraseItem, event);
+				drawForeground = null;
+				drawState = event.doit ? event.detail : 0;
+				drawFlags &= ~(OS.GTK_CELL_RENDERER_FOCUSED | OS.GTK_CELL_RENDERER_SELECTED);
+				if ((drawState & SWT.SELECTED) != 0) drawFlags |= OS.GTK_CELL_RENDERER_SELECTED;
+				if ((drawState & SWT.FOCUSED) != 0) drawFlags |= OS.GTK_CELL_RENDERER_FOCUSED;
+				if ((drawState & SWT.SELECTED) != 0) {
+					int /*long*/ style = OS.gtk_widget_get_style (widget);					
+					//TODO - parity and sorted
+					byte[] detail = Converter.wcsToMbcs (null, "cell_odd", true);
+					OS.gtk_paint_flat_box (style, window, OS.GTK_STATE_SELECTED, OS.GTK_SHADOW_NONE, rect, widget, detail, rect.x, rect.y, rect.width, rect.height);
+				} else {
+					if (wasSelected) drawForeground = gc.getForeground ().handle;
+				}
+				gc.dispose();
+			}
+		}
+	}
+	int /*long*/ result = 0;
+	if ((drawState & SWT.BACKGROUND) != 0 && (drawState & SWT.SELECTED) == 0) {
+		GC gc = new GC (this);
+		gc.setBackground (item.getBackground (columnIndex));
+		GdkRectangle rect = new GdkRectangle ();
+		OS.memmove (rect, background_area, GdkRectangle.sizeof);
+		gc.fillRectangle (rect.x, rect.y, rect.width, rect.height);
+		gc.dispose ();
+	}
+	if ((drawState & SWT.FOREGROUND) != 0 || OS.GTK_IS_CELL_RENDERER_TOGGLE (cell)) {
+		int /*long*/ g_class = OS.g_type_class_peek_parent (OS.G_OBJECT_GET_CLASS (cell));
+		GtkCellRendererClass klass = new GtkCellRendererClass ();
+		OS.memmove (klass, g_class);
+		if (drawForeground != null && OS.GTK_IS_CELL_RENDERER_TEXT (cell)) {
+			OS.g_object_set (cell, OS.foreground_gdk, drawForeground, 0);
+		}
+		result = OS.call (klass.render, cell, window, handle, background_area, cell_area, expose_area, drawFlags);
+	}
+	if (item != null) {
+		if (OS.GTK_IS_CELL_RENDERER_TEXT (cell)) {
+			if (hooks (SWT.PaintItem)) {
+				GdkRectangle rect = new GdkRectangle ();
+				int /*long*/ path = OS.gtk_tree_model_get_path (modelHandle, iter);
+				OS.gtk_tree_view_get_cell_area (handle, path, columnHandle, rect);
+				OS.gtk_tree_path_free (path);
+				if (OS.GTK_VERSION < OS.VERSION (2, 8, 18) && OS.gtk_tree_view_get_expander_column (handle) == columnHandle) {
+					int [] buffer = new int [1];
+					OS.gtk_widget_style_get (handle, OS.expander_size, buffer, 0);
+					rect.x += buffer [0] + TreeItem.EXPANDER_EXTRA_PADDING;
+					rect.width -= buffer [0] + TreeItem.EXPANDER_EXTRA_PADDING;
+					//OS.gtk_widget_style_get (handle, OS.horizontal_separator, buffer, 0);
+					//rect.x += buffer[0];
+					//rect.width -= buffer [0]; // TODO Is this required for some versions?
+				}
+				ignoreSize = true;
+				int [] contentX = new int [1], contentWidth = new int [1];
+				OS.gtk_cell_renderer_get_size (cell, handle, null, null, null, contentWidth, null);
+				OS.gtk_tree_view_column_cell_get_position (columnHandle, cell, contentX, null);
+				ignoreSize = false;
+				Image image = item.getImage (columnIndex);
+				int imageWidth = 0;
+				if (image != null) {
+					Rectangle bounds = image.getBounds ();
+					imageWidth = bounds.width;
+				}
+				contentX [0] -= imageWidth;
+				contentWidth [0] += imageWidth;
+				GC gc = new GC (this);
+				if ((drawState & SWT.SELECTED) != 0) {
+					gc.setBackground (display.getSystemColor (SWT.COLOR_LIST_SELECTION));
+					gc.setForeground (display.getSystemColor (SWT.COLOR_LIST_SELECTION_TEXT));
+				} else {
+					gc.setBackground (item.getBackground (columnIndex));
+					Color foreground = drawForeground != null ? Color.gtk_new (display, drawForeground) : item.getForeground (columnIndex);
+					gc.setForeground (foreground);
+				}
+				gc.setFont (item.getFont (columnIndex));
+				if ((style & SWT.MIRRORED) != 0) rect.x = getClientWidth () - rect.width - rect.x;
+				gc.setClipping (rect.x, rect.y, rect.width, rect.height);
+				Event event = new Event ();
+				event.item = item;
+				event.index = columnIndex;
+				event.gc = gc;
+				event.x = rect.x + contentX [0];
+				event.y = rect.y;
+				event.width = contentWidth [0];
+				event.height = rect.height;
+				event.detail = drawState;
+				sendEvent (SWT.PaintItem, event);	
+				gc.dispose();
+			}
+		}
+	}
+	return result;
+}
+
+void resetCustomDraw () {
+	if ((style & SWT.VIRTUAL) != 0 || ownerDraw) return;
+	int end = Math.max (1, columnCount);
+	for (int i=0; i<end; i++) {
+		boolean customDraw = columnCount != 0 ? columns [i].customDraw : firstCustomDraw;
+		if (customDraw) {
+			int /*long*/ column = OS.gtk_tree_view_get_column (handle, i);
+			int /*long*/ textRenderer = getTextRenderer (column);
+			OS.gtk_tree_view_column_set_cell_data_func (column, textRenderer, 0, 0, 0);
+			if (columnCount != 0) columns [i].customDraw = false;
+		}
+	}
+	firstCustomDraw = false;
+}
+
+/**
+ * Display a mark indicating the point at which an item will be inserted.
+ * The drop insert item has a visual hint to show where a dragged item 
+ * will be inserted when dropped on the tree.
+ * 
+ * @param item the insert item.  Null will clear the insertion mark.
+ * @param before true places the insert mark above 'item'. false places 
+ *	the insert mark below 'item'.
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the item has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setInsertMark (TreeItem item, boolean before) {
+	checkWidget ();
+	if (item == null) {
+		OS.gtk_tree_view_set_drag_dest_row(handle, 0, OS.GTK_TREE_VIEW_DROP_BEFORE);
+		return;
+	}
+	if (item.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);
+	if (item.parent != this) return;
+	Rectangle rect = item.getBounds();
+	int /*long*/ [] path = new int /*long*/ [1];
+	OS.gtk_widget_realize (handle);
+	if (!OS.gtk_tree_view_get_path_at_pos(handle, rect.x, rect.y, path, null, null, null)) return;
+	if (path [0] == 0) return;
+	int position = before ? OS.GTK_TREE_VIEW_DROP_BEFORE : OS.GTK_TREE_VIEW_DROP_AFTER;
+	OS.gtk_tree_view_set_drag_dest_row(handle, path[0], position);
+	OS.gtk_tree_path_free (path [0]);
+}
+
+void setItemCount (int /*long*/ parentIter, int count) {
+	int itemCount = OS.gtk_tree_model_iter_n_children (modelHandle, parentIter);
+	if (count == itemCount) return;
+	boolean isVirtual = (style & SWT.VIRTUAL) != 0;
+	if (!isVirtual) setRedraw (false);
+	remove (parentIter, count, itemCount - 1);
+	if (isVirtual) {
+		for (int i=itemCount; i<count; i++) {
+			int /*long*/ iter = OS.g_malloc (OS.GtkTreeIter_sizeof ());
+			if (iter == 0) error (SWT.ERROR_NO_HANDLES);
+			OS.gtk_tree_store_append (modelHandle, iter, parentIter);
+			OS.gtk_tree_store_set (modelHandle, iter, ID_COLUMN, -1, -1);
+			OS.g_free (iter);
+		}
+	} else {
+		for (int i=itemCount; i<count; i++) {
+			new TreeItem (this, parentIter, SWT.NONE, i, true);
+		}
+	}
+	if (!isVirtual) setRedraw (true);
+	modelChanged = true;
+}
+
+/**
+ * Sets the number of root-level items contained in the receiver.
+ *
+ * @param count the number of items
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 3.2
+ */
+public void setItemCount (int count) {
+	checkWidget ();
+	count = Math.max (0, count);
+	setItemCount (0, count);
+}
+
+/**
+ * Selects an item in the receiver.  If the item was already
+ * selected, it remains selected.
+ *
+ * @param item the item to be selected
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the item is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the item has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 3.4
+ */
+public void select (TreeItem item) {
+	checkWidget ();
+	if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if (item.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT);
+	boolean fixColumn = showFirstColumn ();
+	int /*long*/ selection = OS.gtk_tree_view_get_selection (handle);
+	OS.g_signal_handlers_block_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+	OS.gtk_tree_selection_select_iter (selection, item.handle);
+	OS.g_signal_handlers_unblock_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+	if (fixColumn) hideFirstColumn ();
+}
+
+/**
+ * Selects all of the items in the receiver.
+ * <p>
+ * If the receiver is single-select, do nothing.
+ * </p>
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void selectAll () {
+	checkWidget();
+	if ((style & SWT.SINGLE) != 0) return;
+	boolean fixColumn = showFirstColumn ();
+	int /*long*/ selection = OS.gtk_tree_view_get_selection (handle);
+	OS.g_signal_handlers_block_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+	OS.gtk_tree_selection_select_all (selection);
+	OS.g_signal_handlers_unblock_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+	if (fixColumn) hideFirstColumn ();
+}
+
+void setBackgroundColor (GdkColor color) {
+	super.setBackgroundColor (color);
+	OS.gtk_widget_modify_base (handle, 0, color);
+}
+
+void setBackgroundPixmap (int /*long*/ pixmap) {
+	super.setBackgroundPixmap (pixmap);
+	int /*long*/ window = paintWindow ();
+	if (window != 0) OS.gdk_window_set_back_pixmap (window, 0, true);	
+}
+
+int setBounds (int x, int y, int width, int height, boolean move, boolean resize) {
+	int result = super.setBounds (x, y, width, height, move, resize);
+	/*
+	* Bug on GTK.  The tree view sometimes does not get a paint
+	* event or resizes to a one pixel square when resized in a new
+	* shell that is not visible after any event loop has been run.  The
+	* problem is intermittent. It doesn't seem to happen the first time
+	* a new shell is created. The fix is to ensure the tree view is realized
+	* after it has been resized.
+	*/
+	OS.gtk_widget_realize (handle);
+	/*
+	* Bug in GTK.  An empty GtkTreeView fails to repaint the focus rectangle
+	* correctly when resized on versions before 2.6.0.  The fix is to force
+	* the widget to redraw.
+	*/
+	if (OS.GTK_VERSION < OS.VERSION (2, 6, 0) && OS.gtk_tree_model_iter_n_children (modelHandle, 0) == 0) {
+		redraw (false);
+	}
+	return result;
+}
+
+/**
+ * Sets the order that the items in the receiver should 
+ * be displayed in to the given argument which is described
+ * in terms of the zero-relative ordering of when the items
+ * were added.
+ *
+ * @param order the new order to display the items
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the item order is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the item order is not the same length as the number of items</li>
+ * </ul>
+ * 
+ * @see Tree#getColumnOrder()
+ * @see TreeColumn#getMoveable()
+ * @see TreeColumn#setMoveable(boolean)
+ * @see SWT#Move
+ * 
+ * @since 3.2
+ */
+public void setColumnOrder (int [] order) {
+	checkWidget ();
+	if (order == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if (columnCount == 0) {
+		if (order.length > 0) error (SWT.ERROR_INVALID_ARGUMENT);
+		return;
+	}
+	if (order.length != columnCount) error (SWT.ERROR_INVALID_ARGUMENT);
+	boolean [] seen = new boolean [columnCount];
+	for (int i = 0; i<order.length; i++) {
+		int index = order [i];
+		if (index < 0 || index >= columnCount) error (SWT.ERROR_INVALID_RANGE);
+		if (seen [index]) error (SWT.ERROR_INVALID_ARGUMENT);
+		seen [index] = true;
+	}
+	int /*long*/ baseColumn = 0;
+	for (int i=0; i<order.length; i++) {
+		int /*long*/ column = columns [order [i]].handle;
+		OS.gtk_tree_view_move_column_after (handle, column, baseColumn);
+		baseColumn = column;
+	}
+}
+
+void setFontDescription (int /*long*/ font) {
+	super.setFontDescription (font);
+	TreeColumn[] columns = getColumns ();
+	for (int i = 0; i < columns.length; i++) {
+		if (columns[i] != null) {
+			columns[i].setFontDescription (font);
+		}
+	}
+}
+
+/**
+ * Marks the receiver's header as visible if the argument is <code>true</code>,
+ * and marks it invisible otherwise. 
+ * <p>
+ * If one of the receiver's ancestors is not visible or some
+ * other condition makes the receiver not visible, marking
+ * it visible may not actually cause it to be displayed.
+ * </p>
+ *
+ * @param show the new visibility state
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.1
+ */
+public void setHeaderVisible (boolean show) {
+	checkWidget ();
+	OS.gtk_tree_view_set_headers_visible (handle, show);
+}
+
+/**
+ * Marks the receiver's lines as visible if the argument is <code>true</code>,
+ * and marks it invisible otherwise. 
+ * <p>
+ * If one of the receiver's ancestors is not visible or some
+ * other condition makes the receiver not visible, marking
+ * it visible may not actually cause it to be displayed.
+ * </p>
+ *
+ * @param show the new visibility state
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.1
+ */
+public void setLinesVisible (boolean show) {
+	checkWidget();
+	OS.gtk_tree_view_set_rules_hint (handle, show);
+}
+
+void setParentBackground () {
+	super.setParentBackground ();
+	int /*long*/ window = paintWindow ();
+	if (window != 0) OS.gdk_window_set_back_pixmap (window, 0, true);
+}
+
+void setParentWindow (int /*long*/ widget) {
+	int /*long*/ window = eventWindow ();
+	OS.gtk_widget_set_parent_window (widget, window);
+}
+
+void setScrollWidth (int /*long*/ column, TreeItem item) {
+	if (columnCount != 0 || currentItem == item) return;
+	/*
+	* Use GTK_TREE_VIEW_COLUMN_GROW_ONLY on GTK versions < 2.3.2
+	* because fixed_height_mode is not supported.
+	*/
+	if (((style & SWT.VIRTUAL) != 0) && OS.GTK_VERSION < OS.VERSION (2, 3, 2)) return;
+	int width = OS.gtk_tree_view_column_get_fixed_width (column);
+	int itemWidth = calculateWidth (column, item.handle, true);
+	if (width < itemWidth) {
+		OS.gtk_tree_view_column_set_fixed_width (column, itemWidth);
+	}
+}
+
+/**
+ * Sets the receiver's selection to the given item.
+ * The current selection is cleared before the new item is selected.
+ * <p>
+ * If the item is not in the receiver, then it is ignored.
+ * </p>
+ *
+ * @param item the item to select
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the item is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the item has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.2
+ */
+public void setSelection (TreeItem item) {
+	checkWidget ();
+	if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
+	setSelection (new TreeItem [] {item});
+}
+
+/**
+ * Sets the receiver's selection to be the given array of items.
+ * The current selection is cleared before the new items are selected.
+ * <p>
+ * Items that are not in the receiver are ignored.
+ * If the receiver is single-select and multiple items are specified,
+ * then all items are ignored.
+ * </p>
+ *
+ * @param items the array of items
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the array of items is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if one of the items has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see Tree#deselectAll()
+ */
+public void setSelection (TreeItem [] items) {
+	checkWidget ();
+	if (items == null) error (SWT.ERROR_NULL_ARGUMENT);
+	deselectAll ();
+	int length = items.length;
+	if (length == 0 || ((style & SWT.SINGLE) != 0 && length > 1)) return;
+	boolean fixColumn = showFirstColumn ();
+	int /*long*/ selection = OS.gtk_tree_view_get_selection (handle);
+	OS.g_signal_handlers_block_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+	boolean first = true;
+	for (int i = 0; i < length; i++) {
+		TreeItem item = items [i];
+		if (item == null) continue;
+		if (item.isDisposed ()) break;
+		if (item.parent != this) continue;
+		int /*long*/ path = OS.gtk_tree_model_get_path (modelHandle, item.handle);
+		showItem (path, false);
+		if (first) {
+			OS.gtk_tree_view_set_cursor (handle, path, 0, false);
+		}
+		OS.gtk_tree_selection_select_iter (selection, item.handle);
+		OS.gtk_tree_path_free (path);
+		first = false;
+	}
+	OS.g_signal_handlers_unblock_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+	if (fixColumn) hideFirstColumn ();
+}
+
+/**
+ * Sets the column used by the sort indicator for the receiver. A null
+ * value will clear the sort indicator.  The current sort column is cleared 
+ * before the new column is set.
+ *
+ * @param column the column used by the sort indicator or <code>null</code>
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the column is disposed</li> 
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.2
+ */
+public void setSortColumn (TreeColumn column) {
+	checkWidget ();
+	if (column != null && column.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT);
+	if (sortColumn != null && !sortColumn.isDisposed()) {
+		OS.gtk_tree_view_column_set_sort_indicator (sortColumn.handle, false);
+	}
+	sortColumn = column;
+	if (sortColumn != null && sortDirection != SWT.NONE) {
+		OS.gtk_tree_view_column_set_sort_indicator (sortColumn.handle, true);
+		OS.gtk_tree_view_column_set_sort_order (sortColumn.handle, sortDirection == SWT.DOWN ? 0 : 1);
+	}
+}
+
+/**
+ * Sets the direction of the sort indicator for the receiver. The value 
+ * can be one of <code>UP</code>, <code>DOWN</code> or <code>NONE</code>.
+ *
+ * @param direction the direction of the sort indicator 
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.2
+ */
+public void setSortDirection  (int direction) {
+	checkWidget ();
+	if (direction != SWT.UP && direction != SWT.DOWN && direction != SWT.NONE) return;
+	sortDirection = direction;
+	if (sortColumn == null || sortColumn.isDisposed ()) return;
+	if (sortDirection == SWT.NONE) {
+		OS.gtk_tree_view_column_set_sort_indicator (sortColumn.handle, false);
+	} else {
+		OS.gtk_tree_view_column_set_sort_indicator (sortColumn.handle, true);
+		OS.gtk_tree_view_column_set_sort_order (sortColumn.handle, sortDirection == SWT.DOWN ? 0 : 1);
+	}
+}
+
+/**
+ * Sets the item which is currently at the top of the receiver.
+ * This item can change when items are expanded, collapsed, scrolled
+ * or new items are added or removed.
+ *
+ * @param item the item to be shown
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the item is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the item has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see Tree#getTopItem()
+ * 
+ * @since 2.1
+ */
+public void setTopItem (TreeItem item) {
+	if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if (item.isDisposed ()) error(SWT.ERROR_INVALID_ARGUMENT);
+	if (item.parent != this) return;
+	int /*long*/ path = OS.gtk_tree_model_get_path (modelHandle, item.handle);
+	showItem (path, false);
+	OS.gtk_tree_view_scroll_to_cell (handle, path, 0, true, 0f, 0f);
+	if (OS.GTK_VERSION < OS.VERSION (2, 8, 0)) {
+		/*
+		* Bug in GTK.  According to the documentation, gtk_tree_view_scroll_to_cell
+		* should vertically scroll the cell to the top if use_align is true and row_align is 0.
+		* However, prior to version 2.8 it does not scroll at all.  The fix is to determine
+		* the new location and use gtk_tree_view_scroll_to_point.
+		* If the widget is a pinhead, calling gtk_tree_view_scroll_to_point
+		* will have no effect. Therefore, it is still neccessary to call 
+		* gtk_tree_view_scroll_to_cell.
+		*/
+		OS.gtk_widget_realize (handle);
+		GdkRectangle cellRect = new GdkRectangle ();
+		OS.gtk_tree_view_get_cell_area (handle, path, 0, cellRect);
+		int[] tx = new int[1], ty = new int[1];
+		OS.gtk_tree_view_widget_to_tree_coords(handle, cellRect.x, cellRect.y, tx, ty);
+		OS.gtk_tree_view_scroll_to_point (handle, -1, ty[0]);
+	}
+	OS.gtk_tree_path_free (path);
+}
+
+/**
+ * Shows the column.  If the column is already showing in the receiver,
+ * this method simply returns.  Otherwise, the columns are scrolled until
+ * the column is visible.
+ *
+ * @param column the column to be shown
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the item is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the item has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 3.1
+ */
+public void showColumn (TreeColumn column) {
+	checkWidget ();
+	if (column == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if (column.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
+	if (column.parent != this) return;
+	/*
+	* This code is intentionally commented. According to the
+	* documentation, gtk_tree_view_scroll_to_cell should scroll the
+	* minimum amount to show the column but instead it scrolls strangely.
+	*/
+	//OS.gtk_tree_view_scroll_to_cell (handle, 0, column.handle, false, 0, 0);
+	OS.gtk_widget_realize (handle);
+	GdkRectangle cellRect = new GdkRectangle ();
+	OS.gtk_tree_view_get_cell_area (handle, 0, column.handle, cellRect);
+	GdkRectangle visibleRect = new GdkRectangle ();
+	OS.gtk_tree_view_get_visible_rect (handle, visibleRect);
+	if (cellRect.x < visibleRect.x) {
+		OS.gtk_tree_view_scroll_to_point (handle, cellRect.x, -1);
+	} else {
+		int width = Math.min (visibleRect.width, cellRect.width);
+		if (cellRect.x + width > visibleRect.x + visibleRect.width) {
+			int tree_x = cellRect.x + width - visibleRect.width;
+			OS.gtk_tree_view_scroll_to_point (handle, tree_x, -1);
+		}
+	}
+}
+
+boolean showFirstColumn () {	
+	/*
+	* Bug in GTK.  If no columns are visible, changing the selection
+	* will fail.  The fix is to temporarily make a column visible. 
+	*/
+	int columnCount = Math.max (1, this.columnCount);
+	for (int i=0; i<columnCount; i++) {
+		int /*long*/ column = OS.gtk_tree_view_get_column (handle, i);
+		if (OS.gtk_tree_view_column_get_visible (column)) return false;
+	}
+	int /*long*/ firstColumn = OS.gtk_tree_view_get_column (handle, 0);
+	OS.gtk_tree_view_column_set_visible (firstColumn, true);
+	return true;
+}
+
+/**
+ * Shows the selection.  If the selection is already showing in the receiver,
+ * this method simply returns.  Otherwise, the items are scrolled until
+ * the selection is visible.
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see Tree#showItem(TreeItem)
+ */
+public void showSelection () {
+	checkWidget();
+	TreeItem [] items = getSelection ();
+	if (items.length != 0 && items [0] != null) showItem (items [0]);
+}
+
+void showItem (int /*long*/ path, boolean scroll) {
+	int depth = OS.gtk_tree_path_get_depth (path);
+	if (depth > 1) {
+		int [] indices = new int [depth - 1];
+		int /*long*/ indicesPtr = OS.gtk_tree_path_get_indices (path);
+		OS.memmove (indices, indicesPtr, indices.length * 4);
+		int /*long*/ tempPath = OS.gtk_tree_path_new ();
+		for (int i=0; i<indices.length; i++) {
+			OS.gtk_tree_path_append_index (tempPath, indices [i]);
+			OS.gtk_tree_view_expand_row (handle, tempPath, false);
+		}
+		OS.gtk_tree_path_free (tempPath);		
+	}
+	if (scroll) {
+		OS.gtk_widget_realize (handle);
+		GdkRectangle cellRect = new GdkRectangle ();
+		OS.gtk_tree_view_get_cell_area (handle, path, 0, cellRect);
+		boolean isHidden = cellRect.y == 0 && cellRect.height == 0;
+		int [] tx = new int [1], ty = new int [1];
+		OS.gtk_tree_view_widget_to_tree_coords (handle, cellRect.x, cellRect.y, tx, ty);
+		GdkRectangle visibleRect = new GdkRectangle ();
+		OS.gtk_tree_view_get_visible_rect (handle, visibleRect);
+		if (!isHidden) {
+			if (ty[0] < visibleRect.y || ty[0] + cellRect.height > visibleRect.y + visibleRect.height) {
+				isHidden = true;
+			} 
+		}
+		if (isHidden) {
+			/*
+			* This code intentionally commented.
+			* Bug in GTK.  According to the documentation, gtk_tree_view_scroll_to_cell
+			* should scroll the minimum amount to show the cell if use_align is false.
+			* However, what actually happens is the cell is scrolled to the top.
+			* The fix is to determine the new location and use gtk_tree_view_scroll_to_point.
+			* If the widget is a pinhead, calling gtk_tree_view_scroll_to_point
+			* will have no effect. Therefore, it is still neccessary to 
+			* call gtk_tree_view_scroll_to_cell.
+			*/
+			//	OS.gtk_tree_view_scroll_to_cell (handle, path, 0, depth != 1, 0.5f, 0.0f);
+			if (depth != 1) {
+				OS.gtk_tree_view_scroll_to_cell (handle, path, 0, true, 0.5f, 0.0f);
+			} else {
+				if (ty[0] < visibleRect.y ) {
+					OS.gtk_tree_view_scroll_to_point (handle, -1, ty[0]);
+				} else {
+					int height = Math.min (visibleRect.height, cellRect.height);
+					if (ty[0] + height > visibleRect.y + visibleRect.height) {
+						OS.gtk_tree_view_scroll_to_point (handle, -1, ty[0] + cellRect.height - visibleRect.height);
+					}
+				}
+			}
+		}
+	}
+}
+
+/**
+ * Shows the item.  If the item is already showing in the receiver,
+ * this method simply returns.  Otherwise, the items are scrolled
+ * and expanded until the item is visible.
+ *
+ * @param item the item to be shown
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the item is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the item has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see Tree#showSelection()
+ */
+public void showItem (TreeItem item) {
+	checkWidget ();
+	if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if (item.isDisposed ()) error(SWT.ERROR_INVALID_ARGUMENT);
+	if (item.parent != this) return;
+	int /*long*/ path = OS.gtk_tree_model_get_path (modelHandle, item.handle);
+	showItem (path, true);
+	OS.gtk_tree_path_free (path);
+}
+
+int /*long*/ treeSelectionProc (int /*long*/ model, int /*long*/ path, int /*long*/ iter, int[] selection, int length) {
+	if (selection != null) {
+		int [] index = new int [1];
+		OS.gtk_tree_model_get (modelHandle, iter, ID_COLUMN, index, -1);
+		selection [(int)/*64*/length] = index [0];
+	}
+	return 0;
+}
+
+void updateScrollBarValue (ScrollBar bar) {
+	super.updateScrollBarValue (bar);
+	/*
+	* Bug in GTK. Scrolling changes the XWindow position
+	* and makes the child widgets appear to scroll even
+	* though when queried their position is unchanged.
+	* The fix is to queue a resize event for each child to
+	* force the position to be corrected.
+	*/
+	int /*long*/ parentHandle = parentingHandle ();
+	int /*long*/ list = OS.gtk_container_get_children (parentHandle);
+	if (list == 0) return;
+	int /*long*/ temp = list;
+	while (temp != 0) {
+		int /*long*/ widget = OS.g_list_data (temp);
+		if (widget != 0) OS.gtk_widget_queue_resize  (widget);
+		temp = OS.g_list_next (temp);
+	}
+	OS.g_list_free (list);
+}
+
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/TreeColumn.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/TreeColumn.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/TreeColumn.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,668 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.widgets;
+
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.gtk.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.events.*;
+
+/**
+ * Instances of this class represent a column in a tree widget.
+ * <p><dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>LEFT, RIGHT, CENTER</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd> Move, Resize, Selection</dd>
+ * </dl>
+ * </p><p>
+ * Note: Only one of the styles LEFT, RIGHT and CENTER may be specified.
+ * </p><p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ *
+ * @see <a href="http://www.eclipse.org/swt/snippets/#tree">Tree, TreeItem, TreeColumn snippets</a>
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ * 
+ * @since 3.1
+ */
+public class TreeColumn extends Item {
+	int /*long*/ labelHandle, imageHandle, buttonHandle;
+	Tree parent;
+	int modelIndex, lastButton, lastTime, lastX, lastWidth;
+	boolean customDraw, useFixedWidth;
+	String toolTipText;
+
+/**
+ * Constructs a new instance of this class given its parent
+ * (which must be a <code>Tree</code>) and a style value
+ * describing its behavior and appearance. The item is added
+ * to the end of the items maintained by its parent.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT#LEFT
+ * @see SWT#RIGHT
+ * @see SWT#CENTER
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public TreeColumn (Tree parent, int style) {
+	super (parent, checkStyle (style));
+	this.parent = parent;
+	createWidget (parent.getColumnCount ());
+}
+
+/**
+ * Constructs a new instance of this class given its parent
+ * (which must be a <code>Tree</code>), a style value
+ * describing its behavior and appearance, and the index
+ * at which to place it in the items maintained by its parent.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ * <p>
+ * Note that due to a restriction on some platforms, the first column
+ * is always left aligned.
+ * </p>
+ * @param parent a composite control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ * @param index the zero-relative index to store the receiver in its parent
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the parent (inclusive)</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT#LEFT
+ * @see SWT#RIGHT
+ * @see SWT#CENTER
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public TreeColumn (Tree parent, int style, int index) {
+	super (parent, checkStyle (style));
+	this.parent = parent;
+	createWidget (index);
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the control is moved or resized, by sending
+ * it one of the messages defined in the <code>ControlListener</code>
+ * interface.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see ControlListener
+ * @see #removeControlListener
+ */
+public void addControlListener(ControlListener listener) {
+	checkWidget();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	TypedListener typedListener = new TypedListener (listener);
+	addListener (SWT.Resize,typedListener);
+	addListener (SWT.Move,typedListener);
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the control is selected by the user, by sending
+ * it one of the messages defined in the <code>SelectionListener</code>
+ * interface.
+ * <p>
+ * <code>widgetSelected</code> is called when the column header is selected.
+ * <code>widgetDefaultSelected</code> is not called.
+ * </p>
+ *
+ * @param listener the listener which should be notified when the control is selected by the user
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #removeSelectionListener
+ * @see SelectionEvent
+ */
+public void addSelectionListener (SelectionListener listener) {
+	checkWidget();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	TypedListener typedListener = new TypedListener (listener);
+	addListener (SWT.Selection,typedListener);
+	addListener (SWT.DefaultSelection,typedListener);
+}
+
+static int checkStyle (int style) {
+	return checkBits (style, SWT.LEFT, SWT.CENTER, SWT.RIGHT, 0, 0, 0);
+}
+
+protected void checkSubclass () {
+	if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
+}
+
+void createWidget (int index) {
+	parent.createItem (this, index);
+	setOrientation ();
+	hookEvents ();
+	register ();
+	text = "";
+}
+
+void deregister() {
+	super.deregister ();
+	display.removeWidget (handle);
+	if (buttonHandle != 0) display.removeWidget (buttonHandle);
+	if (labelHandle != 0) display.removeWidget (labelHandle);
+}
+
+void destroyWidget () {
+	parent.destroyItem (this);
+	releaseHandle ();
+}
+
+/**
+ * Returns a value which describes the position of the
+ * text or image in the receiver. The value will be one of
+ * <code>LEFT</code>, <code>RIGHT</code> or <code>CENTER</code>.
+ *
+ * @return the alignment 
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getAlignment () {
+	checkWidget();
+	if ((style & SWT.LEFT) != 0) return SWT.LEFT;
+	if ((style & SWT.CENTER) != 0) return SWT.CENTER;
+	if ((style & SWT.RIGHT) != 0) return SWT.RIGHT;
+	return SWT.LEFT;
+}
+
+/**
+ * Gets the moveable attribute. A column that is
+ * not moveable cannot be reordered by the user 
+ * by dragging the header but may be reordered 
+ * by the programmer.
+ *
+ * @return the moveable attribute
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see Tree#getColumnOrder()
+ * @see Tree#setColumnOrder(int[])
+ * @see TreeColumn#setMoveable(boolean)
+ * @see SWT#Move
+ * 
+ * @since 3.2
+ */
+public boolean getMoveable() {
+	checkWidget();
+	return OS.gtk_tree_view_column_get_reorderable (handle);
+}
+
+/**
+ * Returns the receiver's parent, which must be a <code>Tree</code>.
+ *
+ * @return the receiver's parent
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Tree getParent () {
+	checkWidget();
+	return parent;
+}
+
+/**
+ * Gets the resizable attribute. A column that is
+ * not resizable cannot be dragged by the user but
+ * may be resized by the programmer.
+ *
+ * @return the resizable attribute
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public boolean getResizable () {
+	checkWidget();
+	return OS.gtk_tree_view_column_get_resizable (handle);
+}
+
+/**
+ * Returns the receiver's tool tip text, or null if it has
+ * not been set.
+ *
+ * @return the receiver's tool tip text
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.2
+ */
+public String getToolTipText () {
+	checkWidget();
+	return toolTipText;
+}
+
+/**
+ * Gets the width of the receiver.
+ *
+ * @return the width
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getWidth () {
+	checkWidget();
+	if (!OS.gtk_tree_view_column_get_visible (handle)) {
+		return 0;
+	}
+	if (useFixedWidth) return OS.gtk_tree_view_column_get_fixed_width (handle);
+	return OS.gtk_tree_view_column_get_width (handle);
+}
+
+int /*long*/ gtk_clicked (int /*long*/ widget) {
+	/*
+	* There is no API to get a double click on a table column.  Normally, when
+	* the mouse is double clicked, this is indicated by GDK_2BUTTON_PRESS
+	* but the table column sends the click signal on button release.  The fix is to
+	* test for double click by remembering the last click time and mouse button
+	* and testing for the double click interval.
+	*/
+	boolean doubleClick = false;
+	boolean postEvent = true;
+	int /*long*/ eventPtr = OS.gtk_get_current_event ();
+	if (eventPtr != 0) {
+		GdkEventButton gdkEvent = new GdkEventButton ();
+		OS.memmove (gdkEvent, eventPtr, GdkEventButton.sizeof);
+		OS.gdk_event_free (eventPtr);
+		switch (gdkEvent.type) {
+			case OS.GDK_BUTTON_RELEASE: {
+				int clickTime = display.getDoubleClickTime ();
+				int eventTime = gdkEvent.time, eventButton = gdkEvent.button;
+				if (lastButton == eventButton && lastTime != 0 && Math.abs (lastTime - eventTime) <= clickTime) {
+					doubleClick = true;
+				}
+				lastTime = eventTime == 0 ? 1: eventTime;
+				lastButton = eventButton;
+				break;
+			}
+			case OS.GDK_MOTION_NOTIFY: {
+				/*
+				* Bug in GTK.  Dragging a column in a GtkTreeView causes a clicked 
+				* signal to be emitted even though the mouse button was never released.
+				* The fix to ignore the signal if the current GDK event is a motion notify.
+				* The GTK bug was fixed in version 2.6
+				*/
+				if (OS.GTK_VERSION < OS.VERSION (2, 6, 0)) postEvent = false;
+				break;
+			}
+		}
+	}
+	if (postEvent) postEvent (doubleClick ? SWT.DefaultSelection : SWT.Selection);
+	return 0;
+}
+
+int /*long*/ gtk_mnemonic_activate (int /*long*/ widget, int /*long*/ arg1) {
+	return parent.gtk_mnemonic_activate (widget, arg1);
+}
+
+int /*long*/ gtk_size_allocate (int /*long*/ widget, int /*long*/ allocation) {
+	useFixedWidth = false;
+	int x = OS.GTK_WIDGET_X (widget);
+	int width = OS.GTK_WIDGET_WIDTH (widget);
+	if (x != lastX) {
+		lastX = x;
+		sendEvent (SWT.Move);
+	}
+	if (width != lastWidth) {
+		lastWidth = width;
+		sendEvent (SWT.Resize);
+	}
+	return 0;
+}
+
+void hookEvents () {
+	super.hookEvents ();
+	OS.g_signal_connect_closure (handle, OS.clicked, display.closures [CLICKED], false);
+	if (buttonHandle != 0) OS.g_signal_connect_closure_by_id (buttonHandle, display.signalIds [SIZE_ALLOCATE], 0, display.closures [SIZE_ALLOCATE], false);
+	if (labelHandle != 0) OS.g_signal_connect_closure_by_id (labelHandle, display.signalIds [MNEMONIC_ACTIVATE], 0, display.closures [MNEMONIC_ACTIVATE], false);
+}
+
+/**
+ * Causes the receiver to be resized to its preferred size.
+ * For a composite, this involves computing the preferred size
+ * from its layout, if there is one.
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ */
+public void pack () {
+	checkWidget();
+	int width = 0;
+	if (buttonHandle != 0) {
+		GtkRequisition requisition = new GtkRequisition ();
+		OS.gtk_widget_size_request (buttonHandle, requisition);
+		width = requisition.width;
+	}
+	if ((parent.style & SWT.VIRTUAL) != 0) {
+		//NOT DONE
+	} else {
+		int /*long*/ iter = OS.g_malloc (OS.GtkTreeIter_sizeof ());
+		if (OS.gtk_tree_model_get_iter_first (parent.modelHandle, iter)) {
+			do {
+				width = Math.max (width, parent.calculateWidth (handle, iter, true));
+			} while (OS.gtk_tree_model_iter_next(parent.modelHandle, iter));
+		}
+		OS.g_free (iter);
+	}
+	setWidth(width);
+}
+
+void register () {
+	super.register ();
+	display.addWidget (handle, this);
+	if (buttonHandle != 0) display.addWidget (buttonHandle, this);
+	if (labelHandle != 0) display.addWidget (labelHandle, this);
+}
+
+void releaseHandle () {
+	super.releaseHandle ();
+	handle = buttonHandle = labelHandle = imageHandle = 0;
+	modelIndex = -1;
+	parent = null;
+}
+
+void releaseParent () {
+	super.releaseParent ();
+	if (parent.sortColumn == this) {
+		parent.sortColumn = null;
+	}
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the control is moved or resized.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see ControlListener
+ * @see #addControlListener
+ */
+public void removeControlListener (ControlListener listener) {
+	checkWidget();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if (eventTable == null) return;
+	eventTable.unhook (SWT.Move, listener);
+	eventTable.unhook (SWT.Resize, listener);
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the control is selected by the user.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SelectionListener
+ * @see #addSelectionListener
+ */
+public void removeSelectionListener(SelectionListener listener) {
+	checkWidget();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if (eventTable == null) return;
+	eventTable.unhook (SWT.Selection, listener);
+	eventTable.unhook (SWT.DefaultSelection,listener);	
+}
+
+/**
+ * Controls how text and images will be displayed in the receiver.
+ * The argument should be one of <code>LEFT</code>, <code>RIGHT</code>
+ * or <code>CENTER</code>.
+ * <p>
+ * Note that due to a restriction on some platforms, the first column
+ * is always left aligned.
+ * </p>
+ * @param alignment the new alignment 
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setAlignment (int alignment) {
+	checkWidget();
+	if ((alignment & (SWT.LEFT | SWT.RIGHT | SWT.CENTER)) == 0) return;
+	int index = parent.indexOf (this);
+	if (index == -1 || index == 0) return;
+	style &= ~(SWT.LEFT | SWT.RIGHT | SWT.CENTER);
+	style |= alignment & (SWT.LEFT | SWT.RIGHT | SWT.CENTER);
+	parent.createRenderers (handle, modelIndex, index == 0, style);
+}
+
+void setFontDescription (int /*long*/ font) {
+	OS.gtk_widget_modify_font (labelHandle, font);
+	OS.gtk_widget_modify_font (imageHandle, font);
+}
+
+public void setImage (Image image) {
+	checkWidget ();
+	super.setImage (image);
+	if (image != null) {
+		ImageList headerImageList = parent.headerImageList;
+		if (headerImageList == null) {
+			headerImageList = parent.headerImageList = new ImageList ();
+		}
+		int imageIndex = headerImageList.indexOf (image);
+		if (imageIndex == -1) imageIndex = headerImageList.add (image);
+		int /*long*/ pixbuf = headerImageList.getPixbuf (imageIndex);
+		OS.gtk_image_set_from_pixbuf (imageHandle, pixbuf);
+		OS.gtk_widget_show (imageHandle);
+	} else {
+		OS.gtk_image_set_from_pixbuf (imageHandle, 0);
+		OS.gtk_widget_hide (imageHandle);
+	}
+}
+
+/**
+ * Sets the moveable attribute.  A column that is
+ * moveable can be reordered by the user by dragging
+ * the header. A column that is not moveable cannot be 
+ * dragged by the user but may be reordered 
+ * by the programmer.
+ *
+ * @param moveable the moveable attribute
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see Tree#setColumnOrder(int[])
+ * @see Tree#getColumnOrder()
+ * @see TreeColumn#getMoveable()
+ * @see SWT#Move
+ * 
+ * @since 3.2
+ */
+public void setMoveable (boolean moveable) {
+	checkWidget();
+	OS.gtk_tree_view_column_set_reorderable (handle, moveable);
+}
+
+void setOrientation() {
+	if ((parent.style & SWT.RIGHT_TO_LEFT) != 0) {
+		if (buttonHandle != 0) {
+			OS.gtk_widget_set_direction (buttonHandle, OS.GTK_TEXT_DIR_RTL);
+			OS.gtk_container_forall (buttonHandle, display.setDirectionProc, OS.GTK_TEXT_DIR_RTL);	
+		}
+	}
+}
+
+/**
+ * Sets the resizable attribute.  A column that is
+ * not resizable cannot be dragged by the user but
+ * may be resized by the programmer.
+ *
+ * @param resizable the resize attribute
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setResizable (boolean resizable) {
+	checkWidget();
+	OS.gtk_tree_view_column_set_resizable (handle, resizable);
+}
+
+public void setText (String string) {
+	checkWidget();
+	if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+	super.setText (string);
+	char [] chars = fixMnemonic (string);
+	byte [] buffer = Converter.wcsToMbcs (null, chars, true);
+	OS.gtk_label_set_text_with_mnemonic (labelHandle, buffer);
+	if (string.length () != 0) {
+		OS.gtk_widget_show (labelHandle);
+	} else {
+		OS.gtk_widget_hide (labelHandle);
+	}
+}
+
+/**
+ * Sets the receiver's tool tip text to the argument, which
+ * may be null indicating that no tool tip text should be shown.
+ *
+ * @param string the new tool tip text (or null)
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.2
+ */
+public void setToolTipText (String string) {
+	checkWidget();
+	Shell shell = parent._getShell ();
+	setToolTipText (shell, string);
+	toolTipText = string;
+}
+
+void setToolTipText (Shell shell, String newString) {
+	shell.setToolTipText (buttonHandle, newString);
+}
+
+/**
+ * Sets the width of the receiver.
+ *
+ * @param width the new width
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setWidth (int width) {
+	checkWidget();
+	if (width < 0) return;
+	if (width == lastWidth) return;
+	if (width > 0) {
+		useFixedWidth = true;
+		OS.gtk_tree_view_column_set_fixed_width (handle, width);
+	}
+	/*
+	 * Bug in GTK.  For some reason, calling gtk_tree_view_column_set_visible()
+	 * when the parent is not realized fails to show the column. The fix is to
+	 * ensure that the table has been realized.
+	 */
+	if (width != 0) OS.gtk_widget_realize (parent.handle);
+	OS.gtk_tree_view_column_set_visible (handle, width != 0);
+	lastWidth = width;
+	sendEvent (SWT.Resize);
+}
+
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/TreeItem.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/TreeItem.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/TreeItem.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,1756 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.widgets;
+
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.gtk.*;
+import org.eclipse.swt.graphics.*;
+
+/**
+ * Instances of this class represent a selectable user interface object
+ * that represents a hierarchy of tree items in a tree widget.
+ * 
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>(none)</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>(none)</dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ *
+ * @see <a href="http://www.eclipse.org/swt/snippets/#tree">Tree, TreeItem, TreeColumn snippets</a>
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public class TreeItem extends Item {
+	Tree parent;
+	Font font;
+	Font[] cellFont;
+	boolean cached, grayed;
+	static final int EXPANDER_EXTRA_PADDING = 4;
+
+/**
+ * Constructs a new instance of this class given its parent
+ * (which must be a <code>Tree</code> or a <code>TreeItem</code>)
+ * and a style value describing its behavior and appearance.
+ * The item is added to the end of the items maintained by its parent.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a tree control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public TreeItem (Tree parent, int style) {
+	this (checkNull (parent), 0, style, -1, true);
+}
+
+/**
+ * Constructs a new instance of this class given its parent
+ * (which must be a <code>Tree</code> or a <code>TreeItem</code>),
+ * a style value describing its behavior and appearance, and the index
+ * at which to place it in the items maintained by its parent.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a tree control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ * @param index the zero-relative index to store the receiver in its parent
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the parent (inclusive)</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public TreeItem (Tree parent, int style, int index) {
+	this (checkNull (parent), 0, style, checkIndex (index), true);
+}
+
+/**
+ * Constructs a new instance of this class given its parent
+ * (which must be a <code>Tree</code> or a <code>TreeItem</code>)
+ * and a style value describing its behavior and appearance.
+ * The item is added to the end of the items maintained by its parent.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parentItem a tree control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public TreeItem (TreeItem parentItem, int style) {
+	this (checkNull (parentItem).parent, parentItem.handle, style, -1, true);
+}
+
+/**
+ * Constructs a new instance of this class given its parent
+ * (which must be a <code>Tree</code> or a <code>TreeItem</code>),
+ * a style value describing its behavior and appearance, and the index
+ * at which to place it in the items maintained by its parent.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parentItem a tree control which will be the parent of the new instance (cannot be null)
+ * @param style the style of control to construct
+ * @param index the zero-relative index to store the receiver in its parent
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the parent (inclusive)</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public TreeItem (TreeItem parentItem, int style, int index) {
+	this (checkNull (parentItem).parent, parentItem.handle, style, checkIndex (index), true);
+}
+
+TreeItem (Tree parent, int /*long*/ parentIter, int style, int index, boolean create) {
+	super (parent, style);
+	this.parent = parent;
+	if (create) {
+		parent.createItem (this, parentIter, index);
+	} else {
+		handle = OS.g_malloc (OS.GtkTreeIter_sizeof ());
+		OS.gtk_tree_model_iter_nth_child (parent.modelHandle, handle, parentIter, index);
+	}
+}
+
+static int checkIndex (int index) {
+	if (index < 0) SWT.error (SWT.ERROR_INVALID_RANGE);
+	return index;
+}
+
+static TreeItem checkNull (TreeItem item) {
+	if (item == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+	return item;
+}
+
+static Tree checkNull (Tree control) {
+	if (control == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+	return control;
+}
+
+protected void checkSubclass () {
+	if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
+}
+
+Color _getBackground () {
+	int /*long*/ [] ptr = new int /*long*/ [1];
+	OS.gtk_tree_model_get (parent.modelHandle, handle, Tree.BACKGROUND_COLUMN, ptr, -1);
+	if (ptr [0] == 0) return parent.getBackground ();
+	GdkColor gdkColor = new GdkColor ();
+	OS.memmove (gdkColor, ptr [0], GdkColor.sizeof);
+	return Color.gtk_new (display, gdkColor);
+}
+
+Color _getBackground (int index) {
+	int count = Math.max (1, parent.columnCount);
+	if (0 > index || index > count - 1) return _getBackground ();
+	int /*long*/ [] ptr = new int /*long*/ [1];
+	int modelIndex = parent.columnCount == 0 ? Tree.FIRST_COLUMN : parent.columns [index].modelIndex;
+	OS.gtk_tree_model_get (parent.modelHandle, handle, modelIndex + Tree.CELL_BACKGROUND, ptr, -1);
+	if (ptr [0] == 0) return _getBackground ();
+	GdkColor gdkColor = new GdkColor ();
+	OS.memmove (gdkColor, ptr [0], GdkColor.sizeof);
+	return Color.gtk_new (display, gdkColor);
+}
+
+boolean _getChecked () {
+	int /*long*/ [] ptr = new int /*long*/ [1];
+	OS.gtk_tree_model_get (parent.modelHandle, handle, Tree.CHECKED_COLUMN, ptr, -1);
+	return ptr [0] != 0;
+}
+
+Color _getForeground () {
+	int /*long*/ [] ptr = new int /*long*/ [1];
+	OS.gtk_tree_model_get (parent.modelHandle, handle, Tree.FOREGROUND_COLUMN, ptr, -1);
+	if (ptr [0] == 0) return parent.getForeground ();
+	GdkColor gdkColor = new GdkColor ();
+	OS.memmove (gdkColor, ptr [0], GdkColor.sizeof);
+	return Color.gtk_new (display, gdkColor);
+}
+
+Color _getForeground (int index) {
+	int count = Math.max (1, parent.columnCount);
+	if (0 > index || index > count - 1) return _getForeground ();
+	int /*long*/ [] ptr = new int /*long*/ [1];
+	int modelIndex =  parent.columnCount == 0 ? Tree.FIRST_COLUMN : parent.columns [index].modelIndex;
+	OS.gtk_tree_model_get (parent.modelHandle, handle, modelIndex + Tree.CELL_FOREGROUND, ptr, -1);
+	if (ptr [0] == 0) return _getForeground ();
+	GdkColor gdkColor = new GdkColor ();
+	OS.memmove (gdkColor, ptr [0], GdkColor.sizeof);
+	return Color.gtk_new (display, gdkColor);
+}
+
+Image _getImage (int index) {
+	int count = Math.max (1, parent.getColumnCount ());
+	if (0 > index || index > count - 1) return null;
+	int /*long*/ [] ptr = new int /*long*/ [1];
+	int modelIndex = parent.columnCount == 0 ? Tree.FIRST_COLUMN : parent.columns [index].modelIndex;
+	OS.gtk_tree_model_get (parent.modelHandle, handle, modelIndex + Tree.CELL_PIXBUF, ptr, -1);
+	if (ptr [0] == 0) return null;
+	ImageList imageList = parent.imageList;
+	int imageIndex = imageList.indexOf (ptr [0]);
+	if (imageIndex == -1) return null;
+	return imageList.get (imageIndex);
+}
+
+String _getText (int index) {
+	int count = Math.max (1, parent.getColumnCount ());
+	if (0 > index || index > count - 1) return "";
+	int /*long*/ [] ptr = new int /*long*/ [1];
+	int modelIndex = parent.columnCount == 0 ? Tree.FIRST_COLUMN : parent.columns [index].modelIndex;
+	OS.gtk_tree_model_get (parent.modelHandle, handle, modelIndex + Tree.CELL_TEXT, ptr, -1);
+	if (ptr [0] == 0) return ""; //$NON-NLS-1$
+	int length = OS.strlen (ptr [0]);
+	byte[] buffer = new byte [length];
+	OS.memmove (buffer, ptr [0], length);
+	OS.g_free (ptr [0]);
+	return new String (Converter.mbcsToWcs (null, buffer));
+}
+
+void clear () {
+	if (parent.currentItem == this) return;
+	if (cached || (parent.style & SWT.VIRTUAL) == 0) {
+		int columnCount = OS.gtk_tree_model_get_n_columns (parent.modelHandle);
+		for (int i=Tree.CHECKED_COLUMN; i<columnCount; i++) {
+			OS.gtk_tree_store_set (parent.modelHandle, handle, i, 0, -1);
+		}
+		/*
+		* Bug in GTK.  When using fixed-height-mode,
+		* row changes do not cause the row to be repainted.  The fix is to
+		* invalidate the row when it is cleared.
+		*/
+		if ((parent.style & SWT.VIRTUAL) != 0) {
+			if (OS.GTK_VERSION >= OS.VERSION (2, 3, 2) && OS.GTK_VERSION < OS.VERSION (2, 6, 3)) {
+				redraw ();
+			}
+		}
+	}
+	cached = false;
+	font = null;
+	cellFont = null;
+}
+
+/**
+ * Clears the item at the given zero-relative index in the receiver.
+ * The text, icon and other attributes of the item are set to the default
+ * value.  If the tree was created with the <code>SWT.VIRTUAL</code> style,
+ * these attributes are requested again as needed.
+ *
+ * @param index the index of the item to clear
+ * @param all <code>true</code> if all child items of the indexed item should be
+ * cleared recursively, and <code>false</code> otherwise
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see SWT#VIRTUAL
+ * @see SWT#SetData
+ * 
+ * @since 3.2
+ */
+public void clear (int index, boolean all) {
+	checkWidget ();
+	parent.clear (handle, index, all);
+}
+
+/**
+ * Clears all the items in the receiver. The text, icon and other
+ * attributes of the items are set to their default values. If the
+ * tree was created with the <code>SWT.VIRTUAL</code> style, these
+ * attributes are requested again as needed.
+ * 
+ * @param all <code>true</code> if all child items should be cleared
+ * recursively, and <code>false</code> otherwise
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see SWT#VIRTUAL
+ * @see SWT#SetData
+ * 
+ * @since 3.2
+ */
+public void clearAll (boolean all) {
+	checkWidget ();
+	parent.clearAll (all, handle);
+}
+
+void destroyWidget () {
+	parent.releaseItem (this, false);
+	parent.destroyItem (this);
+	releaseHandle ();
+}
+
+/**
+ * Returns the receiver's background color.
+ *
+ * @return the background color
+ * 
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 2.0
+ * 
+ */
+public Color getBackground () {
+	checkWidget ();
+	if (!parent.checkData (this)) error (SWT.ERROR_WIDGET_DISPOSED);
+	return _getBackground ();
+}
+
+/**
+ * Returns the background color at the given column index in the receiver.
+ *
+ * @param index the column index
+ * @return the background color
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.1
+ */
+public Color getBackground (int index) {
+	checkWidget ();
+	if (!parent.checkData (this)) error (SWT.ERROR_WIDGET_DISPOSED);
+	return _getBackground (index);
+}
+
+/**
+ * Returns a rectangle describing the receiver's size and location
+ * relative to its parent at a column in the tree.
+ *
+ * @param index the index that specifies the column
+ * @return the receiver's bounding column rectangle
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.1
+ */
+public Rectangle getBounds (int index) {
+	// TODO fully test on early and later versions of GTK
+	checkWidget();
+	if (!parent.checkData (this)) error (SWT.ERROR_WIDGET_DISPOSED);
+	int /*long*/ parentHandle = parent.handle;
+	int /*long*/ column = 0;
+	if (index >= 0 && index < parent.columnCount) {
+		column = parent.columns [index].handle;
+	} else {
+		column = OS.gtk_tree_view_get_column (parentHandle, index);
+	}
+	if (column == 0) return new Rectangle (0, 0, 0, 0);
+	int /*long*/ path = OS.gtk_tree_model_get_path (parent.modelHandle, handle);
+	OS.gtk_widget_realize (parentHandle);
+	GdkRectangle rect = new GdkRectangle ();
+	OS.gtk_tree_view_get_cell_area (parentHandle, path, column, rect);
+	if ((parent.getStyle () & SWT.MIRRORED) != 0) rect.x = parent.getClientWidth () - rect.width - rect.x;
+	
+	if (OS.GTK_VERSION < OS.VERSION (2, 8, 18) && OS.gtk_tree_view_get_expander_column (parentHandle) == column) {
+		int [] buffer = new int [1];
+		OS.gtk_widget_style_get (parentHandle, OS.expander_size, buffer, 0);
+		rect.x += buffer [0] + TreeItem.EXPANDER_EXTRA_PADDING;
+		rect.width -= buffer [0] + TreeItem.EXPANDER_EXTRA_PADDING;
+		OS.gtk_widget_style_get (parentHandle, OS.horizontal_separator, buffer, 0);
+		rect.x += buffer [0];
+		//rect.width -= buffer [0]; // TODO Is this required for some versions?
+	}
+	/*
+	* Bug in GTK. In GTK 2.8.x, the cell area is left aligned even
+	* when the widget is mirrored. The fix is to sum up the indentation
+	* of the expanders. 
+	*/
+	if ((parent.getStyle () & SWT.MIRRORED) != 0 && (OS.GTK_VERSION < OS.VERSION (2, 10, 0))) {
+		int depth = OS.gtk_tree_path_get_depth (path);
+		int [] expanderSize = new int [1];
+		OS.gtk_widget_style_get (parentHandle, OS.expander_size, expanderSize, 0);
+		rect.x += depth * (expanderSize[0] + TreeItem.EXPANDER_EXTRA_PADDING);  
+	}
+	OS.gtk_tree_path_free (path);
+	
+	if (index == 0 && (parent.style & SWT.CHECK) != 0) {
+		if (OS.GTK_VERSION >= OS.VERSION (2, 1, 3)) {
+			int [] x = new int [1], w = new int [1];
+			OS.gtk_tree_view_column_cell_get_position (column, parent.checkRenderer, x, w);
+			rect.x += x [0] + w [0];
+			rect.width -= x [0] + w [0];
+		} else {
+			int [] w = new int [1];
+			OS.gtk_cell_renderer_get_size (parent.checkRenderer, parentHandle, null, null, null, w, null);
+			int [] buffer = new int [1];
+			OS.gtk_widget_style_get (parentHandle, OS.horizontal_separator, buffer, 0);
+			rect.x += w [0]  + buffer [0];
+			rect.width -= w [0]  + buffer [0];
+		}
+	}
+	int width = OS.gtk_tree_view_column_get_visible (column) ? rect.width + 1 : 0;
+	return new Rectangle (rect.x, rect.y, width, rect.height + 1);
+}
+
+/**
+ * Returns a rectangle describing the receiver's size and location
+ * relative to its parent.
+ *
+ * @return the receiver's bounding rectangle
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Rectangle getBounds () {
+	// TODO fully test on early and later versions of GTK
+	// shifted a bit too far right on later versions of GTK - however, old Tree also had this problem
+	checkWidget ();
+	if (!parent.checkData (this)) error (SWT.ERROR_WIDGET_DISPOSED);
+	int /*long*/ parentHandle = parent.handle;
+	int /*long*/ column = OS.gtk_tree_view_get_column (parentHandle, 0);
+	if (column == 0) return new Rectangle (0, 0, 0, 0);
+	int /*long*/ textRenderer = parent.getTextRenderer (column);
+	int /*long*/ pixbufRenderer = parent.getPixbufRenderer (column);
+	if (textRenderer == 0 || pixbufRenderer == 0)  return new Rectangle (0, 0, 0, 0);
+
+	int /*long*/ path = OS.gtk_tree_model_get_path (parent.modelHandle, handle);
+	OS.gtk_widget_realize (parentHandle);
+	
+	boolean isExpander = OS.gtk_tree_model_iter_n_children (parent.modelHandle, handle) > 0;
+	boolean isExpanded = OS.gtk_tree_view_row_expanded (parentHandle, path);
+	OS.gtk_tree_view_column_cell_set_cell_data (column, parent.modelHandle, handle, isExpander, isExpanded);
+	
+	GdkRectangle rect = new GdkRectangle ();
+	OS.gtk_tree_view_get_cell_area (parentHandle, path, column, rect);
+	if ((parent.getStyle () & SWT.MIRRORED) != 0) rect.x = parent.getClientWidth () - rect.width - rect.x;
+	int right = rect.x + rect.width;
+
+	int [] x = new int [1], w = new int [1];
+	parent.ignoreSize = true;
+	OS.gtk_cell_renderer_get_size (textRenderer, parentHandle, null, null, null, w, null);
+	parent.ignoreSize = false;
+	rect.width = w [0];
+	int [] buffer = new int [1];
+	if (OS.GTK_VERSION < OS.VERSION (2, 8, 18) && OS.gtk_tree_view_get_expander_column (parentHandle) == column) {
+		OS.gtk_widget_style_get (parentHandle, OS.expander_size, buffer, 0);
+		rect.x += buffer [0] + TreeItem.EXPANDER_EXTRA_PADDING;
+	}
+	/*
+	* Bug in GTK. In GTK 2.8.x, the cell area is left aligned even
+	* when the widget is mirrored. The fix is to sum up the indentation
+	* of the expanders. 
+	*/
+	if ((parent.getStyle () & SWT.MIRRORED) != 0 && (OS.GTK_VERSION < OS.VERSION (2, 10, 0))) {
+		int depth = OS.gtk_tree_path_get_depth (path);
+		int [] expanderSize = new int [1];
+		OS.gtk_widget_style_get (parentHandle, OS.expander_size, expanderSize, 0);
+		rect.x += depth * (expanderSize[0] + TreeItem.EXPANDER_EXTRA_PADDING); 
+	}
+	OS.gtk_tree_path_free (path);
+	
+	OS.gtk_widget_style_get (parentHandle, OS.horizontal_separator, buffer, 0);
+	int horizontalSeparator = buffer[0];
+	rect.x += horizontalSeparator;
+	
+	if (OS.GTK_VERSION >= OS.VERSION (2, 1, 3)) {
+		OS.gtk_tree_view_column_cell_get_position (column, textRenderer, x, null);
+		rect.x += x [0];
+	} else {
+		if ((parent.style & SWT.CHECK) != 0) {
+			OS.gtk_cell_renderer_get_size (parent.checkRenderer, parentHandle, null, null, null, w, null);
+			rect.x += w [0] + horizontalSeparator;
+		}
+		OS.gtk_cell_renderer_get_size (pixbufRenderer, parentHandle, null, null, null, w, null);
+		rect.x += w [0] + horizontalSeparator;
+	}
+	if (parent.columnCount > 0) {
+		if (rect.x + rect.width > right) {
+			rect.width = Math.max (0, right - rect.x);
+		}
+	}
+	int width = OS.gtk_tree_view_column_get_visible (column) ? rect.width + 1 : 0;
+	return new Rectangle (rect.x, rect.y, width, rect.height + 1);
+}
+
+/**
+ * Returns <code>true</code> if the receiver is checked,
+ * and false otherwise.  When the parent does not have
+ * the <code>CHECK style, return false.
+ * <p>
+ *
+ * @return the checked state
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public boolean getChecked () {
+	checkWidget();
+	if (!parent.checkData (this)) error (SWT.ERROR_WIDGET_DISPOSED);
+	if ((parent.style & SWT.CHECK) == 0) return false;
+	return _getChecked ();
+}
+
+/**
+ * Returns <code>true</code> if the receiver is expanded,
+ * and false otherwise.
+ * <p>
+ *
+ * @return the expanded state
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public boolean getExpanded () {
+	checkWidget();
+	int /*long*/ path = OS.gtk_tree_model_get_path (parent.modelHandle, handle);
+	boolean answer = OS.gtk_tree_view_row_expanded (parent.handle, path);
+	OS.gtk_tree_path_free (path);
+	return answer;
+}
+
+/**
+ * Returns the font that the receiver will use to paint textual information for this item.
+ *
+ * @return the receiver's font
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 3.0
+ */
+public Font getFont () {
+	checkWidget ();
+	if (!parent.checkData (this)) error (SWT.ERROR_WIDGET_DISPOSED);
+	return font != null ? font : parent.getFont ();
+}
+
+/**
+ * Returns the font that the receiver will use to paint textual information
+ * for the specified cell in this item.
+ *
+ * @param index the column index
+ * @return the receiver's font
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 3.1
+ */
+public Font getFont (int index) {
+	checkWidget ();
+	if (!parent.checkData (this)) error (SWT.ERROR_WIDGET_DISPOSED);
+	int count = Math.max (1, parent.columnCount);
+	if (0 > index || index > count - 1) return getFont ();
+	if (cellFont == null || cellFont [index] == null) return getFont ();
+	return cellFont [index];
+}
+
+
+/**
+ * Returns the foreground color that the receiver will use to draw.
+ *
+ * @return the receiver's foreground color
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 2.0
+ * 
+ */
+public Color getForeground () {
+	checkWidget ();
+	if (!parent.checkData (this)) error (SWT.ERROR_WIDGET_DISPOSED);
+	return _getForeground ();
+}
+
+/**
+ * 
+ * Returns the foreground color at the given column index in the receiver.
+ *
+ * @param index the column index
+ * @return the foreground color
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.1
+ */
+public Color getForeground (int index) {
+	checkWidget ();
+	if (!parent.checkData (this)) error (SWT.ERROR_WIDGET_DISPOSED);
+	return _getForeground (index);
+}
+
+/**
+ * Returns <code>true</code> if the receiver is grayed,
+ * and false otherwise. When the parent does not have
+ * the <code>CHECK style, return false.
+ * <p>
+ *
+ * @return the grayed state of the checkbox
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public boolean getGrayed () {
+	checkWidget ();
+	if (!parent.checkData (this)) error (SWT.ERROR_WIDGET_DISPOSED);
+	if ((parent.style & SWT.CHECK) == 0) return false;
+	return grayed;
+}
+
+public Image getImage () {
+	checkWidget ();
+	if (!parent.checkData (this)) error (SWT.ERROR_WIDGET_DISPOSED);
+	return getImage (0);
+}
+
+/**
+ * Returns the image stored at the given column index in the receiver,
+ * or null if the image has not been set or if the column does not exist.
+ *
+ * @param index the column index
+ * @return the image stored at the given column index in the receiver
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.1
+ */
+public Image getImage (int index) {
+	checkWidget ();
+	if (!parent.checkData (this)) error (SWT.ERROR_WIDGET_DISPOSED);
+	return _getImage (index);
+}
+
+/**
+ * Returns a rectangle describing the size and location
+ * relative to its parent of an image at a column in the
+ * tree.
+ *
+ * @param index the index that specifies the column
+ * @return the receiver's bounding image rectangle
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.1
+ */
+public Rectangle getImageBounds (int index) {
+	// TODO fully test on early and later versions of GTK
+	checkWidget ();
+	if (!parent.checkData (this)) error (SWT.ERROR_WIDGET_DISPOSED);
+	int /*long*/ parentHandle = parent.handle;
+	int /*long*/ column = 0;
+	if (index >= 0 && index < parent.getColumnCount ()) {
+		column = parent.columns [index].handle;
+	} else {
+		column = OS.gtk_tree_view_get_column (parentHandle, index);
+	}
+	if (column == 0) return new Rectangle (0, 0, 0, 0);
+	int /*long*/ pixbufRenderer = parent.getPixbufRenderer (column);
+	if (pixbufRenderer == 0)  return new Rectangle (0, 0, 0, 0);
+	GdkRectangle rect = new GdkRectangle ();
+	int /*long*/ path = OS.gtk_tree_model_get_path (parent.modelHandle, handle);
+	OS.gtk_widget_realize (parentHandle);
+	OS.gtk_tree_view_get_cell_area (parentHandle, path, column, rect);
+	if ((parent.getStyle () & SWT.MIRRORED) != 0) rect.x = parent.getClientWidth () - rect.width - rect.x;
+	if (OS.GTK_VERSION < OS.VERSION (2, 8, 18) && OS.gtk_tree_view_get_expander_column (parentHandle) == column) {
+		int [] buffer = new int [1];
+		OS.gtk_widget_style_get (parentHandle, OS.expander_size, buffer, 0);
+		rect.x += buffer [0] + TreeItem.EXPANDER_EXTRA_PADDING;
+		rect.width -= buffer [0] + TreeItem.EXPANDER_EXTRA_PADDING;
+		//OS.gtk_widget_style_get (parentHandle, OS.horizontal_separator, buffer, 0);
+		//int horizontalSeparator = buffer[0];
+		//rect.x += horizontalSeparator;
+	}
+	/*
+	* Bug in GTK. In GTK 2.8.x, the cell area is left aligned even
+	* when the widget is mirrored. The fix is to sum up the indentation
+	* of the expanders. 
+	*/
+	if ((parent.getStyle () & SWT.MIRRORED) != 0 && (OS.GTK_VERSION < OS.VERSION (2, 10, 0))) {
+		int depth = OS.gtk_tree_path_get_depth (path);
+		int [] expanderSize = new int [1];
+		OS.gtk_widget_style_get (parentHandle, OS.expander_size, expanderSize, 0);
+		rect.x += depth * (expanderSize[0] + TreeItem.EXPANDER_EXTRA_PADDING);  
+	}
+	OS.gtk_tree_path_free (path);
+	
+	/*
+	* The OS call gtk_cell_renderer_get_size() provides the width of image to be drawn
+	* by the cell renderer.  If there is no image in the cell, the width is zero.  If the table contains
+	* images of varying widths, gtk_cell_renderer_get_size() will return the width of the image, 
+	* not the width of the area in which the image is drawn.
+	* New API was added in GTK 2.1.3 for determining the full width of the renderer area.
+	* For earlier versions of GTK, the result is only correct if all rows have images of the same
+	* width.
+	*/
+	if (OS.GTK_VERSION >= OS.VERSION (2, 1, 3)) {
+		int [] x = new int [1], w = new int[1];
+		OS.gtk_tree_view_column_cell_get_position (column, pixbufRenderer, x, w);
+		rect.x += x [0];
+		rect.width = w [0];
+	} else {
+		int [] w = new int [1];
+		OS.gtk_tree_view_column_cell_set_cell_data (column, parent.modelHandle, handle, false, false);
+		OS.gtk_cell_renderer_get_size (pixbufRenderer, parentHandle, null, null, null, w, null);
+		rect.width = w [0];
+	}
+	int width = OS.gtk_tree_view_column_get_visible (column) ? rect.width : 0;
+	return new Rectangle (rect.x, rect.y, width, rect.height + 1);
+}
+
+/**
+ * Returns the number of items contained in the receiver
+ * that are direct item children of the receiver.
+ *
+ * @return the number of items
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getItemCount () {
+	checkWidget();
+	if (!parent.checkData (this)) error (SWT.ERROR_WIDGET_DISPOSED);
+	return OS.gtk_tree_model_iter_n_children (parent.modelHandle, handle);
+}
+
+/**
+ * Returns the item at the given, zero-relative index in the
+ * receiver. Throws an exception if the index is out of range.
+ *
+ * @param index the index of the item to return
+ * @return the item at the given index
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.1
+ */
+public TreeItem getItem (int index) {
+	checkWidget();
+	if (index < 0) error (SWT.ERROR_INVALID_RANGE);
+	if (!parent.checkData (this)) error (SWT.ERROR_WIDGET_DISPOSED);
+	int itemCount = OS.gtk_tree_model_iter_n_children (parent.modelHandle, handle);
+	if (index >= itemCount)  error (SWT.ERROR_INVALID_RANGE);
+	return  parent._getItem (handle, index);
+}
+
+/**
+ * Returns a (possibly empty) array of <code>TreeItem</code>s which
+ * are the direct item children of the receiver.
+ * <p>
+ * Note: This is not the actual structure used by the receiver
+ * to maintain its list of items, so modifying the array will
+ * not affect the receiver. 
+ * </p>
+ *
+ * @return the receiver's items
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public TreeItem [] getItems () {
+	checkWidget();
+	if (!parent.checkData (this)) error (SWT.ERROR_WIDGET_DISPOSED);
+	return parent.getItems (handle);
+}
+
+String getNameText () {
+	if ((parent.style & SWT.VIRTUAL) != 0) {
+		if (!cached) return "*virtual*"; //$NON-NLS-1$
+	}
+	return super.getNameText ();
+}
+
+/**
+ * Returns the receiver's parent, which must be a <code>Tree</code>.
+ *
+ * @return the receiver's parent
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Tree getParent () {
+	checkWidget ();
+	return parent;
+}
+
+/**
+ * Returns the receiver's parent item, which must be a
+ * <code>TreeItem</code> or null when the receiver is a
+ * root.
+ *
+ * @return the receiver's parent item
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public TreeItem getParentItem () {
+	checkWidget();
+	int /*long*/ path = OS.gtk_tree_model_get_path (parent.modelHandle, handle);
+	TreeItem item = null;
+	int depth = OS.gtk_tree_path_get_depth (path); 
+	if (depth > 1) {
+		OS.gtk_tree_path_up (path);
+		int /*long*/ iter = OS.g_malloc (OS.GtkTreeIter_sizeof ());
+		if (OS.gtk_tree_model_get_iter (parent.modelHandle, iter, path)) {
+			item = parent._getItem (iter);
+		}
+		OS.g_free (iter);
+	}
+	OS.gtk_tree_path_free (path);
+	return item;
+}
+
+public String getText () {
+	checkWidget ();
+	if (!parent.checkData (this)) error (SWT.ERROR_WIDGET_DISPOSED);
+	return getText (0);
+}
+
+/**
+ * Returns the text stored at the given column index in the receiver,
+ * or empty string if the text has not been set.
+ *
+ * @param index the column index
+ * @return the text stored at the given column index in the receiver
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.1
+ */
+public String getText (int index) {
+	checkWidget ();
+	if (!parent.checkData (this)) error (SWT.ERROR_WIDGET_DISPOSED);
+	return _getText (index);
+}
+
+/**
+ * Returns a rectangle describing the size and location
+ * relative to its parent of the text at a column in the
+ * tree.
+ *
+ * @param index the index that specifies the column
+ * @return the receiver's bounding text rectangle
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.3
+ */
+public Rectangle getTextBounds (int index) {
+	checkWidget ();
+	if (!parent.checkData (this)) error (SWT.ERROR_WIDGET_DISPOSED);
+	int count = Math.max (1, parent.getColumnCount ());
+	if (0 > index || index > count - 1) return new Rectangle (0, 0, 0, 0);
+	// TODO fully test on early and later versions of GTK
+	// shifted a bit too far right on later versions of GTK - however, old Tree also had this problem
+	int /*long*/ parentHandle = parent.handle;
+	int /*long*/ column = 0;
+	if (index >= 0 && index < parent.columnCount) {
+		column = parent.columns [index].handle;
+	} else {
+		column = OS.gtk_tree_view_get_column (parentHandle, index);
+	}
+	if (column == 0) return new Rectangle (0, 0, 0, 0);
+	int /*long*/ textRenderer = parent.getTextRenderer (column);
+	int /*long*/ pixbufRenderer = parent.getPixbufRenderer (column);
+	if (textRenderer == 0 || pixbufRenderer == 0)  return new Rectangle (0, 0, 0, 0);
+
+	int /*long*/ path = OS.gtk_tree_model_get_path (parent.modelHandle, handle);
+	OS.gtk_widget_realize (parentHandle);
+	
+	boolean isExpander = OS.gtk_tree_model_iter_n_children (parent.modelHandle, handle) > 0;
+	boolean isExpanded = OS.gtk_tree_view_row_expanded (parentHandle, path);
+	OS.gtk_tree_view_column_cell_set_cell_data (column, parent.modelHandle, handle, isExpander, isExpanded);
+	
+	GdkRectangle rect = new GdkRectangle ();
+	OS.gtk_tree_view_get_cell_area (parentHandle, path, column, rect);
+	if ((parent.getStyle () & SWT.MIRRORED) != 0) rect.x = parent.getClientWidth () - rect.width - rect.x;
+	int right = rect.x + rect.width;
+
+	int [] x = new int [1], w = new int [1];
+	parent.ignoreSize = true;
+	OS.gtk_cell_renderer_get_size (textRenderer, parentHandle, null, null, null, w, null);
+	parent.ignoreSize = false;
+	int [] buffer = new int [1];
+	if (OS.GTK_VERSION < OS.VERSION (2, 8, 18) && OS.gtk_tree_view_get_expander_column (parentHandle) == column) {
+		OS.gtk_widget_style_get (parentHandle, OS.expander_size, buffer, 0);
+		rect.x += buffer [0] + TreeItem.EXPANDER_EXTRA_PADDING;
+	}
+	/*
+	* Bug in GTK. In GTK 2.8.x, the cell area is left aligned even
+	* when the widget is mirrored. The fix is to sum up the indentation
+	* of the expanders. 
+	*/
+	if ((parent.getStyle () & SWT.MIRRORED) != 0 && (OS.GTK_VERSION < OS.VERSION (2, 10, 0))) {
+		int depth = OS.gtk_tree_path_get_depth (path);
+		int [] expanderSize = new int [1];
+		OS.gtk_widget_style_get (parentHandle, OS.expander_size, expanderSize, 0);
+		rect.x += depth * (expanderSize[0] + TreeItem.EXPANDER_EXTRA_PADDING);  
+	}
+	OS.gtk_tree_path_free (path);
+	
+	OS.gtk_widget_style_get (parentHandle, OS.horizontal_separator, buffer, 0);
+	int horizontalSeparator = buffer[0];
+	rect.x += horizontalSeparator;
+	if (OS.GTK_VERSION >= OS.VERSION (2, 1, 3)) {
+		OS.gtk_tree_view_column_cell_get_position (column, textRenderer, x, null);
+		rect.x += x [0];
+	} else {
+		if ((parent.style & SWT.CHECK) != 0) {
+			OS.gtk_cell_renderer_get_size (parent.checkRenderer, parentHandle, null, null, null, w, null);
+			rect.x += w [0] + horizontalSeparator;
+		}
+		OS.gtk_cell_renderer_get_size (pixbufRenderer, parentHandle, null, null, null, w, null);
+		rect.x += w [0] + horizontalSeparator;
+	}
+	if (parent.columnCount > 0) {
+		if (rect.x + rect.width > right) {
+			rect.width = Math.max (0, right - rect.x);
+		}
+	}
+	int width = OS.gtk_tree_view_column_get_visible (column) ? rect.width + 1 : 0;
+	return new Rectangle (rect.x, rect.y, width, rect.height + 1);
+}
+
+/**
+ * Searches the receiver's list starting at the first item
+ * (index 0) until an item is found that is equal to the 
+ * argument, and returns the index of that item. If no item
+ * is found, returns -1.
+ *
+ * @param item the search item
+ * @return the index of the item
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the item is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the item has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.1
+ */
+public int indexOf (TreeItem item) {
+	checkWidget();
+	if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if (item.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);
+	int index = -1;
+	boolean isParent = false;
+	int /*long*/ currentPath = OS.gtk_tree_model_get_path (parent.modelHandle, handle);
+	int /*long*/ parentPath = OS.gtk_tree_model_get_path (parent.modelHandle, item.handle);
+	int depth = OS.gtk_tree_path_get_depth (parentPath);
+	if (depth > 1 && OS.gtk_tree_path_up(parentPath)) {
+		if (OS.gtk_tree_path_compare(currentPath, parentPath) == 0) isParent = true;
+	}
+	OS.gtk_tree_path_free (currentPath);
+	OS.gtk_tree_path_free (parentPath);
+	if (!isParent) return index;
+	int /*long*/ path = OS.gtk_tree_model_get_path (parent.modelHandle, item.handle);
+	if (depth > 1) {
+		int /*long*/ indices = OS.gtk_tree_path_get_indices (path);
+		if (indices != 0) {	
+			int[] temp = new int[depth];
+			OS.memmove (temp, indices, 4 * temp.length);
+			index = temp[temp.length - 1];
+		}
+	}
+	OS.gtk_tree_path_free (path);
+	return index;
+}
+
+void redraw () {
+	int /*long*/ parentHandle = parent.handle;
+	if ((OS.GTK_WIDGET_FLAGS (parentHandle) & OS.GTK_REALIZED) != 0) {
+		int /*long*/ path = OS.gtk_tree_model_get_path (parent.modelHandle, handle);
+		GdkRectangle rect = new GdkRectangle ();
+		OS.gtk_tree_view_get_cell_area (parentHandle, path, 0, rect);
+		OS.gtk_tree_path_free (path);
+		int /*long*/ window = OS.gtk_tree_view_get_bin_window (parentHandle);
+		rect.x = 0;
+		int [] w = new int [1], h = new int [1];
+		OS.gdk_drawable_get_size (window, w, h);
+		rect.width = w [0];
+		OS.gdk_window_invalidate_rect (window, rect, false);
+	}
+}
+
+void releaseChildren (boolean destroy) {
+	if (destroy) {
+		parent.releaseItems (handle);
+	}
+	super.releaseChildren (destroy);
+}
+
+void releaseHandle () {
+	if (handle != 0) OS.g_free (handle);
+	handle = 0;
+	super.releaseHandle ();
+	parent = null;
+}
+
+void releaseWidget () {
+	super.releaseWidget ();
+	font = null;
+	cellFont = null;
+}
+
+/**
+ * Removes all of the items from the receiver.
+ * <p>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 3.1
+ */
+public void removeAll () {
+	checkWidget ();
+	int length = OS.gtk_tree_model_iter_n_children (parent.modelHandle, handle);
+	if (length == 0) return;
+	int /*long*/ iter = OS.g_malloc (OS.GtkTreeIter_sizeof ());
+	int [] index = new int [1];
+	while (OS.gtk_tree_model_iter_children (parent.modelHandle, iter, handle)) {
+		OS.gtk_tree_model_get (parent.modelHandle, iter, Tree.ID_COLUMN, index, -1);
+		if (index [0] != -1) {
+			TreeItem item = parent.items [index [0]];
+			if (item != null && !item.isDisposed ()) {
+				item.dispose ();
+			}
+		}
+	}
+	OS.g_free (iter);
+}
+
+/**
+ * Sets the receiver's background color to the color specified
+ * by the argument, or to the default system color for the item
+ * if the argument is null.
+ *
+ * @param color the new color (or null)
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li> 
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 2.0
+ * 
+ */
+public void setBackground (Color color) {
+	checkWidget ();
+	if (color != null && color.isDisposed ()) {
+		SWT.error (SWT.ERROR_INVALID_ARGUMENT);
+	}
+	if (_getBackground ().equals (color)) return;
+	GdkColor gdkColor = color != null ? color.handle : null;
+	OS.gtk_tree_store_set (parent.modelHandle, handle, Tree.BACKGROUND_COLUMN, gdkColor, -1);
+	/*
+	* Bug in GTK.  When using fixed-height-mode,
+	* row changes do not cause the row to be repainted.  The fix is to
+	* invalidate the row when it is cleared.
+	*/
+	if ((parent.style & SWT.VIRTUAL) != 0) {
+		if (OS.GTK_VERSION >= OS.VERSION (2, 3, 2) && OS.GTK_VERSION < OS.VERSION (2, 6, 3)) {
+			redraw ();
+		}
+	}
+	cached = true;
+}
+
+/**
+ * Sets the background color at the given column index in the receiver 
+ * to the color specified by the argument, or to the default system color for the item
+ * if the argument is null.
+ *
+ * @param index the column index
+ * @param color the new color (or null)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li> 
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.1
+ * 
+ */
+public void setBackground (int index, Color color) {
+	checkWidget ();
+	if (color != null && color.isDisposed ()) {
+		SWT.error (SWT.ERROR_INVALID_ARGUMENT);
+	}
+	if (_getBackground (index).equals (color)) return;
+	int count = Math.max (1, parent.getColumnCount ());
+	if (0 > index || index > count - 1) return;
+	int modelIndex = parent.columnCount == 0 ? Tree.FIRST_COLUMN : parent.columns [index].modelIndex;
+	GdkColor gdkColor = color != null ? color.handle : null;
+	OS.gtk_tree_store_set (parent.modelHandle, handle, modelIndex + Tree.CELL_BACKGROUND, gdkColor, -1);
+	/*
+	* Bug in GTK.  When using fixed-height-mode,
+	* row changes do not cause the row to be repainted.  The fix is to
+	* invalidate the row when it is cleared.
+	*/
+	if ((parent.style & SWT.VIRTUAL) != 0) {
+		if (OS.GTK_VERSION >= OS.VERSION (2, 3, 2) && OS.GTK_VERSION < OS.VERSION (2, 6, 3)) {
+			redraw ();
+		}
+	}
+	cached = true;
+	
+	if (color != null) {
+		boolean customDraw = (parent.columnCount == 0)  ? parent.firstCustomDraw : parent.columns [index].customDraw;
+		if (!customDraw) {
+			if ((parent.style & SWT.VIRTUAL) == 0) {
+				int /*long*/ parentHandle = parent.handle;
+				int /*long*/ column = 0;
+				if (parent.columnCount > 0) {
+					column = parent.columns [index].handle;
+				} else {
+					column = OS.gtk_tree_view_get_column (parentHandle, index);
+				}
+				if (column == 0) return;
+				int /*long*/ textRenderer = parent.getTextRenderer (column);
+				int /*long*/ imageRenderer = parent.getPixbufRenderer (column);
+				OS.gtk_tree_view_column_set_cell_data_func (column, textRenderer, display.cellDataProc, parentHandle, 0);
+				OS.gtk_tree_view_column_set_cell_data_func (column, imageRenderer, display.cellDataProc, parentHandle, 0);
+			}
+			if (parent.columnCount == 0) {
+				parent.firstCustomDraw = true;
+			} else {
+				parent.columns [index].customDraw = true;
+			}
+		}
+	}
+}
+
+/**
+ * Sets the checked state of the receiver.
+ * <p>
+ *
+ * @param checked the new checked state
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setChecked (boolean checked) {
+	checkWidget();
+	if ((parent.style & SWT.CHECK) == 0) return;
+	if (_getChecked () == checked) return;
+	OS.gtk_tree_store_set (parent.modelHandle, handle, Tree.CHECKED_COLUMN, checked, -1);
+	/*
+	* GTK+'s "inconsistent" state does not match SWT's concept of grayed.  To
+	* show checked+grayed differently from unchecked+grayed, we must toggle the
+	* grayed state on check and uncheck. 
+	*/
+	OS.gtk_tree_store_set (parent.modelHandle, handle, Tree.GRAYED_COLUMN, !checked ? false : grayed, -1);
+	cached = true;
+}
+
+/**
+ * Sets the expanded state of the receiver.
+ * <p>
+ *
+ * @param expanded the new expanded state
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setExpanded (boolean expanded) {
+	checkWidget();
+	int /*long*/ path = OS.gtk_tree_model_get_path (parent.modelHandle, handle);
+	if (expanded) {
+		OS.g_signal_handlers_block_matched (parent.handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, TEST_EXPAND_ROW);
+		OS.gtk_tree_view_expand_row (parent.handle, path, false);
+		OS.g_signal_handlers_unblock_matched (parent.handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, TEST_EXPAND_ROW);
+	} else {
+		OS.g_signal_handlers_block_matched (parent.handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, TEST_COLLAPSE_ROW);
+		OS.gtk_widget_realize (parent.handle);
+		OS.gtk_tree_view_collapse_row (parent.handle, path);
+		OS.g_signal_handlers_unblock_matched (parent.handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, TEST_COLLAPSE_ROW);
+	}
+	OS.gtk_tree_path_free (path);
+	cached = true;
+}
+
+
+/**
+ * Sets the font that the receiver will use to paint textual information
+ * for this item to the font specified by the argument, or to the default font
+ * for that kind of control if the argument is null.
+ *
+ * @param font the new font (or null)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li> 
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.0
+ */
+public void setFont (Font font){
+	checkWidget ();
+	if (font != null && font.isDisposed ()) {
+		SWT.error (SWT.ERROR_INVALID_ARGUMENT);
+	}
+	Font oldFont = this.font;
+	if (oldFont == font) return;
+	this.font = font;
+	if (oldFont != null && oldFont.equals (font)) return;
+	int /*long*/ fontHandle = font != null ? font.handle : 0;
+	OS.gtk_tree_store_set (parent.modelHandle, handle, Tree.FONT_COLUMN, fontHandle, -1);
+	/*
+	* Bug in GTK.  When using fixed-height-mode,
+	* row changes do not cause the row to be repainted.  The fix is to
+	* invalidate the row when it is cleared.
+	*/
+	if ((parent.style & SWT.VIRTUAL) != 0) {
+		if (OS.GTK_VERSION >= OS.VERSION (2, 3, 2) && OS.GTK_VERSION < OS.VERSION (2, 6, 3)) {
+			redraw ();
+		}
+	}
+	cached = true;
+}
+
+/**
+ * Sets the font that the receiver will use to paint textual information
+ * for the specified cell in this item to the font specified by the 
+ * argument, or to the default font for that kind of control if the 
+ * argument is null.
+ *
+ * @param index the column index
+ * @param font the new font (or null)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li> 
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.1
+ */
+public void setFont (int index, Font font) {
+	checkWidget ();
+	if (font != null && font.isDisposed ()) {
+		SWT.error (SWT.ERROR_INVALID_ARGUMENT);
+	}
+	int count = Math.max (1, parent.getColumnCount ());
+	if (0 > index || index > count - 1) return;
+	if (cellFont == null) {
+		if (font == null) return;
+		cellFont = new Font [count];
+	}
+	Font oldFont = cellFont [index];
+	if (oldFont == font) return;
+	cellFont [index] = font;
+	if (oldFont != null && oldFont.equals (font)) return;
+	
+	int modelIndex = parent.columnCount == 0 ? Tree.FIRST_COLUMN : parent.columns [index].modelIndex;
+	int /*long*/ fontHandle  = font != null ? font.handle : 0;
+	OS.gtk_tree_store_set (parent.modelHandle, handle, modelIndex + Tree.CELL_FONT, fontHandle, -1);
+	/*
+	* Bug in GTK.  When using fixed-height-mode,
+	* row changes do not cause the row to be repainted.  The fix is to
+	* invalidate the row when it is cleared.
+	*/
+	if ((parent.style & SWT.VIRTUAL) != 0) {
+		if (OS.GTK_VERSION >= OS.VERSION (2, 3, 2) && OS.GTK_VERSION < OS.VERSION (2, 6, 3)) {
+			redraw ();
+		}
+	}
+	cached = true;
+	
+	if (font != null) {
+		boolean customDraw = (parent.columnCount == 0)  ? parent.firstCustomDraw : parent.columns [index].customDraw;
+		if (!customDraw) {
+			if ((parent.style & SWT.VIRTUAL) == 0) {
+				int /*long*/ parentHandle = parent.handle;
+				int /*long*/ column = 0;
+				if (parent.columnCount > 0) {
+					column = parent.columns [index].handle;
+				} else {
+					column = OS.gtk_tree_view_get_column (parentHandle, index);
+				}
+				if (column == 0) return;
+				int /*long*/ textRenderer = parent.getTextRenderer (column);
+				int /*long*/ imageRenderer = parent.getPixbufRenderer (column);
+				OS.gtk_tree_view_column_set_cell_data_func (column, textRenderer, display.cellDataProc, parentHandle, 0);
+				OS.gtk_tree_view_column_set_cell_data_func (column, imageRenderer, display.cellDataProc, parentHandle, 0);
+			}
+			if (parent.columnCount == 0) {
+				parent.firstCustomDraw = true;
+			} else {
+				parent.columns [index].customDraw = true;
+			}
+		}
+	}
+}
+
+/**
+ * Sets the receiver's foreground color to the color specified
+ * by the argument, or to the default system color for the item
+ * if the argument is null.
+ *
+ * @param color the new color (or null)
+ *
+ * @since 2.0
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li> 
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 2.0
+ * 
+ */
+public void setForeground (Color color){
+	checkWidget ();
+	if (color != null && color.isDisposed ()) {
+		SWT.error (SWT.ERROR_INVALID_ARGUMENT);
+	}
+	if (_getForeground ().equals (color)) return;
+	GdkColor gdkColor = color != null ? color.handle : null;
+	OS.gtk_tree_store_set (parent.modelHandle, handle, Tree.FOREGROUND_COLUMN, gdkColor, -1);
+	/*
+	* Bug in GTK.  When using fixed-height-mode,
+	* row changes do not cause the row to be repainted.  The fix is to
+	* invalidate the row when it is cleared.
+	*/
+	if ((parent.style & SWT.VIRTUAL) != 0) {
+		if (OS.GTK_VERSION >= OS.VERSION (2, 3, 2) && OS.GTK_VERSION < OS.VERSION (2, 6, 3)) {
+			redraw ();
+		}
+	}
+	cached = true;
+}
+
+/**
+ * Sets the foreground color at the given column index in the receiver 
+ * to the color specified by the argument, or to the default system color for the item
+ * if the argument is null.
+ *
+ * @param index the column index
+ * @param color the new color (or null)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li> 
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.1
+ * 
+ */
+public void setForeground (int index, Color color){
+	checkWidget ();
+	if (color != null && color.isDisposed ()) {
+		SWT.error (SWT.ERROR_INVALID_ARGUMENT);
+	}
+	if (_getForeground (index).equals (color)) return;
+	int count = Math.max (1, parent.getColumnCount ());
+	if (0 > index || index > count - 1) return;
+	int modelIndex = parent.columnCount == 0 ? Tree.FIRST_COLUMN : parent.columns [index].modelIndex;
+	GdkColor gdkColor = color != null ? color.handle : null;
+	OS.gtk_tree_store_set (parent.modelHandle, handle, modelIndex + Tree.CELL_FOREGROUND, gdkColor, -1);
+	/*
+	* Bug in GTK.  When using fixed-height-mode,
+	* row changes do not cause the row to be repainted.  The fix is to
+	* invalidate the row when it is cleared.
+	*/
+	if ((parent.style & SWT.VIRTUAL) != 0) {
+		if (OS.GTK_VERSION >= OS.VERSION (2, 3, 2) && OS.GTK_VERSION < OS.VERSION (2, 6, 3)) {
+			redraw ();
+		}
+	}
+	cached = true;
+	
+	if (color != null) {
+		boolean customDraw = (parent.columnCount == 0)  ? parent.firstCustomDraw : parent.columns [index].customDraw;
+		if (!customDraw) {
+			if ((parent.style & SWT.VIRTUAL) == 0) {
+				int /*long*/ parentHandle = parent.handle;
+				int /*long*/ column = 0;
+				if (parent.columnCount > 0) {
+					column = parent.columns [index].handle;
+				} else {
+					column = OS.gtk_tree_view_get_column (parentHandle, index);
+				}
+				if (column == 0) return;
+				int /*long*/ textRenderer = parent.getTextRenderer (column);
+				int /*long*/ imageRenderer = parent.getPixbufRenderer (column);
+				OS.gtk_tree_view_column_set_cell_data_func (column, textRenderer, display.cellDataProc, parentHandle, 0);
+				OS.gtk_tree_view_column_set_cell_data_func (column, imageRenderer, display.cellDataProc, parentHandle, 0);
+			}
+			if (parent.columnCount == 0) {
+				parent.firstCustomDraw = true;
+			} else {
+				parent.columns [index].customDraw = true;
+			}
+		}
+	}
+}
+
+/**
+ * Sets the grayed state of the checkbox for this item.  This state change 
+ * only applies if the Tree was created with the SWT.CHECK style.
+ *
+ * @param grayed the new grayed state of the checkbox
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setGrayed (boolean grayed) {
+	checkWidget();
+	if ((parent.style & SWT.CHECK) == 0) return;
+	if (this.grayed == grayed) return;
+	this.grayed = grayed;
+	/*
+	* GTK+'s "inconsistent" state does not match SWT's concept of grayed.
+	* Render checked+grayed as "inconsistent", unchecked+grayed as blank.
+	*/
+	int /*long*/ [] ptr = new int /*long*/ [1];
+	OS.gtk_tree_model_get (parent.modelHandle, handle, Tree.CHECKED_COLUMN, ptr, -1);
+	OS.gtk_tree_store_set (parent.modelHandle, handle, Tree.GRAYED_COLUMN, ptr [0] == 0 ? false : grayed, -1);
+	cached = true;
+}
+
+/**
+ * Sets the receiver's image at a column.
+ *
+ * @param index the column index
+ * @param image the new image
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.1
+ */
+public void setImage (int index, Image image) {
+	checkWidget ();
+	if (image != null && image.isDisposed()) {
+		error(SWT.ERROR_INVALID_ARGUMENT);
+	}
+	if (image != null && image.type == SWT.ICON) {
+		if (image.equals (_getImage (index))) return;
+	}
+	int count = Math.max (1, parent.getColumnCount ());
+	if (0 > index || index > count - 1) return;
+	int /*long*/ pixbuf = 0;
+	if (image != null) {
+		ImageList imageList = parent.imageList;
+		if (imageList == null) imageList = parent.imageList = new ImageList ();
+		int imageIndex = imageList.indexOf (image);
+		if (imageIndex == -1) imageIndex = imageList.add (image);
+		pixbuf = imageList.getPixbuf (imageIndex);
+	}
+	int modelIndex = parent.columnCount == 0 ? Tree.FIRST_COLUMN : parent.columns [index].modelIndex;
+	OS.gtk_tree_store_set (parent.modelHandle, handle, modelIndex + Tree.CELL_PIXBUF, pixbuf, -1);
+	/*
+	* Bug in GTK.  When using fixed-height-mode,
+	* row changes do not cause the row to be repainted.  The fix is to
+	* invalidate the row when the image changes.
+	*/
+	if ((parent.style & SWT.VIRTUAL) != 0) {
+		if (OS.GTK_VERSION >= OS.VERSION (2, 3, 2) && OS.GTK_VERSION < OS.VERSION (2, 6, 3)) {
+			if (parent.columnCount == 0) {
+				redraw ();
+			}
+		}
+	}
+	/*
+	* Bug in GTK.  When using fixed-height-mode, GTK does not recalculate the cell renderer width
+	* when the image is changed in the model.  The fix is to force it to recalculate the width if
+	* more space is required.
+	*/
+	if ((parent.style & SWT.VIRTUAL) != 0 && parent.currentItem == null) {
+		if (OS.GTK_VERSION >= OS.VERSION (2, 3, 2)) {
+			if (image != null) {
+				int /*long*/parentHandle = parent.handle;
+				int /*long*/ column = OS.gtk_tree_view_get_column (parentHandle, index);
+				int [] w = new int [1];
+				int /*long*/ pixbufRenderer = parent.getPixbufRenderer(column);
+				OS.gtk_tree_view_column_cell_get_position (column, pixbufRenderer, null, w);
+				if (w[0] < image.getBounds().width) {
+					/*
+					 * There is no direct way to clear the cell renderer width so we
+					 * are relying on the fact that it is done as part of modifying
+					 * the style.
+					 */
+					int /*long*/ style = OS.gtk_widget_get_modifier_style (parentHandle);
+					parent.modifyStyle (parentHandle, style);
+				}
+			} 
+		}
+	}
+	cached = true;
+}
+
+public void setImage (Image image) {
+	checkWidget ();
+	setImage (0, image);
+}
+
+/**
+ * Sets the image for multiple columns in the tree. 
+ * 
+ * @param images the array of new images
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the array of images is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if one of the images has been disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.1
+ */
+public void setImage (Image [] images) {
+	checkWidget ();
+	if (images == null) error (SWT.ERROR_NULL_ARGUMENT);
+	for (int i=0; i<images.length; i++) {
+		setImage (i, images [i]);
+	}
+}
+
+/**
+ * Sets the number of child items contained in the receiver.
+ *
+ * @param count the number of items
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 3.2
+ */
+public void setItemCount (int count) {
+	checkWidget ();
+	count = Math.max (0, count);
+	parent.setItemCount (handle, count);
+}
+
+/**
+ * Sets the receiver's text at a column
+ *
+ * @param index the column index
+ * @param string the new text
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the text is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.1
+ */
+public void setText (int index, String string) {
+	checkWidget ();
+	if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if (_getText (index).equals (string)) return;
+	int count = Math.max (1, parent.getColumnCount ());
+	if (0 > index || index > count - 1) return;
+	byte[] buffer = Converter.wcsToMbcs (null, string, true);
+	int modelIndex = parent.columnCount == 0 ? Tree.FIRST_COLUMN : parent.columns [index].modelIndex;
+	OS.gtk_tree_store_set (parent.modelHandle, handle, modelIndex + Tree.CELL_TEXT, buffer, -1);
+	/*
+	* Bug in GTK.  When using fixed-height-mode,
+	* row changes do not cause the row to be repainted.  The fix is to
+	* invalidate the row when the text changes.
+	*/
+	if ((parent.style & SWT.VIRTUAL) != 0) {
+		if (OS.GTK_VERSION >= OS.VERSION (2, 3, 2) && OS.GTK_VERSION < OS.VERSION (2, 6, 3)) {
+			redraw ();
+		}
+	}
+	cached = true;
+}
+
+public void setText (String string) {
+	checkWidget ();
+	setText (0, string);
+}
+
+/**
+ * Sets the text for multiple columns in the tree. 
+ * 
+ * @param strings the array of new strings
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the text is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @since 3.1
+ */
+public void setText (String [] strings) {
+	checkWidget ();
+	if (strings == null) error (SWT.ERROR_NULL_ARGUMENT);
+	for (int i=0; i<strings.length; i++) {
+		String string = strings [i];
+		if (string != null) setText (i, string);
+	}
+}
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/TypedListener.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/TypedListener.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/TypedListener.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,257 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.widgets;
+
+
+import org.eclipse.swt.internal.SWTEventListener;
+import org.eclipse.swt.*;
+import org.eclipse.swt.events.*;
+
+/**	 
+ * Instances of this class are <em>internal SWT implementation</em>
+ * objects which provide a mapping between the typed and untyped 
+ * listener mechanisms that SWT supports.
+ * <p>
+ * <b>IMPORTANT:</b> This class is <em>not</em> part of the SWT
+ * public API. It is marked public only so that it can be shared
+ * within the packages provided by SWT. It should never be
+ * referenced from application code.
+ * </p>
+ *
+ * @see Listener
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public class TypedListener implements Listener {
+	
+	/**
+	 * The receiver's event listener
+	 */
+	protected SWTEventListener eventListener;
+
+/**
+ * Constructs a new instance of this class for the given event listener.
+ * <p>
+ * <b>IMPORTANT:</b> This method is <em>not</em> part of the SWT
+ * public API. It is marked public only so that it can be shared
+ * within the packages provided by SWT. It should never be
+ * referenced from application code.
+ * </p>
+ *
+ * @param listener the event listener to store in the receiver
+ */
+public TypedListener (SWTEventListener listener) {
+	eventListener = listener;
+}
+
+/**
+ * Returns the receiver's event listener.
+ * <p>
+ * <b>IMPORTANT:</b> This method is <em>not</em> part of the SWT
+ * public API. It is marked public only so that it can be shared
+ * within the packages provided by SWT. It should never be
+ * referenced from application code.
+ * </p>
+ *
+ * @return the receiver's event listener
+ */
+public SWTEventListener getEventListener () {
+	return eventListener;
+}
+
+/**
+ * Handles the given event.
+ * <p>
+ * <b>IMPORTANT:</b> This method is <em>not</em> part of the SWT
+ * public API. It is marked public only so that it can be shared
+ * within the packages provided by SWT. It should never be
+ * referenced from application code.
+ * </p>
+ * @param e the event to handle
+ */
+public void handleEvent (Event e) {
+	switch (e.type) {
+		case SWT.Activate: {
+			((ShellListener) eventListener).shellActivated(new ShellEvent(e));
+			break;
+		}
+		case SWT.Arm: {
+			((ArmListener) eventListener).widgetArmed (new ArmEvent (e));
+			break;
+		}
+		case SWT.Close: {
+			/* Fields set by Decorations */
+			ShellEvent event = new ShellEvent (e);
+			((ShellListener) eventListener).shellClosed(event);
+			e.doit = event.doit;
+			break;
+		}
+		case SWT.Collapse: {
+			if (eventListener instanceof TreeListener) {
+				((TreeListener) eventListener).treeCollapsed(new TreeEvent(e));
+			} else {
+				((ExpandListener) eventListener).itemCollapsed(new ExpandEvent(e));	
+			}
+			break;
+		}
+		case SWT.Deactivate: {
+			((ShellListener) eventListener).shellDeactivated(new ShellEvent(e));
+			break;
+		}
+		case SWT.Deiconify: {
+			((ShellListener) eventListener).shellDeiconified(new ShellEvent(e));
+			break;
+		}
+		case SWT.DefaultSelection: {
+			((SelectionListener)eventListener).widgetDefaultSelected(new SelectionEvent(e));
+			break;
+		}
+		case SWT.Dispose: {
+			((DisposeListener) eventListener).widgetDisposed(new DisposeEvent(e));
+			break;
+		}
+		case SWT.DragDetect: {
+			((DragDetectListener) eventListener).dragDetected(new DragDetectEvent(e));
+			break;
+		}
+		case SWT.Expand: {
+			if (eventListener instanceof TreeListener) {
+				((TreeListener) eventListener).treeExpanded(new TreeEvent(e));
+			} else {
+				((ExpandListener) eventListener).itemExpanded(new ExpandEvent(e));	
+			}
+			break;
+		}
+		case SWT.FocusIn: {
+			((FocusListener) eventListener).focusGained(new FocusEvent(e));
+			break;
+		}
+		case SWT.FocusOut: {
+			((FocusListener) eventListener).focusLost(new FocusEvent(e));
+			break;
+		}
+		case SWT.Help: {
+			((HelpListener) eventListener).helpRequested (new HelpEvent (e));
+			break;
+		}
+		case SWT.Hide: {
+			((MenuListener) eventListener).menuHidden(new MenuEvent(e));
+			break;
+		}
+		case SWT.Iconify: {
+			((ShellListener) eventListener).shellIconified(new ShellEvent(e));
+			break;
+		}
+		case SWT.KeyDown: {
+			/* Fields set by Control */
+			KeyEvent event = new KeyEvent(e);
+			((KeyListener) eventListener).keyPressed(event);
+			e.doit = event.doit;
+			break;
+		}
+		case SWT.KeyUp: {
+			/* Fields set by Control */
+			KeyEvent event = new KeyEvent(e);
+			((KeyListener) eventListener).keyReleased(event);
+			e.doit = event.doit;
+			break;
+		}
+		case SWT.Modify: {
+			((ModifyListener) eventListener).modifyText(new ModifyEvent(e));
+			break;
+		}
+		case SWT.MenuDetect: {
+			MenuDetectEvent event = new MenuDetectEvent(e);
+			((MenuDetectListener) eventListener).menuDetected(event);
+			e.x = event.x;
+			e.y = event.y;
+			e.doit = event.doit;
+			break;
+		}
+		case SWT.MouseDown: {
+			((MouseListener) eventListener).mouseDown(new MouseEvent(e));
+			break;
+		}
+		case SWT.MouseDoubleClick: {
+			((MouseListener) eventListener).mouseDoubleClick(new MouseEvent(e));
+			break;
+		}
+		case SWT.MouseEnter: {
+			((MouseTrackListener) eventListener).mouseEnter (new MouseEvent (e));
+			break;
+		}
+		case SWT.MouseExit: {
+			((MouseTrackListener) eventListener).mouseExit (new MouseEvent (e));
+			break;
+		}
+		case SWT.MouseHover: {
+			((MouseTrackListener) eventListener).mouseHover (new MouseEvent (e));
+			break;
+		}
+		case SWT.MouseMove: {
+			((MouseMoveListener) eventListener).mouseMove(new MouseEvent(e));
+			return;
+		}
+		case SWT.MouseWheel: {
+			((MouseWheelListener) eventListener).mouseScrolled(new MouseEvent(e));
+			return;
+		}
+		case SWT.MouseUp: {
+			((MouseListener) eventListener).mouseUp(new MouseEvent(e));
+			break;
+		}
+		case SWT.Move: {
+			((ControlListener) eventListener).controlMoved(new ControlEvent(e));
+			break;
+		}
+		case SWT.Paint: {
+			/* Fields set by Control */
+			PaintEvent event = new PaintEvent (e);
+			((PaintListener) eventListener).paintControl (event);
+			e.gc = event.gc;
+			break;
+		}
+		case SWT.Resize: {
+			((ControlListener) eventListener).controlResized(new ControlEvent(e));
+			break;
+		}
+		case SWT.Selection: {
+			/* Fields set by Sash */
+			SelectionEvent event = new SelectionEvent (e);
+			((SelectionListener) eventListener).widgetSelected (event);			
+			e.x = event.x;
+			e.y = event.y;
+			e.doit = event.doit;
+			break;
+		}
+		case SWT.Show: {
+			((MenuListener) eventListener).menuShown(new MenuEvent(e));
+			break;
+		}
+		case SWT.Traverse: {
+			/* Fields set by Control */
+			TraverseEvent event = new TraverseEvent (e);
+			((TraverseListener) eventListener).keyTraversed (event);
+			e.detail = event.detail;
+			e.doit = event.doit;
+			break;
+		}
+		case SWT.Verify: {
+			/* Fields set by Text, RichText */
+			VerifyEvent event = new VerifyEvent (e);
+			((VerifyListener) eventListener).verifyText (event);
+			e.text = event.text;
+			e.doit = event.doit;
+			break;
+		}
+	}
+}
+
+}

Added: branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Widget.java
===================================================================
--- branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Widget.java	                        (rev 0)
+++ branches/upstream/swt-gtk/current/org/eclipse/swt/widgets/Widget.java	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,1587 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.widgets;
+
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.gtk.*;
+import org.eclipse.swt.events.*;
+
+/**
+ * This class is the abstract superclass of all user interface objects.  
+ * Widgets are created, disposed and issue notification to listeners
+ * when events occur which affect them.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>(none)</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Dispose</dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is intended to be subclassed <em>only</em>
+ * within the SWT implementation. However, it has not been marked
+ * final to allow those outside of the SWT development team to implement
+ * patched versions of the class in order to get around specific
+ * limitations in advance of when those limitations can be addressed
+ * by the team.  Any class built using subclassing to access the internals
+ * of this class will likely fail to compile or run between releases and
+ * may be strongly platform specific. Subclassing should not be attempted
+ * without an intimate and detailed understanding of the workings of the
+ * hierarchy. No support is provided for user-written classes which are
+ * implemented as subclasses of this class.
+ * </p>
+ *
+ * @see #checkSubclass
+ * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
+ */
+public abstract class Widget {
+	/**
+	 * the handle to the OS resource 
+	 * (Warning: This field is platform dependent)
+	 * <p>
+	 * <b>IMPORTANT:</b> This field is <em>not</em> part of the SWT
+	 * public API. It is marked public only so that it can be shared
+	 * within the packages provided by SWT. It is not available on all
+	 * platforms and should never be accessed from application code.
+	 * </p>
+	 */
+	public int /*long*/ handle;
+	int style, state;
+	Display display;
+	EventTable eventTable;
+	Object data;
+	
+	/* Global state flags */
+	static final int DISPOSED = 1<<0;
+	static final int CANVAS = 1<<1;
+	static final int KEYED_DATA = 1<<2;
+	static final int HANDLE = 1<<3;
+	static final int DISABLED = 1<<4;
+	static final int MENU = 1<<5;
+	static final int OBSCURED = 1<<6;
+	static final int MOVED = 1<<7;
+	static final int RESIZED = 1<<8;
+	static final int ZERO_WIDTH = 1<<9;
+	static final int ZERO_HEIGHT = 1<<10;
+	static final int HIDDEN = 1<<11;
+	static final int FOREGROUND = 1<<12;
+	static final int BACKGROUND = 1<<13;
+	static final int FONT = 1<<14;
+	static final int PARENT_BACKGROUND = 1<<15;
+	static final int THEME_BACKGROUND = 1<<16;
+	
+	/* A layout was requested on this widget */
+	static final int LAYOUT_NEEDED	= 1<<17;
+	
+	/* The preferred size of a child has changed */
+	static final int LAYOUT_CHANGED = 1<<18;
+	
+	/* A layout was requested in this widget hierachy */
+	static final int LAYOUT_CHILD = 1<<19;
+
+	/* More global state flags */
+	static final int RELEASED = 1<<20;
+	static final int DISPOSE_SENT = 1<<21;
+	static final int FOREIGN_HANDLE = 1<<22;
+	static final int DRAG_DETECT = 1<<23;
+	
+	/* Default size for widgets */
+	static final int DEFAULT_WIDTH	= 64;
+	static final int DEFAULT_HEIGHT	= 64;
+	
+	/* GTK signals data */
+	static final int ACTIVATE = 1;
+	static final int BUTTON_PRESS_EVENT = 2;
+	static final int BUTTON_PRESS_EVENT_INVERSE = 3;
+	static final int BUTTON_RELEASE_EVENT = 4;
+	static final int BUTTON_RELEASE_EVENT_INVERSE = 5;
+	static final int CHANGED = 6;
+	static final int CHANGE_VALUE = 7;
+	static final int CLICKED = 8;
+	static final int COMMIT = 9;
+	static final int CONFIGURE_EVENT = 10;
+	static final int DELETE_EVENT = 11;
+	static final int DELETE_RANGE = 12;
+	static final int DELETE_TEXT = 13;
+	static final int ENTER_NOTIFY_EVENT = 14;
+	static final int EVENT = 15;
+	static final int EVENT_AFTER = 16;
+	static final int EXPAND_COLLAPSE_CURSOR_ROW = 17;
+	static final int EXPOSE_EVENT = 18;
+	static final int EXPOSE_EVENT_INVERSE = 19;
+	static final int FOCUS = 20;
+	static final int FOCUS_IN_EVENT = 21;
+	static final int FOCUS_OUT_EVENT = 22;
+	static final int GRAB_FOCUS = 23;
+	static final int HIDE = 24;
+	static final int INPUT = 25;
+	static final int INSERT_TEXT = 26;
+	static final int KEY_PRESS_EVENT = 27;
+	static final int KEY_RELEASE_EVENT = 28;
+	static final int LEAVE_NOTIFY_EVENT = 29;
+	static final int MAP = 30;
+	static final int MAP_EVENT = 31;
+	static final int MNEMONIC_ACTIVATE = 32;
+	static final int MOTION_NOTIFY_EVENT = 33;
+	static final int MOTION_NOTIFY_EVENT_INVERSE = 34;
+	static final int MOVE_FOCUS = 35;
+	static final int OUTPUT = 36;
+	static final int POPULATE_POPUP = 37;
+	static final int POPUP_MENU = 38;
+	static final int PREEDIT_CHANGED = 39;
+	static final int REALIZE = 40;
+	static final int ROW_ACTIVATED = 41;
+	static final int SCROLL_CHILD = 42;
+	static final int SCROLL_EVENT = 43;
+	static final int SELECT = 44;
+	static final int SHOW = 45;
+	static final int SHOW_HELP = 46;
+	static final int SIZE_ALLOCATE = 47;
+	static final int STYLE_SET = 48;
+	static final int SWITCH_PAGE = 49;
+	static final int TEST_COLLAPSE_ROW = 50;
+	static final int TEST_EXPAND_ROW = 51;
+	static final int TEXT_BUFFER_INSERT_TEXT = 52;
+	static final int TOGGLED = 53;
+	static final int UNMAP = 54;
+	static final int UNMAP_EVENT = 55;
+	static final int UNREALIZE = 56;
+	static final int VALUE_CHANGED = 57;
+	static final int VISIBILITY_NOTIFY_EVENT = 58;
+	static final int WINDOW_STATE_EVENT = 59;
+	static final int ACTIVATE_INVERSE = 60;
+	static final int DAY_SELECTED = 61;
+	static final int MONTH_CHANGED = 62;
+	static final int LAST_SIGNAL = 63;
+
+/**
+ * Prevents uninitialized instances from being created outside the package.
+ */
+Widget () {}
+
+/**
+ * Constructs a new instance of this class given its parent
+ * and a style value describing its behavior and appearance.
+ * <p>
+ * The style value is either one of the style constants defined in
+ * class <code>SWT</code> which is applicable to instances of this
+ * class, or must be built by <em>bitwise OR</em>'ing together 
+ * (that is, using the <code>int</code> "|" operator) two or more
+ * of those <code>SWT</code> style constants. The class description
+ * lists the style constants that are applicable to the class.
+ * Style bits are also inherited from superclasses.
+ * </p>
+ *
+ * @param parent a widget which will be the parent of the new instance (cannot be null)
+ * @param style the style of widget to construct
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the parent is disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT
+ * @see #checkSubclass
+ * @see #getStyle
+ */
+public Widget (Widget parent, int style) {
+	checkSubclass ();
+	checkParent (parent);
+	this.style = style;
+	display = parent.display;
+}
+
+void _addListener (int eventType, Listener listener) {
+	if (eventTable == null) eventTable = new EventTable ();
+	eventTable.hook (eventType, listener);
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when an event of the given type occurs. When the
+ * event does occur in the widget, the listener is notified by
+ * sending it the <code>handleEvent()</code> message. The event
+ * type is one of the event constants defined in class <code>SWT</code>.
+ *
+ * @param eventType the type of event to listen for
+ * @param listener the listener which should be notified when the event occurs
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see Listener
+ * @see SWT
+ * @see #getListeners(int)
+ * @see #removeListener(int, Listener)
+ * @see #notifyListeners
+ */
+public void addListener (int eventType, Listener listener) {
+	checkWidget ();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	_addListener (eventType, listener);
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the widget is disposed. When the widget is
+ * disposed, the listener is notified by sending it the
+ * <code>widgetDisposed()</code> message.
+ *
+ * @param listener the listener which should be notified when the receiver is disposed
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see DisposeListener
+ * @see #removeDisposeListener
+ */
+public void addDisposeListener (DisposeListener listener) {
+	checkWidget ();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	TypedListener typedListener = new TypedListener (listener);
+	addListener (SWT.Dispose, typedListener);
+}
+
+int /*long*/ paintWindow () {
+	return 0;
+}
+
+static int checkBits (int style, int int0, int int1, int int2, int int3, int int4, int int5) {
+	int mask = int0 | int1 | int2 | int3 | int4 | int5;
+	if ((style & mask) == 0) style |= int0;
+	if ((style & int0) != 0) style = (style & ~mask) | int0;
+	if ((style & int1) != 0) style = (style & ~mask) | int1;
+	if ((style & int2) != 0) style = (style & ~mask) | int2;
+	if ((style & int3) != 0) style = (style & ~mask) | int3;
+	if ((style & int4) != 0) style = (style & ~mask) | int4;
+	if ((style & int5) != 0) style = (style & ~mask) | int5;
+	return style;
+}
+
+int /*long*/ cellDataProc (int /*long*/ tree_column, int /*long*/ cell, int /*long*/ tree_model, int /*long*/ iter, int /*long*/ data) {
+	return 0;
+}
+
+void checkOpen () {
+	/* Do nothing */
+}
+
+void checkOrientation (Widget parent) {
+	style &= ~SWT.MIRRORED;
+	if ((style & (SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT)) == 0) {
+		if (parent != null) {
+			if ((parent.style & SWT.LEFT_TO_RIGHT) != 0) style |= SWT.LEFT_TO_RIGHT;
+			if ((parent.style & SWT.RIGHT_TO_LEFT) != 0) style |= SWT.RIGHT_TO_LEFT;
+		}
+	}
+	style = checkBits (style, SWT.LEFT_TO_RIGHT, SWT.RIGHT_TO_LEFT, 0, 0, 0, 0);
+	/* Versions of GTK prior to 2.8 do not render RTL text properly */
+	if (OS.GTK_VERSION < OS.VERSION (2, 8, 0)) {
+		style &= ~SWT.RIGHT_TO_LEFT;
+		style |= SWT.LEFT_TO_RIGHT;			
+	}
+}
+
+/**
+ * Throws an exception if the specified widget can not be
+ * used as a parent for the receiver.
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the parent is disposed</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * </ul>
+ */
+void checkParent (Widget parent) {
+	if (parent == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if (parent.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT);
+	parent.checkWidget ();
+	parent.checkOpen ();
+}
+
+/**
+ * Checks that this class can be subclassed.
+ * <p>
+ * The SWT class library is intended to be subclassed 
+ * only at specific, controlled points (most notably, 
+ * <code>Composite</code> and <code>Canvas</code> when
+ * implementing new widgets). This method enforces this
+ * rule unless it is overridden.
+ * </p><p>
+ * <em>IMPORTANT:</em> By providing an implementation of this
+ * method that allows a subclass of a class which does not 
+ * normally allow subclassing to be created, the implementer
+ * agrees to be fully responsible for the fact that any such
+ * subclass will likely fail between SWT releases and will be
+ * strongly platform specific. No support is provided for
+ * user-written classes which are implemented in this fashion.
+ * </p><p>
+ * The ability to subclass outside of the allowed SWT classes
+ * is intended purely to enable those not on the SWT development
+ * team to implement patches in order to get around specific
+ * limitations in advance of when those limitations can be
+ * addressed by the team. Subclassing should not be attempted
+ * without an intimate and detailed understanding of the hierarchy.
+ * </p>
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ */
+protected void checkSubclass () {
+	if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
+}
+
+/**
+ * Throws an <code>SWTException</code> if the receiver can not
+ * be accessed by the caller. This may include both checks on
+ * the state of the receiver and more generally on the entire
+ * execution context. This method <em>should</em> be called by
+ * widget implementors to enforce the standard SWT invariants.
+ * <p>
+ * Currently, it is an error to invoke any method (other than
+ * <code>isDisposed()</code>) on a widget that has had its 
+ * <code>dispose()</code> method called. It is also an error
+ * to call widget methods from any thread that is different
+ * from the thread that created the widget.
+ * </p><p>
+ * In future releases of SWT, there may be more or fewer error
+ * checks and exceptions may be thrown for different reasons.
+ * </p>
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+protected void checkWidget () {
+	Display display = this.display;
+	if (display == null) error (SWT.ERROR_WIDGET_DISPOSED);
+	if (display.thread != Thread.currentThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+	if ((state & DISPOSED) != 0) error (SWT.ERROR_WIDGET_DISPOSED);
+}
+
+void createHandle (int index) {
+}
+
+void createWidget (int index) {
+	createHandle (index);
+	setOrientation ();
+	hookEvents ();
+	register ();
+}
+
+void deregister () {
+	if (handle == 0) return;
+	if ((state & HANDLE) != 0) display.removeWidget (handle);
+}
+
+void destroyWidget () {
+	int /*long*/ topHandle = topHandle ();
+	releaseHandle ();
+	if (topHandle != 0 && (state & HANDLE) != 0) {
+		OS.gtk_widget_destroy (topHandle);
+	}
+}
+
+/**
+ * Disposes of the operating system resources associated with
+ * the receiver and all its descendants. After this method has
+ * been invoked, the receiver and all descendants will answer
+ * <code>true</code> when sent the message <code>isDisposed()</code>.
+ * Any internal connections between the widgets in the tree will
+ * have been removed to facilitate garbage collection.
+ * <p>
+ * NOTE: This method is not called recursively on the descendants
+ * of the receiver. This means that, widget implementers can not
+ * detect when a widget is being disposed of by re-implementing
+ * this method, but should instead listen for the <code>Dispose</code>
+ * event.
+ * </p>
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #addDisposeListener
+ * @see #removeDisposeListener
+ * @see #checkWidget
+ */
+public void dispose () {
+	/*
+	* Note:  It is valid to attempt to dispose a widget
+	* more than once.  If this happens, fail silently.
+	*/
+	if (isDisposed ()) return;
+	if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+	release (true);
+}
+
+void error (int code) {
+	SWT.error (code);
+}
+
+/**
+ * Returns the application defined widget data associated
+ * with the receiver, or null if it has not been set. The
+ * <em>widget data</em> is a single, unnamed field that is
+ * stored with every widget. 
+ * <p>
+ * Applications may put arbitrary objects in this field. If
+ * the object stored in the widget data needs to be notified
+ * when the widget is disposed of, it is the application's
+ * responsibility to hook the Dispose event on the widget and
+ * do so.
+ * </p>
+ *
+ * @return the widget data
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - when the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - when called from the wrong thread</li>
+ * </ul>
+ *
+ * @see #setData(Object)
+ */
+public Object getData () {
+	checkWidget();
+	return (state & KEYED_DATA) != 0 ? ((Object []) data) [0] : data;
+}
+/**
+ * Returns the application defined property of the receiver
+ * with the specified name, or null if it has not been set.
+ * <p>
+ * Applications may have associated arbitrary objects with the
+ * receiver in this fashion. If the objects stored in the
+ * properties need to be notified when the widget is disposed
+ * of, it is the application's responsibility to hook the
+ * Dispose event on the widget and do so.
+ * </p>
+ *
+ * @param	key the name of the property
+ * @return the value of the property or null if it has not been set
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the key is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #setData(String, Object)
+ */
+public Object getData (String key) {
+	checkWidget();
+	if (key == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if ((state & KEYED_DATA) != 0) {
+		Object [] table = (Object []) data;
+		for (int i=1; i<table.length; i+=2) {
+			if (key.equals (table [i])) return table [i+1];
+		}
+	}
+	return null;
+}
+
+/**
+ * Returns the <code>Display</code> that is associated with
+ * the receiver.
+ * <p>
+ * A widget's display is either provided when it is created
+ * (for example, top level <code>Shell</code>s) or is the
+ * same as its parent's display.
+ * </p>
+ *
+ * @return the receiver's display
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public Display getDisplay () {
+	Display display = this.display;
+	if (display == null) error (SWT.ERROR_WIDGET_DISPOSED);
+	return display;
+}
+
+/**
+ * Returns an array of listeners who will be notified when an event 
+ * of the given type occurs. The event type is one of the event constants 
+ * defined in class <code>SWT</code>.
+ *
+ * @param eventType the type of event to listen for
+ * @return an array of listeners that will be notified when the event occurs
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see Listener
+ * @see SWT
+ * @see #addListener(int, Listener)
+ * @see #removeListener(int, Listener)
+ * @see #notifyListeners
+ * 
+ * @since 3.4
+ */
+public Listener[] getListeners (int eventType) {
+	checkWidget();
+	if (eventTable == null) return new Listener[0];
+	return eventTable.getListeners(eventType);
+}
+
+String getName () {
+//	String string = getClass ().getName ();
+//	int index = string.lastIndexOf ('.');
+//	if (index == -1) return string;	
+	String string = getClass ().getName ();
+	int index = string.length ();
+	while ((--index > 0) && (string.charAt (index) != '.')) {}
+	return string.substring (index + 1, string.length ());
+}
+
+String getNameText () {
+	return "";
+}
+
+/**
+ * Returns the receiver's style information.
+ * <p>
+ * Note that the value which is returned by this method <em>may
+ * not match</em> the value which was provided to the constructor
+ * when the receiver was created. This can occur when the underlying
+ * operating system does not support a particular combination of
+ * requested styles. For example, if the platform widget used to
+ * implement a particular SWT widget always has scroll bars, the
+ * result of calling this method would always have the
+ * <code>SWT.H_SCROLL</code> and <code>SWT.V_SCROLL</code> bits set.
+ * </p>
+ *
+ * @return the style bits
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public int getStyle () {
+	checkWidget ();
+	return style;
+}
+
+
+int /*long*/ gtk_activate (int /*long*/ widget) {
+	return 0;
+}
+
+int /*long*/ gtk_button_press_event (int /*long*/ widget, int /*long*/ event) {
+	return 0;
+}
+
+int /*long*/ gtk_button_release_event (int /*long*/ widget, int /*long*/ event) {
+	return 0;
+}
+
+int /*long*/ gtk_changed (int /*long*/ widget) {
+	return 0;
+}
+
+int /*long*/ gtk_change_value (int /*long*/ widget, int /*long*/ scroll, int /*long*/ value1, int /*long*/ value2) {
+	return 0;
+}
+
+int /*long*/ gtk_clicked (int /*long*/ widget) {
+	return 0;
+}
+
+int /*long*/ gtk_commit (int /*long*/ imcontext, int /*long*/ text) {
+	return 0;
+}
+
+int /*long*/ gtk_configure_event (int /*long*/ widget, int /*long*/ event) {
+	return 0;
+}
+
+int /*long*/ gtk_day_selected (int /*long*/ widget) {
+	return 0;
+}
+
+int /*long*/ gtk_delete_event (int /*long*/ widget, int /*long*/ event) {
+	return 0;
+}
+
+int /*long*/ gtk_delete_range (int /*long*/ widget, int /*long*/ iter1, int /*long*/ iter2) {
+	return 0;
+}
+
+int /*long*/ gtk_delete_text (int /*long*/ widget, int /*long*/ start_pos, int /*long*/ end_pos) {
+	return 0;
+}
+
+int /*long*/ gtk_enter_notify_event (int /*long*/ widget, int /*long*/ event) {
+	return 0;
+}
+
+int /*long*/ gtk_event (int /*long*/ widget, int /*long*/ event) {
+	return 0;
+}
+
+int /*long*/ gtk_event_after (int /*long*/ widget, int /*long*/ event) {
+	return 0;
+}
+
+int /*long*/ gtk_expand_collapse_cursor_row (int /*long*/ widget, int /*long*/ logical, int /*long*/ expand, int /*long*/ open_all) {
+	return 0;
+}
+
+int /*long*/ gtk_expose_event (int /*long*/ widget, int /*long*/ event) {
+	return 0;
+}
+
+int /*long*/ gtk_focus (int /*long*/ widget, int /*long*/ event) {
+	return 0;
+}
+
+int /*long*/ gtk_focus_in_event (int /*long*/ widget, int /*long*/ event) {
+	return 0;
+}
+
+int /*long*/ gtk_focus_out_event (int /*long*/ widget, int /*long*/ event) {
+	return 0;
+}
+
+int /*long*/ gtk_grab_focus (int /*long*/ widget) {
+	return 0;
+}
+
+int /*long*/ gtk_hide (int /*long*/ widget) {
+	return 0;
+}
+
+int /*long*/ gtk_input (int /*long*/ widget, int /*long*/ arg1) {
+	return 0;
+}
+
+int /*long*/ gtk_insert_text (int /*long*/ widget, int /*long*/ new_text, int /*long*/ new_text_length, int /*long*/ position) {
+	return 0;
+}
+
+int /*long*/ gtk_key_press_event (int /*long*/ widget, int /*long*/ event) {
+	GdkEventKey gdkEvent = new GdkEventKey ();
+	OS.memmove (gdkEvent, event, GdkEventKey.sizeof);
+	return sendKeyEvent (SWT.KeyDown, gdkEvent) ? 0 : 1;
+}
+
+int /*long*/ gtk_key_release_event (int /*long*/ widget, int /*long*/ event) {
+	GdkEventKey gdkEvent = new GdkEventKey ();
+	OS.memmove (gdkEvent, event, GdkEventKey.sizeof);
+	return sendKeyEvent (SWT.KeyUp, gdkEvent) ? 0 : 1;
+}
+
+int /*long*/ gtk_leave_notify_event (int /*long*/ widget, int /*long*/ event) {
+	return 0;
+}
+
+int /*long*/ gtk_map (int /*long*/ widget) {
+	return 0;
+}
+
+int /*long*/ gtk_map_event (int /*long*/ widget, int /*long*/ event) {
+	return 0;
+}
+
+int /*long*/ gtk_mnemonic_activate (int /*long*/ widget, int /*long*/ arg1) {
+	return 0;
+}
+
+int /*long*/ gtk_month_changed (int /*long*/ widget) {
+	return 0;
+}
+
+int /*long*/ gtk_motion_notify_event (int /*long*/ widget, int /*long*/ event) {
+	return 0;
+}
+
+int /*long*/ gtk_move_focus (int /*long*/ widget, int /*long*/ event) {
+	return 0;
+}
+
+int /*long*/ gtk_output (int /*long*/ widget) {
+	return 0;
+}
+
+int /*long*/ gtk_populate_popup (int /*long*/ widget, int /*long*/ menu) {
+	return 0;
+}
+
+int /*long*/ gtk_popup_menu (int /*long*/ widget) {
+	return 0;
+}
+
+int /*long*/ gtk_preedit_changed (int /*long*/ imcontext) {
+	return 0;
+}
+
+int /*long*/ gtk_realize (int /*long*/ widget) {
+	return 0;
+}
+
+int /*long*/ gtk_row_activated (int /*long*/ tree, int /*long*/ path, int /*long*/ column) {
+	return 0;
+}
+
+int /*long*/ gtk_scroll_child (int /*long*/ widget, int /*long*/ scrollType, int /*long*/ horizontal) {
+	return 0;
+}
+
+int /*long*/ gtk_scroll_event (int /*long*/ widget, int /*long*/ event) {
+	return 0;
+}
+
+int /*long*/ gtk_select (int /*long*/ item) {
+	return 0;
+}
+
+int /*long*/ gtk_show (int /*long*/ widget) {
+	return 0;
+}
+
+int /*long*/ gtk_show_help (int /*long*/ widget, int /*long*/ helpType) {
+	return 0;
+}
+
+int /*long*/ gtk_size_allocate (int /*long*/ widget, int /*long*/ allocation) {
+	return 0;
+}
+
+int /*long*/ gtk_style_set (int /*long*/ widget, int /*long*/ previousStyle) {
+	return 0;
+}
+
+int /*long*/ gtk_switch_page (int /*long*/ widget, int /*long*/ page, int /*long*/ page_num) {
+	return 0;
+}
+
+int /*long*/ gtk_test_collapse_row (int /*long*/ tree, int /*long*/ iter, int /*long*/ path) {
+	return 0;
+}
+
+int /*long*/ gtk_test_expand_row (int /*long*/ tree, int /*long*/ iter, int /*long*/ path) {
+	return 0;
+}
+
+int /*long*/ gtk_text_buffer_insert_text (int /*long*/ widget, int /*long*/ iter, int /*long*/ text, int /*long*/ length) {
+	return 0;
+}
+
+int /*long*/ gtk_timer () {
+	return 0;
+}
+
+int /*long*/ gtk_toggled (int /*long*/ renderer, int /*long*/ pathStr) {
+	return 0;
+}
+
+int /*long*/ gtk_unmap (int /*long*/ widget) {
+	return 0;
+}
+
+int /*long*/ gtk_unmap_event (int /*long*/ widget, int /*long*/ event) {
+	return 0;
+}
+
+int /*long*/ gtk_unrealize (int /*long*/ widget) {
+	return 0;
+}
+
+int /*long*/ gtk_value_changed (int /*long*/ adjustment) {
+	return 0;
+}
+
+int /*long*/ gtk_visibility_notify_event (int /*long*/ widget, int /*long*/ event) {
+	return 0;
+}
+
+int /*long*/ gtk_window_state_event (int /*long*/ widget, int /*long*/ event) {
+	return 0;
+}
+
+int fontHeight (int /*long*/ font, int /*long*/ widgetHandle) {
+	int /*long*/ context = OS.gtk_widget_get_pango_context (widgetHandle);
+	int /*long*/ lang = OS.pango_context_get_language (context);
+	int /*long*/ metrics = OS.pango_context_get_metrics (context, font, lang);
+	int ascent = OS.pango_font_metrics_get_ascent (metrics);
+	int descent = OS.pango_font_metrics_get_descent (metrics);
+	OS.pango_font_metrics_unref (metrics);
+	return OS.PANGO_PIXELS (ascent + descent);
+}
+
+int /*long*/ filterProc(int /*long*/ xEvent, int /*long*/ gdkEvent, int /*long*/ data2) {
+	return 0;
+}
+
+boolean filters (int eventType) {
+	return display.filters (eventType);
+}
+
+int /*long*/ fixedMapProc (int /*long*/ widget) {
+	return 0;
+}
+
+int /*long*/ fixedSizeAllocateProc(int /*long*/ widget, int /*long*/ allocationPtr) {
+	return OS.Call (Display.oldFixedSizeAllocateProc, widget, allocationPtr);
+}
+
+char [] fixMnemonic (String string) {
+	return fixMnemonic (string, true);
+}
+
+char [] fixMnemonic (String string, boolean replace) {
+	int length = string.length ();
+	char [] text = new char [length];
+	string.getChars (0, length, text, 0);
+	int i = 0, j = 0;
+	char [] result = new char [length * 2];
+	while (i < length) {
+		switch (text [i]) {
+			case '&':
+				if (i + 1 < length && text [i + 1] == '&') {
+					i++; 
+				} else {
+					if (replace) {
+						text [i] = '_';
+					} else {
+						i++;
+					}
+				}
+				break;
+			case '_':
+				if (replace) result [j++] = '_';
+				break;
+		}
+		result [j++] = text [i++];
+	}
+	return result;
+}
+
+/**
+ * Returns <code>true</code> if the widget has been disposed,
+ * and <code>false</code> otherwise.
+ * <p>
+ * This method gets the dispose state for the widget.
+ * When a widget has been disposed, it is an error to
+ * invoke any other method using the widget.
+ * </p>
+ *
+ * @return <code>true</code> when the widget is disposed and <code>false</code> otherwise
+ */
+public boolean isDisposed () {
+	return (state & DISPOSED) != 0;
+}
+
+/**
+ * Returns <code>true</code> if there are any listeners
+ * for the specified event type associated with the receiver,
+ * and <code>false</code> otherwise. The event type is one of
+ * the event constants defined in class <code>SWT</code>.
+ *
+ * @param eventType the type of event
+ * @return true if the event is hooked
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see SWT
+ */
+public boolean isListening (int eventType) {
+	checkWidget ();
+	return hooks (eventType);
+}
+
+boolean isValidThread () {
+	return getDisplay ().isValidThread ();
+}
+
+boolean isValidSubclass() {
+	return Display.isValidClass(getClass());
+}
+
+void hookEvents () {
+}
+
+/*
+ * Returns <code>true</code> if the specified eventType is
+ * hooked, and <code>false</code> otherwise. Implementations
+ * of SWT can avoid creating objects and sending events
+ * when an event happens in the operating system but
+ * there are no listeners hooked for the event.
+ *
+ * @param eventType the event to be checked
+ *
+ * @return <code>true</code> when the eventType is hooked and <code>false</code> otherwise
+ *
+ * @see #isListening
+ */
+boolean hooks (int eventType) {
+	if (eventTable == null) return false;
+	return eventTable.hooks (eventType);
+}
+
+int /*long*/ hoverProc (int /*long*/ widget) {
+	return 0;
+}
+
+int /*long*/ menuPositionProc (int /*long*/ menu, int /*long*/ x, int /*long*/ y, int /*long*/ push_in, int /*long*/ user_data) {
+	return 0;
+}
+
+boolean mnemonicHit (int /*long*/ mnemonicHandle, char key) {
+	if (!mnemonicMatch (mnemonicHandle, key)) return false;
+	OS.g_signal_handlers_block_matched (mnemonicHandle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, MNEMONIC_ACTIVATE);
+	boolean result = OS.gtk_widget_mnemonic_activate (mnemonicHandle, false);
+	OS.g_signal_handlers_unblock_matched (mnemonicHandle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, MNEMONIC_ACTIVATE);
+	return result;
+}
+
+boolean mnemonicMatch (int /*long*/ mnemonicHandle, char key) {
+	int keyval1 = OS.gdk_keyval_to_lower (OS.gdk_unicode_to_keyval (key));
+	int keyval2 = OS.gdk_keyval_to_lower (OS.gtk_label_get_mnemonic_keyval (mnemonicHandle)); 
+	return keyval1 == keyval2;
+}
+
+void modifyStyle (int /*long*/ handle, int /*long*/ style) {
+	OS.gtk_widget_modify_style (handle, style);
+}
+
+/**
+ * Notifies all of the receiver's listeners for events
+ * of the given type that one such event has occurred by
+ * invoking their <code>handleEvent()</code> method.  The
+ * event type is one of the event constants defined in class
+ * <code>SWT</code>.
+ *
+ * @param eventType the type of event which has occurred
+ * @param event the event data
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ * 
+ * @see SWT
+ * @see #addListener
+ * @see #getListeners(int)
+ * @see #removeListener(int, Listener)
+ */
+public void notifyListeners (int eventType, Event event) {
+	checkWidget();
+	if (event == null) event = new Event ();
+	sendEvent (eventType, event);
+}
+
+void postEvent (int eventType) {
+	sendEvent (eventType, null, false);
+}
+
+void postEvent (int eventType, Event event) {
+	sendEvent (eventType, event, false);
+}
+
+void register () {
+	if (handle == 0) return;
+	if ((state & HANDLE) != 0) display.addWidget (handle, this);
+}
+
+void release (boolean destroy) {
+	if ((state & DISPOSE_SENT) == 0) {
+		state |= DISPOSE_SENT;
+		sendEvent (SWT.Dispose);
+	}
+	if ((state & DISPOSED) == 0) {
+		releaseChildren (destroy);
+	}
+	if ((state & RELEASED) == 0) {
+		state |= RELEASED;
+		if (destroy) {
+			releaseParent ();
+			releaseWidget ();
+			destroyWidget ();
+		} else {
+			releaseWidget ();
+			releaseHandle ();
+		}
+	}
+}
+
+void releaseChildren (boolean destroy) {
+}
+
+void releaseHandle () {
+	handle = 0;
+	state |= DISPOSED;
+	display = null;
+}
+
+void releaseParent () {
+	/* Do nothing */
+}
+
+void releaseWidget () {
+	deregister ();
+	eventTable = null;
+	data = null;
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when an event of the given type occurs. The event
+ * type is one of the event constants defined in class <code>SWT</code>.
+ *
+ * @param eventType the type of event to listen for
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see Listener
+ * @see SWT
+ * @see #addListener
+ * @see #getListeners(int)
+ * @see #notifyListeners
+ */
+public void removeListener (int eventType, Listener handler) {
+	checkWidget ();
+	if (handler == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if (eventTable == null) return;
+	eventTable.unhook (eventType, handler);
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when an event of the given type occurs.
+ * <p>
+ * <b>IMPORTANT:</b> This method is <em>not</em> part of the SWT
+ * public API. It is marked public only so that it can be shared
+ * within the packages provided by SWT. It should never be
+ * referenced from application code.
+ * </p>
+ *
+ * @param eventType the type of event to listen for
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see Listener
+ * @see #addListener
+ */
+protected void removeListener (int eventType, SWTEventListener handler) {
+	checkWidget ();
+	if (handler == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if (eventTable == null) return;
+	eventTable.unhook (eventType, handler);
+}
+
+int /*long*/ rendererGetSizeProc (int /*long*/ cell, int /*long*/ handle, int /*long*/ cell_area, int /*long*/ x_offset, int /*long*/ y_offset, int /*long*/ width, int /*long*/ height) {
+	return 0;
+}
+
+int /*long*/ rendererRenderProc (int /*long*/ cell, int /*long*/ window, int /*long*/ handle, int /*long*/ background_area, int /*long*/ cell_area, int /*long*/ expose_area, int /*long*/ flags) {
+	return 0;
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the widget is disposed.
+ *
+ * @param listener the listener which should no longer be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see DisposeListener
+ * @see #addDisposeListener
+ */
+public void removeDisposeListener (DisposeListener listener) {
+	checkWidget ();
+	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+	if (eventTable == null) return;
+	eventTable.unhook (SWT.Dispose, listener);
+}
+
+void sendEvent (Event event) {
+	Display display = event.display;
+	if (!display.filterEvent (event)) {
+		if (eventTable != null) eventTable.sendEvent (event);
+	}
+}
+
+void sendEvent (int eventType) {
+	sendEvent (eventType, null, true);
+}
+
+void sendEvent (int eventType, Event event) {
+	sendEvent (eventType, event, true);
+}
+
+void sendEvent (int eventType, Event event, boolean send) {
+	if (eventTable == null && !display.filters (eventType)) {
+		return;
+	}
+	if (event == null) event = new Event ();
+	event.type = eventType;
+	event.display = display;
+	event.widget = this;
+	if (event.time == 0) {
+		event.time = display.getLastEventTime ();
+	}
+	if (send) {
+		sendEvent (event);
+	} else {
+		display.postEvent (event);
+	}
+}
+
+boolean sendKeyEvent (int type, GdkEventKey keyEvent) {
+	int length = keyEvent.length;
+	if (keyEvent.string == 0 || OS.g_utf8_strlen (keyEvent.string, length) <= 1) {
+		Event event = new Event ();
+		event.time = keyEvent.time;
+		if (!setKeyState (event, keyEvent)) return true;
+		sendEvent (type, event);
+		// widget could be disposed at this point
+	
+		/*
+		* It is possible (but unlikely), that application
+		* code could have disposed the widget in the key
+		* events.  If this happens, end the processing of
+		* the key by returning false.
+		*/
+		if (isDisposed ()) return false;
+		return event.doit;
+	}
+	byte [] buffer = new byte [length];
+	OS.memmove (buffer, keyEvent.string, length);
+	char [] chars = Converter.mbcsToWcs (null, buffer);
+	return sendIMKeyEvent (type, keyEvent, chars) != null;
+}
+
+char [] sendIMKeyEvent (int type, GdkEventKey keyEvent, char [] chars) {
+	int index = 0, count = 0, state = 0;
+	int /*long*/ ptr = 0;
+	if (keyEvent == null) {
+		ptr = OS.gtk_get_current_event ();
+		if (ptr != 0) {
+			keyEvent = new GdkEventKey ();
+			OS.memmove (keyEvent, ptr, GdkEventKey.sizeof);
+			switch (keyEvent.type) {
+				case OS.GDK_KEY_PRESS:
+				case OS.GDK_KEY_RELEASE:
+					state = keyEvent.state;
+					break;
+				default:
+					keyEvent = null;
+					break;
+			}
+		}
+	}
+	if (keyEvent == null) {
+		int [] buffer = new int [1];
+		OS.gtk_get_current_event_state (buffer);
+		state = buffer [0];
+	}
+	while (index < chars.length) {
+		Event event = new Event ();
+		if (keyEvent != null && chars.length <= 1) {
+			setKeyState (event, keyEvent);
+		} else {
+			setInputState (event, state);
+		}
+		event.character = chars [index];
+		sendEvent (type, event);
+	
+		/*
+		* It is possible (but unlikely), that application
+		* code could have disposed the widget in the key
+		* events.  If this happens, end the processing of
+		* the key by returning null.
+		*/
+		if (isDisposed ()) {
+			if (ptr != 0) OS.gdk_event_free (ptr);
+			return null;
+		}
+		if (event.doit) chars [count++] = chars [index];
+		index++;
+	}
+	if (ptr != 0) OS.gdk_event_free (ptr);
+	if (count == 0) return null;
+	if (index != count) {
+		char [] result = new char [count];
+		System.arraycopy (chars, 0, result, 0, count);
+		return result;
+	}
+	return chars;
+}
+
+/**
+ * Sets the application defined widget data associated
+ * with the receiver to be the argument. The <em>widget
+ * data</em> is a single, unnamed field that is stored
+ * with every widget. 
+ * <p>
+ * Applications may put arbitrary objects in this field. If
+ * the object stored in the widget data needs to be notified
+ * when the widget is disposed of, it is the application's
+ * responsibility to hook the Dispose event on the widget and
+ * do so.
+ * </p>
+ *
+ * @param data the widget data
+ *
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - when the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - when called from the wrong thread</li>
+ * </ul>
+ * 
+ * @see #getData()
+ */
+public void setData (Object data) {
+	checkWidget();
+	if ((state & KEYED_DATA) != 0) {
+		((Object []) this.data) [0] = data;
+	} else {
+		this.data = data;
+	}
+}
+
+/**
+ * Sets the application defined property of the receiver
+ * with the specified name to the given value.
+ * <p>
+ * Applications may associate arbitrary objects with the
+ * receiver in this fashion. If the objects stored in the
+ * properties need to be notified when the widget is disposed
+ * of, it is the application's responsibility to hook the
+ * Dispose event on the widget and do so.
+ * </p>
+ *
+ * @param key the name of the property
+ * @param value the new value for the property
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the key is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #getData(String)
+ */
+public void setData (String key, Object value) {
+	checkWidget();
+	if (key == null) error (SWT.ERROR_NULL_ARGUMENT);
+	int index = 1;
+	Object [] table = null;
+	if ((state & KEYED_DATA) != 0) {
+		table = (Object []) data;
+		while (index < table.length) {
+			if (key.equals (table [index])) break;
+			index += 2;
+		}
+	}
+	if (value != null) {
+		if ((state & KEYED_DATA) != 0) {
+			if (index == table.length) {
+				Object [] newTable = new Object [table.length + 2];
+				System.arraycopy (table, 0, newTable, 0, table.length);
+				data = table = newTable;
+			}
+		} else {
+			table = new Object [3];
+			table [0] = data;
+			data = table;
+			state |= KEYED_DATA;
+		}
+		table [index] = key;
+		table [index + 1] = value;
+	} else {
+		if ((state & KEYED_DATA) != 0) {
+			if (index != table.length) {
+				int length = table.length - 2;
+				if (length == 1) {
+					data = table [0];
+					state &= ~KEYED_DATA;
+				} else {
+					Object [] newTable = new Object [length];
+					System.arraycopy (table, 0, newTable, 0, index);
+					System.arraycopy (table, index + 2, newTable, index, length - index);
+					data = newTable;
+				}
+			}
+		}
+	}
+}
+
+void setForegroundColor (int /*long*/ handle, GdkColor color) {
+	int /*long*/ style = OS.gtk_widget_get_modifier_style (handle);
+	OS.gtk_rc_style_set_fg (style, OS.GTK_STATE_NORMAL, color);
+	OS.gtk_rc_style_set_fg (style, OS.GTK_STATE_ACTIVE, color);
+	OS.gtk_rc_style_set_fg (style, OS.GTK_STATE_PRELIGHT, color);
+	int flags = OS.gtk_rc_style_get_color_flags (style, OS.GTK_STATE_NORMAL);
+	flags = (color == null) ? flags & ~OS.GTK_RC_FG: flags | OS.GTK_RC_FG;
+	OS.gtk_rc_style_set_color_flags (style, OS.GTK_STATE_NORMAL, flags);
+	flags = OS.gtk_rc_style_get_color_flags (style, OS.GTK_STATE_ACTIVE);
+	flags = (color == null) ? flags & ~OS.GTK_RC_FG: flags | OS.GTK_RC_FG;
+	OS.gtk_rc_style_set_color_flags (style, OS.GTK_STATE_ACTIVE, flags);
+	flags = OS.gtk_rc_style_get_color_flags (style, OS.GTK_STATE_PRELIGHT);
+	flags = (color == null) ? flags & ~OS.GTK_RC_FG: flags | OS.GTK_RC_FG;
+	OS.gtk_rc_style_set_color_flags (style, OS.GTK_STATE_PRELIGHT, flags);
+
+	OS.gtk_rc_style_set_text (style, OS.GTK_STATE_NORMAL, color);
+	OS.gtk_rc_style_set_text (style, OS.GTK_STATE_ACTIVE, color);
+	OS.gtk_rc_style_set_text (style, OS.GTK_STATE_PRELIGHT, color);
+	flags = OS.gtk_rc_style_get_color_flags (style, OS.GTK_STATE_NORMAL);
+	flags = (color == null) ? flags & ~OS.GTK_RC_TEXT: flags | OS.GTK_RC_TEXT;
+	OS.gtk_rc_style_set_color_flags (style, OS.GTK_STATE_NORMAL, flags);
+	flags = OS.gtk_rc_style_get_color_flags (style, OS.GTK_STATE_PRELIGHT);	
+	flags = (color == null) ? flags & ~OS.GTK_RC_TEXT: flags | OS.GTK_RC_TEXT;
+	OS.gtk_rc_style_set_color_flags (style, OS.GTK_STATE_PRELIGHT, flags);	
+	flags = OS.gtk_rc_style_get_color_flags (style, OS.GTK_STATE_ACTIVE);
+	flags = (color == null) ? flags & ~OS.GTK_RC_TEXT: flags | OS.GTK_RC_TEXT;
+	OS.gtk_rc_style_set_color_flags (style, OS.GTK_STATE_ACTIVE, flags);
+	modifyStyle (handle, style);	
+}
+
+boolean setInputState (Event event, int state) {
+	if ((state & OS.GDK_MOD1_MASK) != 0) event.stateMask |= SWT.ALT;
+	if ((state & OS.GDK_SHIFT_MASK) != 0) event.stateMask |= SWT.SHIFT;
+	if ((state & OS.GDK_CONTROL_MASK) != 0) event.stateMask |= SWT.CONTROL;
+	if ((state & OS.GDK_BUTTON1_MASK) != 0) event.stateMask |= SWT.BUTTON1;
+	if ((state & OS.GDK_BUTTON2_MASK) != 0) event.stateMask |= SWT.BUTTON2;
+	if ((state & OS.GDK_BUTTON3_MASK) != 0) event.stateMask |= SWT.BUTTON3;
+	return true;
+}
+
+boolean setKeyState (Event event, GdkEventKey keyEvent) {
+	if (keyEvent.string != 0 && OS.g_utf8_strlen (keyEvent.string, keyEvent.length) > 1) return false;
+	boolean isNull = false;
+	event.keyCode = Display.translateKey (keyEvent.keyval);
+	switch (keyEvent.keyval) {
+		case OS.GDK_BackSpace:		event.character = SWT.BS; break;
+		case OS.GDK_Linefeed:		event.character = SWT.LF; break;
+		case OS.GDK_KP_Enter:
+		case OS.GDK_Return: 		event.character = SWT.CR; break;
+		case OS.GDK_KP_Delete:
+		case OS.GDK_Delete:			event.character = SWT.DEL; break;
+		case OS.GDK_Escape:			event.character = SWT.ESC; break;
+		case OS.GDK_Tab:
+		case OS.GDK_ISO_Left_Tab: 	event.character = SWT.TAB; break;
+		default: {
+			if (event.keyCode == 0) {
+				int [] keyval = new int [1], effective_group= new int [1], level = new int [1], consumed_modifiers = new int [1];
+				if (OS.gdk_keymap_translate_keyboard_state(OS.gdk_keymap_get_default (), keyEvent.hardware_keycode, 0, keyEvent.group, keyval, effective_group, level, consumed_modifiers)) {
+					event.keyCode = OS.gdk_keyval_to_unicode (keyval [0]);
+				}
+			}
+			int key = keyEvent.keyval;
+			if ((keyEvent.state & OS.GDK_CONTROL_MASK) != 0 && (0 <= key && key <= 0x7F)) {
+				if ('a'  <= key && key <= 'z') key -= 'a' - 'A';
+				if (64 <= key && key <= 95) key -= 64;
+				event.character = (char) key;
+				isNull = keyEvent.keyval == '@' && key == 0;
+			} else {
+				event.character = (char) OS.gdk_keyval_to_unicode (key);
+			}
+		}
+	}
+	if (event.keyCode == 0 && event.character == 0) {
+		if (!isNull) return false;
+	}
+	return setInputState (event, keyEvent.state);
+}
+
+void setOrientation () {
+}
+
+int /*long*/ shellMapProc (int /*long*/ handle, int /*long*/ arg0, int /*long*/ user_data) {
+	return 0;
+}
+
+int /*long*/ sizeAllocateProc (int /*long*/ handle, int /*long*/ arg0, int /*long*/ user_data) {
+	return 0;
+}
+
+int /*long*/ sizeRequestProc (int /*long*/ handle, int /*long*/ arg0, int /*long*/ user_data) {
+	return 0;
+}
+
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the receiver
+ */
+public String toString () {
+	String string = "*Disposed*";
+	if (!isDisposed ()) {
+		string = "*Wrong Thread*";
+		if (isValidThread ()) string = getNameText ();
+	}
+	return getName () + " {" + string + "}";
+}
+
+int /*long*/ topHandle () {
+	return handle;
+}
+
+int /*long*/ timerProc (int /*long*/ widget) {
+	return 0;
+}
+
+int /*long*/ treeSelectionProc (int /*long*/ model, int /*long*/ path, int /*long*/ iter, int [] selection, int length) {
+	return 0;
+}
+
+boolean translateTraversal (int event) {
+	return false;
+}
+
+int /*long*/ windowProc (int /*long*/ handle, int /*long*/ user_data) {
+	switch ((int)/*64*/user_data) {
+		case ACTIVATE: return gtk_activate (handle);
+		case CHANGED: return gtk_changed (handle);
+		case CLICKED: return gtk_clicked (handle);
+		case DAY_SELECTED: return gtk_day_selected (handle);
+		case HIDE: return gtk_hide (handle);
+		case GRAB_FOCUS: return gtk_grab_focus (handle);
+		case MAP: return gtk_map (handle);
+		case MONTH_CHANGED: return gtk_month_changed (handle);
+		case OUTPUT: return gtk_output (handle);
+		case POPUP_MENU: return gtk_popup_menu (handle);
+		case PREEDIT_CHANGED: return gtk_preedit_changed (handle);
+		case REALIZE: return gtk_realize (handle);
+		case SELECT: return gtk_select (handle);
+		case SHOW: return gtk_show (handle);
+		case VALUE_CHANGED: return gtk_value_changed (handle);
+		case UNMAP: return gtk_unmap (handle);
+		case UNREALIZE: return gtk_unrealize (handle);
+		default: return 0;
+	}
+}
+
+int /*long*/ windowProc (int /*long*/ handle, int /*long*/ arg0, int /*long*/ user_data) {
+	switch ((int)/*64*/user_data) {
+		case EXPOSE_EVENT_INVERSE: {
+			GdkEventExpose gdkEvent = new GdkEventExpose ();
+			OS.memmove (gdkEvent, arg0, GdkEventExpose.sizeof);
+			int /*long*/ paintWindow = paintWindow();
+			int /*long*/ window = gdkEvent.window;
+			if (window != paintWindow) return 0;
+			return (state & OBSCURED) != 0 ? 1 : 0;
+		}
+		case BUTTON_PRESS_EVENT_INVERSE:
+		case BUTTON_RELEASE_EVENT_INVERSE:
+		case MOTION_NOTIFY_EVENT_INVERSE: {
+			return 1;
+		}
+		case BUTTON_PRESS_EVENT: return gtk_button_press_event (handle, arg0);
+		case BUTTON_RELEASE_EVENT: return gtk_button_release_event (handle, arg0);
+		case COMMIT: return gtk_commit (handle, arg0);
+		case CONFIGURE_EVENT: return gtk_configure_event (handle, arg0);
+		case DELETE_EVENT: return gtk_delete_event (handle, arg0);
+		case ENTER_NOTIFY_EVENT: return gtk_enter_notify_event (handle, arg0);
+		case EVENT: return gtk_event (handle, arg0);
+		case EVENT_AFTER: return gtk_event_after (handle, arg0);
+		case EXPOSE_EVENT: return gtk_expose_event (handle, arg0);
+		case FOCUS: return gtk_focus (handle, arg0);
+		case FOCUS_IN_EVENT: return gtk_focus_in_event (handle, arg0);
+		case FOCUS_OUT_EVENT: return gtk_focus_out_event (handle, arg0);
+		case KEY_PRESS_EVENT: return gtk_key_press_event (handle, arg0);
+		case KEY_RELEASE_EVENT: return gtk_key_release_event (handle, arg0);
+		case INPUT: return gtk_input (handle, arg0);
+		case LEAVE_NOTIFY_EVENT: return gtk_leave_notify_event (handle, arg0);
+		case MAP_EVENT: return gtk_map_event (handle, arg0);
+		case MNEMONIC_ACTIVATE: return gtk_mnemonic_activate (handle, arg0);
+		case MOTION_NOTIFY_EVENT: return gtk_motion_notify_event (handle, arg0);
+		case MOVE_FOCUS: return gtk_move_focus (handle, arg0);
+		case POPULATE_POPUP: return gtk_populate_popup (handle, arg0);
+		case SCROLL_EVENT:	return gtk_scroll_event (handle, arg0);
+		case SHOW_HELP: return gtk_show_help (handle, arg0);
+		case SIZE_ALLOCATE: return gtk_size_allocate (handle, arg0);
+		case STYLE_SET: return gtk_style_set (handle, arg0);
+		case TOGGLED: return gtk_toggled (handle, arg0);
+		case UNMAP_EVENT: return gtk_unmap_event (handle, arg0);
+		case VISIBILITY_NOTIFY_EVENT: return gtk_visibility_notify_event (handle, arg0);
+		case WINDOW_STATE_EVENT: return gtk_window_state_event (handle, arg0);
+		default: return 0;
+	}
+}
+
+int /*long*/ windowProc (int /*long*/ handle, int /*long*/ arg0, int /*long*/ arg1, int /*long*/ user_data) {
+	switch ((int)/*64*/user_data) {
+		case DELETE_RANGE: return gtk_delete_range (handle, arg0, arg1);
+		case DELETE_TEXT: return gtk_delete_text (handle, arg0, arg1);
+		case ROW_ACTIVATED: return gtk_row_activated (handle, arg0, arg1);
+		case SCROLL_CHILD: return gtk_scroll_child (handle, arg0, arg1);
+		case SWITCH_PAGE: return gtk_switch_page (handle, arg0, arg1);
+		case TEST_COLLAPSE_ROW: return gtk_test_collapse_row (handle, arg0, arg1);
+		case TEST_EXPAND_ROW: return gtk_test_expand_row(handle, arg0, arg1);
+		default: return 0;
+	}
+}
+
+int /*long*/ windowProc (int /*long*/ handle, int /*long*/ arg0, int /*long*/ arg1, int /*long*/ arg2, int /*long*/ user_data) {
+	switch ((int)/*64*/user_data) {
+		case CHANGE_VALUE: return gtk_change_value (handle, arg0, arg1, arg2);
+		case EXPAND_COLLAPSE_CURSOR_ROW: return gtk_expand_collapse_cursor_row (handle, arg0, arg1, arg2);
+		case INSERT_TEXT: return gtk_insert_text (handle, arg0, arg1, arg2);
+		case TEXT_BUFFER_INSERT_TEXT: return gtk_text_buffer_insert_text (handle, arg0, arg1, arg2);
+		default: return 0;
+	}
+}
+
+}

Added: branches/upstream/swt-gtk/current/os.c
===================================================================
--- branches/upstream/swt-gtk/current/os.c	                        (rev 0)
+++ branches/upstream/swt-gtk/current/os.c	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,18442 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others. All rights reserved.
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt).  The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html.  If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+#include "swt.h"
+#include "os_structs.h"
+#include "os_stats.h"
+
+#define OS_NATIVE(func) Java_org_eclipse_swt_internal_gtk_OS_##func
+
+#ifndef NO_Call
+JNIEXPORT jint JNICALL OS_NATIVE(Call)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, Call_FUNC);
+	rc = (jint)((jint (*)())arg0)(arg1, arg2, arg3);
+	OS_NATIVE_EXIT(env, that, Call_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_GDK_1EVENT_1TYPE
+JNIEXPORT jint JNICALL OS_NATIVE(GDK_1EVENT_1TYPE)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, GDK_1EVENT_1TYPE_FUNC);
+	rc = (jint)GDK_EVENT_TYPE((GdkEvent *)arg0);
+	OS_NATIVE_EXIT(env, that, GDK_1EVENT_1TYPE_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_GDK_1EVENT_1WINDOW
+JNIEXPORT jint JNICALL OS_NATIVE(GDK_1EVENT_1WINDOW)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, GDK_1EVENT_1WINDOW_FUNC);
+	rc = (jint)GDK_EVENT_WINDOW((GdkEventAny *)arg0);
+	OS_NATIVE_EXIT(env, that, GDK_1EVENT_1WINDOW_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_GInterfaceInfo_1sizeof
+JNIEXPORT jint JNICALL OS_NATIVE(GInterfaceInfo_1sizeof)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, GInterfaceInfo_1sizeof_FUNC);
+	rc = (jint)GInterfaceInfo_sizeof();
+	OS_NATIVE_EXIT(env, that, GInterfaceInfo_1sizeof_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_GPollFD_1sizeof
+JNIEXPORT jint JNICALL OS_NATIVE(GPollFD_1sizeof)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, GPollFD_1sizeof_FUNC);
+	rc = (jint)GPollFD_sizeof();
+	OS_NATIVE_EXIT(env, that, GPollFD_1sizeof_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_GTK_1ACCEL_1LABEL_1GET_1ACCEL_1STRING
+JNIEXPORT jint JNICALL OS_NATIVE(GTK_1ACCEL_1LABEL_1GET_1ACCEL_1STRING)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, GTK_1ACCEL_1LABEL_1GET_1ACCEL_1STRING_FUNC);
+	rc = (jint)GTK_ACCEL_LABEL_GET_ACCEL_STRING((GtkAccelLabel *)arg0);
+	OS_NATIVE_EXIT(env, that, GTK_1ACCEL_1LABEL_1GET_1ACCEL_1STRING_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_GTK_1ACCEL_1LABEL_1SET_1ACCEL_1STRING
+JNIEXPORT void JNICALL OS_NATIVE(GTK_1ACCEL_1LABEL_1SET_1ACCEL_1STRING)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, GTK_1ACCEL_1LABEL_1SET_1ACCEL_1STRING_FUNC);
+	GTK_ACCEL_LABEL_SET_ACCEL_STRING((GtkAccelLabel *)arg0, (gchar *)arg1);
+	OS_NATIVE_EXIT(env, that, GTK_1ACCEL_1LABEL_1SET_1ACCEL_1STRING_FUNC);
+}
+#endif
+
+#ifndef NO_GTK_1ENTRY_1IM_1CONTEXT
+JNIEXPORT jint JNICALL OS_NATIVE(GTK_1ENTRY_1IM_1CONTEXT)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, GTK_1ENTRY_1IM_1CONTEXT_FUNC);
+	rc = (jint)GTK_ENTRY_IM_CONTEXT((GtkEntry *)arg0);
+	OS_NATIVE_EXIT(env, that, GTK_1ENTRY_1IM_1CONTEXT_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_GTK_1SCROLLED_1WINDOW_1HSCROLLBAR
+JNIEXPORT jint JNICALL OS_NATIVE(GTK_1SCROLLED_1WINDOW_1HSCROLLBAR)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, GTK_1SCROLLED_1WINDOW_1HSCROLLBAR_FUNC);
+	rc = (jint)GTK_SCROLLED_WINDOW_HSCROLLBAR((GtkScrolledWindow *)arg0);
+	OS_NATIVE_EXIT(env, that, GTK_1SCROLLED_1WINDOW_1HSCROLLBAR_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_GTK_1SCROLLED_1WINDOW_1SCROLLBAR_1SPACING
+JNIEXPORT jint JNICALL OS_NATIVE(GTK_1SCROLLED_1WINDOW_1SCROLLBAR_1SPACING)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, GTK_1SCROLLED_1WINDOW_1SCROLLBAR_1SPACING_FUNC);
+	rc = (jint)GTK_SCROLLED_WINDOW_SCROLLBAR_SPACING((GtkScrolledWindow *)arg0);
+	OS_NATIVE_EXIT(env, that, GTK_1SCROLLED_1WINDOW_1SCROLLBAR_1SPACING_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_GTK_1SCROLLED_1WINDOW_1VSCROLLBAR
+JNIEXPORT jint JNICALL OS_NATIVE(GTK_1SCROLLED_1WINDOW_1VSCROLLBAR)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, GTK_1SCROLLED_1WINDOW_1VSCROLLBAR_FUNC);
+	rc = (jint)GTK_SCROLLED_WINDOW_VSCROLLBAR((GtkScrolledWindow *)arg0);
+	OS_NATIVE_EXIT(env, that, GTK_1SCROLLED_1WINDOW_1VSCROLLBAR_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_GTK_1TEXTVIEW_1IM_1CONTEXT
+JNIEXPORT jint JNICALL OS_NATIVE(GTK_1TEXTVIEW_1IM_1CONTEXT)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, GTK_1TEXTVIEW_1IM_1CONTEXT_FUNC);
+	rc = (jint)GTK_TEXTVIEW_IM_CONTEXT((GtkTextView *)arg0);
+	OS_NATIVE_EXIT(env, that, GTK_1TEXTVIEW_1IM_1CONTEXT_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_GTK_1TOOLTIPS_1SET_1ACTIVE
+JNIEXPORT void JNICALL OS_NATIVE(GTK_1TOOLTIPS_1SET_1ACTIVE)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, GTK_1TOOLTIPS_1SET_1ACTIVE_FUNC);
+	GTK_TOOLTIPS_SET_ACTIVE((GtkTooltips *)arg0, (GtkTooltipsData *)arg1);
+	OS_NATIVE_EXIT(env, that, GTK_1TOOLTIPS_1SET_1ACTIVE_FUNC);
+}
+#endif
+
+#ifndef NO_GTK_1TOOLTIPS_1TIP_1WINDOW
+JNIEXPORT jint JNICALL OS_NATIVE(GTK_1TOOLTIPS_1TIP_1WINDOW)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, GTK_1TOOLTIPS_1TIP_1WINDOW_FUNC);
+	rc = (jint)GTK_TOOLTIPS_TIP_WINDOW((GtkTooltips *)arg0);
+	OS_NATIVE_EXIT(env, that, GTK_1TOOLTIPS_1TIP_1WINDOW_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_GTK_1WIDGET_1HEIGHT
+JNIEXPORT jint JNICALL OS_NATIVE(GTK_1WIDGET_1HEIGHT)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, GTK_1WIDGET_1HEIGHT_FUNC);
+	rc = (jint)GTK_WIDGET_HEIGHT((GtkWidget *)arg0);
+	OS_NATIVE_EXIT(env, that, GTK_1WIDGET_1HEIGHT_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_GTK_1WIDGET_1REQUISITION_1HEIGHT
+JNIEXPORT jint JNICALL OS_NATIVE(GTK_1WIDGET_1REQUISITION_1HEIGHT)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, GTK_1WIDGET_1REQUISITION_1HEIGHT_FUNC);
+	rc = (jint)GTK_WIDGET_REQUISITION_HEIGHT((GtkWidget *)arg0);
+	OS_NATIVE_EXIT(env, that, GTK_1WIDGET_1REQUISITION_1HEIGHT_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_GTK_1WIDGET_1REQUISITION_1WIDTH
+JNIEXPORT jint JNICALL OS_NATIVE(GTK_1WIDGET_1REQUISITION_1WIDTH)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, GTK_1WIDGET_1REQUISITION_1WIDTH_FUNC);
+	rc = (jint)GTK_WIDGET_REQUISITION_WIDTH((GtkWidget *)arg0);
+	OS_NATIVE_EXIT(env, that, GTK_1WIDGET_1REQUISITION_1WIDTH_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_GTK_1WIDGET_1SET_1HEIGHT
+JNIEXPORT void JNICALL OS_NATIVE(GTK_1WIDGET_1SET_1HEIGHT)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, GTK_1WIDGET_1SET_1HEIGHT_FUNC);
+	GTK_WIDGET_SET_HEIGHT((GtkWidget *)arg0, arg1);
+	OS_NATIVE_EXIT(env, that, GTK_1WIDGET_1SET_1HEIGHT_FUNC);
+}
+#endif
+
+#ifndef NO_GTK_1WIDGET_1SET_1WIDTH
+JNIEXPORT void JNICALL OS_NATIVE(GTK_1WIDGET_1SET_1WIDTH)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, GTK_1WIDGET_1SET_1WIDTH_FUNC);
+	GTK_WIDGET_SET_WIDTH((GtkWidget *)arg0, arg1);
+	OS_NATIVE_EXIT(env, that, GTK_1WIDGET_1SET_1WIDTH_FUNC);
+}
+#endif
+
+#ifndef NO_GTK_1WIDGET_1SET_1X
+JNIEXPORT void JNICALL OS_NATIVE(GTK_1WIDGET_1SET_1X)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, GTK_1WIDGET_1SET_1X_FUNC);
+	GTK_WIDGET_SET_X((GtkWidget *)arg0, arg1);
+	OS_NATIVE_EXIT(env, that, GTK_1WIDGET_1SET_1X_FUNC);
+}
+#endif
+
+#ifndef NO_GTK_1WIDGET_1SET_1Y
+JNIEXPORT void JNICALL OS_NATIVE(GTK_1WIDGET_1SET_1Y)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, GTK_1WIDGET_1SET_1Y_FUNC);
+	GTK_WIDGET_SET_Y((GtkWidget *)arg0, arg1);
+	OS_NATIVE_EXIT(env, that, GTK_1WIDGET_1SET_1Y_FUNC);
+}
+#endif
+
+#ifndef NO_GTK_1WIDGET_1WIDTH
+JNIEXPORT jint JNICALL OS_NATIVE(GTK_1WIDGET_1WIDTH)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, GTK_1WIDGET_1WIDTH_FUNC);
+	rc = (jint)GTK_WIDGET_WIDTH((GtkWidget *)arg0);
+	OS_NATIVE_EXIT(env, that, GTK_1WIDGET_1WIDTH_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_GTK_1WIDGET_1WINDOW
+JNIEXPORT jint JNICALL OS_NATIVE(GTK_1WIDGET_1WINDOW)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, GTK_1WIDGET_1WINDOW_FUNC);
+	rc = (jint)GTK_WIDGET_WINDOW((GtkWidget *)arg0);
+	OS_NATIVE_EXIT(env, that, GTK_1WIDGET_1WINDOW_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_GTK_1WIDGET_1X
+JNIEXPORT jint JNICALL OS_NATIVE(GTK_1WIDGET_1X)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, GTK_1WIDGET_1X_FUNC);
+	rc = (jint)GTK_WIDGET_X((GtkWidget *)arg0);
+	OS_NATIVE_EXIT(env, that, GTK_1WIDGET_1X_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_GTK_1WIDGET_1Y
+JNIEXPORT jint JNICALL OS_NATIVE(GTK_1WIDGET_1Y)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, GTK_1WIDGET_1Y_FUNC);
+	rc = (jint)GTK_WIDGET_Y((GtkWidget *)arg0);
+	OS_NATIVE_EXIT(env, that, GTK_1WIDGET_1Y_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_GTypeInfo_1sizeof
+JNIEXPORT jint JNICALL OS_NATIVE(GTypeInfo_1sizeof)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, GTypeInfo_1sizeof_FUNC);
+	rc = (jint)GTypeInfo_sizeof();
+	OS_NATIVE_EXIT(env, that, GTypeInfo_1sizeof_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_GTypeQuery_1sizeof
+JNIEXPORT jint JNICALL OS_NATIVE(GTypeQuery_1sizeof)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, GTypeQuery_1sizeof_FUNC);
+	rc = (jint)GTypeQuery_sizeof();
+	OS_NATIVE_EXIT(env, that, GTypeQuery_1sizeof_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_GdkColor_1sizeof
+JNIEXPORT jint JNICALL OS_NATIVE(GdkColor_1sizeof)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, GdkColor_1sizeof_FUNC);
+	rc = (jint)GdkColor_sizeof();
+	OS_NATIVE_EXIT(env, that, GdkColor_1sizeof_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_GdkDragContext_1sizeof
+JNIEXPORT jint JNICALL OS_NATIVE(GdkDragContext_1sizeof)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, GdkDragContext_1sizeof_FUNC);
+	rc = (jint)GdkDragContext_sizeof();
+	OS_NATIVE_EXIT(env, that, GdkDragContext_1sizeof_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_GdkEventAny_1sizeof
+JNIEXPORT jint JNICALL OS_NATIVE(GdkEventAny_1sizeof)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, GdkEventAny_1sizeof_FUNC);
+	rc = (jint)GdkEventAny_sizeof();
+	OS_NATIVE_EXIT(env, that, GdkEventAny_1sizeof_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_GdkEventButton_1sizeof
+JNIEXPORT jint JNICALL OS_NATIVE(GdkEventButton_1sizeof)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, GdkEventButton_1sizeof_FUNC);
+	rc = (jint)GdkEventButton_sizeof();
+	OS_NATIVE_EXIT(env, that, GdkEventButton_1sizeof_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_GdkEventCrossing_1sizeof
+JNIEXPORT jint JNICALL OS_NATIVE(GdkEventCrossing_1sizeof)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, GdkEventCrossing_1sizeof_FUNC);
+	rc = (jint)GdkEventCrossing_sizeof();
+	OS_NATIVE_EXIT(env, that, GdkEventCrossing_1sizeof_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_GdkEventExpose_1sizeof
+JNIEXPORT jint JNICALL OS_NATIVE(GdkEventExpose_1sizeof)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, GdkEventExpose_1sizeof_FUNC);
+	rc = (jint)GdkEventExpose_sizeof();
+	OS_NATIVE_EXIT(env, that, GdkEventExpose_1sizeof_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_GdkEventFocus_1sizeof
+JNIEXPORT jint JNICALL OS_NATIVE(GdkEventFocus_1sizeof)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, GdkEventFocus_1sizeof_FUNC);
+	rc = (jint)GdkEventFocus_sizeof();
+	OS_NATIVE_EXIT(env, that, GdkEventFocus_1sizeof_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_GdkEventKey_1sizeof
+JNIEXPORT jint JNICALL OS_NATIVE(GdkEventKey_1sizeof)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, GdkEventKey_1sizeof_FUNC);
+	rc = (jint)GdkEventKey_sizeof();
+	OS_NATIVE_EXIT(env, that, GdkEventKey_1sizeof_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_GdkEventMotion_1sizeof
+JNIEXPORT jint JNICALL OS_NATIVE(GdkEventMotion_1sizeof)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, GdkEventMotion_1sizeof_FUNC);
+	rc = (jint)GdkEventMotion_sizeof();
+	OS_NATIVE_EXIT(env, that, GdkEventMotion_1sizeof_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_GdkEventScroll_1sizeof
+JNIEXPORT jint JNICALL OS_NATIVE(GdkEventScroll_1sizeof)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, GdkEventScroll_1sizeof_FUNC);
+	rc = (jint)GdkEventScroll_sizeof();
+	OS_NATIVE_EXIT(env, that, GdkEventScroll_1sizeof_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_GdkEventVisibility_1sizeof
+JNIEXPORT jint JNICALL OS_NATIVE(GdkEventVisibility_1sizeof)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, GdkEventVisibility_1sizeof_FUNC);
+	rc = (jint)GdkEventVisibility_sizeof();
+	OS_NATIVE_EXIT(env, that, GdkEventVisibility_1sizeof_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_GdkEventWindowState_1sizeof
+JNIEXPORT jint JNICALL OS_NATIVE(GdkEventWindowState_1sizeof)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, GdkEventWindowState_1sizeof_FUNC);
+	rc = (jint)GdkEventWindowState_sizeof();
+	OS_NATIVE_EXIT(env, that, GdkEventWindowState_1sizeof_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_GdkEvent_1sizeof
+JNIEXPORT jint JNICALL OS_NATIVE(GdkEvent_1sizeof)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, GdkEvent_1sizeof_FUNC);
+	rc = (jint)GdkEvent_sizeof();
+	OS_NATIVE_EXIT(env, that, GdkEvent_1sizeof_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_GdkGCValues_1sizeof
+JNIEXPORT jint JNICALL OS_NATIVE(GdkGCValues_1sizeof)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, GdkGCValues_1sizeof_FUNC);
+	rc = (jint)GdkGCValues_sizeof();
+	OS_NATIVE_EXIT(env, that, GdkGCValues_1sizeof_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_GdkGeometry_1sizeof
+JNIEXPORT jint JNICALL OS_NATIVE(GdkGeometry_1sizeof)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, GdkGeometry_1sizeof_FUNC);
+	rc = (jint)GdkGeometry_sizeof();
+	OS_NATIVE_EXIT(env, that, GdkGeometry_1sizeof_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_GdkImage_1sizeof
+JNIEXPORT jint JNICALL OS_NATIVE(GdkImage_1sizeof)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, GdkImage_1sizeof_FUNC);
+	rc = (jint)GdkImage_sizeof();
+	OS_NATIVE_EXIT(env, that, GdkImage_1sizeof_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_GdkRectangle_1sizeof
+JNIEXPORT jint JNICALL OS_NATIVE(GdkRectangle_1sizeof)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, GdkRectangle_1sizeof_FUNC);
+	rc = (jint)GdkRectangle_sizeof();
+	OS_NATIVE_EXIT(env, that, GdkRectangle_1sizeof_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_GdkVisual_1sizeof
+JNIEXPORT jint JNICALL OS_NATIVE(GdkVisual_1sizeof)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, GdkVisual_1sizeof_FUNC);
+	rc = (jint)GdkVisual_sizeof();
+	OS_NATIVE_EXIT(env, that, GdkVisual_1sizeof_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_GdkWindowAttr_1sizeof
+JNIEXPORT jint JNICALL OS_NATIVE(GdkWindowAttr_1sizeof)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, GdkWindowAttr_1sizeof_FUNC);
+	rc = (jint)GdkWindowAttr_sizeof();
+	OS_NATIVE_EXIT(env, that, GdkWindowAttr_1sizeof_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_GtkAdjustment_1sizeof
+JNIEXPORT jint JNICALL OS_NATIVE(GtkAdjustment_1sizeof)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, GtkAdjustment_1sizeof_FUNC);
+	rc = (jint)GtkAdjustment_sizeof();
+	OS_NATIVE_EXIT(env, that, GtkAdjustment_1sizeof_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_GtkAllocation_1sizeof
+JNIEXPORT jint JNICALL OS_NATIVE(GtkAllocation_1sizeof)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, GtkAllocation_1sizeof_FUNC);
+	rc = (jint)GtkAllocation_sizeof();
+	OS_NATIVE_EXIT(env, that, GtkAllocation_1sizeof_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_GtkBorder_1sizeof
+JNIEXPORT jint JNICALL OS_NATIVE(GtkBorder_1sizeof)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, GtkBorder_1sizeof_FUNC);
+	rc = (jint)GtkBorder_sizeof();
+	OS_NATIVE_EXIT(env, that, GtkBorder_1sizeof_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_GtkCellRendererPixbufClass_1sizeof
+JNIEXPORT jint JNICALL OS_NATIVE(GtkCellRendererPixbufClass_1sizeof)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, GtkCellRendererPixbufClass_1sizeof_FUNC);
+	rc = (jint)GtkCellRendererPixbufClass_sizeof();
+	OS_NATIVE_EXIT(env, that, GtkCellRendererPixbufClass_1sizeof_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_GtkCellRendererPixbuf_1sizeof
+JNIEXPORT jint JNICALL OS_NATIVE(GtkCellRendererPixbuf_1sizeof)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, GtkCellRendererPixbuf_1sizeof_FUNC);
+	rc = (jint)GtkCellRendererPixbuf_sizeof();
+	OS_NATIVE_EXIT(env, that, GtkCellRendererPixbuf_1sizeof_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_GtkCellRendererTextClass_1sizeof
+JNIEXPORT jint JNICALL OS_NATIVE(GtkCellRendererTextClass_1sizeof)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, GtkCellRendererTextClass_1sizeof_FUNC);
+	rc = (jint)GtkCellRendererTextClass_sizeof();
+	OS_NATIVE_EXIT(env, that, GtkCellRendererTextClass_1sizeof_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_GtkCellRendererText_1sizeof
+JNIEXPORT jint JNICALL OS_NATIVE(GtkCellRendererText_1sizeof)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, GtkCellRendererText_1sizeof_FUNC);
+	rc = (jint)GtkCellRendererText_sizeof();
+	OS_NATIVE_EXIT(env, that, GtkCellRendererText_1sizeof_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_GtkCellRendererToggleClass_1sizeof
+JNIEXPORT jint JNICALL OS_NATIVE(GtkCellRendererToggleClass_1sizeof)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, GtkCellRendererToggleClass_1sizeof_FUNC);
+	rc = (jint)GtkCellRendererToggleClass_sizeof();
+	OS_NATIVE_EXIT(env, that, GtkCellRendererToggleClass_1sizeof_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_GtkCellRendererToggle_1sizeof
+JNIEXPORT jint JNICALL OS_NATIVE(GtkCellRendererToggle_1sizeof)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, GtkCellRendererToggle_1sizeof_FUNC);
+	rc = (jint)GtkCellRendererToggle_sizeof();
+	OS_NATIVE_EXIT(env, that, GtkCellRendererToggle_1sizeof_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_GtkColorSelectionDialog_1sizeof
+JNIEXPORT jint JNICALL OS_NATIVE(GtkColorSelectionDialog_1sizeof)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, GtkColorSelectionDialog_1sizeof_FUNC);
+	rc = (jint)GtkColorSelectionDialog_sizeof();
+	OS_NATIVE_EXIT(env, that, GtkColorSelectionDialog_1sizeof_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_GtkCombo_1sizeof
+JNIEXPORT jint JNICALL OS_NATIVE(GtkCombo_1sizeof)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, GtkCombo_1sizeof_FUNC);
+	rc = (jint)GtkCombo_sizeof();
+	OS_NATIVE_EXIT(env, that, GtkCombo_1sizeof_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_GtkFileSelection_1sizeof
+JNIEXPORT jint JNICALL OS_NATIVE(GtkFileSelection_1sizeof)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, GtkFileSelection_1sizeof_FUNC);
+	rc = (jint)GtkFileSelection_sizeof();
+	OS_NATIVE_EXIT(env, that, GtkFileSelection_1sizeof_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_GtkFixedClass_1sizeof
+JNIEXPORT jint JNICALL OS_NATIVE(GtkFixedClass_1sizeof)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, GtkFixedClass_1sizeof_FUNC);
+	rc = (jint)GtkFixedClass_sizeof();
+	OS_NATIVE_EXIT(env, that, GtkFixedClass_1sizeof_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_GtkFixed_1sizeof
+JNIEXPORT jint JNICALL OS_NATIVE(GtkFixed_1sizeof)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, GtkFixed_1sizeof_FUNC);
+	rc = (jint)GtkFixed_sizeof();
+	OS_NATIVE_EXIT(env, that, GtkFixed_1sizeof_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_GtkRequisition_1sizeof
+JNIEXPORT jint JNICALL OS_NATIVE(GtkRequisition_1sizeof)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, GtkRequisition_1sizeof_FUNC);
+	rc = (jint)GtkRequisition_sizeof();
+	OS_NATIVE_EXIT(env, that, GtkRequisition_1sizeof_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_GtkSelectionData_1sizeof
+JNIEXPORT jint JNICALL OS_NATIVE(GtkSelectionData_1sizeof)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, GtkSelectionData_1sizeof_FUNC);
+	rc = (jint)GtkSelectionData_sizeof();
+	OS_NATIVE_EXIT(env, that, GtkSelectionData_1sizeof_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_GtkTargetEntry_1sizeof
+JNIEXPORT jint JNICALL OS_NATIVE(GtkTargetEntry_1sizeof)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, GtkTargetEntry_1sizeof_FUNC);
+	rc = (jint)GtkTargetEntry_sizeof();
+	OS_NATIVE_EXIT(env, that, GtkTargetEntry_1sizeof_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_GtkTargetPair_1sizeof
+JNIEXPORT jint JNICALL OS_NATIVE(GtkTargetPair_1sizeof)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, GtkTargetPair_1sizeof_FUNC);
+	rc = (jint)GtkTargetPair_sizeof();
+	OS_NATIVE_EXIT(env, that, GtkTargetPair_1sizeof_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_GtkTextIter_1sizeof
+JNIEXPORT jint JNICALL OS_NATIVE(GtkTextIter_1sizeof)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, GtkTextIter_1sizeof_FUNC);
+	rc = (jint)GtkTextIter_sizeof();
+	OS_NATIVE_EXIT(env, that, GtkTextIter_1sizeof_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_GtkTreeIter_1sizeof
+JNIEXPORT jint JNICALL OS_NATIVE(GtkTreeIter_1sizeof)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, GtkTreeIter_1sizeof_FUNC);
+	rc = (jint)GtkTreeIter_sizeof();
+	OS_NATIVE_EXIT(env, that, GtkTreeIter_1sizeof_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_PangoAttrColor_1sizeof
+JNIEXPORT jint JNICALL OS_NATIVE(PangoAttrColor_1sizeof)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, PangoAttrColor_1sizeof_FUNC);
+	rc = (jint)PangoAttrColor_sizeof();
+	OS_NATIVE_EXIT(env, that, PangoAttrColor_1sizeof_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_PangoAttrInt_1sizeof
+JNIEXPORT jint JNICALL OS_NATIVE(PangoAttrInt_1sizeof)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, PangoAttrInt_1sizeof_FUNC);
+	rc = (jint)PangoAttrInt_sizeof();
+	OS_NATIVE_EXIT(env, that, PangoAttrInt_1sizeof_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_PangoAttribute_1sizeof
+JNIEXPORT jint JNICALL OS_NATIVE(PangoAttribute_1sizeof)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, PangoAttribute_1sizeof_FUNC);
+	rc = (jint)PangoAttribute_sizeof();
+	OS_NATIVE_EXIT(env, that, PangoAttribute_1sizeof_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_PangoItem_1sizeof
+JNIEXPORT jint JNICALL OS_NATIVE(PangoItem_1sizeof)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, PangoItem_1sizeof_FUNC);
+	rc = (jint)PangoItem_sizeof();
+	OS_NATIVE_EXIT(env, that, PangoItem_1sizeof_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_PangoLayoutLine_1sizeof
+JNIEXPORT jint JNICALL OS_NATIVE(PangoLayoutLine_1sizeof)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, PangoLayoutLine_1sizeof_FUNC);
+	rc = (jint)PangoLayoutLine_sizeof();
+	OS_NATIVE_EXIT(env, that, PangoLayoutLine_1sizeof_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_PangoLayoutRun_1sizeof
+JNIEXPORT jint JNICALL OS_NATIVE(PangoLayoutRun_1sizeof)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, PangoLayoutRun_1sizeof_FUNC);
+	rc = (jint)PangoLayoutRun_sizeof();
+	OS_NATIVE_EXIT(env, that, PangoLayoutRun_1sizeof_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_PangoLogAttr_1sizeof
+JNIEXPORT jint JNICALL OS_NATIVE(PangoLogAttr_1sizeof)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, PangoLogAttr_1sizeof_FUNC);
+	rc = (jint)PangoLogAttr_sizeof();
+	OS_NATIVE_EXIT(env, that, PangoLogAttr_1sizeof_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_PangoRectangle_1sizeof
+JNIEXPORT jint JNICALL OS_NATIVE(PangoRectangle_1sizeof)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, PangoRectangle_1sizeof_FUNC);
+	rc = (jint)PangoRectangle_sizeof();
+	OS_NATIVE_EXIT(env, that, PangoRectangle_1sizeof_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_XAnyEvent_1sizeof
+JNIEXPORT jint JNICALL OS_NATIVE(XAnyEvent_1sizeof)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, XAnyEvent_1sizeof_FUNC);
+	rc = (jint)XAnyEvent_sizeof();
+	OS_NATIVE_EXIT(env, that, XAnyEvent_1sizeof_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_XButtonEvent_1sizeof
+JNIEXPORT jint JNICALL OS_NATIVE(XButtonEvent_1sizeof)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, XButtonEvent_1sizeof_FUNC);
+	rc = (jint)XButtonEvent_sizeof();
+	OS_NATIVE_EXIT(env, that, XButtonEvent_1sizeof_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_XClientMessageEvent_1sizeof
+JNIEXPORT jint JNICALL OS_NATIVE(XClientMessageEvent_1sizeof)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, XClientMessageEvent_1sizeof_FUNC);
+	rc = (jint)XClientMessageEvent_sizeof();
+	OS_NATIVE_EXIT(env, that, XClientMessageEvent_1sizeof_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_XCrossingEvent_1sizeof
+JNIEXPORT jint JNICALL OS_NATIVE(XCrossingEvent_1sizeof)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, XCrossingEvent_1sizeof_FUNC);
+	rc = (jint)XCrossingEvent_sizeof();
+	OS_NATIVE_EXIT(env, that, XCrossingEvent_1sizeof_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_XEvent_1sizeof
+JNIEXPORT jint JNICALL OS_NATIVE(XEvent_1sizeof)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, XEvent_1sizeof_FUNC);
+	rc = (jint)XEvent_sizeof();
+	OS_NATIVE_EXIT(env, that, XEvent_1sizeof_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_XExposeEvent_1sizeof
+JNIEXPORT jint JNICALL OS_NATIVE(XExposeEvent_1sizeof)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, XExposeEvent_1sizeof_FUNC);
+	rc = (jint)XExposeEvent_sizeof();
+	OS_NATIVE_EXIT(env, that, XExposeEvent_1sizeof_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_XFocusChangeEvent_1sizeof
+JNIEXPORT jint JNICALL OS_NATIVE(XFocusChangeEvent_1sizeof)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, XFocusChangeEvent_1sizeof_FUNC);
+	rc = (jint)XFocusChangeEvent_sizeof();
+	OS_NATIVE_EXIT(env, that, XFocusChangeEvent_1sizeof_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_XRenderPictureAttributes_1sizeof
+JNIEXPORT jint JNICALL OS_NATIVE(XRenderPictureAttributes_1sizeof)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, XRenderPictureAttributes_1sizeof_FUNC);
+	rc = (jint)XRenderPictureAttributes_sizeof();
+	OS_NATIVE_EXIT(env, that, XRenderPictureAttributes_1sizeof_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_XVisibilityEvent_1sizeof
+JNIEXPORT jint JNICALL OS_NATIVE(XVisibilityEvent_1sizeof)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, XVisibilityEvent_1sizeof_FUNC);
+	rc = (jint)XVisibilityEvent_sizeof();
+	OS_NATIVE_EXIT(env, that, XVisibilityEvent_1sizeof_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_XWindowChanges_1sizeof
+JNIEXPORT jint JNICALL OS_NATIVE(XWindowChanges_1sizeof)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, XWindowChanges_1sizeof_FUNC);
+	rc = (jint)XWindowChanges_sizeof();
+	OS_NATIVE_EXIT(env, that, XWindowChanges_1sizeof_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_X_1EVENT_1TYPE
+JNIEXPORT jint JNICALL OS_NATIVE(X_1EVENT_1TYPE)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, X_1EVENT_1TYPE_FUNC);
+	rc = (jint)X_EVENT_TYPE((XEvent *)arg0);
+	OS_NATIVE_EXIT(env, that, X_1EVENT_1TYPE_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_X_1EVENT_1WINDOW
+JNIEXPORT jint JNICALL OS_NATIVE(X_1EVENT_1WINDOW)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, X_1EVENT_1WINDOW_FUNC);
+	rc = (jint)X_EVENT_WINDOW((XAnyEvent *)arg0);
+	OS_NATIVE_EXIT(env, that, X_1EVENT_1WINDOW_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1Call
+JNIEXPORT jint JNICALL OS_NATIVE(_1Call)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1Call_FUNC);
+	rc = (jint)((jint (*)())arg0)(arg1, arg2);
+	OS_NATIVE_EXIT(env, that, _1Call_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1FcConfigAppFontAddFile
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1FcConfigAppFontAddFile)
+	(JNIEnv *env, jclass that, jint arg0, jbyteArray arg1)
+{
+	jbyte *lparg1=NULL;
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1FcConfigAppFontAddFile_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+/*
+	rc = (jboolean)FcConfigAppFontAddFile(arg0, lparg1);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jboolean (*FPTR)(jint, jbyte *);
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(FcConfigAppFontAddFile_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "FcConfigAppFontAddFile");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jboolean)(*fptr)(arg0, lparg1);
+		}
+	}
+fail:
+	if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+	OS_NATIVE_EXIT(env, that, _1FcConfigAppFontAddFile_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1GDK_1DISPLAY
+JNIEXPORT jint JNICALL OS_NATIVE(_1GDK_1DISPLAY)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1GDK_1DISPLAY_FUNC);
+	rc = (jint)GDK_DISPLAY();
+	OS_NATIVE_EXIT(env, that, _1GDK_1DISPLAY_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1GDK_1PIXMAP_1XID
+JNIEXPORT jint JNICALL OS_NATIVE(_1GDK_1PIXMAP_1XID)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1GDK_1PIXMAP_1XID_FUNC);
+	rc = (jint)GDK_PIXMAP_XID((GdkPixmap *)arg0);
+	OS_NATIVE_EXIT(env, that, _1GDK_1PIXMAP_1XID_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1GDK_1ROOT_1PARENT
+JNIEXPORT jint JNICALL OS_NATIVE(_1GDK_1ROOT_1PARENT)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1GDK_1ROOT_1PARENT_FUNC);
+	rc = (jint)GDK_ROOT_PARENT();
+	OS_NATIVE_EXIT(env, that, _1GDK_1ROOT_1PARENT_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1GDK_1TYPE_1COLOR
+JNIEXPORT jint JNICALL OS_NATIVE(_1GDK_1TYPE_1COLOR)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1GDK_1TYPE_1COLOR_FUNC);
+	rc = (jint)GDK_TYPE_COLOR;
+	OS_NATIVE_EXIT(env, that, _1GDK_1TYPE_1COLOR_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1GDK_1TYPE_1PIXBUF
+JNIEXPORT jint JNICALL OS_NATIVE(_1GDK_1TYPE_1PIXBUF)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1GDK_1TYPE_1PIXBUF_FUNC);
+	rc = (jint)GDK_TYPE_PIXBUF;
+	OS_NATIVE_EXIT(env, that, _1GDK_1TYPE_1PIXBUF_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1GTK_1IS_1BUTTON
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1GTK_1IS_1BUTTON)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1GTK_1IS_1BUTTON_FUNC);
+	rc = (jboolean)GTK_IS_BUTTON(arg0);
+	OS_NATIVE_EXIT(env, that, _1GTK_1IS_1BUTTON_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1GTK_1IS_1CELL_1RENDERER_1PIXBUF
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1GTK_1IS_1CELL_1RENDERER_1PIXBUF)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1GTK_1IS_1CELL_1RENDERER_1PIXBUF_FUNC);
+	rc = (jboolean)GTK_IS_CELL_RENDERER_PIXBUF(arg0);
+	OS_NATIVE_EXIT(env, that, _1GTK_1IS_1CELL_1RENDERER_1PIXBUF_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1GTK_1IS_1CELL_1RENDERER_1TEXT
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1GTK_1IS_1CELL_1RENDERER_1TEXT)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1GTK_1IS_1CELL_1RENDERER_1TEXT_FUNC);
+	rc = (jboolean)GTK_IS_CELL_RENDERER_TEXT(arg0);
+	OS_NATIVE_EXIT(env, that, _1GTK_1IS_1CELL_1RENDERER_1TEXT_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1GTK_1IS_1CELL_1RENDERER_1TOGGLE
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1GTK_1IS_1CELL_1RENDERER_1TOGGLE)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1GTK_1IS_1CELL_1RENDERER_1TOGGLE_FUNC);
+	rc = (jboolean)GTK_IS_CELL_RENDERER_TOGGLE(arg0);
+	OS_NATIVE_EXIT(env, that, _1GTK_1IS_1CELL_1RENDERER_1TOGGLE_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1GTK_1IS_1CONTAINER
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1GTK_1IS_1CONTAINER)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1GTK_1IS_1CONTAINER_FUNC);
+	rc = (jboolean)GTK_IS_CONTAINER(arg0);
+	OS_NATIVE_EXIT(env, that, _1GTK_1IS_1CONTAINER_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1GTK_1IS_1IMAGE_1MENU_1ITEM
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1GTK_1IS_1IMAGE_1MENU_1ITEM)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1GTK_1IS_1IMAGE_1MENU_1ITEM_FUNC);
+	rc = (jboolean)GTK_IS_IMAGE_MENU_ITEM(arg0);
+	OS_NATIVE_EXIT(env, that, _1GTK_1IS_1IMAGE_1MENU_1ITEM_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1GTK_1IS_1MENU_1ITEM
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1GTK_1IS_1MENU_1ITEM)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1GTK_1IS_1MENU_1ITEM_FUNC);
+	rc = (jboolean)GTK_IS_MENU_ITEM(arg0);
+	OS_NATIVE_EXIT(env, that, _1GTK_1IS_1MENU_1ITEM_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1GTK_1IS_1PLUG
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1GTK_1IS_1PLUG)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1GTK_1IS_1PLUG_FUNC);
+	rc = (jboolean)GTK_IS_PLUG(arg0);
+	OS_NATIVE_EXIT(env, that, _1GTK_1IS_1PLUG_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1GTK_1IS_1WINDOW
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1GTK_1IS_1WINDOW)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1GTK_1IS_1WINDOW_FUNC);
+	rc = (jboolean)GTK_IS_WINDOW(arg0);
+	OS_NATIVE_EXIT(env, that, _1GTK_1IS_1WINDOW_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1GTK_1STOCK_1CANCEL
+JNIEXPORT jint JNICALL OS_NATIVE(_1GTK_1STOCK_1CANCEL)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1GTK_1STOCK_1CANCEL_FUNC);
+	rc = (jint)GTK_STOCK_CANCEL;
+	OS_NATIVE_EXIT(env, that, _1GTK_1STOCK_1CANCEL_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1GTK_1STOCK_1OK
+JNIEXPORT jint JNICALL OS_NATIVE(_1GTK_1STOCK_1OK)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1GTK_1STOCK_1OK_FUNC);
+	rc = (jint)GTK_STOCK_OK;
+	OS_NATIVE_EXIT(env, that, _1GTK_1STOCK_1OK_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1GTK_1TYPE_1CELL_1RENDERER_1PIXBUF
+JNIEXPORT jint JNICALL OS_NATIVE(_1GTK_1TYPE_1CELL_1RENDERER_1PIXBUF)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1GTK_1TYPE_1CELL_1RENDERER_1PIXBUF_FUNC);
+	rc = (jint)GTK_TYPE_CELL_RENDERER_PIXBUF;
+	OS_NATIVE_EXIT(env, that, _1GTK_1TYPE_1CELL_1RENDERER_1PIXBUF_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1GTK_1TYPE_1CELL_1RENDERER_1TEXT
+JNIEXPORT jint JNICALL OS_NATIVE(_1GTK_1TYPE_1CELL_1RENDERER_1TEXT)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1GTK_1TYPE_1CELL_1RENDERER_1TEXT_FUNC);
+	rc = (jint)GTK_TYPE_CELL_RENDERER_TEXT;
+	OS_NATIVE_EXIT(env, that, _1GTK_1TYPE_1CELL_1RENDERER_1TEXT_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1GTK_1TYPE_1CELL_1RENDERER_1TOGGLE
+JNIEXPORT jint JNICALL OS_NATIVE(_1GTK_1TYPE_1CELL_1RENDERER_1TOGGLE)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1GTK_1TYPE_1CELL_1RENDERER_1TOGGLE_FUNC);
+	rc = (jint)GTK_TYPE_CELL_RENDERER_TOGGLE;
+	OS_NATIVE_EXIT(env, that, _1GTK_1TYPE_1CELL_1RENDERER_1TOGGLE_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1GTK_1TYPE_1FIXED
+JNIEXPORT jint JNICALL OS_NATIVE(_1GTK_1TYPE_1FIXED)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1GTK_1TYPE_1FIXED_FUNC);
+	rc = (jint)GTK_TYPE_FIXED;
+	OS_NATIVE_EXIT(env, that, _1GTK_1TYPE_1FIXED_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1GTK_1TYPE_1MENU
+JNIEXPORT jint JNICALL OS_NATIVE(_1GTK_1TYPE_1MENU)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1GTK_1TYPE_1MENU_FUNC);
+	rc = (jint)GTK_TYPE_MENU;
+	OS_NATIVE_EXIT(env, that, _1GTK_1TYPE_1MENU_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1GTK_1TYPE_1WIDGET
+JNIEXPORT jint JNICALL OS_NATIVE(_1GTK_1TYPE_1WIDGET)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1GTK_1TYPE_1WIDGET_FUNC);
+	rc = (jint)GTK_TYPE_WIDGET;
+	OS_NATIVE_EXIT(env, that, _1GTK_1TYPE_1WIDGET_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1GTK_1WIDGET_1FLAGS
+JNIEXPORT jint JNICALL OS_NATIVE(_1GTK_1WIDGET_1FLAGS)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1GTK_1WIDGET_1FLAGS_FUNC);
+	rc = (jint)GTK_WIDGET_FLAGS(arg0);
+	OS_NATIVE_EXIT(env, that, _1GTK_1WIDGET_1FLAGS_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1GTK_1WIDGET_1HAS_1DEFAULT
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1GTK_1WIDGET_1HAS_1DEFAULT)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1GTK_1WIDGET_1HAS_1DEFAULT_FUNC);
+	rc = (jboolean)GTK_WIDGET_HAS_DEFAULT(arg0);
+	OS_NATIVE_EXIT(env, that, _1GTK_1WIDGET_1HAS_1DEFAULT_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1GTK_1WIDGET_1HAS_1FOCUS
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1GTK_1WIDGET_1HAS_1FOCUS)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1GTK_1WIDGET_1HAS_1FOCUS_FUNC);
+	rc = (jboolean)GTK_WIDGET_HAS_FOCUS(arg0);
+	OS_NATIVE_EXIT(env, that, _1GTK_1WIDGET_1HAS_1FOCUS_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1GTK_1WIDGET_1IS_1SENSITIVE
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1GTK_1WIDGET_1IS_1SENSITIVE)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1GTK_1WIDGET_1IS_1SENSITIVE_FUNC);
+	rc = (jboolean)GTK_WIDGET_IS_SENSITIVE(arg0);
+	OS_NATIVE_EXIT(env, that, _1GTK_1WIDGET_1IS_1SENSITIVE_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1GTK_1WIDGET_1MAPPED
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1GTK_1WIDGET_1MAPPED)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1GTK_1WIDGET_1MAPPED_FUNC);
+	rc = (jboolean)GTK_WIDGET_MAPPED(arg0);
+	OS_NATIVE_EXIT(env, that, _1GTK_1WIDGET_1MAPPED_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1GTK_1WIDGET_1SENSITIVE
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1GTK_1WIDGET_1SENSITIVE)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1GTK_1WIDGET_1SENSITIVE_FUNC);
+	rc = (jboolean)GTK_WIDGET_SENSITIVE(arg0);
+	OS_NATIVE_EXIT(env, that, _1GTK_1WIDGET_1SENSITIVE_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1GTK_1WIDGET_1SET_1FLAGS
+JNIEXPORT void JNICALL OS_NATIVE(_1GTK_1WIDGET_1SET_1FLAGS)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1GTK_1WIDGET_1SET_1FLAGS_FUNC);
+	GTK_WIDGET_SET_FLAGS(arg0, arg1);
+	OS_NATIVE_EXIT(env, that, _1GTK_1WIDGET_1SET_1FLAGS_FUNC);
+}
+#endif
+
+#ifndef NO__1GTK_1WIDGET_1STATE
+JNIEXPORT jint JNICALL OS_NATIVE(_1GTK_1WIDGET_1STATE)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1GTK_1WIDGET_1STATE_FUNC);
+	rc = (jint)GTK_WIDGET_STATE(arg0);
+	OS_NATIVE_EXIT(env, that, _1GTK_1WIDGET_1STATE_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1GTK_1WIDGET_1UNSET_1FLAGS
+JNIEXPORT void JNICALL OS_NATIVE(_1GTK_1WIDGET_1UNSET_1FLAGS)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1GTK_1WIDGET_1UNSET_1FLAGS_FUNC);
+	GTK_WIDGET_UNSET_FLAGS(arg0, arg1);
+	OS_NATIVE_EXIT(env, that, _1GTK_1WIDGET_1UNSET_1FLAGS_FUNC);
+}
+#endif
+
+#ifndef NO__1GTK_1WIDGET_1VISIBLE
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1GTK_1WIDGET_1VISIBLE)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1GTK_1WIDGET_1VISIBLE_FUNC);
+	rc = (jboolean)GTK_WIDGET_VISIBLE(arg0);
+	OS_NATIVE_EXIT(env, that, _1GTK_1WIDGET_1VISIBLE_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1G_1OBJECT_1CLASS
+JNIEXPORT jint JNICALL OS_NATIVE(_1G_1OBJECT_1CLASS)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1G_1OBJECT_1CLASS_FUNC);
+	rc = (jint)G_OBJECT_CLASS(arg0);
+	OS_NATIVE_EXIT(env, that, _1G_1OBJECT_1CLASS_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1G_1OBJECT_1GET_1CLASS
+JNIEXPORT jint JNICALL OS_NATIVE(_1G_1OBJECT_1GET_1CLASS)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1G_1OBJECT_1GET_1CLASS_FUNC);
+	rc = (jint)G_OBJECT_GET_CLASS(arg0);
+	OS_NATIVE_EXIT(env, that, _1G_1OBJECT_1GET_1CLASS_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1G_1OBJECT_1TYPE
+JNIEXPORT jint JNICALL OS_NATIVE(_1G_1OBJECT_1TYPE)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1G_1OBJECT_1TYPE_FUNC);
+	rc = (jint)G_OBJECT_TYPE(arg0);
+	OS_NATIVE_EXIT(env, that, _1G_1OBJECT_1TYPE_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1G_1OBJECT_1TYPE_1NAME
+JNIEXPORT jint JNICALL OS_NATIVE(_1G_1OBJECT_1TYPE_1NAME)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1G_1OBJECT_1TYPE_1NAME_FUNC);
+	rc = (jint)G_OBJECT_TYPE_NAME(arg0);
+	OS_NATIVE_EXIT(env, that, _1G_1OBJECT_1TYPE_1NAME_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1G_1TYPE_1BOOLEAN
+JNIEXPORT jint JNICALL OS_NATIVE(_1G_1TYPE_1BOOLEAN)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1G_1TYPE_1BOOLEAN_FUNC);
+	rc = (jint)G_TYPE_BOOLEAN;
+	OS_NATIVE_EXIT(env, that, _1G_1TYPE_1BOOLEAN_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1G_1TYPE_1INT
+JNIEXPORT jint JNICALL OS_NATIVE(_1G_1TYPE_1INT)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1G_1TYPE_1INT_FUNC);
+	rc = (jint)G_TYPE_INT;
+	OS_NATIVE_EXIT(env, that, _1G_1TYPE_1INT_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1G_1TYPE_1STRING
+JNIEXPORT jint JNICALL OS_NATIVE(_1G_1TYPE_1STRING)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1G_1TYPE_1STRING_FUNC);
+	rc = (jint)G_TYPE_STRING;
+	OS_NATIVE_EXIT(env, that, _1G_1TYPE_1STRING_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1PANGO_1PIXELS
+JNIEXPORT jint JNICALL OS_NATIVE(_1PANGO_1PIXELS)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1PANGO_1PIXELS_FUNC);
+	rc = (jint)PANGO_PIXELS(arg0);
+	OS_NATIVE_EXIT(env, that, _1PANGO_1PIXELS_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1PANGO_1TYPE_1FONT_1DESCRIPTION
+JNIEXPORT jint JNICALL OS_NATIVE(_1PANGO_1TYPE_1FONT_1DESCRIPTION)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1PANGO_1TYPE_1FONT_1DESCRIPTION_FUNC);
+	rc = (jint)PANGO_TYPE_FONT_DESCRIPTION;
+	OS_NATIVE_EXIT(env, that, _1PANGO_1TYPE_1FONT_1DESCRIPTION_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1XCheckIfEvent
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1XCheckIfEvent)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3)
+{
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1XCheckIfEvent_FUNC);
+	rc = (jboolean)XCheckIfEvent((Display *)arg0, (XEvent *)arg1, (Bool (*)())arg2, (XPointer)arg3);
+	OS_NATIVE_EXIT(env, that, _1XCheckIfEvent_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1XCheckMaskEvent
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1XCheckMaskEvent)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1XCheckMaskEvent_FUNC);
+	rc = (jboolean)XCheckMaskEvent((Display *)arg0, (long)arg1, (XEvent *)arg2);
+	OS_NATIVE_EXIT(env, that, _1XCheckMaskEvent_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1XCheckWindowEvent
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1XCheckWindowEvent)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3)
+{
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1XCheckWindowEvent_FUNC);
+	rc = (jboolean)XCheckWindowEvent((Display *)arg0, (Window)arg1, (long)arg2, (XEvent *)arg3);
+	OS_NATIVE_EXIT(env, that, _1XCheckWindowEvent_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1XDefaultRootWindow
+JNIEXPORT jint JNICALL OS_NATIVE(_1XDefaultRootWindow)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1XDefaultRootWindow_FUNC);
+	rc = (jint)XDefaultRootWindow((Display *)arg0);
+	OS_NATIVE_EXIT(env, that, _1XDefaultRootWindow_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1XDefaultScreen
+JNIEXPORT jint JNICALL OS_NATIVE(_1XDefaultScreen)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1XDefaultScreen_FUNC);
+	rc = (jint)XDefaultScreen((Display *)arg0);
+	OS_NATIVE_EXIT(env, that, _1XDefaultScreen_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1XFlush
+JNIEXPORT void JNICALL OS_NATIVE(_1XFlush)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1XFlush_FUNC);
+	XFlush((Display *)arg0);
+	OS_NATIVE_EXIT(env, that, _1XFlush_FUNC);
+}
+#endif
+
+#ifndef NO__1XFree
+JNIEXPORT void JNICALL OS_NATIVE(_1XFree)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1XFree_FUNC);
+	XFree((void *)arg0);
+	OS_NATIVE_EXIT(env, that, _1XFree_FUNC);
+}
+#endif
+
+#ifndef NO__1XGetSelectionOwner
+JNIEXPORT jint JNICALL OS_NATIVE(_1XGetSelectionOwner)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1XGetSelectionOwner_FUNC);
+	rc = (jint)XGetSelectionOwner((Display *)arg0, (Atom)arg1);
+	OS_NATIVE_EXIT(env, that, _1XGetSelectionOwner_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1XInternAtom
+JNIEXPORT jint JNICALL OS_NATIVE(_1XInternAtom)
+	(JNIEnv *env, jclass that, jint arg0, jbyteArray arg1, jboolean arg2)
+{
+	jbyte *lparg1=NULL;
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1XInternAtom_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	rc = (jint)XInternAtom((Display *)arg0, (char *)lparg1, (Bool)arg2);
+fail:
+	if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+	OS_NATIVE_EXIT(env, that, _1XInternAtom_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1XKeysymToKeycode
+JNIEXPORT jint JNICALL OS_NATIVE(_1XKeysymToKeycode)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1XKeysymToKeycode_FUNC);
+	rc = (jint)XKeysymToKeycode((Display *)arg0, (KeySym)arg1);
+	OS_NATIVE_EXIT(env, that, _1XKeysymToKeycode_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1XListProperties
+JNIEXPORT jint JNICALL OS_NATIVE(_1XListProperties)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jintArray arg2)
+{
+	jint *lparg2=NULL;
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1XListProperties_FUNC);
+	if (arg2) if ((lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL)) == NULL) goto fail;
+	rc = (jint)XListProperties((Display *)arg0, (Window)arg1, (int *)lparg2);
+fail:
+	if (arg2 && lparg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
+	OS_NATIVE_EXIT(env, that, _1XListProperties_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1XQueryPointer
+JNIEXPORT jint JNICALL OS_NATIVE(_1XQueryPointer)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jintArray arg2, jintArray arg3, jintArray arg4, jintArray arg5, jintArray arg6, jintArray arg7, jintArray arg8)
+{
+	jint *lparg2=NULL;
+	jint *lparg3=NULL;
+	jint *lparg4=NULL;
+	jint *lparg5=NULL;
+	jint *lparg6=NULL;
+	jint *lparg7=NULL;
+	jint *lparg8=NULL;
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1XQueryPointer_FUNC);
+	if (arg2) if ((lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL)) == NULL) goto fail;
+	if (arg3) if ((lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL)) == NULL) goto fail;
+	if (arg4) if ((lparg4 = (*env)->GetIntArrayElements(env, arg4, NULL)) == NULL) goto fail;
+	if (arg5) if ((lparg5 = (*env)->GetIntArrayElements(env, arg5, NULL)) == NULL) goto fail;
+	if (arg6) if ((lparg6 = (*env)->GetIntArrayElements(env, arg6, NULL)) == NULL) goto fail;
+	if (arg7) if ((lparg7 = (*env)->GetIntArrayElements(env, arg7, NULL)) == NULL) goto fail;
+	if (arg8) if ((lparg8 = (*env)->GetIntArrayElements(env, arg8, NULL)) == NULL) goto fail;
+	rc = (jint)XQueryPointer((Display *)arg0, (Window)arg1, (Window *)lparg2, (Window *)lparg3, (int *)lparg4, (int *)lparg5, (int *)lparg6, (int *)lparg7, (unsigned int *)lparg8);
+fail:
+	if (arg8 && lparg8) (*env)->ReleaseIntArrayElements(env, arg8, lparg8, 0);
+	if (arg7 && lparg7) (*env)->ReleaseIntArrayElements(env, arg7, lparg7, 0);
+	if (arg6 && lparg6) (*env)->ReleaseIntArrayElements(env, arg6, lparg6, 0);
+	if (arg5 && lparg5) (*env)->ReleaseIntArrayElements(env, arg5, lparg5, 0);
+	if (arg4 && lparg4) (*env)->ReleaseIntArrayElements(env, arg4, lparg4, 0);
+	if (arg3 && lparg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0);
+	if (arg2 && lparg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
+	OS_NATIVE_EXIT(env, that, _1XQueryPointer_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1XQueryTree
+JNIEXPORT jint JNICALL OS_NATIVE(_1XQueryTree)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jintArray arg2, jintArray arg3, jintArray arg4, jintArray arg5)
+{
+	jint *lparg2=NULL;
+	jint *lparg3=NULL;
+	jint *lparg4=NULL;
+	jint *lparg5=NULL;
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1XQueryTree_FUNC);
+	if (arg2) if ((lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL)) == NULL) goto fail;
+	if (arg3) if ((lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL)) == NULL) goto fail;
+	if (arg4) if ((lparg4 = (*env)->GetIntArrayElements(env, arg4, NULL)) == NULL) goto fail;
+	if (arg5) if ((lparg5 = (*env)->GetIntArrayElements(env, arg5, NULL)) == NULL) goto fail;
+	rc = (jint)XQueryTree((Display *)arg0, (Window)arg1, (Window *)lparg2, (Window *)lparg3, (Window **)lparg4, (unsigned int *)lparg5);
+fail:
+	if (arg5 && lparg5) (*env)->ReleaseIntArrayElements(env, arg5, lparg5, 0);
+	if (arg4 && lparg4) (*env)->ReleaseIntArrayElements(env, arg4, lparg4, 0);
+	if (arg3 && lparg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0);
+	if (arg2 && lparg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
+	OS_NATIVE_EXIT(env, that, _1XQueryTree_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1XReconfigureWMWindow
+JNIEXPORT jint JNICALL OS_NATIVE(_1XReconfigureWMWindow)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jobject arg4)
+{
+	XWindowChanges _arg4, *lparg4=NULL;
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1XReconfigureWMWindow_FUNC);
+	if (arg4) if ((lparg4 = getXWindowChangesFields(env, arg4, &_arg4)) == NULL) goto fail;
+	rc = (jint)XReconfigureWMWindow((Display *)arg0, (Window)arg1, arg2, arg3, lparg4);
+fail:
+	OS_NATIVE_EXIT(env, that, _1XReconfigureWMWindow_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1XRenderComposite
+JNIEXPORT void JNICALL OS_NATIVE(_1XRenderComposite)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4, jint arg5, jint arg6, jint arg7, jint arg8, jint arg9, jint arg10, jint arg11, jint arg12)
+{
+	OS_NATIVE_ENTER(env, that, _1XRenderComposite_FUNC);
+/*
+	XRenderComposite(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef void (*FPTR)(jint, jint, jint, jint, jint, jint, jint, jint, jint, jint, jint, jint, jint);
+		static FPTR fptr;
+		if (!initialized) {
+			if (!handle) handle = dlopen(XRenderComposite_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "XRenderComposite");
+			initialized = 1;
+		}
+		if (fptr) {
+			(*fptr)(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1XRenderComposite_FUNC);
+}
+#endif
+
+#ifndef NO__1XRenderCreatePicture
+JNIEXPORT jint JNICALL OS_NATIVE(_1XRenderCreatePicture)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jobject arg4)
+{
+	XRenderPictureAttributes _arg4, *lparg4=NULL;
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1XRenderCreatePicture_FUNC);
+	if (arg4) if ((lparg4 = getXRenderPictureAttributesFields(env, arg4, &_arg4)) == NULL) goto fail;
+/*
+	rc = (jint)XRenderCreatePicture(arg0, arg1, arg2, arg3, lparg4);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jint (*FPTR)(jint, jint, jint, jint, XRenderPictureAttributes *);
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(XRenderCreatePicture_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "XRenderCreatePicture");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jint)(*fptr)(arg0, arg1, arg2, arg3, lparg4);
+		}
+	}
+fail:
+	OS_NATIVE_EXIT(env, that, _1XRenderCreatePicture_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1XRenderFindStandardFormat
+JNIEXPORT jint JNICALL OS_NATIVE(_1XRenderFindStandardFormat)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1XRenderFindStandardFormat_FUNC);
+/*
+	rc = (jint)XRenderFindStandardFormat(arg0, arg1);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jint (*FPTR)(jint, jint);
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(XRenderFindStandardFormat_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "XRenderFindStandardFormat");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jint)(*fptr)(arg0, arg1);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1XRenderFindStandardFormat_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1XRenderFindVisualFormat
+JNIEXPORT jint JNICALL OS_NATIVE(_1XRenderFindVisualFormat)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1XRenderFindVisualFormat_FUNC);
+/*
+	rc = (jint)XRenderFindVisualFormat(arg0, arg1);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jint (*FPTR)(jint, jint);
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(XRenderFindVisualFormat_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "XRenderFindVisualFormat");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jint)(*fptr)(arg0, arg1);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1XRenderFindVisualFormat_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1XRenderFreePicture
+JNIEXPORT void JNICALL OS_NATIVE(_1XRenderFreePicture)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1XRenderFreePicture_FUNC);
+/*
+	XRenderFreePicture(arg0, arg1);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef void (*FPTR)(jint, jint);
+		static FPTR fptr;
+		if (!initialized) {
+			if (!handle) handle = dlopen(XRenderFreePicture_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "XRenderFreePicture");
+			initialized = 1;
+		}
+		if (fptr) {
+			(*fptr)(arg0, arg1);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1XRenderFreePicture_FUNC);
+}
+#endif
+
+#ifndef NO__1XRenderQueryExtension
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1XRenderQueryExtension)
+	(JNIEnv *env, jclass that, jint arg0, jintArray arg1, jintArray arg2)
+{
+	jint *lparg1=NULL;
+	jint *lparg2=NULL;
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1XRenderQueryExtension_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	if (arg2) if ((lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL)) == NULL) goto fail;
+/*
+	rc = (jboolean)XRenderQueryExtension(arg0, lparg1, lparg2);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jboolean (*FPTR)(jint, jint *, jint *);
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(XRenderQueryExtension_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "XRenderQueryExtension");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jboolean)(*fptr)(arg0, lparg1, lparg2);
+		}
+	}
+fail:
+	if (arg2 && lparg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
+	if (arg1 && lparg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0);
+	OS_NATIVE_EXIT(env, that, _1XRenderQueryExtension_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1XRenderQueryVersion
+JNIEXPORT jint JNICALL OS_NATIVE(_1XRenderQueryVersion)
+	(JNIEnv *env, jclass that, jint arg0, jintArray arg1, jintArray arg2)
+{
+	jint *lparg1=NULL;
+	jint *lparg2=NULL;
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1XRenderQueryVersion_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	if (arg2) if ((lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL)) == NULL) goto fail;
+/*
+	rc = (jint)XRenderQueryVersion(arg0, lparg1, lparg2);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jint (*FPTR)(jint, jint *, jint *);
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(XRenderQueryVersion_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "XRenderQueryVersion");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jint)(*fptr)(arg0, lparg1, lparg2);
+		}
+	}
+fail:
+	if (arg2 && lparg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
+	if (arg1 && lparg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0);
+	OS_NATIVE_EXIT(env, that, _1XRenderQueryVersion_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1XRenderSetPictureClipRectangles
+JNIEXPORT void JNICALL OS_NATIVE(_1XRenderSetPictureClipRectangles)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jshortArray arg4, jint arg5)
+{
+	jshort *lparg4=NULL;
+	OS_NATIVE_ENTER(env, that, _1XRenderSetPictureClipRectangles_FUNC);
+	if (arg4) if ((lparg4 = (*env)->GetShortArrayElements(env, arg4, NULL)) == NULL) goto fail;
+/*
+	XRenderSetPictureClipRectangles(arg0, arg1, arg2, arg3, lparg4, arg5);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef void (*FPTR)(jint, jint, jint, jint, jshort *, jint);
+		static FPTR fptr;
+		if (!initialized) {
+			if (!handle) handle = dlopen(XRenderSetPictureClipRectangles_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "XRenderSetPictureClipRectangles");
+			initialized = 1;
+		}
+		if (fptr) {
+			(*fptr)(arg0, arg1, arg2, arg3, lparg4, arg5);
+		}
+	}
+fail:
+	if (arg4 && lparg4) (*env)->ReleaseShortArrayElements(env, arg4, lparg4, 0);
+	OS_NATIVE_EXIT(env, that, _1XRenderSetPictureClipRectangles_FUNC);
+}
+#endif
+
+#ifndef NO__1XRenderSetPictureTransform
+JNIEXPORT void JNICALL OS_NATIVE(_1XRenderSetPictureTransform)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jintArray arg2)
+{
+	jint *lparg2=NULL;
+	OS_NATIVE_ENTER(env, that, _1XRenderSetPictureTransform_FUNC);
+	if (arg2) if ((lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL)) == NULL) goto fail;
+/*
+	XRenderSetPictureTransform(arg0, arg1, lparg2);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef void (*FPTR)(jint, jint, jint *);
+		static FPTR fptr;
+		if (!initialized) {
+			if (!handle) handle = dlopen(XRenderSetPictureTransform_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "XRenderSetPictureTransform");
+			initialized = 1;
+		}
+		if (fptr) {
+			(*fptr)(arg0, arg1, lparg2);
+		}
+	}
+fail:
+	if (arg2 && lparg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
+	OS_NATIVE_EXIT(env, that, _1XRenderSetPictureTransform_FUNC);
+}
+#endif
+
+#ifndef NO__1XSendEvent
+JNIEXPORT jint JNICALL OS_NATIVE(_1XSendEvent)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jboolean arg2, jint arg3, jint arg4)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1XSendEvent_FUNC);
+	rc = (jint)XSendEvent((Display *)arg0, (Window)arg1, arg2, arg3, (XEvent *)arg4);
+	OS_NATIVE_EXIT(env, that, _1XSendEvent_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1XSetErrorHandler
+JNIEXPORT jint JNICALL OS_NATIVE(_1XSetErrorHandler)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1XSetErrorHandler_FUNC);
+	rc = (jint)XSetErrorHandler((XErrorHandler)arg0);
+	OS_NATIVE_EXIT(env, that, _1XSetErrorHandler_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1XSetIOErrorHandler
+JNIEXPORT jint JNICALL OS_NATIVE(_1XSetIOErrorHandler)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1XSetIOErrorHandler_FUNC);
+	rc = (jint)XSetIOErrorHandler((XIOErrorHandler)arg0);
+	OS_NATIVE_EXIT(env, that, _1XSetIOErrorHandler_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1XSetInputFocus
+JNIEXPORT jint JNICALL OS_NATIVE(_1XSetInputFocus)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1XSetInputFocus_FUNC);
+	rc = (jint)XSetInputFocus((Display *)arg0, (Window)arg1, arg2, arg3);
+	OS_NATIVE_EXIT(env, that, _1XSetInputFocus_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1XSetTransientForHint
+JNIEXPORT jint JNICALL OS_NATIVE(_1XSetTransientForHint)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1XSetTransientForHint_FUNC);
+	rc = (jint)XSetTransientForHint((Display *)arg0, (Window)arg1, (Window)arg2);
+	OS_NATIVE_EXIT(env, that, _1XSetTransientForHint_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1XSynchronize
+JNIEXPORT jint JNICALL OS_NATIVE(_1XSynchronize)
+	(JNIEnv *env, jclass that, jint arg0, jboolean arg1)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1XSynchronize_FUNC);
+	rc = (jint)XSynchronize((Display *)arg0, arg1);
+	OS_NATIVE_EXIT(env, that, _1XSynchronize_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1XTestFakeButtonEvent
+JNIEXPORT void JNICALL OS_NATIVE(_1XTestFakeButtonEvent)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jboolean arg2, jint arg3)
+{
+	OS_NATIVE_ENTER(env, that, _1XTestFakeButtonEvent_FUNC);
+	XTestFakeButtonEvent((Display *)arg0, arg1, (Bool)arg2, (unsigned long)arg3);
+	OS_NATIVE_EXIT(env, that, _1XTestFakeButtonEvent_FUNC);
+}
+#endif
+
+#ifndef NO__1XTestFakeKeyEvent
+JNIEXPORT void JNICALL OS_NATIVE(_1XTestFakeKeyEvent)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jboolean arg2, jint arg3)
+{
+	OS_NATIVE_ENTER(env, that, _1XTestFakeKeyEvent_FUNC);
+	XTestFakeKeyEvent((Display *)arg0, arg1, (Bool)arg2, (unsigned long)arg3);
+	OS_NATIVE_EXIT(env, that, _1XTestFakeKeyEvent_FUNC);
+}
+#endif
+
+#ifndef NO__1XTestFakeMotionEvent
+JNIEXPORT void JNICALL OS_NATIVE(_1XTestFakeMotionEvent)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4)
+{
+	OS_NATIVE_ENTER(env, that, _1XTestFakeMotionEvent_FUNC);
+	XTestFakeMotionEvent((Display *)arg0, arg1, arg2, arg3, (unsigned long)arg4);
+	OS_NATIVE_EXIT(env, that, _1XTestFakeMotionEvent_FUNC);
+}
+#endif
+
+#ifndef NO__1XWarpPointer
+JNIEXPORT jint JNICALL OS_NATIVE(_1XWarpPointer)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4, jint arg5, jint arg6, jint arg7, jint arg8)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1XWarpPointer_FUNC);
+	rc = (jint)XWarpPointer((Display *)arg0, (Window)arg1, (Window)arg2, arg3, arg4, arg5, arg6, arg7, arg8);
+	OS_NATIVE_EXIT(env, that, _1XWarpPointer_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1atk_1object_1add_1relationship
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1atk_1object_1add_1relationship)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1atk_1object_1add_1relationship_FUNC);
+/*
+	rc = (jboolean)atk_object_add_relationship((AtkObject *)arg0, (AtkRelationType)arg1, (AtkObject *)arg2);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jboolean (*FPTR)(AtkObject *, AtkRelationType, AtkObject *);
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(atk_object_add_relationship_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "atk_object_add_relationship");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jboolean)(*fptr)((AtkObject *)arg0, (AtkRelationType)arg1, (AtkObject *)arg2);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1atk_1object_1add_1relationship_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1call
+JNIEXPORT jint JNICALL OS_NATIVE(_1call)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4, jint arg5, jint arg6, jint arg7)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1call_FUNC);
+	rc = (jint)((jint (*)())arg0)(arg1, arg2, arg3, arg4, arg5, arg6, arg7);
+	OS_NATIVE_EXIT(env, that, _1call_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1dlclose
+JNIEXPORT jint JNICALL OS_NATIVE(_1dlclose)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1dlclose_FUNC);
+	rc = (jint)dlclose((void *)arg0);
+	OS_NATIVE_EXIT(env, that, _1dlclose_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1dlopen
+JNIEXPORT jint JNICALL OS_NATIVE(_1dlopen)
+	(JNIEnv *env, jclass that, jbyteArray arg0, jint arg1)
+{
+	jbyte *lparg0=NULL;
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1dlopen_FUNC);
+	if (arg0) if ((lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL)) == NULL) goto fail;
+	rc = (jint)dlopen((const char *)lparg0, arg1);
+fail:
+	if (arg0 && lparg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
+	OS_NATIVE_EXIT(env, that, _1dlopen_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1dlsym
+JNIEXPORT jint JNICALL OS_NATIVE(_1dlsym)
+	(JNIEnv *env, jclass that, jint arg0, jbyteArray arg1)
+{
+	jbyte *lparg1=NULL;
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1dlsym_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	rc = (jint)dlsym((void *)arg0, (const char *)lparg1);
+fail:
+	if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+	OS_NATIVE_EXIT(env, that, _1dlsym_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1g_1cclosure_1new
+JNIEXPORT jint JNICALL OS_NATIVE(_1g_1cclosure_1new)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1g_1cclosure_1new_FUNC);
+	rc = (jint)g_cclosure_new((GCallback)arg0, (gpointer)arg1, (GClosureNotify)arg2);
+	OS_NATIVE_EXIT(env, that, _1g_1cclosure_1new_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1g_1closure_1ref
+JNIEXPORT jint JNICALL OS_NATIVE(_1g_1closure_1ref)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1g_1closure_1ref_FUNC);
+	rc = (jint)g_closure_ref((GClosure *)arg0);
+	OS_NATIVE_EXIT(env, that, _1g_1closure_1ref_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1g_1closure_1unref
+JNIEXPORT void JNICALL OS_NATIVE(_1g_1closure_1unref)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1g_1closure_1unref_FUNC);
+	g_closure_unref((GClosure *)arg0);
+	OS_NATIVE_EXIT(env, that, _1g_1closure_1unref_FUNC);
+}
+#endif
+
+#ifndef NO__1g_1filename_1from_1uri
+JNIEXPORT jint JNICALL OS_NATIVE(_1g_1filename_1from_1uri)
+	(JNIEnv *env, jclass that, jint arg0, jintArray arg1, jintArray arg2)
+{
+	jint *lparg1=NULL;
+	jint *lparg2=NULL;
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1g_1filename_1from_1uri_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	if (arg2) if ((lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL)) == NULL) goto fail;
+	rc = (jint)g_filename_from_uri((const char *)arg0, (char **)lparg1, (GError **)lparg2);
+fail:
+	if (arg2 && lparg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
+	if (arg1 && lparg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0);
+	OS_NATIVE_EXIT(env, that, _1g_1filename_1from_1uri_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1g_1filename_1from_1utf8
+JNIEXPORT jint JNICALL OS_NATIVE(_1g_1filename_1from_1utf8)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jintArray arg2, jintArray arg3, jintArray arg4)
+{
+	jint *lparg2=NULL;
+	jint *lparg3=NULL;
+	jint *lparg4=NULL;
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1g_1filename_1from_1utf8_FUNC);
+	if (arg2) if ((lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL)) == NULL) goto fail;
+	if (arg3) if ((lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL)) == NULL) goto fail;
+	if (arg4) if ((lparg4 = (*env)->GetIntArrayElements(env, arg4, NULL)) == NULL) goto fail;
+	rc = (jint)g_filename_from_utf8((const gchar *)arg0, (gssize)arg1, (gsize *)lparg2, (gsize *)lparg3, (GError **)lparg4);
+fail:
+	if (arg4 && lparg4) (*env)->ReleaseIntArrayElements(env, arg4, lparg4, 0);
+	if (arg3 && lparg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0);
+	if (arg2 && lparg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
+	OS_NATIVE_EXIT(env, that, _1g_1filename_1from_1utf8_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1g_1filename_1to_1uri
+JNIEXPORT jint JNICALL OS_NATIVE(_1g_1filename_1to_1uri)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jintArray arg2)
+{
+	jint *lparg2=NULL;
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1g_1filename_1to_1uri_FUNC);
+	if (arg2) if ((lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL)) == NULL) goto fail;
+	rc = (jint)g_filename_to_uri((const char *)arg0, (const char *)arg1, (GError **)lparg2);
+fail:
+	if (arg2 && lparg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
+	OS_NATIVE_EXIT(env, that, _1g_1filename_1to_1uri_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1g_1filename_1to_1utf8
+JNIEXPORT jint JNICALL OS_NATIVE(_1g_1filename_1to_1utf8)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jintArray arg2, jintArray arg3, jintArray arg4)
+{
+	jint *lparg2=NULL;
+	jint *lparg3=NULL;
+	jint *lparg4=NULL;
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1g_1filename_1to_1utf8_FUNC);
+	if (arg2) if ((lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL)) == NULL) goto fail;
+	if (arg3) if ((lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL)) == NULL) goto fail;
+	if (arg4) if ((lparg4 = (*env)->GetIntArrayElements(env, arg4, NULL)) == NULL) goto fail;
+	rc = (jint)g_filename_to_utf8((const gchar *)arg0, (gssize)arg1, (gsize *)lparg2, (gsize *)lparg3, (GError **)lparg4);
+fail:
+	if (arg4 && lparg4) (*env)->ReleaseIntArrayElements(env, arg4, lparg4, 0);
+	if (arg3 && lparg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0);
+	if (arg2 && lparg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
+	OS_NATIVE_EXIT(env, that, _1g_1filename_1to_1utf8_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1g_1free
+JNIEXPORT void JNICALL OS_NATIVE(_1g_1free)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1g_1free_FUNC);
+	g_free((gpointer)arg0);
+	OS_NATIVE_EXIT(env, that, _1g_1free_FUNC);
+}
+#endif
+
+#ifndef NO__1g_1idle_1add
+JNIEXPORT jint JNICALL OS_NATIVE(_1g_1idle_1add)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1g_1idle_1add_FUNC);
+	rc = (jint)g_idle_add((GSourceFunc)arg0, (gpointer)arg1);
+	OS_NATIVE_EXIT(env, that, _1g_1idle_1add_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1g_1list_1append
+JNIEXPORT jint JNICALL OS_NATIVE(_1g_1list_1append)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1g_1list_1append_FUNC);
+	rc = (jint)g_list_append((GList *)arg0, (gpointer)arg1);
+	OS_NATIVE_EXIT(env, that, _1g_1list_1append_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1g_1list_1data
+JNIEXPORT jint JNICALL OS_NATIVE(_1g_1list_1data)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1g_1list_1data_FUNC);
+	rc = (jint)g_list_data((GList *)arg0);
+	OS_NATIVE_EXIT(env, that, _1g_1list_1data_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1g_1list_1free
+JNIEXPORT void JNICALL OS_NATIVE(_1g_1list_1free)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1g_1list_1free_FUNC);
+	g_list_free((GList *)arg0);
+	OS_NATIVE_EXIT(env, that, _1g_1list_1free_FUNC);
+}
+#endif
+
+#ifndef NO__1g_1list_1free_11
+JNIEXPORT void JNICALL OS_NATIVE(_1g_1list_1free_11)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1g_1list_1free_11_FUNC);
+	g_list_free_1((GList *)arg0);
+	OS_NATIVE_EXIT(env, that, _1g_1list_1free_11_FUNC);
+}
+#endif
+
+#ifndef NO__1g_1list_1length
+JNIEXPORT jint JNICALL OS_NATIVE(_1g_1list_1length)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1g_1list_1length_FUNC);
+	rc = (jint)g_list_length((GList *)arg0);
+	OS_NATIVE_EXIT(env, that, _1g_1list_1length_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1g_1list_1next
+JNIEXPORT jint JNICALL OS_NATIVE(_1g_1list_1next)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1g_1list_1next_FUNC);
+	rc = (jint)g_list_next(arg0);
+	OS_NATIVE_EXIT(env, that, _1g_1list_1next_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1g_1list_1nth
+JNIEXPORT jint JNICALL OS_NATIVE(_1g_1list_1nth)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1g_1list_1nth_FUNC);
+	rc = (jint)g_list_nth((GList *)arg0, (guint)arg1);
+	OS_NATIVE_EXIT(env, that, _1g_1list_1nth_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1g_1list_1nth_1data
+JNIEXPORT jint JNICALL OS_NATIVE(_1g_1list_1nth_1data)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1g_1list_1nth_1data_FUNC);
+	rc = (jint)g_list_nth_data((GList *)arg0, (guint)arg1);
+	OS_NATIVE_EXIT(env, that, _1g_1list_1nth_1data_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1g_1list_1prepend
+JNIEXPORT jint JNICALL OS_NATIVE(_1g_1list_1prepend)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1g_1list_1prepend_FUNC);
+	rc = (jint)g_list_prepend((GList *)arg0, (gpointer)arg1);
+	OS_NATIVE_EXIT(env, that, _1g_1list_1prepend_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1g_1list_1previous
+JNIEXPORT jint JNICALL OS_NATIVE(_1g_1list_1previous)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1g_1list_1previous_FUNC);
+	rc = (jint)g_list_previous(arg0);
+	OS_NATIVE_EXIT(env, that, _1g_1list_1previous_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1g_1list_1remove_1link
+JNIEXPORT jint JNICALL OS_NATIVE(_1g_1list_1remove_1link)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1g_1list_1remove_1link_FUNC);
+	rc = (jint)g_list_remove_link((GList *)arg0, (GList *)arg1);
+	OS_NATIVE_EXIT(env, that, _1g_1list_1remove_1link_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1g_1list_1reverse
+JNIEXPORT jint JNICALL OS_NATIVE(_1g_1list_1reverse)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1g_1list_1reverse_FUNC);
+	rc = (jint)g_list_reverse((GList *)arg0);
+	OS_NATIVE_EXIT(env, that, _1g_1list_1reverse_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1g_1list_1set_1next
+JNIEXPORT void JNICALL OS_NATIVE(_1g_1list_1set_1next)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1g_1list_1set_1next_FUNC);
+	g_list_set_next((GList *)arg0, (GList *)arg1);
+	OS_NATIVE_EXIT(env, that, _1g_1list_1set_1next_FUNC);
+}
+#endif
+
+#ifndef NO__1g_1list_1set_1previous
+JNIEXPORT void JNICALL OS_NATIVE(_1g_1list_1set_1previous)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1g_1list_1set_1previous_FUNC);
+	g_list_set_previous((GList *)arg0, (GList *)arg1);
+	OS_NATIVE_EXIT(env, that, _1g_1list_1set_1previous_FUNC);
+}
+#endif
+
+#ifndef NO__1g_1locale_1from_1utf8
+JNIEXPORT jint JNICALL OS_NATIVE(_1g_1locale_1from_1utf8)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jintArray arg2, jintArray arg3, jintArray arg4)
+{
+	jint *lparg2=NULL;
+	jint *lparg3=NULL;
+	jint *lparg4=NULL;
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1g_1locale_1from_1utf8_FUNC);
+	if (arg2) if ((lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL)) == NULL) goto fail;
+	if (arg3) if ((lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL)) == NULL) goto fail;
+	if (arg4) if ((lparg4 = (*env)->GetIntArrayElements(env, arg4, NULL)) == NULL) goto fail;
+	rc = (jint)g_locale_from_utf8((const gchar *)arg0, (gssize)arg1, (gsize *)lparg2, (gsize *)lparg3, (GError **)lparg4);
+fail:
+	if (arg4 && lparg4) (*env)->ReleaseIntArrayElements(env, arg4, lparg4, 0);
+	if (arg3 && lparg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0);
+	if (arg2 && lparg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
+	OS_NATIVE_EXIT(env, that, _1g_1locale_1from_1utf8_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1g_1locale_1to_1utf8
+JNIEXPORT jint JNICALL OS_NATIVE(_1g_1locale_1to_1utf8)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jintArray arg2, jintArray arg3, jintArray arg4)
+{
+	jint *lparg2=NULL;
+	jint *lparg3=NULL;
+	jint *lparg4=NULL;
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1g_1locale_1to_1utf8_FUNC);
+	if (arg2) if ((lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL)) == NULL) goto fail;
+	if (arg3) if ((lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL)) == NULL) goto fail;
+	if (arg4) if ((lparg4 = (*env)->GetIntArrayElements(env, arg4, NULL)) == NULL) goto fail;
+	rc = (jint)g_locale_to_utf8((const gchar *)arg0, (gssize)arg1, (gsize *)lparg2, (gsize *)lparg3, (GError **)lparg4);
+fail:
+	if (arg4 && lparg4) (*env)->ReleaseIntArrayElements(env, arg4, lparg4, 0);
+	if (arg3 && lparg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0);
+	if (arg2 && lparg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
+	OS_NATIVE_EXIT(env, that, _1g_1locale_1to_1utf8_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1g_1log_1default_1handler
+JNIEXPORT void JNICALL OS_NATIVE(_1g_1log_1default_1handler)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3)
+{
+	OS_NATIVE_ENTER(env, that, _1g_1log_1default_1handler_FUNC);
+	g_log_default_handler((gchar *)arg0, (GLogLevelFlags)arg1, (gchar *)arg2, (gpointer)arg3);
+	OS_NATIVE_EXIT(env, that, _1g_1log_1default_1handler_FUNC);
+}
+#endif
+
+#ifndef NO__1g_1log_1remove_1handler
+JNIEXPORT void JNICALL OS_NATIVE(_1g_1log_1remove_1handler)
+	(JNIEnv *env, jclass that, jbyteArray arg0, jint arg1)
+{
+	jbyte *lparg0=NULL;
+	OS_NATIVE_ENTER(env, that, _1g_1log_1remove_1handler_FUNC);
+	if (arg0) if ((lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL)) == NULL) goto fail;
+	g_log_remove_handler((gchar *)lparg0, (gint)arg1);
+fail:
+	if (arg0 && lparg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, JNI_ABORT);
+	OS_NATIVE_EXIT(env, that, _1g_1log_1remove_1handler_FUNC);
+}
+#endif
+
+#ifndef NO__1g_1log_1set_1handler
+JNIEXPORT jint JNICALL OS_NATIVE(_1g_1log_1set_1handler)
+	(JNIEnv *env, jclass that, jbyteArray arg0, jint arg1, jint arg2, jint arg3)
+{
+	jbyte *lparg0=NULL;
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1g_1log_1set_1handler_FUNC);
+	if (arg0) if ((lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL)) == NULL) goto fail;
+	rc = (jint)g_log_set_handler((gchar *)lparg0, (GLogLevelFlags)arg1, (GLogFunc)arg2, (gpointer)arg3);
+fail:
+	if (arg0 && lparg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, JNI_ABORT);
+	OS_NATIVE_EXIT(env, that, _1g_1log_1set_1handler_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1g_1main_1context_1acquire
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1g_1main_1context_1acquire)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1g_1main_1context_1acquire_FUNC);
+	rc = (jboolean)g_main_context_acquire((GMainContext *)arg0);
+	OS_NATIVE_EXIT(env, that, _1g_1main_1context_1acquire_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1g_1main_1context_1check
+JNIEXPORT jint JNICALL OS_NATIVE(_1g_1main_1context_1check)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1g_1main_1context_1check_FUNC);
+	rc = (jint)g_main_context_check((GMainContext *)arg0, arg1, (GPollFD *)arg2, arg3);
+	OS_NATIVE_EXIT(env, that, _1g_1main_1context_1check_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1g_1main_1context_1default
+JNIEXPORT jint JNICALL OS_NATIVE(_1g_1main_1context_1default)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1g_1main_1context_1default_FUNC);
+	rc = (jint)g_main_context_default();
+	OS_NATIVE_EXIT(env, that, _1g_1main_1context_1default_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1g_1main_1context_1get_1poll_1func
+JNIEXPORT jint JNICALL OS_NATIVE(_1g_1main_1context_1get_1poll_1func)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1g_1main_1context_1get_1poll_1func_FUNC);
+	rc = (jint)g_main_context_get_poll_func((GMainContext *)arg0);
+	OS_NATIVE_EXIT(env, that, _1g_1main_1context_1get_1poll_1func_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1g_1main_1context_1iteration
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1g_1main_1context_1iteration)
+	(JNIEnv *env, jclass that, jint arg0, jboolean arg1)
+{
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1g_1main_1context_1iteration_FUNC);
+	rc = (jboolean)g_main_context_iteration((GMainContext *)arg0, arg1);
+	OS_NATIVE_EXIT(env, that, _1g_1main_1context_1iteration_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1g_1main_1context_1pending
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1g_1main_1context_1pending)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1g_1main_1context_1pending_FUNC);
+	rc = (jboolean)g_main_context_pending((GMainContext *)arg0);
+	OS_NATIVE_EXIT(env, that, _1g_1main_1context_1pending_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1g_1main_1context_1prepare
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1g_1main_1context_1prepare)
+	(JNIEnv *env, jclass that, jint arg0, jintArray arg1)
+{
+	jint *lparg1=NULL;
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1g_1main_1context_1prepare_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	rc = (jboolean)g_main_context_prepare((GMainContext *)arg0, lparg1);
+fail:
+	if (arg1 && lparg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0);
+	OS_NATIVE_EXIT(env, that, _1g_1main_1context_1prepare_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1g_1main_1context_1query
+JNIEXPORT jint JNICALL OS_NATIVE(_1g_1main_1context_1query)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jintArray arg2, jint arg3, jint arg4)
+{
+	jint *lparg2=NULL;
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1g_1main_1context_1query_FUNC);
+	if (arg2) if ((lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL)) == NULL) goto fail;
+	rc = (jint)g_main_context_query((GMainContext *)arg0, arg1, lparg2, (GPollFD *)arg3, arg4);
+fail:
+	if (arg2 && lparg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
+	OS_NATIVE_EXIT(env, that, _1g_1main_1context_1query_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1g_1main_1context_1release
+JNIEXPORT void JNICALL OS_NATIVE(_1g_1main_1context_1release)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1g_1main_1context_1release_FUNC);
+	g_main_context_release((GMainContext *)arg0);
+	OS_NATIVE_EXIT(env, that, _1g_1main_1context_1release_FUNC);
+}
+#endif
+
+#ifndef NO__1g_1malloc
+JNIEXPORT jint JNICALL OS_NATIVE(_1g_1malloc)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1g_1malloc_FUNC);
+	rc = (jint)g_malloc((gulong)arg0);
+	OS_NATIVE_EXIT(env, that, _1g_1malloc_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1g_1object_1get
+JNIEXPORT void JNICALL OS_NATIVE(_1g_1object_1get)
+	(JNIEnv *env, jclass that, jint arg0, jbyteArray arg1, jintArray arg2, jint arg3)
+{
+	jbyte *lparg1=NULL;
+	jint *lparg2=NULL;
+	OS_NATIVE_ENTER(env, that, _1g_1object_1get_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	if (arg2) if ((lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL)) == NULL) goto fail;
+	g_object_get((GObject *)arg0, (const gchar *)lparg1, lparg2, (const gchar *)NULL);
+fail:
+	if (arg2 && lparg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
+	if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, JNI_ABORT);
+	OS_NATIVE_EXIT(env, that, _1g_1object_1get_FUNC);
+}
+#endif
+
+#ifndef NO__1g_1object_1get_1qdata
+JNIEXPORT jint JNICALL OS_NATIVE(_1g_1object_1get_1qdata)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1g_1object_1get_1qdata_FUNC);
+	rc = (jint)g_object_get_qdata((GObject *)arg0, (GQuark)arg1);
+	OS_NATIVE_EXIT(env, that, _1g_1object_1get_1qdata_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1g_1object_1new
+JNIEXPORT jint JNICALL OS_NATIVE(_1g_1object_1new)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1g_1object_1new_FUNC);
+	rc = (jint)g_object_new((GType)arg0, (const gchar *)arg1);
+	OS_NATIVE_EXIT(env, that, _1g_1object_1new_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1g_1object_1ref
+JNIEXPORT jint JNICALL OS_NATIVE(_1g_1object_1ref)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1g_1object_1ref_FUNC);
+	rc = (jint)g_object_ref((gpointer)arg0);
+	OS_NATIVE_EXIT(env, that, _1g_1object_1ref_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1g_1object_1set__I_3BFI
+JNIEXPORT void JNICALL OS_NATIVE(_1g_1object_1set__I_3BFI)
+	(JNIEnv *env, jclass that, jint arg0, jbyteArray arg1, jfloat arg2, jint arg3)
+{
+	jbyte *lparg1=NULL;
+	OS_NATIVE_ENTER(env, that, _1g_1object_1set__I_3BFI_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	g_object_set((gpointer)arg0, (const gchar *)lparg1, arg2, (const gchar *)NULL);
+fail:
+	if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, JNI_ABORT);
+	OS_NATIVE_EXIT(env, that, _1g_1object_1set__I_3BFI_FUNC);
+}
+#endif
+
+#ifndef NO__1g_1object_1set__I_3BII
+JNIEXPORT void JNICALL OS_NATIVE(_1g_1object_1set__I_3BII)
+	(JNIEnv *env, jclass that, jint arg0, jbyteArray arg1, jint arg2, jint arg3)
+{
+	jbyte *lparg1=NULL;
+	OS_NATIVE_ENTER(env, that, _1g_1object_1set__I_3BII_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	g_object_set((gpointer)arg0, (const gchar *)lparg1, arg2, (const gchar *)NULL);
+fail:
+	if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, JNI_ABORT);
+	OS_NATIVE_EXIT(env, that, _1g_1object_1set__I_3BII_FUNC);
+}
+#endif
+
+#ifndef NO__1g_1object_1set__I_3BJI
+JNIEXPORT void JNICALL OS_NATIVE(_1g_1object_1set__I_3BJI)
+	(JNIEnv *env, jclass that, jint arg0, jbyteArray arg1, jlong arg2, jint arg3)
+{
+	jbyte *lparg1=NULL;
+	OS_NATIVE_ENTER(env, that, _1g_1object_1set__I_3BJI_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	g_object_set((gpointer)arg0, (const gchar *)lparg1, arg2, (const gchar *)NULL);
+fail:
+	if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, JNI_ABORT);
+	OS_NATIVE_EXIT(env, that, _1g_1object_1set__I_3BJI_FUNC);
+}
+#endif
+
+#ifndef NO__1g_1object_1set__I_3BLorg_eclipse_swt_internal_gtk_GdkColor_2I
+JNIEXPORT void JNICALL OS_NATIVE(_1g_1object_1set__I_3BLorg_eclipse_swt_internal_gtk_GdkColor_2I)
+	(JNIEnv *env, jclass that, jint arg0, jbyteArray arg1, jobject arg2, jint arg3)
+{
+	jbyte *lparg1=NULL;
+	GdkColor _arg2, *lparg2=NULL;
+	OS_NATIVE_ENTER(env, that, _1g_1object_1set__I_3BLorg_eclipse_swt_internal_gtk_GdkColor_2I_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	if (arg2) if ((lparg2 = getGdkColorFields(env, arg2, &_arg2)) == NULL) goto fail;
+	g_object_set((gpointer)arg0, (const gchar *)lparg1, lparg2, (const gchar *)NULL);
+fail:
+	if (arg2 && lparg2) setGdkColorFields(env, arg2, lparg2);
+	if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+	OS_NATIVE_EXIT(env, that, _1g_1object_1set__I_3BLorg_eclipse_swt_internal_gtk_GdkColor_2I_FUNC);
+}
+#endif
+
+#ifndef NO__1g_1object_1set__I_3BZI
+JNIEXPORT void JNICALL OS_NATIVE(_1g_1object_1set__I_3BZI)
+	(JNIEnv *env, jclass that, jint arg0, jbyteArray arg1, jboolean arg2, jint arg3)
+{
+	jbyte *lparg1=NULL;
+	OS_NATIVE_ENTER(env, that, _1g_1object_1set__I_3BZI_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	g_object_set((gpointer)arg0, (const gchar *)lparg1, arg2, (const gchar *)NULL);
+fail:
+	if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, JNI_ABORT);
+	OS_NATIVE_EXIT(env, that, _1g_1object_1set__I_3BZI_FUNC);
+}
+#endif
+
+#ifndef NO__1g_1object_1set_1qdata
+JNIEXPORT void JNICALL OS_NATIVE(_1g_1object_1set_1qdata)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+	OS_NATIVE_ENTER(env, that, _1g_1object_1set_1qdata_FUNC);
+	g_object_set_qdata((GObject *)arg0, (GQuark)arg1, (gpointer)arg2);
+	OS_NATIVE_EXIT(env, that, _1g_1object_1set_1qdata_FUNC);
+}
+#endif
+
+#ifndef NO__1g_1object_1unref
+JNIEXPORT void JNICALL OS_NATIVE(_1g_1object_1unref)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1g_1object_1unref_FUNC);
+	g_object_unref((gpointer)arg0);
+	OS_NATIVE_EXIT(env, that, _1g_1object_1unref_FUNC);
+}
+#endif
+
+#ifndef NO__1g_1quark_1from_1string
+JNIEXPORT jint JNICALL OS_NATIVE(_1g_1quark_1from_1string)
+	(JNIEnv *env, jclass that, jbyteArray arg0)
+{
+	jbyte *lparg0=NULL;
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1g_1quark_1from_1string_FUNC);
+	if (arg0) if ((lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL)) == NULL) goto fail;
+	rc = (jint)g_quark_from_string((const gchar *)lparg0);
+fail:
+	if (arg0 && lparg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, JNI_ABORT);
+	OS_NATIVE_EXIT(env, that, _1g_1quark_1from_1string_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1g_1set_1prgname
+JNIEXPORT void JNICALL OS_NATIVE(_1g_1set_1prgname)
+	(JNIEnv *env, jclass that, jbyteArray arg0)
+{
+	jbyte *lparg0=NULL;
+	OS_NATIVE_ENTER(env, that, _1g_1set_1prgname_FUNC);
+	if (arg0) if ((lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL)) == NULL) goto fail;
+	g_set_prgname((const gchar *)lparg0);
+fail:
+	if (arg0 && lparg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, JNI_ABORT);
+	OS_NATIVE_EXIT(env, that, _1g_1set_1prgname_FUNC);
+}
+#endif
+
+#ifndef NO__1g_1signal_1add_1emission_1hook
+JNIEXPORT jint JNICALL OS_NATIVE(_1g_1signal_1add_1emission_1hook)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1g_1signal_1add_1emission_1hook_FUNC);
+	rc = (jint)g_signal_add_emission_hook((guint)arg0, (GQuark)arg1, (GSignalEmissionHook)arg2, (gpointer)arg3, (GDestroyNotify)arg4);
+	OS_NATIVE_EXIT(env, that, _1g_1signal_1add_1emission_1hook_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1g_1signal_1connect
+JNIEXPORT jint JNICALL OS_NATIVE(_1g_1signal_1connect)
+	(JNIEnv *env, jclass that, jint arg0, jbyteArray arg1, jint arg2, jint arg3)
+{
+	jbyte *lparg1=NULL;
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1g_1signal_1connect_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	rc = (jint)g_signal_connect((gpointer)arg0, (const gchar *)lparg1, (GCallback)arg2, (gpointer)arg3);
+fail:
+	if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, JNI_ABORT);
+	OS_NATIVE_EXIT(env, that, _1g_1signal_1connect_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1g_1signal_1connect_1after
+JNIEXPORT jint JNICALL OS_NATIVE(_1g_1signal_1connect_1after)
+	(JNIEnv *env, jclass that, jint arg0, jbyteArray arg1, jint arg2, jint arg3)
+{
+	jbyte *lparg1=NULL;
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1g_1signal_1connect_1after_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	rc = (jint)g_signal_connect_after((gpointer)arg0, (const gchar *)lparg1, (GCallback)arg2, (gpointer)arg3);
+fail:
+	if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, JNI_ABORT);
+	OS_NATIVE_EXIT(env, that, _1g_1signal_1connect_1after_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1g_1signal_1connect_1closure
+JNIEXPORT jint JNICALL OS_NATIVE(_1g_1signal_1connect_1closure)
+	(JNIEnv *env, jclass that, jint arg0, jbyteArray arg1, jint arg2, jboolean arg3)
+{
+	jbyte *lparg1=NULL;
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1g_1signal_1connect_1closure_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	rc = (jint)g_signal_connect_closure((gpointer)arg0, (const gchar *)lparg1, (GClosure *)arg2, (gboolean)arg3);
+fail:
+	if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+	OS_NATIVE_EXIT(env, that, _1g_1signal_1connect_1closure_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1g_1signal_1connect_1closure_1by_1id
+JNIEXPORT jint JNICALL OS_NATIVE(_1g_1signal_1connect_1closure_1by_1id)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jboolean arg4)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1g_1signal_1connect_1closure_1by_1id_FUNC);
+	rc = (jint)g_signal_connect_closure_by_id((gpointer)arg0, (guint)arg1, (GQuark)arg2, (GClosure *)arg3, (gboolean)arg4);
+	OS_NATIVE_EXIT(env, that, _1g_1signal_1connect_1closure_1by_1id_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1g_1signal_1emit_1by_1name__I_3B
+JNIEXPORT void JNICALL OS_NATIVE(_1g_1signal_1emit_1by_1name__I_3B)
+	(JNIEnv *env, jclass that, jint arg0, jbyteArray arg1)
+{
+	jbyte *lparg1=NULL;
+	OS_NATIVE_ENTER(env, that, _1g_1signal_1emit_1by_1name__I_3B_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	g_signal_emit_by_name((gpointer)arg0, (const gchar *)lparg1);
+fail:
+	if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, JNI_ABORT);
+	OS_NATIVE_EXIT(env, that, _1g_1signal_1emit_1by_1name__I_3B_FUNC);
+}
+#endif
+
+#ifndef NO__1g_1signal_1emit_1by_1name__I_3BI
+JNIEXPORT void JNICALL OS_NATIVE(_1g_1signal_1emit_1by_1name__I_3BI)
+	(JNIEnv *env, jclass that, jint arg0, jbyteArray arg1, jint arg2)
+{
+	jbyte *lparg1=NULL;
+	OS_NATIVE_ENTER(env, that, _1g_1signal_1emit_1by_1name__I_3BI_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	g_signal_emit_by_name((gpointer)arg0, (const gchar *)lparg1, arg2);
+fail:
+	if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, JNI_ABORT);
+	OS_NATIVE_EXIT(env, that, _1g_1signal_1emit_1by_1name__I_3BI_FUNC);
+}
+#endif
+
+#ifndef NO__1g_1signal_1emit_1by_1name__I_3BII
+JNIEXPORT void JNICALL OS_NATIVE(_1g_1signal_1emit_1by_1name__I_3BII)
+	(JNIEnv *env, jclass that, jint arg0, jbyteArray arg1, jint arg2, jint arg3)
+{
+	jbyte *lparg1=NULL;
+	OS_NATIVE_ENTER(env, that, _1g_1signal_1emit_1by_1name__I_3BII_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	g_signal_emit_by_name((gpointer)arg0, (const gchar *)lparg1, arg2, arg3);
+fail:
+	if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, JNI_ABORT);
+	OS_NATIVE_EXIT(env, that, _1g_1signal_1emit_1by_1name__I_3BII_FUNC);
+}
+#endif
+
+#ifndef NO__1g_1signal_1emit_1by_1name__I_3B_3B
+JNIEXPORT void JNICALL OS_NATIVE(_1g_1signal_1emit_1by_1name__I_3B_3B)
+	(JNIEnv *env, jclass that, jint arg0, jbyteArray arg1, jbyteArray arg2)
+{
+	jbyte *lparg1=NULL;
+	jbyte *lparg2=NULL;
+	OS_NATIVE_ENTER(env, that, _1g_1signal_1emit_1by_1name__I_3B_3B_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	if (arg2) if ((lparg2 = (*env)->GetByteArrayElements(env, arg2, NULL)) == NULL) goto fail;
+	g_signal_emit_by_name((gpointer)arg0, (const gchar *)lparg1, lparg2);
+fail:
+	if (arg2 && lparg2) (*env)->ReleaseByteArrayElements(env, arg2, lparg2, 0);
+	if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, JNI_ABORT);
+	OS_NATIVE_EXIT(env, that, _1g_1signal_1emit_1by_1name__I_3B_3B_FUNC);
+}
+#endif
+
+#ifndef NO__1g_1signal_1handler_1disconnect
+JNIEXPORT void JNICALL OS_NATIVE(_1g_1signal_1handler_1disconnect)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1g_1signal_1handler_1disconnect_FUNC);
+	g_signal_handler_disconnect((gpointer)arg0, (gulong)arg1);
+	OS_NATIVE_EXIT(env, that, _1g_1signal_1handler_1disconnect_FUNC);
+}
+#endif
+
+#ifndef NO__1g_1signal_1handlers_1block_1matched
+JNIEXPORT jint JNICALL OS_NATIVE(_1g_1signal_1handlers_1block_1matched)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4, jint arg5, jint arg6)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1g_1signal_1handlers_1block_1matched_FUNC);
+	rc = (jint)g_signal_handlers_block_matched((gpointer)arg0, (GSignalMatchType)arg1, (guint)arg2, (GQuark)arg3, (GClosure *)arg4, (gpointer)arg5, (gpointer)arg6);
+	OS_NATIVE_EXIT(env, that, _1g_1signal_1handlers_1block_1matched_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1g_1signal_1handlers_1disconnect_1matched
+JNIEXPORT jint JNICALL OS_NATIVE(_1g_1signal_1handlers_1disconnect_1matched)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4, jint arg5, jint arg6)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1g_1signal_1handlers_1disconnect_1matched_FUNC);
+	rc = (jint)g_signal_handlers_disconnect_matched((gpointer)arg0, (GSignalMatchType)arg1, (guint)arg2, (GQuark)arg3, (GClosure *)arg4, (gpointer)arg5, (gpointer)arg6);
+	OS_NATIVE_EXIT(env, that, _1g_1signal_1handlers_1disconnect_1matched_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1g_1signal_1handlers_1unblock_1matched
+JNIEXPORT jint JNICALL OS_NATIVE(_1g_1signal_1handlers_1unblock_1matched)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4, jint arg5, jint arg6)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1g_1signal_1handlers_1unblock_1matched_FUNC);
+	rc = (jint)g_signal_handlers_unblock_matched((gpointer)arg0, (GSignalMatchType)arg1, (guint)arg2, (GQuark)arg3, (GClosure *)arg4, (gpointer)arg5, (gpointer)arg6);
+	OS_NATIVE_EXIT(env, that, _1g_1signal_1handlers_1unblock_1matched_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1g_1signal_1lookup
+JNIEXPORT jint JNICALL OS_NATIVE(_1g_1signal_1lookup)
+	(JNIEnv *env, jclass that, jbyteArray arg0, jint arg1)
+{
+	jbyte *lparg0=NULL;
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1g_1signal_1lookup_FUNC);
+	if (arg0) if ((lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL)) == NULL) goto fail;
+	rc = (jint)g_signal_lookup((const gchar *)lparg0, arg1);
+fail:
+	if (arg0 && lparg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, JNI_ABORT);
+	OS_NATIVE_EXIT(env, that, _1g_1signal_1lookup_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1g_1signal_1remove_1emission_1hook
+JNIEXPORT void JNICALL OS_NATIVE(_1g_1signal_1remove_1emission_1hook)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1g_1signal_1remove_1emission_1hook_FUNC);
+	g_signal_remove_emission_hook((guint)arg0, (gulong)arg1);
+	OS_NATIVE_EXIT(env, that, _1g_1signal_1remove_1emission_1hook_FUNC);
+}
+#endif
+
+#ifndef NO__1g_1signal_1stop_1emission_1by_1name
+JNIEXPORT void JNICALL OS_NATIVE(_1g_1signal_1stop_1emission_1by_1name)
+	(JNIEnv *env, jclass that, jint arg0, jbyteArray arg1)
+{
+	jbyte *lparg1=NULL;
+	OS_NATIVE_ENTER(env, that, _1g_1signal_1stop_1emission_1by_1name_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	g_signal_stop_emission_by_name((gpointer)arg0, (const gchar *)lparg1);
+fail:
+	if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, JNI_ABORT);
+	OS_NATIVE_EXIT(env, that, _1g_1signal_1stop_1emission_1by_1name_FUNC);
+}
+#endif
+
+#ifndef NO__1g_1slist_1data
+JNIEXPORT jint JNICALL OS_NATIVE(_1g_1slist_1data)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1g_1slist_1data_FUNC);
+	rc = (jint)g_slist_data((GSList *)arg0);
+	OS_NATIVE_EXIT(env, that, _1g_1slist_1data_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1g_1slist_1free
+JNIEXPORT void JNICALL OS_NATIVE(_1g_1slist_1free)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1g_1slist_1free_FUNC);
+	g_slist_free((GSList *)arg0);
+	OS_NATIVE_EXIT(env, that, _1g_1slist_1free_FUNC);
+}
+#endif
+
+#ifndef NO__1g_1slist_1length
+JNIEXPORT jint JNICALL OS_NATIVE(_1g_1slist_1length)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1g_1slist_1length_FUNC);
+	rc = (jint)g_slist_length((GSList *)arg0);
+	OS_NATIVE_EXIT(env, that, _1g_1slist_1length_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1g_1slist_1next
+JNIEXPORT jint JNICALL OS_NATIVE(_1g_1slist_1next)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1g_1slist_1next_FUNC);
+	rc = (jint)g_slist_next((GSList *)arg0);
+	OS_NATIVE_EXIT(env, that, _1g_1slist_1next_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1g_1source_1remove
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1g_1source_1remove)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1g_1source_1remove_FUNC);
+	rc = (jboolean)g_source_remove((guint)arg0);
+	OS_NATIVE_EXIT(env, that, _1g_1source_1remove_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1g_1strfreev
+JNIEXPORT void JNICALL OS_NATIVE(_1g_1strfreev)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1g_1strfreev_FUNC);
+	g_strfreev((gchar **)arg0);
+	OS_NATIVE_EXIT(env, that, _1g_1strfreev_FUNC);
+}
+#endif
+
+#ifndef NO__1g_1strtod
+JNIEXPORT jdouble JNICALL OS_NATIVE(_1g_1strtod)
+	(JNIEnv *env, jclass that, jint arg0, jintArray arg1)
+{
+	jint *lparg1=NULL;
+	jdouble rc = 0;
+	OS_NATIVE_ENTER(env, that, _1g_1strtod_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	rc = (jdouble)g_strtod((const gchar *)arg0, (gchar **)lparg1);
+fail:
+	if (arg1 && lparg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0);
+	OS_NATIVE_EXIT(env, that, _1g_1strtod_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1g_1thread_1init
+JNIEXPORT void JNICALL OS_NATIVE(_1g_1thread_1init)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1g_1thread_1init_FUNC);
+	g_thread_init((GThreadFunctions *)arg0);
+	OS_NATIVE_EXIT(env, that, _1g_1thread_1init_FUNC);
+}
+#endif
+
+#ifndef NO__1g_1thread_1supported
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1g_1thread_1supported)
+	(JNIEnv *env, jclass that)
+{
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1g_1thread_1supported_FUNC);
+	rc = (jboolean)g_thread_supported();
+	OS_NATIVE_EXIT(env, that, _1g_1thread_1supported_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1g_1type_1add_1interface_1static
+JNIEXPORT void JNICALL OS_NATIVE(_1g_1type_1add_1interface_1static)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+	OS_NATIVE_ENTER(env, that, _1g_1type_1add_1interface_1static_FUNC);
+	g_type_add_interface_static((GType)arg0, (GType)arg1, (const GInterfaceInfo *)arg2);
+	OS_NATIVE_EXIT(env, that, _1g_1type_1add_1interface_1static_FUNC);
+}
+#endif
+
+#ifndef NO__1g_1type_1class_1peek
+JNIEXPORT jint JNICALL OS_NATIVE(_1g_1type_1class_1peek)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1g_1type_1class_1peek_FUNC);
+	rc = (jint)g_type_class_peek((GType)arg0);
+	OS_NATIVE_EXIT(env, that, _1g_1type_1class_1peek_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1g_1type_1class_1peek_1parent
+JNIEXPORT jint JNICALL OS_NATIVE(_1g_1type_1class_1peek_1parent)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1g_1type_1class_1peek_1parent_FUNC);
+	rc = (jint)g_type_class_peek_parent((gpointer)arg0);
+	OS_NATIVE_EXIT(env, that, _1g_1type_1class_1peek_1parent_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1g_1type_1from_1name
+JNIEXPORT jint JNICALL OS_NATIVE(_1g_1type_1from_1name)
+	(JNIEnv *env, jclass that, jbyteArray arg0)
+{
+	jbyte *lparg0=NULL;
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1g_1type_1from_1name_FUNC);
+	if (arg0) if ((lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL)) == NULL) goto fail;
+	rc = (jint)g_type_from_name((const gchar *)lparg0);
+fail:
+	if (arg0 && lparg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
+	OS_NATIVE_EXIT(env, that, _1g_1type_1from_1name_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1g_1type_1interface_1peek_1parent
+JNIEXPORT jint JNICALL OS_NATIVE(_1g_1type_1interface_1peek_1parent)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1g_1type_1interface_1peek_1parent_FUNC);
+	rc = (jint)g_type_interface_peek_parent((gpointer)arg0);
+	OS_NATIVE_EXIT(env, that, _1g_1type_1interface_1peek_1parent_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1g_1type_1is_1a
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1g_1type_1is_1a)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1g_1type_1is_1a_FUNC);
+	rc = (jboolean)g_type_is_a((GType)arg0, (GType)arg1);
+	OS_NATIVE_EXIT(env, that, _1g_1type_1is_1a_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1g_1type_1name
+JNIEXPORT jint JNICALL OS_NATIVE(_1g_1type_1name)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1g_1type_1name_FUNC);
+	rc = (jint)g_type_name((GType)arg0);
+	OS_NATIVE_EXIT(env, that, _1g_1type_1name_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1g_1type_1parent
+JNIEXPORT jint JNICALL OS_NATIVE(_1g_1type_1parent)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1g_1type_1parent_FUNC);
+	rc = (jint)g_type_parent((GType)arg0);
+	OS_NATIVE_EXIT(env, that, _1g_1type_1parent_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1g_1type_1query
+JNIEXPORT void JNICALL OS_NATIVE(_1g_1type_1query)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1g_1type_1query_FUNC);
+	g_type_query((GType)arg0, (GTypeQuery *)arg1);
+	OS_NATIVE_EXIT(env, that, _1g_1type_1query_FUNC);
+}
+#endif
+
+#ifndef NO__1g_1type_1register_1static
+JNIEXPORT jint JNICALL OS_NATIVE(_1g_1type_1register_1static)
+	(JNIEnv *env, jclass that, jint arg0, jbyteArray arg1, jint arg2, jint arg3)
+{
+	jbyte *lparg1=NULL;
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1g_1type_1register_1static_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	rc = (jint)g_type_register_static((GType)arg0, (const gchar *)lparg1, (const GTypeInfo *)arg2, (GTypeFlags)arg3);
+fail:
+	if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+	OS_NATIVE_EXIT(env, that, _1g_1type_1register_1static_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1g_1utf16_1to_1utf8
+JNIEXPORT jint JNICALL OS_NATIVE(_1g_1utf16_1to_1utf8)
+	(JNIEnv *env, jclass that, jcharArray arg0, jint arg1, jintArray arg2, jintArray arg3, jintArray arg4)
+{
+	jchar *lparg0=NULL;
+	jint *lparg2=NULL;
+	jint *lparg3=NULL;
+	jint *lparg4=NULL;
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1g_1utf16_1to_1utf8_FUNC);
+#ifdef JNI_VERSION_1_2
+	if (IS_JNI_1_2) {
+		if (arg0) if ((lparg0 = (*env)->GetPrimitiveArrayCritical(env, arg0, NULL)) == NULL) goto fail;
+		if (arg2) if ((lparg2 = (*env)->GetPrimitiveArrayCritical(env, arg2, NULL)) == NULL) goto fail;
+		if (arg3) if ((lparg3 = (*env)->GetPrimitiveArrayCritical(env, arg3, NULL)) == NULL) goto fail;
+		if (arg4) if ((lparg4 = (*env)->GetPrimitiveArrayCritical(env, arg4, NULL)) == NULL) goto fail;
+	} else
+#endif
+	{
+		if (arg0) if ((lparg0 = (*env)->GetCharArrayElements(env, arg0, NULL)) == NULL) goto fail;
+		if (arg2) if ((lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL)) == NULL) goto fail;
+		if (arg3) if ((lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL)) == NULL) goto fail;
+		if (arg4) if ((lparg4 = (*env)->GetIntArrayElements(env, arg4, NULL)) == NULL) goto fail;
+	}
+	rc = (jint)g_utf16_to_utf8((const gunichar2 *)lparg0, (glong)arg1, (glong *)lparg2, (glong *)lparg3, (GError **)lparg4);
+fail:
+#ifdef JNI_VERSION_1_2
+	if (IS_JNI_1_2) {
+		if (arg4 && lparg4) (*env)->ReleasePrimitiveArrayCritical(env, arg4, lparg4, 0);
+		if (arg3 && lparg3) (*env)->ReleasePrimitiveArrayCritical(env, arg3, lparg3, 0);
+		if (arg2 && lparg2) (*env)->ReleasePrimitiveArrayCritical(env, arg2, lparg2, 0);
+		if (arg0 && lparg0) (*env)->ReleasePrimitiveArrayCritical(env, arg0, lparg0, JNI_ABORT);
+	} else
+#endif
+	{
+		if (arg4 && lparg4) (*env)->ReleaseIntArrayElements(env, arg4, lparg4, 0);
+		if (arg3 && lparg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0);
+		if (arg2 && lparg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
+		if (arg0 && lparg0) (*env)->ReleaseCharArrayElements(env, arg0, lparg0, JNI_ABORT);
+	}
+	OS_NATIVE_EXIT(env, that, _1g_1utf16_1to_1utf8_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1g_1utf8_1offset_1to_1pointer
+JNIEXPORT jint JNICALL OS_NATIVE(_1g_1utf8_1offset_1to_1pointer)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1g_1utf8_1offset_1to_1pointer_FUNC);
+	rc = (jint)g_utf8_offset_to_pointer((const gchar *)arg0, arg1);
+	OS_NATIVE_EXIT(env, that, _1g_1utf8_1offset_1to_1pointer_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1g_1utf8_1pointer_1to_1offset
+JNIEXPORT jint JNICALL OS_NATIVE(_1g_1utf8_1pointer_1to_1offset)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1g_1utf8_1pointer_1to_1offset_FUNC);
+	rc = (jint)g_utf8_pointer_to_offset((const gchar *)arg0, (const gchar *)arg1);
+	OS_NATIVE_EXIT(env, that, _1g_1utf8_1pointer_1to_1offset_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1g_1utf8_1strlen
+JNIEXPORT jint JNICALL OS_NATIVE(_1g_1utf8_1strlen)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1g_1utf8_1strlen_FUNC);
+	rc = (jint)g_utf8_strlen((const gchar *)arg0, arg1);
+	OS_NATIVE_EXIT(env, that, _1g_1utf8_1strlen_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1g_1utf8_1to_1utf16__II_3I_3I_3I
+JNIEXPORT jint JNICALL OS_NATIVE(_1g_1utf8_1to_1utf16__II_3I_3I_3I)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jintArray arg2, jintArray arg3, jintArray arg4)
+{
+	jint *lparg2=NULL;
+	jint *lparg3=NULL;
+	jint *lparg4=NULL;
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1g_1utf8_1to_1utf16__II_3I_3I_3I_FUNC);
+#ifdef JNI_VERSION_1_2
+	if (IS_JNI_1_2) {
+		if (arg2) if ((lparg2 = (*env)->GetPrimitiveArrayCritical(env, arg2, NULL)) == NULL) goto fail;
+		if (arg3) if ((lparg3 = (*env)->GetPrimitiveArrayCritical(env, arg3, NULL)) == NULL) goto fail;
+		if (arg4) if ((lparg4 = (*env)->GetPrimitiveArrayCritical(env, arg4, NULL)) == NULL) goto fail;
+	} else
+#endif
+	{
+		if (arg2) if ((lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL)) == NULL) goto fail;
+		if (arg3) if ((lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL)) == NULL) goto fail;
+		if (arg4) if ((lparg4 = (*env)->GetIntArrayElements(env, arg4, NULL)) == NULL) goto fail;
+	}
+	rc = (jint)g_utf8_to_utf16((const gchar *)arg0, (glong)arg1, (glong *)lparg2, (glong *)lparg3, (GError **)lparg4);
+fail:
+#ifdef JNI_VERSION_1_2
+	if (IS_JNI_1_2) {
+		if (arg4 && lparg4) (*env)->ReleasePrimitiveArrayCritical(env, arg4, lparg4, 0);
+		if (arg3 && lparg3) (*env)->ReleasePrimitiveArrayCritical(env, arg3, lparg3, 0);
+		if (arg2 && lparg2) (*env)->ReleasePrimitiveArrayCritical(env, arg2, lparg2, 0);
+	} else
+#endif
+	{
+		if (arg4 && lparg4) (*env)->ReleaseIntArrayElements(env, arg4, lparg4, 0);
+		if (arg3 && lparg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0);
+		if (arg2 && lparg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
+	}
+	OS_NATIVE_EXIT(env, that, _1g_1utf8_1to_1utf16__II_3I_3I_3I_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1g_1utf8_1to_1utf16___3BI_3I_3I_3I
+JNIEXPORT jint JNICALL OS_NATIVE(_1g_1utf8_1to_1utf16___3BI_3I_3I_3I)
+	(JNIEnv *env, jclass that, jbyteArray arg0, jint arg1, jintArray arg2, jintArray arg3, jintArray arg4)
+{
+	jbyte *lparg0=NULL;
+	jint *lparg2=NULL;
+	jint *lparg3=NULL;
+	jint *lparg4=NULL;
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1g_1utf8_1to_1utf16___3BI_3I_3I_3I_FUNC);
+#ifdef JNI_VERSION_1_2
+	if (IS_JNI_1_2) {
+		if (arg0) if ((lparg0 = (*env)->GetPrimitiveArrayCritical(env, arg0, NULL)) == NULL) goto fail;
+		if (arg2) if ((lparg2 = (*env)->GetPrimitiveArrayCritical(env, arg2, NULL)) == NULL) goto fail;
+		if (arg3) if ((lparg3 = (*env)->GetPrimitiveArrayCritical(env, arg3, NULL)) == NULL) goto fail;
+		if (arg4) if ((lparg4 = (*env)->GetPrimitiveArrayCritical(env, arg4, NULL)) == NULL) goto fail;
+	} else
+#endif
+	{
+		if (arg0) if ((lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL)) == NULL) goto fail;
+		if (arg2) if ((lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL)) == NULL) goto fail;
+		if (arg3) if ((lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL)) == NULL) goto fail;
+		if (arg4) if ((lparg4 = (*env)->GetIntArrayElements(env, arg4, NULL)) == NULL) goto fail;
+	}
+	rc = (jint)g_utf8_to_utf16((const gchar *)lparg0, (glong)arg1, (glong *)lparg2, (glong *)lparg3, (GError **)lparg4);
+fail:
+#ifdef JNI_VERSION_1_2
+	if (IS_JNI_1_2) {
+		if (arg4 && lparg4) (*env)->ReleasePrimitiveArrayCritical(env, arg4, lparg4, 0);
+		if (arg3 && lparg3) (*env)->ReleasePrimitiveArrayCritical(env, arg3, lparg3, 0);
+		if (arg2 && lparg2) (*env)->ReleasePrimitiveArrayCritical(env, arg2, lparg2, 0);
+		if (arg0 && lparg0) (*env)->ReleasePrimitiveArrayCritical(env, arg0, lparg0, JNI_ABORT);
+	} else
+#endif
+	{
+		if (arg4 && lparg4) (*env)->ReleaseIntArrayElements(env, arg4, lparg4, 0);
+		if (arg3 && lparg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0);
+		if (arg2 && lparg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
+		if (arg0 && lparg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, JNI_ABORT);
+	}
+	OS_NATIVE_EXIT(env, that, _1g_1utf8_1to_1utf16___3BI_3I_3I_3I_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1g_1value_1peek_1pointer
+JNIEXPORT jint JNICALL OS_NATIVE(_1g_1value_1peek_1pointer)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1g_1value_1peek_1pointer_FUNC);
+	rc = (jint)g_value_peek_pointer((const GValue *)arg0);
+	OS_NATIVE_EXIT(env, that, _1g_1value_1peek_1pointer_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gdk_1atom_1intern
+JNIEXPORT jint JNICALL OS_NATIVE(_1gdk_1atom_1intern)
+	(JNIEnv *env, jclass that, jbyteArray arg0, jboolean arg1)
+{
+	jbyte *lparg0=NULL;
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gdk_1atom_1intern_FUNC);
+#ifdef JNI_VERSION_1_2
+	if (IS_JNI_1_2) {
+		if (arg0) if ((lparg0 = (*env)->GetPrimitiveArrayCritical(env, arg0, NULL)) == NULL) goto fail;
+	} else
+#endif
+	{
+		if (arg0) if ((lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL)) == NULL) goto fail;
+	}
+	rc = (jint)gdk_atom_intern((const gchar *)lparg0, arg1);
+fail:
+#ifdef JNI_VERSION_1_2
+	if (IS_JNI_1_2) {
+		if (arg0 && lparg0) (*env)->ReleasePrimitiveArrayCritical(env, arg0, lparg0, JNI_ABORT);
+	} else
+#endif
+	{
+		if (arg0 && lparg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, JNI_ABORT);
+	}
+	OS_NATIVE_EXIT(env, that, _1gdk_1atom_1intern_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gdk_1atom_1name
+JNIEXPORT jint JNICALL OS_NATIVE(_1gdk_1atom_1name)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gdk_1atom_1name_FUNC);
+	rc = (jint)gdk_atom_name((GdkAtom)arg0);
+	OS_NATIVE_EXIT(env, that, _1gdk_1atom_1name_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gdk_1beep
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1beep)
+	(JNIEnv *env, jclass that)
+{
+	OS_NATIVE_ENTER(env, that, _1gdk_1beep_FUNC);
+	gdk_beep();
+	OS_NATIVE_EXIT(env, that, _1gdk_1beep_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1bitmap_1create_1from_1data
+JNIEXPORT jint JNICALL OS_NATIVE(_1gdk_1bitmap_1create_1from_1data)
+	(JNIEnv *env, jclass that, jint arg0, jbyteArray arg1, jint arg2, jint arg3)
+{
+	jbyte *lparg1=NULL;
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gdk_1bitmap_1create_1from_1data_FUNC);
+#ifdef JNI_VERSION_1_2
+	if (IS_JNI_1_2) {
+		if (arg1) if ((lparg1 = (*env)->GetPrimitiveArrayCritical(env, arg1, NULL)) == NULL) goto fail;
+	} else
+#endif
+	{
+		if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	}
+	rc = (jint)gdk_bitmap_create_from_data((GdkWindow *)arg0, (const gchar *)lparg1, (gint)arg2, (gint)arg3);
+fail:
+#ifdef JNI_VERSION_1_2
+	if (IS_JNI_1_2) {
+		if (arg1 && lparg1) (*env)->ReleasePrimitiveArrayCritical(env, arg1, lparg1, JNI_ABORT);
+	} else
+#endif
+	{
+		if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, JNI_ABORT);
+	}
+	OS_NATIVE_EXIT(env, that, _1gdk_1bitmap_1create_1from_1data_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gdk_1cairo_1region
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1cairo_1region)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gdk_1cairo_1region_FUNC);
+/*
+	gdk_cairo_region(arg0, arg1);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef void (*FPTR)(jint, jint);
+		static FPTR fptr;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gdk_cairo_region_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gdk_cairo_region");
+			initialized = 1;
+		}
+		if (fptr) {
+			(*fptr)(arg0, arg1);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gdk_1cairo_1region_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1cairo_1set_1source_1color
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1cairo_1set_1source_1color)
+	(JNIEnv *env, jclass that, jint arg0, jobject arg1)
+{
+	GdkColor _arg1, *lparg1=NULL;
+	OS_NATIVE_ENTER(env, that, _1gdk_1cairo_1set_1source_1color_FUNC);
+	if (arg1) if ((lparg1 = getGdkColorFields(env, arg1, &_arg1)) == NULL) goto fail;
+/*
+	gdk_cairo_set_source_color(arg0, lparg1);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef void (*FPTR)(jint, GdkColor *);
+		static FPTR fptr;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gdk_cairo_set_source_color_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gdk_cairo_set_source_color");
+			initialized = 1;
+		}
+		if (fptr) {
+			(*fptr)(arg0, lparg1);
+		}
+	}
+fail:
+	if (arg1 && lparg1) setGdkColorFields(env, arg1, lparg1);
+	OS_NATIVE_EXIT(env, that, _1gdk_1cairo_1set_1source_1color_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1color_1white
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1gdk_1color_1white)
+	(JNIEnv *env, jclass that, jint arg0, jobject arg1)
+{
+	GdkColor _arg1, *lparg1=NULL;
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gdk_1color_1white_FUNC);
+	if (arg1) if ((lparg1 = &_arg1) == NULL) goto fail;
+	rc = (jboolean)gdk_color_white((GdkColormap *)arg0, (GdkColor *)lparg1);
+fail:
+	if (arg1 && lparg1) setGdkColorFields(env, arg1, lparg1);
+	OS_NATIVE_EXIT(env, that, _1gdk_1color_1white_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gdk_1colormap_1alloc_1color
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1gdk_1colormap_1alloc_1color)
+	(JNIEnv *env, jclass that, jint arg0, jobject arg1, jboolean arg2, jboolean arg3)
+{
+	GdkColor _arg1, *lparg1=NULL;
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gdk_1colormap_1alloc_1color_FUNC);
+	if (arg1) if ((lparg1 = getGdkColorFields(env, arg1, &_arg1)) == NULL) goto fail;
+	rc = (jboolean)gdk_colormap_alloc_color((GdkColormap *)arg0, (GdkColor *)lparg1, (gboolean)arg2, (gboolean)arg3);
+fail:
+	if (arg1 && lparg1) setGdkColorFields(env, arg1, lparg1);
+	OS_NATIVE_EXIT(env, that, _1gdk_1colormap_1alloc_1color_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gdk_1colormap_1free_1colors
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1colormap_1free_1colors)
+	(JNIEnv *env, jclass that, jint arg0, jobject arg1, jint arg2)
+{
+	GdkColor _arg1, *lparg1=NULL;
+	OS_NATIVE_ENTER(env, that, _1gdk_1colormap_1free_1colors_FUNC);
+	if (arg1) if ((lparg1 = getGdkColorFields(env, arg1, &_arg1)) == NULL) goto fail;
+	gdk_colormap_free_colors((GdkColormap *)arg0, (GdkColor *)lparg1, (gint)arg2);
+fail:
+	OS_NATIVE_EXIT(env, that, _1gdk_1colormap_1free_1colors_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1colormap_1get_1system
+JNIEXPORT jint JNICALL OS_NATIVE(_1gdk_1colormap_1get_1system)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gdk_1colormap_1get_1system_FUNC);
+	rc = (jint)gdk_colormap_get_system();
+	OS_NATIVE_EXIT(env, that, _1gdk_1colormap_1get_1system_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gdk_1colormap_1query_1color
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1colormap_1query_1color)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jobject arg2)
+{
+	GdkColor _arg2, *lparg2=NULL;
+	OS_NATIVE_ENTER(env, that, _1gdk_1colormap_1query_1color_FUNC);
+	if (arg2) if ((lparg2 = getGdkColorFields(env, arg2, &_arg2)) == NULL) goto fail;
+	gdk_colormap_query_color((GdkColormap *)arg0, (gulong)arg1, (GdkColor *)lparg2);
+fail:
+	if (arg2 && lparg2) setGdkColorFields(env, arg2, lparg2);
+	OS_NATIVE_EXIT(env, that, _1gdk_1colormap_1query_1color_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1cursor_1destroy
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1cursor_1destroy)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1gdk_1cursor_1destroy_FUNC);
+	gdk_cursor_destroy((GdkCursor *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gdk_1cursor_1destroy_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1cursor_1new
+JNIEXPORT jint JNICALL OS_NATIVE(_1gdk_1cursor_1new)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gdk_1cursor_1new_FUNC);
+	rc = (jint)gdk_cursor_new((GdkCursorType)arg0);
+	OS_NATIVE_EXIT(env, that, _1gdk_1cursor_1new_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gdk_1cursor_1new_1from_1pixbuf
+JNIEXPORT jint JNICALL OS_NATIVE(_1gdk_1cursor_1new_1from_1pixbuf)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gdk_1cursor_1new_1from_1pixbuf_FUNC);
+/*
+	rc = (jint)gdk_cursor_new_from_pixbuf(arg0, arg1, arg2, arg3);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jint (*FPTR)(jint, jint, jint, jint);
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gdk_cursor_new_from_pixbuf_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gdk_cursor_new_from_pixbuf");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jint)(*fptr)(arg0, arg1, arg2, arg3);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gdk_1cursor_1new_1from_1pixbuf_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gdk_1cursor_1new_1from_1pixmap
+JNIEXPORT jint JNICALL OS_NATIVE(_1gdk_1cursor_1new_1from_1pixmap)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jobject arg2, jobject arg3, jint arg4, jint arg5)
+{
+	GdkColor _arg2, *lparg2=NULL;
+	GdkColor _arg3, *lparg3=NULL;
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gdk_1cursor_1new_1from_1pixmap_FUNC);
+	if (arg2) if ((lparg2 = getGdkColorFields(env, arg2, &_arg2)) == NULL) goto fail;
+	if (arg3) if ((lparg3 = getGdkColorFields(env, arg3, &_arg3)) == NULL) goto fail;
+	rc = (jint)gdk_cursor_new_from_pixmap((GdkPixmap *)arg0, (GdkPixmap *)arg1, (GdkColor *)lparg2, (GdkColor *)lparg3, (gint)arg4, (gint)arg5);
+fail:
+	OS_NATIVE_EXIT(env, that, _1gdk_1cursor_1new_1from_1pixmap_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gdk_1display_1get_1default
+JNIEXPORT jint JNICALL OS_NATIVE(_1gdk_1display_1get_1default)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gdk_1display_1get_1default_FUNC);
+/*
+	rc = (jint)gdk_display_get_default();
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jint (*FPTR)();
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gdk_display_get_default_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gdk_display_get_default");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jint)(*fptr)();
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gdk_1display_1get_1default_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gdk_1display_1supports_1cursor_1color
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1gdk_1display_1supports_1cursor_1color)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gdk_1display_1supports_1cursor_1color_FUNC);
+/*
+	rc = (jboolean)gdk_display_supports_cursor_color(arg0);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jboolean (*FPTR)(jint);
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gdk_display_supports_cursor_color_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gdk_display_supports_cursor_color");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jboolean)(*fptr)(arg0);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gdk_1display_1supports_1cursor_1color_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gdk_1drag_1status
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1drag_1status)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+	OS_NATIVE_ENTER(env, that, _1gdk_1drag_1status_FUNC);
+	gdk_drag_status((GdkDragContext *)arg0, (GdkDragAction)arg1, (guint32)arg2);
+	OS_NATIVE_EXIT(env, that, _1gdk_1drag_1status_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1draw_1arc
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1draw_1arc)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4, jint arg5, jint arg6, jint arg7, jint arg8)
+{
+	OS_NATIVE_ENTER(env, that, _1gdk_1draw_1arc_FUNC);
+	gdk_draw_arc((GdkDrawable *)arg0, (GdkGC *)arg1, (gint)arg2, (gint)arg3, (gint)arg4, (gint)arg5, (gint)arg6, (gint)arg7, (gint)arg8);
+	OS_NATIVE_EXIT(env, that, _1gdk_1draw_1arc_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1draw_1drawable
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1draw_1drawable)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4, jint arg5, jint arg6, jint arg7, jint arg8)
+{
+	OS_NATIVE_ENTER(env, that, _1gdk_1draw_1drawable_FUNC);
+	gdk_draw_drawable((GdkDrawable *)arg0, (GdkGC *)arg1, (GdkDrawable *)arg2, (gint)arg3, (gint)arg4, (gint)arg5, (gint)arg6, (gint)arg7, (gint)arg8);
+	OS_NATIVE_EXIT(env, that, _1gdk_1draw_1drawable_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1draw_1image
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1draw_1image)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4, jint arg5, jint arg6, jint arg7, jint arg8)
+{
+	OS_NATIVE_ENTER(env, that, _1gdk_1draw_1image_FUNC);
+	gdk_draw_image((GdkDrawable *)arg0, (GdkGC *)arg1, (GdkImage *)arg2, arg3, arg4, arg5, arg6, arg7, arg8);
+	OS_NATIVE_EXIT(env, that, _1gdk_1draw_1image_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1draw_1layout
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1draw_1layout)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4)
+{
+	OS_NATIVE_ENTER(env, that, _1gdk_1draw_1layout_FUNC);
+	gdk_draw_layout((GdkDrawable *)arg0, (GdkGC *)arg1, (gint)arg2, (gint)arg3, (PangoLayout *)arg4);
+	OS_NATIVE_EXIT(env, that, _1gdk_1draw_1layout_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1draw_1layout_1with_1colors
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1draw_1layout_1with_1colors)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4, jobject arg5, jobject arg6)
+{
+	GdkColor _arg5, *lparg5=NULL;
+	GdkColor _arg6, *lparg6=NULL;
+	OS_NATIVE_ENTER(env, that, _1gdk_1draw_1layout_1with_1colors_FUNC);
+	if (arg5) if ((lparg5 = getGdkColorFields(env, arg5, &_arg5)) == NULL) goto fail;
+	if (arg6) if ((lparg6 = getGdkColorFields(env, arg6, &_arg6)) == NULL) goto fail;
+	gdk_draw_layout_with_colors((GdkDrawable *)arg0, (GdkGC *)arg1, (gint)arg2, (gint)arg3, (PangoLayout *)arg4, lparg5, lparg6);
+fail:
+	OS_NATIVE_EXIT(env, that, _1gdk_1draw_1layout_1with_1colors_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1draw_1line
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1draw_1line)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4, jint arg5)
+{
+	OS_NATIVE_ENTER(env, that, _1gdk_1draw_1line_FUNC);
+	gdk_draw_line((GdkDrawable *)arg0, (GdkGC *)arg1, (gint)arg2, (gint)arg3, (gint)arg4, (gint)arg5);
+	OS_NATIVE_EXIT(env, that, _1gdk_1draw_1line_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1draw_1lines
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1draw_1lines)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jintArray arg2, jint arg3)
+{
+	jint *lparg2=NULL;
+	OS_NATIVE_ENTER(env, that, _1gdk_1draw_1lines_FUNC);
+#ifdef JNI_VERSION_1_2
+	if (IS_JNI_1_2) {
+		if (arg2) if ((lparg2 = (*env)->GetPrimitiveArrayCritical(env, arg2, NULL)) == NULL) goto fail;
+	} else
+#endif
+	{
+		if (arg2) if ((lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL)) == NULL) goto fail;
+	}
+	gdk_draw_lines((GdkDrawable *)arg0, (GdkGC *)arg1, (GdkPoint *)lparg2, (gint)arg3);
+fail:
+#ifdef JNI_VERSION_1_2
+	if (IS_JNI_1_2) {
+		if (arg2 && lparg2) (*env)->ReleasePrimitiveArrayCritical(env, arg2, lparg2, JNI_ABORT);
+	} else
+#endif
+	{
+		if (arg2 && lparg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, JNI_ABORT);
+	}
+	OS_NATIVE_EXIT(env, that, _1gdk_1draw_1lines_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1draw_1pixbuf
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1draw_1pixbuf)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4, jint arg5, jint arg6, jint arg7, jint arg8, jint arg9, jint arg10, jint arg11)
+{
+	OS_NATIVE_ENTER(env, that, _1gdk_1draw_1pixbuf_FUNC);
+/*
+	gdk_draw_pixbuf((GdkDrawable *)arg0, (GdkGC *)arg1, (GdkPixbuf *)arg2, (gint)arg3, (gint)arg4, (gint)arg5, (gint)arg6, (gint)arg7, (gint)arg8, (GdkRgbDither)arg9, (gint)arg10, (gint)arg11);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef void (*FPTR)(GdkDrawable *, GdkGC *, GdkPixbuf *, gint, gint, gint, gint, gint, gint, GdkRgbDither, gint, gint);
+		static FPTR fptr;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gdk_draw_pixbuf_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gdk_draw_pixbuf");
+			initialized = 1;
+		}
+		if (fptr) {
+			(*fptr)((GdkDrawable *)arg0, (GdkGC *)arg1, (GdkPixbuf *)arg2, (gint)arg3, (gint)arg4, (gint)arg5, (gint)arg6, (gint)arg7, (gint)arg8, (GdkRgbDither)arg9, (gint)arg10, (gint)arg11);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gdk_1draw_1pixbuf_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1draw_1point
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1draw_1point)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3)
+{
+	OS_NATIVE_ENTER(env, that, _1gdk_1draw_1point_FUNC);
+	gdk_draw_point((GdkDrawable *)arg0, (GdkGC *)arg1, arg2, arg3);
+	OS_NATIVE_EXIT(env, that, _1gdk_1draw_1point_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1draw_1polygon
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1draw_1polygon)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jintArray arg3, jint arg4)
+{
+	jint *lparg3=NULL;
+	OS_NATIVE_ENTER(env, that, _1gdk_1draw_1polygon_FUNC);
+#ifdef JNI_VERSION_1_2
+	if (IS_JNI_1_2) {
+		if (arg3) if ((lparg3 = (*env)->GetPrimitiveArrayCritical(env, arg3, NULL)) == NULL) goto fail;
+	} else
+#endif
+	{
+		if (arg3) if ((lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL)) == NULL) goto fail;
+	}
+	gdk_draw_polygon((GdkDrawable *)arg0, (GdkGC *)arg1, (gint)arg2, (GdkPoint *)lparg3, (gint)arg4);
+fail:
+#ifdef JNI_VERSION_1_2
+	if (IS_JNI_1_2) {
+		if (arg3 && lparg3) (*env)->ReleasePrimitiveArrayCritical(env, arg3, lparg3, JNI_ABORT);
+	} else
+#endif
+	{
+		if (arg3 && lparg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, JNI_ABORT);
+	}
+	OS_NATIVE_EXIT(env, that, _1gdk_1draw_1polygon_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1draw_1rectangle
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1draw_1rectangle)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4, jint arg5, jint arg6)
+{
+	OS_NATIVE_ENTER(env, that, _1gdk_1draw_1rectangle_FUNC);
+	gdk_draw_rectangle((GdkDrawable *)arg0, (GdkGC *)arg1, (gint)arg2, (gint)arg3, (gint)arg4, (gint)arg5, (gint)arg6);
+	OS_NATIVE_EXIT(env, that, _1gdk_1draw_1rectangle_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1drawable_1get_1depth
+JNIEXPORT jint JNICALL OS_NATIVE(_1gdk_1drawable_1get_1depth)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gdk_1drawable_1get_1depth_FUNC);
+	rc = (jint)gdk_drawable_get_depth((GdkDrawable *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gdk_1drawable_1get_1depth_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gdk_1drawable_1get_1image
+JNIEXPORT jint JNICALL OS_NATIVE(_1gdk_1drawable_1get_1image)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gdk_1drawable_1get_1image_FUNC);
+	rc = (jint)gdk_drawable_get_image((GdkDrawable *)arg0, (gint)arg1, (gint)arg2, (gint)arg3, (gint)arg4);
+	OS_NATIVE_EXIT(env, that, _1gdk_1drawable_1get_1image_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gdk_1drawable_1get_1size
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1drawable_1get_1size)
+	(JNIEnv *env, jclass that, jint arg0, jintArray arg1, jintArray arg2)
+{
+	jint *lparg1=NULL;
+	jint *lparg2=NULL;
+	OS_NATIVE_ENTER(env, that, _1gdk_1drawable_1get_1size_FUNC);
+#ifdef JNI_VERSION_1_2
+	if (IS_JNI_1_2) {
+		if (arg1) if ((lparg1 = (*env)->GetPrimitiveArrayCritical(env, arg1, NULL)) == NULL) goto fail;
+		if (arg2) if ((lparg2 = (*env)->GetPrimitiveArrayCritical(env, arg2, NULL)) == NULL) goto fail;
+	} else
+#endif
+	{
+		if (arg1) if ((lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL)) == NULL) goto fail;
+		if (arg2) if ((lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL)) == NULL) goto fail;
+	}
+	gdk_drawable_get_size((GdkDrawable *)arg0, (gint *)lparg1, (gint *)lparg2);
+fail:
+#ifdef JNI_VERSION_1_2
+	if (IS_JNI_1_2) {
+		if (arg2 && lparg2) (*env)->ReleasePrimitiveArrayCritical(env, arg2, lparg2, 0);
+		if (arg1 && lparg1) (*env)->ReleasePrimitiveArrayCritical(env, arg1, lparg1, 0);
+	} else
+#endif
+	{
+		if (arg2 && lparg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
+		if (arg1 && lparg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0);
+	}
+	OS_NATIVE_EXIT(env, that, _1gdk_1drawable_1get_1size_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1drawable_1get_1visible_1region
+JNIEXPORT jint JNICALL OS_NATIVE(_1gdk_1drawable_1get_1visible_1region)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gdk_1drawable_1get_1visible_1region_FUNC);
+	rc = (jint)gdk_drawable_get_visible_region((GdkDrawable *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gdk_1drawable_1get_1visible_1region_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gdk_1error_1trap_1pop
+JNIEXPORT jint JNICALL OS_NATIVE(_1gdk_1error_1trap_1pop)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gdk_1error_1trap_1pop_FUNC);
+	rc = (jint)gdk_error_trap_pop();
+	OS_NATIVE_EXIT(env, that, _1gdk_1error_1trap_1pop_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gdk_1error_1trap_1push
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1error_1trap_1push)
+	(JNIEnv *env, jclass that)
+{
+	OS_NATIVE_ENTER(env, that, _1gdk_1error_1trap_1push_FUNC);
+	gdk_error_trap_push();
+	OS_NATIVE_EXIT(env, that, _1gdk_1error_1trap_1push_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1event_1copy
+JNIEXPORT jint JNICALL OS_NATIVE(_1gdk_1event_1copy)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gdk_1event_1copy_FUNC);
+	rc = (jint)gdk_event_copy((GdkEvent *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gdk_1event_1copy_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gdk_1event_1free
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1event_1free)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1gdk_1event_1free_FUNC);
+	gdk_event_free((GdkEvent *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gdk_1event_1free_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1event_1get
+JNIEXPORT jint JNICALL OS_NATIVE(_1gdk_1event_1get)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gdk_1event_1get_FUNC);
+	rc = (jint)gdk_event_get();
+	OS_NATIVE_EXIT(env, that, _1gdk_1event_1get_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gdk_1event_1get_1coords
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1gdk_1event_1get_1coords)
+	(JNIEnv *env, jclass that, jint arg0, jdoubleArray arg1, jdoubleArray arg2)
+{
+	jdouble *lparg1=NULL;
+	jdouble *lparg2=NULL;
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gdk_1event_1get_1coords_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetDoubleArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	if (arg2) if ((lparg2 = (*env)->GetDoubleArrayElements(env, arg2, NULL)) == NULL) goto fail;
+	rc = (jboolean)gdk_event_get_coords((GdkEvent *)arg0, (gdouble *)lparg1, (gdouble *)lparg2);
+fail:
+	if (arg2 && lparg2) (*env)->ReleaseDoubleArrayElements(env, arg2, lparg2, 0);
+	if (arg1 && lparg1) (*env)->ReleaseDoubleArrayElements(env, arg1, lparg1, 0);
+	OS_NATIVE_EXIT(env, that, _1gdk_1event_1get_1coords_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gdk_1event_1get_1graphics_1expose
+JNIEXPORT jint JNICALL OS_NATIVE(_1gdk_1event_1get_1graphics_1expose)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gdk_1event_1get_1graphics_1expose_FUNC);
+	rc = (jint)gdk_event_get_graphics_expose((GdkWindow *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gdk_1event_1get_1graphics_1expose_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gdk_1event_1get_1root_1coords
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1gdk_1event_1get_1root_1coords)
+	(JNIEnv *env, jclass that, jint arg0, jdoubleArray arg1, jdoubleArray arg2)
+{
+	jdouble *lparg1=NULL;
+	jdouble *lparg2=NULL;
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gdk_1event_1get_1root_1coords_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetDoubleArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	if (arg2) if ((lparg2 = (*env)->GetDoubleArrayElements(env, arg2, NULL)) == NULL) goto fail;
+	rc = (jboolean)gdk_event_get_root_coords((GdkEvent *)arg0, (gdouble *)lparg1, (gdouble *)lparg2);
+fail:
+	if (arg2 && lparg2) (*env)->ReleaseDoubleArrayElements(env, arg2, lparg2, 0);
+	if (arg1 && lparg1) (*env)->ReleaseDoubleArrayElements(env, arg1, lparg1, 0);
+	OS_NATIVE_EXIT(env, that, _1gdk_1event_1get_1root_1coords_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gdk_1event_1get_1state
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1gdk_1event_1get_1state)
+	(JNIEnv *env, jclass that, jint arg0, jintArray arg1)
+{
+	jint *lparg1=NULL;
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gdk_1event_1get_1state_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	rc = (jboolean)gdk_event_get_state((GdkEvent *)arg0, (GdkModifierType *)lparg1);
+fail:
+	if (arg1 && lparg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0);
+	OS_NATIVE_EXIT(env, that, _1gdk_1event_1get_1state_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gdk_1event_1get_1time
+JNIEXPORT jint JNICALL OS_NATIVE(_1gdk_1event_1get_1time)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gdk_1event_1get_1time_FUNC);
+	rc = (jint)gdk_event_get_time((GdkEvent *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gdk_1event_1get_1time_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gdk_1event_1handler_1set
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1event_1handler_1set)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+	OS_NATIVE_ENTER(env, that, _1gdk_1event_1handler_1set_FUNC);
+	gdk_event_handler_set((GdkEventFunc)arg0, (gpointer)arg1, (GDestroyNotify)arg2);
+	OS_NATIVE_EXIT(env, that, _1gdk_1event_1handler_1set_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1event_1new
+JNIEXPORT jint JNICALL OS_NATIVE(_1gdk_1event_1new)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gdk_1event_1new_FUNC);
+	rc = (jint)gdk_event_new(arg0);
+	OS_NATIVE_EXIT(env, that, _1gdk_1event_1new_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gdk_1event_1peek
+JNIEXPORT jint JNICALL OS_NATIVE(_1gdk_1event_1peek)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gdk_1event_1peek_FUNC);
+	rc = (jint)gdk_event_peek();
+	OS_NATIVE_EXIT(env, that, _1gdk_1event_1peek_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gdk_1event_1put
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1event_1put)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1gdk_1event_1put_FUNC);
+	gdk_event_put((GdkEvent *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gdk_1event_1put_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1flush
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1flush)
+	(JNIEnv *env, jclass that)
+{
+	OS_NATIVE_ENTER(env, that, _1gdk_1flush_FUNC);
+	gdk_flush();
+	OS_NATIVE_EXIT(env, that, _1gdk_1flush_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1free_1text_1list
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1free_1text_1list)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1gdk_1free_1text_1list_FUNC);
+	gdk_free_text_list((gchar **)arg0);
+	OS_NATIVE_EXIT(env, that, _1gdk_1free_1text_1list_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1gc_1get_1values
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1gc_1get_1values)
+	(JNIEnv *env, jclass that, jint arg0, jobject arg1)
+{
+	GdkGCValues _arg1, *lparg1=NULL;
+	OS_NATIVE_ENTER(env, that, _1gdk_1gc_1get_1values_FUNC);
+	if (arg1) if ((lparg1 = &_arg1) == NULL) goto fail;
+	gdk_gc_get_values((GdkGC *)arg0, (GdkGCValues *)lparg1);
+fail:
+	if (arg1 && lparg1) setGdkGCValuesFields(env, arg1, lparg1);
+	OS_NATIVE_EXIT(env, that, _1gdk_1gc_1get_1values_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1gc_1new
+JNIEXPORT jint JNICALL OS_NATIVE(_1gdk_1gc_1new)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gdk_1gc_1new_FUNC);
+	rc = (jint)gdk_gc_new((GdkDrawable *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gdk_1gc_1new_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gdk_1gc_1set_1background
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1gc_1set_1background)
+	(JNIEnv *env, jclass that, jint arg0, jobject arg1)
+{
+	GdkColor _arg1, *lparg1=NULL;
+	OS_NATIVE_ENTER(env, that, _1gdk_1gc_1set_1background_FUNC);
+	if (arg1) if ((lparg1 = getGdkColorFields(env, arg1, &_arg1)) == NULL) goto fail;
+	gdk_gc_set_background((GdkGC *)arg0, (GdkColor *)lparg1);
+fail:
+	OS_NATIVE_EXIT(env, that, _1gdk_1gc_1set_1background_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1gc_1set_1clip_1mask
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1gc_1set_1clip_1mask)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gdk_1gc_1set_1clip_1mask_FUNC);
+	gdk_gc_set_clip_mask((GdkGC *)arg0, (GdkBitmap *)arg1);
+	OS_NATIVE_EXIT(env, that, _1gdk_1gc_1set_1clip_1mask_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1gc_1set_1clip_1origin
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1gc_1set_1clip_1origin)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+	OS_NATIVE_ENTER(env, that, _1gdk_1gc_1set_1clip_1origin_FUNC);
+	gdk_gc_set_clip_origin((GdkGC *)arg0, (gint)arg1, (gint)arg2);
+	OS_NATIVE_EXIT(env, that, _1gdk_1gc_1set_1clip_1origin_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1gc_1set_1clip_1rectangle
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1gc_1set_1clip_1rectangle)
+	(JNIEnv *env, jclass that, jint arg0, jobject arg1)
+{
+	GdkRectangle _arg1, *lparg1=NULL;
+	OS_NATIVE_ENTER(env, that, _1gdk_1gc_1set_1clip_1rectangle_FUNC);
+	if (arg1) if ((lparg1 = getGdkRectangleFields(env, arg1, &_arg1)) == NULL) goto fail;
+	gdk_gc_set_clip_rectangle((GdkGC *)arg0, (GdkRectangle *)lparg1);
+fail:
+	OS_NATIVE_EXIT(env, that, _1gdk_1gc_1set_1clip_1rectangle_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1gc_1set_1clip_1region
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1gc_1set_1clip_1region)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gdk_1gc_1set_1clip_1region_FUNC);
+	gdk_gc_set_clip_region((GdkGC *)arg0, (GdkRegion *)arg1);
+	OS_NATIVE_EXIT(env, that, _1gdk_1gc_1set_1clip_1region_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1gc_1set_1dashes
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1gc_1set_1dashes)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jbyteArray arg2, jint arg3)
+{
+	jbyte *lparg2=NULL;
+	OS_NATIVE_ENTER(env, that, _1gdk_1gc_1set_1dashes_FUNC);
+#ifdef JNI_VERSION_1_2
+	if (IS_JNI_1_2) {
+		if (arg2) if ((lparg2 = (*env)->GetPrimitiveArrayCritical(env, arg2, NULL)) == NULL) goto fail;
+	} else
+#endif
+	{
+		if (arg2) if ((lparg2 = (*env)->GetByteArrayElements(env, arg2, NULL)) == NULL) goto fail;
+	}
+	gdk_gc_set_dashes((GdkGC *)arg0, (gint)arg1, (gint8 *)lparg2, (gint)arg3);
+fail:
+#ifdef JNI_VERSION_1_2
+	if (IS_JNI_1_2) {
+		if (arg2 && lparg2) (*env)->ReleasePrimitiveArrayCritical(env, arg2, lparg2, JNI_ABORT);
+	} else
+#endif
+	{
+		if (arg2 && lparg2) (*env)->ReleaseByteArrayElements(env, arg2, lparg2, JNI_ABORT);
+	}
+	OS_NATIVE_EXIT(env, that, _1gdk_1gc_1set_1dashes_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1gc_1set_1exposures
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1gc_1set_1exposures)
+	(JNIEnv *env, jclass that, jint arg0, jboolean arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gdk_1gc_1set_1exposures_FUNC);
+	gdk_gc_set_exposures((GdkGC *)arg0, (gboolean)arg1);
+	OS_NATIVE_EXIT(env, that, _1gdk_1gc_1set_1exposures_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1gc_1set_1fill
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1gc_1set_1fill)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gdk_1gc_1set_1fill_FUNC);
+	gdk_gc_set_fill((GdkGC *)arg0, (GdkFill)arg1);
+	OS_NATIVE_EXIT(env, that, _1gdk_1gc_1set_1fill_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1gc_1set_1foreground
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1gc_1set_1foreground)
+	(JNIEnv *env, jclass that, jint arg0, jobject arg1)
+{
+	GdkColor _arg1, *lparg1=NULL;
+	OS_NATIVE_ENTER(env, that, _1gdk_1gc_1set_1foreground_FUNC);
+	if (arg1) if ((lparg1 = getGdkColorFields(env, arg1, &_arg1)) == NULL) goto fail;
+	gdk_gc_set_foreground((GdkGC *)arg0, (GdkColor *)lparg1);
+fail:
+	OS_NATIVE_EXIT(env, that, _1gdk_1gc_1set_1foreground_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1gc_1set_1function
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1gc_1set_1function)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gdk_1gc_1set_1function_FUNC);
+	gdk_gc_set_function((GdkGC *)arg0, (GdkFunction)arg1);
+	OS_NATIVE_EXIT(env, that, _1gdk_1gc_1set_1function_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1gc_1set_1line_1attributes
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1gc_1set_1line_1attributes)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4)
+{
+	OS_NATIVE_ENTER(env, that, _1gdk_1gc_1set_1line_1attributes_FUNC);
+	gdk_gc_set_line_attributes((GdkGC *)arg0, (gint)arg1, (GdkLineStyle)arg2, (GdkCapStyle)arg3, (GdkJoinStyle)arg4);
+	OS_NATIVE_EXIT(env, that, _1gdk_1gc_1set_1line_1attributes_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1gc_1set_1stipple
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1gc_1set_1stipple)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gdk_1gc_1set_1stipple_FUNC);
+	gdk_gc_set_stipple((GdkGC *)arg0, (GdkPixmap *)arg1);
+	OS_NATIVE_EXIT(env, that, _1gdk_1gc_1set_1stipple_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1gc_1set_1subwindow
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1gc_1set_1subwindow)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gdk_1gc_1set_1subwindow_FUNC);
+	gdk_gc_set_subwindow((GdkGC *)arg0, (GdkSubwindowMode)arg1);
+	OS_NATIVE_EXIT(env, that, _1gdk_1gc_1set_1subwindow_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1gc_1set_1tile
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1gc_1set_1tile)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gdk_1gc_1set_1tile_FUNC);
+	gdk_gc_set_tile((GdkGC *)arg0, (GdkPixmap *)arg1);
+	OS_NATIVE_EXIT(env, that, _1gdk_1gc_1set_1tile_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1gc_1set_1ts_1origin
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1gc_1set_1ts_1origin)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+	OS_NATIVE_ENTER(env, that, _1gdk_1gc_1set_1ts_1origin_FUNC);
+	gdk_gc_set_ts_origin((GdkGC *)arg0, arg1, arg2);
+	OS_NATIVE_EXIT(env, that, _1gdk_1gc_1set_1ts_1origin_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1gc_1set_1values
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1gc_1set_1values)
+	(JNIEnv *env, jclass that, jint arg0, jobject arg1, jint arg2)
+{
+	GdkGCValues _arg1, *lparg1=NULL;
+	OS_NATIVE_ENTER(env, that, _1gdk_1gc_1set_1values_FUNC);
+	if (arg1) if ((lparg1 = getGdkGCValuesFields(env, arg1, &_arg1)) == NULL) goto fail;
+	gdk_gc_set_values((GdkGC *)arg0, (GdkGCValues *)lparg1, (GdkGCValuesMask)arg2);
+fail:
+	OS_NATIVE_EXIT(env, that, _1gdk_1gc_1set_1values_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1keyboard_1ungrab
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1keyboard_1ungrab)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1gdk_1keyboard_1ungrab_FUNC);
+	gdk_keyboard_ungrab(arg0);
+	OS_NATIVE_EXIT(env, that, _1gdk_1keyboard_1ungrab_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1keymap_1get_1default
+JNIEXPORT jint JNICALL OS_NATIVE(_1gdk_1keymap_1get_1default)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gdk_1keymap_1get_1default_FUNC);
+	rc = (jint)gdk_keymap_get_default();
+	OS_NATIVE_EXIT(env, that, _1gdk_1keymap_1get_1default_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gdk_1keymap_1translate_1keyboard_1state
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1gdk_1keymap_1translate_1keyboard_1state)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jintArray arg4, jintArray arg5, jintArray arg6, jintArray arg7)
+{
+	jint *lparg4=NULL;
+	jint *lparg5=NULL;
+	jint *lparg6=NULL;
+	jint *lparg7=NULL;
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gdk_1keymap_1translate_1keyboard_1state_FUNC);
+	if (arg4) if ((lparg4 = (*env)->GetIntArrayElements(env, arg4, NULL)) == NULL) goto fail;
+	if (arg5) if ((lparg5 = (*env)->GetIntArrayElements(env, arg5, NULL)) == NULL) goto fail;
+	if (arg6) if ((lparg6 = (*env)->GetIntArrayElements(env, arg6, NULL)) == NULL) goto fail;
+	if (arg7) if ((lparg7 = (*env)->GetIntArrayElements(env, arg7, NULL)) == NULL) goto fail;
+	rc = (jboolean)gdk_keymap_translate_keyboard_state((GdkKeymap*)arg0, arg1, (GdkModifierType)arg2, arg3, (guint*)lparg4, (gint*)lparg5, (gint*)lparg6, (GdkModifierType *)lparg7);
+fail:
+	if (arg7 && lparg7) (*env)->ReleaseIntArrayElements(env, arg7, lparg7, 0);
+	if (arg6 && lparg6) (*env)->ReleaseIntArrayElements(env, arg6, lparg6, 0);
+	if (arg5 && lparg5) (*env)->ReleaseIntArrayElements(env, arg5, lparg5, 0);
+	if (arg4 && lparg4) (*env)->ReleaseIntArrayElements(env, arg4, lparg4, 0);
+	OS_NATIVE_EXIT(env, that, _1gdk_1keymap_1translate_1keyboard_1state_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gdk_1keyval_1to_1lower
+JNIEXPORT jint JNICALL OS_NATIVE(_1gdk_1keyval_1to_1lower)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gdk_1keyval_1to_1lower_FUNC);
+	rc = (jint)gdk_keyval_to_lower(arg0);
+	OS_NATIVE_EXIT(env, that, _1gdk_1keyval_1to_1lower_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gdk_1keyval_1to_1unicode
+JNIEXPORT jint JNICALL OS_NATIVE(_1gdk_1keyval_1to_1unicode)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gdk_1keyval_1to_1unicode_FUNC);
+	rc = (jint)gdk_keyval_to_unicode(arg0);
+	OS_NATIVE_EXIT(env, that, _1gdk_1keyval_1to_1unicode_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gdk_1pango_1context_1get
+JNIEXPORT jint JNICALL OS_NATIVE(_1gdk_1pango_1context_1get)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gdk_1pango_1context_1get_FUNC);
+	rc = (jint)gdk_pango_context_get();
+	OS_NATIVE_EXIT(env, that, _1gdk_1pango_1context_1get_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gdk_1pango_1context_1set_1colormap
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1pango_1context_1set_1colormap)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gdk_1pango_1context_1set_1colormap_FUNC);
+	gdk_pango_context_set_colormap((PangoContext *)arg0, (GdkColormap *)arg1);
+	OS_NATIVE_EXIT(env, that, _1gdk_1pango_1context_1set_1colormap_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1pango_1layout_1get_1clip_1region
+JNIEXPORT jint JNICALL OS_NATIVE(_1gdk_1pango_1layout_1get_1clip_1region)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jintArray arg3, jint arg4)
+{
+	jint *lparg3=NULL;
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gdk_1pango_1layout_1get_1clip_1region_FUNC);
+	if (arg3) if ((lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL)) == NULL) goto fail;
+	rc = (jint)gdk_pango_layout_get_clip_region((PangoLayout *)arg0, arg1, arg2, lparg3, arg4);
+fail:
+	if (arg3 && lparg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0);
+	OS_NATIVE_EXIT(env, that, _1gdk_1pango_1layout_1get_1clip_1region_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gdk_1pixbuf_1copy_1area
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1pixbuf_1copy_1area)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4, jint arg5, jint arg6, jint arg7)
+{
+	OS_NATIVE_ENTER(env, that, _1gdk_1pixbuf_1copy_1area_FUNC);
+	gdk_pixbuf_copy_area((GdkPixbuf *)arg0, arg1, arg2, arg3, arg4, (GdkPixbuf *)arg5, arg6, arg7);
+	OS_NATIVE_EXIT(env, that, _1gdk_1pixbuf_1copy_1area_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1pixbuf_1get_1from_1drawable
+JNIEXPORT jint JNICALL OS_NATIVE(_1gdk_1pixbuf_1get_1from_1drawable)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4, jint arg5, jint arg6, jint arg7, jint arg8)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gdk_1pixbuf_1get_1from_1drawable_FUNC);
+	rc = (jint)gdk_pixbuf_get_from_drawable((GdkPixbuf *)arg0, (GdkDrawable *)arg1, (GdkColormap *)arg2, arg3, arg4, arg5, arg6, arg7, arg8);
+	OS_NATIVE_EXIT(env, that, _1gdk_1pixbuf_1get_1from_1drawable_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gdk_1pixbuf_1get_1has_1alpha
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1gdk_1pixbuf_1get_1has_1alpha)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gdk_1pixbuf_1get_1has_1alpha_FUNC);
+	rc = (jboolean)gdk_pixbuf_get_has_alpha((const GdkPixbuf *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gdk_1pixbuf_1get_1has_1alpha_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gdk_1pixbuf_1get_1height
+JNIEXPORT jint JNICALL OS_NATIVE(_1gdk_1pixbuf_1get_1height)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gdk_1pixbuf_1get_1height_FUNC);
+	rc = (jint)gdk_pixbuf_get_height((const GdkPixbuf *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gdk_1pixbuf_1get_1height_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gdk_1pixbuf_1get_1pixels
+JNIEXPORT jint JNICALL OS_NATIVE(_1gdk_1pixbuf_1get_1pixels)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gdk_1pixbuf_1get_1pixels_FUNC);
+	rc = (jint)gdk_pixbuf_get_pixels((const GdkPixbuf *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gdk_1pixbuf_1get_1pixels_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gdk_1pixbuf_1get_1rowstride
+JNIEXPORT jint JNICALL OS_NATIVE(_1gdk_1pixbuf_1get_1rowstride)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gdk_1pixbuf_1get_1rowstride_FUNC);
+	rc = (jint)gdk_pixbuf_get_rowstride((const GdkPixbuf *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gdk_1pixbuf_1get_1rowstride_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gdk_1pixbuf_1get_1width
+JNIEXPORT jint JNICALL OS_NATIVE(_1gdk_1pixbuf_1get_1width)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gdk_1pixbuf_1get_1width_FUNC);
+	rc = (jint)gdk_pixbuf_get_width((const GdkPixbuf *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gdk_1pixbuf_1get_1width_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gdk_1pixbuf_1loader_1close
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1gdk_1pixbuf_1loader_1close)
+	(JNIEnv *env, jclass that, jint arg0, jintArray arg1)
+{
+	jint *lparg1=NULL;
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gdk_1pixbuf_1loader_1close_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	rc = (jboolean)gdk_pixbuf_loader_close((GdkPixbufLoader *)arg0, (GError **)lparg1);
+fail:
+	if (arg1 && lparg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0);
+	OS_NATIVE_EXIT(env, that, _1gdk_1pixbuf_1loader_1close_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gdk_1pixbuf_1loader_1get_1pixbuf
+JNIEXPORT jint JNICALL OS_NATIVE(_1gdk_1pixbuf_1loader_1get_1pixbuf)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gdk_1pixbuf_1loader_1get_1pixbuf_FUNC);
+	rc = (jint)gdk_pixbuf_loader_get_pixbuf((GdkPixbufLoader *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gdk_1pixbuf_1loader_1get_1pixbuf_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gdk_1pixbuf_1loader_1new
+JNIEXPORT jint JNICALL OS_NATIVE(_1gdk_1pixbuf_1loader_1new)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gdk_1pixbuf_1loader_1new_FUNC);
+	rc = (jint)gdk_pixbuf_loader_new();
+	OS_NATIVE_EXIT(env, that, _1gdk_1pixbuf_1loader_1new_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gdk_1pixbuf_1loader_1write
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1gdk_1pixbuf_1loader_1write)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jintArray arg3)
+{
+	jint *lparg3=NULL;
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gdk_1pixbuf_1loader_1write_FUNC);
+	if (arg3) if ((lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL)) == NULL) goto fail;
+	rc = (jboolean)gdk_pixbuf_loader_write((GdkPixbufLoader *)arg0, (const guchar *)arg1, (gsize)arg2, (GError **)lparg3);
+fail:
+	if (arg3 && lparg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0);
+	OS_NATIVE_EXIT(env, that, _1gdk_1pixbuf_1loader_1write_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gdk_1pixbuf_1new
+JNIEXPORT jint JNICALL OS_NATIVE(_1gdk_1pixbuf_1new)
+	(JNIEnv *env, jclass that, jint arg0, jboolean arg1, jint arg2, jint arg3, jint arg4)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gdk_1pixbuf_1new_FUNC);
+	rc = (jint)gdk_pixbuf_new((GdkColorspace)arg0, (gboolean)arg1, arg2, arg3, arg4);
+	OS_NATIVE_EXIT(env, that, _1gdk_1pixbuf_1new_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gdk_1pixbuf_1new_1from_1file
+JNIEXPORT jint JNICALL OS_NATIVE(_1gdk_1pixbuf_1new_1from_1file)
+	(JNIEnv *env, jclass that, jbyteArray arg0, jintArray arg1)
+{
+	jbyte *lparg0=NULL;
+	jint *lparg1=NULL;
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gdk_1pixbuf_1new_1from_1file_FUNC);
+	if (arg0) if ((lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL)) == NULL) goto fail;
+	if (arg1) if ((lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	rc = (jint)gdk_pixbuf_new_from_file((const char *)lparg0, (GError**)lparg1);
+fail:
+	if (arg1 && lparg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0);
+	if (arg0 && lparg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
+	OS_NATIVE_EXIT(env, that, _1gdk_1pixbuf_1new_1from_1file_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gdk_1pixbuf_1render_1pixmap_1and_1mask
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1pixbuf_1render_1pixmap_1and_1mask)
+	(JNIEnv *env, jclass that, jint arg0, jintArray arg1, jintArray arg2, jint arg3)
+{
+	jint *lparg1=NULL;
+	jint *lparg2=NULL;
+	OS_NATIVE_ENTER(env, that, _1gdk_1pixbuf_1render_1pixmap_1and_1mask_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	if (arg2) if ((lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL)) == NULL) goto fail;
+	gdk_pixbuf_render_pixmap_and_mask((GdkPixbuf *)arg0, (GdkDrawable **)lparg1, (GdkBitmap **)lparg2, arg3);
+fail:
+	if (arg2 && lparg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
+	if (arg1 && lparg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0);
+	OS_NATIVE_EXIT(env, that, _1gdk_1pixbuf_1render_1pixmap_1and_1mask_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1pixbuf_1render_1to_1drawable
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1pixbuf_1render_1to_1drawable)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4, jint arg5, jint arg6, jint arg7, jint arg8, jint arg9, jint arg10, jint arg11)
+{
+	OS_NATIVE_ENTER(env, that, _1gdk_1pixbuf_1render_1to_1drawable_FUNC);
+	gdk_pixbuf_render_to_drawable((GdkPixbuf *)arg0, (GdkDrawable *)arg1, (GdkGC *)arg2, arg3, arg4, arg5, arg6, arg7, arg8, (GdkRgbDither)arg9, arg10, arg11);
+	OS_NATIVE_EXIT(env, that, _1gdk_1pixbuf_1render_1to_1drawable_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1pixbuf_1render_1to_1drawable_1alpha
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1pixbuf_1render_1to_1drawable_1alpha)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4, jint arg5, jint arg6, jint arg7, jint arg8, jint arg9, jint arg10, jint arg11, jint arg12)
+{
+	OS_NATIVE_ENTER(env, that, _1gdk_1pixbuf_1render_1to_1drawable_1alpha_FUNC);
+	gdk_pixbuf_render_to_drawable_alpha((GdkPixbuf *)arg0, (GdkDrawable *)arg1, arg2, arg3, arg4, arg5, arg6, arg7, (GdkPixbufAlphaMode)arg8, arg9, (GdkRgbDither)arg10, arg11, arg12);
+	OS_NATIVE_EXIT(env, that, _1gdk_1pixbuf_1render_1to_1drawable_1alpha_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1pixbuf_1save_1to_1buffer
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1gdk_1pixbuf_1save_1to_1buffer)
+	(JNIEnv *env, jclass that, jint arg0, jintArray arg1, jintArray arg2, jbyteArray arg3, jintArray arg4, jbyteArray arg5)
+{
+	jint *lparg1=NULL;
+	jint *lparg2=NULL;
+	jbyte *lparg3=NULL;
+	jint *lparg4=NULL;
+	jbyte *lparg5=NULL;
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gdk_1pixbuf_1save_1to_1buffer_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	if (arg2) if ((lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL)) == NULL) goto fail;
+	if (arg3) if ((lparg3 = (*env)->GetByteArrayElements(env, arg3, NULL)) == NULL) goto fail;
+	if (arg4) if ((lparg4 = (*env)->GetIntArrayElements(env, arg4, NULL)) == NULL) goto fail;
+	if (arg5) if ((lparg5 = (*env)->GetByteArrayElements(env, arg5, NULL)) == NULL) goto fail;
+/*
+	rc = (jboolean)gdk_pixbuf_save_to_buffer((GdkPixbuf *)arg0, (gchar **)lparg1, (gsize *)lparg2, (const char *)lparg3, (GError **)lparg4, (char *)lparg5);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jboolean (*FPTR)(GdkPixbuf *, gchar **, gsize *, const char *, GError **, char *);
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gdk_pixbuf_save_to_buffer_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gdk_pixbuf_save_to_buffer");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jboolean)(*fptr)((GdkPixbuf *)arg0, (gchar **)lparg1, (gsize *)lparg2, (const char *)lparg3, (GError **)lparg4, (char *)lparg5);
+		}
+	}
+fail:
+	if (arg5 && lparg5) (*env)->ReleaseByteArrayElements(env, arg5, lparg5, 0);
+	if (arg4 && lparg4) (*env)->ReleaseIntArrayElements(env, arg4, lparg4, 0);
+	if (arg3 && lparg3) (*env)->ReleaseByteArrayElements(env, arg3, lparg3, 0);
+	if (arg2 && lparg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
+	if (arg1 && lparg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0);
+	OS_NATIVE_EXIT(env, that, _1gdk_1pixbuf_1save_1to_1buffer_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gdk_1pixbuf_1scale
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1pixbuf_1scale)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4, jint arg5, jdouble arg6, jdouble arg7, jdouble arg8, jdouble arg9, jint arg10)
+{
+	OS_NATIVE_ENTER(env, that, _1gdk_1pixbuf_1scale_FUNC);
+	gdk_pixbuf_scale((const GdkPixbuf *)arg0, (GdkPixbuf *)arg1, arg2, arg3, arg4, arg5, (double)arg6, (double)arg7, (double)arg8, (double)arg9, arg10);
+	OS_NATIVE_EXIT(env, that, _1gdk_1pixbuf_1scale_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1pixbuf_1scale_1simple
+JNIEXPORT jint JNICALL OS_NATIVE(_1gdk_1pixbuf_1scale_1simple)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gdk_1pixbuf_1scale_1simple_FUNC);
+	rc = (jint)gdk_pixbuf_scale_simple((const GdkPixbuf *)arg0, arg1, arg2, (GdkInterpType)arg3);
+	OS_NATIVE_EXIT(env, that, _1gdk_1pixbuf_1scale_1simple_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gdk_1pixmap_1foreign_1new
+JNIEXPORT jint JNICALL OS_NATIVE(_1gdk_1pixmap_1foreign_1new)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gdk_1pixmap_1foreign_1new_FUNC);
+	rc = (jint)gdk_pixmap_foreign_new(arg0);
+	OS_NATIVE_EXIT(env, that, _1gdk_1pixmap_1foreign_1new_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gdk_1pixmap_1new
+JNIEXPORT jint JNICALL OS_NATIVE(_1gdk_1pixmap_1new)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gdk_1pixmap_1new_FUNC);
+	rc = (jint)gdk_pixmap_new((GdkWindow *)arg0, (gint)arg1, (gint)arg2, (gint)arg3);
+	OS_NATIVE_EXIT(env, that, _1gdk_1pixmap_1new_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gdk_1pointer_1grab
+JNIEXPORT jint JNICALL OS_NATIVE(_1gdk_1pointer_1grab)
+	(JNIEnv *env, jclass that, jint arg0, jboolean arg1, jint arg2, jint arg3, jint arg4, jint arg5)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gdk_1pointer_1grab_FUNC);
+	rc = (jint)gdk_pointer_grab((GdkWindow *)arg0, (gboolean)arg1, (GdkEventMask)arg2, (GdkWindow *)arg3, (GdkCursor *)arg4, (guint32)arg5);
+	OS_NATIVE_EXIT(env, that, _1gdk_1pointer_1grab_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gdk_1pointer_1is_1grabbed
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1gdk_1pointer_1is_1grabbed)
+	(JNIEnv *env, jclass that)
+{
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gdk_1pointer_1is_1grabbed_FUNC);
+	rc = (jboolean)gdk_pointer_is_grabbed();
+	OS_NATIVE_EXIT(env, that, _1gdk_1pointer_1is_1grabbed_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gdk_1pointer_1ungrab
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1pointer_1ungrab)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1gdk_1pointer_1ungrab_FUNC);
+	gdk_pointer_ungrab((guint32)arg0);
+	OS_NATIVE_EXIT(env, that, _1gdk_1pointer_1ungrab_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1property_1get
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1gdk_1property_1get)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4, jint arg5, jintArray arg6, jintArray arg7, jintArray arg8, jintArray arg9)
+{
+	jint *lparg6=NULL;
+	jint *lparg7=NULL;
+	jint *lparg8=NULL;
+	jint *lparg9=NULL;
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gdk_1property_1get_FUNC);
+	if (arg6) if ((lparg6 = (*env)->GetIntArrayElements(env, arg6, NULL)) == NULL) goto fail;
+	if (arg7) if ((lparg7 = (*env)->GetIntArrayElements(env, arg7, NULL)) == NULL) goto fail;
+	if (arg8) if ((lparg8 = (*env)->GetIntArrayElements(env, arg8, NULL)) == NULL) goto fail;
+	if (arg9) if ((lparg9 = (*env)->GetIntArrayElements(env, arg9, NULL)) == NULL) goto fail;
+	rc = (jboolean)gdk_property_get((GdkWindow *)arg0, (GdkAtom)arg1, (GdkAtom)arg2, arg3, arg4, arg5, (GdkAtom *)lparg6, (gint *)lparg7, (gint *)lparg8, (guchar **)lparg9);
+fail:
+	if (arg9 && lparg9) (*env)->ReleaseIntArrayElements(env, arg9, lparg9, 0);
+	if (arg8 && lparg8) (*env)->ReleaseIntArrayElements(env, arg8, lparg8, 0);
+	if (arg7 && lparg7) (*env)->ReleaseIntArrayElements(env, arg7, lparg7, 0);
+	if (arg6 && lparg6) (*env)->ReleaseIntArrayElements(env, arg6, lparg6, 0);
+	OS_NATIVE_EXIT(env, that, _1gdk_1property_1get_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gdk_1region_1destroy
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1region_1destroy)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1gdk_1region_1destroy_FUNC);
+	gdk_region_destroy((GdkRegion *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gdk_1region_1destroy_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1region_1empty
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1gdk_1region_1empty)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gdk_1region_1empty_FUNC);
+	rc = (jboolean)gdk_region_empty((GdkRegion *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gdk_1region_1empty_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gdk_1region_1get_1clipbox
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1region_1get_1clipbox)
+	(JNIEnv *env, jclass that, jint arg0, jobject arg1)
+{
+	GdkRectangle _arg1, *lparg1=NULL;
+	OS_NATIVE_ENTER(env, that, _1gdk_1region_1get_1clipbox_FUNC);
+	if (arg1) if ((lparg1 = &_arg1) == NULL) goto fail;
+	gdk_region_get_clipbox((GdkRegion *)arg0, (GdkRectangle *)lparg1);
+fail:
+	if (arg1 && lparg1) setGdkRectangleFields(env, arg1, lparg1);
+	OS_NATIVE_EXIT(env, that, _1gdk_1region_1get_1clipbox_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1region_1get_1rectangles
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1region_1get_1rectangles)
+	(JNIEnv *env, jclass that, jint arg0, jintArray arg1, jintArray arg2)
+{
+	jint *lparg1=NULL;
+	jint *lparg2=NULL;
+	OS_NATIVE_ENTER(env, that, _1gdk_1region_1get_1rectangles_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	if (arg2) if ((lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL)) == NULL) goto fail;
+	gdk_region_get_rectangles((GdkRegion *)arg0, (GdkRectangle **)lparg1, (gint *)lparg2);
+fail:
+	if (arg2 && lparg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
+	if (arg1 && lparg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0);
+	OS_NATIVE_EXIT(env, that, _1gdk_1region_1get_1rectangles_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1region_1intersect
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1region_1intersect)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gdk_1region_1intersect_FUNC);
+	gdk_region_intersect((GdkRegion *)arg0, (GdkRegion *)arg1);
+	OS_NATIVE_EXIT(env, that, _1gdk_1region_1intersect_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1region_1new
+JNIEXPORT jint JNICALL OS_NATIVE(_1gdk_1region_1new)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gdk_1region_1new_FUNC);
+	rc = (jint)gdk_region_new();
+	OS_NATIVE_EXIT(env, that, _1gdk_1region_1new_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gdk_1region_1offset
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1region_1offset)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+	OS_NATIVE_ENTER(env, that, _1gdk_1region_1offset_FUNC);
+	gdk_region_offset((GdkRegion *)arg0, (gint)arg1, (gint)arg2);
+	OS_NATIVE_EXIT(env, that, _1gdk_1region_1offset_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1region_1point_1in
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1gdk_1region_1point_1in)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gdk_1region_1point_1in_FUNC);
+	rc = (jboolean)gdk_region_point_in((GdkRegion *)arg0, (gint)arg1, (gint)arg2);
+	OS_NATIVE_EXIT(env, that, _1gdk_1region_1point_1in_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gdk_1region_1polygon
+JNIEXPORT jint JNICALL OS_NATIVE(_1gdk_1region_1polygon)
+	(JNIEnv *env, jclass that, jintArray arg0, jint arg1, jint arg2)
+{
+	jint *lparg0=NULL;
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gdk_1region_1polygon_FUNC);
+	if (arg0) if ((lparg0 = (*env)->GetIntArrayElements(env, arg0, NULL)) == NULL) goto fail;
+	rc = (jint)gdk_region_polygon((GdkPoint *)lparg0, arg1, (GdkFillRule)arg2);
+fail:
+	if (arg0 && lparg0) (*env)->ReleaseIntArrayElements(env, arg0, lparg0, 0);
+	OS_NATIVE_EXIT(env, that, _1gdk_1region_1polygon_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gdk_1region_1rect_1in
+JNIEXPORT jint JNICALL OS_NATIVE(_1gdk_1region_1rect_1in)
+	(JNIEnv *env, jclass that, jint arg0, jobject arg1)
+{
+	GdkRectangle _arg1, *lparg1=NULL;
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gdk_1region_1rect_1in_FUNC);
+	if (arg1) if ((lparg1 = getGdkRectangleFields(env, arg1, &_arg1)) == NULL) goto fail;
+	rc = (jint)gdk_region_rect_in((GdkRegion *)arg0, (GdkRectangle *)lparg1);
+fail:
+	OS_NATIVE_EXIT(env, that, _1gdk_1region_1rect_1in_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gdk_1region_1rectangle
+JNIEXPORT jint JNICALL OS_NATIVE(_1gdk_1region_1rectangle)
+	(JNIEnv *env, jclass that, jobject arg0)
+{
+	GdkRectangle _arg0, *lparg0=NULL;
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gdk_1region_1rectangle_FUNC);
+	if (arg0) if ((lparg0 = getGdkRectangleFields(env, arg0, &_arg0)) == NULL) goto fail;
+	rc = (jint)gdk_region_rectangle(lparg0);
+fail:
+	OS_NATIVE_EXIT(env, that, _1gdk_1region_1rectangle_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gdk_1region_1subtract
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1region_1subtract)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gdk_1region_1subtract_FUNC);
+	gdk_region_subtract((GdkRegion *)arg0, (GdkRegion *)arg1);
+	OS_NATIVE_EXIT(env, that, _1gdk_1region_1subtract_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1region_1union
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1region_1union)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gdk_1region_1union_FUNC);
+	gdk_region_union((GdkRegion *)arg0, (GdkRegion *)arg1);
+	OS_NATIVE_EXIT(env, that, _1gdk_1region_1union_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1region_1union_1with_1rect
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1region_1union_1with_1rect)
+	(JNIEnv *env, jclass that, jint arg0, jobject arg1)
+{
+	GdkRectangle _arg1, *lparg1=NULL;
+	OS_NATIVE_ENTER(env, that, _1gdk_1region_1union_1with_1rect_FUNC);
+	if (arg1) if ((lparg1 = getGdkRectangleFields(env, arg1, &_arg1)) == NULL) goto fail;
+	gdk_region_union_with_rect((GdkRegion *)arg0, (GdkRectangle *)lparg1);
+fail:
+	OS_NATIVE_EXIT(env, that, _1gdk_1region_1union_1with_1rect_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1rgb_1init
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1rgb_1init)
+	(JNIEnv *env, jclass that)
+{
+	OS_NATIVE_ENTER(env, that, _1gdk_1rgb_1init_FUNC);
+	gdk_rgb_init();
+	OS_NATIVE_EXIT(env, that, _1gdk_1rgb_1init_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1screen_1get_1default
+JNIEXPORT jint JNICALL OS_NATIVE(_1gdk_1screen_1get_1default)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gdk_1screen_1get_1default_FUNC);
+/*
+	rc = (jint)gdk_screen_get_default();
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jint (*FPTR)();
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gdk_screen_get_default_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gdk_screen_get_default");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jint)(*fptr)();
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gdk_1screen_1get_1default_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gdk_1screen_1get_1monitor_1at_1point
+JNIEXPORT jint JNICALL OS_NATIVE(_1gdk_1screen_1get_1monitor_1at_1point)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gdk_1screen_1get_1monitor_1at_1point_FUNC);
+/*
+	rc = (jint)gdk_screen_get_monitor_at_point((GdkScreen *)arg0, (gint)arg1, (gint)arg2);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jint (*FPTR)(GdkScreen *, gint, gint);
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gdk_screen_get_monitor_at_point_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gdk_screen_get_monitor_at_point");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jint)(*fptr)((GdkScreen *)arg0, (gint)arg1, (gint)arg2);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gdk_1screen_1get_1monitor_1at_1point_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gdk_1screen_1get_1monitor_1at_1window
+JNIEXPORT jint JNICALL OS_NATIVE(_1gdk_1screen_1get_1monitor_1at_1window)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gdk_1screen_1get_1monitor_1at_1window_FUNC);
+/*
+	rc = (jint)gdk_screen_get_monitor_at_window((GdkScreen *)arg0, (GdkWindow *)arg1);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jint (*FPTR)(GdkScreen *, GdkWindow *);
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gdk_screen_get_monitor_at_window_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gdk_screen_get_monitor_at_window");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jint)(*fptr)((GdkScreen *)arg0, (GdkWindow *)arg1);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gdk_1screen_1get_1monitor_1at_1window_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gdk_1screen_1get_1monitor_1geometry
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1screen_1get_1monitor_1geometry)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jobject arg2)
+{
+	GdkRectangle _arg2, *lparg2=NULL;
+	OS_NATIVE_ENTER(env, that, _1gdk_1screen_1get_1monitor_1geometry_FUNC);
+	if (arg2) if ((lparg2 = &_arg2) == NULL) goto fail;
+/*
+	gdk_screen_get_monitor_geometry((GdkScreen *)arg0, arg1, lparg2);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef void (*FPTR)(GdkScreen *, jint, GdkRectangle *);
+		static FPTR fptr;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gdk_screen_get_monitor_geometry_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gdk_screen_get_monitor_geometry");
+			initialized = 1;
+		}
+		if (fptr) {
+			(*fptr)((GdkScreen *)arg0, arg1, lparg2);
+		}
+	}
+fail:
+	if (arg2 && lparg2) setGdkRectangleFields(env, arg2, lparg2);
+	OS_NATIVE_EXIT(env, that, _1gdk_1screen_1get_1monitor_1geometry_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1screen_1get_1n_1monitors
+JNIEXPORT jint JNICALL OS_NATIVE(_1gdk_1screen_1get_1n_1monitors)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gdk_1screen_1get_1n_1monitors_FUNC);
+/*
+	rc = (jint)gdk_screen_get_n_monitors((GdkScreen *)arg0);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jint (*FPTR)(GdkScreen *);
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gdk_screen_get_n_monitors_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gdk_screen_get_n_monitors");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jint)(*fptr)((GdkScreen *)arg0);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gdk_1screen_1get_1n_1monitors_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gdk_1screen_1get_1number
+JNIEXPORT jint JNICALL OS_NATIVE(_1gdk_1screen_1get_1number)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gdk_1screen_1get_1number_FUNC);
+/*
+	rc = (jint)gdk_screen_get_number((GdkScreen *)arg0);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jint (*FPTR)(GdkScreen *);
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gdk_screen_get_number_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gdk_screen_get_number");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jint)(*fptr)((GdkScreen *)arg0);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gdk_1screen_1get_1number_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gdk_1screen_1height
+JNIEXPORT jint JNICALL OS_NATIVE(_1gdk_1screen_1height)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gdk_1screen_1height_FUNC);
+	rc = (jint)gdk_screen_height();
+	OS_NATIVE_EXIT(env, that, _1gdk_1screen_1height_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gdk_1screen_1width
+JNIEXPORT jint JNICALL OS_NATIVE(_1gdk_1screen_1width)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gdk_1screen_1width_FUNC);
+	rc = (jint)gdk_screen_width();
+	OS_NATIVE_EXIT(env, that, _1gdk_1screen_1width_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gdk_1screen_1width_1mm
+JNIEXPORT jint JNICALL OS_NATIVE(_1gdk_1screen_1width_1mm)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gdk_1screen_1width_1mm_FUNC);
+	rc = (jint)gdk_screen_width_mm();
+	OS_NATIVE_EXIT(env, that, _1gdk_1screen_1width_1mm_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gdk_1set_1program_1class
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1set_1program_1class)
+	(JNIEnv *env, jclass that, jbyteArray arg0)
+{
+	jbyte *lparg0=NULL;
+	OS_NATIVE_ENTER(env, that, _1gdk_1set_1program_1class_FUNC);
+	if (arg0) if ((lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL)) == NULL) goto fail;
+	gdk_set_program_class((const char *)lparg0);
+fail:
+	if (arg0 && lparg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
+	OS_NATIVE_EXIT(env, that, _1gdk_1set_1program_1class_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1text_1property_1to_1utf8_1list
+JNIEXPORT jint JNICALL OS_NATIVE(_1gdk_1text_1property_1to_1utf8_1list)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jintArray arg4)
+{
+	jint *lparg4=NULL;
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gdk_1text_1property_1to_1utf8_1list_FUNC);
+	if (arg4) if ((lparg4 = (*env)->GetIntArrayElements(env, arg4, NULL)) == NULL) goto fail;
+	rc = (jint)gdk_text_property_to_utf8_list((GdkAtom)arg0, arg1, (guchar *)arg2, arg3, (gchar ***)lparg4);
+fail:
+	if (arg4 && lparg4) (*env)->ReleaseIntArrayElements(env, arg4, lparg4, 0);
+	OS_NATIVE_EXIT(env, that, _1gdk_1text_1property_1to_1utf8_1list_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gdk_1unicode_1to_1keyval
+JNIEXPORT jint JNICALL OS_NATIVE(_1gdk_1unicode_1to_1keyval)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gdk_1unicode_1to_1keyval_FUNC);
+	rc = (jint)gdk_unicode_to_keyval(arg0);
+	OS_NATIVE_EXIT(env, that, _1gdk_1unicode_1to_1keyval_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gdk_1utf8_1to_1compound_1text
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1gdk_1utf8_1to_1compound_1text)
+	(JNIEnv *env, jclass that, jbyteArray arg0, jintArray arg1, jintArray arg2, jintArray arg3, jintArray arg4)
+{
+	jbyte *lparg0=NULL;
+	jint *lparg1=NULL;
+	jint *lparg2=NULL;
+	jint *lparg3=NULL;
+	jint *lparg4=NULL;
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gdk_1utf8_1to_1compound_1text_FUNC);
+	if (arg0) if ((lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL)) == NULL) goto fail;
+	if (arg1) if ((lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	if (arg2) if ((lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL)) == NULL) goto fail;
+	if (arg3) if ((lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL)) == NULL) goto fail;
+	if (arg4) if ((lparg4 = (*env)->GetIntArrayElements(env, arg4, NULL)) == NULL) goto fail;
+	rc = (jboolean)gdk_utf8_to_compound_text((const gchar *)lparg0, (GdkAtom *)lparg1, (gint *)lparg2, (guchar **)lparg3, (gint *)lparg4);
+fail:
+	if (arg4 && lparg4) (*env)->ReleaseIntArrayElements(env, arg4, lparg4, 0);
+	if (arg3 && lparg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0);
+	if (arg2 && lparg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
+	if (arg1 && lparg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0);
+	if (arg0 && lparg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
+	OS_NATIVE_EXIT(env, that, _1gdk_1utf8_1to_1compound_1text_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gdk_1utf8_1to_1string_1target
+JNIEXPORT jint JNICALL OS_NATIVE(_1gdk_1utf8_1to_1string_1target)
+	(JNIEnv *env, jclass that, jbyteArray arg0)
+{
+	jbyte *lparg0=NULL;
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gdk_1utf8_1to_1string_1target_FUNC);
+	if (arg0) if ((lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL)) == NULL) goto fail;
+	rc = (jint)gdk_utf8_to_string_target((const gchar *)lparg0);
+fail:
+	if (arg0 && lparg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
+	OS_NATIVE_EXIT(env, that, _1gdk_1utf8_1to_1string_1target_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gdk_1visual_1get_1system
+JNIEXPORT jint JNICALL OS_NATIVE(_1gdk_1visual_1get_1system)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gdk_1visual_1get_1system_FUNC);
+	rc = (jint)gdk_visual_get_system();
+	OS_NATIVE_EXIT(env, that, _1gdk_1visual_1get_1system_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gdk_1window_1add_1filter
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1window_1add_1filter)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+	OS_NATIVE_ENTER(env, that, _1gdk_1window_1add_1filter_FUNC);
+	gdk_window_add_filter((GdkWindow *)arg0, (GdkFilterFunc)arg1, (gpointer)arg2);
+	OS_NATIVE_EXIT(env, that, _1gdk_1window_1add_1filter_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1window_1at_1pointer
+JNIEXPORT jint JNICALL OS_NATIVE(_1gdk_1window_1at_1pointer)
+	(JNIEnv *env, jclass that, jintArray arg0, jintArray arg1)
+{
+	jint *lparg0=NULL;
+	jint *lparg1=NULL;
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gdk_1window_1at_1pointer_FUNC);
+	if (arg0) if ((lparg0 = (*env)->GetIntArrayElements(env, arg0, NULL)) == NULL) goto fail;
+	if (arg1) if ((lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	rc = (jint)gdk_window_at_pointer((gint *)lparg0, (gint *)lparg1);
+fail:
+	if (arg1 && lparg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0);
+	if (arg0 && lparg0) (*env)->ReleaseIntArrayElements(env, arg0, lparg0, 0);
+	OS_NATIVE_EXIT(env, that, _1gdk_1window_1at_1pointer_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gdk_1window_1begin_1paint_1rect
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1window_1begin_1paint_1rect)
+	(JNIEnv *env, jclass that, jint arg0, jobject arg1)
+{
+	GdkRectangle _arg1, *lparg1=NULL;
+	OS_NATIVE_ENTER(env, that, _1gdk_1window_1begin_1paint_1rect_FUNC);
+	if (arg1) if ((lparg1 = getGdkRectangleFields(env, arg1, &_arg1)) == NULL) goto fail;
+	gdk_window_begin_paint_rect((GdkWindow *)arg0, (GdkRectangle *)lparg1);
+fail:
+	OS_NATIVE_EXIT(env, that, _1gdk_1window_1begin_1paint_1rect_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1window_1clear_1area
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1window_1clear_1area)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4)
+{
+	OS_NATIVE_ENTER(env, that, _1gdk_1window_1clear_1area_FUNC);
+	gdk_window_clear_area((GdkWindow *)arg0, arg1, arg2, arg3, arg4);
+	OS_NATIVE_EXIT(env, that, _1gdk_1window_1clear_1area_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1window_1destroy
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1window_1destroy)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1gdk_1window_1destroy_FUNC);
+	gdk_window_destroy((GdkWindow *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gdk_1window_1destroy_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1window_1end_1paint
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1window_1end_1paint)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1gdk_1window_1end_1paint_FUNC);
+	gdk_window_end_paint((GdkWindow *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gdk_1window_1end_1paint_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1window_1focus
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1window_1focus)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gdk_1window_1focus_FUNC);
+	gdk_window_focus((GdkWindow *)arg0, arg1);
+	OS_NATIVE_EXIT(env, that, _1gdk_1window_1focus_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1window_1freeze_1updates
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1window_1freeze_1updates)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1gdk_1window_1freeze_1updates_FUNC);
+	gdk_window_freeze_updates((GdkWindow *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gdk_1window_1freeze_1updates_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1window_1get_1children
+JNIEXPORT jint JNICALL OS_NATIVE(_1gdk_1window_1get_1children)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gdk_1window_1get_1children_FUNC);
+	rc = (jint)gdk_window_get_children((GdkWindow *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gdk_1window_1get_1children_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gdk_1window_1get_1events
+JNIEXPORT jint JNICALL OS_NATIVE(_1gdk_1window_1get_1events)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gdk_1window_1get_1events_FUNC);
+	rc = (jint)gdk_window_get_events((GdkWindow *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gdk_1window_1get_1events_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gdk_1window_1get_1frame_1extents
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1window_1get_1frame_1extents)
+	(JNIEnv *env, jclass that, jint arg0, jobject arg1)
+{
+	GdkRectangle _arg1, *lparg1=NULL;
+	OS_NATIVE_ENTER(env, that, _1gdk_1window_1get_1frame_1extents_FUNC);
+	if (arg1) if ((lparg1 = &_arg1) == NULL) goto fail;
+	gdk_window_get_frame_extents((GdkWindow *)arg0, (GdkRectangle *)lparg1);
+fail:
+	if (arg1 && lparg1) setGdkRectangleFields(env, arg1, lparg1);
+	OS_NATIVE_EXIT(env, that, _1gdk_1window_1get_1frame_1extents_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1window_1get_1internal_1paint_1info
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1window_1get_1internal_1paint_1info)
+	(JNIEnv *env, jclass that, jint arg0, jintArray arg1, jintArray arg2, jintArray arg3)
+{
+	jint *lparg1=NULL;
+	jint *lparg2=NULL;
+	jint *lparg3=NULL;
+	OS_NATIVE_ENTER(env, that, _1gdk_1window_1get_1internal_1paint_1info_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	if (arg2) if ((lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL)) == NULL) goto fail;
+	if (arg3) if ((lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL)) == NULL) goto fail;
+	gdk_window_get_internal_paint_info((GdkWindow *)arg0, (GdkDrawable **)lparg1, (gint *)lparg2, (gint *)lparg3);
+fail:
+	if (arg3 && lparg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0);
+	if (arg2 && lparg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
+	if (arg1 && lparg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0);
+	OS_NATIVE_EXIT(env, that, _1gdk_1window_1get_1internal_1paint_1info_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1window_1get_1origin
+JNIEXPORT jint JNICALL OS_NATIVE(_1gdk_1window_1get_1origin)
+	(JNIEnv *env, jclass that, jint arg0, jintArray arg1, jintArray arg2)
+{
+	jint *lparg1=NULL;
+	jint *lparg2=NULL;
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gdk_1window_1get_1origin_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	if (arg2) if ((lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL)) == NULL) goto fail;
+	rc = (jint)gdk_window_get_origin((GdkWindow *)arg0, (gint *)lparg1, (gint *)lparg2);
+fail:
+	if (arg2 && lparg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
+	if (arg1 && lparg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0);
+	OS_NATIVE_EXIT(env, that, _1gdk_1window_1get_1origin_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gdk_1window_1get_1parent
+JNIEXPORT jint JNICALL OS_NATIVE(_1gdk_1window_1get_1parent)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gdk_1window_1get_1parent_FUNC);
+	rc = (jint)gdk_window_get_parent((GdkWindow *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gdk_1window_1get_1parent_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gdk_1window_1get_1pointer
+JNIEXPORT jint JNICALL OS_NATIVE(_1gdk_1window_1get_1pointer)
+	(JNIEnv *env, jclass that, jint arg0, jintArray arg1, jintArray arg2, jintArray arg3)
+{
+	jint *lparg1=NULL;
+	jint *lparg2=NULL;
+	jint *lparg3=NULL;
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gdk_1window_1get_1pointer_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	if (arg2) if ((lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL)) == NULL) goto fail;
+	if (arg3) if ((lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL)) == NULL) goto fail;
+	rc = (jint)gdk_window_get_pointer((GdkWindow *)arg0, (gint *)lparg1, (gint *)lparg2, (GdkModifierType *)lparg3);
+fail:
+	if (arg3 && lparg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0);
+	if (arg2 && lparg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
+	if (arg1 && lparg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0);
+	OS_NATIVE_EXIT(env, that, _1gdk_1window_1get_1pointer_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gdk_1window_1get_1position
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1window_1get_1position)
+	(JNIEnv *env, jclass that, jint arg0, jintArray arg1, jintArray arg2)
+{
+	jint *lparg1=NULL;
+	jint *lparg2=NULL;
+	OS_NATIVE_ENTER(env, that, _1gdk_1window_1get_1position_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	if (arg2) if ((lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL)) == NULL) goto fail;
+	gdk_window_get_position((GdkWindow *)arg0, (gint *)lparg1, (gint *)lparg2);
+fail:
+	if (arg2 && lparg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
+	if (arg1 && lparg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0);
+	OS_NATIVE_EXIT(env, that, _1gdk_1window_1get_1position_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1window_1get_1user_1data
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1window_1get_1user_1data)
+	(JNIEnv *env, jclass that, jint arg0, jintArray arg1)
+{
+	jint *lparg1=NULL;
+	OS_NATIVE_ENTER(env, that, _1gdk_1window_1get_1user_1data_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	gdk_window_get_user_data((GdkWindow *)arg0, (gpointer *)lparg1);
+fail:
+	if (arg1 && lparg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0);
+	OS_NATIVE_EXIT(env, that, _1gdk_1window_1get_1user_1data_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1window_1hide
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1window_1hide)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1gdk_1window_1hide_FUNC);
+	gdk_window_hide((GdkWindow *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gdk_1window_1hide_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1window_1invalidate_1rect
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1window_1invalidate_1rect)
+	(JNIEnv *env, jclass that, jint arg0, jobject arg1, jboolean arg2)
+{
+	GdkRectangle _arg1, *lparg1=NULL;
+	OS_NATIVE_ENTER(env, that, _1gdk_1window_1invalidate_1rect_FUNC);
+	if (arg1) if ((lparg1 = getGdkRectangleFields(env, arg1, &_arg1)) == NULL) goto fail;
+	gdk_window_invalidate_rect((GdkWindow *)arg0, (GdkRectangle *)lparg1, (gboolean)arg2);
+fail:
+	OS_NATIVE_EXIT(env, that, _1gdk_1window_1invalidate_1rect_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1window_1invalidate_1region
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1window_1invalidate_1region)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jboolean arg2)
+{
+	OS_NATIVE_ENTER(env, that, _1gdk_1window_1invalidate_1region_FUNC);
+	gdk_window_invalidate_region((GdkWindow *)arg0, (GdkRegion *)arg1, (gboolean)arg2);
+	OS_NATIVE_EXIT(env, that, _1gdk_1window_1invalidate_1region_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1window_1is_1visible
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1gdk_1window_1is_1visible)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gdk_1window_1is_1visible_FUNC);
+	rc = (jboolean)gdk_window_is_visible((GdkWindow *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gdk_1window_1is_1visible_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gdk_1window_1lookup
+JNIEXPORT jint JNICALL OS_NATIVE(_1gdk_1window_1lookup)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gdk_1window_1lookup_FUNC);
+	rc = (jint)gdk_window_lookup(arg0);
+	OS_NATIVE_EXIT(env, that, _1gdk_1window_1lookup_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gdk_1window_1lower
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1window_1lower)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1gdk_1window_1lower_FUNC);
+	gdk_window_lower((GdkWindow *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gdk_1window_1lower_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1window_1move
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1window_1move)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+	OS_NATIVE_ENTER(env, that, _1gdk_1window_1move_FUNC);
+	gdk_window_move((GdkWindow *)arg0, arg1, arg2);
+	OS_NATIVE_EXIT(env, that, _1gdk_1window_1move_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1window_1new
+JNIEXPORT jint JNICALL OS_NATIVE(_1gdk_1window_1new)
+	(JNIEnv *env, jclass that, jint arg0, jobject arg1, jint arg2)
+{
+	GdkWindowAttr _arg1, *lparg1=NULL;
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gdk_1window_1new_FUNC);
+	if (arg1) if ((lparg1 = getGdkWindowAttrFields(env, arg1, &_arg1)) == NULL) goto fail;
+	rc = (jint)gdk_window_new((GdkWindow *)arg0, lparg1, arg2);
+fail:
+	OS_NATIVE_EXIT(env, that, _1gdk_1window_1new_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gdk_1window_1process_1all_1updates
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1window_1process_1all_1updates)
+	(JNIEnv *env, jclass that)
+{
+	OS_NATIVE_ENTER(env, that, _1gdk_1window_1process_1all_1updates_FUNC);
+	gdk_window_process_all_updates();
+	OS_NATIVE_EXIT(env, that, _1gdk_1window_1process_1all_1updates_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1window_1process_1updates
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1window_1process_1updates)
+	(JNIEnv *env, jclass that, jint arg0, jboolean arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gdk_1window_1process_1updates_FUNC);
+	gdk_window_process_updates((GdkWindow *)arg0, (gboolean)arg1);
+	OS_NATIVE_EXIT(env, that, _1gdk_1window_1process_1updates_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1window_1raise
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1window_1raise)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1gdk_1window_1raise_FUNC);
+	gdk_window_raise((GdkWindow *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gdk_1window_1raise_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1window_1remove_1filter
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1window_1remove_1filter)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+	OS_NATIVE_ENTER(env, that, _1gdk_1window_1remove_1filter_FUNC);
+	gdk_window_remove_filter((GdkWindow *)arg0, (GdkFilterFunc)arg1, (gpointer)arg2);
+	OS_NATIVE_EXIT(env, that, _1gdk_1window_1remove_1filter_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1window_1resize
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1window_1resize)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+	OS_NATIVE_ENTER(env, that, _1gdk_1window_1resize_FUNC);
+	gdk_window_resize((GdkWindow *)arg0, arg1, arg2);
+	OS_NATIVE_EXIT(env, that, _1gdk_1window_1resize_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1window_1scroll
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1window_1scroll)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+	OS_NATIVE_ENTER(env, that, _1gdk_1window_1scroll_FUNC);
+	gdk_window_scroll((GdkWindow *)arg0, arg1, arg2);
+	OS_NATIVE_EXIT(env, that, _1gdk_1window_1scroll_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1window_1set_1accept_1focus
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1window_1set_1accept_1focus)
+	(JNIEnv *env, jclass that, jint arg0, jboolean arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gdk_1window_1set_1accept_1focus_FUNC);
+/*
+	gdk_window_set_accept_focus((GdkWindow *)arg0, (gboolean)arg1);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef void (*FPTR)(GdkWindow *, gboolean);
+		static FPTR fptr;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gdk_window_set_accept_focus_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gdk_window_set_accept_focus");
+			initialized = 1;
+		}
+		if (fptr) {
+			(*fptr)((GdkWindow *)arg0, (gboolean)arg1);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gdk_1window_1set_1accept_1focus_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1window_1set_1back_1pixmap
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1window_1set_1back_1pixmap)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jboolean arg2)
+{
+	OS_NATIVE_ENTER(env, that, _1gdk_1window_1set_1back_1pixmap_FUNC);
+	gdk_window_set_back_pixmap((GdkWindow *)arg0, (GdkPixmap *)arg1, (gboolean)arg2);
+	OS_NATIVE_EXIT(env, that, _1gdk_1window_1set_1back_1pixmap_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1window_1set_1cursor
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1window_1set_1cursor)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gdk_1window_1set_1cursor_FUNC);
+	gdk_window_set_cursor((GdkWindow *)arg0, (GdkCursor *)arg1);
+	OS_NATIVE_EXIT(env, that, _1gdk_1window_1set_1cursor_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1window_1set_1debug_1updates
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1window_1set_1debug_1updates)
+	(JNIEnv *env, jclass that, jboolean arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1gdk_1window_1set_1debug_1updates_FUNC);
+	gdk_window_set_debug_updates((gboolean)arg0);
+	OS_NATIVE_EXIT(env, that, _1gdk_1window_1set_1debug_1updates_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1window_1set_1decorations
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1window_1set_1decorations)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gdk_1window_1set_1decorations_FUNC);
+	gdk_window_set_decorations((GdkWindow *)arg0, (GdkWMDecoration)arg1);
+	OS_NATIVE_EXIT(env, that, _1gdk_1window_1set_1decorations_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1window_1set_1events
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1window_1set_1events)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gdk_1window_1set_1events_FUNC);
+	gdk_window_set_events((GdkWindow *)arg0, arg1);
+	OS_NATIVE_EXIT(env, that, _1gdk_1window_1set_1events_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1window_1set_1icon
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1window_1set_1icon)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3)
+{
+	OS_NATIVE_ENTER(env, that, _1gdk_1window_1set_1icon_FUNC);
+	gdk_window_set_icon((GdkWindow *)arg0, (GdkWindow *)arg1, (GdkPixmap *)arg2, (GdkBitmap *)arg3);
+	OS_NATIVE_EXIT(env, that, _1gdk_1window_1set_1icon_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1window_1set_1icon_1list
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1window_1set_1icon_1list)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gdk_1window_1set_1icon_1list_FUNC);
+	gdk_window_set_icon_list((GdkWindow *)arg0, (GList *)arg1);
+	OS_NATIVE_EXIT(env, that, _1gdk_1window_1set_1icon_1list_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1window_1set_1keep_1above
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1window_1set_1keep_1above)
+	(JNIEnv *env, jclass that, jint arg0, jboolean arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gdk_1window_1set_1keep_1above_FUNC);
+/*
+	gdk_window_set_keep_above((GdkWindow *)arg0, (gboolean)arg1);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef void (*FPTR)(GdkWindow *, gboolean);
+		static FPTR fptr;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gdk_window_set_keep_above_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gdk_window_set_keep_above");
+			initialized = 1;
+		}
+		if (fptr) {
+			(*fptr)((GdkWindow *)arg0, (gboolean)arg1);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gdk_1window_1set_1keep_1above_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1window_1set_1override_1redirect
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1window_1set_1override_1redirect)
+	(JNIEnv *env, jclass that, jint arg0, jboolean arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gdk_1window_1set_1override_1redirect_FUNC);
+	gdk_window_set_override_redirect((GdkWindow *)arg0, (gboolean)arg1);
+	OS_NATIVE_EXIT(env, that, _1gdk_1window_1set_1override_1redirect_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1window_1set_1user_1data
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1window_1set_1user_1data)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gdk_1window_1set_1user_1data_FUNC);
+	gdk_window_set_user_data((GdkWindow *)arg0, (gpointer)arg1);
+	OS_NATIVE_EXIT(env, that, _1gdk_1window_1set_1user_1data_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1window_1shape_1combine_1region
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1window_1shape_1combine_1region)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3)
+{
+	OS_NATIVE_ENTER(env, that, _1gdk_1window_1shape_1combine_1region_FUNC);
+	gdk_window_shape_combine_region((GdkWindow *)arg0, (GdkRegion *)arg1, arg2, arg3);
+	OS_NATIVE_EXIT(env, that, _1gdk_1window_1shape_1combine_1region_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1window_1show
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1window_1show)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1gdk_1window_1show_FUNC);
+	gdk_window_show((GdkWindow *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gdk_1window_1show_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1window_1show_1unraised
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1window_1show_1unraised)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1gdk_1window_1show_1unraised_FUNC);
+	gdk_window_show_unraised((GdkWindow *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gdk_1window_1show_1unraised_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1window_1thaw_1updates
+JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1window_1thaw_1updates)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1gdk_1window_1thaw_1updates_FUNC);
+	gdk_window_thaw_updates((GdkWindow *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gdk_1window_1thaw_1updates_FUNC);
+}
+#endif
+
+#ifndef NO__1gdk_1x11_1atom_1to_1xatom
+JNIEXPORT jint JNICALL OS_NATIVE(_1gdk_1x11_1atom_1to_1xatom)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gdk_1x11_1atom_1to_1xatom_FUNC);
+	rc = (jint)gdk_x11_atom_to_xatom((GdkAtom)arg0);
+	OS_NATIVE_EXIT(env, that, _1gdk_1x11_1atom_1to_1xatom_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gdk_1x11_1colormap_1get_1xcolormap
+JNIEXPORT jint JNICALL OS_NATIVE(_1gdk_1x11_1colormap_1get_1xcolormap)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gdk_1x11_1colormap_1get_1xcolormap_FUNC);
+	rc = (jint)gdk_x11_colormap_get_xcolormap((GdkColormap *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gdk_1x11_1colormap_1get_1xcolormap_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gdk_1x11_1drawable_1get_1xdisplay
+JNIEXPORT jint JNICALL OS_NATIVE(_1gdk_1x11_1drawable_1get_1xdisplay)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gdk_1x11_1drawable_1get_1xdisplay_FUNC);
+	rc = (jint)gdk_x11_drawable_get_xdisplay((GdkDrawable *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gdk_1x11_1drawable_1get_1xdisplay_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gdk_1x11_1drawable_1get_1xid
+JNIEXPORT jint JNICALL OS_NATIVE(_1gdk_1x11_1drawable_1get_1xid)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gdk_1x11_1drawable_1get_1xid_FUNC);
+	rc = (jint)gdk_x11_drawable_get_xid((GdkDrawable *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gdk_1x11_1drawable_1get_1xid_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gdk_1x11_1screen_1get_1window_1manager_1name
+JNIEXPORT jint JNICALL OS_NATIVE(_1gdk_1x11_1screen_1get_1window_1manager_1name)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gdk_1x11_1screen_1get_1window_1manager_1name_FUNC);
+/*
+	rc = (jint)gdk_x11_screen_get_window_manager_name((GdkScreen *)arg0);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jint (*FPTR)(GdkScreen *);
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gdk_x11_screen_get_window_manager_name_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gdk_x11_screen_get_window_manager_name");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jint)(*fptr)((GdkScreen *)arg0);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gdk_1x11_1screen_1get_1window_1manager_1name_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gdk_1x11_1screen_1lookup_1visual
+JNIEXPORT jint JNICALL OS_NATIVE(_1gdk_1x11_1screen_1lookup_1visual)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gdk_1x11_1screen_1lookup_1visual_FUNC);
+/*
+	rc = (jint)gdk_x11_screen_lookup_visual((GdkScreen *)arg0, (VisualID)arg1);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jint (*FPTR)(GdkScreen *, VisualID);
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gdk_x11_screen_lookup_visual_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gdk_x11_screen_lookup_visual");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jint)(*fptr)((GdkScreen *)arg0, (VisualID)arg1);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gdk_1x11_1screen_1lookup_1visual_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gdk_1x11_1visual_1get_1xvisual
+JNIEXPORT jint JNICALL OS_NATIVE(_1gdk_1x11_1visual_1get_1xvisual)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gdk_1x11_1visual_1get_1xvisual_FUNC);
+	rc = (jint)gdk_x11_visual_get_xvisual((GdkVisual *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gdk_1x11_1visual_1get_1xvisual_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1accel_1group_1new
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1accel_1group_1new)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1accel_1group_1new_FUNC);
+	rc = (jint)gtk_accel_group_new();
+	OS_NATIVE_EXIT(env, that, _1gtk_1accel_1group_1new_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1accel_1groups_1activate
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1gtk_1accel_1groups_1activate)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1accel_1groups_1activate_FUNC);
+	rc = (jboolean)gtk_accel_groups_activate((GObject *)arg0, (guint)arg1, (GdkModifierType)arg2);
+	OS_NATIVE_EXIT(env, that, _1gtk_1accel_1groups_1activate_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1accel_1label_1set_1accel_1widget
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1accel_1label_1set_1accel_1widget)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1accel_1label_1set_1accel_1widget_FUNC);
+	gtk_accel_label_set_accel_widget((GtkAccelLabel *)arg0, (GtkWidget *)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1accel_1label_1set_1accel_1widget_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1adjustment_1changed
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1adjustment_1changed)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1adjustment_1changed_FUNC);
+	gtk_adjustment_changed((GtkAdjustment *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1adjustment_1changed_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1adjustment_1new
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1adjustment_1new)
+	(JNIEnv *env, jclass that, jdouble arg0, jdouble arg1, jdouble arg2, jdouble arg3, jdouble arg4, jdouble arg5)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1adjustment_1new_FUNC);
+	rc = (jint)gtk_adjustment_new((gdouble)arg0, (gdouble)arg1, (gdouble)arg2, (gdouble)arg3, (gdouble)arg4, arg5);
+	OS_NATIVE_EXIT(env, that, _1gtk_1adjustment_1new_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1adjustment_1set_1value
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1adjustment_1set_1value)
+	(JNIEnv *env, jclass that, jint arg0, jdouble arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1adjustment_1set_1value_FUNC);
+	gtk_adjustment_set_value((GtkAdjustment *)arg0, (gdouble)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1adjustment_1set_1value_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1adjustment_1value_1changed
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1adjustment_1value_1changed)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1adjustment_1value_1changed_FUNC);
+	gtk_adjustment_value_changed((GtkAdjustment *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1adjustment_1value_1changed_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1arrow_1new
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1arrow_1new)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1arrow_1new_FUNC);
+	rc = (jint)gtk_arrow_new((GtkArrowType)arg0, (GtkShadowType)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1arrow_1new_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1arrow_1set
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1arrow_1set)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1arrow_1set_FUNC);
+	gtk_arrow_set((GtkArrow *)arg0, (GtkArrowType)arg1, (GtkShadowType)arg2);
+	OS_NATIVE_EXIT(env, that, _1gtk_1arrow_1set_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1bin_1get_1child
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1bin_1get_1child)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1bin_1get_1child_FUNC);
+	rc = (jint)gtk_bin_get_child((GtkBin *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1bin_1get_1child_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1box_1set_1child_1packing
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1box_1set_1child_1packing)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jboolean arg2, jboolean arg3, jint arg4, jint arg5)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1box_1set_1child_1packing_FUNC);
+	gtk_box_set_child_packing((GtkBox *)arg0, (GtkWidget *)arg1, arg2, arg3, arg4, arg5);
+	OS_NATIVE_EXIT(env, that, _1gtk_1box_1set_1child_1packing_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1box_1set_1spacing
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1box_1set_1spacing)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1box_1set_1spacing_FUNC);
+	gtk_box_set_spacing((GtkBox *)arg0, arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1box_1set_1spacing_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1button_1clicked
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1button_1clicked)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1button_1clicked_FUNC);
+	gtk_button_clicked((GtkButton *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1button_1clicked_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1button_1get_1relief
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1button_1get_1relief)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1button_1get_1relief_FUNC);
+	rc = (jint)gtk_button_get_relief((GtkButton *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1button_1get_1relief_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1button_1new
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1button_1new)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1button_1new_FUNC);
+	rc = (jint)gtk_button_new();
+	OS_NATIVE_EXIT(env, that, _1gtk_1button_1new_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1button_1set_1relief
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1button_1set_1relief)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1button_1set_1relief_FUNC);
+	gtk_button_set_relief((GtkButton *)arg0, (GtkReliefStyle)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1button_1set_1relief_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1calendar_1display_1options
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1calendar_1display_1options)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1calendar_1display_1options_FUNC);
+/*
+	gtk_calendar_display_options((GtkCalendar *)arg0, (GtkCalendarDisplayOptions)arg1);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef void (*FPTR)(GtkCalendar *, GtkCalendarDisplayOptions);
+		static FPTR fptr;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_calendar_display_options_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_calendar_display_options");
+			initialized = 1;
+		}
+		if (fptr) {
+			(*fptr)((GtkCalendar *)arg0, (GtkCalendarDisplayOptions)arg1);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1calendar_1display_1options_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1calendar_1get_1date
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1calendar_1get_1date)
+	(JNIEnv *env, jclass that, jint arg0, jintArray arg1, jintArray arg2, jintArray arg3)
+{
+	jint *lparg1=NULL;
+	jint *lparg2=NULL;
+	jint *lparg3=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1calendar_1get_1date_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	if (arg2) if ((lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL)) == NULL) goto fail;
+	if (arg3) if ((lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL)) == NULL) goto fail;
+/*
+	gtk_calendar_get_date((GtkCalendar *)arg0, (guint *)lparg1, (guint *)lparg2, (guint *)lparg3);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef void (*FPTR)(GtkCalendar *, guint *, guint *, guint *);
+		static FPTR fptr;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_calendar_get_date_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_calendar_get_date");
+			initialized = 1;
+		}
+		if (fptr) {
+			(*fptr)((GtkCalendar *)arg0, (guint *)lparg1, (guint *)lparg2, (guint *)lparg3);
+		}
+	}
+fail:
+	if (arg3 && lparg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0);
+	if (arg2 && lparg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
+	if (arg1 && lparg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1calendar_1get_1date_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1calendar_1new
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1calendar_1new)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1calendar_1new_FUNC);
+/*
+	rc = (jint)gtk_calendar_new();
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jint (*FPTR)();
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_calendar_new_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_calendar_new");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jint)(*fptr)();
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1calendar_1new_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1calendar_1select_1day
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1calendar_1select_1day)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1calendar_1select_1day_FUNC);
+/*
+	gtk_calendar_select_day((GtkCalendar *)arg0, (guint)arg1);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef void (*FPTR)(GtkCalendar *, guint);
+		static FPTR fptr;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_calendar_select_day_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_calendar_select_day");
+			initialized = 1;
+		}
+		if (fptr) {
+			(*fptr)((GtkCalendar *)arg0, (guint)arg1);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1calendar_1select_1day_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1calendar_1select_1month
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1gtk_1calendar_1select_1month)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1calendar_1select_1month_FUNC);
+/*
+	rc = (jboolean)gtk_calendar_select_month((GtkCalendar *)arg0, (guint)arg1, (guint)arg2);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jboolean (*FPTR)(GtkCalendar *, guint, guint);
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_calendar_select_month_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_calendar_select_month");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jboolean)(*fptr)((GtkCalendar *)arg0, (guint)arg1, (guint)arg2);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1calendar_1select_1month_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1calendar_1set_1display_1options
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1calendar_1set_1display_1options)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1calendar_1set_1display_1options_FUNC);
+/*
+	gtk_calendar_set_display_options((GtkCalendar *)arg0, (GtkCalendarDisplayOptions)arg1);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef void (*FPTR)(GtkCalendar *, GtkCalendarDisplayOptions);
+		static FPTR fptr;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_calendar_set_display_options_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_calendar_set_display_options");
+			initialized = 1;
+		}
+		if (fptr) {
+			(*fptr)((GtkCalendar *)arg0, (GtkCalendarDisplayOptions)arg1);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1calendar_1set_1display_1options_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1cell_1layout_1clear
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1cell_1layout_1clear)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1cell_1layout_1clear_FUNC);
+/*
+	gtk_cell_layout_clear(arg0);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef void (*FPTR)(jint);
+		static FPTR fptr;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_cell_layout_clear_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_cell_layout_clear");
+			initialized = 1;
+		}
+		if (fptr) {
+			(*fptr)(arg0);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1cell_1layout_1clear_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1cell_1layout_1pack_1start
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1cell_1layout_1pack_1start)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jboolean arg2)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1cell_1layout_1pack_1start_FUNC);
+/*
+	gtk_cell_layout_pack_start(arg0, arg1, arg2);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef void (*FPTR)(jint, jint, jboolean);
+		static FPTR fptr;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_cell_layout_pack_start_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_cell_layout_pack_start");
+			initialized = 1;
+		}
+		if (fptr) {
+			(*fptr)(arg0, arg1, arg2);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1cell_1layout_1pack_1start_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1cell_1renderer_1get_1size
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1cell_1renderer_1get_1size)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jobject arg2, jintArray arg3, jintArray arg4, jintArray arg5, jintArray arg6)
+{
+	GdkRectangle _arg2, *lparg2=NULL;
+	jint *lparg3=NULL;
+	jint *lparg4=NULL;
+	jint *lparg5=NULL;
+	jint *lparg6=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1cell_1renderer_1get_1size_FUNC);
+	if (arg2) if ((lparg2 = &_arg2) == NULL) goto fail;
+	if (arg3) if ((lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL)) == NULL) goto fail;
+	if (arg4) if ((lparg4 = (*env)->GetIntArrayElements(env, arg4, NULL)) == NULL) goto fail;
+	if (arg5) if ((lparg5 = (*env)->GetIntArrayElements(env, arg5, NULL)) == NULL) goto fail;
+	if (arg6) if ((lparg6 = (*env)->GetIntArrayElements(env, arg6, NULL)) == NULL) goto fail;
+	gtk_cell_renderer_get_size((GtkCellRenderer *)arg0, (GtkWidget *)arg1, (GdkRectangle *)lparg2, (gint *)lparg3, (gint *)lparg4, (gint *)lparg5, (gint *)lparg6);
+fail:
+	if (arg6 && lparg6) (*env)->ReleaseIntArrayElements(env, arg6, lparg6, 0);
+	if (arg5 && lparg5) (*env)->ReleaseIntArrayElements(env, arg5, lparg5, 0);
+	if (arg4 && lparg4) (*env)->ReleaseIntArrayElements(env, arg4, lparg4, 0);
+	if (arg3 && lparg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0);
+	if (arg2 && lparg2) setGdkRectangleFields(env, arg2, lparg2);
+	OS_NATIVE_EXIT(env, that, _1gtk_1cell_1renderer_1get_1size_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1cell_1renderer_1pixbuf_1new
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1cell_1renderer_1pixbuf_1new)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1cell_1renderer_1pixbuf_1new_FUNC);
+	rc = (jint)gtk_cell_renderer_pixbuf_new();
+	OS_NATIVE_EXIT(env, that, _1gtk_1cell_1renderer_1pixbuf_1new_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1cell_1renderer_1text_1new
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1cell_1renderer_1text_1new)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1cell_1renderer_1text_1new_FUNC);
+	rc = (jint)gtk_cell_renderer_text_new();
+	OS_NATIVE_EXIT(env, that, _1gtk_1cell_1renderer_1text_1new_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1cell_1renderer_1toggle_1new
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1cell_1renderer_1toggle_1new)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1cell_1renderer_1toggle_1new_FUNC);
+	rc = (jint)gtk_cell_renderer_toggle_new();
+	OS_NATIVE_EXIT(env, that, _1gtk_1cell_1renderer_1toggle_1new_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1check_1button_1new
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1check_1button_1new)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1check_1button_1new_FUNC);
+	rc = (jint)gtk_check_button_new();
+	OS_NATIVE_EXIT(env, that, _1gtk_1check_1button_1new_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1check_1menu_1item_1get_1active
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1gtk_1check_1menu_1item_1get_1active)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1check_1menu_1item_1get_1active_FUNC);
+	rc = (jboolean)gtk_check_menu_item_get_active((GtkCheckMenuItem *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1check_1menu_1item_1get_1active_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1check_1menu_1item_1new_1with_1label
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1check_1menu_1item_1new_1with_1label)
+	(JNIEnv *env, jclass that, jbyteArray arg0)
+{
+	jbyte *lparg0=NULL;
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1check_1menu_1item_1new_1with_1label_FUNC);
+	if (arg0) if ((lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL)) == NULL) goto fail;
+	rc = (jint)gtk_check_menu_item_new_with_label((const gchar *)lparg0);
+fail:
+	if (arg0 && lparg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1check_1menu_1item_1new_1with_1label_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1check_1menu_1item_1set_1active
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1check_1menu_1item_1set_1active)
+	(JNIEnv *env, jclass that, jint arg0, jboolean arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1check_1menu_1item_1set_1active_FUNC);
+	gtk_check_menu_item_set_active((GtkCheckMenuItem *)arg0, (gboolean)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1check_1menu_1item_1set_1active_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1check_1version
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1check_1version)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1check_1version_FUNC);
+	rc = (jint)gtk_check_version(arg0, arg1, arg2);
+	OS_NATIVE_EXIT(env, that, _1gtk_1check_1version_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1clipboard_1clear
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1clipboard_1clear)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1clipboard_1clear_FUNC);
+	gtk_clipboard_clear((GtkClipboard *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1clipboard_1clear_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1clipboard_1get
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1clipboard_1get)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1clipboard_1get_FUNC);
+	rc = (jint)gtk_clipboard_get((GdkAtom)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1clipboard_1get_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1clipboard_1set_1with_1data
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1gtk_1clipboard_1set_1with_1data)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4, jint arg5)
+{
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1clipboard_1set_1with_1data_FUNC);
+	rc = (jboolean)gtk_clipboard_set_with_data((GtkClipboard *)arg0, (const GtkTargetEntry *)arg1, (guint)arg2, (GtkClipboardGetFunc)arg3, (GtkClipboardClearFunc)arg4, (GObject *)arg5);
+	OS_NATIVE_EXIT(env, that, _1gtk_1clipboard_1set_1with_1data_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1clipboard_1wait_1for_1contents
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1clipboard_1wait_1for_1contents)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1clipboard_1wait_1for_1contents_FUNC);
+	rc = (jint)gtk_clipboard_wait_for_contents((GtkClipboard *)arg0, (GdkAtom)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1clipboard_1wait_1for_1contents_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1color_1selection_1dialog_1new
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1color_1selection_1dialog_1new)
+	(JNIEnv *env, jclass that, jbyteArray arg0)
+{
+	jbyte *lparg0=NULL;
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1color_1selection_1dialog_1new_FUNC);
+	if (arg0) if ((lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL)) == NULL) goto fail;
+	rc = (jint)gtk_color_selection_dialog_new((const gchar *)lparg0);
+fail:
+	if (arg0 && lparg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1color_1selection_1dialog_1new_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1color_1selection_1get_1current_1color
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1color_1selection_1get_1current_1color)
+	(JNIEnv *env, jclass that, jint arg0, jobject arg1)
+{
+	GdkColor _arg1, *lparg1=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1color_1selection_1get_1current_1color_FUNC);
+	if (arg1) if ((lparg1 = &_arg1) == NULL) goto fail;
+	gtk_color_selection_get_current_color((GtkColorSelection *)arg0, (GdkColor *)lparg1);
+fail:
+	if (arg1 && lparg1) setGdkColorFields(env, arg1, lparg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1color_1selection_1get_1current_1color_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1color_1selection_1set_1current_1color
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1color_1selection_1set_1current_1color)
+	(JNIEnv *env, jclass that, jint arg0, jobject arg1)
+{
+	GdkColor _arg1, *lparg1=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1color_1selection_1set_1current_1color_FUNC);
+	if (arg1) if ((lparg1 = getGdkColorFields(env, arg1, &_arg1)) == NULL) goto fail;
+	gtk_color_selection_set_current_color((GtkColorSelection *)arg0, (GdkColor *)lparg1);
+fail:
+	OS_NATIVE_EXIT(env, that, _1gtk_1color_1selection_1set_1current_1color_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1color_1selection_1set_1has_1palette
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1color_1selection_1set_1has_1palette)
+	(JNIEnv *env, jclass that, jint arg0, jboolean arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1color_1selection_1set_1has_1palette_FUNC);
+	gtk_color_selection_set_has_palette((GtkColorSelection *)arg0, arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1color_1selection_1set_1has_1palette_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1combo_1box_1entry_1new_1text
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1combo_1box_1entry_1new_1text)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1combo_1box_1entry_1new_1text_FUNC);
+/*
+	rc = (jint)gtk_combo_box_entry_new_text();
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jint (*FPTR)();
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_combo_box_entry_new_text_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_combo_box_entry_new_text");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jint)(*fptr)();
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1combo_1box_1entry_1new_1text_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1combo_1box_1get_1active
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1combo_1box_1get_1active)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1combo_1box_1get_1active_FUNC);
+/*
+	rc = (jint)gtk_combo_box_get_active(arg0);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jint (*FPTR)(jint);
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_combo_box_get_active_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_combo_box_get_active");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jint)(*fptr)(arg0);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1combo_1box_1get_1active_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1combo_1box_1get_1model
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1combo_1box_1get_1model)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1combo_1box_1get_1model_FUNC);
+/*
+	rc = (jint)gtk_combo_box_get_model(arg0);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jint (*FPTR)(jint);
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_combo_box_get_model_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_combo_box_get_model");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jint)(*fptr)(arg0);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1combo_1box_1get_1model_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1combo_1box_1insert_1text
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1combo_1box_1insert_1text)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jbyteArray arg2)
+{
+	jbyte *lparg2=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1combo_1box_1insert_1text_FUNC);
+	if (arg2) if ((lparg2 = (*env)->GetByteArrayElements(env, arg2, NULL)) == NULL) goto fail;
+/*
+	gtk_combo_box_insert_text(arg0, arg1, lparg2);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef void (*FPTR)(jint, jint, jbyte *);
+		static FPTR fptr;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_combo_box_insert_text_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_combo_box_insert_text");
+			initialized = 1;
+		}
+		if (fptr) {
+			(*fptr)(arg0, arg1, lparg2);
+		}
+	}
+fail:
+	if (arg2 && lparg2) (*env)->ReleaseByteArrayElements(env, arg2, lparg2, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1combo_1box_1insert_1text_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1combo_1box_1new_1text
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1combo_1box_1new_1text)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1combo_1box_1new_1text_FUNC);
+/*
+	rc = (jint)gtk_combo_box_new_text();
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jint (*FPTR)();
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_combo_box_new_text_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_combo_box_new_text");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jint)(*fptr)();
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1combo_1box_1new_1text_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1combo_1box_1popdown
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1combo_1box_1popdown)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1combo_1box_1popdown_FUNC);
+/*
+	gtk_combo_box_popdown(arg0);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef void (*FPTR)(jint);
+		static FPTR fptr;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_combo_box_popdown_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_combo_box_popdown");
+			initialized = 1;
+		}
+		if (fptr) {
+			(*fptr)(arg0);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1combo_1box_1popdown_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1combo_1box_1popup
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1combo_1box_1popup)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1combo_1box_1popup_FUNC);
+/*
+	gtk_combo_box_popup(arg0);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef void (*FPTR)(jint);
+		static FPTR fptr;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_combo_box_popup_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_combo_box_popup");
+			initialized = 1;
+		}
+		if (fptr) {
+			(*fptr)(arg0);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1combo_1box_1popup_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1combo_1box_1remove_1text
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1combo_1box_1remove_1text)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1combo_1box_1remove_1text_FUNC);
+/*
+	gtk_combo_box_remove_text(arg0, arg1);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef void (*FPTR)(jint, jint);
+		static FPTR fptr;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_combo_box_remove_text_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_combo_box_remove_text");
+			initialized = 1;
+		}
+		if (fptr) {
+			(*fptr)(arg0, arg1);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1combo_1box_1remove_1text_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1combo_1box_1set_1active
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1combo_1box_1set_1active)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1combo_1box_1set_1active_FUNC);
+/*
+	gtk_combo_box_set_active(arg0, arg1);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef void (*FPTR)(jint, jint);
+		static FPTR fptr;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_combo_box_set_active_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_combo_box_set_active");
+			initialized = 1;
+		}
+		if (fptr) {
+			(*fptr)(arg0, arg1);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1combo_1box_1set_1active_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1combo_1box_1set_1focus_1on_1click
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1combo_1box_1set_1focus_1on_1click)
+	(JNIEnv *env, jclass that, jint arg0, jboolean arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1combo_1box_1set_1focus_1on_1click_FUNC);
+/*
+	gtk_combo_box_set_focus_on_click(arg0, arg1);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef void (*FPTR)(jint, jboolean);
+		static FPTR fptr;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_combo_box_set_focus_on_click_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_combo_box_set_focus_on_click");
+			initialized = 1;
+		}
+		if (fptr) {
+			(*fptr)(arg0, arg1);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1combo_1box_1set_1focus_1on_1click_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1combo_1disable_1activate
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1combo_1disable_1activate)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1combo_1disable_1activate_FUNC);
+	gtk_combo_disable_activate((GtkCombo *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1combo_1disable_1activate_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1combo_1new
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1combo_1new)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1combo_1new_FUNC);
+	rc = (jint)gtk_combo_new();
+	OS_NATIVE_EXIT(env, that, _1gtk_1combo_1new_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1combo_1set_1case_1sensitive
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1combo_1set_1case_1sensitive)
+	(JNIEnv *env, jclass that, jint arg0, jboolean arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1combo_1set_1case_1sensitive_FUNC);
+	gtk_combo_set_case_sensitive((GtkCombo *)arg0, (gboolean)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1combo_1set_1case_1sensitive_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1combo_1set_1popdown_1strings
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1combo_1set_1popdown_1strings)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1combo_1set_1popdown_1strings_FUNC);
+	gtk_combo_set_popdown_strings((GtkCombo *)arg0, (GList *)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1combo_1set_1popdown_1strings_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1container_1add
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1container_1add)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1container_1add_FUNC);
+	gtk_container_add((GtkContainer *)arg0, (GtkWidget *)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1container_1add_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1container_1forall
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1container_1forall)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1container_1forall_FUNC);
+	gtk_container_forall((GtkContainer *)arg0, (GtkCallback)arg1, (gpointer)arg2);
+	OS_NATIVE_EXIT(env, that, _1gtk_1container_1forall_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1container_1get_1border_1width
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1container_1get_1border_1width)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1container_1get_1border_1width_FUNC);
+	rc = (jint)gtk_container_get_border_width((GtkContainer *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1container_1get_1border_1width_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1container_1get_1children
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1container_1get_1children)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1container_1get_1children_FUNC);
+	rc = (jint)gtk_container_get_children((GtkContainer *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1container_1get_1children_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1container_1remove
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1container_1remove)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1container_1remove_FUNC);
+	gtk_container_remove((GtkContainer *)arg0, (GtkWidget *)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1container_1remove_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1container_1resize_1children
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1container_1resize_1children)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1container_1resize_1children_FUNC);
+	gtk_container_resize_children((GtkContainer *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1container_1resize_1children_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1container_1set_1border_1width
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1container_1set_1border_1width)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1container_1set_1border_1width_FUNC);
+	gtk_container_set_border_width((GtkContainer *)arg0, (guint)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1container_1set_1border_1width_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1dialog_1add_1button
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1dialog_1add_1button)
+	(JNIEnv *env, jclass that, jint arg0, jbyteArray arg1, jint arg2)
+{
+	jbyte *lparg1=NULL;
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1dialog_1add_1button_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	rc = (jint)gtk_dialog_add_button((GtkDialog *)arg0, (const gchar *)lparg1, (gint)arg2);
+fail:
+	if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1dialog_1add_1button_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1dialog_1run
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1dialog_1run)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1dialog_1run_FUNC);
+	rc = (jint)gtk_dialog_run((GtkDialog *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1dialog_1run_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1drag_1begin
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1drag_1begin)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1drag_1begin_FUNC);
+	rc = (jint)gtk_drag_begin((GtkWidget *)arg0, (GtkTargetList *)arg1, (GdkDragAction)arg2, (gint)arg3, (GdkEvent *)arg4);
+	OS_NATIVE_EXIT(env, that, _1gtk_1drag_1begin_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1drag_1check_1threshold
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1gtk_1drag_1check_1threshold)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4)
+{
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1drag_1check_1threshold_FUNC);
+	rc = (jboolean)gtk_drag_check_threshold((GtkWidget *)arg0, (gint)arg1, (gint)arg2, (gint)arg3, (gint)arg4);
+	OS_NATIVE_EXIT(env, that, _1gtk_1drag_1check_1threshold_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1drag_1dest_1find_1target
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1drag_1dest_1find_1target)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1drag_1dest_1find_1target_FUNC);
+	rc = (jint)gtk_drag_dest_find_target((GtkWidget *)arg0, (GdkDragContext *)arg1, (GtkTargetList *)arg2);
+	OS_NATIVE_EXIT(env, that, _1gtk_1drag_1dest_1find_1target_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1drag_1dest_1set
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1drag_1dest_1set)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1drag_1dest_1set_FUNC);
+	gtk_drag_dest_set((GtkWidget *)arg0, (GtkDestDefaults)arg1, (const GtkTargetEntry *)arg2, (gint)arg3, (GdkDragAction)arg4);
+	OS_NATIVE_EXIT(env, that, _1gtk_1drag_1dest_1set_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1drag_1dest_1unset
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1drag_1dest_1unset)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1drag_1dest_1unset_FUNC);
+	gtk_drag_dest_unset((GtkWidget *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1drag_1dest_1unset_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1drag_1finish
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1drag_1finish)
+	(JNIEnv *env, jclass that, jint arg0, jboolean arg1, jboolean arg2, jint arg3)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1drag_1finish_FUNC);
+	gtk_drag_finish((GdkDragContext *)arg0, (gboolean)arg1, (gboolean)arg2, (guint32)arg3);
+	OS_NATIVE_EXIT(env, that, _1gtk_1drag_1finish_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1drag_1get_1data
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1drag_1get_1data)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1drag_1get_1data_FUNC);
+	gtk_drag_get_data((GtkWidget *)arg0, (GdkDragContext *)arg1, (GdkAtom)arg2, (guint32)arg3);
+	OS_NATIVE_EXIT(env, that, _1gtk_1drag_1get_1data_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1drag_1set_1icon_1pixbuf
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1drag_1set_1icon_1pixbuf)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1drag_1set_1icon_1pixbuf_FUNC);
+	gtk_drag_set_icon_pixbuf((GdkDragContext *)arg0, (GdkPixbuf *)arg1, arg2, arg3);
+	OS_NATIVE_EXIT(env, that, _1gtk_1drag_1set_1icon_1pixbuf_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1drawing_1area_1new
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1drawing_1area_1new)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1drawing_1area_1new_FUNC);
+	rc = (jint)gtk_drawing_area_new();
+	OS_NATIVE_EXIT(env, that, _1gtk_1drawing_1area_1new_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1editable_1copy_1clipboard
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1editable_1copy_1clipboard)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1editable_1copy_1clipboard_FUNC);
+	gtk_editable_copy_clipboard((GtkEditable *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1editable_1copy_1clipboard_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1editable_1cut_1clipboard
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1editable_1cut_1clipboard)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1editable_1cut_1clipboard_FUNC);
+	gtk_editable_cut_clipboard((GtkEditable *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1editable_1cut_1clipboard_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1editable_1delete_1selection
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1editable_1delete_1selection)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1editable_1delete_1selection_FUNC);
+	gtk_editable_delete_selection((GtkEditable *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1editable_1delete_1selection_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1editable_1delete_1text
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1editable_1delete_1text)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1editable_1delete_1text_FUNC);
+	gtk_editable_delete_text((GtkEditable *)arg0, (gint)arg1, (gint)arg2);
+	OS_NATIVE_EXIT(env, that, _1gtk_1editable_1delete_1text_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1editable_1get_1chars
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1editable_1get_1chars)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1editable_1get_1chars_FUNC);
+	rc = (jint)gtk_editable_get_chars((GtkEditable *)arg0, (gint)arg1, (gint)arg2);
+	OS_NATIVE_EXIT(env, that, _1gtk_1editable_1get_1chars_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1editable_1get_1editable
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1gtk_1editable_1get_1editable)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1editable_1get_1editable_FUNC);
+	rc = (jboolean)gtk_editable_get_editable((GtkEditable *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1editable_1get_1editable_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1editable_1get_1position
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1editable_1get_1position)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1editable_1get_1position_FUNC);
+	rc = (jint)gtk_editable_get_position((GtkEditable *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1editable_1get_1position_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1editable_1get_1selection_1bounds
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1gtk_1editable_1get_1selection_1bounds)
+	(JNIEnv *env, jclass that, jint arg0, jintArray arg1, jintArray arg2)
+{
+	jint *lparg1=NULL;
+	jint *lparg2=NULL;
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1editable_1get_1selection_1bounds_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	if (arg2) if ((lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL)) == NULL) goto fail;
+	rc = (jboolean)gtk_editable_get_selection_bounds((GtkEditable *)arg0, (gint *)lparg1, (gint *)lparg2);
+fail:
+	if (arg2 && lparg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
+	if (arg1 && lparg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1editable_1get_1selection_1bounds_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1editable_1insert_1text
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1editable_1insert_1text)
+	(JNIEnv *env, jclass that, jint arg0, jbyteArray arg1, jint arg2, jintArray arg3)
+{
+	jbyte *lparg1=NULL;
+	jint *lparg3=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1editable_1insert_1text_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	if (arg3) if ((lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL)) == NULL) goto fail;
+	gtk_editable_insert_text((GtkEditable *)arg0, (gchar *)lparg1, (gint)arg2, (gint *)lparg3);
+fail:
+	if (arg3 && lparg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0);
+	if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1editable_1insert_1text_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1editable_1paste_1clipboard
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1editable_1paste_1clipboard)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1editable_1paste_1clipboard_FUNC);
+	gtk_editable_paste_clipboard((GtkEditable *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1editable_1paste_1clipboard_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1editable_1select_1region
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1editable_1select_1region)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1editable_1select_1region_FUNC);
+	gtk_editable_select_region((GtkEditable *)arg0, (gint)arg1, (gint)arg2);
+	OS_NATIVE_EXIT(env, that, _1gtk_1editable_1select_1region_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1editable_1set_1editable
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1editable_1set_1editable)
+	(JNIEnv *env, jclass that, jint arg0, jboolean arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1editable_1set_1editable_FUNC);
+	gtk_editable_set_editable((GtkEditable *)arg0, (gboolean)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1editable_1set_1editable_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1editable_1set_1position
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1editable_1set_1position)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1editable_1set_1position_FUNC);
+	gtk_editable_set_position((GtkEditable *)arg0, (gint)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1editable_1set_1position_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1entry_1get_1invisible_1char
+JNIEXPORT jchar JNICALL OS_NATIVE(_1gtk_1entry_1get_1invisible_1char)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jchar rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1entry_1get_1invisible_1char_FUNC);
+	rc = (jchar)gtk_entry_get_invisible_char((GtkEntry *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1entry_1get_1invisible_1char_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1entry_1get_1layout
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1entry_1get_1layout)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1entry_1get_1layout_FUNC);
+	rc = (jint)gtk_entry_get_layout((GtkEntry *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1entry_1get_1layout_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1entry_1get_1layout_1offsets
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1entry_1get_1layout_1offsets)
+	(JNIEnv *env, jclass that, jint arg0, jintArray arg1, jintArray arg2)
+{
+	jint *lparg1=NULL;
+	jint *lparg2=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1entry_1get_1layout_1offsets_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	if (arg2) if ((lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL)) == NULL) goto fail;
+	gtk_entry_get_layout_offsets((GtkEntry *)arg0, lparg1, lparg2);
+fail:
+	if (arg2 && lparg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
+	if (arg1 && lparg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1entry_1get_1layout_1offsets_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1entry_1get_1max_1length
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1entry_1get_1max_1length)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1entry_1get_1max_1length_FUNC);
+	rc = (jint)gtk_entry_get_max_length((GtkEntry *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1entry_1get_1max_1length_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1entry_1get_1text
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1entry_1get_1text)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1entry_1get_1text_FUNC);
+	rc = (jint)gtk_entry_get_text((GtkEntry *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1entry_1get_1text_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1entry_1get_1visibility
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1gtk_1entry_1get_1visibility)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1entry_1get_1visibility_FUNC);
+	rc = (jboolean)gtk_entry_get_visibility((GtkEntry *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1entry_1get_1visibility_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1entry_1new
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1entry_1new)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1entry_1new_FUNC);
+	rc = (jint)gtk_entry_new();
+	OS_NATIVE_EXIT(env, that, _1gtk_1entry_1new_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1entry_1set_1activates_1default
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1entry_1set_1activates_1default)
+	(JNIEnv *env, jclass that, jint arg0, jboolean arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1entry_1set_1activates_1default_FUNC);
+	gtk_entry_set_activates_default((GtkEntry *)arg0, (gboolean)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1entry_1set_1activates_1default_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1entry_1set_1alignment
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1entry_1set_1alignment)
+	(JNIEnv *env, jclass that, jint arg0, jfloat arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1entry_1set_1alignment_FUNC);
+/*
+	gtk_entry_set_alignment((GtkEntry *)arg0, (gfloat)arg1);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef void (*FPTR)(GtkEntry *, gfloat);
+		static FPTR fptr;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_entry_set_alignment_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_entry_set_alignment");
+			initialized = 1;
+		}
+		if (fptr) {
+			(*fptr)((GtkEntry *)arg0, (gfloat)arg1);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1entry_1set_1alignment_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1entry_1set_1has_1frame
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1entry_1set_1has_1frame)
+	(JNIEnv *env, jclass that, jint arg0, jboolean arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1entry_1set_1has_1frame_FUNC);
+	gtk_entry_set_has_frame((GtkEntry *)arg0, (gboolean)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1entry_1set_1has_1frame_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1entry_1set_1invisible_1char
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1entry_1set_1invisible_1char)
+	(JNIEnv *env, jclass that, jint arg0, jchar arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1entry_1set_1invisible_1char_FUNC);
+	gtk_entry_set_invisible_char((GtkEntry *)arg0, (gint)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1entry_1set_1invisible_1char_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1entry_1set_1max_1length
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1entry_1set_1max_1length)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1entry_1set_1max_1length_FUNC);
+	gtk_entry_set_max_length((GtkEntry *)arg0, (gint)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1entry_1set_1max_1length_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1entry_1set_1text
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1entry_1set_1text)
+	(JNIEnv *env, jclass that, jint arg0, jbyteArray arg1)
+{
+	jbyte *lparg1=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1entry_1set_1text_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	gtk_entry_set_text((GtkEntry *)arg0, (const gchar *)lparg1);
+fail:
+	if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1entry_1set_1text_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1entry_1set_1visibility
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1entry_1set_1visibility)
+	(JNIEnv *env, jclass that, jint arg0, jboolean arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1entry_1set_1visibility_FUNC);
+	gtk_entry_set_visibility((GtkEntry *)arg0, (gboolean)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1entry_1set_1visibility_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1entry_1text_1index_1to_1layout_1index
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1entry_1text_1index_1to_1layout_1index)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1entry_1text_1index_1to_1layout_1index_FUNC);
+/*
+	rc = (jint)gtk_entry_text_index_to_layout_index(arg0, arg1);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jint (*FPTR)(jint, jint);
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_entry_text_index_to_layout_index_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_entry_text_index_to_layout_index");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jint)(*fptr)(arg0, arg1);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1entry_1text_1index_1to_1layout_1index_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1enumerate_1printers
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1enumerate_1printers)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jboolean arg3)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1enumerate_1printers_FUNC);
+/*
+	gtk_enumerate_printers(arg0, (gpointer)arg1, (GDestroyNotify)arg2, (gboolean)arg3);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef void (*FPTR)(jint, gpointer, GDestroyNotify, gboolean);
+		static FPTR fptr;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_enumerate_printers_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_enumerate_printers");
+			initialized = 1;
+		}
+		if (fptr) {
+			(*fptr)(arg0, (gpointer)arg1, (GDestroyNotify)arg2, (gboolean)arg3);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1enumerate_1printers_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1events_1pending
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1events_1pending)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1events_1pending_FUNC);
+	rc = (jint)gtk_events_pending();
+	OS_NATIVE_EXIT(env, that, _1gtk_1events_1pending_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1expander_1get_1expanded
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1gtk_1expander_1get_1expanded)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1expander_1get_1expanded_FUNC);
+/*
+	rc = (jboolean)gtk_expander_get_expanded(arg0);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jboolean (*FPTR)(jint);
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_expander_get_expanded_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_expander_get_expanded");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jboolean)(*fptr)(arg0);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1expander_1get_1expanded_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1expander_1get_1label_1widget
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1expander_1get_1label_1widget)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1expander_1get_1label_1widget_FUNC);
+/*
+	rc = (jint)gtk_expander_get_label_widget(arg0);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jint (*FPTR)(jint);
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_expander_get_label_widget_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_expander_get_label_widget");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jint)(*fptr)(arg0);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1expander_1get_1label_1widget_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1expander_1new
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1expander_1new)
+	(JNIEnv *env, jclass that, jbyteArray arg0)
+{
+	jbyte *lparg0=NULL;
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1expander_1new_FUNC);
+	if (arg0) if ((lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL)) == NULL) goto fail;
+/*
+	rc = (jint)gtk_expander_new((const gchar *)lparg0);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jint (*FPTR)(const gchar *);
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_expander_new_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_expander_new");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jint)(*fptr)((const gchar *)lparg0);
+		}
+	}
+fail:
+	if (arg0 && lparg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1expander_1new_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1expander_1set_1expanded
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1expander_1set_1expanded)
+	(JNIEnv *env, jclass that, jint arg0, jboolean arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1expander_1set_1expanded_FUNC);
+/*
+	gtk_expander_set_expanded(arg0, arg1);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef void (*FPTR)(jint, jboolean);
+		static FPTR fptr;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_expander_set_expanded_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_expander_set_expanded");
+			initialized = 1;
+		}
+		if (fptr) {
+			(*fptr)(arg0, arg1);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1expander_1set_1expanded_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1expander_1set_1label
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1expander_1set_1label)
+	(JNIEnv *env, jclass that, jint arg0, jbyteArray arg1)
+{
+	jbyte *lparg1=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1expander_1set_1label_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+/*
+	gtk_expander_set_label(arg0, (const gchar *)lparg1);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef void (*FPTR)(jint, const gchar *);
+		static FPTR fptr;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_expander_set_label_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_expander_set_label");
+			initialized = 1;
+		}
+		if (fptr) {
+			(*fptr)(arg0, (const gchar *)lparg1);
+		}
+	}
+fail:
+	if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1expander_1set_1label_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1expander_1set_1label_1widget
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1expander_1set_1label_1widget)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1expander_1set_1label_1widget_FUNC);
+/*
+	gtk_expander_set_label_widget(arg0, arg1);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef void (*FPTR)(jint, jint);
+		static FPTR fptr;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_expander_set_label_widget_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_expander_set_label_widget");
+			initialized = 1;
+		}
+		if (fptr) {
+			(*fptr)(arg0, arg1);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1expander_1set_1label_1widget_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1file_1chooser_1add_1filter
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1file_1chooser_1add_1filter)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1file_1chooser_1add_1filter_FUNC);
+/*
+	gtk_file_chooser_add_filter(arg0, arg1);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef void (*FPTR)(jint, jint);
+		static FPTR fptr;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_file_chooser_add_filter_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_file_chooser_add_filter");
+			initialized = 1;
+		}
+		if (fptr) {
+			(*fptr)(arg0, arg1);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1file_1chooser_1add_1filter_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1file_1chooser_1get_1current_1folder
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1file_1chooser_1get_1current_1folder)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1file_1chooser_1get_1current_1folder_FUNC);
+/*
+	rc = (jint)gtk_file_chooser_get_current_folder(arg0);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jint (*FPTR)(jint);
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_file_chooser_get_current_folder_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_file_chooser_get_current_folder");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jint)(*fptr)(arg0);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1file_1chooser_1get_1current_1folder_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1file_1chooser_1get_1filename
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1file_1chooser_1get_1filename)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1file_1chooser_1get_1filename_FUNC);
+/*
+	rc = (jint)gtk_file_chooser_get_filename(arg0);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jint (*FPTR)(jint);
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_file_chooser_get_filename_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_file_chooser_get_filename");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jint)(*fptr)(arg0);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1file_1chooser_1get_1filename_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1file_1chooser_1get_1filenames
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1file_1chooser_1get_1filenames)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1file_1chooser_1get_1filenames_FUNC);
+/*
+	rc = (jint)gtk_file_chooser_get_filenames(arg0);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jint (*FPTR)(jint);
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_file_chooser_get_filenames_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_file_chooser_get_filenames");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jint)(*fptr)(arg0);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1file_1chooser_1get_1filenames_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1file_1chooser_1get_1filter
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1file_1chooser_1get_1filter)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1file_1chooser_1get_1filter_FUNC);
+/*
+	rc = (jint)gtk_file_chooser_get_filter(arg0);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jint (*FPTR)(jint);
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_file_chooser_get_filter_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_file_chooser_get_filter");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jint)(*fptr)(arg0);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1file_1chooser_1get_1filter_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1file_1chooser_1set_1current_1folder
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1file_1chooser_1set_1current_1folder)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1file_1chooser_1set_1current_1folder_FUNC);
+/*
+	gtk_file_chooser_set_current_folder(arg0, arg1);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef void (*FPTR)(jint, jint);
+		static FPTR fptr;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_file_chooser_set_current_folder_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_file_chooser_set_current_folder");
+			initialized = 1;
+		}
+		if (fptr) {
+			(*fptr)(arg0, arg1);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1file_1chooser_1set_1current_1folder_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1file_1chooser_1set_1current_1name
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1file_1chooser_1set_1current_1name)
+	(JNIEnv *env, jclass that, jint arg0, jbyteArray arg1)
+{
+	jbyte *lparg1=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1file_1chooser_1set_1current_1name_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+/*
+	gtk_file_chooser_set_current_name(arg0, lparg1);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef void (*FPTR)(jint, jbyte *);
+		static FPTR fptr;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_file_chooser_set_current_name_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_file_chooser_set_current_name");
+			initialized = 1;
+		}
+		if (fptr) {
+			(*fptr)(arg0, lparg1);
+		}
+	}
+fail:
+	if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1file_1chooser_1set_1current_1name_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1file_1chooser_1set_1do_1overwrite_1confirmation
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1file_1chooser_1set_1do_1overwrite_1confirmation)
+	(JNIEnv *env, jclass that, jint arg0, jboolean arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1file_1chooser_1set_1do_1overwrite_1confirmation_FUNC);
+/*
+	gtk_file_chooser_set_do_overwrite_confirmation(arg0, arg1);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef void (*FPTR)(jint, jboolean);
+		static FPTR fptr;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_file_chooser_set_do_overwrite_confirmation_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_file_chooser_set_do_overwrite_confirmation");
+			initialized = 1;
+		}
+		if (fptr) {
+			(*fptr)(arg0, arg1);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1file_1chooser_1set_1do_1overwrite_1confirmation_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1file_1chooser_1set_1extra_1widget
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1file_1chooser_1set_1extra_1widget)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1file_1chooser_1set_1extra_1widget_FUNC);
+/*
+	gtk_file_chooser_set_extra_widget(arg0, arg1);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef void (*FPTR)(jint, jint);
+		static FPTR fptr;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_file_chooser_set_extra_widget_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_file_chooser_set_extra_widget");
+			initialized = 1;
+		}
+		if (fptr) {
+			(*fptr)(arg0, arg1);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1file_1chooser_1set_1extra_1widget_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1file_1chooser_1set_1filename
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1file_1chooser_1set_1filename)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1file_1chooser_1set_1filename_FUNC);
+/*
+	gtk_file_chooser_set_filename(arg0, arg1);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef void (*FPTR)(jint, jint);
+		static FPTR fptr;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_file_chooser_set_filename_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_file_chooser_set_filename");
+			initialized = 1;
+		}
+		if (fptr) {
+			(*fptr)(arg0, arg1);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1file_1chooser_1set_1filename_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1file_1chooser_1set_1filter
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1file_1chooser_1set_1filter)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1file_1chooser_1set_1filter_FUNC);
+/*
+	gtk_file_chooser_set_filter(arg0, arg1);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef void (*FPTR)(jint, jint);
+		static FPTR fptr;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_file_chooser_set_filter_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_file_chooser_set_filter");
+			initialized = 1;
+		}
+		if (fptr) {
+			(*fptr)(arg0, arg1);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1file_1chooser_1set_1filter_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1file_1chooser_1set_1select_1multiple
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1file_1chooser_1set_1select_1multiple)
+	(JNIEnv *env, jclass that, jint arg0, jboolean arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1file_1chooser_1set_1select_1multiple_FUNC);
+/*
+	gtk_file_chooser_set_select_multiple(arg0, arg1);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef void (*FPTR)(jint, jboolean);
+		static FPTR fptr;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_file_chooser_set_select_multiple_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_file_chooser_set_select_multiple");
+			initialized = 1;
+		}
+		if (fptr) {
+			(*fptr)(arg0, arg1);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1file_1chooser_1set_1select_1multiple_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1file_1filter_1add_1pattern
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1file_1filter_1add_1pattern)
+	(JNIEnv *env, jclass that, jint arg0, jbyteArray arg1)
+{
+	jbyte *lparg1=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1file_1filter_1add_1pattern_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+/*
+	gtk_file_filter_add_pattern(arg0, lparg1);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef void (*FPTR)(jint, jbyte *);
+		static FPTR fptr;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_file_filter_add_pattern_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_file_filter_add_pattern");
+			initialized = 1;
+		}
+		if (fptr) {
+			(*fptr)(arg0, lparg1);
+		}
+	}
+fail:
+	if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1file_1filter_1add_1pattern_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1file_1filter_1get_1name
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1file_1filter_1get_1name)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1file_1filter_1get_1name_FUNC);
+/*
+	rc = (jint)gtk_file_filter_get_name(arg0);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jint (*FPTR)(jint);
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_file_filter_get_name_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_file_filter_get_name");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jint)(*fptr)(arg0);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1file_1filter_1get_1name_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1file_1filter_1new
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1file_1filter_1new)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1file_1filter_1new_FUNC);
+/*
+	rc = (jint)gtk_file_filter_new();
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jint (*FPTR)();
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_file_filter_new_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_file_filter_new");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jint)(*fptr)();
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1file_1filter_1new_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1file_1filter_1set_1name
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1file_1filter_1set_1name)
+	(JNIEnv *env, jclass that, jint arg0, jbyteArray arg1)
+{
+	jbyte *lparg1=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1file_1filter_1set_1name_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+/*
+	gtk_file_filter_set_name(arg0, lparg1);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef void (*FPTR)(jint, jbyte *);
+		static FPTR fptr;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_file_filter_set_name_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_file_filter_set_name");
+			initialized = 1;
+		}
+		if (fptr) {
+			(*fptr)(arg0, lparg1);
+		}
+	}
+fail:
+	if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1file_1filter_1set_1name_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1file_1selection_1get_1filename
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1file_1selection_1get_1filename)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1file_1selection_1get_1filename_FUNC);
+	rc = (jint)gtk_file_selection_get_filename((GtkFileSelection *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1file_1selection_1get_1filename_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1file_1selection_1get_1selections
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1file_1selection_1get_1selections)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1file_1selection_1get_1selections_FUNC);
+	rc = (jint)gtk_file_selection_get_selections((GtkFileSelection *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1file_1selection_1get_1selections_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1file_1selection_1hide_1fileop_1buttons
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1file_1selection_1hide_1fileop_1buttons)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1file_1selection_1hide_1fileop_1buttons_FUNC);
+	gtk_file_selection_hide_fileop_buttons((GtkFileSelection *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1file_1selection_1hide_1fileop_1buttons_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1file_1selection_1new
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1file_1selection_1new)
+	(JNIEnv *env, jclass that, jbyteArray arg0)
+{
+	jbyte *lparg0=NULL;
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1file_1selection_1new_FUNC);
+	if (arg0) if ((lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL)) == NULL) goto fail;
+	rc = (jint)gtk_file_selection_new((const gchar *)lparg0);
+fail:
+	if (arg0 && lparg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1file_1selection_1new_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1file_1selection_1set_1filename
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1file_1selection_1set_1filename)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1file_1selection_1set_1filename_FUNC);
+	gtk_file_selection_set_filename((GtkFileSelection *)arg0, (const gchar *)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1file_1selection_1set_1filename_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1file_1selection_1set_1select_1multiple
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1file_1selection_1set_1select_1multiple)
+	(JNIEnv *env, jclass that, jint arg0, jboolean arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1file_1selection_1set_1select_1multiple_FUNC);
+	gtk_file_selection_set_select_multiple((GtkFileSelection *)arg0, (gboolean)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1file_1selection_1set_1select_1multiple_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1fixed_1move
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1fixed_1move)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1fixed_1move_FUNC);
+	gtk_fixed_move((GtkFixed *)arg0, (GtkWidget *)arg1, (gint)arg2, (gint)arg3);
+	OS_NATIVE_EXIT(env, that, _1gtk_1fixed_1move_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1fixed_1new
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1fixed_1new)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1fixed_1new_FUNC);
+	rc = (jint)gtk_fixed_new();
+	OS_NATIVE_EXIT(env, that, _1gtk_1fixed_1new_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1fixed_1set_1has_1window
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1fixed_1set_1has_1window)
+	(JNIEnv *env, jclass that, jint arg0, jboolean arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1fixed_1set_1has_1window_FUNC);
+	gtk_fixed_set_has_window((GtkFixed *)arg0, (gboolean)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1fixed_1set_1has_1window_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1font_1selection_1dialog_1get_1font_1name
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1font_1selection_1dialog_1get_1font_1name)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1font_1selection_1dialog_1get_1font_1name_FUNC);
+	rc = (jint)gtk_font_selection_dialog_get_font_name((GtkFontSelectionDialog *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1font_1selection_1dialog_1get_1font_1name_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1font_1selection_1dialog_1new
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1font_1selection_1dialog_1new)
+	(JNIEnv *env, jclass that, jbyteArray arg0)
+{
+	jbyte *lparg0=NULL;
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1font_1selection_1dialog_1new_FUNC);
+	if (arg0) if ((lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL)) == NULL) goto fail;
+	rc = (jint)gtk_font_selection_dialog_new((const gchar *)lparg0);
+fail:
+	if (arg0 && lparg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1font_1selection_1dialog_1new_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1font_1selection_1dialog_1set_1font_1name
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1gtk_1font_1selection_1dialog_1set_1font_1name)
+	(JNIEnv *env, jclass that, jint arg0, jbyteArray arg1)
+{
+	jbyte *lparg1=NULL;
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1font_1selection_1dialog_1set_1font_1name_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	rc = (jboolean)gtk_font_selection_dialog_set_font_name((GtkFontSelectionDialog *)arg0, (const gchar *)lparg1);
+fail:
+	if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1font_1selection_1dialog_1set_1font_1name_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1frame_1get_1label_1widget
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1frame_1get_1label_1widget)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1frame_1get_1label_1widget_FUNC);
+	rc = (jint)gtk_frame_get_label_widget((GtkFrame *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1frame_1get_1label_1widget_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1frame_1new
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1frame_1new)
+	(JNIEnv *env, jclass that, jbyteArray arg0)
+{
+	jbyte *lparg0=NULL;
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1frame_1new_FUNC);
+	if (arg0) if ((lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL)) == NULL) goto fail;
+	rc = (jint)gtk_frame_new((const gchar *)lparg0);
+fail:
+	if (arg0 && lparg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1frame_1new_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1frame_1set_1label
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1frame_1set_1label)
+	(JNIEnv *env, jclass that, jint arg0, jbyteArray arg1)
+{
+	jbyte *lparg1=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1frame_1set_1label_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	gtk_frame_set_label((GtkFrame *)arg0, (const gchar *)lparg1);
+fail:
+	if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1frame_1set_1label_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1frame_1set_1label_1widget
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1frame_1set_1label_1widget)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1frame_1set_1label_1widget_FUNC);
+	gtk_frame_set_label_widget((GtkFrame *)arg0, (GtkWidget *)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1frame_1set_1label_1widget_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1frame_1set_1shadow_1type
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1frame_1set_1shadow_1type)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1frame_1set_1shadow_1type_FUNC);
+	gtk_frame_set_shadow_type((GtkFrame *)arg0, (GtkShadowType)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1frame_1set_1shadow_1type_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1get_1current_1event
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1get_1current_1event)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1get_1current_1event_FUNC);
+	rc = (jint)gtk_get_current_event();
+	OS_NATIVE_EXIT(env, that, _1gtk_1get_1current_1event_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1get_1current_1event_1state
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1gtk_1get_1current_1event_1state)
+	(JNIEnv *env, jclass that, jintArray arg0)
+{
+	jint *lparg0=NULL;
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1get_1current_1event_1state_FUNC);
+	if (arg0) if ((lparg0 = (*env)->GetIntArrayElements(env, arg0, NULL)) == NULL) goto fail;
+	rc = (jboolean)gtk_get_current_event_state((GdkModifierType*)lparg0);
+fail:
+	if (arg0 && lparg0) (*env)->ReleaseIntArrayElements(env, arg0, lparg0, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1get_1current_1event_1state_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1get_1current_1event_1time
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1get_1current_1event_1time)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1get_1current_1event_1time_FUNC);
+	rc = (jint)gtk_get_current_event_time();
+	OS_NATIVE_EXIT(env, that, _1gtk_1get_1current_1event_1time_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1get_1default_1language
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1get_1default_1language)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1get_1default_1language_FUNC);
+	rc = (jint)gtk_get_default_language();
+	OS_NATIVE_EXIT(env, that, _1gtk_1get_1default_1language_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1get_1event_1widget
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1get_1event_1widget)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1get_1event_1widget_FUNC);
+	rc = (jint)gtk_get_event_widget((GdkEvent *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1get_1event_1widget_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1grab_1add
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1grab_1add)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1grab_1add_FUNC);
+	gtk_grab_add((GtkWidget *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1grab_1add_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1grab_1get_1current
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1grab_1get_1current)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1grab_1get_1current_FUNC);
+	rc = (jint)gtk_grab_get_current();
+	OS_NATIVE_EXIT(env, that, _1gtk_1grab_1get_1current_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1grab_1remove
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1grab_1remove)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1grab_1remove_FUNC);
+	gtk_grab_remove((GtkWidget *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1grab_1remove_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1hbox_1new
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1hbox_1new)
+	(JNIEnv *env, jclass that, jboolean arg0, jint arg1)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1hbox_1new_FUNC);
+	rc = (jint)gtk_hbox_new((gboolean)arg0, (gint)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1hbox_1new_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1hscale_1new
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1hscale_1new)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1hscale_1new_FUNC);
+	rc = (jint)gtk_hscale_new((GtkAdjustment *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1hscale_1new_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1hscrollbar_1new
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1hscrollbar_1new)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1hscrollbar_1new_FUNC);
+	rc = (jint)gtk_hscrollbar_new((GtkAdjustment *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1hscrollbar_1new_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1hseparator_1new
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1hseparator_1new)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1hseparator_1new_FUNC);
+	rc = (jint)gtk_hseparator_new();
+	OS_NATIVE_EXIT(env, that, _1gtk_1hseparator_1new_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1icon_1factory_1lookup_1default
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1icon_1factory_1lookup_1default)
+	(JNIEnv *env, jclass that, jbyteArray arg0)
+{
+	jbyte *lparg0=NULL;
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1icon_1factory_1lookup_1default_FUNC);
+	if (arg0) if ((lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL)) == NULL) goto fail;
+	rc = (jint)gtk_icon_factory_lookup_default((const gchar *)lparg0);
+fail:
+	if (arg0 && lparg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1icon_1factory_1lookup_1default_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1icon_1set_1render_1icon
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1icon_1set_1render_1icon)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4, jint arg5, jint arg6)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1icon_1set_1render_1icon_FUNC);
+	rc = (jint)gtk_icon_set_render_icon((GtkIconSet *)arg0, (GtkStyle *)arg1, (GtkTextDirection)arg2, (GtkStateType)arg3, (GtkIconSize)arg4, (GtkWidget *)arg5, (const char *)arg6);
+	OS_NATIVE_EXIT(env, that, _1gtk_1icon_1set_1render_1icon_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1icon_1source_1free
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1icon_1source_1free)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1icon_1source_1free_FUNC);
+	gtk_icon_source_free((GtkIconSource *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1icon_1source_1free_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1icon_1source_1new
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1icon_1source_1new)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1icon_1source_1new_FUNC);
+	rc = (jint)gtk_icon_source_new();
+	OS_NATIVE_EXIT(env, that, _1gtk_1icon_1source_1new_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1icon_1source_1set_1pixbuf
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1icon_1source_1set_1pixbuf)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1icon_1source_1set_1pixbuf_FUNC);
+	gtk_icon_source_set_pixbuf((GtkIconSource *)arg0, (GdkPixbuf *)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1icon_1source_1set_1pixbuf_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1im_1context_1filter_1keypress
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1gtk_1im_1context_1filter_1keypress)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1im_1context_1filter_1keypress_FUNC);
+	rc = (jboolean)gtk_im_context_filter_keypress((GtkIMContext *)arg0, (GdkEventKey *)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1im_1context_1filter_1keypress_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1im_1context_1focus_1in
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1im_1context_1focus_1in)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1im_1context_1focus_1in_FUNC);
+	gtk_im_context_focus_in((GtkIMContext *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1im_1context_1focus_1in_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1im_1context_1focus_1out
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1im_1context_1focus_1out)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1im_1context_1focus_1out_FUNC);
+	gtk_im_context_focus_out((GtkIMContext *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1im_1context_1focus_1out_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1im_1context_1get_1preedit_1string
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1im_1context_1get_1preedit_1string)
+	(JNIEnv *env, jclass that, jint arg0, jintArray arg1, jintArray arg2, jintArray arg3)
+{
+	jint *lparg1=NULL;
+	jint *lparg2=NULL;
+	jint *lparg3=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1im_1context_1get_1preedit_1string_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	if (arg2) if ((lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL)) == NULL) goto fail;
+	if (arg3) if ((lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL)) == NULL) goto fail;
+	gtk_im_context_get_preedit_string((GtkIMContext *)arg0, (gchar **)lparg1, (PangoAttrList **)lparg2, (gint *)lparg3);
+fail:
+	if (arg3 && lparg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0);
+	if (arg2 && lparg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
+	if (arg1 && lparg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1im_1context_1get_1preedit_1string_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1im_1context_1get_1type
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1im_1context_1get_1type)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1im_1context_1get_1type_FUNC);
+	rc = (jint)gtk_im_context_get_type();
+	OS_NATIVE_EXIT(env, that, _1gtk_1im_1context_1get_1type_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1im_1context_1reset
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1im_1context_1reset)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1im_1context_1reset_FUNC);
+	gtk_im_context_reset((GtkIMContext *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1im_1context_1reset_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1im_1context_1set_1client_1window
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1im_1context_1set_1client_1window)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1im_1context_1set_1client_1window_FUNC);
+	gtk_im_context_set_client_window((GtkIMContext *)arg0, (GdkWindow *)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1im_1context_1set_1client_1window_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1im_1context_1set_1cursor_1location
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1im_1context_1set_1cursor_1location)
+	(JNIEnv *env, jclass that, jint arg0, jobject arg1)
+{
+	GdkRectangle _arg1, *lparg1=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1im_1context_1set_1cursor_1location_FUNC);
+	if (arg1) if ((lparg1 = getGdkRectangleFields(env, arg1, &_arg1)) == NULL) goto fail;
+	gtk_im_context_set_cursor_location((GtkIMContext *)arg0, (GdkRectangle *)lparg1);
+fail:
+	OS_NATIVE_EXIT(env, that, _1gtk_1im_1context_1set_1cursor_1location_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1im_1multicontext_1append_1menuitems
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1im_1multicontext_1append_1menuitems)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1im_1multicontext_1append_1menuitems_FUNC);
+	gtk_im_multicontext_append_menuitems((GtkIMMulticontext *)arg0, (GtkMenuShell *)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1im_1multicontext_1append_1menuitems_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1im_1multicontext_1new
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1im_1multicontext_1new)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1im_1multicontext_1new_FUNC);
+	rc = (jint)gtk_im_multicontext_new();
+	OS_NATIVE_EXIT(env, that, _1gtk_1im_1multicontext_1new_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1image_1menu_1item_1new_1with_1label
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1image_1menu_1item_1new_1with_1label)
+	(JNIEnv *env, jclass that, jbyteArray arg0)
+{
+	jbyte *lparg0=NULL;
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1image_1menu_1item_1new_1with_1label_FUNC);
+	if (arg0) if ((lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL)) == NULL) goto fail;
+	rc = (jint)gtk_image_menu_item_new_with_label((const gchar *)lparg0);
+fail:
+	if (arg0 && lparg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1image_1menu_1item_1new_1with_1label_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1image_1menu_1item_1set_1image
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1image_1menu_1item_1set_1image)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1image_1menu_1item_1set_1image_FUNC);
+	gtk_image_menu_item_set_image((GtkImageMenuItem *)arg0, (GtkWidget *)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1image_1menu_1item_1set_1image_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1image_1new
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1image_1new)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1image_1new_FUNC);
+	rc = (jint)gtk_image_new();
+	OS_NATIVE_EXIT(env, that, _1gtk_1image_1new_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1image_1new_1from_1pixbuf
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1image_1new_1from_1pixbuf)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1image_1new_1from_1pixbuf_FUNC);
+	rc = (jint)gtk_image_new_from_pixbuf((GdkPixbuf *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1image_1new_1from_1pixbuf_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1image_1new_1from_1pixmap
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1image_1new_1from_1pixmap)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1image_1new_1from_1pixmap_FUNC);
+	rc = (jint)gtk_image_new_from_pixmap((GdkPixmap *)arg0, (GdkBitmap *)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1image_1new_1from_1pixmap_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1image_1set_1from_1pixbuf
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1image_1set_1from_1pixbuf)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1image_1set_1from_1pixbuf_FUNC);
+	gtk_image_set_from_pixbuf((GtkImage *)arg0, (GdkPixbuf *)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1image_1set_1from_1pixbuf_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1image_1set_1from_1pixmap
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1image_1set_1from_1pixmap)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1image_1set_1from_1pixmap_FUNC);
+	gtk_image_set_from_pixmap((GtkImage *)arg0, (GdkBitmap *)arg1, (GdkBitmap *)arg2);
+	OS_NATIVE_EXIT(env, that, _1gtk_1image_1set_1from_1pixmap_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1init_1check
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1gtk_1init_1check)
+	(JNIEnv *env, jclass that, jintArray arg0, jintArray arg1)
+{
+	jint *lparg0=NULL;
+	jint *lparg1=NULL;
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1init_1check_FUNC);
+	if (arg0) if ((lparg0 = (*env)->GetIntArrayElements(env, arg0, NULL)) == NULL) goto fail;
+	if (arg1) if ((lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	rc = (jboolean)gtk_init_check((int *)lparg0, (char ***)lparg1);
+fail:
+	if (arg1 && lparg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0);
+	if (arg0 && lparg0) (*env)->ReleaseIntArrayElements(env, arg0, lparg0, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1init_1check_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1label_1get_1layout
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1label_1get_1layout)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1label_1get_1layout_FUNC);
+	rc = (jint)gtk_label_get_layout((GtkLabel *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1label_1get_1layout_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1label_1get_1mnemonic_1keyval
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1label_1get_1mnemonic_1keyval)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1label_1get_1mnemonic_1keyval_FUNC);
+	rc = (jint)gtk_label_get_mnemonic_keyval((GtkLabel *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1label_1get_1mnemonic_1keyval_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1label_1new
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1label_1new)
+	(JNIEnv *env, jclass that, jbyteArray arg0)
+{
+	jbyte *lparg0=NULL;
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1label_1new_FUNC);
+	if (arg0) if ((lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL)) == NULL) goto fail;
+	rc = (jint)gtk_label_new((const gchar *)lparg0);
+fail:
+	if (arg0 && lparg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1label_1new_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1label_1new_1with_1mnemonic
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1label_1new_1with_1mnemonic)
+	(JNIEnv *env, jclass that, jbyteArray arg0)
+{
+	jbyte *lparg0=NULL;
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1label_1new_1with_1mnemonic_FUNC);
+	if (arg0) if ((lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL)) == NULL) goto fail;
+	rc = (jint)gtk_label_new_with_mnemonic((const gchar *)lparg0);
+fail:
+	if (arg0 && lparg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1label_1new_1with_1mnemonic_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1label_1set_1attributes
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1label_1set_1attributes)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1label_1set_1attributes_FUNC);
+	gtk_label_set_attributes((GtkLabel *)arg0, (PangoAttrList *)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1label_1set_1attributes_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1label_1set_1justify
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1label_1set_1justify)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1label_1set_1justify_FUNC);
+	gtk_label_set_justify((GtkLabel *)arg0, (GtkJustification)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1label_1set_1justify_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1label_1set_1line_1wrap
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1label_1set_1line_1wrap)
+	(JNIEnv *env, jclass that, jint arg0, jboolean arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1label_1set_1line_1wrap_FUNC);
+	gtk_label_set_line_wrap((GtkLabel *)arg0, (gboolean)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1label_1set_1line_1wrap_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1label_1set_1line_1wrap_1mode
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1label_1set_1line_1wrap_1mode)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1label_1set_1line_1wrap_1mode_FUNC);
+/*
+	gtk_label_set_line_wrap_mode(arg0, arg1);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef void (*FPTR)(jint, jint);
+		static FPTR fptr;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_label_set_line_wrap_mode_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_label_set_line_wrap_mode");
+			initialized = 1;
+		}
+		if (fptr) {
+			(*fptr)(arg0, arg1);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1label_1set_1line_1wrap_1mode_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1label_1set_1text__II
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1label_1set_1text__II)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1label_1set_1text__II_FUNC);
+	gtk_label_set_text((GtkLabel *)arg0, (const gchar *)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1label_1set_1text__II_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1label_1set_1text__I_3B
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1label_1set_1text__I_3B)
+	(JNIEnv *env, jclass that, jint arg0, jbyteArray arg1)
+{
+	jbyte *lparg1=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1label_1set_1text__I_3B_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	gtk_label_set_text((GtkLabel *)arg0, (const gchar *)lparg1);
+fail:
+	if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1label_1set_1text__I_3B_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1label_1set_1text_1with_1mnemonic
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1label_1set_1text_1with_1mnemonic)
+	(JNIEnv *env, jclass that, jint arg0, jbyteArray arg1)
+{
+	jbyte *lparg1=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1label_1set_1text_1with_1mnemonic_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	gtk_label_set_text_with_mnemonic((GtkLabel *)arg0, (const gchar *)lparg1);
+fail:
+	if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1label_1set_1text_1with_1mnemonic_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1list_1append_1items
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1list_1append_1items)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1list_1append_1items_FUNC);
+	gtk_list_append_items((GtkList *)arg0, (GList *)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1list_1append_1items_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1list_1clear_1items
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1list_1clear_1items)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1list_1clear_1items_FUNC);
+	gtk_list_clear_items((GtkList *)arg0, arg1, arg2);
+	OS_NATIVE_EXIT(env, that, _1gtk_1list_1clear_1items_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1list_1insert_1items
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1list_1insert_1items)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1list_1insert_1items_FUNC);
+	gtk_list_insert_items((GtkList *)arg0, (GList *)arg1, arg2);
+	OS_NATIVE_EXIT(env, that, _1gtk_1list_1insert_1items_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1list_1item_1new_1with_1label
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1list_1item_1new_1with_1label)
+	(JNIEnv *env, jclass that, jbyteArray arg0)
+{
+	jbyte *lparg0=NULL;
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1list_1item_1new_1with_1label_FUNC);
+	if (arg0) if ((lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL)) == NULL) goto fail;
+	rc = (jint)gtk_list_item_new_with_label((const gchar *)lparg0);
+fail:
+	if (arg0 && lparg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1list_1item_1new_1with_1label_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1list_1remove_1items
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1list_1remove_1items)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1list_1remove_1items_FUNC);
+	gtk_list_remove_items((GtkList *)arg0, (GList *)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1list_1remove_1items_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1list_1select_1item
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1list_1select_1item)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1list_1select_1item_FUNC);
+	gtk_list_select_item((GtkList *)arg0, arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1list_1select_1item_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1list_1store_1append
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1list_1store_1append)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1list_1store_1append_FUNC);
+	gtk_list_store_append((GtkListStore *)arg0, (GtkTreeIter *)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1list_1store_1append_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1list_1store_1clear
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1list_1store_1clear)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1list_1store_1clear_FUNC);
+	gtk_list_store_clear((GtkListStore *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1list_1store_1clear_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1list_1store_1insert
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1list_1store_1insert)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1list_1store_1insert_FUNC);
+	gtk_list_store_insert((GtkListStore *)arg0, (GtkTreeIter *)arg1, (gint)arg2);
+	OS_NATIVE_EXIT(env, that, _1gtk_1list_1store_1insert_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1list_1store_1newv
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1list_1store_1newv)
+	(JNIEnv *env, jclass that, jint arg0, jintArray arg1)
+{
+	jint *lparg1=NULL;
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1list_1store_1newv_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	rc = (jint)gtk_list_store_newv((gint)arg0, (GType *)lparg1);
+fail:
+	if (arg1 && lparg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1list_1store_1newv_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1list_1store_1remove
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1list_1store_1remove)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1list_1store_1remove_FUNC);
+	gtk_list_store_remove((GtkListStore *)arg0, (GtkTreeIter *)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1list_1store_1remove_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1list_1store_1set__IIIII
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1list_1store_1set__IIIII)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1list_1store_1set__IIIII_FUNC);
+	gtk_list_store_set((GtkListStore *)arg0, (GtkTreeIter *)arg1, arg2, arg3, arg4);
+	OS_NATIVE_EXIT(env, that, _1gtk_1list_1store_1set__IIIII_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1list_1store_1set__IIIJI
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1list_1store_1set__IIIJI)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jlong arg3, jint arg4)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1list_1store_1set__IIIJI_FUNC);
+	gtk_list_store_set((GtkListStore *)arg0, (GtkTreeIter *)arg1, arg2, arg3, arg4);
+	OS_NATIVE_EXIT(env, that, _1gtk_1list_1store_1set__IIIJI_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1list_1store_1set__IIILorg_eclipse_swt_internal_gtk_GdkColor_2I
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1list_1store_1set__IIILorg_eclipse_swt_internal_gtk_GdkColor_2I)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jobject arg3, jint arg4)
+{
+	GdkColor _arg3, *lparg3=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1list_1store_1set__IIILorg_eclipse_swt_internal_gtk_GdkColor_2I_FUNC);
+	if (arg3) if ((lparg3 = getGdkColorFields(env, arg3, &_arg3)) == NULL) goto fail;
+	gtk_list_store_set((GtkListStore *)arg0, (GtkTreeIter *)arg1, arg2, lparg3, arg4);
+fail:
+	OS_NATIVE_EXIT(env, that, _1gtk_1list_1store_1set__IIILorg_eclipse_swt_internal_gtk_GdkColor_2I_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1list_1store_1set__IIIZI
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1list_1store_1set__IIIZI)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jboolean arg3, jint arg4)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1list_1store_1set__IIIZI_FUNC);
+	gtk_list_store_set((GtkListStore *)arg0, (GtkTreeIter *)arg1, arg2, arg3, arg4);
+	OS_NATIVE_EXIT(env, that, _1gtk_1list_1store_1set__IIIZI_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1list_1store_1set__III_3BI
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1list_1store_1set__III_3BI)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jbyteArray arg3, jint arg4)
+{
+	jbyte *lparg3=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1list_1store_1set__III_3BI_FUNC);
+	if (arg3) if ((lparg3 = (*env)->GetByteArrayElements(env, arg3, NULL)) == NULL) goto fail;
+	gtk_list_store_set((GtkListStore *)arg0, (GtkTreeIter *)arg1, arg2, lparg3, arg4);
+fail:
+	if (arg3 && lparg3) (*env)->ReleaseByteArrayElements(env, arg3, lparg3, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1list_1store_1set__III_3BI_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1list_1unselect_1all
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1list_1unselect_1all)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1list_1unselect_1all_FUNC);
+	gtk_list_unselect_all((GtkList *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1list_1unselect_1all_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1list_1unselect_1item
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1list_1unselect_1item)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1list_1unselect_1item_FUNC);
+	gtk_list_unselect_item((GtkList *)arg0, arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1list_1unselect_1item_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1main
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1main)
+	(JNIEnv *env, jclass that)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1main_FUNC);
+	gtk_main();
+	OS_NATIVE_EXIT(env, that, _1gtk_1main_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1main_1do_1event
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1main_1do_1event)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1main_1do_1event_FUNC);
+	gtk_main_do_event((GdkEvent *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1main_1do_1event_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1main_1iteration
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1main_1iteration)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1main_1iteration_FUNC);
+	rc = (jint)gtk_main_iteration();
+	OS_NATIVE_EXIT(env, that, _1gtk_1main_1iteration_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1major_1version
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1major_1version)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1major_1version_FUNC);
+	rc = (jint)gtk_major_version;
+	OS_NATIVE_EXIT(env, that, _1gtk_1major_1version_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1menu_1bar_1new
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1menu_1bar_1new)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1menu_1bar_1new_FUNC);
+	rc = (jint)gtk_menu_bar_new();
+	OS_NATIVE_EXIT(env, that, _1gtk_1menu_1bar_1new_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1menu_1item_1get_1submenu
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1menu_1item_1get_1submenu)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1menu_1item_1get_1submenu_FUNC);
+	rc = (jint)gtk_menu_item_get_submenu((GtkMenuItem *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1menu_1item_1get_1submenu_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1menu_1item_1remove_1submenu
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1menu_1item_1remove_1submenu)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1menu_1item_1remove_1submenu_FUNC);
+	gtk_menu_item_remove_submenu((GtkMenuItem *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1menu_1item_1remove_1submenu_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1menu_1item_1set_1submenu
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1menu_1item_1set_1submenu)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1menu_1item_1set_1submenu_FUNC);
+	gtk_menu_item_set_submenu((GtkMenuItem *)arg0, (GtkWidget *)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1menu_1item_1set_1submenu_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1menu_1new
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1menu_1new)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1menu_1new_FUNC);
+	rc = (jint)gtk_menu_new();
+	OS_NATIVE_EXIT(env, that, _1gtk_1menu_1new_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1menu_1popdown
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1menu_1popdown)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1menu_1popdown_FUNC);
+	gtk_menu_popdown((GtkMenu *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1menu_1popdown_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1menu_1popup
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1menu_1popup)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4, jint arg5, jint arg6)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1menu_1popup_FUNC);
+	gtk_menu_popup((GtkMenu *)arg0, (GtkWidget *)arg1, (GtkWidget *)arg2, (GtkMenuPositionFunc)arg3, (gpointer)arg4, (guint)arg5, (guint32)arg6);
+	OS_NATIVE_EXIT(env, that, _1gtk_1menu_1popup_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1menu_1shell_1deactivate
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1menu_1shell_1deactivate)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1menu_1shell_1deactivate_FUNC);
+	gtk_menu_shell_deactivate((GtkMenuShell *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1menu_1shell_1deactivate_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1menu_1shell_1insert
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1menu_1shell_1insert)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1menu_1shell_1insert_FUNC);
+	gtk_menu_shell_insert((GtkMenuShell *)arg0, (GtkWidget *)arg1, (gint)arg2);
+	OS_NATIVE_EXIT(env, that, _1gtk_1menu_1shell_1insert_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1menu_1shell_1select_1item
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1menu_1shell_1select_1item)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1menu_1shell_1select_1item_FUNC);
+	gtk_menu_shell_select_item((GtkMenuShell *)arg0, (GtkWidget *)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1menu_1shell_1select_1item_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1menu_1shell_1set_1take_1focus
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1menu_1shell_1set_1take_1focus)
+	(JNIEnv *env, jclass that, jint arg0, jboolean arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1menu_1shell_1set_1take_1focus_FUNC);
+/*
+	gtk_menu_shell_set_take_focus((GtkMenuShell *)arg0, (gboolean)arg1);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef void (*FPTR)(GtkMenuShell *, gboolean);
+		static FPTR fptr;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_menu_shell_set_take_focus_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_menu_shell_set_take_focus");
+			initialized = 1;
+		}
+		if (fptr) {
+			(*fptr)((GtkMenuShell *)arg0, (gboolean)arg1);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1menu_1shell_1set_1take_1focus_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1message_1dialog_1new
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1message_1dialog_1new)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jbyteArray arg4)
+{
+	jbyte *lparg4=NULL;
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1message_1dialog_1new_FUNC);
+	if (arg4) if ((lparg4 = (*env)->GetByteArrayElements(env, arg4, NULL)) == NULL) goto fail;
+	rc = (jint)gtk_message_dialog_new((GtkWindow *)arg0, (GtkDialogFlags)arg1, (GtkMessageType)arg2, (GtkButtonsType)arg3, (const gchar *)lparg4);
+fail:
+	if (arg4 && lparg4) (*env)->ReleaseByteArrayElements(env, arg4, lparg4, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1message_1dialog_1new_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1micro_1version
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1micro_1version)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1micro_1version_FUNC);
+	rc = (jint)gtk_micro_version;
+	OS_NATIVE_EXIT(env, that, _1gtk_1micro_1version_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1minor_1version
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1minor_1version)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1minor_1version_FUNC);
+	rc = (jint)gtk_minor_version;
+	OS_NATIVE_EXIT(env, that, _1gtk_1minor_1version_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1misc_1set_1alignment
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1misc_1set_1alignment)
+	(JNIEnv *env, jclass that, jint arg0, jfloat arg1, jfloat arg2)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1misc_1set_1alignment_FUNC);
+	gtk_misc_set_alignment((GtkMisc *)arg0, (gfloat)arg1, (gfloat)arg2);
+	OS_NATIVE_EXIT(env, that, _1gtk_1misc_1set_1alignment_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1notebook_1get_1current_1page
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1notebook_1get_1current_1page)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1notebook_1get_1current_1page_FUNC);
+	rc = (jint)gtk_notebook_get_current_page((GtkNotebook *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1notebook_1get_1current_1page_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1notebook_1get_1scrollable
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1gtk_1notebook_1get_1scrollable)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1notebook_1get_1scrollable_FUNC);
+	rc = (jboolean)gtk_notebook_get_scrollable((GtkNotebook *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1notebook_1get_1scrollable_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1notebook_1insert_1page
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1notebook_1insert_1page)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1notebook_1insert_1page_FUNC);
+	gtk_notebook_insert_page((GtkNotebook *)arg0, (GtkWidget *)arg1, (GtkWidget *)arg2, (gint)arg3);
+	OS_NATIVE_EXIT(env, that, _1gtk_1notebook_1insert_1page_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1notebook_1new
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1notebook_1new)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1notebook_1new_FUNC);
+	rc = (jint)gtk_notebook_new();
+	OS_NATIVE_EXIT(env, that, _1gtk_1notebook_1new_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1notebook_1next_1page
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1notebook_1next_1page)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1notebook_1next_1page_FUNC);
+	gtk_notebook_next_page((GtkNotebook *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1notebook_1next_1page_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1notebook_1prev_1page
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1notebook_1prev_1page)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1notebook_1prev_1page_FUNC);
+	gtk_notebook_prev_page((GtkNotebook *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1notebook_1prev_1page_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1notebook_1remove_1page
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1notebook_1remove_1page)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1notebook_1remove_1page_FUNC);
+	gtk_notebook_remove_page((GtkNotebook *)arg0, (gint)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1notebook_1remove_1page_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1notebook_1set_1current_1page
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1notebook_1set_1current_1page)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1notebook_1set_1current_1page_FUNC);
+	gtk_notebook_set_current_page((GtkNotebook *)arg0, (gint)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1notebook_1set_1current_1page_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1notebook_1set_1scrollable
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1notebook_1set_1scrollable)
+	(JNIEnv *env, jclass that, jint arg0, jboolean arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1notebook_1set_1scrollable_FUNC);
+	gtk_notebook_set_scrollable((GtkNotebook *)arg0, (gboolean)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1notebook_1set_1scrollable_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1notebook_1set_1show_1tabs
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1notebook_1set_1show_1tabs)
+	(JNIEnv *env, jclass that, jint arg0, jboolean arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1notebook_1set_1show_1tabs_FUNC);
+	gtk_notebook_set_show_tabs((GtkNotebook *)arg0, (gboolean)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1notebook_1set_1show_1tabs_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1notebook_1set_1tab_1pos
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1notebook_1set_1tab_1pos)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1notebook_1set_1tab_1pos_FUNC);
+	gtk_notebook_set_tab_pos((GtkNotebook *)arg0, (GtkPositionType)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1notebook_1set_1tab_1pos_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1object_1sink
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1object_1sink)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1object_1sink_FUNC);
+	gtk_object_sink((GtkObject *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1object_1sink_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1page_1setup_1get_1bottom_1margin
+JNIEXPORT jdouble JNICALL OS_NATIVE(_1gtk_1page_1setup_1get_1bottom_1margin)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	jdouble rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1page_1setup_1get_1bottom_1margin_FUNC);
+/*
+	rc = (jdouble)gtk_page_setup_get_bottom_margin(arg0, arg1);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jdouble (*FPTR)(jint, jint);
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_page_setup_get_bottom_margin_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_page_setup_get_bottom_margin");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jdouble)(*fptr)(arg0, arg1);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1page_1setup_1get_1bottom_1margin_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1page_1setup_1get_1left_1margin
+JNIEXPORT jdouble JNICALL OS_NATIVE(_1gtk_1page_1setup_1get_1left_1margin)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	jdouble rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1page_1setup_1get_1left_1margin_FUNC);
+/*
+	rc = (jdouble)gtk_page_setup_get_left_margin(arg0, arg1);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jdouble (*FPTR)(jint, jint);
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_page_setup_get_left_margin_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_page_setup_get_left_margin");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jdouble)(*fptr)(arg0, arg1);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1page_1setup_1get_1left_1margin_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1page_1setup_1get_1orientation
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1page_1setup_1get_1orientation)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1page_1setup_1get_1orientation_FUNC);
+/*
+	rc = (jint)gtk_page_setup_get_orientation(arg0);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jint (*FPTR)(jint);
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_page_setup_get_orientation_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_page_setup_get_orientation");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jint)(*fptr)(arg0);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1page_1setup_1get_1orientation_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1page_1setup_1get_1page_1height
+JNIEXPORT jdouble JNICALL OS_NATIVE(_1gtk_1page_1setup_1get_1page_1height)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	jdouble rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1page_1setup_1get_1page_1height_FUNC);
+/*
+	rc = (jdouble)gtk_page_setup_get_page_height(arg0, arg1);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jdouble (*FPTR)(jint, jint);
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_page_setup_get_page_height_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_page_setup_get_page_height");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jdouble)(*fptr)(arg0, arg1);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1page_1setup_1get_1page_1height_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1page_1setup_1get_1page_1width
+JNIEXPORT jdouble JNICALL OS_NATIVE(_1gtk_1page_1setup_1get_1page_1width)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	jdouble rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1page_1setup_1get_1page_1width_FUNC);
+/*
+	rc = (jdouble)gtk_page_setup_get_page_width(arg0, arg1);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jdouble (*FPTR)(jint, jint);
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_page_setup_get_page_width_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_page_setup_get_page_width");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jdouble)(*fptr)(arg0, arg1);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1page_1setup_1get_1page_1width_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1page_1setup_1get_1paper_1height
+JNIEXPORT jdouble JNICALL OS_NATIVE(_1gtk_1page_1setup_1get_1paper_1height)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	jdouble rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1page_1setup_1get_1paper_1height_FUNC);
+/*
+	rc = (jdouble)gtk_page_setup_get_paper_height(arg0, arg1);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jdouble (*FPTR)(jint, jint);
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_page_setup_get_paper_height_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_page_setup_get_paper_height");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jdouble)(*fptr)(arg0, arg1);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1page_1setup_1get_1paper_1height_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1page_1setup_1get_1paper_1size
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1page_1setup_1get_1paper_1size)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1page_1setup_1get_1paper_1size_FUNC);
+/*
+	rc = (jint)gtk_page_setup_get_paper_size(arg0);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jint (*FPTR)(jint);
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_page_setup_get_paper_size_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_page_setup_get_paper_size");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jint)(*fptr)(arg0);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1page_1setup_1get_1paper_1size_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1page_1setup_1get_1paper_1width
+JNIEXPORT jdouble JNICALL OS_NATIVE(_1gtk_1page_1setup_1get_1paper_1width)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	jdouble rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1page_1setup_1get_1paper_1width_FUNC);
+/*
+	rc = (jdouble)gtk_page_setup_get_paper_width(arg0, arg1);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jdouble (*FPTR)(jint, jint);
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_page_setup_get_paper_width_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_page_setup_get_paper_width");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jdouble)(*fptr)(arg0, arg1);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1page_1setup_1get_1paper_1width_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1page_1setup_1get_1right_1margin
+JNIEXPORT jdouble JNICALL OS_NATIVE(_1gtk_1page_1setup_1get_1right_1margin)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	jdouble rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1page_1setup_1get_1right_1margin_FUNC);
+/*
+	rc = (jdouble)gtk_page_setup_get_right_margin(arg0, arg1);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jdouble (*FPTR)(jint, jint);
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_page_setup_get_right_margin_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_page_setup_get_right_margin");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jdouble)(*fptr)(arg0, arg1);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1page_1setup_1get_1right_1margin_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1page_1setup_1get_1top_1margin
+JNIEXPORT jdouble JNICALL OS_NATIVE(_1gtk_1page_1setup_1get_1top_1margin)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	jdouble rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1page_1setup_1get_1top_1margin_FUNC);
+/*
+	rc = (jdouble)gtk_page_setup_get_top_margin(arg0, arg1);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jdouble (*FPTR)(jint, jint);
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_page_setup_get_top_margin_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_page_setup_get_top_margin");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jdouble)(*fptr)(arg0, arg1);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1page_1setup_1get_1top_1margin_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1page_1setup_1new
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1page_1setup_1new)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1page_1setup_1new_FUNC);
+/*
+	rc = (jint)gtk_page_setup_new();
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jint (*FPTR)();
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_page_setup_new_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_page_setup_new");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jint)(*fptr)();
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1page_1setup_1new_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1page_1setup_1set_1bottom_1margin
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1page_1setup_1set_1bottom_1margin)
+	(JNIEnv *env, jclass that, jint arg0, jdouble arg1, jint arg2)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1page_1setup_1set_1bottom_1margin_FUNC);
+/*
+	gtk_page_setup_set_bottom_margin(arg0, arg1, arg2);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef void (*FPTR)(jint, jdouble, jint);
+		static FPTR fptr;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_page_setup_set_bottom_margin_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_page_setup_set_bottom_margin");
+			initialized = 1;
+		}
+		if (fptr) {
+			(*fptr)(arg0, arg1, arg2);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1page_1setup_1set_1bottom_1margin_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1page_1setup_1set_1left_1margin
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1page_1setup_1set_1left_1margin)
+	(JNIEnv *env, jclass that, jint arg0, jdouble arg1, jint arg2)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1page_1setup_1set_1left_1margin_FUNC);
+/*
+	gtk_page_setup_set_left_margin(arg0, arg1, arg2);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef void (*FPTR)(jint, jdouble, jint);
+		static FPTR fptr;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_page_setup_set_left_margin_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_page_setup_set_left_margin");
+			initialized = 1;
+		}
+		if (fptr) {
+			(*fptr)(arg0, arg1, arg2);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1page_1setup_1set_1left_1margin_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1page_1setup_1set_1orientation
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1page_1setup_1set_1orientation)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1page_1setup_1set_1orientation_FUNC);
+/*
+	gtk_page_setup_set_orientation(arg0, arg1);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef void (*FPTR)(jint, jint);
+		static FPTR fptr;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_page_setup_set_orientation_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_page_setup_set_orientation");
+			initialized = 1;
+		}
+		if (fptr) {
+			(*fptr)(arg0, arg1);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1page_1setup_1set_1orientation_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1page_1setup_1set_1paper_1size
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1page_1setup_1set_1paper_1size)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1page_1setup_1set_1paper_1size_FUNC);
+/*
+	gtk_page_setup_set_paper_size(arg0, arg1);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef void (*FPTR)(jint, jint);
+		static FPTR fptr;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_page_setup_set_paper_size_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_page_setup_set_paper_size");
+			initialized = 1;
+		}
+		if (fptr) {
+			(*fptr)(arg0, arg1);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1page_1setup_1set_1paper_1size_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1page_1setup_1set_1right_1margin
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1page_1setup_1set_1right_1margin)
+	(JNIEnv *env, jclass that, jint arg0, jdouble arg1, jint arg2)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1page_1setup_1set_1right_1margin_FUNC);
+/*
+	gtk_page_setup_set_right_margin(arg0, arg1, arg2);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef void (*FPTR)(jint, jdouble, jint);
+		static FPTR fptr;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_page_setup_set_right_margin_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_page_setup_set_right_margin");
+			initialized = 1;
+		}
+		if (fptr) {
+			(*fptr)(arg0, arg1, arg2);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1page_1setup_1set_1right_1margin_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1page_1setup_1set_1top_1margin
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1page_1setup_1set_1top_1margin)
+	(JNIEnv *env, jclass that, jint arg0, jdouble arg1, jint arg2)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1page_1setup_1set_1top_1margin_FUNC);
+/*
+	gtk_page_setup_set_top_margin(arg0, arg1, arg2);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef void (*FPTR)(jint, jdouble, jint);
+		static FPTR fptr;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_page_setup_set_top_margin_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_page_setup_set_top_margin");
+			initialized = 1;
+		}
+		if (fptr) {
+			(*fptr)(arg0, arg1, arg2);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1page_1setup_1set_1top_1margin_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1paint_1arrow
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1paint_1arrow)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jobject arg4, jint arg5, jbyteArray arg6, jint arg7, jboolean arg8, jint arg9, jint arg10, jint arg11, jint arg12)
+{
+	GdkRectangle _arg4, *lparg4=NULL;
+	jbyte *lparg6=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1paint_1arrow_FUNC);
+	if (arg4) if ((lparg4 = getGdkRectangleFields(env, arg4, &_arg4)) == NULL) goto fail;
+	if (arg6) if ((lparg6 = (*env)->GetByteArrayElements(env, arg6, NULL)) == NULL) goto fail;
+	gtk_paint_arrow((GtkStyle *)arg0, (GdkWindow *)arg1, arg2, arg3, lparg4, (GtkWidget *)arg5, (const gchar *)lparg6, arg7, arg8, arg9, arg10, arg11, arg12);
+fail:
+	if (arg6 && lparg6) (*env)->ReleaseByteArrayElements(env, arg6, lparg6, 0);
+	if (arg4 && lparg4) setGdkRectangleFields(env, arg4, lparg4);
+	OS_NATIVE_EXIT(env, that, _1gtk_1paint_1arrow_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1paint_1box
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1paint_1box)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jobject arg4, jint arg5, jbyteArray arg6, jint arg7, jint arg8, jint arg9, jint arg10)
+{
+	GdkRectangle _arg4, *lparg4=NULL;
+	jbyte *lparg6=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1paint_1box_FUNC);
+	if (arg4) if ((lparg4 = getGdkRectangleFields(env, arg4, &_arg4)) == NULL) goto fail;
+	if (arg6) if ((lparg6 = (*env)->GetByteArrayElements(env, arg6, NULL)) == NULL) goto fail;
+	gtk_paint_box((GtkStyle *)arg0, (GdkWindow *)arg1, arg2, arg3, lparg4, (GtkWidget *)arg5, (const gchar *)lparg6, arg7, arg8, arg9, arg10);
+fail:
+	if (arg6 && lparg6) (*env)->ReleaseByteArrayElements(env, arg6, lparg6, 0);
+	if (arg4 && lparg4) setGdkRectangleFields(env, arg4, lparg4);
+	OS_NATIVE_EXIT(env, that, _1gtk_1paint_1box_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1paint_1box_1gap
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1paint_1box_1gap)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jobject arg4, jint arg5, jbyteArray arg6, jint arg7, jint arg8, jint arg9, jint arg10, jint arg11, jint arg12, jint arg13)
+{
+	GdkRectangle _arg4, *lparg4=NULL;
+	jbyte *lparg6=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1paint_1box_1gap_FUNC);
+	if (arg4) if ((lparg4 = getGdkRectangleFields(env, arg4, &_arg4)) == NULL) goto fail;
+	if (arg6) if ((lparg6 = (*env)->GetByteArrayElements(env, arg6, NULL)) == NULL) goto fail;
+	gtk_paint_box_gap((GtkStyle *)arg0, (GdkWindow *)arg1, arg2, arg3, lparg4, (GtkWidget *)arg5, (gchar *)lparg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13);
+fail:
+	if (arg6 && lparg6) (*env)->ReleaseByteArrayElements(env, arg6, lparg6, 0);
+	if (arg4 && lparg4) setGdkRectangleFields(env, arg4, lparg4);
+	OS_NATIVE_EXIT(env, that, _1gtk_1paint_1box_1gap_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1paint_1check
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1paint_1check)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jobject arg4, jint arg5, jbyteArray arg6, jint arg7, jint arg8, jint arg9, jint arg10)
+{
+	GdkRectangle _arg4, *lparg4=NULL;
+	jbyte *lparg6=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1paint_1check_FUNC);
+	if (arg4) if ((lparg4 = getGdkRectangleFields(env, arg4, &_arg4)) == NULL) goto fail;
+	if (arg6) if ((lparg6 = (*env)->GetByteArrayElements(env, arg6, NULL)) == NULL) goto fail;
+	gtk_paint_check((GtkStyle *)arg0, (GdkWindow *)arg1, arg2, arg3, lparg4, (GtkWidget *)arg5, (const gchar *)lparg6, arg7, arg8, arg9, arg10);
+fail:
+	if (arg6 && lparg6) (*env)->ReleaseByteArrayElements(env, arg6, lparg6, 0);
+	if (arg4 && lparg4) setGdkRectangleFields(env, arg4, lparg4);
+	OS_NATIVE_EXIT(env, that, _1gtk_1paint_1check_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1paint_1expander
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1paint_1expander)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jobject arg3, jint arg4, jbyteArray arg5, jint arg6, jint arg7, jint arg8)
+{
+	GdkRectangle _arg3, *lparg3=NULL;
+	jbyte *lparg5=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1paint_1expander_FUNC);
+	if (arg3) if ((lparg3 = getGdkRectangleFields(env, arg3, &_arg3)) == NULL) goto fail;
+	if (arg5) if ((lparg5 = (*env)->GetByteArrayElements(env, arg5, NULL)) == NULL) goto fail;
+	gtk_paint_expander((GtkStyle *)arg0, (GdkWindow *)arg1, arg2, lparg3, (GtkWidget *)arg4, (const gchar *)lparg5, arg6, arg7, arg8);
+fail:
+	if (arg5 && lparg5) (*env)->ReleaseByteArrayElements(env, arg5, lparg5, 0);
+	if (arg3 && lparg3) setGdkRectangleFields(env, arg3, lparg3);
+	OS_NATIVE_EXIT(env, that, _1gtk_1paint_1expander_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1paint_1extension
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1paint_1extension)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jobject arg4, jint arg5, jbyteArray arg6, jint arg7, jint arg8, jint arg9, jint arg10, jint arg11)
+{
+	GdkRectangle _arg4, *lparg4=NULL;
+	jbyte *lparg6=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1paint_1extension_FUNC);
+	if (arg4) if ((lparg4 = getGdkRectangleFields(env, arg4, &_arg4)) == NULL) goto fail;
+	if (arg6) if ((lparg6 = (*env)->GetByteArrayElements(env, arg6, NULL)) == NULL) goto fail;
+	gtk_paint_extension((GtkStyle *)arg0, (GdkWindow *)arg1, arg2, arg3, lparg4, (GtkWidget *)arg5, (gchar *)lparg6, arg7, arg8, arg9, arg10, arg11);
+fail:
+	if (arg6 && lparg6) (*env)->ReleaseByteArrayElements(env, arg6, lparg6, 0);
+	if (arg4 && lparg4) setGdkRectangleFields(env, arg4, lparg4);
+	OS_NATIVE_EXIT(env, that, _1gtk_1paint_1extension_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1paint_1flat_1box
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1paint_1flat_1box)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jobject arg4, jint arg5, jbyteArray arg6, jint arg7, jint arg8, jint arg9, jint arg10)
+{
+	GdkRectangle _arg4, *lparg4=NULL;
+	jbyte *lparg6=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1paint_1flat_1box_FUNC);
+	if (arg4) if ((lparg4 = getGdkRectangleFields(env, arg4, &_arg4)) == NULL) goto fail;
+	if (arg6) if ((lparg6 = (*env)->GetByteArrayElements(env, arg6, NULL)) == NULL) goto fail;
+	gtk_paint_flat_box((GtkStyle *)arg0, (GdkWindow *)arg1, arg2, arg3, lparg4, (GtkWidget *)arg5, (const gchar *)lparg6, arg7, arg8, arg9, arg10);
+fail:
+	if (arg6 && lparg6) (*env)->ReleaseByteArrayElements(env, arg6, lparg6, 0);
+	if (arg4 && lparg4) setGdkRectangleFields(env, arg4, lparg4);
+	OS_NATIVE_EXIT(env, that, _1gtk_1paint_1flat_1box_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1paint_1focus
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1paint_1focus)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jobject arg3, jint arg4, jbyteArray arg5, jint arg6, jint arg7, jint arg8, jint arg9)
+{
+	GdkRectangle _arg3, *lparg3=NULL;
+	jbyte *lparg5=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1paint_1focus_FUNC);
+	if (arg3) if ((lparg3 = getGdkRectangleFields(env, arg3, &_arg3)) == NULL) goto fail;
+	if (arg5) if ((lparg5 = (*env)->GetByteArrayElements(env, arg5, NULL)) == NULL) goto fail;
+	gtk_paint_focus((GtkStyle *)arg0, (GdkWindow *)arg1, arg2, lparg3, (GtkWidget *)arg4, (const gchar *)lparg5, arg6, arg7, arg8, arg9);
+fail:
+	if (arg5 && lparg5) (*env)->ReleaseByteArrayElements(env, arg5, lparg5, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1paint_1focus_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1paint_1handle
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1paint_1handle)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jobject arg4, jint arg5, jbyteArray arg6, jint arg7, jint arg8, jint arg9, jint arg10, jint arg11)
+{
+	GdkRectangle _arg4, *lparg4=NULL;
+	jbyte *lparg6=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1paint_1handle_FUNC);
+	if (arg4) if ((lparg4 = getGdkRectangleFields(env, arg4, &_arg4)) == NULL) goto fail;
+	if (arg6) if ((lparg6 = (*env)->GetByteArrayElements(env, arg6, NULL)) == NULL) goto fail;
+	gtk_paint_handle((GtkStyle *)arg0, (GdkWindow *)arg1, arg2, arg3, lparg4, (GtkWidget *)arg5, (const gchar *)lparg6, arg7, arg8, arg9, arg10, arg11);
+fail:
+	if (arg6 && lparg6) (*env)->ReleaseByteArrayElements(env, arg6, lparg6, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1paint_1handle_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1paint_1hline
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1paint_1hline)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jobject arg3, jint arg4, jbyteArray arg5, jint arg6, jint arg7, jint arg8)
+{
+	GdkRectangle _arg3, *lparg3=NULL;
+	jbyte *lparg5=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1paint_1hline_FUNC);
+	if (arg3) if ((lparg3 = getGdkRectangleFields(env, arg3, &_arg3)) == NULL) goto fail;
+	if (arg5) if ((lparg5 = (*env)->GetByteArrayElements(env, arg5, NULL)) == NULL) goto fail;
+	gtk_paint_hline((GtkStyle *)arg0, (GdkWindow *)arg1, arg2, lparg3, (GtkWidget *)arg4, (const gchar *)lparg5, arg6, arg7, arg8);
+fail:
+	if (arg5 && lparg5) (*env)->ReleaseByteArrayElements(env, arg5, lparg5, 0);
+	if (arg3 && lparg3) setGdkRectangleFields(env, arg3, lparg3);
+	OS_NATIVE_EXIT(env, that, _1gtk_1paint_1hline_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1paint_1layout
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1paint_1layout)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jboolean arg3, jobject arg4, jint arg5, jbyteArray arg6, jint arg7, jint arg8, jint arg9)
+{
+	GdkRectangle _arg4, *lparg4=NULL;
+	jbyte *lparg6=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1paint_1layout_FUNC);
+	if (arg4) if ((lparg4 = getGdkRectangleFields(env, arg4, &_arg4)) == NULL) goto fail;
+	if (arg6) if ((lparg6 = (*env)->GetByteArrayElements(env, arg6, NULL)) == NULL) goto fail;
+	gtk_paint_layout((GtkStyle *)arg0, (GdkWindow *)arg1, arg2, arg3, lparg4, (GtkWidget *)arg5, (const gchar *)lparg6, arg7, arg8, (PangoLayout *)arg9);
+fail:
+	if (arg6 && lparg6) (*env)->ReleaseByteArrayElements(env, arg6, lparg6, 0);
+	if (arg4 && lparg4) setGdkRectangleFields(env, arg4, lparg4);
+	OS_NATIVE_EXIT(env, that, _1gtk_1paint_1layout_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1paint_1option
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1paint_1option)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jobject arg4, jint arg5, jbyteArray arg6, jint arg7, jint arg8, jint arg9, jint arg10)
+{
+	GdkRectangle _arg4, *lparg4=NULL;
+	jbyte *lparg6=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1paint_1option_FUNC);
+	if (arg4) if ((lparg4 = getGdkRectangleFields(env, arg4, &_arg4)) == NULL) goto fail;
+	if (arg6) if ((lparg6 = (*env)->GetByteArrayElements(env, arg6, NULL)) == NULL) goto fail;
+	gtk_paint_option((GtkStyle *)arg0, (GdkWindow *)arg1, arg2, arg3, lparg4, (GtkWidget *)arg5, (const gchar *)lparg6, arg7, arg8, arg9, arg10);
+fail:
+	if (arg6 && lparg6) (*env)->ReleaseByteArrayElements(env, arg6, lparg6, 0);
+	if (arg4 && lparg4) setGdkRectangleFields(env, arg4, lparg4);
+	OS_NATIVE_EXIT(env, that, _1gtk_1paint_1option_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1paint_1shadow
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1paint_1shadow)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jobject arg4, jint arg5, jbyteArray arg6, jint arg7, jint arg8, jint arg9, jint arg10)
+{
+	GdkRectangle _arg4, *lparg4=NULL;
+	jbyte *lparg6=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1paint_1shadow_FUNC);
+	if (arg4) if ((lparg4 = getGdkRectangleFields(env, arg4, &_arg4)) == NULL) goto fail;
+	if (arg6) if ((lparg6 = (*env)->GetByteArrayElements(env, arg6, NULL)) == NULL) goto fail;
+	gtk_paint_shadow((GtkStyle *)arg0, (GdkWindow *)arg1, arg2, arg3, lparg4, (GtkWidget *)arg5, (gchar *)lparg6, arg7, arg8, arg9, arg10);
+fail:
+	if (arg6 && lparg6) (*env)->ReleaseByteArrayElements(env, arg6, lparg6, 0);
+	if (arg4 && lparg4) setGdkRectangleFields(env, arg4, lparg4);
+	OS_NATIVE_EXIT(env, that, _1gtk_1paint_1shadow_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1paint_1shadow_1gap
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1paint_1shadow_1gap)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jobject arg4, jint arg5, jbyteArray arg6, jint arg7, jint arg8, jint arg9, jint arg10, jint arg11, jint arg12, jint arg13)
+{
+	GdkRectangle _arg4, *lparg4=NULL;
+	jbyte *lparg6=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1paint_1shadow_1gap_FUNC);
+	if (arg4) if ((lparg4 = getGdkRectangleFields(env, arg4, &_arg4)) == NULL) goto fail;
+	if (arg6) if ((lparg6 = (*env)->GetByteArrayElements(env, arg6, NULL)) == NULL) goto fail;
+	gtk_paint_shadow_gap((GtkStyle *)arg0, (GdkWindow *)arg1, arg2, arg3, lparg4, (GtkWidget *)arg5, (gchar *)lparg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13);
+fail:
+	if (arg6 && lparg6) (*env)->ReleaseByteArrayElements(env, arg6, lparg6, 0);
+	if (arg4 && lparg4) setGdkRectangleFields(env, arg4, lparg4);
+	OS_NATIVE_EXIT(env, that, _1gtk_1paint_1shadow_1gap_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1paint_1slider
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1paint_1slider)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jobject arg4, jint arg5, jbyteArray arg6, jint arg7, jint arg8, jint arg9, jint arg10, jint arg11)
+{
+	GdkRectangle _arg4, *lparg4=NULL;
+	jbyte *lparg6=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1paint_1slider_FUNC);
+	if (arg4) if ((lparg4 = getGdkRectangleFields(env, arg4, &_arg4)) == NULL) goto fail;
+	if (arg6) if ((lparg6 = (*env)->GetByteArrayElements(env, arg6, NULL)) == NULL) goto fail;
+	gtk_paint_slider((GtkStyle *)arg0, (GdkWindow *)arg1, arg2, arg3, lparg4, (GtkWidget *)arg5, (const gchar *)lparg6, arg7, arg8, arg9, arg10, arg11);
+fail:
+	if (arg6 && lparg6) (*env)->ReleaseByteArrayElements(env, arg6, lparg6, 0);
+	if (arg4 && lparg4) setGdkRectangleFields(env, arg4, lparg4);
+	OS_NATIVE_EXIT(env, that, _1gtk_1paint_1slider_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1paint_1tab
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1paint_1tab)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jobject arg4, jint arg5, jbyteArray arg6, jint arg7, jint arg8, jint arg9, jint arg10)
+{
+	GdkRectangle _arg4, *lparg4=NULL;
+	jbyte *lparg6=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1paint_1tab_FUNC);
+	if (arg4) if ((lparg4 = getGdkRectangleFields(env, arg4, &_arg4)) == NULL) goto fail;
+	if (arg6) if ((lparg6 = (*env)->GetByteArrayElements(env, arg6, NULL)) == NULL) goto fail;
+	gtk_paint_tab((GtkStyle *)arg0, (GdkWindow *)arg1, arg2, arg3, lparg4, (GtkWidget *)arg5, (const gchar *)lparg6, arg7, arg8, arg9, arg10);
+fail:
+	if (arg6 && lparg6) (*env)->ReleaseByteArrayElements(env, arg6, lparg6, 0);
+	if (arg4 && lparg4) setGdkRectangleFields(env, arg4, lparg4);
+	OS_NATIVE_EXIT(env, that, _1gtk_1paint_1tab_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1paint_1vline
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1paint_1vline)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jobject arg3, jint arg4, jbyteArray arg5, jint arg6, jint arg7, jint arg8)
+{
+	GdkRectangle _arg3, *lparg3=NULL;
+	jbyte *lparg5=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1paint_1vline_FUNC);
+	if (arg3) if ((lparg3 = getGdkRectangleFields(env, arg3, &_arg3)) == NULL) goto fail;
+	if (arg5) if ((lparg5 = (*env)->GetByteArrayElements(env, arg5, NULL)) == NULL) goto fail;
+	gtk_paint_vline((GtkStyle *)arg0, (GdkWindow *)arg1, arg2, lparg3, (GtkWidget *)arg4, (const gchar *)lparg5, arg6, arg7, arg8);
+fail:
+	if (arg5 && lparg5) (*env)->ReleaseByteArrayElements(env, arg5, lparg5, 0);
+	if (arg3 && lparg3) setGdkRectangleFields(env, arg3, lparg3);
+	OS_NATIVE_EXIT(env, that, _1gtk_1paint_1vline_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1paper_1size_1free
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1paper_1size_1free)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1paper_1size_1free_FUNC);
+/*
+	gtk_paper_size_free(arg0);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef void (*FPTR)(jint);
+		static FPTR fptr;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_paper_size_free_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_paper_size_free");
+			initialized = 1;
+		}
+		if (fptr) {
+			(*fptr)(arg0);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1paper_1size_1free_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1paper_1size_1get_1display_1name
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1paper_1size_1get_1display_1name)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1paper_1size_1get_1display_1name_FUNC);
+/*
+	rc = (jint)gtk_paper_size_get_display_name(arg0);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jint (*FPTR)(jint);
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_paper_size_get_display_name_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_paper_size_get_display_name");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jint)(*fptr)(arg0);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1paper_1size_1get_1display_1name_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1paper_1size_1get_1height
+JNIEXPORT jdouble JNICALL OS_NATIVE(_1gtk_1paper_1size_1get_1height)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	jdouble rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1paper_1size_1get_1height_FUNC);
+/*
+	rc = (jdouble)gtk_paper_size_get_height(arg0, arg1);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jdouble (*FPTR)(jint, jint);
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_paper_size_get_height_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_paper_size_get_height");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jdouble)(*fptr)(arg0, arg1);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1paper_1size_1get_1height_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1paper_1size_1get_1name
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1paper_1size_1get_1name)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1paper_1size_1get_1name_FUNC);
+/*
+	rc = (jint)gtk_paper_size_get_name(arg0);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jint (*FPTR)(jint);
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_paper_size_get_name_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_paper_size_get_name");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jint)(*fptr)(arg0);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1paper_1size_1get_1name_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1paper_1size_1get_1ppd_1name
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1paper_1size_1get_1ppd_1name)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1paper_1size_1get_1ppd_1name_FUNC);
+/*
+	rc = (jint)gtk_paper_size_get_ppd_name(arg0);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jint (*FPTR)(jint);
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_paper_size_get_ppd_name_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_paper_size_get_ppd_name");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jint)(*fptr)(arg0);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1paper_1size_1get_1ppd_1name_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1paper_1size_1get_1width
+JNIEXPORT jdouble JNICALL OS_NATIVE(_1gtk_1paper_1size_1get_1width)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	jdouble rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1paper_1size_1get_1width_FUNC);
+/*
+	rc = (jdouble)gtk_paper_size_get_width(arg0, arg1);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jdouble (*FPTR)(jint, jint);
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_paper_size_get_width_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_paper_size_get_width");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jdouble)(*fptr)(arg0, arg1);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1paper_1size_1get_1width_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1paper_1size_1is_1custom
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1gtk_1paper_1size_1is_1custom)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1paper_1size_1is_1custom_FUNC);
+/*
+	rc = (jboolean)gtk_paper_size_is_custom(arg0);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jboolean (*FPTR)(jint);
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_paper_size_is_custom_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_paper_size_is_custom");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jboolean)(*fptr)(arg0);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1paper_1size_1is_1custom_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1paper_1size_1new
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1paper_1size_1new)
+	(JNIEnv *env, jclass that, jbyteArray arg0)
+{
+	jbyte *lparg0=NULL;
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1paper_1size_1new_FUNC);
+	if (arg0) if ((lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL)) == NULL) goto fail;
+/*
+	rc = (jint)gtk_paper_size_new(lparg0);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jint (*FPTR)(jbyte *);
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_paper_size_new_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_paper_size_new");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jint)(*fptr)(lparg0);
+		}
+	}
+fail:
+	if (arg0 && lparg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1paper_1size_1new_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1paper_1size_1new_1custom
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1paper_1size_1new_1custom)
+	(JNIEnv *env, jclass that, jbyteArray arg0, jbyteArray arg1, jdouble arg2, jdouble arg3, jint arg4)
+{
+	jbyte *lparg0=NULL;
+	jbyte *lparg1=NULL;
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1paper_1size_1new_1custom_FUNC);
+	if (arg0) if ((lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL)) == NULL) goto fail;
+	if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+/*
+	rc = (jint)gtk_paper_size_new_custom(lparg0, lparg1, arg2, arg3, arg4);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jint (*FPTR)(jbyte *, jbyte *, jdouble, jdouble, jint);
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_paper_size_new_custom_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_paper_size_new_custom");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jint)(*fptr)(lparg0, lparg1, arg2, arg3, arg4);
+		}
+	}
+fail:
+	if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+	if (arg0 && lparg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1paper_1size_1new_1custom_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1paper_1size_1new_1from_1ppd
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1paper_1size_1new_1from_1ppd)
+	(JNIEnv *env, jclass that, jbyteArray arg0, jbyteArray arg1, jdouble arg2, jdouble arg3)
+{
+	jbyte *lparg0=NULL;
+	jbyte *lparg1=NULL;
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1paper_1size_1new_1from_1ppd_FUNC);
+	if (arg0) if ((lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL)) == NULL) goto fail;
+	if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+/*
+	rc = (jint)gtk_paper_size_new_from_ppd(lparg0, lparg1, arg2, arg3);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jint (*FPTR)(jbyte *, jbyte *, jdouble, jdouble);
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_paper_size_new_from_ppd_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_paper_size_new_from_ppd");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jint)(*fptr)(lparg0, lparg1, arg2, arg3);
+		}
+	}
+fail:
+	if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+	if (arg0 && lparg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1paper_1size_1new_1from_1ppd_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1plug_1get_1id
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1plug_1get_1id)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1plug_1get_1id_FUNC);
+	rc = (jint)gtk_plug_get_id((GtkPlug *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1plug_1get_1id_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1plug_1new
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1plug_1new)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1plug_1new_FUNC);
+	rc = (jint)gtk_plug_new(arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1plug_1new_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1print_1job_1get_1printer
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1print_1job_1get_1printer)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1print_1job_1get_1printer_FUNC);
+/*
+	rc = (jint)gtk_print_job_get_printer(arg0);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jint (*FPTR)(jint);
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_print_job_get_printer_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_print_job_get_printer");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jint)(*fptr)(arg0);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1print_1job_1get_1printer_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1print_1job_1get_1settings
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1print_1job_1get_1settings)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1print_1job_1get_1settings_FUNC);
+/*
+	rc = (jint)gtk_print_job_get_settings(arg0);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jint (*FPTR)(jint);
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_print_job_get_settings_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_print_job_get_settings");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jint)(*fptr)(arg0);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1print_1job_1get_1settings_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1print_1job_1get_1status
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1print_1job_1get_1status)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1print_1job_1get_1status_FUNC);
+/*
+	rc = (jint)gtk_print_job_get_status(arg0);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jint (*FPTR)(jint);
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_print_job_get_status_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_print_job_get_status");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jint)(*fptr)(arg0);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1print_1job_1get_1status_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1print_1job_1get_1surface
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1print_1job_1get_1surface)
+	(JNIEnv *env, jclass that, jint arg0, jintArray arg1)
+{
+	jint *lparg1=NULL;
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1print_1job_1get_1surface_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL)) == NULL) goto fail;
+/*
+	rc = (jint)gtk_print_job_get_surface(arg0, (GError **)lparg1);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jint (*FPTR)(jint, GError **);
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_print_job_get_surface_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_print_job_get_surface");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jint)(*fptr)(arg0, (GError **)lparg1);
+		}
+	}
+fail:
+	if (arg1 && lparg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1print_1job_1get_1surface_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1print_1job_1get_1title
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1print_1job_1get_1title)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1print_1job_1get_1title_FUNC);
+/*
+	rc = (jint)gtk_print_job_get_title(arg0);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jint (*FPTR)(jint);
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_print_job_get_title_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_print_job_get_title");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jint)(*fptr)(arg0);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1print_1job_1get_1title_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1print_1job_1new
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1print_1job_1new)
+	(JNIEnv *env, jclass that, jbyteArray arg0, jint arg1, jint arg2, jint arg3)
+{
+	jbyte *lparg0=NULL;
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1print_1job_1new_FUNC);
+	if (arg0) if ((lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL)) == NULL) goto fail;
+/*
+	rc = (jint)gtk_print_job_new((const gchar *)lparg0, arg1, arg2, arg3);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jint (*FPTR)(const gchar *, jint, jint, jint);
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_print_job_new_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_print_job_new");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jint)(*fptr)((const gchar *)lparg0, arg1, arg2, arg3);
+		}
+	}
+fail:
+	if (arg0 && lparg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1print_1job_1new_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1print_1job_1send
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1print_1job_1send)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1print_1job_1send_FUNC);
+/*
+	gtk_print_job_send(arg0, arg1, (gpointer)arg2, (GDestroyNotify)arg3);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef void (*FPTR)(jint, jint, gpointer, GDestroyNotify);
+		static FPTR fptr;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_print_job_send_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_print_job_send");
+			initialized = 1;
+		}
+		if (fptr) {
+			(*fptr)(arg0, arg1, (gpointer)arg2, (GDestroyNotify)arg3);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1print_1job_1send_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1print_1job_1set_1source_1file
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1gtk_1print_1job_1set_1source_1file)
+	(JNIEnv *env, jclass that, jint arg0, jbyteArray arg1, jintArray arg2)
+{
+	jbyte *lparg1=NULL;
+	jint *lparg2=NULL;
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1print_1job_1set_1source_1file_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	if (arg2) if ((lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL)) == NULL) goto fail;
+/*
+	rc = (jboolean)gtk_print_job_set_source_file(arg0, (const gchar *)lparg1, (GError **)lparg2);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jboolean (*FPTR)(jint, const gchar *, GError **);
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_print_job_set_source_file_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_print_job_set_source_file");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jboolean)(*fptr)(arg0, (const gchar *)lparg1, (GError **)lparg2);
+		}
+	}
+fail:
+	if (arg2 && lparg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
+	if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1print_1job_1set_1source_1file_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1print_1settings_1foreach
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1print_1settings_1foreach)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1print_1settings_1foreach_FUNC);
+/*
+	gtk_print_settings_foreach(arg0, arg1, (gpointer)arg2);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef void (*FPTR)(jint, jint, gpointer);
+		static FPTR fptr;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_print_settings_foreach_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_print_settings_foreach");
+			initialized = 1;
+		}
+		if (fptr) {
+			(*fptr)(arg0, arg1, (gpointer)arg2);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1print_1settings_1foreach_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1print_1settings_1get
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1print_1settings_1get)
+	(JNIEnv *env, jclass that, jint arg0, jbyteArray arg1)
+{
+	jbyte *lparg1=NULL;
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1print_1settings_1get_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+/*
+	rc = (jint)gtk_print_settings_get(arg0, (const gchar *)lparg1);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jint (*FPTR)(jint, const gchar *);
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_print_settings_get_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_print_settings_get");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jint)(*fptr)(arg0, (const gchar *)lparg1);
+		}
+	}
+fail:
+	if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1print_1settings_1get_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1print_1settings_1get_1collate
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1gtk_1print_1settings_1get_1collate)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1print_1settings_1get_1collate_FUNC);
+/*
+	rc = (jboolean)gtk_print_settings_get_collate(arg0);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jboolean (*FPTR)(jint);
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_print_settings_get_collate_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_print_settings_get_collate");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jboolean)(*fptr)(arg0);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1print_1settings_1get_1collate_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1print_1settings_1get_1n_1copies
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1print_1settings_1get_1n_1copies)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1print_1settings_1get_1n_1copies_FUNC);
+/*
+	rc = (jint)gtk_print_settings_get_n_copies(arg0);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jint (*FPTR)(jint);
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_print_settings_get_n_copies_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_print_settings_get_n_copies");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jint)(*fptr)(arg0);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1print_1settings_1get_1n_1copies_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1print_1settings_1get_1orientation
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1print_1settings_1get_1orientation)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1print_1settings_1get_1orientation_FUNC);
+/*
+	rc = (jint)gtk_print_settings_get_orientation(arg0);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jint (*FPTR)(jint);
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_print_settings_get_orientation_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_print_settings_get_orientation");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jint)(*fptr)(arg0);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1print_1settings_1get_1orientation_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1print_1settings_1get_1page_1ranges
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1print_1settings_1get_1page_1ranges)
+	(JNIEnv *env, jclass that, jint arg0, jintArray arg1)
+{
+	jint *lparg1=NULL;
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1print_1settings_1get_1page_1ranges_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL)) == NULL) goto fail;
+/*
+	rc = (jint)gtk_print_settings_get_page_ranges(arg0, (gint *)lparg1);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jint (*FPTR)(jint, gint *);
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_print_settings_get_page_ranges_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_print_settings_get_page_ranges");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jint)(*fptr)(arg0, (gint *)lparg1);
+		}
+	}
+fail:
+	if (arg1 && lparg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1print_1settings_1get_1page_1ranges_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1print_1settings_1get_1paper_1height
+JNIEXPORT jdouble JNICALL OS_NATIVE(_1gtk_1print_1settings_1get_1paper_1height)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	jdouble rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1print_1settings_1get_1paper_1height_FUNC);
+/*
+	rc = (jdouble)gtk_print_settings_get_paper_height(arg0, arg1);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jdouble (*FPTR)(jint, jint);
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_print_settings_get_paper_height_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_print_settings_get_paper_height");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jdouble)(*fptr)(arg0, arg1);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1print_1settings_1get_1paper_1height_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1print_1settings_1get_1paper_1width
+JNIEXPORT jdouble JNICALL OS_NATIVE(_1gtk_1print_1settings_1get_1paper_1width)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	jdouble rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1print_1settings_1get_1paper_1width_FUNC);
+/*
+	rc = (jdouble)gtk_print_settings_get_paper_width(arg0, arg1);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jdouble (*FPTR)(jint, jint);
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_print_settings_get_paper_width_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_print_settings_get_paper_width");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jdouble)(*fptr)(arg0, arg1);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1print_1settings_1get_1paper_1width_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1print_1settings_1get_1print_1pages
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1print_1settings_1get_1print_1pages)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1print_1settings_1get_1print_1pages_FUNC);
+/*
+	rc = (jint)gtk_print_settings_get_print_pages(arg0);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jint (*FPTR)(jint);
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_print_settings_get_print_pages_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_print_settings_get_print_pages");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jint)(*fptr)(arg0);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1print_1settings_1get_1print_1pages_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1print_1settings_1get_1printer
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1print_1settings_1get_1printer)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1print_1settings_1get_1printer_FUNC);
+/*
+	rc = (jint)gtk_print_settings_get_printer(arg0);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jint (*FPTR)(jint);
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_print_settings_get_printer_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_print_settings_get_printer");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jint)(*fptr)(arg0);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1print_1settings_1get_1printer_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1print_1settings_1get_1resolution
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1print_1settings_1get_1resolution)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1print_1settings_1get_1resolution_FUNC);
+/*
+	rc = (jint)gtk_print_settings_get_resolution(arg0);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jint (*FPTR)(jint);
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_print_settings_get_resolution_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_print_settings_get_resolution");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jint)(*fptr)(arg0);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1print_1settings_1get_1resolution_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1print_1settings_1new
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1print_1settings_1new)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1print_1settings_1new_FUNC);
+/*
+	rc = (jint)gtk_print_settings_new();
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jint (*FPTR)();
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_print_settings_new_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_print_settings_new");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jint)(*fptr)();
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1print_1settings_1new_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1print_1settings_1set
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1print_1settings_1set)
+	(JNIEnv *env, jclass that, jint arg0, jbyteArray arg1, jbyteArray arg2)
+{
+	jbyte *lparg1=NULL;
+	jbyte *lparg2=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1print_1settings_1set_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	if (arg2) if ((lparg2 = (*env)->GetByteArrayElements(env, arg2, NULL)) == NULL) goto fail;
+/*
+	gtk_print_settings_set(arg0, (const gchar *)lparg1, (const gchar *)lparg2);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef void (*FPTR)(jint, const gchar *, const gchar *);
+		static FPTR fptr;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_print_settings_set_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_print_settings_set");
+			initialized = 1;
+		}
+		if (fptr) {
+			(*fptr)(arg0, (const gchar *)lparg1, (const gchar *)lparg2);
+		}
+	}
+fail:
+	if (arg2 && lparg2) (*env)->ReleaseByteArrayElements(env, arg2, lparg2, 0);
+	if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1print_1settings_1set_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1print_1settings_1set_1collate
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1print_1settings_1set_1collate)
+	(JNIEnv *env, jclass that, jint arg0, jboolean arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1print_1settings_1set_1collate_FUNC);
+/*
+	gtk_print_settings_set_collate(arg0, (gboolean)arg1);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef void (*FPTR)(jint, gboolean);
+		static FPTR fptr;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_print_settings_set_collate_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_print_settings_set_collate");
+			initialized = 1;
+		}
+		if (fptr) {
+			(*fptr)(arg0, (gboolean)arg1);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1print_1settings_1set_1collate_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1print_1settings_1set_1n_1copies
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1print_1settings_1set_1n_1copies)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1print_1settings_1set_1n_1copies_FUNC);
+/*
+	gtk_print_settings_set_n_copies(arg0, (gint)arg1);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef void (*FPTR)(jint, gint);
+		static FPTR fptr;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_print_settings_set_n_copies_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_print_settings_set_n_copies");
+			initialized = 1;
+		}
+		if (fptr) {
+			(*fptr)(arg0, (gint)arg1);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1print_1settings_1set_1n_1copies_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1print_1settings_1set_1orientation
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1print_1settings_1set_1orientation)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1print_1settings_1set_1orientation_FUNC);
+/*
+	gtk_print_settings_set_orientation(arg0, arg1);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef void (*FPTR)(jint, jint);
+		static FPTR fptr;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_print_settings_set_orientation_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_print_settings_set_orientation");
+			initialized = 1;
+		}
+		if (fptr) {
+			(*fptr)(arg0, arg1);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1print_1settings_1set_1orientation_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1print_1settings_1set_1page_1ranges
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1print_1settings_1set_1page_1ranges)
+	(JNIEnv *env, jclass that, jint arg0, jintArray arg1, jint arg2)
+{
+	jint *lparg1=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1print_1settings_1set_1page_1ranges_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL)) == NULL) goto fail;
+/*
+	gtk_print_settings_set_page_ranges(arg0, lparg1, (gint)arg2);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef void (*FPTR)(jint, jint *, gint);
+		static FPTR fptr;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_print_settings_set_page_ranges_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_print_settings_set_page_ranges");
+			initialized = 1;
+		}
+		if (fptr) {
+			(*fptr)(arg0, lparg1, (gint)arg2);
+		}
+	}
+fail:
+	if (arg1 && lparg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1print_1settings_1set_1page_1ranges_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1print_1settings_1set_1print_1pages
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1print_1settings_1set_1print_1pages)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1print_1settings_1set_1print_1pages_FUNC);
+/*
+	gtk_print_settings_set_print_pages(arg0, arg1);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef void (*FPTR)(jint, jint);
+		static FPTR fptr;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_print_settings_set_print_pages_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_print_settings_set_print_pages");
+			initialized = 1;
+		}
+		if (fptr) {
+			(*fptr)(arg0, arg1);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1print_1settings_1set_1print_1pages_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1print_1settings_1set_1printer
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1print_1settings_1set_1printer)
+	(JNIEnv *env, jclass that, jint arg0, jbyteArray arg1)
+{
+	jbyte *lparg1=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1print_1settings_1set_1printer_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+/*
+	gtk_print_settings_set_printer(arg0, lparg1);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef void (*FPTR)(jint, jbyte *);
+		static FPTR fptr;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_print_settings_set_printer_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_print_settings_set_printer");
+			initialized = 1;
+		}
+		if (fptr) {
+			(*fptr)(arg0, lparg1);
+		}
+	}
+fail:
+	if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1print_1settings_1set_1printer_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1print_1unix_1dialog_1get_1current_1page
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1print_1unix_1dialog_1get_1current_1page)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1print_1unix_1dialog_1get_1current_1page_FUNC);
+/*
+	rc = (jint)gtk_print_unix_dialog_get_current_page(arg0);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jint (*FPTR)(jint);
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_print_unix_dialog_get_current_page_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_print_unix_dialog_get_current_page");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jint)(*fptr)(arg0);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1print_1unix_1dialog_1get_1current_1page_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1print_1unix_1dialog_1get_1page_1setup
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1print_1unix_1dialog_1get_1page_1setup)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1print_1unix_1dialog_1get_1page_1setup_FUNC);
+/*
+	rc = (jint)gtk_print_unix_dialog_get_page_setup(arg0);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jint (*FPTR)(jint);
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_print_unix_dialog_get_page_setup_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_print_unix_dialog_get_page_setup");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jint)(*fptr)(arg0);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1print_1unix_1dialog_1get_1page_1setup_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1print_1unix_1dialog_1get_1selected_1printer
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1print_1unix_1dialog_1get_1selected_1printer)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1print_1unix_1dialog_1get_1selected_1printer_FUNC);
+/*
+	rc = (jint)gtk_print_unix_dialog_get_selected_printer(arg0);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jint (*FPTR)(jint);
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_print_unix_dialog_get_selected_printer_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_print_unix_dialog_get_selected_printer");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jint)(*fptr)(arg0);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1print_1unix_1dialog_1get_1selected_1printer_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1print_1unix_1dialog_1get_1settings
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1print_1unix_1dialog_1get_1settings)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1print_1unix_1dialog_1get_1settings_FUNC);
+/*
+	rc = (jint)gtk_print_unix_dialog_get_settings(arg0);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jint (*FPTR)(jint);
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_print_unix_dialog_get_settings_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_print_unix_dialog_get_settings");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jint)(*fptr)(arg0);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1print_1unix_1dialog_1get_1settings_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1print_1unix_1dialog_1new
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1print_1unix_1dialog_1new)
+	(JNIEnv *env, jclass that, jbyteArray arg0, jint arg1)
+{
+	jbyte *lparg0=NULL;
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1print_1unix_1dialog_1new_FUNC);
+	if (arg0) if ((lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL)) == NULL) goto fail;
+/*
+	rc = (jint)gtk_print_unix_dialog_new((const gchar *)lparg0, (GtkWindow *)arg1);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jint (*FPTR)(const gchar *, GtkWindow *);
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_print_unix_dialog_new_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_print_unix_dialog_new");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jint)(*fptr)((const gchar *)lparg0, (GtkWindow *)arg1);
+		}
+	}
+fail:
+	if (arg0 && lparg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1print_1unix_1dialog_1new_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1print_1unix_1dialog_1set_1current_1page
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1print_1unix_1dialog_1set_1current_1page)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1print_1unix_1dialog_1set_1current_1page_FUNC);
+/*
+	gtk_print_unix_dialog_set_current_page(arg0, (gint)arg1);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef void (*FPTR)(jint, gint);
+		static FPTR fptr;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_print_unix_dialog_set_current_page_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_print_unix_dialog_set_current_page");
+			initialized = 1;
+		}
+		if (fptr) {
+			(*fptr)(arg0, (gint)arg1);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1print_1unix_1dialog_1set_1current_1page_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1print_1unix_1dialog_1set_1manual_1capabilities
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1print_1unix_1dialog_1set_1manual_1capabilities)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1print_1unix_1dialog_1set_1manual_1capabilities_FUNC);
+/*
+	gtk_print_unix_dialog_set_manual_capabilities(arg0, arg1);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef void (*FPTR)(jint, jint);
+		static FPTR fptr;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_print_unix_dialog_set_manual_capabilities_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_print_unix_dialog_set_manual_capabilities");
+			initialized = 1;
+		}
+		if (fptr) {
+			(*fptr)(arg0, arg1);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1print_1unix_1dialog_1set_1manual_1capabilities_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1print_1unix_1dialog_1set_1page_1setup
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1print_1unix_1dialog_1set_1page_1setup)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1print_1unix_1dialog_1set_1page_1setup_FUNC);
+/*
+	gtk_print_unix_dialog_set_page_setup(arg0, arg1);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef void (*FPTR)(jint, jint);
+		static FPTR fptr;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_print_unix_dialog_set_page_setup_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_print_unix_dialog_set_page_setup");
+			initialized = 1;
+		}
+		if (fptr) {
+			(*fptr)(arg0, arg1);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1print_1unix_1dialog_1set_1page_1setup_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1print_1unix_1dialog_1set_1settings
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1print_1unix_1dialog_1set_1settings)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1print_1unix_1dialog_1set_1settings_FUNC);
+/*
+	gtk_print_unix_dialog_set_settings(arg0, arg1);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef void (*FPTR)(jint, jint);
+		static FPTR fptr;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_print_unix_dialog_set_settings_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_print_unix_dialog_set_settings");
+			initialized = 1;
+		}
+		if (fptr) {
+			(*fptr)(arg0, arg1);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1print_1unix_1dialog_1set_1settings_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1printer_1get_1backend
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1printer_1get_1backend)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1printer_1get_1backend_FUNC);
+/*
+	rc = (jint)gtk_printer_get_backend(arg0);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jint (*FPTR)(jint);
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_printer_get_backend_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_printer_get_backend");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jint)(*fptr)(arg0);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1printer_1get_1backend_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1printer_1get_1name
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1printer_1get_1name)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1printer_1get_1name_FUNC);
+/*
+	rc = (jint)gtk_printer_get_name(arg0);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jint (*FPTR)(jint);
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_printer_get_name_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_printer_get_name");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jint)(*fptr)(arg0);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1printer_1get_1name_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1printer_1is_1default
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1gtk_1printer_1is_1default)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1printer_1is_1default_FUNC);
+/*
+	rc = (jboolean)gtk_printer_is_default(arg0);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jboolean (*FPTR)(jint);
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_printer_is_default_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_printer_is_default");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jboolean)(*fptr)(arg0);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1printer_1is_1default_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1progress_1bar_1new
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1progress_1bar_1new)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1progress_1bar_1new_FUNC);
+	rc = (jint)gtk_progress_bar_new();
+	OS_NATIVE_EXIT(env, that, _1gtk_1progress_1bar_1new_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1progress_1bar_1pulse
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1progress_1bar_1pulse)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1progress_1bar_1pulse_FUNC);
+	gtk_progress_bar_pulse((GtkProgressBar *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1progress_1bar_1pulse_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1progress_1bar_1set_1fraction
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1progress_1bar_1set_1fraction)
+	(JNIEnv *env, jclass that, jint arg0, jdouble arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1progress_1bar_1set_1fraction_FUNC);
+	gtk_progress_bar_set_fraction((GtkProgressBar *)arg0, (gdouble)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1progress_1bar_1set_1fraction_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1progress_1bar_1set_1orientation
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1progress_1bar_1set_1orientation)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1progress_1bar_1set_1orientation_FUNC);
+	gtk_progress_bar_set_orientation((GtkProgressBar *)arg0, (GtkProgressBarOrientation)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1progress_1bar_1set_1orientation_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1radio_1button_1get_1group
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1radio_1button_1get_1group)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1radio_1button_1get_1group_FUNC);
+	rc = (jint)gtk_radio_button_get_group((GtkRadioButton *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1radio_1button_1get_1group_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1radio_1button_1new
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1radio_1button_1new)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1radio_1button_1new_FUNC);
+	rc = (jint)gtk_radio_button_new((GSList *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1radio_1button_1new_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1radio_1menu_1item_1get_1group
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1radio_1menu_1item_1get_1group)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1radio_1menu_1item_1get_1group_FUNC);
+	rc = (jint)gtk_radio_menu_item_get_group((GtkRadioMenuItem *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1radio_1menu_1item_1get_1group_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1radio_1menu_1item_1new
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1radio_1menu_1item_1new)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1radio_1menu_1item_1new_FUNC);
+	rc = (jint)gtk_radio_menu_item_new((GSList *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1radio_1menu_1item_1new_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1radio_1menu_1item_1new_1with_1label
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1radio_1menu_1item_1new_1with_1label)
+	(JNIEnv *env, jclass that, jint arg0, jbyteArray arg1)
+{
+	jbyte *lparg1=NULL;
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1radio_1menu_1item_1new_1with_1label_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	rc = (jint)gtk_radio_menu_item_new_with_label((GSList *)arg0, (const gchar *)lparg1);
+fail:
+	if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1radio_1menu_1item_1new_1with_1label_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1range_1get_1adjustment
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1range_1get_1adjustment)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1range_1get_1adjustment_FUNC);
+	rc = (jint)gtk_range_get_adjustment((GtkRange *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1range_1get_1adjustment_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1range_1set_1increments
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1range_1set_1increments)
+	(JNIEnv *env, jclass that, jint arg0, jdouble arg1, jdouble arg2)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1range_1set_1increments_FUNC);
+	gtk_range_set_increments((GtkRange *)arg0, arg1, arg2);
+	OS_NATIVE_EXIT(env, that, _1gtk_1range_1set_1increments_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1range_1set_1inverted
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1range_1set_1inverted)
+	(JNIEnv *env, jclass that, jint arg0, jboolean arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1range_1set_1inverted_FUNC);
+	gtk_range_set_inverted((GtkRange *)arg0, arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1range_1set_1inverted_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1range_1set_1range
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1range_1set_1range)
+	(JNIEnv *env, jclass that, jint arg0, jdouble arg1, jdouble arg2)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1range_1set_1range_FUNC);
+	gtk_range_set_range((GtkRange *)arg0, arg1, arg2);
+	OS_NATIVE_EXIT(env, that, _1gtk_1range_1set_1range_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1range_1set_1value
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1range_1set_1value)
+	(JNIEnv *env, jclass that, jint arg0, jdouble arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1range_1set_1value_FUNC);
+	gtk_range_set_value((GtkRange *)arg0, arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1range_1set_1value_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1rc_1parse_1string
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1rc_1parse_1string)
+	(JNIEnv *env, jclass that, jbyteArray arg0)
+{
+	jbyte *lparg0=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1rc_1parse_1string_FUNC);
+	if (arg0) if ((lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL)) == NULL) goto fail;
+	gtk_rc_parse_string((const gchar *)lparg0);
+fail:
+	if (arg0 && lparg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1rc_1parse_1string_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1rc_1style_1get_1bg_1pixmap_1name
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1rc_1style_1get_1bg_1pixmap_1name)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1rc_1style_1get_1bg_1pixmap_1name_FUNC);
+	rc = (jint)gtk_rc_style_get_bg_pixmap_name((GtkRcStyle *)arg0, arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1rc_1style_1get_1bg_1pixmap_1name_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1rc_1style_1get_1color_1flags
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1rc_1style_1get_1color_1flags)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1rc_1style_1get_1color_1flags_FUNC);
+	rc = (jint)gtk_rc_style_get_color_flags((GtkRcStyle *)arg0, arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1rc_1style_1get_1color_1flags_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1rc_1style_1set_1bg
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1rc_1style_1set_1bg)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jobject arg2)
+{
+	GdkColor _arg2, *lparg2=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1rc_1style_1set_1bg_FUNC);
+	if (arg2) if ((lparg2 = getGdkColorFields(env, arg2, &_arg2)) == NULL) goto fail;
+	gtk_rc_style_set_bg((GtkRcStyle *)arg0, arg1, lparg2);
+fail:
+	OS_NATIVE_EXIT(env, that, _1gtk_1rc_1style_1set_1bg_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1rc_1style_1set_1bg_1pixmap_1name
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1rc_1style_1set_1bg_1pixmap_1name)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1rc_1style_1set_1bg_1pixmap_1name_FUNC);
+	gtk_rc_style_set_bg_pixmap_name((GtkRcStyle *)arg0, arg1, (char *)arg2);
+	OS_NATIVE_EXIT(env, that, _1gtk_1rc_1style_1set_1bg_1pixmap_1name_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1rc_1style_1set_1color_1flags
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1rc_1style_1set_1color_1flags)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1rc_1style_1set_1color_1flags_FUNC);
+	gtk_rc_style_set_color_flags((GtkRcStyle *)arg0, arg1, arg2);
+	OS_NATIVE_EXIT(env, that, _1gtk_1rc_1style_1set_1color_1flags_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1rc_1style_1set_1fg
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1rc_1style_1set_1fg)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jobject arg2)
+{
+	GdkColor _arg2, *lparg2=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1rc_1style_1set_1fg_FUNC);
+	if (arg2) if ((lparg2 = getGdkColorFields(env, arg2, &_arg2)) == NULL) goto fail;
+	gtk_rc_style_set_fg((GtkRcStyle *)arg0, arg1, lparg2);
+fail:
+	OS_NATIVE_EXIT(env, that, _1gtk_1rc_1style_1set_1fg_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1rc_1style_1set_1text
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1rc_1style_1set_1text)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jobject arg2)
+{
+	GdkColor _arg2, *lparg2=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1rc_1style_1set_1text_FUNC);
+	if (arg2) if ((lparg2 = getGdkColorFields(env, arg2, &_arg2)) == NULL) goto fail;
+	gtk_rc_style_set_text((GtkRcStyle *)arg0, arg1, lparg2);
+fail:
+	OS_NATIVE_EXIT(env, that, _1gtk_1rc_1style_1set_1text_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1scale_1set_1digits
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1scale_1set_1digits)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1scale_1set_1digits_FUNC);
+	gtk_scale_set_digits((GtkScale *)arg0, (gint)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1scale_1set_1digits_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1scale_1set_1draw_1value
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1scale_1set_1draw_1value)
+	(JNIEnv *env, jclass that, jint arg0, jboolean arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1scale_1set_1draw_1value_FUNC);
+	gtk_scale_set_draw_value((GtkScale *)arg0, (gboolean)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1scale_1set_1draw_1value_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1scrolled_1window_1add_1with_1viewport
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1scrolled_1window_1add_1with_1viewport)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1scrolled_1window_1add_1with_1viewport_FUNC);
+	gtk_scrolled_window_add_with_viewport((GtkScrolledWindow *)arg0, (GtkWidget *)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1scrolled_1window_1add_1with_1viewport_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1scrolled_1window_1get_1hadjustment
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1scrolled_1window_1get_1hadjustment)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1scrolled_1window_1get_1hadjustment_FUNC);
+	rc = (jint)gtk_scrolled_window_get_hadjustment((GtkScrolledWindow *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1scrolled_1window_1get_1hadjustment_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1scrolled_1window_1get_1policy
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1scrolled_1window_1get_1policy)
+	(JNIEnv *env, jclass that, jint arg0, jintArray arg1, jintArray arg2)
+{
+	jint *lparg1=NULL;
+	jint *lparg2=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1scrolled_1window_1get_1policy_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	if (arg2) if ((lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL)) == NULL) goto fail;
+	gtk_scrolled_window_get_policy((GtkScrolledWindow *)arg0, (GtkPolicyType *)lparg1, (GtkPolicyType *)lparg2);
+fail:
+	if (arg2 && lparg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
+	if (arg1 && lparg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1scrolled_1window_1get_1policy_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1scrolled_1window_1get_1shadow_1type
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1scrolled_1window_1get_1shadow_1type)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1scrolled_1window_1get_1shadow_1type_FUNC);
+	rc = (jint)gtk_scrolled_window_get_shadow_type((GtkScrolledWindow *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1scrolled_1window_1get_1shadow_1type_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1scrolled_1window_1get_1vadjustment
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1scrolled_1window_1get_1vadjustment)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1scrolled_1window_1get_1vadjustment_FUNC);
+	rc = (jint)gtk_scrolled_window_get_vadjustment((GtkScrolledWindow *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1scrolled_1window_1get_1vadjustment_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1scrolled_1window_1new
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1scrolled_1window_1new)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1scrolled_1window_1new_FUNC);
+	rc = (jint)gtk_scrolled_window_new((GtkAdjustment *)arg0, (GtkAdjustment *)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1scrolled_1window_1new_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1scrolled_1window_1set_1placement
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1scrolled_1window_1set_1placement)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1scrolled_1window_1set_1placement_FUNC);
+	gtk_scrolled_window_set_placement((GtkScrolledWindow *)arg0, (GtkCornerType)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1scrolled_1window_1set_1placement_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1scrolled_1window_1set_1policy
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1scrolled_1window_1set_1policy)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1scrolled_1window_1set_1policy_FUNC);
+	gtk_scrolled_window_set_policy((GtkScrolledWindow *)arg0, (GtkPolicyType)arg1, (GtkPolicyType)arg2);
+	OS_NATIVE_EXIT(env, that, _1gtk_1scrolled_1window_1set_1policy_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1scrolled_1window_1set_1shadow_1type
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1scrolled_1window_1set_1shadow_1type)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1scrolled_1window_1set_1shadow_1type_FUNC);
+	gtk_scrolled_window_set_shadow_type((GtkScrolledWindow *)arg0, (GtkShadowType)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1scrolled_1window_1set_1shadow_1type_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1selection_1data_1free
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1selection_1data_1free)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1selection_1data_1free_FUNC);
+	gtk_selection_data_free((GtkSelectionData *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1selection_1data_1free_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1selection_1data_1set
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1selection_1data_1set)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1selection_1data_1set_FUNC);
+	gtk_selection_data_set((GtkSelectionData *)arg0, (GdkAtom)arg1, (gint)arg2, (const guchar *)arg3, (gint)arg4);
+	OS_NATIVE_EXIT(env, that, _1gtk_1selection_1data_1set_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1separator_1menu_1item_1new
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1separator_1menu_1item_1new)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1separator_1menu_1item_1new_FUNC);
+	rc = (jint)gtk_separator_menu_item_new();
+	OS_NATIVE_EXIT(env, that, _1gtk_1separator_1menu_1item_1new_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1set_1locale
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1set_1locale)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1set_1locale_FUNC);
+	rc = (jint)gtk_set_locale();
+	OS_NATIVE_EXIT(env, that, _1gtk_1set_1locale_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1settings_1get_1default
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1settings_1get_1default)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1settings_1get_1default_FUNC);
+	rc = (jint)gtk_settings_get_default();
+	OS_NATIVE_EXIT(env, that, _1gtk_1settings_1get_1default_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1socket_1get_1id
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1socket_1get_1id)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1socket_1get_1id_FUNC);
+	rc = (jint)gtk_socket_get_id((GtkSocket *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1socket_1get_1id_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1socket_1new
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1socket_1new)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1socket_1new_FUNC);
+	rc = (jint)gtk_socket_new();
+	OS_NATIVE_EXIT(env, that, _1gtk_1socket_1new_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1spin_1button_1get_1adjustment
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1spin_1button_1get_1adjustment)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1spin_1button_1get_1adjustment_FUNC);
+	rc = (jint)gtk_spin_button_get_adjustment((GtkSpinButton*)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1spin_1button_1get_1adjustment_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1spin_1button_1get_1digits
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1spin_1button_1get_1digits)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1spin_1button_1get_1digits_FUNC);
+	rc = (jint)gtk_spin_button_get_digits((GtkSpinButton*)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1spin_1button_1get_1digits_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1spin_1button_1new
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1spin_1button_1new)
+	(JNIEnv *env, jclass that, jint arg0, jdouble arg1, jint arg2)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1spin_1button_1new_FUNC);
+	rc = (jint)gtk_spin_button_new((GtkAdjustment *)arg0, arg1, arg2);
+	OS_NATIVE_EXIT(env, that, _1gtk_1spin_1button_1new_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1spin_1button_1set_1digits
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1spin_1button_1set_1digits)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1spin_1button_1set_1digits_FUNC);
+	gtk_spin_button_set_digits((GtkSpinButton*)arg0, arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1spin_1button_1set_1digits_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1spin_1button_1set_1increments
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1spin_1button_1set_1increments)
+	(JNIEnv *env, jclass that, jint arg0, jdouble arg1, jdouble arg2)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1spin_1button_1set_1increments_FUNC);
+	gtk_spin_button_set_increments((GtkSpinButton*)arg0, arg1, arg2);
+	OS_NATIVE_EXIT(env, that, _1gtk_1spin_1button_1set_1increments_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1spin_1button_1set_1range
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1spin_1button_1set_1range)
+	(JNIEnv *env, jclass that, jint arg0, jdouble arg1, jdouble arg2)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1spin_1button_1set_1range_FUNC);
+	gtk_spin_button_set_range((GtkSpinButton*)arg0, arg1, arg2);
+	OS_NATIVE_EXIT(env, that, _1gtk_1spin_1button_1set_1range_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1spin_1button_1set_1value
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1spin_1button_1set_1value)
+	(JNIEnv *env, jclass that, jint arg0, jdouble arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1spin_1button_1set_1value_FUNC);
+	gtk_spin_button_set_value((GtkSpinButton*)arg0, arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1spin_1button_1set_1value_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1spin_1button_1set_1wrap
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1spin_1button_1set_1wrap)
+	(JNIEnv *env, jclass that, jint arg0, jboolean arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1spin_1button_1set_1wrap_FUNC);
+	gtk_spin_button_set_wrap((GtkSpinButton*)arg0, arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1spin_1button_1set_1wrap_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1spin_1button_1update
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1spin_1button_1update)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1spin_1button_1update_FUNC);
+	gtk_spin_button_update((GtkSpinButton*)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1spin_1button_1update_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1style_1get_1base
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1style_1get_1base)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jobject arg2)
+{
+	GdkColor _arg2, *lparg2=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1style_1get_1base_FUNC);
+	if (arg2) if ((lparg2 = &_arg2) == NULL) goto fail;
+	gtk_style_get_base((GtkStyle *)arg0, arg1, lparg2);
+fail:
+	if (arg2 && lparg2) setGdkColorFields(env, arg2, lparg2);
+	OS_NATIVE_EXIT(env, that, _1gtk_1style_1get_1base_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1style_1get_1bg
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1style_1get_1bg)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jobject arg2)
+{
+	GdkColor _arg2, *lparg2=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1style_1get_1bg_FUNC);
+	if (arg2) if ((lparg2 = &_arg2) == NULL) goto fail;
+	gtk_style_get_bg((GtkStyle *)arg0, arg1, lparg2);
+fail:
+	if (arg2 && lparg2) setGdkColorFields(env, arg2, lparg2);
+	OS_NATIVE_EXIT(env, that, _1gtk_1style_1get_1bg_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1style_1get_1bg_1gc
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1style_1get_1bg_1gc)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jintArray arg2)
+{
+	jint *lparg2=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1style_1get_1bg_1gc_FUNC);
+	if (arg2) if ((lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL)) == NULL) goto fail;
+	gtk_style_get_bg_gc((GtkStyle *)arg0, arg1, (GdkGC **)lparg2);
+fail:
+	if (arg2 && lparg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1style_1get_1bg_1gc_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1style_1get_1black
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1style_1get_1black)
+	(JNIEnv *env, jclass that, jint arg0, jobject arg1)
+{
+	GdkColor _arg1, *lparg1=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1style_1get_1black_FUNC);
+	if (arg1) if ((lparg1 = &_arg1) == NULL) goto fail;
+	gtk_style_get_black((GtkStyle *)arg0, lparg1);
+fail:
+	if (arg1 && lparg1) setGdkColorFields(env, arg1, lparg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1style_1get_1black_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1style_1get_1black_1gc
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1style_1get_1black_1gc)
+	(JNIEnv *env, jclass that, jint arg0, jintArray arg1)
+{
+	jint *lparg1=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1style_1get_1black_1gc_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	gtk_style_get_black_gc((GtkStyle *)arg0, (GdkGC **)lparg1);
+fail:
+	if (arg1 && lparg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1style_1get_1black_1gc_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1style_1get_1dark
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1style_1get_1dark)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jobject arg2)
+{
+	GdkColor _arg2, *lparg2=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1style_1get_1dark_FUNC);
+	if (arg2) if ((lparg2 = &_arg2) == NULL) goto fail;
+	gtk_style_get_dark((GtkStyle *)arg0, arg1, lparg2);
+fail:
+	if (arg2 && lparg2) setGdkColorFields(env, arg2, lparg2);
+	OS_NATIVE_EXIT(env, that, _1gtk_1style_1get_1dark_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1style_1get_1dark_1gc
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1style_1get_1dark_1gc)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jintArray arg2)
+{
+	jint *lparg2=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1style_1get_1dark_1gc_FUNC);
+	if (arg2) if ((lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL)) == NULL) goto fail;
+	gtk_style_get_dark_gc((GtkStyle *)arg0, arg1, (GdkGC **)lparg2);
+fail:
+	if (arg2 && lparg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1style_1get_1dark_1gc_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1style_1get_1fg
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1style_1get_1fg)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jobject arg2)
+{
+	GdkColor _arg2, *lparg2=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1style_1get_1fg_FUNC);
+	if (arg2) if ((lparg2 = &_arg2) == NULL) goto fail;
+	gtk_style_get_fg((GtkStyle *)arg0, arg1, lparg2);
+fail:
+	if (arg2 && lparg2) setGdkColorFields(env, arg2, lparg2);
+	OS_NATIVE_EXIT(env, that, _1gtk_1style_1get_1fg_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1style_1get_1fg_1gc
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1style_1get_1fg_1gc)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jintArray arg2)
+{
+	jint *lparg2=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1style_1get_1fg_1gc_FUNC);
+	if (arg2) if ((lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL)) == NULL) goto fail;
+	gtk_style_get_fg_gc((GtkStyle *)arg0, arg1, (GdkGC **)lparg2);
+fail:
+	if (arg2 && lparg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1style_1get_1fg_1gc_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1style_1get_1font_1desc
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1style_1get_1font_1desc)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1style_1get_1font_1desc_FUNC);
+	rc = (jint)gtk_style_get_font_desc((GtkStyle *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1style_1get_1font_1desc_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1style_1get_1light
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1style_1get_1light)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jobject arg2)
+{
+	GdkColor _arg2, *lparg2=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1style_1get_1light_FUNC);
+	if (arg2) if ((lparg2 = &_arg2) == NULL) goto fail;
+	gtk_style_get_light((GtkStyle *)arg0, arg1, lparg2);
+fail:
+	if (arg2 && lparg2) setGdkColorFields(env, arg2, lparg2);
+	OS_NATIVE_EXIT(env, that, _1gtk_1style_1get_1light_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1style_1get_1light_1gc
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1style_1get_1light_1gc)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jintArray arg2)
+{
+	jint *lparg2=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1style_1get_1light_1gc_FUNC);
+	if (arg2) if ((lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL)) == NULL) goto fail;
+	gtk_style_get_light_gc((GtkStyle *)arg0, arg1, (GdkGC **)lparg2);
+fail:
+	if (arg2 && lparg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1style_1get_1light_1gc_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1style_1get_1mid_1gc
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1style_1get_1mid_1gc)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jintArray arg2)
+{
+	jint *lparg2=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1style_1get_1mid_1gc_FUNC);
+	if (arg2) if ((lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL)) == NULL) goto fail;
+	gtk_style_get_mid_gc((GtkStyle *)arg0, arg1, (GdkGC **)lparg2);
+fail:
+	if (arg2 && lparg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1style_1get_1mid_1gc_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1style_1get_1text
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1style_1get_1text)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jobject arg2)
+{
+	GdkColor _arg2, *lparg2=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1style_1get_1text_FUNC);
+	if (arg2) if ((lparg2 = &_arg2) == NULL) goto fail;
+	gtk_style_get_text((GtkStyle *)arg0, arg1, lparg2);
+fail:
+	if (arg2 && lparg2) setGdkColorFields(env, arg2, lparg2);
+	OS_NATIVE_EXIT(env, that, _1gtk_1style_1get_1text_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1style_1get_1text_1aa_1gc
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1style_1get_1text_1aa_1gc)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jintArray arg2)
+{
+	jint *lparg2=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1style_1get_1text_1aa_1gc_FUNC);
+	if (arg2) if ((lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL)) == NULL) goto fail;
+	gtk_style_get_text_aa_gc((GtkStyle *)arg0, arg1, (GdkGC **)lparg2);
+fail:
+	if (arg2 && lparg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1style_1get_1text_1aa_1gc_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1style_1get_1text_1gc
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1style_1get_1text_1gc)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jintArray arg2)
+{
+	jint *lparg2=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1style_1get_1text_1gc_FUNC);
+	if (arg2) if ((lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL)) == NULL) goto fail;
+	gtk_style_get_text_gc((GtkStyle *)arg0, arg1, (GdkGC **)lparg2);
+fail:
+	if (arg2 && lparg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1style_1get_1text_1gc_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1style_1get_1white_1gc
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1style_1get_1white_1gc)
+	(JNIEnv *env, jclass that, jint arg0, jintArray arg1)
+{
+	jint *lparg1=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1style_1get_1white_1gc_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	gtk_style_get_white_gc((GtkStyle *)arg0, (GdkGC **)lparg1);
+fail:
+	if (arg1 && lparg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1style_1get_1white_1gc_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1style_1get_1xthickness
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1style_1get_1xthickness)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1style_1get_1xthickness_FUNC);
+	rc = (jint)gtk_style_get_xthickness((GtkStyle *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1style_1get_1xthickness_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1style_1get_1ythickness
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1style_1get_1ythickness)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1style_1get_1ythickness_FUNC);
+	rc = (jint)gtk_style_get_ythickness((GtkStyle *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1style_1get_1ythickness_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1style_1render_1icon
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1style_1render_1icon)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4, jint arg5, jbyteArray arg6)
+{
+	jbyte *lparg6=NULL;
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1style_1render_1icon_FUNC);
+	if (arg6) if ((lparg6 = (*env)->GetByteArrayElements(env, arg6, NULL)) == NULL) goto fail;
+	rc = (jint)gtk_style_render_icon((GtkStyle *)arg0, (GtkIconSource *)arg1, arg2, arg3, arg4, (GtkWidget *)arg5, (const gchar *)lparg6);
+fail:
+	if (arg6 && lparg6) (*env)->ReleaseByteArrayElements(env, arg6, lparg6, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1style_1render_1icon_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1target_1list_1new
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1target_1list_1new)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1target_1list_1new_FUNC);
+	rc = (jint)gtk_target_list_new((const GtkTargetEntry *)arg0, (guint)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1target_1list_1new_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1target_1list_1unref
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1target_1list_1unref)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1target_1list_1unref_FUNC);
+	gtk_target_list_unref((GtkTargetList *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1target_1list_1unref_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1text_1buffer_1copy_1clipboard
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1text_1buffer_1copy_1clipboard)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1text_1buffer_1copy_1clipboard_FUNC);
+	gtk_text_buffer_copy_clipboard((GtkTextBuffer *)arg0, (GtkClipboard *)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1text_1buffer_1copy_1clipboard_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1text_1buffer_1cut_1clipboard
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1text_1buffer_1cut_1clipboard)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jboolean arg2)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1text_1buffer_1cut_1clipboard_FUNC);
+	gtk_text_buffer_cut_clipboard((GtkTextBuffer *)arg0, (GtkClipboard *)arg1, (gboolean)arg2);
+	OS_NATIVE_EXIT(env, that, _1gtk_1text_1buffer_1cut_1clipboard_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1text_1buffer_1delete
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1text_1buffer_1delete)
+	(JNIEnv *env, jclass that, jint arg0, jbyteArray arg1, jbyteArray arg2)
+{
+	jbyte *lparg1=NULL;
+	jbyte *lparg2=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1text_1buffer_1delete_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	if (arg2) if ((lparg2 = (*env)->GetByteArrayElements(env, arg2, NULL)) == NULL) goto fail;
+	gtk_text_buffer_delete((GtkTextBuffer *)arg0, (GtkTextIter *)lparg1, (GtkTextIter *)lparg2);
+fail:
+	if (arg2 && lparg2) (*env)->ReleaseByteArrayElements(env, arg2, lparg2, 0);
+	if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1text_1buffer_1delete_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1text_1buffer_1get_1bounds
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1text_1buffer_1get_1bounds)
+	(JNIEnv *env, jclass that, jint arg0, jbyteArray arg1, jbyteArray arg2)
+{
+	jbyte *lparg1=NULL;
+	jbyte *lparg2=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1text_1buffer_1get_1bounds_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	if (arg2) if ((lparg2 = (*env)->GetByteArrayElements(env, arg2, NULL)) == NULL) goto fail;
+	gtk_text_buffer_get_bounds((GtkTextBuffer *)arg0, (GtkTextIter *)lparg1, (GtkTextIter *)lparg2);
+fail:
+	if (arg2 && lparg2) (*env)->ReleaseByteArrayElements(env, arg2, lparg2, 0);
+	if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1text_1buffer_1get_1bounds_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1text_1buffer_1get_1char_1count
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1text_1buffer_1get_1char_1count)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1text_1buffer_1get_1char_1count_FUNC);
+	rc = (jint)gtk_text_buffer_get_char_count((GtkTextBuffer *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1text_1buffer_1get_1char_1count_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1text_1buffer_1get_1end_1iter
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1text_1buffer_1get_1end_1iter)
+	(JNIEnv *env, jclass that, jint arg0, jbyteArray arg1)
+{
+	jbyte *lparg1=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1text_1buffer_1get_1end_1iter_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	gtk_text_buffer_get_end_iter((GtkTextBuffer *)arg0, (GtkTextIter *)lparg1);
+fail:
+	if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1text_1buffer_1get_1end_1iter_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1text_1buffer_1get_1insert
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1text_1buffer_1get_1insert)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1text_1buffer_1get_1insert_FUNC);
+	rc = (jint)gtk_text_buffer_get_insert((GtkTextBuffer *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1text_1buffer_1get_1insert_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1text_1buffer_1get_1iter_1at_1line
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1text_1buffer_1get_1iter_1at_1line)
+	(JNIEnv *env, jclass that, jint arg0, jbyteArray arg1, jint arg2)
+{
+	jbyte *lparg1=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1text_1buffer_1get_1iter_1at_1line_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	gtk_text_buffer_get_iter_at_line((GtkTextBuffer *)arg0, (GtkTextIter *)lparg1, (gint)arg2);
+fail:
+	if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1text_1buffer_1get_1iter_1at_1line_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1text_1buffer_1get_1iter_1at_1mark
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1text_1buffer_1get_1iter_1at_1mark)
+	(JNIEnv *env, jclass that, jint arg0, jbyteArray arg1, jint arg2)
+{
+	jbyte *lparg1=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1text_1buffer_1get_1iter_1at_1mark_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	gtk_text_buffer_get_iter_at_mark((GtkTextBuffer *)arg0, (GtkTextIter *)lparg1, (GtkTextMark *)arg2);
+fail:
+	if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1text_1buffer_1get_1iter_1at_1mark_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1text_1buffer_1get_1iter_1at_1offset
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1text_1buffer_1get_1iter_1at_1offset)
+	(JNIEnv *env, jclass that, jint arg0, jbyteArray arg1, jint arg2)
+{
+	jbyte *lparg1=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1text_1buffer_1get_1iter_1at_1offset_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	gtk_text_buffer_get_iter_at_offset((GtkTextBuffer *)arg0, (GtkTextIter *)lparg1, (gint)arg2);
+fail:
+	if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1text_1buffer_1get_1iter_1at_1offset_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1text_1buffer_1get_1line_1count
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1text_1buffer_1get_1line_1count)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1text_1buffer_1get_1line_1count_FUNC);
+	rc = (jint)gtk_text_buffer_get_line_count((GtkTextBuffer *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1text_1buffer_1get_1line_1count_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1text_1buffer_1get_1selection_1bound
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1text_1buffer_1get_1selection_1bound)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1text_1buffer_1get_1selection_1bound_FUNC);
+	rc = (jint)gtk_text_buffer_get_selection_bound((GtkTextBuffer *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1text_1buffer_1get_1selection_1bound_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1text_1buffer_1get_1selection_1bounds
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1gtk_1text_1buffer_1get_1selection_1bounds)
+	(JNIEnv *env, jclass that, jint arg0, jbyteArray arg1, jbyteArray arg2)
+{
+	jbyte *lparg1=NULL;
+	jbyte *lparg2=NULL;
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1text_1buffer_1get_1selection_1bounds_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	if (arg2) if ((lparg2 = (*env)->GetByteArrayElements(env, arg2, NULL)) == NULL) goto fail;
+	rc = (jboolean)gtk_text_buffer_get_selection_bounds((GtkTextBuffer *)arg0, (GtkTextIter *)lparg1, (GtkTextIter *)lparg2);
+fail:
+	if (arg2 && lparg2) (*env)->ReleaseByteArrayElements(env, arg2, lparg2, 0);
+	if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1text_1buffer_1get_1selection_1bounds_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1text_1buffer_1get_1text
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1text_1buffer_1get_1text)
+	(JNIEnv *env, jclass that, jint arg0, jbyteArray arg1, jbyteArray arg2, jboolean arg3)
+{
+	jbyte *lparg1=NULL;
+	jbyte *lparg2=NULL;
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1text_1buffer_1get_1text_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	if (arg2) if ((lparg2 = (*env)->GetByteArrayElements(env, arg2, NULL)) == NULL) goto fail;
+	rc = (jint)gtk_text_buffer_get_text((GtkTextBuffer *)arg0, (GtkTextIter *)lparg1, (GtkTextIter *)lparg2, (gboolean)arg3);
+fail:
+	if (arg2 && lparg2) (*env)->ReleaseByteArrayElements(env, arg2, lparg2, 0);
+	if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1text_1buffer_1get_1text_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1text_1buffer_1insert__II_3BI
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1text_1buffer_1insert__II_3BI)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jbyteArray arg2, jint arg3)
+{
+	jbyte *lparg2=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1text_1buffer_1insert__II_3BI_FUNC);
+	if (arg2) if ((lparg2 = (*env)->GetByteArrayElements(env, arg2, NULL)) == NULL) goto fail;
+	gtk_text_buffer_insert((GtkTextBuffer *)arg0, (GtkTextIter *)arg1, (const gchar *)lparg2, (gint)arg3);
+fail:
+	if (arg2 && lparg2) (*env)->ReleaseByteArrayElements(env, arg2, lparg2, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1text_1buffer_1insert__II_3BI_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1text_1buffer_1insert__I_3B_3BI
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1text_1buffer_1insert__I_3B_3BI)
+	(JNIEnv *env, jclass that, jint arg0, jbyteArray arg1, jbyteArray arg2, jint arg3)
+{
+	jbyte *lparg1=NULL;
+	jbyte *lparg2=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1text_1buffer_1insert__I_3B_3BI_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	if (arg2) if ((lparg2 = (*env)->GetByteArrayElements(env, arg2, NULL)) == NULL) goto fail;
+	gtk_text_buffer_insert((GtkTextBuffer *)arg0, (GtkTextIter *)lparg1, (const gchar *)lparg2, (gint)arg3);
+fail:
+	if (arg2 && lparg2) (*env)->ReleaseByteArrayElements(env, arg2, lparg2, 0);
+	if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1text_1buffer_1insert__I_3B_3BI_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1text_1buffer_1move_1mark
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1text_1buffer_1move_1mark)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jbyteArray arg2)
+{
+	jbyte *lparg2=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1text_1buffer_1move_1mark_FUNC);
+	if (arg2) if ((lparg2 = (*env)->GetByteArrayElements(env, arg2, NULL)) == NULL) goto fail;
+	gtk_text_buffer_move_mark((GtkTextBuffer *)arg0, (GtkTextMark *)arg1, (const GtkTextIter *)lparg2);
+fail:
+	if (arg2 && lparg2) (*env)->ReleaseByteArrayElements(env, arg2, lparg2, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1text_1buffer_1move_1mark_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1text_1buffer_1paste_1clipboard
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1text_1buffer_1paste_1clipboard)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jbyteArray arg2, jboolean arg3)
+{
+	jbyte *lparg2=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1text_1buffer_1paste_1clipboard_FUNC);
+	if (arg2) if ((lparg2 = (*env)->GetByteArrayElements(env, arg2, NULL)) == NULL) goto fail;
+	gtk_text_buffer_paste_clipboard((GtkTextBuffer *)arg0, (GtkClipboard *)arg1, (GtkTextIter *)lparg2, (gboolean)arg3);
+fail:
+	if (arg2 && lparg2) (*env)->ReleaseByteArrayElements(env, arg2, lparg2, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1text_1buffer_1paste_1clipboard_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1text_1buffer_1place_1cursor
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1text_1buffer_1place_1cursor)
+	(JNIEnv *env, jclass that, jint arg0, jbyteArray arg1)
+{
+	jbyte *lparg1=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1text_1buffer_1place_1cursor_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	gtk_text_buffer_place_cursor((GtkTextBuffer *)arg0, (const GtkTextIter *)lparg1);
+fail:
+	if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1text_1buffer_1place_1cursor_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1text_1buffer_1set_1text
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1text_1buffer_1set_1text)
+	(JNIEnv *env, jclass that, jint arg0, jbyteArray arg1, jint arg2)
+{
+	jbyte *lparg1=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1text_1buffer_1set_1text_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	gtk_text_buffer_set_text((GtkTextBuffer *)arg0, (const gchar *)lparg1, (gint)arg2);
+fail:
+	if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1text_1buffer_1set_1text_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1text_1iter_1get_1line
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1text_1iter_1get_1line)
+	(JNIEnv *env, jclass that, jbyteArray arg0)
+{
+	jbyte *lparg0=NULL;
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1text_1iter_1get_1line_FUNC);
+	if (arg0) if ((lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL)) == NULL) goto fail;
+	rc = (jint)gtk_text_iter_get_line((const GtkTextIter *)lparg0);
+fail:
+	if (arg0 && lparg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1text_1iter_1get_1line_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1text_1iter_1get_1offset
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1text_1iter_1get_1offset)
+	(JNIEnv *env, jclass that, jbyteArray arg0)
+{
+	jbyte *lparg0=NULL;
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1text_1iter_1get_1offset_FUNC);
+	if (arg0) if ((lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL)) == NULL) goto fail;
+	rc = (jint)gtk_text_iter_get_offset((const GtkTextIter *)lparg0);
+fail:
+	if (arg0 && lparg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1text_1iter_1get_1offset_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1text_1view_1buffer_1to_1window_1coords
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1text_1view_1buffer_1to_1window_1coords)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jintArray arg4, jintArray arg5)
+{
+	jint *lparg4=NULL;
+	jint *lparg5=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1text_1view_1buffer_1to_1window_1coords_FUNC);
+	if (arg4) if ((lparg4 = (*env)->GetIntArrayElements(env, arg4, NULL)) == NULL) goto fail;
+	if (arg5) if ((lparg5 = (*env)->GetIntArrayElements(env, arg5, NULL)) == NULL) goto fail;
+	gtk_text_view_buffer_to_window_coords((GtkTextView *)arg0, (GtkTextWindowType)arg1, (gint)arg2, (gint)arg3, (gint *)lparg4, (gint *)lparg5);
+fail:
+	if (arg5 && lparg5) (*env)->ReleaseIntArrayElements(env, arg5, lparg5, 0);
+	if (arg4 && lparg4) (*env)->ReleaseIntArrayElements(env, arg4, lparg4, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1text_1view_1buffer_1to_1window_1coords_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1text_1view_1get_1buffer
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1text_1view_1get_1buffer)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1text_1view_1get_1buffer_FUNC);
+	rc = (jint)gtk_text_view_get_buffer((GtkTextView *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1text_1view_1get_1buffer_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1text_1view_1get_1editable
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1gtk_1text_1view_1get_1editable)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1text_1view_1get_1editable_FUNC);
+	rc = (jboolean)gtk_text_view_get_editable((GtkTextView *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1text_1view_1get_1editable_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1text_1view_1get_1iter_1at_1location
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1text_1view_1get_1iter_1at_1location)
+	(JNIEnv *env, jclass that, jint arg0, jbyteArray arg1, jint arg2, jint arg3)
+{
+	jbyte *lparg1=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1text_1view_1get_1iter_1at_1location_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	gtk_text_view_get_iter_at_location((GtkTextView *)arg0, (GtkTextIter *)lparg1, (gint)arg2, (gint)arg3);
+fail:
+	if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1text_1view_1get_1iter_1at_1location_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1text_1view_1get_1iter_1location
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1text_1view_1get_1iter_1location)
+	(JNIEnv *env, jclass that, jint arg0, jbyteArray arg1, jobject arg2)
+{
+	jbyte *lparg1=NULL;
+	GdkRectangle _arg2, *lparg2=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1text_1view_1get_1iter_1location_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	if (arg2) if ((lparg2 = &_arg2) == NULL) goto fail;
+	gtk_text_view_get_iter_location((GtkTextView *)arg0, (const GtkTextIter *)lparg1, (GdkRectangle *)lparg2);
+fail:
+	if (arg2 && lparg2) setGdkRectangleFields(env, arg2, lparg2);
+	if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1text_1view_1get_1iter_1location_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1text_1view_1get_1line_1at_1y
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1text_1view_1get_1line_1at_1y)
+	(JNIEnv *env, jclass that, jint arg0, jbyteArray arg1, jint arg2, jintArray arg3)
+{
+	jbyte *lparg1=NULL;
+	jint *lparg3=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1text_1view_1get_1line_1at_1y_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	if (arg3) if ((lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL)) == NULL) goto fail;
+	gtk_text_view_get_line_at_y((GtkTextView *)arg0, (GtkTextIter *)lparg1, (gint)arg2, (gint *)lparg3);
+fail:
+	if (arg3 && lparg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0);
+	if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1text_1view_1get_1line_1at_1y_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1text_1view_1get_1visible_1rect
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1text_1view_1get_1visible_1rect)
+	(JNIEnv *env, jclass that, jint arg0, jobject arg1)
+{
+	GdkRectangle _arg1, *lparg1=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1text_1view_1get_1visible_1rect_FUNC);
+	if (arg1) if ((lparg1 = &_arg1) == NULL) goto fail;
+	gtk_text_view_get_visible_rect((GtkTextView *)arg0, (GdkRectangle *)lparg1);
+fail:
+	if (arg1 && lparg1) setGdkRectangleFields(env, arg1, lparg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1text_1view_1get_1visible_1rect_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1text_1view_1get_1window
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1text_1view_1get_1window)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1text_1view_1get_1window_FUNC);
+	rc = (jint)gtk_text_view_get_window((GtkTextView *)arg0, (GtkTextWindowType)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1text_1view_1get_1window_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1text_1view_1new
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1text_1view_1new)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1text_1view_1new_FUNC);
+	rc = (jint)gtk_text_view_new();
+	OS_NATIVE_EXIT(env, that, _1gtk_1text_1view_1new_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1text_1view_1scroll_1mark_1onscreen
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1text_1view_1scroll_1mark_1onscreen)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1text_1view_1scroll_1mark_1onscreen_FUNC);
+	gtk_text_view_scroll_mark_onscreen((GtkTextView *)arg0, (GtkTextMark *)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1text_1view_1scroll_1mark_1onscreen_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1text_1view_1scroll_1to_1iter
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1gtk_1text_1view_1scroll_1to_1iter)
+	(JNIEnv *env, jclass that, jint arg0, jbyteArray arg1, jdouble arg2, jboolean arg3, jdouble arg4, jdouble arg5)
+{
+	jbyte *lparg1=NULL;
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1text_1view_1scroll_1to_1iter_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	rc = (jboolean)gtk_text_view_scroll_to_iter((GtkTextView *)arg0, (GtkTextIter *)lparg1, (gdouble)arg2, (gboolean)arg3, (gdouble)arg4, (gdouble)arg5);
+fail:
+	if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1text_1view_1scroll_1to_1iter_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1text_1view_1set_1editable
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1text_1view_1set_1editable)
+	(JNIEnv *env, jclass that, jint arg0, jboolean arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1text_1view_1set_1editable_FUNC);
+	gtk_text_view_set_editable((GtkTextView *)arg0, (gboolean)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1text_1view_1set_1editable_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1text_1view_1set_1justification
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1text_1view_1set_1justification)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1text_1view_1set_1justification_FUNC);
+	gtk_text_view_set_justification((GtkTextView *)arg0, arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1text_1view_1set_1justification_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1text_1view_1set_1tabs
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1text_1view_1set_1tabs)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1text_1view_1set_1tabs_FUNC);
+	gtk_text_view_set_tabs((GtkTextView *)arg0, (PangoTabArray *)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1text_1view_1set_1tabs_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1text_1view_1set_1wrap_1mode
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1text_1view_1set_1wrap_1mode)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1text_1view_1set_1wrap_1mode_FUNC);
+	gtk_text_view_set_wrap_mode((GtkTextView *)arg0, arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1text_1view_1set_1wrap_1mode_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1text_1view_1window_1to_1buffer_1coords
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1text_1view_1window_1to_1buffer_1coords)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jintArray arg4, jintArray arg5)
+{
+	jint *lparg4=NULL;
+	jint *lparg5=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1text_1view_1window_1to_1buffer_1coords_FUNC);
+	if (arg4) if ((lparg4 = (*env)->GetIntArrayElements(env, arg4, NULL)) == NULL) goto fail;
+	if (arg5) if ((lparg5 = (*env)->GetIntArrayElements(env, arg5, NULL)) == NULL) goto fail;
+	gtk_text_view_window_to_buffer_coords((GtkTextView *)arg0, (GtkTextWindowType)arg1, (gint)arg2, (gint)arg3, (gint *)lparg4, (gint *)lparg5);
+fail:
+	if (arg5 && lparg5) (*env)->ReleaseIntArrayElements(env, arg5, lparg5, 0);
+	if (arg4 && lparg4) (*env)->ReleaseIntArrayElements(env, arg4, lparg4, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1text_1view_1window_1to_1buffer_1coords_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1timeout_1add
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1timeout_1add)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1timeout_1add_FUNC);
+	rc = (jint)gtk_timeout_add((guint32)arg0, (GtkFunction)arg1, (gpointer)arg2);
+	OS_NATIVE_EXIT(env, that, _1gtk_1timeout_1add_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1timeout_1remove
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1timeout_1remove)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1timeout_1remove_FUNC);
+	gtk_timeout_remove((guint)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1timeout_1remove_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1toggle_1button_1get_1active
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1gtk_1toggle_1button_1get_1active)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1toggle_1button_1get_1active_FUNC);
+	rc = (jboolean)gtk_toggle_button_get_active((GtkToggleButton *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1toggle_1button_1get_1active_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1toggle_1button_1get_1inconsistent
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1gtk_1toggle_1button_1get_1inconsistent)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1toggle_1button_1get_1inconsistent_FUNC);
+	rc = (jboolean)gtk_toggle_button_get_inconsistent((GtkToggleButton *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1toggle_1button_1get_1inconsistent_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1toggle_1button_1new
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1toggle_1button_1new)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1toggle_1button_1new_FUNC);
+	rc = (jint)gtk_toggle_button_new();
+	OS_NATIVE_EXIT(env, that, _1gtk_1toggle_1button_1new_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1toggle_1button_1set_1active
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1toggle_1button_1set_1active)
+	(JNIEnv *env, jclass that, jint arg0, jboolean arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1toggle_1button_1set_1active_FUNC);
+	gtk_toggle_button_set_active((GtkToggleButton *)arg0, (gboolean)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1toggle_1button_1set_1active_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1toggle_1button_1set_1inconsistent
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1toggle_1button_1set_1inconsistent)
+	(JNIEnv *env, jclass that, jint arg0, jboolean arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1toggle_1button_1set_1inconsistent_FUNC);
+	gtk_toggle_button_set_inconsistent((GtkToggleButton *)arg0, (gboolean)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1toggle_1button_1set_1inconsistent_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1toggle_1button_1set_1mode
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1toggle_1button_1set_1mode)
+	(JNIEnv *env, jclass that, jint arg0, jboolean arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1toggle_1button_1set_1mode_FUNC);
+	gtk_toggle_button_set_mode((GtkToggleButton *)arg0, (gboolean)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1toggle_1button_1set_1mode_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1toolbar_1insert_1widget
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1toolbar_1insert_1widget)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jbyteArray arg2, jbyteArray arg3, jint arg4)
+{
+	jbyte *lparg2=NULL;
+	jbyte *lparg3=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1toolbar_1insert_1widget_FUNC);
+	if (arg2) if ((lparg2 = (*env)->GetByteArrayElements(env, arg2, NULL)) == NULL) goto fail;
+	if (arg3) if ((lparg3 = (*env)->GetByteArrayElements(env, arg3, NULL)) == NULL) goto fail;
+	gtk_toolbar_insert_widget((GtkToolbar *)arg0, (GtkWidget *)arg1, (const char *)lparg2, (const char *)lparg3, (gint)arg4);
+fail:
+	if (arg3 && lparg3) (*env)->ReleaseByteArrayElements(env, arg3, lparg3, 0);
+	if (arg2 && lparg2) (*env)->ReleaseByteArrayElements(env, arg2, lparg2, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1toolbar_1insert_1widget_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1toolbar_1new
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1toolbar_1new)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1toolbar_1new_FUNC);
+	rc = (jint)gtk_toolbar_new();
+	OS_NATIVE_EXIT(env, that, _1gtk_1toolbar_1new_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1toolbar_1set_1orientation
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1toolbar_1set_1orientation)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1toolbar_1set_1orientation_FUNC);
+	gtk_toolbar_set_orientation((GtkToolbar *)arg0, (GtkOrientation)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1toolbar_1set_1orientation_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1tooltip_1trigger_1tooltip_1query
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1tooltip_1trigger_1tooltip_1query)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1tooltip_1trigger_1tooltip_1query_FUNC);
+/*
+	gtk_tooltip_trigger_tooltip_query((GdkDisplay*)arg0);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef void (*FPTR)(GdkDisplay*);
+		static FPTR fptr;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_tooltip_trigger_tooltip_query_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_tooltip_trigger_tooltip_query");
+			initialized = 1;
+		}
+		if (fptr) {
+			(*fptr)((GdkDisplay*)arg0);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1tooltip_1trigger_1tooltip_1query_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1tooltips_1data_1get
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1tooltips_1data_1get)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1tooltips_1data_1get_FUNC);
+	rc = (jint)gtk_tooltips_data_get((GtkWidget *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tooltips_1data_1get_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1tooltips_1disable
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1tooltips_1disable)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1tooltips_1disable_FUNC);
+	gtk_tooltips_disable((GtkTooltips *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tooltips_1disable_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1tooltips_1enable
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1tooltips_1enable)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1tooltips_1enable_FUNC);
+	gtk_tooltips_enable((GtkTooltips *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tooltips_1enable_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1tooltips_1force_1window
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1tooltips_1force_1window)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1tooltips_1force_1window_FUNC);
+	gtk_tooltips_force_window((GtkTooltips *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tooltips_1force_1window_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1tooltips_1new
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1tooltips_1new)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1tooltips_1new_FUNC);
+	rc = (jint)gtk_tooltips_new();
+	OS_NATIVE_EXIT(env, that, _1gtk_1tooltips_1new_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1tooltips_1set_1tip
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1tooltips_1set_1tip)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jbyteArray arg2, jbyteArray arg3)
+{
+	jbyte *lparg2=NULL;
+	jbyte *lparg3=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1tooltips_1set_1tip_FUNC);
+	if (arg2) if ((lparg2 = (*env)->GetByteArrayElements(env, arg2, NULL)) == NULL) goto fail;
+	if (arg3) if ((lparg3 = (*env)->GetByteArrayElements(env, arg3, NULL)) == NULL) goto fail;
+	gtk_tooltips_set_tip((GtkTooltips *)arg0, (GtkWidget *)arg1, (const gchar *)lparg2, (const gchar *)lparg3);
+fail:
+	if (arg3 && lparg3) (*env)->ReleaseByteArrayElements(env, arg3, lparg3, 0);
+	if (arg2 && lparg2) (*env)->ReleaseByteArrayElements(env, arg2, lparg2, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tooltips_1set_1tip_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1model_1get__III_3II
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1tree_1model_1get__III_3II)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jintArray arg3, jint arg4)
+{
+	jint *lparg3=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1model_1get__III_3II_FUNC);
+	if (arg3) if ((lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL)) == NULL) goto fail;
+	gtk_tree_model_get((GtkTreeModel *)arg0, (GtkTreeIter *)arg1, arg2, lparg3, arg4);
+fail:
+	if (arg3 && lparg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1model_1get__III_3II_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1model_1get__III_3JI
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1tree_1model_1get__III_3JI)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jlongArray arg3, jint arg4)
+{
+	jlong *lparg3=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1model_1get__III_3JI_FUNC);
+	if (arg3) if ((lparg3 = (*env)->GetLongArrayElements(env, arg3, NULL)) == NULL) goto fail;
+	gtk_tree_model_get((GtkTreeModel *)arg0, (GtkTreeIter *)arg1, arg2, lparg3, arg4);
+fail:
+	if (arg3 && lparg3) (*env)->ReleaseLongArrayElements(env, arg3, lparg3, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1model_1get__III_3JI_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1model_1get_1iter
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1gtk_1tree_1model_1get_1iter)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1model_1get_1iter_FUNC);
+	rc = (jboolean)gtk_tree_model_get_iter((GtkTreeModel *)arg0, (GtkTreeIter *)arg1, (GtkTreePath *)arg2);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1model_1get_1iter_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1model_1get_1iter_1first
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1gtk_1tree_1model_1get_1iter_1first)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1model_1get_1iter_1first_FUNC);
+	rc = (jboolean)gtk_tree_model_get_iter_first((GtkTreeModel *)arg0, (GtkTreeIter *)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1model_1get_1iter_1first_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1model_1get_1n_1columns
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1tree_1model_1get_1n_1columns)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1model_1get_1n_1columns_FUNC);
+	rc = (jint)gtk_tree_model_get_n_columns((GtkTreeModel *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1model_1get_1n_1columns_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1model_1get_1path
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1tree_1model_1get_1path)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1model_1get_1path_FUNC);
+	rc = (jint)gtk_tree_model_get_path((GtkTreeModel *)arg0, (GtkTreeIter *)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1model_1get_1path_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1model_1get_1type
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1tree_1model_1get_1type)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1model_1get_1type_FUNC);
+	rc = (jint)gtk_tree_model_get_type();
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1model_1get_1type_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1model_1iter_1children
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1gtk_1tree_1model_1iter_1children)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1model_1iter_1children_FUNC);
+	rc = (jboolean)gtk_tree_model_iter_children((GtkTreeModel *)arg0, (GtkTreeIter *)arg1, (GtkTreeIter *)arg2);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1model_1iter_1children_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1model_1iter_1n_1children
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1tree_1model_1iter_1n_1children)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1model_1iter_1n_1children_FUNC);
+	rc = (jint)gtk_tree_model_iter_n_children((GtkTreeModel *)arg0, (GtkTreeIter *)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1model_1iter_1n_1children_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1model_1iter_1next
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1gtk_1tree_1model_1iter_1next)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1model_1iter_1next_FUNC);
+	rc = (jboolean)gtk_tree_model_iter_next((GtkTreeModel *)arg0, (GtkTreeIter *)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1model_1iter_1next_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1model_1iter_1nth_1child
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1gtk_1tree_1model_1iter_1nth_1child)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3)
+{
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1model_1iter_1nth_1child_FUNC);
+	rc = (jboolean)gtk_tree_model_iter_nth_child((GtkTreeModel *)arg0, (GtkTreeIter *)arg1, (GtkTreeIter *)arg2, arg3);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1model_1iter_1nth_1child_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1path_1append_1index
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1tree_1path_1append_1index)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1path_1append_1index_FUNC);
+	gtk_tree_path_append_index((GtkTreePath *)arg0, arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1path_1append_1index_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1path_1compare
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1tree_1path_1compare)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1path_1compare_FUNC);
+	rc = (jint)gtk_tree_path_compare((const GtkTreePath *)arg0, (const GtkTreePath *)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1path_1compare_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1path_1down
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1tree_1path_1down)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1path_1down_FUNC);
+	gtk_tree_path_down((GtkTreePath *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1path_1down_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1path_1free
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1tree_1path_1free)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1path_1free_FUNC);
+	gtk_tree_path_free((GtkTreePath *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1path_1free_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1path_1get_1depth
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1tree_1path_1get_1depth)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1path_1get_1depth_FUNC);
+	rc = (jint)gtk_tree_path_get_depth((GtkTreePath *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1path_1get_1depth_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1path_1get_1indices
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1tree_1path_1get_1indices)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1path_1get_1indices_FUNC);
+	rc = (jint)gtk_tree_path_get_indices((GtkTreePath *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1path_1get_1indices_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1path_1new
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1tree_1path_1new)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1path_1new_FUNC);
+	rc = (jint)gtk_tree_path_new();
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1path_1new_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1path_1new_1first
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1tree_1path_1new_1first)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1path_1new_1first_FUNC);
+	rc = (jint)gtk_tree_path_new_first();
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1path_1new_1first_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1path_1new_1from_1string__I
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1tree_1path_1new_1from_1string__I)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1path_1new_1from_1string__I_FUNC);
+	rc = (jint)gtk_tree_path_new_from_string((const gchar *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1path_1new_1from_1string__I_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1path_1new_1from_1string___3B
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1tree_1path_1new_1from_1string___3B)
+	(JNIEnv *env, jclass that, jbyteArray arg0)
+{
+	jbyte *lparg0=NULL;
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1path_1new_1from_1string___3B_FUNC);
+	if (arg0) if ((lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL)) == NULL) goto fail;
+	rc = (jint)gtk_tree_path_new_from_string((const gchar *)lparg0);
+fail:
+	if (arg0 && lparg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1path_1new_1from_1string___3B_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1path_1next
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1tree_1path_1next)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1path_1next_FUNC);
+	gtk_tree_path_next((GtkTreePath *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1path_1next_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1path_1prev
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1gtk_1tree_1path_1prev)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1path_1prev_FUNC);
+	rc = (jboolean)gtk_tree_path_prev((GtkTreePath *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1path_1prev_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1path_1up
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1gtk_1tree_1path_1up)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1path_1up_FUNC);
+	rc = (jboolean)gtk_tree_path_up((GtkTreePath *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1path_1up_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1selection_1count_1selected_1rows
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1tree_1selection_1count_1selected_1rows)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1selection_1count_1selected_1rows_FUNC);
+/*
+	rc = (jint)gtk_tree_selection_count_selected_rows((GtkTreeSelection *)arg0);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jint (*FPTR)(GtkTreeSelection *);
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_tree_selection_count_selected_rows_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_tree_selection_count_selected_rows");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jint)(*fptr)((GtkTreeSelection *)arg0);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1selection_1count_1selected_1rows_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1selection_1get_1selected
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1gtk_1tree_1selection_1get_1selected)
+	(JNIEnv *env, jclass that, jint arg0, jintArray arg1, jint arg2)
+{
+	jint *lparg1=NULL;
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1selection_1get_1selected_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	rc = (jboolean)gtk_tree_selection_get_selected((GtkTreeSelection *)arg0, (GtkTreeModel **)lparg1, (GtkTreeIter *)arg2);
+fail:
+	if (arg1 && lparg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1selection_1get_1selected_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1selection_1get_1selected_1rows
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1tree_1selection_1get_1selected_1rows)
+	(JNIEnv *env, jclass that, jint arg0, jintArray arg1)
+{
+	jint *lparg1=NULL;
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1selection_1get_1selected_1rows_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL)) == NULL) goto fail;
+/*
+	rc = (jint)gtk_tree_selection_get_selected_rows((GtkTreeSelection *)arg0, (GtkTreeModel **)lparg1);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jint (*FPTR)(GtkTreeSelection *, GtkTreeModel **);
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_tree_selection_get_selected_rows_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_tree_selection_get_selected_rows");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jint)(*fptr)((GtkTreeSelection *)arg0, (GtkTreeModel **)lparg1);
+		}
+	}
+fail:
+	if (arg1 && lparg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1selection_1get_1selected_1rows_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1selection_1path_1is_1selected
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1gtk_1tree_1selection_1path_1is_1selected)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1selection_1path_1is_1selected_FUNC);
+	rc = (jboolean)gtk_tree_selection_path_is_selected((GtkTreeSelection *)arg0, (GtkTreePath *)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1selection_1path_1is_1selected_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1selection_1select_1all
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1tree_1selection_1select_1all)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1selection_1select_1all_FUNC);
+	gtk_tree_selection_select_all((GtkTreeSelection *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1selection_1select_1all_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1selection_1select_1iter
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1tree_1selection_1select_1iter)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1selection_1select_1iter_FUNC);
+	gtk_tree_selection_select_iter((GtkTreeSelection *)arg0, (GtkTreeIter *)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1selection_1select_1iter_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1selection_1selected_1foreach
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1tree_1selection_1selected_1foreach)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1selection_1selected_1foreach_FUNC);
+	gtk_tree_selection_selected_foreach((GtkTreeSelection *)arg0, (GtkTreeSelectionForeachFunc)arg1, (gpointer)arg2);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1selection_1selected_1foreach_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1selection_1set_1mode
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1tree_1selection_1set_1mode)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1selection_1set_1mode_FUNC);
+	gtk_tree_selection_set_mode((GtkTreeSelection *)arg0, (GtkSelectionMode)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1selection_1set_1mode_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1selection_1unselect_1all
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1tree_1selection_1unselect_1all)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1selection_1unselect_1all_FUNC);
+	gtk_tree_selection_unselect_all((GtkTreeSelection *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1selection_1unselect_1all_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1selection_1unselect_1iter
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1tree_1selection_1unselect_1iter)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1selection_1unselect_1iter_FUNC);
+	gtk_tree_selection_unselect_iter((GtkTreeSelection *)arg0, (GtkTreeIter *)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1selection_1unselect_1iter_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1store_1append
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1tree_1store_1append)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1store_1append_FUNC);
+	gtk_tree_store_append((GtkTreeStore *)arg0, (GtkTreeIter *)arg1, (GtkTreeIter *)arg2);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1store_1append_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1store_1clear
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1tree_1store_1clear)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1store_1clear_FUNC);
+	gtk_tree_store_clear((GtkTreeStore *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1store_1clear_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1store_1insert
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1tree_1store_1insert)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1store_1insert_FUNC);
+	gtk_tree_store_insert((GtkTreeStore *)arg0, (GtkTreeIter *)arg1, (GtkTreeIter *)arg2, (gint)arg3);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1store_1insert_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1store_1newv
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1tree_1store_1newv)
+	(JNIEnv *env, jclass that, jint arg0, jintArray arg1)
+{
+	jint *lparg1=NULL;
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1store_1newv_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	rc = (jint)gtk_tree_store_newv(arg0, (GType *)lparg1);
+fail:
+	if (arg1 && lparg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1store_1newv_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1store_1remove
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1tree_1store_1remove)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1store_1remove_FUNC);
+	gtk_tree_store_remove((GtkTreeStore *)arg0, (GtkTreeIter *)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1store_1remove_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1store_1set__IIIII
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1tree_1store_1set__IIIII)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1store_1set__IIIII_FUNC);
+	gtk_tree_store_set((GtkTreeStore *)arg0, (GtkTreeIter *)arg1, arg2, arg3, arg4);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1store_1set__IIIII_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1store_1set__IIIJI
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1tree_1store_1set__IIIJI)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jlong arg3, jint arg4)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1store_1set__IIIJI_FUNC);
+	gtk_tree_store_set((GtkTreeStore *)arg0, (GtkTreeIter *)arg1, arg2, arg3, arg4);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1store_1set__IIIJI_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1store_1set__IIILorg_eclipse_swt_internal_gtk_GdkColor_2I
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1tree_1store_1set__IIILorg_eclipse_swt_internal_gtk_GdkColor_2I)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jobject arg3, jint arg4)
+{
+	GdkColor _arg3, *lparg3=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1store_1set__IIILorg_eclipse_swt_internal_gtk_GdkColor_2I_FUNC);
+	if (arg3) if ((lparg3 = getGdkColorFields(env, arg3, &_arg3)) == NULL) goto fail;
+	gtk_tree_store_set((GtkTreeStore *)arg0, (GtkTreeIter *)arg1, arg2, lparg3, arg4);
+fail:
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1store_1set__IIILorg_eclipse_swt_internal_gtk_GdkColor_2I_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1store_1set__IIIZI
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1tree_1store_1set__IIIZI)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jboolean arg3, jint arg4)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1store_1set__IIIZI_FUNC);
+	gtk_tree_store_set((GtkTreeStore *)arg0, (GtkTreeIter *)arg1, arg2, arg3, arg4);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1store_1set__IIIZI_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1store_1set__III_3BI
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1tree_1store_1set__III_3BI)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jbyteArray arg3, jint arg4)
+{
+	jbyte *lparg3=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1store_1set__III_3BI_FUNC);
+	if (arg3) if ((lparg3 = (*env)->GetByteArrayElements(env, arg3, NULL)) == NULL) goto fail;
+	gtk_tree_store_set((GtkTreeStore *)arg0, (GtkTreeIter *)arg1, arg2, lparg3, arg4);
+fail:
+	if (arg3 && lparg3) (*env)->ReleaseByteArrayElements(env, arg3, lparg3, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1store_1set__III_3BI_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1view_1collapse_1row
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1gtk_1tree_1view_1collapse_1row)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1view_1collapse_1row_FUNC);
+	rc = (jboolean)gtk_tree_view_collapse_row((GtkTreeView *)arg0, (GtkTreePath *)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1view_1collapse_1row_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1view_1column_1add_1attribute
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1tree_1view_1column_1add_1attribute)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jbyteArray arg2, jint arg3)
+{
+	jbyte *lparg2=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1view_1column_1add_1attribute_FUNC);
+	if (arg2) if ((lparg2 = (*env)->GetByteArrayElements(env, arg2, NULL)) == NULL) goto fail;
+	gtk_tree_view_column_add_attribute((GtkTreeViewColumn *)arg0, (GtkCellRenderer *)arg1, (const gchar *)lparg2, (gint)arg3);
+fail:
+	if (arg2 && lparg2) (*env)->ReleaseByteArrayElements(env, arg2, lparg2, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1view_1column_1add_1attribute_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1view_1column_1cell_1get_1position
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1gtk_1tree_1view_1column_1cell_1get_1position)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jintArray arg2, jintArray arg3)
+{
+	jint *lparg2=NULL;
+	jint *lparg3=NULL;
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1view_1column_1cell_1get_1position_FUNC);
+	if (arg2) if ((lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL)) == NULL) goto fail;
+	if (arg3) if ((lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL)) == NULL) goto fail;
+/*
+	rc = (jboolean)gtk_tree_view_column_cell_get_position((GtkTreeViewColumn *)arg0, (GtkCellRenderer *)arg1, (gint *)lparg2, (gint *)lparg3);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jboolean (*FPTR)(GtkTreeViewColumn *, GtkCellRenderer *, gint *, gint *);
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_tree_view_column_cell_get_position_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_tree_view_column_cell_get_position");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jboolean)(*fptr)((GtkTreeViewColumn *)arg0, (GtkCellRenderer *)arg1, (gint *)lparg2, (gint *)lparg3);
+		}
+	}
+fail:
+	if (arg3 && lparg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0);
+	if (arg2 && lparg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1view_1column_1cell_1get_1position_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1view_1column_1cell_1get_1size
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1tree_1view_1column_1cell_1get_1size)
+	(JNIEnv *env, jclass that, jint arg0, jobject arg1, jintArray arg2, jintArray arg3, jintArray arg4, jintArray arg5)
+{
+	GdkRectangle _arg1, *lparg1=NULL;
+	jint *lparg2=NULL;
+	jint *lparg3=NULL;
+	jint *lparg4=NULL;
+	jint *lparg5=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1view_1column_1cell_1get_1size_FUNC);
+	if (arg1) if ((lparg1 = &_arg1) == NULL) goto fail;
+	if (arg2) if ((lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL)) == NULL) goto fail;
+	if (arg3) if ((lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL)) == NULL) goto fail;
+	if (arg4) if ((lparg4 = (*env)->GetIntArrayElements(env, arg4, NULL)) == NULL) goto fail;
+	if (arg5) if ((lparg5 = (*env)->GetIntArrayElements(env, arg5, NULL)) == NULL) goto fail;
+	gtk_tree_view_column_cell_get_size((GtkTreeViewColumn *)arg0, (GdkRectangle *)lparg1, (gint *)lparg2, (gint *)lparg3, (gint *)lparg4, (gint *)lparg5);
+fail:
+	if (arg5 && lparg5) (*env)->ReleaseIntArrayElements(env, arg5, lparg5, 0);
+	if (arg4 && lparg4) (*env)->ReleaseIntArrayElements(env, arg4, lparg4, 0);
+	if (arg3 && lparg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0);
+	if (arg2 && lparg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
+	if (arg1 && lparg1) setGdkRectangleFields(env, arg1, lparg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1view_1column_1cell_1get_1size_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1view_1column_1cell_1set_1cell_1data
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1tree_1view_1column_1cell_1set_1cell_1data)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jboolean arg3, jboolean arg4)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1view_1column_1cell_1set_1cell_1data_FUNC);
+	gtk_tree_view_column_cell_set_cell_data((GtkTreeViewColumn *)arg0, (GtkTreeModel *)arg1, (GtkTreeIter *)arg2, arg3, arg4);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1view_1column_1cell_1set_1cell_1data_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1view_1column_1clear
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1tree_1view_1column_1clear)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1view_1column_1clear_FUNC);
+	gtk_tree_view_column_clear((GtkTreeViewColumn *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1view_1column_1clear_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1view_1column_1get_1cell_1renderers
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1tree_1view_1column_1get_1cell_1renderers)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1view_1column_1get_1cell_1renderers_FUNC);
+	rc = (jint)gtk_tree_view_column_get_cell_renderers((GtkTreeViewColumn *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1view_1column_1get_1cell_1renderers_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1view_1column_1get_1fixed_1width
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1tree_1view_1column_1get_1fixed_1width)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1view_1column_1get_1fixed_1width_FUNC);
+	rc = (jint)gtk_tree_view_column_get_fixed_width((GtkTreeViewColumn *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1view_1column_1get_1fixed_1width_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1view_1column_1get_1reorderable
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1gtk_1tree_1view_1column_1get_1reorderable)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1view_1column_1get_1reorderable_FUNC);
+	rc = (jboolean)gtk_tree_view_column_get_reorderable((GtkTreeViewColumn *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1view_1column_1get_1reorderable_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1view_1column_1get_1resizable
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1gtk_1tree_1view_1column_1get_1resizable)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1view_1column_1get_1resizable_FUNC);
+	rc = (jboolean)gtk_tree_view_column_get_resizable((GtkTreeViewColumn *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1view_1column_1get_1resizable_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1view_1column_1get_1sizing
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1tree_1view_1column_1get_1sizing)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1view_1column_1get_1sizing_FUNC);
+	rc = (jint)gtk_tree_view_column_get_sizing((GtkTreeViewColumn *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1view_1column_1get_1sizing_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1view_1column_1get_1sort_1indicator
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1gtk_1tree_1view_1column_1get_1sort_1indicator)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1view_1column_1get_1sort_1indicator_FUNC);
+	rc = (jboolean)gtk_tree_view_column_get_sort_indicator((GtkTreeViewColumn *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1view_1column_1get_1sort_1indicator_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1view_1column_1get_1sort_1order
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1tree_1view_1column_1get_1sort_1order)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1view_1column_1get_1sort_1order_FUNC);
+	rc = (jint)gtk_tree_view_column_get_sort_order((GtkTreeViewColumn *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1view_1column_1get_1sort_1order_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1view_1column_1get_1spacing
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1tree_1view_1column_1get_1spacing)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1view_1column_1get_1spacing_FUNC);
+	rc = (jint)gtk_tree_view_column_get_spacing((GtkTreeViewColumn *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1view_1column_1get_1spacing_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1view_1column_1get_1visible
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1gtk_1tree_1view_1column_1get_1visible)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1view_1column_1get_1visible_FUNC);
+	rc = (jboolean)gtk_tree_view_column_get_visible((GtkTreeViewColumn *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1view_1column_1get_1visible_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1view_1column_1get_1width
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1tree_1view_1column_1get_1width)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1view_1column_1get_1width_FUNC);
+	rc = (jint)gtk_tree_view_column_get_width((GtkTreeViewColumn *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1view_1column_1get_1width_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1view_1column_1new
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1tree_1view_1column_1new)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1view_1column_1new_FUNC);
+	rc = (jint)gtk_tree_view_column_new();
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1view_1column_1new_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1view_1column_1pack_1end
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1tree_1view_1column_1pack_1end)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jboolean arg2)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1view_1column_1pack_1end_FUNC);
+	gtk_tree_view_column_pack_end((GtkTreeViewColumn *)arg0, (GtkCellRenderer *)arg1, (gboolean)arg2);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1view_1column_1pack_1end_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1view_1column_1pack_1start
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1tree_1view_1column_1pack_1start)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jboolean arg2)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1view_1column_1pack_1start_FUNC);
+	gtk_tree_view_column_pack_start((GtkTreeViewColumn *)arg0, (GtkCellRenderer *)arg1, (gboolean)arg2);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1view_1column_1pack_1start_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1view_1column_1set_1alignment
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1tree_1view_1column_1set_1alignment)
+	(JNIEnv *env, jclass that, jint arg0, jfloat arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1view_1column_1set_1alignment_FUNC);
+	gtk_tree_view_column_set_alignment((GtkTreeViewColumn *)arg0, arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1view_1column_1set_1alignment_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1view_1column_1set_1cell_1data_1func
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1tree_1view_1column_1set_1cell_1data_1func)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1view_1column_1set_1cell_1data_1func_FUNC);
+	gtk_tree_view_column_set_cell_data_func((GtkTreeViewColumn *)arg0, (GtkCellRenderer *)arg1, (GtkTreeCellDataFunc)arg2, (gpointer)arg3, (GtkDestroyNotify)arg4);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1view_1column_1set_1cell_1data_1func_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1view_1column_1set_1clickable
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1tree_1view_1column_1set_1clickable)
+	(JNIEnv *env, jclass that, jint arg0, jboolean arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1view_1column_1set_1clickable_FUNC);
+	gtk_tree_view_column_set_clickable((GtkTreeViewColumn *)arg0, (gboolean)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1view_1column_1set_1clickable_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1view_1column_1set_1fixed_1width
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1tree_1view_1column_1set_1fixed_1width)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1view_1column_1set_1fixed_1width_FUNC);
+	gtk_tree_view_column_set_fixed_width((GtkTreeViewColumn *)arg0, (gint)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1view_1column_1set_1fixed_1width_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1view_1column_1set_1min_1width
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1tree_1view_1column_1set_1min_1width)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1view_1column_1set_1min_1width_FUNC);
+	gtk_tree_view_column_set_min_width((GtkTreeViewColumn *)arg0, (gint)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1view_1column_1set_1min_1width_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1view_1column_1set_1reorderable
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1tree_1view_1column_1set_1reorderable)
+	(JNIEnv *env, jclass that, jint arg0, jboolean arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1view_1column_1set_1reorderable_FUNC);
+	gtk_tree_view_column_set_reorderable((GtkTreeViewColumn *)arg0, (gboolean)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1view_1column_1set_1reorderable_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1view_1column_1set_1resizable
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1tree_1view_1column_1set_1resizable)
+	(JNIEnv *env, jclass that, jint arg0, jboolean arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1view_1column_1set_1resizable_FUNC);
+	gtk_tree_view_column_set_resizable((GtkTreeViewColumn *)arg0, (gboolean)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1view_1column_1set_1resizable_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1view_1column_1set_1sizing
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1tree_1view_1column_1set_1sizing)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1view_1column_1set_1sizing_FUNC);
+	gtk_tree_view_column_set_sizing((GtkTreeViewColumn *)arg0, (GtkTreeViewColumnSizing)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1view_1column_1set_1sizing_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1view_1column_1set_1sort_1indicator
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1tree_1view_1column_1set_1sort_1indicator)
+	(JNIEnv *env, jclass that, jint arg0, jboolean arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1view_1column_1set_1sort_1indicator_FUNC);
+	gtk_tree_view_column_set_sort_indicator((GtkTreeViewColumn *)arg0, (gboolean)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1view_1column_1set_1sort_1indicator_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1view_1column_1set_1sort_1order
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1tree_1view_1column_1set_1sort_1order)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1view_1column_1set_1sort_1order_FUNC);
+	gtk_tree_view_column_set_sort_order((GtkTreeViewColumn *)arg0, (GtkSortType)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1view_1column_1set_1sort_1order_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1view_1column_1set_1title
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1tree_1view_1column_1set_1title)
+	(JNIEnv *env, jclass that, jint arg0, jbyteArray arg1)
+{
+	jbyte *lparg1=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1view_1column_1set_1title_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	gtk_tree_view_column_set_title((GtkTreeViewColumn *)arg0, (const gchar *)lparg1);
+fail:
+	if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1view_1column_1set_1title_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1view_1column_1set_1visible
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1tree_1view_1column_1set_1visible)
+	(JNIEnv *env, jclass that, jint arg0, jboolean arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1view_1column_1set_1visible_FUNC);
+	gtk_tree_view_column_set_visible((GtkTreeViewColumn *)arg0, arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1view_1column_1set_1visible_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1view_1column_1set_1widget
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1tree_1view_1column_1set_1widget)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1view_1column_1set_1widget_FUNC);
+	gtk_tree_view_column_set_widget((GtkTreeViewColumn *)arg0, (GtkWidget *)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1view_1column_1set_1widget_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1view_1create_1row_1drag_1icon
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1tree_1view_1create_1row_1drag_1icon)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1view_1create_1row_1drag_1icon_FUNC);
+	rc = (jint)gtk_tree_view_create_row_drag_icon((GtkTreeView *)arg0, (GtkTreePath *)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1view_1create_1row_1drag_1icon_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1view_1expand_1row
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1gtk_1tree_1view_1expand_1row)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jboolean arg2)
+{
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1view_1expand_1row_FUNC);
+	rc = (jboolean)gtk_tree_view_expand_row((GtkTreeView *)arg0, (GtkTreePath *)arg1, (gboolean)arg2);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1view_1expand_1row_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1view_1get_1background_1area
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1tree_1view_1get_1background_1area)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jobject arg3)
+{
+	GdkRectangle _arg3, *lparg3=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1view_1get_1background_1area_FUNC);
+	if (arg3) if ((lparg3 = getGdkRectangleFields(env, arg3, &_arg3)) == NULL) goto fail;
+	gtk_tree_view_get_background_area((GtkTreeView *)arg0, (GtkTreePath *)arg1, (GtkTreeViewColumn *)arg2, (GdkRectangle *)lparg3);
+fail:
+	if (arg3 && lparg3) setGdkRectangleFields(env, arg3, lparg3);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1view_1get_1background_1area_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1view_1get_1bin_1window
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1tree_1view_1get_1bin_1window)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1view_1get_1bin_1window_FUNC);
+	rc = (jint)gtk_tree_view_get_bin_window((GtkTreeView *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1view_1get_1bin_1window_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1view_1get_1cell_1area
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1tree_1view_1get_1cell_1area)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jobject arg3)
+{
+	GdkRectangle _arg3, *lparg3=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1view_1get_1cell_1area_FUNC);
+	if (arg3) if ((lparg3 = &_arg3) == NULL) goto fail;
+	gtk_tree_view_get_cell_area((GtkTreeView *)arg0, (GtkTreePath *)arg1, (GtkTreeViewColumn *)arg2, (GdkRectangle *)lparg3);
+fail:
+	if (arg3 && lparg3) setGdkRectangleFields(env, arg3, lparg3);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1view_1get_1cell_1area_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1view_1get_1column
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1tree_1view_1get_1column)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1view_1get_1column_FUNC);
+	rc = (jint)gtk_tree_view_get_column((GtkTreeView *)arg0, (gint)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1view_1get_1column_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1view_1get_1columns
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1tree_1view_1get_1columns)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1view_1get_1columns_FUNC);
+	rc = (jint)gtk_tree_view_get_columns((GtkTreeView *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1view_1get_1columns_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1view_1get_1cursor
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1tree_1view_1get_1cursor)
+	(JNIEnv *env, jclass that, jint arg0, jintArray arg1, jintArray arg2)
+{
+	jint *lparg1=NULL;
+	jint *lparg2=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1view_1get_1cursor_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	if (arg2) if ((lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL)) == NULL) goto fail;
+	gtk_tree_view_get_cursor((GtkTreeView *)arg0, (GtkTreePath **)lparg1, (GtkTreeViewColumn **)lparg2);
+fail:
+	if (arg2 && lparg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
+	if (arg1 && lparg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1view_1get_1cursor_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1view_1get_1expander_1column
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1tree_1view_1get_1expander_1column)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1view_1get_1expander_1column_FUNC);
+	rc = (jint)gtk_tree_view_get_expander_column((GtkTreeView *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1view_1get_1expander_1column_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1view_1get_1headers_1visible
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1gtk_1tree_1view_1get_1headers_1visible)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1view_1get_1headers_1visible_FUNC);
+	rc = (jboolean)gtk_tree_view_get_headers_visible((GtkTreeView *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1view_1get_1headers_1visible_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1view_1get_1path_1at_1pos
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1gtk_1tree_1view_1get_1path_1at_1pos)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jintArray arg3, jintArray arg4, jintArray arg5, jintArray arg6)
+{
+	jint *lparg3=NULL;
+	jint *lparg4=NULL;
+	jint *lparg5=NULL;
+	jint *lparg6=NULL;
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1view_1get_1path_1at_1pos_FUNC);
+	if (arg3) if ((lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL)) == NULL) goto fail;
+	if (arg4) if ((lparg4 = (*env)->GetIntArrayElements(env, arg4, NULL)) == NULL) goto fail;
+	if (arg5) if ((lparg5 = (*env)->GetIntArrayElements(env, arg5, NULL)) == NULL) goto fail;
+	if (arg6) if ((lparg6 = (*env)->GetIntArrayElements(env, arg6, NULL)) == NULL) goto fail;
+	rc = (jboolean)gtk_tree_view_get_path_at_pos((GtkTreeView *)arg0, (gint)arg1, (gint)arg2, (GtkTreePath **)lparg3, (GtkTreeViewColumn **)lparg4, (gint *)lparg5, (gint *)lparg6);
+fail:
+	if (arg6 && lparg6) (*env)->ReleaseIntArrayElements(env, arg6, lparg6, 0);
+	if (arg5 && lparg5) (*env)->ReleaseIntArrayElements(env, arg5, lparg5, 0);
+	if (arg4 && lparg4) (*env)->ReleaseIntArrayElements(env, arg4, lparg4, 0);
+	if (arg3 && lparg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1view_1get_1path_1at_1pos_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1view_1get_1rules_1hint
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1gtk_1tree_1view_1get_1rules_1hint)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1view_1get_1rules_1hint_FUNC);
+	rc = (jboolean)gtk_tree_view_get_rules_hint((GtkTreeView *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1view_1get_1rules_1hint_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1view_1get_1selection
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1tree_1view_1get_1selection)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1view_1get_1selection_FUNC);
+	rc = (jint)gtk_tree_view_get_selection((GtkTreeView *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1view_1get_1selection_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1view_1get_1visible_1rect
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1tree_1view_1get_1visible_1rect)
+	(JNIEnv *env, jclass that, jint arg0, jobject arg1)
+{
+	GdkRectangle _arg1, *lparg1=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1view_1get_1visible_1rect_FUNC);
+	if (arg1) if ((lparg1 = &_arg1) == NULL) goto fail;
+	gtk_tree_view_get_visible_rect((GtkTreeView *)arg0, lparg1);
+fail:
+	if (arg1 && lparg1) setGdkRectangleFields(env, arg1, lparg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1view_1get_1visible_1rect_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1view_1insert_1column
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1tree_1view_1insert_1column)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1view_1insert_1column_FUNC);
+	rc = (jint)gtk_tree_view_insert_column((GtkTreeView *)arg0, (GtkTreeViewColumn *)arg1, (gint)arg2);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1view_1insert_1column_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1view_1move_1column_1after
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1tree_1view_1move_1column_1after)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1view_1move_1column_1after_FUNC);
+	gtk_tree_view_move_column_after((GtkTreeView *)arg0, (GtkTreeViewColumn *)arg1, (GtkTreeViewColumn *)arg2);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1view_1move_1column_1after_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1view_1new_1with_1model
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1tree_1view_1new_1with_1model)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1view_1new_1with_1model_FUNC);
+	rc = (jint)gtk_tree_view_new_with_model((GtkTreeModel *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1view_1new_1with_1model_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1view_1remove_1column
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1tree_1view_1remove_1column)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1view_1remove_1column_FUNC);
+	gtk_tree_view_remove_column((GtkTreeView *)arg0, (GtkTreeViewColumn *)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1view_1remove_1column_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1view_1row_1expanded
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1gtk_1tree_1view_1row_1expanded)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1view_1row_1expanded_FUNC);
+	rc = (jboolean)gtk_tree_view_row_expanded((GtkTreeView *)arg0, (GtkTreePath *)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1view_1row_1expanded_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1view_1scroll_1to_1cell
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1tree_1view_1scroll_1to_1cell)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jboolean arg3, jfloat arg4, jfloat arg5)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1view_1scroll_1to_1cell_FUNC);
+	gtk_tree_view_scroll_to_cell((GtkTreeView *)arg0, (GtkTreePath *)arg1, (GtkTreeViewColumn *)arg2, (gboolean)arg3, (gfloat)arg4, (gfloat)arg5);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1view_1scroll_1to_1cell_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1view_1scroll_1to_1point
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1tree_1view_1scroll_1to_1point)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1view_1scroll_1to_1point_FUNC);
+	gtk_tree_view_scroll_to_point((GtkTreeView *)arg0, (gint)arg1, (gint)arg2);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1view_1scroll_1to_1point_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1view_1set_1cursor
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1tree_1view_1set_1cursor)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jboolean arg3)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1view_1set_1cursor_FUNC);
+	gtk_tree_view_set_cursor((GtkTreeView *)arg0, (GtkTreePath *)arg1, (GtkTreeViewColumn *)arg2, arg3);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1view_1set_1cursor_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1view_1set_1drag_1dest_1row
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1tree_1view_1set_1drag_1dest_1row)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1view_1set_1drag_1dest_1row_FUNC);
+	gtk_tree_view_set_drag_dest_row((GtkTreeView *)arg0, (GtkTreePath *)arg1, arg2);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1view_1set_1drag_1dest_1row_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1view_1set_1enable_1search
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1tree_1view_1set_1enable_1search)
+	(JNIEnv *env, jclass that, jint arg0, jboolean arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1view_1set_1enable_1search_FUNC);
+	gtk_tree_view_set_enable_search((GtkTreeView *)arg0, arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1view_1set_1enable_1search_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1view_1set_1headers_1visible
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1tree_1view_1set_1headers_1visible)
+	(JNIEnv *env, jclass that, jint arg0, jboolean arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1view_1set_1headers_1visible_FUNC);
+	gtk_tree_view_set_headers_visible((GtkTreeView *)arg0, (gboolean)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1view_1set_1headers_1visible_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1view_1set_1model
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1tree_1view_1set_1model)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1view_1set_1model_FUNC);
+	gtk_tree_view_set_model((GtkTreeView *)arg0, (GtkTreeModel *)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1view_1set_1model_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1view_1set_1rules_1hint
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1tree_1view_1set_1rules_1hint)
+	(JNIEnv *env, jclass that, jint arg0, jboolean arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1view_1set_1rules_1hint_FUNC);
+	gtk_tree_view_set_rules_hint((GtkTreeView *)arg0, arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1view_1set_1rules_1hint_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1view_1set_1search_1column
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1tree_1view_1set_1search_1column)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1view_1set_1search_1column_FUNC);
+	gtk_tree_view_set_search_column((GtkTreeView *)arg0, (gint)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1view_1set_1search_1column_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1view_1tree_1to_1widget_1coords
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1tree_1view_1tree_1to_1widget_1coords)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jintArray arg3, jintArray arg4)
+{
+	jint *lparg3=NULL;
+	jint *lparg4=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1view_1tree_1to_1widget_1coords_FUNC);
+	if (arg3) if ((lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL)) == NULL) goto fail;
+	if (arg4) if ((lparg4 = (*env)->GetIntArrayElements(env, arg4, NULL)) == NULL) goto fail;
+	gtk_tree_view_tree_to_widget_coords((GtkTreeView *)arg0, (gint)arg1, (gint)arg2, (gint *)lparg3, (gint *)lparg4);
+fail:
+	if (arg4 && lparg4) (*env)->ReleaseIntArrayElements(env, arg4, lparg4, 0);
+	if (arg3 && lparg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1view_1tree_1to_1widget_1coords_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1view_1unset_1rows_1drag_1dest
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1tree_1view_1unset_1rows_1drag_1dest)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1view_1unset_1rows_1drag_1dest_FUNC);
+	gtk_tree_view_unset_rows_drag_dest((GtkTreeView *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1view_1unset_1rows_1drag_1dest_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1tree_1view_1widget_1to_1tree_1coords
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1tree_1view_1widget_1to_1tree_1coords)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jintArray arg3, jintArray arg4)
+{
+	jint *lparg3=NULL;
+	jint *lparg4=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1tree_1view_1widget_1to_1tree_1coords_FUNC);
+	if (arg3) if ((lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL)) == NULL) goto fail;
+	if (arg4) if ((lparg4 = (*env)->GetIntArrayElements(env, arg4, NULL)) == NULL) goto fail;
+	gtk_tree_view_widget_to_tree_coords((GtkTreeView *)arg0, arg1, arg2, lparg3, lparg4);
+fail:
+	if (arg4 && lparg4) (*env)->ReleaseIntArrayElements(env, arg4, lparg4, 0);
+	if (arg3 && lparg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1tree_1view_1widget_1to_1tree_1coords_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1vbox_1new
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1vbox_1new)
+	(JNIEnv *env, jclass that, jboolean arg0, jint arg1)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1vbox_1new_FUNC);
+	rc = (jint)gtk_vbox_new((gboolean)arg0, (gint)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1vbox_1new_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1vscale_1new
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1vscale_1new)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1vscale_1new_FUNC);
+	rc = (jint)gtk_vscale_new((GtkAdjustment *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1vscale_1new_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1vscrollbar_1new
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1vscrollbar_1new)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1vscrollbar_1new_FUNC);
+	rc = (jint)gtk_vscrollbar_new((GtkAdjustment *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1vscrollbar_1new_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1vseparator_1new
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1vseparator_1new)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1vseparator_1new_FUNC);
+	rc = (jint)gtk_vseparator_new();
+	OS_NATIVE_EXIT(env, that, _1gtk_1vseparator_1new_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1widget_1add_1accelerator
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1widget_1add_1accelerator)
+	(JNIEnv *env, jclass that, jint arg0, jbyteArray arg1, jint arg2, jint arg3, jint arg4, jint arg5)
+{
+	jbyte *lparg1=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1widget_1add_1accelerator_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	gtk_widget_add_accelerator((GtkWidget *)arg0, (const gchar *)lparg1, (GtkAccelGroup *)arg2, (guint)arg3, (GdkModifierType)arg4, arg5);
+fail:
+	if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1widget_1add_1accelerator_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1widget_1add_1events
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1widget_1add_1events)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1widget_1add_1events_FUNC);
+	gtk_widget_add_events((GtkWidget *)arg0, (gint)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1widget_1add_1events_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1widget_1child_1focus
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1gtk_1widget_1child_1focus)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1widget_1child_1focus_FUNC);
+	rc = (jboolean)gtk_widget_child_focus((GtkWidget *)arg0, arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1widget_1child_1focus_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1widget_1create_1pango_1layout__II
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1widget_1create_1pango_1layout__II)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1widget_1create_1pango_1layout__II_FUNC);
+	rc = (jint)gtk_widget_create_pango_layout((GtkWidget *)arg0, (const gchar *)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1widget_1create_1pango_1layout__II_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1widget_1create_1pango_1layout__I_3B
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1widget_1create_1pango_1layout__I_3B)
+	(JNIEnv *env, jclass that, jint arg0, jbyteArray arg1)
+{
+	jbyte *lparg1=NULL;
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1widget_1create_1pango_1layout__I_3B_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	rc = (jint)gtk_widget_create_pango_layout((GtkWidget *)arg0, (const gchar *)lparg1);
+fail:
+	if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1widget_1create_1pango_1layout__I_3B_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1widget_1destroy
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1widget_1destroy)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1widget_1destroy_FUNC);
+	gtk_widget_destroy((GtkWidget *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1widget_1destroy_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1widget_1event
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1gtk_1widget_1event)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1widget_1event_FUNC);
+	rc = (jboolean)gtk_widget_event((GtkWidget *)arg0, (GdkEvent *)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1widget_1event_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1widget_1get_1accessible
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1widget_1get_1accessible)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1widget_1get_1accessible_FUNC);
+	rc = (jint)gtk_widget_get_accessible((GtkWidget *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1widget_1get_1accessible_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1widget_1get_1child_1visible
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1gtk_1widget_1get_1child_1visible)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1widget_1get_1child_1visible_FUNC);
+	rc = (jboolean)gtk_widget_get_child_visible((GtkWidget *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1widget_1get_1child_1visible_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1widget_1get_1default_1direction
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1widget_1get_1default_1direction)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1widget_1get_1default_1direction_FUNC);
+	rc = (jint)gtk_widget_get_default_direction();
+	OS_NATIVE_EXIT(env, that, _1gtk_1widget_1get_1default_1direction_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1widget_1get_1default_1style
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1widget_1get_1default_1style)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1widget_1get_1default_1style_FUNC);
+	rc = (jint)gtk_widget_get_default_style();
+	OS_NATIVE_EXIT(env, that, _1gtk_1widget_1get_1default_1style_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1widget_1get_1direction
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1widget_1get_1direction)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1widget_1get_1direction_FUNC);
+	rc = (jint)gtk_widget_get_direction((GtkWidget *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1widget_1get_1direction_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1widget_1get_1events
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1widget_1get_1events)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1widget_1get_1events_FUNC);
+	rc = (jint)gtk_widget_get_events((GtkWidget *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1widget_1get_1events_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1widget_1get_1modifier_1style
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1widget_1get_1modifier_1style)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1widget_1get_1modifier_1style_FUNC);
+	rc = (jint)gtk_widget_get_modifier_style((GtkWidget *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1widget_1get_1modifier_1style_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1widget_1get_1pango_1context
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1widget_1get_1pango_1context)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1widget_1get_1pango_1context_FUNC);
+	rc = (jint)gtk_widget_get_pango_context((GtkWidget *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1widget_1get_1pango_1context_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1widget_1get_1parent
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1widget_1get_1parent)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1widget_1get_1parent_FUNC);
+	rc = (jint)gtk_widget_get_parent((GtkWidget *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1widget_1get_1parent_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1widget_1get_1size_1request
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1widget_1get_1size_1request)
+	(JNIEnv *env, jclass that, jint arg0, jintArray arg1, jintArray arg2)
+{
+	jint *lparg1=NULL;
+	jint *lparg2=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1widget_1get_1size_1request_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	if (arg2) if ((lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL)) == NULL) goto fail;
+	gtk_widget_get_size_request((GtkWidget *)arg0, (gint *)lparg1, (gint *)lparg2);
+fail:
+	if (arg2 && lparg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
+	if (arg1 && lparg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1widget_1get_1size_1request_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1widget_1get_1style
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1widget_1get_1style)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1widget_1get_1style_FUNC);
+	rc = (jint)gtk_widget_get_style((GtkWidget *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1widget_1get_1style_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1widget_1get_1toplevel
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1widget_1get_1toplevel)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1widget_1get_1toplevel_FUNC);
+	rc = (jint)gtk_widget_get_toplevel((GtkWidget *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1widget_1get_1toplevel_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1widget_1grab_1focus
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1widget_1grab_1focus)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1widget_1grab_1focus_FUNC);
+	gtk_widget_grab_focus((GtkWidget *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1widget_1grab_1focus_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1widget_1hide
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1widget_1hide)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1widget_1hide_FUNC);
+	gtk_widget_hide((GtkWidget *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1widget_1hide_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1widget_1is_1composited
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1gtk_1widget_1is_1composited)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1widget_1is_1composited_FUNC);
+/*
+	rc = (jboolean)gtk_widget_is_composited((GtkWidget *)arg0);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jboolean (*FPTR)(GtkWidget *);
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_widget_is_composited_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_widget_is_composited");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jboolean)(*fptr)((GtkWidget *)arg0);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1widget_1is_1composited_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1widget_1is_1focus
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1gtk_1widget_1is_1focus)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1widget_1is_1focus_FUNC);
+	rc = (jboolean)gtk_widget_is_focus((GtkWidget *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1widget_1is_1focus_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1widget_1map
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1widget_1map)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1widget_1map_FUNC);
+	gtk_widget_map((GtkWidget *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1widget_1map_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1widget_1mnemonic_1activate
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1gtk_1widget_1mnemonic_1activate)
+	(JNIEnv *env, jclass that, jint arg0, jboolean arg1)
+{
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1widget_1mnemonic_1activate_FUNC);
+	rc = (jboolean)gtk_widget_mnemonic_activate((GtkWidget *)arg0, (gboolean)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1widget_1mnemonic_1activate_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1widget_1modify_1base
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1widget_1modify_1base)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jobject arg2)
+{
+	GdkColor _arg2, *lparg2=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1widget_1modify_1base_FUNC);
+	if (arg2) if ((lparg2 = getGdkColorFields(env, arg2, &_arg2)) == NULL) goto fail;
+	gtk_widget_modify_base((GtkWidget *)arg0, (GtkStateType)arg1, (GdkColor *)lparg2);
+fail:
+	OS_NATIVE_EXIT(env, that, _1gtk_1widget_1modify_1base_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1widget_1modify_1bg
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1widget_1modify_1bg)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jobject arg2)
+{
+	GdkColor _arg2, *lparg2=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1widget_1modify_1bg_FUNC);
+	if (arg2) if ((lparg2 = getGdkColorFields(env, arg2, &_arg2)) == NULL) goto fail;
+	gtk_widget_modify_bg((GtkWidget *)arg0, (GtkStateType)arg1, (GdkColor *)lparg2);
+fail:
+	OS_NATIVE_EXIT(env, that, _1gtk_1widget_1modify_1bg_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1widget_1modify_1fg
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1widget_1modify_1fg)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jobject arg2)
+{
+	GdkColor _arg2, *lparg2=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1widget_1modify_1fg_FUNC);
+	if (arg2) if ((lparg2 = getGdkColorFields(env, arg2, &_arg2)) == NULL) goto fail;
+	gtk_widget_modify_fg((GtkWidget *)arg0, (GtkStateType)arg1, (GdkColor *)lparg2);
+fail:
+	OS_NATIVE_EXIT(env, that, _1gtk_1widget_1modify_1fg_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1widget_1modify_1font
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1widget_1modify_1font)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1widget_1modify_1font_FUNC);
+	gtk_widget_modify_font((GtkWidget *)arg0, (PangoFontDescription *)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1widget_1modify_1font_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1widget_1modify_1style
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1widget_1modify_1style)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1widget_1modify_1style_FUNC);
+	gtk_widget_modify_style((GtkWidget *)arg0, (GtkRcStyle *)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1widget_1modify_1style_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1widget_1modify_1text
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1widget_1modify_1text)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jobject arg2)
+{
+	GdkColor _arg2, *lparg2=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1widget_1modify_1text_FUNC);
+	if (arg2) if ((lparg2 = getGdkColorFields(env, arg2, &_arg2)) == NULL) goto fail;
+	gtk_widget_modify_text((GtkWidget *)arg0, (GtkStateType)arg1, (GdkColor *)lparg2);
+fail:
+	OS_NATIVE_EXIT(env, that, _1gtk_1widget_1modify_1text_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1widget_1queue_1resize
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1widget_1queue_1resize)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1widget_1queue_1resize_FUNC);
+	gtk_widget_queue_resize((GtkWidget *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1widget_1queue_1resize_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1widget_1realize
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1widget_1realize)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1widget_1realize_FUNC);
+	gtk_widget_realize((GtkWidget *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1widget_1realize_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1widget_1remove_1accelerator
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1widget_1remove_1accelerator)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1widget_1remove_1accelerator_FUNC);
+	gtk_widget_remove_accelerator((GtkWidget *)arg0, (GtkAccelGroup *)arg1, (guint)arg2, (GdkModifierType)arg3);
+	OS_NATIVE_EXIT(env, that, _1gtk_1widget_1remove_1accelerator_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1widget_1reparent
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1widget_1reparent)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1widget_1reparent_FUNC);
+	gtk_widget_reparent((GtkWidget *)arg0, (GtkWidget *)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1widget_1reparent_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1widget_1send_1expose
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1widget_1send_1expose)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1widget_1send_1expose_FUNC);
+	rc = (jint)gtk_widget_send_expose((GtkWidget *)arg0, (GdkEvent *)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1widget_1send_1expose_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1widget_1set_1app_1paintable
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1widget_1set_1app_1paintable)
+	(JNIEnv *env, jclass that, jint arg0, jboolean arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1widget_1set_1app_1paintable_FUNC);
+	gtk_widget_set_app_paintable((GtkWidget *)arg0, arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1widget_1set_1app_1paintable_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1widget_1set_1default_1direction
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1widget_1set_1default_1direction)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1widget_1set_1default_1direction_FUNC);
+	gtk_widget_set_default_direction((GtkTextDirection)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1widget_1set_1default_1direction_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1widget_1set_1direction
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1widget_1set_1direction)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1widget_1set_1direction_FUNC);
+	gtk_widget_set_direction((GtkWidget *)arg0, (GtkTextDirection)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1widget_1set_1direction_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1widget_1set_1double_1buffered
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1widget_1set_1double_1buffered)
+	(JNIEnv *env, jclass that, jint arg0, jboolean arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1widget_1set_1double_1buffered_FUNC);
+	gtk_widget_set_double_buffered((GtkWidget *)arg0, (gboolean)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1widget_1set_1double_1buffered_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1widget_1set_1name
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1widget_1set_1name)
+	(JNIEnv *env, jclass that, jint arg0, jbyteArray arg1)
+{
+	jbyte *lparg1=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1widget_1set_1name_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	gtk_widget_set_name((GtkWidget *)arg0, (const char *)lparg1);
+fail:
+	if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1widget_1set_1name_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1widget_1set_1parent_1window
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1widget_1set_1parent_1window)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1widget_1set_1parent_1window_FUNC);
+	gtk_widget_set_parent_window((GtkWidget *)arg0, (GdkWindow *)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1widget_1set_1parent_1window_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1widget_1set_1redraw_1on_1allocate
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1widget_1set_1redraw_1on_1allocate)
+	(JNIEnv *env, jclass that, jint arg0, jboolean arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1widget_1set_1redraw_1on_1allocate_FUNC);
+	gtk_widget_set_redraw_on_allocate((GtkWidget *)arg0, (gboolean)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1widget_1set_1redraw_1on_1allocate_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1widget_1set_1sensitive
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1widget_1set_1sensitive)
+	(JNIEnv *env, jclass that, jint arg0, jboolean arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1widget_1set_1sensitive_FUNC);
+	gtk_widget_set_sensitive((GtkWidget *)arg0, (gboolean)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1widget_1set_1sensitive_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1widget_1set_1size_1request
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1widget_1set_1size_1request)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1widget_1set_1size_1request_FUNC);
+	gtk_widget_set_size_request((GtkWidget *)arg0, (gint)arg1, (gint)arg2);
+	OS_NATIVE_EXIT(env, that, _1gtk_1widget_1set_1size_1request_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1widget_1set_1state
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1widget_1set_1state)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1widget_1set_1state_FUNC);
+	gtk_widget_set_state((GtkWidget *)arg0, (GtkStateType)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1widget_1set_1state_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1widget_1set_1style
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1widget_1set_1style)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1widget_1set_1style_FUNC);
+	gtk_widget_set_style((GtkWidget *)arg0, (GtkStyle *)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1widget_1set_1style_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1widget_1set_1tooltip_1text
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1widget_1set_1tooltip_1text)
+	(JNIEnv *env, jclass that, jint arg0, jbyteArray arg1)
+{
+	jbyte *lparg1=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1widget_1set_1tooltip_1text_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+/*
+	gtk_widget_set_tooltip_text((GtkWidget *)arg0, (const gchar *)lparg1);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef void (*FPTR)(GtkWidget *, const gchar *);
+		static FPTR fptr;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_widget_set_tooltip_text_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_widget_set_tooltip_text");
+			initialized = 1;
+		}
+		if (fptr) {
+			(*fptr)((GtkWidget *)arg0, (const gchar *)lparg1);
+		}
+	}
+fail:
+	if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1widget_1set_1tooltip_1text_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1widget_1shape_1combine_1mask
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1widget_1shape_1combine_1mask)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1widget_1shape_1combine_1mask_FUNC);
+	gtk_widget_shape_combine_mask((GtkWidget *)arg0, (GdkBitmap *)arg1, (gint)arg2, (gint)arg3);
+	OS_NATIVE_EXIT(env, that, _1gtk_1widget_1shape_1combine_1mask_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1widget_1show
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1widget_1show)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1widget_1show_FUNC);
+	gtk_widget_show((GtkWidget *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1widget_1show_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1widget_1show_1now
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1widget_1show_1now)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1widget_1show_1now_FUNC);
+	gtk_widget_show_now((GtkWidget *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1widget_1show_1now_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1widget_1size_1allocate
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1widget_1size_1allocate)
+	(JNIEnv *env, jclass that, jint arg0, jobject arg1)
+{
+	GtkAllocation _arg1, *lparg1=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1widget_1size_1allocate_FUNC);
+	if (arg1) if ((lparg1 = getGtkAllocationFields(env, arg1, &_arg1)) == NULL) goto fail;
+	gtk_widget_size_allocate((GtkWidget *)arg0, (GtkAllocation *)lparg1);
+fail:
+	OS_NATIVE_EXIT(env, that, _1gtk_1widget_1size_1allocate_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1widget_1size_1request
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1widget_1size_1request)
+	(JNIEnv *env, jclass that, jint arg0, jobject arg1)
+{
+	GtkRequisition _arg1, *lparg1=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1widget_1size_1request_FUNC);
+	if (arg1) if ((lparg1 = &_arg1) == NULL) goto fail;
+	gtk_widget_size_request((GtkWidget *)arg0, (GtkRequisition *)lparg1);
+fail:
+	if (arg1 && lparg1) setGtkRequisitionFields(env, arg1, lparg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1widget_1size_1request_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1widget_1style_1get__I_3B_3II
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1widget_1style_1get__I_3B_3II)
+	(JNIEnv *env, jclass that, jint arg0, jbyteArray arg1, jintArray arg2, jint arg3)
+{
+	jbyte *lparg1=NULL;
+	jint *lparg2=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1widget_1style_1get__I_3B_3II_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	if (arg2) if ((lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL)) == NULL) goto fail;
+	gtk_widget_style_get((GtkWidget *)arg0, (const gchar *)lparg1, lparg2, (const gchar *)NULL);
+fail:
+	if (arg2 && lparg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
+	if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1widget_1style_1get__I_3B_3II_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1widget_1style_1get__I_3B_3JI
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1widget_1style_1get__I_3B_3JI)
+	(JNIEnv *env, jclass that, jint arg0, jbyteArray arg1, jlongArray arg2, jint arg3)
+{
+	jbyte *lparg1=NULL;
+	jlong *lparg2=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1widget_1style_1get__I_3B_3JI_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	if (arg2) if ((lparg2 = (*env)->GetLongArrayElements(env, arg2, NULL)) == NULL) goto fail;
+	gtk_widget_style_get((GtkWidget *)arg0, (const gchar *)lparg1, lparg2, (const gchar *)NULL);
+fail:
+	if (arg2 && lparg2) (*env)->ReleaseLongArrayElements(env, arg2, lparg2, 0);
+	if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1widget_1style_1get__I_3B_3JI_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1widget_1translate_1coordinates
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1gtk_1widget_1translate_1coordinates)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jintArray arg4, jintArray arg5)
+{
+	jint *lparg4=NULL;
+	jint *lparg5=NULL;
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1widget_1translate_1coordinates_FUNC);
+	if (arg4) if ((lparg4 = (*env)->GetIntArrayElements(env, arg4, NULL)) == NULL) goto fail;
+	if (arg5) if ((lparg5 = (*env)->GetIntArrayElements(env, arg5, NULL)) == NULL) goto fail;
+	rc = (jboolean)gtk_widget_translate_coordinates((GtkWidget *)arg0, (GtkWidget *)arg1, arg2, arg3, lparg4, lparg5);
+fail:
+	if (arg5 && lparg5) (*env)->ReleaseIntArrayElements(env, arg5, lparg5, 0);
+	if (arg4 && lparg4) (*env)->ReleaseIntArrayElements(env, arg4, lparg4, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1widget_1translate_1coordinates_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1widget_1unrealize
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1widget_1unrealize)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1widget_1unrealize_FUNC);
+	gtk_widget_unrealize((GtkWidget *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1widget_1unrealize_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1window_1activate_1default
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1gtk_1window_1activate_1default)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1window_1activate_1default_FUNC);
+	rc = (jboolean)gtk_window_activate_default((GtkWindow *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1window_1activate_1default_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1window_1add_1accel_1group
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1window_1add_1accel_1group)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1window_1add_1accel_1group_FUNC);
+	gtk_window_add_accel_group((GtkWindow *)arg0, (GtkAccelGroup *)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1window_1add_1accel_1group_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1window_1deiconify
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1window_1deiconify)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1window_1deiconify_FUNC);
+	gtk_window_deiconify((GtkWindow *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1window_1deiconify_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1window_1fullscreen
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1window_1fullscreen)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1window_1fullscreen_FUNC);
+	gtk_window_fullscreen((GtkWindow *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1window_1fullscreen_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1window_1get_1focus
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1window_1get_1focus)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1window_1get_1focus_FUNC);
+	rc = (jint)gtk_window_get_focus((GtkWindow *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1window_1get_1focus_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1window_1get_1group
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1window_1get_1group)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1window_1get_1group_FUNC);
+/*
+	rc = (jint)gtk_window_get_group((GtkWindow *)arg0);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jint (*FPTR)(GtkWindow *);
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_window_get_group_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_window_get_group");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jint)(*fptr)((GtkWindow *)arg0);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1window_1get_1group_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1window_1get_1icon_1list
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1window_1get_1icon_1list)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1window_1get_1icon_1list_FUNC);
+	rc = (jint)gtk_window_get_icon_list((GtkWindow *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1window_1get_1icon_1list_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1window_1get_1mnemonic_1modifier
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1window_1get_1mnemonic_1modifier)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1window_1get_1mnemonic_1modifier_FUNC);
+	rc = (jint)gtk_window_get_mnemonic_modifier((GtkWindow *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1window_1get_1mnemonic_1modifier_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1window_1get_1modal
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1gtk_1window_1get_1modal)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1window_1get_1modal_FUNC);
+	rc = (jboolean)gtk_window_get_modal((GtkWindow *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1window_1get_1modal_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1window_1get_1opacity
+JNIEXPORT jdouble JNICALL OS_NATIVE(_1gtk_1window_1get_1opacity)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jdouble rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1window_1get_1opacity_FUNC);
+/*
+	rc = (jdouble)gtk_window_get_opacity((GtkWindow *)arg0);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jdouble (*FPTR)(GtkWindow *);
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_window_get_opacity_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_window_get_opacity");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jdouble)(*fptr)((GtkWindow *)arg0);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1window_1get_1opacity_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1window_1get_1position
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1window_1get_1position)
+	(JNIEnv *env, jclass that, jint arg0, jintArray arg1, jintArray arg2)
+{
+	jint *lparg1=NULL;
+	jint *lparg2=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1window_1get_1position_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	if (arg2) if ((lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL)) == NULL) goto fail;
+	gtk_window_get_position((GtkWindow *)arg0, (gint *)lparg1, (gint *)lparg2);
+fail:
+	if (arg2 && lparg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
+	if (arg1 && lparg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1window_1get_1position_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1window_1get_1size
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1window_1get_1size)
+	(JNIEnv *env, jclass that, jint arg0, jintArray arg1, jintArray arg2)
+{
+	jint *lparg1=NULL;
+	jint *lparg2=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1window_1get_1size_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	if (arg2) if ((lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL)) == NULL) goto fail;
+	gtk_window_get_size((GtkWindow *)arg0, (gint *)lparg1, (gint *)lparg2);
+fail:
+	if (arg2 && lparg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
+	if (arg1 && lparg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1window_1get_1size_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1window_1group_1add_1window
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1window_1group_1add_1window)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1window_1group_1add_1window_FUNC);
+	gtk_window_group_add_window((GtkWindowGroup*)arg0, (GtkWindow*)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1window_1group_1add_1window_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1window_1group_1new
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1window_1group_1new)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1window_1group_1new_FUNC);
+	rc = (jint)gtk_window_group_new();
+	OS_NATIVE_EXIT(env, that, _1gtk_1window_1group_1new_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1window_1group_1remove_1window
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1window_1group_1remove_1window)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1window_1group_1remove_1window_FUNC);
+	gtk_window_group_remove_window((GtkWindowGroup*)arg0, (GtkWindow*)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1window_1group_1remove_1window_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1window_1iconify
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1window_1iconify)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1window_1iconify_FUNC);
+	gtk_window_iconify((GtkWindow *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1window_1iconify_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1window_1list_1toplevels
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1window_1list_1toplevels)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1window_1list_1toplevels_FUNC);
+	rc = (jint)gtk_window_list_toplevels();
+	OS_NATIVE_EXIT(env, that, _1gtk_1window_1list_1toplevels_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1window_1maximize
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1window_1maximize)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1window_1maximize_FUNC);
+	gtk_window_maximize((GtkWindow *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1window_1maximize_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1window_1move
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1window_1move)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1window_1move_FUNC);
+	gtk_window_move((GtkWindow *)arg0, (gint)arg1, (gint)arg2);
+	OS_NATIVE_EXIT(env, that, _1gtk_1window_1move_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1window_1new
+JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1window_1new)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1window_1new_FUNC);
+	rc = (jint)gtk_window_new((GtkWindowType)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1window_1new_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1window_1present
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1window_1present)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1window_1present_FUNC);
+	gtk_window_present((GtkWindow *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1window_1present_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1window_1remove_1accel_1group
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1window_1remove_1accel_1group)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1window_1remove_1accel_1group_FUNC);
+	gtk_window_remove_accel_group((GtkWindow *)arg0, (GtkAccelGroup *)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1window_1remove_1accel_1group_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1window_1resize
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1window_1resize)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1window_1resize_FUNC);
+	gtk_window_resize((GtkWindow *)arg0, (gint)arg1, (gint)arg2);
+	OS_NATIVE_EXIT(env, that, _1gtk_1window_1resize_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1window_1set_1default
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1window_1set_1default)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1window_1set_1default_FUNC);
+	gtk_window_set_default((GtkWindow *)arg0, (GtkWidget *)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1window_1set_1default_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1window_1set_1destroy_1with_1parent
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1window_1set_1destroy_1with_1parent)
+	(JNIEnv *env, jclass that, jint arg0, jboolean arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1window_1set_1destroy_1with_1parent_FUNC);
+	gtk_window_set_destroy_with_parent((GtkWindow *)arg0, (gboolean)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1window_1set_1destroy_1with_1parent_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1window_1set_1geometry_1hints
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1window_1set_1geometry_1hints)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jobject arg2, jint arg3)
+{
+	GdkGeometry _arg2, *lparg2=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1window_1set_1geometry_1hints_FUNC);
+	if (arg2) if ((lparg2 = getGdkGeometryFields(env, arg2, &_arg2)) == NULL) goto fail;
+	gtk_window_set_geometry_hints((GtkWindow *)arg0, (GtkWidget *)arg1, lparg2, arg3);
+fail:
+	OS_NATIVE_EXIT(env, that, _1gtk_1window_1set_1geometry_1hints_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1window_1set_1icon_1list
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1window_1set_1icon_1list)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1window_1set_1icon_1list_FUNC);
+	gtk_window_set_icon_list((GtkWindow *)arg0, (GList *)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1window_1set_1icon_1list_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1window_1set_1keep_1below
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1window_1set_1keep_1below)
+	(JNIEnv *env, jclass that, jint arg0, jboolean arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1window_1set_1keep_1below_FUNC);
+/*
+	gtk_window_set_keep_below((GtkWindow *)arg0, (gboolean)arg1);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef void (*FPTR)(GtkWindow *, gboolean);
+		static FPTR fptr;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_window_set_keep_below_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_window_set_keep_below");
+			initialized = 1;
+		}
+		if (fptr) {
+			(*fptr)((GtkWindow *)arg0, (gboolean)arg1);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1window_1set_1keep_1below_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1window_1set_1modal
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1window_1set_1modal)
+	(JNIEnv *env, jclass that, jint arg0, jboolean arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1window_1set_1modal_FUNC);
+	gtk_window_set_modal((GtkWindow *)arg0, (gboolean)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1window_1set_1modal_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1window_1set_1opacity
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1window_1set_1opacity)
+	(JNIEnv *env, jclass that, jint arg0, jdouble arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1window_1set_1opacity_FUNC);
+/*
+	gtk_window_set_opacity((GtkWindow *)arg0, arg1);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef void (*FPTR)(GtkWindow *, jdouble);
+		static FPTR fptr;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_window_set_opacity_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_window_set_opacity");
+			initialized = 1;
+		}
+		if (fptr) {
+			(*fptr)((GtkWindow *)arg0, arg1);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1window_1set_1opacity_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1window_1set_1resizable
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1window_1set_1resizable)
+	(JNIEnv *env, jclass that, jint arg0, jboolean arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1window_1set_1resizable_FUNC);
+	gtk_window_set_resizable((GtkWindow *)arg0, (gboolean)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1window_1set_1resizable_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1window_1set_1skip_1taskbar_1hint
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1window_1set_1skip_1taskbar_1hint)
+	(JNIEnv *env, jclass that, jint arg0, jboolean arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1window_1set_1skip_1taskbar_1hint_FUNC);
+/*
+	gtk_window_set_skip_taskbar_hint((GtkWindow *)arg0, (gboolean)arg1);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef void (*FPTR)(GtkWindow *, gboolean);
+		static FPTR fptr;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_window_set_skip_taskbar_hint_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_window_set_skip_taskbar_hint");
+			initialized = 1;
+		}
+		if (fptr) {
+			(*fptr)((GtkWindow *)arg0, (gboolean)arg1);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1gtk_1window_1set_1skip_1taskbar_1hint_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1window_1set_1title
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1window_1set_1title)
+	(JNIEnv *env, jclass that, jint arg0, jbyteArray arg1)
+{
+	jbyte *lparg1=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1window_1set_1title_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	gtk_window_set_title((GtkWindow *)arg0, (const gchar *)lparg1);
+fail:
+	if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1window_1set_1title_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1window_1set_1transient_1for
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1window_1set_1transient_1for)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1window_1set_1transient_1for_FUNC);
+	gtk_window_set_transient_for((GtkWindow *)arg0, (GtkWindow *)arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1window_1set_1transient_1for_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1window_1set_1type_1hint
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1window_1set_1type_1hint)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1window_1set_1type_1hint_FUNC);
+	gtk_window_set_type_hint((GtkWindow *)arg0, arg1);
+	OS_NATIVE_EXIT(env, that, _1gtk_1window_1set_1type_1hint_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1window_1unfullscreen
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1window_1unfullscreen)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1window_1unfullscreen_FUNC);
+	gtk_window_unfullscreen((GtkWindow *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1window_1unfullscreen_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1window_1unmaximize
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1window_1unmaximize)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1gtk_1window_1unmaximize_FUNC);
+	gtk_window_unmaximize((GtkWindow *)arg0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1window_1unmaximize_FUNC);
+}
+#endif
+
+#ifndef NO__1pango_1attr_1background_1new
+JNIEXPORT jint JNICALL OS_NATIVE(_1pango_1attr_1background_1new)
+	(JNIEnv *env, jclass that, jshort arg0, jshort arg1, jshort arg2)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1pango_1attr_1background_1new_FUNC);
+	rc = (jint)pango_attr_background_new(arg0, arg1, arg2);
+	OS_NATIVE_EXIT(env, that, _1pango_1attr_1background_1new_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1pango_1attr_1font_1desc_1new
+JNIEXPORT jint JNICALL OS_NATIVE(_1pango_1attr_1font_1desc_1new)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1pango_1attr_1font_1desc_1new_FUNC);
+	rc = (jint)pango_attr_font_desc_new((const PangoFontDescription *)arg0);
+	OS_NATIVE_EXIT(env, that, _1pango_1attr_1font_1desc_1new_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1pango_1attr_1foreground_1new
+JNIEXPORT jint JNICALL OS_NATIVE(_1pango_1attr_1foreground_1new)
+	(JNIEnv *env, jclass that, jshort arg0, jshort arg1, jshort arg2)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1pango_1attr_1foreground_1new_FUNC);
+	rc = (jint)pango_attr_foreground_new(arg0, arg1, arg2);
+	OS_NATIVE_EXIT(env, that, _1pango_1attr_1foreground_1new_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1pango_1attr_1iterator_1destroy
+JNIEXPORT void JNICALL OS_NATIVE(_1pango_1attr_1iterator_1destroy)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1pango_1attr_1iterator_1destroy_FUNC);
+	pango_attr_iterator_destroy((PangoAttrIterator *)arg0);
+	OS_NATIVE_EXIT(env, that, _1pango_1attr_1iterator_1destroy_FUNC);
+}
+#endif
+
+#ifndef NO__1pango_1attr_1iterator_1get
+JNIEXPORT jint JNICALL OS_NATIVE(_1pango_1attr_1iterator_1get)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1pango_1attr_1iterator_1get_FUNC);
+	rc = (jint)pango_attr_iterator_get((PangoAttrIterator *)arg0, (PangoAttrType)arg1);
+	OS_NATIVE_EXIT(env, that, _1pango_1attr_1iterator_1get_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1pango_1attr_1iterator_1get_1attrs
+JNIEXPORT jint JNICALL OS_NATIVE(_1pango_1attr_1iterator_1get_1attrs)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1pango_1attr_1iterator_1get_1attrs_FUNC);
+	rc = (jint)pango_attr_iterator_get_attrs((PangoAttrIterator *)arg0);
+	OS_NATIVE_EXIT(env, that, _1pango_1attr_1iterator_1get_1attrs_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1pango_1attr_1iterator_1next
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1pango_1attr_1iterator_1next)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1pango_1attr_1iterator_1next_FUNC);
+	rc = (jboolean)pango_attr_iterator_next((PangoAttrIterator *)arg0);
+	OS_NATIVE_EXIT(env, that, _1pango_1attr_1iterator_1next_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1pango_1attr_1iterator_1range
+JNIEXPORT void JNICALL OS_NATIVE(_1pango_1attr_1iterator_1range)
+	(JNIEnv *env, jclass that, jint arg0, jintArray arg1, jintArray arg2)
+{
+	jint *lparg1=NULL;
+	jint *lparg2=NULL;
+	OS_NATIVE_ENTER(env, that, _1pango_1attr_1iterator_1range_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	if (arg2) if ((lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL)) == NULL) goto fail;
+	pango_attr_iterator_range((PangoAttrIterator *)arg0, lparg1, lparg2);
+fail:
+	if (arg2 && lparg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
+	if (arg1 && lparg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0);
+	OS_NATIVE_EXIT(env, that, _1pango_1attr_1iterator_1range_FUNC);
+}
+#endif
+
+#ifndef NO__1pango_1attr_1list_1change
+JNIEXPORT void JNICALL OS_NATIVE(_1pango_1attr_1list_1change)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1pango_1attr_1list_1change_FUNC);
+	pango_attr_list_change((PangoAttrList *)arg0, (PangoAttribute *)arg1);
+	OS_NATIVE_EXIT(env, that, _1pango_1attr_1list_1change_FUNC);
+}
+#endif
+
+#ifndef NO__1pango_1attr_1list_1get_1iterator
+JNIEXPORT jint JNICALL OS_NATIVE(_1pango_1attr_1list_1get_1iterator)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1pango_1attr_1list_1get_1iterator_FUNC);
+	rc = (jint)pango_attr_list_get_iterator((PangoAttrList *)arg0);
+	OS_NATIVE_EXIT(env, that, _1pango_1attr_1list_1get_1iterator_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1pango_1attr_1list_1insert
+JNIEXPORT void JNICALL OS_NATIVE(_1pango_1attr_1list_1insert)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1pango_1attr_1list_1insert_FUNC);
+	pango_attr_list_insert((PangoAttrList *)arg0, (PangoAttribute *)arg1);
+	OS_NATIVE_EXIT(env, that, _1pango_1attr_1list_1insert_FUNC);
+}
+#endif
+
+#ifndef NO__1pango_1attr_1list_1new
+JNIEXPORT jint JNICALL OS_NATIVE(_1pango_1attr_1list_1new)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1pango_1attr_1list_1new_FUNC);
+	rc = (jint)pango_attr_list_new();
+	OS_NATIVE_EXIT(env, that, _1pango_1attr_1list_1new_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1pango_1attr_1list_1unref
+JNIEXPORT void JNICALL OS_NATIVE(_1pango_1attr_1list_1unref)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1pango_1attr_1list_1unref_FUNC);
+	pango_attr_list_unref((PangoAttrList *)arg0);
+	OS_NATIVE_EXIT(env, that, _1pango_1attr_1list_1unref_FUNC);
+}
+#endif
+
+#ifndef NO__1pango_1attr_1rise_1new
+JNIEXPORT jint JNICALL OS_NATIVE(_1pango_1attr_1rise_1new)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1pango_1attr_1rise_1new_FUNC);
+	rc = (jint)pango_attr_rise_new(arg0);
+	OS_NATIVE_EXIT(env, that, _1pango_1attr_1rise_1new_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1pango_1attr_1shape_1new
+JNIEXPORT jint JNICALL OS_NATIVE(_1pango_1attr_1shape_1new)
+	(JNIEnv *env, jclass that, jobject arg0, jobject arg1)
+{
+	PangoRectangle _arg0, *lparg0=NULL;
+	PangoRectangle _arg1, *lparg1=NULL;
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1pango_1attr_1shape_1new_FUNC);
+	if (arg0) if ((lparg0 = getPangoRectangleFields(env, arg0, &_arg0)) == NULL) goto fail;
+	if (arg1) if ((lparg1 = getPangoRectangleFields(env, arg1, &_arg1)) == NULL) goto fail;
+	rc = (jint)pango_attr_shape_new(lparg0, lparg1);
+fail:
+	OS_NATIVE_EXIT(env, that, _1pango_1attr_1shape_1new_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1pango_1attr_1strikethrough_1color_1new
+JNIEXPORT jint JNICALL OS_NATIVE(_1pango_1attr_1strikethrough_1color_1new)
+	(JNIEnv *env, jclass that, jshort arg0, jshort arg1, jshort arg2)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1pango_1attr_1strikethrough_1color_1new_FUNC);
+/*
+	rc = (jint)pango_attr_strikethrough_color_new(arg0, arg1, arg2);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jint (*FPTR)(jshort, jshort, jshort);
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(pango_attr_strikethrough_color_new_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "pango_attr_strikethrough_color_new");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jint)(*fptr)(arg0, arg1, arg2);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1pango_1attr_1strikethrough_1color_1new_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1pango_1attr_1strikethrough_1new
+JNIEXPORT jint JNICALL OS_NATIVE(_1pango_1attr_1strikethrough_1new)
+	(JNIEnv *env, jclass that, jboolean arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1pango_1attr_1strikethrough_1new_FUNC);
+	rc = (jint)pango_attr_strikethrough_new(arg0);
+	OS_NATIVE_EXIT(env, that, _1pango_1attr_1strikethrough_1new_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1pango_1attr_1underline_1color_1new
+JNIEXPORT jint JNICALL OS_NATIVE(_1pango_1attr_1underline_1color_1new)
+	(JNIEnv *env, jclass that, jshort arg0, jshort arg1, jshort arg2)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1pango_1attr_1underline_1color_1new_FUNC);
+/*
+	rc = (jint)pango_attr_underline_color_new(arg0, arg1, arg2);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jint (*FPTR)(jshort, jshort, jshort);
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(pango_attr_underline_color_new_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "pango_attr_underline_color_new");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jint)(*fptr)(arg0, arg1, arg2);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1pango_1attr_1underline_1color_1new_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1pango_1attr_1underline_1new
+JNIEXPORT jint JNICALL OS_NATIVE(_1pango_1attr_1underline_1new)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1pango_1attr_1underline_1new_FUNC);
+	rc = (jint)pango_attr_underline_new(arg0);
+	OS_NATIVE_EXIT(env, that, _1pango_1attr_1underline_1new_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1pango_1attr_1weight_1new
+JNIEXPORT jint JNICALL OS_NATIVE(_1pango_1attr_1weight_1new)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1pango_1attr_1weight_1new_FUNC);
+	rc = (jint)pango_attr_weight_new(arg0);
+	OS_NATIVE_EXIT(env, that, _1pango_1attr_1weight_1new_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1pango_1cairo_1context_1get_1font_1options
+JNIEXPORT jint JNICALL OS_NATIVE(_1pango_1cairo_1context_1get_1font_1options)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1pango_1cairo_1context_1get_1font_1options_FUNC);
+/*
+	rc = (jint)pango_cairo_context_get_font_options((PangoContext *)arg0);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jint (*FPTR)(PangoContext *);
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(pango_cairo_context_get_font_options_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "pango_cairo_context_get_font_options");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jint)(*fptr)((PangoContext *)arg0);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1pango_1cairo_1context_1get_1font_1options_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1pango_1cairo_1context_1set_1font_1options
+JNIEXPORT void JNICALL OS_NATIVE(_1pango_1cairo_1context_1set_1font_1options)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1pango_1cairo_1context_1set_1font_1options_FUNC);
+/*
+	pango_cairo_context_set_font_options((PangoContext *)arg0, arg1);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef void (*FPTR)(PangoContext *, jint);
+		static FPTR fptr;
+		if (!initialized) {
+			if (!handle) handle = dlopen(pango_cairo_context_set_font_options_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "pango_cairo_context_set_font_options");
+			initialized = 1;
+		}
+		if (fptr) {
+			(*fptr)((PangoContext *)arg0, arg1);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1pango_1cairo_1context_1set_1font_1options_FUNC);
+}
+#endif
+
+#ifndef NO__1pango_1cairo_1create_1layout
+JNIEXPORT jint JNICALL OS_NATIVE(_1pango_1cairo_1create_1layout)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1pango_1cairo_1create_1layout_FUNC);
+/*
+	rc = (jint)pango_cairo_create_layout(arg0);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jint (*FPTR)(jint);
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(pango_cairo_create_layout_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "pango_cairo_create_layout");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jint)(*fptr)(arg0);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1pango_1cairo_1create_1layout_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1pango_1cairo_1font_1map_1create_1context
+JNIEXPORT jint JNICALL OS_NATIVE(_1pango_1cairo_1font_1map_1create_1context)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1pango_1cairo_1font_1map_1create_1context_FUNC);
+/*
+	rc = (jint)pango_cairo_font_map_create_context(arg0);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jint (*FPTR)(jint);
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(pango_cairo_font_map_create_context_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "pango_cairo_font_map_create_context");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jint)(*fptr)(arg0);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1pango_1cairo_1font_1map_1create_1context_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1pango_1cairo_1font_1map_1get_1default
+JNIEXPORT jint JNICALL OS_NATIVE(_1pango_1cairo_1font_1map_1get_1default)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1pango_1cairo_1font_1map_1get_1default_FUNC);
+/*
+	rc = (jint)pango_cairo_font_map_get_default();
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jint (*FPTR)();
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(pango_cairo_font_map_get_default_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "pango_cairo_font_map_get_default");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jint)(*fptr)();
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1pango_1cairo_1font_1map_1get_1default_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1pango_1cairo_1font_1map_1new
+JNIEXPORT jint JNICALL OS_NATIVE(_1pango_1cairo_1font_1map_1new)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1pango_1cairo_1font_1map_1new_FUNC);
+/*
+	rc = (jint)pango_cairo_font_map_new();
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jint (*FPTR)();
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(pango_cairo_font_map_new_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "pango_cairo_font_map_new");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jint)(*fptr)();
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1pango_1cairo_1font_1map_1new_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1pango_1cairo_1font_1map_1set_1resolution
+JNIEXPORT void JNICALL OS_NATIVE(_1pango_1cairo_1font_1map_1set_1resolution)
+	(JNIEnv *env, jclass that, jint arg0, jdouble arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1pango_1cairo_1font_1map_1set_1resolution_FUNC);
+/*
+	pango_cairo_font_map_set_resolution(arg0, arg1);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef void (*FPTR)(jint, jdouble);
+		static FPTR fptr;
+		if (!initialized) {
+			if (!handle) handle = dlopen(pango_cairo_font_map_set_resolution_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "pango_cairo_font_map_set_resolution");
+			initialized = 1;
+		}
+		if (fptr) {
+			(*fptr)(arg0, arg1);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1pango_1cairo_1font_1map_1set_1resolution_FUNC);
+}
+#endif
+
+#ifndef NO__1pango_1cairo_1layout_1path
+JNIEXPORT void JNICALL OS_NATIVE(_1pango_1cairo_1layout_1path)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1pango_1cairo_1layout_1path_FUNC);
+/*
+	pango_cairo_layout_path(arg0, arg1);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef void (*FPTR)(jint, jint);
+		static FPTR fptr;
+		if (!initialized) {
+			if (!handle) handle = dlopen(pango_cairo_layout_path_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "pango_cairo_layout_path");
+			initialized = 1;
+		}
+		if (fptr) {
+			(*fptr)(arg0, arg1);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1pango_1cairo_1layout_1path_FUNC);
+}
+#endif
+
+#ifndef NO__1pango_1cairo_1show_1layout
+JNIEXPORT void JNICALL OS_NATIVE(_1pango_1cairo_1show_1layout)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1pango_1cairo_1show_1layout_FUNC);
+/*
+	pango_cairo_show_layout(arg0, arg1);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef void (*FPTR)(jint, jint);
+		static FPTR fptr;
+		if (!initialized) {
+			if (!handle) handle = dlopen(pango_cairo_show_layout_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "pango_cairo_show_layout");
+			initialized = 1;
+		}
+		if (fptr) {
+			(*fptr)(arg0, arg1);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1pango_1cairo_1show_1layout_FUNC);
+}
+#endif
+
+#ifndef NO__1pango_1context_1get_1base_1dir
+JNIEXPORT jint JNICALL OS_NATIVE(_1pango_1context_1get_1base_1dir)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1pango_1context_1get_1base_1dir_FUNC);
+	rc = (jint)pango_context_get_base_dir((PangoContext *)arg0);
+	OS_NATIVE_EXIT(env, that, _1pango_1context_1get_1base_1dir_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1pango_1context_1get_1language
+JNIEXPORT jint JNICALL OS_NATIVE(_1pango_1context_1get_1language)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1pango_1context_1get_1language_FUNC);
+	rc = (jint)pango_context_get_language((PangoContext *)arg0);
+	OS_NATIVE_EXIT(env, that, _1pango_1context_1get_1language_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1pango_1context_1get_1metrics
+JNIEXPORT jint JNICALL OS_NATIVE(_1pango_1context_1get_1metrics)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1pango_1context_1get_1metrics_FUNC);
+	rc = (jint)pango_context_get_metrics((PangoContext *)arg0, (const PangoFontDescription *)arg1, (PangoLanguage *)arg2);
+	OS_NATIVE_EXIT(env, that, _1pango_1context_1get_1metrics_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1pango_1context_1list_1families
+JNIEXPORT void JNICALL OS_NATIVE(_1pango_1context_1list_1families)
+	(JNIEnv *env, jclass that, jint arg0, jintArray arg1, jintArray arg2)
+{
+	jint *lparg1=NULL;
+	jint *lparg2=NULL;
+	OS_NATIVE_ENTER(env, that, _1pango_1context_1list_1families_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	if (arg2) if ((lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL)) == NULL) goto fail;
+	pango_context_list_families((PangoContext *)arg0, (PangoFontFamily ***)lparg1, (int *)lparg2);
+fail:
+	if (arg2 && lparg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
+	if (arg1 && lparg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0);
+	OS_NATIVE_EXIT(env, that, _1pango_1context_1list_1families_FUNC);
+}
+#endif
+
+#ifndef NO__1pango_1context_1set_1base_1dir
+JNIEXPORT void JNICALL OS_NATIVE(_1pango_1context_1set_1base_1dir)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1pango_1context_1set_1base_1dir_FUNC);
+	pango_context_set_base_dir((PangoContext *)arg0, arg1);
+	OS_NATIVE_EXIT(env, that, _1pango_1context_1set_1base_1dir_FUNC);
+}
+#endif
+
+#ifndef NO__1pango_1context_1set_1language
+JNIEXPORT void JNICALL OS_NATIVE(_1pango_1context_1set_1language)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1pango_1context_1set_1language_FUNC);
+	pango_context_set_language((PangoContext *)arg0, (PangoLanguage *)arg1);
+	OS_NATIVE_EXIT(env, that, _1pango_1context_1set_1language_FUNC);
+}
+#endif
+
+#ifndef NO__1pango_1font_1description_1copy
+JNIEXPORT jint JNICALL OS_NATIVE(_1pango_1font_1description_1copy)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1pango_1font_1description_1copy_FUNC);
+	rc = (jint)pango_font_description_copy((PangoFontDescription *)arg0);
+	OS_NATIVE_EXIT(env, that, _1pango_1font_1description_1copy_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1pango_1font_1description_1free
+JNIEXPORT void JNICALL OS_NATIVE(_1pango_1font_1description_1free)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1pango_1font_1description_1free_FUNC);
+	pango_font_description_free((PangoFontDescription *)arg0);
+	OS_NATIVE_EXIT(env, that, _1pango_1font_1description_1free_FUNC);
+}
+#endif
+
+#ifndef NO__1pango_1font_1description_1from_1string
+JNIEXPORT jint JNICALL OS_NATIVE(_1pango_1font_1description_1from_1string)
+	(JNIEnv *env, jclass that, jbyteArray arg0)
+{
+	jbyte *lparg0=NULL;
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1pango_1font_1description_1from_1string_FUNC);
+#ifdef JNI_VERSION_1_2
+	if (IS_JNI_1_2) {
+		if (arg0) if ((lparg0 = (*env)->GetPrimitiveArrayCritical(env, arg0, NULL)) == NULL) goto fail;
+	} else
+#endif
+	{
+		if (arg0) if ((lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL)) == NULL) goto fail;
+	}
+	rc = (jint)pango_font_description_from_string((const char *)lparg0);
+fail:
+#ifdef JNI_VERSION_1_2
+	if (IS_JNI_1_2) {
+		if (arg0 && lparg0) (*env)->ReleasePrimitiveArrayCritical(env, arg0, lparg0, JNI_ABORT);
+	} else
+#endif
+	{
+		if (arg0 && lparg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, JNI_ABORT);
+	}
+	OS_NATIVE_EXIT(env, that, _1pango_1font_1description_1from_1string_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1pango_1font_1description_1get_1family
+JNIEXPORT jint JNICALL OS_NATIVE(_1pango_1font_1description_1get_1family)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1pango_1font_1description_1get_1family_FUNC);
+	rc = (jint)pango_font_description_get_family((PangoFontDescription *)arg0);
+	OS_NATIVE_EXIT(env, that, _1pango_1font_1description_1get_1family_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1pango_1font_1description_1get_1size
+JNIEXPORT jint JNICALL OS_NATIVE(_1pango_1font_1description_1get_1size)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1pango_1font_1description_1get_1size_FUNC);
+	rc = (jint)pango_font_description_get_size((PangoFontDescription *)arg0);
+	OS_NATIVE_EXIT(env, that, _1pango_1font_1description_1get_1size_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1pango_1font_1description_1get_1style
+JNIEXPORT jint JNICALL OS_NATIVE(_1pango_1font_1description_1get_1style)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1pango_1font_1description_1get_1style_FUNC);
+	rc = (jint)pango_font_description_get_style((PangoFontDescription *)arg0);
+	OS_NATIVE_EXIT(env, that, _1pango_1font_1description_1get_1style_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1pango_1font_1description_1get_1weight
+JNIEXPORT jint JNICALL OS_NATIVE(_1pango_1font_1description_1get_1weight)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1pango_1font_1description_1get_1weight_FUNC);
+	rc = (jint)pango_font_description_get_weight((PangoFontDescription *)arg0);
+	OS_NATIVE_EXIT(env, that, _1pango_1font_1description_1get_1weight_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1pango_1font_1description_1new
+JNIEXPORT jint JNICALL OS_NATIVE(_1pango_1font_1description_1new)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1pango_1font_1description_1new_FUNC);
+	rc = (jint)pango_font_description_new();
+	OS_NATIVE_EXIT(env, that, _1pango_1font_1description_1new_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1pango_1font_1description_1set_1family
+JNIEXPORT void JNICALL OS_NATIVE(_1pango_1font_1description_1set_1family)
+	(JNIEnv *env, jclass that, jint arg0, jbyteArray arg1)
+{
+	jbyte *lparg1=NULL;
+	OS_NATIVE_ENTER(env, that, _1pango_1font_1description_1set_1family_FUNC);
+#ifdef JNI_VERSION_1_2
+	if (IS_JNI_1_2) {
+		if (arg1) if ((lparg1 = (*env)->GetPrimitiveArrayCritical(env, arg1, NULL)) == NULL) goto fail;
+	} else
+#endif
+	{
+		if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	}
+	pango_font_description_set_family((PangoFontDescription *)arg0, (const char *)lparg1);
+fail:
+#ifdef JNI_VERSION_1_2
+	if (IS_JNI_1_2) {
+		if (arg1 && lparg1) (*env)->ReleasePrimitiveArrayCritical(env, arg1, lparg1, JNI_ABORT);
+	} else
+#endif
+	{
+		if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, JNI_ABORT);
+	}
+	OS_NATIVE_EXIT(env, that, _1pango_1font_1description_1set_1family_FUNC);
+}
+#endif
+
+#ifndef NO__1pango_1font_1description_1set_1size
+JNIEXPORT void JNICALL OS_NATIVE(_1pango_1font_1description_1set_1size)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1pango_1font_1description_1set_1size_FUNC);
+	pango_font_description_set_size((PangoFontDescription *)arg0, (gint)arg1);
+	OS_NATIVE_EXIT(env, that, _1pango_1font_1description_1set_1size_FUNC);
+}
+#endif
+
+#ifndef NO__1pango_1font_1description_1set_1stretch
+JNIEXPORT void JNICALL OS_NATIVE(_1pango_1font_1description_1set_1stretch)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1pango_1font_1description_1set_1stretch_FUNC);
+	pango_font_description_set_stretch((PangoFontDescription *)arg0, (PangoStretch)arg1);
+	OS_NATIVE_EXIT(env, that, _1pango_1font_1description_1set_1stretch_FUNC);
+}
+#endif
+
+#ifndef NO__1pango_1font_1description_1set_1style
+JNIEXPORT void JNICALL OS_NATIVE(_1pango_1font_1description_1set_1style)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1pango_1font_1description_1set_1style_FUNC);
+	pango_font_description_set_style((PangoFontDescription *)arg0, (PangoStyle)arg1);
+	OS_NATIVE_EXIT(env, that, _1pango_1font_1description_1set_1style_FUNC);
+}
+#endif
+
+#ifndef NO__1pango_1font_1description_1set_1weight
+JNIEXPORT void JNICALL OS_NATIVE(_1pango_1font_1description_1set_1weight)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1pango_1font_1description_1set_1weight_FUNC);
+	pango_font_description_set_weight((PangoFontDescription *)arg0, (PangoWeight)arg1);
+	OS_NATIVE_EXIT(env, that, _1pango_1font_1description_1set_1weight_FUNC);
+}
+#endif
+
+#ifndef NO__1pango_1font_1description_1to_1string
+JNIEXPORT jint JNICALL OS_NATIVE(_1pango_1font_1description_1to_1string)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1pango_1font_1description_1to_1string_FUNC);
+	rc = (jint)pango_font_description_to_string((PangoFontDescription *)arg0);
+	OS_NATIVE_EXIT(env, that, _1pango_1font_1description_1to_1string_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1pango_1font_1face_1describe
+JNIEXPORT jint JNICALL OS_NATIVE(_1pango_1font_1face_1describe)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1pango_1font_1face_1describe_FUNC);
+	rc = (jint)pango_font_face_describe((PangoFontFace *)arg0);
+	OS_NATIVE_EXIT(env, that, _1pango_1font_1face_1describe_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1pango_1font_1family_1get_1name
+JNIEXPORT jint JNICALL OS_NATIVE(_1pango_1font_1family_1get_1name)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1pango_1font_1family_1get_1name_FUNC);
+	rc = (jint)pango_font_family_get_name((PangoFontFamily *)arg0);
+	OS_NATIVE_EXIT(env, that, _1pango_1font_1family_1get_1name_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1pango_1font_1family_1list_1faces
+JNIEXPORT void JNICALL OS_NATIVE(_1pango_1font_1family_1list_1faces)
+	(JNIEnv *env, jclass that, jint arg0, jintArray arg1, jintArray arg2)
+{
+	jint *lparg1=NULL;
+	jint *lparg2=NULL;
+	OS_NATIVE_ENTER(env, that, _1pango_1font_1family_1list_1faces_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	if (arg2) if ((lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL)) == NULL) goto fail;
+	pango_font_family_list_faces((PangoFontFamily *)arg0, (PangoFontFace ***)lparg1, (int *)lparg2);
+fail:
+	if (arg2 && lparg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
+	if (arg1 && lparg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0);
+	OS_NATIVE_EXIT(env, that, _1pango_1font_1family_1list_1faces_FUNC);
+}
+#endif
+
+#ifndef NO__1pango_1font_1get_1metrics
+JNIEXPORT jint JNICALL OS_NATIVE(_1pango_1font_1get_1metrics)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1pango_1font_1get_1metrics_FUNC);
+	rc = (jint)pango_font_get_metrics((PangoFont *)arg0, (PangoLanguage *)arg1);
+	OS_NATIVE_EXIT(env, that, _1pango_1font_1get_1metrics_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1pango_1font_1metrics_1get_1approximate_1char_1width
+JNIEXPORT jint JNICALL OS_NATIVE(_1pango_1font_1metrics_1get_1approximate_1char_1width)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1pango_1font_1metrics_1get_1approximate_1char_1width_FUNC);
+	rc = (jint)pango_font_metrics_get_approximate_char_width((PangoFontMetrics *)arg0);
+	OS_NATIVE_EXIT(env, that, _1pango_1font_1metrics_1get_1approximate_1char_1width_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1pango_1font_1metrics_1get_1ascent
+JNIEXPORT jint JNICALL OS_NATIVE(_1pango_1font_1metrics_1get_1ascent)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1pango_1font_1metrics_1get_1ascent_FUNC);
+	rc = (jint)pango_font_metrics_get_ascent((PangoFontMetrics *)arg0);
+	OS_NATIVE_EXIT(env, that, _1pango_1font_1metrics_1get_1ascent_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1pango_1font_1metrics_1get_1descent
+JNIEXPORT jint JNICALL OS_NATIVE(_1pango_1font_1metrics_1get_1descent)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1pango_1font_1metrics_1get_1descent_FUNC);
+	rc = (jint)pango_font_metrics_get_descent((PangoFontMetrics *)arg0);
+	OS_NATIVE_EXIT(env, that, _1pango_1font_1metrics_1get_1descent_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1pango_1font_1metrics_1get_1strikethrough_1position
+JNIEXPORT jint JNICALL OS_NATIVE(_1pango_1font_1metrics_1get_1strikethrough_1position)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1pango_1font_1metrics_1get_1strikethrough_1position_FUNC);
+/*
+	rc = (jint)pango_font_metrics_get_strikethrough_position(arg0);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jint (*FPTR)(jint);
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(pango_font_metrics_get_strikethrough_position_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "pango_font_metrics_get_strikethrough_position");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jint)(*fptr)(arg0);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1pango_1font_1metrics_1get_1strikethrough_1position_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1pango_1font_1metrics_1get_1strikethrough_1thickness
+JNIEXPORT jint JNICALL OS_NATIVE(_1pango_1font_1metrics_1get_1strikethrough_1thickness)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1pango_1font_1metrics_1get_1strikethrough_1thickness_FUNC);
+/*
+	rc = (jint)pango_font_metrics_get_strikethrough_thickness(arg0);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jint (*FPTR)(jint);
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(pango_font_metrics_get_strikethrough_thickness_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "pango_font_metrics_get_strikethrough_thickness");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jint)(*fptr)(arg0);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1pango_1font_1metrics_1get_1strikethrough_1thickness_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1pango_1font_1metrics_1get_1underline_1position
+JNIEXPORT jint JNICALL OS_NATIVE(_1pango_1font_1metrics_1get_1underline_1position)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1pango_1font_1metrics_1get_1underline_1position_FUNC);
+/*
+	rc = (jint)pango_font_metrics_get_underline_position(arg0);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jint (*FPTR)(jint);
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(pango_font_metrics_get_underline_position_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "pango_font_metrics_get_underline_position");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jint)(*fptr)(arg0);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1pango_1font_1metrics_1get_1underline_1position_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1pango_1font_1metrics_1get_1underline_1thickness
+JNIEXPORT jint JNICALL OS_NATIVE(_1pango_1font_1metrics_1get_1underline_1thickness)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1pango_1font_1metrics_1get_1underline_1thickness_FUNC);
+/*
+	rc = (jint)pango_font_metrics_get_underline_thickness(arg0);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef jint (*FPTR)(jint);
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(pango_font_metrics_get_underline_thickness_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "pango_font_metrics_get_underline_thickness");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (jint)(*fptr)(arg0);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1pango_1font_1metrics_1get_1underline_1thickness_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1pango_1font_1metrics_1unref
+JNIEXPORT void JNICALL OS_NATIVE(_1pango_1font_1metrics_1unref)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1pango_1font_1metrics_1unref_FUNC);
+	pango_font_metrics_unref((PangoFontMetrics *)arg0);
+	OS_NATIVE_EXIT(env, that, _1pango_1font_1metrics_1unref_FUNC);
+}
+#endif
+
+#ifndef NO__1pango_1language_1from_1string
+JNIEXPORT jint JNICALL OS_NATIVE(_1pango_1language_1from_1string)
+	(JNIEnv *env, jclass that, jbyteArray arg0)
+{
+	jbyte *lparg0=NULL;
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1pango_1language_1from_1string_FUNC);
+	if (arg0) if ((lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL)) == NULL) goto fail;
+	rc = (jint)pango_language_from_string((const char *)lparg0);
+fail:
+	if (arg0 && lparg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, JNI_ABORT);
+	OS_NATIVE_EXIT(env, that, _1pango_1language_1from_1string_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1pango_1layout_1context_1changed
+JNIEXPORT void JNICALL OS_NATIVE(_1pango_1layout_1context_1changed)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1pango_1layout_1context_1changed_FUNC);
+	pango_layout_context_changed((PangoLayout *)arg0);
+	OS_NATIVE_EXIT(env, that, _1pango_1layout_1context_1changed_FUNC);
+}
+#endif
+
+#ifndef NO__1pango_1layout_1get_1alignment
+JNIEXPORT jint JNICALL OS_NATIVE(_1pango_1layout_1get_1alignment)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1pango_1layout_1get_1alignment_FUNC);
+	rc = (jint)pango_layout_get_alignment((PangoLayout*)arg0);
+	OS_NATIVE_EXIT(env, that, _1pango_1layout_1get_1alignment_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1pango_1layout_1get_1attributes
+JNIEXPORT jint JNICALL OS_NATIVE(_1pango_1layout_1get_1attributes)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1pango_1layout_1get_1attributes_FUNC);
+	rc = (jint)pango_layout_get_attributes((PangoLayout *)arg0);
+	OS_NATIVE_EXIT(env, that, _1pango_1layout_1get_1attributes_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1pango_1layout_1get_1context
+JNIEXPORT jint JNICALL OS_NATIVE(_1pango_1layout_1get_1context)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1pango_1layout_1get_1context_FUNC);
+	rc = (jint)pango_layout_get_context((PangoLayout *)arg0);
+	OS_NATIVE_EXIT(env, that, _1pango_1layout_1get_1context_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1pango_1layout_1get_1indent
+JNIEXPORT jint JNICALL OS_NATIVE(_1pango_1layout_1get_1indent)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1pango_1layout_1get_1indent_FUNC);
+	rc = (jint)pango_layout_get_indent((PangoLayout*)arg0);
+	OS_NATIVE_EXIT(env, that, _1pango_1layout_1get_1indent_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1pango_1layout_1get_1iter
+JNIEXPORT jint JNICALL OS_NATIVE(_1pango_1layout_1get_1iter)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1pango_1layout_1get_1iter_FUNC);
+	rc = (jint)pango_layout_get_iter((PangoLayout*)arg0);
+	OS_NATIVE_EXIT(env, that, _1pango_1layout_1get_1iter_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1pango_1layout_1get_1justify
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1pango_1layout_1get_1justify)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1pango_1layout_1get_1justify_FUNC);
+	rc = (jboolean)pango_layout_get_justify((PangoLayout*)arg0);
+	OS_NATIVE_EXIT(env, that, _1pango_1layout_1get_1justify_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1pango_1layout_1get_1line
+JNIEXPORT jint JNICALL OS_NATIVE(_1pango_1layout_1get_1line)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1pango_1layout_1get_1line_FUNC);
+	rc = (jint)pango_layout_get_line((PangoLayout *)arg0, arg1);
+	OS_NATIVE_EXIT(env, that, _1pango_1layout_1get_1line_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1pango_1layout_1get_1line_1count
+JNIEXPORT jint JNICALL OS_NATIVE(_1pango_1layout_1get_1line_1count)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1pango_1layout_1get_1line_1count_FUNC);
+	rc = (jint)pango_layout_get_line_count((PangoLayout*)arg0);
+	OS_NATIVE_EXIT(env, that, _1pango_1layout_1get_1line_1count_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1pango_1layout_1get_1log_1attrs
+JNIEXPORT void JNICALL OS_NATIVE(_1pango_1layout_1get_1log_1attrs)
+	(JNIEnv *env, jclass that, jint arg0, jintArray arg1, jintArray arg2)
+{
+	jint *lparg1=NULL;
+	jint *lparg2=NULL;
+	OS_NATIVE_ENTER(env, that, _1pango_1layout_1get_1log_1attrs_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	if (arg2) if ((lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL)) == NULL) goto fail;
+	pango_layout_get_log_attrs((PangoLayout*)arg0, (PangoLogAttr **)lparg1, (int *)lparg2);
+fail:
+	if (arg2 && lparg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
+	if (arg1 && lparg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0);
+	OS_NATIVE_EXIT(env, that, _1pango_1layout_1get_1log_1attrs_FUNC);
+}
+#endif
+
+#ifndef NO__1pango_1layout_1get_1size
+JNIEXPORT void JNICALL OS_NATIVE(_1pango_1layout_1get_1size)
+	(JNIEnv *env, jclass that, jint arg0, jintArray arg1, jintArray arg2)
+{
+	jint *lparg1=NULL;
+	jint *lparg2=NULL;
+	OS_NATIVE_ENTER(env, that, _1pango_1layout_1get_1size_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	if (arg2) if ((lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL)) == NULL) goto fail;
+	pango_layout_get_size((PangoLayout *)arg0, (int *)lparg1, (int *)lparg2);
+fail:
+	if (arg2 && lparg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
+	if (arg1 && lparg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0);
+	OS_NATIVE_EXIT(env, that, _1pango_1layout_1get_1size_FUNC);
+}
+#endif
+
+#ifndef NO__1pango_1layout_1get_1spacing
+JNIEXPORT jint JNICALL OS_NATIVE(_1pango_1layout_1get_1spacing)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1pango_1layout_1get_1spacing_FUNC);
+	rc = (jint)pango_layout_get_spacing((PangoLayout*)arg0);
+	OS_NATIVE_EXIT(env, that, _1pango_1layout_1get_1spacing_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1pango_1layout_1get_1tabs
+JNIEXPORT jint JNICALL OS_NATIVE(_1pango_1layout_1get_1tabs)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1pango_1layout_1get_1tabs_FUNC);
+	rc = (jint)pango_layout_get_tabs((PangoLayout*)arg0);
+	OS_NATIVE_EXIT(env, that, _1pango_1layout_1get_1tabs_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1pango_1layout_1get_1text
+JNIEXPORT jint JNICALL OS_NATIVE(_1pango_1layout_1get_1text)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1pango_1layout_1get_1text_FUNC);
+	rc = (jint)pango_layout_get_text((PangoLayout *)arg0);
+	OS_NATIVE_EXIT(env, that, _1pango_1layout_1get_1text_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1pango_1layout_1get_1width
+JNIEXPORT jint JNICALL OS_NATIVE(_1pango_1layout_1get_1width)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1pango_1layout_1get_1width_FUNC);
+	rc = (jint)pango_layout_get_width((PangoLayout *)arg0);
+	OS_NATIVE_EXIT(env, that, _1pango_1layout_1get_1width_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1pango_1layout_1index_1to_1pos
+JNIEXPORT void JNICALL OS_NATIVE(_1pango_1layout_1index_1to_1pos)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jobject arg2)
+{
+	PangoRectangle _arg2, *lparg2=NULL;
+	OS_NATIVE_ENTER(env, that, _1pango_1layout_1index_1to_1pos_FUNC);
+	if (arg2) if ((lparg2 = &_arg2) == NULL) goto fail;
+	pango_layout_index_to_pos((PangoLayout*)arg0, arg1, lparg2);
+fail:
+	if (arg2 && lparg2) setPangoRectangleFields(env, arg2, lparg2);
+	OS_NATIVE_EXIT(env, that, _1pango_1layout_1index_1to_1pos_FUNC);
+}
+#endif
+
+#ifndef NO__1pango_1layout_1iter_1free
+JNIEXPORT void JNICALL OS_NATIVE(_1pango_1layout_1iter_1free)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1pango_1layout_1iter_1free_FUNC);
+	pango_layout_iter_free((PangoLayoutIter*)arg0);
+	OS_NATIVE_EXIT(env, that, _1pango_1layout_1iter_1free_FUNC);
+}
+#endif
+
+#ifndef NO__1pango_1layout_1iter_1get_1index
+JNIEXPORT jint JNICALL OS_NATIVE(_1pango_1layout_1iter_1get_1index)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1pango_1layout_1iter_1get_1index_FUNC);
+	rc = (jint)pango_layout_iter_get_index((PangoLayoutIter*)arg0);
+	OS_NATIVE_EXIT(env, that, _1pango_1layout_1iter_1get_1index_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1pango_1layout_1iter_1get_1line_1extents
+JNIEXPORT void JNICALL OS_NATIVE(_1pango_1layout_1iter_1get_1line_1extents)
+	(JNIEnv *env, jclass that, jint arg0, jobject arg1, jobject arg2)
+{
+	PangoRectangle _arg1, *lparg1=NULL;
+	PangoRectangle _arg2, *lparg2=NULL;
+	OS_NATIVE_ENTER(env, that, _1pango_1layout_1iter_1get_1line_1extents_FUNC);
+	if (arg1) if ((lparg1 = &_arg1) == NULL) goto fail;
+	if (arg2) if ((lparg2 = &_arg2) == NULL) goto fail;
+	pango_layout_iter_get_line_extents((PangoLayoutIter*)arg0, lparg1, lparg2);
+fail:
+	if (arg2 && lparg2) setPangoRectangleFields(env, arg2, lparg2);
+	if (arg1 && lparg1) setPangoRectangleFields(env, arg1, lparg1);
+	OS_NATIVE_EXIT(env, that, _1pango_1layout_1iter_1get_1line_1extents_FUNC);
+}
+#endif
+
+#ifndef NO__1pango_1layout_1iter_1get_1run
+JNIEXPORT jint JNICALL OS_NATIVE(_1pango_1layout_1iter_1get_1run)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1pango_1layout_1iter_1get_1run_FUNC);
+	rc = (jint)pango_layout_iter_get_run((PangoLayoutIter*)arg0);
+	OS_NATIVE_EXIT(env, that, _1pango_1layout_1iter_1get_1run_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1pango_1layout_1iter_1next_1line
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1pango_1layout_1iter_1next_1line)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1pango_1layout_1iter_1next_1line_FUNC);
+	rc = (jboolean)pango_layout_iter_next_line((PangoLayoutIter*)arg0);
+	OS_NATIVE_EXIT(env, that, _1pango_1layout_1iter_1next_1line_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1pango_1layout_1iter_1next_1run
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1pango_1layout_1iter_1next_1run)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1pango_1layout_1iter_1next_1run_FUNC);
+	rc = (jboolean)pango_layout_iter_next_run((PangoLayoutIter*)arg0);
+	OS_NATIVE_EXIT(env, that, _1pango_1layout_1iter_1next_1run_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1pango_1layout_1line_1get_1extents
+JNIEXPORT void JNICALL OS_NATIVE(_1pango_1layout_1line_1get_1extents)
+	(JNIEnv *env, jclass that, jint arg0, jobject arg1, jobject arg2)
+{
+	PangoRectangle _arg1, *lparg1=NULL;
+	PangoRectangle _arg2, *lparg2=NULL;
+	OS_NATIVE_ENTER(env, that, _1pango_1layout_1line_1get_1extents_FUNC);
+	if (arg1) if ((lparg1 = &_arg1) == NULL) goto fail;
+	if (arg2) if ((lparg2 = &_arg2) == NULL) goto fail;
+	pango_layout_line_get_extents((PangoLayoutLine*)arg0, (PangoRectangle *)lparg1, (PangoRectangle *)lparg2);
+fail:
+	if (arg2 && lparg2) setPangoRectangleFields(env, arg2, lparg2);
+	if (arg1 && lparg1) setPangoRectangleFields(env, arg1, lparg1);
+	OS_NATIVE_EXIT(env, that, _1pango_1layout_1line_1get_1extents_FUNC);
+}
+#endif
+
+#ifndef NO__1pango_1layout_1line_1x_1to_1index
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1pango_1layout_1line_1x_1to_1index)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jintArray arg2, jintArray arg3)
+{
+	jint *lparg2=NULL;
+	jint *lparg3=NULL;
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1pango_1layout_1line_1x_1to_1index_FUNC);
+	if (arg2) if ((lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL)) == NULL) goto fail;
+	if (arg3) if ((lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL)) == NULL) goto fail;
+	rc = (jboolean)pango_layout_line_x_to_index((PangoLayoutLine*)arg0, arg1, (int *)lparg2, (int *)lparg3);
+fail:
+	if (arg3 && lparg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0);
+	if (arg2 && lparg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
+	OS_NATIVE_EXIT(env, that, _1pango_1layout_1line_1x_1to_1index_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1pango_1layout_1new
+JNIEXPORT jint JNICALL OS_NATIVE(_1pango_1layout_1new)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1pango_1layout_1new_FUNC);
+	rc = (jint)pango_layout_new((PangoContext *)arg0);
+	OS_NATIVE_EXIT(env, that, _1pango_1layout_1new_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1pango_1layout_1set_1alignment
+JNIEXPORT void JNICALL OS_NATIVE(_1pango_1layout_1set_1alignment)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1pango_1layout_1set_1alignment_FUNC);
+	pango_layout_set_alignment((PangoLayout *)arg0, arg1);
+	OS_NATIVE_EXIT(env, that, _1pango_1layout_1set_1alignment_FUNC);
+}
+#endif
+
+#ifndef NO__1pango_1layout_1set_1attributes
+JNIEXPORT void JNICALL OS_NATIVE(_1pango_1layout_1set_1attributes)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1pango_1layout_1set_1attributes_FUNC);
+	pango_layout_set_attributes((PangoLayout *)arg0, (PangoAttrList *)arg1);
+	OS_NATIVE_EXIT(env, that, _1pango_1layout_1set_1attributes_FUNC);
+}
+#endif
+
+#ifndef NO__1pango_1layout_1set_1auto_1dir
+JNIEXPORT void JNICALL OS_NATIVE(_1pango_1layout_1set_1auto_1dir)
+	(JNIEnv *env, jclass that, jint arg0, jboolean arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1pango_1layout_1set_1auto_1dir_FUNC);
+/*
+	pango_layout_set_auto_dir(arg0, arg1);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		typedef void (*FPTR)(jint, jboolean);
+		static FPTR fptr;
+		if (!initialized) {
+			if (!handle) handle = dlopen(pango_layout_set_auto_dir_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "pango_layout_set_auto_dir");
+			initialized = 1;
+		}
+		if (fptr) {
+			(*fptr)(arg0, arg1);
+		}
+	}
+	OS_NATIVE_EXIT(env, that, _1pango_1layout_1set_1auto_1dir_FUNC);
+}
+#endif
+
+#ifndef NO__1pango_1layout_1set_1font_1description
+JNIEXPORT void JNICALL OS_NATIVE(_1pango_1layout_1set_1font_1description)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1pango_1layout_1set_1font_1description_FUNC);
+	pango_layout_set_font_description((PangoLayout *)arg0, (PangoFontDescription *)arg1);
+	OS_NATIVE_EXIT(env, that, _1pango_1layout_1set_1font_1description_FUNC);
+}
+#endif
+
+#ifndef NO__1pango_1layout_1set_1indent
+JNIEXPORT void JNICALL OS_NATIVE(_1pango_1layout_1set_1indent)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1pango_1layout_1set_1indent_FUNC);
+	pango_layout_set_indent((PangoLayout*)arg0, arg1);
+	OS_NATIVE_EXIT(env, that, _1pango_1layout_1set_1indent_FUNC);
+}
+#endif
+
+#ifndef NO__1pango_1layout_1set_1justify
+JNIEXPORT void JNICALL OS_NATIVE(_1pango_1layout_1set_1justify)
+	(JNIEnv *env, jclass that, jint arg0, jboolean arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1pango_1layout_1set_1justify_FUNC);
+	pango_layout_set_justify((PangoLayout*)arg0, arg1);
+	OS_NATIVE_EXIT(env, that, _1pango_1layout_1set_1justify_FUNC);
+}
+#endif
+
+#ifndef NO__1pango_1layout_1set_1single_1paragraph_1mode
+JNIEXPORT void JNICALL OS_NATIVE(_1pango_1layout_1set_1single_1paragraph_1mode)
+	(JNIEnv *env, jclass that, jint arg0, jboolean arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1pango_1layout_1set_1single_1paragraph_1mode_FUNC);
+	pango_layout_set_single_paragraph_mode((PangoLayout *)arg0, (gboolean)arg1);
+	OS_NATIVE_EXIT(env, that, _1pango_1layout_1set_1single_1paragraph_1mode_FUNC);
+}
+#endif
+
+#ifndef NO__1pango_1layout_1set_1spacing
+JNIEXPORT void JNICALL OS_NATIVE(_1pango_1layout_1set_1spacing)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1pango_1layout_1set_1spacing_FUNC);
+	pango_layout_set_spacing((PangoLayout *)arg0, arg1);
+	OS_NATIVE_EXIT(env, that, _1pango_1layout_1set_1spacing_FUNC);
+}
+#endif
+
+#ifndef NO__1pango_1layout_1set_1tabs
+JNIEXPORT void JNICALL OS_NATIVE(_1pango_1layout_1set_1tabs)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1pango_1layout_1set_1tabs_FUNC);
+	pango_layout_set_tabs((PangoLayout *)arg0, (PangoTabArray *)arg1);
+	OS_NATIVE_EXIT(env, that, _1pango_1layout_1set_1tabs_FUNC);
+}
+#endif
+
+#ifndef NO__1pango_1layout_1set_1text
+JNIEXPORT void JNICALL OS_NATIVE(_1pango_1layout_1set_1text)
+	(JNIEnv *env, jclass that, jint arg0, jbyteArray arg1, jint arg2)
+{
+	jbyte *lparg1=NULL;
+	OS_NATIVE_ENTER(env, that, _1pango_1layout_1set_1text_FUNC);
+#ifdef JNI_VERSION_1_2
+	if (IS_JNI_1_2) {
+		if (arg1) if ((lparg1 = (*env)->GetPrimitiveArrayCritical(env, arg1, NULL)) == NULL) goto fail;
+	} else
+#endif
+	{
+		if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	}
+	pango_layout_set_text((PangoLayout *)arg0, (const char *)lparg1, (int)arg2);
+fail:
+#ifdef JNI_VERSION_1_2
+	if (IS_JNI_1_2) {
+		if (arg1 && lparg1) (*env)->ReleasePrimitiveArrayCritical(env, arg1, lparg1, JNI_ABORT);
+	} else
+#endif
+	{
+		if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, JNI_ABORT);
+	}
+	OS_NATIVE_EXIT(env, that, _1pango_1layout_1set_1text_FUNC);
+}
+#endif
+
+#ifndef NO__1pango_1layout_1set_1width
+JNIEXPORT void JNICALL OS_NATIVE(_1pango_1layout_1set_1width)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1pango_1layout_1set_1width_FUNC);
+	pango_layout_set_width((PangoLayout *)arg0, arg1);
+	OS_NATIVE_EXIT(env, that, _1pango_1layout_1set_1width_FUNC);
+}
+#endif
+
+#ifndef NO__1pango_1layout_1set_1wrap
+JNIEXPORT void JNICALL OS_NATIVE(_1pango_1layout_1set_1wrap)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, _1pango_1layout_1set_1wrap_FUNC);
+	pango_layout_set_wrap((PangoLayout *)arg0, arg1);
+	OS_NATIVE_EXIT(env, that, _1pango_1layout_1set_1wrap_FUNC);
+}
+#endif
+
+#ifndef NO__1pango_1layout_1xy_1to_1index
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1pango_1layout_1xy_1to_1index)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jintArray arg3, jintArray arg4)
+{
+	jint *lparg3=NULL;
+	jint *lparg4=NULL;
+	jboolean rc = 0;
+	OS_NATIVE_ENTER(env, that, _1pango_1layout_1xy_1to_1index_FUNC);
+	if (arg3) if ((lparg3 = (*env)->GetIntArrayElements(env, arg3, NULL)) == NULL) goto fail;
+	if (arg4) if ((lparg4 = (*env)->GetIntArrayElements(env, arg4, NULL)) == NULL) goto fail;
+	rc = (jboolean)pango_layout_xy_to_index((PangoLayout *)arg0, arg1, arg2, (int *)lparg3, (int *)lparg4);
+fail:
+	if (arg4 && lparg4) (*env)->ReleaseIntArrayElements(env, arg4, lparg4, 0);
+	if (arg3 && lparg3) (*env)->ReleaseIntArrayElements(env, arg3, lparg3, 0);
+	OS_NATIVE_EXIT(env, that, _1pango_1layout_1xy_1to_1index_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1pango_1tab_1array_1free
+JNIEXPORT void JNICALL OS_NATIVE(_1pango_1tab_1array_1free)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, _1pango_1tab_1array_1free_FUNC);
+	pango_tab_array_free((PangoTabArray *)arg0);
+	OS_NATIVE_EXIT(env, that, _1pango_1tab_1array_1free_FUNC);
+}
+#endif
+
+#ifndef NO__1pango_1tab_1array_1get_1size
+JNIEXPORT jint JNICALL OS_NATIVE(_1pango_1tab_1array_1get_1size)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1pango_1tab_1array_1get_1size_FUNC);
+	rc = (jint)pango_tab_array_get_size((PangoTabArray *)arg0);
+	OS_NATIVE_EXIT(env, that, _1pango_1tab_1array_1get_1size_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1pango_1tab_1array_1get_1tabs
+JNIEXPORT void JNICALL OS_NATIVE(_1pango_1tab_1array_1get_1tabs)
+	(JNIEnv *env, jclass that, jint arg0, jintArray arg1, jintArray arg2)
+{
+	jint *lparg1=NULL;
+	jint *lparg2=NULL;
+	OS_NATIVE_ENTER(env, that, _1pango_1tab_1array_1get_1tabs_FUNC);
+	if (arg1) if ((lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	if (arg2) if ((lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL)) == NULL) goto fail;
+	pango_tab_array_get_tabs((PangoTabArray *)arg0, (PangoTabAlign **)lparg1, (int **)lparg2);
+fail:
+	if (arg2 && lparg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
+	if (arg1 && lparg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0);
+	OS_NATIVE_EXIT(env, that, _1pango_1tab_1array_1get_1tabs_FUNC);
+}
+#endif
+
+#ifndef NO__1pango_1tab_1array_1new
+JNIEXPORT jint JNICALL OS_NATIVE(_1pango_1tab_1array_1new)
+	(JNIEnv *env, jclass that, jint arg0, jboolean arg1)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1pango_1tab_1array_1new_FUNC);
+	rc = (jint)pango_tab_array_new((gint)arg0, (gboolean)arg1);
+	OS_NATIVE_EXIT(env, that, _1pango_1tab_1array_1new_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1pango_1tab_1array_1set_1tab
+JNIEXPORT void JNICALL OS_NATIVE(_1pango_1tab_1array_1set_1tab)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3)
+{
+	OS_NATIVE_ENTER(env, that, _1pango_1tab_1array_1set_1tab_FUNC);
+	pango_tab_array_set_tab((PangoTabArray *)arg0, (gint)arg1, (PangoTabAlign)arg2, (gint)arg3);
+	OS_NATIVE_EXIT(env, that, _1pango_1tab_1array_1set_1tab_FUNC);
+}
+#endif
+
+#ifndef NO_g_1main_1context_1wakeup
+JNIEXPORT void JNICALL OS_NATIVE(g_1main_1context_1wakeup)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	OS_NATIVE_ENTER(env, that, g_1main_1context_1wakeup_FUNC);
+	g_main_context_wakeup((GMainContext *)arg0);
+	OS_NATIVE_EXIT(env, that, g_1main_1context_1wakeup_FUNC);
+}
+#endif
+
+#ifndef NO_localeconv_1decimal_1point
+JNIEXPORT jint JNICALL OS_NATIVE(localeconv_1decimal_1point)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, localeconv_1decimal_1point_FUNC);
+	rc = (jint)localeconv_decimal_point();
+	OS_NATIVE_EXIT(env, that, localeconv_1decimal_1point_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_memmove__ILorg_eclipse_swt_internal_gtk_GInterfaceInfo_2I
+JNIEXPORT void JNICALL OS_NATIVE(memmove__ILorg_eclipse_swt_internal_gtk_GInterfaceInfo_2I)
+	(JNIEnv *env, jclass that, jint arg0, jobject arg1, jint arg2)
+{
+	GInterfaceInfo _arg1, *lparg1=NULL;
+	OS_NATIVE_ENTER(env, that, memmove__ILorg_eclipse_swt_internal_gtk_GInterfaceInfo_2I_FUNC);
+	if (arg1) if ((lparg1 = getGInterfaceInfoFields(env, arg1, &_arg1)) == NULL) goto fail;
+	memmove((void *)arg0, (const void *)lparg1, (size_t)arg2);
+fail:
+	OS_NATIVE_EXIT(env, that, memmove__ILorg_eclipse_swt_internal_gtk_GInterfaceInfo_2I_FUNC);
+}
+#endif
+
+#ifndef NO_memmove__ILorg_eclipse_swt_internal_gtk_GObjectClass_2
+JNIEXPORT void JNICALL OS_NATIVE(memmove__ILorg_eclipse_swt_internal_gtk_GObjectClass_2)
+	(JNIEnv *env, jclass that, jint arg0, jobject arg1)
+{
+	OS_NATIVE_ENTER(env, that, memmove__ILorg_eclipse_swt_internal_gtk_GObjectClass_2_FUNC);
+	if (arg1) getGObjectClassFields(env, arg1, (GObjectClass *)arg0);
+	OS_NATIVE_EXIT(env, that, memmove__ILorg_eclipse_swt_internal_gtk_GObjectClass_2_FUNC);
+}
+#endif
+
+#ifndef NO_memmove__ILorg_eclipse_swt_internal_gtk_GTypeInfo_2I
+JNIEXPORT void JNICALL OS_NATIVE(memmove__ILorg_eclipse_swt_internal_gtk_GTypeInfo_2I)
+	(JNIEnv *env, jclass that, jint arg0, jobject arg1, jint arg2)
+{
+	GTypeInfo _arg1, *lparg1=NULL;
+	OS_NATIVE_ENTER(env, that, memmove__ILorg_eclipse_swt_internal_gtk_GTypeInfo_2I_FUNC);
+	if (arg1) if ((lparg1 = getGTypeInfoFields(env, arg1, &_arg1)) == NULL) goto fail;
+	memmove((void *)arg0, (const void *)lparg1, (size_t)arg2);
+fail:
+	OS_NATIVE_EXIT(env, that, memmove__ILorg_eclipse_swt_internal_gtk_GTypeInfo_2I_FUNC);
+}
+#endif
+
+#ifndef NO_memmove__ILorg_eclipse_swt_internal_gtk_GdkEventButton_2I
+JNIEXPORT void JNICALL OS_NATIVE(memmove__ILorg_eclipse_swt_internal_gtk_GdkEventButton_2I)
+	(JNIEnv *env, jclass that, jint arg0, jobject arg1, jint arg2)
+{
+	GdkEventButton _arg1, *lparg1=NULL;
+	OS_NATIVE_ENTER(env, that, memmove__ILorg_eclipse_swt_internal_gtk_GdkEventButton_2I_FUNC);
+	if (arg1) if ((lparg1 = getGdkEventButtonFields(env, arg1, &_arg1)) == NULL) goto fail;
+	memmove((void *)arg0, (const void *)lparg1, (size_t)arg2);
+fail:
+	OS_NATIVE_EXIT(env, that, memmove__ILorg_eclipse_swt_internal_gtk_GdkEventButton_2I_FUNC);
+}
+#endif
+
+#ifndef NO_memmove__ILorg_eclipse_swt_internal_gtk_GdkEventExpose_2I
+JNIEXPORT void JNICALL OS_NATIVE(memmove__ILorg_eclipse_swt_internal_gtk_GdkEventExpose_2I)
+	(JNIEnv *env, jclass that, jint arg0, jobject arg1, jint arg2)
+{
+	GdkEventExpose _arg1, *lparg1=NULL;
+	OS_NATIVE_ENTER(env, that, memmove__ILorg_eclipse_swt_internal_gtk_GdkEventExpose_2I_FUNC);
+	if (arg1) if ((lparg1 = getGdkEventExposeFields(env, arg1, &_arg1)) == NULL) goto fail;
+	memmove((void *)arg0, (const void *)lparg1, (size_t)arg2);
+fail:
+	OS_NATIVE_EXIT(env, that, memmove__ILorg_eclipse_swt_internal_gtk_GdkEventExpose_2I_FUNC);
+}
+#endif
+
+#ifndef NO_memmove__ILorg_eclipse_swt_internal_gtk_GdkEventMotion_2I
+JNIEXPORT void JNICALL OS_NATIVE(memmove__ILorg_eclipse_swt_internal_gtk_GdkEventMotion_2I)
+	(JNIEnv *env, jclass that, jint arg0, jobject arg1, jint arg2)
+{
+	GdkEventMotion _arg1, *lparg1=NULL;
+	OS_NATIVE_ENTER(env, that, memmove__ILorg_eclipse_swt_internal_gtk_GdkEventMotion_2I_FUNC);
+	if (arg1) if ((lparg1 = getGdkEventMotionFields(env, arg1, &_arg1)) == NULL) goto fail;
+	memmove((void *)arg0, (const void *)lparg1, (size_t)arg2);
+fail:
+	OS_NATIVE_EXIT(env, that, memmove__ILorg_eclipse_swt_internal_gtk_GdkEventMotion_2I_FUNC);
+}
+#endif
+
+#ifndef NO_memmove__ILorg_eclipse_swt_internal_gtk_GtkAdjustment_2
+JNIEXPORT void JNICALL OS_NATIVE(memmove__ILorg_eclipse_swt_internal_gtk_GtkAdjustment_2)
+	(JNIEnv *env, jclass that, jint arg0, jobject arg1)
+{
+	OS_NATIVE_ENTER(env, that, memmove__ILorg_eclipse_swt_internal_gtk_GtkAdjustment_2_FUNC);
+	if (arg1) getGtkAdjustmentFields(env, arg1, (GtkAdjustment *)arg0);
+	OS_NATIVE_EXIT(env, that, memmove__ILorg_eclipse_swt_internal_gtk_GtkAdjustment_2_FUNC);
+}
+#endif
+
+#ifndef NO_memmove__ILorg_eclipse_swt_internal_gtk_GtkCellRendererClass_2
+JNIEXPORT void JNICALL OS_NATIVE(memmove__ILorg_eclipse_swt_internal_gtk_GtkCellRendererClass_2)
+	(JNIEnv *env, jclass that, jint arg0, jobject arg1)
+{
+	OS_NATIVE_ENTER(env, that, memmove__ILorg_eclipse_swt_internal_gtk_GtkCellRendererClass_2_FUNC);
+	if (arg1) getGtkCellRendererClassFields(env, arg1, (GtkCellRendererClass *)arg0);
+	OS_NATIVE_EXIT(env, that, memmove__ILorg_eclipse_swt_internal_gtk_GtkCellRendererClass_2_FUNC);
+}
+#endif
+
+#ifndef NO_memmove__ILorg_eclipse_swt_internal_gtk_GtkFixed_2
+JNIEXPORT void JNICALL OS_NATIVE(memmove__ILorg_eclipse_swt_internal_gtk_GtkFixed_2)
+	(JNIEnv *env, jclass that, jint arg0, jobject arg1)
+{
+	OS_NATIVE_ENTER(env, that, memmove__ILorg_eclipse_swt_internal_gtk_GtkFixed_2_FUNC);
+	if (arg1) getGtkFixedFields(env, arg1, (GtkFixed *)arg0);
+	OS_NATIVE_EXIT(env, that, memmove__ILorg_eclipse_swt_internal_gtk_GtkFixed_2_FUNC);
+}
+#endif
+
+#ifndef NO_memmove__ILorg_eclipse_swt_internal_gtk_GtkTargetEntry_2I
+JNIEXPORT void JNICALL OS_NATIVE(memmove__ILorg_eclipse_swt_internal_gtk_GtkTargetEntry_2I)
+	(JNIEnv *env, jclass that, jint arg0, jobject arg1, jint arg2)
+{
+	GtkTargetEntry _arg1, *lparg1=NULL;
+	OS_NATIVE_ENTER(env, that, memmove__ILorg_eclipse_swt_internal_gtk_GtkTargetEntry_2I_FUNC);
+	if (arg1) if ((lparg1 = getGtkTargetEntryFields(env, arg1, &_arg1)) == NULL) goto fail;
+	memmove((void *)arg0, (const void *)lparg1, (size_t)arg2);
+fail:
+	OS_NATIVE_EXIT(env, that, memmove__ILorg_eclipse_swt_internal_gtk_GtkTargetEntry_2I_FUNC);
+}
+#endif
+
+#ifndef NO_memmove__ILorg_eclipse_swt_internal_gtk_GtkWidgetClass_2
+JNIEXPORT void JNICALL OS_NATIVE(memmove__ILorg_eclipse_swt_internal_gtk_GtkWidgetClass_2)
+	(JNIEnv *env, jclass that, jint arg0, jobject arg1)
+{
+	OS_NATIVE_ENTER(env, that, memmove__ILorg_eclipse_swt_internal_gtk_GtkWidgetClass_2_FUNC);
+	if (arg1) getGtkWidgetClassFields(env, arg1, (GtkWidgetClass *)arg0);
+	OS_NATIVE_EXIT(env, that, memmove__ILorg_eclipse_swt_internal_gtk_GtkWidgetClass_2_FUNC);
+}
+#endif
+
+#ifndef NO_memmove__ILorg_eclipse_swt_internal_gtk_PangoAttribute_2I
+JNIEXPORT void JNICALL OS_NATIVE(memmove__ILorg_eclipse_swt_internal_gtk_PangoAttribute_2I)
+	(JNIEnv *env, jclass that, jint arg0, jobject arg1, jint arg2)
+{
+	PangoAttribute _arg1, *lparg1=NULL;
+	OS_NATIVE_ENTER(env, that, memmove__ILorg_eclipse_swt_internal_gtk_PangoAttribute_2I_FUNC);
+	if (arg1) if ((lparg1 = getPangoAttributeFields(env, arg1, &_arg1)) == NULL) goto fail;
+	memmove((void *)arg0, (const void *)lparg1, (size_t)arg2);
+fail:
+	OS_NATIVE_EXIT(env, that, memmove__ILorg_eclipse_swt_internal_gtk_PangoAttribute_2I_FUNC);
+}
+#endif
+
+#ifndef NO_memmove__ILorg_eclipse_swt_internal_gtk_XButtonEvent_2I
+JNIEXPORT void JNICALL OS_NATIVE(memmove__ILorg_eclipse_swt_internal_gtk_XButtonEvent_2I)
+	(JNIEnv *env, jclass that, jint arg0, jobject arg1, jint arg2)
+{
+	XButtonEvent _arg1, *lparg1=NULL;
+	OS_NATIVE_ENTER(env, that, memmove__ILorg_eclipse_swt_internal_gtk_XButtonEvent_2I_FUNC);
+	if (arg1) if ((lparg1 = getXButtonEventFields(env, arg1, &_arg1)) == NULL) goto fail;
+	memmove((void *)arg0, (const void *)lparg1, (size_t)arg2);
+fail:
+	OS_NATIVE_EXIT(env, that, memmove__ILorg_eclipse_swt_internal_gtk_XButtonEvent_2I_FUNC);
+}
+#endif
+
+#ifndef NO_memmove__ILorg_eclipse_swt_internal_gtk_XClientMessageEvent_2I
+JNIEXPORT void JNICALL OS_NATIVE(memmove__ILorg_eclipse_swt_internal_gtk_XClientMessageEvent_2I)
+	(JNIEnv *env, jclass that, jint arg0, jobject arg1, jint arg2)
+{
+	XClientMessageEvent _arg1, *lparg1=NULL;
+	OS_NATIVE_ENTER(env, that, memmove__ILorg_eclipse_swt_internal_gtk_XClientMessageEvent_2I_FUNC);
+	if (arg1) if ((lparg1 = getXClientMessageEventFields(env, arg1, &_arg1)) == NULL) goto fail;
+	memmove((void *)arg0, (const void *)lparg1, (size_t)arg2);
+fail:
+	OS_NATIVE_EXIT(env, that, memmove__ILorg_eclipse_swt_internal_gtk_XClientMessageEvent_2I_FUNC);
+}
+#endif
+
+#ifndef NO_memmove__ILorg_eclipse_swt_internal_gtk_XCrossingEvent_2I
+JNIEXPORT void JNICALL OS_NATIVE(memmove__ILorg_eclipse_swt_internal_gtk_XCrossingEvent_2I)
+	(JNIEnv *env, jclass that, jint arg0, jobject arg1, jint arg2)
+{
+	XCrossingEvent _arg1, *lparg1=NULL;
+	OS_NATIVE_ENTER(env, that, memmove__ILorg_eclipse_swt_internal_gtk_XCrossingEvent_2I_FUNC);
+	if (arg1) if ((lparg1 = getXCrossingEventFields(env, arg1, &_arg1)) == NULL) goto fail;
+	memmove((void *)arg0, (const void *)lparg1, (size_t)arg2);
+fail:
+	OS_NATIVE_EXIT(env, that, memmove__ILorg_eclipse_swt_internal_gtk_XCrossingEvent_2I_FUNC);
+}
+#endif
+
+#ifndef NO_memmove__ILorg_eclipse_swt_internal_gtk_XExposeEvent_2I
+JNIEXPORT void JNICALL OS_NATIVE(memmove__ILorg_eclipse_swt_internal_gtk_XExposeEvent_2I)
+	(JNIEnv *env, jclass that, jint arg0, jobject arg1, jint arg2)
+{
+	XExposeEvent _arg1, *lparg1=NULL;
+	OS_NATIVE_ENTER(env, that, memmove__ILorg_eclipse_swt_internal_gtk_XExposeEvent_2I_FUNC);
+	if (arg1) if ((lparg1 = getXExposeEventFields(env, arg1, &_arg1)) == NULL) goto fail;
+	memmove((void *)arg0, (const void *)lparg1, (size_t)arg2);
+fail:
+	OS_NATIVE_EXIT(env, that, memmove__ILorg_eclipse_swt_internal_gtk_XExposeEvent_2I_FUNC);
+}
+#endif
+
+#ifndef NO_memmove__ILorg_eclipse_swt_internal_gtk_XFocusChangeEvent_2I
+JNIEXPORT void JNICALL OS_NATIVE(memmove__ILorg_eclipse_swt_internal_gtk_XFocusChangeEvent_2I)
+	(JNIEnv *env, jclass that, jint arg0, jobject arg1, jint arg2)
+{
+	XFocusChangeEvent _arg1, *lparg1=NULL;
+	OS_NATIVE_ENTER(env, that, memmove__ILorg_eclipse_swt_internal_gtk_XFocusChangeEvent_2I_FUNC);
+	if (arg1) if ((lparg1 = getXFocusChangeEventFields(env, arg1, &_arg1)) == NULL) goto fail;
+	memmove((void *)arg0, (const void *)lparg1, (size_t)arg2);
+fail:
+	OS_NATIVE_EXIT(env, that, memmove__ILorg_eclipse_swt_internal_gtk_XFocusChangeEvent_2I_FUNC);
+}
+#endif
+
+#ifndef NO_memmove__Lorg_eclipse_swt_internal_gtk_GObjectClass_2I
+JNIEXPORT void JNICALL OS_NATIVE(memmove__Lorg_eclipse_swt_internal_gtk_GObjectClass_2I)
+	(JNIEnv *env, jclass that, jobject arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, memmove__Lorg_eclipse_swt_internal_gtk_GObjectClass_2I_FUNC);
+	if (arg0) setGObjectClassFields(env, arg0, (GObjectClass *)arg1);
+	OS_NATIVE_EXIT(env, that, memmove__Lorg_eclipse_swt_internal_gtk_GObjectClass_2I_FUNC);
+}
+#endif
+
+#ifndef NO_memmove__Lorg_eclipse_swt_internal_gtk_GTypeQuery_2II
+JNIEXPORT void JNICALL OS_NATIVE(memmove__Lorg_eclipse_swt_internal_gtk_GTypeQuery_2II)
+	(JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2)
+{
+	GTypeQuery _arg0, *lparg0=NULL;
+	OS_NATIVE_ENTER(env, that, memmove__Lorg_eclipse_swt_internal_gtk_GTypeQuery_2II_FUNC);
+	if (arg0) if ((lparg0 = &_arg0) == NULL) goto fail;
+	memmove((void *)lparg0, (const void *)arg1, (size_t)arg2);
+fail:
+	if (arg0 && lparg0) setGTypeQueryFields(env, arg0, lparg0);
+	OS_NATIVE_EXIT(env, that, memmove__Lorg_eclipse_swt_internal_gtk_GTypeQuery_2II_FUNC);
+}
+#endif
+
+#ifndef NO_memmove__Lorg_eclipse_swt_internal_gtk_GdkColor_2II
+JNIEXPORT void JNICALL OS_NATIVE(memmove__Lorg_eclipse_swt_internal_gtk_GdkColor_2II)
+	(JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2)
+{
+	GdkColor _arg0, *lparg0=NULL;
+	OS_NATIVE_ENTER(env, that, memmove__Lorg_eclipse_swt_internal_gtk_GdkColor_2II_FUNC);
+	if (arg0) if ((lparg0 = &_arg0) == NULL) goto fail;
+	memmove((void *)lparg0, (const void *)arg1, (size_t)arg2);
+fail:
+	if (arg0 && lparg0) setGdkColorFields(env, arg0, lparg0);
+	OS_NATIVE_EXIT(env, that, memmove__Lorg_eclipse_swt_internal_gtk_GdkColor_2II_FUNC);
+}
+#endif
+
+#ifndef NO_memmove__Lorg_eclipse_swt_internal_gtk_GdkDragContext_2II
+JNIEXPORT void JNICALL OS_NATIVE(memmove__Lorg_eclipse_swt_internal_gtk_GdkDragContext_2II)
+	(JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2)
+{
+	GdkDragContext _arg0, *lparg0=NULL;
+	OS_NATIVE_ENTER(env, that, memmove__Lorg_eclipse_swt_internal_gtk_GdkDragContext_2II_FUNC);
+	if (arg0) if ((lparg0 = &_arg0) == NULL) goto fail;
+	memmove((void *)lparg0, (const void *)arg1, (size_t)arg2);
+fail:
+	if (arg0 && lparg0) setGdkDragContextFields(env, arg0, lparg0);
+	OS_NATIVE_EXIT(env, that, memmove__Lorg_eclipse_swt_internal_gtk_GdkDragContext_2II_FUNC);
+}
+#endif
+
+#ifndef NO_memmove__Lorg_eclipse_swt_internal_gtk_GdkEventAny_2II
+JNIEXPORT void JNICALL OS_NATIVE(memmove__Lorg_eclipse_swt_internal_gtk_GdkEventAny_2II)
+	(JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2)
+{
+	GdkEventAny _arg0, *lparg0=NULL;
+	OS_NATIVE_ENTER(env, that, memmove__Lorg_eclipse_swt_internal_gtk_GdkEventAny_2II_FUNC);
+	if (arg0) if ((lparg0 = &_arg0) == NULL) goto fail;
+	memmove((void *)lparg0, (const void *)arg1, (size_t)arg2);
+fail:
+	if (arg0 && lparg0) setGdkEventAnyFields(env, arg0, lparg0);
+	OS_NATIVE_EXIT(env, that, memmove__Lorg_eclipse_swt_internal_gtk_GdkEventAny_2II_FUNC);
+}
+#endif
+
+#ifndef NO_memmove__Lorg_eclipse_swt_internal_gtk_GdkEventButton_2II
+JNIEXPORT void JNICALL OS_NATIVE(memmove__Lorg_eclipse_swt_internal_gtk_GdkEventButton_2II)
+	(JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2)
+{
+	GdkEventButton _arg0, *lparg0=NULL;
+	OS_NATIVE_ENTER(env, that, memmove__Lorg_eclipse_swt_internal_gtk_GdkEventButton_2II_FUNC);
+	if (arg0) if ((lparg0 = &_arg0) == NULL) goto fail;
+	memmove((void *)lparg0, (const void *)arg1, (size_t)arg2);
+fail:
+	if (arg0 && lparg0) setGdkEventButtonFields(env, arg0, lparg0);
+	OS_NATIVE_EXIT(env, that, memmove__Lorg_eclipse_swt_internal_gtk_GdkEventButton_2II_FUNC);
+}
+#endif
+
+#ifndef NO_memmove__Lorg_eclipse_swt_internal_gtk_GdkEventCrossing_2II
+JNIEXPORT void JNICALL OS_NATIVE(memmove__Lorg_eclipse_swt_internal_gtk_GdkEventCrossing_2II)
+	(JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2)
+{
+	GdkEventCrossing _arg0, *lparg0=NULL;
+	OS_NATIVE_ENTER(env, that, memmove__Lorg_eclipse_swt_internal_gtk_GdkEventCrossing_2II_FUNC);
+	if (arg0) if ((lparg0 = &_arg0) == NULL) goto fail;
+	memmove((void *)lparg0, (const void *)arg1, (size_t)arg2);
+fail:
+	if (arg0 && lparg0) setGdkEventCrossingFields(env, arg0, lparg0);
+	OS_NATIVE_EXIT(env, that, memmove__Lorg_eclipse_swt_internal_gtk_GdkEventCrossing_2II_FUNC);
+}
+#endif
+
+#ifndef NO_memmove__Lorg_eclipse_swt_internal_gtk_GdkEventExpose_2II
+JNIEXPORT void JNICALL OS_NATIVE(memmove__Lorg_eclipse_swt_internal_gtk_GdkEventExpose_2II)
+	(JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2)
+{
+	GdkEventExpose _arg0, *lparg0=NULL;
+	OS_NATIVE_ENTER(env, that, memmove__Lorg_eclipse_swt_internal_gtk_GdkEventExpose_2II_FUNC);
+	if (arg0) if ((lparg0 = &_arg0) == NULL) goto fail;
+	memmove((void *)lparg0, (const void *)arg1, (size_t)arg2);
+fail:
+	if (arg0 && lparg0) setGdkEventExposeFields(env, arg0, lparg0);
+	OS_NATIVE_EXIT(env, that, memmove__Lorg_eclipse_swt_internal_gtk_GdkEventExpose_2II_FUNC);
+}
+#endif
+
+#ifndef NO_memmove__Lorg_eclipse_swt_internal_gtk_GdkEventFocus_2II
+JNIEXPORT void JNICALL OS_NATIVE(memmove__Lorg_eclipse_swt_internal_gtk_GdkEventFocus_2II)
+	(JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2)
+{
+	GdkEventFocus _arg0, *lparg0=NULL;
+	OS_NATIVE_ENTER(env, that, memmove__Lorg_eclipse_swt_internal_gtk_GdkEventFocus_2II_FUNC);
+	if (arg0) if ((lparg0 = &_arg0) == NULL) goto fail;
+	memmove((void *)lparg0, (const void *)arg1, (size_t)arg2);
+fail:
+	if (arg0 && lparg0) setGdkEventFocusFields(env, arg0, lparg0);
+	OS_NATIVE_EXIT(env, that, memmove__Lorg_eclipse_swt_internal_gtk_GdkEventFocus_2II_FUNC);
+}
+#endif
+
+#ifndef NO_memmove__Lorg_eclipse_swt_internal_gtk_GdkEventKey_2II
+JNIEXPORT void JNICALL OS_NATIVE(memmove__Lorg_eclipse_swt_internal_gtk_GdkEventKey_2II)
+	(JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2)
+{
+	GdkEventKey _arg0, *lparg0=NULL;
+	OS_NATIVE_ENTER(env, that, memmove__Lorg_eclipse_swt_internal_gtk_GdkEventKey_2II_FUNC);
+	if (arg0) if ((lparg0 = &_arg0) == NULL) goto fail;
+	memmove((void *)lparg0, (const void *)arg1, (size_t)arg2);
+fail:
+	if (arg0 && lparg0) setGdkEventKeyFields(env, arg0, lparg0);
+	OS_NATIVE_EXIT(env, that, memmove__Lorg_eclipse_swt_internal_gtk_GdkEventKey_2II_FUNC);
+}
+#endif
+
+#ifndef NO_memmove__Lorg_eclipse_swt_internal_gtk_GdkEventMotion_2II
+JNIEXPORT void JNICALL OS_NATIVE(memmove__Lorg_eclipse_swt_internal_gtk_GdkEventMotion_2II)
+	(JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2)
+{
+	GdkEventMotion _arg0, *lparg0=NULL;
+	OS_NATIVE_ENTER(env, that, memmove__Lorg_eclipse_swt_internal_gtk_GdkEventMotion_2II_FUNC);
+	if (arg0) if ((lparg0 = &_arg0) == NULL) goto fail;
+	memmove((void *)lparg0, (const void *)arg1, (size_t)arg2);
+fail:
+	if (arg0 && lparg0) setGdkEventMotionFields(env, arg0, lparg0);
+	OS_NATIVE_EXIT(env, that, memmove__Lorg_eclipse_swt_internal_gtk_GdkEventMotion_2II_FUNC);
+}
+#endif
+
+#ifndef NO_memmove__Lorg_eclipse_swt_internal_gtk_GdkEventScroll_2II
+JNIEXPORT void JNICALL OS_NATIVE(memmove__Lorg_eclipse_swt_internal_gtk_GdkEventScroll_2II)
+	(JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2)
+{
+	GdkEventScroll _arg0, *lparg0=NULL;
+	OS_NATIVE_ENTER(env, that, memmove__Lorg_eclipse_swt_internal_gtk_GdkEventScroll_2II_FUNC);
+	if (arg0) if ((lparg0 = &_arg0) == NULL) goto fail;
+	memmove((void *)lparg0, (const void *)arg1, (size_t)arg2);
+fail:
+	if (arg0 && lparg0) setGdkEventScrollFields(env, arg0, lparg0);
+	OS_NATIVE_EXIT(env, that, memmove__Lorg_eclipse_swt_internal_gtk_GdkEventScroll_2II_FUNC);
+}
+#endif
+
+#ifndef NO_memmove__Lorg_eclipse_swt_internal_gtk_GdkEventVisibility_2II
+JNIEXPORT void JNICALL OS_NATIVE(memmove__Lorg_eclipse_swt_internal_gtk_GdkEventVisibility_2II)
+	(JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2)
+{
+	GdkEventVisibility _arg0, *lparg0=NULL;
+	OS_NATIVE_ENTER(env, that, memmove__Lorg_eclipse_swt_internal_gtk_GdkEventVisibility_2II_FUNC);
+	if (arg0) if ((lparg0 = &_arg0) == NULL) goto fail;
+	memmove((void *)lparg0, (const void *)arg1, (size_t)arg2);
+fail:
+	if (arg0 && lparg0) setGdkEventVisibilityFields(env, arg0, lparg0);
+	OS_NATIVE_EXIT(env, that, memmove__Lorg_eclipse_swt_internal_gtk_GdkEventVisibility_2II_FUNC);
+}
+#endif
+
+#ifndef NO_memmove__Lorg_eclipse_swt_internal_gtk_GdkEventWindowState_2II
+JNIEXPORT void JNICALL OS_NATIVE(memmove__Lorg_eclipse_swt_internal_gtk_GdkEventWindowState_2II)
+	(JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2)
+{
+	GdkEventWindowState _arg0, *lparg0=NULL;
+	OS_NATIVE_ENTER(env, that, memmove__Lorg_eclipse_swt_internal_gtk_GdkEventWindowState_2II_FUNC);
+	if (arg0) if ((lparg0 = &_arg0) == NULL) goto fail;
+	memmove((void *)lparg0, (const void *)arg1, (size_t)arg2);
+fail:
+	if (arg0 && lparg0) setGdkEventWindowStateFields(env, arg0, lparg0);
+	OS_NATIVE_EXIT(env, that, memmove__Lorg_eclipse_swt_internal_gtk_GdkEventWindowState_2II_FUNC);
+}
+#endif
+
+#ifndef NO_memmove__Lorg_eclipse_swt_internal_gtk_GdkEvent_2II
+JNIEXPORT void JNICALL OS_NATIVE(memmove__Lorg_eclipse_swt_internal_gtk_GdkEvent_2II)
+	(JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2)
+{
+	GdkEvent _arg0, *lparg0=NULL;
+	OS_NATIVE_ENTER(env, that, memmove__Lorg_eclipse_swt_internal_gtk_GdkEvent_2II_FUNC);
+	if (arg0) if ((lparg0 = &_arg0) == NULL) goto fail;
+	memmove((void *)lparg0, (const void *)arg1, (size_t)arg2);
+fail:
+	if (arg0 && lparg0) setGdkEventFields(env, arg0, lparg0);
+	OS_NATIVE_EXIT(env, that, memmove__Lorg_eclipse_swt_internal_gtk_GdkEvent_2II_FUNC);
+}
+#endif
+
+#ifndef NO_memmove__Lorg_eclipse_swt_internal_gtk_GdkImage_2I
+JNIEXPORT void JNICALL OS_NATIVE(memmove__Lorg_eclipse_swt_internal_gtk_GdkImage_2I)
+	(JNIEnv *env, jclass that, jobject arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, memmove__Lorg_eclipse_swt_internal_gtk_GdkImage_2I_FUNC);
+	if (arg0) setGdkImageFields(env, arg0, (GdkImage *)arg1);
+	OS_NATIVE_EXIT(env, that, memmove__Lorg_eclipse_swt_internal_gtk_GdkImage_2I_FUNC);
+}
+#endif
+
+#ifndef NO_memmove__Lorg_eclipse_swt_internal_gtk_GdkRectangle_2II
+JNIEXPORT void JNICALL OS_NATIVE(memmove__Lorg_eclipse_swt_internal_gtk_GdkRectangle_2II)
+	(JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2)
+{
+	GdkRectangle _arg0, *lparg0=NULL;
+	OS_NATIVE_ENTER(env, that, memmove__Lorg_eclipse_swt_internal_gtk_GdkRectangle_2II_FUNC);
+	if (arg0) if ((lparg0 = &_arg0) == NULL) goto fail;
+	memmove((void *)lparg0, (const void *)arg1, (size_t)arg2);
+fail:
+	if (arg0 && lparg0) setGdkRectangleFields(env, arg0, lparg0);
+	OS_NATIVE_EXIT(env, that, memmove__Lorg_eclipse_swt_internal_gtk_GdkRectangle_2II_FUNC);
+}
+#endif
+
+#ifndef NO_memmove__Lorg_eclipse_swt_internal_gtk_GdkVisual_2I
+JNIEXPORT void JNICALL OS_NATIVE(memmove__Lorg_eclipse_swt_internal_gtk_GdkVisual_2I)
+	(JNIEnv *env, jclass that, jobject arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, memmove__Lorg_eclipse_swt_internal_gtk_GdkVisual_2I_FUNC);
+	if (arg0) setGdkVisualFields(env, arg0, (GdkVisual *)arg1);
+	OS_NATIVE_EXIT(env, that, memmove__Lorg_eclipse_swt_internal_gtk_GdkVisual_2I_FUNC);
+}
+#endif
+
+#ifndef NO_memmove__Lorg_eclipse_swt_internal_gtk_GtkAdjustment_2I
+JNIEXPORT void JNICALL OS_NATIVE(memmove__Lorg_eclipse_swt_internal_gtk_GtkAdjustment_2I)
+	(JNIEnv *env, jclass that, jobject arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, memmove__Lorg_eclipse_swt_internal_gtk_GtkAdjustment_2I_FUNC);
+	if (arg0) setGtkAdjustmentFields(env, arg0, (GtkAdjustment *)arg1);
+	OS_NATIVE_EXIT(env, that, memmove__Lorg_eclipse_swt_internal_gtk_GtkAdjustment_2I_FUNC);
+}
+#endif
+
+#ifndef NO_memmove__Lorg_eclipse_swt_internal_gtk_GtkBorder_2II
+JNIEXPORT void JNICALL OS_NATIVE(memmove__Lorg_eclipse_swt_internal_gtk_GtkBorder_2II)
+	(JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2)
+{
+	GtkBorder _arg0, *lparg0=NULL;
+	OS_NATIVE_ENTER(env, that, memmove__Lorg_eclipse_swt_internal_gtk_GtkBorder_2II_FUNC);
+	if (arg0) if ((lparg0 = &_arg0) == NULL) goto fail;
+	memmove((void *)lparg0, (const void *)arg1, (size_t)arg2);
+fail:
+	if (arg0 && lparg0) setGtkBorderFields(env, arg0, lparg0);
+	OS_NATIVE_EXIT(env, that, memmove__Lorg_eclipse_swt_internal_gtk_GtkBorder_2II_FUNC);
+}
+#endif
+
+#ifndef NO_memmove__Lorg_eclipse_swt_internal_gtk_GtkCellRendererClass_2I
+JNIEXPORT void JNICALL OS_NATIVE(memmove__Lorg_eclipse_swt_internal_gtk_GtkCellRendererClass_2I)
+	(JNIEnv *env, jclass that, jobject arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, memmove__Lorg_eclipse_swt_internal_gtk_GtkCellRendererClass_2I_FUNC);
+	if (arg0) setGtkCellRendererClassFields(env, arg0, (GtkCellRendererClass *)arg1);
+	OS_NATIVE_EXIT(env, that, memmove__Lorg_eclipse_swt_internal_gtk_GtkCellRendererClass_2I_FUNC);
+}
+#endif
+
+#ifndef NO_memmove__Lorg_eclipse_swt_internal_gtk_GtkColorSelectionDialog_2I
+JNIEXPORT void JNICALL OS_NATIVE(memmove__Lorg_eclipse_swt_internal_gtk_GtkColorSelectionDialog_2I)
+	(JNIEnv *env, jclass that, jobject arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, memmove__Lorg_eclipse_swt_internal_gtk_GtkColorSelectionDialog_2I_FUNC);
+	if (arg0) setGtkColorSelectionDialogFields(env, arg0, (GtkColorSelectionDialog *)arg1);
+	OS_NATIVE_EXIT(env, that, memmove__Lorg_eclipse_swt_internal_gtk_GtkColorSelectionDialog_2I_FUNC);
+}
+#endif
+
+#ifndef NO_memmove__Lorg_eclipse_swt_internal_gtk_GtkCombo_2I
+JNIEXPORT void JNICALL OS_NATIVE(memmove__Lorg_eclipse_swt_internal_gtk_GtkCombo_2I)
+	(JNIEnv *env, jclass that, jobject arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, memmove__Lorg_eclipse_swt_internal_gtk_GtkCombo_2I_FUNC);
+	if (arg0) setGtkComboFields(env, arg0, (GtkCombo *)arg1);
+	OS_NATIVE_EXIT(env, that, memmove__Lorg_eclipse_swt_internal_gtk_GtkCombo_2I_FUNC);
+}
+#endif
+
+#ifndef NO_memmove__Lorg_eclipse_swt_internal_gtk_GtkFileSelection_2I
+JNIEXPORT void JNICALL OS_NATIVE(memmove__Lorg_eclipse_swt_internal_gtk_GtkFileSelection_2I)
+	(JNIEnv *env, jclass that, jobject arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, memmove__Lorg_eclipse_swt_internal_gtk_GtkFileSelection_2I_FUNC);
+	if (arg0) setGtkFileSelectionFields(env, arg0, (GtkFileSelection *)arg1);
+	OS_NATIVE_EXIT(env, that, memmove__Lorg_eclipse_swt_internal_gtk_GtkFileSelection_2I_FUNC);
+}
+#endif
+
+#ifndef NO_memmove__Lorg_eclipse_swt_internal_gtk_GtkFixed_2I
+JNIEXPORT void JNICALL OS_NATIVE(memmove__Lorg_eclipse_swt_internal_gtk_GtkFixed_2I)
+	(JNIEnv *env, jclass that, jobject arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, memmove__Lorg_eclipse_swt_internal_gtk_GtkFixed_2I_FUNC);
+	if (arg0) setGtkFixedFields(env, arg0, (GtkFixed *)arg1);
+	OS_NATIVE_EXIT(env, that, memmove__Lorg_eclipse_swt_internal_gtk_GtkFixed_2I_FUNC);
+}
+#endif
+
+#ifndef NO_memmove__Lorg_eclipse_swt_internal_gtk_GtkSelectionData_2II
+JNIEXPORT void JNICALL OS_NATIVE(memmove__Lorg_eclipse_swt_internal_gtk_GtkSelectionData_2II)
+	(JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2)
+{
+	GtkSelectionData _arg0, *lparg0=NULL;
+	OS_NATIVE_ENTER(env, that, memmove__Lorg_eclipse_swt_internal_gtk_GtkSelectionData_2II_FUNC);
+	if (arg0) if ((lparg0 = &_arg0) == NULL) goto fail;
+	memmove((void *)lparg0, (const void *)arg1, (size_t)arg2);
+fail:
+	if (arg0 && lparg0) setGtkSelectionDataFields(env, arg0, lparg0);
+	OS_NATIVE_EXIT(env, that, memmove__Lorg_eclipse_swt_internal_gtk_GtkSelectionData_2II_FUNC);
+}
+#endif
+
+#ifndef NO_memmove__Lorg_eclipse_swt_internal_gtk_GtkTargetPair_2II
+JNIEXPORT void JNICALL OS_NATIVE(memmove__Lorg_eclipse_swt_internal_gtk_GtkTargetPair_2II)
+	(JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2)
+{
+	GtkTargetPair _arg0, *lparg0=NULL;
+	OS_NATIVE_ENTER(env, that, memmove__Lorg_eclipse_swt_internal_gtk_GtkTargetPair_2II_FUNC);
+	if (arg0) if ((lparg0 = &_arg0) == NULL) goto fail;
+	memmove((void *)lparg0, (const void *)arg1, (size_t)arg2);
+fail:
+	if (arg0 && lparg0) setGtkTargetPairFields(env, arg0, lparg0);
+	OS_NATIVE_EXIT(env, that, memmove__Lorg_eclipse_swt_internal_gtk_GtkTargetPair_2II_FUNC);
+}
+#endif
+
+#ifndef NO_memmove__Lorg_eclipse_swt_internal_gtk_GtkWidgetClass_2I
+JNIEXPORT void JNICALL OS_NATIVE(memmove__Lorg_eclipse_swt_internal_gtk_GtkWidgetClass_2I)
+	(JNIEnv *env, jclass that, jobject arg0, jint arg1)
+{
+	OS_NATIVE_ENTER(env, that, memmove__Lorg_eclipse_swt_internal_gtk_GtkWidgetClass_2I_FUNC);
+	if (arg0) setGtkWidgetClassFields(env, arg0, (GtkWidgetClass *)arg1);
+	OS_NATIVE_EXIT(env, that, memmove__Lorg_eclipse_swt_internal_gtk_GtkWidgetClass_2I_FUNC);
+}
+#endif
+
+#ifndef NO_memmove__Lorg_eclipse_swt_internal_gtk_PangoAttrColor_2II
+JNIEXPORT void JNICALL OS_NATIVE(memmove__Lorg_eclipse_swt_internal_gtk_PangoAttrColor_2II)
+	(JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2)
+{
+	PangoAttrColor _arg0, *lparg0=NULL;
+	OS_NATIVE_ENTER(env, that, memmove__Lorg_eclipse_swt_internal_gtk_PangoAttrColor_2II_FUNC);
+	if (arg0) if ((lparg0 = &_arg0) == NULL) goto fail;
+	memmove((void *)lparg0, (const void *)arg1, (size_t)arg2);
+fail:
+	if (arg0 && lparg0) setPangoAttrColorFields(env, arg0, lparg0);
+	OS_NATIVE_EXIT(env, that, memmove__Lorg_eclipse_swt_internal_gtk_PangoAttrColor_2II_FUNC);
+}
+#endif
+
+#ifndef NO_memmove__Lorg_eclipse_swt_internal_gtk_PangoAttrInt_2II
+JNIEXPORT void JNICALL OS_NATIVE(memmove__Lorg_eclipse_swt_internal_gtk_PangoAttrInt_2II)
+	(JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2)
+{
+	PangoAttrInt _arg0, *lparg0=NULL;
+	OS_NATIVE_ENTER(env, that, memmove__Lorg_eclipse_swt_internal_gtk_PangoAttrInt_2II_FUNC);
+	if (arg0) if ((lparg0 = &_arg0) == NULL) goto fail;
+	memmove((void *)lparg0, (const void *)arg1, (size_t)arg2);
+fail:
+	if (arg0 && lparg0) setPangoAttrIntFields(env, arg0, lparg0);
+	OS_NATIVE_EXIT(env, that, memmove__Lorg_eclipse_swt_internal_gtk_PangoAttrInt_2II_FUNC);
+}
+#endif
+
+#ifndef NO_memmove__Lorg_eclipse_swt_internal_gtk_PangoAttribute_2II
+JNIEXPORT void JNICALL OS_NATIVE(memmove__Lorg_eclipse_swt_internal_gtk_PangoAttribute_2II)
+	(JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2)
+{
+	PangoAttribute _arg0, *lparg0=NULL;
+	OS_NATIVE_ENTER(env, that, memmove__Lorg_eclipse_swt_internal_gtk_PangoAttribute_2II_FUNC);
+	if (arg0) if ((lparg0 = &_arg0) == NULL) goto fail;
+	memmove((void *)lparg0, (const void *)arg1, (size_t)arg2);
+fail:
+	if (arg0 && lparg0) setPangoAttributeFields(env, arg0, lparg0);
+	OS_NATIVE_EXIT(env, that, memmove__Lorg_eclipse_swt_internal_gtk_PangoAttribute_2II_FUNC);
+}
+#endif
+
+#ifndef NO_memmove__Lorg_eclipse_swt_internal_gtk_PangoItem_2II
+JNIEXPORT void JNICALL OS_NATIVE(memmove__Lorg_eclipse_swt_internal_gtk_PangoItem_2II)
+	(JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2)
+{
+	PangoItem _arg0, *lparg0=NULL;
+	OS_NATIVE_ENTER(env, that, memmove__Lorg_eclipse_swt_internal_gtk_PangoItem_2II_FUNC);
+	if (arg0) if ((lparg0 = &_arg0) == NULL) goto fail;
+	memmove((void *)lparg0, (const void *)arg1, (size_t)arg2);
+fail:
+	if (arg0 && lparg0) setPangoItemFields(env, arg0, lparg0);
+	OS_NATIVE_EXIT(env, that, memmove__Lorg_eclipse_swt_internal_gtk_PangoItem_2II_FUNC);
+}
+#endif
+
+#ifndef NO_memmove__Lorg_eclipse_swt_internal_gtk_PangoLayoutLine_2II
+JNIEXPORT void JNICALL OS_NATIVE(memmove__Lorg_eclipse_swt_internal_gtk_PangoLayoutLine_2II)
+	(JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2)
+{
+	PangoLayoutLine _arg0, *lparg0=NULL;
+	OS_NATIVE_ENTER(env, that, memmove__Lorg_eclipse_swt_internal_gtk_PangoLayoutLine_2II_FUNC);
+	if (arg0) if ((lparg0 = &_arg0) == NULL) goto fail;
+	memmove((void *)lparg0, (const void *)arg1, (size_t)arg2);
+fail:
+	if (arg0 && lparg0) setPangoLayoutLineFields(env, arg0, lparg0);
+	OS_NATIVE_EXIT(env, that, memmove__Lorg_eclipse_swt_internal_gtk_PangoLayoutLine_2II_FUNC);
+}
+#endif
+
+#ifndef NO_memmove__Lorg_eclipse_swt_internal_gtk_PangoLayoutRun_2II
+JNIEXPORT void JNICALL OS_NATIVE(memmove__Lorg_eclipse_swt_internal_gtk_PangoLayoutRun_2II)
+	(JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2)
+{
+	PangoLayoutRun _arg0, *lparg0=NULL;
+	OS_NATIVE_ENTER(env, that, memmove__Lorg_eclipse_swt_internal_gtk_PangoLayoutRun_2II_FUNC);
+	if (arg0) if ((lparg0 = &_arg0) == NULL) goto fail;
+	memmove((void *)lparg0, (const void *)arg1, (size_t)arg2);
+fail:
+	if (arg0 && lparg0) setPangoLayoutRunFields(env, arg0, lparg0);
+	OS_NATIVE_EXIT(env, that, memmove__Lorg_eclipse_swt_internal_gtk_PangoLayoutRun_2II_FUNC);
+}
+#endif
+
+#ifndef NO_memmove__Lorg_eclipse_swt_internal_gtk_PangoLogAttr_2II
+JNIEXPORT void JNICALL OS_NATIVE(memmove__Lorg_eclipse_swt_internal_gtk_PangoLogAttr_2II)
+	(JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2)
+{
+	PangoLogAttr _arg0, *lparg0=NULL;
+	OS_NATIVE_ENTER(env, that, memmove__Lorg_eclipse_swt_internal_gtk_PangoLogAttr_2II_FUNC);
+	if (arg0) if ((lparg0 = &_arg0) == NULL) goto fail;
+	memmove((void *)lparg0, (const void *)arg1, (size_t)arg2);
+fail:
+	if (arg0 && lparg0) setPangoLogAttrFields(env, arg0, lparg0);
+	OS_NATIVE_EXIT(env, that, memmove__Lorg_eclipse_swt_internal_gtk_PangoLogAttr_2II_FUNC);
+}
+#endif
+
+#ifndef NO_memmove__Lorg_eclipse_swt_internal_gtk_XButtonEvent_2II
+JNIEXPORT void JNICALL OS_NATIVE(memmove__Lorg_eclipse_swt_internal_gtk_XButtonEvent_2II)
+	(JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2)
+{
+	XButtonEvent _arg0, *lparg0=NULL;
+	OS_NATIVE_ENTER(env, that, memmove__Lorg_eclipse_swt_internal_gtk_XButtonEvent_2II_FUNC);
+	if (arg0) if ((lparg0 = &_arg0) == NULL) goto fail;
+	memmove((void *)lparg0, (const void *)arg1, (size_t)arg2);
+fail:
+	if (arg0 && lparg0) setXButtonEventFields(env, arg0, lparg0);
+	OS_NATIVE_EXIT(env, that, memmove__Lorg_eclipse_swt_internal_gtk_XButtonEvent_2II_FUNC);
+}
+#endif
+
+#ifndef NO_memmove__Lorg_eclipse_swt_internal_gtk_XCrossingEvent_2II
+JNIEXPORT void JNICALL OS_NATIVE(memmove__Lorg_eclipse_swt_internal_gtk_XCrossingEvent_2II)
+	(JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2)
+{
+	XCrossingEvent _arg0, *lparg0=NULL;
+	OS_NATIVE_ENTER(env, that, memmove__Lorg_eclipse_swt_internal_gtk_XCrossingEvent_2II_FUNC);
+	if (arg0) if ((lparg0 = &_arg0) == NULL) goto fail;
+	memmove((void *)lparg0, (const void *)arg1, (size_t)arg2);
+fail:
+	if (arg0 && lparg0) setXCrossingEventFields(env, arg0, lparg0);
+	OS_NATIVE_EXIT(env, that, memmove__Lorg_eclipse_swt_internal_gtk_XCrossingEvent_2II_FUNC);
+}
+#endif
+
+#ifndef NO_memmove__Lorg_eclipse_swt_internal_gtk_XExposeEvent_2II
+JNIEXPORT void JNICALL OS_NATIVE(memmove__Lorg_eclipse_swt_internal_gtk_XExposeEvent_2II)
+	(JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2)
+{
+	XExposeEvent _arg0, *lparg0=NULL;
+	OS_NATIVE_ENTER(env, that, memmove__Lorg_eclipse_swt_internal_gtk_XExposeEvent_2II_FUNC);
+	if (arg0) if ((lparg0 = &_arg0) == NULL) goto fail;
+	memmove((void *)lparg0, (const void *)arg1, (size_t)arg2);
+fail:
+	if (arg0 && lparg0) setXExposeEventFields(env, arg0, lparg0);
+	OS_NATIVE_EXIT(env, that, memmove__Lorg_eclipse_swt_internal_gtk_XExposeEvent_2II_FUNC);
+}
+#endif
+
+#ifndef NO_memmove__Lorg_eclipse_swt_internal_gtk_XFocusChangeEvent_2II
+JNIEXPORT void JNICALL OS_NATIVE(memmove__Lorg_eclipse_swt_internal_gtk_XFocusChangeEvent_2II)
+	(JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2)
+{
+	XFocusChangeEvent _arg0, *lparg0=NULL;
+	OS_NATIVE_ENTER(env, that, memmove__Lorg_eclipse_swt_internal_gtk_XFocusChangeEvent_2II_FUNC);
+	if (arg0) if ((lparg0 = &_arg0) == NULL) goto fail;
+	memmove((void *)lparg0, (const void *)arg1, (size_t)arg2);
+fail:
+	if (arg0 && lparg0) setXFocusChangeEventFields(env, arg0, lparg0);
+	OS_NATIVE_EXIT(env, that, memmove__Lorg_eclipse_swt_internal_gtk_XFocusChangeEvent_2II_FUNC);
+}
+#endif
+
+#ifndef NO_memmove__Lorg_eclipse_swt_internal_gtk_XVisibilityEvent_2II
+JNIEXPORT void JNICALL OS_NATIVE(memmove__Lorg_eclipse_swt_internal_gtk_XVisibilityEvent_2II)
+	(JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2)
+{
+	XVisibilityEvent _arg0, *lparg0=NULL;
+	OS_NATIVE_ENTER(env, that, memmove__Lorg_eclipse_swt_internal_gtk_XVisibilityEvent_2II_FUNC);
+	if (arg0) if ((lparg0 = &_arg0) == NULL) goto fail;
+	memmove((void *)lparg0, (const void *)arg1, (size_t)arg2);
+fail:
+	if (arg0 && lparg0) setXVisibilityEventFields(env, arg0, lparg0);
+	OS_NATIVE_EXIT(env, that, memmove__Lorg_eclipse_swt_internal_gtk_XVisibilityEvent_2II_FUNC);
+}
+#endif
+
+#ifndef NO_realpath
+JNIEXPORT jint JNICALL OS_NATIVE(realpath)
+	(JNIEnv *env, jclass that, jbyteArray arg0, jbyteArray arg1)
+{
+	jbyte *lparg0=NULL;
+	jbyte *lparg1=NULL;
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, realpath_FUNC);
+	if (arg0) if ((lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL)) == NULL) goto fail;
+	if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+	rc = (jint)realpath((const char *)lparg0, (char *)lparg1);
+fail:
+	if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+	if (arg0 && lparg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
+	OS_NATIVE_EXIT(env, that, realpath_FUNC);
+	return rc;
+}
+#endif
+

Added: branches/upstream/swt-gtk/current/os.h
===================================================================
--- branches/upstream/swt-gtk/current/os.h	                        (rev 0)
+++ branches/upstream/swt-gtk/current/os.h	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,89 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others. All rights reserved.
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt).  The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html.  If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+  
+#ifndef INC_os_H
+#define INC_os_H
+
+#define NDEBUG
+
+/*
+#define G_DISABLE_DEPRECATED
+#define GTK_DISABLE_DEPRECATED
+*/
+
+#include <stdlib.h>
+#include <gtk/gtk.h>
+#include <gdk/gdk.h>
+#include <pango/pango.h>
+#include <pango/pango-font.h>
+#include <string.h>
+#include <dlfcn.h>
+#include <locale.h>
+
+#ifndef GDK_WINDOWING_X11
+
+/* X Structures */
+#define NO_XClientMessageEvent
+#define NO_XCrossingEvent
+#define NO_XExposeEvent
+#define NO_XFocusChangeEvent
+#define NO_XVisibilityEvent
+#define NO_XWindowChanges
+
+/* X functions */
+#define NO__1XCheckMaskEvent
+#define NO__1XCheckWindowEvent
+#define NO__1XCheckIfEvent
+#define NO__1XDefaultScreen
+#define NO__1XDefaultRootWindow
+#define NO__1XFlush
+#define NO__1XGetSelectionOwner
+#define NO__1XQueryTree
+#define NO__1XQueryPointer
+#define NO__1XKeysymToKeycode
+#define NO__1XReconfigureWMWindow
+#define NO__1XSendEvent
+#define NO__1XSetInputFocus
+#define NO__1XSynchronize
+#define NO__1XSetErrorHandler
+#define NO__1XSetIOErrorHandler
+#define NO__1XSetTransientForHint
+#define NO__1XTestFakeButtonEvent
+#define NO__1XTestFakeKeyEvent
+#define NO__1XTestFakeMotionEvent
+#define NO__1XWarpPointer
+#define NO__1gdk_x11_atom_to_xatom
+#define NO__1gdk_1x11_1drawable_1get_1xdisplay
+#define NO__1gdk_1x11_1drawable_1get_1xid
+#define NO__1gdk_window_lookup
+#define NO__1gdk_window_add_filter
+#define NO_memmove__ILorg_eclipse_swt_internal_gtk_XClientMessageEvent_2I
+#define NO_memmove__ILorg_eclipse_swt_internal_gtk_XCrossingEvent_2I
+#define NO_memmove__ILorg_eclipse_swt_internal_gtk_XExposeEvent_2I
+#define NO_memmove__ILorg_eclipse_swt_internal_gtk_XFocusChangeEvent_2I
+#define NO_memmove__Lorg_eclipse_swt_internal_gtk_XCrossingEvent_2II
+#define NO_memmove__Lorg_eclipse_swt_internal_gtk_XExposeEvent_2II
+#define NO_memmove__Lorg_eclipse_swt_internal_gtk_XFocusChangeEvent_2II
+#define NO_memmove__Lorg_eclipse_swt_internal_gtk_XVisibilityEvent_2II
+
+#else
+#include <gdk/gdkx.h>
+#include <X11/extensions/XTest.h>
+#include <X11/extensions/Xrender.h>
+#endif
+
+#include "os_custom.h"
+
+#endif /* INC_os_H */

Added: branches/upstream/swt-gtk/current/os_custom.c
===================================================================
--- branches/upstream/swt-gtk/current/os_custom.c	                        (rev 0)
+++ branches/upstream/swt-gtk/current/os_custom.c	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,142 @@
+/*******************************************************************************
+* Copyright (c) 2000, 2008 IBM Corporation and others. All rights reserved.
+* The contents of this file are made available under the terms
+* of the GNU Lesser General Public License (LGPL) Version 2.1 that
+* accompanies this distribution (lgpl-v21.txt).  The LGPL is also
+* available at http://www.gnu.org/licenses/lgpl.html.  If the version
+* of the LGPL at http://www.gnu.org is different to the version of
+* the LGPL accompanying this distribution and there is any conflict
+* between the two license versions, the terms of the LGPL accompanying
+* this distribution shall govern.
+* 
+* Contributors:
+*     IBM Corporation - initial API and implementation
+*******************************************************************************/
+
+#include "swt.h"
+#include "os_structs.h"
+#include "os_stats.h"
+
+#define OS_NATIVE(func) Java_org_eclipse_swt_internal_gtk_OS_##func
+
+#ifndef NO_GDK_1WINDOWING_1X11
+JNIEXPORT jboolean JNICALL OS_NATIVE(GDK_1WINDOWING_1X11)
+	(JNIEnv *env, jclass that)
+{
+	jboolean rc;
+	OS_NATIVE_ENTER(env, that, GDK_1WINDOWING_1X11_FUNC)
+#ifdef GDK_WINDOWING_X11
+	rc = (jboolean)1;
+#else
+	rc = (jboolean)0;
+#endif	
+	OS_NATIVE_EXIT(env, that, GDK_1WINDOWING_1X11_FUNC)
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1file_1chooser_1dialog_1new
+JNIEXPORT SWT_PTR JNICALL OS_NATIVE(_1gtk_1file_1chooser_1dialog_1new)
+	(JNIEnv *env, jclass that, jbyteArray arg0, SWT_PTR arg1, jint arg2, SWT_PTR arg3, jint arg4, SWT_PTR arg5, jint arg6, SWT_PTR arg7)
+{
+	jbyte *lparg0=NULL;
+	SWT_PTR rc = 0;
+	OS_NATIVE_ENTER(env, that, _1gtk_1file_1chooser_1dialog_1new_FUNC);
+	if (arg0) if ((lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL)) == NULL) goto fail;
+/*
+	rc = (SWT_PTR)gtk_file_chooser_dialog_new(lparg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		/*
+		* On AMD64, it is critical that functions which have a variable number of
+		* arguments, indicated by '...', include the '...' in their prototype.  This
+		* changes the calling convention, and leaving it out will cause crashes.
+		*
+		* For some reason, we must also explicitly declare all of the arguments we
+		* are passing in, otherwise it crashes.
+		*/
+/*		typedef SWT_PTR (*FPTR)(jbyte *, SWT_PTR, jint, SWT_PTR, ...); */
+		typedef SWT_PTR (*FPTR)(jbyte *, SWT_PTR, jint, SWT_PTR, jint, SWT_PTR, jint, SWT_PTR, ...);
+		static FPTR fptr;
+		rc = 0;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_file_chooser_dialog_new_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_file_chooser_dialog_new");
+			initialized = 1;
+		}
+		if (fptr) {
+			rc = (SWT_PTR)(*fptr)(lparg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7);
+		}
+	}
+fail:
+	if (arg0 && lparg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1file_1chooser_1dialog_1new_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1cell_1layout_1set_1attributes
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1cell_1layout_1set_1attributes)
+	(JNIEnv *env, jclass that, SWT_PTR arg0, SWT_PTR arg1, jbyteArray arg2, jint arg3, SWT_PTR arg4)
+{
+	jbyte *lparg2=NULL;
+	OS_NATIVE_ENTER(env, that, _1gtk_1cell_1layout_1set_1attributes_FUNC);
+	if (arg2) if ((lparg2 = (*env)->GetByteArrayElements(env, arg2, NULL)) == NULL) goto fail;
+/*
+	gtk_cell_layout_set_attributes(arg0, arg1, lparg2, arg3, arg4);
+*/
+	{
+		static int initialized = 0;
+		static void *handle = NULL;
+		/*
+		* On AMD64, it is critical that functions which have a variable number of
+		* arguments, indicated by '...', include the '...' in their prototype.  This
+		* changes the calling convention, and leaving it out will cause crashes.
+		*
+		* For some reason, we must also explicitly declare all of the arguments we
+		* are passing in, otherwise it crashes.
+		*/
+/*		typedef void (*FPTR)(SWT_PTR, SWT_PTR, ...); */
+		typedef void (*FPTR)(SWT_PTR, SWT_PTR, jbyte *, jint, SWT_PTR, ...);
+		static FPTR fptr;
+		if (!initialized) {
+			if (!handle) handle = dlopen(gtk_cell_layout_set_attributes_LIB, RTLD_LAZY);
+			if (handle) fptr = (FPTR)dlsym(handle, "gtk_cell_layout_set_attributes");
+			initialized = 1;
+		}
+		if (fptr) {
+			(*fptr)(arg0, arg1, lparg2, arg3, arg4);
+		}
+	}
+fail:
+	if (arg2 && lparg2) (*env)->ReleaseByteArrayElements(env, arg2, lparg2, 0);
+	OS_NATIVE_EXIT(env, that, _1gtk_1cell_1layout_1set_1attributes_FUNC);
+}
+#endif
+
+struct _PangoLayoutLineSWT
+{
+  PangoLayout *layout;
+  gint         start_index; 
+  gint         length;      
+  GSList      *runs;
+  guint        is_paragraph_start : 1;
+  guint        resolved_dir : 3;
+};
+typedef struct _PangoLayoutLineSWT  PangoLayoutLineSWT;
+
+#ifndef NO__1pango_1layout_1line_1get_1resolved_1dir
+JNIEXPORT jint JNICALL OS_NATIVE(_1pango_1layout_1line_1get_1resolved_1dir)
+	(JNIEnv *env, jclass that, SWT_PTR arg0)
+{
+	jint rc = 0;
+	OS_NATIVE_ENTER(env, that, _1pango_1layout_1line_1get_1resolved_1dir_FUNC);
+	if (gtk_check_version(2,4,0) == NULL) {
+		rc = ((PangoLayoutLineSWT*)(arg0))->resolved_dir;
+	}
+	OS_NATIVE_EXIT(env, that, _1pango_1layout_1line_1get_1resolved_1dir_FUNC);
+	return rc;
+}
+#endif

Added: branches/upstream/swt-gtk/current/os_custom.h
===================================================================
--- branches/upstream/swt-gtk/current/os_custom.h	                        (rev 0)
+++ branches/upstream/swt-gtk/current/os_custom.h	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,255 @@
+/*******************************************************************************
+* Copyright (c) 2000, 2008 IBM Corporation and others. All rights reserved.
+* The contents of this file are made available under the terms
+* of the GNU Lesser General Public License (LGPL) Version 2.1 that
+* accompanies this distribution (lgpl-v21.txt).  The LGPL is also
+* available at http://www.gnu.org/licenses/lgpl.html.  If the version
+* of the LGPL at http://www.gnu.org is different to the version of
+* the LGPL accompanying this distribution and there is any conflict
+* between the two license versions, the terms of the LGPL accompanying
+* this distribution shall govern.
+* 
+* Contributors:
+*     IBM Corporation - initial API and implementation
+*******************************************************************************/
+
+/* Special sizeof's */
+#define GPollFD_sizeof() sizeof(GPollFD)
+#define GtkFixedClass_sizeof() sizeof(GtkFixedClass)
+#define GtkCellRendererText_sizeof() sizeof(GtkCellRendererText)
+#define GtkCellRendererTextClass_sizeof() sizeof(GtkCellRendererTextClass)
+#define GtkCellRendererPixbuf_sizeof() sizeof(GtkCellRendererPixbuf)
+#define GtkCellRendererPixbufClass_sizeof() sizeof(GtkCellRendererPixbufClass)
+#define GtkCellRendererToggle_sizeof() sizeof(GtkCellRendererToggle)
+#define GtkCellRendererToggleClass_sizeof() sizeof(GtkCellRendererToggleClass)
+#define GtkTextIter_sizeof() sizeof(GtkTextIter)
+#define GtkTreeIter_sizeof() sizeof(GtkTreeIter)
+
+/* Libraries for dynamic loaded functions */
+#define XRenderQueryExtension_LIB "libXrender.so"
+#define XRenderQueryVersion_LIB "libXrender.so"
+#define XRenderFindStandardFormat_LIB "libXrender.so"
+#define XRenderFindVisualFormat_LIB "libXrender.so"
+#define XRenderComposite_LIB "libXrender.so"
+#define XRenderCreatePicture_LIB "libXrender.so"
+#define XRenderFreePicture_LIB "libXrender.so"
+#define XRenderSetPictureClipRectangles_LIB "libXrender.so"
+#define XRenderSetPictureTransform_LIB "libXrender.so"
+#define gtk_calendar_display_options_LIB "libgtk-x11-2.0.so.0"
+#define gtk_calendar_get_date_LIB "libgtk-x11-2.0.so.0"
+#define gtk_calendar_new_LIB "libgtk-x11-2.0.so.0"
+#define gtk_calendar_select_day_LIB "libgtk-x11-2.0.so.0"
+#define gtk_calendar_select_month_LIB "libgtk-x11-2.0.so.0"
+#define gtk_calendar_set_display_options_LIB "libgtk-x11-2.0.so.0"
+#define gtk_cell_layout_set_attributes_LIB "libgtk-x11-2.0.so.0"
+#define gtk_cell_layout_clear_LIB "libgtk-x11-2.0.so.0"
+#define gtk_cell_layout_pack_start_LIB "libgtk-x11-2.0.so.0"
+#define gtk_combo_box_entry_new_text_LIB "libgtk-x11-2.0.so.0"
+#define gtk_combo_box_new_text_LIB "libgtk-x11-2.0.so.0"
+#define gtk_combo_box_insert_text_LIB "libgtk-x11-2.0.so.0"
+#define gtk_combo_box_remove_text_LIB "libgtk-x11-2.0.so.0"
+#define gtk_combo_box_get_active_LIB "libgtk-x11-2.0.so.0"
+#define gtk_combo_box_get_model_LIB "libgtk-x11-2.0.so.0"
+#define gtk_combo_box_set_active_LIB "libgtk-x11-2.0.so.0"
+#define gtk_combo_box_set_focus_on_click_LIB "libgtk-x11-2.0.so.0"
+#define gtk_combo_box_popup_LIB "libgtk-x11-2.0.so.0"
+#define gtk_combo_box_popdown_LIB "libgtk-x11-2.0.so.0"
+#define gtk_entry_text_index_to_layout_index_LIB "libgtk-x11-2.0.so.0"
+#define gtk_file_chooser_add_filter_LIB "libgtk-x11-2.0.so.0"
+#define gtk_file_chooser_dialog_new_LIB "libgtk-x11-2.0.so.0"
+#define gtk_file_chooser_get_current_folder_LIB "libgtk-x11-2.0.so.0"
+#define gtk_file_chooser_get_filename_LIB "libgtk-x11-2.0.so.0"
+#define gtk_file_chooser_get_filenames_LIB "libgtk-x11-2.0.so.0"
+#define gtk_file_chooser_get_filter_LIB "libgtk-x11-2.0.so.0"
+#define gtk_file_chooser_set_current_folder_LIB "libgtk-x11-2.0.so.0"
+#define gtk_file_chooser_set_current_name_LIB "libgtk-x11-2.0.so.0"
+#define gtk_file_chooser_set_do_overwrite_confirmation_LIB "libgtk-x11-2.0.so.0"
+#define gtk_file_chooser_set_extra_widget_LIB "libgtk-x11-2.0.so.0"
+#define gtk_file_chooser_set_filename_LIB "libgtk-x11-2.0.so.0"
+#define gtk_file_chooser_set_filter_LIB "libgtk-x11-2.0.so.0"
+#define gtk_file_chooser_set_select_multiple_LIB "libgtk-x11-2.0.so.0"
+#define gtk_file_filter_add_pattern_LIB "libgtk-x11-2.0.so.0"
+#define gtk_file_filter_new_LIB "libgtk-x11-2.0.so.0"
+#define gtk_file_filter_get_name_LIB "libgtk-x11-2.0.so.0"
+#define gtk_file_filter_set_name_LIB "libgtk-x11-2.0.so.0"
+#define gtk_expander_get_expanded_LIB "libgtk-x11-2.0.so.0"
+#define gtk_expander_get_label_widget_LIB "libgtk-x11-2.0.so.0"
+#define gtk_expander_new_LIB "libgtk-x11-2.0.so.0"
+#define gtk_expander_set_expanded_LIB "libgtk-x11-2.0.so.0"
+#define gtk_expander_set_label_LIB "libgtk-x11-2.0.so.0"
+#define gtk_expander_set_label_widget_LIB "libgtk-x11-2.0.so.0"
+#define gtk_label_set_line_wrap_mode_LIB "libgtk-x11-2.0.so.0"
+#define gtk_menu_shell_set_take_focus_LIB "libgtk-x11-2.0.so.0"
+#define gtk_window_set_keep_below_LIB "libgtk-x11-2.0.so.0"
+#define gtk_tooltip_trigger_tooltip_query_LIB "libgtk-x11-2.0.so.0"
+#define gtk_tree_selection_count_selected_rows_LIB "libgtk-x11-2.0.so.0"
+#define gtk_tree_selection_get_selected_rows_LIB "libgtk-x11-2.0.so.0"
+#define gtk_tree_view_column_cell_get_position_LIB "libgtk-x11-2.0.so.0"
+#define gtk_entry_set_alignment_LIB "libgtk-x11-2.0.so.0"
+#define gdk_cursor_new_from_pixbuf_LIB "libgdk-x11-2.0.so.0"
+#define gdk_display_get_default_LIB "libgdk-x11-2.0.so.0"
+#define gdk_display_supports_cursor_color_LIB "libgdk-x11-2.0.so.0"
+#define gdk_draw_pixbuf_LIB "libgdk-x11-2.0.so.0"
+#define gdk_pixbuf_save_to_buffer_LIB "libgdk-x11-2.0.so.0"
+#define gdk_screen_get_default_LIB "libgdk-x11-2.0.so.0"
+#define gdk_screen_get_monitor_at_point_LIB "libgdk-x11-2.0.so.0"
+#define gdk_screen_get_monitor_at_window_LIB "libgdk-x11-2.0.so.0"
+#define gdk_screen_get_monitor_geometry_LIB "libgdk-x11-2.0.so.0"
+#define gdk_screen_get_n_monitors_LIB "libgdk-x11-2.0.so.0"
+#define gdk_screen_get_number_LIB "libgdk-x11-2.0.so.0"
+#define gtk_window_get_group_LIB "libgtk-x11-2.0.so.0"
+#define gtk_window_get_opacity_LIB "libgtk-x11-2.0.so.0"
+#define gdk_window_set_keep_above_LIB "libgdk-x11-2.0.so.0"
+#define gdk_window_set_accept_focus_LIB "libgdk-x11-2.0.so.0"
+#define gtk_window_set_opacity_LIB "libgtk-x11-2.0.so.0"
+#define gtk_window_set_skip_taskbar_hint_LIB "libgtk-x11-2.0.so.0"
+#define gtk_widget_is_composited_LIB "libgtk-x11-2.0.so.0"
+#define gtk_widget_set_tooltip_text_LIB "libgtk-x11-2.0.so.0"
+#define gdk_x11_screen_get_window_manager_name_LIB "libgdk-x11-2.0.so.0"
+#define gdk_x11_screen_lookup_visual_LIB "libgdk-x11-2.0.so.0"
+
+#define atk_object_add_relationship_LIB "libatk-1.0.so.0"
+#define pango_attr_underline_color_new_LIB "libpango-1.0.so.0"
+#define pango_attr_strikethrough_color_new_LIB "libpango-1.0.so.0"
+#define pango_font_metrics_get_underline_thickness_LIB "libpango-1.0.so.0"
+#define pango_font_metrics_get_underline_position_LIB "libpango-1.0.so.0"
+#define pango_font_metrics_get_strikethrough_thickness_LIB "libpango-1.0.so.0"
+#define pango_font_metrics_get_strikethrough_position_LIB "libpango-1.0.so.0"
+#define pango_layout_set_auto_dir_LIB "libpango-1.0.so.0"
+#define pango_cairo_create_layout_LIB "libpangocairo-1.0.so.0"
+#define pango_cairo_context_set_font_options_LIB "libpangocairo-1.0.so.0"
+#define pango_cairo_context_get_font_options_LIB "libpangocairo-1.0.so.0"
+#define pango_cairo_layout_path_LIB "libpangocairo-1.0.so.0"
+#define pango_cairo_show_layout_LIB "libpangocairo-1.0.so.0"
+#define pango_cairo_font_map_create_context_LIB "libpangocairo-1.0.so.0"
+#define pango_cairo_font_map_new_LIB "libpangocairo-1.0.so.0"
+#define pango_cairo_font_map_get_default_LIB "libpangocairo-1.0.so.0"
+#define pango_cairo_font_map_set_resolution_LIB "libpangocairo-1.0.so.0"
+#define gdk_cairo_set_source_color_LIB "libgdk-x11-2.0.so.0"
+#define gdk_cairo_region_LIB "libgdk-x11-2.0.so.0"
+#define gtk_enumerate_printers_LIB "libgtk-x11-2.0.so.0"
+#define gtk_page_setup_get_bottom_margin_LIB "libgtk-x11-2.0.so.0"
+#define gtk_page_setup_get_left_margin_LIB "libgtk-x11-2.0.so.0"
+#define gtk_page_setup_get_orientation_LIB "libgtk-x11-2.0.so.0"
+#define gtk_page_setup_get_page_height_LIB "libgtk-x11-2.0.so.0"
+#define gtk_page_setup_get_page_width_LIB "libgtk-x11-2.0.so.0"
+#define gtk_page_setup_get_paper_height_LIB "libgtk-x11-2.0.so.0"
+#define gtk_page_setup_get_paper_size_LIB "libgtk-x11-2.0.so.0"
+#define gtk_page_setup_get_paper_width_LIB "libgtk-x11-2.0.so.0"
+#define gtk_page_setup_get_right_margin_LIB "libgtk-x11-2.0.so.0"
+#define gtk_page_setup_get_top_margin_LIB "libgtk-x11-2.0.so.0"
+#define gtk_page_setup_new_LIB "libgtk-x11-2.0.so.0"
+#define gtk_page_setup_set_bottom_margin_LIB "libgtk-x11-2.0.so.0"
+#define gtk_page_setup_set_left_margin_LIB "libgtk-x11-2.0.so.0"
+#define gtk_page_setup_set_orientation_LIB "libgtk-x11-2.0.so.0"
+#define gtk_page_setup_set_paper_size_LIB "libgtk-x11-2.0.so.0"
+#define gtk_page_setup_set_right_margin_LIB "libgtk-x11-2.0.so.0"
+#define gtk_page_setup_set_top_margin_LIB "libgtk-x11-2.0.so.0"
+#define gtk_paper_size_free_LIB "libgtk-x11-2.0.so.0"
+#define gtk_paper_size_get_display_name_LIB "libgtk-x11-2.0.so.0"
+#define gtk_paper_size_get_name_LIB "libgtk-x11-2.0.so.0"
+#define gtk_paper_size_get_ppd_name_LIB "libgtk-x11-2.0.so.0"
+#define gtk_paper_size_get_height_LIB "libgtk-x11-2.0.so.0"
+#define gtk_paper_size_get_width_LIB "libgtk-x11-2.0.so.0"
+#define gtk_paper_size_is_custom_LIB "libgtk-x11-2.0.so.0"
+#define gtk_paper_size_new_LIB "libgtk-x11-2.0.so.0"
+#define gtk_paper_size_new_custom_LIB "libgtk-x11-2.0.so.0"
+#define gtk_paper_size_new_from_ppd_LIB "libgtk-x11-2.0.so.0"
+#define gtk_print_job_get_printer_LIB "libgtk-x11-2.0.so.0"
+#define gtk_print_job_get_settings_LIB "libgtk-x11-2.0.so.0"
+#define gtk_print_job_get_status_LIB "libgtk-x11-2.0.so.0"
+#define gtk_print_job_get_surface_LIB "libgtk-x11-2.0.so.0"
+#define gtk_print_job_get_title_LIB "libgtk-x11-2.0.so.0"
+#define gtk_print_job_new_LIB "libgtk-x11-2.0.so.0"
+#define gtk_print_job_send_LIB "libgtk-x11-2.0.so.0"
+#define gtk_print_job_set_source_file_LIB "libgtk-x11-2.0.so.0"
+#define gtk_print_settings_foreach_LIB "libgtk-x11-2.0.so.0"
+#define gtk_print_settings_get_LIB "libgtk-x11-2.0.so.0"
+#define gtk_print_settings_get_collate_LIB "libgtk-x11-2.0.so.0"
+#define gtk_print_settings_get_n_copies_LIB "libgtk-x11-2.0.so.0"
+#define gtk_print_settings_get_orientation_LIB "libgtk-x11-2.0.so.0"
+#define gtk_print_settings_get_page_ranges_LIB "libgtk-x11-2.0.so.0"
+#define gtk_print_settings_get_paper_height_LIB "libgtk-x11-2.0.so.0"
+#define gtk_print_settings_get_paper_width_LIB "libgtk-x11-2.0.so.0"
+#define gtk_print_settings_get_print_pages_LIB "libgtk-x11-2.0.so.0"
+#define gtk_print_settings_get_printer_LIB "libgtk-x11-2.0.so.0"
+#define gtk_print_settings_get_resolution_LIB "libgtk-x11-2.0.so.0"
+#define gtk_print_settings_new_LIB "libgtk-x11-2.0.so.0"
+#define gtk_print_settings_set_LIB "libgtk-x11-2.0.so.0"
+#define gtk_print_settings_set_collate_LIB "libgtk-x11-2.0.so.0"
+#define gtk_print_settings_set_n_copies_LIB "libgtk-x11-2.0.so.0"
+#define gtk_print_settings_set_orientation_LIB "libgtk-x11-2.0.so.0"
+#define gtk_print_settings_set_page_ranges_LIB "libgtk-x11-2.0.so.0"
+#define gtk_print_settings_set_print_pages_LIB "libgtk-x11-2.0.so.0"
+#define gtk_print_settings_set_printer_LIB "libgtk-x11-2.0.so.0"
+#define gtk_print_unix_dialog_get_current_page_LIB "libgtk-x11-2.0.so.0"
+#define gtk_print_unix_dialog_get_page_setup_LIB "libgtk-x11-2.0.so.0"
+#define gtk_print_unix_dialog_get_selected_printer_LIB "libgtk-x11-2.0.so.0"
+#define gtk_print_unix_dialog_get_settings_LIB "libgtk-x11-2.0.so.0"
+#define gtk_print_unix_dialog_new_LIB "libgtk-x11-2.0.so.0"
+#define gtk_print_unix_dialog_set_current_page_LIB "libgtk-x11-2.0.so.0"
+#define gtk_print_unix_dialog_set_manual_capabilities_LIB "libgtk-x11-2.0.so.0"
+#define gtk_print_unix_dialog_set_page_setup_LIB "libgtk-x11-2.0.so.0"
+#define gtk_print_unix_dialog_set_settings_LIB "libgtk-x11-2.0.so.0"
+#define gtk_printer_get_backend_LIB "libgtk-x11-2.0.so.0"
+#define gtk_printer_get_name_LIB "libgtk-x11-2.0.so.0"
+#define gtk_printer_is_default_LIB "libgtk-x11-2.0.so.0"
+#define FcConfigAppFontAddFile_LIB "libfontconfig.so.1"
+
+/* Field accessors */
+#define GTK_ACCEL_LABEL_SET_ACCEL_STRING(arg0, arg1) (arg0)->accel_string = arg1
+#define GTK_ACCEL_LABEL_GET_ACCEL_STRING(arg0) (arg0)->accel_string
+#define GTK_SCROLLED_WINDOW_HSCROLLBAR(arg0) (arg0)->hscrollbar
+#define GTK_SCROLLED_WINDOW_SCROLLBAR_SPACING(arg0) (GTK_SCROLLED_WINDOW_GET_CLASS (arg0)->scrollbar_spacing >= 0 ? GTK_SCROLLED_WINDOW_GET_CLASS (arg0)->scrollbar_spacing : 3)		
+#define GTK_SCROLLED_WINDOW_VSCROLLBAR(arg0) (arg0)->vscrollbar
+#define GTK_WIDGET_HEIGHT(arg0) (arg0)->allocation.height
+#define GTK_WIDGET_SET_HEIGHT(arg0, arg1) (arg0)->allocation.height = arg1
+#define GTK_WIDGET_WIDTH(arg0) (arg0)->allocation.width
+#define GTK_WIDGET_SET_WIDTH(arg0, arg1) (arg0)->allocation.width = arg1
+#define GTK_WIDGET_WINDOW(arg0) (arg0)->window
+#define GTK_WIDGET_X(arg0) (arg0)->allocation.x
+#define GTK_WIDGET_SET_X(arg0, arg1) (arg0)->allocation.x = arg1
+#define GTK_ENTRY_IM_CONTEXT(arg0) (arg0)->im_context
+#define GTK_TEXTVIEW_IM_CONTEXT(arg0) (arg0)->im_context
+#define GTK_TOOLTIPS_TIP_WINDOW(arg0) (arg0)->tip_window
+#define GTK_TOOLTIPS_SET_ACTIVE(arg0, arg1) (arg0)->active_tips_data = arg1
+#define GTK_WIDGET_Y(arg0) ((GtkWidget *)arg0)->allocation.y
+#define GTK_WIDGET_SET_Y(arg0, arg1) (arg0)->allocation.y = arg1
+#define GTK_WIDGET_REQUISITION_WIDTH(arg0) (arg0)->requisition.width
+#define GTK_WIDGET_REQUISITION_HEIGHT(arg0) (arg0)->requisition.height
+#define GDK_EVENT_TYPE(arg0) (arg0)->type
+#define GDK_EVENT_WINDOW(arg0) (arg0)->window
+#define X_EVENT_TYPE(arg0) (arg0)->type
+#define X_EVENT_WINDOW(arg0) (arg0)->window
+#define g_list_data(arg0) (arg0)->data
+#define g_slist_data(arg0) (arg0)->data
+#define g_list_set_next(arg0, arg1) (arg0)->next = arg1
+#define g_list_set_previous(arg0, arg1) (arg0)->prev = arg1
+#define gtk_rc_style_get_bg_pixmap_name(arg0, arg1) (arg0)->bg_pixmap_name[arg1]
+#define gtk_rc_style_get_color_flags(arg0, arg1) (arg0)->color_flags[arg1]
+#define gtk_rc_style_set_bg(arg0, arg1, arg2) if (arg2) (arg0)->bg[arg1] = *arg2
+#define gtk_rc_style_set_bg_pixmap_name(arg0, arg1, arg2) (arg0)->bg_pixmap_name[arg1] = (char *)arg2
+#define gtk_rc_style_set_color_flags(arg0, arg1, arg2) (arg0)->color_flags[arg1] = arg2
+#define gtk_rc_style_set_fg(arg0, arg1, arg2) if (arg2) (arg0)->fg[arg1] = *arg2
+#define gtk_rc_style_set_text(arg0, arg1, arg2) if (arg2) (arg0)->text[arg1] = *arg2
+#define gtk_style_get_font_desc(arg0) (arg0)->font_desc
+#define gtk_style_get_base(arg0, arg1, arg2) *arg2 = (arg0)->base[arg1]
+#define gtk_style_get_bg(arg0, arg1, arg2) *arg2 = (arg0)->bg[arg1]
+#define gtk_style_get_black(arg0, arg1) *arg1 = (arg0)->black
+#define gtk_style_get_dark(arg0, arg1, arg2) *arg2 = (arg0)->dark[arg1]
+#define gtk_style_get_fg(arg0, arg1, arg2) *arg2 = (arg0)->fg[arg1]
+#define gtk_style_get_light(arg0, arg1, arg2) *arg2 = (arg0)->light[arg1]
+#define gtk_style_get_text(arg0, arg1, arg2) *arg2 = (arg0)->text[arg1]
+#define gtk_style_get_xthickness(arg0) (arg0)->xthickness
+#define gtk_style_get_ythickness(arg0) (arg0)->ythickness
+#define gtk_style_get_fg_gc(arg0, arg1, arg2) *arg2 = (arg0)->fg_gc[arg1]
+#define gtk_style_get_bg_gc(arg0, arg1, arg2) *arg2 = (arg0)->bg_gc[arg1]
+#define gtk_style_get_light_gc(arg0, arg1, arg2) *arg2 = (arg0)->light_gc[arg1]
+#define gtk_style_get_dark_gc(arg0, arg1, arg2) *arg2 = (arg0)->dark_gc[arg1]
+#define gtk_style_get_mid_gc(arg0, arg1, arg2) *arg2 = (arg0)->mid_gc[arg1]
+#define gtk_style_get_text_gc(arg0, arg1, arg2) *arg2 = (arg0)->text_gc[arg1]
+#define gtk_style_get_text_aa_gc(arg0, arg1, arg2) *arg2 = (arg0)->text_aa_gc[arg1]
+#define gtk_style_get_black_gc(arg0, arg1) *arg1 = (arg0)->black_gc
+#define gtk_style_get_white_gc(arg0, arg1) *arg1 = (arg0)->white_gc
+#define localeconv_decimal_point() localeconv()->decimal_point
+

Added: branches/upstream/swt-gtk/current/os_stats.c
===================================================================
--- branches/upstream/swt-gtk/current/os_stats.c	                        (rev 0)
+++ branches/upstream/swt-gtk/current/os_stats.c	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,1312 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others. All rights reserved.
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt).  The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html.  If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+#include "swt.h"
+#include "os_stats.h"
+
+#ifdef NATIVE_STATS
+
+int OS_nativeFunctionCount = 1266;
+int OS_nativeFunctionCallCount[1266];
+char * OS_nativeFunctionNames[] = {
+	"Call",
+	"GDK_1EVENT_1TYPE",
+	"GDK_1EVENT_1WINDOW",
+	"GDK_1WINDOWING_1X11",
+	"GInterfaceInfo_1sizeof",
+	"GPollFD_1sizeof",
+	"GTK_1ACCEL_1LABEL_1GET_1ACCEL_1STRING",
+	"GTK_1ACCEL_1LABEL_1SET_1ACCEL_1STRING",
+	"GTK_1ENTRY_1IM_1CONTEXT",
+	"GTK_1SCROLLED_1WINDOW_1HSCROLLBAR",
+	"GTK_1SCROLLED_1WINDOW_1SCROLLBAR_1SPACING",
+	"GTK_1SCROLLED_1WINDOW_1VSCROLLBAR",
+	"GTK_1TEXTVIEW_1IM_1CONTEXT",
+	"GTK_1TOOLTIPS_1SET_1ACTIVE",
+	"GTK_1TOOLTIPS_1TIP_1WINDOW",
+	"GTK_1WIDGET_1HEIGHT",
+	"GTK_1WIDGET_1REQUISITION_1HEIGHT",
+	"GTK_1WIDGET_1REQUISITION_1WIDTH",
+	"GTK_1WIDGET_1SET_1HEIGHT",
+	"GTK_1WIDGET_1SET_1WIDTH",
+	"GTK_1WIDGET_1SET_1X",
+	"GTK_1WIDGET_1SET_1Y",
+	"GTK_1WIDGET_1WIDTH",
+	"GTK_1WIDGET_1WINDOW",
+	"GTK_1WIDGET_1X",
+	"GTK_1WIDGET_1Y",
+	"GTypeInfo_1sizeof",
+	"GTypeQuery_1sizeof",
+	"GdkColor_1sizeof",
+	"GdkDragContext_1sizeof",
+	"GdkEventAny_1sizeof",
+	"GdkEventButton_1sizeof",
+	"GdkEventCrossing_1sizeof",
+	"GdkEventExpose_1sizeof",
+	"GdkEventFocus_1sizeof",
+	"GdkEventKey_1sizeof",
+	"GdkEventMotion_1sizeof",
+	"GdkEventScroll_1sizeof",
+	"GdkEventVisibility_1sizeof",
+	"GdkEventWindowState_1sizeof",
+	"GdkEvent_1sizeof",
+	"GdkGCValues_1sizeof",
+	"GdkGeometry_1sizeof",
+	"GdkImage_1sizeof",
+	"GdkRectangle_1sizeof",
+	"GdkVisual_1sizeof",
+	"GdkWindowAttr_1sizeof",
+	"GtkAdjustment_1sizeof",
+	"GtkAllocation_1sizeof",
+	"GtkBorder_1sizeof",
+	"GtkCellRendererPixbufClass_1sizeof",
+	"GtkCellRendererPixbuf_1sizeof",
+	"GtkCellRendererTextClass_1sizeof",
+	"GtkCellRendererText_1sizeof",
+	"GtkCellRendererToggleClass_1sizeof",
+	"GtkCellRendererToggle_1sizeof",
+	"GtkColorSelectionDialog_1sizeof",
+	"GtkCombo_1sizeof",
+	"GtkFileSelection_1sizeof",
+	"GtkFixedClass_1sizeof",
+	"GtkFixed_1sizeof",
+	"GtkRequisition_1sizeof",
+	"GtkSelectionData_1sizeof",
+	"GtkTargetEntry_1sizeof",
+	"GtkTargetPair_1sizeof",
+	"GtkTextIter_1sizeof",
+	"GtkTreeIter_1sizeof",
+	"PangoAttrColor_1sizeof",
+	"PangoAttrInt_1sizeof",
+	"PangoAttribute_1sizeof",
+	"PangoItem_1sizeof",
+	"PangoLayoutLine_1sizeof",
+	"PangoLayoutRun_1sizeof",
+	"PangoLogAttr_1sizeof",
+	"PangoRectangle_1sizeof",
+	"XAnyEvent_1sizeof",
+	"XButtonEvent_1sizeof",
+	"XClientMessageEvent_1sizeof",
+	"XCrossingEvent_1sizeof",
+	"XEvent_1sizeof",
+	"XExposeEvent_1sizeof",
+	"XFocusChangeEvent_1sizeof",
+	"XRenderPictureAttributes_1sizeof",
+	"XVisibilityEvent_1sizeof",
+	"XWindowChanges_1sizeof",
+	"X_1EVENT_1TYPE",
+	"X_1EVENT_1WINDOW",
+	"_1Call",
+	"_1FcConfigAppFontAddFile",
+	"_1GDK_1DISPLAY",
+	"_1GDK_1PIXMAP_1XID",
+	"_1GDK_1ROOT_1PARENT",
+	"_1GDK_1TYPE_1COLOR",
+	"_1GDK_1TYPE_1PIXBUF",
+	"_1GTK_1IS_1BUTTON",
+	"_1GTK_1IS_1CELL_1RENDERER_1PIXBUF",
+	"_1GTK_1IS_1CELL_1RENDERER_1TEXT",
+	"_1GTK_1IS_1CELL_1RENDERER_1TOGGLE",
+	"_1GTK_1IS_1CONTAINER",
+	"_1GTK_1IS_1IMAGE_1MENU_1ITEM",
+	"_1GTK_1IS_1MENU_1ITEM",
+	"_1GTK_1IS_1PLUG",
+	"_1GTK_1IS_1WINDOW",
+	"_1GTK_1STOCK_1CANCEL",
+	"_1GTK_1STOCK_1OK",
+	"_1GTK_1TYPE_1CELL_1RENDERER_1PIXBUF",
+	"_1GTK_1TYPE_1CELL_1RENDERER_1TEXT",
+	"_1GTK_1TYPE_1CELL_1RENDERER_1TOGGLE",
+	"_1GTK_1TYPE_1FIXED",
+	"_1GTK_1TYPE_1MENU",
+	"_1GTK_1TYPE_1WIDGET",
+	"_1GTK_1WIDGET_1FLAGS",
+	"_1GTK_1WIDGET_1HAS_1DEFAULT",
+	"_1GTK_1WIDGET_1HAS_1FOCUS",
+	"_1GTK_1WIDGET_1IS_1SENSITIVE",
+	"_1GTK_1WIDGET_1MAPPED",
+	"_1GTK_1WIDGET_1SENSITIVE",
+	"_1GTK_1WIDGET_1SET_1FLAGS",
+	"_1GTK_1WIDGET_1STATE",
+	"_1GTK_1WIDGET_1UNSET_1FLAGS",
+	"_1GTK_1WIDGET_1VISIBLE",
+	"_1G_1OBJECT_1CLASS",
+	"_1G_1OBJECT_1GET_1CLASS",
+	"_1G_1OBJECT_1TYPE",
+	"_1G_1OBJECT_1TYPE_1NAME",
+	"_1G_1TYPE_1BOOLEAN",
+	"_1G_1TYPE_1INT",
+	"_1G_1TYPE_1STRING",
+	"_1PANGO_1PIXELS",
+	"_1PANGO_1TYPE_1FONT_1DESCRIPTION",
+	"_1XCheckIfEvent",
+	"_1XCheckMaskEvent",
+	"_1XCheckWindowEvent",
+	"_1XDefaultRootWindow",
+	"_1XDefaultScreen",
+	"_1XFlush",
+	"_1XFree",
+	"_1XGetSelectionOwner",
+	"_1XInternAtom",
+	"_1XKeysymToKeycode",
+	"_1XListProperties",
+	"_1XQueryPointer",
+	"_1XQueryTree",
+	"_1XReconfigureWMWindow",
+	"_1XRenderComposite",
+	"_1XRenderCreatePicture",
+	"_1XRenderFindStandardFormat",
+	"_1XRenderFindVisualFormat",
+	"_1XRenderFreePicture",
+	"_1XRenderQueryExtension",
+	"_1XRenderQueryVersion",
+	"_1XRenderSetPictureClipRectangles",
+	"_1XRenderSetPictureTransform",
+	"_1XSendEvent",
+	"_1XSetErrorHandler",
+	"_1XSetIOErrorHandler",
+	"_1XSetInputFocus",
+	"_1XSetTransientForHint",
+	"_1XSynchronize",
+	"_1XTestFakeButtonEvent",
+	"_1XTestFakeKeyEvent",
+	"_1XTestFakeMotionEvent",
+	"_1XWarpPointer",
+	"_1atk_1object_1add_1relationship",
+	"_1call",
+	"_1dlclose",
+	"_1dlopen",
+	"_1dlsym",
+	"_1g_1cclosure_1new",
+	"_1g_1closure_1ref",
+	"_1g_1closure_1unref",
+	"_1g_1filename_1from_1uri",
+	"_1g_1filename_1from_1utf8",
+	"_1g_1filename_1to_1uri",
+	"_1g_1filename_1to_1utf8",
+	"_1g_1free",
+	"_1g_1idle_1add",
+	"_1g_1list_1append",
+	"_1g_1list_1data",
+	"_1g_1list_1free",
+	"_1g_1list_1free_11",
+	"_1g_1list_1length",
+	"_1g_1list_1next",
+	"_1g_1list_1nth",
+	"_1g_1list_1nth_1data",
+	"_1g_1list_1prepend",
+	"_1g_1list_1previous",
+	"_1g_1list_1remove_1link",
+	"_1g_1list_1reverse",
+	"_1g_1list_1set_1next",
+	"_1g_1list_1set_1previous",
+	"_1g_1locale_1from_1utf8",
+	"_1g_1locale_1to_1utf8",
+	"_1g_1log_1default_1handler",
+	"_1g_1log_1remove_1handler",
+	"_1g_1log_1set_1handler",
+	"_1g_1main_1context_1acquire",
+	"_1g_1main_1context_1check",
+	"_1g_1main_1context_1default",
+	"_1g_1main_1context_1get_1poll_1func",
+	"_1g_1main_1context_1iteration",
+	"_1g_1main_1context_1pending",
+	"_1g_1main_1context_1prepare",
+	"_1g_1main_1context_1query",
+	"_1g_1main_1context_1release",
+	"_1g_1malloc",
+	"_1g_1object_1get",
+	"_1g_1object_1get_1qdata",
+	"_1g_1object_1new",
+	"_1g_1object_1ref",
+	"_1g_1object_1set__I_3BFI",
+	"_1g_1object_1set__I_3BII",
+	"_1g_1object_1set__I_3BJI",
+	"_1g_1object_1set__I_3BLorg_eclipse_swt_internal_gtk_GdkColor_2I",
+	"_1g_1object_1set__I_3BZI",
+	"_1g_1object_1set_1qdata",
+	"_1g_1object_1unref",
+	"_1g_1quark_1from_1string",
+	"_1g_1set_1prgname",
+	"_1g_1signal_1add_1emission_1hook",
+	"_1g_1signal_1connect",
+	"_1g_1signal_1connect_1after",
+	"_1g_1signal_1connect_1closure",
+	"_1g_1signal_1connect_1closure_1by_1id",
+	"_1g_1signal_1emit_1by_1name__I_3B",
+	"_1g_1signal_1emit_1by_1name__I_3BI",
+	"_1g_1signal_1emit_1by_1name__I_3BII",
+	"_1g_1signal_1emit_1by_1name__I_3B_3B",
+	"_1g_1signal_1handler_1disconnect",
+	"_1g_1signal_1handlers_1block_1matched",
+	"_1g_1signal_1handlers_1disconnect_1matched",
+	"_1g_1signal_1handlers_1unblock_1matched",
+	"_1g_1signal_1lookup",
+	"_1g_1signal_1remove_1emission_1hook",
+	"_1g_1signal_1stop_1emission_1by_1name",
+	"_1g_1slist_1data",
+	"_1g_1slist_1free",
+	"_1g_1slist_1length",
+	"_1g_1slist_1next",
+	"_1g_1source_1remove",
+	"_1g_1strfreev",
+	"_1g_1strtod",
+	"_1g_1thread_1init",
+	"_1g_1thread_1supported",
+	"_1g_1type_1add_1interface_1static",
+	"_1g_1type_1class_1peek",
+	"_1g_1type_1class_1peek_1parent",
+	"_1g_1type_1from_1name",
+	"_1g_1type_1interface_1peek_1parent",
+	"_1g_1type_1is_1a",
+	"_1g_1type_1name",
+	"_1g_1type_1parent",
+	"_1g_1type_1query",
+	"_1g_1type_1register_1static",
+	"_1g_1utf16_1to_1utf8",
+	"_1g_1utf8_1offset_1to_1pointer",
+	"_1g_1utf8_1pointer_1to_1offset",
+	"_1g_1utf8_1strlen",
+	"_1g_1utf8_1to_1utf16__II_3I_3I_3I",
+	"_1g_1utf8_1to_1utf16___3BI_3I_3I_3I",
+	"_1g_1value_1peek_1pointer",
+	"_1gdk_1atom_1intern",
+	"_1gdk_1atom_1name",
+	"_1gdk_1beep",
+	"_1gdk_1bitmap_1create_1from_1data",
+	"_1gdk_1cairo_1region",
+	"_1gdk_1cairo_1set_1source_1color",
+	"_1gdk_1color_1white",
+	"_1gdk_1colormap_1alloc_1color",
+	"_1gdk_1colormap_1free_1colors",
+	"_1gdk_1colormap_1get_1system",
+	"_1gdk_1colormap_1query_1color",
+	"_1gdk_1cursor_1destroy",
+	"_1gdk_1cursor_1new",
+	"_1gdk_1cursor_1new_1from_1pixbuf",
+	"_1gdk_1cursor_1new_1from_1pixmap",
+	"_1gdk_1display_1get_1default",
+	"_1gdk_1display_1supports_1cursor_1color",
+	"_1gdk_1drag_1status",
+	"_1gdk_1draw_1arc",
+	"_1gdk_1draw_1drawable",
+	"_1gdk_1draw_1image",
+	"_1gdk_1draw_1layout",
+	"_1gdk_1draw_1layout_1with_1colors",
+	"_1gdk_1draw_1line",
+	"_1gdk_1draw_1lines",
+	"_1gdk_1draw_1pixbuf",
+	"_1gdk_1draw_1point",
+	"_1gdk_1draw_1polygon",
+	"_1gdk_1draw_1rectangle",
+	"_1gdk_1drawable_1get_1depth",
+	"_1gdk_1drawable_1get_1image",
+	"_1gdk_1drawable_1get_1size",
+	"_1gdk_1drawable_1get_1visible_1region",
+	"_1gdk_1error_1trap_1pop",
+	"_1gdk_1error_1trap_1push",
+	"_1gdk_1event_1copy",
+	"_1gdk_1event_1free",
+	"_1gdk_1event_1get",
+	"_1gdk_1event_1get_1coords",
+	"_1gdk_1event_1get_1graphics_1expose",
+	"_1gdk_1event_1get_1root_1coords",
+	"_1gdk_1event_1get_1state",
+	"_1gdk_1event_1get_1time",
+	"_1gdk_1event_1handler_1set",
+	"_1gdk_1event_1new",
+	"_1gdk_1event_1peek",
+	"_1gdk_1event_1put",
+	"_1gdk_1flush",
+	"_1gdk_1free_1text_1list",
+	"_1gdk_1gc_1get_1values",
+	"_1gdk_1gc_1new",
+	"_1gdk_1gc_1set_1background",
+	"_1gdk_1gc_1set_1clip_1mask",
+	"_1gdk_1gc_1set_1clip_1origin",
+	"_1gdk_1gc_1set_1clip_1rectangle",
+	"_1gdk_1gc_1set_1clip_1region",
+	"_1gdk_1gc_1set_1dashes",
+	"_1gdk_1gc_1set_1exposures",
+	"_1gdk_1gc_1set_1fill",
+	"_1gdk_1gc_1set_1foreground",
+	"_1gdk_1gc_1set_1function",
+	"_1gdk_1gc_1set_1line_1attributes",
+	"_1gdk_1gc_1set_1stipple",
+	"_1gdk_1gc_1set_1subwindow",
+	"_1gdk_1gc_1set_1tile",
+	"_1gdk_1gc_1set_1ts_1origin",
+	"_1gdk_1gc_1set_1values",
+	"_1gdk_1keyboard_1ungrab",
+	"_1gdk_1keymap_1get_1default",
+	"_1gdk_1keymap_1translate_1keyboard_1state",
+	"_1gdk_1keyval_1to_1lower",
+	"_1gdk_1keyval_1to_1unicode",
+	"_1gdk_1pango_1context_1get",
+	"_1gdk_1pango_1context_1set_1colormap",
+	"_1gdk_1pango_1layout_1get_1clip_1region",
+	"_1gdk_1pixbuf_1copy_1area",
+	"_1gdk_1pixbuf_1get_1from_1drawable",
+	"_1gdk_1pixbuf_1get_1has_1alpha",
+	"_1gdk_1pixbuf_1get_1height",
+	"_1gdk_1pixbuf_1get_1pixels",
+	"_1gdk_1pixbuf_1get_1rowstride",
+	"_1gdk_1pixbuf_1get_1width",
+	"_1gdk_1pixbuf_1loader_1close",
+	"_1gdk_1pixbuf_1loader_1get_1pixbuf",
+	"_1gdk_1pixbuf_1loader_1new",
+	"_1gdk_1pixbuf_1loader_1write",
+	"_1gdk_1pixbuf_1new",
+	"_1gdk_1pixbuf_1new_1from_1file",
+	"_1gdk_1pixbuf_1render_1pixmap_1and_1mask",
+	"_1gdk_1pixbuf_1render_1to_1drawable",
+	"_1gdk_1pixbuf_1render_1to_1drawable_1alpha",
+	"_1gdk_1pixbuf_1save_1to_1buffer",
+	"_1gdk_1pixbuf_1scale",
+	"_1gdk_1pixbuf_1scale_1simple",
+	"_1gdk_1pixmap_1foreign_1new",
+	"_1gdk_1pixmap_1new",
+	"_1gdk_1pointer_1grab",
+	"_1gdk_1pointer_1is_1grabbed",
+	"_1gdk_1pointer_1ungrab",
+	"_1gdk_1property_1get",
+	"_1gdk_1region_1destroy",
+	"_1gdk_1region_1empty",
+	"_1gdk_1region_1get_1clipbox",
+	"_1gdk_1region_1get_1rectangles",
+	"_1gdk_1region_1intersect",
+	"_1gdk_1region_1new",
+	"_1gdk_1region_1offset",
+	"_1gdk_1region_1point_1in",
+	"_1gdk_1region_1polygon",
+	"_1gdk_1region_1rect_1in",
+	"_1gdk_1region_1rectangle",
+	"_1gdk_1region_1subtract",
+	"_1gdk_1region_1union",
+	"_1gdk_1region_1union_1with_1rect",
+	"_1gdk_1rgb_1init",
+	"_1gdk_1screen_1get_1default",
+	"_1gdk_1screen_1get_1monitor_1at_1point",
+	"_1gdk_1screen_1get_1monitor_1at_1window",
+	"_1gdk_1screen_1get_1monitor_1geometry",
+	"_1gdk_1screen_1get_1n_1monitors",
+	"_1gdk_1screen_1get_1number",
+	"_1gdk_1screen_1height",
+	"_1gdk_1screen_1width",
+	"_1gdk_1screen_1width_1mm",
+	"_1gdk_1set_1program_1class",
+	"_1gdk_1text_1property_1to_1utf8_1list",
+	"_1gdk_1unicode_1to_1keyval",
+	"_1gdk_1utf8_1to_1compound_1text",
+	"_1gdk_1utf8_1to_1string_1target",
+	"_1gdk_1visual_1get_1system",
+	"_1gdk_1window_1add_1filter",
+	"_1gdk_1window_1at_1pointer",
+	"_1gdk_1window_1begin_1paint_1rect",
+	"_1gdk_1window_1clear_1area",
+	"_1gdk_1window_1destroy",
+	"_1gdk_1window_1end_1paint",
+	"_1gdk_1window_1focus",
+	"_1gdk_1window_1freeze_1updates",
+	"_1gdk_1window_1get_1children",
+	"_1gdk_1window_1get_1events",
+	"_1gdk_1window_1get_1frame_1extents",
+	"_1gdk_1window_1get_1internal_1paint_1info",
+	"_1gdk_1window_1get_1origin",
+	"_1gdk_1window_1get_1parent",
+	"_1gdk_1window_1get_1pointer",
+	"_1gdk_1window_1get_1position",
+	"_1gdk_1window_1get_1user_1data",
+	"_1gdk_1window_1hide",
+	"_1gdk_1window_1invalidate_1rect",
+	"_1gdk_1window_1invalidate_1region",
+	"_1gdk_1window_1is_1visible",
+	"_1gdk_1window_1lookup",
+	"_1gdk_1window_1lower",
+	"_1gdk_1window_1move",
+	"_1gdk_1window_1new",
+	"_1gdk_1window_1process_1all_1updates",
+	"_1gdk_1window_1process_1updates",
+	"_1gdk_1window_1raise",
+	"_1gdk_1window_1remove_1filter",
+	"_1gdk_1window_1resize",
+	"_1gdk_1window_1scroll",
+	"_1gdk_1window_1set_1accept_1focus",
+	"_1gdk_1window_1set_1back_1pixmap",
+	"_1gdk_1window_1set_1cursor",
+	"_1gdk_1window_1set_1debug_1updates",
+	"_1gdk_1window_1set_1decorations",
+	"_1gdk_1window_1set_1events",
+	"_1gdk_1window_1set_1icon",
+	"_1gdk_1window_1set_1icon_1list",
+	"_1gdk_1window_1set_1keep_1above",
+	"_1gdk_1window_1set_1override_1redirect",
+	"_1gdk_1window_1set_1user_1data",
+	"_1gdk_1window_1shape_1combine_1region",
+	"_1gdk_1window_1show",
+	"_1gdk_1window_1show_1unraised",
+	"_1gdk_1window_1thaw_1updates",
+	"_1gdk_1x11_1atom_1to_1xatom",
+	"_1gdk_1x11_1colormap_1get_1xcolormap",
+	"_1gdk_1x11_1drawable_1get_1xdisplay",
+	"_1gdk_1x11_1drawable_1get_1xid",
+	"_1gdk_1x11_1screen_1get_1window_1manager_1name",
+	"_1gdk_1x11_1screen_1lookup_1visual",
+	"_1gdk_1x11_1visual_1get_1xvisual",
+	"_1gtk_1accel_1group_1new",
+	"_1gtk_1accel_1groups_1activate",
+	"_1gtk_1accel_1label_1set_1accel_1widget",
+	"_1gtk_1adjustment_1changed",
+	"_1gtk_1adjustment_1new",
+	"_1gtk_1adjustment_1set_1value",
+	"_1gtk_1adjustment_1value_1changed",
+	"_1gtk_1arrow_1new",
+	"_1gtk_1arrow_1set",
+	"_1gtk_1bin_1get_1child",
+	"_1gtk_1box_1set_1child_1packing",
+	"_1gtk_1box_1set_1spacing",
+	"_1gtk_1button_1clicked",
+	"_1gtk_1button_1get_1relief",
+	"_1gtk_1button_1new",
+	"_1gtk_1button_1set_1relief",
+	"_1gtk_1calendar_1display_1options",
+	"_1gtk_1calendar_1get_1date",
+	"_1gtk_1calendar_1new",
+	"_1gtk_1calendar_1select_1day",
+	"_1gtk_1calendar_1select_1month",
+	"_1gtk_1calendar_1set_1display_1options",
+	"_1gtk_1cell_1layout_1clear",
+	"_1gtk_1cell_1layout_1pack_1start",
+	"_1gtk_1cell_1layout_1set_1attributes",
+	"_1gtk_1cell_1renderer_1get_1size",
+	"_1gtk_1cell_1renderer_1pixbuf_1new",
+	"_1gtk_1cell_1renderer_1text_1new",
+	"_1gtk_1cell_1renderer_1toggle_1new",
+	"_1gtk_1check_1button_1new",
+	"_1gtk_1check_1menu_1item_1get_1active",
+	"_1gtk_1check_1menu_1item_1new_1with_1label",
+	"_1gtk_1check_1menu_1item_1set_1active",
+	"_1gtk_1check_1version",
+	"_1gtk_1clipboard_1clear",
+	"_1gtk_1clipboard_1get",
+	"_1gtk_1clipboard_1set_1with_1data",
+	"_1gtk_1clipboard_1wait_1for_1contents",
+	"_1gtk_1color_1selection_1dialog_1new",
+	"_1gtk_1color_1selection_1get_1current_1color",
+	"_1gtk_1color_1selection_1set_1current_1color",
+	"_1gtk_1color_1selection_1set_1has_1palette",
+	"_1gtk_1combo_1box_1entry_1new_1text",
+	"_1gtk_1combo_1box_1get_1active",
+	"_1gtk_1combo_1box_1get_1model",
+	"_1gtk_1combo_1box_1insert_1text",
+	"_1gtk_1combo_1box_1new_1text",
+	"_1gtk_1combo_1box_1popdown",
+	"_1gtk_1combo_1box_1popup",
+	"_1gtk_1combo_1box_1remove_1text",
+	"_1gtk_1combo_1box_1set_1active",
+	"_1gtk_1combo_1box_1set_1focus_1on_1click",
+	"_1gtk_1combo_1disable_1activate",
+	"_1gtk_1combo_1new",
+	"_1gtk_1combo_1set_1case_1sensitive",
+	"_1gtk_1combo_1set_1popdown_1strings",
+	"_1gtk_1container_1add",
+	"_1gtk_1container_1forall",
+	"_1gtk_1container_1get_1border_1width",
+	"_1gtk_1container_1get_1children",
+	"_1gtk_1container_1remove",
+	"_1gtk_1container_1resize_1children",
+	"_1gtk_1container_1set_1border_1width",
+	"_1gtk_1dialog_1add_1button",
+	"_1gtk_1dialog_1run",
+	"_1gtk_1drag_1begin",
+	"_1gtk_1drag_1check_1threshold",
+	"_1gtk_1drag_1dest_1find_1target",
+	"_1gtk_1drag_1dest_1set",
+	"_1gtk_1drag_1dest_1unset",
+	"_1gtk_1drag_1finish",
+	"_1gtk_1drag_1get_1data",
+	"_1gtk_1drag_1set_1icon_1pixbuf",
+	"_1gtk_1drawing_1area_1new",
+	"_1gtk_1editable_1copy_1clipboard",
+	"_1gtk_1editable_1cut_1clipboard",
+	"_1gtk_1editable_1delete_1selection",
+	"_1gtk_1editable_1delete_1text",
+	"_1gtk_1editable_1get_1chars",
+	"_1gtk_1editable_1get_1editable",
+	"_1gtk_1editable_1get_1position",
+	"_1gtk_1editable_1get_1selection_1bounds",
+	"_1gtk_1editable_1insert_1text",
+	"_1gtk_1editable_1paste_1clipboard",
+	"_1gtk_1editable_1select_1region",
+	"_1gtk_1editable_1set_1editable",
+	"_1gtk_1editable_1set_1position",
+	"_1gtk_1entry_1get_1invisible_1char",
+	"_1gtk_1entry_1get_1layout",
+	"_1gtk_1entry_1get_1layout_1offsets",
+	"_1gtk_1entry_1get_1max_1length",
+	"_1gtk_1entry_1get_1text",
+	"_1gtk_1entry_1get_1visibility",
+	"_1gtk_1entry_1new",
+	"_1gtk_1entry_1set_1activates_1default",
+	"_1gtk_1entry_1set_1alignment",
+	"_1gtk_1entry_1set_1has_1frame",
+	"_1gtk_1entry_1set_1invisible_1char",
+	"_1gtk_1entry_1set_1max_1length",
+	"_1gtk_1entry_1set_1text",
+	"_1gtk_1entry_1set_1visibility",
+	"_1gtk_1entry_1text_1index_1to_1layout_1index",
+	"_1gtk_1enumerate_1printers",
+	"_1gtk_1events_1pending",
+	"_1gtk_1expander_1get_1expanded",
+	"_1gtk_1expander_1get_1label_1widget",
+	"_1gtk_1expander_1new",
+	"_1gtk_1expander_1set_1expanded",
+	"_1gtk_1expander_1set_1label",
+	"_1gtk_1expander_1set_1label_1widget",
+	"_1gtk_1file_1chooser_1add_1filter",
+	"_1gtk_1file_1chooser_1dialog_1new",
+	"_1gtk_1file_1chooser_1get_1current_1folder",
+	"_1gtk_1file_1chooser_1get_1filename",
+	"_1gtk_1file_1chooser_1get_1filenames",
+	"_1gtk_1file_1chooser_1get_1filter",
+	"_1gtk_1file_1chooser_1set_1current_1folder",
+	"_1gtk_1file_1chooser_1set_1current_1name",
+	"_1gtk_1file_1chooser_1set_1do_1overwrite_1confirmation",
+	"_1gtk_1file_1chooser_1set_1extra_1widget",
+	"_1gtk_1file_1chooser_1set_1filename",
+	"_1gtk_1file_1chooser_1set_1filter",
+	"_1gtk_1file_1chooser_1set_1select_1multiple",
+	"_1gtk_1file_1filter_1add_1pattern",
+	"_1gtk_1file_1filter_1get_1name",
+	"_1gtk_1file_1filter_1new",
+	"_1gtk_1file_1filter_1set_1name",
+	"_1gtk_1file_1selection_1get_1filename",
+	"_1gtk_1file_1selection_1get_1selections",
+	"_1gtk_1file_1selection_1hide_1fileop_1buttons",
+	"_1gtk_1file_1selection_1new",
+	"_1gtk_1file_1selection_1set_1filename",
+	"_1gtk_1file_1selection_1set_1select_1multiple",
+	"_1gtk_1fixed_1move",
+	"_1gtk_1fixed_1new",
+	"_1gtk_1fixed_1set_1has_1window",
+	"_1gtk_1font_1selection_1dialog_1get_1font_1name",
+	"_1gtk_1font_1selection_1dialog_1new",
+	"_1gtk_1font_1selection_1dialog_1set_1font_1name",
+	"_1gtk_1frame_1get_1label_1widget",
+	"_1gtk_1frame_1new",
+	"_1gtk_1frame_1set_1label",
+	"_1gtk_1frame_1set_1label_1widget",
+	"_1gtk_1frame_1set_1shadow_1type",
+	"_1gtk_1get_1current_1event",
+	"_1gtk_1get_1current_1event_1state",
+	"_1gtk_1get_1current_1event_1time",
+	"_1gtk_1get_1default_1language",
+	"_1gtk_1get_1event_1widget",
+	"_1gtk_1grab_1add",
+	"_1gtk_1grab_1get_1current",
+	"_1gtk_1grab_1remove",
+	"_1gtk_1hbox_1new",
+	"_1gtk_1hscale_1new",
+	"_1gtk_1hscrollbar_1new",
+	"_1gtk_1hseparator_1new",
+	"_1gtk_1icon_1factory_1lookup_1default",
+	"_1gtk_1icon_1set_1render_1icon",
+	"_1gtk_1icon_1source_1free",
+	"_1gtk_1icon_1source_1new",
+	"_1gtk_1icon_1source_1set_1pixbuf",
+	"_1gtk_1im_1context_1filter_1keypress",
+	"_1gtk_1im_1context_1focus_1in",
+	"_1gtk_1im_1context_1focus_1out",
+	"_1gtk_1im_1context_1get_1preedit_1string",
+	"_1gtk_1im_1context_1get_1type",
+	"_1gtk_1im_1context_1reset",
+	"_1gtk_1im_1context_1set_1client_1window",
+	"_1gtk_1im_1context_1set_1cursor_1location",
+	"_1gtk_1im_1multicontext_1append_1menuitems",
+	"_1gtk_1im_1multicontext_1new",
+	"_1gtk_1image_1menu_1item_1new_1with_1label",
+	"_1gtk_1image_1menu_1item_1set_1image",
+	"_1gtk_1image_1new",
+	"_1gtk_1image_1new_1from_1pixbuf",
+	"_1gtk_1image_1new_1from_1pixmap",
+	"_1gtk_1image_1set_1from_1pixbuf",
+	"_1gtk_1image_1set_1from_1pixmap",
+	"_1gtk_1init_1check",
+	"_1gtk_1label_1get_1layout",
+	"_1gtk_1label_1get_1mnemonic_1keyval",
+	"_1gtk_1label_1new",
+	"_1gtk_1label_1new_1with_1mnemonic",
+	"_1gtk_1label_1set_1attributes",
+	"_1gtk_1label_1set_1justify",
+	"_1gtk_1label_1set_1line_1wrap",
+	"_1gtk_1label_1set_1line_1wrap_1mode",
+	"_1gtk_1label_1set_1text__II",
+	"_1gtk_1label_1set_1text__I_3B",
+	"_1gtk_1label_1set_1text_1with_1mnemonic",
+	"_1gtk_1list_1append_1items",
+	"_1gtk_1list_1clear_1items",
+	"_1gtk_1list_1insert_1items",
+	"_1gtk_1list_1item_1new_1with_1label",
+	"_1gtk_1list_1remove_1items",
+	"_1gtk_1list_1select_1item",
+	"_1gtk_1list_1store_1append",
+	"_1gtk_1list_1store_1clear",
+	"_1gtk_1list_1store_1insert",
+	"_1gtk_1list_1store_1newv",
+	"_1gtk_1list_1store_1remove",
+	"_1gtk_1list_1store_1set__IIIII",
+	"_1gtk_1list_1store_1set__IIIJI",
+	"_1gtk_1list_1store_1set__IIILorg_eclipse_swt_internal_gtk_GdkColor_2I",
+	"_1gtk_1list_1store_1set__IIIZI",
+	"_1gtk_1list_1store_1set__III_3BI",
+	"_1gtk_1list_1unselect_1all",
+	"_1gtk_1list_1unselect_1item",
+	"_1gtk_1main",
+	"_1gtk_1main_1do_1event",
+	"_1gtk_1main_1iteration",
+	"_1gtk_1major_1version",
+	"_1gtk_1menu_1bar_1new",
+	"_1gtk_1menu_1item_1get_1submenu",
+	"_1gtk_1menu_1item_1remove_1submenu",
+	"_1gtk_1menu_1item_1set_1submenu",
+	"_1gtk_1menu_1new",
+	"_1gtk_1menu_1popdown",
+	"_1gtk_1menu_1popup",
+	"_1gtk_1menu_1shell_1deactivate",
+	"_1gtk_1menu_1shell_1insert",
+	"_1gtk_1menu_1shell_1select_1item",
+	"_1gtk_1menu_1shell_1set_1take_1focus",
+	"_1gtk_1message_1dialog_1new",
+	"_1gtk_1micro_1version",
+	"_1gtk_1minor_1version",
+	"_1gtk_1misc_1set_1alignment",
+	"_1gtk_1notebook_1get_1current_1page",
+	"_1gtk_1notebook_1get_1scrollable",
+	"_1gtk_1notebook_1insert_1page",
+	"_1gtk_1notebook_1new",
+	"_1gtk_1notebook_1next_1page",
+	"_1gtk_1notebook_1prev_1page",
+	"_1gtk_1notebook_1remove_1page",
+	"_1gtk_1notebook_1set_1current_1page",
+	"_1gtk_1notebook_1set_1scrollable",
+	"_1gtk_1notebook_1set_1show_1tabs",
+	"_1gtk_1notebook_1set_1tab_1pos",
+	"_1gtk_1object_1sink",
+	"_1gtk_1page_1setup_1get_1bottom_1margin",
+	"_1gtk_1page_1setup_1get_1left_1margin",
+	"_1gtk_1page_1setup_1get_1orientation",
+	"_1gtk_1page_1setup_1get_1page_1height",
+	"_1gtk_1page_1setup_1get_1page_1width",
+	"_1gtk_1page_1setup_1get_1paper_1height",
+	"_1gtk_1page_1setup_1get_1paper_1size",
+	"_1gtk_1page_1setup_1get_1paper_1width",
+	"_1gtk_1page_1setup_1get_1right_1margin",
+	"_1gtk_1page_1setup_1get_1top_1margin",
+	"_1gtk_1page_1setup_1new",
+	"_1gtk_1page_1setup_1set_1bottom_1margin",
+	"_1gtk_1page_1setup_1set_1left_1margin",
+	"_1gtk_1page_1setup_1set_1orientation",
+	"_1gtk_1page_1setup_1set_1paper_1size",
+	"_1gtk_1page_1setup_1set_1right_1margin",
+	"_1gtk_1page_1setup_1set_1top_1margin",
+	"_1gtk_1paint_1arrow",
+	"_1gtk_1paint_1box",
+	"_1gtk_1paint_1box_1gap",
+	"_1gtk_1paint_1check",
+	"_1gtk_1paint_1expander",
+	"_1gtk_1paint_1extension",
+	"_1gtk_1paint_1flat_1box",
+	"_1gtk_1paint_1focus",
+	"_1gtk_1paint_1handle",
+	"_1gtk_1paint_1hline",
+	"_1gtk_1paint_1layout",
+	"_1gtk_1paint_1option",
+	"_1gtk_1paint_1shadow",
+	"_1gtk_1paint_1shadow_1gap",
+	"_1gtk_1paint_1slider",
+	"_1gtk_1paint_1tab",
+	"_1gtk_1paint_1vline",
+	"_1gtk_1paper_1size_1free",
+	"_1gtk_1paper_1size_1get_1display_1name",
+	"_1gtk_1paper_1size_1get_1height",
+	"_1gtk_1paper_1size_1get_1name",
+	"_1gtk_1paper_1size_1get_1ppd_1name",
+	"_1gtk_1paper_1size_1get_1width",
+	"_1gtk_1paper_1size_1is_1custom",
+	"_1gtk_1paper_1size_1new",
+	"_1gtk_1paper_1size_1new_1custom",
+	"_1gtk_1paper_1size_1new_1from_1ppd",
+	"_1gtk_1plug_1get_1id",
+	"_1gtk_1plug_1new",
+	"_1gtk_1print_1job_1get_1printer",
+	"_1gtk_1print_1job_1get_1settings",
+	"_1gtk_1print_1job_1get_1status",
+	"_1gtk_1print_1job_1get_1surface",
+	"_1gtk_1print_1job_1get_1title",
+	"_1gtk_1print_1job_1new",
+	"_1gtk_1print_1job_1send",
+	"_1gtk_1print_1job_1set_1source_1file",
+	"_1gtk_1print_1settings_1foreach",
+	"_1gtk_1print_1settings_1get",
+	"_1gtk_1print_1settings_1get_1collate",
+	"_1gtk_1print_1settings_1get_1n_1copies",
+	"_1gtk_1print_1settings_1get_1orientation",
+	"_1gtk_1print_1settings_1get_1page_1ranges",
+	"_1gtk_1print_1settings_1get_1paper_1height",
+	"_1gtk_1print_1settings_1get_1paper_1width",
+	"_1gtk_1print_1settings_1get_1print_1pages",
+	"_1gtk_1print_1settings_1get_1printer",
+	"_1gtk_1print_1settings_1get_1resolution",
+	"_1gtk_1print_1settings_1new",
+	"_1gtk_1print_1settings_1set",
+	"_1gtk_1print_1settings_1set_1collate",
+	"_1gtk_1print_1settings_1set_1n_1copies",
+	"_1gtk_1print_1settings_1set_1orientation",
+	"_1gtk_1print_1settings_1set_1page_1ranges",
+	"_1gtk_1print_1settings_1set_1print_1pages",
+	"_1gtk_1print_1settings_1set_1printer",
+	"_1gtk_1print_1unix_1dialog_1get_1current_1page",
+	"_1gtk_1print_1unix_1dialog_1get_1page_1setup",
+	"_1gtk_1print_1unix_1dialog_1get_1selected_1printer",
+	"_1gtk_1print_1unix_1dialog_1get_1settings",
+	"_1gtk_1print_1unix_1dialog_1new",
+	"_1gtk_1print_1unix_1dialog_1set_1current_1page",
+	"_1gtk_1print_1unix_1dialog_1set_1manual_1capabilities",
+	"_1gtk_1print_1unix_1dialog_1set_1page_1setup",
+	"_1gtk_1print_1unix_1dialog_1set_1settings",
+	"_1gtk_1printer_1get_1backend",
+	"_1gtk_1printer_1get_1name",
+	"_1gtk_1printer_1is_1default",
+	"_1gtk_1progress_1bar_1new",
+	"_1gtk_1progress_1bar_1pulse",
+	"_1gtk_1progress_1bar_1set_1fraction",
+	"_1gtk_1progress_1bar_1set_1orientation",
+	"_1gtk_1radio_1button_1get_1group",
+	"_1gtk_1radio_1button_1new",
+	"_1gtk_1radio_1menu_1item_1get_1group",
+	"_1gtk_1radio_1menu_1item_1new",
+	"_1gtk_1radio_1menu_1item_1new_1with_1label",
+	"_1gtk_1range_1get_1adjustment",
+	"_1gtk_1range_1set_1increments",
+	"_1gtk_1range_1set_1inverted",
+	"_1gtk_1range_1set_1range",
+	"_1gtk_1range_1set_1value",
+	"_1gtk_1rc_1parse_1string",
+	"_1gtk_1rc_1style_1get_1bg_1pixmap_1name",
+	"_1gtk_1rc_1style_1get_1color_1flags",
+	"_1gtk_1rc_1style_1set_1bg",
+	"_1gtk_1rc_1style_1set_1bg_1pixmap_1name",
+	"_1gtk_1rc_1style_1set_1color_1flags",
+	"_1gtk_1rc_1style_1set_1fg",
+	"_1gtk_1rc_1style_1set_1text",
+	"_1gtk_1scale_1set_1digits",
+	"_1gtk_1scale_1set_1draw_1value",
+	"_1gtk_1scrolled_1window_1add_1with_1viewport",
+	"_1gtk_1scrolled_1window_1get_1hadjustment",
+	"_1gtk_1scrolled_1window_1get_1policy",
+	"_1gtk_1scrolled_1window_1get_1shadow_1type",
+	"_1gtk_1scrolled_1window_1get_1vadjustment",
+	"_1gtk_1scrolled_1window_1new",
+	"_1gtk_1scrolled_1window_1set_1placement",
+	"_1gtk_1scrolled_1window_1set_1policy",
+	"_1gtk_1scrolled_1window_1set_1shadow_1type",
+	"_1gtk_1selection_1data_1free",
+	"_1gtk_1selection_1data_1set",
+	"_1gtk_1separator_1menu_1item_1new",
+	"_1gtk_1set_1locale",
+	"_1gtk_1settings_1get_1default",
+	"_1gtk_1socket_1get_1id",
+	"_1gtk_1socket_1new",
+	"_1gtk_1spin_1button_1get_1adjustment",
+	"_1gtk_1spin_1button_1get_1digits",
+	"_1gtk_1spin_1button_1new",
+	"_1gtk_1spin_1button_1set_1digits",
+	"_1gtk_1spin_1button_1set_1increments",
+	"_1gtk_1spin_1button_1set_1range",
+	"_1gtk_1spin_1button_1set_1value",
+	"_1gtk_1spin_1button_1set_1wrap",
+	"_1gtk_1spin_1button_1update",
+	"_1gtk_1style_1get_1base",
+	"_1gtk_1style_1get_1bg",
+	"_1gtk_1style_1get_1bg_1gc",
+	"_1gtk_1style_1get_1black",
+	"_1gtk_1style_1get_1black_1gc",
+	"_1gtk_1style_1get_1dark",
+	"_1gtk_1style_1get_1dark_1gc",
+	"_1gtk_1style_1get_1fg",
+	"_1gtk_1style_1get_1fg_1gc",
+	"_1gtk_1style_1get_1font_1desc",
+	"_1gtk_1style_1get_1light",
+	"_1gtk_1style_1get_1light_1gc",
+	"_1gtk_1style_1get_1mid_1gc",
+	"_1gtk_1style_1get_1text",
+	"_1gtk_1style_1get_1text_1aa_1gc",
+	"_1gtk_1style_1get_1text_1gc",
+	"_1gtk_1style_1get_1white_1gc",
+	"_1gtk_1style_1get_1xthickness",
+	"_1gtk_1style_1get_1ythickness",
+	"_1gtk_1style_1render_1icon",
+	"_1gtk_1target_1list_1new",
+	"_1gtk_1target_1list_1unref",
+	"_1gtk_1text_1buffer_1copy_1clipboard",
+	"_1gtk_1text_1buffer_1cut_1clipboard",
+	"_1gtk_1text_1buffer_1delete",
+	"_1gtk_1text_1buffer_1get_1bounds",
+	"_1gtk_1text_1buffer_1get_1char_1count",
+	"_1gtk_1text_1buffer_1get_1end_1iter",
+	"_1gtk_1text_1buffer_1get_1insert",
+	"_1gtk_1text_1buffer_1get_1iter_1at_1line",
+	"_1gtk_1text_1buffer_1get_1iter_1at_1mark",
+	"_1gtk_1text_1buffer_1get_1iter_1at_1offset",
+	"_1gtk_1text_1buffer_1get_1line_1count",
+	"_1gtk_1text_1buffer_1get_1selection_1bound",
+	"_1gtk_1text_1buffer_1get_1selection_1bounds",
+	"_1gtk_1text_1buffer_1get_1text",
+	"_1gtk_1text_1buffer_1insert__II_3BI",
+	"_1gtk_1text_1buffer_1insert__I_3B_3BI",
+	"_1gtk_1text_1buffer_1move_1mark",
+	"_1gtk_1text_1buffer_1paste_1clipboard",
+	"_1gtk_1text_1buffer_1place_1cursor",
+	"_1gtk_1text_1buffer_1set_1text",
+	"_1gtk_1text_1iter_1get_1line",
+	"_1gtk_1text_1iter_1get_1offset",
+	"_1gtk_1text_1view_1buffer_1to_1window_1coords",
+	"_1gtk_1text_1view_1get_1buffer",
+	"_1gtk_1text_1view_1get_1editable",
+	"_1gtk_1text_1view_1get_1iter_1at_1location",
+	"_1gtk_1text_1view_1get_1iter_1location",
+	"_1gtk_1text_1view_1get_1line_1at_1y",
+	"_1gtk_1text_1view_1get_1visible_1rect",
+	"_1gtk_1text_1view_1get_1window",
+	"_1gtk_1text_1view_1new",
+	"_1gtk_1text_1view_1scroll_1mark_1onscreen",
+	"_1gtk_1text_1view_1scroll_1to_1iter",
+	"_1gtk_1text_1view_1set_1editable",
+	"_1gtk_1text_1view_1set_1justification",
+	"_1gtk_1text_1view_1set_1tabs",
+	"_1gtk_1text_1view_1set_1wrap_1mode",
+	"_1gtk_1text_1view_1window_1to_1buffer_1coords",
+	"_1gtk_1timeout_1add",
+	"_1gtk_1timeout_1remove",
+	"_1gtk_1toggle_1button_1get_1active",
+	"_1gtk_1toggle_1button_1get_1inconsistent",
+	"_1gtk_1toggle_1button_1new",
+	"_1gtk_1toggle_1button_1set_1active",
+	"_1gtk_1toggle_1button_1set_1inconsistent",
+	"_1gtk_1toggle_1button_1set_1mode",
+	"_1gtk_1toolbar_1insert_1widget",
+	"_1gtk_1toolbar_1new",
+	"_1gtk_1toolbar_1set_1orientation",
+	"_1gtk_1tooltip_1trigger_1tooltip_1query",
+	"_1gtk_1tooltips_1data_1get",
+	"_1gtk_1tooltips_1disable",
+	"_1gtk_1tooltips_1enable",
+	"_1gtk_1tooltips_1force_1window",
+	"_1gtk_1tooltips_1new",
+	"_1gtk_1tooltips_1set_1tip",
+	"_1gtk_1tree_1model_1get__III_3II",
+	"_1gtk_1tree_1model_1get__III_3JI",
+	"_1gtk_1tree_1model_1get_1iter",
+	"_1gtk_1tree_1model_1get_1iter_1first",
+	"_1gtk_1tree_1model_1get_1n_1columns",
+	"_1gtk_1tree_1model_1get_1path",
+	"_1gtk_1tree_1model_1get_1type",
+	"_1gtk_1tree_1model_1iter_1children",
+	"_1gtk_1tree_1model_1iter_1n_1children",
+	"_1gtk_1tree_1model_1iter_1next",
+	"_1gtk_1tree_1model_1iter_1nth_1child",
+	"_1gtk_1tree_1path_1append_1index",
+	"_1gtk_1tree_1path_1compare",
+	"_1gtk_1tree_1path_1down",
+	"_1gtk_1tree_1path_1free",
+	"_1gtk_1tree_1path_1get_1depth",
+	"_1gtk_1tree_1path_1get_1indices",
+	"_1gtk_1tree_1path_1new",
+	"_1gtk_1tree_1path_1new_1first",
+	"_1gtk_1tree_1path_1new_1from_1string__I",
+	"_1gtk_1tree_1path_1new_1from_1string___3B",
+	"_1gtk_1tree_1path_1next",
+	"_1gtk_1tree_1path_1prev",
+	"_1gtk_1tree_1path_1up",
+	"_1gtk_1tree_1selection_1count_1selected_1rows",
+	"_1gtk_1tree_1selection_1get_1selected",
+	"_1gtk_1tree_1selection_1get_1selected_1rows",
+	"_1gtk_1tree_1selection_1path_1is_1selected",
+	"_1gtk_1tree_1selection_1select_1all",
+	"_1gtk_1tree_1selection_1select_1iter",
+	"_1gtk_1tree_1selection_1selected_1foreach",
+	"_1gtk_1tree_1selection_1set_1mode",
+	"_1gtk_1tree_1selection_1unselect_1all",
+	"_1gtk_1tree_1selection_1unselect_1iter",
+	"_1gtk_1tree_1store_1append",
+	"_1gtk_1tree_1store_1clear",
+	"_1gtk_1tree_1store_1insert",
+	"_1gtk_1tree_1store_1newv",
+	"_1gtk_1tree_1store_1remove",
+	"_1gtk_1tree_1store_1set__IIIII",
+	"_1gtk_1tree_1store_1set__IIIJI",
+	"_1gtk_1tree_1store_1set__IIILorg_eclipse_swt_internal_gtk_GdkColor_2I",
+	"_1gtk_1tree_1store_1set__IIIZI",
+	"_1gtk_1tree_1store_1set__III_3BI",
+	"_1gtk_1tree_1view_1collapse_1row",
+	"_1gtk_1tree_1view_1column_1add_1attribute",
+	"_1gtk_1tree_1view_1column_1cell_1get_1position",
+	"_1gtk_1tree_1view_1column_1cell_1get_1size",
+	"_1gtk_1tree_1view_1column_1cell_1set_1cell_1data",
+	"_1gtk_1tree_1view_1column_1clear",
+	"_1gtk_1tree_1view_1column_1get_1cell_1renderers",
+	"_1gtk_1tree_1view_1column_1get_1fixed_1width",
+	"_1gtk_1tree_1view_1column_1get_1reorderable",
+	"_1gtk_1tree_1view_1column_1get_1resizable",
+	"_1gtk_1tree_1view_1column_1get_1sizing",
+	"_1gtk_1tree_1view_1column_1get_1sort_1indicator",
+	"_1gtk_1tree_1view_1column_1get_1sort_1order",
+	"_1gtk_1tree_1view_1column_1get_1spacing",
+	"_1gtk_1tree_1view_1column_1get_1visible",
+	"_1gtk_1tree_1view_1column_1get_1width",
+	"_1gtk_1tree_1view_1column_1new",
+	"_1gtk_1tree_1view_1column_1pack_1end",
+	"_1gtk_1tree_1view_1column_1pack_1start",
+	"_1gtk_1tree_1view_1column_1set_1alignment",
+	"_1gtk_1tree_1view_1column_1set_1cell_1data_1func",
+	"_1gtk_1tree_1view_1column_1set_1clickable",
+	"_1gtk_1tree_1view_1column_1set_1fixed_1width",
+	"_1gtk_1tree_1view_1column_1set_1min_1width",
+	"_1gtk_1tree_1view_1column_1set_1reorderable",
+	"_1gtk_1tree_1view_1column_1set_1resizable",
+	"_1gtk_1tree_1view_1column_1set_1sizing",
+	"_1gtk_1tree_1view_1column_1set_1sort_1indicator",
+	"_1gtk_1tree_1view_1column_1set_1sort_1order",
+	"_1gtk_1tree_1view_1column_1set_1title",
+	"_1gtk_1tree_1view_1column_1set_1visible",
+	"_1gtk_1tree_1view_1column_1set_1widget",
+	"_1gtk_1tree_1view_1create_1row_1drag_1icon",
+	"_1gtk_1tree_1view_1expand_1row",
+	"_1gtk_1tree_1view_1get_1background_1area",
+	"_1gtk_1tree_1view_1get_1bin_1window",
+	"_1gtk_1tree_1view_1get_1cell_1area",
+	"_1gtk_1tree_1view_1get_1column",
+	"_1gtk_1tree_1view_1get_1columns",
+	"_1gtk_1tree_1view_1get_1cursor",
+	"_1gtk_1tree_1view_1get_1expander_1column",
+	"_1gtk_1tree_1view_1get_1headers_1visible",
+	"_1gtk_1tree_1view_1get_1path_1at_1pos",
+	"_1gtk_1tree_1view_1get_1rules_1hint",
+	"_1gtk_1tree_1view_1get_1selection",
+	"_1gtk_1tree_1view_1get_1visible_1rect",
+	"_1gtk_1tree_1view_1insert_1column",
+	"_1gtk_1tree_1view_1move_1column_1after",
+	"_1gtk_1tree_1view_1new_1with_1model",
+	"_1gtk_1tree_1view_1remove_1column",
+	"_1gtk_1tree_1view_1row_1expanded",
+	"_1gtk_1tree_1view_1scroll_1to_1cell",
+	"_1gtk_1tree_1view_1scroll_1to_1point",
+	"_1gtk_1tree_1view_1set_1cursor",
+	"_1gtk_1tree_1view_1set_1drag_1dest_1row",
+	"_1gtk_1tree_1view_1set_1enable_1search",
+	"_1gtk_1tree_1view_1set_1headers_1visible",
+	"_1gtk_1tree_1view_1set_1model",
+	"_1gtk_1tree_1view_1set_1rules_1hint",
+	"_1gtk_1tree_1view_1set_1search_1column",
+	"_1gtk_1tree_1view_1tree_1to_1widget_1coords",
+	"_1gtk_1tree_1view_1unset_1rows_1drag_1dest",
+	"_1gtk_1tree_1view_1widget_1to_1tree_1coords",
+	"_1gtk_1vbox_1new",
+	"_1gtk_1vscale_1new",
+	"_1gtk_1vscrollbar_1new",
+	"_1gtk_1vseparator_1new",
+	"_1gtk_1widget_1add_1accelerator",
+	"_1gtk_1widget_1add_1events",
+	"_1gtk_1widget_1child_1focus",
+	"_1gtk_1widget_1create_1pango_1layout__II",
+	"_1gtk_1widget_1create_1pango_1layout__I_3B",
+	"_1gtk_1widget_1destroy",
+	"_1gtk_1widget_1event",
+	"_1gtk_1widget_1get_1accessible",
+	"_1gtk_1widget_1get_1child_1visible",
+	"_1gtk_1widget_1get_1default_1direction",
+	"_1gtk_1widget_1get_1default_1style",
+	"_1gtk_1widget_1get_1direction",
+	"_1gtk_1widget_1get_1events",
+	"_1gtk_1widget_1get_1modifier_1style",
+	"_1gtk_1widget_1get_1pango_1context",
+	"_1gtk_1widget_1get_1parent",
+	"_1gtk_1widget_1get_1size_1request",
+	"_1gtk_1widget_1get_1style",
+	"_1gtk_1widget_1get_1toplevel",
+	"_1gtk_1widget_1grab_1focus",
+	"_1gtk_1widget_1hide",
+	"_1gtk_1widget_1is_1composited",
+	"_1gtk_1widget_1is_1focus",
+	"_1gtk_1widget_1map",
+	"_1gtk_1widget_1mnemonic_1activate",
+	"_1gtk_1widget_1modify_1base",
+	"_1gtk_1widget_1modify_1bg",
+	"_1gtk_1widget_1modify_1fg",
+	"_1gtk_1widget_1modify_1font",
+	"_1gtk_1widget_1modify_1style",
+	"_1gtk_1widget_1modify_1text",
+	"_1gtk_1widget_1queue_1resize",
+	"_1gtk_1widget_1realize",
+	"_1gtk_1widget_1remove_1accelerator",
+	"_1gtk_1widget_1reparent",
+	"_1gtk_1widget_1send_1expose",
+	"_1gtk_1widget_1set_1app_1paintable",
+	"_1gtk_1widget_1set_1default_1direction",
+	"_1gtk_1widget_1set_1direction",
+	"_1gtk_1widget_1set_1double_1buffered",
+	"_1gtk_1widget_1set_1name",
+	"_1gtk_1widget_1set_1parent_1window",
+	"_1gtk_1widget_1set_1redraw_1on_1allocate",
+	"_1gtk_1widget_1set_1sensitive",
+	"_1gtk_1widget_1set_1size_1request",
+	"_1gtk_1widget_1set_1state",
+	"_1gtk_1widget_1set_1style",
+	"_1gtk_1widget_1set_1tooltip_1text",
+	"_1gtk_1widget_1shape_1combine_1mask",
+	"_1gtk_1widget_1show",
+	"_1gtk_1widget_1show_1now",
+	"_1gtk_1widget_1size_1allocate",
+	"_1gtk_1widget_1size_1request",
+	"_1gtk_1widget_1style_1get__I_3B_3II",
+	"_1gtk_1widget_1style_1get__I_3B_3JI",
+	"_1gtk_1widget_1translate_1coordinates",
+	"_1gtk_1widget_1unrealize",
+	"_1gtk_1window_1activate_1default",
+	"_1gtk_1window_1add_1accel_1group",
+	"_1gtk_1window_1deiconify",
+	"_1gtk_1window_1fullscreen",
+	"_1gtk_1window_1get_1focus",
+	"_1gtk_1window_1get_1group",
+	"_1gtk_1window_1get_1icon_1list",
+	"_1gtk_1window_1get_1mnemonic_1modifier",
+	"_1gtk_1window_1get_1modal",
+	"_1gtk_1window_1get_1opacity",
+	"_1gtk_1window_1get_1position",
+	"_1gtk_1window_1get_1size",
+	"_1gtk_1window_1group_1add_1window",
+	"_1gtk_1window_1group_1new",
+	"_1gtk_1window_1group_1remove_1window",
+	"_1gtk_1window_1iconify",
+	"_1gtk_1window_1list_1toplevels",
+	"_1gtk_1window_1maximize",
+	"_1gtk_1window_1move",
+	"_1gtk_1window_1new",
+	"_1gtk_1window_1present",
+	"_1gtk_1window_1remove_1accel_1group",
+	"_1gtk_1window_1resize",
+	"_1gtk_1window_1set_1default",
+	"_1gtk_1window_1set_1destroy_1with_1parent",
+	"_1gtk_1window_1set_1geometry_1hints",
+	"_1gtk_1window_1set_1icon_1list",
+	"_1gtk_1window_1set_1keep_1below",
+	"_1gtk_1window_1set_1modal",
+	"_1gtk_1window_1set_1opacity",
+	"_1gtk_1window_1set_1resizable",
+	"_1gtk_1window_1set_1skip_1taskbar_1hint",
+	"_1gtk_1window_1set_1title",
+	"_1gtk_1window_1set_1transient_1for",
+	"_1gtk_1window_1set_1type_1hint",
+	"_1gtk_1window_1unfullscreen",
+	"_1gtk_1window_1unmaximize",
+	"_1pango_1attr_1background_1new",
+	"_1pango_1attr_1font_1desc_1new",
+	"_1pango_1attr_1foreground_1new",
+	"_1pango_1attr_1iterator_1destroy",
+	"_1pango_1attr_1iterator_1get",
+	"_1pango_1attr_1iterator_1get_1attrs",
+	"_1pango_1attr_1iterator_1next",
+	"_1pango_1attr_1iterator_1range",
+	"_1pango_1attr_1list_1change",
+	"_1pango_1attr_1list_1get_1iterator",
+	"_1pango_1attr_1list_1insert",
+	"_1pango_1attr_1list_1new",
+	"_1pango_1attr_1list_1unref",
+	"_1pango_1attr_1rise_1new",
+	"_1pango_1attr_1shape_1new",
+	"_1pango_1attr_1strikethrough_1color_1new",
+	"_1pango_1attr_1strikethrough_1new",
+	"_1pango_1attr_1underline_1color_1new",
+	"_1pango_1attr_1underline_1new",
+	"_1pango_1attr_1weight_1new",
+	"_1pango_1cairo_1context_1get_1font_1options",
+	"_1pango_1cairo_1context_1set_1font_1options",
+	"_1pango_1cairo_1create_1layout",
+	"_1pango_1cairo_1font_1map_1create_1context",
+	"_1pango_1cairo_1font_1map_1get_1default",
+	"_1pango_1cairo_1font_1map_1new",
+	"_1pango_1cairo_1font_1map_1set_1resolution",
+	"_1pango_1cairo_1layout_1path",
+	"_1pango_1cairo_1show_1layout",
+	"_1pango_1context_1get_1base_1dir",
+	"_1pango_1context_1get_1language",
+	"_1pango_1context_1get_1metrics",
+	"_1pango_1context_1list_1families",
+	"_1pango_1context_1set_1base_1dir",
+	"_1pango_1context_1set_1language",
+	"_1pango_1font_1description_1copy",
+	"_1pango_1font_1description_1free",
+	"_1pango_1font_1description_1from_1string",
+	"_1pango_1font_1description_1get_1family",
+	"_1pango_1font_1description_1get_1size",
+	"_1pango_1font_1description_1get_1style",
+	"_1pango_1font_1description_1get_1weight",
+	"_1pango_1font_1description_1new",
+	"_1pango_1font_1description_1set_1family",
+	"_1pango_1font_1description_1set_1size",
+	"_1pango_1font_1description_1set_1stretch",
+	"_1pango_1font_1description_1set_1style",
+	"_1pango_1font_1description_1set_1weight",
+	"_1pango_1font_1description_1to_1string",
+	"_1pango_1font_1face_1describe",
+	"_1pango_1font_1family_1get_1name",
+	"_1pango_1font_1family_1list_1faces",
+	"_1pango_1font_1get_1metrics",
+	"_1pango_1font_1metrics_1get_1approximate_1char_1width",
+	"_1pango_1font_1metrics_1get_1ascent",
+	"_1pango_1font_1metrics_1get_1descent",
+	"_1pango_1font_1metrics_1get_1strikethrough_1position",
+	"_1pango_1font_1metrics_1get_1strikethrough_1thickness",
+	"_1pango_1font_1metrics_1get_1underline_1position",
+	"_1pango_1font_1metrics_1get_1underline_1thickness",
+	"_1pango_1font_1metrics_1unref",
+	"_1pango_1language_1from_1string",
+	"_1pango_1layout_1context_1changed",
+	"_1pango_1layout_1get_1alignment",
+	"_1pango_1layout_1get_1attributes",
+	"_1pango_1layout_1get_1context",
+	"_1pango_1layout_1get_1indent",
+	"_1pango_1layout_1get_1iter",
+	"_1pango_1layout_1get_1justify",
+	"_1pango_1layout_1get_1line",
+	"_1pango_1layout_1get_1line_1count",
+	"_1pango_1layout_1get_1log_1attrs",
+	"_1pango_1layout_1get_1size",
+	"_1pango_1layout_1get_1spacing",
+	"_1pango_1layout_1get_1tabs",
+	"_1pango_1layout_1get_1text",
+	"_1pango_1layout_1get_1width",
+	"_1pango_1layout_1index_1to_1pos",
+	"_1pango_1layout_1iter_1free",
+	"_1pango_1layout_1iter_1get_1index",
+	"_1pango_1layout_1iter_1get_1line_1extents",
+	"_1pango_1layout_1iter_1get_1run",
+	"_1pango_1layout_1iter_1next_1line",
+	"_1pango_1layout_1iter_1next_1run",
+	"_1pango_1layout_1line_1get_1extents",
+	"_1pango_1layout_1line_1get_1resolved_1dir",
+	"_1pango_1layout_1line_1x_1to_1index",
+	"_1pango_1layout_1new",
+	"_1pango_1layout_1set_1alignment",
+	"_1pango_1layout_1set_1attributes",
+	"_1pango_1layout_1set_1auto_1dir",
+	"_1pango_1layout_1set_1font_1description",
+	"_1pango_1layout_1set_1indent",
+	"_1pango_1layout_1set_1justify",
+	"_1pango_1layout_1set_1single_1paragraph_1mode",
+	"_1pango_1layout_1set_1spacing",
+	"_1pango_1layout_1set_1tabs",
+	"_1pango_1layout_1set_1text",
+	"_1pango_1layout_1set_1width",
+	"_1pango_1layout_1set_1wrap",
+	"_1pango_1layout_1xy_1to_1index",
+	"_1pango_1tab_1array_1free",
+	"_1pango_1tab_1array_1get_1size",
+	"_1pango_1tab_1array_1get_1tabs",
+	"_1pango_1tab_1array_1new",
+	"_1pango_1tab_1array_1set_1tab",
+	"g_1main_1context_1wakeup",
+	"localeconv_1decimal_1point",
+	"memmove__ILorg_eclipse_swt_internal_gtk_GInterfaceInfo_2I",
+	"memmove__ILorg_eclipse_swt_internal_gtk_GObjectClass_2",
+	"memmove__ILorg_eclipse_swt_internal_gtk_GTypeInfo_2I",
+	"memmove__ILorg_eclipse_swt_internal_gtk_GdkEventButton_2I",
+	"memmove__ILorg_eclipse_swt_internal_gtk_GdkEventExpose_2I",
+	"memmove__ILorg_eclipse_swt_internal_gtk_GdkEventMotion_2I",
+	"memmove__ILorg_eclipse_swt_internal_gtk_GtkAdjustment_2",
+	"memmove__ILorg_eclipse_swt_internal_gtk_GtkCellRendererClass_2",
+	"memmove__ILorg_eclipse_swt_internal_gtk_GtkFixed_2",
+	"memmove__ILorg_eclipse_swt_internal_gtk_GtkTargetEntry_2I",
+	"memmove__ILorg_eclipse_swt_internal_gtk_GtkWidgetClass_2",
+	"memmove__ILorg_eclipse_swt_internal_gtk_PangoAttribute_2I",
+	"memmove__ILorg_eclipse_swt_internal_gtk_XButtonEvent_2I",
+	"memmove__ILorg_eclipse_swt_internal_gtk_XClientMessageEvent_2I",
+	"memmove__ILorg_eclipse_swt_internal_gtk_XCrossingEvent_2I",
+	"memmove__ILorg_eclipse_swt_internal_gtk_XExposeEvent_2I",
+	"memmove__ILorg_eclipse_swt_internal_gtk_XFocusChangeEvent_2I",
+	"memmove__Lorg_eclipse_swt_internal_gtk_GObjectClass_2I",
+	"memmove__Lorg_eclipse_swt_internal_gtk_GTypeQuery_2II",
+	"memmove__Lorg_eclipse_swt_internal_gtk_GdkColor_2II",
+	"memmove__Lorg_eclipse_swt_internal_gtk_GdkDragContext_2II",
+	"memmove__Lorg_eclipse_swt_internal_gtk_GdkEventAny_2II",
+	"memmove__Lorg_eclipse_swt_internal_gtk_GdkEventButton_2II",
+	"memmove__Lorg_eclipse_swt_internal_gtk_GdkEventCrossing_2II",
+	"memmove__Lorg_eclipse_swt_internal_gtk_GdkEventExpose_2II",
+	"memmove__Lorg_eclipse_swt_internal_gtk_GdkEventFocus_2II",
+	"memmove__Lorg_eclipse_swt_internal_gtk_GdkEventKey_2II",
+	"memmove__Lorg_eclipse_swt_internal_gtk_GdkEventMotion_2II",
+	"memmove__Lorg_eclipse_swt_internal_gtk_GdkEventScroll_2II",
+	"memmove__Lorg_eclipse_swt_internal_gtk_GdkEventVisibility_2II",
+	"memmove__Lorg_eclipse_swt_internal_gtk_GdkEventWindowState_2II",
+	"memmove__Lorg_eclipse_swt_internal_gtk_GdkEvent_2II",
+	"memmove__Lorg_eclipse_swt_internal_gtk_GdkImage_2I",
+	"memmove__Lorg_eclipse_swt_internal_gtk_GdkRectangle_2II",
+	"memmove__Lorg_eclipse_swt_internal_gtk_GdkVisual_2I",
+	"memmove__Lorg_eclipse_swt_internal_gtk_GtkAdjustment_2I",
+	"memmove__Lorg_eclipse_swt_internal_gtk_GtkBorder_2II",
+	"memmove__Lorg_eclipse_swt_internal_gtk_GtkCellRendererClass_2I",
+	"memmove__Lorg_eclipse_swt_internal_gtk_GtkColorSelectionDialog_2I",
+	"memmove__Lorg_eclipse_swt_internal_gtk_GtkCombo_2I",
+	"memmove__Lorg_eclipse_swt_internal_gtk_GtkFileSelection_2I",
+	"memmove__Lorg_eclipse_swt_internal_gtk_GtkFixed_2I",
+	"memmove__Lorg_eclipse_swt_internal_gtk_GtkSelectionData_2II",
+	"memmove__Lorg_eclipse_swt_internal_gtk_GtkTargetPair_2II",
+	"memmove__Lorg_eclipse_swt_internal_gtk_GtkWidgetClass_2I",
+	"memmove__Lorg_eclipse_swt_internal_gtk_PangoAttrColor_2II",
+	"memmove__Lorg_eclipse_swt_internal_gtk_PangoAttrInt_2II",
+	"memmove__Lorg_eclipse_swt_internal_gtk_PangoAttribute_2II",
+	"memmove__Lorg_eclipse_swt_internal_gtk_PangoItem_2II",
+	"memmove__Lorg_eclipse_swt_internal_gtk_PangoLayoutLine_2II",
+	"memmove__Lorg_eclipse_swt_internal_gtk_PangoLayoutRun_2II",
+	"memmove__Lorg_eclipse_swt_internal_gtk_PangoLogAttr_2II",
+	"memmove__Lorg_eclipse_swt_internal_gtk_XButtonEvent_2II",
+	"memmove__Lorg_eclipse_swt_internal_gtk_XCrossingEvent_2II",
+	"memmove__Lorg_eclipse_swt_internal_gtk_XExposeEvent_2II",
+	"memmove__Lorg_eclipse_swt_internal_gtk_XFocusChangeEvent_2II",
+	"memmove__Lorg_eclipse_swt_internal_gtk_XVisibilityEvent_2II",
+	"realpath",
+};
+
+#define STATS_NATIVE(func) Java_org_eclipse_swt_tools_internal_NativeStats_##func
+
+JNIEXPORT jint JNICALL STATS_NATIVE(OS_1GetFunctionCount)
+	(JNIEnv *env, jclass that)
+{
+	return OS_nativeFunctionCount;
+}
+
+JNIEXPORT jstring JNICALL STATS_NATIVE(OS_1GetFunctionName)
+	(JNIEnv *env, jclass that, jint index)
+{
+	return (*env)->NewStringUTF(env, OS_nativeFunctionNames[index]);
+}
+
+JNIEXPORT jint JNICALL STATS_NATIVE(OS_1GetFunctionCallCount)
+	(JNIEnv *env, jclass that, jint index)
+{
+	return OS_nativeFunctionCallCount[index];
+}
+
+#endif

Added: branches/upstream/swt-gtk/current/os_stats.h
===================================================================
--- branches/upstream/swt-gtk/current/os_stats.h	                        (rev 0)
+++ branches/upstream/swt-gtk/current/os_stats.h	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,1298 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others. All rights reserved.
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt).  The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html.  If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+#ifdef NATIVE_STATS
+extern int OS_nativeFunctionCount;
+extern int OS_nativeFunctionCallCount[];
+extern char* OS_nativeFunctionNames[];
+#define OS_NATIVE_ENTER(env, that, func) OS_nativeFunctionCallCount[func]++;
+#define OS_NATIVE_EXIT(env, that, func) 
+#else
+#ifndef OS_NATIVE_ENTER
+#define OS_NATIVE_ENTER(env, that, func) 
+#endif
+#ifndef OS_NATIVE_EXIT
+#define OS_NATIVE_EXIT(env, that, func) 
+#endif
+#endif
+
+typedef enum {
+	Call_FUNC,
+	GDK_1EVENT_1TYPE_FUNC,
+	GDK_1EVENT_1WINDOW_FUNC,
+	GDK_1WINDOWING_1X11_FUNC,
+	GInterfaceInfo_1sizeof_FUNC,
+	GPollFD_1sizeof_FUNC,
+	GTK_1ACCEL_1LABEL_1GET_1ACCEL_1STRING_FUNC,
+	GTK_1ACCEL_1LABEL_1SET_1ACCEL_1STRING_FUNC,
+	GTK_1ENTRY_1IM_1CONTEXT_FUNC,
+	GTK_1SCROLLED_1WINDOW_1HSCROLLBAR_FUNC,
+	GTK_1SCROLLED_1WINDOW_1SCROLLBAR_1SPACING_FUNC,
+	GTK_1SCROLLED_1WINDOW_1VSCROLLBAR_FUNC,
+	GTK_1TEXTVIEW_1IM_1CONTEXT_FUNC,
+	GTK_1TOOLTIPS_1SET_1ACTIVE_FUNC,
+	GTK_1TOOLTIPS_1TIP_1WINDOW_FUNC,
+	GTK_1WIDGET_1HEIGHT_FUNC,
+	GTK_1WIDGET_1REQUISITION_1HEIGHT_FUNC,
+	GTK_1WIDGET_1REQUISITION_1WIDTH_FUNC,
+	GTK_1WIDGET_1SET_1HEIGHT_FUNC,
+	GTK_1WIDGET_1SET_1WIDTH_FUNC,
+	GTK_1WIDGET_1SET_1X_FUNC,
+	GTK_1WIDGET_1SET_1Y_FUNC,
+	GTK_1WIDGET_1WIDTH_FUNC,
+	GTK_1WIDGET_1WINDOW_FUNC,
+	GTK_1WIDGET_1X_FUNC,
+	GTK_1WIDGET_1Y_FUNC,
+	GTypeInfo_1sizeof_FUNC,
+	GTypeQuery_1sizeof_FUNC,
+	GdkColor_1sizeof_FUNC,
+	GdkDragContext_1sizeof_FUNC,
+	GdkEventAny_1sizeof_FUNC,
+	GdkEventButton_1sizeof_FUNC,
+	GdkEventCrossing_1sizeof_FUNC,
+	GdkEventExpose_1sizeof_FUNC,
+	GdkEventFocus_1sizeof_FUNC,
+	GdkEventKey_1sizeof_FUNC,
+	GdkEventMotion_1sizeof_FUNC,
+	GdkEventScroll_1sizeof_FUNC,
+	GdkEventVisibility_1sizeof_FUNC,
+	GdkEventWindowState_1sizeof_FUNC,
+	GdkEvent_1sizeof_FUNC,
+	GdkGCValues_1sizeof_FUNC,
+	GdkGeometry_1sizeof_FUNC,
+	GdkImage_1sizeof_FUNC,
+	GdkRectangle_1sizeof_FUNC,
+	GdkVisual_1sizeof_FUNC,
+	GdkWindowAttr_1sizeof_FUNC,
+	GtkAdjustment_1sizeof_FUNC,
+	GtkAllocation_1sizeof_FUNC,
+	GtkBorder_1sizeof_FUNC,
+	GtkCellRendererPixbufClass_1sizeof_FUNC,
+	GtkCellRendererPixbuf_1sizeof_FUNC,
+	GtkCellRendererTextClass_1sizeof_FUNC,
+	GtkCellRendererText_1sizeof_FUNC,
+	GtkCellRendererToggleClass_1sizeof_FUNC,
+	GtkCellRendererToggle_1sizeof_FUNC,
+	GtkColorSelectionDialog_1sizeof_FUNC,
+	GtkCombo_1sizeof_FUNC,
+	GtkFileSelection_1sizeof_FUNC,
+	GtkFixedClass_1sizeof_FUNC,
+	GtkFixed_1sizeof_FUNC,
+	GtkRequisition_1sizeof_FUNC,
+	GtkSelectionData_1sizeof_FUNC,
+	GtkTargetEntry_1sizeof_FUNC,
+	GtkTargetPair_1sizeof_FUNC,
+	GtkTextIter_1sizeof_FUNC,
+	GtkTreeIter_1sizeof_FUNC,
+	PangoAttrColor_1sizeof_FUNC,
+	PangoAttrInt_1sizeof_FUNC,
+	PangoAttribute_1sizeof_FUNC,
+	PangoItem_1sizeof_FUNC,
+	PangoLayoutLine_1sizeof_FUNC,
+	PangoLayoutRun_1sizeof_FUNC,
+	PangoLogAttr_1sizeof_FUNC,
+	PangoRectangle_1sizeof_FUNC,
+	XAnyEvent_1sizeof_FUNC,
+	XButtonEvent_1sizeof_FUNC,
+	XClientMessageEvent_1sizeof_FUNC,
+	XCrossingEvent_1sizeof_FUNC,
+	XEvent_1sizeof_FUNC,
+	XExposeEvent_1sizeof_FUNC,
+	XFocusChangeEvent_1sizeof_FUNC,
+	XRenderPictureAttributes_1sizeof_FUNC,
+	XVisibilityEvent_1sizeof_FUNC,
+	XWindowChanges_1sizeof_FUNC,
+	X_1EVENT_1TYPE_FUNC,
+	X_1EVENT_1WINDOW_FUNC,
+	_1Call_FUNC,
+	_1FcConfigAppFontAddFile_FUNC,
+	_1GDK_1DISPLAY_FUNC,
+	_1GDK_1PIXMAP_1XID_FUNC,
+	_1GDK_1ROOT_1PARENT_FUNC,
+	_1GDK_1TYPE_1COLOR_FUNC,
+	_1GDK_1TYPE_1PIXBUF_FUNC,
+	_1GTK_1IS_1BUTTON_FUNC,
+	_1GTK_1IS_1CELL_1RENDERER_1PIXBUF_FUNC,
+	_1GTK_1IS_1CELL_1RENDERER_1TEXT_FUNC,
+	_1GTK_1IS_1CELL_1RENDERER_1TOGGLE_FUNC,
+	_1GTK_1IS_1CONTAINER_FUNC,
+	_1GTK_1IS_1IMAGE_1MENU_1ITEM_FUNC,
+	_1GTK_1IS_1MENU_1ITEM_FUNC,
+	_1GTK_1IS_1PLUG_FUNC,
+	_1GTK_1IS_1WINDOW_FUNC,
+	_1GTK_1STOCK_1CANCEL_FUNC,
+	_1GTK_1STOCK_1OK_FUNC,
+	_1GTK_1TYPE_1CELL_1RENDERER_1PIXBUF_FUNC,
+	_1GTK_1TYPE_1CELL_1RENDERER_1TEXT_FUNC,
+	_1GTK_1TYPE_1CELL_1RENDERER_1TOGGLE_FUNC,
+	_1GTK_1TYPE_1FIXED_FUNC,
+	_1GTK_1TYPE_1MENU_FUNC,
+	_1GTK_1TYPE_1WIDGET_FUNC,
+	_1GTK_1WIDGET_1FLAGS_FUNC,
+	_1GTK_1WIDGET_1HAS_1DEFAULT_FUNC,
+	_1GTK_1WIDGET_1HAS_1FOCUS_FUNC,
+	_1GTK_1WIDGET_1IS_1SENSITIVE_FUNC,
+	_1GTK_1WIDGET_1MAPPED_FUNC,
+	_1GTK_1WIDGET_1SENSITIVE_FUNC,
+	_1GTK_1WIDGET_1SET_1FLAGS_FUNC,
+	_1GTK_1WIDGET_1STATE_FUNC,
+	_1GTK_1WIDGET_1UNSET_1FLAGS_FUNC,
+	_1GTK_1WIDGET_1VISIBLE_FUNC,
+	_1G_1OBJECT_1CLASS_FUNC,
+	_1G_1OBJECT_1GET_1CLASS_FUNC,
+	_1G_1OBJECT_1TYPE_FUNC,
+	_1G_1OBJECT_1TYPE_1NAME_FUNC,
+	_1G_1TYPE_1BOOLEAN_FUNC,
+	_1G_1TYPE_1INT_FUNC,
+	_1G_1TYPE_1STRING_FUNC,
+	_1PANGO_1PIXELS_FUNC,
+	_1PANGO_1TYPE_1FONT_1DESCRIPTION_FUNC,
+	_1XCheckIfEvent_FUNC,
+	_1XCheckMaskEvent_FUNC,
+	_1XCheckWindowEvent_FUNC,
+	_1XDefaultRootWindow_FUNC,
+	_1XDefaultScreen_FUNC,
+	_1XFlush_FUNC,
+	_1XFree_FUNC,
+	_1XGetSelectionOwner_FUNC,
+	_1XInternAtom_FUNC,
+	_1XKeysymToKeycode_FUNC,
+	_1XListProperties_FUNC,
+	_1XQueryPointer_FUNC,
+	_1XQueryTree_FUNC,
+	_1XReconfigureWMWindow_FUNC,
+	_1XRenderComposite_FUNC,
+	_1XRenderCreatePicture_FUNC,
+	_1XRenderFindStandardFormat_FUNC,
+	_1XRenderFindVisualFormat_FUNC,
+	_1XRenderFreePicture_FUNC,
+	_1XRenderQueryExtension_FUNC,
+	_1XRenderQueryVersion_FUNC,
+	_1XRenderSetPictureClipRectangles_FUNC,
+	_1XRenderSetPictureTransform_FUNC,
+	_1XSendEvent_FUNC,
+	_1XSetErrorHandler_FUNC,
+	_1XSetIOErrorHandler_FUNC,
+	_1XSetInputFocus_FUNC,
+	_1XSetTransientForHint_FUNC,
+	_1XSynchronize_FUNC,
+	_1XTestFakeButtonEvent_FUNC,
+	_1XTestFakeKeyEvent_FUNC,
+	_1XTestFakeMotionEvent_FUNC,
+	_1XWarpPointer_FUNC,
+	_1atk_1object_1add_1relationship_FUNC,
+	_1call_FUNC,
+	_1dlclose_FUNC,
+	_1dlopen_FUNC,
+	_1dlsym_FUNC,
+	_1g_1cclosure_1new_FUNC,
+	_1g_1closure_1ref_FUNC,
+	_1g_1closure_1unref_FUNC,
+	_1g_1filename_1from_1uri_FUNC,
+	_1g_1filename_1from_1utf8_FUNC,
+	_1g_1filename_1to_1uri_FUNC,
+	_1g_1filename_1to_1utf8_FUNC,
+	_1g_1free_FUNC,
+	_1g_1idle_1add_FUNC,
+	_1g_1list_1append_FUNC,
+	_1g_1list_1data_FUNC,
+	_1g_1list_1free_FUNC,
+	_1g_1list_1free_11_FUNC,
+	_1g_1list_1length_FUNC,
+	_1g_1list_1next_FUNC,
+	_1g_1list_1nth_FUNC,
+	_1g_1list_1nth_1data_FUNC,
+	_1g_1list_1prepend_FUNC,
+	_1g_1list_1previous_FUNC,
+	_1g_1list_1remove_1link_FUNC,
+	_1g_1list_1reverse_FUNC,
+	_1g_1list_1set_1next_FUNC,
+	_1g_1list_1set_1previous_FUNC,
+	_1g_1locale_1from_1utf8_FUNC,
+	_1g_1locale_1to_1utf8_FUNC,
+	_1g_1log_1default_1handler_FUNC,
+	_1g_1log_1remove_1handler_FUNC,
+	_1g_1log_1set_1handler_FUNC,
+	_1g_1main_1context_1acquire_FUNC,
+	_1g_1main_1context_1check_FUNC,
+	_1g_1main_1context_1default_FUNC,
+	_1g_1main_1context_1get_1poll_1func_FUNC,
+	_1g_1main_1context_1iteration_FUNC,
+	_1g_1main_1context_1pending_FUNC,
+	_1g_1main_1context_1prepare_FUNC,
+	_1g_1main_1context_1query_FUNC,
+	_1g_1main_1context_1release_FUNC,
+	_1g_1malloc_FUNC,
+	_1g_1object_1get_FUNC,
+	_1g_1object_1get_1qdata_FUNC,
+	_1g_1object_1new_FUNC,
+	_1g_1object_1ref_FUNC,
+	_1g_1object_1set__I_3BFI_FUNC,
+	_1g_1object_1set__I_3BII_FUNC,
+	_1g_1object_1set__I_3BJI_FUNC,
+	_1g_1object_1set__I_3BLorg_eclipse_swt_internal_gtk_GdkColor_2I_FUNC,
+	_1g_1object_1set__I_3BZI_FUNC,
+	_1g_1object_1set_1qdata_FUNC,
+	_1g_1object_1unref_FUNC,
+	_1g_1quark_1from_1string_FUNC,
+	_1g_1set_1prgname_FUNC,
+	_1g_1signal_1add_1emission_1hook_FUNC,
+	_1g_1signal_1connect_FUNC,
+	_1g_1signal_1connect_1after_FUNC,
+	_1g_1signal_1connect_1closure_FUNC,
+	_1g_1signal_1connect_1closure_1by_1id_FUNC,
+	_1g_1signal_1emit_1by_1name__I_3B_FUNC,
+	_1g_1signal_1emit_1by_1name__I_3BI_FUNC,
+	_1g_1signal_1emit_1by_1name__I_3BII_FUNC,
+	_1g_1signal_1emit_1by_1name__I_3B_3B_FUNC,
+	_1g_1signal_1handler_1disconnect_FUNC,
+	_1g_1signal_1handlers_1block_1matched_FUNC,
+	_1g_1signal_1handlers_1disconnect_1matched_FUNC,
+	_1g_1signal_1handlers_1unblock_1matched_FUNC,
+	_1g_1signal_1lookup_FUNC,
+	_1g_1signal_1remove_1emission_1hook_FUNC,
+	_1g_1signal_1stop_1emission_1by_1name_FUNC,
+	_1g_1slist_1data_FUNC,
+	_1g_1slist_1free_FUNC,
+	_1g_1slist_1length_FUNC,
+	_1g_1slist_1next_FUNC,
+	_1g_1source_1remove_FUNC,
+	_1g_1strfreev_FUNC,
+	_1g_1strtod_FUNC,
+	_1g_1thread_1init_FUNC,
+	_1g_1thread_1supported_FUNC,
+	_1g_1type_1add_1interface_1static_FUNC,
+	_1g_1type_1class_1peek_FUNC,
+	_1g_1type_1class_1peek_1parent_FUNC,
+	_1g_1type_1from_1name_FUNC,
+	_1g_1type_1interface_1peek_1parent_FUNC,
+	_1g_1type_1is_1a_FUNC,
+	_1g_1type_1name_FUNC,
+	_1g_1type_1parent_FUNC,
+	_1g_1type_1query_FUNC,
+	_1g_1type_1register_1static_FUNC,
+	_1g_1utf16_1to_1utf8_FUNC,
+	_1g_1utf8_1offset_1to_1pointer_FUNC,
+	_1g_1utf8_1pointer_1to_1offset_FUNC,
+	_1g_1utf8_1strlen_FUNC,
+	_1g_1utf8_1to_1utf16__II_3I_3I_3I_FUNC,
+	_1g_1utf8_1to_1utf16___3BI_3I_3I_3I_FUNC,
+	_1g_1value_1peek_1pointer_FUNC,
+	_1gdk_1atom_1intern_FUNC,
+	_1gdk_1atom_1name_FUNC,
+	_1gdk_1beep_FUNC,
+	_1gdk_1bitmap_1create_1from_1data_FUNC,
+	_1gdk_1cairo_1region_FUNC,
+	_1gdk_1cairo_1set_1source_1color_FUNC,
+	_1gdk_1color_1white_FUNC,
+	_1gdk_1colormap_1alloc_1color_FUNC,
+	_1gdk_1colormap_1free_1colors_FUNC,
+	_1gdk_1colormap_1get_1system_FUNC,
+	_1gdk_1colormap_1query_1color_FUNC,
+	_1gdk_1cursor_1destroy_FUNC,
+	_1gdk_1cursor_1new_FUNC,
+	_1gdk_1cursor_1new_1from_1pixbuf_FUNC,
+	_1gdk_1cursor_1new_1from_1pixmap_FUNC,
+	_1gdk_1display_1get_1default_FUNC,
+	_1gdk_1display_1supports_1cursor_1color_FUNC,
+	_1gdk_1drag_1status_FUNC,
+	_1gdk_1draw_1arc_FUNC,
+	_1gdk_1draw_1drawable_FUNC,
+	_1gdk_1draw_1image_FUNC,
+	_1gdk_1draw_1layout_FUNC,
+	_1gdk_1draw_1layout_1with_1colors_FUNC,
+	_1gdk_1draw_1line_FUNC,
+	_1gdk_1draw_1lines_FUNC,
+	_1gdk_1draw_1pixbuf_FUNC,
+	_1gdk_1draw_1point_FUNC,
+	_1gdk_1draw_1polygon_FUNC,
+	_1gdk_1draw_1rectangle_FUNC,
+	_1gdk_1drawable_1get_1depth_FUNC,
+	_1gdk_1drawable_1get_1image_FUNC,
+	_1gdk_1drawable_1get_1size_FUNC,
+	_1gdk_1drawable_1get_1visible_1region_FUNC,
+	_1gdk_1error_1trap_1pop_FUNC,
+	_1gdk_1error_1trap_1push_FUNC,
+	_1gdk_1event_1copy_FUNC,
+	_1gdk_1event_1free_FUNC,
+	_1gdk_1event_1get_FUNC,
+	_1gdk_1event_1get_1coords_FUNC,
+	_1gdk_1event_1get_1graphics_1expose_FUNC,
+	_1gdk_1event_1get_1root_1coords_FUNC,
+	_1gdk_1event_1get_1state_FUNC,
+	_1gdk_1event_1get_1time_FUNC,
+	_1gdk_1event_1handler_1set_FUNC,
+	_1gdk_1event_1new_FUNC,
+	_1gdk_1event_1peek_FUNC,
+	_1gdk_1event_1put_FUNC,
+	_1gdk_1flush_FUNC,
+	_1gdk_1free_1text_1list_FUNC,
+	_1gdk_1gc_1get_1values_FUNC,
+	_1gdk_1gc_1new_FUNC,
+	_1gdk_1gc_1set_1background_FUNC,
+	_1gdk_1gc_1set_1clip_1mask_FUNC,
+	_1gdk_1gc_1set_1clip_1origin_FUNC,
+	_1gdk_1gc_1set_1clip_1rectangle_FUNC,
+	_1gdk_1gc_1set_1clip_1region_FUNC,
+	_1gdk_1gc_1set_1dashes_FUNC,
+	_1gdk_1gc_1set_1exposures_FUNC,
+	_1gdk_1gc_1set_1fill_FUNC,
+	_1gdk_1gc_1set_1foreground_FUNC,
+	_1gdk_1gc_1set_1function_FUNC,
+	_1gdk_1gc_1set_1line_1attributes_FUNC,
+	_1gdk_1gc_1set_1stipple_FUNC,
+	_1gdk_1gc_1set_1subwindow_FUNC,
+	_1gdk_1gc_1set_1tile_FUNC,
+	_1gdk_1gc_1set_1ts_1origin_FUNC,
+	_1gdk_1gc_1set_1values_FUNC,
+	_1gdk_1keyboard_1ungrab_FUNC,
+	_1gdk_1keymap_1get_1default_FUNC,
+	_1gdk_1keymap_1translate_1keyboard_1state_FUNC,
+	_1gdk_1keyval_1to_1lower_FUNC,
+	_1gdk_1keyval_1to_1unicode_FUNC,
+	_1gdk_1pango_1context_1get_FUNC,
+	_1gdk_1pango_1context_1set_1colormap_FUNC,
+	_1gdk_1pango_1layout_1get_1clip_1region_FUNC,
+	_1gdk_1pixbuf_1copy_1area_FUNC,
+	_1gdk_1pixbuf_1get_1from_1drawable_FUNC,
+	_1gdk_1pixbuf_1get_1has_1alpha_FUNC,
+	_1gdk_1pixbuf_1get_1height_FUNC,
+	_1gdk_1pixbuf_1get_1pixels_FUNC,
+	_1gdk_1pixbuf_1get_1rowstride_FUNC,
+	_1gdk_1pixbuf_1get_1width_FUNC,
+	_1gdk_1pixbuf_1loader_1close_FUNC,
+	_1gdk_1pixbuf_1loader_1get_1pixbuf_FUNC,
+	_1gdk_1pixbuf_1loader_1new_FUNC,
+	_1gdk_1pixbuf_1loader_1write_FUNC,
+	_1gdk_1pixbuf_1new_FUNC,
+	_1gdk_1pixbuf_1new_1from_1file_FUNC,
+	_1gdk_1pixbuf_1render_1pixmap_1and_1mask_FUNC,
+	_1gdk_1pixbuf_1render_1to_1drawable_FUNC,
+	_1gdk_1pixbuf_1render_1to_1drawable_1alpha_FUNC,
+	_1gdk_1pixbuf_1save_1to_1buffer_FUNC,
+	_1gdk_1pixbuf_1scale_FUNC,
+	_1gdk_1pixbuf_1scale_1simple_FUNC,
+	_1gdk_1pixmap_1foreign_1new_FUNC,
+	_1gdk_1pixmap_1new_FUNC,
+	_1gdk_1pointer_1grab_FUNC,
+	_1gdk_1pointer_1is_1grabbed_FUNC,
+	_1gdk_1pointer_1ungrab_FUNC,
+	_1gdk_1property_1get_FUNC,
+	_1gdk_1region_1destroy_FUNC,
+	_1gdk_1region_1empty_FUNC,
+	_1gdk_1region_1get_1clipbox_FUNC,
+	_1gdk_1region_1get_1rectangles_FUNC,
+	_1gdk_1region_1intersect_FUNC,
+	_1gdk_1region_1new_FUNC,
+	_1gdk_1region_1offset_FUNC,
+	_1gdk_1region_1point_1in_FUNC,
+	_1gdk_1region_1polygon_FUNC,
+	_1gdk_1region_1rect_1in_FUNC,
+	_1gdk_1region_1rectangle_FUNC,
+	_1gdk_1region_1subtract_FUNC,
+	_1gdk_1region_1union_FUNC,
+	_1gdk_1region_1union_1with_1rect_FUNC,
+	_1gdk_1rgb_1init_FUNC,
+	_1gdk_1screen_1get_1default_FUNC,
+	_1gdk_1screen_1get_1monitor_1at_1point_FUNC,
+	_1gdk_1screen_1get_1monitor_1at_1window_FUNC,
+	_1gdk_1screen_1get_1monitor_1geometry_FUNC,
+	_1gdk_1screen_1get_1n_1monitors_FUNC,
+	_1gdk_1screen_1get_1number_FUNC,
+	_1gdk_1screen_1height_FUNC,
+	_1gdk_1screen_1width_FUNC,
+	_1gdk_1screen_1width_1mm_FUNC,
+	_1gdk_1set_1program_1class_FUNC,
+	_1gdk_1text_1property_1to_1utf8_1list_FUNC,
+	_1gdk_1unicode_1to_1keyval_FUNC,
+	_1gdk_1utf8_1to_1compound_1text_FUNC,
+	_1gdk_1utf8_1to_1string_1target_FUNC,
+	_1gdk_1visual_1get_1system_FUNC,
+	_1gdk_1window_1add_1filter_FUNC,
+	_1gdk_1window_1at_1pointer_FUNC,
+	_1gdk_1window_1begin_1paint_1rect_FUNC,
+	_1gdk_1window_1clear_1area_FUNC,
+	_1gdk_1window_1destroy_FUNC,
+	_1gdk_1window_1end_1paint_FUNC,
+	_1gdk_1window_1focus_FUNC,
+	_1gdk_1window_1freeze_1updates_FUNC,
+	_1gdk_1window_1get_1children_FUNC,
+	_1gdk_1window_1get_1events_FUNC,
+	_1gdk_1window_1get_1frame_1extents_FUNC,
+	_1gdk_1window_1get_1internal_1paint_1info_FUNC,
+	_1gdk_1window_1get_1origin_FUNC,
+	_1gdk_1window_1get_1parent_FUNC,
+	_1gdk_1window_1get_1pointer_FUNC,
+	_1gdk_1window_1get_1position_FUNC,
+	_1gdk_1window_1get_1user_1data_FUNC,
+	_1gdk_1window_1hide_FUNC,
+	_1gdk_1window_1invalidate_1rect_FUNC,
+	_1gdk_1window_1invalidate_1region_FUNC,
+	_1gdk_1window_1is_1visible_FUNC,
+	_1gdk_1window_1lookup_FUNC,
+	_1gdk_1window_1lower_FUNC,
+	_1gdk_1window_1move_FUNC,
+	_1gdk_1window_1new_FUNC,
+	_1gdk_1window_1process_1all_1updates_FUNC,
+	_1gdk_1window_1process_1updates_FUNC,
+	_1gdk_1window_1raise_FUNC,
+	_1gdk_1window_1remove_1filter_FUNC,
+	_1gdk_1window_1resize_FUNC,
+	_1gdk_1window_1scroll_FUNC,
+	_1gdk_1window_1set_1accept_1focus_FUNC,
+	_1gdk_1window_1set_1back_1pixmap_FUNC,
+	_1gdk_1window_1set_1cursor_FUNC,
+	_1gdk_1window_1set_1debug_1updates_FUNC,
+	_1gdk_1window_1set_1decorations_FUNC,
+	_1gdk_1window_1set_1events_FUNC,
+	_1gdk_1window_1set_1icon_FUNC,
+	_1gdk_1window_1set_1icon_1list_FUNC,
+	_1gdk_1window_1set_1keep_1above_FUNC,
+	_1gdk_1window_1set_1override_1redirect_FUNC,
+	_1gdk_1window_1set_1user_1data_FUNC,
+	_1gdk_1window_1shape_1combine_1region_FUNC,
+	_1gdk_1window_1show_FUNC,
+	_1gdk_1window_1show_1unraised_FUNC,
+	_1gdk_1window_1thaw_1updates_FUNC,
+	_1gdk_1x11_1atom_1to_1xatom_FUNC,
+	_1gdk_1x11_1colormap_1get_1xcolormap_FUNC,
+	_1gdk_1x11_1drawable_1get_1xdisplay_FUNC,
+	_1gdk_1x11_1drawable_1get_1xid_FUNC,
+	_1gdk_1x11_1screen_1get_1window_1manager_1name_FUNC,
+	_1gdk_1x11_1screen_1lookup_1visual_FUNC,
+	_1gdk_1x11_1visual_1get_1xvisual_FUNC,
+	_1gtk_1accel_1group_1new_FUNC,
+	_1gtk_1accel_1groups_1activate_FUNC,
+	_1gtk_1accel_1label_1set_1accel_1widget_FUNC,
+	_1gtk_1adjustment_1changed_FUNC,
+	_1gtk_1adjustment_1new_FUNC,
+	_1gtk_1adjustment_1set_1value_FUNC,
+	_1gtk_1adjustment_1value_1changed_FUNC,
+	_1gtk_1arrow_1new_FUNC,
+	_1gtk_1arrow_1set_FUNC,
+	_1gtk_1bin_1get_1child_FUNC,
+	_1gtk_1box_1set_1child_1packing_FUNC,
+	_1gtk_1box_1set_1spacing_FUNC,
+	_1gtk_1button_1clicked_FUNC,
+	_1gtk_1button_1get_1relief_FUNC,
+	_1gtk_1button_1new_FUNC,
+	_1gtk_1button_1set_1relief_FUNC,
+	_1gtk_1calendar_1display_1options_FUNC,
+	_1gtk_1calendar_1get_1date_FUNC,
+	_1gtk_1calendar_1new_FUNC,
+	_1gtk_1calendar_1select_1day_FUNC,
+	_1gtk_1calendar_1select_1month_FUNC,
+	_1gtk_1calendar_1set_1display_1options_FUNC,
+	_1gtk_1cell_1layout_1clear_FUNC,
+	_1gtk_1cell_1layout_1pack_1start_FUNC,
+	_1gtk_1cell_1layout_1set_1attributes_FUNC,
+	_1gtk_1cell_1renderer_1get_1size_FUNC,
+	_1gtk_1cell_1renderer_1pixbuf_1new_FUNC,
+	_1gtk_1cell_1renderer_1text_1new_FUNC,
+	_1gtk_1cell_1renderer_1toggle_1new_FUNC,
+	_1gtk_1check_1button_1new_FUNC,
+	_1gtk_1check_1menu_1item_1get_1active_FUNC,
+	_1gtk_1check_1menu_1item_1new_1with_1label_FUNC,
+	_1gtk_1check_1menu_1item_1set_1active_FUNC,
+	_1gtk_1check_1version_FUNC,
+	_1gtk_1clipboard_1clear_FUNC,
+	_1gtk_1clipboard_1get_FUNC,
+	_1gtk_1clipboard_1set_1with_1data_FUNC,
+	_1gtk_1clipboard_1wait_1for_1contents_FUNC,
+	_1gtk_1color_1selection_1dialog_1new_FUNC,
+	_1gtk_1color_1selection_1get_1current_1color_FUNC,
+	_1gtk_1color_1selection_1set_1current_1color_FUNC,
+	_1gtk_1color_1selection_1set_1has_1palette_FUNC,
+	_1gtk_1combo_1box_1entry_1new_1text_FUNC,
+	_1gtk_1combo_1box_1get_1active_FUNC,
+	_1gtk_1combo_1box_1get_1model_FUNC,
+	_1gtk_1combo_1box_1insert_1text_FUNC,
+	_1gtk_1combo_1box_1new_1text_FUNC,
+	_1gtk_1combo_1box_1popdown_FUNC,
+	_1gtk_1combo_1box_1popup_FUNC,
+	_1gtk_1combo_1box_1remove_1text_FUNC,
+	_1gtk_1combo_1box_1set_1active_FUNC,
+	_1gtk_1combo_1box_1set_1focus_1on_1click_FUNC,
+	_1gtk_1combo_1disable_1activate_FUNC,
+	_1gtk_1combo_1new_FUNC,
+	_1gtk_1combo_1set_1case_1sensitive_FUNC,
+	_1gtk_1combo_1set_1popdown_1strings_FUNC,
+	_1gtk_1container_1add_FUNC,
+	_1gtk_1container_1forall_FUNC,
+	_1gtk_1container_1get_1border_1width_FUNC,
+	_1gtk_1container_1get_1children_FUNC,
+	_1gtk_1container_1remove_FUNC,
+	_1gtk_1container_1resize_1children_FUNC,
+	_1gtk_1container_1set_1border_1width_FUNC,
+	_1gtk_1dialog_1add_1button_FUNC,
+	_1gtk_1dialog_1run_FUNC,
+	_1gtk_1drag_1begin_FUNC,
+	_1gtk_1drag_1check_1threshold_FUNC,
+	_1gtk_1drag_1dest_1find_1target_FUNC,
+	_1gtk_1drag_1dest_1set_FUNC,
+	_1gtk_1drag_1dest_1unset_FUNC,
+	_1gtk_1drag_1finish_FUNC,
+	_1gtk_1drag_1get_1data_FUNC,
+	_1gtk_1drag_1set_1icon_1pixbuf_FUNC,
+	_1gtk_1drawing_1area_1new_FUNC,
+	_1gtk_1editable_1copy_1clipboard_FUNC,
+	_1gtk_1editable_1cut_1clipboard_FUNC,
+	_1gtk_1editable_1delete_1selection_FUNC,
+	_1gtk_1editable_1delete_1text_FUNC,
+	_1gtk_1editable_1get_1chars_FUNC,
+	_1gtk_1editable_1get_1editable_FUNC,
+	_1gtk_1editable_1get_1position_FUNC,
+	_1gtk_1editable_1get_1selection_1bounds_FUNC,
+	_1gtk_1editable_1insert_1text_FUNC,
+	_1gtk_1editable_1paste_1clipboard_FUNC,
+	_1gtk_1editable_1select_1region_FUNC,
+	_1gtk_1editable_1set_1editable_FUNC,
+	_1gtk_1editable_1set_1position_FUNC,
+	_1gtk_1entry_1get_1invisible_1char_FUNC,
+	_1gtk_1entry_1get_1layout_FUNC,
+	_1gtk_1entry_1get_1layout_1offsets_FUNC,
+	_1gtk_1entry_1get_1max_1length_FUNC,
+	_1gtk_1entry_1get_1text_FUNC,
+	_1gtk_1entry_1get_1visibility_FUNC,
+	_1gtk_1entry_1new_FUNC,
+	_1gtk_1entry_1set_1activates_1default_FUNC,
+	_1gtk_1entry_1set_1alignment_FUNC,
+	_1gtk_1entry_1set_1has_1frame_FUNC,
+	_1gtk_1entry_1set_1invisible_1char_FUNC,
+	_1gtk_1entry_1set_1max_1length_FUNC,
+	_1gtk_1entry_1set_1text_FUNC,
+	_1gtk_1entry_1set_1visibility_FUNC,
+	_1gtk_1entry_1text_1index_1to_1layout_1index_FUNC,
+	_1gtk_1enumerate_1printers_FUNC,
+	_1gtk_1events_1pending_FUNC,
+	_1gtk_1expander_1get_1expanded_FUNC,
+	_1gtk_1expander_1get_1label_1widget_FUNC,
+	_1gtk_1expander_1new_FUNC,
+	_1gtk_1expander_1set_1expanded_FUNC,
+	_1gtk_1expander_1set_1label_FUNC,
+	_1gtk_1expander_1set_1label_1widget_FUNC,
+	_1gtk_1file_1chooser_1add_1filter_FUNC,
+	_1gtk_1file_1chooser_1dialog_1new_FUNC,
+	_1gtk_1file_1chooser_1get_1current_1folder_FUNC,
+	_1gtk_1file_1chooser_1get_1filename_FUNC,
+	_1gtk_1file_1chooser_1get_1filenames_FUNC,
+	_1gtk_1file_1chooser_1get_1filter_FUNC,
+	_1gtk_1file_1chooser_1set_1current_1folder_FUNC,
+	_1gtk_1file_1chooser_1set_1current_1name_FUNC,
+	_1gtk_1file_1chooser_1set_1do_1overwrite_1confirmation_FUNC,
+	_1gtk_1file_1chooser_1set_1extra_1widget_FUNC,
+	_1gtk_1file_1chooser_1set_1filename_FUNC,
+	_1gtk_1file_1chooser_1set_1filter_FUNC,
+	_1gtk_1file_1chooser_1set_1select_1multiple_FUNC,
+	_1gtk_1file_1filter_1add_1pattern_FUNC,
+	_1gtk_1file_1filter_1get_1name_FUNC,
+	_1gtk_1file_1filter_1new_FUNC,
+	_1gtk_1file_1filter_1set_1name_FUNC,
+	_1gtk_1file_1selection_1get_1filename_FUNC,
+	_1gtk_1file_1selection_1get_1selections_FUNC,
+	_1gtk_1file_1selection_1hide_1fileop_1buttons_FUNC,
+	_1gtk_1file_1selection_1new_FUNC,
+	_1gtk_1file_1selection_1set_1filename_FUNC,
+	_1gtk_1file_1selection_1set_1select_1multiple_FUNC,
+	_1gtk_1fixed_1move_FUNC,
+	_1gtk_1fixed_1new_FUNC,
+	_1gtk_1fixed_1set_1has_1window_FUNC,
+	_1gtk_1font_1selection_1dialog_1get_1font_1name_FUNC,
+	_1gtk_1font_1selection_1dialog_1new_FUNC,
+	_1gtk_1font_1selection_1dialog_1set_1font_1name_FUNC,
+	_1gtk_1frame_1get_1label_1widget_FUNC,
+	_1gtk_1frame_1new_FUNC,
+	_1gtk_1frame_1set_1label_FUNC,
+	_1gtk_1frame_1set_1label_1widget_FUNC,
+	_1gtk_1frame_1set_1shadow_1type_FUNC,
+	_1gtk_1get_1current_1event_FUNC,
+	_1gtk_1get_1current_1event_1state_FUNC,
+	_1gtk_1get_1current_1event_1time_FUNC,
+	_1gtk_1get_1default_1language_FUNC,
+	_1gtk_1get_1event_1widget_FUNC,
+	_1gtk_1grab_1add_FUNC,
+	_1gtk_1grab_1get_1current_FUNC,
+	_1gtk_1grab_1remove_FUNC,
+	_1gtk_1hbox_1new_FUNC,
+	_1gtk_1hscale_1new_FUNC,
+	_1gtk_1hscrollbar_1new_FUNC,
+	_1gtk_1hseparator_1new_FUNC,
+	_1gtk_1icon_1factory_1lookup_1default_FUNC,
+	_1gtk_1icon_1set_1render_1icon_FUNC,
+	_1gtk_1icon_1source_1free_FUNC,
+	_1gtk_1icon_1source_1new_FUNC,
+	_1gtk_1icon_1source_1set_1pixbuf_FUNC,
+	_1gtk_1im_1context_1filter_1keypress_FUNC,
+	_1gtk_1im_1context_1focus_1in_FUNC,
+	_1gtk_1im_1context_1focus_1out_FUNC,
+	_1gtk_1im_1context_1get_1preedit_1string_FUNC,
+	_1gtk_1im_1context_1get_1type_FUNC,
+	_1gtk_1im_1context_1reset_FUNC,
+	_1gtk_1im_1context_1set_1client_1window_FUNC,
+	_1gtk_1im_1context_1set_1cursor_1location_FUNC,
+	_1gtk_1im_1multicontext_1append_1menuitems_FUNC,
+	_1gtk_1im_1multicontext_1new_FUNC,
+	_1gtk_1image_1menu_1item_1new_1with_1label_FUNC,
+	_1gtk_1image_1menu_1item_1set_1image_FUNC,
+	_1gtk_1image_1new_FUNC,
+	_1gtk_1image_1new_1from_1pixbuf_FUNC,
+	_1gtk_1image_1new_1from_1pixmap_FUNC,
+	_1gtk_1image_1set_1from_1pixbuf_FUNC,
+	_1gtk_1image_1set_1from_1pixmap_FUNC,
+	_1gtk_1init_1check_FUNC,
+	_1gtk_1label_1get_1layout_FUNC,
+	_1gtk_1label_1get_1mnemonic_1keyval_FUNC,
+	_1gtk_1label_1new_FUNC,
+	_1gtk_1label_1new_1with_1mnemonic_FUNC,
+	_1gtk_1label_1set_1attributes_FUNC,
+	_1gtk_1label_1set_1justify_FUNC,
+	_1gtk_1label_1set_1line_1wrap_FUNC,
+	_1gtk_1label_1set_1line_1wrap_1mode_FUNC,
+	_1gtk_1label_1set_1text__II_FUNC,
+	_1gtk_1label_1set_1text__I_3B_FUNC,
+	_1gtk_1label_1set_1text_1with_1mnemonic_FUNC,
+	_1gtk_1list_1append_1items_FUNC,
+	_1gtk_1list_1clear_1items_FUNC,
+	_1gtk_1list_1insert_1items_FUNC,
+	_1gtk_1list_1item_1new_1with_1label_FUNC,
+	_1gtk_1list_1remove_1items_FUNC,
+	_1gtk_1list_1select_1item_FUNC,
+	_1gtk_1list_1store_1append_FUNC,
+	_1gtk_1list_1store_1clear_FUNC,
+	_1gtk_1list_1store_1insert_FUNC,
+	_1gtk_1list_1store_1newv_FUNC,
+	_1gtk_1list_1store_1remove_FUNC,
+	_1gtk_1list_1store_1set__IIIII_FUNC,
+	_1gtk_1list_1store_1set__IIIJI_FUNC,
+	_1gtk_1list_1store_1set__IIILorg_eclipse_swt_internal_gtk_GdkColor_2I_FUNC,
+	_1gtk_1list_1store_1set__IIIZI_FUNC,
+	_1gtk_1list_1store_1set__III_3BI_FUNC,
+	_1gtk_1list_1unselect_1all_FUNC,
+	_1gtk_1list_1unselect_1item_FUNC,
+	_1gtk_1main_FUNC,
+	_1gtk_1main_1do_1event_FUNC,
+	_1gtk_1main_1iteration_FUNC,
+	_1gtk_1major_1version_FUNC,
+	_1gtk_1menu_1bar_1new_FUNC,
+	_1gtk_1menu_1item_1get_1submenu_FUNC,
+	_1gtk_1menu_1item_1remove_1submenu_FUNC,
+	_1gtk_1menu_1item_1set_1submenu_FUNC,
+	_1gtk_1menu_1new_FUNC,
+	_1gtk_1menu_1popdown_FUNC,
+	_1gtk_1menu_1popup_FUNC,
+	_1gtk_1menu_1shell_1deactivate_FUNC,
+	_1gtk_1menu_1shell_1insert_FUNC,
+	_1gtk_1menu_1shell_1select_1item_FUNC,
+	_1gtk_1menu_1shell_1set_1take_1focus_FUNC,
+	_1gtk_1message_1dialog_1new_FUNC,
+	_1gtk_1micro_1version_FUNC,
+	_1gtk_1minor_1version_FUNC,
+	_1gtk_1misc_1set_1alignment_FUNC,
+	_1gtk_1notebook_1get_1current_1page_FUNC,
+	_1gtk_1notebook_1get_1scrollable_FUNC,
+	_1gtk_1notebook_1insert_1page_FUNC,
+	_1gtk_1notebook_1new_FUNC,
+	_1gtk_1notebook_1next_1page_FUNC,
+	_1gtk_1notebook_1prev_1page_FUNC,
+	_1gtk_1notebook_1remove_1page_FUNC,
+	_1gtk_1notebook_1set_1current_1page_FUNC,
+	_1gtk_1notebook_1set_1scrollable_FUNC,
+	_1gtk_1notebook_1set_1show_1tabs_FUNC,
+	_1gtk_1notebook_1set_1tab_1pos_FUNC,
+	_1gtk_1object_1sink_FUNC,
+	_1gtk_1page_1setup_1get_1bottom_1margin_FUNC,
+	_1gtk_1page_1setup_1get_1left_1margin_FUNC,
+	_1gtk_1page_1setup_1get_1orientation_FUNC,
+	_1gtk_1page_1setup_1get_1page_1height_FUNC,
+	_1gtk_1page_1setup_1get_1page_1width_FUNC,
+	_1gtk_1page_1setup_1get_1paper_1height_FUNC,
+	_1gtk_1page_1setup_1get_1paper_1size_FUNC,
+	_1gtk_1page_1setup_1get_1paper_1width_FUNC,
+	_1gtk_1page_1setup_1get_1right_1margin_FUNC,
+	_1gtk_1page_1setup_1get_1top_1margin_FUNC,
+	_1gtk_1page_1setup_1new_FUNC,
+	_1gtk_1page_1setup_1set_1bottom_1margin_FUNC,
+	_1gtk_1page_1setup_1set_1left_1margin_FUNC,
+	_1gtk_1page_1setup_1set_1orientation_FUNC,
+	_1gtk_1page_1setup_1set_1paper_1size_FUNC,
+	_1gtk_1page_1setup_1set_1right_1margin_FUNC,
+	_1gtk_1page_1setup_1set_1top_1margin_FUNC,
+	_1gtk_1paint_1arrow_FUNC,
+	_1gtk_1paint_1box_FUNC,
+	_1gtk_1paint_1box_1gap_FUNC,
+	_1gtk_1paint_1check_FUNC,
+	_1gtk_1paint_1expander_FUNC,
+	_1gtk_1paint_1extension_FUNC,
+	_1gtk_1paint_1flat_1box_FUNC,
+	_1gtk_1paint_1focus_FUNC,
+	_1gtk_1paint_1handle_FUNC,
+	_1gtk_1paint_1hline_FUNC,
+	_1gtk_1paint_1layout_FUNC,
+	_1gtk_1paint_1option_FUNC,
+	_1gtk_1paint_1shadow_FUNC,
+	_1gtk_1paint_1shadow_1gap_FUNC,
+	_1gtk_1paint_1slider_FUNC,
+	_1gtk_1paint_1tab_FUNC,
+	_1gtk_1paint_1vline_FUNC,
+	_1gtk_1paper_1size_1free_FUNC,
+	_1gtk_1paper_1size_1get_1display_1name_FUNC,
+	_1gtk_1paper_1size_1get_1height_FUNC,
+	_1gtk_1paper_1size_1get_1name_FUNC,
+	_1gtk_1paper_1size_1get_1ppd_1name_FUNC,
+	_1gtk_1paper_1size_1get_1width_FUNC,
+	_1gtk_1paper_1size_1is_1custom_FUNC,
+	_1gtk_1paper_1size_1new_FUNC,
+	_1gtk_1paper_1size_1new_1custom_FUNC,
+	_1gtk_1paper_1size_1new_1from_1ppd_FUNC,
+	_1gtk_1plug_1get_1id_FUNC,
+	_1gtk_1plug_1new_FUNC,
+	_1gtk_1print_1job_1get_1printer_FUNC,
+	_1gtk_1print_1job_1get_1settings_FUNC,
+	_1gtk_1print_1job_1get_1status_FUNC,
+	_1gtk_1print_1job_1get_1surface_FUNC,
+	_1gtk_1print_1job_1get_1title_FUNC,
+	_1gtk_1print_1job_1new_FUNC,
+	_1gtk_1print_1job_1send_FUNC,
+	_1gtk_1print_1job_1set_1source_1file_FUNC,
+	_1gtk_1print_1settings_1foreach_FUNC,
+	_1gtk_1print_1settings_1get_FUNC,
+	_1gtk_1print_1settings_1get_1collate_FUNC,
+	_1gtk_1print_1settings_1get_1n_1copies_FUNC,
+	_1gtk_1print_1settings_1get_1orientation_FUNC,
+	_1gtk_1print_1settings_1get_1page_1ranges_FUNC,
+	_1gtk_1print_1settings_1get_1paper_1height_FUNC,
+	_1gtk_1print_1settings_1get_1paper_1width_FUNC,
+	_1gtk_1print_1settings_1get_1print_1pages_FUNC,
+	_1gtk_1print_1settings_1get_1printer_FUNC,
+	_1gtk_1print_1settings_1get_1resolution_FUNC,
+	_1gtk_1print_1settings_1new_FUNC,
+	_1gtk_1print_1settings_1set_FUNC,
+	_1gtk_1print_1settings_1set_1collate_FUNC,
+	_1gtk_1print_1settings_1set_1n_1copies_FUNC,
+	_1gtk_1print_1settings_1set_1orientation_FUNC,
+	_1gtk_1print_1settings_1set_1page_1ranges_FUNC,
+	_1gtk_1print_1settings_1set_1print_1pages_FUNC,
+	_1gtk_1print_1settings_1set_1printer_FUNC,
+	_1gtk_1print_1unix_1dialog_1get_1current_1page_FUNC,
+	_1gtk_1print_1unix_1dialog_1get_1page_1setup_FUNC,
+	_1gtk_1print_1unix_1dialog_1get_1selected_1printer_FUNC,
+	_1gtk_1print_1unix_1dialog_1get_1settings_FUNC,
+	_1gtk_1print_1unix_1dialog_1new_FUNC,
+	_1gtk_1print_1unix_1dialog_1set_1current_1page_FUNC,
+	_1gtk_1print_1unix_1dialog_1set_1manual_1capabilities_FUNC,
+	_1gtk_1print_1unix_1dialog_1set_1page_1setup_FUNC,
+	_1gtk_1print_1unix_1dialog_1set_1settings_FUNC,
+	_1gtk_1printer_1get_1backend_FUNC,
+	_1gtk_1printer_1get_1name_FUNC,
+	_1gtk_1printer_1is_1default_FUNC,
+	_1gtk_1progress_1bar_1new_FUNC,
+	_1gtk_1progress_1bar_1pulse_FUNC,
+	_1gtk_1progress_1bar_1set_1fraction_FUNC,
+	_1gtk_1progress_1bar_1set_1orientation_FUNC,
+	_1gtk_1radio_1button_1get_1group_FUNC,
+	_1gtk_1radio_1button_1new_FUNC,
+	_1gtk_1radio_1menu_1item_1get_1group_FUNC,
+	_1gtk_1radio_1menu_1item_1new_FUNC,
+	_1gtk_1radio_1menu_1item_1new_1with_1label_FUNC,
+	_1gtk_1range_1get_1adjustment_FUNC,
+	_1gtk_1range_1set_1increments_FUNC,
+	_1gtk_1range_1set_1inverted_FUNC,
+	_1gtk_1range_1set_1range_FUNC,
+	_1gtk_1range_1set_1value_FUNC,
+	_1gtk_1rc_1parse_1string_FUNC,
+	_1gtk_1rc_1style_1get_1bg_1pixmap_1name_FUNC,
+	_1gtk_1rc_1style_1get_1color_1flags_FUNC,
+	_1gtk_1rc_1style_1set_1bg_FUNC,
+	_1gtk_1rc_1style_1set_1bg_1pixmap_1name_FUNC,
+	_1gtk_1rc_1style_1set_1color_1flags_FUNC,
+	_1gtk_1rc_1style_1set_1fg_FUNC,
+	_1gtk_1rc_1style_1set_1text_FUNC,
+	_1gtk_1scale_1set_1digits_FUNC,
+	_1gtk_1scale_1set_1draw_1value_FUNC,
+	_1gtk_1scrolled_1window_1add_1with_1viewport_FUNC,
+	_1gtk_1scrolled_1window_1get_1hadjustment_FUNC,
+	_1gtk_1scrolled_1window_1get_1policy_FUNC,
+	_1gtk_1scrolled_1window_1get_1shadow_1type_FUNC,
+	_1gtk_1scrolled_1window_1get_1vadjustment_FUNC,
+	_1gtk_1scrolled_1window_1new_FUNC,
+	_1gtk_1scrolled_1window_1set_1placement_FUNC,
+	_1gtk_1scrolled_1window_1set_1policy_FUNC,
+	_1gtk_1scrolled_1window_1set_1shadow_1type_FUNC,
+	_1gtk_1selection_1data_1free_FUNC,
+	_1gtk_1selection_1data_1set_FUNC,
+	_1gtk_1separator_1menu_1item_1new_FUNC,
+	_1gtk_1set_1locale_FUNC,
+	_1gtk_1settings_1get_1default_FUNC,
+	_1gtk_1socket_1get_1id_FUNC,
+	_1gtk_1socket_1new_FUNC,
+	_1gtk_1spin_1button_1get_1adjustment_FUNC,
+	_1gtk_1spin_1button_1get_1digits_FUNC,
+	_1gtk_1spin_1button_1new_FUNC,
+	_1gtk_1spin_1button_1set_1digits_FUNC,
+	_1gtk_1spin_1button_1set_1increments_FUNC,
+	_1gtk_1spin_1button_1set_1range_FUNC,
+	_1gtk_1spin_1button_1set_1value_FUNC,
+	_1gtk_1spin_1button_1set_1wrap_FUNC,
+	_1gtk_1spin_1button_1update_FUNC,
+	_1gtk_1style_1get_1base_FUNC,
+	_1gtk_1style_1get_1bg_FUNC,
+	_1gtk_1style_1get_1bg_1gc_FUNC,
+	_1gtk_1style_1get_1black_FUNC,
+	_1gtk_1style_1get_1black_1gc_FUNC,
+	_1gtk_1style_1get_1dark_FUNC,
+	_1gtk_1style_1get_1dark_1gc_FUNC,
+	_1gtk_1style_1get_1fg_FUNC,
+	_1gtk_1style_1get_1fg_1gc_FUNC,
+	_1gtk_1style_1get_1font_1desc_FUNC,
+	_1gtk_1style_1get_1light_FUNC,
+	_1gtk_1style_1get_1light_1gc_FUNC,
+	_1gtk_1style_1get_1mid_1gc_FUNC,
+	_1gtk_1style_1get_1text_FUNC,
+	_1gtk_1style_1get_1text_1aa_1gc_FUNC,
+	_1gtk_1style_1get_1text_1gc_FUNC,
+	_1gtk_1style_1get_1white_1gc_FUNC,
+	_1gtk_1style_1get_1xthickness_FUNC,
+	_1gtk_1style_1get_1ythickness_FUNC,
+	_1gtk_1style_1render_1icon_FUNC,
+	_1gtk_1target_1list_1new_FUNC,
+	_1gtk_1target_1list_1unref_FUNC,
+	_1gtk_1text_1buffer_1copy_1clipboard_FUNC,
+	_1gtk_1text_1buffer_1cut_1clipboard_FUNC,
+	_1gtk_1text_1buffer_1delete_FUNC,
+	_1gtk_1text_1buffer_1get_1bounds_FUNC,
+	_1gtk_1text_1buffer_1get_1char_1count_FUNC,
+	_1gtk_1text_1buffer_1get_1end_1iter_FUNC,
+	_1gtk_1text_1buffer_1get_1insert_FUNC,
+	_1gtk_1text_1buffer_1get_1iter_1at_1line_FUNC,
+	_1gtk_1text_1buffer_1get_1iter_1at_1mark_FUNC,
+	_1gtk_1text_1buffer_1get_1iter_1at_1offset_FUNC,
+	_1gtk_1text_1buffer_1get_1line_1count_FUNC,
+	_1gtk_1text_1buffer_1get_1selection_1bound_FUNC,
+	_1gtk_1text_1buffer_1get_1selection_1bounds_FUNC,
+	_1gtk_1text_1buffer_1get_1text_FUNC,
+	_1gtk_1text_1buffer_1insert__II_3BI_FUNC,
+	_1gtk_1text_1buffer_1insert__I_3B_3BI_FUNC,
+	_1gtk_1text_1buffer_1move_1mark_FUNC,
+	_1gtk_1text_1buffer_1paste_1clipboard_FUNC,
+	_1gtk_1text_1buffer_1place_1cursor_FUNC,
+	_1gtk_1text_1buffer_1set_1text_FUNC,
+	_1gtk_1text_1iter_1get_1line_FUNC,
+	_1gtk_1text_1iter_1get_1offset_FUNC,
+	_1gtk_1text_1view_1buffer_1to_1window_1coords_FUNC,
+	_1gtk_1text_1view_1get_1buffer_FUNC,
+	_1gtk_1text_1view_1get_1editable_FUNC,
+	_1gtk_1text_1view_1get_1iter_1at_1location_FUNC,
+	_1gtk_1text_1view_1get_1iter_1location_FUNC,
+	_1gtk_1text_1view_1get_1line_1at_1y_FUNC,
+	_1gtk_1text_1view_1get_1visible_1rect_FUNC,
+	_1gtk_1text_1view_1get_1window_FUNC,
+	_1gtk_1text_1view_1new_FUNC,
+	_1gtk_1text_1view_1scroll_1mark_1onscreen_FUNC,
+	_1gtk_1text_1view_1scroll_1to_1iter_FUNC,
+	_1gtk_1text_1view_1set_1editable_FUNC,
+	_1gtk_1text_1view_1set_1justification_FUNC,
+	_1gtk_1text_1view_1set_1tabs_FUNC,
+	_1gtk_1text_1view_1set_1wrap_1mode_FUNC,
+	_1gtk_1text_1view_1window_1to_1buffer_1coords_FUNC,
+	_1gtk_1timeout_1add_FUNC,
+	_1gtk_1timeout_1remove_FUNC,
+	_1gtk_1toggle_1button_1get_1active_FUNC,
+	_1gtk_1toggle_1button_1get_1inconsistent_FUNC,
+	_1gtk_1toggle_1button_1new_FUNC,
+	_1gtk_1toggle_1button_1set_1active_FUNC,
+	_1gtk_1toggle_1button_1set_1inconsistent_FUNC,
+	_1gtk_1toggle_1button_1set_1mode_FUNC,
+	_1gtk_1toolbar_1insert_1widget_FUNC,
+	_1gtk_1toolbar_1new_FUNC,
+	_1gtk_1toolbar_1set_1orientation_FUNC,
+	_1gtk_1tooltip_1trigger_1tooltip_1query_FUNC,
+	_1gtk_1tooltips_1data_1get_FUNC,
+	_1gtk_1tooltips_1disable_FUNC,
+	_1gtk_1tooltips_1enable_FUNC,
+	_1gtk_1tooltips_1force_1window_FUNC,
+	_1gtk_1tooltips_1new_FUNC,
+	_1gtk_1tooltips_1set_1tip_FUNC,
+	_1gtk_1tree_1model_1get__III_3II_FUNC,
+	_1gtk_1tree_1model_1get__III_3JI_FUNC,
+	_1gtk_1tree_1model_1get_1iter_FUNC,
+	_1gtk_1tree_1model_1get_1iter_1first_FUNC,
+	_1gtk_1tree_1model_1get_1n_1columns_FUNC,
+	_1gtk_1tree_1model_1get_1path_FUNC,
+	_1gtk_1tree_1model_1get_1type_FUNC,
+	_1gtk_1tree_1model_1iter_1children_FUNC,
+	_1gtk_1tree_1model_1iter_1n_1children_FUNC,
+	_1gtk_1tree_1model_1iter_1next_FUNC,
+	_1gtk_1tree_1model_1iter_1nth_1child_FUNC,
+	_1gtk_1tree_1path_1append_1index_FUNC,
+	_1gtk_1tree_1path_1compare_FUNC,
+	_1gtk_1tree_1path_1down_FUNC,
+	_1gtk_1tree_1path_1free_FUNC,
+	_1gtk_1tree_1path_1get_1depth_FUNC,
+	_1gtk_1tree_1path_1get_1indices_FUNC,
+	_1gtk_1tree_1path_1new_FUNC,
+	_1gtk_1tree_1path_1new_1first_FUNC,
+	_1gtk_1tree_1path_1new_1from_1string__I_FUNC,
+	_1gtk_1tree_1path_1new_1from_1string___3B_FUNC,
+	_1gtk_1tree_1path_1next_FUNC,
+	_1gtk_1tree_1path_1prev_FUNC,
+	_1gtk_1tree_1path_1up_FUNC,
+	_1gtk_1tree_1selection_1count_1selected_1rows_FUNC,
+	_1gtk_1tree_1selection_1get_1selected_FUNC,
+	_1gtk_1tree_1selection_1get_1selected_1rows_FUNC,
+	_1gtk_1tree_1selection_1path_1is_1selected_FUNC,
+	_1gtk_1tree_1selection_1select_1all_FUNC,
+	_1gtk_1tree_1selection_1select_1iter_FUNC,
+	_1gtk_1tree_1selection_1selected_1foreach_FUNC,
+	_1gtk_1tree_1selection_1set_1mode_FUNC,
+	_1gtk_1tree_1selection_1unselect_1all_FUNC,
+	_1gtk_1tree_1selection_1unselect_1iter_FUNC,
+	_1gtk_1tree_1store_1append_FUNC,
+	_1gtk_1tree_1store_1clear_FUNC,
+	_1gtk_1tree_1store_1insert_FUNC,
+	_1gtk_1tree_1store_1newv_FUNC,
+	_1gtk_1tree_1store_1remove_FUNC,
+	_1gtk_1tree_1store_1set__IIIII_FUNC,
+	_1gtk_1tree_1store_1set__IIIJI_FUNC,
+	_1gtk_1tree_1store_1set__IIILorg_eclipse_swt_internal_gtk_GdkColor_2I_FUNC,
+	_1gtk_1tree_1store_1set__IIIZI_FUNC,
+	_1gtk_1tree_1store_1set__III_3BI_FUNC,
+	_1gtk_1tree_1view_1collapse_1row_FUNC,
+	_1gtk_1tree_1view_1column_1add_1attribute_FUNC,
+	_1gtk_1tree_1view_1column_1cell_1get_1position_FUNC,
+	_1gtk_1tree_1view_1column_1cell_1get_1size_FUNC,
+	_1gtk_1tree_1view_1column_1cell_1set_1cell_1data_FUNC,
+	_1gtk_1tree_1view_1column_1clear_FUNC,
+	_1gtk_1tree_1view_1column_1get_1cell_1renderers_FUNC,
+	_1gtk_1tree_1view_1column_1get_1fixed_1width_FUNC,
+	_1gtk_1tree_1view_1column_1get_1reorderable_FUNC,
+	_1gtk_1tree_1view_1column_1get_1resizable_FUNC,
+	_1gtk_1tree_1view_1column_1get_1sizing_FUNC,
+	_1gtk_1tree_1view_1column_1get_1sort_1indicator_FUNC,
+	_1gtk_1tree_1view_1column_1get_1sort_1order_FUNC,
+	_1gtk_1tree_1view_1column_1get_1spacing_FUNC,
+	_1gtk_1tree_1view_1column_1get_1visible_FUNC,
+	_1gtk_1tree_1view_1column_1get_1width_FUNC,
+	_1gtk_1tree_1view_1column_1new_FUNC,
+	_1gtk_1tree_1view_1column_1pack_1end_FUNC,
+	_1gtk_1tree_1view_1column_1pack_1start_FUNC,
+	_1gtk_1tree_1view_1column_1set_1alignment_FUNC,
+	_1gtk_1tree_1view_1column_1set_1cell_1data_1func_FUNC,
+	_1gtk_1tree_1view_1column_1set_1clickable_FUNC,
+	_1gtk_1tree_1view_1column_1set_1fixed_1width_FUNC,
+	_1gtk_1tree_1view_1column_1set_1min_1width_FUNC,
+	_1gtk_1tree_1view_1column_1set_1reorderable_FUNC,
+	_1gtk_1tree_1view_1column_1set_1resizable_FUNC,
+	_1gtk_1tree_1view_1column_1set_1sizing_FUNC,
+	_1gtk_1tree_1view_1column_1set_1sort_1indicator_FUNC,
+	_1gtk_1tree_1view_1column_1set_1sort_1order_FUNC,
+	_1gtk_1tree_1view_1column_1set_1title_FUNC,
+	_1gtk_1tree_1view_1column_1set_1visible_FUNC,
+	_1gtk_1tree_1view_1column_1set_1widget_FUNC,
+	_1gtk_1tree_1view_1create_1row_1drag_1icon_FUNC,
+	_1gtk_1tree_1view_1expand_1row_FUNC,
+	_1gtk_1tree_1view_1get_1background_1area_FUNC,
+	_1gtk_1tree_1view_1get_1bin_1window_FUNC,
+	_1gtk_1tree_1view_1get_1cell_1area_FUNC,
+	_1gtk_1tree_1view_1get_1column_FUNC,
+	_1gtk_1tree_1view_1get_1columns_FUNC,
+	_1gtk_1tree_1view_1get_1cursor_FUNC,
+	_1gtk_1tree_1view_1get_1expander_1column_FUNC,
+	_1gtk_1tree_1view_1get_1headers_1visible_FUNC,
+	_1gtk_1tree_1view_1get_1path_1at_1pos_FUNC,
+	_1gtk_1tree_1view_1get_1rules_1hint_FUNC,
+	_1gtk_1tree_1view_1get_1selection_FUNC,
+	_1gtk_1tree_1view_1get_1visible_1rect_FUNC,
+	_1gtk_1tree_1view_1insert_1column_FUNC,
+	_1gtk_1tree_1view_1move_1column_1after_FUNC,
+	_1gtk_1tree_1view_1new_1with_1model_FUNC,
+	_1gtk_1tree_1view_1remove_1column_FUNC,
+	_1gtk_1tree_1view_1row_1expanded_FUNC,
+	_1gtk_1tree_1view_1scroll_1to_1cell_FUNC,
+	_1gtk_1tree_1view_1scroll_1to_1point_FUNC,
+	_1gtk_1tree_1view_1set_1cursor_FUNC,
+	_1gtk_1tree_1view_1set_1drag_1dest_1row_FUNC,
+	_1gtk_1tree_1view_1set_1enable_1search_FUNC,
+	_1gtk_1tree_1view_1set_1headers_1visible_FUNC,
+	_1gtk_1tree_1view_1set_1model_FUNC,
+	_1gtk_1tree_1view_1set_1rules_1hint_FUNC,
+	_1gtk_1tree_1view_1set_1search_1column_FUNC,
+	_1gtk_1tree_1view_1tree_1to_1widget_1coords_FUNC,
+	_1gtk_1tree_1view_1unset_1rows_1drag_1dest_FUNC,
+	_1gtk_1tree_1view_1widget_1to_1tree_1coords_FUNC,
+	_1gtk_1vbox_1new_FUNC,
+	_1gtk_1vscale_1new_FUNC,
+	_1gtk_1vscrollbar_1new_FUNC,
+	_1gtk_1vseparator_1new_FUNC,
+	_1gtk_1widget_1add_1accelerator_FUNC,
+	_1gtk_1widget_1add_1events_FUNC,
+	_1gtk_1widget_1child_1focus_FUNC,
+	_1gtk_1widget_1create_1pango_1layout__II_FUNC,
+	_1gtk_1widget_1create_1pango_1layout__I_3B_FUNC,
+	_1gtk_1widget_1destroy_FUNC,
+	_1gtk_1widget_1event_FUNC,
+	_1gtk_1widget_1get_1accessible_FUNC,
+	_1gtk_1widget_1get_1child_1visible_FUNC,
+	_1gtk_1widget_1get_1default_1direction_FUNC,
+	_1gtk_1widget_1get_1default_1style_FUNC,
+	_1gtk_1widget_1get_1direction_FUNC,
+	_1gtk_1widget_1get_1events_FUNC,
+	_1gtk_1widget_1get_1modifier_1style_FUNC,
+	_1gtk_1widget_1get_1pango_1context_FUNC,
+	_1gtk_1widget_1get_1parent_FUNC,
+	_1gtk_1widget_1get_1size_1request_FUNC,
+	_1gtk_1widget_1get_1style_FUNC,
+	_1gtk_1widget_1get_1toplevel_FUNC,
+	_1gtk_1widget_1grab_1focus_FUNC,
+	_1gtk_1widget_1hide_FUNC,
+	_1gtk_1widget_1is_1composited_FUNC,
+	_1gtk_1widget_1is_1focus_FUNC,
+	_1gtk_1widget_1map_FUNC,
+	_1gtk_1widget_1mnemonic_1activate_FUNC,
+	_1gtk_1widget_1modify_1base_FUNC,
+	_1gtk_1widget_1modify_1bg_FUNC,
+	_1gtk_1widget_1modify_1fg_FUNC,
+	_1gtk_1widget_1modify_1font_FUNC,
+	_1gtk_1widget_1modify_1style_FUNC,
+	_1gtk_1widget_1modify_1text_FUNC,
+	_1gtk_1widget_1queue_1resize_FUNC,
+	_1gtk_1widget_1realize_FUNC,
+	_1gtk_1widget_1remove_1accelerator_FUNC,
+	_1gtk_1widget_1reparent_FUNC,
+	_1gtk_1widget_1send_1expose_FUNC,
+	_1gtk_1widget_1set_1app_1paintable_FUNC,
+	_1gtk_1widget_1set_1default_1direction_FUNC,
+	_1gtk_1widget_1set_1direction_FUNC,
+	_1gtk_1widget_1set_1double_1buffered_FUNC,
+	_1gtk_1widget_1set_1name_FUNC,
+	_1gtk_1widget_1set_1parent_1window_FUNC,
+	_1gtk_1widget_1set_1redraw_1on_1allocate_FUNC,
+	_1gtk_1widget_1set_1sensitive_FUNC,
+	_1gtk_1widget_1set_1size_1request_FUNC,
+	_1gtk_1widget_1set_1state_FUNC,
+	_1gtk_1widget_1set_1style_FUNC,
+	_1gtk_1widget_1set_1tooltip_1text_FUNC,
+	_1gtk_1widget_1shape_1combine_1mask_FUNC,
+	_1gtk_1widget_1show_FUNC,
+	_1gtk_1widget_1show_1now_FUNC,
+	_1gtk_1widget_1size_1allocate_FUNC,
+	_1gtk_1widget_1size_1request_FUNC,
+	_1gtk_1widget_1style_1get__I_3B_3II_FUNC,
+	_1gtk_1widget_1style_1get__I_3B_3JI_FUNC,
+	_1gtk_1widget_1translate_1coordinates_FUNC,
+	_1gtk_1widget_1unrealize_FUNC,
+	_1gtk_1window_1activate_1default_FUNC,
+	_1gtk_1window_1add_1accel_1group_FUNC,
+	_1gtk_1window_1deiconify_FUNC,
+	_1gtk_1window_1fullscreen_FUNC,
+	_1gtk_1window_1get_1focus_FUNC,
+	_1gtk_1window_1get_1group_FUNC,
+	_1gtk_1window_1get_1icon_1list_FUNC,
+	_1gtk_1window_1get_1mnemonic_1modifier_FUNC,
+	_1gtk_1window_1get_1modal_FUNC,
+	_1gtk_1window_1get_1opacity_FUNC,
+	_1gtk_1window_1get_1position_FUNC,
+	_1gtk_1window_1get_1size_FUNC,
+	_1gtk_1window_1group_1add_1window_FUNC,
+	_1gtk_1window_1group_1new_FUNC,
+	_1gtk_1window_1group_1remove_1window_FUNC,
+	_1gtk_1window_1iconify_FUNC,
+	_1gtk_1window_1list_1toplevels_FUNC,
+	_1gtk_1window_1maximize_FUNC,
+	_1gtk_1window_1move_FUNC,
+	_1gtk_1window_1new_FUNC,
+	_1gtk_1window_1present_FUNC,
+	_1gtk_1window_1remove_1accel_1group_FUNC,
+	_1gtk_1window_1resize_FUNC,
+	_1gtk_1window_1set_1default_FUNC,
+	_1gtk_1window_1set_1destroy_1with_1parent_FUNC,
+	_1gtk_1window_1set_1geometry_1hints_FUNC,
+	_1gtk_1window_1set_1icon_1list_FUNC,
+	_1gtk_1window_1set_1keep_1below_FUNC,
+	_1gtk_1window_1set_1modal_FUNC,
+	_1gtk_1window_1set_1opacity_FUNC,
+	_1gtk_1window_1set_1resizable_FUNC,
+	_1gtk_1window_1set_1skip_1taskbar_1hint_FUNC,
+	_1gtk_1window_1set_1title_FUNC,
+	_1gtk_1window_1set_1transient_1for_FUNC,
+	_1gtk_1window_1set_1type_1hint_FUNC,
+	_1gtk_1window_1unfullscreen_FUNC,
+	_1gtk_1window_1unmaximize_FUNC,
+	_1pango_1attr_1background_1new_FUNC,
+	_1pango_1attr_1font_1desc_1new_FUNC,
+	_1pango_1attr_1foreground_1new_FUNC,
+	_1pango_1attr_1iterator_1destroy_FUNC,
+	_1pango_1attr_1iterator_1get_FUNC,
+	_1pango_1attr_1iterator_1get_1attrs_FUNC,
+	_1pango_1attr_1iterator_1next_FUNC,
+	_1pango_1attr_1iterator_1range_FUNC,
+	_1pango_1attr_1list_1change_FUNC,
+	_1pango_1attr_1list_1get_1iterator_FUNC,
+	_1pango_1attr_1list_1insert_FUNC,
+	_1pango_1attr_1list_1new_FUNC,
+	_1pango_1attr_1list_1unref_FUNC,
+	_1pango_1attr_1rise_1new_FUNC,
+	_1pango_1attr_1shape_1new_FUNC,
+	_1pango_1attr_1strikethrough_1color_1new_FUNC,
+	_1pango_1attr_1strikethrough_1new_FUNC,
+	_1pango_1attr_1underline_1color_1new_FUNC,
+	_1pango_1attr_1underline_1new_FUNC,
+	_1pango_1attr_1weight_1new_FUNC,
+	_1pango_1cairo_1context_1get_1font_1options_FUNC,
+	_1pango_1cairo_1context_1set_1font_1options_FUNC,
+	_1pango_1cairo_1create_1layout_FUNC,
+	_1pango_1cairo_1font_1map_1create_1context_FUNC,
+	_1pango_1cairo_1font_1map_1get_1default_FUNC,
+	_1pango_1cairo_1font_1map_1new_FUNC,
+	_1pango_1cairo_1font_1map_1set_1resolution_FUNC,
+	_1pango_1cairo_1layout_1path_FUNC,
+	_1pango_1cairo_1show_1layout_FUNC,
+	_1pango_1context_1get_1base_1dir_FUNC,
+	_1pango_1context_1get_1language_FUNC,
+	_1pango_1context_1get_1metrics_FUNC,
+	_1pango_1context_1list_1families_FUNC,
+	_1pango_1context_1set_1base_1dir_FUNC,
+	_1pango_1context_1set_1language_FUNC,
+	_1pango_1font_1description_1copy_FUNC,
+	_1pango_1font_1description_1free_FUNC,
+	_1pango_1font_1description_1from_1string_FUNC,
+	_1pango_1font_1description_1get_1family_FUNC,
+	_1pango_1font_1description_1get_1size_FUNC,
+	_1pango_1font_1description_1get_1style_FUNC,
+	_1pango_1font_1description_1get_1weight_FUNC,
+	_1pango_1font_1description_1new_FUNC,
+	_1pango_1font_1description_1set_1family_FUNC,
+	_1pango_1font_1description_1set_1size_FUNC,
+	_1pango_1font_1description_1set_1stretch_FUNC,
+	_1pango_1font_1description_1set_1style_FUNC,
+	_1pango_1font_1description_1set_1weight_FUNC,
+	_1pango_1font_1description_1to_1string_FUNC,
+	_1pango_1font_1face_1describe_FUNC,
+	_1pango_1font_1family_1get_1name_FUNC,
+	_1pango_1font_1family_1list_1faces_FUNC,
+	_1pango_1font_1get_1metrics_FUNC,
+	_1pango_1font_1metrics_1get_1approximate_1char_1width_FUNC,
+	_1pango_1font_1metrics_1get_1ascent_FUNC,
+	_1pango_1font_1metrics_1get_1descent_FUNC,
+	_1pango_1font_1metrics_1get_1strikethrough_1position_FUNC,
+	_1pango_1font_1metrics_1get_1strikethrough_1thickness_FUNC,
+	_1pango_1font_1metrics_1get_1underline_1position_FUNC,
+	_1pango_1font_1metrics_1get_1underline_1thickness_FUNC,
+	_1pango_1font_1metrics_1unref_FUNC,
+	_1pango_1language_1from_1string_FUNC,
+	_1pango_1layout_1context_1changed_FUNC,
+	_1pango_1layout_1get_1alignment_FUNC,
+	_1pango_1layout_1get_1attributes_FUNC,
+	_1pango_1layout_1get_1context_FUNC,
+	_1pango_1layout_1get_1indent_FUNC,
+	_1pango_1layout_1get_1iter_FUNC,
+	_1pango_1layout_1get_1justify_FUNC,
+	_1pango_1layout_1get_1line_FUNC,
+	_1pango_1layout_1get_1line_1count_FUNC,
+	_1pango_1layout_1get_1log_1attrs_FUNC,
+	_1pango_1layout_1get_1size_FUNC,
+	_1pango_1layout_1get_1spacing_FUNC,
+	_1pango_1layout_1get_1tabs_FUNC,
+	_1pango_1layout_1get_1text_FUNC,
+	_1pango_1layout_1get_1width_FUNC,
+	_1pango_1layout_1index_1to_1pos_FUNC,
+	_1pango_1layout_1iter_1free_FUNC,
+	_1pango_1layout_1iter_1get_1index_FUNC,
+	_1pango_1layout_1iter_1get_1line_1extents_FUNC,
+	_1pango_1layout_1iter_1get_1run_FUNC,
+	_1pango_1layout_1iter_1next_1line_FUNC,
+	_1pango_1layout_1iter_1next_1run_FUNC,
+	_1pango_1layout_1line_1get_1extents_FUNC,
+	_1pango_1layout_1line_1get_1resolved_1dir_FUNC,
+	_1pango_1layout_1line_1x_1to_1index_FUNC,
+	_1pango_1layout_1new_FUNC,
+	_1pango_1layout_1set_1alignment_FUNC,
+	_1pango_1layout_1set_1attributes_FUNC,
+	_1pango_1layout_1set_1auto_1dir_FUNC,
+	_1pango_1layout_1set_1font_1description_FUNC,
+	_1pango_1layout_1set_1indent_FUNC,
+	_1pango_1layout_1set_1justify_FUNC,
+	_1pango_1layout_1set_1single_1paragraph_1mode_FUNC,
+	_1pango_1layout_1set_1spacing_FUNC,
+	_1pango_1layout_1set_1tabs_FUNC,
+	_1pango_1layout_1set_1text_FUNC,
+	_1pango_1layout_1set_1width_FUNC,
+	_1pango_1layout_1set_1wrap_FUNC,
+	_1pango_1layout_1xy_1to_1index_FUNC,
+	_1pango_1tab_1array_1free_FUNC,
+	_1pango_1tab_1array_1get_1size_FUNC,
+	_1pango_1tab_1array_1get_1tabs_FUNC,
+	_1pango_1tab_1array_1new_FUNC,
+	_1pango_1tab_1array_1set_1tab_FUNC,
+	g_1main_1context_1wakeup_FUNC,
+	localeconv_1decimal_1point_FUNC,
+	memmove__ILorg_eclipse_swt_internal_gtk_GInterfaceInfo_2I_FUNC,
+	memmove__ILorg_eclipse_swt_internal_gtk_GObjectClass_2_FUNC,
+	memmove__ILorg_eclipse_swt_internal_gtk_GTypeInfo_2I_FUNC,
+	memmove__ILorg_eclipse_swt_internal_gtk_GdkEventButton_2I_FUNC,
+	memmove__ILorg_eclipse_swt_internal_gtk_GdkEventExpose_2I_FUNC,
+	memmove__ILorg_eclipse_swt_internal_gtk_GdkEventMotion_2I_FUNC,
+	memmove__ILorg_eclipse_swt_internal_gtk_GtkAdjustment_2_FUNC,
+	memmove__ILorg_eclipse_swt_internal_gtk_GtkCellRendererClass_2_FUNC,
+	memmove__ILorg_eclipse_swt_internal_gtk_GtkFixed_2_FUNC,
+	memmove__ILorg_eclipse_swt_internal_gtk_GtkTargetEntry_2I_FUNC,
+	memmove__ILorg_eclipse_swt_internal_gtk_GtkWidgetClass_2_FUNC,
+	memmove__ILorg_eclipse_swt_internal_gtk_PangoAttribute_2I_FUNC,
+	memmove__ILorg_eclipse_swt_internal_gtk_XButtonEvent_2I_FUNC,
+	memmove__ILorg_eclipse_swt_internal_gtk_XClientMessageEvent_2I_FUNC,
+	memmove__ILorg_eclipse_swt_internal_gtk_XCrossingEvent_2I_FUNC,
+	memmove__ILorg_eclipse_swt_internal_gtk_XExposeEvent_2I_FUNC,
+	memmove__ILorg_eclipse_swt_internal_gtk_XFocusChangeEvent_2I_FUNC,
+	memmove__Lorg_eclipse_swt_internal_gtk_GObjectClass_2I_FUNC,
+	memmove__Lorg_eclipse_swt_internal_gtk_GTypeQuery_2II_FUNC,
+	memmove__Lorg_eclipse_swt_internal_gtk_GdkColor_2II_FUNC,
+	memmove__Lorg_eclipse_swt_internal_gtk_GdkDragContext_2II_FUNC,
+	memmove__Lorg_eclipse_swt_internal_gtk_GdkEventAny_2II_FUNC,
+	memmove__Lorg_eclipse_swt_internal_gtk_GdkEventButton_2II_FUNC,
+	memmove__Lorg_eclipse_swt_internal_gtk_GdkEventCrossing_2II_FUNC,
+	memmove__Lorg_eclipse_swt_internal_gtk_GdkEventExpose_2II_FUNC,
+	memmove__Lorg_eclipse_swt_internal_gtk_GdkEventFocus_2II_FUNC,
+	memmove__Lorg_eclipse_swt_internal_gtk_GdkEventKey_2II_FUNC,
+	memmove__Lorg_eclipse_swt_internal_gtk_GdkEventMotion_2II_FUNC,
+	memmove__Lorg_eclipse_swt_internal_gtk_GdkEventScroll_2II_FUNC,
+	memmove__Lorg_eclipse_swt_internal_gtk_GdkEventVisibility_2II_FUNC,
+	memmove__Lorg_eclipse_swt_internal_gtk_GdkEventWindowState_2II_FUNC,
+	memmove__Lorg_eclipse_swt_internal_gtk_GdkEvent_2II_FUNC,
+	memmove__Lorg_eclipse_swt_internal_gtk_GdkImage_2I_FUNC,
+	memmove__Lorg_eclipse_swt_internal_gtk_GdkRectangle_2II_FUNC,
+	memmove__Lorg_eclipse_swt_internal_gtk_GdkVisual_2I_FUNC,
+	memmove__Lorg_eclipse_swt_internal_gtk_GtkAdjustment_2I_FUNC,
+	memmove__Lorg_eclipse_swt_internal_gtk_GtkBorder_2II_FUNC,
+	memmove__Lorg_eclipse_swt_internal_gtk_GtkCellRendererClass_2I_FUNC,
+	memmove__Lorg_eclipse_swt_internal_gtk_GtkColorSelectionDialog_2I_FUNC,
+	memmove__Lorg_eclipse_swt_internal_gtk_GtkCombo_2I_FUNC,
+	memmove__Lorg_eclipse_swt_internal_gtk_GtkFileSelection_2I_FUNC,
+	memmove__Lorg_eclipse_swt_internal_gtk_GtkFixed_2I_FUNC,
+	memmove__Lorg_eclipse_swt_internal_gtk_GtkSelectionData_2II_FUNC,
+	memmove__Lorg_eclipse_swt_internal_gtk_GtkTargetPair_2II_FUNC,
+	memmove__Lorg_eclipse_swt_internal_gtk_GtkWidgetClass_2I_FUNC,
+	memmove__Lorg_eclipse_swt_internal_gtk_PangoAttrColor_2II_FUNC,
+	memmove__Lorg_eclipse_swt_internal_gtk_PangoAttrInt_2II_FUNC,
+	memmove__Lorg_eclipse_swt_internal_gtk_PangoAttribute_2II_FUNC,
+	memmove__Lorg_eclipse_swt_internal_gtk_PangoItem_2II_FUNC,
+	memmove__Lorg_eclipse_swt_internal_gtk_PangoLayoutLine_2II_FUNC,
+	memmove__Lorg_eclipse_swt_internal_gtk_PangoLayoutRun_2II_FUNC,
+	memmove__Lorg_eclipse_swt_internal_gtk_PangoLogAttr_2II_FUNC,
+	memmove__Lorg_eclipse_swt_internal_gtk_XButtonEvent_2II_FUNC,
+	memmove__Lorg_eclipse_swt_internal_gtk_XCrossingEvent_2II_FUNC,
+	memmove__Lorg_eclipse_swt_internal_gtk_XExposeEvent_2II_FUNC,
+	memmove__Lorg_eclipse_swt_internal_gtk_XFocusChangeEvent_2II_FUNC,
+	memmove__Lorg_eclipse_swt_internal_gtk_XVisibilityEvent_2II_FUNC,
+	realpath_FUNC,
+} OS_FUNCS;

Added: branches/upstream/swt-gtk/current/os_structs.c
===================================================================
--- branches/upstream/swt-gtk/current/os_structs.c	                        (rev 0)
+++ branches/upstream/swt-gtk/current/os_structs.c	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,2823 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others. All rights reserved.
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt).  The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html.  If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+#include "swt.h"
+#include "os_structs.h"
+
+#ifndef NO_GInterfaceInfo
+typedef struct GInterfaceInfo_FID_CACHE {
+	int cached;
+	jclass clazz;
+	jfieldID interface_init, interface_finalize, interface_data;
+} GInterfaceInfo_FID_CACHE;
+
+GInterfaceInfo_FID_CACHE GInterfaceInfoFc;
+
+void cacheGInterfaceInfoFields(JNIEnv *env, jobject lpObject)
+{
+	if (GInterfaceInfoFc.cached) return;
+	GInterfaceInfoFc.clazz = (*env)->GetObjectClass(env, lpObject);
+	GInterfaceInfoFc.interface_init = (*env)->GetFieldID(env, GInterfaceInfoFc.clazz, "interface_init", "I");
+	GInterfaceInfoFc.interface_finalize = (*env)->GetFieldID(env, GInterfaceInfoFc.clazz, "interface_finalize", "I");
+	GInterfaceInfoFc.interface_data = (*env)->GetFieldID(env, GInterfaceInfoFc.clazz, "interface_data", "I");
+	GInterfaceInfoFc.cached = 1;
+}
+
+GInterfaceInfo *getGInterfaceInfoFields(JNIEnv *env, jobject lpObject, GInterfaceInfo *lpStruct)
+{
+	if (!GInterfaceInfoFc.cached) cacheGInterfaceInfoFields(env, lpObject);
+	lpStruct->interface_init = (GInterfaceInitFunc)(*env)->GetIntField(env, lpObject, GInterfaceInfoFc.interface_init);
+	lpStruct->interface_finalize = (GInterfaceFinalizeFunc)(*env)->GetIntField(env, lpObject, GInterfaceInfoFc.interface_finalize);
+	lpStruct->interface_data = (gpointer)(*env)->GetIntField(env, lpObject, GInterfaceInfoFc.interface_data);
+	return lpStruct;
+}
+
+void setGInterfaceInfoFields(JNIEnv *env, jobject lpObject, GInterfaceInfo *lpStruct)
+{
+	if (!GInterfaceInfoFc.cached) cacheGInterfaceInfoFields(env, lpObject);
+	(*env)->SetIntField(env, lpObject, GInterfaceInfoFc.interface_init, (jint)lpStruct->interface_init);
+	(*env)->SetIntField(env, lpObject, GInterfaceInfoFc.interface_finalize, (jint)lpStruct->interface_finalize);
+	(*env)->SetIntField(env, lpObject, GInterfaceInfoFc.interface_data, (jint)lpStruct->interface_data);
+}
+#endif
+
+#ifndef NO_GObjectClass
+typedef struct GObjectClass_FID_CACHE {
+	int cached;
+	jclass clazz;
+	jfieldID constructor, set_property, get_property, dispose, finalize, dispatch_properties_changed, notify;
+} GObjectClass_FID_CACHE;
+
+GObjectClass_FID_CACHE GObjectClassFc;
+
+void cacheGObjectClassFields(JNIEnv *env, jobject lpObject)
+{
+	if (GObjectClassFc.cached) return;
+	GObjectClassFc.clazz = (*env)->GetObjectClass(env, lpObject);
+	GObjectClassFc.constructor = (*env)->GetFieldID(env, GObjectClassFc.clazz, "constructor", "I");
+	GObjectClassFc.set_property = (*env)->GetFieldID(env, GObjectClassFc.clazz, "set_property", "I");
+	GObjectClassFc.get_property = (*env)->GetFieldID(env, GObjectClassFc.clazz, "get_property", "I");
+	GObjectClassFc.dispose = (*env)->GetFieldID(env, GObjectClassFc.clazz, "dispose", "I");
+	GObjectClassFc.finalize = (*env)->GetFieldID(env, GObjectClassFc.clazz, "finalize", "I");
+	GObjectClassFc.dispatch_properties_changed = (*env)->GetFieldID(env, GObjectClassFc.clazz, "dispatch_properties_changed", "I");
+	GObjectClassFc.notify = (*env)->GetFieldID(env, GObjectClassFc.clazz, "notify", "I");
+	GObjectClassFc.cached = 1;
+}
+
+GObjectClass *getGObjectClassFields(JNIEnv *env, jobject lpObject, GObjectClass *lpStruct)
+{
+	if (!GObjectClassFc.cached) cacheGObjectClassFields(env, lpObject);
+	lpStruct->constructor = (GObject *(*)())(*env)->GetIntField(env, lpObject, GObjectClassFc.constructor);
+	lpStruct->set_property = (void (*)())(*env)->GetIntField(env, lpObject, GObjectClassFc.set_property);
+	lpStruct->get_property = (void (*)())(*env)->GetIntField(env, lpObject, GObjectClassFc.get_property);
+	lpStruct->dispose = (void (*)())(*env)->GetIntField(env, lpObject, GObjectClassFc.dispose);
+	lpStruct->finalize = (void (*)())(*env)->GetIntField(env, lpObject, GObjectClassFc.finalize);
+	lpStruct->dispatch_properties_changed = (void (*)())(*env)->GetIntField(env, lpObject, GObjectClassFc.dispatch_properties_changed);
+	lpStruct->notify = (void (*)())(*env)->GetIntField(env, lpObject, GObjectClassFc.notify);
+	return lpStruct;
+}
+
+void setGObjectClassFields(JNIEnv *env, jobject lpObject, GObjectClass *lpStruct)
+{
+	if (!GObjectClassFc.cached) cacheGObjectClassFields(env, lpObject);
+	(*env)->SetIntField(env, lpObject, GObjectClassFc.constructor, (jint)lpStruct->constructor);
+	(*env)->SetIntField(env, lpObject, GObjectClassFc.set_property, (jint)lpStruct->set_property);
+	(*env)->SetIntField(env, lpObject, GObjectClassFc.get_property, (jint)lpStruct->get_property);
+	(*env)->SetIntField(env, lpObject, GObjectClassFc.dispose, (jint)lpStruct->dispose);
+	(*env)->SetIntField(env, lpObject, GObjectClassFc.finalize, (jint)lpStruct->finalize);
+	(*env)->SetIntField(env, lpObject, GObjectClassFc.dispatch_properties_changed, (jint)lpStruct->dispatch_properties_changed);
+	(*env)->SetIntField(env, lpObject, GObjectClassFc.notify, (jint)lpStruct->notify);
+}
+#endif
+
+#ifndef NO_GTypeInfo
+typedef struct GTypeInfo_FID_CACHE {
+	int cached;
+	jclass clazz;
+	jfieldID class_size, base_init, base_finalize, class_init, class_finalize, class_data, instance_size, n_preallocs, instance_init, value_table;
+} GTypeInfo_FID_CACHE;
+
+GTypeInfo_FID_CACHE GTypeInfoFc;
+
+void cacheGTypeInfoFields(JNIEnv *env, jobject lpObject)
+{
+	if (GTypeInfoFc.cached) return;
+	GTypeInfoFc.clazz = (*env)->GetObjectClass(env, lpObject);
+	GTypeInfoFc.class_size = (*env)->GetFieldID(env, GTypeInfoFc.clazz, "class_size", "S");
+	GTypeInfoFc.base_init = (*env)->GetFieldID(env, GTypeInfoFc.clazz, "base_init", "I");
+	GTypeInfoFc.base_finalize = (*env)->GetFieldID(env, GTypeInfoFc.clazz, "base_finalize", "I");
+	GTypeInfoFc.class_init = (*env)->GetFieldID(env, GTypeInfoFc.clazz, "class_init", "I");
+	GTypeInfoFc.class_finalize = (*env)->GetFieldID(env, GTypeInfoFc.clazz, "class_finalize", "I");
+	GTypeInfoFc.class_data = (*env)->GetFieldID(env, GTypeInfoFc.clazz, "class_data", "I");
+	GTypeInfoFc.instance_size = (*env)->GetFieldID(env, GTypeInfoFc.clazz, "instance_size", "S");
+	GTypeInfoFc.n_preallocs = (*env)->GetFieldID(env, GTypeInfoFc.clazz, "n_preallocs", "S");
+	GTypeInfoFc.instance_init = (*env)->GetFieldID(env, GTypeInfoFc.clazz, "instance_init", "I");
+	GTypeInfoFc.value_table = (*env)->GetFieldID(env, GTypeInfoFc.clazz, "value_table", "I");
+	GTypeInfoFc.cached = 1;
+}
+
+GTypeInfo *getGTypeInfoFields(JNIEnv *env, jobject lpObject, GTypeInfo *lpStruct)
+{
+	if (!GTypeInfoFc.cached) cacheGTypeInfoFields(env, lpObject);
+	lpStruct->class_size = (guint16)(*env)->GetShortField(env, lpObject, GTypeInfoFc.class_size);
+	lpStruct->base_init = (GBaseInitFunc)(*env)->GetIntField(env, lpObject, GTypeInfoFc.base_init);
+	lpStruct->base_finalize = (GBaseFinalizeFunc)(*env)->GetIntField(env, lpObject, GTypeInfoFc.base_finalize);
+	lpStruct->class_init = (GClassInitFunc)(*env)->GetIntField(env, lpObject, GTypeInfoFc.class_init);
+	lpStruct->class_finalize = (GClassFinalizeFunc)(*env)->GetIntField(env, lpObject, GTypeInfoFc.class_finalize);
+	lpStruct->class_data = (gconstpointer)(*env)->GetIntField(env, lpObject, GTypeInfoFc.class_data);
+	lpStruct->instance_size = (guint16)(*env)->GetShortField(env, lpObject, GTypeInfoFc.instance_size);
+	lpStruct->n_preallocs = (guint16)(*env)->GetShortField(env, lpObject, GTypeInfoFc.n_preallocs);
+	lpStruct->instance_init = (GInstanceInitFunc)(*env)->GetIntField(env, lpObject, GTypeInfoFc.instance_init);
+	lpStruct->value_table = (GTypeValueTable *)(*env)->GetIntField(env, lpObject, GTypeInfoFc.value_table);
+	return lpStruct;
+}
+
+void setGTypeInfoFields(JNIEnv *env, jobject lpObject, GTypeInfo *lpStruct)
+{
+	if (!GTypeInfoFc.cached) cacheGTypeInfoFields(env, lpObject);
+	(*env)->SetShortField(env, lpObject, GTypeInfoFc.class_size, (jshort)lpStruct->class_size);
+	(*env)->SetIntField(env, lpObject, GTypeInfoFc.base_init, (jint)lpStruct->base_init);
+	(*env)->SetIntField(env, lpObject, GTypeInfoFc.base_finalize, (jint)lpStruct->base_finalize);
+	(*env)->SetIntField(env, lpObject, GTypeInfoFc.class_init, (jint)lpStruct->class_init);
+	(*env)->SetIntField(env, lpObject, GTypeInfoFc.class_finalize, (jint)lpStruct->class_finalize);
+	(*env)->SetIntField(env, lpObject, GTypeInfoFc.class_data, (jint)lpStruct->class_data);
+	(*env)->SetShortField(env, lpObject, GTypeInfoFc.instance_size, (jshort)lpStruct->instance_size);
+	(*env)->SetShortField(env, lpObject, GTypeInfoFc.n_preallocs, (jshort)lpStruct->n_preallocs);
+	(*env)->SetIntField(env, lpObject, GTypeInfoFc.instance_init, (jint)lpStruct->instance_init);
+	(*env)->SetIntField(env, lpObject, GTypeInfoFc.value_table, (jint)lpStruct->value_table);
+}
+#endif
+
+#ifndef NO_GTypeQuery
+typedef struct GTypeQuery_FID_CACHE {
+	int cached;
+	jclass clazz;
+	jfieldID type, type_name, class_size, instance_size;
+} GTypeQuery_FID_CACHE;
+
+GTypeQuery_FID_CACHE GTypeQueryFc;
+
+void cacheGTypeQueryFields(JNIEnv *env, jobject lpObject)
+{
+	if (GTypeQueryFc.cached) return;
+	GTypeQueryFc.clazz = (*env)->GetObjectClass(env, lpObject);
+	GTypeQueryFc.type = (*env)->GetFieldID(env, GTypeQueryFc.clazz, "type", "I");
+	GTypeQueryFc.type_name = (*env)->GetFieldID(env, GTypeQueryFc.clazz, "type_name", "I");
+	GTypeQueryFc.class_size = (*env)->GetFieldID(env, GTypeQueryFc.clazz, "class_size", "I");
+	GTypeQueryFc.instance_size = (*env)->GetFieldID(env, GTypeQueryFc.clazz, "instance_size", "I");
+	GTypeQueryFc.cached = 1;
+}
+
+GTypeQuery *getGTypeQueryFields(JNIEnv *env, jobject lpObject, GTypeQuery *lpStruct)
+{
+	if (!GTypeQueryFc.cached) cacheGTypeQueryFields(env, lpObject);
+	lpStruct->type = (GType)(*env)->GetIntField(env, lpObject, GTypeQueryFc.type);
+	lpStruct->type_name = (const gchar *)(*env)->GetIntField(env, lpObject, GTypeQueryFc.type_name);
+	lpStruct->class_size = (guint)(*env)->GetIntField(env, lpObject, GTypeQueryFc.class_size);
+	lpStruct->instance_size = (guint)(*env)->GetIntField(env, lpObject, GTypeQueryFc.instance_size);
+	return lpStruct;
+}
+
+void setGTypeQueryFields(JNIEnv *env, jobject lpObject, GTypeQuery *lpStruct)
+{
+	if (!GTypeQueryFc.cached) cacheGTypeQueryFields(env, lpObject);
+	(*env)->SetIntField(env, lpObject, GTypeQueryFc.type, (jint)lpStruct->type);
+	(*env)->SetIntField(env, lpObject, GTypeQueryFc.type_name, (jint)lpStruct->type_name);
+	(*env)->SetIntField(env, lpObject, GTypeQueryFc.class_size, (jint)lpStruct->class_size);
+	(*env)->SetIntField(env, lpObject, GTypeQueryFc.instance_size, (jint)lpStruct->instance_size);
+}
+#endif
+
+#ifndef NO_GdkColor
+typedef struct GdkColor_FID_CACHE {
+	int cached;
+	jclass clazz;
+	jfieldID pixel, red, green, blue;
+} GdkColor_FID_CACHE;
+
+GdkColor_FID_CACHE GdkColorFc;
+
+void cacheGdkColorFields(JNIEnv *env, jobject lpObject)
+{
+	if (GdkColorFc.cached) return;
+	GdkColorFc.clazz = (*env)->GetObjectClass(env, lpObject);
+	GdkColorFc.pixel = (*env)->GetFieldID(env, GdkColorFc.clazz, "pixel", "I");
+	GdkColorFc.red = (*env)->GetFieldID(env, GdkColorFc.clazz, "red", "S");
+	GdkColorFc.green = (*env)->GetFieldID(env, GdkColorFc.clazz, "green", "S");
+	GdkColorFc.blue = (*env)->GetFieldID(env, GdkColorFc.clazz, "blue", "S");
+	GdkColorFc.cached = 1;
+}
+
+GdkColor *getGdkColorFields(JNIEnv *env, jobject lpObject, GdkColor *lpStruct)
+{
+	if (!GdkColorFc.cached) cacheGdkColorFields(env, lpObject);
+	lpStruct->pixel = (guint32)(*env)->GetIntField(env, lpObject, GdkColorFc.pixel);
+	lpStruct->red = (guint16)(*env)->GetShortField(env, lpObject, GdkColorFc.red);
+	lpStruct->green = (guint16)(*env)->GetShortField(env, lpObject, GdkColorFc.green);
+	lpStruct->blue = (guint16)(*env)->GetShortField(env, lpObject, GdkColorFc.blue);
+	return lpStruct;
+}
+
+void setGdkColorFields(JNIEnv *env, jobject lpObject, GdkColor *lpStruct)
+{
+	if (!GdkColorFc.cached) cacheGdkColorFields(env, lpObject);
+	(*env)->SetIntField(env, lpObject, GdkColorFc.pixel, (jint)lpStruct->pixel);
+	(*env)->SetShortField(env, lpObject, GdkColorFc.red, (jshort)lpStruct->red);
+	(*env)->SetShortField(env, lpObject, GdkColorFc.green, (jshort)lpStruct->green);
+	(*env)->SetShortField(env, lpObject, GdkColorFc.blue, (jshort)lpStruct->blue);
+}
+#endif
+
+#ifndef NO_GdkDragContext
+typedef struct GdkDragContext_FID_CACHE {
+	int cached;
+	jclass clazz;
+	jfieldID protocol, is_source, source_window, dest_window, targets, actions, suggested_action, action, start_time;
+} GdkDragContext_FID_CACHE;
+
+GdkDragContext_FID_CACHE GdkDragContextFc;
+
+void cacheGdkDragContextFields(JNIEnv *env, jobject lpObject)
+{
+	if (GdkDragContextFc.cached) return;
+	GdkDragContextFc.clazz = (*env)->GetObjectClass(env, lpObject);
+	GdkDragContextFc.protocol = (*env)->GetFieldID(env, GdkDragContextFc.clazz, "protocol", "I");
+	GdkDragContextFc.is_source = (*env)->GetFieldID(env, GdkDragContextFc.clazz, "is_source", "Z");
+	GdkDragContextFc.source_window = (*env)->GetFieldID(env, GdkDragContextFc.clazz, "source_window", "I");
+	GdkDragContextFc.dest_window = (*env)->GetFieldID(env, GdkDragContextFc.clazz, "dest_window", "I");
+	GdkDragContextFc.targets = (*env)->GetFieldID(env, GdkDragContextFc.clazz, "targets", "I");
+	GdkDragContextFc.actions = (*env)->GetFieldID(env, GdkDragContextFc.clazz, "actions", "I");
+	GdkDragContextFc.suggested_action = (*env)->GetFieldID(env, GdkDragContextFc.clazz, "suggested_action", "I");
+	GdkDragContextFc.action = (*env)->GetFieldID(env, GdkDragContextFc.clazz, "action", "I");
+	GdkDragContextFc.start_time = (*env)->GetFieldID(env, GdkDragContextFc.clazz, "start_time", "I");
+	GdkDragContextFc.cached = 1;
+}
+
+GdkDragContext *getGdkDragContextFields(JNIEnv *env, jobject lpObject, GdkDragContext *lpStruct)
+{
+	if (!GdkDragContextFc.cached) cacheGdkDragContextFields(env, lpObject);
+	lpStruct->protocol = (GdkDragProtocol)(*env)->GetIntField(env, lpObject, GdkDragContextFc.protocol);
+	lpStruct->is_source = (gboolean)(*env)->GetBooleanField(env, lpObject, GdkDragContextFc.is_source);
+	lpStruct->source_window = (GdkWindow *)(*env)->GetIntField(env, lpObject, GdkDragContextFc.source_window);
+	lpStruct->dest_window = (GdkWindow *)(*env)->GetIntField(env, lpObject, GdkDragContextFc.dest_window);
+	lpStruct->targets = (GList *)(*env)->GetIntField(env, lpObject, GdkDragContextFc.targets);
+	lpStruct->actions = (GdkDragAction)(*env)->GetIntField(env, lpObject, GdkDragContextFc.actions);
+	lpStruct->suggested_action = (GdkDragAction)(*env)->GetIntField(env, lpObject, GdkDragContextFc.suggested_action);
+	lpStruct->action = (GdkDragAction)(*env)->GetIntField(env, lpObject, GdkDragContextFc.action);
+	lpStruct->start_time = (guint32)(*env)->GetIntField(env, lpObject, GdkDragContextFc.start_time);
+	return lpStruct;
+}
+
+void setGdkDragContextFields(JNIEnv *env, jobject lpObject, GdkDragContext *lpStruct)
+{
+	if (!GdkDragContextFc.cached) cacheGdkDragContextFields(env, lpObject);
+	(*env)->SetIntField(env, lpObject, GdkDragContextFc.protocol, (jint)lpStruct->protocol);
+	(*env)->SetBooleanField(env, lpObject, GdkDragContextFc.is_source, (jboolean)lpStruct->is_source);
+	(*env)->SetIntField(env, lpObject, GdkDragContextFc.source_window, (jint)lpStruct->source_window);
+	(*env)->SetIntField(env, lpObject, GdkDragContextFc.dest_window, (jint)lpStruct->dest_window);
+	(*env)->SetIntField(env, lpObject, GdkDragContextFc.targets, (jint)lpStruct->targets);
+	(*env)->SetIntField(env, lpObject, GdkDragContextFc.actions, (jint)lpStruct->actions);
+	(*env)->SetIntField(env, lpObject, GdkDragContextFc.suggested_action, (jint)lpStruct->suggested_action);
+	(*env)->SetIntField(env, lpObject, GdkDragContextFc.action, (jint)lpStruct->action);
+	(*env)->SetIntField(env, lpObject, GdkDragContextFc.start_time, (jint)lpStruct->start_time);
+}
+#endif
+
+#ifndef NO_GdkEvent
+typedef struct GdkEvent_FID_CACHE {
+	int cached;
+	jclass clazz;
+	jfieldID type;
+} GdkEvent_FID_CACHE;
+
+GdkEvent_FID_CACHE GdkEventFc;
+
+void cacheGdkEventFields(JNIEnv *env, jobject lpObject)
+{
+	if (GdkEventFc.cached) return;
+	GdkEventFc.clazz = (*env)->GetObjectClass(env, lpObject);
+	GdkEventFc.type = (*env)->GetFieldID(env, GdkEventFc.clazz, "type", "I");
+	GdkEventFc.cached = 1;
+}
+
+GdkEvent *getGdkEventFields(JNIEnv *env, jobject lpObject, GdkEvent *lpStruct)
+{
+	if (!GdkEventFc.cached) cacheGdkEventFields(env, lpObject);
+	lpStruct->type = (GdkEventType)(*env)->GetIntField(env, lpObject, GdkEventFc.type);
+	return lpStruct;
+}
+
+void setGdkEventFields(JNIEnv *env, jobject lpObject, GdkEvent *lpStruct)
+{
+	if (!GdkEventFc.cached) cacheGdkEventFields(env, lpObject);
+	(*env)->SetIntField(env, lpObject, GdkEventFc.type, (jint)lpStruct->type);
+}
+#endif
+
+#ifndef NO_GdkEventAny
+typedef struct GdkEventAny_FID_CACHE {
+	int cached;
+	jclass clazz;
+	jfieldID window, send_event;
+} GdkEventAny_FID_CACHE;
+
+GdkEventAny_FID_CACHE GdkEventAnyFc;
+
+void cacheGdkEventAnyFields(JNIEnv *env, jobject lpObject)
+{
+	if (GdkEventAnyFc.cached) return;
+	cacheGdkEventFields(env, lpObject);
+	GdkEventAnyFc.clazz = (*env)->GetObjectClass(env, lpObject);
+	GdkEventAnyFc.window = (*env)->GetFieldID(env, GdkEventAnyFc.clazz, "window", "I");
+	GdkEventAnyFc.send_event = (*env)->GetFieldID(env, GdkEventAnyFc.clazz, "send_event", "B");
+	GdkEventAnyFc.cached = 1;
+}
+
+GdkEventAny *getGdkEventAnyFields(JNIEnv *env, jobject lpObject, GdkEventAny *lpStruct)
+{
+	if (!GdkEventAnyFc.cached) cacheGdkEventAnyFields(env, lpObject);
+	getGdkEventFields(env, lpObject, (GdkEvent *)lpStruct);
+	lpStruct->window = (GdkWindow *)(*env)->GetIntField(env, lpObject, GdkEventAnyFc.window);
+	lpStruct->send_event = (gint8)(*env)->GetByteField(env, lpObject, GdkEventAnyFc.send_event);
+	return lpStruct;
+}
+
+void setGdkEventAnyFields(JNIEnv *env, jobject lpObject, GdkEventAny *lpStruct)
+{
+	if (!GdkEventAnyFc.cached) cacheGdkEventAnyFields(env, lpObject);
+	setGdkEventFields(env, lpObject, (GdkEvent *)lpStruct);
+	(*env)->SetIntField(env, lpObject, GdkEventAnyFc.window, (jint)lpStruct->window);
+	(*env)->SetByteField(env, lpObject, GdkEventAnyFc.send_event, (jbyte)lpStruct->send_event);
+}
+#endif
+
+#ifndef NO_GdkEventButton
+typedef struct GdkEventButton_FID_CACHE {
+	int cached;
+	jclass clazz;
+	jfieldID window, send_event, time, x, y, axes, state, button, device, x_root, y_root;
+} GdkEventButton_FID_CACHE;
+
+GdkEventButton_FID_CACHE GdkEventButtonFc;
+
+void cacheGdkEventButtonFields(JNIEnv *env, jobject lpObject)
+{
+	if (GdkEventButtonFc.cached) return;
+	cacheGdkEventFields(env, lpObject);
+	GdkEventButtonFc.clazz = (*env)->GetObjectClass(env, lpObject);
+	GdkEventButtonFc.window = (*env)->GetFieldID(env, GdkEventButtonFc.clazz, "window", "I");
+	GdkEventButtonFc.send_event = (*env)->GetFieldID(env, GdkEventButtonFc.clazz, "send_event", "B");
+	GdkEventButtonFc.time = (*env)->GetFieldID(env, GdkEventButtonFc.clazz, "time", "I");
+	GdkEventButtonFc.x = (*env)->GetFieldID(env, GdkEventButtonFc.clazz, "x", "D");
+	GdkEventButtonFc.y = (*env)->GetFieldID(env, GdkEventButtonFc.clazz, "y", "D");
+	GdkEventButtonFc.axes = (*env)->GetFieldID(env, GdkEventButtonFc.clazz, "axes", "I");
+	GdkEventButtonFc.state = (*env)->GetFieldID(env, GdkEventButtonFc.clazz, "state", "I");
+	GdkEventButtonFc.button = (*env)->GetFieldID(env, GdkEventButtonFc.clazz, "button", "I");
+	GdkEventButtonFc.device = (*env)->GetFieldID(env, GdkEventButtonFc.clazz, "device", "I");
+	GdkEventButtonFc.x_root = (*env)->GetFieldID(env, GdkEventButtonFc.clazz, "x_root", "D");
+	GdkEventButtonFc.y_root = (*env)->GetFieldID(env, GdkEventButtonFc.clazz, "y_root", "D");
+	GdkEventButtonFc.cached = 1;
+}
+
+GdkEventButton *getGdkEventButtonFields(JNIEnv *env, jobject lpObject, GdkEventButton *lpStruct)
+{
+	if (!GdkEventButtonFc.cached) cacheGdkEventButtonFields(env, lpObject);
+	getGdkEventFields(env, lpObject, (GdkEvent *)lpStruct);
+	lpStruct->window = (GdkWindow *)(*env)->GetIntField(env, lpObject, GdkEventButtonFc.window);
+	lpStruct->send_event = (gint8)(*env)->GetByteField(env, lpObject, GdkEventButtonFc.send_event);
+	lpStruct->time = (guint32)(*env)->GetIntField(env, lpObject, GdkEventButtonFc.time);
+	lpStruct->x = (gdouble)(*env)->GetDoubleField(env, lpObject, GdkEventButtonFc.x);
+	lpStruct->y = (gdouble)(*env)->GetDoubleField(env, lpObject, GdkEventButtonFc.y);
+	lpStruct->axes = (gdouble *)(*env)->GetIntField(env, lpObject, GdkEventButtonFc.axes);
+	lpStruct->state = (guint)(*env)->GetIntField(env, lpObject, GdkEventButtonFc.state);
+	lpStruct->button = (guint)(*env)->GetIntField(env, lpObject, GdkEventButtonFc.button);
+	lpStruct->device = (GdkDevice *)(*env)->GetIntField(env, lpObject, GdkEventButtonFc.device);
+	lpStruct->x_root = (gdouble)(*env)->GetDoubleField(env, lpObject, GdkEventButtonFc.x_root);
+	lpStruct->y_root = (gdouble)(*env)->GetDoubleField(env, lpObject, GdkEventButtonFc.y_root);
+	return lpStruct;
+}
+
+void setGdkEventButtonFields(JNIEnv *env, jobject lpObject, GdkEventButton *lpStruct)
+{
+	if (!GdkEventButtonFc.cached) cacheGdkEventButtonFields(env, lpObject);
+	setGdkEventFields(env, lpObject, (GdkEvent *)lpStruct);
+	(*env)->SetIntField(env, lpObject, GdkEventButtonFc.window, (jint)lpStruct->window);
+	(*env)->SetByteField(env, lpObject, GdkEventButtonFc.send_event, (jbyte)lpStruct->send_event);
+	(*env)->SetIntField(env, lpObject, GdkEventButtonFc.time, (jint)lpStruct->time);
+	(*env)->SetDoubleField(env, lpObject, GdkEventButtonFc.x, (jdouble)lpStruct->x);
+	(*env)->SetDoubleField(env, lpObject, GdkEventButtonFc.y, (jdouble)lpStruct->y);
+	(*env)->SetIntField(env, lpObject, GdkEventButtonFc.axes, (jint)lpStruct->axes);
+	(*env)->SetIntField(env, lpObject, GdkEventButtonFc.state, (jint)lpStruct->state);
+	(*env)->SetIntField(env, lpObject, GdkEventButtonFc.button, (jint)lpStruct->button);
+	(*env)->SetIntField(env, lpObject, GdkEventButtonFc.device, (jint)lpStruct->device);
+	(*env)->SetDoubleField(env, lpObject, GdkEventButtonFc.x_root, (jdouble)lpStruct->x_root);
+	(*env)->SetDoubleField(env, lpObject, GdkEventButtonFc.y_root, (jdouble)lpStruct->y_root);
+}
+#endif
+
+#ifndef NO_GdkEventCrossing
+typedef struct GdkEventCrossing_FID_CACHE {
+	int cached;
+	jclass clazz;
+	jfieldID window, send_event, subwindow, time, x, y, x_root, y_root, mode, detail, focus, state;
+} GdkEventCrossing_FID_CACHE;
+
+GdkEventCrossing_FID_CACHE GdkEventCrossingFc;
+
+void cacheGdkEventCrossingFields(JNIEnv *env, jobject lpObject)
+{
+	if (GdkEventCrossingFc.cached) return;
+	cacheGdkEventFields(env, lpObject);
+	GdkEventCrossingFc.clazz = (*env)->GetObjectClass(env, lpObject);
+	GdkEventCrossingFc.window = (*env)->GetFieldID(env, GdkEventCrossingFc.clazz, "window", "I");
+	GdkEventCrossingFc.send_event = (*env)->GetFieldID(env, GdkEventCrossingFc.clazz, "send_event", "B");
+	GdkEventCrossingFc.subwindow = (*env)->GetFieldID(env, GdkEventCrossingFc.clazz, "subwindow", "I");
+	GdkEventCrossingFc.time = (*env)->GetFieldID(env, GdkEventCrossingFc.clazz, "time", "I");
+	GdkEventCrossingFc.x = (*env)->GetFieldID(env, GdkEventCrossingFc.clazz, "x", "D");
+	GdkEventCrossingFc.y = (*env)->GetFieldID(env, GdkEventCrossingFc.clazz, "y", "D");
+	GdkEventCrossingFc.x_root = (*env)->GetFieldID(env, GdkEventCrossingFc.clazz, "x_root", "D");
+	GdkEventCrossingFc.y_root = (*env)->GetFieldID(env, GdkEventCrossingFc.clazz, "y_root", "D");
+	GdkEventCrossingFc.mode = (*env)->GetFieldID(env, GdkEventCrossingFc.clazz, "mode", "I");
+	GdkEventCrossingFc.detail = (*env)->GetFieldID(env, GdkEventCrossingFc.clazz, "detail", "I");
+	GdkEventCrossingFc.focus = (*env)->GetFieldID(env, GdkEventCrossingFc.clazz, "focus", "Z");
+	GdkEventCrossingFc.state = (*env)->GetFieldID(env, GdkEventCrossingFc.clazz, "state", "I");
+	GdkEventCrossingFc.cached = 1;
+}
+
+GdkEventCrossing *getGdkEventCrossingFields(JNIEnv *env, jobject lpObject, GdkEventCrossing *lpStruct)
+{
+	if (!GdkEventCrossingFc.cached) cacheGdkEventCrossingFields(env, lpObject);
+	getGdkEventFields(env, lpObject, (GdkEvent *)lpStruct);
+	lpStruct->window = (GdkWindow *)(*env)->GetIntField(env, lpObject, GdkEventCrossingFc.window);
+	lpStruct->send_event = (gint8)(*env)->GetByteField(env, lpObject, GdkEventCrossingFc.send_event);
+	lpStruct->subwindow = (GdkWindow *)(*env)->GetIntField(env, lpObject, GdkEventCrossingFc.subwindow);
+	lpStruct->time = (*env)->GetIntField(env, lpObject, GdkEventCrossingFc.time);
+	lpStruct->x = (*env)->GetDoubleField(env, lpObject, GdkEventCrossingFc.x);
+	lpStruct->y = (*env)->GetDoubleField(env, lpObject, GdkEventCrossingFc.y);
+	lpStruct->x_root = (*env)->GetDoubleField(env, lpObject, GdkEventCrossingFc.x_root);
+	lpStruct->y_root = (*env)->GetDoubleField(env, lpObject, GdkEventCrossingFc.y_root);
+	lpStruct->mode = (GdkCrossingMode)(*env)->GetIntField(env, lpObject, GdkEventCrossingFc.mode);
+	lpStruct->detail = (GdkNotifyType)(*env)->GetIntField(env, lpObject, GdkEventCrossingFc.detail);
+	lpStruct->focus = (gboolean)(*env)->GetBooleanField(env, lpObject, GdkEventCrossingFc.focus);
+	lpStruct->state = (*env)->GetIntField(env, lpObject, GdkEventCrossingFc.state);
+	return lpStruct;
+}
+
+void setGdkEventCrossingFields(JNIEnv *env, jobject lpObject, GdkEventCrossing *lpStruct)
+{
+	if (!GdkEventCrossingFc.cached) cacheGdkEventCrossingFields(env, lpObject);
+	setGdkEventFields(env, lpObject, (GdkEvent *)lpStruct);
+	(*env)->SetIntField(env, lpObject, GdkEventCrossingFc.window, (jint)lpStruct->window);
+	(*env)->SetByteField(env, lpObject, GdkEventCrossingFc.send_event, (jbyte)lpStruct->send_event);
+	(*env)->SetIntField(env, lpObject, GdkEventCrossingFc.subwindow, (jint)lpStruct->subwindow);
+	(*env)->SetIntField(env, lpObject, GdkEventCrossingFc.time, (jint)lpStruct->time);
+	(*env)->SetDoubleField(env, lpObject, GdkEventCrossingFc.x, (jdouble)lpStruct->x);
+	(*env)->SetDoubleField(env, lpObject, GdkEventCrossingFc.y, (jdouble)lpStruct->y);
+	(*env)->SetDoubleField(env, lpObject, GdkEventCrossingFc.x_root, (jdouble)lpStruct->x_root);
+	(*env)->SetDoubleField(env, lpObject, GdkEventCrossingFc.y_root, (jdouble)lpStruct->y_root);
+	(*env)->SetIntField(env, lpObject, GdkEventCrossingFc.mode, (jint)lpStruct->mode);
+	(*env)->SetIntField(env, lpObject, GdkEventCrossingFc.detail, (jint)lpStruct->detail);
+	(*env)->SetBooleanField(env, lpObject, GdkEventCrossingFc.focus, (jboolean)lpStruct->focus);
+	(*env)->SetIntField(env, lpObject, GdkEventCrossingFc.state, (jint)lpStruct->state);
+}
+#endif
+
+#ifndef NO_GdkEventExpose
+typedef struct GdkEventExpose_FID_CACHE {
+	int cached;
+	jclass clazz;
+	jfieldID window, send_event, area_x, area_y, area_width, area_height, region, count;
+} GdkEventExpose_FID_CACHE;
+
+GdkEventExpose_FID_CACHE GdkEventExposeFc;
+
+void cacheGdkEventExposeFields(JNIEnv *env, jobject lpObject)
+{
+	if (GdkEventExposeFc.cached) return;
+	cacheGdkEventFields(env, lpObject);
+	GdkEventExposeFc.clazz = (*env)->GetObjectClass(env, lpObject);
+	GdkEventExposeFc.window = (*env)->GetFieldID(env, GdkEventExposeFc.clazz, "window", "I");
+	GdkEventExposeFc.send_event = (*env)->GetFieldID(env, GdkEventExposeFc.clazz, "send_event", "B");
+	GdkEventExposeFc.area_x = (*env)->GetFieldID(env, GdkEventExposeFc.clazz, "area_x", "I");
+	GdkEventExposeFc.area_y = (*env)->GetFieldID(env, GdkEventExposeFc.clazz, "area_y", "I");
+	GdkEventExposeFc.area_width = (*env)->GetFieldID(env, GdkEventExposeFc.clazz, "area_width", "I");
+	GdkEventExposeFc.area_height = (*env)->GetFieldID(env, GdkEventExposeFc.clazz, "area_height", "I");
+	GdkEventExposeFc.region = (*env)->GetFieldID(env, GdkEventExposeFc.clazz, "region", "I");
+	GdkEventExposeFc.count = (*env)->GetFieldID(env, GdkEventExposeFc.clazz, "count", "I");
+	GdkEventExposeFc.cached = 1;
+}
+
+GdkEventExpose *getGdkEventExposeFields(JNIEnv *env, jobject lpObject, GdkEventExpose *lpStruct)
+{
+	if (!GdkEventExposeFc.cached) cacheGdkEventExposeFields(env, lpObject);
+	getGdkEventFields(env, lpObject, (GdkEvent *)lpStruct);
+	lpStruct->window = (GdkWindow *)(*env)->GetIntField(env, lpObject, GdkEventExposeFc.window);
+	lpStruct->send_event = (gint8)(*env)->GetByteField(env, lpObject, GdkEventExposeFc.send_event);
+	lpStruct->area.x = (*env)->GetIntField(env, lpObject, GdkEventExposeFc.area_x);
+	lpStruct->area.y = (*env)->GetIntField(env, lpObject, GdkEventExposeFc.area_y);
+	lpStruct->area.width = (*env)->GetIntField(env, lpObject, GdkEventExposeFc.area_width);
+	lpStruct->area.height = (*env)->GetIntField(env, lpObject, GdkEventExposeFc.area_height);
+	lpStruct->region = (GdkRegion *)(*env)->GetIntField(env, lpObject, GdkEventExposeFc.region);
+	lpStruct->count = (gint)(*env)->GetIntField(env, lpObject, GdkEventExposeFc.count);
+	return lpStruct;
+}
+
+void setGdkEventExposeFields(JNIEnv *env, jobject lpObject, GdkEventExpose *lpStruct)
+{
+	if (!GdkEventExposeFc.cached) cacheGdkEventExposeFields(env, lpObject);
+	setGdkEventFields(env, lpObject, (GdkEvent *)lpStruct);
+	(*env)->SetIntField(env, lpObject, GdkEventExposeFc.window, (jint)lpStruct->window);
+	(*env)->SetByteField(env, lpObject, GdkEventExposeFc.send_event, (jbyte)lpStruct->send_event);
+	(*env)->SetIntField(env, lpObject, GdkEventExposeFc.area_x, (jint)lpStruct->area.x);
+	(*env)->SetIntField(env, lpObject, GdkEventExposeFc.area_y, (jint)lpStruct->area.y);
+	(*env)->SetIntField(env, lpObject, GdkEventExposeFc.area_width, (jint)lpStruct->area.width);
+	(*env)->SetIntField(env, lpObject, GdkEventExposeFc.area_height, (jint)lpStruct->area.height);
+	(*env)->SetIntField(env, lpObject, GdkEventExposeFc.region, (jint)lpStruct->region);
+	(*env)->SetIntField(env, lpObject, GdkEventExposeFc.count, (jint)lpStruct->count);
+}
+#endif
+
+#ifndef NO_GdkEventFocus
+typedef struct GdkEventFocus_FID_CACHE {
+	int cached;
+	jclass clazz;
+	jfieldID window, send_event, in;
+} GdkEventFocus_FID_CACHE;
+
+GdkEventFocus_FID_CACHE GdkEventFocusFc;
+
+void cacheGdkEventFocusFields(JNIEnv *env, jobject lpObject)
+{
+	if (GdkEventFocusFc.cached) return;
+	cacheGdkEventFields(env, lpObject);
+	GdkEventFocusFc.clazz = (*env)->GetObjectClass(env, lpObject);
+	GdkEventFocusFc.window = (*env)->GetFieldID(env, GdkEventFocusFc.clazz, "window", "I");
+	GdkEventFocusFc.send_event = (*env)->GetFieldID(env, GdkEventFocusFc.clazz, "send_event", "B");
+	GdkEventFocusFc.in = (*env)->GetFieldID(env, GdkEventFocusFc.clazz, "in", "S");
+	GdkEventFocusFc.cached = 1;
+}
+
+GdkEventFocus *getGdkEventFocusFields(JNIEnv *env, jobject lpObject, GdkEventFocus *lpStruct)
+{
+	if (!GdkEventFocusFc.cached) cacheGdkEventFocusFields(env, lpObject);
+	getGdkEventFields(env, lpObject, (GdkEvent *)lpStruct);
+	lpStruct->window = (GdkWindow *)(*env)->GetIntField(env, lpObject, GdkEventFocusFc.window);
+	lpStruct->send_event = (gint8)(*env)->GetByteField(env, lpObject, GdkEventFocusFc.send_event);
+	lpStruct->in = (gint16)(*env)->GetShortField(env, lpObject, GdkEventFocusFc.in);
+	return lpStruct;
+}
+
+void setGdkEventFocusFields(JNIEnv *env, jobject lpObject, GdkEventFocus *lpStruct)
+{
+	if (!GdkEventFocusFc.cached) cacheGdkEventFocusFields(env, lpObject);
+	setGdkEventFields(env, lpObject, (GdkEvent *)lpStruct);
+	(*env)->SetIntField(env, lpObject, GdkEventFocusFc.window, (jint)lpStruct->window);
+	(*env)->SetByteField(env, lpObject, GdkEventFocusFc.send_event, (jbyte)lpStruct->send_event);
+	(*env)->SetShortField(env, lpObject, GdkEventFocusFc.in, (jshort)lpStruct->in);
+}
+#endif
+
+#ifndef NO_GdkEventKey
+typedef struct GdkEventKey_FID_CACHE {
+	int cached;
+	jclass clazz;
+	jfieldID window, send_event, time, state, keyval, length, string, hardware_keycode, group;
+} GdkEventKey_FID_CACHE;
+
+GdkEventKey_FID_CACHE GdkEventKeyFc;
+
+void cacheGdkEventKeyFields(JNIEnv *env, jobject lpObject)
+{
+	if (GdkEventKeyFc.cached) return;
+	cacheGdkEventFields(env, lpObject);
+	GdkEventKeyFc.clazz = (*env)->GetObjectClass(env, lpObject);
+	GdkEventKeyFc.window = (*env)->GetFieldID(env, GdkEventKeyFc.clazz, "window", "I");
+	GdkEventKeyFc.send_event = (*env)->GetFieldID(env, GdkEventKeyFc.clazz, "send_event", "B");
+	GdkEventKeyFc.time = (*env)->GetFieldID(env, GdkEventKeyFc.clazz, "time", "I");
+	GdkEventKeyFc.state = (*env)->GetFieldID(env, GdkEventKeyFc.clazz, "state", "I");
+	GdkEventKeyFc.keyval = (*env)->GetFieldID(env, GdkEventKeyFc.clazz, "keyval", "I");
+	GdkEventKeyFc.length = (*env)->GetFieldID(env, GdkEventKeyFc.clazz, "length", "I");
+	GdkEventKeyFc.string = (*env)->GetFieldID(env, GdkEventKeyFc.clazz, "string", "I");
+	GdkEventKeyFc.hardware_keycode = (*env)->GetFieldID(env, GdkEventKeyFc.clazz, "hardware_keycode", "S");
+	GdkEventKeyFc.group = (*env)->GetFieldID(env, GdkEventKeyFc.clazz, "group", "B");
+	GdkEventKeyFc.cached = 1;
+}
+
+GdkEventKey *getGdkEventKeyFields(JNIEnv *env, jobject lpObject, GdkEventKey *lpStruct)
+{
+	if (!GdkEventKeyFc.cached) cacheGdkEventKeyFields(env, lpObject);
+	getGdkEventFields(env, lpObject, (GdkEvent *)lpStruct);
+	lpStruct->window = (GdkWindow *)(*env)->GetIntField(env, lpObject, GdkEventKeyFc.window);
+	lpStruct->send_event = (gint8)(*env)->GetByteField(env, lpObject, GdkEventKeyFc.send_event);
+	lpStruct->time = (guint32)(*env)->GetIntField(env, lpObject, GdkEventKeyFc.time);
+	lpStruct->state = (guint)(*env)->GetIntField(env, lpObject, GdkEventKeyFc.state);
+	lpStruct->keyval = (guint)(*env)->GetIntField(env, lpObject, GdkEventKeyFc.keyval);
+	lpStruct->length = (gint)(*env)->GetIntField(env, lpObject, GdkEventKeyFc.length);
+	lpStruct->string = (gchar *)(*env)->GetIntField(env, lpObject, GdkEventKeyFc.string);
+	lpStruct->hardware_keycode = (guint16)(*env)->GetShortField(env, lpObject, GdkEventKeyFc.hardware_keycode);
+	lpStruct->group = (guint8)(*env)->GetByteField(env, lpObject, GdkEventKeyFc.group);
+	return lpStruct;
+}
+
+void setGdkEventKeyFields(JNIEnv *env, jobject lpObject, GdkEventKey *lpStruct)
+{
+	if (!GdkEventKeyFc.cached) cacheGdkEventKeyFields(env, lpObject);
+	setGdkEventFields(env, lpObject, (GdkEvent *)lpStruct);
+	(*env)->SetIntField(env, lpObject, GdkEventKeyFc.window, (jint)lpStruct->window);
+	(*env)->SetByteField(env, lpObject, GdkEventKeyFc.send_event, (jbyte)lpStruct->send_event);
+	(*env)->SetIntField(env, lpObject, GdkEventKeyFc.time, (jint)lpStruct->time);
+	(*env)->SetIntField(env, lpObject, GdkEventKeyFc.state, (jint)lpStruct->state);
+	(*env)->SetIntField(env, lpObject, GdkEventKeyFc.keyval, (jint)lpStruct->keyval);
+	(*env)->SetIntField(env, lpObject, GdkEventKeyFc.length, (jint)lpStruct->length);
+	(*env)->SetIntField(env, lpObject, GdkEventKeyFc.string, (jint)lpStruct->string);
+	(*env)->SetShortField(env, lpObject, GdkEventKeyFc.hardware_keycode, (jshort)lpStruct->hardware_keycode);
+	(*env)->SetByteField(env, lpObject, GdkEventKeyFc.group, (jbyte)lpStruct->group);
+}
+#endif
+
+#ifndef NO_GdkEventMotion
+typedef struct GdkEventMotion_FID_CACHE {
+	int cached;
+	jclass clazz;
+	jfieldID window, send_event, time, x, y, axes, state, is_hint, device, x_root, y_root;
+} GdkEventMotion_FID_CACHE;
+
+GdkEventMotion_FID_CACHE GdkEventMotionFc;
+
+void cacheGdkEventMotionFields(JNIEnv *env, jobject lpObject)
+{
+	if (GdkEventMotionFc.cached) return;
+	cacheGdkEventFields(env, lpObject);
+	GdkEventMotionFc.clazz = (*env)->GetObjectClass(env, lpObject);
+	GdkEventMotionFc.window = (*env)->GetFieldID(env, GdkEventMotionFc.clazz, "window", "I");
+	GdkEventMotionFc.send_event = (*env)->GetFieldID(env, GdkEventMotionFc.clazz, "send_event", "B");
+	GdkEventMotionFc.time = (*env)->GetFieldID(env, GdkEventMotionFc.clazz, "time", "I");
+	GdkEventMotionFc.x = (*env)->GetFieldID(env, GdkEventMotionFc.clazz, "x", "D");
+	GdkEventMotionFc.y = (*env)->GetFieldID(env, GdkEventMotionFc.clazz, "y", "D");
+	GdkEventMotionFc.axes = (*env)->GetFieldID(env, GdkEventMotionFc.clazz, "axes", "I");
+	GdkEventMotionFc.state = (*env)->GetFieldID(env, GdkEventMotionFc.clazz, "state", "I");
+	GdkEventMotionFc.is_hint = (*env)->GetFieldID(env, GdkEventMotionFc.clazz, "is_hint", "S");
+	GdkEventMotionFc.device = (*env)->GetFieldID(env, GdkEventMotionFc.clazz, "device", "I");
+	GdkEventMotionFc.x_root = (*env)->GetFieldID(env, GdkEventMotionFc.clazz, "x_root", "D");
+	GdkEventMotionFc.y_root = (*env)->GetFieldID(env, GdkEventMotionFc.clazz, "y_root", "D");
+	GdkEventMotionFc.cached = 1;
+}
+
+GdkEventMotion *getGdkEventMotionFields(JNIEnv *env, jobject lpObject, GdkEventMotion *lpStruct)
+{
+	if (!GdkEventMotionFc.cached) cacheGdkEventMotionFields(env, lpObject);
+	getGdkEventFields(env, lpObject, (GdkEvent *)lpStruct);
+	lpStruct->window = (GdkWindow *)(*env)->GetIntField(env, lpObject, GdkEventMotionFc.window);
+	lpStruct->send_event = (gint8)(*env)->GetByteField(env, lpObject, GdkEventMotionFc.send_event);
+	lpStruct->time = (guint32)(*env)->GetIntField(env, lpObject, GdkEventMotionFc.time);
+	lpStruct->x = (gdouble)(*env)->GetDoubleField(env, lpObject, GdkEventMotionFc.x);
+	lpStruct->y = (gdouble)(*env)->GetDoubleField(env, lpObject, GdkEventMotionFc.y);
+	lpStruct->axes = (gdouble *)(*env)->GetIntField(env, lpObject, GdkEventMotionFc.axes);
+	lpStruct->state = (guint)(*env)->GetIntField(env, lpObject, GdkEventMotionFc.state);
+	lpStruct->is_hint = (gint16)(*env)->GetShortField(env, lpObject, GdkEventMotionFc.is_hint);
+	lpStruct->device = (GdkDevice *)(*env)->GetIntField(env, lpObject, GdkEventMotionFc.device);
+	lpStruct->x_root = (gdouble)(*env)->GetDoubleField(env, lpObject, GdkEventMotionFc.x_root);
+	lpStruct->y_root = (gdouble)(*env)->GetDoubleField(env, lpObject, GdkEventMotionFc.y_root);
+	return lpStruct;
+}
+
+void setGdkEventMotionFields(JNIEnv *env, jobject lpObject, GdkEventMotion *lpStruct)
+{
+	if (!GdkEventMotionFc.cached) cacheGdkEventMotionFields(env, lpObject);
+	setGdkEventFields(env, lpObject, (GdkEvent *)lpStruct);
+	(*env)->SetIntField(env, lpObject, GdkEventMotionFc.window, (jint)lpStruct->window);
+	(*env)->SetByteField(env, lpObject, GdkEventMotionFc.send_event, (jbyte)lpStruct->send_event);
+	(*env)->SetIntField(env, lpObject, GdkEventMotionFc.time, (jint)lpStruct->time);
+	(*env)->SetDoubleField(env, lpObject, GdkEventMotionFc.x, (jdouble)lpStruct->x);
+	(*env)->SetDoubleField(env, lpObject, GdkEventMotionFc.y, (jdouble)lpStruct->y);
+	(*env)->SetIntField(env, lpObject, GdkEventMotionFc.axes, (jint)lpStruct->axes);
+	(*env)->SetIntField(env, lpObject, GdkEventMotionFc.state, (jint)lpStruct->state);
+	(*env)->SetShortField(env, lpObject, GdkEventMotionFc.is_hint, (jshort)lpStruct->is_hint);
+	(*env)->SetIntField(env, lpObject, GdkEventMotionFc.device, (jint)lpStruct->device);
+	(*env)->SetDoubleField(env, lpObject, GdkEventMotionFc.x_root, (jdouble)lpStruct->x_root);
+	(*env)->SetDoubleField(env, lpObject, GdkEventMotionFc.y_root, (jdouble)lpStruct->y_root);
+}
+#endif
+
+#ifndef NO_GdkEventScroll
+typedef struct GdkEventScroll_FID_CACHE {
+	int cached;
+	jclass clazz;
+	jfieldID window, send_event, time, x, y, state, direction, device, x_root, y_root;
+} GdkEventScroll_FID_CACHE;
+
+GdkEventScroll_FID_CACHE GdkEventScrollFc;
+
+void cacheGdkEventScrollFields(JNIEnv *env, jobject lpObject)
+{
+	if (GdkEventScrollFc.cached) return;
+	cacheGdkEventFields(env, lpObject);
+	GdkEventScrollFc.clazz = (*env)->GetObjectClass(env, lpObject);
+	GdkEventScrollFc.window = (*env)->GetFieldID(env, GdkEventScrollFc.clazz, "window", "I");
+	GdkEventScrollFc.send_event = (*env)->GetFieldID(env, GdkEventScrollFc.clazz, "send_event", "B");
+	GdkEventScrollFc.time = (*env)->GetFieldID(env, GdkEventScrollFc.clazz, "time", "I");
+	GdkEventScrollFc.x = (*env)->GetFieldID(env, GdkEventScrollFc.clazz, "x", "D");
+	GdkEventScrollFc.y = (*env)->GetFieldID(env, GdkEventScrollFc.clazz, "y", "D");
+	GdkEventScrollFc.state = (*env)->GetFieldID(env, GdkEventScrollFc.clazz, "state", "I");
+	GdkEventScrollFc.direction = (*env)->GetFieldID(env, GdkEventScrollFc.clazz, "direction", "I");
+	GdkEventScrollFc.device = (*env)->GetFieldID(env, GdkEventScrollFc.clazz, "device", "I");
+	GdkEventScrollFc.x_root = (*env)->GetFieldID(env, GdkEventScrollFc.clazz, "x_root", "D");
+	GdkEventScrollFc.y_root = (*env)->GetFieldID(env, GdkEventScrollFc.clazz, "y_root", "D");
+	GdkEventScrollFc.cached = 1;
+}
+
+GdkEventScroll *getGdkEventScrollFields(JNIEnv *env, jobject lpObject, GdkEventScroll *lpStruct)
+{
+	if (!GdkEventScrollFc.cached) cacheGdkEventScrollFields(env, lpObject);
+	getGdkEventFields(env, lpObject, (GdkEvent *)lpStruct);
+	lpStruct->window = (GdkWindow *)(*env)->GetIntField(env, lpObject, GdkEventScrollFc.window);
+	lpStruct->send_event = (gint8)(*env)->GetByteField(env, lpObject, GdkEventScrollFc.send_event);
+	lpStruct->time = (guint32)(*env)->GetIntField(env, lpObject, GdkEventScrollFc.time);
+	lpStruct->x = (gdouble)(*env)->GetDoubleField(env, lpObject, GdkEventScrollFc.x);
+	lpStruct->y = (gdouble)(*env)->GetDoubleField(env, lpObject, GdkEventScrollFc.y);
+	lpStruct->state = (guint)(*env)->GetIntField(env, lpObject, GdkEventScrollFc.state);
+	lpStruct->direction = (GdkScrollDirection)(*env)->GetIntField(env, lpObject, GdkEventScrollFc.direction);
+	lpStruct->device = (GdkDevice *)(*env)->GetIntField(env, lpObject, GdkEventScrollFc.device);
+	lpStruct->x_root = (gdouble)(*env)->GetDoubleField(env, lpObject, GdkEventScrollFc.x_root);
+	lpStruct->y_root = (gdouble)(*env)->GetDoubleField(env, lpObject, GdkEventScrollFc.y_root);
+	return lpStruct;
+}
+
+void setGdkEventScrollFields(JNIEnv *env, jobject lpObject, GdkEventScroll *lpStruct)
+{
+	if (!GdkEventScrollFc.cached) cacheGdkEventScrollFields(env, lpObject);
+	setGdkEventFields(env, lpObject, (GdkEvent *)lpStruct);
+	(*env)->SetIntField(env, lpObject, GdkEventScrollFc.window, (jint)lpStruct->window);
+	(*env)->SetByteField(env, lpObject, GdkEventScrollFc.send_event, (jbyte)lpStruct->send_event);
+	(*env)->SetIntField(env, lpObject, GdkEventScrollFc.time, (jint)lpStruct->time);
+	(*env)->SetDoubleField(env, lpObject, GdkEventScrollFc.x, (jdouble)lpStruct->x);
+	(*env)->SetDoubleField(env, lpObject, GdkEventScrollFc.y, (jdouble)lpStruct->y);
+	(*env)->SetIntField(env, lpObject, GdkEventScrollFc.state, (jint)lpStruct->state);
+	(*env)->SetIntField(env, lpObject, GdkEventScrollFc.direction, (jint)lpStruct->direction);
+	(*env)->SetIntField(env, lpObject, GdkEventScrollFc.device, (jint)lpStruct->device);
+	(*env)->SetDoubleField(env, lpObject, GdkEventScrollFc.x_root, (jdouble)lpStruct->x_root);
+	(*env)->SetDoubleField(env, lpObject, GdkEventScrollFc.y_root, (jdouble)lpStruct->y_root);
+}
+#endif
+
+#ifndef NO_GdkEventVisibility
+typedef struct GdkEventVisibility_FID_CACHE {
+	int cached;
+	jclass clazz;
+	jfieldID window, send_event, state;
+} GdkEventVisibility_FID_CACHE;
+
+GdkEventVisibility_FID_CACHE GdkEventVisibilityFc;
+
+void cacheGdkEventVisibilityFields(JNIEnv *env, jobject lpObject)
+{
+	if (GdkEventVisibilityFc.cached) return;
+	cacheGdkEventFields(env, lpObject);
+	GdkEventVisibilityFc.clazz = (*env)->GetObjectClass(env, lpObject);
+	GdkEventVisibilityFc.window = (*env)->GetFieldID(env, GdkEventVisibilityFc.clazz, "window", "I");
+	GdkEventVisibilityFc.send_event = (*env)->GetFieldID(env, GdkEventVisibilityFc.clazz, "send_event", "B");
+	GdkEventVisibilityFc.state = (*env)->GetFieldID(env, GdkEventVisibilityFc.clazz, "state", "I");
+	GdkEventVisibilityFc.cached = 1;
+}
+
+GdkEventVisibility *getGdkEventVisibilityFields(JNIEnv *env, jobject lpObject, GdkEventVisibility *lpStruct)
+{
+	if (!GdkEventVisibilityFc.cached) cacheGdkEventVisibilityFields(env, lpObject);
+	getGdkEventFields(env, lpObject, (GdkEvent *)lpStruct);
+	lpStruct->window = (GdkWindow *)(*env)->GetIntField(env, lpObject, GdkEventVisibilityFc.window);
+	lpStruct->send_event = (gint8)(*env)->GetByteField(env, lpObject, GdkEventVisibilityFc.send_event);
+	lpStruct->state = (GdkVisibilityState)(*env)->GetIntField(env, lpObject, GdkEventVisibilityFc.state);
+	return lpStruct;
+}
+
+void setGdkEventVisibilityFields(JNIEnv *env, jobject lpObject, GdkEventVisibility *lpStruct)
+{
+	if (!GdkEventVisibilityFc.cached) cacheGdkEventVisibilityFields(env, lpObject);
+	setGdkEventFields(env, lpObject, (GdkEvent *)lpStruct);
+	(*env)->SetIntField(env, lpObject, GdkEventVisibilityFc.window, (jint)lpStruct->window);
+	(*env)->SetByteField(env, lpObject, GdkEventVisibilityFc.send_event, (jbyte)lpStruct->send_event);
+	(*env)->SetIntField(env, lpObject, GdkEventVisibilityFc.state, (jint)lpStruct->state);
+}
+#endif
+
+#ifndef NO_GdkEventWindowState
+typedef struct GdkEventWindowState_FID_CACHE {
+	int cached;
+	jclass clazz;
+	jfieldID window, send_event, changed_mask, new_window_state;
+} GdkEventWindowState_FID_CACHE;
+
+GdkEventWindowState_FID_CACHE GdkEventWindowStateFc;
+
+void cacheGdkEventWindowStateFields(JNIEnv *env, jobject lpObject)
+{
+	if (GdkEventWindowStateFc.cached) return;
+	cacheGdkEventFields(env, lpObject);
+	GdkEventWindowStateFc.clazz = (*env)->GetObjectClass(env, lpObject);
+	GdkEventWindowStateFc.window = (*env)->GetFieldID(env, GdkEventWindowStateFc.clazz, "window", "I");
+	GdkEventWindowStateFc.send_event = (*env)->GetFieldID(env, GdkEventWindowStateFc.clazz, "send_event", "B");
+	GdkEventWindowStateFc.changed_mask = (*env)->GetFieldID(env, GdkEventWindowStateFc.clazz, "changed_mask", "I");
+	GdkEventWindowStateFc.new_window_state = (*env)->GetFieldID(env, GdkEventWindowStateFc.clazz, "new_window_state", "I");
+	GdkEventWindowStateFc.cached = 1;
+}
+
+GdkEventWindowState *getGdkEventWindowStateFields(JNIEnv *env, jobject lpObject, GdkEventWindowState *lpStruct)
+{
+	if (!GdkEventWindowStateFc.cached) cacheGdkEventWindowStateFields(env, lpObject);
+	getGdkEventFields(env, lpObject, (GdkEvent *)lpStruct);
+	lpStruct->window = (GdkWindow *)(*env)->GetIntField(env, lpObject, GdkEventWindowStateFc.window);
+	lpStruct->send_event = (*env)->GetByteField(env, lpObject, GdkEventWindowStateFc.send_event);
+	lpStruct->changed_mask = (*env)->GetIntField(env, lpObject, GdkEventWindowStateFc.changed_mask);
+	lpStruct->new_window_state = (*env)->GetIntField(env, lpObject, GdkEventWindowStateFc.new_window_state);
+	return lpStruct;
+}
+
+void setGdkEventWindowStateFields(JNIEnv *env, jobject lpObject, GdkEventWindowState *lpStruct)
+{
+	if (!GdkEventWindowStateFc.cached) cacheGdkEventWindowStateFields(env, lpObject);
+	setGdkEventFields(env, lpObject, (GdkEvent *)lpStruct);
+	(*env)->SetIntField(env, lpObject, GdkEventWindowStateFc.window, (jint)lpStruct->window);
+	(*env)->SetByteField(env, lpObject, GdkEventWindowStateFc.send_event, (jbyte)lpStruct->send_event);
+	(*env)->SetIntField(env, lpObject, GdkEventWindowStateFc.changed_mask, (jint)lpStruct->changed_mask);
+	(*env)->SetIntField(env, lpObject, GdkEventWindowStateFc.new_window_state, (jint)lpStruct->new_window_state);
+}
+#endif
+
+#ifndef NO_GdkGCValues
+typedef struct GdkGCValues_FID_CACHE {
+	int cached;
+	jclass clazz;
+	jfieldID foreground_pixel, foreground_red, foreground_green, foreground_blue, background_pixel, background_red, background_green, background_blue, font, function, fill, tile, stipple, clip_mask, subwindow_mode, ts_x_origin, ts_y_origin, clip_x_origin, clip_y_origin, graphics_exposures, line_width, line_style, cap_style, join_style;
+} GdkGCValues_FID_CACHE;
+
+GdkGCValues_FID_CACHE GdkGCValuesFc;
+
+void cacheGdkGCValuesFields(JNIEnv *env, jobject lpObject)
+{
+	if (GdkGCValuesFc.cached) return;
+	GdkGCValuesFc.clazz = (*env)->GetObjectClass(env, lpObject);
+	GdkGCValuesFc.foreground_pixel = (*env)->GetFieldID(env, GdkGCValuesFc.clazz, "foreground_pixel", "I");
+	GdkGCValuesFc.foreground_red = (*env)->GetFieldID(env, GdkGCValuesFc.clazz, "foreground_red", "S");
+	GdkGCValuesFc.foreground_green = (*env)->GetFieldID(env, GdkGCValuesFc.clazz, "foreground_green", "S");
+	GdkGCValuesFc.foreground_blue = (*env)->GetFieldID(env, GdkGCValuesFc.clazz, "foreground_blue", "S");
+	GdkGCValuesFc.background_pixel = (*env)->GetFieldID(env, GdkGCValuesFc.clazz, "background_pixel", "I");
+	GdkGCValuesFc.background_red = (*env)->GetFieldID(env, GdkGCValuesFc.clazz, "background_red", "S");
+	GdkGCValuesFc.background_green = (*env)->GetFieldID(env, GdkGCValuesFc.clazz, "background_green", "S");
+	GdkGCValuesFc.background_blue = (*env)->GetFieldID(env, GdkGCValuesFc.clazz, "background_blue", "S");
+	GdkGCValuesFc.font = (*env)->GetFieldID(env, GdkGCValuesFc.clazz, "font", "I");
+	GdkGCValuesFc.function = (*env)->GetFieldID(env, GdkGCValuesFc.clazz, "function", "I");
+	GdkGCValuesFc.fill = (*env)->GetFieldID(env, GdkGCValuesFc.clazz, "fill", "I");
+	GdkGCValuesFc.tile = (*env)->GetFieldID(env, GdkGCValuesFc.clazz, "tile", "I");
+	GdkGCValuesFc.stipple = (*env)->GetFieldID(env, GdkGCValuesFc.clazz, "stipple", "I");
+	GdkGCValuesFc.clip_mask = (*env)->GetFieldID(env, GdkGCValuesFc.clazz, "clip_mask", "I");
+	GdkGCValuesFc.subwindow_mode = (*env)->GetFieldID(env, GdkGCValuesFc.clazz, "subwindow_mode", "I");
+	GdkGCValuesFc.ts_x_origin = (*env)->GetFieldID(env, GdkGCValuesFc.clazz, "ts_x_origin", "I");
+	GdkGCValuesFc.ts_y_origin = (*env)->GetFieldID(env, GdkGCValuesFc.clazz, "ts_y_origin", "I");
+	GdkGCValuesFc.clip_x_origin = (*env)->GetFieldID(env, GdkGCValuesFc.clazz, "clip_x_origin", "I");
+	GdkGCValuesFc.clip_y_origin = (*env)->GetFieldID(env, GdkGCValuesFc.clazz, "clip_y_origin", "I");
+	GdkGCValuesFc.graphics_exposures = (*env)->GetFieldID(env, GdkGCValuesFc.clazz, "graphics_exposures", "I");
+	GdkGCValuesFc.line_width = (*env)->GetFieldID(env, GdkGCValuesFc.clazz, "line_width", "I");
+	GdkGCValuesFc.line_style = (*env)->GetFieldID(env, GdkGCValuesFc.clazz, "line_style", "I");
+	GdkGCValuesFc.cap_style = (*env)->GetFieldID(env, GdkGCValuesFc.clazz, "cap_style", "I");
+	GdkGCValuesFc.join_style = (*env)->GetFieldID(env, GdkGCValuesFc.clazz, "join_style", "I");
+	GdkGCValuesFc.cached = 1;
+}
+
+GdkGCValues *getGdkGCValuesFields(JNIEnv *env, jobject lpObject, GdkGCValues *lpStruct)
+{
+	if (!GdkGCValuesFc.cached) cacheGdkGCValuesFields(env, lpObject);
+	lpStruct->foreground.pixel = (guint32)(*env)->GetIntField(env, lpObject, GdkGCValuesFc.foreground_pixel);
+	lpStruct->foreground.red = (guint16)(*env)->GetShortField(env, lpObject, GdkGCValuesFc.foreground_red);
+	lpStruct->foreground.green = (guint16)(*env)->GetShortField(env, lpObject, GdkGCValuesFc.foreground_green);
+	lpStruct->foreground.blue = (guint16)(*env)->GetShortField(env, lpObject, GdkGCValuesFc.foreground_blue);
+	lpStruct->background.pixel = (guint32)(*env)->GetIntField(env, lpObject, GdkGCValuesFc.background_pixel);
+	lpStruct->background.red = (guint16)(*env)->GetShortField(env, lpObject, GdkGCValuesFc.background_red);
+	lpStruct->background.green = (guint16)(*env)->GetShortField(env, lpObject, GdkGCValuesFc.background_green);
+	lpStruct->background.blue = (guint16)(*env)->GetShortField(env, lpObject, GdkGCValuesFc.background_blue);
+	lpStruct->font = (GdkFont *)(*env)->GetIntField(env, lpObject, GdkGCValuesFc.font);
+	lpStruct->function = (GdkFunction)(*env)->GetIntField(env, lpObject, GdkGCValuesFc.function);
+	lpStruct->fill = (GdkFill)(*env)->GetIntField(env, lpObject, GdkGCValuesFc.fill);
+	lpStruct->tile = (GdkPixmap *)(*env)->GetIntField(env, lpObject, GdkGCValuesFc.tile);
+	lpStruct->stipple = (GdkPixmap *)(*env)->GetIntField(env, lpObject, GdkGCValuesFc.stipple);
+	lpStruct->clip_mask = (GdkPixmap *)(*env)->GetIntField(env, lpObject, GdkGCValuesFc.clip_mask);
+	lpStruct->subwindow_mode = (GdkSubwindowMode)(*env)->GetIntField(env, lpObject, GdkGCValuesFc.subwindow_mode);
+	lpStruct->ts_x_origin = (gint)(*env)->GetIntField(env, lpObject, GdkGCValuesFc.ts_x_origin);
+	lpStruct->ts_y_origin = (gint)(*env)->GetIntField(env, lpObject, GdkGCValuesFc.ts_y_origin);
+	lpStruct->clip_x_origin = (gint)(*env)->GetIntField(env, lpObject, GdkGCValuesFc.clip_x_origin);
+	lpStruct->clip_y_origin = (gint)(*env)->GetIntField(env, lpObject, GdkGCValuesFc.clip_y_origin);
+	lpStruct->graphics_exposures = (gint)(*env)->GetIntField(env, lpObject, GdkGCValuesFc.graphics_exposures);
+	lpStruct->line_width = (gint)(*env)->GetIntField(env, lpObject, GdkGCValuesFc.line_width);
+	lpStruct->line_style = (GdkLineStyle)(*env)->GetIntField(env, lpObject, GdkGCValuesFc.line_style);
+	lpStruct->cap_style = (GdkCapStyle)(*env)->GetIntField(env, lpObject, GdkGCValuesFc.cap_style);
+	lpStruct->join_style = (GdkJoinStyle)(*env)->GetIntField(env, lpObject, GdkGCValuesFc.join_style);
+	return lpStruct;
+}
+
+void setGdkGCValuesFields(JNIEnv *env, jobject lpObject, GdkGCValues *lpStruct)
+{
+	if (!GdkGCValuesFc.cached) cacheGdkGCValuesFields(env, lpObject);
+	(*env)->SetIntField(env, lpObject, GdkGCValuesFc.foreground_pixel, (jint)lpStruct->foreground.pixel);
+	(*env)->SetShortField(env, lpObject, GdkGCValuesFc.foreground_red, (jshort)lpStruct->foreground.red);
+	(*env)->SetShortField(env, lpObject, GdkGCValuesFc.foreground_green, (jshort)lpStruct->foreground.green);
+	(*env)->SetShortField(env, lpObject, GdkGCValuesFc.foreground_blue, (jshort)lpStruct->foreground.blue);
+	(*env)->SetIntField(env, lpObject, GdkGCValuesFc.background_pixel, (jint)lpStruct->background.pixel);
+	(*env)->SetShortField(env, lpObject, GdkGCValuesFc.background_red, (jshort)lpStruct->background.red);
+	(*env)->SetShortField(env, lpObject, GdkGCValuesFc.background_green, (jshort)lpStruct->background.green);
+	(*env)->SetShortField(env, lpObject, GdkGCValuesFc.background_blue, (jshort)lpStruct->background.blue);
+	(*env)->SetIntField(env, lpObject, GdkGCValuesFc.font, (jint)lpStruct->font);
+	(*env)->SetIntField(env, lpObject, GdkGCValuesFc.function, (jint)lpStruct->function);
+	(*env)->SetIntField(env, lpObject, GdkGCValuesFc.fill, (jint)lpStruct->fill);
+	(*env)->SetIntField(env, lpObject, GdkGCValuesFc.tile, (jint)lpStruct->tile);
+	(*env)->SetIntField(env, lpObject, GdkGCValuesFc.stipple, (jint)lpStruct->stipple);
+	(*env)->SetIntField(env, lpObject, GdkGCValuesFc.clip_mask, (jint)lpStruct->clip_mask);
+	(*env)->SetIntField(env, lpObject, GdkGCValuesFc.subwindow_mode, (jint)lpStruct->subwindow_mode);
+	(*env)->SetIntField(env, lpObject, GdkGCValuesFc.ts_x_origin, (jint)lpStruct->ts_x_origin);
+	(*env)->SetIntField(env, lpObject, GdkGCValuesFc.ts_y_origin, (jint)lpStruct->ts_y_origin);
+	(*env)->SetIntField(env, lpObject, GdkGCValuesFc.clip_x_origin, (jint)lpStruct->clip_x_origin);
+	(*env)->SetIntField(env, lpObject, GdkGCValuesFc.clip_y_origin, (jint)lpStruct->clip_y_origin);
+	(*env)->SetIntField(env, lpObject, GdkGCValuesFc.graphics_exposures, (jint)lpStruct->graphics_exposures);
+	(*env)->SetIntField(env, lpObject, GdkGCValuesFc.line_width, (jint)lpStruct->line_width);
+	(*env)->SetIntField(env, lpObject, GdkGCValuesFc.line_style, (jint)lpStruct->line_style);
+	(*env)->SetIntField(env, lpObject, GdkGCValuesFc.cap_style, (jint)lpStruct->cap_style);
+	(*env)->SetIntField(env, lpObject, GdkGCValuesFc.join_style, (jint)lpStruct->join_style);
+}
+#endif
+
+#ifndef NO_GdkGeometry
+typedef struct GdkGeometry_FID_CACHE {
+	int cached;
+	jclass clazz;
+	jfieldID min_width, min_height, max_width, max_height, base_width, base_height, width_inc, height_inc, min_aspect, max_aspect, win_gravity;
+} GdkGeometry_FID_CACHE;
+
+GdkGeometry_FID_CACHE GdkGeometryFc;
+
+void cacheGdkGeometryFields(JNIEnv *env, jobject lpObject)
+{
+	if (GdkGeometryFc.cached) return;
+	GdkGeometryFc.clazz = (*env)->GetObjectClass(env, lpObject);
+	GdkGeometryFc.min_width = (*env)->GetFieldID(env, GdkGeometryFc.clazz, "min_width", "I");
+	GdkGeometryFc.min_height = (*env)->GetFieldID(env, GdkGeometryFc.clazz, "min_height", "I");
+	GdkGeometryFc.max_width = (*env)->GetFieldID(env, GdkGeometryFc.clazz, "max_width", "I");
+	GdkGeometryFc.max_height = (*env)->GetFieldID(env, GdkGeometryFc.clazz, "max_height", "I");
+	GdkGeometryFc.base_width = (*env)->GetFieldID(env, GdkGeometryFc.clazz, "base_width", "I");
+	GdkGeometryFc.base_height = (*env)->GetFieldID(env, GdkGeometryFc.clazz, "base_height", "I");
+	GdkGeometryFc.width_inc = (*env)->GetFieldID(env, GdkGeometryFc.clazz, "width_inc", "I");
+	GdkGeometryFc.height_inc = (*env)->GetFieldID(env, GdkGeometryFc.clazz, "height_inc", "I");
+	GdkGeometryFc.min_aspect = (*env)->GetFieldID(env, GdkGeometryFc.clazz, "min_aspect", "D");
+	GdkGeometryFc.max_aspect = (*env)->GetFieldID(env, GdkGeometryFc.clazz, "max_aspect", "D");
+	GdkGeometryFc.win_gravity = (*env)->GetFieldID(env, GdkGeometryFc.clazz, "win_gravity", "I");
+	GdkGeometryFc.cached = 1;
+}
+
+GdkGeometry *getGdkGeometryFields(JNIEnv *env, jobject lpObject, GdkGeometry *lpStruct)
+{
+	if (!GdkGeometryFc.cached) cacheGdkGeometryFields(env, lpObject);
+	lpStruct->min_width = (*env)->GetIntField(env, lpObject, GdkGeometryFc.min_width);
+	lpStruct->min_height = (*env)->GetIntField(env, lpObject, GdkGeometryFc.min_height);
+	lpStruct->max_width = (*env)->GetIntField(env, lpObject, GdkGeometryFc.max_width);
+	lpStruct->max_height = (*env)->GetIntField(env, lpObject, GdkGeometryFc.max_height);
+	lpStruct->base_width = (*env)->GetIntField(env, lpObject, GdkGeometryFc.base_width);
+	lpStruct->base_height = (*env)->GetIntField(env, lpObject, GdkGeometryFc.base_height);
+	lpStruct->width_inc = (*env)->GetIntField(env, lpObject, GdkGeometryFc.width_inc);
+	lpStruct->height_inc = (*env)->GetIntField(env, lpObject, GdkGeometryFc.height_inc);
+	lpStruct->min_aspect = (*env)->GetDoubleField(env, lpObject, GdkGeometryFc.min_aspect);
+	lpStruct->max_aspect = (*env)->GetDoubleField(env, lpObject, GdkGeometryFc.max_aspect);
+	lpStruct->win_gravity = (*env)->GetIntField(env, lpObject, GdkGeometryFc.win_gravity);
+	return lpStruct;
+}
+
+void setGdkGeometryFields(JNIEnv *env, jobject lpObject, GdkGeometry *lpStruct)
+{
+	if (!GdkGeometryFc.cached) cacheGdkGeometryFields(env, lpObject);
+	(*env)->SetIntField(env, lpObject, GdkGeometryFc.min_width, (jint)lpStruct->min_width);
+	(*env)->SetIntField(env, lpObject, GdkGeometryFc.min_height, (jint)lpStruct->min_height);
+	(*env)->SetIntField(env, lpObject, GdkGeometryFc.max_width, (jint)lpStruct->max_width);
+	(*env)->SetIntField(env, lpObject, GdkGeometryFc.max_height, (jint)lpStruct->max_height);
+	(*env)->SetIntField(env, lpObject, GdkGeometryFc.base_width, (jint)lpStruct->base_width);
+	(*env)->SetIntField(env, lpObject, GdkGeometryFc.base_height, (jint)lpStruct->base_height);
+	(*env)->SetIntField(env, lpObject, GdkGeometryFc.width_inc, (jint)lpStruct->width_inc);
+	(*env)->SetIntField(env, lpObject, GdkGeometryFc.height_inc, (jint)lpStruct->height_inc);
+	(*env)->SetDoubleField(env, lpObject, GdkGeometryFc.min_aspect, (jdouble)lpStruct->min_aspect);
+	(*env)->SetDoubleField(env, lpObject, GdkGeometryFc.max_aspect, (jdouble)lpStruct->max_aspect);
+	(*env)->SetIntField(env, lpObject, GdkGeometryFc.win_gravity, (jint)lpStruct->win_gravity);
+}
+#endif
+
+#ifndef NO_GdkImage
+typedef struct GdkImage_FID_CACHE {
+	int cached;
+	jclass clazz;
+	jfieldID type, visual, byte_order, width, height, depth, bpp, bpl, bits_per_pixel, mem, colormap, windowing_data;
+} GdkImage_FID_CACHE;
+
+GdkImage_FID_CACHE GdkImageFc;
+
+void cacheGdkImageFields(JNIEnv *env, jobject lpObject)
+{
+	if (GdkImageFc.cached) return;
+	GdkImageFc.clazz = (*env)->GetObjectClass(env, lpObject);
+	GdkImageFc.type = (*env)->GetFieldID(env, GdkImageFc.clazz, "type", "I");
+	GdkImageFc.visual = (*env)->GetFieldID(env, GdkImageFc.clazz, "visual", "I");
+	GdkImageFc.byte_order = (*env)->GetFieldID(env, GdkImageFc.clazz, "byte_order", "I");
+	GdkImageFc.width = (*env)->GetFieldID(env, GdkImageFc.clazz, "width", "I");
+	GdkImageFc.height = (*env)->GetFieldID(env, GdkImageFc.clazz, "height", "I");
+	GdkImageFc.depth = (*env)->GetFieldID(env, GdkImageFc.clazz, "depth", "S");
+	GdkImageFc.bpp = (*env)->GetFieldID(env, GdkImageFc.clazz, "bpp", "S");
+	GdkImageFc.bpl = (*env)->GetFieldID(env, GdkImageFc.clazz, "bpl", "S");
+	GdkImageFc.bits_per_pixel = (*env)->GetFieldID(env, GdkImageFc.clazz, "bits_per_pixel", "S");
+	GdkImageFc.mem = (*env)->GetFieldID(env, GdkImageFc.clazz, "mem", "I");
+	GdkImageFc.colormap = (*env)->GetFieldID(env, GdkImageFc.clazz, "colormap", "I");
+	GdkImageFc.windowing_data = (*env)->GetFieldID(env, GdkImageFc.clazz, "windowing_data", "I");
+	GdkImageFc.cached = 1;
+}
+
+GdkImage *getGdkImageFields(JNIEnv *env, jobject lpObject, GdkImage *lpStruct)
+{
+	if (!GdkImageFc.cached) cacheGdkImageFields(env, lpObject);
+	lpStruct->type = (GdkImageType)(*env)->GetIntField(env, lpObject, GdkImageFc.type);
+	lpStruct->visual = (GdkVisual *)(*env)->GetIntField(env, lpObject, GdkImageFc.visual);
+	lpStruct->byte_order = (GdkByteOrder)(*env)->GetIntField(env, lpObject, GdkImageFc.byte_order);
+	lpStruct->width = (gint)(*env)->GetIntField(env, lpObject, GdkImageFc.width);
+	lpStruct->height = (gint)(*env)->GetIntField(env, lpObject, GdkImageFc.height);
+	lpStruct->depth = (guint16)(*env)->GetShortField(env, lpObject, GdkImageFc.depth);
+	lpStruct->bpp = (guint16)(*env)->GetShortField(env, lpObject, GdkImageFc.bpp);
+	lpStruct->bpl = (guint16)(*env)->GetShortField(env, lpObject, GdkImageFc.bpl);
+	lpStruct->bits_per_pixel = (guint16)(*env)->GetShortField(env, lpObject, GdkImageFc.bits_per_pixel);
+	lpStruct->mem = (gpointer)(*env)->GetIntField(env, lpObject, GdkImageFc.mem);
+	lpStruct->colormap = (GdkColormap *)(*env)->GetIntField(env, lpObject, GdkImageFc.colormap);
+	lpStruct->windowing_data = (gpointer)(*env)->GetIntField(env, lpObject, GdkImageFc.windowing_data);
+	return lpStruct;
+}
+
+void setGdkImageFields(JNIEnv *env, jobject lpObject, GdkImage *lpStruct)
+{
+	if (!GdkImageFc.cached) cacheGdkImageFields(env, lpObject);
+	(*env)->SetIntField(env, lpObject, GdkImageFc.type, (jint)lpStruct->type);
+	(*env)->SetIntField(env, lpObject, GdkImageFc.visual, (jint)lpStruct->visual);
+	(*env)->SetIntField(env, lpObject, GdkImageFc.byte_order, (jint)lpStruct->byte_order);
+	(*env)->SetIntField(env, lpObject, GdkImageFc.width, (jint)lpStruct->width);
+	(*env)->SetIntField(env, lpObject, GdkImageFc.height, (jint)lpStruct->height);
+	(*env)->SetShortField(env, lpObject, GdkImageFc.depth, (jshort)lpStruct->depth);
+	(*env)->SetShortField(env, lpObject, GdkImageFc.bpp, (jshort)lpStruct->bpp);
+	(*env)->SetShortField(env, lpObject, GdkImageFc.bpl, (jshort)lpStruct->bpl);
+	(*env)->SetShortField(env, lpObject, GdkImageFc.bits_per_pixel, (jshort)lpStruct->bits_per_pixel);
+	(*env)->SetIntField(env, lpObject, GdkImageFc.mem, (jint)lpStruct->mem);
+	(*env)->SetIntField(env, lpObject, GdkImageFc.colormap, (jint)lpStruct->colormap);
+	(*env)->SetIntField(env, lpObject, GdkImageFc.windowing_data, (jint)lpStruct->windowing_data);
+}
+#endif
+
+#ifndef NO_GdkRectangle
+typedef struct GdkRectangle_FID_CACHE {
+	int cached;
+	jclass clazz;
+	jfieldID x, y, width, height;
+} GdkRectangle_FID_CACHE;
+
+GdkRectangle_FID_CACHE GdkRectangleFc;
+
+void cacheGdkRectangleFields(JNIEnv *env, jobject lpObject)
+{
+	if (GdkRectangleFc.cached) return;
+	GdkRectangleFc.clazz = (*env)->GetObjectClass(env, lpObject);
+	GdkRectangleFc.x = (*env)->GetFieldID(env, GdkRectangleFc.clazz, "x", "I");
+	GdkRectangleFc.y = (*env)->GetFieldID(env, GdkRectangleFc.clazz, "y", "I");
+	GdkRectangleFc.width = (*env)->GetFieldID(env, GdkRectangleFc.clazz, "width", "I");
+	GdkRectangleFc.height = (*env)->GetFieldID(env, GdkRectangleFc.clazz, "height", "I");
+	GdkRectangleFc.cached = 1;
+}
+
+GdkRectangle *getGdkRectangleFields(JNIEnv *env, jobject lpObject, GdkRectangle *lpStruct)
+{
+	if (!GdkRectangleFc.cached) cacheGdkRectangleFields(env, lpObject);
+	lpStruct->x = (gint)(*env)->GetIntField(env, lpObject, GdkRectangleFc.x);
+	lpStruct->y = (gint)(*env)->GetIntField(env, lpObject, GdkRectangleFc.y);
+	lpStruct->width = (gint)(*env)->GetIntField(env, lpObject, GdkRectangleFc.width);
+	lpStruct->height = (gint)(*env)->GetIntField(env, lpObject, GdkRectangleFc.height);
+	return lpStruct;
+}
+
+void setGdkRectangleFields(JNIEnv *env, jobject lpObject, GdkRectangle *lpStruct)
+{
+	if (!GdkRectangleFc.cached) cacheGdkRectangleFields(env, lpObject);
+	(*env)->SetIntField(env, lpObject, GdkRectangleFc.x, (jint)lpStruct->x);
+	(*env)->SetIntField(env, lpObject, GdkRectangleFc.y, (jint)lpStruct->y);
+	(*env)->SetIntField(env, lpObject, GdkRectangleFc.width, (jint)lpStruct->width);
+	(*env)->SetIntField(env, lpObject, GdkRectangleFc.height, (jint)lpStruct->height);
+}
+#endif
+
+#ifndef NO_GdkVisual
+typedef struct GdkVisual_FID_CACHE {
+	int cached;
+	jclass clazz;
+	jfieldID type, depth, byte_order, colormap_size, bits_per_rgb, red_mask, red_shift, red_prec, green_mask, green_shift, green_prec, blue_mask, blue_shift, blue_prec;
+} GdkVisual_FID_CACHE;
+
+GdkVisual_FID_CACHE GdkVisualFc;
+
+void cacheGdkVisualFields(JNIEnv *env, jobject lpObject)
+{
+	if (GdkVisualFc.cached) return;
+	GdkVisualFc.clazz = (*env)->GetObjectClass(env, lpObject);
+	GdkVisualFc.type = (*env)->GetFieldID(env, GdkVisualFc.clazz, "type", "I");
+	GdkVisualFc.depth = (*env)->GetFieldID(env, GdkVisualFc.clazz, "depth", "I");
+	GdkVisualFc.byte_order = (*env)->GetFieldID(env, GdkVisualFc.clazz, "byte_order", "I");
+	GdkVisualFc.colormap_size = (*env)->GetFieldID(env, GdkVisualFc.clazz, "colormap_size", "I");
+	GdkVisualFc.bits_per_rgb = (*env)->GetFieldID(env, GdkVisualFc.clazz, "bits_per_rgb", "I");
+	GdkVisualFc.red_mask = (*env)->GetFieldID(env, GdkVisualFc.clazz, "red_mask", "I");
+	GdkVisualFc.red_shift = (*env)->GetFieldID(env, GdkVisualFc.clazz, "red_shift", "I");
+	GdkVisualFc.red_prec = (*env)->GetFieldID(env, GdkVisualFc.clazz, "red_prec", "I");
+	GdkVisualFc.green_mask = (*env)->GetFieldID(env, GdkVisualFc.clazz, "green_mask", "I");
+	GdkVisualFc.green_shift = (*env)->GetFieldID(env, GdkVisualFc.clazz, "green_shift", "I");
+	GdkVisualFc.green_prec = (*env)->GetFieldID(env, GdkVisualFc.clazz, "green_prec", "I");
+	GdkVisualFc.blue_mask = (*env)->GetFieldID(env, GdkVisualFc.clazz, "blue_mask", "I");
+	GdkVisualFc.blue_shift = (*env)->GetFieldID(env, GdkVisualFc.clazz, "blue_shift", "I");
+	GdkVisualFc.blue_prec = (*env)->GetFieldID(env, GdkVisualFc.clazz, "blue_prec", "I");
+	GdkVisualFc.cached = 1;
+}
+
+GdkVisual *getGdkVisualFields(JNIEnv *env, jobject lpObject, GdkVisual *lpStruct)
+{
+	if (!GdkVisualFc.cached) cacheGdkVisualFields(env, lpObject);
+	lpStruct->type = (GdkVisualType)(*env)->GetIntField(env, lpObject, GdkVisualFc.type);
+	lpStruct->depth = (gint)(*env)->GetIntField(env, lpObject, GdkVisualFc.depth);
+	lpStruct->byte_order = (GdkByteOrder)(*env)->GetIntField(env, lpObject, GdkVisualFc.byte_order);
+	lpStruct->colormap_size = (gint)(*env)->GetIntField(env, lpObject, GdkVisualFc.colormap_size);
+	lpStruct->bits_per_rgb = (gint)(*env)->GetIntField(env, lpObject, GdkVisualFc.bits_per_rgb);
+	lpStruct->red_mask = (guint32)(*env)->GetIntField(env, lpObject, GdkVisualFc.red_mask);
+	lpStruct->red_shift = (gint)(*env)->GetIntField(env, lpObject, GdkVisualFc.red_shift);
+	lpStruct->red_prec = (gint)(*env)->GetIntField(env, lpObject, GdkVisualFc.red_prec);
+	lpStruct->green_mask = (guint32)(*env)->GetIntField(env, lpObject, GdkVisualFc.green_mask);
+	lpStruct->green_shift = (gint)(*env)->GetIntField(env, lpObject, GdkVisualFc.green_shift);
+	lpStruct->green_prec = (gint)(*env)->GetIntField(env, lpObject, GdkVisualFc.green_prec);
+	lpStruct->blue_mask = (guint32)(*env)->GetIntField(env, lpObject, GdkVisualFc.blue_mask);
+	lpStruct->blue_shift = (gint)(*env)->GetIntField(env, lpObject, GdkVisualFc.blue_shift);
+	lpStruct->blue_prec = (gint)(*env)->GetIntField(env, lpObject, GdkVisualFc.blue_prec);
+	return lpStruct;
+}
+
+void setGdkVisualFields(JNIEnv *env, jobject lpObject, GdkVisual *lpStruct)
+{
+	if (!GdkVisualFc.cached) cacheGdkVisualFields(env, lpObject);
+	(*env)->SetIntField(env, lpObject, GdkVisualFc.type, (jint)lpStruct->type);
+	(*env)->SetIntField(env, lpObject, GdkVisualFc.depth, (jint)lpStruct->depth);
+	(*env)->SetIntField(env, lpObject, GdkVisualFc.byte_order, (jint)lpStruct->byte_order);
+	(*env)->SetIntField(env, lpObject, GdkVisualFc.colormap_size, (jint)lpStruct->colormap_size);
+	(*env)->SetIntField(env, lpObject, GdkVisualFc.bits_per_rgb, (jint)lpStruct->bits_per_rgb);
+	(*env)->SetIntField(env, lpObject, GdkVisualFc.red_mask, (jint)lpStruct->red_mask);
+	(*env)->SetIntField(env, lpObject, GdkVisualFc.red_shift, (jint)lpStruct->red_shift);
+	(*env)->SetIntField(env, lpObject, GdkVisualFc.red_prec, (jint)lpStruct->red_prec);
+	(*env)->SetIntField(env, lpObject, GdkVisualFc.green_mask, (jint)lpStruct->green_mask);
+	(*env)->SetIntField(env, lpObject, GdkVisualFc.green_shift, (jint)lpStruct->green_shift);
+	(*env)->SetIntField(env, lpObject, GdkVisualFc.green_prec, (jint)lpStruct->green_prec);
+	(*env)->SetIntField(env, lpObject, GdkVisualFc.blue_mask, (jint)lpStruct->blue_mask);
+	(*env)->SetIntField(env, lpObject, GdkVisualFc.blue_shift, (jint)lpStruct->blue_shift);
+	(*env)->SetIntField(env, lpObject, GdkVisualFc.blue_prec, (jint)lpStruct->blue_prec);
+}
+#endif
+
+#ifndef NO_GdkWindowAttr
+typedef struct GdkWindowAttr_FID_CACHE {
+	int cached;
+	jclass clazz;
+	jfieldID title, event_mask, x, y, width, height, wclass, visual, colormap, window_type, cursor, wmclass_name, wmclass_class, override_redirect;
+} GdkWindowAttr_FID_CACHE;
+
+GdkWindowAttr_FID_CACHE GdkWindowAttrFc;
+
+void cacheGdkWindowAttrFields(JNIEnv *env, jobject lpObject)
+{
+	if (GdkWindowAttrFc.cached) return;
+	GdkWindowAttrFc.clazz = (*env)->GetObjectClass(env, lpObject);
+	GdkWindowAttrFc.title = (*env)->GetFieldID(env, GdkWindowAttrFc.clazz, "title", "I");
+	GdkWindowAttrFc.event_mask = (*env)->GetFieldID(env, GdkWindowAttrFc.clazz, "event_mask", "I");
+	GdkWindowAttrFc.x = (*env)->GetFieldID(env, GdkWindowAttrFc.clazz, "x", "I");
+	GdkWindowAttrFc.y = (*env)->GetFieldID(env, GdkWindowAttrFc.clazz, "y", "I");
+	GdkWindowAttrFc.width = (*env)->GetFieldID(env, GdkWindowAttrFc.clazz, "width", "I");
+	GdkWindowAttrFc.height = (*env)->GetFieldID(env, GdkWindowAttrFc.clazz, "height", "I");
+	GdkWindowAttrFc.wclass = (*env)->GetFieldID(env, GdkWindowAttrFc.clazz, "wclass", "I");
+	GdkWindowAttrFc.visual = (*env)->GetFieldID(env, GdkWindowAttrFc.clazz, "visual", "I");
+	GdkWindowAttrFc.colormap = (*env)->GetFieldID(env, GdkWindowAttrFc.clazz, "colormap", "I");
+	GdkWindowAttrFc.window_type = (*env)->GetFieldID(env, GdkWindowAttrFc.clazz, "window_type", "I");
+	GdkWindowAttrFc.cursor = (*env)->GetFieldID(env, GdkWindowAttrFc.clazz, "cursor", "I");
+	GdkWindowAttrFc.wmclass_name = (*env)->GetFieldID(env, GdkWindowAttrFc.clazz, "wmclass_name", "I");
+	GdkWindowAttrFc.wmclass_class = (*env)->GetFieldID(env, GdkWindowAttrFc.clazz, "wmclass_class", "I");
+	GdkWindowAttrFc.override_redirect = (*env)->GetFieldID(env, GdkWindowAttrFc.clazz, "override_redirect", "Z");
+	GdkWindowAttrFc.cached = 1;
+}
+
+GdkWindowAttr *getGdkWindowAttrFields(JNIEnv *env, jobject lpObject, GdkWindowAttr *lpStruct)
+{
+	if (!GdkWindowAttrFc.cached) cacheGdkWindowAttrFields(env, lpObject);
+	lpStruct->title = (gchar *)(*env)->GetIntField(env, lpObject, GdkWindowAttrFc.title);
+	lpStruct->event_mask = (*env)->GetIntField(env, lpObject, GdkWindowAttrFc.event_mask);
+	lpStruct->x = (*env)->GetIntField(env, lpObject, GdkWindowAttrFc.x);
+	lpStruct->y = (*env)->GetIntField(env, lpObject, GdkWindowAttrFc.y);
+	lpStruct->width = (*env)->GetIntField(env, lpObject, GdkWindowAttrFc.width);
+	lpStruct->height = (*env)->GetIntField(env, lpObject, GdkWindowAttrFc.height);
+	lpStruct->wclass = (*env)->GetIntField(env, lpObject, GdkWindowAttrFc.wclass);
+	lpStruct->visual = (GdkVisual *)(*env)->GetIntField(env, lpObject, GdkWindowAttrFc.visual);
+	lpStruct->colormap = (GdkColormap *)(*env)->GetIntField(env, lpObject, GdkWindowAttrFc.colormap);
+	lpStruct->window_type = (*env)->GetIntField(env, lpObject, GdkWindowAttrFc.window_type);
+	lpStruct->cursor = (GdkCursor *)(*env)->GetIntField(env, lpObject, GdkWindowAttrFc.cursor);
+	lpStruct->wmclass_name = (gchar *)(*env)->GetIntField(env, lpObject, GdkWindowAttrFc.wmclass_name);
+	lpStruct->wmclass_class = (gchar *)(*env)->GetIntField(env, lpObject, GdkWindowAttrFc.wmclass_class);
+	lpStruct->override_redirect = (*env)->GetBooleanField(env, lpObject, GdkWindowAttrFc.override_redirect);
+	return lpStruct;
+}
+
+void setGdkWindowAttrFields(JNIEnv *env, jobject lpObject, GdkWindowAttr *lpStruct)
+{
+	if (!GdkWindowAttrFc.cached) cacheGdkWindowAttrFields(env, lpObject);
+	(*env)->SetIntField(env, lpObject, GdkWindowAttrFc.title, (jint)lpStruct->title);
+	(*env)->SetIntField(env, lpObject, GdkWindowAttrFc.event_mask, (jint)lpStruct->event_mask);
+	(*env)->SetIntField(env, lpObject, GdkWindowAttrFc.x, (jint)lpStruct->x);
+	(*env)->SetIntField(env, lpObject, GdkWindowAttrFc.y, (jint)lpStruct->y);
+	(*env)->SetIntField(env, lpObject, GdkWindowAttrFc.width, (jint)lpStruct->width);
+	(*env)->SetIntField(env, lpObject, GdkWindowAttrFc.height, (jint)lpStruct->height);
+	(*env)->SetIntField(env, lpObject, GdkWindowAttrFc.wclass, (jint)lpStruct->wclass);
+	(*env)->SetIntField(env, lpObject, GdkWindowAttrFc.visual, (jint)lpStruct->visual);
+	(*env)->SetIntField(env, lpObject, GdkWindowAttrFc.colormap, (jint)lpStruct->colormap);
+	(*env)->SetIntField(env, lpObject, GdkWindowAttrFc.window_type, (jint)lpStruct->window_type);
+	(*env)->SetIntField(env, lpObject, GdkWindowAttrFc.cursor, (jint)lpStruct->cursor);
+	(*env)->SetIntField(env, lpObject, GdkWindowAttrFc.wmclass_name, (jint)lpStruct->wmclass_name);
+	(*env)->SetIntField(env, lpObject, GdkWindowAttrFc.wmclass_class, (jint)lpStruct->wmclass_class);
+	(*env)->SetBooleanField(env, lpObject, GdkWindowAttrFc.override_redirect, (jboolean)lpStruct->override_redirect);
+}
+#endif
+
+#ifndef NO_GtkAdjustment
+typedef struct GtkAdjustment_FID_CACHE {
+	int cached;
+	jclass clazz;
+	jfieldID lower, upper, value, step_increment, page_increment, page_size;
+} GtkAdjustment_FID_CACHE;
+
+GtkAdjustment_FID_CACHE GtkAdjustmentFc;
+
+void cacheGtkAdjustmentFields(JNIEnv *env, jobject lpObject)
+{
+	if (GtkAdjustmentFc.cached) return;
+	GtkAdjustmentFc.clazz = (*env)->GetObjectClass(env, lpObject);
+	GtkAdjustmentFc.lower = (*env)->GetFieldID(env, GtkAdjustmentFc.clazz, "lower", "D");
+	GtkAdjustmentFc.upper = (*env)->GetFieldID(env, GtkAdjustmentFc.clazz, "upper", "D");
+	GtkAdjustmentFc.value = (*env)->GetFieldID(env, GtkAdjustmentFc.clazz, "value", "D");
+	GtkAdjustmentFc.step_increment = (*env)->GetFieldID(env, GtkAdjustmentFc.clazz, "step_increment", "D");
+	GtkAdjustmentFc.page_increment = (*env)->GetFieldID(env, GtkAdjustmentFc.clazz, "page_increment", "D");
+	GtkAdjustmentFc.page_size = (*env)->GetFieldID(env, GtkAdjustmentFc.clazz, "page_size", "D");
+	GtkAdjustmentFc.cached = 1;
+}
+
+GtkAdjustment *getGtkAdjustmentFields(JNIEnv *env, jobject lpObject, GtkAdjustment *lpStruct)
+{
+	if (!GtkAdjustmentFc.cached) cacheGtkAdjustmentFields(env, lpObject);
+	lpStruct->lower = (gdouble)(*env)->GetDoubleField(env, lpObject, GtkAdjustmentFc.lower);
+	lpStruct->upper = (gdouble)(*env)->GetDoubleField(env, lpObject, GtkAdjustmentFc.upper);
+	lpStruct->value = (gdouble)(*env)->GetDoubleField(env, lpObject, GtkAdjustmentFc.value);
+	lpStruct->step_increment = (gdouble)(*env)->GetDoubleField(env, lpObject, GtkAdjustmentFc.step_increment);
+	lpStruct->page_increment = (gdouble)(*env)->GetDoubleField(env, lpObject, GtkAdjustmentFc.page_increment);
+	lpStruct->page_size = (gdouble)(*env)->GetDoubleField(env, lpObject, GtkAdjustmentFc.page_size);
+	return lpStruct;
+}
+
+void setGtkAdjustmentFields(JNIEnv *env, jobject lpObject, GtkAdjustment *lpStruct)
+{
+	if (!GtkAdjustmentFc.cached) cacheGtkAdjustmentFields(env, lpObject);
+	(*env)->SetDoubleField(env, lpObject, GtkAdjustmentFc.lower, (jdouble)lpStruct->lower);
+	(*env)->SetDoubleField(env, lpObject, GtkAdjustmentFc.upper, (jdouble)lpStruct->upper);
+	(*env)->SetDoubleField(env, lpObject, GtkAdjustmentFc.value, (jdouble)lpStruct->value);
+	(*env)->SetDoubleField(env, lpObject, GtkAdjustmentFc.step_increment, (jdouble)lpStruct->step_increment);
+	(*env)->SetDoubleField(env, lpObject, GtkAdjustmentFc.page_increment, (jdouble)lpStruct->page_increment);
+	(*env)->SetDoubleField(env, lpObject, GtkAdjustmentFc.page_size, (jdouble)lpStruct->page_size);
+}
+#endif
+
+#ifndef NO_GtkAllocation
+typedef struct GtkAllocation_FID_CACHE {
+	int cached;
+	jclass clazz;
+	jfieldID x, y, width, height;
+} GtkAllocation_FID_CACHE;
+
+GtkAllocation_FID_CACHE GtkAllocationFc;
+
+void cacheGtkAllocationFields(JNIEnv *env, jobject lpObject)
+{
+	if (GtkAllocationFc.cached) return;
+	GtkAllocationFc.clazz = (*env)->GetObjectClass(env, lpObject);
+	GtkAllocationFc.x = (*env)->GetFieldID(env, GtkAllocationFc.clazz, "x", "I");
+	GtkAllocationFc.y = (*env)->GetFieldID(env, GtkAllocationFc.clazz, "y", "I");
+	GtkAllocationFc.width = (*env)->GetFieldID(env, GtkAllocationFc.clazz, "width", "I");
+	GtkAllocationFc.height = (*env)->GetFieldID(env, GtkAllocationFc.clazz, "height", "I");
+	GtkAllocationFc.cached = 1;
+}
+
+GtkAllocation *getGtkAllocationFields(JNIEnv *env, jobject lpObject, GtkAllocation *lpStruct)
+{
+	if (!GtkAllocationFc.cached) cacheGtkAllocationFields(env, lpObject);
+	lpStruct->x = (*env)->GetIntField(env, lpObject, GtkAllocationFc.x);
+	lpStruct->y = (*env)->GetIntField(env, lpObject, GtkAllocationFc.y);
+	lpStruct->width = (*env)->GetIntField(env, lpObject, GtkAllocationFc.width);
+	lpStruct->height = (*env)->GetIntField(env, lpObject, GtkAllocationFc.height);
+	return lpStruct;
+}
+
+void setGtkAllocationFields(JNIEnv *env, jobject lpObject, GtkAllocation *lpStruct)
+{
+	if (!GtkAllocationFc.cached) cacheGtkAllocationFields(env, lpObject);
+	(*env)->SetIntField(env, lpObject, GtkAllocationFc.x, (jint)lpStruct->x);
+	(*env)->SetIntField(env, lpObject, GtkAllocationFc.y, (jint)lpStruct->y);
+	(*env)->SetIntField(env, lpObject, GtkAllocationFc.width, (jint)lpStruct->width);
+	(*env)->SetIntField(env, lpObject, GtkAllocationFc.height, (jint)lpStruct->height);
+}
+#endif
+
+#ifndef NO_GtkBorder
+typedef struct GtkBorder_FID_CACHE {
+	int cached;
+	jclass clazz;
+	jfieldID left, right, top, bottom;
+} GtkBorder_FID_CACHE;
+
+GtkBorder_FID_CACHE GtkBorderFc;
+
+void cacheGtkBorderFields(JNIEnv *env, jobject lpObject)
+{
+	if (GtkBorderFc.cached) return;
+	GtkBorderFc.clazz = (*env)->GetObjectClass(env, lpObject);
+	GtkBorderFc.left = (*env)->GetFieldID(env, GtkBorderFc.clazz, "left", "I");
+	GtkBorderFc.right = (*env)->GetFieldID(env, GtkBorderFc.clazz, "right", "I");
+	GtkBorderFc.top = (*env)->GetFieldID(env, GtkBorderFc.clazz, "top", "I");
+	GtkBorderFc.bottom = (*env)->GetFieldID(env, GtkBorderFc.clazz, "bottom", "I");
+	GtkBorderFc.cached = 1;
+}
+
+GtkBorder *getGtkBorderFields(JNIEnv *env, jobject lpObject, GtkBorder *lpStruct)
+{
+	if (!GtkBorderFc.cached) cacheGtkBorderFields(env, lpObject);
+	lpStruct->left = (*env)->GetIntField(env, lpObject, GtkBorderFc.left);
+	lpStruct->right = (*env)->GetIntField(env, lpObject, GtkBorderFc.right);
+	lpStruct->top = (*env)->GetIntField(env, lpObject, GtkBorderFc.top);
+	lpStruct->bottom = (*env)->GetIntField(env, lpObject, GtkBorderFc.bottom);
+	return lpStruct;
+}
+
+void setGtkBorderFields(JNIEnv *env, jobject lpObject, GtkBorder *lpStruct)
+{
+	if (!GtkBorderFc.cached) cacheGtkBorderFields(env, lpObject);
+	(*env)->SetIntField(env, lpObject, GtkBorderFc.left, (jint)lpStruct->left);
+	(*env)->SetIntField(env, lpObject, GtkBorderFc.right, (jint)lpStruct->right);
+	(*env)->SetIntField(env, lpObject, GtkBorderFc.top, (jint)lpStruct->top);
+	(*env)->SetIntField(env, lpObject, GtkBorderFc.bottom, (jint)lpStruct->bottom);
+}
+#endif
+
+#ifndef NO_GtkCellRendererClass
+typedef struct GtkCellRendererClass_FID_CACHE {
+	int cached;
+	jclass clazz;
+	jfieldID render, get_size;
+} GtkCellRendererClass_FID_CACHE;
+
+GtkCellRendererClass_FID_CACHE GtkCellRendererClassFc;
+
+void cacheGtkCellRendererClassFields(JNIEnv *env, jobject lpObject)
+{
+	if (GtkCellRendererClassFc.cached) return;
+	GtkCellRendererClassFc.clazz = (*env)->GetObjectClass(env, lpObject);
+	GtkCellRendererClassFc.render = (*env)->GetFieldID(env, GtkCellRendererClassFc.clazz, "render", "I");
+	GtkCellRendererClassFc.get_size = (*env)->GetFieldID(env, GtkCellRendererClassFc.clazz, "get_size", "I");
+	GtkCellRendererClassFc.cached = 1;
+}
+
+GtkCellRendererClass *getGtkCellRendererClassFields(JNIEnv *env, jobject lpObject, GtkCellRendererClass *lpStruct)
+{
+	if (!GtkCellRendererClassFc.cached) cacheGtkCellRendererClassFields(env, lpObject);
+	lpStruct->render = (void(*)())(*env)->GetIntField(env, lpObject, GtkCellRendererClassFc.render);
+	lpStruct->get_size = (void(*)())(*env)->GetIntField(env, lpObject, GtkCellRendererClassFc.get_size);
+	return lpStruct;
+}
+
+void setGtkCellRendererClassFields(JNIEnv *env, jobject lpObject, GtkCellRendererClass *lpStruct)
+{
+	if (!GtkCellRendererClassFc.cached) cacheGtkCellRendererClassFields(env, lpObject);
+	(*env)->SetIntField(env, lpObject, GtkCellRendererClassFc.render, (jint)lpStruct->render);
+	(*env)->SetIntField(env, lpObject, GtkCellRendererClassFc.get_size, (jint)lpStruct->get_size);
+}
+#endif
+
+#ifndef NO_GtkColorSelectionDialog
+typedef struct GtkColorSelectionDialog_FID_CACHE {
+	int cached;
+	jclass clazz;
+	jfieldID colorsel, ok_button, cancel_button, help_button;
+} GtkColorSelectionDialog_FID_CACHE;
+
+GtkColorSelectionDialog_FID_CACHE GtkColorSelectionDialogFc;
+
+void cacheGtkColorSelectionDialogFields(JNIEnv *env, jobject lpObject)
+{
+	if (GtkColorSelectionDialogFc.cached) return;
+	GtkColorSelectionDialogFc.clazz = (*env)->GetObjectClass(env, lpObject);
+	GtkColorSelectionDialogFc.colorsel = (*env)->GetFieldID(env, GtkColorSelectionDialogFc.clazz, "colorsel", "I");
+	GtkColorSelectionDialogFc.ok_button = (*env)->GetFieldID(env, GtkColorSelectionDialogFc.clazz, "ok_button", "I");
+	GtkColorSelectionDialogFc.cancel_button = (*env)->GetFieldID(env, GtkColorSelectionDialogFc.clazz, "cancel_button", "I");
+	GtkColorSelectionDialogFc.help_button = (*env)->GetFieldID(env, GtkColorSelectionDialogFc.clazz, "help_button", "I");
+	GtkColorSelectionDialogFc.cached = 1;
+}
+
+GtkColorSelectionDialog *getGtkColorSelectionDialogFields(JNIEnv *env, jobject lpObject, GtkColorSelectionDialog *lpStruct)
+{
+	if (!GtkColorSelectionDialogFc.cached) cacheGtkColorSelectionDialogFields(env, lpObject);
+	lpStruct->colorsel = (GtkWidget *)(*env)->GetIntField(env, lpObject, GtkColorSelectionDialogFc.colorsel);
+	lpStruct->ok_button = (GtkWidget *)(*env)->GetIntField(env, lpObject, GtkColorSelectionDialogFc.ok_button);
+	lpStruct->cancel_button = (GtkWidget *)(*env)->GetIntField(env, lpObject, GtkColorSelectionDialogFc.cancel_button);
+	lpStruct->help_button = (GtkWidget *)(*env)->GetIntField(env, lpObject, GtkColorSelectionDialogFc.help_button);
+	return lpStruct;
+}
+
+void setGtkColorSelectionDialogFields(JNIEnv *env, jobject lpObject, GtkColorSelectionDialog *lpStruct)
+{
+	if (!GtkColorSelectionDialogFc.cached) cacheGtkColorSelectionDialogFields(env, lpObject);
+	(*env)->SetIntField(env, lpObject, GtkColorSelectionDialogFc.colorsel, (jint)lpStruct->colorsel);
+	(*env)->SetIntField(env, lpObject, GtkColorSelectionDialogFc.ok_button, (jint)lpStruct->ok_button);
+	(*env)->SetIntField(env, lpObject, GtkColorSelectionDialogFc.cancel_button, (jint)lpStruct->cancel_button);
+	(*env)->SetIntField(env, lpObject, GtkColorSelectionDialogFc.help_button, (jint)lpStruct->help_button);
+}
+#endif
+
+#ifndef NO_GtkCombo
+typedef struct GtkCombo_FID_CACHE {
+	int cached;
+	jclass clazz;
+	jfieldID entry, list;
+} GtkCombo_FID_CACHE;
+
+GtkCombo_FID_CACHE GtkComboFc;
+
+void cacheGtkComboFields(JNIEnv *env, jobject lpObject)
+{
+	if (GtkComboFc.cached) return;
+	GtkComboFc.clazz = (*env)->GetObjectClass(env, lpObject);
+	GtkComboFc.entry = (*env)->GetFieldID(env, GtkComboFc.clazz, "entry", "I");
+	GtkComboFc.list = (*env)->GetFieldID(env, GtkComboFc.clazz, "list", "I");
+	GtkComboFc.cached = 1;
+}
+
+GtkCombo *getGtkComboFields(JNIEnv *env, jobject lpObject, GtkCombo *lpStruct)
+{
+	if (!GtkComboFc.cached) cacheGtkComboFields(env, lpObject);
+	lpStruct->entry = (GtkWidget *)(*env)->GetIntField(env, lpObject, GtkComboFc.entry);
+	lpStruct->list = (GtkWidget *)(*env)->GetIntField(env, lpObject, GtkComboFc.list);
+	return lpStruct;
+}
+
+void setGtkComboFields(JNIEnv *env, jobject lpObject, GtkCombo *lpStruct)
+{
+	if (!GtkComboFc.cached) cacheGtkComboFields(env, lpObject);
+	(*env)->SetIntField(env, lpObject, GtkComboFc.entry, (jint)lpStruct->entry);
+	(*env)->SetIntField(env, lpObject, GtkComboFc.list, (jint)lpStruct->list);
+}
+#endif
+
+#ifndef NO_GtkFileSelection
+typedef struct GtkFileSelection_FID_CACHE {
+	int cached;
+	jclass clazz;
+	jfieldID dir_list, file_list, selection_entry, selection_text, main_vbox, ok_button, cancel_button, help_button, history_pulldown, history_menu, history_list, fileop_dialog, fileop_entry, fileop_file, cmpl_state, fileop_c_dir, fileop_del_file, fileop_ren_file, button_area, action_area;
+} GtkFileSelection_FID_CACHE;
+
+GtkFileSelection_FID_CACHE GtkFileSelectionFc;
+
+void cacheGtkFileSelectionFields(JNIEnv *env, jobject lpObject)
+{
+	if (GtkFileSelectionFc.cached) return;
+	GtkFileSelectionFc.clazz = (*env)->GetObjectClass(env, lpObject);
+	GtkFileSelectionFc.dir_list = (*env)->GetFieldID(env, GtkFileSelectionFc.clazz, "dir_list", "I");
+	GtkFileSelectionFc.file_list = (*env)->GetFieldID(env, GtkFileSelectionFc.clazz, "file_list", "I");
+	GtkFileSelectionFc.selection_entry = (*env)->GetFieldID(env, GtkFileSelectionFc.clazz, "selection_entry", "I");
+	GtkFileSelectionFc.selection_text = (*env)->GetFieldID(env, GtkFileSelectionFc.clazz, "selection_text", "I");
+	GtkFileSelectionFc.main_vbox = (*env)->GetFieldID(env, GtkFileSelectionFc.clazz, "main_vbox", "I");
+	GtkFileSelectionFc.ok_button = (*env)->GetFieldID(env, GtkFileSelectionFc.clazz, "ok_button", "I");
+	GtkFileSelectionFc.cancel_button = (*env)->GetFieldID(env, GtkFileSelectionFc.clazz, "cancel_button", "I");
+	GtkFileSelectionFc.help_button = (*env)->GetFieldID(env, GtkFileSelectionFc.clazz, "help_button", "I");
+	GtkFileSelectionFc.history_pulldown = (*env)->GetFieldID(env, GtkFileSelectionFc.clazz, "history_pulldown", "I");
+	GtkFileSelectionFc.history_menu = (*env)->GetFieldID(env, GtkFileSelectionFc.clazz, "history_menu", "I");
+	GtkFileSelectionFc.history_list = (*env)->GetFieldID(env, GtkFileSelectionFc.clazz, "history_list", "I");
+	GtkFileSelectionFc.fileop_dialog = (*env)->GetFieldID(env, GtkFileSelectionFc.clazz, "fileop_dialog", "I");
+	GtkFileSelectionFc.fileop_entry = (*env)->GetFieldID(env, GtkFileSelectionFc.clazz, "fileop_entry", "I");
+	GtkFileSelectionFc.fileop_file = (*env)->GetFieldID(env, GtkFileSelectionFc.clazz, "fileop_file", "I");
+	GtkFileSelectionFc.cmpl_state = (*env)->GetFieldID(env, GtkFileSelectionFc.clazz, "cmpl_state", "I");
+	GtkFileSelectionFc.fileop_c_dir = (*env)->GetFieldID(env, GtkFileSelectionFc.clazz, "fileop_c_dir", "I");
+	GtkFileSelectionFc.fileop_del_file = (*env)->GetFieldID(env, GtkFileSelectionFc.clazz, "fileop_del_file", "I");
+	GtkFileSelectionFc.fileop_ren_file = (*env)->GetFieldID(env, GtkFileSelectionFc.clazz, "fileop_ren_file", "I");
+	GtkFileSelectionFc.button_area = (*env)->GetFieldID(env, GtkFileSelectionFc.clazz, "button_area", "I");
+	GtkFileSelectionFc.action_area = (*env)->GetFieldID(env, GtkFileSelectionFc.clazz, "action_area", "I");
+	GtkFileSelectionFc.cached = 1;
+}
+
+GtkFileSelection *getGtkFileSelectionFields(JNIEnv *env, jobject lpObject, GtkFileSelection *lpStruct)
+{
+	if (!GtkFileSelectionFc.cached) cacheGtkFileSelectionFields(env, lpObject);
+	lpStruct->dir_list = (GtkWidget *)(*env)->GetIntField(env, lpObject, GtkFileSelectionFc.dir_list);
+	lpStruct->file_list = (GtkWidget *)(*env)->GetIntField(env, lpObject, GtkFileSelectionFc.file_list);
+	lpStruct->selection_entry = (GtkWidget *)(*env)->GetIntField(env, lpObject, GtkFileSelectionFc.selection_entry);
+	lpStruct->selection_text = (GtkWidget *)(*env)->GetIntField(env, lpObject, GtkFileSelectionFc.selection_text);
+	lpStruct->main_vbox = (GtkWidget *)(*env)->GetIntField(env, lpObject, GtkFileSelectionFc.main_vbox);
+	lpStruct->ok_button = (GtkWidget *)(*env)->GetIntField(env, lpObject, GtkFileSelectionFc.ok_button);
+	lpStruct->cancel_button = (GtkWidget *)(*env)->GetIntField(env, lpObject, GtkFileSelectionFc.cancel_button);
+	lpStruct->help_button = (GtkWidget *)(*env)->GetIntField(env, lpObject, GtkFileSelectionFc.help_button);
+	lpStruct->history_pulldown = (GtkWidget *)(*env)->GetIntField(env, lpObject, GtkFileSelectionFc.history_pulldown);
+	lpStruct->history_menu = (GtkWidget *)(*env)->GetIntField(env, lpObject, GtkFileSelectionFc.history_menu);
+	lpStruct->history_list = (GList *)(*env)->GetIntField(env, lpObject, GtkFileSelectionFc.history_list);
+	lpStruct->fileop_dialog = (GtkWidget *)(*env)->GetIntField(env, lpObject, GtkFileSelectionFc.fileop_dialog);
+	lpStruct->fileop_entry = (GtkWidget *)(*env)->GetIntField(env, lpObject, GtkFileSelectionFc.fileop_entry);
+	lpStruct->fileop_file = (gchar *)(*env)->GetIntField(env, lpObject, GtkFileSelectionFc.fileop_file);
+	lpStruct->cmpl_state = (gpointer)(*env)->GetIntField(env, lpObject, GtkFileSelectionFc.cmpl_state);
+	lpStruct->fileop_c_dir = (GtkWidget *)(*env)->GetIntField(env, lpObject, GtkFileSelectionFc.fileop_c_dir);
+	lpStruct->fileop_del_file = (GtkWidget *)(*env)->GetIntField(env, lpObject, GtkFileSelectionFc.fileop_del_file);
+	lpStruct->fileop_ren_file = (GtkWidget *)(*env)->GetIntField(env, lpObject, GtkFileSelectionFc.fileop_ren_file);
+	lpStruct->button_area = (GtkWidget *)(*env)->GetIntField(env, lpObject, GtkFileSelectionFc.button_area);
+	lpStruct->action_area = (GtkWidget *)(*env)->GetIntField(env, lpObject, GtkFileSelectionFc.action_area);
+	return lpStruct;
+}
+
+void setGtkFileSelectionFields(JNIEnv *env, jobject lpObject, GtkFileSelection *lpStruct)
+{
+	if (!GtkFileSelectionFc.cached) cacheGtkFileSelectionFields(env, lpObject);
+	(*env)->SetIntField(env, lpObject, GtkFileSelectionFc.dir_list, (jint)lpStruct->dir_list);
+	(*env)->SetIntField(env, lpObject, GtkFileSelectionFc.file_list, (jint)lpStruct->file_list);
+	(*env)->SetIntField(env, lpObject, GtkFileSelectionFc.selection_entry, (jint)lpStruct->selection_entry);
+	(*env)->SetIntField(env, lpObject, GtkFileSelectionFc.selection_text, (jint)lpStruct->selection_text);
+	(*env)->SetIntField(env, lpObject, GtkFileSelectionFc.main_vbox, (jint)lpStruct->main_vbox);
+	(*env)->SetIntField(env, lpObject, GtkFileSelectionFc.ok_button, (jint)lpStruct->ok_button);
+	(*env)->SetIntField(env, lpObject, GtkFileSelectionFc.cancel_button, (jint)lpStruct->cancel_button);
+	(*env)->SetIntField(env, lpObject, GtkFileSelectionFc.help_button, (jint)lpStruct->help_button);
+	(*env)->SetIntField(env, lpObject, GtkFileSelectionFc.history_pulldown, (jint)lpStruct->history_pulldown);
+	(*env)->SetIntField(env, lpObject, GtkFileSelectionFc.history_menu, (jint)lpStruct->history_menu);
+	(*env)->SetIntField(env, lpObject, GtkFileSelectionFc.history_list, (jint)lpStruct->history_list);
+	(*env)->SetIntField(env, lpObject, GtkFileSelectionFc.fileop_dialog, (jint)lpStruct->fileop_dialog);
+	(*env)->SetIntField(env, lpObject, GtkFileSelectionFc.fileop_entry, (jint)lpStruct->fileop_entry);
+	(*env)->SetIntField(env, lpObject, GtkFileSelectionFc.fileop_file, (jint)lpStruct->fileop_file);
+	(*env)->SetIntField(env, lpObject, GtkFileSelectionFc.cmpl_state, (jint)lpStruct->cmpl_state);
+	(*env)->SetIntField(env, lpObject, GtkFileSelectionFc.fileop_c_dir, (jint)lpStruct->fileop_c_dir);
+	(*env)->SetIntField(env, lpObject, GtkFileSelectionFc.fileop_del_file, (jint)lpStruct->fileop_del_file);
+	(*env)->SetIntField(env, lpObject, GtkFileSelectionFc.fileop_ren_file, (jint)lpStruct->fileop_ren_file);
+	(*env)->SetIntField(env, lpObject, GtkFileSelectionFc.button_area, (jint)lpStruct->button_area);
+	(*env)->SetIntField(env, lpObject, GtkFileSelectionFc.action_area, (jint)lpStruct->action_area);
+}
+#endif
+
+#ifndef NO_GtkFixed
+typedef struct GtkFixed_FID_CACHE {
+	int cached;
+	jclass clazz;
+	jfieldID children;
+} GtkFixed_FID_CACHE;
+
+GtkFixed_FID_CACHE GtkFixedFc;
+
+void cacheGtkFixedFields(JNIEnv *env, jobject lpObject)
+{
+	if (GtkFixedFc.cached) return;
+	GtkFixedFc.clazz = (*env)->GetObjectClass(env, lpObject);
+	GtkFixedFc.children = (*env)->GetFieldID(env, GtkFixedFc.clazz, "children", "I");
+	GtkFixedFc.cached = 1;
+}
+
+GtkFixed *getGtkFixedFields(JNIEnv *env, jobject lpObject, GtkFixed *lpStruct)
+{
+	if (!GtkFixedFc.cached) cacheGtkFixedFields(env, lpObject);
+	lpStruct->children = (GList *)(*env)->GetIntField(env, lpObject, GtkFixedFc.children);
+	return lpStruct;
+}
+
+void setGtkFixedFields(JNIEnv *env, jobject lpObject, GtkFixed *lpStruct)
+{
+	if (!GtkFixedFc.cached) cacheGtkFixedFields(env, lpObject);
+	(*env)->SetIntField(env, lpObject, GtkFixedFc.children, (jint)lpStruct->children);
+}
+#endif
+
+#ifndef NO_GtkRequisition
+typedef struct GtkRequisition_FID_CACHE {
+	int cached;
+	jclass clazz;
+	jfieldID width, height;
+} GtkRequisition_FID_CACHE;
+
+GtkRequisition_FID_CACHE GtkRequisitionFc;
+
+void cacheGtkRequisitionFields(JNIEnv *env, jobject lpObject)
+{
+	if (GtkRequisitionFc.cached) return;
+	GtkRequisitionFc.clazz = (*env)->GetObjectClass(env, lpObject);
+	GtkRequisitionFc.width = (*env)->GetFieldID(env, GtkRequisitionFc.clazz, "width", "I");
+	GtkRequisitionFc.height = (*env)->GetFieldID(env, GtkRequisitionFc.clazz, "height", "I");
+	GtkRequisitionFc.cached = 1;
+}
+
+GtkRequisition *getGtkRequisitionFields(JNIEnv *env, jobject lpObject, GtkRequisition *lpStruct)
+{
+	if (!GtkRequisitionFc.cached) cacheGtkRequisitionFields(env, lpObject);
+	lpStruct->width = (*env)->GetIntField(env, lpObject, GtkRequisitionFc.width);
+	lpStruct->height = (*env)->GetIntField(env, lpObject, GtkRequisitionFc.height);
+	return lpStruct;
+}
+
+void setGtkRequisitionFields(JNIEnv *env, jobject lpObject, GtkRequisition *lpStruct)
+{
+	if (!GtkRequisitionFc.cached) cacheGtkRequisitionFields(env, lpObject);
+	(*env)->SetIntField(env, lpObject, GtkRequisitionFc.width, (jint)lpStruct->width);
+	(*env)->SetIntField(env, lpObject, GtkRequisitionFc.height, (jint)lpStruct->height);
+}
+#endif
+
+#ifndef NO_GtkSelectionData
+typedef struct GtkSelectionData_FID_CACHE {
+	int cached;
+	jclass clazz;
+	jfieldID selection, target, type, format, data, length;
+} GtkSelectionData_FID_CACHE;
+
+GtkSelectionData_FID_CACHE GtkSelectionDataFc;
+
+void cacheGtkSelectionDataFields(JNIEnv *env, jobject lpObject)
+{
+	if (GtkSelectionDataFc.cached) return;
+	GtkSelectionDataFc.clazz = (*env)->GetObjectClass(env, lpObject);
+	GtkSelectionDataFc.selection = (*env)->GetFieldID(env, GtkSelectionDataFc.clazz, "selection", "I");
+	GtkSelectionDataFc.target = (*env)->GetFieldID(env, GtkSelectionDataFc.clazz, "target", "I");
+	GtkSelectionDataFc.type = (*env)->GetFieldID(env, GtkSelectionDataFc.clazz, "type", "I");
+	GtkSelectionDataFc.format = (*env)->GetFieldID(env, GtkSelectionDataFc.clazz, "format", "I");
+	GtkSelectionDataFc.data = (*env)->GetFieldID(env, GtkSelectionDataFc.clazz, "data", "I");
+	GtkSelectionDataFc.length = (*env)->GetFieldID(env, GtkSelectionDataFc.clazz, "length", "I");
+	GtkSelectionDataFc.cached = 1;
+}
+
+GtkSelectionData *getGtkSelectionDataFields(JNIEnv *env, jobject lpObject, GtkSelectionData *lpStruct)
+{
+	if (!GtkSelectionDataFc.cached) cacheGtkSelectionDataFields(env, lpObject);
+	lpStruct->selection = (GdkAtom)(*env)->GetIntField(env, lpObject, GtkSelectionDataFc.selection);
+	lpStruct->target = (GdkAtom)(*env)->GetIntField(env, lpObject, GtkSelectionDataFc.target);
+	lpStruct->type = (GdkAtom)(*env)->GetIntField(env, lpObject, GtkSelectionDataFc.type);
+	lpStruct->format = (gint)(*env)->GetIntField(env, lpObject, GtkSelectionDataFc.format);
+	lpStruct->data = (guchar *)(*env)->GetIntField(env, lpObject, GtkSelectionDataFc.data);
+	lpStruct->length = (gint)(*env)->GetIntField(env, lpObject, GtkSelectionDataFc.length);
+	return lpStruct;
+}
+
+void setGtkSelectionDataFields(JNIEnv *env, jobject lpObject, GtkSelectionData *lpStruct)
+{
+	if (!GtkSelectionDataFc.cached) cacheGtkSelectionDataFields(env, lpObject);
+	(*env)->SetIntField(env, lpObject, GtkSelectionDataFc.selection, (jint)lpStruct->selection);
+	(*env)->SetIntField(env, lpObject, GtkSelectionDataFc.target, (jint)lpStruct->target);
+	(*env)->SetIntField(env, lpObject, GtkSelectionDataFc.type, (jint)lpStruct->type);
+	(*env)->SetIntField(env, lpObject, GtkSelectionDataFc.format, (jint)lpStruct->format);
+	(*env)->SetIntField(env, lpObject, GtkSelectionDataFc.data, (jint)lpStruct->data);
+	(*env)->SetIntField(env, lpObject, GtkSelectionDataFc.length, (jint)lpStruct->length);
+}
+#endif
+
+#ifndef NO_GtkTargetEntry
+typedef struct GtkTargetEntry_FID_CACHE {
+	int cached;
+	jclass clazz;
+	jfieldID target, flags, info;
+} GtkTargetEntry_FID_CACHE;
+
+GtkTargetEntry_FID_CACHE GtkTargetEntryFc;
+
+void cacheGtkTargetEntryFields(JNIEnv *env, jobject lpObject)
+{
+	if (GtkTargetEntryFc.cached) return;
+	GtkTargetEntryFc.clazz = (*env)->GetObjectClass(env, lpObject);
+	GtkTargetEntryFc.target = (*env)->GetFieldID(env, GtkTargetEntryFc.clazz, "target", "I");
+	GtkTargetEntryFc.flags = (*env)->GetFieldID(env, GtkTargetEntryFc.clazz, "flags", "I");
+	GtkTargetEntryFc.info = (*env)->GetFieldID(env, GtkTargetEntryFc.clazz, "info", "I");
+	GtkTargetEntryFc.cached = 1;
+}
+
+GtkTargetEntry *getGtkTargetEntryFields(JNIEnv *env, jobject lpObject, GtkTargetEntry *lpStruct)
+{
+	if (!GtkTargetEntryFc.cached) cacheGtkTargetEntryFields(env, lpObject);
+	lpStruct->target = (gchar *)(*env)->GetIntField(env, lpObject, GtkTargetEntryFc.target);
+	lpStruct->flags = (guint)(*env)->GetIntField(env, lpObject, GtkTargetEntryFc.flags);
+	lpStruct->info = (guint)(*env)->GetIntField(env, lpObject, GtkTargetEntryFc.info);
+	return lpStruct;
+}
+
+void setGtkTargetEntryFields(JNIEnv *env, jobject lpObject, GtkTargetEntry *lpStruct)
+{
+	if (!GtkTargetEntryFc.cached) cacheGtkTargetEntryFields(env, lpObject);
+	(*env)->SetIntField(env, lpObject, GtkTargetEntryFc.target, (jint)lpStruct->target);
+	(*env)->SetIntField(env, lpObject, GtkTargetEntryFc.flags, (jint)lpStruct->flags);
+	(*env)->SetIntField(env, lpObject, GtkTargetEntryFc.info, (jint)lpStruct->info);
+}
+#endif
+
+#ifndef NO_GtkTargetPair
+typedef struct GtkTargetPair_FID_CACHE {
+	int cached;
+	jclass clazz;
+	jfieldID target, flags, info;
+} GtkTargetPair_FID_CACHE;
+
+GtkTargetPair_FID_CACHE GtkTargetPairFc;
+
+void cacheGtkTargetPairFields(JNIEnv *env, jobject lpObject)
+{
+	if (GtkTargetPairFc.cached) return;
+	GtkTargetPairFc.clazz = (*env)->GetObjectClass(env, lpObject);
+	GtkTargetPairFc.target = (*env)->GetFieldID(env, GtkTargetPairFc.clazz, "target", "I");
+	GtkTargetPairFc.flags = (*env)->GetFieldID(env, GtkTargetPairFc.clazz, "flags", "I");
+	GtkTargetPairFc.info = (*env)->GetFieldID(env, GtkTargetPairFc.clazz, "info", "I");
+	GtkTargetPairFc.cached = 1;
+}
+
+GtkTargetPair *getGtkTargetPairFields(JNIEnv *env, jobject lpObject, GtkTargetPair *lpStruct)
+{
+	if (!GtkTargetPairFc.cached) cacheGtkTargetPairFields(env, lpObject);
+	lpStruct->target = (GdkAtom)(*env)->GetIntField(env, lpObject, GtkTargetPairFc.target);
+	lpStruct->flags = (guint)(*env)->GetIntField(env, lpObject, GtkTargetPairFc.flags);
+	lpStruct->info = (guint)(*env)->GetIntField(env, lpObject, GtkTargetPairFc.info);
+	return lpStruct;
+}
+
+void setGtkTargetPairFields(JNIEnv *env, jobject lpObject, GtkTargetPair *lpStruct)
+{
+	if (!GtkTargetPairFc.cached) cacheGtkTargetPairFields(env, lpObject);
+	(*env)->SetIntField(env, lpObject, GtkTargetPairFc.target, (jint)lpStruct->target);
+	(*env)->SetIntField(env, lpObject, GtkTargetPairFc.flags, (jint)lpStruct->flags);
+	(*env)->SetIntField(env, lpObject, GtkTargetPairFc.info, (jint)lpStruct->info);
+}
+#endif
+
+#ifndef NO_GtkWidgetClass
+typedef struct GtkWidgetClass_FID_CACHE {
+	int cached;
+	jclass clazz;
+	jfieldID activate_signal, set_scroll_adjustments_signal, dispatch_child_properties_changed, show, show_all, hide, hide_all, map, unmap, realize, unrealize, size_request, size_allocate, state_changed, parent_set, hierarchy_changed, style_set, direction_changed, grab_notify, child_notify, mnemonic_activate, grab_focus, focus, event, button_press_event, button_release_event, scroll_event, motion_notify_event, delete_event, destroy_event, expose_event, key_press_event, key_release_event, enter_notify_event, leave_notify_event, configure_event, focus_in_event, focus_out_event, map_event, unmap_event, property_notify_event, selection_clear_event, selection_request_event, selection_notify_event, proximity_in_event, proximity_out_event, visibility_notify_event, client_event, no_expose_event, window_state_event, selection_get, selection_received, drag_begin, drag_end, drag_data_get, drag_data_delete, drag_leave, drag_motion, drag_drop, drag_data_received, popup_menu, show_help, get_accessible, screen_changed;
+} GtkWidgetClass_FID_CACHE;
+
+GtkWidgetClass_FID_CACHE GtkWidgetClassFc;
+
+void cacheGtkWidgetClassFields(JNIEnv *env, jobject lpObject)
+{
+	if (GtkWidgetClassFc.cached) return;
+	cacheGObjectClassFields(env, lpObject);
+	GtkWidgetClassFc.clazz = (*env)->GetObjectClass(env, lpObject);
+	GtkWidgetClassFc.activate_signal = (*env)->GetFieldID(env, GtkWidgetClassFc.clazz, "activate_signal", "I");
+	GtkWidgetClassFc.set_scroll_adjustments_signal = (*env)->GetFieldID(env, GtkWidgetClassFc.clazz, "set_scroll_adjustments_signal", "I");
+	GtkWidgetClassFc.dispatch_child_properties_changed = (*env)->GetFieldID(env, GtkWidgetClassFc.clazz, "dispatch_child_properties_changed", "I");
+	GtkWidgetClassFc.show = (*env)->GetFieldID(env, GtkWidgetClassFc.clazz, "show", "I");
+	GtkWidgetClassFc.show_all = (*env)->GetFieldID(env, GtkWidgetClassFc.clazz, "show_all", "I");
+	GtkWidgetClassFc.hide = (*env)->GetFieldID(env, GtkWidgetClassFc.clazz, "hide", "I");
+	GtkWidgetClassFc.hide_all = (*env)->GetFieldID(env, GtkWidgetClassFc.clazz, "hide_all", "I");
+	GtkWidgetClassFc.map = (*env)->GetFieldID(env, GtkWidgetClassFc.clazz, "map", "I");
+	GtkWidgetClassFc.unmap = (*env)->GetFieldID(env, GtkWidgetClassFc.clazz, "unmap", "I");
+	GtkWidgetClassFc.realize = (*env)->GetFieldID(env, GtkWidgetClassFc.clazz, "realize", "I");
+	GtkWidgetClassFc.unrealize = (*env)->GetFieldID(env, GtkWidgetClassFc.clazz, "unrealize", "I");
+	GtkWidgetClassFc.size_request = (*env)->GetFieldID(env, GtkWidgetClassFc.clazz, "size_request", "I");
+	GtkWidgetClassFc.size_allocate = (*env)->GetFieldID(env, GtkWidgetClassFc.clazz, "size_allocate", "I");
+	GtkWidgetClassFc.state_changed = (*env)->GetFieldID(env, GtkWidgetClassFc.clazz, "state_changed", "I");
+	GtkWidgetClassFc.parent_set = (*env)->GetFieldID(env, GtkWidgetClassFc.clazz, "parent_set", "I");
+	GtkWidgetClassFc.hierarchy_changed = (*env)->GetFieldID(env, GtkWidgetClassFc.clazz, "hierarchy_changed", "I");
+	GtkWidgetClassFc.style_set = (*env)->GetFieldID(env, GtkWidgetClassFc.clazz, "style_set", "I");
+	GtkWidgetClassFc.direction_changed = (*env)->GetFieldID(env, GtkWidgetClassFc.clazz, "direction_changed", "I");
+	GtkWidgetClassFc.grab_notify = (*env)->GetFieldID(env, GtkWidgetClassFc.clazz, "grab_notify", "I");
+	GtkWidgetClassFc.child_notify = (*env)->GetFieldID(env, GtkWidgetClassFc.clazz, "child_notify", "I");
+	GtkWidgetClassFc.mnemonic_activate = (*env)->GetFieldID(env, GtkWidgetClassFc.clazz, "mnemonic_activate", "I");
+	GtkWidgetClassFc.grab_focus = (*env)->GetFieldID(env, GtkWidgetClassFc.clazz, "grab_focus", "I");
+	GtkWidgetClassFc.focus = (*env)->GetFieldID(env, GtkWidgetClassFc.clazz, "focus", "I");
+	GtkWidgetClassFc.event = (*env)->GetFieldID(env, GtkWidgetClassFc.clazz, "event", "I");
+	GtkWidgetClassFc.button_press_event = (*env)->GetFieldID(env, GtkWidgetClassFc.clazz, "button_press_event", "I");
+	GtkWidgetClassFc.button_release_event = (*env)->GetFieldID(env, GtkWidgetClassFc.clazz, "button_release_event", "I");
+	GtkWidgetClassFc.scroll_event = (*env)->GetFieldID(env, GtkWidgetClassFc.clazz, "scroll_event", "I");
+	GtkWidgetClassFc.motion_notify_event = (*env)->GetFieldID(env, GtkWidgetClassFc.clazz, "motion_notify_event", "I");
+	GtkWidgetClassFc.delete_event = (*env)->GetFieldID(env, GtkWidgetClassFc.clazz, "delete_event", "I");
+	GtkWidgetClassFc.destroy_event = (*env)->GetFieldID(env, GtkWidgetClassFc.clazz, "destroy_event", "I");
+	GtkWidgetClassFc.expose_event = (*env)->GetFieldID(env, GtkWidgetClassFc.clazz, "expose_event", "I");
+	GtkWidgetClassFc.key_press_event = (*env)->GetFieldID(env, GtkWidgetClassFc.clazz, "key_press_event", "I");
+	GtkWidgetClassFc.key_release_event = (*env)->GetFieldID(env, GtkWidgetClassFc.clazz, "key_release_event", "I");
+	GtkWidgetClassFc.enter_notify_event = (*env)->GetFieldID(env, GtkWidgetClassFc.clazz, "enter_notify_event", "I");
+	GtkWidgetClassFc.leave_notify_event = (*env)->GetFieldID(env, GtkWidgetClassFc.clazz, "leave_notify_event", "I");
+	GtkWidgetClassFc.configure_event = (*env)->GetFieldID(env, GtkWidgetClassFc.clazz, "configure_event", "I");
+	GtkWidgetClassFc.focus_in_event = (*env)->GetFieldID(env, GtkWidgetClassFc.clazz, "focus_in_event", "I");
+	GtkWidgetClassFc.focus_out_event = (*env)->GetFieldID(env, GtkWidgetClassFc.clazz, "focus_out_event", "I");
+	GtkWidgetClassFc.map_event = (*env)->GetFieldID(env, GtkWidgetClassFc.clazz, "map_event", "I");
+	GtkWidgetClassFc.unmap_event = (*env)->GetFieldID(env, GtkWidgetClassFc.clazz, "unmap_event", "I");
+	GtkWidgetClassFc.property_notify_event = (*env)->GetFieldID(env, GtkWidgetClassFc.clazz, "property_notify_event", "I");
+	GtkWidgetClassFc.selection_clear_event = (*env)->GetFieldID(env, GtkWidgetClassFc.clazz, "selection_clear_event", "I");
+	GtkWidgetClassFc.selection_request_event = (*env)->GetFieldID(env, GtkWidgetClassFc.clazz, "selection_request_event", "I");
+	GtkWidgetClassFc.selection_notify_event = (*env)->GetFieldID(env, GtkWidgetClassFc.clazz, "selection_notify_event", "I");
+	GtkWidgetClassFc.proximity_in_event = (*env)->GetFieldID(env, GtkWidgetClassFc.clazz, "proximity_in_event", "I");
+	GtkWidgetClassFc.proximity_out_event = (*env)->GetFieldID(env, GtkWidgetClassFc.clazz, "proximity_out_event", "I");
+	GtkWidgetClassFc.visibility_notify_event = (*env)->GetFieldID(env, GtkWidgetClassFc.clazz, "visibility_notify_event", "I");
+	GtkWidgetClassFc.client_event = (*env)->GetFieldID(env, GtkWidgetClassFc.clazz, "client_event", "I");
+	GtkWidgetClassFc.no_expose_event = (*env)->GetFieldID(env, GtkWidgetClassFc.clazz, "no_expose_event", "I");
+	GtkWidgetClassFc.window_state_event = (*env)->GetFieldID(env, GtkWidgetClassFc.clazz, "window_state_event", "I");
+	GtkWidgetClassFc.selection_get = (*env)->GetFieldID(env, GtkWidgetClassFc.clazz, "selection_get", "I");
+	GtkWidgetClassFc.selection_received = (*env)->GetFieldID(env, GtkWidgetClassFc.clazz, "selection_received", "I");
+	GtkWidgetClassFc.drag_begin = (*env)->GetFieldID(env, GtkWidgetClassFc.clazz, "drag_begin", "I");
+	GtkWidgetClassFc.drag_end = (*env)->GetFieldID(env, GtkWidgetClassFc.clazz, "drag_end", "I");
+	GtkWidgetClassFc.drag_data_get = (*env)->GetFieldID(env, GtkWidgetClassFc.clazz, "drag_data_get", "I");
+	GtkWidgetClassFc.drag_data_delete = (*env)->GetFieldID(env, GtkWidgetClassFc.clazz, "drag_data_delete", "I");
+	GtkWidgetClassFc.drag_leave = (*env)->GetFieldID(env, GtkWidgetClassFc.clazz, "drag_leave", "I");
+	GtkWidgetClassFc.drag_motion = (*env)->GetFieldID(env, GtkWidgetClassFc.clazz, "drag_motion", "I");
+	GtkWidgetClassFc.drag_drop = (*env)->GetFieldID(env, GtkWidgetClassFc.clazz, "drag_drop", "I");
+	GtkWidgetClassFc.drag_data_received = (*env)->GetFieldID(env, GtkWidgetClassFc.clazz, "drag_data_received", "I");
+	GtkWidgetClassFc.popup_menu = (*env)->GetFieldID(env, GtkWidgetClassFc.clazz, "popup_menu", "I");
+	GtkWidgetClassFc.show_help = (*env)->GetFieldID(env, GtkWidgetClassFc.clazz, "show_help", "I");
+	GtkWidgetClassFc.get_accessible = (*env)->GetFieldID(env, GtkWidgetClassFc.clazz, "get_accessible", "I");
+	GtkWidgetClassFc.screen_changed = (*env)->GetFieldID(env, GtkWidgetClassFc.clazz, "screen_changed", "I");
+	GtkWidgetClassFc.cached = 1;
+}
+
+GtkWidgetClass *getGtkWidgetClassFields(JNIEnv *env, jobject lpObject, GtkWidgetClass *lpStruct)
+{
+	if (!GtkWidgetClassFc.cached) cacheGtkWidgetClassFields(env, lpObject);
+	getGObjectClassFields(env, lpObject, (GObjectClass *)lpStruct);
+	lpStruct->activate_signal = (*env)->GetIntField(env, lpObject, GtkWidgetClassFc.activate_signal);
+	lpStruct->set_scroll_adjustments_signal = (*env)->GetIntField(env, lpObject, GtkWidgetClassFc.set_scroll_adjustments_signal);
+	lpStruct->dispatch_child_properties_changed = (void(*)())(*env)->GetIntField(env, lpObject, GtkWidgetClassFc.dispatch_child_properties_changed);
+	lpStruct->show = (void(*)())(*env)->GetIntField(env, lpObject, GtkWidgetClassFc.show);
+	lpStruct->show_all = (void(*)())(*env)->GetIntField(env, lpObject, GtkWidgetClassFc.show_all);
+	lpStruct->hide = (void(*)())(*env)->GetIntField(env, lpObject, GtkWidgetClassFc.hide);
+	lpStruct->hide_all = (void(*)())(*env)->GetIntField(env, lpObject, GtkWidgetClassFc.hide_all);
+	lpStruct->map = (void(*)())(*env)->GetIntField(env, lpObject, GtkWidgetClassFc.map);
+	lpStruct->unmap = (void(*)())(*env)->GetIntField(env, lpObject, GtkWidgetClassFc.unmap);
+	lpStruct->realize = (void(*)())(*env)->GetIntField(env, lpObject, GtkWidgetClassFc.realize);
+	lpStruct->unrealize = (void(*)())(*env)->GetIntField(env, lpObject, GtkWidgetClassFc.unrealize);
+	lpStruct->size_request = (void(*)())(*env)->GetIntField(env, lpObject, GtkWidgetClassFc.size_request);
+	lpStruct->size_allocate = (void(*)())(*env)->GetIntField(env, lpObject, GtkWidgetClassFc.size_allocate);
+	lpStruct->state_changed = (void(*)())(*env)->GetIntField(env, lpObject, GtkWidgetClassFc.state_changed);
+	lpStruct->parent_set = (void(*)())(*env)->GetIntField(env, lpObject, GtkWidgetClassFc.parent_set);
+	lpStruct->hierarchy_changed = (void(*)())(*env)->GetIntField(env, lpObject, GtkWidgetClassFc.hierarchy_changed);
+	lpStruct->style_set = (void(*)())(*env)->GetIntField(env, lpObject, GtkWidgetClassFc.style_set);
+	lpStruct->direction_changed = (void(*)())(*env)->GetIntField(env, lpObject, GtkWidgetClassFc.direction_changed);
+	lpStruct->grab_notify = (void(*)())(*env)->GetIntField(env, lpObject, GtkWidgetClassFc.grab_notify);
+	lpStruct->child_notify = (void(*)())(*env)->GetIntField(env, lpObject, GtkWidgetClassFc.child_notify);
+	lpStruct->mnemonic_activate = (gboolean(*)())(*env)->GetIntField(env, lpObject, GtkWidgetClassFc.mnemonic_activate);
+	lpStruct->grab_focus = (void(*)())(*env)->GetIntField(env, lpObject, GtkWidgetClassFc.grab_focus);
+	lpStruct->focus = (gboolean(*)())(*env)->GetIntField(env, lpObject, GtkWidgetClassFc.focus);
+	lpStruct->event = (gboolean(*)())(*env)->GetIntField(env, lpObject, GtkWidgetClassFc.event);
+	lpStruct->button_press_event = (gboolean(*)())(*env)->GetIntField(env, lpObject, GtkWidgetClassFc.button_press_event);
+	lpStruct->button_release_event = (gboolean(*)())(*env)->GetIntField(env, lpObject, GtkWidgetClassFc.button_release_event);
+	lpStruct->scroll_event = (gboolean(*)())(*env)->GetIntField(env, lpObject, GtkWidgetClassFc.scroll_event);
+	lpStruct->motion_notify_event = (gboolean(*)())(*env)->GetIntField(env, lpObject, GtkWidgetClassFc.motion_notify_event);
+	lpStruct->delete_event = (gboolean(*)())(*env)->GetIntField(env, lpObject, GtkWidgetClassFc.delete_event);
+	lpStruct->destroy_event = (gboolean(*)())(*env)->GetIntField(env, lpObject, GtkWidgetClassFc.destroy_event);
+	lpStruct->expose_event = (gboolean(*)())(*env)->GetIntField(env, lpObject, GtkWidgetClassFc.expose_event);
+	lpStruct->key_press_event = (gboolean(*)())(*env)->GetIntField(env, lpObject, GtkWidgetClassFc.key_press_event);
+	lpStruct->key_release_event = (gboolean(*)())(*env)->GetIntField(env, lpObject, GtkWidgetClassFc.key_release_event);
+	lpStruct->enter_notify_event = (gboolean(*)())(*env)->GetIntField(env, lpObject, GtkWidgetClassFc.enter_notify_event);
+	lpStruct->leave_notify_event = (gboolean(*)())(*env)->GetIntField(env, lpObject, GtkWidgetClassFc.leave_notify_event);
+	lpStruct->configure_event = (gboolean(*)())(*env)->GetIntField(env, lpObject, GtkWidgetClassFc.configure_event);
+	lpStruct->focus_in_event = (gboolean(*)())(*env)->GetIntField(env, lpObject, GtkWidgetClassFc.focus_in_event);
+	lpStruct->focus_out_event = (gboolean(*)())(*env)->GetIntField(env, lpObject, GtkWidgetClassFc.focus_out_event);
+	lpStruct->map_event = (gboolean(*)())(*env)->GetIntField(env, lpObject, GtkWidgetClassFc.map_event);
+	lpStruct->unmap_event = (gboolean(*)())(*env)->GetIntField(env, lpObject, GtkWidgetClassFc.unmap_event);
+	lpStruct->property_notify_event = (gboolean(*)())(*env)->GetIntField(env, lpObject, GtkWidgetClassFc.property_notify_event);
+	lpStruct->selection_clear_event = (gboolean(*)())(*env)->GetIntField(env, lpObject, GtkWidgetClassFc.selection_clear_event);
+	lpStruct->selection_request_event = (gboolean(*)())(*env)->GetIntField(env, lpObject, GtkWidgetClassFc.selection_request_event);
+	lpStruct->selection_notify_event = (gboolean(*)())(*env)->GetIntField(env, lpObject, GtkWidgetClassFc.selection_notify_event);
+	lpStruct->proximity_in_event = (gboolean(*)())(*env)->GetIntField(env, lpObject, GtkWidgetClassFc.proximity_in_event);
+	lpStruct->proximity_out_event = (gboolean(*)())(*env)->GetIntField(env, lpObject, GtkWidgetClassFc.proximity_out_event);
+	lpStruct->visibility_notify_event = (gboolean(*)())(*env)->GetIntField(env, lpObject, GtkWidgetClassFc.visibility_notify_event);
+	lpStruct->client_event = (gboolean(*)())(*env)->GetIntField(env, lpObject, GtkWidgetClassFc.client_event);
+	lpStruct->no_expose_event = (gboolean(*)())(*env)->GetIntField(env, lpObject, GtkWidgetClassFc.no_expose_event);
+	lpStruct->window_state_event = (gboolean(*)())(*env)->GetIntField(env, lpObject, GtkWidgetClassFc.window_state_event);
+	lpStruct->selection_get = (void(*)())(*env)->GetIntField(env, lpObject, GtkWidgetClassFc.selection_get);
+	lpStruct->selection_received = (void(*)())(*env)->GetIntField(env, lpObject, GtkWidgetClassFc.selection_received);
+	lpStruct->drag_begin = (void(*)())(*env)->GetIntField(env, lpObject, GtkWidgetClassFc.drag_begin);
+	lpStruct->drag_end = (void(*)())(*env)->GetIntField(env, lpObject, GtkWidgetClassFc.drag_end);
+	lpStruct->drag_data_get = (void(*)())(*env)->GetIntField(env, lpObject, GtkWidgetClassFc.drag_data_get);
+	lpStruct->drag_data_delete = (void(*)())(*env)->GetIntField(env, lpObject, GtkWidgetClassFc.drag_data_delete);
+	lpStruct->drag_leave = (void(*)())(*env)->GetIntField(env, lpObject, GtkWidgetClassFc.drag_leave);
+	lpStruct->drag_motion = (gboolean(*)())(*env)->GetIntField(env, lpObject, GtkWidgetClassFc.drag_motion);
+	lpStruct->drag_drop = (gboolean(*)())(*env)->GetIntField(env, lpObject, GtkWidgetClassFc.drag_drop);
+	lpStruct->drag_data_received = (void(*)())(*env)->GetIntField(env, lpObject, GtkWidgetClassFc.drag_data_received);
+	lpStruct->popup_menu = (gboolean(*)())(*env)->GetIntField(env, lpObject, GtkWidgetClassFc.popup_menu);
+	lpStruct->show_help = (gboolean(*)())(*env)->GetIntField(env, lpObject, GtkWidgetClassFc.show_help);
+	lpStruct->get_accessible = (AtkObject*(*)())(*env)->GetIntField(env, lpObject, GtkWidgetClassFc.get_accessible);
+	lpStruct->screen_changed = (void(*)())(*env)->GetIntField(env, lpObject, GtkWidgetClassFc.screen_changed);
+	return lpStruct;
+}
+
+void setGtkWidgetClassFields(JNIEnv *env, jobject lpObject, GtkWidgetClass *lpStruct)
+{
+	if (!GtkWidgetClassFc.cached) cacheGtkWidgetClassFields(env, lpObject);
+	setGObjectClassFields(env, lpObject, (GObjectClass *)lpStruct);
+	(*env)->SetIntField(env, lpObject, GtkWidgetClassFc.activate_signal, (jint)lpStruct->activate_signal);
+	(*env)->SetIntField(env, lpObject, GtkWidgetClassFc.set_scroll_adjustments_signal, (jint)lpStruct->set_scroll_adjustments_signal);
+	(*env)->SetIntField(env, lpObject, GtkWidgetClassFc.dispatch_child_properties_changed, (jint)lpStruct->dispatch_child_properties_changed);
+	(*env)->SetIntField(env, lpObject, GtkWidgetClassFc.show, (jint)lpStruct->show);
+	(*env)->SetIntField(env, lpObject, GtkWidgetClassFc.show_all, (jint)lpStruct->show_all);
+	(*env)->SetIntField(env, lpObject, GtkWidgetClassFc.hide, (jint)lpStruct->hide);
+	(*env)->SetIntField(env, lpObject, GtkWidgetClassFc.hide_all, (jint)lpStruct->hide_all);
+	(*env)->SetIntField(env, lpObject, GtkWidgetClassFc.map, (jint)lpStruct->map);
+	(*env)->SetIntField(env, lpObject, GtkWidgetClassFc.unmap, (jint)lpStruct->unmap);
+	(*env)->SetIntField(env, lpObject, GtkWidgetClassFc.realize, (jint)lpStruct->realize);
+	(*env)->SetIntField(env, lpObject, GtkWidgetClassFc.unrealize, (jint)lpStruct->unrealize);
+	(*env)->SetIntField(env, lpObject, GtkWidgetClassFc.size_request, (jint)lpStruct->size_request);
+	(*env)->SetIntField(env, lpObject, GtkWidgetClassFc.size_allocate, (jint)lpStruct->size_allocate);
+	(*env)->SetIntField(env, lpObject, GtkWidgetClassFc.state_changed, (jint)lpStruct->state_changed);
+	(*env)->SetIntField(env, lpObject, GtkWidgetClassFc.parent_set, (jint)lpStruct->parent_set);
+	(*env)->SetIntField(env, lpObject, GtkWidgetClassFc.hierarchy_changed, (jint)lpStruct->hierarchy_changed);
+	(*env)->SetIntField(env, lpObject, GtkWidgetClassFc.style_set, (jint)lpStruct->style_set);
+	(*env)->SetIntField(env, lpObject, GtkWidgetClassFc.direction_changed, (jint)lpStruct->direction_changed);
+	(*env)->SetIntField(env, lpObject, GtkWidgetClassFc.grab_notify, (jint)lpStruct->grab_notify);
+	(*env)->SetIntField(env, lpObject, GtkWidgetClassFc.child_notify, (jint)lpStruct->child_notify);
+	(*env)->SetIntField(env, lpObject, GtkWidgetClassFc.mnemonic_activate, (jint)lpStruct->mnemonic_activate);
+	(*env)->SetIntField(env, lpObject, GtkWidgetClassFc.grab_focus, (jint)lpStruct->grab_focus);
+	(*env)->SetIntField(env, lpObject, GtkWidgetClassFc.focus, (jint)lpStruct->focus);
+	(*env)->SetIntField(env, lpObject, GtkWidgetClassFc.event, (jint)lpStruct->event);
+	(*env)->SetIntField(env, lpObject, GtkWidgetClassFc.button_press_event, (jint)lpStruct->button_press_event);
+	(*env)->SetIntField(env, lpObject, GtkWidgetClassFc.button_release_event, (jint)lpStruct->button_release_event);
+	(*env)->SetIntField(env, lpObject, GtkWidgetClassFc.scroll_event, (jint)lpStruct->scroll_event);
+	(*env)->SetIntField(env, lpObject, GtkWidgetClassFc.motion_notify_event, (jint)lpStruct->motion_notify_event);
+	(*env)->SetIntField(env, lpObject, GtkWidgetClassFc.delete_event, (jint)lpStruct->delete_event);
+	(*env)->SetIntField(env, lpObject, GtkWidgetClassFc.destroy_event, (jint)lpStruct->destroy_event);
+	(*env)->SetIntField(env, lpObject, GtkWidgetClassFc.expose_event, (jint)lpStruct->expose_event);
+	(*env)->SetIntField(env, lpObject, GtkWidgetClassFc.key_press_event, (jint)lpStruct->key_press_event);
+	(*env)->SetIntField(env, lpObject, GtkWidgetClassFc.key_release_event, (jint)lpStruct->key_release_event);
+	(*env)->SetIntField(env, lpObject, GtkWidgetClassFc.enter_notify_event, (jint)lpStruct->enter_notify_event);
+	(*env)->SetIntField(env, lpObject, GtkWidgetClassFc.leave_notify_event, (jint)lpStruct->leave_notify_event);
+	(*env)->SetIntField(env, lpObject, GtkWidgetClassFc.configure_event, (jint)lpStruct->configure_event);
+	(*env)->SetIntField(env, lpObject, GtkWidgetClassFc.focus_in_event, (jint)lpStruct->focus_in_event);
+	(*env)->SetIntField(env, lpObject, GtkWidgetClassFc.focus_out_event, (jint)lpStruct->focus_out_event);
+	(*env)->SetIntField(env, lpObject, GtkWidgetClassFc.map_event, (jint)lpStruct->map_event);
+	(*env)->SetIntField(env, lpObject, GtkWidgetClassFc.unmap_event, (jint)lpStruct->unmap_event);
+	(*env)->SetIntField(env, lpObject, GtkWidgetClassFc.property_notify_event, (jint)lpStruct->property_notify_event);
+	(*env)->SetIntField(env, lpObject, GtkWidgetClassFc.selection_clear_event, (jint)lpStruct->selection_clear_event);
+	(*env)->SetIntField(env, lpObject, GtkWidgetClassFc.selection_request_event, (jint)lpStruct->selection_request_event);
+	(*env)->SetIntField(env, lpObject, GtkWidgetClassFc.selection_notify_event, (jint)lpStruct->selection_notify_event);
+	(*env)->SetIntField(env, lpObject, GtkWidgetClassFc.proximity_in_event, (jint)lpStruct->proximity_in_event);
+	(*env)->SetIntField(env, lpObject, GtkWidgetClassFc.proximity_out_event, (jint)lpStruct->proximity_out_event);
+	(*env)->SetIntField(env, lpObject, GtkWidgetClassFc.visibility_notify_event, (jint)lpStruct->visibility_notify_event);
+	(*env)->SetIntField(env, lpObject, GtkWidgetClassFc.client_event, (jint)lpStruct->client_event);
+	(*env)->SetIntField(env, lpObject, GtkWidgetClassFc.no_expose_event, (jint)lpStruct->no_expose_event);
+	(*env)->SetIntField(env, lpObject, GtkWidgetClassFc.window_state_event, (jint)lpStruct->window_state_event);
+	(*env)->SetIntField(env, lpObject, GtkWidgetClassFc.selection_get, (jint)lpStruct->selection_get);
+	(*env)->SetIntField(env, lpObject, GtkWidgetClassFc.selection_received, (jint)lpStruct->selection_received);
+	(*env)->SetIntField(env, lpObject, GtkWidgetClassFc.drag_begin, (jint)lpStruct->drag_begin);
+	(*env)->SetIntField(env, lpObject, GtkWidgetClassFc.drag_end, (jint)lpStruct->drag_end);
+	(*env)->SetIntField(env, lpObject, GtkWidgetClassFc.drag_data_get, (jint)lpStruct->drag_data_get);
+	(*env)->SetIntField(env, lpObject, GtkWidgetClassFc.drag_data_delete, (jint)lpStruct->drag_data_delete);
+	(*env)->SetIntField(env, lpObject, GtkWidgetClassFc.drag_leave, (jint)lpStruct->drag_leave);
+	(*env)->SetIntField(env, lpObject, GtkWidgetClassFc.drag_motion, (jint)lpStruct->drag_motion);
+	(*env)->SetIntField(env, lpObject, GtkWidgetClassFc.drag_drop, (jint)lpStruct->drag_drop);
+	(*env)->SetIntField(env, lpObject, GtkWidgetClassFc.drag_data_received, (jint)lpStruct->drag_data_received);
+	(*env)->SetIntField(env, lpObject, GtkWidgetClassFc.popup_menu, (jint)lpStruct->popup_menu);
+	(*env)->SetIntField(env, lpObject, GtkWidgetClassFc.show_help, (jint)lpStruct->show_help);
+	(*env)->SetIntField(env, lpObject, GtkWidgetClassFc.get_accessible, (jint)lpStruct->get_accessible);
+	(*env)->SetIntField(env, lpObject, GtkWidgetClassFc.screen_changed, (jint)lpStruct->screen_changed);
+}
+#endif
+
+#ifndef NO_PangoAttrColor
+typedef struct PangoAttrColor_FID_CACHE {
+	int cached;
+	jclass clazz;
+	jfieldID color_red, color_green, color_blue;
+} PangoAttrColor_FID_CACHE;
+
+PangoAttrColor_FID_CACHE PangoAttrColorFc;
+
+void cachePangoAttrColorFields(JNIEnv *env, jobject lpObject)
+{
+	if (PangoAttrColorFc.cached) return;
+	cachePangoAttributeFields(env, lpObject);
+	PangoAttrColorFc.clazz = (*env)->GetObjectClass(env, lpObject);
+	PangoAttrColorFc.color_red = (*env)->GetFieldID(env, PangoAttrColorFc.clazz, "color_red", "S");
+	PangoAttrColorFc.color_green = (*env)->GetFieldID(env, PangoAttrColorFc.clazz, "color_green", "S");
+	PangoAttrColorFc.color_blue = (*env)->GetFieldID(env, PangoAttrColorFc.clazz, "color_blue", "S");
+	PangoAttrColorFc.cached = 1;
+}
+
+PangoAttrColor *getPangoAttrColorFields(JNIEnv *env, jobject lpObject, PangoAttrColor *lpStruct)
+{
+	if (!PangoAttrColorFc.cached) cachePangoAttrColorFields(env, lpObject);
+	getPangoAttributeFields(env, lpObject, (PangoAttribute *)lpStruct);
+	lpStruct->color.red = (*env)->GetShortField(env, lpObject, PangoAttrColorFc.color_red);
+	lpStruct->color.green = (*env)->GetShortField(env, lpObject, PangoAttrColorFc.color_green);
+	lpStruct->color.blue = (*env)->GetShortField(env, lpObject, PangoAttrColorFc.color_blue);
+	return lpStruct;
+}
+
+void setPangoAttrColorFields(JNIEnv *env, jobject lpObject, PangoAttrColor *lpStruct)
+{
+	if (!PangoAttrColorFc.cached) cachePangoAttrColorFields(env, lpObject);
+	setPangoAttributeFields(env, lpObject, (PangoAttribute *)lpStruct);
+	(*env)->SetShortField(env, lpObject, PangoAttrColorFc.color_red, (jshort)lpStruct->color.red);
+	(*env)->SetShortField(env, lpObject, PangoAttrColorFc.color_green, (jshort)lpStruct->color.green);
+	(*env)->SetShortField(env, lpObject, PangoAttrColorFc.color_blue, (jshort)lpStruct->color.blue);
+}
+#endif
+
+#ifndef NO_PangoAttrInt
+typedef struct PangoAttrInt_FID_CACHE {
+	int cached;
+	jclass clazz;
+	jfieldID value;
+} PangoAttrInt_FID_CACHE;
+
+PangoAttrInt_FID_CACHE PangoAttrIntFc;
+
+void cachePangoAttrIntFields(JNIEnv *env, jobject lpObject)
+{
+	if (PangoAttrIntFc.cached) return;
+	cachePangoAttributeFields(env, lpObject);
+	PangoAttrIntFc.clazz = (*env)->GetObjectClass(env, lpObject);
+	PangoAttrIntFc.value = (*env)->GetFieldID(env, PangoAttrIntFc.clazz, "value", "I");
+	PangoAttrIntFc.cached = 1;
+}
+
+PangoAttrInt *getPangoAttrIntFields(JNIEnv *env, jobject lpObject, PangoAttrInt *lpStruct)
+{
+	if (!PangoAttrIntFc.cached) cachePangoAttrIntFields(env, lpObject);
+	getPangoAttributeFields(env, lpObject, (PangoAttribute *)lpStruct);
+	lpStruct->value = (*env)->GetIntField(env, lpObject, PangoAttrIntFc.value);
+	return lpStruct;
+}
+
+void setPangoAttrIntFields(JNIEnv *env, jobject lpObject, PangoAttrInt *lpStruct)
+{
+	if (!PangoAttrIntFc.cached) cachePangoAttrIntFields(env, lpObject);
+	setPangoAttributeFields(env, lpObject, (PangoAttribute *)lpStruct);
+	(*env)->SetIntField(env, lpObject, PangoAttrIntFc.value, (jint)lpStruct->value);
+}
+#endif
+
+#ifndef NO_PangoAttribute
+typedef struct PangoAttribute_FID_CACHE {
+	int cached;
+	jclass clazz;
+	jfieldID klass, start_index, end_index;
+} PangoAttribute_FID_CACHE;
+
+PangoAttribute_FID_CACHE PangoAttributeFc;
+
+void cachePangoAttributeFields(JNIEnv *env, jobject lpObject)
+{
+	if (PangoAttributeFc.cached) return;
+	PangoAttributeFc.clazz = (*env)->GetObjectClass(env, lpObject);
+	PangoAttributeFc.klass = (*env)->GetFieldID(env, PangoAttributeFc.clazz, "klass", "I");
+	PangoAttributeFc.start_index = (*env)->GetFieldID(env, PangoAttributeFc.clazz, "start_index", "I");
+	PangoAttributeFc.end_index = (*env)->GetFieldID(env, PangoAttributeFc.clazz, "end_index", "I");
+	PangoAttributeFc.cached = 1;
+}
+
+PangoAttribute *getPangoAttributeFields(JNIEnv *env, jobject lpObject, PangoAttribute *lpStruct)
+{
+	if (!PangoAttributeFc.cached) cachePangoAttributeFields(env, lpObject);
+	lpStruct->klass = (const PangoAttrClass *)(*env)->GetIntField(env, lpObject, PangoAttributeFc.klass);
+	lpStruct->start_index = (*env)->GetIntField(env, lpObject, PangoAttributeFc.start_index);
+	lpStruct->end_index = (*env)->GetIntField(env, lpObject, PangoAttributeFc.end_index);
+	return lpStruct;
+}
+
+void setPangoAttributeFields(JNIEnv *env, jobject lpObject, PangoAttribute *lpStruct)
+{
+	if (!PangoAttributeFc.cached) cachePangoAttributeFields(env, lpObject);
+	(*env)->SetIntField(env, lpObject, PangoAttributeFc.klass, (jint)lpStruct->klass);
+	(*env)->SetIntField(env, lpObject, PangoAttributeFc.start_index, (jint)lpStruct->start_index);
+	(*env)->SetIntField(env, lpObject, PangoAttributeFc.end_index, (jint)lpStruct->end_index);
+}
+#endif
+
+#ifndef NO_PangoItem
+typedef struct PangoItem_FID_CACHE {
+	int cached;
+	jclass clazz;
+	jfieldID offset, length, num_chars, analysis_shape_engine, analysis_lang_engine, analysis_font, analysis_level, analysis_language, analysis_extra_attrs;
+} PangoItem_FID_CACHE;
+
+PangoItem_FID_CACHE PangoItemFc;
+
+void cachePangoItemFields(JNIEnv *env, jobject lpObject)
+{
+	if (PangoItemFc.cached) return;
+	PangoItemFc.clazz = (*env)->GetObjectClass(env, lpObject);
+	PangoItemFc.offset = (*env)->GetFieldID(env, PangoItemFc.clazz, "offset", "I");
+	PangoItemFc.length = (*env)->GetFieldID(env, PangoItemFc.clazz, "length", "I");
+	PangoItemFc.num_chars = (*env)->GetFieldID(env, PangoItemFc.clazz, "num_chars", "I");
+	PangoItemFc.analysis_shape_engine = (*env)->GetFieldID(env, PangoItemFc.clazz, "analysis_shape_engine", "I");
+	PangoItemFc.analysis_lang_engine = (*env)->GetFieldID(env, PangoItemFc.clazz, "analysis_lang_engine", "I");
+	PangoItemFc.analysis_font = (*env)->GetFieldID(env, PangoItemFc.clazz, "analysis_font", "I");
+	PangoItemFc.analysis_level = (*env)->GetFieldID(env, PangoItemFc.clazz, "analysis_level", "B");
+	PangoItemFc.analysis_language = (*env)->GetFieldID(env, PangoItemFc.clazz, "analysis_language", "I");
+	PangoItemFc.analysis_extra_attrs = (*env)->GetFieldID(env, PangoItemFc.clazz, "analysis_extra_attrs", "I");
+	PangoItemFc.cached = 1;
+}
+
+PangoItem *getPangoItemFields(JNIEnv *env, jobject lpObject, PangoItem *lpStruct)
+{
+	if (!PangoItemFc.cached) cachePangoItemFields(env, lpObject);
+	lpStruct->offset = (*env)->GetIntField(env, lpObject, PangoItemFc.offset);
+	lpStruct->length = (*env)->GetIntField(env, lpObject, PangoItemFc.length);
+	lpStruct->num_chars = (*env)->GetIntField(env, lpObject, PangoItemFc.num_chars);
+	lpStruct->analysis.shape_engine = (PangoEngineShape *)(*env)->GetIntField(env, lpObject, PangoItemFc.analysis_shape_engine);
+	lpStruct->analysis.lang_engine = (PangoEngineLang *)(*env)->GetIntField(env, lpObject, PangoItemFc.analysis_lang_engine);
+	lpStruct->analysis.font = (PangoFont *)(*env)->GetIntField(env, lpObject, PangoItemFc.analysis_font);
+	lpStruct->analysis.level = (*env)->GetByteField(env, lpObject, PangoItemFc.analysis_level);
+	lpStruct->analysis.language = (PangoLanguage *)(*env)->GetIntField(env, lpObject, PangoItemFc.analysis_language);
+	lpStruct->analysis.extra_attrs = (GSList *)(*env)->GetIntField(env, lpObject, PangoItemFc.analysis_extra_attrs);
+	return lpStruct;
+}
+
+void setPangoItemFields(JNIEnv *env, jobject lpObject, PangoItem *lpStruct)
+{
+	if (!PangoItemFc.cached) cachePangoItemFields(env, lpObject);
+	(*env)->SetIntField(env, lpObject, PangoItemFc.offset, (jint)lpStruct->offset);
+	(*env)->SetIntField(env, lpObject, PangoItemFc.length, (jint)lpStruct->length);
+	(*env)->SetIntField(env, lpObject, PangoItemFc.num_chars, (jint)lpStruct->num_chars);
+	(*env)->SetIntField(env, lpObject, PangoItemFc.analysis_shape_engine, (jint)lpStruct->analysis.shape_engine);
+	(*env)->SetIntField(env, lpObject, PangoItemFc.analysis_lang_engine, (jint)lpStruct->analysis.lang_engine);
+	(*env)->SetIntField(env, lpObject, PangoItemFc.analysis_font, (jint)lpStruct->analysis.font);
+	(*env)->SetByteField(env, lpObject, PangoItemFc.analysis_level, (jbyte)lpStruct->analysis.level);
+	(*env)->SetIntField(env, lpObject, PangoItemFc.analysis_language, (jint)lpStruct->analysis.language);
+	(*env)->SetIntField(env, lpObject, PangoItemFc.analysis_extra_attrs, (jint)lpStruct->analysis.extra_attrs);
+}
+#endif
+
+#ifndef NO_PangoLayoutLine
+typedef struct PangoLayoutLine_FID_CACHE {
+	int cached;
+	jclass clazz;
+	jfieldID layout, start_index, length, runs;
+} PangoLayoutLine_FID_CACHE;
+
+PangoLayoutLine_FID_CACHE PangoLayoutLineFc;
+
+void cachePangoLayoutLineFields(JNIEnv *env, jobject lpObject)
+{
+	if (PangoLayoutLineFc.cached) return;
+	PangoLayoutLineFc.clazz = (*env)->GetObjectClass(env, lpObject);
+	PangoLayoutLineFc.layout = (*env)->GetFieldID(env, PangoLayoutLineFc.clazz, "layout", "I");
+	PangoLayoutLineFc.start_index = (*env)->GetFieldID(env, PangoLayoutLineFc.clazz, "start_index", "I");
+	PangoLayoutLineFc.length = (*env)->GetFieldID(env, PangoLayoutLineFc.clazz, "length", "I");
+	PangoLayoutLineFc.runs = (*env)->GetFieldID(env, PangoLayoutLineFc.clazz, "runs", "I");
+	PangoLayoutLineFc.cached = 1;
+}
+
+PangoLayoutLine *getPangoLayoutLineFields(JNIEnv *env, jobject lpObject, PangoLayoutLine *lpStruct)
+{
+	if (!PangoLayoutLineFc.cached) cachePangoLayoutLineFields(env, lpObject);
+	lpStruct->layout = (PangoLayout *)(*env)->GetIntField(env, lpObject, PangoLayoutLineFc.layout);
+	lpStruct->start_index = (*env)->GetIntField(env, lpObject, PangoLayoutLineFc.start_index);
+	lpStruct->length = (*env)->GetIntField(env, lpObject, PangoLayoutLineFc.length);
+	lpStruct->runs = (GSList *)(*env)->GetIntField(env, lpObject, PangoLayoutLineFc.runs);
+	return lpStruct;
+}
+
+void setPangoLayoutLineFields(JNIEnv *env, jobject lpObject, PangoLayoutLine *lpStruct)
+{
+	if (!PangoLayoutLineFc.cached) cachePangoLayoutLineFields(env, lpObject);
+	(*env)->SetIntField(env, lpObject, PangoLayoutLineFc.layout, (jint)lpStruct->layout);
+	(*env)->SetIntField(env, lpObject, PangoLayoutLineFc.start_index, (jint)lpStruct->start_index);
+	(*env)->SetIntField(env, lpObject, PangoLayoutLineFc.length, (jint)lpStruct->length);
+	(*env)->SetIntField(env, lpObject, PangoLayoutLineFc.runs, (jint)lpStruct->runs);
+}
+#endif
+
+#ifndef NO_PangoLayoutRun
+typedef struct PangoLayoutRun_FID_CACHE {
+	int cached;
+	jclass clazz;
+	jfieldID item, glyphs;
+} PangoLayoutRun_FID_CACHE;
+
+PangoLayoutRun_FID_CACHE PangoLayoutRunFc;
+
+void cachePangoLayoutRunFields(JNIEnv *env, jobject lpObject)
+{
+	if (PangoLayoutRunFc.cached) return;
+	PangoLayoutRunFc.clazz = (*env)->GetObjectClass(env, lpObject);
+	PangoLayoutRunFc.item = (*env)->GetFieldID(env, PangoLayoutRunFc.clazz, "item", "I");
+	PangoLayoutRunFc.glyphs = (*env)->GetFieldID(env, PangoLayoutRunFc.clazz, "glyphs", "I");
+	PangoLayoutRunFc.cached = 1;
+}
+
+PangoLayoutRun *getPangoLayoutRunFields(JNIEnv *env, jobject lpObject, PangoLayoutRun *lpStruct)
+{
+	if (!PangoLayoutRunFc.cached) cachePangoLayoutRunFields(env, lpObject);
+	lpStruct->item = (PangoItem *)(*env)->GetIntField(env, lpObject, PangoLayoutRunFc.item);
+	lpStruct->glyphs = (PangoGlyphString *)(*env)->GetIntField(env, lpObject, PangoLayoutRunFc.glyphs);
+	return lpStruct;
+}
+
+void setPangoLayoutRunFields(JNIEnv *env, jobject lpObject, PangoLayoutRun *lpStruct)
+{
+	if (!PangoLayoutRunFc.cached) cachePangoLayoutRunFields(env, lpObject);
+	(*env)->SetIntField(env, lpObject, PangoLayoutRunFc.item, (jint)lpStruct->item);
+	(*env)->SetIntField(env, lpObject, PangoLayoutRunFc.glyphs, (jint)lpStruct->glyphs);
+}
+#endif
+
+#ifndef NO_PangoLogAttr
+typedef struct PangoLogAttr_FID_CACHE {
+	int cached;
+	jclass clazz;
+	jfieldID is_line_break, is_mandatory_break, is_char_break, is_white, is_cursor_position, is_word_start, is_word_end, is_sentence_boundary, is_sentence_start, is_sentence_end;
+} PangoLogAttr_FID_CACHE;
+
+PangoLogAttr_FID_CACHE PangoLogAttrFc;
+
+void cachePangoLogAttrFields(JNIEnv *env, jobject lpObject)
+{
+	if (PangoLogAttrFc.cached) return;
+	PangoLogAttrFc.clazz = (*env)->GetObjectClass(env, lpObject);
+	PangoLogAttrFc.is_line_break = (*env)->GetFieldID(env, PangoLogAttrFc.clazz, "is_line_break", "Z");
+	PangoLogAttrFc.is_mandatory_break = (*env)->GetFieldID(env, PangoLogAttrFc.clazz, "is_mandatory_break", "Z");
+	PangoLogAttrFc.is_char_break = (*env)->GetFieldID(env, PangoLogAttrFc.clazz, "is_char_break", "Z");
+	PangoLogAttrFc.is_white = (*env)->GetFieldID(env, PangoLogAttrFc.clazz, "is_white", "Z");
+	PangoLogAttrFc.is_cursor_position = (*env)->GetFieldID(env, PangoLogAttrFc.clazz, "is_cursor_position", "Z");
+	PangoLogAttrFc.is_word_start = (*env)->GetFieldID(env, PangoLogAttrFc.clazz, "is_word_start", "Z");
+	PangoLogAttrFc.is_word_end = (*env)->GetFieldID(env, PangoLogAttrFc.clazz, "is_word_end", "Z");
+	PangoLogAttrFc.is_sentence_boundary = (*env)->GetFieldID(env, PangoLogAttrFc.clazz, "is_sentence_boundary", "Z");
+	PangoLogAttrFc.is_sentence_start = (*env)->GetFieldID(env, PangoLogAttrFc.clazz, "is_sentence_start", "Z");
+	PangoLogAttrFc.is_sentence_end = (*env)->GetFieldID(env, PangoLogAttrFc.clazz, "is_sentence_end", "Z");
+	PangoLogAttrFc.cached = 1;
+}
+
+PangoLogAttr *getPangoLogAttrFields(JNIEnv *env, jobject lpObject, PangoLogAttr *lpStruct)
+{
+	if (!PangoLogAttrFc.cached) cachePangoLogAttrFields(env, lpObject);
+	lpStruct->is_line_break = (*env)->GetBooleanField(env, lpObject, PangoLogAttrFc.is_line_break);
+	lpStruct->is_mandatory_break = (*env)->GetBooleanField(env, lpObject, PangoLogAttrFc.is_mandatory_break);
+	lpStruct->is_char_break = (*env)->GetBooleanField(env, lpObject, PangoLogAttrFc.is_char_break);
+	lpStruct->is_white = (*env)->GetBooleanField(env, lpObject, PangoLogAttrFc.is_white);
+	lpStruct->is_cursor_position = (*env)->GetBooleanField(env, lpObject, PangoLogAttrFc.is_cursor_position);
+	lpStruct->is_word_start = (*env)->GetBooleanField(env, lpObject, PangoLogAttrFc.is_word_start);
+	lpStruct->is_word_end = (*env)->GetBooleanField(env, lpObject, PangoLogAttrFc.is_word_end);
+	lpStruct->is_sentence_boundary = (*env)->GetBooleanField(env, lpObject, PangoLogAttrFc.is_sentence_boundary);
+	lpStruct->is_sentence_start = (*env)->GetBooleanField(env, lpObject, PangoLogAttrFc.is_sentence_start);
+	lpStruct->is_sentence_end = (*env)->GetBooleanField(env, lpObject, PangoLogAttrFc.is_sentence_end);
+	return lpStruct;
+}
+
+void setPangoLogAttrFields(JNIEnv *env, jobject lpObject, PangoLogAttr *lpStruct)
+{
+	if (!PangoLogAttrFc.cached) cachePangoLogAttrFields(env, lpObject);
+	(*env)->SetBooleanField(env, lpObject, PangoLogAttrFc.is_line_break, (jboolean)lpStruct->is_line_break);
+	(*env)->SetBooleanField(env, lpObject, PangoLogAttrFc.is_mandatory_break, (jboolean)lpStruct->is_mandatory_break);
+	(*env)->SetBooleanField(env, lpObject, PangoLogAttrFc.is_char_break, (jboolean)lpStruct->is_char_break);
+	(*env)->SetBooleanField(env, lpObject, PangoLogAttrFc.is_white, (jboolean)lpStruct->is_white);
+	(*env)->SetBooleanField(env, lpObject, PangoLogAttrFc.is_cursor_position, (jboolean)lpStruct->is_cursor_position);
+	(*env)->SetBooleanField(env, lpObject, PangoLogAttrFc.is_word_start, (jboolean)lpStruct->is_word_start);
+	(*env)->SetBooleanField(env, lpObject, PangoLogAttrFc.is_word_end, (jboolean)lpStruct->is_word_end);
+	(*env)->SetBooleanField(env, lpObject, PangoLogAttrFc.is_sentence_boundary, (jboolean)lpStruct->is_sentence_boundary);
+	(*env)->SetBooleanField(env, lpObject, PangoLogAttrFc.is_sentence_start, (jboolean)lpStruct->is_sentence_start);
+	(*env)->SetBooleanField(env, lpObject, PangoLogAttrFc.is_sentence_end, (jboolean)lpStruct->is_sentence_end);
+}
+#endif
+
+#ifndef NO_PangoRectangle
+typedef struct PangoRectangle_FID_CACHE {
+	int cached;
+	jclass clazz;
+	jfieldID x, y, width, height;
+} PangoRectangle_FID_CACHE;
+
+PangoRectangle_FID_CACHE PangoRectangleFc;
+
+void cachePangoRectangleFields(JNIEnv *env, jobject lpObject)
+{
+	if (PangoRectangleFc.cached) return;
+	PangoRectangleFc.clazz = (*env)->GetObjectClass(env, lpObject);
+	PangoRectangleFc.x = (*env)->GetFieldID(env, PangoRectangleFc.clazz, "x", "I");
+	PangoRectangleFc.y = (*env)->GetFieldID(env, PangoRectangleFc.clazz, "y", "I");
+	PangoRectangleFc.width = (*env)->GetFieldID(env, PangoRectangleFc.clazz, "width", "I");
+	PangoRectangleFc.height = (*env)->GetFieldID(env, PangoRectangleFc.clazz, "height", "I");
+	PangoRectangleFc.cached = 1;
+}
+
+PangoRectangle *getPangoRectangleFields(JNIEnv *env, jobject lpObject, PangoRectangle *lpStruct)
+{
+	if (!PangoRectangleFc.cached) cachePangoRectangleFields(env, lpObject);
+	lpStruct->x = (*env)->GetIntField(env, lpObject, PangoRectangleFc.x);
+	lpStruct->y = (*env)->GetIntField(env, lpObject, PangoRectangleFc.y);
+	lpStruct->width = (*env)->GetIntField(env, lpObject, PangoRectangleFc.width);
+	lpStruct->height = (*env)->GetIntField(env, lpObject, PangoRectangleFc.height);
+	return lpStruct;
+}
+
+void setPangoRectangleFields(JNIEnv *env, jobject lpObject, PangoRectangle *lpStruct)
+{
+	if (!PangoRectangleFc.cached) cachePangoRectangleFields(env, lpObject);
+	(*env)->SetIntField(env, lpObject, PangoRectangleFc.x, (jint)lpStruct->x);
+	(*env)->SetIntField(env, lpObject, PangoRectangleFc.y, (jint)lpStruct->y);
+	(*env)->SetIntField(env, lpObject, PangoRectangleFc.width, (jint)lpStruct->width);
+	(*env)->SetIntField(env, lpObject, PangoRectangleFc.height, (jint)lpStruct->height);
+}
+#endif
+
+#ifndef NO_XAnyEvent
+typedef struct XAnyEvent_FID_CACHE {
+	int cached;
+	jclass clazz;
+	jfieldID serial, send_event, display, window;
+} XAnyEvent_FID_CACHE;
+
+XAnyEvent_FID_CACHE XAnyEventFc;
+
+void cacheXAnyEventFields(JNIEnv *env, jobject lpObject)
+{
+	if (XAnyEventFc.cached) return;
+	cacheXEventFields(env, lpObject);
+	XAnyEventFc.clazz = (*env)->GetObjectClass(env, lpObject);
+	XAnyEventFc.serial = (*env)->GetFieldID(env, XAnyEventFc.clazz, "serial", "I");
+	XAnyEventFc.send_event = (*env)->GetFieldID(env, XAnyEventFc.clazz, "send_event", "I");
+	XAnyEventFc.display = (*env)->GetFieldID(env, XAnyEventFc.clazz, "display", "I");
+	XAnyEventFc.window = (*env)->GetFieldID(env, XAnyEventFc.clazz, "window", "I");
+	XAnyEventFc.cached = 1;
+}
+
+XAnyEvent *getXAnyEventFields(JNIEnv *env, jobject lpObject, XAnyEvent *lpStruct)
+{
+	if (!XAnyEventFc.cached) cacheXAnyEventFields(env, lpObject);
+	getXEventFields(env, lpObject, (XEvent *)lpStruct);
+	lpStruct->serial = (*env)->GetIntField(env, lpObject, XAnyEventFc.serial);
+	lpStruct->send_event = (*env)->GetIntField(env, lpObject, XAnyEventFc.send_event);
+	lpStruct->display = (Display *)(*env)->GetIntField(env, lpObject, XAnyEventFc.display);
+	lpStruct->window = (Window)(*env)->GetIntField(env, lpObject, XAnyEventFc.window);
+	return lpStruct;
+}
+
+void setXAnyEventFields(JNIEnv *env, jobject lpObject, XAnyEvent *lpStruct)
+{
+	if (!XAnyEventFc.cached) cacheXAnyEventFields(env, lpObject);
+	setXEventFields(env, lpObject, (XEvent *)lpStruct);
+	(*env)->SetIntField(env, lpObject, XAnyEventFc.serial, (jint)lpStruct->serial);
+	(*env)->SetIntField(env, lpObject, XAnyEventFc.send_event, (jint)lpStruct->send_event);
+	(*env)->SetIntField(env, lpObject, XAnyEventFc.display, (jint)lpStruct->display);
+	(*env)->SetIntField(env, lpObject, XAnyEventFc.window, (jint)lpStruct->window);
+}
+#endif
+
+#ifndef NO_XButtonEvent
+typedef struct XButtonEvent_FID_CACHE {
+	int cached;
+	jclass clazz;
+	jfieldID root, subwindow, time, x, y, x_root, y_root, state, button, same_screen;
+} XButtonEvent_FID_CACHE;
+
+XButtonEvent_FID_CACHE XButtonEventFc;
+
+void cacheXButtonEventFields(JNIEnv *env, jobject lpObject)
+{
+	if (XButtonEventFc.cached) return;
+	cacheXAnyEventFields(env, lpObject);
+	XButtonEventFc.clazz = (*env)->GetObjectClass(env, lpObject);
+	XButtonEventFc.root = (*env)->GetFieldID(env, XButtonEventFc.clazz, "root", "I");
+	XButtonEventFc.subwindow = (*env)->GetFieldID(env, XButtonEventFc.clazz, "subwindow", "I");
+	XButtonEventFc.time = (*env)->GetFieldID(env, XButtonEventFc.clazz, "time", "I");
+	XButtonEventFc.x = (*env)->GetFieldID(env, XButtonEventFc.clazz, "x", "I");
+	XButtonEventFc.y = (*env)->GetFieldID(env, XButtonEventFc.clazz, "y", "I");
+	XButtonEventFc.x_root = (*env)->GetFieldID(env, XButtonEventFc.clazz, "x_root", "I");
+	XButtonEventFc.y_root = (*env)->GetFieldID(env, XButtonEventFc.clazz, "y_root", "I");
+	XButtonEventFc.state = (*env)->GetFieldID(env, XButtonEventFc.clazz, "state", "I");
+	XButtonEventFc.button = (*env)->GetFieldID(env, XButtonEventFc.clazz, "button", "I");
+	XButtonEventFc.same_screen = (*env)->GetFieldID(env, XButtonEventFc.clazz, "same_screen", "I");
+	XButtonEventFc.cached = 1;
+}
+
+XButtonEvent *getXButtonEventFields(JNIEnv *env, jobject lpObject, XButtonEvent *lpStruct)
+{
+	if (!XButtonEventFc.cached) cacheXButtonEventFields(env, lpObject);
+	getXAnyEventFields(env, lpObject, (XAnyEvent *)lpStruct);
+	lpStruct->root = (*env)->GetIntField(env, lpObject, XButtonEventFc.root);
+	lpStruct->subwindow = (*env)->GetIntField(env, lpObject, XButtonEventFc.subwindow);
+	lpStruct->time = (*env)->GetIntField(env, lpObject, XButtonEventFc.time);
+	lpStruct->x = (*env)->GetIntField(env, lpObject, XButtonEventFc.x);
+	lpStruct->y = (*env)->GetIntField(env, lpObject, XButtonEventFc.y);
+	lpStruct->x_root = (*env)->GetIntField(env, lpObject, XButtonEventFc.x_root);
+	lpStruct->y_root = (*env)->GetIntField(env, lpObject, XButtonEventFc.y_root);
+	lpStruct->state = (*env)->GetIntField(env, lpObject, XButtonEventFc.state);
+	lpStruct->button = (*env)->GetIntField(env, lpObject, XButtonEventFc.button);
+	lpStruct->same_screen = (*env)->GetIntField(env, lpObject, XButtonEventFc.same_screen);
+	return lpStruct;
+}
+
+void setXButtonEventFields(JNIEnv *env, jobject lpObject, XButtonEvent *lpStruct)
+{
+	if (!XButtonEventFc.cached) cacheXButtonEventFields(env, lpObject);
+	setXAnyEventFields(env, lpObject, (XAnyEvent *)lpStruct);
+	(*env)->SetIntField(env, lpObject, XButtonEventFc.root, (jint)lpStruct->root);
+	(*env)->SetIntField(env, lpObject, XButtonEventFc.subwindow, (jint)lpStruct->subwindow);
+	(*env)->SetIntField(env, lpObject, XButtonEventFc.time, (jint)lpStruct->time);
+	(*env)->SetIntField(env, lpObject, XButtonEventFc.x, (jint)lpStruct->x);
+	(*env)->SetIntField(env, lpObject, XButtonEventFc.y, (jint)lpStruct->y);
+	(*env)->SetIntField(env, lpObject, XButtonEventFc.x_root, (jint)lpStruct->x_root);
+	(*env)->SetIntField(env, lpObject, XButtonEventFc.y_root, (jint)lpStruct->y_root);
+	(*env)->SetIntField(env, lpObject, XButtonEventFc.state, (jint)lpStruct->state);
+	(*env)->SetIntField(env, lpObject, XButtonEventFc.button, (jint)lpStruct->button);
+	(*env)->SetIntField(env, lpObject, XButtonEventFc.same_screen, (jint)lpStruct->same_screen);
+}
+#endif
+
+#ifndef NO_XClientMessageEvent
+typedef struct XClientMessageEvent_FID_CACHE {
+	int cached;
+	jclass clazz;
+	jfieldID type, serial, send_event, display, window, message_type, format, data;
+} XClientMessageEvent_FID_CACHE;
+
+XClientMessageEvent_FID_CACHE XClientMessageEventFc;
+
+void cacheXClientMessageEventFields(JNIEnv *env, jobject lpObject)
+{
+	if (XClientMessageEventFc.cached) return;
+	XClientMessageEventFc.clazz = (*env)->GetObjectClass(env, lpObject);
+	XClientMessageEventFc.type = (*env)->GetFieldID(env, XClientMessageEventFc.clazz, "type", "I");
+	XClientMessageEventFc.serial = (*env)->GetFieldID(env, XClientMessageEventFc.clazz, "serial", "I");
+	XClientMessageEventFc.send_event = (*env)->GetFieldID(env, XClientMessageEventFc.clazz, "send_event", "Z");
+	XClientMessageEventFc.display = (*env)->GetFieldID(env, XClientMessageEventFc.clazz, "display", "I");
+	XClientMessageEventFc.window = (*env)->GetFieldID(env, XClientMessageEventFc.clazz, "window", "I");
+	XClientMessageEventFc.message_type = (*env)->GetFieldID(env, XClientMessageEventFc.clazz, "message_type", "I");
+	XClientMessageEventFc.format = (*env)->GetFieldID(env, XClientMessageEventFc.clazz, "format", "I");
+	XClientMessageEventFc.data = (*env)->GetFieldID(env, XClientMessageEventFc.clazz, "data", "[I");
+	XClientMessageEventFc.cached = 1;
+}
+
+XClientMessageEvent *getXClientMessageEventFields(JNIEnv *env, jobject lpObject, XClientMessageEvent *lpStruct)
+{
+	if (!XClientMessageEventFc.cached) cacheXClientMessageEventFields(env, lpObject);
+	lpStruct->type = (*env)->GetIntField(env, lpObject, XClientMessageEventFc.type);
+	lpStruct->serial = (*env)->GetIntField(env, lpObject, XClientMessageEventFc.serial);
+	lpStruct->send_event = (*env)->GetBooleanField(env, lpObject, XClientMessageEventFc.send_event);
+	lpStruct->display = (Display *)(*env)->GetIntField(env, lpObject, XClientMessageEventFc.display);
+	lpStruct->window = (Window)(*env)->GetIntField(env, lpObject, XClientMessageEventFc.window);
+	lpStruct->message_type = (Atom)(*env)->GetIntField(env, lpObject, XClientMessageEventFc.message_type);
+	lpStruct->format = (*env)->GetIntField(env, lpObject, XClientMessageEventFc.format);
+	{
+	jintArray lpObject1 = (jintArray)(*env)->GetObjectField(env, lpObject, XClientMessageEventFc.data);
+	(*env)->GetIntArrayRegion(env, lpObject1, 0, sizeof(lpStruct->data.l) / 4, (jint *)lpStruct->data.l);
+	}
+	return lpStruct;
+}
+
+void setXClientMessageEventFields(JNIEnv *env, jobject lpObject, XClientMessageEvent *lpStruct)
+{
+	if (!XClientMessageEventFc.cached) cacheXClientMessageEventFields(env, lpObject);
+	(*env)->SetIntField(env, lpObject, XClientMessageEventFc.type, (jint)lpStruct->type);
+	(*env)->SetIntField(env, lpObject, XClientMessageEventFc.serial, (jint)lpStruct->serial);
+	(*env)->SetBooleanField(env, lpObject, XClientMessageEventFc.send_event, (jboolean)lpStruct->send_event);
+	(*env)->SetIntField(env, lpObject, XClientMessageEventFc.display, (jint)lpStruct->display);
+	(*env)->SetIntField(env, lpObject, XClientMessageEventFc.window, (jint)lpStruct->window);
+	(*env)->SetIntField(env, lpObject, XClientMessageEventFc.message_type, (jint)lpStruct->message_type);
+	(*env)->SetIntField(env, lpObject, XClientMessageEventFc.format, (jint)lpStruct->format);
+	{
+	jintArray lpObject1 = (jintArray)(*env)->GetObjectField(env, lpObject, XClientMessageEventFc.data);
+	(*env)->SetIntArrayRegion(env, lpObject1, 0, sizeof(lpStruct->data.l) / 4, (jint *)lpStruct->data.l);
+	}
+}
+#endif
+
+#ifndef NO_XCrossingEvent
+typedef struct XCrossingEvent_FID_CACHE {
+	int cached;
+	jclass clazz;
+	jfieldID root, subwindow, time, x, y, x_root, y_root, mode, detail, same_screen, focus, state;
+} XCrossingEvent_FID_CACHE;
+
+XCrossingEvent_FID_CACHE XCrossingEventFc;
+
+void cacheXCrossingEventFields(JNIEnv *env, jobject lpObject)
+{
+	if (XCrossingEventFc.cached) return;
+	cacheXAnyEventFields(env, lpObject);
+	XCrossingEventFc.clazz = (*env)->GetObjectClass(env, lpObject);
+	XCrossingEventFc.root = (*env)->GetFieldID(env, XCrossingEventFc.clazz, "root", "I");
+	XCrossingEventFc.subwindow = (*env)->GetFieldID(env, XCrossingEventFc.clazz, "subwindow", "I");
+	XCrossingEventFc.time = (*env)->GetFieldID(env, XCrossingEventFc.clazz, "time", "I");
+	XCrossingEventFc.x = (*env)->GetFieldID(env, XCrossingEventFc.clazz, "x", "I");
+	XCrossingEventFc.y = (*env)->GetFieldID(env, XCrossingEventFc.clazz, "y", "I");
+	XCrossingEventFc.x_root = (*env)->GetFieldID(env, XCrossingEventFc.clazz, "x_root", "I");
+	XCrossingEventFc.y_root = (*env)->GetFieldID(env, XCrossingEventFc.clazz, "y_root", "I");
+	XCrossingEventFc.mode = (*env)->GetFieldID(env, XCrossingEventFc.clazz, "mode", "I");
+	XCrossingEventFc.detail = (*env)->GetFieldID(env, XCrossingEventFc.clazz, "detail", "I");
+	XCrossingEventFc.same_screen = (*env)->GetFieldID(env, XCrossingEventFc.clazz, "same_screen", "Z");
+	XCrossingEventFc.focus = (*env)->GetFieldID(env, XCrossingEventFc.clazz, "focus", "Z");
+	XCrossingEventFc.state = (*env)->GetFieldID(env, XCrossingEventFc.clazz, "state", "I");
+	XCrossingEventFc.cached = 1;
+}
+
+XCrossingEvent *getXCrossingEventFields(JNIEnv *env, jobject lpObject, XCrossingEvent *lpStruct)
+{
+	if (!XCrossingEventFc.cached) cacheXCrossingEventFields(env, lpObject);
+	getXAnyEventFields(env, lpObject, (XAnyEvent *)lpStruct);
+	lpStruct->root = (Window)(*env)->GetIntField(env, lpObject, XCrossingEventFc.root);
+	lpStruct->subwindow = (Window)(*env)->GetIntField(env, lpObject, XCrossingEventFc.subwindow);
+	lpStruct->time = (Time)(*env)->GetIntField(env, lpObject, XCrossingEventFc.time);
+	lpStruct->x = (*env)->GetIntField(env, lpObject, XCrossingEventFc.x);
+	lpStruct->y = (*env)->GetIntField(env, lpObject, XCrossingEventFc.y);
+	lpStruct->x_root = (*env)->GetIntField(env, lpObject, XCrossingEventFc.x_root);
+	lpStruct->y_root = (*env)->GetIntField(env, lpObject, XCrossingEventFc.y_root);
+	lpStruct->mode = (*env)->GetIntField(env, lpObject, XCrossingEventFc.mode);
+	lpStruct->detail = (*env)->GetIntField(env, lpObject, XCrossingEventFc.detail);
+	lpStruct->same_screen = (Bool)(*env)->GetBooleanField(env, lpObject, XCrossingEventFc.same_screen);
+	lpStruct->focus = (Bool)(*env)->GetBooleanField(env, lpObject, XCrossingEventFc.focus);
+	lpStruct->state = (unsigned int)(*env)->GetIntField(env, lpObject, XCrossingEventFc.state);
+	return lpStruct;
+}
+
+void setXCrossingEventFields(JNIEnv *env, jobject lpObject, XCrossingEvent *lpStruct)
+{
+	if (!XCrossingEventFc.cached) cacheXCrossingEventFields(env, lpObject);
+	setXAnyEventFields(env, lpObject, (XAnyEvent *)lpStruct);
+	(*env)->SetIntField(env, lpObject, XCrossingEventFc.root, (jint)lpStruct->root);
+	(*env)->SetIntField(env, lpObject, XCrossingEventFc.subwindow, (jint)lpStruct->subwindow);
+	(*env)->SetIntField(env, lpObject, XCrossingEventFc.time, (jint)lpStruct->time);
+	(*env)->SetIntField(env, lpObject, XCrossingEventFc.x, (jint)lpStruct->x);
+	(*env)->SetIntField(env, lpObject, XCrossingEventFc.y, (jint)lpStruct->y);
+	(*env)->SetIntField(env, lpObject, XCrossingEventFc.x_root, (jint)lpStruct->x_root);
+	(*env)->SetIntField(env, lpObject, XCrossingEventFc.y_root, (jint)lpStruct->y_root);
+	(*env)->SetIntField(env, lpObject, XCrossingEventFc.mode, (jint)lpStruct->mode);
+	(*env)->SetIntField(env, lpObject, XCrossingEventFc.detail, (jint)lpStruct->detail);
+	(*env)->SetBooleanField(env, lpObject, XCrossingEventFc.same_screen, (jboolean)lpStruct->same_screen);
+	(*env)->SetBooleanField(env, lpObject, XCrossingEventFc.focus, (jboolean)lpStruct->focus);
+	(*env)->SetIntField(env, lpObject, XCrossingEventFc.state, (jint)lpStruct->state);
+}
+#endif
+
+#ifndef NO_XEvent
+typedef struct XEvent_FID_CACHE {
+	int cached;
+	jclass clazz;
+	jfieldID type;
+} XEvent_FID_CACHE;
+
+XEvent_FID_CACHE XEventFc;
+
+void cacheXEventFields(JNIEnv *env, jobject lpObject)
+{
+	if (XEventFc.cached) return;
+	XEventFc.clazz = (*env)->GetObjectClass(env, lpObject);
+	XEventFc.type = (*env)->GetFieldID(env, XEventFc.clazz, "type", "I");
+	XEventFc.cached = 1;
+}
+
+XEvent *getXEventFields(JNIEnv *env, jobject lpObject, XEvent *lpStruct)
+{
+	if (!XEventFc.cached) cacheXEventFields(env, lpObject);
+	lpStruct->type = (*env)->GetIntField(env, lpObject, XEventFc.type);
+	return lpStruct;
+}
+
+void setXEventFields(JNIEnv *env, jobject lpObject, XEvent *lpStruct)
+{
+	if (!XEventFc.cached) cacheXEventFields(env, lpObject);
+	(*env)->SetIntField(env, lpObject, XEventFc.type, (jint)lpStruct->type);
+}
+#endif
+
+#ifndef NO_XExposeEvent
+typedef struct XExposeEvent_FID_CACHE {
+	int cached;
+	jclass clazz;
+	jfieldID x, y, width, height, count;
+} XExposeEvent_FID_CACHE;
+
+XExposeEvent_FID_CACHE XExposeEventFc;
+
+void cacheXExposeEventFields(JNIEnv *env, jobject lpObject)
+{
+	if (XExposeEventFc.cached) return;
+	cacheXAnyEventFields(env, lpObject);
+	XExposeEventFc.clazz = (*env)->GetObjectClass(env, lpObject);
+	XExposeEventFc.x = (*env)->GetFieldID(env, XExposeEventFc.clazz, "x", "I");
+	XExposeEventFc.y = (*env)->GetFieldID(env, XExposeEventFc.clazz, "y", "I");
+	XExposeEventFc.width = (*env)->GetFieldID(env, XExposeEventFc.clazz, "width", "I");
+	XExposeEventFc.height = (*env)->GetFieldID(env, XExposeEventFc.clazz, "height", "I");
+	XExposeEventFc.count = (*env)->GetFieldID(env, XExposeEventFc.clazz, "count", "I");
+	XExposeEventFc.cached = 1;
+}
+
+XExposeEvent *getXExposeEventFields(JNIEnv *env, jobject lpObject, XExposeEvent *lpStruct)
+{
+	if (!XExposeEventFc.cached) cacheXExposeEventFields(env, lpObject);
+	getXAnyEventFields(env, lpObject, (XAnyEvent *)lpStruct);
+	lpStruct->x = (*env)->GetIntField(env, lpObject, XExposeEventFc.x);
+	lpStruct->y = (*env)->GetIntField(env, lpObject, XExposeEventFc.y);
+	lpStruct->width = (*env)->GetIntField(env, lpObject, XExposeEventFc.width);
+	lpStruct->height = (*env)->GetIntField(env, lpObject, XExposeEventFc.height);
+	lpStruct->count = (*env)->GetIntField(env, lpObject, XExposeEventFc.count);
+	return lpStruct;
+}
+
+void setXExposeEventFields(JNIEnv *env, jobject lpObject, XExposeEvent *lpStruct)
+{
+	if (!XExposeEventFc.cached) cacheXExposeEventFields(env, lpObject);
+	setXAnyEventFields(env, lpObject, (XAnyEvent *)lpStruct);
+	(*env)->SetIntField(env, lpObject, XExposeEventFc.x, (jint)lpStruct->x);
+	(*env)->SetIntField(env, lpObject, XExposeEventFc.y, (jint)lpStruct->y);
+	(*env)->SetIntField(env, lpObject, XExposeEventFc.width, (jint)lpStruct->width);
+	(*env)->SetIntField(env, lpObject, XExposeEventFc.height, (jint)lpStruct->height);
+	(*env)->SetIntField(env, lpObject, XExposeEventFc.count, (jint)lpStruct->count);
+}
+#endif
+
+#ifndef NO_XFocusChangeEvent
+typedef struct XFocusChangeEvent_FID_CACHE {
+	int cached;
+	jclass clazz;
+	jfieldID mode, detail;
+} XFocusChangeEvent_FID_CACHE;
+
+XFocusChangeEvent_FID_CACHE XFocusChangeEventFc;
+
+void cacheXFocusChangeEventFields(JNIEnv *env, jobject lpObject)
+{
+	if (XFocusChangeEventFc.cached) return;
+	cacheXAnyEventFields(env, lpObject);
+	XFocusChangeEventFc.clazz = (*env)->GetObjectClass(env, lpObject);
+	XFocusChangeEventFc.mode = (*env)->GetFieldID(env, XFocusChangeEventFc.clazz, "mode", "I");
+	XFocusChangeEventFc.detail = (*env)->GetFieldID(env, XFocusChangeEventFc.clazz, "detail", "I");
+	XFocusChangeEventFc.cached = 1;
+}
+
+XFocusChangeEvent *getXFocusChangeEventFields(JNIEnv *env, jobject lpObject, XFocusChangeEvent *lpStruct)
+{
+	if (!XFocusChangeEventFc.cached) cacheXFocusChangeEventFields(env, lpObject);
+	getXAnyEventFields(env, lpObject, (XAnyEvent *)lpStruct);
+	lpStruct->mode = (*env)->GetIntField(env, lpObject, XFocusChangeEventFc.mode);
+	lpStruct->detail = (*env)->GetIntField(env, lpObject, XFocusChangeEventFc.detail);
+	return lpStruct;
+}
+
+void setXFocusChangeEventFields(JNIEnv *env, jobject lpObject, XFocusChangeEvent *lpStruct)
+{
+	if (!XFocusChangeEventFc.cached) cacheXFocusChangeEventFields(env, lpObject);
+	setXAnyEventFields(env, lpObject, (XAnyEvent *)lpStruct);
+	(*env)->SetIntField(env, lpObject, XFocusChangeEventFc.mode, (jint)lpStruct->mode);
+	(*env)->SetIntField(env, lpObject, XFocusChangeEventFc.detail, (jint)lpStruct->detail);
+}
+#endif
+
+#ifndef NO_XRenderPictureAttributes
+typedef struct XRenderPictureAttributes_FID_CACHE {
+	int cached;
+	jclass clazz;
+	jfieldID repeat, alpha_map, alpha_x_origin, alpha_y_origin, clip_x_origin, clip_y_origin, clip_mask, graphics_exposures, subwindow_mode, poly_edge, poly_mode, dither, component_alpha;
+} XRenderPictureAttributes_FID_CACHE;
+
+XRenderPictureAttributes_FID_CACHE XRenderPictureAttributesFc;
+
+void cacheXRenderPictureAttributesFields(JNIEnv *env, jobject lpObject)
+{
+	if (XRenderPictureAttributesFc.cached) return;
+	XRenderPictureAttributesFc.clazz = (*env)->GetObjectClass(env, lpObject);
+	XRenderPictureAttributesFc.repeat = (*env)->GetFieldID(env, XRenderPictureAttributesFc.clazz, "repeat", "Z");
+	XRenderPictureAttributesFc.alpha_map = (*env)->GetFieldID(env, XRenderPictureAttributesFc.clazz, "alpha_map", "I");
+	XRenderPictureAttributesFc.alpha_x_origin = (*env)->GetFieldID(env, XRenderPictureAttributesFc.clazz, "alpha_x_origin", "I");
+	XRenderPictureAttributesFc.alpha_y_origin = (*env)->GetFieldID(env, XRenderPictureAttributesFc.clazz, "alpha_y_origin", "I");
+	XRenderPictureAttributesFc.clip_x_origin = (*env)->GetFieldID(env, XRenderPictureAttributesFc.clazz, "clip_x_origin", "I");
+	XRenderPictureAttributesFc.clip_y_origin = (*env)->GetFieldID(env, XRenderPictureAttributesFc.clazz, "clip_y_origin", "I");
+	XRenderPictureAttributesFc.clip_mask = (*env)->GetFieldID(env, XRenderPictureAttributesFc.clazz, "clip_mask", "I");
+	XRenderPictureAttributesFc.graphics_exposures = (*env)->GetFieldID(env, XRenderPictureAttributesFc.clazz, "graphics_exposures", "Z");
+	XRenderPictureAttributesFc.subwindow_mode = (*env)->GetFieldID(env, XRenderPictureAttributesFc.clazz, "subwindow_mode", "I");
+	XRenderPictureAttributesFc.poly_edge = (*env)->GetFieldID(env, XRenderPictureAttributesFc.clazz, "poly_edge", "I");
+	XRenderPictureAttributesFc.poly_mode = (*env)->GetFieldID(env, XRenderPictureAttributesFc.clazz, "poly_mode", "I");
+	XRenderPictureAttributesFc.dither = (*env)->GetFieldID(env, XRenderPictureAttributesFc.clazz, "dither", "I");
+	XRenderPictureAttributesFc.component_alpha = (*env)->GetFieldID(env, XRenderPictureAttributesFc.clazz, "component_alpha", "Z");
+	XRenderPictureAttributesFc.cached = 1;
+}
+
+XRenderPictureAttributes *getXRenderPictureAttributesFields(JNIEnv *env, jobject lpObject, XRenderPictureAttributes *lpStruct)
+{
+	if (!XRenderPictureAttributesFc.cached) cacheXRenderPictureAttributesFields(env, lpObject);
+	lpStruct->repeat = (*env)->GetBooleanField(env, lpObject, XRenderPictureAttributesFc.repeat);
+	lpStruct->alpha_map = (*env)->GetIntField(env, lpObject, XRenderPictureAttributesFc.alpha_map);
+	lpStruct->alpha_x_origin = (*env)->GetIntField(env, lpObject, XRenderPictureAttributesFc.alpha_x_origin);
+	lpStruct->alpha_y_origin = (*env)->GetIntField(env, lpObject, XRenderPictureAttributesFc.alpha_y_origin);
+	lpStruct->clip_x_origin = (*env)->GetIntField(env, lpObject, XRenderPictureAttributesFc.clip_x_origin);
+	lpStruct->clip_y_origin = (*env)->GetIntField(env, lpObject, XRenderPictureAttributesFc.clip_y_origin);
+	lpStruct->clip_mask = (*env)->GetIntField(env, lpObject, XRenderPictureAttributesFc.clip_mask);
+	lpStruct->graphics_exposures = (*env)->GetBooleanField(env, lpObject, XRenderPictureAttributesFc.graphics_exposures);
+	lpStruct->subwindow_mode = (*env)->GetIntField(env, lpObject, XRenderPictureAttributesFc.subwindow_mode);
+	lpStruct->poly_edge = (*env)->GetIntField(env, lpObject, XRenderPictureAttributesFc.poly_edge);
+	lpStruct->poly_mode = (*env)->GetIntField(env, lpObject, XRenderPictureAttributesFc.poly_mode);
+	lpStruct->dither = (*env)->GetIntField(env, lpObject, XRenderPictureAttributesFc.dither);
+	lpStruct->component_alpha = (*env)->GetBooleanField(env, lpObject, XRenderPictureAttributesFc.component_alpha);
+	return lpStruct;
+}
+
+void setXRenderPictureAttributesFields(JNIEnv *env, jobject lpObject, XRenderPictureAttributes *lpStruct)
+{
+	if (!XRenderPictureAttributesFc.cached) cacheXRenderPictureAttributesFields(env, lpObject);
+	(*env)->SetBooleanField(env, lpObject, XRenderPictureAttributesFc.repeat, (jboolean)lpStruct->repeat);
+	(*env)->SetIntField(env, lpObject, XRenderPictureAttributesFc.alpha_map, (jint)lpStruct->alpha_map);
+	(*env)->SetIntField(env, lpObject, XRenderPictureAttributesFc.alpha_x_origin, (jint)lpStruct->alpha_x_origin);
+	(*env)->SetIntField(env, lpObject, XRenderPictureAttributesFc.alpha_y_origin, (jint)lpStruct->alpha_y_origin);
+	(*env)->SetIntField(env, lpObject, XRenderPictureAttributesFc.clip_x_origin, (jint)lpStruct->clip_x_origin);
+	(*env)->SetIntField(env, lpObject, XRenderPictureAttributesFc.clip_y_origin, (jint)lpStruct->clip_y_origin);
+	(*env)->SetIntField(env, lpObject, XRenderPictureAttributesFc.clip_mask, (jint)lpStruct->clip_mask);
+	(*env)->SetBooleanField(env, lpObject, XRenderPictureAttributesFc.graphics_exposures, (jboolean)lpStruct->graphics_exposures);
+	(*env)->SetIntField(env, lpObject, XRenderPictureAttributesFc.subwindow_mode, (jint)lpStruct->subwindow_mode);
+	(*env)->SetIntField(env, lpObject, XRenderPictureAttributesFc.poly_edge, (jint)lpStruct->poly_edge);
+	(*env)->SetIntField(env, lpObject, XRenderPictureAttributesFc.poly_mode, (jint)lpStruct->poly_mode);
+	(*env)->SetIntField(env, lpObject, XRenderPictureAttributesFc.dither, (jint)lpStruct->dither);
+	(*env)->SetBooleanField(env, lpObject, XRenderPictureAttributesFc.component_alpha, (jboolean)lpStruct->component_alpha);
+}
+#endif
+
+#ifndef NO_XVisibilityEvent
+typedef struct XVisibilityEvent_FID_CACHE {
+	int cached;
+	jclass clazz;
+	jfieldID state;
+} XVisibilityEvent_FID_CACHE;
+
+XVisibilityEvent_FID_CACHE XVisibilityEventFc;
+
+void cacheXVisibilityEventFields(JNIEnv *env, jobject lpObject)
+{
+	if (XVisibilityEventFc.cached) return;
+	cacheXAnyEventFields(env, lpObject);
+	XVisibilityEventFc.clazz = (*env)->GetObjectClass(env, lpObject);
+	XVisibilityEventFc.state = (*env)->GetFieldID(env, XVisibilityEventFc.clazz, "state", "I");
+	XVisibilityEventFc.cached = 1;
+}
+
+XVisibilityEvent *getXVisibilityEventFields(JNIEnv *env, jobject lpObject, XVisibilityEvent *lpStruct)
+{
+	if (!XVisibilityEventFc.cached) cacheXVisibilityEventFields(env, lpObject);
+	getXAnyEventFields(env, lpObject, (XAnyEvent *)lpStruct);
+	lpStruct->state = (*env)->GetIntField(env, lpObject, XVisibilityEventFc.state);
+	return lpStruct;
+}
+
+void setXVisibilityEventFields(JNIEnv *env, jobject lpObject, XVisibilityEvent *lpStruct)
+{
+	if (!XVisibilityEventFc.cached) cacheXVisibilityEventFields(env, lpObject);
+	setXAnyEventFields(env, lpObject, (XAnyEvent *)lpStruct);
+	(*env)->SetIntField(env, lpObject, XVisibilityEventFc.state, (jint)lpStruct->state);
+}
+#endif
+
+#ifndef NO_XWindowChanges
+typedef struct XWindowChanges_FID_CACHE {
+	int cached;
+	jclass clazz;
+	jfieldID x, y, width, height, border_width, sibling, stack_mode;
+} XWindowChanges_FID_CACHE;
+
+XWindowChanges_FID_CACHE XWindowChangesFc;
+
+void cacheXWindowChangesFields(JNIEnv *env, jobject lpObject)
+{
+	if (XWindowChangesFc.cached) return;
+	XWindowChangesFc.clazz = (*env)->GetObjectClass(env, lpObject);
+	XWindowChangesFc.x = (*env)->GetFieldID(env, XWindowChangesFc.clazz, "x", "I");
+	XWindowChangesFc.y = (*env)->GetFieldID(env, XWindowChangesFc.clazz, "y", "I");
+	XWindowChangesFc.width = (*env)->GetFieldID(env, XWindowChangesFc.clazz, "width", "I");
+	XWindowChangesFc.height = (*env)->GetFieldID(env, XWindowChangesFc.clazz, "height", "I");
+	XWindowChangesFc.border_width = (*env)->GetFieldID(env, XWindowChangesFc.clazz, "border_width", "I");
+	XWindowChangesFc.sibling = (*env)->GetFieldID(env, XWindowChangesFc.clazz, "sibling", "I");
+	XWindowChangesFc.stack_mode = (*env)->GetFieldID(env, XWindowChangesFc.clazz, "stack_mode", "I");
+	XWindowChangesFc.cached = 1;
+}
+
+XWindowChanges *getXWindowChangesFields(JNIEnv *env, jobject lpObject, XWindowChanges *lpStruct)
+{
+	if (!XWindowChangesFc.cached) cacheXWindowChangesFields(env, lpObject);
+	lpStruct->x = (*env)->GetIntField(env, lpObject, XWindowChangesFc.x);
+	lpStruct->y = (*env)->GetIntField(env, lpObject, XWindowChangesFc.y);
+	lpStruct->width = (*env)->GetIntField(env, lpObject, XWindowChangesFc.width);
+	lpStruct->height = (*env)->GetIntField(env, lpObject, XWindowChangesFc.height);
+	lpStruct->border_width = (*env)->GetIntField(env, lpObject, XWindowChangesFc.border_width);
+	lpStruct->sibling = (*env)->GetIntField(env, lpObject, XWindowChangesFc.sibling);
+	lpStruct->stack_mode = (*env)->GetIntField(env, lpObject, XWindowChangesFc.stack_mode);
+	return lpStruct;
+}
+
+void setXWindowChangesFields(JNIEnv *env, jobject lpObject, XWindowChanges *lpStruct)
+{
+	if (!XWindowChangesFc.cached) cacheXWindowChangesFields(env, lpObject);
+	(*env)->SetIntField(env, lpObject, XWindowChangesFc.x, (jint)lpStruct->x);
+	(*env)->SetIntField(env, lpObject, XWindowChangesFc.y, (jint)lpStruct->y);
+	(*env)->SetIntField(env, lpObject, XWindowChangesFc.width, (jint)lpStruct->width);
+	(*env)->SetIntField(env, lpObject, XWindowChangesFc.height, (jint)lpStruct->height);
+	(*env)->SetIntField(env, lpObject, XWindowChangesFc.border_width, (jint)lpStruct->border_width);
+	(*env)->SetIntField(env, lpObject, XWindowChangesFc.sibling, (jint)lpStruct->sibling);
+	(*env)->SetIntField(env, lpObject, XWindowChangesFc.stack_mode, (jint)lpStruct->stack_mode);
+}
+#endif
+

Added: branches/upstream/swt-gtk/current/os_structs.h
===================================================================
--- branches/upstream/swt-gtk/current/os_structs.h	                        (rev 0)
+++ branches/upstream/swt-gtk/current/os_structs.h	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,665 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others. All rights reserved.
+ * The contents of this file are made available under the terms
+ * of the GNU Lesser General Public License (LGPL) Version 2.1 that
+ * accompanies this distribution (lgpl-v21.txt).  The LGPL is also
+ * available at http://www.gnu.org/licenses/lgpl.html.  If the version
+ * of the LGPL at http://www.gnu.org is different to the version of
+ * the LGPL accompanying this distribution and there is any conflict
+ * between the two license versions, the terms of the LGPL accompanying
+ * this distribution shall govern.
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+#include "os.h"
+
+#ifndef NO_GInterfaceInfo
+void cacheGInterfaceInfoFields(JNIEnv *env, jobject lpObject);
+GInterfaceInfo *getGInterfaceInfoFields(JNIEnv *env, jobject lpObject, GInterfaceInfo *lpStruct);
+void setGInterfaceInfoFields(JNIEnv *env, jobject lpObject, GInterfaceInfo *lpStruct);
+#define GInterfaceInfo_sizeof() sizeof(GInterfaceInfo)
+#else
+#define cacheGInterfaceInfoFields(a,b)
+#define getGInterfaceInfoFields(a,b,c) NULL
+#define setGInterfaceInfoFields(a,b,c)
+#define GInterfaceInfo_sizeof() 0
+#endif
+
+#ifndef NO_GObjectClass
+void cacheGObjectClassFields(JNIEnv *env, jobject lpObject);
+GObjectClass *getGObjectClassFields(JNIEnv *env, jobject lpObject, GObjectClass *lpStruct);
+void setGObjectClassFields(JNIEnv *env, jobject lpObject, GObjectClass *lpStruct);
+#define GObjectClass_sizeof() sizeof(GObjectClass)
+#else
+#define cacheGObjectClassFields(a,b)
+#define getGObjectClassFields(a,b,c) NULL
+#define setGObjectClassFields(a,b,c)
+#define GObjectClass_sizeof() 0
+#endif
+
+#ifndef NO_GTypeInfo
+void cacheGTypeInfoFields(JNIEnv *env, jobject lpObject);
+GTypeInfo *getGTypeInfoFields(JNIEnv *env, jobject lpObject, GTypeInfo *lpStruct);
+void setGTypeInfoFields(JNIEnv *env, jobject lpObject, GTypeInfo *lpStruct);
+#define GTypeInfo_sizeof() sizeof(GTypeInfo)
+#else
+#define cacheGTypeInfoFields(a,b)
+#define getGTypeInfoFields(a,b,c) NULL
+#define setGTypeInfoFields(a,b,c)
+#define GTypeInfo_sizeof() 0
+#endif
+
+#ifndef NO_GTypeQuery
+void cacheGTypeQueryFields(JNIEnv *env, jobject lpObject);
+GTypeQuery *getGTypeQueryFields(JNIEnv *env, jobject lpObject, GTypeQuery *lpStruct);
+void setGTypeQueryFields(JNIEnv *env, jobject lpObject, GTypeQuery *lpStruct);
+#define GTypeQuery_sizeof() sizeof(GTypeQuery)
+#else
+#define cacheGTypeQueryFields(a,b)
+#define getGTypeQueryFields(a,b,c) NULL
+#define setGTypeQueryFields(a,b,c)
+#define GTypeQuery_sizeof() 0
+#endif
+
+#ifndef NO_GdkColor
+void cacheGdkColorFields(JNIEnv *env, jobject lpObject);
+GdkColor *getGdkColorFields(JNIEnv *env, jobject lpObject, GdkColor *lpStruct);
+void setGdkColorFields(JNIEnv *env, jobject lpObject, GdkColor *lpStruct);
+#define GdkColor_sizeof() sizeof(GdkColor)
+#else
+#define cacheGdkColorFields(a,b)
+#define getGdkColorFields(a,b,c) NULL
+#define setGdkColorFields(a,b,c)
+#define GdkColor_sizeof() 0
+#endif
+
+#ifndef NO_GdkDragContext
+void cacheGdkDragContextFields(JNIEnv *env, jobject lpObject);
+GdkDragContext *getGdkDragContextFields(JNIEnv *env, jobject lpObject, GdkDragContext *lpStruct);
+void setGdkDragContextFields(JNIEnv *env, jobject lpObject, GdkDragContext *lpStruct);
+#define GdkDragContext_sizeof() sizeof(GdkDragContext)
+#else
+#define cacheGdkDragContextFields(a,b)
+#define getGdkDragContextFields(a,b,c) NULL
+#define setGdkDragContextFields(a,b,c)
+#define GdkDragContext_sizeof() 0
+#endif
+
+#ifndef NO_GdkEvent
+void cacheGdkEventFields(JNIEnv *env, jobject lpObject);
+GdkEvent *getGdkEventFields(JNIEnv *env, jobject lpObject, GdkEvent *lpStruct);
+void setGdkEventFields(JNIEnv *env, jobject lpObject, GdkEvent *lpStruct);
+#define GdkEvent_sizeof() sizeof(GdkEvent)
+#else
+#define cacheGdkEventFields(a,b)
+#define getGdkEventFields(a,b,c) NULL
+#define setGdkEventFields(a,b,c)
+#define GdkEvent_sizeof() 0
+#endif
+
+#ifndef NO_GdkEventAny
+void cacheGdkEventAnyFields(JNIEnv *env, jobject lpObject);
+GdkEventAny *getGdkEventAnyFields(JNIEnv *env, jobject lpObject, GdkEventAny *lpStruct);
+void setGdkEventAnyFields(JNIEnv *env, jobject lpObject, GdkEventAny *lpStruct);
+#define GdkEventAny_sizeof() sizeof(GdkEventAny)
+#else
+#define cacheGdkEventAnyFields(a,b)
+#define getGdkEventAnyFields(a,b,c) NULL
+#define setGdkEventAnyFields(a,b,c)
+#define GdkEventAny_sizeof() 0
+#endif
+
+#ifndef NO_GdkEventButton
+void cacheGdkEventButtonFields(JNIEnv *env, jobject lpObject);
+GdkEventButton *getGdkEventButtonFields(JNIEnv *env, jobject lpObject, GdkEventButton *lpStruct);
+void setGdkEventButtonFields(JNIEnv *env, jobject lpObject, GdkEventButton *lpStruct);
+#define GdkEventButton_sizeof() sizeof(GdkEventButton)
+#else
+#define cacheGdkEventButtonFields(a,b)
+#define getGdkEventButtonFields(a,b,c) NULL
+#define setGdkEventButtonFields(a,b,c)
+#define GdkEventButton_sizeof() 0
+#endif
+
+#ifndef NO_GdkEventCrossing
+void cacheGdkEventCrossingFields(JNIEnv *env, jobject lpObject);
+GdkEventCrossing *getGdkEventCrossingFields(JNIEnv *env, jobject lpObject, GdkEventCrossing *lpStruct);
+void setGdkEventCrossingFields(JNIEnv *env, jobject lpObject, GdkEventCrossing *lpStruct);
+#define GdkEventCrossing_sizeof() sizeof(GdkEventCrossing)
+#else
+#define cacheGdkEventCrossingFields(a,b)
+#define getGdkEventCrossingFields(a,b,c) NULL
+#define setGdkEventCrossingFields(a,b,c)
+#define GdkEventCrossing_sizeof() 0
+#endif
+
+#ifndef NO_GdkEventExpose
+void cacheGdkEventExposeFields(JNIEnv *env, jobject lpObject);
+GdkEventExpose *getGdkEventExposeFields(JNIEnv *env, jobject lpObject, GdkEventExpose *lpStruct);
+void setGdkEventExposeFields(JNIEnv *env, jobject lpObject, GdkEventExpose *lpStruct);
+#define GdkEventExpose_sizeof() sizeof(GdkEventExpose)
+#else
+#define cacheGdkEventExposeFields(a,b)
+#define getGdkEventExposeFields(a,b,c) NULL
+#define setGdkEventExposeFields(a,b,c)
+#define GdkEventExpose_sizeof() 0
+#endif
+
+#ifndef NO_GdkEventFocus
+void cacheGdkEventFocusFields(JNIEnv *env, jobject lpObject);
+GdkEventFocus *getGdkEventFocusFields(JNIEnv *env, jobject lpObject, GdkEventFocus *lpStruct);
+void setGdkEventFocusFields(JNIEnv *env, jobject lpObject, GdkEventFocus *lpStruct);
+#define GdkEventFocus_sizeof() sizeof(GdkEventFocus)
+#else
+#define cacheGdkEventFocusFields(a,b)
+#define getGdkEventFocusFields(a,b,c) NULL
+#define setGdkEventFocusFields(a,b,c)
+#define GdkEventFocus_sizeof() 0
+#endif
+
+#ifndef NO_GdkEventKey
+void cacheGdkEventKeyFields(JNIEnv *env, jobject lpObject);
+GdkEventKey *getGdkEventKeyFields(JNIEnv *env, jobject lpObject, GdkEventKey *lpStruct);
+void setGdkEventKeyFields(JNIEnv *env, jobject lpObject, GdkEventKey *lpStruct);
+#define GdkEventKey_sizeof() sizeof(GdkEventKey)
+#else
+#define cacheGdkEventKeyFields(a,b)
+#define getGdkEventKeyFields(a,b,c) NULL
+#define setGdkEventKeyFields(a,b,c)
+#define GdkEventKey_sizeof() 0
+#endif
+
+#ifndef NO_GdkEventMotion
+void cacheGdkEventMotionFields(JNIEnv *env, jobject lpObject);
+GdkEventMotion *getGdkEventMotionFields(JNIEnv *env, jobject lpObject, GdkEventMotion *lpStruct);
+void setGdkEventMotionFields(JNIEnv *env, jobject lpObject, GdkEventMotion *lpStruct);
+#define GdkEventMotion_sizeof() sizeof(GdkEventMotion)
+#else
+#define cacheGdkEventMotionFields(a,b)
+#define getGdkEventMotionFields(a,b,c) NULL
+#define setGdkEventMotionFields(a,b,c)
+#define GdkEventMotion_sizeof() 0
+#endif
+
+#ifndef NO_GdkEventScroll
+void cacheGdkEventScrollFields(JNIEnv *env, jobject lpObject);
+GdkEventScroll *getGdkEventScrollFields(JNIEnv *env, jobject lpObject, GdkEventScroll *lpStruct);
+void setGdkEventScrollFields(JNIEnv *env, jobject lpObject, GdkEventScroll *lpStruct);
+#define GdkEventScroll_sizeof() sizeof(GdkEventScroll)
+#else
+#define cacheGdkEventScrollFields(a,b)
+#define getGdkEventScrollFields(a,b,c) NULL
+#define setGdkEventScrollFields(a,b,c)
+#define GdkEventScroll_sizeof() 0
+#endif
+
+#ifndef NO_GdkEventVisibility
+void cacheGdkEventVisibilityFields(JNIEnv *env, jobject lpObject);
+GdkEventVisibility *getGdkEventVisibilityFields(JNIEnv *env, jobject lpObject, GdkEventVisibility *lpStruct);
+void setGdkEventVisibilityFields(JNIEnv *env, jobject lpObject, GdkEventVisibility *lpStruct);
+#define GdkEventVisibility_sizeof() sizeof(GdkEventVisibility)
+#else
+#define cacheGdkEventVisibilityFields(a,b)
+#define getGdkEventVisibilityFields(a,b,c) NULL
+#define setGdkEventVisibilityFields(a,b,c)
+#define GdkEventVisibility_sizeof() 0
+#endif
+
+#ifndef NO_GdkEventWindowState
+void cacheGdkEventWindowStateFields(JNIEnv *env, jobject lpObject);
+GdkEventWindowState *getGdkEventWindowStateFields(JNIEnv *env, jobject lpObject, GdkEventWindowState *lpStruct);
+void setGdkEventWindowStateFields(JNIEnv *env, jobject lpObject, GdkEventWindowState *lpStruct);
+#define GdkEventWindowState_sizeof() sizeof(GdkEventWindowState)
+#else
+#define cacheGdkEventWindowStateFields(a,b)
+#define getGdkEventWindowStateFields(a,b,c) NULL
+#define setGdkEventWindowStateFields(a,b,c)
+#define GdkEventWindowState_sizeof() 0
+#endif
+
+#ifndef NO_GdkGCValues
+void cacheGdkGCValuesFields(JNIEnv *env, jobject lpObject);
+GdkGCValues *getGdkGCValuesFields(JNIEnv *env, jobject lpObject, GdkGCValues *lpStruct);
+void setGdkGCValuesFields(JNIEnv *env, jobject lpObject, GdkGCValues *lpStruct);
+#define GdkGCValues_sizeof() sizeof(GdkGCValues)
+#else
+#define cacheGdkGCValuesFields(a,b)
+#define getGdkGCValuesFields(a,b,c) NULL
+#define setGdkGCValuesFields(a,b,c)
+#define GdkGCValues_sizeof() 0
+#endif
+
+#ifndef NO_GdkGeometry
+void cacheGdkGeometryFields(JNIEnv *env, jobject lpObject);
+GdkGeometry *getGdkGeometryFields(JNIEnv *env, jobject lpObject, GdkGeometry *lpStruct);
+void setGdkGeometryFields(JNIEnv *env, jobject lpObject, GdkGeometry *lpStruct);
+#define GdkGeometry_sizeof() sizeof(GdkGeometry)
+#else
+#define cacheGdkGeometryFields(a,b)
+#define getGdkGeometryFields(a,b,c) NULL
+#define setGdkGeometryFields(a,b,c)
+#define GdkGeometry_sizeof() 0
+#endif
+
+#ifndef NO_GdkImage
+void cacheGdkImageFields(JNIEnv *env, jobject lpObject);
+GdkImage *getGdkImageFields(JNIEnv *env, jobject lpObject, GdkImage *lpStruct);
+void setGdkImageFields(JNIEnv *env, jobject lpObject, GdkImage *lpStruct);
+#define GdkImage_sizeof() sizeof(GdkImage)
+#else
+#define cacheGdkImageFields(a,b)
+#define getGdkImageFields(a,b,c) NULL
+#define setGdkImageFields(a,b,c)
+#define GdkImage_sizeof() 0
+#endif
+
+#ifndef NO_GdkRectangle
+void cacheGdkRectangleFields(JNIEnv *env, jobject lpObject);
+GdkRectangle *getGdkRectangleFields(JNIEnv *env, jobject lpObject, GdkRectangle *lpStruct);
+void setGdkRectangleFields(JNIEnv *env, jobject lpObject, GdkRectangle *lpStruct);
+#define GdkRectangle_sizeof() sizeof(GdkRectangle)
+#else
+#define cacheGdkRectangleFields(a,b)
+#define getGdkRectangleFields(a,b,c) NULL
+#define setGdkRectangleFields(a,b,c)
+#define GdkRectangle_sizeof() 0
+#endif
+
+#ifndef NO_GdkVisual
+void cacheGdkVisualFields(JNIEnv *env, jobject lpObject);
+GdkVisual *getGdkVisualFields(JNIEnv *env, jobject lpObject, GdkVisual *lpStruct);
+void setGdkVisualFields(JNIEnv *env, jobject lpObject, GdkVisual *lpStruct);
+#define GdkVisual_sizeof() sizeof(GdkVisual)
+#else
+#define cacheGdkVisualFields(a,b)
+#define getGdkVisualFields(a,b,c) NULL
+#define setGdkVisualFields(a,b,c)
+#define GdkVisual_sizeof() 0
+#endif
+
+#ifndef NO_GdkWindowAttr
+void cacheGdkWindowAttrFields(JNIEnv *env, jobject lpObject);
+GdkWindowAttr *getGdkWindowAttrFields(JNIEnv *env, jobject lpObject, GdkWindowAttr *lpStruct);
+void setGdkWindowAttrFields(JNIEnv *env, jobject lpObject, GdkWindowAttr *lpStruct);
+#define GdkWindowAttr_sizeof() sizeof(GdkWindowAttr)
+#else
+#define cacheGdkWindowAttrFields(a,b)
+#define getGdkWindowAttrFields(a,b,c) NULL
+#define setGdkWindowAttrFields(a,b,c)
+#define GdkWindowAttr_sizeof() 0
+#endif
+
+#ifndef NO_GtkAdjustment
+void cacheGtkAdjustmentFields(JNIEnv *env, jobject lpObject);
+GtkAdjustment *getGtkAdjustmentFields(JNIEnv *env, jobject lpObject, GtkAdjustment *lpStruct);
+void setGtkAdjustmentFields(JNIEnv *env, jobject lpObject, GtkAdjustment *lpStruct);
+#define GtkAdjustment_sizeof() sizeof(GtkAdjustment)
+#else
+#define cacheGtkAdjustmentFields(a,b)
+#define getGtkAdjustmentFields(a,b,c) NULL
+#define setGtkAdjustmentFields(a,b,c)
+#define GtkAdjustment_sizeof() 0
+#endif
+
+#ifndef NO_GtkAllocation
+void cacheGtkAllocationFields(JNIEnv *env, jobject lpObject);
+GtkAllocation *getGtkAllocationFields(JNIEnv *env, jobject lpObject, GtkAllocation *lpStruct);
+void setGtkAllocationFields(JNIEnv *env, jobject lpObject, GtkAllocation *lpStruct);
+#define GtkAllocation_sizeof() sizeof(GtkAllocation)
+#else
+#define cacheGtkAllocationFields(a,b)
+#define getGtkAllocationFields(a,b,c) NULL
+#define setGtkAllocationFields(a,b,c)
+#define GtkAllocation_sizeof() 0
+#endif
+
+#ifndef NO_GtkBorder
+void cacheGtkBorderFields(JNIEnv *env, jobject lpObject);
+GtkBorder *getGtkBorderFields(JNIEnv *env, jobject lpObject, GtkBorder *lpStruct);
+void setGtkBorderFields(JNIEnv *env, jobject lpObject, GtkBorder *lpStruct);
+#define GtkBorder_sizeof() sizeof(GtkBorder)
+#else
+#define cacheGtkBorderFields(a,b)
+#define getGtkBorderFields(a,b,c) NULL
+#define setGtkBorderFields(a,b,c)
+#define GtkBorder_sizeof() 0
+#endif
+
+#ifndef NO_GtkCellRendererClass
+void cacheGtkCellRendererClassFields(JNIEnv *env, jobject lpObject);
+GtkCellRendererClass *getGtkCellRendererClassFields(JNIEnv *env, jobject lpObject, GtkCellRendererClass *lpStruct);
+void setGtkCellRendererClassFields(JNIEnv *env, jobject lpObject, GtkCellRendererClass *lpStruct);
+#define GtkCellRendererClass_sizeof() sizeof(GtkCellRendererClass)
+#else
+#define cacheGtkCellRendererClassFields(a,b)
+#define getGtkCellRendererClassFields(a,b,c) NULL
+#define setGtkCellRendererClassFields(a,b,c)
+#define GtkCellRendererClass_sizeof() 0
+#endif
+
+#ifndef NO_GtkColorSelectionDialog
+void cacheGtkColorSelectionDialogFields(JNIEnv *env, jobject lpObject);
+GtkColorSelectionDialog *getGtkColorSelectionDialogFields(JNIEnv *env, jobject lpObject, GtkColorSelectionDialog *lpStruct);
+void setGtkColorSelectionDialogFields(JNIEnv *env, jobject lpObject, GtkColorSelectionDialog *lpStruct);
+#define GtkColorSelectionDialog_sizeof() sizeof(GtkColorSelectionDialog)
+#else
+#define cacheGtkColorSelectionDialogFields(a,b)
+#define getGtkColorSelectionDialogFields(a,b,c) NULL
+#define setGtkColorSelectionDialogFields(a,b,c)
+#define GtkColorSelectionDialog_sizeof() 0
+#endif
+
+#ifndef NO_GtkCombo
+void cacheGtkComboFields(JNIEnv *env, jobject lpObject);
+GtkCombo *getGtkComboFields(JNIEnv *env, jobject lpObject, GtkCombo *lpStruct);
+void setGtkComboFields(JNIEnv *env, jobject lpObject, GtkCombo *lpStruct);
+#define GtkCombo_sizeof() sizeof(GtkCombo)
+#else
+#define cacheGtkComboFields(a,b)
+#define getGtkComboFields(a,b,c) NULL
+#define setGtkComboFields(a,b,c)
+#define GtkCombo_sizeof() 0
+#endif
+
+#ifndef NO_GtkFileSelection
+void cacheGtkFileSelectionFields(JNIEnv *env, jobject lpObject);
+GtkFileSelection *getGtkFileSelectionFields(JNIEnv *env, jobject lpObject, GtkFileSelection *lpStruct);
+void setGtkFileSelectionFields(JNIEnv *env, jobject lpObject, GtkFileSelection *lpStruct);
+#define GtkFileSelection_sizeof() sizeof(GtkFileSelection)
+#else
+#define cacheGtkFileSelectionFields(a,b)
+#define getGtkFileSelectionFields(a,b,c) NULL
+#define setGtkFileSelectionFields(a,b,c)
+#define GtkFileSelection_sizeof() 0
+#endif
+
+#ifndef NO_GtkFixed
+void cacheGtkFixedFields(JNIEnv *env, jobject lpObject);
+GtkFixed *getGtkFixedFields(JNIEnv *env, jobject lpObject, GtkFixed *lpStruct);
+void setGtkFixedFields(JNIEnv *env, jobject lpObject, GtkFixed *lpStruct);
+#define GtkFixed_sizeof() sizeof(GtkFixed)
+#else
+#define cacheGtkFixedFields(a,b)
+#define getGtkFixedFields(a,b,c) NULL
+#define setGtkFixedFields(a,b,c)
+#define GtkFixed_sizeof() 0
+#endif
+
+#ifndef NO_GtkRequisition
+void cacheGtkRequisitionFields(JNIEnv *env, jobject lpObject);
+GtkRequisition *getGtkRequisitionFields(JNIEnv *env, jobject lpObject, GtkRequisition *lpStruct);
+void setGtkRequisitionFields(JNIEnv *env, jobject lpObject, GtkRequisition *lpStruct);
+#define GtkRequisition_sizeof() sizeof(GtkRequisition)
+#else
+#define cacheGtkRequisitionFields(a,b)
+#define getGtkRequisitionFields(a,b,c) NULL
+#define setGtkRequisitionFields(a,b,c)
+#define GtkRequisition_sizeof() 0
+#endif
+
+#ifndef NO_GtkSelectionData
+void cacheGtkSelectionDataFields(JNIEnv *env, jobject lpObject);
+GtkSelectionData *getGtkSelectionDataFields(JNIEnv *env, jobject lpObject, GtkSelectionData *lpStruct);
+void setGtkSelectionDataFields(JNIEnv *env, jobject lpObject, GtkSelectionData *lpStruct);
+#define GtkSelectionData_sizeof() sizeof(GtkSelectionData)
+#else
+#define cacheGtkSelectionDataFields(a,b)
+#define getGtkSelectionDataFields(a,b,c) NULL
+#define setGtkSelectionDataFields(a,b,c)
+#define GtkSelectionData_sizeof() 0
+#endif
+
+#ifndef NO_GtkTargetEntry
+void cacheGtkTargetEntryFields(JNIEnv *env, jobject lpObject);
+GtkTargetEntry *getGtkTargetEntryFields(JNIEnv *env, jobject lpObject, GtkTargetEntry *lpStruct);
+void setGtkTargetEntryFields(JNIEnv *env, jobject lpObject, GtkTargetEntry *lpStruct);
+#define GtkTargetEntry_sizeof() sizeof(GtkTargetEntry)
+#else
+#define cacheGtkTargetEntryFields(a,b)
+#define getGtkTargetEntryFields(a,b,c) NULL
+#define setGtkTargetEntryFields(a,b,c)
+#define GtkTargetEntry_sizeof() 0
+#endif
+
+#ifndef NO_GtkTargetPair
+void cacheGtkTargetPairFields(JNIEnv *env, jobject lpObject);
+GtkTargetPair *getGtkTargetPairFields(JNIEnv *env, jobject lpObject, GtkTargetPair *lpStruct);
+void setGtkTargetPairFields(JNIEnv *env, jobject lpObject, GtkTargetPair *lpStruct);
+#define GtkTargetPair_sizeof() sizeof(GtkTargetPair)
+#else
+#define cacheGtkTargetPairFields(a,b)
+#define getGtkTargetPairFields(a,b,c) NULL
+#define setGtkTargetPairFields(a,b,c)
+#define GtkTargetPair_sizeof() 0
+#endif
+
+#ifndef NO_GtkWidgetClass
+void cacheGtkWidgetClassFields(JNIEnv *env, jobject lpObject);
+GtkWidgetClass *getGtkWidgetClassFields(JNIEnv *env, jobject lpObject, GtkWidgetClass *lpStruct);
+void setGtkWidgetClassFields(JNIEnv *env, jobject lpObject, GtkWidgetClass *lpStruct);
+#define GtkWidgetClass_sizeof() sizeof(GtkWidgetClass)
+#else
+#define cacheGtkWidgetClassFields(a,b)
+#define getGtkWidgetClassFields(a,b,c) NULL
+#define setGtkWidgetClassFields(a,b,c)
+#define GtkWidgetClass_sizeof() 0
+#endif
+
+#ifndef NO_PangoAttrColor
+void cachePangoAttrColorFields(JNIEnv *env, jobject lpObject);
+PangoAttrColor *getPangoAttrColorFields(JNIEnv *env, jobject lpObject, PangoAttrColor *lpStruct);
+void setPangoAttrColorFields(JNIEnv *env, jobject lpObject, PangoAttrColor *lpStruct);
+#define PangoAttrColor_sizeof() sizeof(PangoAttrColor)
+#else
+#define cachePangoAttrColorFields(a,b)
+#define getPangoAttrColorFields(a,b,c) NULL
+#define setPangoAttrColorFields(a,b,c)
+#define PangoAttrColor_sizeof() 0
+#endif
+
+#ifndef NO_PangoAttrInt
+void cachePangoAttrIntFields(JNIEnv *env, jobject lpObject);
+PangoAttrInt *getPangoAttrIntFields(JNIEnv *env, jobject lpObject, PangoAttrInt *lpStruct);
+void setPangoAttrIntFields(JNIEnv *env, jobject lpObject, PangoAttrInt *lpStruct);
+#define PangoAttrInt_sizeof() sizeof(PangoAttrInt)
+#else
+#define cachePangoAttrIntFields(a,b)
+#define getPangoAttrIntFields(a,b,c) NULL
+#define setPangoAttrIntFields(a,b,c)
+#define PangoAttrInt_sizeof() 0
+#endif
+
+#ifndef NO_PangoAttribute
+void cachePangoAttributeFields(JNIEnv *env, jobject lpObject);
+PangoAttribute *getPangoAttributeFields(JNIEnv *env, jobject lpObject, PangoAttribute *lpStruct);
+void setPangoAttributeFields(JNIEnv *env, jobject lpObject, PangoAttribute *lpStruct);
+#define PangoAttribute_sizeof() sizeof(PangoAttribute)
+#else
+#define cachePangoAttributeFields(a,b)
+#define getPangoAttributeFields(a,b,c) NULL
+#define setPangoAttributeFields(a,b,c)
+#define PangoAttribute_sizeof() 0
+#endif
+
+#ifndef NO_PangoItem
+void cachePangoItemFields(JNIEnv *env, jobject lpObject);
+PangoItem *getPangoItemFields(JNIEnv *env, jobject lpObject, PangoItem *lpStruct);
+void setPangoItemFields(JNIEnv *env, jobject lpObject, PangoItem *lpStruct);
+#define PangoItem_sizeof() sizeof(PangoItem)
+#else
+#define cachePangoItemFields(a,b)
+#define getPangoItemFields(a,b,c) NULL
+#define setPangoItemFields(a,b,c)
+#define PangoItem_sizeof() 0
+#endif
+
+#ifndef NO_PangoLayoutLine
+void cachePangoLayoutLineFields(JNIEnv *env, jobject lpObject);
+PangoLayoutLine *getPangoLayoutLineFields(JNIEnv *env, jobject lpObject, PangoLayoutLine *lpStruct);
+void setPangoLayoutLineFields(JNIEnv *env, jobject lpObject, PangoLayoutLine *lpStruct);
+#define PangoLayoutLine_sizeof() sizeof(PangoLayoutLine)
+#else
+#define cachePangoLayoutLineFields(a,b)
+#define getPangoLayoutLineFields(a,b,c) NULL
+#define setPangoLayoutLineFields(a,b,c)
+#define PangoLayoutLine_sizeof() 0
+#endif
+
+#ifndef NO_PangoLayoutRun
+void cachePangoLayoutRunFields(JNIEnv *env, jobject lpObject);
+PangoLayoutRun *getPangoLayoutRunFields(JNIEnv *env, jobject lpObject, PangoLayoutRun *lpStruct);
+void setPangoLayoutRunFields(JNIEnv *env, jobject lpObject, PangoLayoutRun *lpStruct);
+#define PangoLayoutRun_sizeof() sizeof(PangoLayoutRun)
+#else
+#define cachePangoLayoutRunFields(a,b)
+#define getPangoLayoutRunFields(a,b,c) NULL
+#define setPangoLayoutRunFields(a,b,c)
+#define PangoLayoutRun_sizeof() 0
+#endif
+
+#ifndef NO_PangoLogAttr
+void cachePangoLogAttrFields(JNIEnv *env, jobject lpObject);
+PangoLogAttr *getPangoLogAttrFields(JNIEnv *env, jobject lpObject, PangoLogAttr *lpStruct);
+void setPangoLogAttrFields(JNIEnv *env, jobject lpObject, PangoLogAttr *lpStruct);
+#define PangoLogAttr_sizeof() sizeof(PangoLogAttr)
+#else
+#define cachePangoLogAttrFields(a,b)
+#define getPangoLogAttrFields(a,b,c) NULL
+#define setPangoLogAttrFields(a,b,c)
+#define PangoLogAttr_sizeof() 0
+#endif
+
+#ifndef NO_PangoRectangle
+void cachePangoRectangleFields(JNIEnv *env, jobject lpObject);
+PangoRectangle *getPangoRectangleFields(JNIEnv *env, jobject lpObject, PangoRectangle *lpStruct);
+void setPangoRectangleFields(JNIEnv *env, jobject lpObject, PangoRectangle *lpStruct);
+#define PangoRectangle_sizeof() sizeof(PangoRectangle)
+#else
+#define cachePangoRectangleFields(a,b)
+#define getPangoRectangleFields(a,b,c) NULL
+#define setPangoRectangleFields(a,b,c)
+#define PangoRectangle_sizeof() 0
+#endif
+
+#ifndef NO_XAnyEvent
+void cacheXAnyEventFields(JNIEnv *env, jobject lpObject);
+XAnyEvent *getXAnyEventFields(JNIEnv *env, jobject lpObject, XAnyEvent *lpStruct);
+void setXAnyEventFields(JNIEnv *env, jobject lpObject, XAnyEvent *lpStruct);
+#define XAnyEvent_sizeof() sizeof(XAnyEvent)
+#else
+#define cacheXAnyEventFields(a,b)
+#define getXAnyEventFields(a,b,c) NULL
+#define setXAnyEventFields(a,b,c)
+#define XAnyEvent_sizeof() 0
+#endif
+
+#ifndef NO_XButtonEvent
+void cacheXButtonEventFields(JNIEnv *env, jobject lpObject);
+XButtonEvent *getXButtonEventFields(JNIEnv *env, jobject lpObject, XButtonEvent *lpStruct);
+void setXButtonEventFields(JNIEnv *env, jobject lpObject, XButtonEvent *lpStruct);
+#define XButtonEvent_sizeof() sizeof(XButtonEvent)
+#else
+#define cacheXButtonEventFields(a,b)
+#define getXButtonEventFields(a,b,c) NULL
+#define setXButtonEventFields(a,b,c)
+#define XButtonEvent_sizeof() 0
+#endif
+
+#ifndef NO_XClientMessageEvent
+void cacheXClientMessageEventFields(JNIEnv *env, jobject lpObject);
+XClientMessageEvent *getXClientMessageEventFields(JNIEnv *env, jobject lpObject, XClientMessageEvent *lpStruct);
+void setXClientMessageEventFields(JNIEnv *env, jobject lpObject, XClientMessageEvent *lpStruct);
+#define XClientMessageEvent_sizeof() sizeof(XClientMessageEvent)
+#else
+#define cacheXClientMessageEventFields(a,b)
+#define getXClientMessageEventFields(a,b,c) NULL
+#define setXClientMessageEventFields(a,b,c)
+#define XClientMessageEvent_sizeof() 0
+#endif
+
+#ifndef NO_XCrossingEvent
+void cacheXCrossingEventFields(JNIEnv *env, jobject lpObject);
+XCrossingEvent *getXCrossingEventFields(JNIEnv *env, jobject lpObject, XCrossingEvent *lpStruct);
+void setXCrossingEventFields(JNIEnv *env, jobject lpObject, XCrossingEvent *lpStruct);
+#define XCrossingEvent_sizeof() sizeof(XCrossingEvent)
+#else
+#define cacheXCrossingEventFields(a,b)
+#define getXCrossingEventFields(a,b,c) NULL
+#define setXCrossingEventFields(a,b,c)
+#define XCrossingEvent_sizeof() 0
+#endif
+
+#ifndef NO_XEvent
+void cacheXEventFields(JNIEnv *env, jobject lpObject);
+XEvent *getXEventFields(JNIEnv *env, jobject lpObject, XEvent *lpStruct);
+void setXEventFields(JNIEnv *env, jobject lpObject, XEvent *lpStruct);
+#define XEvent_sizeof() sizeof(XEvent)
+#else
+#define cacheXEventFields(a,b)
+#define getXEventFields(a,b,c) NULL
+#define setXEventFields(a,b,c)
+#define XEvent_sizeof() 0
+#endif
+
+#ifndef NO_XExposeEvent
+void cacheXExposeEventFields(JNIEnv *env, jobject lpObject);
+XExposeEvent *getXExposeEventFields(JNIEnv *env, jobject lpObject, XExposeEvent *lpStruct);
+void setXExposeEventFields(JNIEnv *env, jobject lpObject, XExposeEvent *lpStruct);
+#define XExposeEvent_sizeof() sizeof(XExposeEvent)
+#else
+#define cacheXExposeEventFields(a,b)
+#define getXExposeEventFields(a,b,c) NULL
+#define setXExposeEventFields(a,b,c)
+#define XExposeEvent_sizeof() 0
+#endif
+
+#ifndef NO_XFocusChangeEvent
+void cacheXFocusChangeEventFields(JNIEnv *env, jobject lpObject);
+XFocusChangeEvent *getXFocusChangeEventFields(JNIEnv *env, jobject lpObject, XFocusChangeEvent *lpStruct);
+void setXFocusChangeEventFields(JNIEnv *env, jobject lpObject, XFocusChangeEvent *lpStruct);
+#define XFocusChangeEvent_sizeof() sizeof(XFocusChangeEvent)
+#else
+#define cacheXFocusChangeEventFields(a,b)
+#define getXFocusChangeEventFields(a,b,c) NULL
+#define setXFocusChangeEventFields(a,b,c)
+#define XFocusChangeEvent_sizeof() 0
+#endif
+
+#ifndef NO_XRenderPictureAttributes
+void cacheXRenderPictureAttributesFields(JNIEnv *env, jobject lpObject);
+XRenderPictureAttributes *getXRenderPictureAttributesFields(JNIEnv *env, jobject lpObject, XRenderPictureAttributes *lpStruct);
+void setXRenderPictureAttributesFields(JNIEnv *env, jobject lpObject, XRenderPictureAttributes *lpStruct);
+#define XRenderPictureAttributes_sizeof() sizeof(XRenderPictureAttributes)
+#else
+#define cacheXRenderPictureAttributesFields(a,b)
+#define getXRenderPictureAttributesFields(a,b,c) NULL
+#define setXRenderPictureAttributesFields(a,b,c)
+#define XRenderPictureAttributes_sizeof() 0
+#endif
+
+#ifndef NO_XVisibilityEvent
+void cacheXVisibilityEventFields(JNIEnv *env, jobject lpObject);
+XVisibilityEvent *getXVisibilityEventFields(JNIEnv *env, jobject lpObject, XVisibilityEvent *lpStruct);
+void setXVisibilityEventFields(JNIEnv *env, jobject lpObject, XVisibilityEvent *lpStruct);
+#define XVisibilityEvent_sizeof() sizeof(XVisibilityEvent)
+#else
+#define cacheXVisibilityEventFields(a,b)
+#define getXVisibilityEventFields(a,b,c) NULL
+#define setXVisibilityEventFields(a,b,c)
+#define XVisibilityEvent_sizeof() 0
+#endif
+
+#ifndef NO_XWindowChanges
+void cacheXWindowChangesFields(JNIEnv *env, jobject lpObject);
+XWindowChanges *getXWindowChangesFields(JNIEnv *env, jobject lpObject, XWindowChanges *lpStruct);
+void setXWindowChangesFields(JNIEnv *env, jobject lpObject, XWindowChanges *lpStruct);
+#define XWindowChanges_sizeof() sizeof(XWindowChanges)
+#else
+#define cacheXWindowChangesFields(a,b)
+#define getXWindowChangesFields(a,b,c) NULL
+#define setXWindowChangesFields(a,b,c)
+#define XWindowChanges_sizeof() 0
+#endif
+

Added: branches/upstream/swt-gtk/current/swt.c
===================================================================
--- branches/upstream/swt-gtk/current/swt.c	                        (rev 0)
+++ branches/upstream/swt-gtk/current/swt.c	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+ 
+#include "swt.h"
+
+int IS_JNI_1_2 = 0;
+
+#ifdef JNI_VERSION_1_2
+JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) {
+	IS_JNI_1_2 = 1;
+	return JNI_VERSION_1_2;
+}
+#endif
+
+void throwOutOfMemory(JNIEnv *env) {
+	jclass clazz = (*env)->FindClass(env, "java/lang/OutOfMemoryError");
+	if (clazz != NULL) {
+		(*env)->ThrowNew(env, clazz, "");
+	}
+}

Added: branches/upstream/swt-gtk/current/swt.h
===================================================================
--- branches/upstream/swt-gtk/current/swt.h	                        (rev 0)
+++ branches/upstream/swt-gtk/current/swt.h	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,82 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+ 
+/**
+ * swt.h
+ *
+ * This file contains the global macro declarations for the
+ * SWT library.
+ *
+ */
+
+#ifndef INC_swt_H
+#define INC_swt_H
+
+#include "jni.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern int IS_JNI_1_2;
+
+/* 64 bit support */
+#ifndef SWT_PTR_SIZE_64
+
+#define GetSWT_PTRField GetIntField
+#define SetSWT_PTRField SetIntField
+#define NewSWT_PTRArray NewIntArray
+#define CallStaticSWT_PTRMethodV CallStaticIntMethodV
+#define CallSWT_PTRMethodV CallIntMethodV
+#define CallStaticSWT_PTRMethod CallStaticIntMethod
+#define CallSWT_PTRMethod CallIntMethod
+#define GetSWT_PTRArrayElements GetIntArrayElements
+#define ReleaseSWT_PTRArrayElements ReleaseIntArrayElements
+#define SWT_PTRArray jintArray
+#define SWT_PTR jint
+#define SWT_PTR_SIGNATURE "I"
+
+#else
+
+#define GetSWT_PTRField GetLongField
+#define SetSWT_PTRField SetLongField
+#define NewSWT_PTRArray NewLongArray
+#define CallStaticSWT_PTRMethodV CallStaticLongMethodV
+#define CallSWT_PTRMethodV CallLongMethodV
+#define CallStaticSWT_PTRMethod CallStaticLongMethod
+#define CallSWT_PTRMethod CallLongMethod
+#define GetSWT_PTRArrayElements GetLongArrayElements
+#define ReleaseSWT_PTRArrayElements ReleaseLongArrayElements
+#define SWT_PTRArray jlongArray
+#define SWT_PTR jlong
+#define SWT_PTR_SIGNATURE "J"
+
+#endif
+
+void throwOutOfMemory(JNIEnv *env);
+
+#define CHECK_NULL_VOID(ptr) \
+	if ((ptr) == NULL) { \
+		throwOutOfMemory(env); \
+		return; \
+	}
+
+#define CHECK_NULL(ptr) \
+	if ((ptr) == NULL) { \
+		throwOutOfMemory(env); \
+		return 0; \
+	}
+
+#ifdef __cplusplus
+}
+#endif 
+
+#endif /* ifndef INC_swt_H */

Added: branches/upstream/swt-gtk/current/swt_awt.c
===================================================================
--- branches/upstream/swt-gtk/current/swt_awt.c	                        (rev 0)
+++ branches/upstream/swt-gtk/current/swt_awt.c	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+#include "swt.h"
+#include "jawt_md.h"
+
+#define SWT_AWT_NATIVE(func) Java_org_eclipse_swt_awt_SWT_1AWT_##func
+
+#ifndef NO_getAWTHandle
+JNIEXPORT SWT_PTR JNICALL SWT_AWT_NATIVE(getAWTHandle)
+	(JNIEnv *env, jclass that, jobject canvas)
+{
+	JAWT awt;
+	JAWT_DrawingSurface* ds;
+	JAWT_DrawingSurfaceInfo* dsi;
+	JAWT_X11DrawingSurfaceInfo* dsi_x11;
+	SWT_PTR result = 0;
+	jint lock;
+
+	awt.version = JAWT_VERSION_1_3;
+	if (JAWT_GetAWT(env, &awt) != 0) {
+		ds = awt.GetDrawingSurface(env, canvas);
+		if (ds != NULL) {
+			lock = ds->Lock(ds);
+		 	if ((lock & JAWT_LOCK_ERROR) == 0) {
+			 	dsi = ds->GetDrawingSurfaceInfo(ds);
+				dsi_x11 = (JAWT_X11DrawingSurfaceInfo*)dsi->platformInfo;
+				result = (SWT_PTR)dsi_x11->drawable;
+				ds->FreeDrawingSurfaceInfo(dsi);
+				ds->Unlock(ds);
+			}
+		}
+		awt.FreeDrawingSurface(ds);
+	}
+	return result;
+}
+#endif
+
+#ifndef NO_setDebug
+JNIEXPORT void JNICALL SWT_AWT_NATIVE(setDebug)
+	(JNIEnv *env, jclass that, jobject frame, jboolean debug)
+{
+	JAWT awt;
+	JAWT_DrawingSurface* ds;
+	JAWT_DrawingSurfaceInfo* dsi;
+	JAWT_X11DrawingSurfaceInfo* dsi_x11;
+	jint lock;
+
+	awt.version = JAWT_VERSION_1_3;
+	if (JAWT_GetAWT(env, &awt) != 0) {
+		ds = awt.GetDrawingSurface(env, frame);
+		if (ds != NULL) {
+			lock = ds->Lock(ds);
+		 	if ((lock & JAWT_LOCK_ERROR) == 0) {
+			 	dsi = ds->GetDrawingSurfaceInfo(ds);
+				dsi_x11 = (JAWT_X11DrawingSurfaceInfo*)dsi->platformInfo;
+				XSynchronize(dsi_x11->display, debug);
+				ds->FreeDrawingSurfaceInfo(dsi);
+				ds->Unlock(ds);
+			}
+		}
+		awt.FreeDrawingSurface(ds);
+	}
+}
+#endif

Added: branches/upstream/swt-gtk/current/swt_xpcom.rc
===================================================================
--- branches/upstream/swt-gtk/current/swt_xpcom.rc	                        (rev 0)
+++ branches/upstream/swt-gtk/current/swt_xpcom.rc	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+ 
+#include "windows.h"
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION SWT_COMMA_VERSION
+ PRODUCTVERSION 0,0,0,0
+ FILEFLAGSMASK 0x3fL
+#ifdef _DEBUG
+ FILEFLAGS 0x1L
+#else
+ FILEFLAGS 0x0L
+#endif
+ FILEOS 0x40000L
+ FILETYPE 0x2L
+ FILESUBTYPE 0x0L
+BEGIN
+    BLOCK "StringFileInfo"
+    BEGIN
+        BLOCK "040904b0"
+        BEGIN
+            VALUE "CompanyName", "Eclipse Foundation\0"
+            VALUE "FileDescription", "SWT for Windows native library\0"
+            VALUE "FileVersion", SWT_FILE_VERSION
+            VALUE "InternalName", "SWT\0"
+            VALUE "LegalCopyright", "Copyright (c) 2000, 2006 IBM Corp.  All Rights Reserved.\0"
+            VALUE "OriginalFilename", SWT_ORG_FILENAME
+            VALUE "ProductName", "Standard Widget Toolkit\0"
+            VALUE "ProductVersion", "0,0,0,0\0"
+        END
+    END
+    BLOCK "VarFileInfo"
+    BEGIN
+        VALUE "Translation", 0x409, 1200
+    END
+END

Added: branches/upstream/swt-gtk/current/version.txt
===================================================================
--- branches/upstream/swt-gtk/current/version.txt	                        (rev 0)
+++ branches/upstream/swt-gtk/current/version.txt	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1 @@
+version 3.452
\ No newline at end of file

Added: branches/upstream/swt-gtk/current/xpcom.cpp
===================================================================
--- branches/upstream/swt-gtk/current/xpcom.cpp	                        (rev 0)
+++ branches/upstream/swt-gtk/current/xpcom.cpp	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,3272 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+#include "swt.h"
+#include "xpcom_structs.h"
+#include "xpcom_stats.h"
+
+#define XPCOM_NATIVE(func) Java_org_eclipse_swt_internal_mozilla_XPCOM_##func
+
+#ifndef NO_Call
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(Call)(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jbyteArray arg3, jint arg4, jint arg5, jintArray arg6);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(Call)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jbyteArray arg3, jint arg4, jint arg5, jintArray arg6)
+{
+	jbyte *lparg3=NULL;
+	jint *lparg6=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, Call_FUNC);
+	if (arg3) if ((lparg3 = env->GetByteArrayElements(arg3, NULL)) == NULL) goto fail;
+	if (arg6) if ((lparg6 = env->GetIntArrayElements(arg6, NULL)) == NULL) goto fail;
+	rc = (jint)((nsWriteSegmentFun)arg0)((nsIInputStream *)arg1, (void *)arg2, (const char *)lparg3, arg4, arg5, (PRUint32 *)lparg6);
+fail:
+	if (arg6 && lparg6) env->ReleaseIntArrayElements(arg6, lparg6, 0);
+	if (arg3 && lparg3) env->ReleaseByteArrayElements(arg3, lparg3, 0);
+	XPCOM_NATIVE_EXIT(env, that, Call_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_NS_1GetComponentManager
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(NS_1GetComponentManager)(JNIEnv *env, jclass that, jintArray arg0);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(NS_1GetComponentManager)
+	(JNIEnv *env, jclass that, jintArray arg0)
+{
+	jint *lparg0=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, NS_1GetComponentManager_FUNC);
+	if (arg0) if ((lparg0 = env->GetIntArrayElements(arg0, NULL)) == NULL) goto fail;
+	rc = (jint)NS_GetComponentManager((nsIComponentManager**)lparg0);
+fail:
+	if (arg0 && lparg0) env->ReleaseIntArrayElements(arg0, lparg0, 0);
+	XPCOM_NATIVE_EXIT(env, that, NS_1GetComponentManager_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_NS_1GetServiceManager
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(NS_1GetServiceManager)(JNIEnv *env, jclass that, jintArray arg0);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(NS_1GetServiceManager)
+	(JNIEnv *env, jclass that, jintArray arg0)
+{
+	jint *lparg0=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, NS_1GetServiceManager_FUNC);
+	if (arg0) if ((lparg0 = env->GetIntArrayElements(arg0, NULL)) == NULL) goto fail;
+	rc = (jint)NS_GetServiceManager((nsIServiceManager**)lparg0);
+fail:
+	if (arg0 && lparg0) env->ReleaseIntArrayElements(arg0, lparg0, 0);
+	XPCOM_NATIVE_EXIT(env, that, NS_1GetServiceManager_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_NS_1InitXPCOM2
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(NS_1InitXPCOM2)(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(NS_1InitXPCOM2)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, NS_1InitXPCOM2_FUNC);
+	rc = (jint)NS_InitXPCOM2((nsIServiceManager **)arg0, (nsIFile *)arg1, (nsIDirectoryServiceProvider *)arg2);
+	XPCOM_NATIVE_EXIT(env, that, NS_1InitXPCOM2_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_NS_1NewLocalFile
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(NS_1NewLocalFile)(JNIEnv *env, jclass that, jint arg0, jint arg1, jintArray arg2);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(NS_1NewLocalFile)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jintArray arg2)
+{
+	jint *lparg2=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, NS_1NewLocalFile_FUNC);
+	if (arg2) if ((lparg2 = env->GetIntArrayElements(arg2, NULL)) == NULL) goto fail;
+	rc = (jint)NS_NewLocalFile(*(nsAString *)arg0, arg1, (nsILocalFile**)lparg2);
+fail:
+	if (arg2 && lparg2) env->ReleaseIntArrayElements(arg2, lparg2, 0);
+	XPCOM_NATIVE_EXIT(env, that, NS_1NewLocalFile_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__II
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__II)(JNIEnv *env, jclass that, jint arg0, jint arg1);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__II)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__II_FUNC);
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint))(*(jint **)arg1)[arg0])(arg1);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__II_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__IIF
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIF)(JNIEnv *env, jclass that, jint arg0, jint arg1, jfloat arg2);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIF)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jfloat arg2)
+{
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__IIF_FUNC);
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jfloat))(*(jint **)arg1)[arg0])(arg1, arg2);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__IIF_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__III
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__III)(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__III)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__III_FUNC);
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jint))(*(jint **)arg1)[arg0])(arg1, arg2);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__III_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__IIII
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIII)(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIII)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3)
+{
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__IIII_FUNC);
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jint, jint))(*(jint **)arg1)[arg0])(arg1, arg2, arg3);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__IIII_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__IIIII
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIIII)(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIIII)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4)
+{
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__IIIII_FUNC);
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jint, jint, jint))(*(jint **)arg1)[arg0])(arg1, arg2, arg3, arg4);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__IIIII_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__IIIIII
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIIIII)(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4, jint arg5);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIIIII)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4, jint arg5)
+{
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__IIIIII_FUNC);
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jint, jint, jint, jint))(*(jint **)arg1)[arg0])(arg1, arg2, arg3, arg4, arg5);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__IIIIII_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__IIIIIII
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIIIIII)(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4, jint arg5, jint arg6);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIIIIII)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4, jint arg5, jint arg6)
+{
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__IIIIIII_FUNC);
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jint, jint, jint, jint, jint))(*(jint **)arg1)[arg0])(arg1, arg2, arg3, arg4, arg5, arg6);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__IIIIIII_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__IIIIIIII
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIIIIIII)(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4, jint arg5, jint arg6, jint arg7);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIIIIIII)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4, jint arg5, jint arg6, jint arg7)
+{
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__IIIIIIII_FUNC);
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jint, jint, jint, jint, jint, jint))(*(jint **)arg1)[arg0])(arg1, arg2, arg3, arg4, arg5, arg6, arg7);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__IIIIIIII_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__IIIIIIIIIIII
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIIIIIIIIIII)(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4, jint arg5, jint arg6, jint arg7, jint arg8, jint arg9, jint arg10, jint arg11);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIIIIIIIIIII)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4, jint arg5, jint arg6, jint arg7, jint arg8, jint arg9, jint arg10, jint arg11)
+{
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__IIIIIIIIIIII_FUNC);
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jint, jint, jint, jint, jint, jint, jint, jint, jint, jint))(*(jint **)arg1)[arg0])(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__IIIIIIIIIIII_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__IIIIIIIIIIIIIIISI
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIIIIIIIIIIIIIISI)(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4, jint arg5, jint arg6, jint arg7, jint arg8, jint arg9, jint arg10, jint arg11, jint arg12, jint arg13, jint arg14, jshort arg15, jint arg16);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIIIIIIIIIIIIIISI)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4, jint arg5, jint arg6, jint arg7, jint arg8, jint arg9, jint arg10, jint arg11, jint arg12, jint arg13, jint arg14, jshort arg15, jint arg16)
+{
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__IIIIIIIIIIIIIIISI_FUNC);
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jint, jint, jint, jint, jint, jint, jint, jint, jint, jint, jint, jint, jint, jshort, jint))(*(jint **)arg1)[arg0])(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15, arg16);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__IIIIIIIIIIIIIIISI_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__IIIIIIII_3C_3I_3I
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIIIIIII_3C_3I_3I)(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4, jint arg5, jint arg6, jint arg7, jcharArray arg8, jintArray arg9, jintArray arg10);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIIIIIII_3C_3I_3I)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4, jint arg5, jint arg6, jint arg7, jcharArray arg8, jintArray arg9, jintArray arg10)
+{
+	jchar *lparg8=NULL;
+	jint *lparg9=NULL;
+	jint *lparg10=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__IIIIIIII_3C_3I_3I_FUNC);
+	if (arg8) if ((lparg8 = env->GetCharArrayElements(arg8, NULL)) == NULL) goto fail;
+	if (arg9) if ((lparg9 = env->GetIntArrayElements(arg9, NULL)) == NULL) goto fail;
+	if (arg10) if ((lparg10 = env->GetIntArrayElements(arg10, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jint, jint, jint, jint, jint, jint, jchar *, jint *, jint *))(*(jint **)arg1)[arg0])(arg1, arg2, arg3, arg4, arg5, arg6, arg7, lparg8, lparg9, lparg10);
+fail:
+	if (arg10 && lparg10) env->ReleaseIntArrayElements(arg10, lparg10, 0);
+	if (arg9 && lparg9) env->ReleaseIntArrayElements(arg9, lparg9, 0);
+	if (arg8 && lparg8) env->ReleaseCharArrayElements(arg8, lparg8, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__IIIIIIII_3C_3I_3I_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__IIIIIIJII
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIIIIIJII)(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4, jint arg5, jlong arg6, jint arg7, jint arg8);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIIIIIJII)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4, jint arg5, jlong arg6, jint arg7, jint arg8)
+{
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__IIIIIIJII_FUNC);
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jint, jint, jint, jint, jlong, jint, jint))(*(jint **)arg1)[arg0])(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__IIIIIIJII_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__IIIIII_3CIIIII_3I_3I
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIIIII_3CIIIII_3I_3I)(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4, jint arg5, jcharArray arg6, jint arg7, jint arg8, jint arg9, jint arg10, jint arg11, jintArray arg12, jintArray arg13);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIIIII_3CIIIII_3I_3I)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4, jint arg5, jcharArray arg6, jint arg7, jint arg8, jint arg9, jint arg10, jint arg11, jintArray arg12, jintArray arg13)
+{
+	jchar *lparg6=NULL;
+	jint *lparg12=NULL;
+	jint *lparg13=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__IIIIII_3CIIIII_3I_3I_FUNC);
+	if (arg6) if ((lparg6 = env->GetCharArrayElements(arg6, NULL)) == NULL) goto fail;
+	if (arg12) if ((lparg12 = env->GetIntArrayElements(arg12, NULL)) == NULL) goto fail;
+	if (arg13) if ((lparg13 = env->GetIntArrayElements(arg13, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jint, jint, jint, jint, jchar *, jint, jint, jint, jint, jint, jint *, jint *))(*(jint **)arg1)[arg0])(arg1, arg2, arg3, arg4, arg5, lparg6, arg7, arg8, arg9, arg10, arg11, lparg12, lparg13);
+fail:
+	if (arg13 && lparg13) env->ReleaseIntArrayElements(arg13, lparg13, 0);
+	if (arg12 && lparg12) env->ReleaseIntArrayElements(arg12, lparg12, 0);
+	if (arg6 && lparg6) env->ReleaseCharArrayElements(arg6, lparg6, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__IIIIII_3CIIIII_3I_3I_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__IIIIII_3C_3BIIIII_3I_3I
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIIIII_3C_3BIIIII_3I_3I)(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4, jint arg5, jcharArray arg6, jbyteArray arg7, jint arg8, jint arg9, jint arg10, jint arg11, jint arg12, jintArray arg13, jintArray arg14);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIIIII_3C_3BIIIII_3I_3I)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4, jint arg5, jcharArray arg6, jbyteArray arg7, jint arg8, jint arg9, jint arg10, jint arg11, jint arg12, jintArray arg13, jintArray arg14)
+{
+	jchar *lparg6=NULL;
+	jbyte *lparg7=NULL;
+	jint *lparg13=NULL;
+	jint *lparg14=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__IIIIII_3C_3BIIIII_3I_3I_FUNC);
+	if (arg6) if ((lparg6 = env->GetCharArrayElements(arg6, NULL)) == NULL) goto fail;
+	if (arg7) if ((lparg7 = env->GetByteArrayElements(arg7, NULL)) == NULL) goto fail;
+	if (arg13) if ((lparg13 = env->GetIntArrayElements(arg13, NULL)) == NULL) goto fail;
+	if (arg14) if ((lparg14 = env->GetIntArrayElements(arg14, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jint, jint, jint, jint, jchar *, jbyte *, jint, jint, jint, jint, jint, jint *, jint *))(*(jint **)arg1)[arg0])(arg1, arg2, arg3, arg4, arg5, lparg6, lparg7, arg8, arg9, arg10, arg11, arg12, lparg13, lparg14);
+fail:
+	if (arg14 && lparg14) env->ReleaseIntArrayElements(arg14, lparg14, 0);
+	if (arg13 && lparg13) env->ReleaseIntArrayElements(arg13, lparg13, 0);
+	if (arg7 && lparg7) env->ReleaseByteArrayElements(arg7, lparg7, 0);
+	if (arg6 && lparg6) env->ReleaseCharArrayElements(arg6, lparg6, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__IIIIII_3C_3BIIIII_3I_3I_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__IIIIII_3C_3I_3I
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIIIII_3C_3I_3I)(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4, jint arg5, jcharArray arg6, jintArray arg7, jintArray arg8);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIIIII_3C_3I_3I)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4, jint arg5, jcharArray arg6, jintArray arg7, jintArray arg8)
+{
+	jchar *lparg6=NULL;
+	jint *lparg7=NULL;
+	jint *lparg8=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__IIIIII_3C_3I_3I_FUNC);
+	if (arg6) if ((lparg6 = env->GetCharArrayElements(arg6, NULL)) == NULL) goto fail;
+	if (arg7) if ((lparg7 = env->GetIntArrayElements(arg7, NULL)) == NULL) goto fail;
+	if (arg8) if ((lparg8 = env->GetIntArrayElements(arg8, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jint, jint, jint, jint, jchar *, jint *, jint *))(*(jint **)arg1)[arg0])(arg1, arg2, arg3, arg4, arg5, lparg6, lparg7, lparg8);
+fail:
+	if (arg8 && lparg8) env->ReleaseIntArrayElements(arg8, lparg8, 0);
+	if (arg7 && lparg7) env->ReleaseIntArrayElements(arg7, lparg7, 0);
+	if (arg6 && lparg6) env->ReleaseCharArrayElements(arg6, lparg6, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__IIIIII_3C_3I_3I_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__IIIIII_3I_3I
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIIIII_3I_3I)(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4, jint arg5, jintArray arg6, jintArray arg7);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIIIII_3I_3I)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4, jint arg5, jintArray arg6, jintArray arg7)
+{
+	jint *lparg6=NULL;
+	jint *lparg7=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__IIIIII_3I_3I_FUNC);
+	if (arg6) if ((lparg6 = env->GetIntArrayElements(arg6, NULL)) == NULL) goto fail;
+	if (arg7) if ((lparg7 = env->GetIntArrayElements(arg7, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jint, jint, jint, jint, jint *, jint *))(*(jint **)arg1)[arg0])(arg1, arg2, arg3, arg4, arg5, lparg6, lparg7);
+fail:
+	if (arg7 && lparg7) env->ReleaseIntArrayElements(arg7, lparg7, 0);
+	if (arg6 && lparg6) env->ReleaseIntArrayElements(arg6, lparg6, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__IIIIII_3I_3I_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__IIIII_3C
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIIII_3C)(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4, jcharArray arg5);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIIII_3C)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4, jcharArray arg5)
+{
+	jchar *lparg5=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__IIIII_3C_FUNC);
+	if (arg5) if ((lparg5 = env->GetCharArrayElements(arg5, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jint, jint, jint, jchar *))(*(jint **)arg1)[arg0])(arg1, arg2, arg3, arg4, lparg5);
+fail:
+	if (arg5 && lparg5) env->ReleaseCharArrayElements(arg5, lparg5, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__IIIII_3C_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__IIIII_3I
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIIII_3I)(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4, jintArray arg5);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIIII_3I)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4, jintArray arg5)
+{
+	jint *lparg5=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__IIIII_3I_FUNC);
+	if (arg5) if ((lparg5 = env->GetIntArrayElements(arg5, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jint, jint, jint, jint *))(*(jint **)arg1)[arg0])(arg1, arg2, arg3, arg4, lparg5);
+fail:
+	if (arg5 && lparg5) env->ReleaseIntArrayElements(arg5, lparg5, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__IIIII_3I_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__IIIIJJJJ
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIIIJJJJ)(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jlong arg4, jlong arg5, jlong arg6, jlong arg7);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIIIJJJJ)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jlong arg4, jlong arg5, jlong arg6, jlong arg7)
+{
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__IIIIJJJJ_FUNC);
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jint, jint, jlong, jlong, jlong, jlong))(*(jint **)arg1)[arg0])(arg1, arg2, arg3, arg4, arg5, arg6, arg7);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__IIIIJJJJ_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__IIII_3B
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIII_3B)(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jbyteArray arg4);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIII_3B)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jbyteArray arg4)
+{
+	jbyte *lparg4=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__IIII_3B_FUNC);
+	if (arg4) if ((lparg4 = env->GetByteArrayElements(arg4, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jint, jint, jbyte *))(*(jint **)arg1)[arg0])(arg1, arg2, arg3, lparg4);
+fail:
+	if (arg4 && lparg4) env->ReleaseByteArrayElements(arg4, lparg4, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__IIII_3B_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__IIII_3C
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIII_3C)(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jcharArray arg4);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIII_3C)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jcharArray arg4)
+{
+	jchar *lparg4=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__IIII_3C_FUNC);
+	if (arg4) if ((lparg4 = env->GetCharArrayElements(arg4, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jint, jint, jchar *))(*(jint **)arg1)[arg0])(arg1, arg2, arg3, lparg4);
+fail:
+	if (arg4 && lparg4) env->ReleaseCharArrayElements(arg4, lparg4, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__IIII_3C_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__IIII_3CIJI
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIII_3CIJI)(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jcharArray arg4, jint arg5, jlong arg6, jint arg7);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIII_3CIJI)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jcharArray arg4, jint arg5, jlong arg6, jint arg7)
+{
+	jchar *lparg4=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__IIII_3CIJI_FUNC);
+	if (arg4) if ((lparg4 = env->GetCharArrayElements(arg4, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jint, jint, jchar *, jint, jlong, jint))(*(jint **)arg1)[arg0])(arg1, arg2, arg3, lparg4, arg5, arg6, arg7);
+fail:
+	if (arg4 && lparg4) env->ReleaseCharArrayElements(arg4, lparg4, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__IIII_3CIJI_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__IIII_3CJJJ
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIII_3CJJJ)(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jcharArray arg4, jlong arg5, jlong arg6, jlong arg7);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIII_3CJJJ)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jcharArray arg4, jlong arg5, jlong arg6, jlong arg7)
+{
+	jchar *lparg4=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__IIII_3CJJJ_FUNC);
+	if (arg4) if ((lparg4 = env->GetCharArrayElements(arg4, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jint, jint, jchar *, jlong, jlong, jlong))(*(jint **)arg1)[arg0])(arg1, arg2, arg3, lparg4, arg5, arg6, arg7);
+fail:
+	if (arg4 && lparg4) env->ReleaseCharArrayElements(arg4, lparg4, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__IIII_3CJJJ_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__IIII_3C_3CI_3I
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIII_3C_3CI_3I)(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jcharArray arg4, jcharArray arg5, jint arg6, jintArray arg7);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIII_3C_3CI_3I)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jcharArray arg4, jcharArray arg5, jint arg6, jintArray arg7)
+{
+	jchar *lparg4=NULL;
+	jchar *lparg5=NULL;
+	jint *lparg7=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__IIII_3C_3CI_3I_FUNC);
+	if (arg4) if ((lparg4 = env->GetCharArrayElements(arg4, NULL)) == NULL) goto fail;
+	if (arg5) if ((lparg5 = env->GetCharArrayElements(arg5, NULL)) == NULL) goto fail;
+	if (arg7) if ((lparg7 = env->GetIntArrayElements(arg7, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jint, jint, jchar *, jchar *, jint, jint *))(*(jint **)arg1)[arg0])(arg1, arg2, arg3, lparg4, lparg5, arg6, lparg7);
+fail:
+	if (arg7 && lparg7) env->ReleaseIntArrayElements(arg7, lparg7, 0);
+	if (arg5 && lparg5) env->ReleaseCharArrayElements(arg5, lparg5, 0);
+	if (arg4 && lparg4) env->ReleaseCharArrayElements(arg4, lparg4, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__IIII_3C_3CI_3I_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__IIII_3I
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIII_3I)(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jintArray arg4);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIII_3I)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jintArray arg4)
+{
+	jint *lparg4=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__IIII_3I_FUNC);
+	if (arg4) if ((lparg4 = env->GetIntArrayElements(arg4, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jint, jint, jint *))(*(jint **)arg1)[arg0])(arg1, arg2, arg3, lparg4);
+fail:
+	if (arg4 && lparg4) env->ReleaseIntArrayElements(arg4, lparg4, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__IIII_3I_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__IIII_3J
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIII_3J)(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jlongArray arg4);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIII_3J)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jint arg3, jlongArray arg4)
+{
+	jlong *lparg4=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__IIII_3J_FUNC);
+	if (arg4) if ((lparg4 = env->GetLongArrayElements(arg4, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jint, jint, jlong *))(*(jint **)arg1)[arg0])(arg1, arg2, arg3, lparg4);
+fail:
+	if (arg4 && lparg4) env->ReleaseLongArrayElements(arg4, lparg4, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__IIII_3J_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__IIIJJ
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIIJJ)(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jlong arg3, jlong arg4);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIIJJ)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jlong arg3, jlong arg4)
+{
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__IIIJJ_FUNC);
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jint, jlong, jlong))(*(jint **)arg1)[arg0])(arg1, arg2, arg3, arg4);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__IIIJJ_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__IIILorg_eclipse_swt_internal_mozilla_nsID_2
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIILorg_eclipse_swt_internal_mozilla_nsID_2)(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jobject arg3);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIILorg_eclipse_swt_internal_mozilla_nsID_2)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jobject arg3)
+{
+	nsID _arg3, *lparg3=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__IIILorg_eclipse_swt_internal_mozilla_nsID_2_FUNC);
+	if (arg3) if ((lparg3 = getnsIDFields(env, arg3, &_arg3)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jint, nsID *))(*(jint **)arg1)[arg0])(arg1, arg2, lparg3);
+fail:
+	if (arg3 && lparg3) setnsIDFields(env, arg3, lparg3);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__IIILorg_eclipse_swt_internal_mozilla_nsID_2_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__IIILorg_eclipse_swt_internal_mozilla_nsID_2_3I
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIILorg_eclipse_swt_internal_mozilla_nsID_2_3I)(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jobject arg3, jintArray arg4);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIILorg_eclipse_swt_internal_mozilla_nsID_2_3I)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jobject arg3, jintArray arg4)
+{
+	nsID _arg3, *lparg3=NULL;
+	jint *lparg4=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__IIILorg_eclipse_swt_internal_mozilla_nsID_2_3I_FUNC);
+	if (arg3) if ((lparg3 = getnsIDFields(env, arg3, &_arg3)) == NULL) goto fail;
+	if (arg4) if ((lparg4 = env->GetIntArrayElements(arg4, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jint, nsID *, jint *))(*(jint **)arg1)[arg0])(arg1, arg2, lparg3, lparg4);
+fail:
+	if (arg4 && lparg4) env->ReleaseIntArrayElements(arg4, lparg4, 0);
+	if (arg3 && lparg3) setnsIDFields(env, arg3, lparg3);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__IIILorg_eclipse_swt_internal_mozilla_nsID_2_3I_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__III_3B
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__III_3B)(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jbyteArray arg3);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__III_3B)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jbyteArray arg3)
+{
+	jbyte *lparg3=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__III_3B_FUNC);
+	if (arg3) if ((lparg3 = env->GetByteArrayElements(arg3, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jint, jbyte *))(*(jint **)arg1)[arg0])(arg1, arg2, lparg3);
+fail:
+	if (arg3 && lparg3) env->ReleaseByteArrayElements(arg3, lparg3, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__III_3B_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__III_3BI
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__III_3BI)(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jbyteArray arg3, jint arg4);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__III_3BI)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jbyteArray arg3, jint arg4)
+{
+	jbyte *lparg3=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__III_3BI_FUNC);
+	if (arg3) if ((lparg3 = env->GetByteArrayElements(arg3, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jint, jbyte *, jint))(*(jint **)arg1)[arg0])(arg1, arg2, lparg3, arg4);
+fail:
+	if (arg3 && lparg3) env->ReleaseByteArrayElements(arg3, lparg3, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__III_3BI_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__III_3BI_3I
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__III_3BI_3I)(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jbyteArray arg3, jint arg4, jintArray arg5);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__III_3BI_3I)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jbyteArray arg3, jint arg4, jintArray arg5)
+{
+	jbyte *lparg3=NULL;
+	jint *lparg5=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__III_3BI_3I_FUNC);
+	if (arg3) if ((lparg3 = env->GetByteArrayElements(arg3, NULL)) == NULL) goto fail;
+	if (arg5) if ((lparg5 = env->GetIntArrayElements(arg5, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jint, jbyte *, jint, jint *))(*(jint **)arg1)[arg0])(arg1, arg2, lparg3, arg4, lparg5);
+fail:
+	if (arg5 && lparg5) env->ReleaseIntArrayElements(arg5, lparg5, 0);
+	if (arg3 && lparg3) env->ReleaseByteArrayElements(arg3, lparg3, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__III_3BI_3I_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__III_3B_3B_3BI_3I
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__III_3B_3B_3BI_3I)(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jbyteArray arg3, jbyteArray arg4, jbyteArray arg5, jint arg6, jintArray arg7);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__III_3B_3B_3BI_3I)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jbyteArray arg3, jbyteArray arg4, jbyteArray arg5, jint arg6, jintArray arg7)
+{
+	jbyte *lparg3=NULL;
+	jbyte *lparg4=NULL;
+	jbyte *lparg5=NULL;
+	jint *lparg7=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__III_3B_3B_3BI_3I_FUNC);
+	if (arg3) if ((lparg3 = env->GetByteArrayElements(arg3, NULL)) == NULL) goto fail;
+	if (arg4) if ((lparg4 = env->GetByteArrayElements(arg4, NULL)) == NULL) goto fail;
+	if (arg5) if ((lparg5 = env->GetByteArrayElements(arg5, NULL)) == NULL) goto fail;
+	if (arg7) if ((lparg7 = env->GetIntArrayElements(arg7, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jint, jbyte *, jbyte *, jbyte *, jint, jint *))(*(jint **)arg1)[arg0])(arg1, arg2, lparg3, lparg4, lparg5, arg6, lparg7);
+fail:
+	if (arg7 && lparg7) env->ReleaseIntArrayElements(arg7, lparg7, 0);
+	if (arg5 && lparg5) env->ReleaseByteArrayElements(arg5, lparg5, 0);
+	if (arg4 && lparg4) env->ReleaseByteArrayElements(arg4, lparg4, 0);
+	if (arg3 && lparg3) env->ReleaseByteArrayElements(arg3, lparg3, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__III_3B_3B_3BI_3I_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__III_3B_3C
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__III_3B_3C)(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jbyteArray arg3, jcharArray arg4);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__III_3B_3C)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jbyteArray arg3, jcharArray arg4)
+{
+	jbyte *lparg3=NULL;
+	jchar *lparg4=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__III_3B_3C_FUNC);
+	if (arg3) if ((lparg3 = env->GetByteArrayElements(arg3, NULL)) == NULL) goto fail;
+	if (arg4) if ((lparg4 = env->GetCharArrayElements(arg4, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jint, jbyte *, jchar *))(*(jint **)arg1)[arg0])(arg1, arg2, lparg3, lparg4);
+fail:
+	if (arg4 && lparg4) env->ReleaseCharArrayElements(arg4, lparg4, 0);
+	if (arg3 && lparg3) env->ReleaseByteArrayElements(arg3, lparg3, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__III_3B_3C_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__III_3B_3I
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__III_3B_3I)(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jbyteArray arg3, jintArray arg4);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__III_3B_3I)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jbyteArray arg3, jintArray arg4)
+{
+	jbyte *lparg3=NULL;
+	jint *lparg4=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__III_3B_3I_FUNC);
+	if (arg3) if ((lparg3 = env->GetByteArrayElements(arg3, NULL)) == NULL) goto fail;
+	if (arg4) if ((lparg4 = env->GetIntArrayElements(arg4, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jint, jbyte *, jint *))(*(jint **)arg1)[arg0])(arg1, arg2, lparg3, lparg4);
+fail:
+	if (arg4 && lparg4) env->ReleaseIntArrayElements(arg4, lparg4, 0);
+	if (arg3 && lparg3) env->ReleaseByteArrayElements(arg3, lparg3, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__III_3B_3I_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__III_3C
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__III_3C)(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jcharArray arg3);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__III_3C)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jcharArray arg3)
+{
+	jchar *lparg3=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__III_3C_FUNC);
+	if (arg3) if ((lparg3 = env->GetCharArrayElements(arg3, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jint, jchar *))(*(jint **)arg1)[arg0])(arg1, arg2, lparg3);
+fail:
+	if (arg3 && lparg3) env->ReleaseCharArrayElements(arg3, lparg3, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__III_3C_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__III_3CI
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__III_3CI)(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jcharArray arg3, jint arg4);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__III_3CI)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jcharArray arg3, jint arg4)
+{
+	jchar *lparg3=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__III_3CI_FUNC);
+	if (arg3) if ((lparg3 = env->GetCharArrayElements(arg3, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jint, jchar *, jint))(*(jint **)arg1)[arg0])(arg1, arg2, lparg3, arg4);
+fail:
+	if (arg3 && lparg3) env->ReleaseCharArrayElements(arg3, lparg3, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__III_3CI_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__III_3C_3C
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__III_3C_3C)(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jcharArray arg3, jcharArray arg4);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__III_3C_3C)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jcharArray arg3, jcharArray arg4)
+{
+	jchar *lparg3=NULL;
+	jchar *lparg4=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__III_3C_3C_FUNC);
+	if (arg3) if ((lparg3 = env->GetCharArrayElements(arg3, NULL)) == NULL) goto fail;
+	if (arg4) if ((lparg4 = env->GetCharArrayElements(arg4, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jint, jchar *, jchar *))(*(jint **)arg1)[arg0])(arg1, arg2, lparg3, lparg4);
+fail:
+	if (arg4 && lparg4) env->ReleaseCharArrayElements(arg4, lparg4, 0);
+	if (arg3 && lparg3) env->ReleaseCharArrayElements(arg3, lparg3, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__III_3C_3C_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__III_3C_3CI_3C_3C_3C_3C_3I_3I
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__III_3C_3CI_3C_3C_3C_3C_3I_3I)(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jcharArray arg3, jcharArray arg4, jint arg5, jcharArray arg6, jcharArray arg7, jcharArray arg8, jcharArray arg9, jintArray arg10, jintArray arg11);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__III_3C_3CI_3C_3C_3C_3C_3I_3I)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jcharArray arg3, jcharArray arg4, jint arg5, jcharArray arg6, jcharArray arg7, jcharArray arg8, jcharArray arg9, jintArray arg10, jintArray arg11)
+{
+	jchar *lparg3=NULL;
+	jchar *lparg4=NULL;
+	jchar *lparg6=NULL;
+	jchar *lparg7=NULL;
+	jchar *lparg8=NULL;
+	jchar *lparg9=NULL;
+	jint *lparg10=NULL;
+	jint *lparg11=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__III_3C_3CI_3C_3C_3C_3C_3I_3I_FUNC);
+	if (arg3) if ((lparg3 = env->GetCharArrayElements(arg3, NULL)) == NULL) goto fail;
+	if (arg4) if ((lparg4 = env->GetCharArrayElements(arg4, NULL)) == NULL) goto fail;
+	if (arg6) if ((lparg6 = env->GetCharArrayElements(arg6, NULL)) == NULL) goto fail;
+	if (arg7) if ((lparg7 = env->GetCharArrayElements(arg7, NULL)) == NULL) goto fail;
+	if (arg8) if ((lparg8 = env->GetCharArrayElements(arg8, NULL)) == NULL) goto fail;
+	if (arg9) if ((lparg9 = env->GetCharArrayElements(arg9, NULL)) == NULL) goto fail;
+	if (arg10) if ((lparg10 = env->GetIntArrayElements(arg10, NULL)) == NULL) goto fail;
+	if (arg11) if ((lparg11 = env->GetIntArrayElements(arg11, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jint, jchar *, jchar *, jint, jchar *, jchar *, jchar *, jchar *, jint *, jint *))(*(jint **)arg1)[arg0])(arg1, arg2, lparg3, lparg4, arg5, lparg6, lparg7, lparg8, lparg9, lparg10, lparg11);
+fail:
+	if (arg11 && lparg11) env->ReleaseIntArrayElements(arg11, lparg11, 0);
+	if (arg10 && lparg10) env->ReleaseIntArrayElements(arg10, lparg10, 0);
+	if (arg9 && lparg9) env->ReleaseCharArrayElements(arg9, lparg9, 0);
+	if (arg8 && lparg8) env->ReleaseCharArrayElements(arg8, lparg8, 0);
+	if (arg7 && lparg7) env->ReleaseCharArrayElements(arg7, lparg7, 0);
+	if (arg6 && lparg6) env->ReleaseCharArrayElements(arg6, lparg6, 0);
+	if (arg4 && lparg4) env->ReleaseCharArrayElements(arg4, lparg4, 0);
+	if (arg3 && lparg3) env->ReleaseCharArrayElements(arg3, lparg3, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__III_3C_3CI_3C_3C_3C_3C_3I_3I_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__III_3C_3CI_3I_3I_3I
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__III_3C_3CI_3I_3I_3I)(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jcharArray arg3, jcharArray arg4, jint arg5, jintArray arg6, jintArray arg7, jintArray arg8);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__III_3C_3CI_3I_3I_3I)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jcharArray arg3, jcharArray arg4, jint arg5, jintArray arg6, jintArray arg7, jintArray arg8)
+{
+	jchar *lparg3=NULL;
+	jchar *lparg4=NULL;
+	jint *lparg6=NULL;
+	jint *lparg7=NULL;
+	jint *lparg8=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__III_3C_3CI_3I_3I_3I_FUNC);
+	if (arg3) if ((lparg3 = env->GetCharArrayElements(arg3, NULL)) == NULL) goto fail;
+	if (arg4) if ((lparg4 = env->GetCharArrayElements(arg4, NULL)) == NULL) goto fail;
+	if (arg6) if ((lparg6 = env->GetIntArrayElements(arg6, NULL)) == NULL) goto fail;
+	if (arg7) if ((lparg7 = env->GetIntArrayElements(arg7, NULL)) == NULL) goto fail;
+	if (arg8) if ((lparg8 = env->GetIntArrayElements(arg8, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jint, jchar *, jchar *, jint, jint *, jint *, jint *))(*(jint **)arg1)[arg0])(arg1, arg2, lparg3, lparg4, arg5, lparg6, lparg7, lparg8);
+fail:
+	if (arg8 && lparg8) env->ReleaseIntArrayElements(arg8, lparg8, 0);
+	if (arg7 && lparg7) env->ReleaseIntArrayElements(arg7, lparg7, 0);
+	if (arg6 && lparg6) env->ReleaseIntArrayElements(arg6, lparg6, 0);
+	if (arg4 && lparg4) env->ReleaseCharArrayElements(arg4, lparg4, 0);
+	if (arg3 && lparg3) env->ReleaseCharArrayElements(arg3, lparg3, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__III_3C_3CI_3I_3I_3I_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__III_3C_3C_3C_3I
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__III_3C_3C_3C_3I)(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jcharArray arg3, jcharArray arg4, jcharArray arg5, jintArray arg6);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__III_3C_3C_3C_3I)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jcharArray arg3, jcharArray arg4, jcharArray arg5, jintArray arg6)
+{
+	jchar *lparg3=NULL;
+	jchar *lparg4=NULL;
+	jchar *lparg5=NULL;
+	jint *lparg6=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__III_3C_3C_3C_3I_FUNC);
+	if (arg3) if ((lparg3 = env->GetCharArrayElements(arg3, NULL)) == NULL) goto fail;
+	if (arg4) if ((lparg4 = env->GetCharArrayElements(arg4, NULL)) == NULL) goto fail;
+	if (arg5) if ((lparg5 = env->GetCharArrayElements(arg5, NULL)) == NULL) goto fail;
+	if (arg6) if ((lparg6 = env->GetIntArrayElements(arg6, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jint, jchar *, jchar *, jchar *, jint *))(*(jint **)arg1)[arg0])(arg1, arg2, lparg3, lparg4, lparg5, lparg6);
+fail:
+	if (arg6 && lparg6) env->ReleaseIntArrayElements(arg6, lparg6, 0);
+	if (arg5 && lparg5) env->ReleaseCharArrayElements(arg5, lparg5, 0);
+	if (arg4 && lparg4) env->ReleaseCharArrayElements(arg4, lparg4, 0);
+	if (arg3 && lparg3) env->ReleaseCharArrayElements(arg3, lparg3, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__III_3C_3C_3C_3I_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__III_3C_3C_3C_3I_3I
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__III_3C_3C_3C_3I_3I)(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jcharArray arg3, jcharArray arg4, jcharArray arg5, jintArray arg6, jintArray arg7);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__III_3C_3C_3C_3I_3I)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jcharArray arg3, jcharArray arg4, jcharArray arg5, jintArray arg6, jintArray arg7)
+{
+	jchar *lparg3=NULL;
+	jchar *lparg4=NULL;
+	jchar *lparg5=NULL;
+	jint *lparg6=NULL;
+	jint *lparg7=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__III_3C_3C_3C_3I_3I_FUNC);
+	if (arg3) if ((lparg3 = env->GetCharArrayElements(arg3, NULL)) == NULL) goto fail;
+	if (arg4) if ((lparg4 = env->GetCharArrayElements(arg4, NULL)) == NULL) goto fail;
+	if (arg5) if ((lparg5 = env->GetCharArrayElements(arg5, NULL)) == NULL) goto fail;
+	if (arg6) if ((lparg6 = env->GetIntArrayElements(arg6, NULL)) == NULL) goto fail;
+	if (arg7) if ((lparg7 = env->GetIntArrayElements(arg7, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jint, jchar *, jchar *, jchar *, jint *, jint *))(*(jint **)arg1)[arg0])(arg1, arg2, lparg3, lparg4, lparg5, lparg6, lparg7);
+fail:
+	if (arg7 && lparg7) env->ReleaseIntArrayElements(arg7, lparg7, 0);
+	if (arg6 && lparg6) env->ReleaseIntArrayElements(arg6, lparg6, 0);
+	if (arg5 && lparg5) env->ReleaseCharArrayElements(arg5, lparg5, 0);
+	if (arg4 && lparg4) env->ReleaseCharArrayElements(arg4, lparg4, 0);
+	if (arg3 && lparg3) env->ReleaseCharArrayElements(arg3, lparg3, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__III_3C_3C_3C_3I_3I_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__III_3C_3C_3I
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__III_3C_3C_3I)(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jcharArray arg3, jcharArray arg4, jintArray arg5);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__III_3C_3C_3I)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jcharArray arg3, jcharArray arg4, jintArray arg5)
+{
+	jchar *lparg3=NULL;
+	jchar *lparg4=NULL;
+	jint *lparg5=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__III_3C_3C_3I_FUNC);
+	if (arg3) if ((lparg3 = env->GetCharArrayElements(arg3, NULL)) == NULL) goto fail;
+	if (arg4) if ((lparg4 = env->GetCharArrayElements(arg4, NULL)) == NULL) goto fail;
+	if (arg5) if ((lparg5 = env->GetIntArrayElements(arg5, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jint, jchar *, jchar *, jint *))(*(jint **)arg1)[arg0])(arg1, arg2, lparg3, lparg4, lparg5);
+fail:
+	if (arg5 && lparg5) env->ReleaseIntArrayElements(arg5, lparg5, 0);
+	if (arg4 && lparg4) env->ReleaseCharArrayElements(arg4, lparg4, 0);
+	if (arg3 && lparg3) env->ReleaseCharArrayElements(arg3, lparg3, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__III_3C_3C_3I_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__III_3C_3C_3I_3C_3I_3I
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__III_3C_3C_3I_3C_3I_3I)(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jcharArray arg3, jcharArray arg4, jintArray arg5, jcharArray arg6, jintArray arg7, jintArray arg8);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__III_3C_3C_3I_3C_3I_3I)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jcharArray arg3, jcharArray arg4, jintArray arg5, jcharArray arg6, jintArray arg7, jintArray arg8)
+{
+	jchar *lparg3=NULL;
+	jchar *lparg4=NULL;
+	jint *lparg5=NULL;
+	jchar *lparg6=NULL;
+	jint *lparg7=NULL;
+	jint *lparg8=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__III_3C_3C_3I_3C_3I_3I_FUNC);
+	if (arg3) if ((lparg3 = env->GetCharArrayElements(arg3, NULL)) == NULL) goto fail;
+	if (arg4) if ((lparg4 = env->GetCharArrayElements(arg4, NULL)) == NULL) goto fail;
+	if (arg5) if ((lparg5 = env->GetIntArrayElements(arg5, NULL)) == NULL) goto fail;
+	if (arg6) if ((lparg6 = env->GetCharArrayElements(arg6, NULL)) == NULL) goto fail;
+	if (arg7) if ((lparg7 = env->GetIntArrayElements(arg7, NULL)) == NULL) goto fail;
+	if (arg8) if ((lparg8 = env->GetIntArrayElements(arg8, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jint, jchar *, jchar *, jint *, jchar *, jint *, jint *))(*(jint **)arg1)[arg0])(arg1, arg2, lparg3, lparg4, lparg5, lparg6, lparg7, lparg8);
+fail:
+	if (arg8 && lparg8) env->ReleaseIntArrayElements(arg8, lparg8, 0);
+	if (arg7 && lparg7) env->ReleaseIntArrayElements(arg7, lparg7, 0);
+	if (arg6 && lparg6) env->ReleaseCharArrayElements(arg6, lparg6, 0);
+	if (arg5 && lparg5) env->ReleaseIntArrayElements(arg5, lparg5, 0);
+	if (arg4 && lparg4) env->ReleaseCharArrayElements(arg4, lparg4, 0);
+	if (arg3 && lparg3) env->ReleaseCharArrayElements(arg3, lparg3, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__III_3C_3C_3I_3C_3I_3I_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__III_3C_3C_3I_3I_3C_3I_3I
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__III_3C_3C_3I_3I_3C_3I_3I)(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jcharArray arg3, jcharArray arg4, jintArray arg5, jintArray arg6, jcharArray arg7, jintArray arg8, jintArray arg9);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__III_3C_3C_3I_3I_3C_3I_3I)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jcharArray arg3, jcharArray arg4, jintArray arg5, jintArray arg6, jcharArray arg7, jintArray arg8, jintArray arg9)
+{
+	jchar *lparg3=NULL;
+	jchar *lparg4=NULL;
+	jint *lparg5=NULL;
+	jint *lparg6=NULL;
+	jchar *lparg7=NULL;
+	jint *lparg8=NULL;
+	jint *lparg9=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__III_3C_3C_3I_3I_3C_3I_3I_FUNC);
+	if (arg3) if ((lparg3 = env->GetCharArrayElements(arg3, NULL)) == NULL) goto fail;
+	if (arg4) if ((lparg4 = env->GetCharArrayElements(arg4, NULL)) == NULL) goto fail;
+	if (arg5) if ((lparg5 = env->GetIntArrayElements(arg5, NULL)) == NULL) goto fail;
+	if (arg6) if ((lparg6 = env->GetIntArrayElements(arg6, NULL)) == NULL) goto fail;
+	if (arg7) if ((lparg7 = env->GetCharArrayElements(arg7, NULL)) == NULL) goto fail;
+	if (arg8) if ((lparg8 = env->GetIntArrayElements(arg8, NULL)) == NULL) goto fail;
+	if (arg9) if ((lparg9 = env->GetIntArrayElements(arg9, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jint, jchar *, jchar *, jint *, jint *, jchar *, jint *, jint *))(*(jint **)arg1)[arg0])(arg1, arg2, lparg3, lparg4, lparg5, lparg6, lparg7, lparg8, lparg9);
+fail:
+	if (arg9 && lparg9) env->ReleaseIntArrayElements(arg9, lparg9, 0);
+	if (arg8 && lparg8) env->ReleaseIntArrayElements(arg8, lparg8, 0);
+	if (arg7 && lparg7) env->ReleaseCharArrayElements(arg7, lparg7, 0);
+	if (arg6 && lparg6) env->ReleaseIntArrayElements(arg6, lparg6, 0);
+	if (arg5 && lparg5) env->ReleaseIntArrayElements(arg5, lparg5, 0);
+	if (arg4 && lparg4) env->ReleaseCharArrayElements(arg4, lparg4, 0);
+	if (arg3 && lparg3) env->ReleaseCharArrayElements(arg3, lparg3, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__III_3C_3C_3I_3I_3C_3I_3I_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__III_3I
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__III_3I)(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jintArray arg3);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__III_3I)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jintArray arg3)
+{
+	jint *lparg3=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__III_3I_FUNC);
+	if (arg3) if ((lparg3 = env->GetIntArrayElements(arg3, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jint, jint *))(*(jint **)arg1)[arg0])(arg1, arg2, lparg3);
+fail:
+	if (arg3 && lparg3) env->ReleaseIntArrayElements(arg3, lparg3, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__III_3I_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__III_3I_3I_3I_3I
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__III_3I_3I_3I_3I)(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jintArray arg3, jintArray arg4, jintArray arg5, jintArray arg6);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__III_3I_3I_3I_3I)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2, jintArray arg3, jintArray arg4, jintArray arg5, jintArray arg6)
+{
+	jint *lparg3=NULL;
+	jint *lparg4=NULL;
+	jint *lparg5=NULL;
+	jint *lparg6=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__III_3I_3I_3I_3I_FUNC);
+	if (arg3) if ((lparg3 = env->GetIntArrayElements(arg3, NULL)) == NULL) goto fail;
+	if (arg4) if ((lparg4 = env->GetIntArrayElements(arg4, NULL)) == NULL) goto fail;
+	if (arg5) if ((lparg5 = env->GetIntArrayElements(arg5, NULL)) == NULL) goto fail;
+	if (arg6) if ((lparg6 = env->GetIntArrayElements(arg6, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jint, jint *, jint *, jint *, jint *))(*(jint **)arg1)[arg0])(arg1, arg2, lparg3, lparg4, lparg5, lparg6);
+fail:
+	if (arg6 && lparg6) env->ReleaseIntArrayElements(arg6, lparg6, 0);
+	if (arg5 && lparg5) env->ReleaseIntArrayElements(arg5, lparg5, 0);
+	if (arg4 && lparg4) env->ReleaseIntArrayElements(arg4, lparg4, 0);
+	if (arg3 && lparg3) env->ReleaseIntArrayElements(arg3, lparg3, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__III_3I_3I_3I_3I_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__IIJ
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIJ)(JNIEnv *env, jclass that, jint arg0, jint arg1, jlong arg2);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIJ)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jlong arg2)
+{
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__IIJ_FUNC);
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jlong))(*(jint **)arg1)[arg0])(arg1, arg2);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__IIJ_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__IIJI
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIJI)(JNIEnv *env, jclass that, jint arg0, jint arg1, jlong arg2, jint arg3);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIJI)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jlong arg2, jint arg3)
+{
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__IIJI_FUNC);
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jlong, jint))(*(jint **)arg1)[arg0])(arg1, arg2, arg3);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__IIJI_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__IIJIIJIIIIII
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIJIIJIIIIII)(JNIEnv *env, jclass that, jint arg0, jint arg1, jlong arg2, jint arg3, jint arg4, jlong arg5, jint arg6, jint arg7, jint arg8, jint arg9, jint arg10, jint arg11);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIJIIJIIIIII)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jlong arg2, jint arg3, jint arg4, jlong arg5, jint arg6, jint arg7, jint arg8, jint arg9, jint arg10, jint arg11)
+{
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__IIJIIJIIIIII_FUNC);
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jlong, jint, jint, jlong, jint, jint, jint, jint, jint, jint))(*(jint **)arg1)[arg0])(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__IIJIIJIIIIII_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__IIJIIJIIIIIIIIISJ
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIJIIJIIIIIIIIISJ)(JNIEnv *env, jclass that, jint arg0, jint arg1, jlong arg2, jint arg3, jint arg4, jlong arg5, jint arg6, jint arg7, jint arg8, jint arg9, jint arg10, jint arg11, jint arg12, jint arg13, jint arg14, jshort arg15, jlong arg16);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIJIIJIIIIIIIIISJ)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jlong arg2, jint arg3, jint arg4, jlong arg5, jint arg6, jint arg7, jint arg8, jint arg9, jint arg10, jint arg11, jint arg12, jint arg13, jint arg14, jshort arg15, jlong arg16)
+{
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__IIJIIJIIIIIIIIISJ_FUNC);
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jlong, jint, jint, jlong, jint, jint, jint, jint, jint, jint, jint, jint, jint, jshort, jlong))(*(jint **)arg1)[arg0])(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15, arg16);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__IIJIIJIIIIIIIIISJ_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__IIJIIJ_3I_3J
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIJIIJ_3I_3J)(JNIEnv *env, jclass that, jint arg0, jint arg1, jlong arg2, jint arg3, jint arg4, jlong arg5, jintArray arg6, jlongArray arg7);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIJIIJ_3I_3J)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jlong arg2, jint arg3, jint arg4, jlong arg5, jintArray arg6, jlongArray arg7)
+{
+	jint *lparg6=NULL;
+	jlong *lparg7=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__IIJIIJ_3I_3J_FUNC);
+	if (arg6) if ((lparg6 = env->GetIntArrayElements(arg6, NULL)) == NULL) goto fail;
+	if (arg7) if ((lparg7 = env->GetLongArrayElements(arg7, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jlong, jint, jint, jlong, jint *, jlong *))(*(jint **)arg1)[arg0])(arg1, arg2, arg3, arg4, arg5, lparg6, lparg7);
+fail:
+	if (arg7 && lparg7) env->ReleaseLongArrayElements(arg7, lparg7, 0);
+	if (arg6 && lparg6) env->ReleaseIntArrayElements(arg6, lparg6, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__IIJIIJ_3I_3J_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__IIJI_3J
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIJI_3J)(JNIEnv *env, jclass that, jint arg0, jint arg1, jlong arg2, jint arg3, jlongArray arg4);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIJI_3J)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jlong arg2, jint arg3, jlongArray arg4)
+{
+	jlong *lparg4=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__IIJI_3J_FUNC);
+	if (arg4) if ((lparg4 = env->GetLongArrayElements(arg4, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jlong, jint, jlong *))(*(jint **)arg1)[arg0])(arg1, arg2, arg3, lparg4);
+fail:
+	if (arg4 && lparg4) env->ReleaseLongArrayElements(arg4, lparg4, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__IIJI_3J_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__IIJJ
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIJJ)(JNIEnv *env, jclass that, jint arg0, jint arg1, jlong arg2, jlong arg3);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIJJ)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jlong arg2, jlong arg3)
+{
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__IIJJ_FUNC);
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jlong, jlong))(*(jint **)arg1)[arg0])(arg1, arg2, arg3);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__IIJJ_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__IIJJI
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIJJI)(JNIEnv *env, jclass that, jint arg0, jint arg1, jlong arg2, jlong arg3, jint arg4);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIJJI)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jlong arg2, jlong arg3, jint arg4)
+{
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__IIJJI_FUNC);
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jlong, jlong, jint))(*(jint **)arg1)[arg0])(arg1, arg2, arg3, arg4);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__IIJJI_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__IIJJII
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIJJII)(JNIEnv *env, jclass that, jint arg0, jint arg1, jlong arg2, jlong arg3, jint arg4, jint arg5);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIJJII)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jlong arg2, jlong arg3, jint arg4, jint arg5)
+{
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__IIJJII_FUNC);
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jlong, jlong, jint, jint))(*(jint **)arg1)[arg0])(arg1, arg2, arg3, arg4, arg5);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__IIJJII_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__IIJJIIII
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIJJIIII)(JNIEnv *env, jclass that, jint arg0, jint arg1, jlong arg2, jlong arg3, jint arg4, jint arg5, jint arg6, jint arg7);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIJJIIII)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jlong arg2, jlong arg3, jint arg4, jint arg5, jint arg6, jint arg7)
+{
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__IIJJIIII_FUNC);
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jlong, jlong, jint, jint, jint, jint))(*(jint **)arg1)[arg0])(arg1, arg2, arg3, arg4, arg5, arg6, arg7);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__IIJJIIII_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__IIJJIJ_3C_3I_3I
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIJJIJ_3C_3I_3I)(JNIEnv *env, jclass that, jint arg0, jint arg1, jlong arg2, jlong arg3, jint arg4, jlong arg5, jcharArray arg6, jintArray arg7, jintArray arg8);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIJJIJ_3C_3I_3I)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jlong arg2, jlong arg3, jint arg4, jlong arg5, jcharArray arg6, jintArray arg7, jintArray arg8)
+{
+	jchar *lparg6=NULL;
+	jint *lparg7=NULL;
+	jint *lparg8=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__IIJJIJ_3C_3I_3I_FUNC);
+	if (arg6) if ((lparg6 = env->GetCharArrayElements(arg6, NULL)) == NULL) goto fail;
+	if (arg7) if ((lparg7 = env->GetIntArrayElements(arg7, NULL)) == NULL) goto fail;
+	if (arg8) if ((lparg8 = env->GetIntArrayElements(arg8, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jlong, jlong, jint, jlong, jchar *, jint *, jint *))(*(jint **)arg1)[arg0])(arg1, arg2, arg3, arg4, arg5, lparg6, lparg7, lparg8);
+fail:
+	if (arg8 && lparg8) env->ReleaseIntArrayElements(arg8, lparg8, 0);
+	if (arg7 && lparg7) env->ReleaseIntArrayElements(arg7, lparg7, 0);
+	if (arg6 && lparg6) env->ReleaseCharArrayElements(arg6, lparg6, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__IIJJIJ_3C_3I_3I_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__IIJJI_3C
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIJJI_3C)(JNIEnv *env, jclass that, jint arg0, jint arg1, jlong arg2, jlong arg3, jint arg4, jcharArray arg5);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIJJI_3C)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jlong arg2, jlong arg3, jint arg4, jcharArray arg5)
+{
+	jchar *lparg5=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__IIJJI_3C_FUNC);
+	if (arg5) if ((lparg5 = env->GetCharArrayElements(arg5, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jlong, jlong, jint, jchar *))(*(jint **)arg1)[arg0])(arg1, arg2, arg3, arg4, lparg5);
+fail:
+	if (arg5 && lparg5) env->ReleaseCharArrayElements(arg5, lparg5, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__IIJJI_3C_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__IIJJI_3I
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIJJI_3I)(JNIEnv *env, jclass that, jint arg0, jint arg1, jlong arg2, jlong arg3, jint arg4, jintArray arg5);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIJJI_3I)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jlong arg2, jlong arg3, jint arg4, jintArray arg5)
+{
+	jint *lparg5=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__IIJJI_3I_FUNC);
+	if (arg5) if ((lparg5 = env->GetIntArrayElements(arg5, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jlong, jlong, jint, jint *))(*(jint **)arg1)[arg0])(arg1, arg2, arg3, arg4, lparg5);
+fail:
+	if (arg5 && lparg5) env->ReleaseIntArrayElements(arg5, lparg5, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__IIJJI_3I_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__IIJJJ
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIJJJ)(JNIEnv *env, jclass that, jint arg0, jint arg1, jlong arg2, jlong arg3, jlong arg4);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIJJJ)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jlong arg2, jlong arg3, jlong arg4)
+{
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__IIJJJ_FUNC);
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jlong, jlong, jlong))(*(jint **)arg1)[arg0])(arg1, arg2, arg3, arg4);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__IIJJJ_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__IIJJJI
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIJJJI)(JNIEnv *env, jclass that, jint arg0, jint arg1, jlong arg2, jlong arg3, jlong arg4, jint arg5);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIJJJI)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jlong arg2, jlong arg3, jlong arg4, jint arg5)
+{
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__IIJJJI_FUNC);
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jlong, jlong, jlong, jint))(*(jint **)arg1)[arg0])(arg1, arg2, arg3, arg4, arg5);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__IIJJJI_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__IIJJJI_3CJJIJI_3J_3J
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIJJJI_3CJJIJI_3J_3J)(JNIEnv *env, jclass that, jint arg0, jint arg1, jlong arg2, jlong arg3, jlong arg4, jint arg5, jcharArray arg6, jlong arg7, jlong arg8, jint arg9, jlong arg10, jint arg11, jlongArray arg12, jlongArray arg13);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIJJJI_3CJJIJI_3J_3J)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jlong arg2, jlong arg3, jlong arg4, jint arg5, jcharArray arg6, jlong arg7, jlong arg8, jint arg9, jlong arg10, jint arg11, jlongArray arg12, jlongArray arg13)
+{
+	jchar *lparg6=NULL;
+	jlong *lparg12=NULL;
+	jlong *lparg13=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__IIJJJI_3CJJIJI_3J_3J_FUNC);
+	if (arg6) if ((lparg6 = env->GetCharArrayElements(arg6, NULL)) == NULL) goto fail;
+	if (arg12) if ((lparg12 = env->GetLongArrayElements(arg12, NULL)) == NULL) goto fail;
+	if (arg13) if ((lparg13 = env->GetLongArrayElements(arg13, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jlong, jlong, jlong, jint, jchar *, jlong, jlong, jint, jlong, jint, jlong *, jlong *))(*(jint **)arg1)[arg0])(arg1, arg2, arg3, arg4, arg5, lparg6, arg7, arg8, arg9, arg10, arg11, lparg12, lparg13);
+fail:
+	if (arg13 && lparg13) env->ReleaseLongArrayElements(arg13, lparg13, 0);
+	if (arg12 && lparg12) env->ReleaseLongArrayElements(arg12, lparg12, 0);
+	if (arg6 && lparg6) env->ReleaseCharArrayElements(arg6, lparg6, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__IIJJJI_3CJJIJI_3J_3J_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__IIJJJI_3C_3BJJIJI_3J_3J
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIJJJI_3C_3BJJIJI_3J_3J)(JNIEnv *env, jclass that, jint arg0, jint arg1, jlong arg2, jlong arg3, jlong arg4, jint arg5, jcharArray arg6, jbyteArray arg7, jlong arg8, jlong arg9, jint arg10, jlong arg11, jint arg12, jlongArray arg13, jlongArray arg14);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIJJJI_3C_3BJJIJI_3J_3J)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jlong arg2, jlong arg3, jlong arg4, jint arg5, jcharArray arg6, jbyteArray arg7, jlong arg8, jlong arg9, jint arg10, jlong arg11, jint arg12, jlongArray arg13, jlongArray arg14)
+{
+	jchar *lparg6=NULL;
+	jbyte *lparg7=NULL;
+	jlong *lparg13=NULL;
+	jlong *lparg14=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__IIJJJI_3C_3BJJIJI_3J_3J_FUNC);
+	if (arg6) if ((lparg6 = env->GetCharArrayElements(arg6, NULL)) == NULL) goto fail;
+	if (arg7) if ((lparg7 = env->GetByteArrayElements(arg7, NULL)) == NULL) goto fail;
+	if (arg13) if ((lparg13 = env->GetLongArrayElements(arg13, NULL)) == NULL) goto fail;
+	if (arg14) if ((lparg14 = env->GetLongArrayElements(arg14, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jlong, jlong, jlong, jint, jchar *, jbyte *, jlong, jlong, jint, jlong, jint, jlong *, jlong *))(*(jint **)arg1)[arg0])(arg1, arg2, arg3, arg4, arg5, lparg6, lparg7, arg8, arg9, arg10, arg11, arg12, lparg13, lparg14);
+fail:
+	if (arg14 && lparg14) env->ReleaseLongArrayElements(arg14, lparg14, 0);
+	if (arg13 && lparg13) env->ReleaseLongArrayElements(arg13, lparg13, 0);
+	if (arg7 && lparg7) env->ReleaseByteArrayElements(arg7, lparg7, 0);
+	if (arg6 && lparg6) env->ReleaseCharArrayElements(arg6, lparg6, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__IIJJJI_3C_3BJJIJI_3J_3J_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__IIJJJJIJ_3C_3I_3J
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIJJJJIJ_3C_3I_3J)(JNIEnv *env, jclass that, jint arg0, jint arg1, jlong arg2, jlong arg3, jlong arg4, jlong arg5, jint arg6, jlong arg7, jcharArray arg8, jintArray arg9, jlongArray arg10);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIJJJJIJ_3C_3I_3J)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jlong arg2, jlong arg3, jlong arg4, jlong arg5, jint arg6, jlong arg7, jcharArray arg8, jintArray arg9, jlongArray arg10)
+{
+	jchar *lparg8=NULL;
+	jint *lparg9=NULL;
+	jlong *lparg10=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__IIJJJJIJ_3C_3I_3J_FUNC);
+	if (arg8) if ((lparg8 = env->GetCharArrayElements(arg8, NULL)) == NULL) goto fail;
+	if (arg9) if ((lparg9 = env->GetIntArrayElements(arg9, NULL)) == NULL) goto fail;
+	if (arg10) if ((lparg10 = env->GetLongArrayElements(arg10, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jlong, jlong, jlong, jlong, jint, jlong, jchar *, jint *, jlong *))(*(jint **)arg1)[arg0])(arg1, arg2, arg3, arg4, arg5, arg6, arg7, lparg8, lparg9, lparg10);
+fail:
+	if (arg10 && lparg10) env->ReleaseLongArrayElements(arg10, lparg10, 0);
+	if (arg9 && lparg9) env->ReleaseIntArrayElements(arg9, lparg9, 0);
+	if (arg8 && lparg8) env->ReleaseCharArrayElements(arg8, lparg8, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__IIJJJJIJ_3C_3I_3J_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__IIJJJJJ
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIJJJJJ)(JNIEnv *env, jclass that, jint arg0, jint arg1, jlong arg2, jlong arg3, jlong arg4, jlong arg5, jlong arg6);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIJJJJJ)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jlong arg2, jlong arg3, jlong arg4, jlong arg5, jlong arg6)
+{
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__IIJJJJJ_FUNC);
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jlong, jlong, jlong, jlong, jlong))(*(jint **)arg1)[arg0])(arg1, arg2, arg3, arg4, arg5, arg6);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__IIJJJJJ_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__IIJJJJJJ
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIJJJJJJ)(JNIEnv *env, jclass that, jint arg0, jint arg1, jlong arg2, jlong arg3, jlong arg4, jlong arg5, jlong arg6, jlong arg7);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIJJJJJJ)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jlong arg2, jlong arg3, jlong arg4, jlong arg5, jlong arg6, jlong arg7)
+{
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__IIJJJJJJ_FUNC);
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jlong, jlong, jlong, jlong, jlong, jlong))(*(jint **)arg1)[arg0])(arg1, arg2, arg3, arg4, arg5, arg6, arg7);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__IIJJJJJJ_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__IIJJJJJJJ
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIJJJJJJJ)(JNIEnv *env, jclass that, jint arg0, jint arg1, jlong arg2, jlong arg3, jlong arg4, jlong arg5, jlong arg6, jlong arg7, jlong arg8);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIJJJJJJJ)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jlong arg2, jlong arg3, jlong arg4, jlong arg5, jlong arg6, jlong arg7, jlong arg8)
+{
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__IIJJJJJJJ_FUNC);
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jlong, jlong, jlong, jlong, jlong, jlong, jlong))(*(jint **)arg1)[arg0])(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__IIJJJJJJJ_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__IIJJ_3B
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIJJ_3B)(JNIEnv *env, jclass that, jint arg0, jint arg1, jlong arg2, jlong arg3, jbyteArray arg4);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIJJ_3B)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jlong arg2, jlong arg3, jbyteArray arg4)
+{
+	jbyte *lparg4=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__IIJJ_3B_FUNC);
+	if (arg4) if ((lparg4 = env->GetByteArrayElements(arg4, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jlong, jlong, jbyte *))(*(jint **)arg1)[arg0])(arg1, arg2, arg3, lparg4);
+fail:
+	if (arg4 && lparg4) env->ReleaseByteArrayElements(arg4, lparg4, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__IIJJ_3B_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__IIJJ_3CIJI
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIJJ_3CIJI)(JNIEnv *env, jclass that, jint arg0, jint arg1, jlong arg2, jlong arg3, jcharArray arg4, jint arg5, jlong arg6, jint arg7);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIJJ_3CIJI)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jlong arg2, jlong arg3, jcharArray arg4, jint arg5, jlong arg6, jint arg7)
+{
+	jchar *lparg4=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__IIJJ_3CIJI_FUNC);
+	if (arg4) if ((lparg4 = env->GetCharArrayElements(arg4, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jlong, jlong, jchar *, jint, jlong, jint))(*(jint **)arg1)[arg0])(arg1, arg2, arg3, lparg4, arg5, arg6, arg7);
+fail:
+	if (arg4 && lparg4) env->ReleaseCharArrayElements(arg4, lparg4, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__IIJJ_3CIJI_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__IIJJ_3CJJJ
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIJJ_3CJJJ)(JNIEnv *env, jclass that, jint arg0, jint arg1, jlong arg2, jlong arg3, jcharArray arg4, jlong arg5, jlong arg6, jlong arg7);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIJJ_3CJJJ)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jlong arg2, jlong arg3, jcharArray arg4, jlong arg5, jlong arg6, jlong arg7)
+{
+	jchar *lparg4=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__IIJJ_3CJJJ_FUNC);
+	if (arg4) if ((lparg4 = env->GetCharArrayElements(arg4, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jlong, jlong, jchar *, jlong, jlong, jlong))(*(jint **)arg1)[arg0])(arg1, arg2, arg3, lparg4, arg5, arg6, arg7);
+fail:
+	if (arg4 && lparg4) env->ReleaseCharArrayElements(arg4, lparg4, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__IIJJ_3CJJJ_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__IIJJ_3C_3CI_3J
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIJJ_3C_3CI_3J)(JNIEnv *env, jclass that, jint arg0, jint arg1, jlong arg2, jlong arg3, jcharArray arg4, jcharArray arg5, jint arg6, jlongArray arg7);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIJJ_3C_3CI_3J)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jlong arg2, jlong arg3, jcharArray arg4, jcharArray arg5, jint arg6, jlongArray arg7)
+{
+	jchar *lparg4=NULL;
+	jchar *lparg5=NULL;
+	jlong *lparg7=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__IIJJ_3C_3CI_3J_FUNC);
+	if (arg4) if ((lparg4 = env->GetCharArrayElements(arg4, NULL)) == NULL) goto fail;
+	if (arg5) if ((lparg5 = env->GetCharArrayElements(arg5, NULL)) == NULL) goto fail;
+	if (arg7) if ((lparg7 = env->GetLongArrayElements(arg7, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jlong, jlong, jchar *, jchar *, jint, jlong *))(*(jint **)arg1)[arg0])(arg1, arg2, arg3, lparg4, lparg5, arg6, lparg7);
+fail:
+	if (arg7 && lparg7) env->ReleaseLongArrayElements(arg7, lparg7, 0);
+	if (arg5 && lparg5) env->ReleaseCharArrayElements(arg5, lparg5, 0);
+	if (arg4 && lparg4) env->ReleaseCharArrayElements(arg4, lparg4, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__IIJJ_3C_3CI_3J_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__IIJJ_3I
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIJJ_3I)(JNIEnv *env, jclass that, jint arg0, jint arg1, jlong arg2, jlong arg3, jintArray arg4);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIJJ_3I)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jlong arg2, jlong arg3, jintArray arg4)
+{
+	jint *lparg4=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__IIJJ_3I_FUNC);
+	if (arg4) if ((lparg4 = env->GetIntArrayElements(arg4, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jlong, jlong, jint *))(*(jint **)arg1)[arg0])(arg1, arg2, arg3, lparg4);
+fail:
+	if (arg4 && lparg4) env->ReleaseIntArrayElements(arg4, lparg4, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__IIJJ_3I_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__IIJLorg_eclipse_swt_internal_mozilla_nsID_2
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIJLorg_eclipse_swt_internal_mozilla_nsID_2)(JNIEnv *env, jclass that, jint arg0, jint arg1, jlong arg2, jobject arg3);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIJLorg_eclipse_swt_internal_mozilla_nsID_2)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jlong arg2, jobject arg3)
+{
+	nsID _arg3, *lparg3=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__IIJLorg_eclipse_swt_internal_mozilla_nsID_2_FUNC);
+	if (arg3) if ((lparg3 = getnsIDFields(env, arg3, &_arg3)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jlong, nsID *))(*(jint **)arg1)[arg0])(arg1, arg2, lparg3);
+fail:
+	if (arg3 && lparg3) setnsIDFields(env, arg3, lparg3);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__IIJLorg_eclipse_swt_internal_mozilla_nsID_2_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__IIJLorg_eclipse_swt_internal_mozilla_nsID_2_3J
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIJLorg_eclipse_swt_internal_mozilla_nsID_2_3J)(JNIEnv *env, jclass that, jint arg0, jint arg1, jlong arg2, jobject arg3, jlongArray arg4);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIJLorg_eclipse_swt_internal_mozilla_nsID_2_3J)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jlong arg2, jobject arg3, jlongArray arg4)
+{
+	nsID _arg3, *lparg3=NULL;
+	jlong *lparg4=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__IIJLorg_eclipse_swt_internal_mozilla_nsID_2_3J_FUNC);
+	if (arg3) if ((lparg3 = getnsIDFields(env, arg3, &_arg3)) == NULL) goto fail;
+	if (arg4) if ((lparg4 = env->GetLongArrayElements(arg4, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jlong, nsID *, jlong *))(*(jint **)arg1)[arg0])(arg1, arg2, lparg3, lparg4);
+fail:
+	if (arg4 && lparg4) env->ReleaseLongArrayElements(arg4, lparg4, 0);
+	if (arg3 && lparg3) setnsIDFields(env, arg3, lparg3);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__IIJLorg_eclipse_swt_internal_mozilla_nsID_2_3J_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__IIJ_3B
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIJ_3B)(JNIEnv *env, jclass that, jint arg0, jint arg1, jlong arg2, jbyteArray arg3);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIJ_3B)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jlong arg2, jbyteArray arg3)
+{
+	jbyte *lparg3=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__IIJ_3B_FUNC);
+	if (arg3) if ((lparg3 = env->GetByteArrayElements(arg3, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jlong, jbyte *))(*(jint **)arg1)[arg0])(arg1, arg2, lparg3);
+fail:
+	if (arg3 && lparg3) env->ReleaseByteArrayElements(arg3, lparg3, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__IIJ_3B_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__IIJ_3BI
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIJ_3BI)(JNIEnv *env, jclass that, jint arg0, jint arg1, jlong arg2, jbyteArray arg3, jint arg4);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIJ_3BI)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jlong arg2, jbyteArray arg3, jint arg4)
+{
+	jbyte *lparg3=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__IIJ_3BI_FUNC);
+	if (arg3) if ((lparg3 = env->GetByteArrayElements(arg3, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jlong, jbyte *, jint))(*(jint **)arg1)[arg0])(arg1, arg2, lparg3, arg4);
+fail:
+	if (arg3 && lparg3) env->ReleaseByteArrayElements(arg3, lparg3, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__IIJ_3BI_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__IIJ_3BJ_3J
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIJ_3BJ_3J)(JNIEnv *env, jclass that, jint arg0, jint arg1, jlong arg2, jbyteArray arg3, jlong arg4, jlongArray arg5);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIJ_3BJ_3J)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jlong arg2, jbyteArray arg3, jlong arg4, jlongArray arg5)
+{
+	jbyte *lparg3=NULL;
+	jlong *lparg5=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__IIJ_3BJ_3J_FUNC);
+	if (arg3) if ((lparg3 = env->GetByteArrayElements(arg3, NULL)) == NULL) goto fail;
+	if (arg5) if ((lparg5 = env->GetLongArrayElements(arg5, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jlong, jbyte *, jlong, jlong *))(*(jint **)arg1)[arg0])(arg1, arg2, lparg3, arg4, lparg5);
+fail:
+	if (arg5 && lparg5) env->ReleaseLongArrayElements(arg5, lparg5, 0);
+	if (arg3 && lparg3) env->ReleaseByteArrayElements(arg3, lparg3, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__IIJ_3BJ_3J_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__IIJ_3B_3B_3BJ_3J
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIJ_3B_3B_3BJ_3J)(JNIEnv *env, jclass that, jint arg0, jint arg1, jlong arg2, jbyteArray arg3, jbyteArray arg4, jbyteArray arg5, jlong arg6, jlongArray arg7);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIJ_3B_3B_3BJ_3J)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jlong arg2, jbyteArray arg3, jbyteArray arg4, jbyteArray arg5, jlong arg6, jlongArray arg7)
+{
+	jbyte *lparg3=NULL;
+	jbyte *lparg4=NULL;
+	jbyte *lparg5=NULL;
+	jlong *lparg7=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__IIJ_3B_3B_3BJ_3J_FUNC);
+	if (arg3) if ((lparg3 = env->GetByteArrayElements(arg3, NULL)) == NULL) goto fail;
+	if (arg4) if ((lparg4 = env->GetByteArrayElements(arg4, NULL)) == NULL) goto fail;
+	if (arg5) if ((lparg5 = env->GetByteArrayElements(arg5, NULL)) == NULL) goto fail;
+	if (arg7) if ((lparg7 = env->GetLongArrayElements(arg7, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jlong, jbyte *, jbyte *, jbyte *, jlong, jlong *))(*(jint **)arg1)[arg0])(arg1, arg2, lparg3, lparg4, lparg5, arg6, lparg7);
+fail:
+	if (arg7 && lparg7) env->ReleaseLongArrayElements(arg7, lparg7, 0);
+	if (arg5 && lparg5) env->ReleaseByteArrayElements(arg5, lparg5, 0);
+	if (arg4 && lparg4) env->ReleaseByteArrayElements(arg4, lparg4, 0);
+	if (arg3 && lparg3) env->ReleaseByteArrayElements(arg3, lparg3, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__IIJ_3B_3B_3BJ_3J_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__IIJ_3B_3C
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIJ_3B_3C)(JNIEnv *env, jclass that, jint arg0, jint arg1, jlong arg2, jbyteArray arg3, jcharArray arg4);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIJ_3B_3C)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jlong arg2, jbyteArray arg3, jcharArray arg4)
+{
+	jbyte *lparg3=NULL;
+	jchar *lparg4=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__IIJ_3B_3C_FUNC);
+	if (arg3) if ((lparg3 = env->GetByteArrayElements(arg3, NULL)) == NULL) goto fail;
+	if (arg4) if ((lparg4 = env->GetCharArrayElements(arg4, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jlong, jbyte *, jchar *))(*(jint **)arg1)[arg0])(arg1, arg2, lparg3, lparg4);
+fail:
+	if (arg4 && lparg4) env->ReleaseCharArrayElements(arg4, lparg4, 0);
+	if (arg3 && lparg3) env->ReleaseByteArrayElements(arg3, lparg3, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__IIJ_3B_3C_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__IIJ_3CI
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIJ_3CI)(JNIEnv *env, jclass that, jint arg0, jint arg1, jlong arg2, jcharArray arg3, jint arg4);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIJ_3CI)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jlong arg2, jcharArray arg3, jint arg4)
+{
+	jchar *lparg3=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__IIJ_3CI_FUNC);
+	if (arg3) if ((lparg3 = env->GetCharArrayElements(arg3, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jlong, jchar *, jint))(*(jint **)arg1)[arg0])(arg1, arg2, lparg3, arg4);
+fail:
+	if (arg3 && lparg3) env->ReleaseCharArrayElements(arg3, lparg3, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__IIJ_3CI_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__IIJ_3C_3C
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIJ_3C_3C)(JNIEnv *env, jclass that, jint arg0, jint arg1, jlong arg2, jcharArray arg3, jcharArray arg4);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIJ_3C_3C)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jlong arg2, jcharArray arg3, jcharArray arg4)
+{
+	jchar *lparg3=NULL;
+	jchar *lparg4=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__IIJ_3C_3C_FUNC);
+	if (arg3) if ((lparg3 = env->GetCharArrayElements(arg3, NULL)) == NULL) goto fail;
+	if (arg4) if ((lparg4 = env->GetCharArrayElements(arg4, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jlong, jchar *, jchar *))(*(jint **)arg1)[arg0])(arg1, arg2, lparg3, lparg4);
+fail:
+	if (arg4 && lparg4) env->ReleaseCharArrayElements(arg4, lparg4, 0);
+	if (arg3 && lparg3) env->ReleaseCharArrayElements(arg3, lparg3, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__IIJ_3C_3C_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__IIJ_3C_3CI_3C_3C_3C_3C_3I_3I
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIJ_3C_3CI_3C_3C_3C_3C_3I_3I)(JNIEnv *env, jclass that, jint arg0, jint arg1, jlong arg2, jcharArray arg3, jcharArray arg4, jint arg5, jcharArray arg6, jcharArray arg7, jcharArray arg8, jcharArray arg9, jintArray arg10, jintArray arg11);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIJ_3C_3CI_3C_3C_3C_3C_3I_3I)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jlong arg2, jcharArray arg3, jcharArray arg4, jint arg5, jcharArray arg6, jcharArray arg7, jcharArray arg8, jcharArray arg9, jintArray arg10, jintArray arg11)
+{
+	jchar *lparg3=NULL;
+	jchar *lparg4=NULL;
+	jchar *lparg6=NULL;
+	jchar *lparg7=NULL;
+	jchar *lparg8=NULL;
+	jchar *lparg9=NULL;
+	jint *lparg10=NULL;
+	jint *lparg11=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__IIJ_3C_3CI_3C_3C_3C_3C_3I_3I_FUNC);
+	if (arg3) if ((lparg3 = env->GetCharArrayElements(arg3, NULL)) == NULL) goto fail;
+	if (arg4) if ((lparg4 = env->GetCharArrayElements(arg4, NULL)) == NULL) goto fail;
+	if (arg6) if ((lparg6 = env->GetCharArrayElements(arg6, NULL)) == NULL) goto fail;
+	if (arg7) if ((lparg7 = env->GetCharArrayElements(arg7, NULL)) == NULL) goto fail;
+	if (arg8) if ((lparg8 = env->GetCharArrayElements(arg8, NULL)) == NULL) goto fail;
+	if (arg9) if ((lparg9 = env->GetCharArrayElements(arg9, NULL)) == NULL) goto fail;
+	if (arg10) if ((lparg10 = env->GetIntArrayElements(arg10, NULL)) == NULL) goto fail;
+	if (arg11) if ((lparg11 = env->GetIntArrayElements(arg11, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jlong, jchar *, jchar *, jint, jchar *, jchar *, jchar *, jchar *, jint *, jint *))(*(jint **)arg1)[arg0])(arg1, arg2, lparg3, lparg4, arg5, lparg6, lparg7, lparg8, lparg9, lparg10, lparg11);
+fail:
+	if (arg11 && lparg11) env->ReleaseIntArrayElements(arg11, lparg11, 0);
+	if (arg10 && lparg10) env->ReleaseIntArrayElements(arg10, lparg10, 0);
+	if (arg9 && lparg9) env->ReleaseCharArrayElements(arg9, lparg9, 0);
+	if (arg8 && lparg8) env->ReleaseCharArrayElements(arg8, lparg8, 0);
+	if (arg7 && lparg7) env->ReleaseCharArrayElements(arg7, lparg7, 0);
+	if (arg6 && lparg6) env->ReleaseCharArrayElements(arg6, lparg6, 0);
+	if (arg4 && lparg4) env->ReleaseCharArrayElements(arg4, lparg4, 0);
+	if (arg3 && lparg3) env->ReleaseCharArrayElements(arg3, lparg3, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__IIJ_3C_3CI_3C_3C_3C_3C_3I_3I_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__IIJ_3C_3CI_3J_3I_3I
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIJ_3C_3CI_3J_3I_3I)(JNIEnv *env, jclass that, jint arg0, jint arg1, jlong arg2, jcharArray arg3, jcharArray arg4, jint arg5, jlongArray arg6, jintArray arg7, jintArray arg8);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIJ_3C_3CI_3J_3I_3I)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jlong arg2, jcharArray arg3, jcharArray arg4, jint arg5, jlongArray arg6, jintArray arg7, jintArray arg8)
+{
+	jchar *lparg3=NULL;
+	jchar *lparg4=NULL;
+	jlong *lparg6=NULL;
+	jint *lparg7=NULL;
+	jint *lparg8=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__IIJ_3C_3CI_3J_3I_3I_FUNC);
+	if (arg3) if ((lparg3 = env->GetCharArrayElements(arg3, NULL)) == NULL) goto fail;
+	if (arg4) if ((lparg4 = env->GetCharArrayElements(arg4, NULL)) == NULL) goto fail;
+	if (arg6) if ((lparg6 = env->GetLongArrayElements(arg6, NULL)) == NULL) goto fail;
+	if (arg7) if ((lparg7 = env->GetIntArrayElements(arg7, NULL)) == NULL) goto fail;
+	if (arg8) if ((lparg8 = env->GetIntArrayElements(arg8, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jlong, jchar *, jchar *, jint, jlong *, jint *, jint *))(*(jint **)arg1)[arg0])(arg1, arg2, lparg3, lparg4, arg5, lparg6, lparg7, lparg8);
+fail:
+	if (arg8 && lparg8) env->ReleaseIntArrayElements(arg8, lparg8, 0);
+	if (arg7 && lparg7) env->ReleaseIntArrayElements(arg7, lparg7, 0);
+	if (arg6 && lparg6) env->ReleaseLongArrayElements(arg6, lparg6, 0);
+	if (arg4 && lparg4) env->ReleaseCharArrayElements(arg4, lparg4, 0);
+	if (arg3 && lparg3) env->ReleaseCharArrayElements(arg3, lparg3, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__IIJ_3C_3CI_3J_3I_3I_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__IIJ_3C_3C_3C_3I
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIJ_3C_3C_3C_3I)(JNIEnv *env, jclass that, jint arg0, jint arg1, jlong arg2, jcharArray arg3, jcharArray arg4, jcharArray arg5, jintArray arg6);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIJ_3C_3C_3C_3I)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jlong arg2, jcharArray arg3, jcharArray arg4, jcharArray arg5, jintArray arg6)
+{
+	jchar *lparg3=NULL;
+	jchar *lparg4=NULL;
+	jchar *lparg5=NULL;
+	jint *lparg6=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__IIJ_3C_3C_3C_3I_FUNC);
+	if (arg3) if ((lparg3 = env->GetCharArrayElements(arg3, NULL)) == NULL) goto fail;
+	if (arg4) if ((lparg4 = env->GetCharArrayElements(arg4, NULL)) == NULL) goto fail;
+	if (arg5) if ((lparg5 = env->GetCharArrayElements(arg5, NULL)) == NULL) goto fail;
+	if (arg6) if ((lparg6 = env->GetIntArrayElements(arg6, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jlong, jchar *, jchar *, jchar *, jint *))(*(jint **)arg1)[arg0])(arg1, arg2, lparg3, lparg4, lparg5, lparg6);
+fail:
+	if (arg6 && lparg6) env->ReleaseIntArrayElements(arg6, lparg6, 0);
+	if (arg5 && lparg5) env->ReleaseCharArrayElements(arg5, lparg5, 0);
+	if (arg4 && lparg4) env->ReleaseCharArrayElements(arg4, lparg4, 0);
+	if (arg3 && lparg3) env->ReleaseCharArrayElements(arg3, lparg3, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__IIJ_3C_3C_3C_3I_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__IIJ_3C_3C_3C_3I_3I
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIJ_3C_3C_3C_3I_3I)(JNIEnv *env, jclass that, jint arg0, jint arg1, jlong arg2, jcharArray arg3, jcharArray arg4, jcharArray arg5, jintArray arg6, jintArray arg7);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIJ_3C_3C_3C_3I_3I)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jlong arg2, jcharArray arg3, jcharArray arg4, jcharArray arg5, jintArray arg6, jintArray arg7)
+{
+	jchar *lparg3=NULL;
+	jchar *lparg4=NULL;
+	jchar *lparg5=NULL;
+	jint *lparg6=NULL;
+	jint *lparg7=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__IIJ_3C_3C_3C_3I_3I_FUNC);
+	if (arg3) if ((lparg3 = env->GetCharArrayElements(arg3, NULL)) == NULL) goto fail;
+	if (arg4) if ((lparg4 = env->GetCharArrayElements(arg4, NULL)) == NULL) goto fail;
+	if (arg5) if ((lparg5 = env->GetCharArrayElements(arg5, NULL)) == NULL) goto fail;
+	if (arg6) if ((lparg6 = env->GetIntArrayElements(arg6, NULL)) == NULL) goto fail;
+	if (arg7) if ((lparg7 = env->GetIntArrayElements(arg7, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jlong, jchar *, jchar *, jchar *, jint *, jint *))(*(jint **)arg1)[arg0])(arg1, arg2, lparg3, lparg4, lparg5, lparg6, lparg7);
+fail:
+	if (arg7 && lparg7) env->ReleaseIntArrayElements(arg7, lparg7, 0);
+	if (arg6 && lparg6) env->ReleaseIntArrayElements(arg6, lparg6, 0);
+	if (arg5 && lparg5) env->ReleaseCharArrayElements(arg5, lparg5, 0);
+	if (arg4 && lparg4) env->ReleaseCharArrayElements(arg4, lparg4, 0);
+	if (arg3 && lparg3) env->ReleaseCharArrayElements(arg3, lparg3, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__IIJ_3C_3C_3C_3I_3I_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__IIJ_3C_3C_3I
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIJ_3C_3C_3I)(JNIEnv *env, jclass that, jint arg0, jint arg1, jlong arg2, jcharArray arg3, jcharArray arg4, jintArray arg5);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIJ_3C_3C_3I)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jlong arg2, jcharArray arg3, jcharArray arg4, jintArray arg5)
+{
+	jchar *lparg3=NULL;
+	jchar *lparg4=NULL;
+	jint *lparg5=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__IIJ_3C_3C_3I_FUNC);
+	if (arg3) if ((lparg3 = env->GetCharArrayElements(arg3, NULL)) == NULL) goto fail;
+	if (arg4) if ((lparg4 = env->GetCharArrayElements(arg4, NULL)) == NULL) goto fail;
+	if (arg5) if ((lparg5 = env->GetIntArrayElements(arg5, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jlong, jchar *, jchar *, jint *))(*(jint **)arg1)[arg0])(arg1, arg2, lparg3, lparg4, lparg5);
+fail:
+	if (arg5 && lparg5) env->ReleaseIntArrayElements(arg5, lparg5, 0);
+	if (arg4 && lparg4) env->ReleaseCharArrayElements(arg4, lparg4, 0);
+	if (arg3 && lparg3) env->ReleaseCharArrayElements(arg3, lparg3, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__IIJ_3C_3C_3I_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__IIJ_3C_3C_3J
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIJ_3C_3C_3J)(JNIEnv *env, jclass that, jint arg0, jint arg1, jlong arg2, jcharArray arg3, jcharArray arg4, jlongArray arg5);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIJ_3C_3C_3J)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jlong arg2, jcharArray arg3, jcharArray arg4, jlongArray arg5)
+{
+	jchar *lparg3=NULL;
+	jchar *lparg4=NULL;
+	jlong *lparg5=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__IIJ_3C_3C_3J_FUNC);
+	if (arg3) if ((lparg3 = env->GetCharArrayElements(arg3, NULL)) == NULL) goto fail;
+	if (arg4) if ((lparg4 = env->GetCharArrayElements(arg4, NULL)) == NULL) goto fail;
+	if (arg5) if ((lparg5 = env->GetLongArrayElements(arg5, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jlong, jchar *, jchar *, jlong *))(*(jint **)arg1)[arg0])(arg1, arg2, lparg3, lparg4, lparg5);
+fail:
+	if (arg5 && lparg5) env->ReleaseLongArrayElements(arg5, lparg5, 0);
+	if (arg4 && lparg4) env->ReleaseCharArrayElements(arg4, lparg4, 0);
+	if (arg3 && lparg3) env->ReleaseCharArrayElements(arg3, lparg3, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__IIJ_3C_3C_3J_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__IIJ_3C_3C_3J_3C_3I_3I
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIJ_3C_3C_3J_3C_3I_3I)(JNIEnv *env, jclass that, jint arg0, jint arg1, jlong arg2, jcharArray arg3, jcharArray arg4, jlongArray arg5, jcharArray arg6, jintArray arg7, jintArray arg8);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIJ_3C_3C_3J_3C_3I_3I)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jlong arg2, jcharArray arg3, jcharArray arg4, jlongArray arg5, jcharArray arg6, jintArray arg7, jintArray arg8)
+{
+	jchar *lparg3=NULL;
+	jchar *lparg4=NULL;
+	jlong *lparg5=NULL;
+	jchar *lparg6=NULL;
+	jint *lparg7=NULL;
+	jint *lparg8=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__IIJ_3C_3C_3J_3C_3I_3I_FUNC);
+	if (arg3) if ((lparg3 = env->GetCharArrayElements(arg3, NULL)) == NULL) goto fail;
+	if (arg4) if ((lparg4 = env->GetCharArrayElements(arg4, NULL)) == NULL) goto fail;
+	if (arg5) if ((lparg5 = env->GetLongArrayElements(arg5, NULL)) == NULL) goto fail;
+	if (arg6) if ((lparg6 = env->GetCharArrayElements(arg6, NULL)) == NULL) goto fail;
+	if (arg7) if ((lparg7 = env->GetIntArrayElements(arg7, NULL)) == NULL) goto fail;
+	if (arg8) if ((lparg8 = env->GetIntArrayElements(arg8, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jlong, jchar *, jchar *, jlong *, jchar *, jint *, jint *))(*(jint **)arg1)[arg0])(arg1, arg2, lparg3, lparg4, lparg5, lparg6, lparg7, lparg8);
+fail:
+	if (arg8 && lparg8) env->ReleaseIntArrayElements(arg8, lparg8, 0);
+	if (arg7 && lparg7) env->ReleaseIntArrayElements(arg7, lparg7, 0);
+	if (arg6 && lparg6) env->ReleaseCharArrayElements(arg6, lparg6, 0);
+	if (arg5 && lparg5) env->ReleaseLongArrayElements(arg5, lparg5, 0);
+	if (arg4 && lparg4) env->ReleaseCharArrayElements(arg4, lparg4, 0);
+	if (arg3 && lparg3) env->ReleaseCharArrayElements(arg3, lparg3, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__IIJ_3C_3C_3J_3C_3I_3I_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__IIJ_3C_3C_3J_3J_3C_3I_3I
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIJ_3C_3C_3J_3J_3C_3I_3I)(JNIEnv *env, jclass that, jint arg0, jint arg1, jlong arg2, jcharArray arg3, jcharArray arg4, jlongArray arg5, jlongArray arg6, jcharArray arg7, jintArray arg8, jintArray arg9);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIJ_3C_3C_3J_3J_3C_3I_3I)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jlong arg2, jcharArray arg3, jcharArray arg4, jlongArray arg5, jlongArray arg6, jcharArray arg7, jintArray arg8, jintArray arg9)
+{
+	jchar *lparg3=NULL;
+	jchar *lparg4=NULL;
+	jlong *lparg5=NULL;
+	jlong *lparg6=NULL;
+	jchar *lparg7=NULL;
+	jint *lparg8=NULL;
+	jint *lparg9=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__IIJ_3C_3C_3J_3J_3C_3I_3I_FUNC);
+	if (arg3) if ((lparg3 = env->GetCharArrayElements(arg3, NULL)) == NULL) goto fail;
+	if (arg4) if ((lparg4 = env->GetCharArrayElements(arg4, NULL)) == NULL) goto fail;
+	if (arg5) if ((lparg5 = env->GetLongArrayElements(arg5, NULL)) == NULL) goto fail;
+	if (arg6) if ((lparg6 = env->GetLongArrayElements(arg6, NULL)) == NULL) goto fail;
+	if (arg7) if ((lparg7 = env->GetCharArrayElements(arg7, NULL)) == NULL) goto fail;
+	if (arg8) if ((lparg8 = env->GetIntArrayElements(arg8, NULL)) == NULL) goto fail;
+	if (arg9) if ((lparg9 = env->GetIntArrayElements(arg9, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jlong, jchar *, jchar *, jlong *, jlong *, jchar *, jint *, jint *))(*(jint **)arg1)[arg0])(arg1, arg2, lparg3, lparg4, lparg5, lparg6, lparg7, lparg8, lparg9);
+fail:
+	if (arg9 && lparg9) env->ReleaseIntArrayElements(arg9, lparg9, 0);
+	if (arg8 && lparg8) env->ReleaseIntArrayElements(arg8, lparg8, 0);
+	if (arg7 && lparg7) env->ReleaseCharArrayElements(arg7, lparg7, 0);
+	if (arg6 && lparg6) env->ReleaseLongArrayElements(arg6, lparg6, 0);
+	if (arg5 && lparg5) env->ReleaseLongArrayElements(arg5, lparg5, 0);
+	if (arg4 && lparg4) env->ReleaseCharArrayElements(arg4, lparg4, 0);
+	if (arg3 && lparg3) env->ReleaseCharArrayElements(arg3, lparg3, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__IIJ_3C_3C_3J_3J_3C_3I_3I_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__IIJ_3I
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIJ_3I)(JNIEnv *env, jclass that, jint arg0, jint arg1, jlong arg2, jintArray arg3);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIJ_3I)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jlong arg2, jintArray arg3)
+{
+	jint *lparg3=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__IIJ_3I_FUNC);
+	if (arg3) if ((lparg3 = env->GetIntArrayElements(arg3, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jlong, jint *))(*(jint **)arg1)[arg0])(arg1, arg2, lparg3);
+fail:
+	if (arg3 && lparg3) env->ReleaseIntArrayElements(arg3, lparg3, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__IIJ_3I_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__IIJ_3J
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIJ_3J)(JNIEnv *env, jclass that, jint arg0, jint arg1, jlong arg2, jlongArray arg3);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IIJ_3J)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jlong arg2, jlongArray arg3)
+{
+	jlong *lparg3=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__IIJ_3J_FUNC);
+	if (arg3) if ((lparg3 = env->GetLongArrayElements(arg3, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jlong, jlong *))(*(jint **)arg1)[arg0])(arg1, arg2, lparg3);
+fail:
+	if (arg3 && lparg3) env->ReleaseLongArrayElements(arg3, lparg3, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__IIJ_3J_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__IILorg_eclipse_swt_internal_mozilla_nsID_2I
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IILorg_eclipse_swt_internal_mozilla_nsID_2I)(JNIEnv *env, jclass that, jint arg0, jint arg1, jobject arg2, jint arg3);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IILorg_eclipse_swt_internal_mozilla_nsID_2I)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jobject arg2, jint arg3)
+{
+	nsID _arg2, *lparg2=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__IILorg_eclipse_swt_internal_mozilla_nsID_2I_FUNC);
+	if (arg2) if ((lparg2 = getnsIDFields(env, arg2, &_arg2)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, nsID *, jint))(*(jint **)arg1)[arg0])(arg1, lparg2, arg3);
+fail:
+	if (arg2 && lparg2) setnsIDFields(env, arg2, lparg2);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__IILorg_eclipse_swt_internal_mozilla_nsID_2I_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__IILorg_eclipse_swt_internal_mozilla_nsID_2ILorg_eclipse_swt_internal_mozilla_nsID_2_3I
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IILorg_eclipse_swt_internal_mozilla_nsID_2ILorg_eclipse_swt_internal_mozilla_nsID_2_3I)(JNIEnv *env, jclass that, jint arg0, jint arg1, jobject arg2, jint arg3, jobject arg4, jintArray arg5);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IILorg_eclipse_swt_internal_mozilla_nsID_2ILorg_eclipse_swt_internal_mozilla_nsID_2_3I)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jobject arg2, jint arg3, jobject arg4, jintArray arg5)
+{
+	nsID _arg2, *lparg2=NULL;
+	nsID _arg4, *lparg4=NULL;
+	jint *lparg5=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__IILorg_eclipse_swt_internal_mozilla_nsID_2ILorg_eclipse_swt_internal_mozilla_nsID_2_3I_FUNC);
+	if (arg2) if ((lparg2 = getnsIDFields(env, arg2, &_arg2)) == NULL) goto fail;
+	if (arg4) if ((lparg4 = getnsIDFields(env, arg4, &_arg4)) == NULL) goto fail;
+	if (arg5) if ((lparg5 = env->GetIntArrayElements(arg5, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, nsID *, jint, nsID *, jint *))(*(jint **)arg1)[arg0])(arg1, lparg2, arg3, lparg4, lparg5);
+fail:
+	if (arg5 && lparg5) env->ReleaseIntArrayElements(arg5, lparg5, 0);
+	if (arg4 && lparg4) setnsIDFields(env, arg4, lparg4);
+	if (arg2 && lparg2) setnsIDFields(env, arg2, lparg2);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__IILorg_eclipse_swt_internal_mozilla_nsID_2ILorg_eclipse_swt_internal_mozilla_nsID_2_3I_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__IILorg_eclipse_swt_internal_mozilla_nsID_2J
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IILorg_eclipse_swt_internal_mozilla_nsID_2J)(JNIEnv *env, jclass that, jint arg0, jint arg1, jobject arg2, jlong arg3);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IILorg_eclipse_swt_internal_mozilla_nsID_2J)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jobject arg2, jlong arg3)
+{
+	nsID _arg2, *lparg2=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__IILorg_eclipse_swt_internal_mozilla_nsID_2J_FUNC);
+	if (arg2) if ((lparg2 = getnsIDFields(env, arg2, &_arg2)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, nsID *, jlong))(*(jint **)arg1)[arg0])(arg1, lparg2, arg3);
+fail:
+	if (arg2 && lparg2) setnsIDFields(env, arg2, lparg2);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__IILorg_eclipse_swt_internal_mozilla_nsID_2J_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__IILorg_eclipse_swt_internal_mozilla_nsID_2JLorg_eclipse_swt_internal_mozilla_nsID_2_3J
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IILorg_eclipse_swt_internal_mozilla_nsID_2JLorg_eclipse_swt_internal_mozilla_nsID_2_3J)(JNIEnv *env, jclass that, jint arg0, jint arg1, jobject arg2, jlong arg3, jobject arg4, jlongArray arg5);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IILorg_eclipse_swt_internal_mozilla_nsID_2JLorg_eclipse_swt_internal_mozilla_nsID_2_3J)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jobject arg2, jlong arg3, jobject arg4, jlongArray arg5)
+{
+	nsID _arg2, *lparg2=NULL;
+	nsID _arg4, *lparg4=NULL;
+	jlong *lparg5=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__IILorg_eclipse_swt_internal_mozilla_nsID_2JLorg_eclipse_swt_internal_mozilla_nsID_2_3J_FUNC);
+	if (arg2) if ((lparg2 = getnsIDFields(env, arg2, &_arg2)) == NULL) goto fail;
+	if (arg4) if ((lparg4 = getnsIDFields(env, arg4, &_arg4)) == NULL) goto fail;
+	if (arg5) if ((lparg5 = env->GetLongArrayElements(arg5, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, nsID *, jlong, nsID *, jlong *))(*(jint **)arg1)[arg0])(arg1, lparg2, arg3, lparg4, lparg5);
+fail:
+	if (arg5 && lparg5) env->ReleaseLongArrayElements(arg5, lparg5, 0);
+	if (arg4 && lparg4) setnsIDFields(env, arg4, lparg4);
+	if (arg2 && lparg2) setnsIDFields(env, arg2, lparg2);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__IILorg_eclipse_swt_internal_mozilla_nsID_2JLorg_eclipse_swt_internal_mozilla_nsID_2_3J_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__IILorg_eclipse_swt_internal_mozilla_nsID_2Lorg_eclipse_swt_internal_mozilla_nsID_2_3I
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IILorg_eclipse_swt_internal_mozilla_nsID_2Lorg_eclipse_swt_internal_mozilla_nsID_2_3I)(JNIEnv *env, jclass that, jint arg0, jint arg1, jobject arg2, jobject arg3, jintArray arg4);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IILorg_eclipse_swt_internal_mozilla_nsID_2Lorg_eclipse_swt_internal_mozilla_nsID_2_3I)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jobject arg2, jobject arg3, jintArray arg4)
+{
+	nsID _arg2, *lparg2=NULL;
+	nsID _arg3, *lparg3=NULL;
+	jint *lparg4=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__IILorg_eclipse_swt_internal_mozilla_nsID_2Lorg_eclipse_swt_internal_mozilla_nsID_2_3I_FUNC);
+	if (arg2) if ((lparg2 = getnsIDFields(env, arg2, &_arg2)) == NULL) goto fail;
+	if (arg3) if ((lparg3 = getnsIDFields(env, arg3, &_arg3)) == NULL) goto fail;
+	if (arg4) if ((lparg4 = env->GetIntArrayElements(arg4, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, nsID *, nsID *, jint *))(*(jint **)arg1)[arg0])(arg1, lparg2, lparg3, lparg4);
+fail:
+	if (arg4 && lparg4) env->ReleaseIntArrayElements(arg4, lparg4, 0);
+	if (arg3 && lparg3) setnsIDFields(env, arg3, lparg3);
+	if (arg2 && lparg2) setnsIDFields(env, arg2, lparg2);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__IILorg_eclipse_swt_internal_mozilla_nsID_2Lorg_eclipse_swt_internal_mozilla_nsID_2_3I_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__IILorg_eclipse_swt_internal_mozilla_nsID_2Lorg_eclipse_swt_internal_mozilla_nsID_2_3J
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IILorg_eclipse_swt_internal_mozilla_nsID_2Lorg_eclipse_swt_internal_mozilla_nsID_2_3J)(JNIEnv *env, jclass that, jint arg0, jint arg1, jobject arg2, jobject arg3, jlongArray arg4);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IILorg_eclipse_swt_internal_mozilla_nsID_2Lorg_eclipse_swt_internal_mozilla_nsID_2_3J)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jobject arg2, jobject arg3, jlongArray arg4)
+{
+	nsID _arg2, *lparg2=NULL;
+	nsID _arg3, *lparg3=NULL;
+	jlong *lparg4=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__IILorg_eclipse_swt_internal_mozilla_nsID_2Lorg_eclipse_swt_internal_mozilla_nsID_2_3J_FUNC);
+	if (arg2) if ((lparg2 = getnsIDFields(env, arg2, &_arg2)) == NULL) goto fail;
+	if (arg3) if ((lparg3 = getnsIDFields(env, arg3, &_arg3)) == NULL) goto fail;
+	if (arg4) if ((lparg4 = env->GetLongArrayElements(arg4, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, nsID *, nsID *, jlong *))(*(jint **)arg1)[arg0])(arg1, lparg2, lparg3, lparg4);
+fail:
+	if (arg4 && lparg4) env->ReleaseLongArrayElements(arg4, lparg4, 0);
+	if (arg3 && lparg3) setnsIDFields(env, arg3, lparg3);
+	if (arg2 && lparg2) setnsIDFields(env, arg2, lparg2);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__IILorg_eclipse_swt_internal_mozilla_nsID_2Lorg_eclipse_swt_internal_mozilla_nsID_2_3J_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__IILorg_eclipse_swt_internal_mozilla_nsID_2_3B_3BI
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IILorg_eclipse_swt_internal_mozilla_nsID_2_3B_3BI)(JNIEnv *env, jclass that, jint arg0, jint arg1, jobject arg2, jbyteArray arg3, jbyteArray arg4, jint arg5);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IILorg_eclipse_swt_internal_mozilla_nsID_2_3B_3BI)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jobject arg2, jbyteArray arg3, jbyteArray arg4, jint arg5)
+{
+	nsID _arg2, *lparg2=NULL;
+	jbyte *lparg3=NULL;
+	jbyte *lparg4=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__IILorg_eclipse_swt_internal_mozilla_nsID_2_3B_3BI_FUNC);
+	if (arg2) if ((lparg2 = getnsIDFields(env, arg2, &_arg2)) == NULL) goto fail;
+	if (arg3) if ((lparg3 = env->GetByteArrayElements(arg3, NULL)) == NULL) goto fail;
+	if (arg4) if ((lparg4 = env->GetByteArrayElements(arg4, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, nsID *, jbyte *, jbyte *, jint))(*(jint **)arg1)[arg0])(arg1, lparg2, lparg3, lparg4, arg5);
+fail:
+	if (arg4 && lparg4) env->ReleaseByteArrayElements(arg4, lparg4, 0);
+	if (arg3 && lparg3) env->ReleaseByteArrayElements(arg3, lparg3, 0);
+	if (arg2 && lparg2) setnsIDFields(env, arg2, lparg2);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__IILorg_eclipse_swt_internal_mozilla_nsID_2_3B_3BI_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__IILorg_eclipse_swt_internal_mozilla_nsID_2_3B_3BI_3B_3B
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IILorg_eclipse_swt_internal_mozilla_nsID_2_3B_3BI_3B_3B)(JNIEnv *env, jclass that, jint arg0, jint arg1, jobject arg2, jbyteArray arg3, jbyteArray arg4, jint arg5, jbyteArray arg6, jbyteArray arg7);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IILorg_eclipse_swt_internal_mozilla_nsID_2_3B_3BI_3B_3B)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jobject arg2, jbyteArray arg3, jbyteArray arg4, jint arg5, jbyteArray arg6, jbyteArray arg7)
+{
+	nsID _arg2, *lparg2=NULL;
+	jbyte *lparg3=NULL;
+	jbyte *lparg4=NULL;
+	jbyte *lparg6=NULL;
+	jbyte *lparg7=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__IILorg_eclipse_swt_internal_mozilla_nsID_2_3B_3BI_3B_3B_FUNC);
+	if (arg2) if ((lparg2 = getnsIDFields(env, arg2, &_arg2)) == NULL) goto fail;
+	if (arg3) if ((lparg3 = env->GetByteArrayElements(arg3, NULL)) == NULL) goto fail;
+	if (arg4) if ((lparg4 = env->GetByteArrayElements(arg4, NULL)) == NULL) goto fail;
+	if (arg6) if ((lparg6 = env->GetByteArrayElements(arg6, NULL)) == NULL) goto fail;
+	if (arg7) if ((lparg7 = env->GetByteArrayElements(arg7, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, nsID *, jbyte *, jbyte *, jint, jbyte *, jbyte *))(*(jint **)arg1)[arg0])(arg1, lparg2, lparg3, lparg4, arg5, lparg6, lparg7);
+fail:
+	if (arg7 && lparg7) env->ReleaseByteArrayElements(arg7, lparg7, 0);
+	if (arg6 && lparg6) env->ReleaseByteArrayElements(arg6, lparg6, 0);
+	if (arg4 && lparg4) env->ReleaseByteArrayElements(arg4, lparg4, 0);
+	if (arg3 && lparg3) env->ReleaseByteArrayElements(arg3, lparg3, 0);
+	if (arg2 && lparg2) setnsIDFields(env, arg2, lparg2);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__IILorg_eclipse_swt_internal_mozilla_nsID_2_3B_3BI_3B_3B_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__IILorg_eclipse_swt_internal_mozilla_nsID_2_3B_3BJ
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IILorg_eclipse_swt_internal_mozilla_nsID_2_3B_3BJ)(JNIEnv *env, jclass that, jint arg0, jint arg1, jobject arg2, jbyteArray arg3, jbyteArray arg4, jlong arg5);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IILorg_eclipse_swt_internal_mozilla_nsID_2_3B_3BJ)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jobject arg2, jbyteArray arg3, jbyteArray arg4, jlong arg5)
+{
+	nsID _arg2, *lparg2=NULL;
+	jbyte *lparg3=NULL;
+	jbyte *lparg4=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__IILorg_eclipse_swt_internal_mozilla_nsID_2_3B_3BJ_FUNC);
+	if (arg2) if ((lparg2 = getnsIDFields(env, arg2, &_arg2)) == NULL) goto fail;
+	if (arg3) if ((lparg3 = env->GetByteArrayElements(arg3, NULL)) == NULL) goto fail;
+	if (arg4) if ((lparg4 = env->GetByteArrayElements(arg4, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, nsID *, jbyte *, jbyte *, jlong))(*(jint **)arg1)[arg0])(arg1, lparg2, lparg3, lparg4, arg5);
+fail:
+	if (arg4 && lparg4) env->ReleaseByteArrayElements(arg4, lparg4, 0);
+	if (arg3 && lparg3) env->ReleaseByteArrayElements(arg3, lparg3, 0);
+	if (arg2 && lparg2) setnsIDFields(env, arg2, lparg2);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__IILorg_eclipse_swt_internal_mozilla_nsID_2_3B_3BJ_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__IILorg_eclipse_swt_internal_mozilla_nsID_2_3B_3BJ_3B_3B
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IILorg_eclipse_swt_internal_mozilla_nsID_2_3B_3BJ_3B_3B)(JNIEnv *env, jclass that, jint arg0, jint arg1, jobject arg2, jbyteArray arg3, jbyteArray arg4, jlong arg5, jbyteArray arg6, jbyteArray arg7);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IILorg_eclipse_swt_internal_mozilla_nsID_2_3B_3BJ_3B_3B)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jobject arg2, jbyteArray arg3, jbyteArray arg4, jlong arg5, jbyteArray arg6, jbyteArray arg7)
+{
+	nsID _arg2, *lparg2=NULL;
+	jbyte *lparg3=NULL;
+	jbyte *lparg4=NULL;
+	jbyte *lparg6=NULL;
+	jbyte *lparg7=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__IILorg_eclipse_swt_internal_mozilla_nsID_2_3B_3BJ_3B_3B_FUNC);
+	if (arg2) if ((lparg2 = getnsIDFields(env, arg2, &_arg2)) == NULL) goto fail;
+	if (arg3) if ((lparg3 = env->GetByteArrayElements(arg3, NULL)) == NULL) goto fail;
+	if (arg4) if ((lparg4 = env->GetByteArrayElements(arg4, NULL)) == NULL) goto fail;
+	if (arg6) if ((lparg6 = env->GetByteArrayElements(arg6, NULL)) == NULL) goto fail;
+	if (arg7) if ((lparg7 = env->GetByteArrayElements(arg7, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, nsID *, jbyte *, jbyte *, jlong, jbyte *, jbyte *))(*(jint **)arg1)[arg0])(arg1, lparg2, lparg3, lparg4, arg5, lparg6, lparg7);
+fail:
+	if (arg7 && lparg7) env->ReleaseByteArrayElements(arg7, lparg7, 0);
+	if (arg6 && lparg6) env->ReleaseByteArrayElements(arg6, lparg6, 0);
+	if (arg4 && lparg4) env->ReleaseByteArrayElements(arg4, lparg4, 0);
+	if (arg3 && lparg3) env->ReleaseByteArrayElements(arg3, lparg3, 0);
+	if (arg2 && lparg2) setnsIDFields(env, arg2, lparg2);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__IILorg_eclipse_swt_internal_mozilla_nsID_2_3B_3BJ_3B_3B_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__IILorg_eclipse_swt_internal_mozilla_nsID_2_3I
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IILorg_eclipse_swt_internal_mozilla_nsID_2_3I)(JNIEnv *env, jclass that, jint arg0, jint arg1, jobject arg2, jintArray arg3);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IILorg_eclipse_swt_internal_mozilla_nsID_2_3I)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jobject arg2, jintArray arg3)
+{
+	nsID _arg2, *lparg2=NULL;
+	jint *lparg3=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__IILorg_eclipse_swt_internal_mozilla_nsID_2_3I_FUNC);
+	if (arg2) if ((lparg2 = getnsIDFields(env, arg2, &_arg2)) == NULL) goto fail;
+	if (arg3) if ((lparg3 = env->GetIntArrayElements(arg3, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, nsID *, jint *))(*(jint **)arg1)[arg0])(arg1, lparg2, lparg3);
+fail:
+	if (arg3 && lparg3) env->ReleaseIntArrayElements(arg3, lparg3, 0);
+	if (arg2 && lparg2) setnsIDFields(env, arg2, lparg2);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__IILorg_eclipse_swt_internal_mozilla_nsID_2_3I_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__IILorg_eclipse_swt_internal_mozilla_nsID_2_3J
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IILorg_eclipse_swt_internal_mozilla_nsID_2_3J)(JNIEnv *env, jclass that, jint arg0, jint arg1, jobject arg2, jlongArray arg3);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__IILorg_eclipse_swt_internal_mozilla_nsID_2_3J)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jobject arg2, jlongArray arg3)
+{
+	nsID _arg2, *lparg2=NULL;
+	jlong *lparg3=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__IILorg_eclipse_swt_internal_mozilla_nsID_2_3J_FUNC);
+	if (arg2) if ((lparg2 = getnsIDFields(env, arg2, &_arg2)) == NULL) goto fail;
+	if (arg3) if ((lparg3 = env->GetLongArrayElements(arg3, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, nsID *, jlong *))(*(jint **)arg1)[arg0])(arg1, lparg2, lparg3);
+fail:
+	if (arg3 && lparg3) env->ReleaseLongArrayElements(arg3, lparg3, 0);
+	if (arg2 && lparg2) setnsIDFields(env, arg2, lparg2);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__IILorg_eclipse_swt_internal_mozilla_nsID_2_3J_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__II_3B
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__II_3B)(JNIEnv *env, jclass that, jint arg0, jint arg1, jbyteArray arg2);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__II_3B)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jbyteArray arg2)
+{
+	jbyte *lparg2=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__II_3B_FUNC);
+	if (arg2) if ((lparg2 = env->GetByteArrayElements(arg2, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jbyte *))(*(jint **)arg1)[arg0])(arg1, lparg2);
+fail:
+	if (arg2 && lparg2) env->ReleaseByteArrayElements(arg2, lparg2, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__II_3B_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__II_3BI
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__II_3BI)(JNIEnv *env, jclass that, jint arg0, jint arg1, jbyteArray arg2, jint arg3);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__II_3BI)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jbyteArray arg2, jint arg3)
+{
+	jbyte *lparg2=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__II_3BI_FUNC);
+	if (arg2) if ((lparg2 = env->GetByteArrayElements(arg2, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jbyte *, jint))(*(jint **)arg1)[arg0])(arg1, lparg2, arg3);
+fail:
+	if (arg2 && lparg2) env->ReleaseByteArrayElements(arg2, lparg2, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__II_3BI_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__II_3BII_3I_3I
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__II_3BII_3I_3I)(JNIEnv *env, jclass that, jint arg0, jint arg1, jbyteArray arg2, jint arg3, jint arg4, jintArray arg5, jintArray arg6);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__II_3BII_3I_3I)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jbyteArray arg2, jint arg3, jint arg4, jintArray arg5, jintArray arg6)
+{
+	jbyte *lparg2=NULL;
+	jint *lparg5=NULL;
+	jint *lparg6=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__II_3BII_3I_3I_FUNC);
+	if (arg2) if ((lparg2 = env->GetByteArrayElements(arg2, NULL)) == NULL) goto fail;
+	if (arg5) if ((lparg5 = env->GetIntArrayElements(arg5, NULL)) == NULL) goto fail;
+	if (arg6) if ((lparg6 = env->GetIntArrayElements(arg6, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jbyte *, jint, jint, jint *, jint *))(*(jint **)arg1)[arg0])(arg1, lparg2, arg3, arg4, lparg5, lparg6);
+fail:
+	if (arg6 && lparg6) env->ReleaseIntArrayElements(arg6, lparg6, 0);
+	if (arg5 && lparg5) env->ReleaseIntArrayElements(arg5, lparg5, 0);
+	if (arg2 && lparg2) env->ReleaseByteArrayElements(arg2, lparg2, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__II_3BII_3I_3I_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__II_3BIJ_3J_3I
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__II_3BIJ_3J_3I)(JNIEnv *env, jclass that, jint arg0, jint arg1, jbyteArray arg2, jint arg3, jlong arg4, jlongArray arg5, jintArray arg6);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__II_3BIJ_3J_3I)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jbyteArray arg2, jint arg3, jlong arg4, jlongArray arg5, jintArray arg6)
+{
+	jbyte *lparg2=NULL;
+	jlong *lparg5=NULL;
+	jint *lparg6=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__II_3BIJ_3J_3I_FUNC);
+	if (arg2) if ((lparg2 = env->GetByteArrayElements(arg2, NULL)) == NULL) goto fail;
+	if (arg5) if ((lparg5 = env->GetLongArrayElements(arg5, NULL)) == NULL) goto fail;
+	if (arg6) if ((lparg6 = env->GetIntArrayElements(arg6, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jbyte *, jint, jlong, jlong *, jint *))(*(jint **)arg1)[arg0])(arg1, lparg2, arg3, arg4, lparg5, lparg6);
+fail:
+	if (arg6 && lparg6) env->ReleaseIntArrayElements(arg6, lparg6, 0);
+	if (arg5 && lparg5) env->ReleaseLongArrayElements(arg5, lparg5, 0);
+	if (arg2 && lparg2) env->ReleaseByteArrayElements(arg2, lparg2, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__II_3BIJ_3J_3I_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__II_3BILorg_eclipse_swt_internal_mozilla_nsID_2_3I
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__II_3BILorg_eclipse_swt_internal_mozilla_nsID_2_3I)(JNIEnv *env, jclass that, jint arg0, jint arg1, jbyteArray arg2, jint arg3, jobject arg4, jintArray arg5);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__II_3BILorg_eclipse_swt_internal_mozilla_nsID_2_3I)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jbyteArray arg2, jint arg3, jobject arg4, jintArray arg5)
+{
+	jbyte *lparg2=NULL;
+	nsID _arg4, *lparg4=NULL;
+	jint *lparg5=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__II_3BILorg_eclipse_swt_internal_mozilla_nsID_2_3I_FUNC);
+	if (arg2) if ((lparg2 = env->GetByteArrayElements(arg2, NULL)) == NULL) goto fail;
+	if (arg4) if ((lparg4 = getnsIDFields(env, arg4, &_arg4)) == NULL) goto fail;
+	if (arg5) if ((lparg5 = env->GetIntArrayElements(arg5, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jbyte *, jint, nsID *, jint *))(*(jint **)arg1)[arg0])(arg1, lparg2, arg3, lparg4, lparg5);
+fail:
+	if (arg5 && lparg5) env->ReleaseIntArrayElements(arg5, lparg5, 0);
+	if (arg4 && lparg4) setnsIDFields(env, arg4, lparg4);
+	if (arg2 && lparg2) env->ReleaseByteArrayElements(arg2, lparg2, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__II_3BILorg_eclipse_swt_internal_mozilla_nsID_2_3I_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__II_3BI_3I
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__II_3BI_3I)(JNIEnv *env, jclass that, jint arg0, jint arg1, jbyteArray arg2, jint arg3, jintArray arg4);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__II_3BI_3I)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jbyteArray arg2, jint arg3, jintArray arg4)
+{
+	jbyte *lparg2=NULL;
+	jint *lparg4=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__II_3BI_3I_FUNC);
+	if (arg2) if ((lparg2 = env->GetByteArrayElements(arg2, NULL)) == NULL) goto fail;
+	if (arg4) if ((lparg4 = env->GetIntArrayElements(arg4, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jbyte *, jint, jint *))(*(jint **)arg1)[arg0])(arg1, lparg2, arg3, lparg4);
+fail:
+	if (arg4 && lparg4) env->ReleaseIntArrayElements(arg4, lparg4, 0);
+	if (arg2 && lparg2) env->ReleaseByteArrayElements(arg2, lparg2, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__II_3BI_3I_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__II_3BI_3I_3I
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__II_3BI_3I_3I)(JNIEnv *env, jclass that, jint arg0, jint arg1, jbyteArray arg2, jint arg3, jintArray arg4, jintArray arg5);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__II_3BI_3I_3I)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jbyteArray arg2, jint arg3, jintArray arg4, jintArray arg5)
+{
+	jbyte *lparg2=NULL;
+	jint *lparg4=NULL;
+	jint *lparg5=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__II_3BI_3I_3I_FUNC);
+	if (arg2) if ((lparg2 = env->GetByteArrayElements(arg2, NULL)) == NULL) goto fail;
+	if (arg4) if ((lparg4 = env->GetIntArrayElements(arg4, NULL)) == NULL) goto fail;
+	if (arg5) if ((lparg5 = env->GetIntArrayElements(arg5, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jbyte *, jint, jint *, jint *))(*(jint **)arg1)[arg0])(arg1, lparg2, arg3, lparg4, lparg5);
+fail:
+	if (arg5 && lparg5) env->ReleaseIntArrayElements(arg5, lparg5, 0);
+	if (arg4 && lparg4) env->ReleaseIntArrayElements(arg4, lparg4, 0);
+	if (arg2 && lparg2) env->ReleaseByteArrayElements(arg2, lparg2, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__II_3BI_3I_3I_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__II_3BI_3J_3I
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__II_3BI_3J_3I)(JNIEnv *env, jclass that, jint arg0, jint arg1, jbyteArray arg2, jint arg3, jlongArray arg4, jintArray arg5);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__II_3BI_3J_3I)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jbyteArray arg2, jint arg3, jlongArray arg4, jintArray arg5)
+{
+	jbyte *lparg2=NULL;
+	jlong *lparg4=NULL;
+	jint *lparg5=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__II_3BI_3J_3I_FUNC);
+	if (arg2) if ((lparg2 = env->GetByteArrayElements(arg2, NULL)) == NULL) goto fail;
+	if (arg4) if ((lparg4 = env->GetLongArrayElements(arg4, NULL)) == NULL) goto fail;
+	if (arg5) if ((lparg5 = env->GetIntArrayElements(arg5, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jbyte *, jint, jlong *, jint *))(*(jint **)arg1)[arg0])(arg1, lparg2, arg3, lparg4, lparg5);
+fail:
+	if (arg5 && lparg5) env->ReleaseIntArrayElements(arg5, lparg5, 0);
+	if (arg4 && lparg4) env->ReleaseLongArrayElements(arg4, lparg4, 0);
+	if (arg2 && lparg2) env->ReleaseByteArrayElements(arg2, lparg2, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__II_3BI_3J_3I_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__II_3BJ
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__II_3BJ)(JNIEnv *env, jclass that, jint arg0, jint arg1, jbyteArray arg2, jlong arg3);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__II_3BJ)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jbyteArray arg2, jlong arg3)
+{
+	jbyte *lparg2=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__II_3BJ_FUNC);
+	if (arg2) if ((lparg2 = env->GetByteArrayElements(arg2, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jbyte *, jlong))(*(jint **)arg1)[arg0])(arg1, lparg2, arg3);
+fail:
+	if (arg2 && lparg2) env->ReleaseByteArrayElements(arg2, lparg2, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__II_3BJ_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__II_3BJLorg_eclipse_swt_internal_mozilla_nsID_2_3J
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__II_3BJLorg_eclipse_swt_internal_mozilla_nsID_2_3J)(JNIEnv *env, jclass that, jint arg0, jint arg1, jbyteArray arg2, jlong arg3, jobject arg4, jlongArray arg5);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__II_3BJLorg_eclipse_swt_internal_mozilla_nsID_2_3J)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jbyteArray arg2, jlong arg3, jobject arg4, jlongArray arg5)
+{
+	jbyte *lparg2=NULL;
+	nsID _arg4, *lparg4=NULL;
+	jlong *lparg5=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__II_3BJLorg_eclipse_swt_internal_mozilla_nsID_2_3J_FUNC);
+	if (arg2) if ((lparg2 = env->GetByteArrayElements(arg2, NULL)) == NULL) goto fail;
+	if (arg4) if ((lparg4 = getnsIDFields(env, arg4, &_arg4)) == NULL) goto fail;
+	if (arg5) if ((lparg5 = env->GetLongArrayElements(arg5, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jbyte *, jlong, nsID *, jlong *))(*(jint **)arg1)[arg0])(arg1, lparg2, arg3, lparg4, lparg5);
+fail:
+	if (arg5 && lparg5) env->ReleaseLongArrayElements(arg5, lparg5, 0);
+	if (arg4 && lparg4) setnsIDFields(env, arg4, lparg4);
+	if (arg2 && lparg2) env->ReleaseByteArrayElements(arg2, lparg2, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__II_3BJLorg_eclipse_swt_internal_mozilla_nsID_2_3J_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__II_3BLorg_eclipse_swt_internal_mozilla_nsID_2I
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__II_3BLorg_eclipse_swt_internal_mozilla_nsID_2I)(JNIEnv *env, jclass that, jint arg0, jint arg1, jbyteArray arg2, jobject arg3, jint arg4);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__II_3BLorg_eclipse_swt_internal_mozilla_nsID_2I)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jbyteArray arg2, jobject arg3, jint arg4)
+{
+	jbyte *lparg2=NULL;
+	nsID _arg3, *lparg3=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__II_3BLorg_eclipse_swt_internal_mozilla_nsID_2I_FUNC);
+	if (arg2) if ((lparg2 = env->GetByteArrayElements(arg2, NULL)) == NULL) goto fail;
+	if (arg3) if ((lparg3 = getnsIDFields(env, arg3, &_arg3)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jbyte *, nsID *, jint))(*(jint **)arg1)[arg0])(arg1, lparg2, lparg3, arg4);
+fail:
+	if (arg3 && lparg3) setnsIDFields(env, arg3, lparg3);
+	if (arg2 && lparg2) env->ReleaseByteArrayElements(arg2, lparg2, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__II_3BLorg_eclipse_swt_internal_mozilla_nsID_2I_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__II_3BLorg_eclipse_swt_internal_mozilla_nsID_2J
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__II_3BLorg_eclipse_swt_internal_mozilla_nsID_2J)(JNIEnv *env, jclass that, jint arg0, jint arg1, jbyteArray arg2, jobject arg3, jlong arg4);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__II_3BLorg_eclipse_swt_internal_mozilla_nsID_2J)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jbyteArray arg2, jobject arg3, jlong arg4)
+{
+	jbyte *lparg2=NULL;
+	nsID _arg3, *lparg3=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__II_3BLorg_eclipse_swt_internal_mozilla_nsID_2J_FUNC);
+	if (arg2) if ((lparg2 = env->GetByteArrayElements(arg2, NULL)) == NULL) goto fail;
+	if (arg3) if ((lparg3 = getnsIDFields(env, arg3, &_arg3)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jbyte *, nsID *, jlong))(*(jint **)arg1)[arg0])(arg1, lparg2, lparg3, arg4);
+fail:
+	if (arg3 && lparg3) setnsIDFields(env, arg3, lparg3);
+	if (arg2 && lparg2) env->ReleaseByteArrayElements(arg2, lparg2, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__II_3BLorg_eclipse_swt_internal_mozilla_nsID_2J_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__II_3BLorg_eclipse_swt_internal_mozilla_nsID_2_3I
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__II_3BLorg_eclipse_swt_internal_mozilla_nsID_2_3I)(JNIEnv *env, jclass that, jint arg0, jint arg1, jbyteArray arg2, jobject arg3, jintArray arg4);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__II_3BLorg_eclipse_swt_internal_mozilla_nsID_2_3I)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jbyteArray arg2, jobject arg3, jintArray arg4)
+{
+	jbyte *lparg2=NULL;
+	nsID _arg3, *lparg3=NULL;
+	jint *lparg4=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__II_3BLorg_eclipse_swt_internal_mozilla_nsID_2_3I_FUNC);
+	if (arg2) if ((lparg2 = env->GetByteArrayElements(arg2, NULL)) == NULL) goto fail;
+	if (arg3) if ((lparg3 = getnsIDFields(env, arg3, &_arg3)) == NULL) goto fail;
+	if (arg4) if ((lparg4 = env->GetIntArrayElements(arg4, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jbyte *, nsID *, jint *))(*(jint **)arg1)[arg0])(arg1, lparg2, lparg3, lparg4);
+fail:
+	if (arg4 && lparg4) env->ReleaseIntArrayElements(arg4, lparg4, 0);
+	if (arg3 && lparg3) setnsIDFields(env, arg3, lparg3);
+	if (arg2 && lparg2) env->ReleaseByteArrayElements(arg2, lparg2, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__II_3BLorg_eclipse_swt_internal_mozilla_nsID_2_3I_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__II_3BLorg_eclipse_swt_internal_mozilla_nsID_2_3J
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__II_3BLorg_eclipse_swt_internal_mozilla_nsID_2_3J)(JNIEnv *env, jclass that, jint arg0, jint arg1, jbyteArray arg2, jobject arg3, jlongArray arg4);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__II_3BLorg_eclipse_swt_internal_mozilla_nsID_2_3J)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jbyteArray arg2, jobject arg3, jlongArray arg4)
+{
+	jbyte *lparg2=NULL;
+	nsID _arg3, *lparg3=NULL;
+	jlong *lparg4=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__II_3BLorg_eclipse_swt_internal_mozilla_nsID_2_3J_FUNC);
+	if (arg2) if ((lparg2 = env->GetByteArrayElements(arg2, NULL)) == NULL) goto fail;
+	if (arg3) if ((lparg3 = getnsIDFields(env, arg3, &_arg3)) == NULL) goto fail;
+	if (arg4) if ((lparg4 = env->GetLongArrayElements(arg4, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jbyte *, nsID *, jlong *))(*(jint **)arg1)[arg0])(arg1, lparg2, lparg3, lparg4);
+fail:
+	if (arg4 && lparg4) env->ReleaseLongArrayElements(arg4, lparg4, 0);
+	if (arg3 && lparg3) setnsIDFields(env, arg3, lparg3);
+	if (arg2 && lparg2) env->ReleaseByteArrayElements(arg2, lparg2, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__II_3BLorg_eclipse_swt_internal_mozilla_nsID_2_3J_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__II_3B_3B
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__II_3B_3B)(JNIEnv *env, jclass that, jint arg0, jint arg1, jbyteArray arg2, jbyteArray arg3);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__II_3B_3B)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jbyteArray arg2, jbyteArray arg3)
+{
+	jbyte *lparg2=NULL;
+	jbyte *lparg3=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__II_3B_3B_FUNC);
+	if (arg2) if ((lparg2 = env->GetByteArrayElements(arg2, NULL)) == NULL) goto fail;
+	if (arg3) if ((lparg3 = env->GetByteArrayElements(arg3, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jbyte *, jbyte *))(*(jint **)arg1)[arg0])(arg1, lparg2, lparg3);
+fail:
+	if (arg3 && lparg3) env->ReleaseByteArrayElements(arg3, lparg3, 0);
+	if (arg2 && lparg2) env->ReleaseByteArrayElements(arg2, lparg2, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__II_3B_3B_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__II_3B_3BI
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__II_3B_3BI)(JNIEnv *env, jclass that, jint arg0, jint arg1, jbyteArray arg2, jbyteArray arg3, jint arg4);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__II_3B_3BI)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jbyteArray arg2, jbyteArray arg3, jint arg4)
+{
+	jbyte *lparg2=NULL;
+	jbyte *lparg3=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__II_3B_3BI_FUNC);
+	if (arg2) if ((lparg2 = env->GetByteArrayElements(arg2, NULL)) == NULL) goto fail;
+	if (arg3) if ((lparg3 = env->GetByteArrayElements(arg3, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jbyte *, jbyte *, jint))(*(jint **)arg1)[arg0])(arg1, lparg2, lparg3, arg4);
+fail:
+	if (arg3 && lparg3) env->ReleaseByteArrayElements(arg3, lparg3, 0);
+	if (arg2 && lparg2) env->ReleaseByteArrayElements(arg2, lparg2, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__II_3B_3BI_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__II_3B_3B_3BII_3I
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__II_3B_3B_3BII_3I)(JNIEnv *env, jclass that, jint arg0, jint arg1, jbyteArray arg2, jbyteArray arg3, jbyteArray arg4, jint arg5, jint arg6, jintArray arg7);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__II_3B_3B_3BII_3I)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jbyteArray arg2, jbyteArray arg3, jbyteArray arg4, jint arg5, jint arg6, jintArray arg7)
+{
+	jbyte *lparg2=NULL;
+	jbyte *lparg3=NULL;
+	jbyte *lparg4=NULL;
+	jint *lparg7=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__II_3B_3B_3BII_3I_FUNC);
+	if (arg2) if ((lparg2 = env->GetByteArrayElements(arg2, NULL)) == NULL) goto fail;
+	if (arg3) if ((lparg3 = env->GetByteArrayElements(arg3, NULL)) == NULL) goto fail;
+	if (arg4) if ((lparg4 = env->GetByteArrayElements(arg4, NULL)) == NULL) goto fail;
+	if (arg7) if ((lparg7 = env->GetIntArrayElements(arg7, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jbyte *, jbyte *, jbyte *, jint, jint, jint *))(*(jint **)arg1)[arg0])(arg1, lparg2, lparg3, lparg4, arg5, arg6, lparg7);
+fail:
+	if (arg7 && lparg7) env->ReleaseIntArrayElements(arg7, lparg7, 0);
+	if (arg4 && lparg4) env->ReleaseByteArrayElements(arg4, lparg4, 0);
+	if (arg3 && lparg3) env->ReleaseByteArrayElements(arg3, lparg3, 0);
+	if (arg2 && lparg2) env->ReleaseByteArrayElements(arg2, lparg2, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__II_3B_3B_3BII_3I_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__II_3B_3B_3BII_3J
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__II_3B_3B_3BII_3J)(JNIEnv *env, jclass that, jint arg0, jint arg1, jbyteArray arg2, jbyteArray arg3, jbyteArray arg4, jint arg5, jint arg6, jlongArray arg7);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__II_3B_3B_3BII_3J)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jbyteArray arg2, jbyteArray arg3, jbyteArray arg4, jint arg5, jint arg6, jlongArray arg7)
+{
+	jbyte *lparg2=NULL;
+	jbyte *lparg3=NULL;
+	jbyte *lparg4=NULL;
+	jlong *lparg7=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__II_3B_3B_3BII_3J_FUNC);
+	if (arg2) if ((lparg2 = env->GetByteArrayElements(arg2, NULL)) == NULL) goto fail;
+	if (arg3) if ((lparg3 = env->GetByteArrayElements(arg3, NULL)) == NULL) goto fail;
+	if (arg4) if ((lparg4 = env->GetByteArrayElements(arg4, NULL)) == NULL) goto fail;
+	if (arg7) if ((lparg7 = env->GetLongArrayElements(arg7, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jbyte *, jbyte *, jbyte *, jint, jint, jlong *))(*(jint **)arg1)[arg0])(arg1, lparg2, lparg3, lparg4, arg5, arg6, lparg7);
+fail:
+	if (arg7 && lparg7) env->ReleaseLongArrayElements(arg7, lparg7, 0);
+	if (arg4 && lparg4) env->ReleaseByteArrayElements(arg4, lparg4, 0);
+	if (arg3 && lparg3) env->ReleaseByteArrayElements(arg3, lparg3, 0);
+	if (arg2 && lparg2) env->ReleaseByteArrayElements(arg2, lparg2, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__II_3B_3B_3BII_3J_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__II_3B_3B_3I
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__II_3B_3B_3I)(JNIEnv *env, jclass that, jint arg0, jint arg1, jbyteArray arg2, jbyteArray arg3, jintArray arg4);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__II_3B_3B_3I)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jbyteArray arg2, jbyteArray arg3, jintArray arg4)
+{
+	jbyte *lparg2=NULL;
+	jbyte *lparg3=NULL;
+	jint *lparg4=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__II_3B_3B_3I_FUNC);
+	if (arg2) if ((lparg2 = env->GetByteArrayElements(arg2, NULL)) == NULL) goto fail;
+	if (arg3) if ((lparg3 = env->GetByteArrayElements(arg3, NULL)) == NULL) goto fail;
+	if (arg4) if ((lparg4 = env->GetIntArrayElements(arg4, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jbyte *, jbyte *, jint *))(*(jint **)arg1)[arg0])(arg1, lparg2, lparg3, lparg4);
+fail:
+	if (arg4 && lparg4) env->ReleaseIntArrayElements(arg4, lparg4, 0);
+	if (arg3 && lparg3) env->ReleaseByteArrayElements(arg3, lparg3, 0);
+	if (arg2 && lparg2) env->ReleaseByteArrayElements(arg2, lparg2, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__II_3B_3B_3I_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__II_3B_3B_3J
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__II_3B_3B_3J)(JNIEnv *env, jclass that, jint arg0, jint arg1, jbyteArray arg2, jbyteArray arg3, jlongArray arg4);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__II_3B_3B_3J)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jbyteArray arg2, jbyteArray arg3, jlongArray arg4)
+{
+	jbyte *lparg2=NULL;
+	jbyte *lparg3=NULL;
+	jlong *lparg4=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__II_3B_3B_3J_FUNC);
+	if (arg2) if ((lparg2 = env->GetByteArrayElements(arg2, NULL)) == NULL) goto fail;
+	if (arg3) if ((lparg3 = env->GetByteArrayElements(arg3, NULL)) == NULL) goto fail;
+	if (arg4) if ((lparg4 = env->GetLongArrayElements(arg4, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jbyte *, jbyte *, jlong *))(*(jint **)arg1)[arg0])(arg1, lparg2, lparg3, lparg4);
+fail:
+	if (arg4 && lparg4) env->ReleaseLongArrayElements(arg4, lparg4, 0);
+	if (arg3 && lparg3) env->ReleaseByteArrayElements(arg3, lparg3, 0);
+	if (arg2 && lparg2) env->ReleaseByteArrayElements(arg2, lparg2, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__II_3B_3B_3J_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__II_3B_3I
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__II_3B_3I)(JNIEnv *env, jclass that, jint arg0, jint arg1, jbyteArray arg2, jintArray arg3);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__II_3B_3I)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jbyteArray arg2, jintArray arg3)
+{
+	jbyte *lparg2=NULL;
+	jint *lparg3=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__II_3B_3I_FUNC);
+	if (arg2) if ((lparg2 = env->GetByteArrayElements(arg2, NULL)) == NULL) goto fail;
+	if (arg3) if ((lparg3 = env->GetIntArrayElements(arg3, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jbyte *, jint *))(*(jint **)arg1)[arg0])(arg1, lparg2, lparg3);
+fail:
+	if (arg3 && lparg3) env->ReleaseIntArrayElements(arg3, lparg3, 0);
+	if (arg2 && lparg2) env->ReleaseByteArrayElements(arg2, lparg2, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__II_3B_3I_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__II_3B_3I_3I
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__II_3B_3I_3I)(JNIEnv *env, jclass that, jint arg0, jint arg1, jbyteArray arg2, jintArray arg3, jintArray arg4);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__II_3B_3I_3I)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jbyteArray arg2, jintArray arg3, jintArray arg4)
+{
+	jbyte *lparg2=NULL;
+	jint *lparg3=NULL;
+	jint *lparg4=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__II_3B_3I_3I_FUNC);
+	if (arg2) if ((lparg2 = env->GetByteArrayElements(arg2, NULL)) == NULL) goto fail;
+	if (arg3) if ((lparg3 = env->GetIntArrayElements(arg3, NULL)) == NULL) goto fail;
+	if (arg4) if ((lparg4 = env->GetIntArrayElements(arg4, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jbyte *, jint *, jint *))(*(jint **)arg1)[arg0])(arg1, lparg2, lparg3, lparg4);
+fail:
+	if (arg4 && lparg4) env->ReleaseIntArrayElements(arg4, lparg4, 0);
+	if (arg3 && lparg3) env->ReleaseIntArrayElements(arg3, lparg3, 0);
+	if (arg2 && lparg2) env->ReleaseByteArrayElements(arg2, lparg2, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__II_3B_3I_3I_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__II_3B_3I_3J
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__II_3B_3I_3J)(JNIEnv *env, jclass that, jint arg0, jint arg1, jbyteArray arg2, jintArray arg3, jlongArray arg4);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__II_3B_3I_3J)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jbyteArray arg2, jintArray arg3, jlongArray arg4)
+{
+	jbyte *lparg2=NULL;
+	jint *lparg3=NULL;
+	jlong *lparg4=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__II_3B_3I_3J_FUNC);
+	if (arg2) if ((lparg2 = env->GetByteArrayElements(arg2, NULL)) == NULL) goto fail;
+	if (arg3) if ((lparg3 = env->GetIntArrayElements(arg3, NULL)) == NULL) goto fail;
+	if (arg4) if ((lparg4 = env->GetLongArrayElements(arg4, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jbyte *, jint *, jlong *))(*(jint **)arg1)[arg0])(arg1, lparg2, lparg3, lparg4);
+fail:
+	if (arg4 && lparg4) env->ReleaseLongArrayElements(arg4, lparg4, 0);
+	if (arg3 && lparg3) env->ReleaseIntArrayElements(arg3, lparg3, 0);
+	if (arg2 && lparg2) env->ReleaseByteArrayElements(arg2, lparg2, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__II_3B_3I_3J_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__II_3B_3J
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__II_3B_3J)(JNIEnv *env, jclass that, jint arg0, jint arg1, jbyteArray arg2, jlongArray arg3);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__II_3B_3J)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jbyteArray arg2, jlongArray arg3)
+{
+	jbyte *lparg2=NULL;
+	jlong *lparg3=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__II_3B_3J_FUNC);
+	if (arg2) if ((lparg2 = env->GetByteArrayElements(arg2, NULL)) == NULL) goto fail;
+	if (arg3) if ((lparg3 = env->GetLongArrayElements(arg3, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jbyte *, jlong *))(*(jint **)arg1)[arg0])(arg1, lparg2, lparg3);
+fail:
+	if (arg3 && lparg3) env->ReleaseLongArrayElements(arg3, lparg3, 0);
+	if (arg2 && lparg2) env->ReleaseByteArrayElements(arg2, lparg2, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__II_3B_3J_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__II_3B_3J_3I
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__II_3B_3J_3I)(JNIEnv *env, jclass that, jint arg0, jint arg1, jbyteArray arg2, jlongArray arg3, jintArray arg4);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__II_3B_3J_3I)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jbyteArray arg2, jlongArray arg3, jintArray arg4)
+{
+	jbyte *lparg2=NULL;
+	jlong *lparg3=NULL;
+	jint *lparg4=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__II_3B_3J_3I_FUNC);
+	if (arg2) if ((lparg2 = env->GetByteArrayElements(arg2, NULL)) == NULL) goto fail;
+	if (arg3) if ((lparg3 = env->GetLongArrayElements(arg3, NULL)) == NULL) goto fail;
+	if (arg4) if ((lparg4 = env->GetIntArrayElements(arg4, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jbyte *, jlong *, jint *))(*(jint **)arg1)[arg0])(arg1, lparg2, lparg3, lparg4);
+fail:
+	if (arg4 && lparg4) env->ReleaseIntArrayElements(arg4, lparg4, 0);
+	if (arg3 && lparg3) env->ReleaseLongArrayElements(arg3, lparg3, 0);
+	if (arg2 && lparg2) env->ReleaseByteArrayElements(arg2, lparg2, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__II_3B_3J_3I_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__II_3C
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__II_3C)(JNIEnv *env, jclass that, jint arg0, jint arg1, jcharArray arg2);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__II_3C)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jcharArray arg2)
+{
+	jchar *lparg2=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__II_3C_FUNC);
+	if (arg2) if ((lparg2 = env->GetCharArrayElements(arg2, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jchar *))(*(jint **)arg1)[arg0])(arg1, lparg2);
+fail:
+	if (arg2 && lparg2) env->ReleaseCharArrayElements(arg2, lparg2, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__II_3C_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__II_3CIIII
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__II_3CIIII)(JNIEnv *env, jclass that, jint arg0, jint arg1, jcharArray arg2, jint arg3, jint arg4, jint arg5, jint arg6);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__II_3CIIII)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jcharArray arg2, jint arg3, jint arg4, jint arg5, jint arg6)
+{
+	jchar *lparg2=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__II_3CIIII_FUNC);
+	if (arg2) if ((lparg2 = env->GetCharArrayElements(arg2, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jchar *, jint, jint, jint, jint))(*(jint **)arg1)[arg0])(arg1, lparg2, arg3, arg4, arg5, arg6);
+fail:
+	if (arg2 && lparg2) env->ReleaseCharArrayElements(arg2, lparg2, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__II_3CIIII_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__II_3CIJJJ
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__II_3CIJJJ)(JNIEnv *env, jclass that, jint arg0, jint arg1, jcharArray arg2, jint arg3, jlong arg4, jlong arg5, jlong arg6);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__II_3CIJJJ)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jcharArray arg2, jint arg3, jlong arg4, jlong arg5, jlong arg6)
+{
+	jchar *lparg2=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__II_3CIJJJ_FUNC);
+	if (arg2) if ((lparg2 = env->GetCharArrayElements(arg2, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jchar *, jint, jlong, jlong, jlong))(*(jint **)arg1)[arg0])(arg1, lparg2, arg3, arg4, arg5, arg6);
+fail:
+	if (arg2 && lparg2) env->ReleaseCharArrayElements(arg2, lparg2, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__II_3CIJJJ_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__II_3CI_3I
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__II_3CI_3I)(JNIEnv *env, jclass that, jint arg0, jint arg1, jcharArray arg2, jint arg3, jintArray arg4);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__II_3CI_3I)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jcharArray arg2, jint arg3, jintArray arg4)
+{
+	jchar *lparg2=NULL;
+	jint *lparg4=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__II_3CI_3I_FUNC);
+	if (arg2) if ((lparg2 = env->GetCharArrayElements(arg2, NULL)) == NULL) goto fail;
+	if (arg4) if ((lparg4 = env->GetIntArrayElements(arg4, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jchar *, jint, jint *))(*(jint **)arg1)[arg0])(arg1, lparg2, arg3, lparg4);
+fail:
+	if (arg4 && lparg4) env->ReleaseIntArrayElements(arg4, lparg4, 0);
+	if (arg2 && lparg2) env->ReleaseCharArrayElements(arg2, lparg2, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__II_3CI_3I_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__II_3CJ_3J
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__II_3CJ_3J)(JNIEnv *env, jclass that, jint arg0, jint arg1, jcharArray arg2, jlong arg3, jlongArray arg4);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__II_3CJ_3J)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jcharArray arg2, jlong arg3, jlongArray arg4)
+{
+	jchar *lparg2=NULL;
+	jlong *lparg4=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__II_3CJ_3J_FUNC);
+	if (arg2) if ((lparg2 = env->GetCharArrayElements(arg2, NULL)) == NULL) goto fail;
+	if (arg4) if ((lparg4 = env->GetLongArrayElements(arg4, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jchar *, jlong, jlong *))(*(jint **)arg1)[arg0])(arg1, lparg2, arg3, lparg4);
+fail:
+	if (arg4 && lparg4) env->ReleaseLongArrayElements(arg4, lparg4, 0);
+	if (arg2 && lparg2) env->ReleaseCharArrayElements(arg2, lparg2, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__II_3CJ_3J_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__II_3C_3C
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__II_3C_3C)(JNIEnv *env, jclass that, jint arg0, jint arg1, jcharArray arg2, jcharArray arg3);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__II_3C_3C)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jcharArray arg2, jcharArray arg3)
+{
+	jchar *lparg2=NULL;
+	jchar *lparg3=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__II_3C_3C_FUNC);
+	if (arg2) if ((lparg2 = env->GetCharArrayElements(arg2, NULL)) == NULL) goto fail;
+	if (arg3) if ((lparg3 = env->GetCharArrayElements(arg3, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jchar *, jchar *))(*(jint **)arg1)[arg0])(arg1, lparg2, lparg3);
+fail:
+	if (arg3 && lparg3) env->ReleaseCharArrayElements(arg3, lparg3, 0);
+	if (arg2 && lparg2) env->ReleaseCharArrayElements(arg2, lparg2, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__II_3C_3C_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__II_3F
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__II_3F)(JNIEnv *env, jclass that, jint arg0, jint arg1, jfloatArray arg2);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__II_3F)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jfloatArray arg2)
+{
+	jfloat *lparg2=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__II_3F_FUNC);
+	if (arg2) if ((lparg2 = env->GetFloatArrayElements(arg2, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jfloat *))(*(jint **)arg1)[arg0])(arg1, lparg2);
+fail:
+	if (arg2 && lparg2) env->ReleaseFloatArrayElements(arg2, lparg2, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__II_3F_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__II_3I
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__II_3I)(JNIEnv *env, jclass that, jint arg0, jint arg1, jintArray arg2);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__II_3I)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jintArray arg2)
+{
+	jint *lparg2=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__II_3I_FUNC);
+	if (arg2) if ((lparg2 = env->GetIntArrayElements(arg2, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jint *))(*(jint **)arg1)[arg0])(arg1, lparg2);
+fail:
+	if (arg2 && lparg2) env->ReleaseIntArrayElements(arg2, lparg2, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__II_3I_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__II_3I_3I
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__II_3I_3I)(JNIEnv *env, jclass that, jint arg0, jint arg1, jintArray arg2, jintArray arg3);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__II_3I_3I)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jintArray arg2, jintArray arg3)
+{
+	jint *lparg2=NULL;
+	jint *lparg3=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__II_3I_3I_FUNC);
+	if (arg2) if ((lparg2 = env->GetIntArrayElements(arg2, NULL)) == NULL) goto fail;
+	if (arg3) if ((lparg3 = env->GetIntArrayElements(arg3, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jint *, jint *))(*(jint **)arg1)[arg0])(arg1, lparg2, lparg3);
+fail:
+	if (arg3 && lparg3) env->ReleaseIntArrayElements(arg3, lparg3, 0);
+	if (arg2 && lparg2) env->ReleaseIntArrayElements(arg2, lparg2, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__II_3I_3I_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__II_3I_3I_3I
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__II_3I_3I_3I)(JNIEnv *env, jclass that, jint arg0, jint arg1, jintArray arg2, jintArray arg3, jintArray arg4);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__II_3I_3I_3I)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jintArray arg2, jintArray arg3, jintArray arg4)
+{
+	jint *lparg2=NULL;
+	jint *lparg3=NULL;
+	jint *lparg4=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__II_3I_3I_3I_FUNC);
+	if (arg2) if ((lparg2 = env->GetIntArrayElements(arg2, NULL)) == NULL) goto fail;
+	if (arg3) if ((lparg3 = env->GetIntArrayElements(arg3, NULL)) == NULL) goto fail;
+	if (arg4) if ((lparg4 = env->GetIntArrayElements(arg4, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jint *, jint *, jint *))(*(jint **)arg1)[arg0])(arg1, lparg2, lparg3, lparg4);
+fail:
+	if (arg4 && lparg4) env->ReleaseIntArrayElements(arg4, lparg4, 0);
+	if (arg3 && lparg3) env->ReleaseIntArrayElements(arg3, lparg3, 0);
+	if (arg2 && lparg2) env->ReleaseIntArrayElements(arg2, lparg2, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__II_3I_3I_3I_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__II_3I_3I_3I_3I
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__II_3I_3I_3I_3I)(JNIEnv *env, jclass that, jint arg0, jint arg1, jintArray arg2, jintArray arg3, jintArray arg4, jintArray arg5);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__II_3I_3I_3I_3I)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jintArray arg2, jintArray arg3, jintArray arg4, jintArray arg5)
+{
+	jint *lparg2=NULL;
+	jint *lparg3=NULL;
+	jint *lparg4=NULL;
+	jint *lparg5=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__II_3I_3I_3I_3I_FUNC);
+	if (arg2) if ((lparg2 = env->GetIntArrayElements(arg2, NULL)) == NULL) goto fail;
+	if (arg3) if ((lparg3 = env->GetIntArrayElements(arg3, NULL)) == NULL) goto fail;
+	if (arg4) if ((lparg4 = env->GetIntArrayElements(arg4, NULL)) == NULL) goto fail;
+	if (arg5) if ((lparg5 = env->GetIntArrayElements(arg5, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jint *, jint *, jint *, jint *))(*(jint **)arg1)[arg0])(arg1, lparg2, lparg3, lparg4, lparg5);
+fail:
+	if (arg5 && lparg5) env->ReleaseIntArrayElements(arg5, lparg5, 0);
+	if (arg4 && lparg4) env->ReleaseIntArrayElements(arg4, lparg4, 0);
+	if (arg3 && lparg3) env->ReleaseIntArrayElements(arg3, lparg3, 0);
+	if (arg2 && lparg2) env->ReleaseIntArrayElements(arg2, lparg2, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__II_3I_3I_3I_3I_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__II_3I_3J
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__II_3I_3J)(JNIEnv *env, jclass that, jint arg0, jint arg1, jintArray arg2, jlongArray arg3);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__II_3I_3J)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jintArray arg2, jlongArray arg3)
+{
+	jint *lparg2=NULL;
+	jlong *lparg3=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__II_3I_3J_FUNC);
+	if (arg2) if ((lparg2 = env->GetIntArrayElements(arg2, NULL)) == NULL) goto fail;
+	if (arg3) if ((lparg3 = env->GetLongArrayElements(arg3, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jint *, jlong *))(*(jint **)arg1)[arg0])(arg1, lparg2, lparg3);
+fail:
+	if (arg3 && lparg3) env->ReleaseLongArrayElements(arg3, lparg3, 0);
+	if (arg2 && lparg2) env->ReleaseIntArrayElements(arg2, lparg2, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__II_3I_3J_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__II_3I_3J_3I
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__II_3I_3J_3I)(JNIEnv *env, jclass that, jint arg0, jint arg1, jintArray arg2, jlongArray arg3, jintArray arg4);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__II_3I_3J_3I)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jintArray arg2, jlongArray arg3, jintArray arg4)
+{
+	jint *lparg2=NULL;
+	jlong *lparg3=NULL;
+	jint *lparg4=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__II_3I_3J_3I_FUNC);
+	if (arg2) if ((lparg2 = env->GetIntArrayElements(arg2, NULL)) == NULL) goto fail;
+	if (arg3) if ((lparg3 = env->GetLongArrayElements(arg3, NULL)) == NULL) goto fail;
+	if (arg4) if ((lparg4 = env->GetIntArrayElements(arg4, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jint *, jlong *, jint *))(*(jint **)arg1)[arg0])(arg1, lparg2, lparg3, lparg4);
+fail:
+	if (arg4 && lparg4) env->ReleaseIntArrayElements(arg4, lparg4, 0);
+	if (arg3 && lparg3) env->ReleaseLongArrayElements(arg3, lparg3, 0);
+	if (arg2 && lparg2) env->ReleaseIntArrayElements(arg2, lparg2, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__II_3I_3J_3I_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__II_3I_3J_3J
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__II_3I_3J_3J)(JNIEnv *env, jclass that, jint arg0, jint arg1, jintArray arg2, jlongArray arg3, jlongArray arg4);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__II_3I_3J_3J)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jintArray arg2, jlongArray arg3, jlongArray arg4)
+{
+	jint *lparg2=NULL;
+	jlong *lparg3=NULL;
+	jlong *lparg4=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__II_3I_3J_3J_FUNC);
+	if (arg2) if ((lparg2 = env->GetIntArrayElements(arg2, NULL)) == NULL) goto fail;
+	if (arg3) if ((lparg3 = env->GetLongArrayElements(arg3, NULL)) == NULL) goto fail;
+	if (arg4) if ((lparg4 = env->GetLongArrayElements(arg4, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jint *, jlong *, jlong *))(*(jint **)arg1)[arg0])(arg1, lparg2, lparg3, lparg4);
+fail:
+	if (arg4 && lparg4) env->ReleaseLongArrayElements(arg4, lparg4, 0);
+	if (arg3 && lparg3) env->ReleaseLongArrayElements(arg3, lparg3, 0);
+	if (arg2 && lparg2) env->ReleaseIntArrayElements(arg2, lparg2, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__II_3I_3J_3J_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__II_3J
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__II_3J)(JNIEnv *env, jclass that, jint arg0, jint arg1, jlongArray arg2);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__II_3J)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jlongArray arg2)
+{
+	jlong *lparg2=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__II_3J_FUNC);
+	if (arg2) if ((lparg2 = env->GetLongArrayElements(arg2, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jlong *))(*(jint **)arg1)[arg0])(arg1, lparg2);
+fail:
+	if (arg2 && lparg2) env->ReleaseLongArrayElements(arg2, lparg2, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__II_3J_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__II_3J_3J_3J
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__II_3J_3J_3J)(JNIEnv *env, jclass that, jint arg0, jint arg1, jlongArray arg2, jlongArray arg3, jlongArray arg4);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__II_3J_3J_3J)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jlongArray arg2, jlongArray arg3, jlongArray arg4)
+{
+	jlong *lparg2=NULL;
+	jlong *lparg3=NULL;
+	jlong *lparg4=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__II_3J_3J_3J_FUNC);
+	if (arg2) if ((lparg2 = env->GetLongArrayElements(arg2, NULL)) == NULL) goto fail;
+	if (arg3) if ((lparg3 = env->GetLongArrayElements(arg3, NULL)) == NULL) goto fail;
+	if (arg4) if ((lparg4 = env->GetLongArrayElements(arg4, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jlong *, jlong *, jlong *))(*(jint **)arg1)[arg0])(arg1, lparg2, lparg3, lparg4);
+fail:
+	if (arg4 && lparg4) env->ReleaseLongArrayElements(arg4, lparg4, 0);
+	if (arg3 && lparg3) env->ReleaseLongArrayElements(arg3, lparg3, 0);
+	if (arg2 && lparg2) env->ReleaseLongArrayElements(arg2, lparg2, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__II_3J_3J_3J_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_VtblCall__II_3S
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__II_3S)(JNIEnv *env, jclass that, jint arg0, jint arg1, jshortArray arg2);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(VtblCall__II_3S)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1, jshortArray arg2)
+{
+	jshort *lparg2=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, VtblCall__II_3S_FUNC);
+	if (arg2) if ((lparg2 = env->GetShortArrayElements(arg2, NULL)) == NULL) goto fail;
+	rc = (jint)((jint (STDMETHODCALLTYPE *)(jint, jshort *))(*(jint **)arg1)[arg0])(arg1, lparg2);
+fail:
+	if (arg2 && lparg2) env->ReleaseShortArrayElements(arg2, lparg2, 0);
+	XPCOM_NATIVE_EXIT(env, that, VtblCall__II_3S_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_XPCOMGlueShutdown
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(XPCOMGlueShutdown)(JNIEnv *env, jclass that);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(XPCOMGlueShutdown)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, XPCOMGlueShutdown_FUNC);
+	rc = (jint)XPCOMGlueShutdown();
+	XPCOM_NATIVE_EXIT(env, that, XPCOMGlueShutdown_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_XPCOMGlueStartup
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(XPCOMGlueStartup)(JNIEnv *env, jclass that, jbyteArray arg0);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(XPCOMGlueStartup)
+	(JNIEnv *env, jclass that, jbyteArray arg0)
+{
+	jbyte *lparg0=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, XPCOMGlueStartup_FUNC);
+	if (arg0) if ((lparg0 = env->GetByteArrayElements(arg0, NULL)) == NULL) goto fail;
+	rc = (jint)XPCOMGlueStartup((const char *)lparg0);
+fail:
+	if (arg0 && lparg0) env->ReleaseByteArrayElements(arg0, lparg0, 0);
+	XPCOM_NATIVE_EXIT(env, that, XPCOMGlueStartup_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_memmove__ILorg_eclipse_swt_internal_mozilla_nsID_2I
+extern "C" JNIEXPORT void JNICALL XPCOM_NATIVE(memmove__ILorg_eclipse_swt_internal_mozilla_nsID_2I)(JNIEnv *env, jclass that, jint arg0, jobject arg1, jint arg2);
+JNIEXPORT void JNICALL XPCOM_NATIVE(memmove__ILorg_eclipse_swt_internal_mozilla_nsID_2I)
+	(JNIEnv *env, jclass that, jint arg0, jobject arg1, jint arg2)
+{
+	nsID _arg1, *lparg1=NULL;
+	XPCOM_NATIVE_ENTER(env, that, memmove__ILorg_eclipse_swt_internal_mozilla_nsID_2I_FUNC);
+	if (arg1) if ((lparg1 = getnsIDFields(env, arg1, &_arg1)) == NULL) goto fail;
+	memmove((void *)arg0, (const void *)lparg1, (size_t)arg2);
+fail:
+	if (arg1 && lparg1) setnsIDFields(env, arg1, lparg1);
+	XPCOM_NATIVE_EXIT(env, that, memmove__ILorg_eclipse_swt_internal_mozilla_nsID_2I_FUNC);
+}
+#endif
+
+#ifndef NO_memmove__Lorg_eclipse_swt_internal_mozilla_nsID_2II
+extern "C" JNIEXPORT void JNICALL XPCOM_NATIVE(memmove__Lorg_eclipse_swt_internal_mozilla_nsID_2II)(JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2);
+JNIEXPORT void JNICALL XPCOM_NATIVE(memmove__Lorg_eclipse_swt_internal_mozilla_nsID_2II)
+	(JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2)
+{
+	nsID _arg0, *lparg0=NULL;
+	XPCOM_NATIVE_ENTER(env, that, memmove__Lorg_eclipse_swt_internal_mozilla_nsID_2II_FUNC);
+	if (arg0) if ((lparg0 = getnsIDFields(env, arg0, &_arg0)) == NULL) goto fail;
+	memmove((void *)lparg0, (const void *)arg1, (size_t)arg2);
+fail:
+	if (arg0 && lparg0) setnsIDFields(env, arg0, lparg0);
+	XPCOM_NATIVE_EXIT(env, that, memmove__Lorg_eclipse_swt_internal_mozilla_nsID_2II_FUNC);
+}
+#endif
+
+#ifndef NO_nsEmbedCString_1Length
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(nsEmbedCString_1Length)(JNIEnv *env, jclass that, jint arg0);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(nsEmbedCString_1Length)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, nsEmbedCString_1Length_FUNC);
+	rc = (jint)((nsEmbedCString *)arg0)->Length();
+	XPCOM_NATIVE_EXIT(env, that, nsEmbedCString_1Length_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_nsEmbedCString_1delete
+extern "C" JNIEXPORT void JNICALL XPCOM_NATIVE(nsEmbedCString_1delete)(JNIEnv *env, jclass that, jint arg0);
+JNIEXPORT void JNICALL XPCOM_NATIVE(nsEmbedCString_1delete)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	XPCOM_NATIVE_ENTER(env, that, nsEmbedCString_1delete_FUNC);
+	delete (nsEmbedCString *)arg0;
+	XPCOM_NATIVE_EXIT(env, that, nsEmbedCString_1delete_FUNC);
+}
+#endif
+
+#ifndef NO_nsEmbedCString_1get
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(nsEmbedCString_1get)(JNIEnv *env, jclass that, jint arg0);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(nsEmbedCString_1get)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, nsEmbedCString_1get_FUNC);
+	rc = (jint)((nsEmbedCString *)arg0)->get();
+	XPCOM_NATIVE_EXIT(env, that, nsEmbedCString_1get_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_nsEmbedCString_1new__
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(nsEmbedCString_1new__)(JNIEnv *env, jclass that);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(nsEmbedCString_1new__)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, nsEmbedCString_1new___FUNC);
+	rc = (jint)new nsEmbedCString();
+	XPCOM_NATIVE_EXIT(env, that, nsEmbedCString_1new___FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_nsEmbedCString_1new__II
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(nsEmbedCString_1new__II)(JNIEnv *env, jclass that, jint arg0, jint arg1);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(nsEmbedCString_1new__II)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, nsEmbedCString_1new__II_FUNC);
+	rc = (jint)new nsEmbedCString((const char *)arg0, arg1);
+	XPCOM_NATIVE_EXIT(env, that, nsEmbedCString_1new__II_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_nsEmbedCString_1new___3BI
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(nsEmbedCString_1new___3BI)(JNIEnv *env, jclass that, jbyteArray arg0, jint arg1);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(nsEmbedCString_1new___3BI)
+	(JNIEnv *env, jclass that, jbyteArray arg0, jint arg1)
+{
+	jbyte *lparg0=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, nsEmbedCString_1new___3BI_FUNC);
+	if (arg0) if ((lparg0 = env->GetByteArrayElements(arg0, NULL)) == NULL) goto fail;
+	rc = (jint)new nsEmbedCString((const char *)lparg0, arg1);
+fail:
+	if (arg0 && lparg0) env->ReleaseByteArrayElements(arg0, lparg0, 0);
+	XPCOM_NATIVE_EXIT(env, that, nsEmbedCString_1new___3BI_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_nsEmbedString_1Length
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(nsEmbedString_1Length)(JNIEnv *env, jclass that, jint arg0);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(nsEmbedString_1Length)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, nsEmbedString_1Length_FUNC);
+	rc = (jint)((nsEmbedString *)arg0)->Length();
+	XPCOM_NATIVE_EXIT(env, that, nsEmbedString_1Length_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_nsEmbedString_1delete
+extern "C" JNIEXPORT void JNICALL XPCOM_NATIVE(nsEmbedString_1delete)(JNIEnv *env, jclass that, jint arg0);
+JNIEXPORT void JNICALL XPCOM_NATIVE(nsEmbedString_1delete)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	XPCOM_NATIVE_ENTER(env, that, nsEmbedString_1delete_FUNC);
+	delete (nsEmbedString *)arg0;
+	XPCOM_NATIVE_EXIT(env, that, nsEmbedString_1delete_FUNC);
+}
+#endif
+
+#ifndef NO_nsEmbedString_1get
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(nsEmbedString_1get)(JNIEnv *env, jclass that, jint arg0);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(nsEmbedString_1get)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, nsEmbedString_1get_FUNC);
+	rc = (jint)((nsEmbedString *)arg0)->get();
+	XPCOM_NATIVE_EXIT(env, that, nsEmbedString_1get_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_nsEmbedString_1new__
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(nsEmbedString_1new__)(JNIEnv *env, jclass that);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(nsEmbedString_1new__)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, nsEmbedString_1new___FUNC);
+	rc = (jint)new nsEmbedString();
+	XPCOM_NATIVE_EXIT(env, that, nsEmbedString_1new___FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_nsEmbedString_1new___3C
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(nsEmbedString_1new___3C)(JNIEnv *env, jclass that, jcharArray arg0);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(nsEmbedString_1new___3C)
+	(JNIEnv *env, jclass that, jcharArray arg0)
+{
+	jchar *lparg0=NULL;
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, nsEmbedString_1new___3C_FUNC);
+	if (arg0) if ((lparg0 = env->GetCharArrayElements(arg0, NULL)) == NULL) goto fail;
+	rc = (jint)new nsEmbedString((PRUnichar *)lparg0);
+fail:
+	if (arg0 && lparg0) env->ReleaseCharArrayElements(arg0, lparg0, 0);
+	XPCOM_NATIVE_EXIT(env, that, nsEmbedString_1new___3C_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_nsID_1Equals
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(nsID_1Equals)(JNIEnv *env, jclass that, jint arg0, jint arg1);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(nsID_1Equals)
+	(JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, nsID_1Equals_FUNC);
+	rc = (jint)((nsID *)arg0)->Equals(*(nsID *)arg1);
+	XPCOM_NATIVE_EXIT(env, that, nsID_1Equals_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_nsID_1delete
+extern "C" JNIEXPORT void JNICALL XPCOM_NATIVE(nsID_1delete)(JNIEnv *env, jclass that, jint arg0);
+JNIEXPORT void JNICALL XPCOM_NATIVE(nsID_1delete)
+	(JNIEnv *env, jclass that, jint arg0)
+{
+	XPCOM_NATIVE_ENTER(env, that, nsID_1delete_FUNC);
+	delete (nsID *)arg0;
+	XPCOM_NATIVE_EXIT(env, that, nsID_1delete_FUNC);
+}
+#endif
+
+#ifndef NO_nsID_1new
+extern "C" JNIEXPORT jint JNICALL XPCOM_NATIVE(nsID_1new)(JNIEnv *env, jclass that);
+JNIEXPORT jint JNICALL XPCOM_NATIVE(nsID_1new)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	XPCOM_NATIVE_ENTER(env, that, nsID_1new_FUNC);
+	rc = (jint)new nsID();
+	XPCOM_NATIVE_EXIT(env, that, nsID_1new_FUNC);
+	return rc;
+}
+#endif
+

Added: branches/upstream/swt-gtk/current/xpcom.h
===================================================================
--- branches/upstream/swt-gtk/current/xpcom.h	                        (rev 0)
+++ branches/upstream/swt-gtk/current/xpcom.h	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    IBM Corporation - initial API and implementation
+ *******************************************************************************/
+  
+#ifndef INC_xpcom_H
+#define INC_xpcom_H
+
+#define NDEBUG
+#define XPCOM_GLUE 1
+
+#include "nsXPCOM.h"
+#include "nsEmbedString.h"
+#include "nsIInputStream.h"
+#include "nsISupportsUtils.h"
+#include "nsXPCOMGlue.h"
+
+#ifdef _WIN32
+#define STDMETHODCALLTYPE __stdcall
+#else
+#define STDMETHODCALLTYPE
+#endif
+
+#endif /* INC_xpcom_H */

Added: branches/upstream/swt-gtk/current/xpcom_custom.cpp
===================================================================
--- branches/upstream/swt-gtk/current/xpcom_custom.cpp	                        (rev 0)
+++ branches/upstream/swt-gtk/current/xpcom_custom.cpp	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+#include "swt.h"
+#include "xpcom_structs.h"
+#include "xpcom_stats.h"
+
+extern "C" {
+
+#define XPCOM_NATIVE(func) Java_org_eclipse_swt_internal_mozilla_XPCOM_##func
+
+#ifndef NO_strlen_1PRUnichar
+JNIEXPORT jint JNICALL XPCOM_NATIVE(strlen_1PRUnichar)
+	(JNIEnv *env, jclass that, SWT_PTR arg0)
+{
+	jint rc;
+	XPCOM_NATIVE_ENTER(env, that, strlen_1PRUnichar_FUNC);
+	{
+	const PRUnichar* lparg0 = NULL;
+	if (arg0) lparg0 = (const PRUnichar *)arg0;
+	PRUint32 len = 0;
+	if (lparg0 != NULL)	while (*lparg0++ != 0) len++;
+	rc = (jint)len;
+	}
+	XPCOM_NATIVE_EXIT(env, that, strlen_1PRUnichar_FUNC);
+	return rc;
+}
+#endif
+
+}

Added: branches/upstream/swt-gtk/current/xpcom_stats.cpp
===================================================================
--- branches/upstream/swt-gtk/current/xpcom_stats.cpp	                        (rev 0)
+++ branches/upstream/swt-gtk/current/xpcom_stats.cpp	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,212 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+#include "swt.h"
+#include "xpcom_stats.h"
+
+#ifdef NATIVE_STATS
+
+int XPCOM_nativeFunctionCount = 170;
+int XPCOM_nativeFunctionCallCount[170];
+char * XPCOM_nativeFunctionNames[] = {
+	"Call",
+	"NS_1GetComponentManager",
+	"NS_1GetServiceManager",
+	"NS_1InitXPCOM2",
+	"NS_1NewLocalFile",
+	"VtblCall__II",
+	"VtblCall__IIF",
+	"VtblCall__III",
+	"VtblCall__IIII",
+	"VtblCall__IIIII",
+	"VtblCall__IIIIII",
+	"VtblCall__IIIIIII",
+	"VtblCall__IIIIIIII",
+	"VtblCall__IIIIIIIIIIII",
+	"VtblCall__IIIIIIIIIIIIIIISI",
+	"VtblCall__IIIIIIII_3C_3I_3I",
+	"VtblCall__IIIIIIJII",
+	"VtblCall__IIIIII_3CIIIII_3I_3I",
+	"VtblCall__IIIIII_3C_3BIIIII_3I_3I",
+	"VtblCall__IIIIII_3C_3I_3I",
+	"VtblCall__IIIIII_3I_3I",
+	"VtblCall__IIIII_3C",
+	"VtblCall__IIIII_3I",
+	"VtblCall__IIIIJJJJ",
+	"VtblCall__IIII_3B",
+	"VtblCall__IIII_3C",
+	"VtblCall__IIII_3CIJI",
+	"VtblCall__IIII_3CJJJ",
+	"VtblCall__IIII_3C_3CI_3I",
+	"VtblCall__IIII_3I",
+	"VtblCall__IIII_3J",
+	"VtblCall__IIIJJ",
+	"VtblCall__IIILorg_eclipse_swt_internal_mozilla_nsID_2",
+	"VtblCall__IIILorg_eclipse_swt_internal_mozilla_nsID_2_3I",
+	"VtblCall__III_3B",
+	"VtblCall__III_3BI",
+	"VtblCall__III_3BI_3I",
+	"VtblCall__III_3B_3B_3BI_3I",
+	"VtblCall__III_3B_3C",
+	"VtblCall__III_3B_3I",
+	"VtblCall__III_3C",
+	"VtblCall__III_3CI",
+	"VtblCall__III_3C_3C",
+	"VtblCall__III_3C_3CI_3C_3C_3C_3C_3I_3I",
+	"VtblCall__III_3C_3CI_3I_3I_3I",
+	"VtblCall__III_3C_3C_3C_3I",
+	"VtblCall__III_3C_3C_3C_3I_3I",
+	"VtblCall__III_3C_3C_3I",
+	"VtblCall__III_3C_3C_3I_3C_3I_3I",
+	"VtblCall__III_3C_3C_3I_3I_3C_3I_3I",
+	"VtblCall__III_3I",
+	"VtblCall__III_3I_3I_3I_3I",
+	"VtblCall__IIJ",
+	"VtblCall__IIJI",
+	"VtblCall__IIJIIJIIIIII",
+	"VtblCall__IIJIIJIIIIIIIIISJ",
+	"VtblCall__IIJIIJ_3I_3J",
+	"VtblCall__IIJI_3J",
+	"VtblCall__IIJJ",
+	"VtblCall__IIJJI",
+	"VtblCall__IIJJII",
+	"VtblCall__IIJJIIII",
+	"VtblCall__IIJJIJ_3C_3I_3I",
+	"VtblCall__IIJJI_3C",
+	"VtblCall__IIJJI_3I",
+	"VtblCall__IIJJJ",
+	"VtblCall__IIJJJI",
+	"VtblCall__IIJJJI_3CJJIJI_3J_3J",
+	"VtblCall__IIJJJI_3C_3BJJIJI_3J_3J",
+	"VtblCall__IIJJJJIJ_3C_3I_3J",
+	"VtblCall__IIJJJJJ",
+	"VtblCall__IIJJJJJJ",
+	"VtblCall__IIJJJJJJJ",
+	"VtblCall__IIJJ_3B",
+	"VtblCall__IIJJ_3CIJI",
+	"VtblCall__IIJJ_3CJJJ",
+	"VtblCall__IIJJ_3C_3CI_3J",
+	"VtblCall__IIJJ_3I",
+	"VtblCall__IIJLorg_eclipse_swt_internal_mozilla_nsID_2",
+	"VtblCall__IIJLorg_eclipse_swt_internal_mozilla_nsID_2_3J",
+	"VtblCall__IIJ_3B",
+	"VtblCall__IIJ_3BI",
+	"VtblCall__IIJ_3BJ_3J",
+	"VtblCall__IIJ_3B_3B_3BJ_3J",
+	"VtblCall__IIJ_3B_3C",
+	"VtblCall__IIJ_3CI",
+	"VtblCall__IIJ_3C_3C",
+	"VtblCall__IIJ_3C_3CI_3C_3C_3C_3C_3I_3I",
+	"VtblCall__IIJ_3C_3CI_3J_3I_3I",
+	"VtblCall__IIJ_3C_3C_3C_3I",
+	"VtblCall__IIJ_3C_3C_3C_3I_3I",
+	"VtblCall__IIJ_3C_3C_3I",
+	"VtblCall__IIJ_3C_3C_3J",
+	"VtblCall__IIJ_3C_3C_3J_3C_3I_3I",
+	"VtblCall__IIJ_3C_3C_3J_3J_3C_3I_3I",
+	"VtblCall__IIJ_3I",
+	"VtblCall__IIJ_3J",
+	"VtblCall__IILorg_eclipse_swt_internal_mozilla_nsID_2I",
+	"VtblCall__IILorg_eclipse_swt_internal_mozilla_nsID_2ILorg_eclipse_swt_internal_mozilla_nsID_2_3I",
+	"VtblCall__IILorg_eclipse_swt_internal_mozilla_nsID_2J",
+	"VtblCall__IILorg_eclipse_swt_internal_mozilla_nsID_2JLorg_eclipse_swt_internal_mozilla_nsID_2_3J",
+	"VtblCall__IILorg_eclipse_swt_internal_mozilla_nsID_2Lorg_eclipse_swt_internal_mozilla_nsID_2_3I",
+	"VtblCall__IILorg_eclipse_swt_internal_mozilla_nsID_2Lorg_eclipse_swt_internal_mozilla_nsID_2_3J",
+	"VtblCall__IILorg_eclipse_swt_internal_mozilla_nsID_2_3B_3BI",
+	"VtblCall__IILorg_eclipse_swt_internal_mozilla_nsID_2_3B_3BI_3B_3B",
+	"VtblCall__IILorg_eclipse_swt_internal_mozilla_nsID_2_3B_3BJ",
+	"VtblCall__IILorg_eclipse_swt_internal_mozilla_nsID_2_3B_3BJ_3B_3B",
+	"VtblCall__IILorg_eclipse_swt_internal_mozilla_nsID_2_3I",
+	"VtblCall__IILorg_eclipse_swt_internal_mozilla_nsID_2_3J",
+	"VtblCall__II_3B",
+	"VtblCall__II_3BI",
+	"VtblCall__II_3BII_3I_3I",
+	"VtblCall__II_3BIJ_3J_3I",
+	"VtblCall__II_3BILorg_eclipse_swt_internal_mozilla_nsID_2_3I",
+	"VtblCall__II_3BI_3I",
+	"VtblCall__II_3BI_3I_3I",
+	"VtblCall__II_3BI_3J_3I",
+	"VtblCall__II_3BJ",
+	"VtblCall__II_3BJLorg_eclipse_swt_internal_mozilla_nsID_2_3J",
+	"VtblCall__II_3BLorg_eclipse_swt_internal_mozilla_nsID_2I",
+	"VtblCall__II_3BLorg_eclipse_swt_internal_mozilla_nsID_2J",
+	"VtblCall__II_3BLorg_eclipse_swt_internal_mozilla_nsID_2_3I",
+	"VtblCall__II_3BLorg_eclipse_swt_internal_mozilla_nsID_2_3J",
+	"VtblCall__II_3B_3B",
+	"VtblCall__II_3B_3BI",
+	"VtblCall__II_3B_3B_3BII_3I",
+	"VtblCall__II_3B_3B_3BII_3J",
+	"VtblCall__II_3B_3B_3I",
+	"VtblCall__II_3B_3B_3J",
+	"VtblCall__II_3B_3I",
+	"VtblCall__II_3B_3I_3I",
+	"VtblCall__II_3B_3I_3J",
+	"VtblCall__II_3B_3J",
+	"VtblCall__II_3B_3J_3I",
+	"VtblCall__II_3C",
+	"VtblCall__II_3CIIII",
+	"VtblCall__II_3CIJJJ",
+	"VtblCall__II_3CI_3I",
+	"VtblCall__II_3CJ_3J",
+	"VtblCall__II_3C_3C",
+	"VtblCall__II_3F",
+	"VtblCall__II_3I",
+	"VtblCall__II_3I_3I",
+	"VtblCall__II_3I_3I_3I",
+	"VtblCall__II_3I_3I_3I_3I",
+	"VtblCall__II_3I_3J",
+	"VtblCall__II_3I_3J_3I",
+	"VtblCall__II_3I_3J_3J",
+	"VtblCall__II_3J",
+	"VtblCall__II_3J_3J_3J",
+	"VtblCall__II_3S",
+	"XPCOMGlueShutdown",
+	"XPCOMGlueStartup",
+	"memmove__ILorg_eclipse_swt_internal_mozilla_nsID_2I",
+	"memmove__Lorg_eclipse_swt_internal_mozilla_nsID_2II",
+	"nsEmbedCString_1Length",
+	"nsEmbedCString_1delete",
+	"nsEmbedCString_1get",
+	"nsEmbedCString_1new__",
+	"nsEmbedCString_1new__II",
+	"nsEmbedCString_1new___3BI",
+	"nsEmbedString_1Length",
+	"nsEmbedString_1delete",
+	"nsEmbedString_1get",
+	"nsEmbedString_1new__",
+	"nsEmbedString_1new___3C",
+	"nsID_1Equals",
+	"nsID_1delete",
+	"nsID_1new",
+	"strlen_1PRUnichar",
+};
+
+#define STATS_NATIVE(func) Java_org_eclipse_swt_tools_internal_NativeStats_##func
+
+JNIEXPORT jint JNICALL STATS_NATIVE(XPCOM_1GetFunctionCount)
+	(JNIEnv *env, jclass that)
+{
+	return XPCOM_nativeFunctionCount;
+}
+
+JNIEXPORT jstring JNICALL STATS_NATIVE(XPCOM_1GetFunctionName)
+	(JNIEnv *env, jclass that, jint index)
+{
+	return env->NewStringUTF(XPCOM_nativeFunctionNames[index]);
+}
+
+JNIEXPORT jint JNICALL STATS_NATIVE(XPCOM_1GetFunctionCallCount)
+	(JNIEnv *env, jclass that, jint index)
+{
+	return XPCOM_nativeFunctionCallCount[index];
+}
+
+#endif

Added: branches/upstream/swt-gtk/current/xpcom_stats.h
===================================================================
--- branches/upstream/swt-gtk/current/xpcom_stats.h	                        (rev 0)
+++ branches/upstream/swt-gtk/current/xpcom_stats.h	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,198 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+#ifdef NATIVE_STATS
+extern int XPCOM_nativeFunctionCount;
+extern int XPCOM_nativeFunctionCallCount[];
+extern char* XPCOM_nativeFunctionNames[];
+#define XPCOM_NATIVE_ENTER(env, that, func) XPCOM_nativeFunctionCallCount[func]++;
+#define XPCOM_NATIVE_EXIT(env, that, func) 
+#else
+#ifndef XPCOM_NATIVE_ENTER
+#define XPCOM_NATIVE_ENTER(env, that, func) 
+#endif
+#ifndef XPCOM_NATIVE_EXIT
+#define XPCOM_NATIVE_EXIT(env, that, func) 
+#endif
+#endif
+
+typedef enum {
+	Call_FUNC,
+	NS_1GetComponentManager_FUNC,
+	NS_1GetServiceManager_FUNC,
+	NS_1InitXPCOM2_FUNC,
+	NS_1NewLocalFile_FUNC,
+	VtblCall__II_FUNC,
+	VtblCall__IIF_FUNC,
+	VtblCall__III_FUNC,
+	VtblCall__IIII_FUNC,
+	VtblCall__IIIII_FUNC,
+	VtblCall__IIIIII_FUNC,
+	VtblCall__IIIIIII_FUNC,
+	VtblCall__IIIIIIII_FUNC,
+	VtblCall__IIIIIIIIIIII_FUNC,
+	VtblCall__IIIIIIIIIIIIIIISI_FUNC,
+	VtblCall__IIIIIIII_3C_3I_3I_FUNC,
+	VtblCall__IIIIIIJII_FUNC,
+	VtblCall__IIIIII_3CIIIII_3I_3I_FUNC,
+	VtblCall__IIIIII_3C_3BIIIII_3I_3I_FUNC,
+	VtblCall__IIIIII_3C_3I_3I_FUNC,
+	VtblCall__IIIIII_3I_3I_FUNC,
+	VtblCall__IIIII_3C_FUNC,
+	VtblCall__IIIII_3I_FUNC,
+	VtblCall__IIIIJJJJ_FUNC,
+	VtblCall__IIII_3B_FUNC,
+	VtblCall__IIII_3C_FUNC,
+	VtblCall__IIII_3CIJI_FUNC,
+	VtblCall__IIII_3CJJJ_FUNC,
+	VtblCall__IIII_3C_3CI_3I_FUNC,
+	VtblCall__IIII_3I_FUNC,
+	VtblCall__IIII_3J_FUNC,
+	VtblCall__IIIJJ_FUNC,
+	VtblCall__IIILorg_eclipse_swt_internal_mozilla_nsID_2_FUNC,
+	VtblCall__IIILorg_eclipse_swt_internal_mozilla_nsID_2_3I_FUNC,
+	VtblCall__III_3B_FUNC,
+	VtblCall__III_3BI_FUNC,
+	VtblCall__III_3BI_3I_FUNC,
+	VtblCall__III_3B_3B_3BI_3I_FUNC,
+	VtblCall__III_3B_3C_FUNC,
+	VtblCall__III_3B_3I_FUNC,
+	VtblCall__III_3C_FUNC,
+	VtblCall__III_3CI_FUNC,
+	VtblCall__III_3C_3C_FUNC,
+	VtblCall__III_3C_3CI_3C_3C_3C_3C_3I_3I_FUNC,
+	VtblCall__III_3C_3CI_3I_3I_3I_FUNC,
+	VtblCall__III_3C_3C_3C_3I_FUNC,
+	VtblCall__III_3C_3C_3C_3I_3I_FUNC,
+	VtblCall__III_3C_3C_3I_FUNC,
+	VtblCall__III_3C_3C_3I_3C_3I_3I_FUNC,
+	VtblCall__III_3C_3C_3I_3I_3C_3I_3I_FUNC,
+	VtblCall__III_3I_FUNC,
+	VtblCall__III_3I_3I_3I_3I_FUNC,
+	VtblCall__IIJ_FUNC,
+	VtblCall__IIJI_FUNC,
+	VtblCall__IIJIIJIIIIII_FUNC,
+	VtblCall__IIJIIJIIIIIIIIISJ_FUNC,
+	VtblCall__IIJIIJ_3I_3J_FUNC,
+	VtblCall__IIJI_3J_FUNC,
+	VtblCall__IIJJ_FUNC,
+	VtblCall__IIJJI_FUNC,
+	VtblCall__IIJJII_FUNC,
+	VtblCall__IIJJIIII_FUNC,
+	VtblCall__IIJJIJ_3C_3I_3I_FUNC,
+	VtblCall__IIJJI_3C_FUNC,
+	VtblCall__IIJJI_3I_FUNC,
+	VtblCall__IIJJJ_FUNC,
+	VtblCall__IIJJJI_FUNC,
+	VtblCall__IIJJJI_3CJJIJI_3J_3J_FUNC,
+	VtblCall__IIJJJI_3C_3BJJIJI_3J_3J_FUNC,
+	VtblCall__IIJJJJIJ_3C_3I_3J_FUNC,
+	VtblCall__IIJJJJJ_FUNC,
+	VtblCall__IIJJJJJJ_FUNC,
+	VtblCall__IIJJJJJJJ_FUNC,
+	VtblCall__IIJJ_3B_FUNC,
+	VtblCall__IIJJ_3CIJI_FUNC,
+	VtblCall__IIJJ_3CJJJ_FUNC,
+	VtblCall__IIJJ_3C_3CI_3J_FUNC,
+	VtblCall__IIJJ_3I_FUNC,
+	VtblCall__IIJLorg_eclipse_swt_internal_mozilla_nsID_2_FUNC,
+	VtblCall__IIJLorg_eclipse_swt_internal_mozilla_nsID_2_3J_FUNC,
+	VtblCall__IIJ_3B_FUNC,
+	VtblCall__IIJ_3BI_FUNC,
+	VtblCall__IIJ_3BJ_3J_FUNC,
+	VtblCall__IIJ_3B_3B_3BJ_3J_FUNC,
+	VtblCall__IIJ_3B_3C_FUNC,
+	VtblCall__IIJ_3CI_FUNC,
+	VtblCall__IIJ_3C_3C_FUNC,
+	VtblCall__IIJ_3C_3CI_3C_3C_3C_3C_3I_3I_FUNC,
+	VtblCall__IIJ_3C_3CI_3J_3I_3I_FUNC,
+	VtblCall__IIJ_3C_3C_3C_3I_FUNC,
+	VtblCall__IIJ_3C_3C_3C_3I_3I_FUNC,
+	VtblCall__IIJ_3C_3C_3I_FUNC,
+	VtblCall__IIJ_3C_3C_3J_FUNC,
+	VtblCall__IIJ_3C_3C_3J_3C_3I_3I_FUNC,
+	VtblCall__IIJ_3C_3C_3J_3J_3C_3I_3I_FUNC,
+	VtblCall__IIJ_3I_FUNC,
+	VtblCall__IIJ_3J_FUNC,
+	VtblCall__IILorg_eclipse_swt_internal_mozilla_nsID_2I_FUNC,
+	VtblCall__IILorg_eclipse_swt_internal_mozilla_nsID_2ILorg_eclipse_swt_internal_mozilla_nsID_2_3I_FUNC,
+	VtblCall__IILorg_eclipse_swt_internal_mozilla_nsID_2J_FUNC,
+	VtblCall__IILorg_eclipse_swt_internal_mozilla_nsID_2JLorg_eclipse_swt_internal_mozilla_nsID_2_3J_FUNC,
+	VtblCall__IILorg_eclipse_swt_internal_mozilla_nsID_2Lorg_eclipse_swt_internal_mozilla_nsID_2_3I_FUNC,
+	VtblCall__IILorg_eclipse_swt_internal_mozilla_nsID_2Lorg_eclipse_swt_internal_mozilla_nsID_2_3J_FUNC,
+	VtblCall__IILorg_eclipse_swt_internal_mozilla_nsID_2_3B_3BI_FUNC,
+	VtblCall__IILorg_eclipse_swt_internal_mozilla_nsID_2_3B_3BI_3B_3B_FUNC,
+	VtblCall__IILorg_eclipse_swt_internal_mozilla_nsID_2_3B_3BJ_FUNC,
+	VtblCall__IILorg_eclipse_swt_internal_mozilla_nsID_2_3B_3BJ_3B_3B_FUNC,
+	VtblCall__IILorg_eclipse_swt_internal_mozilla_nsID_2_3I_FUNC,
+	VtblCall__IILorg_eclipse_swt_internal_mozilla_nsID_2_3J_FUNC,
+	VtblCall__II_3B_FUNC,
+	VtblCall__II_3BI_FUNC,
+	VtblCall__II_3BII_3I_3I_FUNC,
+	VtblCall__II_3BIJ_3J_3I_FUNC,
+	VtblCall__II_3BILorg_eclipse_swt_internal_mozilla_nsID_2_3I_FUNC,
+	VtblCall__II_3BI_3I_FUNC,
+	VtblCall__II_3BI_3I_3I_FUNC,
+	VtblCall__II_3BI_3J_3I_FUNC,
+	VtblCall__II_3BJ_FUNC,
+	VtblCall__II_3BJLorg_eclipse_swt_internal_mozilla_nsID_2_3J_FUNC,
+	VtblCall__II_3BLorg_eclipse_swt_internal_mozilla_nsID_2I_FUNC,
+	VtblCall__II_3BLorg_eclipse_swt_internal_mozilla_nsID_2J_FUNC,
+	VtblCall__II_3BLorg_eclipse_swt_internal_mozilla_nsID_2_3I_FUNC,
+	VtblCall__II_3BLorg_eclipse_swt_internal_mozilla_nsID_2_3J_FUNC,
+	VtblCall__II_3B_3B_FUNC,
+	VtblCall__II_3B_3BI_FUNC,
+	VtblCall__II_3B_3B_3BII_3I_FUNC,
+	VtblCall__II_3B_3B_3BII_3J_FUNC,
+	VtblCall__II_3B_3B_3I_FUNC,
+	VtblCall__II_3B_3B_3J_FUNC,
+	VtblCall__II_3B_3I_FUNC,
+	VtblCall__II_3B_3I_3I_FUNC,
+	VtblCall__II_3B_3I_3J_FUNC,
+	VtblCall__II_3B_3J_FUNC,
+	VtblCall__II_3B_3J_3I_FUNC,
+	VtblCall__II_3C_FUNC,
+	VtblCall__II_3CIIII_FUNC,
+	VtblCall__II_3CIJJJ_FUNC,
+	VtblCall__II_3CI_3I_FUNC,
+	VtblCall__II_3CJ_3J_FUNC,
+	VtblCall__II_3C_3C_FUNC,
+	VtblCall__II_3F_FUNC,
+	VtblCall__II_3I_FUNC,
+	VtblCall__II_3I_3I_FUNC,
+	VtblCall__II_3I_3I_3I_FUNC,
+	VtblCall__II_3I_3I_3I_3I_FUNC,
+	VtblCall__II_3I_3J_FUNC,
+	VtblCall__II_3I_3J_3I_FUNC,
+	VtblCall__II_3I_3J_3J_FUNC,
+	VtblCall__II_3J_FUNC,
+	VtblCall__II_3J_3J_3J_FUNC,
+	VtblCall__II_3S_FUNC,
+	XPCOMGlueShutdown_FUNC,
+	XPCOMGlueStartup_FUNC,
+	memmove__ILorg_eclipse_swt_internal_mozilla_nsID_2I_FUNC,
+	memmove__Lorg_eclipse_swt_internal_mozilla_nsID_2II_FUNC,
+	nsEmbedCString_1Length_FUNC,
+	nsEmbedCString_1delete_FUNC,
+	nsEmbedCString_1get_FUNC,
+	nsEmbedCString_1new___FUNC,
+	nsEmbedCString_1new__II_FUNC,
+	nsEmbedCString_1new___3BI_FUNC,
+	nsEmbedString_1Length_FUNC,
+	nsEmbedString_1delete_FUNC,
+	nsEmbedString_1get_FUNC,
+	nsEmbedString_1new___FUNC,
+	nsEmbedString_1new___3C_FUNC,
+	nsID_1Equals_FUNC,
+	nsID_1delete_FUNC,
+	nsID_1new_FUNC,
+	strlen_1PRUnichar_FUNC,
+} XPCOM_FUNCS;

Added: branches/upstream/swt-gtk/current/xpcom_structs.cpp
===================================================================
--- branches/upstream/swt-gtk/current/xpcom_structs.cpp	                        (rev 0)
+++ branches/upstream/swt-gtk/current/xpcom_structs.cpp	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+#include "swt.h"
+#include "xpcom_structs.h"
+
+#ifndef NO_nsID
+typedef struct nsID_FID_CACHE {
+	int cached;
+	jclass clazz;
+	jfieldID m0, m1, m2, m3;
+} nsID_FID_CACHE;
+
+nsID_FID_CACHE nsIDFc;
+
+void cachensIDFields(JNIEnv *env, jobject lpObject)
+{
+	if (nsIDFc.cached) return;
+	nsIDFc.clazz = env->GetObjectClass(lpObject);
+	nsIDFc.m0 = env->GetFieldID(nsIDFc.clazz, "m0", "I");
+	nsIDFc.m1 = env->GetFieldID(nsIDFc.clazz, "m1", "S");
+	nsIDFc.m2 = env->GetFieldID(nsIDFc.clazz, "m2", "S");
+	nsIDFc.m3 = env->GetFieldID(nsIDFc.clazz, "m3", "[B");
+	nsIDFc.cached = 1;
+}
+
+nsID *getnsIDFields(JNIEnv *env, jobject lpObject, nsID *lpStruct)
+{
+	if (!nsIDFc.cached) cachensIDFields(env, lpObject);
+	lpStruct->m0 = env->GetIntField(lpObject, nsIDFc.m0);
+	lpStruct->m1 = env->GetShortField(lpObject, nsIDFc.m1);
+	lpStruct->m2 = env->GetShortField(lpObject, nsIDFc.m2);
+	{
+	jbyteArray lpObject1 = (jbyteArray)env->GetObjectField(lpObject, nsIDFc.m3);
+	env->GetByteArrayRegion(lpObject1, 0, sizeof(lpStruct->m3), (jbyte *)lpStruct->m3);
+	}
+	return lpStruct;
+}
+
+void setnsIDFields(JNIEnv *env, jobject lpObject, nsID *lpStruct)
+{
+	if (!nsIDFc.cached) cachensIDFields(env, lpObject);
+	env->SetIntField(lpObject, nsIDFc.m0, (jint)lpStruct->m0);
+	env->SetShortField(lpObject, nsIDFc.m1, (jshort)lpStruct->m1);
+	env->SetShortField(lpObject, nsIDFc.m2, (jshort)lpStruct->m2);
+	{
+	jbyteArray lpObject1 = (jbyteArray)env->GetObjectField(lpObject, nsIDFc.m3);
+	env->SetByteArrayRegion(lpObject1, 0, sizeof(lpStruct->m3), (jbyte *)lpStruct->m3);
+	}
+}
+#endif
+

Added: branches/upstream/swt-gtk/current/xpcom_structs.h
===================================================================
--- branches/upstream/swt-gtk/current/xpcom_structs.h	                        (rev 0)
+++ branches/upstream/swt-gtk/current/xpcom_structs.h	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+#include "xpcom.h"
+
+#ifndef NO_nsID
+void cachensIDFields(JNIEnv *env, jobject lpObject);
+nsID *getnsIDFields(JNIEnv *env, jobject lpObject, nsID *lpStruct);
+void setnsIDFields(JNIEnv *env, jobject lpObject, nsID *lpStruct);
+#define nsID_sizeof() sizeof(nsID)
+#else
+#define cachensIDFields(a,b)
+#define getnsIDFields(a,b,c) NULL
+#define setnsIDFields(a,b,c)
+#define nsID_sizeof() 0
+#endif
+

Added: branches/upstream/swt-gtk/current/xpcominit.cpp
===================================================================
--- branches/upstream/swt-gtk/current/xpcominit.cpp	                        (rev 0)
+++ branches/upstream/swt-gtk/current/xpcominit.cpp	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,77 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+#include "swt.h"
+#include "xpcominit_structs.h"
+#include "xpcominit_stats.h"
+
+#define XPCOMInit_NATIVE(func) Java_org_eclipse_swt_internal_mozilla_XPCOMInit_##func
+
+#ifndef NO_GREVersionRange_1sizeof
+extern "C" JNIEXPORT jint JNICALL XPCOMInit_NATIVE(GREVersionRange_1sizeof)(JNIEnv *env, jclass that);
+JNIEXPORT jint JNICALL XPCOMInit_NATIVE(GREVersionRange_1sizeof)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	XPCOMInit_NATIVE_ENTER(env, that, GREVersionRange_1sizeof_FUNC);
+	rc = (jint)GREVersionRange_sizeof();
+	XPCOMInit_NATIVE_EXIT(env, that, GREVersionRange_1sizeof_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_GRE_1GetGREPathWithProperties
+extern "C" JNIEXPORT jint JNICALL XPCOMInit_NATIVE(GRE_1GetGREPathWithProperties)(JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2, jint arg3, jint arg4, jint arg5);
+JNIEXPORT jint JNICALL XPCOMInit_NATIVE(GRE_1GetGREPathWithProperties)
+	(JNIEnv *env, jclass that, jobject arg0, jint arg1, jint arg2, jint arg3, jint arg4, jint arg5)
+{
+	GREVersionRange _arg0, *lparg0=NULL;
+	jint rc = 0;
+	XPCOMInit_NATIVE_ENTER(env, that, GRE_1GetGREPathWithProperties_FUNC);
+	if (arg0) if ((lparg0 = getGREVersionRangeFields(env, arg0, &_arg0)) == NULL) goto fail;
+	rc = (jint)GRE_GetGREPathWithProperties((const GREVersionRange *)lparg0, arg1, (const GREProperty *)arg2, arg3, (char *)arg4, arg5);
+fail:
+	if (arg0 && lparg0) setGREVersionRangeFields(env, arg0, lparg0);
+	XPCOMInit_NATIVE_EXIT(env, that, GRE_1GetGREPathWithProperties_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_XPCOMGlueShutdown
+extern "C" JNIEXPORT jint JNICALL XPCOMInit_NATIVE(XPCOMGlueShutdown)(JNIEnv *env, jclass that);
+JNIEXPORT jint JNICALL XPCOMInit_NATIVE(XPCOMGlueShutdown)
+	(JNIEnv *env, jclass that)
+{
+	jint rc = 0;
+	XPCOMInit_NATIVE_ENTER(env, that, XPCOMGlueShutdown_FUNC);
+	rc = (jint)XPCOMGlueShutdown();
+	XPCOMInit_NATIVE_EXIT(env, that, XPCOMGlueShutdown_FUNC);
+	return rc;
+}
+#endif
+
+#ifndef NO_XPCOMGlueStartup
+extern "C" JNIEXPORT jint JNICALL XPCOMInit_NATIVE(XPCOMGlueStartup)(JNIEnv *env, jclass that, jbyteArray arg0);
+JNIEXPORT jint JNICALL XPCOMInit_NATIVE(XPCOMGlueStartup)
+	(JNIEnv *env, jclass that, jbyteArray arg0)
+{
+	jbyte *lparg0=NULL;
+	jint rc = 0;
+	XPCOMInit_NATIVE_ENTER(env, that, XPCOMGlueStartup_FUNC);
+	if (arg0) if ((lparg0 = env->GetByteArrayElements(arg0, NULL)) == NULL) goto fail;
+	rc = (jint)XPCOMGlueStartup((const char *)lparg0);
+fail:
+	if (arg0 && lparg0) env->ReleaseByteArrayElements(arg0, lparg0, 0);
+	XPCOMInit_NATIVE_EXIT(env, that, XPCOMGlueStartup_FUNC);
+	return rc;
+}
+#endif
+

Added: branches/upstream/swt-gtk/current/xpcominit.h
===================================================================
--- branches/upstream/swt-gtk/current/xpcominit.h	                        (rev 0)
+++ branches/upstream/swt-gtk/current/xpcominit.h	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    IBM Corporation - initial API and implementation
+ *******************************************************************************/
+  
+#ifndef INC_xpcominit_H
+#define INC_xpcominit_H
+
+#define NDEBUG
+
+#define XPCOM_GLUE 1
+#include "nsXPCOMGlue.h"
+
+#ifdef _WIN32
+#define STDMETHODCALLTYPE __stdcall
+#else
+#define STDMETHODCALLTYPE
+#endif
+
+#endif /* INC_xpcominit_H */

Added: branches/upstream/swt-gtk/current/xpcominit_stats.cpp
===================================================================
--- branches/upstream/swt-gtk/current/xpcominit_stats.cpp	                        (rev 0)
+++ branches/upstream/swt-gtk/current/xpcominit_stats.cpp	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+#include "swt.h"
+#include "xpcominit_stats.h"
+
+#ifdef NATIVE_STATS
+
+int XPCOMInit_nativeFunctionCount = 4;
+int XPCOMInit_nativeFunctionCallCount[4];
+char * XPCOMInit_nativeFunctionNames[] = {
+	"GREVersionRange_1sizeof",
+	"GRE_1GetGREPathWithProperties",
+	"XPCOMGlueShutdown",
+	"XPCOMGlueStartup",
+};
+
+#define STATS_NATIVE(func) Java_org_eclipse_swt_tools_internal_NativeStats_##func
+
+JNIEXPORT jint JNICALL STATS_NATIVE(XPCOMInit_1GetFunctionCount)
+	(JNIEnv *env, jclass that)
+{
+	return XPCOMInit_nativeFunctionCount;
+}
+
+JNIEXPORT jstring JNICALL STATS_NATIVE(XPCOMInit_1GetFunctionName)
+	(JNIEnv *env, jclass that, jint index)
+{
+	return env->NewStringUTF(XPCOMInit_nativeFunctionNames[index]);
+}
+
+JNIEXPORT jint JNICALL STATS_NATIVE(XPCOMInit_1GetFunctionCallCount)
+	(JNIEnv *env, jclass that, jint index)
+{
+	return XPCOMInit_nativeFunctionCallCount[index];
+}
+
+#endif

Added: branches/upstream/swt-gtk/current/xpcominit_stats.h
===================================================================
--- branches/upstream/swt-gtk/current/xpcominit_stats.h	                        (rev 0)
+++ branches/upstream/swt-gtk/current/xpcominit_stats.h	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+#ifdef NATIVE_STATS
+extern int XPCOMInit_nativeFunctionCount;
+extern int XPCOMInit_nativeFunctionCallCount[];
+extern char* XPCOMInit_nativeFunctionNames[];
+#define XPCOMInit_NATIVE_ENTER(env, that, func) XPCOMInit_nativeFunctionCallCount[func]++;
+#define XPCOMInit_NATIVE_EXIT(env, that, func) 
+#else
+#ifndef XPCOMInit_NATIVE_ENTER
+#define XPCOMInit_NATIVE_ENTER(env, that, func) 
+#endif
+#ifndef XPCOMInit_NATIVE_EXIT
+#define XPCOMInit_NATIVE_EXIT(env, that, func) 
+#endif
+#endif
+
+typedef enum {
+	GREVersionRange_1sizeof_FUNC,
+	GRE_1GetGREPathWithProperties_FUNC,
+	XPCOMGlueShutdown_FUNC,
+	XPCOMGlueStartup_FUNC,
+} XPCOMInit_FUNCS;

Added: branches/upstream/swt-gtk/current/xpcominit_structs.cpp
===================================================================
--- branches/upstream/swt-gtk/current/xpcominit_structs.cpp	                        (rev 0)
+++ branches/upstream/swt-gtk/current/xpcominit_structs.cpp	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+#include "swt.h"
+#include "xpcominit_structs.h"
+
+#ifndef NO_GREVersionRange
+typedef struct GREVersionRange_FID_CACHE {
+	int cached;
+	jclass clazz;
+	jfieldID lower, lowerInclusive, upper, upperInclusive;
+} GREVersionRange_FID_CACHE;
+
+GREVersionRange_FID_CACHE GREVersionRangeFc;
+
+void cacheGREVersionRangeFields(JNIEnv *env, jobject lpObject)
+{
+	if (GREVersionRangeFc.cached) return;
+	GREVersionRangeFc.clazz = env->GetObjectClass(lpObject);
+	GREVersionRangeFc.lower = env->GetFieldID(GREVersionRangeFc.clazz, "lower", "I");
+	GREVersionRangeFc.lowerInclusive = env->GetFieldID(GREVersionRangeFc.clazz, "lowerInclusive", "Z");
+	GREVersionRangeFc.upper = env->GetFieldID(GREVersionRangeFc.clazz, "upper", "I");
+	GREVersionRangeFc.upperInclusive = env->GetFieldID(GREVersionRangeFc.clazz, "upperInclusive", "Z");
+	GREVersionRangeFc.cached = 1;
+}
+
+GREVersionRange *getGREVersionRangeFields(JNIEnv *env, jobject lpObject, GREVersionRange *lpStruct)
+{
+	if (!GREVersionRangeFc.cached) cacheGREVersionRangeFields(env, lpObject);
+	lpStruct->lower = (const char *)env->GetIntField(lpObject, GREVersionRangeFc.lower);
+	lpStruct->lowerInclusive = env->GetBooleanField(lpObject, GREVersionRangeFc.lowerInclusive);
+	lpStruct->upper = (const char *)env->GetIntField(lpObject, GREVersionRangeFc.upper);
+	lpStruct->upperInclusive = env->GetBooleanField(lpObject, GREVersionRangeFc.upperInclusive);
+	return lpStruct;
+}
+
+void setGREVersionRangeFields(JNIEnv *env, jobject lpObject, GREVersionRange *lpStruct)
+{
+	if (!GREVersionRangeFc.cached) cacheGREVersionRangeFields(env, lpObject);
+	env->SetIntField(lpObject, GREVersionRangeFc.lower, (jint)lpStruct->lower);
+	env->SetBooleanField(lpObject, GREVersionRangeFc.lowerInclusive, (jboolean)lpStruct->lowerInclusive);
+	env->SetIntField(lpObject, GREVersionRangeFc.upper, (jint)lpStruct->upper);
+	env->SetBooleanField(lpObject, GREVersionRangeFc.upperInclusive, (jboolean)lpStruct->upperInclusive);
+}
+#endif
+

Added: branches/upstream/swt-gtk/current/xpcominit_structs.h
===================================================================
--- branches/upstream/swt-gtk/current/xpcominit_structs.h	                        (rev 0)
+++ branches/upstream/swt-gtk/current/xpcominit_structs.h	2009-08-18 13:26:39 UTC (rev 10122)
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+#include "xpcominit.h"
+
+#ifndef NO_GREVersionRange
+void cacheGREVersionRangeFields(JNIEnv *env, jobject lpObject);
+GREVersionRange *getGREVersionRangeFields(JNIEnv *env, jobject lpObject, GREVersionRange *lpStruct);
+void setGREVersionRangeFields(JNIEnv *env, jobject lpObject, GREVersionRange *lpStruct);
+#define GREVersionRange_sizeof() sizeof(GREVersionRange)
+#else
+#define cacheGREVersionRangeFields(a,b)
+#define getGREVersionRangeFields(a,b,c) NULL
+#define setGREVersionRangeFields(a,b,c)
+#define GREVersionRange_sizeof() 0
+#endif
+




More information about the pkg-java-commits mailing list